MCPcopy
hub / github.com/markmap/markmap / checkData

Function checkData

packages/markmap-cli/src/client/index.ts:28–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26checkData();
27
28async function checkData() {
29 try {
30 const query = new URLSearchParams(
31 [
32 ['key', key],
33 ['content', state.content.ts],
34 ['line', state.line.ts],
35 ].map((pair) => pair.map((s) => `${s}`)),
36 );
37 const resp = await fetch(`/~data?${query}`);
38 if (!resp.ok)
39 throw {
40 status: resp.status,
41 };
42 const res = (await resp.json()) as IFileState;
43 if (res.content) {
44 const value = res.content.value as ITransformResult;
45 mm.setOptions(markmap.deriveOptions(value.frontmatter?.markmap));
46 await mm.setData(value.root);
47 if (!state.content.ts) await mm.fit();
48 }
49 Object.assign(state, res);
50 if (res.line && state.content.value) {
51 await setCursor({ line: res.line.value as number });
52 }
53 setTimeout(checkData);
54 } catch (err) {
55 if ((err as { status: number }).status !== 404) {
56 setTimeout(checkData, 1000);
57 }
58 }
59}
60
61function findActiveNode({
62 line,

Callers 1

index.tsFile · 0.85

Calls 4

setCursorFunction · 0.85
setOptionsMethod · 0.80
setDataMethod · 0.80
fitMethod · 0.80

Tested by

no test coverage detected