@pie-element/element-player 0.1.2-next.4 → 0.1.2-next.6

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/README.md CHANGED
@@ -1,30 +1,6 @@
1
1
  # PIE Element Player
2
2
 
3
- Self-contained web components for rendering PIE elements, following the same architecture as `@pie-framework/pie-players`.
4
-
5
- ---
6
-
7
- ## ⚠️ IMPORTANT: NOT FOR PUBLISHING
8
-
9
- **This package is currently marked as `private` and should NOT be published to npm.**
10
-
11
- ### Build Issue
12
-
13
- The package has a dependency resolution issue that prevents it from building as a standalone library:
14
-
15
- - [element-loader.ts](src/lib/element-loader.ts) imports `$lib/element-imports` for local development mode
16
- - This import only exists in the element-demo app, not in this package
17
- - The import is marked as external in the build config as a workaround
18
- - For production use, this architecture needs to be refactored
19
-
20
- **Before publishing this package**, the following must be resolved:
21
-
22
- 1. Refactor the element-loader to not depend on app-specific imports
23
- 2. Either remove local development mode from the library OR provide a proper abstraction
24
- 3. Ensure the build completes successfully without external dependencies on non-existent modules
25
- 4. Remove the `"private": true` field from package.json
26
-
27
- **Issue tracked in**: Build fails with "Rollup failed to resolve import '$lib/element-imports'"
3
+ Self-contained web components for rendering PIE elements, following the same architecture as the `@pie-players/*` players in [pie-players](https://github.com/pie-framework/pie-players).
28
4
 
29
5
  ---
30
6
 
@@ -143,7 +119,7 @@ The player dispatches each event from `<pie-element-player>`, bubbling and compo
143
119
  | `controller-load` | a load completes, except a `preloaded` one that finds its tag defined (below) | `status`, `source`, `packageName`, `strategy`, `view`, `message` |
144
120
  | `controller-changed` | IIFE delivery: the bundle's controller loads | the controller |
145
121
 
146
- `session-changed` also fires with no learner action. Once the element has a model, the player sets `session` on it, and sets it again whenever the host assigns a different session. An element that reports that assignment after its setter returns, as multiple-choice does, has the report forwarded.
122
+ `session-changed` also fires with no learner action. Once the element has a model, the player sets `session` on it, and sets it again whenever the host assigns a different session. A report the element dispatches while that setter runs is dropped; one it dispatches after the setter returns is forwarded.
147
123
 
148
124
  An abort error is a load error whose message contains `aborted`, whatever the strategy. The player then emits `bundle-retry-status` with state `cancelled`, `build-state` with stage `cancelled` and `load-cancelled`, in place of `player-error`.
149
125
 
@@ -0,0 +1,96 @@
1
+ //#region ../shared/math-rendering-mathjax/dist/index.js
2
+ var e = {
3
+ parallelogram: "\\lower.2em{\\Huge\\unicode{x25B1}}",
4
+ overarc: "\\overparen",
5
+ napprox: "\\not\\approx",
6
+ longdiv: "\\enclose{longdiv}",
7
+ abs: ["\\left|#1\\right|", 1]
8
+ }, t = "[math-rendering] using $ is not advisable, please use $$..$$ or \\(...\\)", n = /\\\(|\\\[|\$\$|\\\$|\\begin\{|\\(?:eq)?ref\{/, r = /\\\(|\\\[|\$|\\begin\{|\\(?:eq)?ref\{/, i = /\\embed\{newLine\}\[\]/g, a = [
9
+ ["$$", "$$"],
10
+ ["$", "$"],
11
+ ["\\[", "\\]"],
12
+ ["\\(", "\\)"]
13
+ ], o = Symbol.for("@pie-element/shared-math-rendering-mathjax/loading");
14
+ function s() {
15
+ return window.MathJax;
16
+ }
17
+ function c(e) {
18
+ let t = e.includes("\\displaystyle") ? e.replace("\\displaystyle", "").trim() : e;
19
+ for (let [e, n] of a) if (t.startsWith(e) && t.endsWith(n)) return t.substring(e.length, t.length - n.length);
20
+ return t;
21
+ }
22
+ function l(e) {
23
+ for (let t of e.querySelectorAll("[data-latex]")) {
24
+ if (t.dataset.mathHandled || t.closest("mjx-container")) continue;
25
+ let e = t.textContent;
26
+ e && (t.textContent = `\\(${c(e)}\\)`.replace(i, "\\newline "), t.dataset.mathHandled = "true");
27
+ }
28
+ }
29
+ function u(e, t) {
30
+ for (let t of e.querySelectorAll("math")) if (!t.closest("mjx-assistive-mml")) return !0;
31
+ return (t ? r : n).test(e.textContent ?? "");
32
+ }
33
+ function d(n) {
34
+ return new Promise((r, i) => {
35
+ let { useSingleDollar: a = !1, accessibility: o = !0, loadFonts: c = !0, srcUrl: l } = n, u = {
36
+ loader: {
37
+ load: o ? ["a11y/assistive-mml"] : [],
38
+ failed: (e) => i(e)
39
+ },
40
+ startup: {
41
+ typeset: !1,
42
+ ready: () => {
43
+ let e = s()?.startup;
44
+ e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => r(), i);
45
+ }
46
+ },
47
+ tex: { macros: { ...e } },
48
+ options: {
49
+ enableMenu: o,
50
+ menuOptions: { settings: {
51
+ assistiveMml: o,
52
+ enrich: !1,
53
+ inTabOrder: !1
54
+ } }
55
+ }
56
+ };
57
+ a && u.tex && (console.warn(t), u.tex.inlineMath = [["$", "$"], ["\\(", "\\)"]], u.tex.processEscapes = !0), c || (u.chtml = { fontURL: "" }), window.MathJax = u;
58
+ let d = document.createElement("script");
59
+ 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);
60
+ });
61
+ }
62
+ function f(e) {
63
+ return new Promise((t, n) => {
64
+ let r = e.startup ?? {};
65
+ e.startup = r;
66
+ let i = r.ready;
67
+ r.ready = () => {
68
+ let e = s()?.startup;
69
+ i ? i.call(r) : e?.defaultReady?.(), Promise.resolve(e?.promise).then(() => t(), n);
70
+ };
71
+ });
72
+ }
73
+ function p(e) {
74
+ let t = s();
75
+ return t ? t.version ? t.startup?.promise ? Promise.resolve(t.startup.promise).then(() => void 0) : Promise.resolve() : f(t) : d(e);
76
+ }
77
+ function m(e) {
78
+ return p(e).then(() => {
79
+ typeof s()?.typesetPromise != "function" && console.warn("[mathjax-renderer] MathJax on this page has no typesetPromise; math stays untypeset.");
80
+ });
81
+ }
82
+ function h(e) {
83
+ let t = globalThis, n = t[o];
84
+ return n || (n = m(e), t[o] = n), n;
85
+ }
86
+ function g(e = {}) {
87
+ let t = e.useSingleDollar ?? !1;
88
+ return async (n) => {
89
+ if (typeof window > "u" || (l(n), !u(n, t))) return;
90
+ await h(e);
91
+ let r = s();
92
+ await r?.startup?.promise, typeof r?.typesetPromise == "function" && await r.typesetPromise([n]);
93
+ };
94
+ }
95
+ //#endregion
96
+ export { g as t };