@pie-element/simple-cloze 0.1.4-next.15 → 0.1.4-next.16

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.
@@ -4577,131 +4577,212 @@ function create_custom_element(Component, props_definition, slots, exports, shad
4577
4577
  }
4578
4578
  //#endregion
4579
4579
  //#region ../../shared/math-rendering-mathjax/dist/index.js
4580
- var e$2 = {
4580
+ var e$2 = "https://github.com/pie-framework/pie-players/blob/develop/docs/item-player/loading-strategies.md#one-mathjax-version-per-page";
4581
+ var t$2 = "pie-mathjax-version-conflict";
4582
+ var n = Symbol.for("@pie-element/shared-math-rendering-mathjax/unsupported-page");
4583
+ function r$1(r, i) {
4584
+ if (typeof window > "u") return;
4585
+ let a = globalThis;
4586
+ a[n] ?? (a[n] = {
4587
+ logged: !1,
4588
+ conditions: []
4589
+ });
4590
+ let o = a[n];
4591
+ if (o.conditions.includes(r)) return;
4592
+ o.conditions.push(r);
4593
+ let s = `[math-rendering] Unsupported page (${r}): ${i}. PIE supports one MathJax major version per page; with MathJax 3 and 4 on one page, math rendering is best effort and may break. See ${e$2}`;
4594
+ o.logged || (o.logged = !0, console.error(s)), window.dispatchEvent(new CustomEvent(t$2, { detail: {
4595
+ condition: r,
4596
+ message: s,
4597
+ docsUrl: e$2
4598
+ } }));
4599
+ }
4600
+ function i() {
4601
+ let e = window.MathJax?.version;
4602
+ return typeof e == "string" && e.startsWith("3.") ? e : void 0;
4603
+ }
4604
+ var a = "https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-mml-chtml.js";
4605
+ var o = {
4581
4606
  parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
4582
4607
  overarc: "\\overparen",
4583
4608
  napprox: "\\not\\approx",
4584
4609
  longdiv: "\\enclose{longdiv}",
4585
4610
  abs: ["\\left|#1\\right|", 1]
4586
4611
  };
4587
- var t$2 = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)";
4588
- var n = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/;
4589
- var r$1 = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/;
4590
- var i = /\\embed\{newLine\}\[\]/g;
4591
- var a = [
4612
+ var s = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)";
4613
+ var c = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/;
4614
+ var l = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/;
4615
+ var u = /\\embed\{newLine\}\[\]/g;
4616
+ var d = [
4592
4617
  ["$$", "$$"],
4593
4618
  ["$", "$"],
4594
4619
  ["\\[", "\\]"],
4595
4620
  ["\\(", "\\)"]
4596
4621
  ];
