@pie-element/shared-math-rendering-mathjax 0.1.1-next.0 → 0.1.1-next.2

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.
Files changed (2) hide show
  1. package/dist/index.js +39 -35
  2. package/package.json +2 -7
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  //#region src/adapter.ts
2
- var e = "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", t = null;
3
- function n(n) {
4
- return typeof window > "u" || window.MathJax?.typesetPromise ? Promise.resolve() : t || (t = new Promise((t, r) => {
5
- let { useSingleDollar: i = !1, accessibility: a = !0, loadFonts: o = !0, srcUrl: s } = n, c = {
6
- loader: { load: a ? ["a11y/assistive-mml"] : [] },
2
+ var e = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading");
3
+ function t(t) {
4
+ if (typeof window > "u" || window.MathJax?.typesetPromise) return Promise.resolve();
5
+ let n = globalThis, r = n[e];
6
+ if (r) return r;
7
+ let i = new Promise((e, n) => {
8
+ let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = t, s = {
9
+ loader: { load: i ? ["a11y/assistive-mml"] : [] },
7
10
  tex: {
8
11
  packages: [
9
12
  "base",
@@ -18,27 +21,28 @@ function n(n) {
18
21
  }
19
22
  },
20
23
  options: {
21
- enableMenu: a,
22
- enableExplorer: a,
23
- enableAssistiveMml: a
24
+ enableMenu: i,
25
+ enableExplorer: i,
26
+ enableAssistiveMml: i
24
27
  },
25
28
  startup: {
26
29
  ready: () => {
27
- window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), t());
30
+ window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), e());
28
31
  },
29
32
  defaultReady: () => {}
30
33
  }
31
34
  };
32
- i && c.tex && (c.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], c.tex.processEscapes = !0), o || (c.chtml = { fontURL: "" }), window.MathJax = c;
33
- let l = document.createElement("script");
34
- l.src = s || e, l.async = !0, l.onload = () => {
35
- setTimeout(t, 100);
36
- }, l.onerror = () => {
37
- r(/* @__PURE__ */ Error("Failed to load MathJax"));
38
- }, document.head.appendChild(l);
39
- }), t);
35
+ r && s.tex && (s.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], s.tex.processEscapes = !0), a || (s.chtml = { fontURL: "" }), window.MathJax = s;
36
+ let c = document.createElement("script");
37
+ c.src = o || "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", c.async = !0, c.onload = () => {
38
+ setTimeout(e, 100);
39
+ }, c.onerror = () => {
40
+ n(/* @__PURE__ */ Error("Failed to load MathJax"));
41
+ }, document.head.appendChild(c);
42
+ });
43
+ return n[e] = i, i;
40
44
  }
41
- function r() {
45
+ function n() {
42
46
  let e = window.MathJax?.startup?.document;
43
47
  if (typeof e?.assistiveMml == "function") try {
44
48
  e.assistiveMml().updateDocument?.();
@@ -46,39 +50,39 @@ function r() {
46
50
  console.warn("[mathjax-renderer] Failed to attach assistive MathML:", e);
47
51
  }
48
52
  }
49
- function i(e = {}) {
50
- return async (t) => {
51
- if (await n(e), !window.MathJax?.typesetPromise) {
53
+ function r(e = {}) {
54
+ return async (r) => {
55
+ if (await t(e), !window.MathJax?.typesetPromise) {
52
56
  console.warn("[mathjax-renderer] MathJax not loaded or missing typesetPromise.");
53
57
  return;
54
58
  }
55
- await window.MathJax.typesetPromise([t]), r();
59
+ await window.MathJax.typesetPromise([r]), n();
56
60
  };
57
61
  }
58
- function a() {
62
+ function i() {
59
63
  return [];
60
64
  }
61
65
  //#endregion
62
66
  //#region src/render-math.ts
63
- var o = "@pie-lib/math-rendering", s = null;
64
- function c() {
65
- return s ||= i({
67
+ var a = "@pie-lib/math-rendering", o = null;
68
+ function s() {
69
+ return o ||= r({
66
70
  accessibility: !0,
67
71
  useSingleDollar: !0
68
- }), s;
72
+ }), o;
69
73
  }
70
- function l() {
74
+ function c() {
71
75
  if (typeof window > "u") return null;
72
- let e = window[o];
76
+ let e = window[a];
73
77
  return typeof e?.renderMath == "function" ? e : null;
74
78
  }
75
- var u = async (e) => {
79
+ var l = async (e) => {
76
80
  if (typeof window > "u") return;
77
81
  let t = typeof e == "string", n;
78
82
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
79
- let r = l();
80
- return r ? await r.renderMath?.(n) : await c()(n), t ? n.innerHTML : void 0;
81
- }, d = (e) => l()?.wrapMath?.(e) ?? e, f = (e) => {
83
+ let r = c();
84
+ return r ? await r.renderMath?.(n) : await s()(n), t ? n.innerHTML : void 0;
85
+ }, u = (e) => c()?.wrapMath?.(e) ?? e, d = (e) => {
82
86
  let t = e.trim();
83
87
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
84
88
  unwrapped: t.slice(2, -2).trim(),
@@ -105,6 +109,6 @@ var u = async (e) => {
105
109
  close: "$"
106
110
  }
107
111
  } : { unwrapped: t };
108
- }, p = (e) => l()?.mmlToLatex?.(e) ?? e;
112
+ }, f = (e) => c()?.mmlToLatex?.(e) ?? e;
109
113
  //#endregion
110
- export { i as createMathjaxRenderer, a as getMathjaxCssUrls, p as mmlToLatex, u as renderMath, f as unWrapMath, d as wrapMath };
114
+ export { r as createMathjaxRenderer, i as getMathjaxCssUrls, f as mmlToLatex, l as renderMath, d as unWrapMath, u as wrapMath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/shared-math-rendering-mathjax",
3
- "version": "0.1.1-next.0",
3
+ "version": "0.1.1-next.2",
4
4
  "description": "MathJax adapter for PIE math rendering",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,11 +21,6 @@
21
21
  "clean": "rm -rf dist"
22
22
  },
23
23
  "dependencies": {},
24
- "devDependencies": {
25
- "typescript": "^5.9.3",
26
- "vite": "^8.0.1",
27
- "vitest": "^4.1.0"
28
- },
29
24
  "publishConfig": {
30
25
  "access": "public"
31
26
  },
@@ -39,7 +34,7 @@
39
34
  "license": "MIT",
40
35
  "repository": {
41
36
  "type": "git",
42
- "url": "https://github.com/pie-framework/pie-elements-ng.git",
37
+ "url": "git+https://github.com/pie-framework/pie-elements-ng.git",
43
38
  "directory": "packages/shared/math-rendering-mathjax"
44
39
  },
45
40
  "homepage": "https://github.com/pie-framework/pie-elements-ng#readme",