mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
e807e2b89c
Follow-ups from the Workspaces adoption of 0.32.0: the default KaTeX loader moves to its own module so a host that registers a mathRendererLoader can alias it away and drop the unused KaTeX chunk (a registered loader is never backfilled by the default); docs state when onUnanchoredChange first delivers, what projectHostThreads loses on markdown surfaces (export ordering, line labels, repeated-text disambiguation, no-flash restore) while still re-anchoring by text search, and that cap-dropped handling is a backstop once maxAdditionalTargets is enforced upstream; HANDOFF.md now ships in the tarball so the README references resolve. Plannotator's own behavior is unchanged (the eager entry fills the slot before first render; built-bundle markers and sizes match main). AI-assisted (Claude) under maintainer direction.
25 lines
1.2 KiB
TypeScript
25 lines
1.2 KiB
TypeScript
/**
|
|
* The default math renderer loader: KaTeX's JS only, fetched lazily.
|
|
*
|
|
* This module is the ONLY place in `@plannotator/ui` that names `katex` at
|
|
* runtime (`./math-eager` names it too, but a host chooses to import that).
|
|
* `./math` calls `loadDefaultMathRenderer` only when no host loader is
|
|
* registered (`setMathRendererLoader` / `configurePlannotatorUI({
|
|
* mathRendererLoader })`), so a host that registers one never runs the
|
|
* `import('katex')` below and never requests the chunk it produces.
|
|
*
|
|
* Keeping the import in its own module is what lets a bundler drop the chunk
|
|
* entirely: chunk emission is static, so a host that registers a loader and
|
|
* wants no KaTeX chunk from the package at all points this module at a stub
|
|
* (see HANDOFF.md "Lazy renderers and eager entries", the alias recipe). The
|
|
* stylesheet is deliberately NOT imported here; CSS loading stays the host's
|
|
* job (HANDOFF.md "Math rendering"), and a host that already serves
|
|
* `katex.min.css` would otherwise load it twice.
|
|
*/
|
|
|
|
import type { MathRenderer } from './math';
|
|
|
|
export function loadDefaultMathRenderer(): Promise<MathRenderer> {
|
|
return import('katex').then((m) => m.default);
|
|
}
|