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

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 +35 -35
  2. package/package.json +2 -7
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
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 = null;
3
+ function t(t) {
4
+ return typeof window > "u" || window.MathJax?.typesetPromise ? Promise.resolve() : e || (e = new Promise((e, n) => {
5
+ let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: a = !0, srcUrl: o } = t, s = {
6
+ loader: { load: i ? ["a11y/assistive-mml"] : [] },
7
7
  tex: {
8
8
  packages: [
9
9
  "base",
@@ -18,27 +18,27 @@ function n(n) {
18
18
  }
19
19
  },
20
20
  options: {
21
- enableMenu: a,
22
- enableExplorer: a,
23
- enableAssistiveMml: a
21
+ enableMenu: i,
22
+ enableExplorer: i,
23
+ enableAssistiveMml: i
24
24
  },
25
25
  startup: {
26
26
  ready: () => {
27
- window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), t());
27
+ window.MathJax?.startup.defaultReady && (window.MathJax.startup.defaultReady(), e());
28
28
  },
29
29
  defaultReady: () => {}
30
30
  }
31
31
  };
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);
32
+ r && s.tex && (s.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], s.tex.processEscapes = !0), a || (s.chtml = { fontURL: "" }), window.MathJax = s;
33
+ let c = document.createElement("script");
34
+ c.src = o || "https://cdn.jsdelivr.net/npm/mathjax@4/tex-chtml.js", c.async = !0, c.onload = () => {
35
+ setTimeout(e, 100);
36
+ }, c.onerror = () => {
37
+ n(/* @__PURE__ */ Error("Failed to load MathJax"));
38
+ }, document.head.appendChild(c);
39
+ }), e);
40
40
  }
41
- function r() {
41
+ function n() {
42
42
  let e = window.MathJax?.startup?.document;
43
43
  if (typeof e?.assistiveMml == "function") try {
44
44
  e.assistiveMml().updateDocument?.();
@@ -46,39 +46,39 @@ function r() {
46
46
  console.warn("[mathjax-renderer] Failed to attach assistive MathML:", e);
47
47
  }
48
48
  }
49
- function i(e = {}) {
50
- return async (t) => {
51
- if (await n(e), !window.MathJax?.typesetPromise) {
49
+ function r(e = {}) {
50
+ return async (r) => {
51
+ if (await t(e), !window.MathJax?.typesetPromise) {
52
52
  console.warn("[mathjax-renderer] MathJax not loaded or missing typesetPromise.");
53
53
  return;
54
54
  }
55
- await window.MathJax.typesetPromise([t]), r();
55
+ await window.MathJax.typesetPromise([r]), n();
56
56
  };
57
57
  }
58
- function a() {
58
+ function i() {
59
59
  return [];
60
60
  }
61
61
  //#endregion
62
62
  //#region src/render-math.ts
63
- var o = "@pie-lib/math-rendering", s = null;
64
- function c() {
65
- return s ||= i({
63
+ var a = null;
64
+ function o() {
65
+ return a ||= r({
66
66
  accessibility: !0,
67
67
  useSingleDollar: !0
68
- }), s;
68
+ }), a;
69
69
  }
70
- function l() {
70
+ function s() {
71
71
  if (typeof window > "u") return null;
72
- let e = window[o];
72
+ let e = window["@pie-lib/math-rendering"];
73
73
  return typeof e?.renderMath == "function" ? e : null;
74
74
  }
75
- var u = async (e) => {
75
+ var c = async (e) => {
76
76
  if (typeof window > "u") return;
77
77
  let t = typeof e == "string", n;
78
78
  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) => {
79
+ let r = s();
80
+ return r ? await r.renderMath?.(n) : await o()(n), t ? n.innerHTML : void 0;
81
+ }, l = (e) => s()?.wrapMath?.(e) ?? e, u = (e) => {
82
82
  let t = e.trim();
83
83
  return t.startsWith("\\[") && t.endsWith("\\]") ? {
84
84
  unwrapped: t.slice(2, -2).trim(),
@@ -105,6 +105,6 @@ var u = async (e) => {
105
105
  close: "$"
106
106
  }
107
107
  } : { unwrapped: t };
108
- }, p = (e) => l()?.mmlToLatex?.(e) ?? e;
108
+ }, d = (e) => s()?.mmlToLatex?.(e) ?? e;
109
109
  //#endregion
110
- export { i as createMathjaxRenderer, a as getMathjaxCssUrls, p as mmlToLatex, u as renderMath, f as unWrapMath, d as wrapMath };
110
+ export { r as createMathjaxRenderer, i as getMathjaxCssUrls, d as mmlToLatex, c as renderMath, u as unWrapMath, l 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.1",
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",