()
| 23 | let renderQueue: Promise<void> = Promise.resolve(); |
| 24 | |
| 25 | async 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 | |
| 47 | const cache = new Map<string, { ok: true; svg: string }>(); |
| 48 | const inFlight = new Map<string, Promise<TikzRenderResult | TikzRenderError>>(); |
no outgoing calls
no test coverage detected