MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / load

Function load

apps/desktop/src/main/tikz.ts:25–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23let renderQueue: Promise<void> = Promise.resolve();
24
25async function load(): Promise<Tex2Svg> {
26 if (tex2svg) return tex2svg;
27 if (loadPromise) return loadPromise;
28 loadPromise = (async () => {
29 const mod = await import("node-tikzjax");
30 // node-tikzjax is a CJS module; its default export is itself `{ default: tex2svg }`.
31 const candidate =
32 (mod as unknown as { default?: { default?: Tex2Svg } | Tex2Svg })
33 .default ?? (mod as unknown as Tex2Svg);
34 const fn =
35 typeof candidate === "function"
36 ? candidate
37 : (candidate as { default: Tex2Svg }).default;
38 if (typeof fn !== "function") {
39 throw new Error("Could not locate tex2svg in node-tikzjax");
40 }
41 tex2svg = fn;
42 return fn;
43 })();
44 return loadPromise;
45}
46
47const cache = new Map<string, { ok: true; svg: string }>();
48const inFlight = new Map<string, Promise<TikzRenderResult | TikzRenderError>>();

Callers 2

renderTikzFunction · 0.70
SearchNotesFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected