@pie-element/shared-math-rendering-mathjax 0.1.3-next.20261006160832 → 0.1.3-next.20261007003844

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/adapter.d.ts CHANGED
@@ -25,6 +25,7 @@ export interface MathJaxGlobal {
25
25
  version?: string;
26
26
  loader?: {
27
27
  load?: string[];
28
+ paths?: Record<string, string>;
28
29
  failed?: (error: Error) => void;
29
30
  'output/svg'?: {
30
31
  ready?: (name: string) => string;
@@ -50,6 +51,13 @@ export interface MathJaxGlobal {
50
51
  a11y?: {
51
52
  inTabOrder?: boolean;
52
53
  };
54
+ sre?: {
55
+ locale?: string;
56
+ };
57
+ worker?: {
58
+ path?: string;
59
+ maps?: string;
60
+ };
53
61
  };
54
62
  output?: {
55
63
  displayOverflow?: string;
@@ -61,6 +69,11 @@ export interface MathJaxGlobal {
61
69
  typesetClear?: (elements?: Element[]) => void;
62
70
  /** The component build's module tree. */
63
71
  _?: {
72
+ a11y?: {
73
+ sre_ts?: {
74
+ locales?: Map<string, string>;
75
+ };
76
+ };
64
77
  output?: {
65
78
  chtml_ts?: {
66
79
  CHTML?: {
@@ -89,9 +102,9 @@ export declare function stripLegacyDelimiters(latex: string): string;
89
102
  /**
90
103
  * Create a MathJax renderer function.
91
104
  *
92
- * MathJax loads once per page, on the first render, from `srcUrl` or MathJax 4.1.3 on jsDelivr.
93
- * A MathJax the page already has, or is loading, is used instead. A render waits on the load only
94
- * when its element holds math.
105
+ * MathJax loads once per page, on the first render, from `srcUrl` or the asset root (see
106
+ * {@link MathjaxOptions.assetRoot}). A MathJax the page already has, or is loading, is used
107
+ * instead. A render waits on the load only when its element holds math.
95
108
  *
96
109
  * @param options - Renderer options
97
110
  * @returns Renderer function that typesets math in an element
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Where MathJax's fonts, speech worker and, for the npm build, MathJax itself load from. Neither
3
+ * build names a host: every file resolves from an npm root, a URL under which
4
+ * `<package>@<version>/<path>` serves that file of the package, as jsDelivr's `/npm`, raw.esm.sh,
5
+ * unpkg and npm-mirroring proxies do.
6
+ */
7
+ import type { MathjaxOptions } from './types.js';
8
+ /** The version `mathjax`, `@mathjax/src` and both MathJax fonts are pinned to. */
9
+ export declare const MATHJAX_VERSION = "4.1.3";
10
+ export declare const ASSETS_DOCS_URL = "https://github.com/pie-framework/pie-elements-ng/blob/develop/docs/MATH-RENDERING.md#assets";
11
+ /** The legacy renderer's page options, which this adapter reads as well. */
12
+ export declare const PAGE_OPTIONS_KEY = "@pie-lib/math-rendering@2";
13
+ /** The npm path of the directory holding SRE's speech worker and its `mathmaps/`. */
14
+ export declare const SRE_PATH = "mathjax@4.1.3/sre";
15
+ export interface MathjaxAssets {
16
+ /** The npm root MathJax's files load from. */
17
+ root?: string;
18
+ /** The directory of `speech-worker.js` and its `mathmaps/`. */
19
+ speechPath?: string;
20
+ /** The URL of each file listed by npm path, `<package>@<version>/<path>`. */
21
+ urls?: Map<string, string>;
22
+ /** The speech locales the menu lists, by id, with any label to show; undefined lists SRE's. */
23
+ speechLocales?: Map<string, string | undefined>;
24
+ }
25
+ /**
26
+ * The npm root of `url`: the part before its last `<package>@<version>` path segment, scope
27
+ * included. Undefined for a URL without one, a file under `node_modules`, and a URL with no
28
+ * origin (`file:`, `blob:`, `data:`), which is what bundlers turn a module's URL into.
29
+ */
30
+ export declare function npmRoot(url: string | undefined): string | undefined;
31
+ /**
32
+ * The assets `options` set, then the page's options, then the npm root of `moduleUrl`, the URL
33
+ * this module loaded from.
34
+ */
35
+ export declare function resolveAssets(options: MathjaxOptions, moduleUrl?: string): MathjaxAssets;
36
+ /** The URL of the file at npm path `path`: the one `urls` lists, else under the root. */
37
+ export declare function assetUrl({ root, urls }: MathjaxAssets, path: string): string | undefined;
38
+ /** The URL of `file` in the speech directory: the one `urls` lists, else under `speechPath`. */
39
+ export declare function speechFileUrl({ speechPath, urls }: MathjaxAssets, file: string): string | undefined;
40
+ /** The menu lists SRE's `locales`; this leaves the listed locales in it, braille codes kept. */
41
+ export declare function listSpeechLocales(locales: Map<string, string> | undefined, listed: Map<string, string | undefined> | undefined): void;
42
+ /** The locale speech starts in when English is not listed: the first listed locale. */
43
+ export declare function defaultSpeechLocale(listed: Map<string, string | undefined> | undefined): string | undefined;
44
+ /**
45
+ * Dispatched on `window` once per effect per page when an adapter copy has no asset root, with a
46
+ * {@link NoAssetRootDetail}. Players forward it to their instrumentation.
47
+ */
48
+ export declare const NO_ASSET_ROOT_EVENT = "pie-mathjax-no-asset-root";
49
+ export type NoAssetRootEffect =
50
+ /** The npm build loads no MathJax, so math stays untypeset. */
51
+ 'untypeset'
52
+ /** The browser build typesets in the page's fonts. */
53
+ | 'no-web-fonts'
54
+ /** The browser build typesets in the page's fonts, with speech, braille and the explorer off. */
55
+ | 'no-web-fonts-or-speech';
56
+ export interface NoAssetRootDetail {
57
+ effect: NoAssetRootEffect;
58
+ message: string;
59
+ docsUrl: string;
60
+ }
61
+ /**
62
+ * Reports once per effect per page that MathJax's files have nowhere to load from: a
63
+ * `console.error` when math stays untypeset, a `console.warn` when it renders degraded, and
64
+ * {@link NO_ASSET_ROOT_EVENT} for each.
65
+ */
66
+ export declare function reportNoAssetRoot(effect: NoAssetRootEffect): void;