4597
- var o = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading");
4598
- function s() {
4622
+ var f = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading");
4623
+ var p = "PIE-MJX-CHTML-styles";
4624
+ var m = "MJX-CHTML-styles";
4625
+ var h = [m, "MJX-SVG-styles"];
4626
+ var g = 201;
4627
+ function _(e) {
4628
+ let t = [...e.matches("mjx-container") ? [e] : [], ...e.querySelectorAll("mjx-container")];
4629
+ for (let e of t) for (let t of [e, ...e.querySelectorAll("[data-latex],[data-latex-item]")]) t.removeAttribute("data-latex"), t.removeAttribute("data-latex-item");
4630
+ }
4631
+ function v() {
4599
4632
  return window.MathJax;
4600
4633
  }
4601
- function c(e) {
4634
+ function y(e) {
4602
4635
  let t = e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e;
4603
- for (let [e, n] of a) if (t.startsWith(e) && t.endsWith(n)) return t.substring(e.length, t.length - n.length);
4636
+ for (let [e, n] of d) if (t.startsWith(e) && t.endsWith(n)) return t.substring(e.length, t.length - n.length);
4604
4637
  return t;
4605
4638
  }
4606
- function l(e) {
4639
+ function b(e) {
4607
4640
  for (let t of e.querySelectorAll("[data-latex]")) {
4608
4641
  if (t.dataset.mathHandled || t.closest("mjx-container")) continue;
4609
4642
  let e = t.textContent;
4610
- e && (t.textContent = `\\(${c(e)}\\)`.replace(i, "\\newline "), t.dataset.mathHandled = "true");
4643
+ e && (t.textContent = `\\(${y(e)}\\)`.replace(u, "\\newline "), t.dataset.mathHandled = "true");
4611
4644
  }
4612
4645
  }
4613
- function u(e, t) {
4646
+ function x(e, t) {
4614
4647
  for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
4615
- return (t ? r$1 : n).test(e.textContent ?? "");
4648
+ return (t ? l : c).test(e.textContent ?? "");
4616
4649
  }
4617
- function d(n) {
4618
- return new Promise((r, i) => {
4619
- let { useSingleDollar: a = !1, accessibility: o = !0, loadFonts: c = !0, srcUrl: l } = n, u = {
4650
+ function S(e) {
4651
+ return new Promise((t, n) => {
4652
+ let { useSingleDollar: r = !1, accessibility: i = !0, loadFonts: c = !0, srcUrl: l } = e, u = {
4620
4653
  loader: {
4621
- load: o ? ["a11y/assistive-mml"] : [],
4622
- failed: (e) => i(e)
4654
+ load: i ? ["a11y/assistive-mml"] : [],
4655
+ failed: (e) => n(e)
4623
4656
  },
4624
4657
  startup: {
4625
4658
  typeset: !1,
4626
4659
  ready: () => {
4627
- let e = s()?.startup;
4628
- e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => r(), i);
4660
+ let e = v(), r = e?.startup, i = !!e?.version?.startsWith("4.");
4661
+ i && C(e), r?.defaultReady?.(), i && w(r?.document), Promise.resolve(r?.promise).then(() => t(), n);
4629
4662
  }
4630
4663
  },
4631
- tex: { macros: { ...e$2 } },
4664
+ tex: { macros: { ...o } },
4632
4665
  options: {
4633
- enableMenu: o,
4666
+ enableMenu: i,
4634
4667
  menuOptions: { settings: {
4635
- assistiveMml: o,
4668
+ assistiveMml: i,
4636
4669
  enrich: !1,
4637
4670
  inTabOrder: !1
4638
4671
  } }
4639
4672
  }
4640
4673
  };
4641
- a && u.tex && (console.warn(t$2), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), c || (u.chtml = { fontURL: "" }), window.MathJax = u;
4674
+ r && u.tex && (console.warn(s), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), c || (u.chtml = { fontURL: "" }), window.MathJax = u;
4642
4675
  let d = document.createElement("script");
4643
- d.src = l || "https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-mml-chtml.js", d.async = !0, d.onerror = () => i(/* @__PURE__ */ Error("Failed to load MathJax")), document.head.appendChild(d);
4676
+ d.src = l || a, d.async = !0, d.onerror = () => n(/* @__PURE__ */ Error("Failed to load MathJax")), document.head.appendChild(d);
4644
4677
  });
4645
4678
  }
4646
- function f(e) {
4679
+ function C(e) {
4680
+ let t = e?._?.output?.chtml_ts?.CHTML;
4681
+ t && (t.STYLESHEETID = p);
4682
+ }
4683
+ function w(e) {
4684
+ if (!e) return;
4685
+ let t = /* @__PURE__ */ new WeakSet(), n = (e) => {
4686
+ let n = e.typesetRoot;
4687
+ !n || t.has(n) || (_(n), t.add(n));
4688
+ };
4689
+ e.addRenderAction?.("pie-strip-latex", g, (e) => {
4690
+ for (let t of e.math ?? []) n(t);
4691
+ return !1;
4692
+ }, (e) => {
4693
+ let t = e.typesetRoot;
4694
+ return t && _(t), !1;
4695
+ });
4696
+ let r = e.outputJax?.chtmlStyles;
4697
+ r?.id === m && (r.id = p), D();
4698
+ }
4699
+ function T(e) {
4700
+ return e instanceof HTMLStyleElement && h.includes(e.id);
4701
+ }
4702
+ function E(e) {
4703
+ r$1("foreign-output-stylesheet", `another MathJax added <style id="${e.id}"> to <head>`);
4704
+ }
4705
+ function D() {
4706
+ let e = document.head, t = [...e.children].find(T);
4707
+ if (t) {
4708
+ E(t);
4709
+ return;
4710
+ }
4711
+ let n = new MutationObserver((e) => {
4712
+ for (let t of e) {
4713
+ let e = [...t.addedNodes].find(T);
4714
+ if (e) {
4715
+ E(e), n.disconnect();
4716
+ return;
4717
+ }
4718
+ }
4719
+ });
4720
+ n.observe(e, { childList: !0 });
4721
+ }
4722
+ function O(e) {
4647
4723
  return new Promise((t, n) => {
4648
4724
  let r = e.startup ?? {};
4649
4725
  e.startup = r;
4650
4726
  let i = r.ready;
4651
4727
  r.ready = () => {
4652
- let e = s()?.startup;
4728
+ let e = v()?.startup;
4653
4729
  i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
4654
4730
  };
4655
4731
  });
4656
4732
  }
4657
- function p(e) {
4658
- let t = s();
4659
- return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : f(t) : d(e);
4733
+ function k(e) {
4734
+ let t = v();
4735
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : O(t) : S(e);
4660
4736
  }
4661
- function m(e) {
4662
- return p(e).then(() => {
4663
- typeof s()?.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
4737
+ function A(e) {
4738
+ return k(e).then(() => {
4739
+ typeof v()?.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
4664
4740
  });
4665
4741
  }
4666
- function h(e) {
4667
- let t = globalThis, n = t[o];
4668
- return n || (n = m(e), t[o] = n), n;
4742
+ function j(e) {
4743
+ let t = globalThis, n = t[f];
4744
+ return n || (n = A(e), t[f] = n), n;
4669
4745
  }
4670
- function g(e = {}) {
4746
+ function M(e = {}) {
4671
4747
  let t = e.useSingleDollar ?? !1;
4672
4748
  return async (n) => {
4673
4749
  if (typeof window > "u") return;
4674
- l(n);
4675
- let r = h(e);
4676
- if (!u(n, t)) {
4677
- r.catch(() => {});
4750
+ let a = i();
4751
+ a && r$1("mathjax-3-global", `window.MathJax is MathJax ${a}`), b(n);
4752
+ let o = j(e);
4753
+ if (!x(n, t)) {
4754
+ o.catch(() => {});
4678
4755
  return;
4679
4756
  }
4680
- await r;
4681
- let i = s();
4682
- await i?.startup?.promise, typeof i?.typesetPromise == "function" && await i.typesetPromise([n]);
4757
+ await o;
4758
+ let s = v();
4759
+ await s?.startup?.promise, typeof s?.typesetPromise == "function" && (await s.typesetPromise([n]), _(n));
4683
4760
  };
4684
4761
  }
4685
- var v = "@pie-lib/math-rendering";
4686
- var y = "@pie-lib/math-rendering@2";
4687
- var b = null;
4688
- function x() {
4689
- return !!window[y]?.opts?.useSingleDollar;
4762
+ var P = "@pie-lib/math-rendering";
4763
+ var F = "@pie-lib/math-rendering@2";
4764
+ var I = null;
4765
+ function L() {
4766
+ return !!window[F]?.opts?.useSingleDollar;
4690
4767
  }
4691
- function S() {
4692
- return b || (b = g({ useSingleDollar: x() })), b;
4768
+ function R() {
4769
+ return I || (I = M({ useSingleDollar: L() })), I;
4693
4770
  }
4694
- function C() {
4771
+ function z() {
4695
4772
  if (typeof window > "u") return null;
4696
- let e = window[v];
4773
+ let e = window[P];
4697
4774
  return typeof e?.renderMath == "function" ? e : null;
4698
4775
  }
4699
- var w = async (e) => {
4776
+ function B() {
4777
+ let e = i();
4778
+ e && r$1("legacy-renderer-delegation", `window['${P}'] renders this element's math with MathJax ${e}`);
4779
+ }
4780
+ var V = async (e) => {
4700
4781
  if (typeof window > "u") return;
4701
4782
  let t = typeof e == "string", n;
4702
4783
  t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
4703
- let r = C();
4704
- return r ? await r.renderMath?.(n) : await S()(n), t ? n.innerHTML : void 0;
4784
+ let r = z();
4785
+ return r ? (B(), await r.renderMath?.(n)) : await R()(n), t ? n.innerHTML : void 0;
4705
4786
  };
4706
4787
  //#endregion
4707
4788
  //#region src/controller/plain-text.ts
@@ -7129,7 +7210,7 @@ function Print($$anchor, $$props) {
7129
7210
  if (!get$1(promptElement) || !get$1(prompt)) return;
7130
7211
  const warn = (err) => console.warn("simple-cloze: MathJax render failed", err);
7131
7212
  try {
7132
- Promise.resolve(w(get$1(promptElement))).catch(warn);
7213
+ Promise.resolve(V(get$1(promptElement))).catch(warn);
7133
7214
  } catch (err) {
7134
7215
  warn(err);
7135
7216
  }