@pie-element/shared-math-rendering-mathjax 0.1.1-next.5 → 0.1.1-next.7
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/index.js +35 -14
- package/dist/unsupported-page.d.ts +1 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -175,29 +175,50 @@ function N() {
|
|
|
175
175
|
}
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/render-math.ts
|
|
178
|
-
var P = "@pie-lib/math-rendering", F = "@pie-lib/math-rendering@2", I = null;
|
|
179
|
-
function
|
|
178
|
+
var P = "@pie-lib/math-rendering", F = "@pie-lib/math-rendering@2", I = "pie-print", L = 50, R = 1e4, z = null;
|
|
179
|
+
function B() {
|
|
180
180
|
return !!window[F]?.opts?.useSingleDollar;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
return
|
|
182
|
+
function V() {
|
|
183
|
+
return z ||= M({ useSingleDollar: B() }), z;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function H() {
|
|
186
186
|
if (typeof window > "u") return null;
|
|
187
187
|
let e = window[P];
|
|
188
188
|
return typeof e?.renderMath == "function" ? e : null;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
let
|
|
192
|
-
|
|
190
|
+
function U(e) {
|
|
191
|
+
let t = e;
|
|
192
|
+
for (; t;) {
|
|
193
|
+
if (t instanceof Element && t.localName === I) return t;
|
|
194
|
+
t = t instanceof ShadowRoot ? t.host : t.parentNode;
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
function W() {
|
|
199
|
+
let e = window.renderMath;
|
|
200
|
+
return typeof e == "function" ? e : null;
|
|
201
|
+
}
|
|
202
|
+
async function G(e) {
|
|
203
|
+
let t = U(e);
|
|
204
|
+
if (!t) return null;
|
|
205
|
+
let n = W();
|
|
206
|
+
if (n || t.mathRenderingModuleUrlImported !== !0) return n;
|
|
207
|
+
let r = Date.now() + R;
|
|
208
|
+
for (; Date.now() < r;) {
|
|
209
|
+
await new Promise((e) => setTimeout(e, L));
|
|
210
|
+
let e = W();
|
|
211
|
+
if (e) return e;
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
193
214
|
}
|
|
194
|
-
var
|
|
215
|
+
var K = async (e) => {
|
|
195
216
|
if (typeof window > "u") return;
|
|
196
217
|
let t = typeof e == "string", n;
|
|
197
218
|
t ? (n = document.createElement("div"), n.innerHTML = e) : n = e || document.body;
|
|
198
|
-
let r =
|
|
199
|
-
return r ?
|
|
200
|
-
},
|
|
219
|
+
let r = H(), i = r || t ? null : await G(n);
|
|
220
|
+
return r ? await r.renderMath?.(n) : i ? await i(n) : await V()(n), t ? n.innerHTML : void 0;
|
|
221
|
+
}, q = (e) => H()?.wrapMath?.(e) ?? e, J = (e) => {
|
|
201
222
|
let t = e.trim();
|
|
202
223
|
return t.startsWith("\\[") && t.endsWith("\\]") ? {
|
|
203
224
|
unwrapped: t.slice(2, -2).trim(),
|
|
@@ -224,6 +245,6 @@ var V = async (e) => {
|
|
|
224
245
|
close: "$"
|
|
225
246
|
}
|
|
226
247
|
} : { unwrapped: t };
|
|
227
|
-
},
|
|
248
|
+
}, Y = (e) => H()?.mmlToLatex?.(e) ?? e;
|
|
228
249
|
//#endregion
|
|
229
|
-
export { t as MATHJAX_CONFLICT_EVENT, e as UNSUPPORTED_PAGE_DOCS_URL, M as createMathjaxRenderer, N as getMathjaxCssUrls,
|
|
250
|
+
export { t as MATHJAX_CONFLICT_EVENT, e as UNSUPPORTED_PAGE_DOCS_URL, M as createMathjaxRenderer, N as getMathjaxCssUrls, Y as mmlToLatex, K as renderMath, J as unWrapMath, q as wrapMath };
|
|
@@ -13,9 +13,7 @@ export type MathjaxConflictCondition =
|
|
|
13
13
|
/** `window.MathJax` is a MathJax 3 build. */
|
|
14
14
|
'mathjax-3-global'
|
|
15
15
|
/** Another MathJax output stylesheet was added to `<head>` beside this adapter's. */
|
|
16
|
-
| 'foreign-output-stylesheet'
|
|
17
|
-
/** `window['@pie-lib/math-rendering']` routes ESM element math to MathJax 3. */
|
|
18
|
-
| 'legacy-renderer-delegation';
|
|
16
|
+
| 'foreign-output-stylesheet';
|
|
19
17
|
export interface MathjaxConflictDetail {
|
|
20
18
|
condition: MathjaxConflictCondition;
|
|
21
19
|
message: string;
|