reactive-md 0.9.0 → 0.9.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.
- package/CHANGELOG-ch.md +13 -0
- package/CHANGELOG.md +13 -0
- package/README-ch.md +6 -6
- package/README-en.md +6 -6
- package/README.md +6 -6
- package/SECURITY-ch.md +3 -3
- package/SECURITY.md +3 -3
- package/THIRD_PARTY_NOTICES.md +111 -1
- package/cli/build.mjs +1 -0
- package/cli/init.mjs +1 -1
- package/dist-library/{LocalDocumentView-K7Y-2bRJ.js → LocalDocumentView-sthUP0ct.js} +10 -10
- package/dist-library/LocalDocumentViewCore-GiWV3bey.js +9829 -0
- package/dist-library/LocalReactiveDocumentCore-ZjQSGyHE.js +275 -0
- package/dist-library/{authoring-Co_TiE-P.js → authoring-Dsune4Hy.js} +40 -20
- package/dist-library/{compile-LhpTKqCR.js → compile-wUv8KEge.js} +1 -1
- package/dist-library/{compiler-core-DTxY-qYz.js → compiler-core-As_m-MNm.js} +2449 -1742
- package/dist-library/{compiler-DfGbQhyD.js → compiler-eOfcinZs.js} +19 -19
- package/dist-library/{component-state-BBJ08vML.js → component-state-C52ZFJGl.js} +1 -1
- package/dist-library/{config-BUo-8O5C.js → config-BadfhjdP.js} +1 -1
- package/dist-library/{config-validation-C5kJYk-J.js → config-validation-F47AcE6o.js} +49 -1
- package/dist-library/{controls-BWiLLtBO.js → controls-CcT6n7k_.js} +2433 -2409
- package/dist-library/{coordinate-BSl6enWV.js → coordinate-CWS9p5q_.js} +108 -107
- package/dist-library/{data-table-DfvytZKQ.js → data-table-Bgccxd7h.js} +68 -65
- package/dist-library/{display-lw3BT1TA.js → display-B-VhqVND.js} +1 -1
- package/dist-library/{export-C7IDW9ul.js → export-BqVmTXm8.js} +145 -87
- package/dist-library/{gallery-B8kSt1oI.js → gallery-CY6mTx8i.js} +151 -147
- package/dist-library/html-CNT4KD-2.js +757 -0
- package/dist-library/{incremental-D_6vwAAE.js → incremental-Dv0FSp_U.js} +404 -142
- package/dist-library/layout-C0YlEPGr.js +562 -0
- package/dist-library/{mount-preset-C5s9ebEH.js → mount-preset-KxvtKgJb.js} +2 -2
- package/dist-library/options-1aDLK7JY.js +121 -0
- package/dist-library/{package-core-D0POW4Gd.js → package-core-WFK1RhAZ.js} +3 -3
- package/dist-library/{parser-standard-OToYcOBL.js → parser-standard-Yuf3A_VI.js} +3270 -3778
- package/dist-library/react-D5iGiUdL.js +7 -0
- package/dist-library/reactive-md-authoring.js +16 -18
- package/dist-library/reactive-md-build.js +51 -51
- package/dist-library/reactive-md-compiler-standard.js +10 -9
- package/dist-library/reactive-md-compiler.js +3 -3
- package/dist-library/reactive-md-export.js +4 -4
- package/dist-library/reactive-md-minimal-react-preset.js +3 -3
- package/dist-library/reactive-md-pdf.js +127 -3
- package/dist-library/reactive-md-plugin-chart.js +2 -2
- package/dist-library/reactive-md-plugin-data.js +4 -4
- package/dist-library/reactive-md-plugin-diagram.js +3 -3
- package/dist-library/reactive-md-plugin-forms.js +2 -2
- package/dist-library/reactive-md-plugin-gallery.js +2 -2
- package/dist-library/reactive-md-plugin-navigation.js +2 -2
- package/dist-library/reactive-md-plugin-network.js +117 -115
- package/dist-library/reactive-md-plugin-plot.js +3 -3
- package/dist-library/reactive-md-react-minimal.js +4 -4
- package/dist-library/reactive-md-react-server.js +6 -6
- package/dist-library/reactive-md-react-unstyled.js +10 -11
- package/dist-library/reactive-md-react.js +10 -11
- package/dist-library/reactive-md-sdk.js +3 -3
- package/dist-library/reactive-md-standalone-configured.js +2 -2
- package/dist-library/reactive-md-standalone-host.js +2 -2
- package/dist-library/reactive-md-testing-browser.js +2 -2
- package/dist-library/reactive-md-testing-react.js +6 -6
- package/dist-library/reactive-md-testing.js +4 -4
- package/dist-library/reactive-md.js +280 -193
- package/dist-library/{registry-05JiqmEp.js → registry-B9NGct4d.js} +1 -1
- package/dist-library/{resources-IeJomeUT.js → resources-D2GDQS0p.js} +1 -1
- package/dist-library/{runtime-CuOyRe9f.js → runtime-kcA7bG7G.js} +341 -341
- package/dist-library/{schema-C-AeByPp.js → schema-BufhKUSM.js} +5 -5
- package/dist-library/{sdk-core-BJLJaVR5.js → sdk-core-BoJT1SIt.js} +490 -150
- package/dist-library/{session-core-BGka5D1J.js → session-core-nmJHuR9c.js} +170 -156
- package/dist-library/{shareable-jkGi2g6y.js → shareable-DpbE-59H.js} +207 -242
- package/dist-library/types/authoring/catalog.d.ts +1 -2
- package/dist-library/types/components/shared/visual-frame.d.ts +6 -2
- package/dist-library/types/local/compilation/compiler-capabilities.d.ts +3 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +11 -3
- package/dist-library/types/local/compilation/compiler-services.d.ts +8 -4
- package/dist-library/types/local/compilation/compiler.d.ts +3 -3
- package/dist-library/types/local/compilation/session/incremental.d.ts +20 -5
- package/dist-library/types/local/compilation/streaming.d.ts +27 -0
- package/dist-library/types/local/configuration/capability-policy.d.ts +3 -0
- package/dist-library/types/local/configuration/diagnostic-messages.d.ts +48 -0
- package/dist-library/types/local/configuration/options-core.d.ts +1 -2
- package/dist-library/types/local/configuration/options.d.ts +1 -0
- package/dist-library/types/local/css/author-css.d.ts +66 -0
- package/dist-library/types/local/html/extended-fragment.d.ts +41 -0
- package/dist-library/types/local/html/html.d.ts +39 -3
- package/dist-library/types/local/index.d.ts +1 -1
- package/dist-library/types/local/parsing/author-markdown.d.ts +11 -0
- package/dist-library/types/local/parsing/parse-session.d.ts +2 -2
- package/dist-library/types/local/parsing/parser-convert.d.ts +2 -1
- package/dist-library/types/local/parsing/parser-core.d.ts +8 -1
- package/dist-library/types/local/parsing/parser.d.ts +2 -2
- package/dist-library/types/local/rendering/document/ExtendedHtmlFragment.d.ts +14 -0
- package/dist-library/types/local/rendering/document/LocalDocumentViewCore.d.ts +25 -1
- package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +1 -1
- package/dist-library/types/local/rendering/document/use-author-script.d.ts +3 -0
- package/dist-library/types/local/rendering/document/view-render-context.d.ts +11 -1
- package/dist-library/types/local/runtime/author-script-protocol.d.ts +59 -0
- package/dist-library/types/local/transport/worker.d.ts +27 -4
- package/dist-library/types/local/types.d.ts +52 -16
- package/dist-library/types/react/component-api.d.ts +10 -1
- package/dist-library/types/react/component-utils.d.ts +9 -1
- package/dist-library/types/react/sdk-core.d.ts +4 -1
- package/dist-library/types/shareable.d.ts +5 -4
- package/dist-library/types/standalone/prepare.d.ts +1 -1
- package/dist-library/types/standalone/session-core.d.ts +3 -2
- package/dist-library/{types-BFC5rzC4.js → types-BeNtPqdY.js} +1 -1
- package/dist-library/{validation-BlDL2uD9.js → validation-BEBA_HvS.js} +88 -72
- package/dist-library/{visual-frame-G8PHoj1e.js → visual-frame-CyV1FXzs.js} +6 -5
- package/dist-library/{visuals-BkYRmYGO.js → visuals-BZbZYA7w.js} +24181 -24180
- package/dist-standalone/reactive-md-standalone.js +124 -117
- package/docs/README-ch.md +2 -1
- package/docs/README.md +2 -1
- package/docs/compatibility/compatibility-ch.md +6 -6
- package/docs/compatibility/compatibility-en.md +6 -6
- package/docs/compatibility/source-versioning-ch.md +1 -1
- package/docs/compatibility/source-versioning-en.md +1 -1
- package/docs/development/component-development-ch.md +2 -2
- package/docs/development/component-development-en.md +2 -2
- package/docs/development/component-development-reference-ch.md +2 -2
- package/docs/development/component-development-reference-en.md +2 -2
- package/docs/development/component-protocol-ch.md +2 -2
- package/docs/development/component-protocol-en.md +2 -2
- package/docs/development/extension-tutorial-ch.md +3 -3
- package/docs/development/extension-tutorial-en.md +3 -3
- package/docs/integration/author-tools-ch.md +1 -1
- package/docs/integration/author-tools-en.md +1 -1
- package/docs/integration/compiler-ch.md +3 -1
- package/docs/integration/compiler-en.md +3 -1
- package/docs/integration/editor-ch.md +3 -3
- package/docs/integration/editor-en.md +3 -3
- package/docs/integration/extension-sdk-ch.md +2 -2
- package/docs/integration/extension-sdk-en.md +2 -2
- package/docs/integration/local-integration-ch.md +130 -8
- package/docs/integration/local-integration-en.md +130 -8
- package/docs/integration/shareable-export-ch.md +4 -2
- package/docs/integration/shareable-export-en.md +4 -2
- package/docs/reference/html-compatibility-ch.md +20 -67
- package/docs/reference/html-compatibility-en.md +19 -64
- package/docs/reference/public-api-ch.md +10 -7
- package/docs/reference/public-api-en.md +10 -7
- package/docs/releases/release-0.9.1-ch.md +29 -0
- package/docs/releases/release-0.9.1-en.md +29 -0
- package/examples/component-package/README-ch.md +1 -1
- package/examples/component-package/README.md +1 -1
- package/examples/game-2048-package/README-ch.md +1 -1
- package/examples/game-2048-package/README.md +1 -1
- package/examples/integration/README-ch.md +21 -2
- package/examples/integration/README.md +21 -2
- package/examples/integration/extension-sdk/README-ch.md +1 -1
- package/examples/integration/extension-sdk/README.md +1 -1
- package/examples/integration/streaming/index.html +48 -0
- package/examples/integration/streaming/main.js +175 -0
- package/examples/integration/streaming/package.json +13 -0
- package/examples/integration/streaming/worker.js +3 -0
- package/examples/minimal-extension/README-ch.md +3 -3
- package/examples/minimal-extension/README.md +3 -3
- package/examples/tetris-package/README-ch.md +1 -1
- package/examples/tetris-package/README.md +1 -1
- package/package.json +6 -1
- package/dist-library/LocalDocumentViewCore-BLG4hMuO.js +0 -9535
- package/dist-library/LocalReactiveDocumentCore-DVQ6WA9G.js +0 -259
- package/dist-library/component-utils-BvHL8VGt.js +0 -298
- package/dist-library/layout-C22VjZh0.js +0 -542
- package/dist-library/options-CdSKOi7p.js +0 -116
- package/dist-library/react-LY5qsVeP.js +0 -7
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { A as e, B as t, G as n, J as r, K as i, O as a, it as o } from "./preset-core-CKc5YXSM.js";
|
|
2
|
-
import { V as s, f as c, l, u } from "./config-validation-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
6
|
-
import {
|
|
7
|
-
import { C as
|
|
8
|
-
import { n as
|
|
9
|
-
import { i as
|
|
2
|
+
import { V as s, f as c, l, u } from "./config-validation-F47AcE6o.js";
|
|
3
|
+
import { S as d } from "./validation-BEBA_HvS.js";
|
|
4
|
+
import { l as f, o as p } from "./parser-standard-Yuf3A_VI.js";
|
|
5
|
+
import { i as m, s as h } from "./config-BadfhjdP.js";
|
|
6
|
+
import { r as g } from "./options-1aDLK7JY.js";
|
|
7
|
+
import { C as _, u as ee, w as te } from "./component-state-BoLCGee4.js";
|
|
8
|
+
import { n as v } from "./runtime-kcA7bG7G.js";
|
|
9
|
+
import { i as ne, t as y } from "./resources-D2GDQS0p.js";
|
|
10
10
|
// src/local/runtime/state.ts
|
|
11
|
-
var
|
|
11
|
+
var b = "reactive-md-state/v1", x = 1048576, S = /^fnv1a32:[0-9a-f]{8}$/, C = /* @__PURE__ */ new Set([
|
|
12
12
|
"format",
|
|
13
13
|
"syntax",
|
|
14
14
|
"sourceDigest",
|
|
15
15
|
"parameters",
|
|
16
16
|
"generator"
|
|
17
|
-
]),
|
|
18
|
-
function
|
|
17
|
+
]), re = /* @__PURE__ */ new Set(["name", "version"]), ie = new TextEncoder();
|
|
18
|
+
function w(e, t) {
|
|
19
19
|
return {
|
|
20
20
|
code: e,
|
|
21
21
|
message: t.length > 2e3 ? `${s(t, o - 1)}…` : t,
|
|
@@ -28,13 +28,13 @@ function E(e, t) {
|
|
|
28
28
|
column: 1
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
e.length < 100 && e.push(
|
|
31
|
+
function T(e, t, n) {
|
|
32
|
+
e.length < 100 && e.push(w(t, n));
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function E(e) {
|
|
35
35
|
return e instanceof Error ? e.message : String(e);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function D(e) {
|
|
38
38
|
for (let t = 0; t < e.length; t += 1) {
|
|
39
39
|
let n = e.charCodeAt(t);
|
|
40
40
|
if (n >= 55296 && n <= 56319) {
|
|
@@ -49,8 +49,8 @@ function k(e) {
|
|
|
49
49
|
}
|
|
50
50
|
return !0;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
if (typeof e == "string") return
|
|
52
|
+
function O(e) {
|
|
53
|
+
if (typeof e == "string") return D(e) ? {
|
|
54
54
|
ok: !0,
|
|
55
55
|
value: e
|
|
56
56
|
} : {
|
|
@@ -73,7 +73,7 @@ function A(e) {
|
|
|
73
73
|
for (let r = 0; r < e.length; r += 1) {
|
|
74
74
|
let i = e[r];
|
|
75
75
|
if (n === "string" && typeof i == "string") {
|
|
76
|
-
if (!
|
|
76
|
+
if (!D(i)) return {
|
|
77
77
|
ok: !1,
|
|
78
78
|
message: "contains malformed Unicode."
|
|
79
79
|
};
|
|
@@ -94,30 +94,30 @@ function A(e) {
|
|
|
94
94
|
message: "must be a string, finite number, boolean, null or homogeneous primitive array."
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function k(e) {
|
|
98
98
|
if (typeof e != "object" || !e || Array.isArray(e)) return !1;
|
|
99
99
|
let t = Object.getPrototypeOf(e);
|
|
100
100
|
return t === Object.prototype || t === null;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function A(e) {
|
|
103
103
|
return Object.freeze(e.parameters), e.generator && Object.freeze(e.generator), Object.freeze(e);
|
|
104
104
|
}
|
|
105
|
-
function
|
|
105
|
+
function j(e) {
|
|
106
106
|
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("generator must be an object with string name and version.");
|
|
107
107
|
if (typeof e.name != "string" || typeof e.version != "string") throw TypeError("generator must have string name and version.");
|
|
108
|
-
if (!
|
|
108
|
+
if (!D(e.name) || !D(e.version)) throw TypeError("generator name and version must be well-formed Unicode strings.");
|
|
109
109
|
return Object.freeze({
|
|
110
110
|
name: e.name,
|
|
111
111
|
version: e.version
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function M(e) {
|
|
115
115
|
return typeof e == "string" ? `"${e.length > 48 ? `${s(e, 48)}…` : e}"` : e === null ? "null" : Array.isArray(e) ? "an array" : typeof e;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
return e.length > t ? e.length :
|
|
117
|
+
function N(e, t) {
|
|
118
|
+
return e.length > t ? e.length : ie.encode(e).byteLength;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function ae(e, t) {
|
|
121
121
|
let n;
|
|
122
122
|
try {
|
|
123
123
|
let t = JSON.stringify(e);
|
|
@@ -126,17 +126,17 @@ function oe(e, t) {
|
|
|
126
126
|
} catch {
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
|
-
return
|
|
129
|
+
return N(n, t);
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
if (e === void 0) return
|
|
131
|
+
function oe(e) {
|
|
132
|
+
if (e === void 0) return x;
|
|
133
133
|
if (typeof e != "object" || !e) throw TypeError("parseLocalState options must be an object.");
|
|
134
134
|
let { maxLength: t } = e;
|
|
135
|
-
if (t === void 0) return
|
|
135
|
+
if (t === void 0) return x;
|
|
136
136
|
if (typeof t != "number" || !Number.isSafeInteger(t) || t <= 0) throw RangeError("maxLength must be a finite positive integer.");
|
|
137
137
|
return t;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function P(e, t, n) {
|
|
140
140
|
if (!e || e.syntax !== "local" || typeof e.source != "string") throw TypeError("createLocalStateFile requires a compiled local document.");
|
|
141
141
|
if (!t || typeof t != "object" || Array.isArray(t)) throw TypeError("createLocalStateFile requires a state object.");
|
|
142
142
|
let r = Object.keys(e.bindings).filter((e) => !e.startsWith("@")).sort(), i = new Set(r), a = /* @__PURE__ */ new Map();
|
|
@@ -147,7 +147,7 @@ function I(e, t, n) {
|
|
|
147
147
|
continue;
|
|
148
148
|
}
|
|
149
149
|
if (!i.has(n)) throw Error(`Cannot persist parameter "${n}": it is not a public binding of this document.`);
|
|
150
|
-
let r =
|
|
150
|
+
let r = O(t[n]);
|
|
151
151
|
if (!r.ok) throw TypeError(`Cannot persist parameter "${n}": the value ${r.message}`);
|
|
152
152
|
a.set(n, r.value);
|
|
153
153
|
}
|
|
@@ -157,57 +157,57 @@ function I(e, t, n) {
|
|
|
157
157
|
o[e] = a.get(e);
|
|
158
158
|
}
|
|
159
159
|
let s = {
|
|
160
|
-
format:
|
|
160
|
+
format: b,
|
|
161
161
|
syntax: d,
|
|
162
|
-
sourceDigest:
|
|
162
|
+
sourceDigest: _(e.source),
|
|
163
163
|
parameters: o
|
|
164
164
|
};
|
|
165
|
-
return n !== void 0 && (s.generator =
|
|
165
|
+
return n !== void 0 && (s.generator = j(n)), A(s);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
let n = [], r = (e, t) =>
|
|
167
|
+
function se(e, t) {
|
|
168
|
+
let n = [], r = (e, t) => T(n, e, t), i = e;
|
|
169
169
|
if (typeof e == "string") {
|
|
170
|
-
if (
|
|
170
|
+
if (N(e, t) > t) return {
|
|
171
171
|
ok: !1,
|
|
172
|
-
diagnostics: [
|
|
172
|
+
diagnostics: [w("local.state.size", `The state payload exceeds the ${t}-byte limit.`)]
|
|
173
173
|
};
|
|
174
|
-
if (!
|
|
174
|
+
if (!D(e)) return {
|
|
175
175
|
ok: !1,
|
|
176
|
-
diagnostics: [
|
|
176
|
+
diagnostics: [w("local.state.utf", "The state payload contains malformed Unicode.")]
|
|
177
177
|
};
|
|
178
178
|
try {
|
|
179
179
|
i = JSON.parse(e);
|
|
180
180
|
} catch (e) {
|
|
181
181
|
return {
|
|
182
182
|
ok: !1,
|
|
183
|
-
diagnostics: [
|
|
183
|
+
diagnostics: [w("local.state.json", `The state payload is not valid JSON: ${E(e)}`)]
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
186
|
} else {
|
|
187
|
-
let n =
|
|
187
|
+
let n = ae(e, t);
|
|
188
188
|
if (n === null) return {
|
|
189
189
|
ok: !1,
|
|
190
|
-
diagnostics: [
|
|
190
|
+
diagnostics: [w("local.state.shape", "The state payload must be a JSON object.")]
|
|
191
191
|
};
|
|
192
192
|
if (n > t) return {
|
|
193
193
|
ok: !1,
|
|
194
|
-
diagnostics: [
|
|
194
|
+
diagnostics: [w("local.state.size", `The state payload exceeds the ${t}-byte limit.`)]
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
|
-
if (!
|
|
197
|
+
if (!k(i)) return {
|
|
198
198
|
ok: !1,
|
|
199
|
-
diagnostics: [
|
|
199
|
+
diagnostics: [w("local.state.shape", "The state payload must be a JSON object.")]
|
|
200
200
|
};
|
|
201
201
|
Object.getOwnPropertySymbols(i).length > 0 && r("local.state.shape", "The state payload cannot use symbol keys.");
|
|
202
|
-
for (let e of Object.keys(i))
|
|
202
|
+
for (let e of Object.keys(i)) C.has(e) || r("local.state.key", `Unknown top-level state key "${e}".`);
|
|
203
203
|
let a = i.format;
|
|
204
|
-
a !== "reactive-md-state/v1" && r("local.state.format", `Unsupported state format ${
|
|
204
|
+
a !== "reactive-md-state/v1" && r("local.state.format", `Unsupported state format ${M(a)}; expected "${b}".`);
|
|
205
205
|
let o = i.syntax;
|
|
206
|
-
o !== "local-draft-3" && r("local.state.syntax", `Unsupported state syntax ${
|
|
206
|
+
o !== "local-draft-3" && r("local.state.syntax", `Unsupported state syntax ${M(o)}; expected "${d}".`);
|
|
207
207
|
let s = i.sourceDigest;
|
|
208
|
-
typeof s == "string" &&
|
|
208
|
+
typeof s == "string" && S.test(s) || r("local.state.digest", "sourceDigest must match \"fnv1a32:\" followed by 8 lowercase hexadecimal digits.");
|
|
209
209
|
let c = {}, l = i.parameters;
|
|
210
|
-
if (!
|
|
210
|
+
if (!k(l)) r("local.state.parameters", "parameters must be a JSON object of public binding values.");
|
|
211
211
|
else for (let e of Object.keys(l).sort()) {
|
|
212
212
|
if (e === "__proto__") {
|
|
213
213
|
r("local.state.parameter.prototype", "Parameter names cannot be \"__proto__\".");
|
|
@@ -217,16 +217,16 @@ function ce(e, t) {
|
|
|
217
217
|
r("local.state.parameter.internal", `Internal parameter "${e}" cannot be persisted.`);
|
|
218
218
|
continue;
|
|
219
219
|
}
|
|
220
|
-
let t =
|
|
220
|
+
let t = O(l[e]);
|
|
221
221
|
t.ok ? c[e] = t.value : r("local.state.parameter.value", `Parameter "${e}" ${t.message}`);
|
|
222
222
|
}
|
|
223
223
|
let u;
|
|
224
224
|
if (Object.hasOwn(i, "generator")) {
|
|
225
225
|
let e = i.generator;
|
|
226
|
-
if (!
|
|
226
|
+
if (!k(e)) r("local.state.generator", "generator must be an object with string name and version.");
|
|
227
227
|
else {
|
|
228
|
-
for (let t of Object.keys(e))
|
|
229
|
-
typeof e.name != "string" || typeof e.version != "string" ? r("local.state.generator", "generator must have string name and version.") : !
|
|
228
|
+
for (let t of Object.keys(e)) re.has(t) || r("local.state.generator", `generator has unknown key "${t}".`);
|
|
229
|
+
typeof e.name != "string" || typeof e.version != "string" ? r("local.state.generator", "generator must have string name and version.") : !D(e.name) || !D(e.version) ? r("local.state.utf", "generator contains malformed Unicode.") : u = Object.freeze({
|
|
230
230
|
name: e.name,
|
|
231
231
|
version: e.version
|
|
232
232
|
});
|
|
@@ -237,35 +237,35 @@ function ce(e, t) {
|
|
|
237
237
|
diagnostics: n
|
|
238
238
|
};
|
|
239
239
|
let f = {
|
|
240
|
-
format:
|
|
240
|
+
format: b,
|
|
241
241
|
syntax: d,
|
|
242
242
|
sourceDigest: s,
|
|
243
243
|
parameters: c
|
|
244
244
|
};
|
|
245
245
|
return u && (f.generator = u), {
|
|
246
246
|
ok: !0,
|
|
247
|
-
file:
|
|
247
|
+
file: A(f)
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
-
function
|
|
251
|
-
let n =
|
|
250
|
+
function F(e, t) {
|
|
251
|
+
let n = oe(t);
|
|
252
252
|
try {
|
|
253
|
-
return
|
|
253
|
+
return se(e, n);
|
|
254
254
|
} catch (e) {
|
|
255
255
|
return {
|
|
256
256
|
ok: !1,
|
|
257
|
-
diagnostics: [
|
|
257
|
+
diagnostics: [w("local.state.invalid", `Cannot read the local state: ${E(e)}`)]
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function ce(e) {
|
|
262
262
|
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
263
263
|
for (let r of e) t.set(r.id, r), r.children && n(r.children);
|
|
264
264
|
};
|
|
265
265
|
return n(e.nodes), t;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
let t =
|
|
267
|
+
function I(e) {
|
|
268
|
+
let t = ce(e), n = /* @__PURE__ */ new Map(), r = [];
|
|
269
269
|
for (let [i, a] of Object.entries(e.bindingSlots ?? {})) {
|
|
270
270
|
let e = t.get(i);
|
|
271
271
|
if (!e) continue;
|
|
@@ -307,9 +307,9 @@ function R(e) {
|
|
|
307
307
|
groups: r
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function L(e, t, n) {
|
|
311
311
|
let r = [], i = Object.create(null);
|
|
312
|
-
for (let a of t.plans) a.slot === void 0 && Object.hasOwn(n, a.key) && (a.node ? Object.is(e.get(a.node), n[a.key]) || (i[a.key] = n[a.key]) : r.push(
|
|
312
|
+
for (let a of t.plans) a.slot === void 0 && Object.hasOwn(n, a.key) && (a.node ? Object.is(e.get(a.node), n[a.key]) || (i[a.key] = n[a.key]) : r.push(w("local.state.document", `The document has no component for parameter "${a.key}".`)));
|
|
313
313
|
if (r.length) return r;
|
|
314
314
|
r.push(...e.setParameters(i));
|
|
315
315
|
for (let i of t.groups) {
|
|
@@ -319,7 +319,7 @@ function z(e, t, n) {
|
|
|
319
319
|
}
|
|
320
320
|
return r;
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function le(e, t) {
|
|
323
323
|
let n = e.snapshot(), r = {};
|
|
324
324
|
for (let e of t) {
|
|
325
325
|
let t = n.state[e];
|
|
@@ -327,46 +327,46 @@ function ue(e, t) {
|
|
|
327
327
|
}
|
|
328
328
|
return Object.freeze(r);
|
|
329
329
|
}
|
|
330
|
-
function
|
|
331
|
-
let i =
|
|
330
|
+
function R(e, t, n, r) {
|
|
331
|
+
let i = F(t, r);
|
|
332
332
|
if (!i.ok) return i;
|
|
333
333
|
if (!e || e.syntax !== "local" || typeof e.source != "string" || !Array.isArray(e.nodes) || !e.bindings) return {
|
|
334
334
|
ok: !1,
|
|
335
|
-
diagnostics: [
|
|
335
|
+
diagnostics: [w("local.state.document", "resolveLocalState requires a compiled local document.")]
|
|
336
336
|
};
|
|
337
337
|
if (i.file.syntax !== "local-draft-3") return {
|
|
338
338
|
ok: !1,
|
|
339
|
-
diagnostics: [
|
|
339
|
+
diagnostics: [w("local.state.syntax", `This state file uses syntax "${i.file.syntax}", but this build accepts "${d}".`)]
|
|
340
340
|
};
|
|
341
|
-
if (i.file.sourceDigest !==
|
|
341
|
+
if (i.file.sourceDigest !== _(e.source)) return {
|
|
342
342
|
ok: !1,
|
|
343
|
-
diagnostics: [
|
|
343
|
+
diagnostics: [w("local.state.source", "This state file was created for a different document (source digest mismatch).")]
|
|
344
344
|
};
|
|
345
|
-
let a =
|
|
346
|
-
for (let e of Object.keys(i.file.parameters)) o.has(e) ||
|
|
347
|
-
for (let e of o) Object.hasOwn(i.file.parameters, e) ||
|
|
345
|
+
let a = I(e), o = new Set(a.plans.map((e) => e.key)), s = [];
|
|
346
|
+
for (let e of Object.keys(i.file.parameters)) o.has(e) || T(s, "local.state.parameter.unknown", `The state contains unknown parameter "${e}" for this document.`);
|
|
347
|
+
for (let e of o) Object.hasOwn(i.file.parameters, e) || T(s, "local.state.parameter.missing", `The state is missing parameter "${e}".`);
|
|
348
348
|
if (s.length) return {
|
|
349
349
|
ok: !1,
|
|
350
350
|
diagnostics: s
|
|
351
351
|
};
|
|
352
352
|
let c;
|
|
353
353
|
try {
|
|
354
|
-
c =
|
|
354
|
+
c = v(e);
|
|
355
355
|
} catch (e) {
|
|
356
356
|
return {
|
|
357
357
|
ok: !1,
|
|
358
|
-
diagnostics: [
|
|
358
|
+
diagnostics: [w("local.state.document", `Cannot validate this document: ${E(e)}`)]
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
361
|
try {
|
|
362
362
|
if (n) {
|
|
363
|
-
let e =
|
|
363
|
+
let e = L(c, a, n);
|
|
364
364
|
if (e.length) return {
|
|
365
365
|
ok: !1,
|
|
366
366
|
diagnostics: e
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
|
-
let e =
|
|
369
|
+
let e = L(c, a, i.file.parameters);
|
|
370
370
|
if (e.length) return {
|
|
371
371
|
ok: !1,
|
|
372
372
|
diagnostics: e
|
|
@@ -375,51 +375,51 @@ function B(e, t, n, r) {
|
|
|
375
375
|
return {
|
|
376
376
|
ok: !0,
|
|
377
377
|
file: i.file,
|
|
378
|
-
state:
|
|
378
|
+
state: le(c, t)
|
|
379
379
|
};
|
|
380
380
|
} finally {
|
|
381
381
|
c.dispose();
|
|
382
382
|
}
|
|
383
383
|
}
|
|
384
|
-
function
|
|
384
|
+
function z(e, t, n) {
|
|
385
385
|
try {
|
|
386
|
-
return
|
|
386
|
+
return R(e, t, void 0, n);
|
|
387
387
|
} catch (e) {
|
|
388
388
|
return {
|
|
389
389
|
ok: !1,
|
|
390
|
-
diagnostics: [
|
|
390
|
+
diagnostics: [w("local.state.invalid", `Cannot resolve the local state: ${E(e)}`)]
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function B(e, t, n) {
|
|
395
395
|
let r;
|
|
396
396
|
try {
|
|
397
|
-
r =
|
|
397
|
+
r = R(e.document, t, e.snapshot().state, n);
|
|
398
398
|
} catch (e) {
|
|
399
|
-
return [
|
|
399
|
+
return [w("local.state.invalid", `Cannot apply the local state: ${E(e)}`)];
|
|
400
400
|
}
|
|
401
401
|
if (!r.ok) return r.diagnostics;
|
|
402
|
-
let i =
|
|
402
|
+
let i = I(e.document);
|
|
403
403
|
try {
|
|
404
|
-
return
|
|
404
|
+
return L(e, i, r.state);
|
|
405
405
|
} catch (e) {
|
|
406
|
-
return [
|
|
406
|
+
return [w("local.state.invalid", `Cannot apply the local state: ${E(e)}`)];
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
return
|
|
409
|
+
function ue(e, t) {
|
|
410
|
+
return P(e.document, e.getParameters(), t);
|
|
411
411
|
}
|
|
412
|
-
function
|
|
413
|
-
let r =
|
|
414
|
-
return r.ok ?
|
|
412
|
+
function de(e, t, n) {
|
|
413
|
+
let r = F(t, n);
|
|
414
|
+
return r.ok ? B(e, r.file, n) : r.diagnostics;
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function fe(e) {
|
|
417
417
|
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("serializeLocalState requires a state file.");
|
|
418
418
|
if (!e.parameters || typeof e.parameters != "object" || Array.isArray(e.parameters)) throw TypeError("serializeLocalState requires an object of parameters.");
|
|
419
419
|
let t = Object.create(null);
|
|
420
420
|
for (let n of Object.keys(e.parameters).sort()) {
|
|
421
421
|
if (n === "__proto__" || n.startsWith("@")) throw TypeError(`Cannot serialize parameter "${n}".`);
|
|
422
|
-
let r =
|
|
422
|
+
let r = O(e.parameters[n]);
|
|
423
423
|
if (!r.ok) throw TypeError(`Cannot serialize parameter "${n}": the value ${r.message}`);
|
|
424
424
|
t[n] = r.value;
|
|
425
425
|
}
|
|
@@ -430,7 +430,7 @@ function pe(e) {
|
|
|
430
430
|
parameters: t
|
|
431
431
|
};
|
|
432
432
|
if (e.generator !== void 0) {
|
|
433
|
-
let t =
|
|
433
|
+
let t = j(e.generator);
|
|
434
434
|
n.generator = {
|
|
435
435
|
name: t.name,
|
|
436
436
|
version: t.version
|
|
@@ -439,9 +439,9 @@ function pe(e) {
|
|
|
439
439
|
return JSON.stringify(n);
|
|
440
440
|
}
|
|
441
441
|
// src/local/configuration/portable-options.ts
|
|
442
|
-
function
|
|
442
|
+
function V(e) {
|
|
443
443
|
if (e === void 0) return;
|
|
444
|
-
let t =
|
|
444
|
+
let t = g(e);
|
|
445
445
|
if (!t.ok) throw TypeError(`Invalid portable compile options: ${t.message}`);
|
|
446
446
|
return {
|
|
447
447
|
enableCss: t.html.enableCss,
|
|
@@ -449,7 +449,7 @@ function U(e) {
|
|
|
449
449
|
enableExtendedHtml: t.html.enableExtendedHtml,
|
|
450
450
|
...Object.hasOwn(e, "strict") && e.strict !== void 0 ? { strict: t.strict } : {},
|
|
451
451
|
...e.markdownBreaks === void 0 ? {} : { markdownBreaks: t.markdownBreaks },
|
|
452
|
-
...e.config === void 0 ? t.hostComponents.length ? { hostComponents: t.hostComponents } : {} : { config:
|
|
452
|
+
...e.config === void 0 ? t.hostComponents.length ? { hostComponents: t.hostComponents } : {} : { config: h(e.config) },
|
|
453
453
|
...e.limits === void 0 ? {} : { limits: {
|
|
454
454
|
...e.limits.maxSyntaxNodes === void 0 ? {} : { maxSyntaxNodes: t.maxSyntaxNodes },
|
|
455
455
|
...e.limits.maxParseWork === void 0 ? {} : { maxParseWork: t.maxParseWork },
|
|
@@ -458,8 +458,8 @@ function U(e) {
|
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
460
|
// src/export/restoration.ts
|
|
461
|
-
var
|
|
462
|
-
function
|
|
461
|
+
var pe = r;
|
|
462
|
+
function H(e) {
|
|
463
463
|
return r(JSON.stringify([
|
|
464
464
|
e.id,
|
|
465
465
|
e.name,
|
|
@@ -469,8 +469,8 @@ function W(e) {
|
|
|
469
469
|
e.css.map(({ id: e, css: t }) => [e, t])
|
|
470
470
|
]));
|
|
471
471
|
}
|
|
472
|
-
function
|
|
473
|
-
let i =
|
|
472
|
+
function me(e, n) {
|
|
473
|
+
let i = h(n), a = l(i);
|
|
474
474
|
return Object.freeze({
|
|
475
475
|
protocol: "reactive-md-bundle/v1",
|
|
476
476
|
sdkVersion: t,
|
|
@@ -482,12 +482,12 @@ function he(e, n) {
|
|
|
482
482
|
id: e.id,
|
|
483
483
|
name: e.name,
|
|
484
484
|
version: e.version,
|
|
485
|
-
digest:
|
|
485
|
+
digest: H(e)
|
|
486
486
|
})))
|
|
487
487
|
});
|
|
488
488
|
}
|
|
489
|
-
function
|
|
490
|
-
let s =
|
|
489
|
+
function U(e, n, i, o = []) {
|
|
490
|
+
let s = h(n), c = /* @__PURE__ */ new Set(), u = [...e.nodes];
|
|
491
491
|
for (; u.length;) {
|
|
492
492
|
let e = u.pop();
|
|
493
493
|
(e.type === "component" || e.type === "hostComponent") && e.name && c.add(e.name), e.children && u.push(...e.children);
|
|
@@ -502,7 +502,7 @@ function G(e, n, i, o = []) {
|
|
|
502
502
|
id: e.id,
|
|
503
503
|
name: e.name,
|
|
504
504
|
version: e.version,
|
|
505
|
-
digest:
|
|
505
|
+
digest: H(e)
|
|
506
506
|
}));
|
|
507
507
|
return Object.freeze({
|
|
508
508
|
protocol: "reactive-md-restore/v1",
|
|
@@ -519,13 +519,13 @@ function G(e, n, i, o = []) {
|
|
|
519
519
|
})))
|
|
520
520
|
});
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function W(e) {
|
|
523
523
|
return typeof e == "object" && !!e && !Array.isArray(e) && [Object.prototype, null].includes(Object.getPrototypeOf(e));
|
|
524
524
|
}
|
|
525
|
-
function
|
|
525
|
+
function G(e) {
|
|
526
526
|
return typeof e == "string" && e.length > 0 && e.length <= 256;
|
|
527
527
|
}
|
|
528
|
-
function
|
|
528
|
+
function K(o, s) {
|
|
529
529
|
if (o === void 0) return [];
|
|
530
530
|
let l = [], u = (e, t) => l.push({
|
|
531
531
|
code: `local.extension.restore-${e}`,
|
|
@@ -539,7 +539,7 @@ function J(o, s) {
|
|
|
539
539
|
column: 1
|
|
540
540
|
});
|
|
541
541
|
try {
|
|
542
|
-
if (!
|
|
542
|
+
if (!W(o) || e(o) > 262144 || o.protocol !== "reactive-md-restore/v1" || !G(o.sdk) || !G(o.configKey) || !G(o.sourceDigest) || ![
|
|
543
543
|
"static",
|
|
544
544
|
"ssr",
|
|
545
545
|
"offline"
|
|
@@ -556,17 +556,17 @@ function J(o, s) {
|
|
|
556
556
|
"assembly"
|
|
557
557
|
]);
|
|
558
558
|
Object.keys(o).some((e) => !d.has(e)) && u("metadata", "Unknown restoration requirement field.");
|
|
559
|
-
let f = s.config === void 0 ?
|
|
560
|
-
i(o.sdk) && n("0.7.0", o.sdk) || u("sdk", `SDK ${t} does not satisfy ${o.sdk}.`), c(f, o.configKey) || u("config", "The installed configuration differs from the exported configuration."), o.assembly !== void 0 && (
|
|
559
|
+
let f = s.config === void 0 ? m() : h(s.config);
|
|
560
|
+
i(o.sdk) && n("0.7.0", o.sdk) || u("sdk", `SDK ${t} does not satisfy ${o.sdk}.`), c(f, o.configKey) || u("config", "The installed configuration differs from the exported configuration."), o.assembly !== void 0 && (W(o.assembly) && o.assembly.protocol === "reactive-md-assembly-seal/v1" && G(o.assembly.configKey) && c(f, o.assembly.configKey) || u("assembly", "The exported assembly identity is invalid or belongs to another configuration.")), r(s.source) !== o.sourceDigest && u("source", "The source differs from the exported source. Recompile before restoring state.");
|
|
561
561
|
let p = /* @__PURE__ */ new Set();
|
|
562
562
|
for (let e of o.components) {
|
|
563
|
-
if (!
|
|
563
|
+
if (!W(e) || ![
|
|
564
564
|
"id",
|
|
565
565
|
"name",
|
|
566
566
|
"version",
|
|
567
567
|
"range",
|
|
568
568
|
"digest"
|
|
569
|
-
].every((t) =>
|
|
569
|
+
].every((t) => G(e[t])) || !i(e.range) || p.has(e.id)) {
|
|
570
570
|
u("metadata", "Invalid or duplicate component restoration requirement.");
|
|
571
571
|
continue;
|
|
572
572
|
}
|
|
@@ -585,45 +585,45 @@ function J(o, s) {
|
|
|
585
585
|
for (let n of r) t.capabilities[n] || u("capability", `Component ${e.id} cannot render ${n}.`);
|
|
586
586
|
}
|
|
587
587
|
if (s.document) {
|
|
588
|
-
let e =
|
|
588
|
+
let e = U(s.document, f, o.target);
|
|
589
589
|
for (let t of e.components) p.has(t.id) || u("component-missing", `Used component ${t.id} is missing from restoration requirements.`);
|
|
590
590
|
}
|
|
591
591
|
p.clear();
|
|
592
592
|
for (let e of o.themes) {
|
|
593
|
-
if (!
|
|
593
|
+
if (!W(e) || ![
|
|
594
594
|
"id",
|
|
595
595
|
"name",
|
|
596
596
|
"version",
|
|
597
597
|
"digest"
|
|
598
|
-
].every((t) =>
|
|
598
|
+
].every((t) => G(e[t])) || p.has(e.id)) {
|
|
599
599
|
u("metadata", "Invalid or duplicate theme restoration requirement.");
|
|
600
600
|
continue;
|
|
601
601
|
}
|
|
602
602
|
p.add(e.id);
|
|
603
603
|
let t = f.themes.find((t) => t.id === e.id);
|
|
604
|
-
t && t.name === e.name && t.version === e.version &&
|
|
604
|
+
t && t.name === e.name && t.version === e.version && H(t) === e.digest || u("theme", `Required theme ${e.id}@${e.version} does not match the installed theme.`);
|
|
605
605
|
}
|
|
606
606
|
if (s.document) {
|
|
607
607
|
let e = f.themes.find((e) => e.name === s.document.theme);
|
|
608
608
|
e && !p.has(e.id) && u("theme", `Selected theme ${e.id} is missing from restoration requirements.`);
|
|
609
609
|
}
|
|
610
|
-
let
|
|
611
|
-
l.push(...
|
|
612
|
-
let
|
|
610
|
+
let g = y(s.resources ?? []);
|
|
611
|
+
l.push(...g.diagnostics);
|
|
612
|
+
let _ = new Map(g.resources.map((e) => [e.id, e.css]));
|
|
613
613
|
p.clear();
|
|
614
614
|
for (let e of o.resources) {
|
|
615
|
-
if (!
|
|
615
|
+
if (!W(e) || !G(e.id) || !G(e.digest) || p.has(e.id)) {
|
|
616
616
|
u("metadata", "Invalid or duplicate style restoration requirement.");
|
|
617
617
|
continue;
|
|
618
618
|
}
|
|
619
619
|
p.add(e.id);
|
|
620
|
-
let t =
|
|
620
|
+
let t = _.get(e.id);
|
|
621
621
|
t === void 0 ? u("resource-missing", `Required style resource ${e.id} is missing before state restoration.`) : r(t) !== e.digest && u("resource-digest", `Style resource ${e.id} differs from the exported content.`);
|
|
622
622
|
}
|
|
623
623
|
if (s.document) {
|
|
624
|
-
let e =
|
|
624
|
+
let e = U(s.document, f, o.target), t = new Set(e.components.map((e) => e.id)), n = f.registry.filter((e) => t.has(e.id)).flatMap((e) => e.styles ?? []);
|
|
625
625
|
n.push(...f.themes.filter((e) => e.name === s.document.theme).flatMap((e) => e.css.map((e) => e.id)));
|
|
626
|
-
for (let e of n) p.has(e) &&
|
|
626
|
+
for (let e of n) p.has(e) && _.has(e) || u("resource-missing", `Used style resource ${e} is required before state restoration.`);
|
|
627
627
|
}
|
|
628
628
|
} catch (e) {
|
|
629
629
|
u("metadata", e instanceof Error ? e.message : String(e));
|
|
@@ -631,21 +631,21 @@ function J(o, s) {
|
|
|
631
631
|
return l;
|
|
632
632
|
}
|
|
633
633
|
// src/shareable.ts
|
|
634
|
-
var
|
|
635
|
-
function
|
|
634
|
+
var q = "reactive-md-html/v1", J = "reactive-md-html/v2", he = /^[A-Za-z][A-Za-z0-9_-]*$/, ge = /^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/, _e = /^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/, ve = /[\u0000-\u001f\u007f-\u009f]/, Y = 64, ye = 41943040, be = 4096;
|
|
635
|
+
function X(e, t = !1) {
|
|
636
636
|
let n = e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
637
637
|
return t && (n = n.replace(/"/g, """).replace(/'/g, "'")), n;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function xe(e) {
|
|
640
640
|
return e.replace(/<\/style/gi, "<\\/style");
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function Se(e) {
|
|
643
643
|
return e.replace(/<\/script/gi, "<\\/script").replace(/<!--/g, "<\\!--");
|
|
644
644
|
}
|
|
645
|
-
function
|
|
646
|
-
return
|
|
645
|
+
function Z(e) {
|
|
646
|
+
return X(e, !0);
|
|
647
647
|
}
|
|
648
|
-
function
|
|
648
|
+
function Q(e) {
|
|
649
649
|
let t = JSON.stringify(e);
|
|
650
650
|
if (typeof t != "string") throw TypeError("Cannot serialize a non-JSON value for an inline script.");
|
|
651
651
|
return t.replace(/[<>&\u2028\u2029]/g, (e) => {
|
|
@@ -658,87 +658,57 @@ function Te(e) {
|
|
|
658
658
|
}
|
|
659
659
|
});
|
|
660
660
|
}
|
|
661
|
-
function
|
|
661
|
+
function $(e) {
|
|
662
662
|
return Array.isArray(e) ? e.slice() : e;
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function Ce(e) {
|
|
665
665
|
try {
|
|
666
|
-
return
|
|
666
|
+
return V(e);
|
|
667
667
|
} catch (e) {
|
|
668
668
|
throw TypeError(`createShareableHtml received invalid compileOptions: ${e instanceof Error ? e.message : String(e)}`);
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
function
|
|
672
|
-
let t =
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
if (i.tagName.toLowerCase() === "iframe") {
|
|
687
|
-
let e = i.attrs.filter((e) => {
|
|
688
|
-
let t = e.name.toLowerCase();
|
|
689
|
-
return t !== "srcdoc" && t !== "sandbox";
|
|
690
|
-
});
|
|
691
|
-
e.push({
|
|
692
|
-
name: "srcdoc",
|
|
693
|
-
value: t
|
|
694
|
-
}), e.push({
|
|
695
|
-
name: "sandbox",
|
|
696
|
-
value: n
|
|
697
|
-
}), i.attrs = e, r = !0;
|
|
671
|
+
function we(e, t) {
|
|
672
|
+
let n = t.enableExtendedHtml ? "frame-src about: data: blob:" : "frame-src 'none'", r = e ? "script-src 'unsafe-inline'" + (t.enableJavaScript ? " 'wasm-unsafe-eval'" : "") : "script-src 'none'", i = e && t.enableJavaScript ? "worker-src blob:" : "worker-src 'none'";
|
|
673
|
+
return `default-src 'none'; img-src data:; style-src 'unsafe-inline'; ${r}; font-src data:; ${e ? "connect-src 'none'; media-src 'none'; " : ""}object-src 'none'; ${n}; ${i}; base-uri 'none'; form-action 'none'`;
|
|
674
|
+
}
|
|
675
|
+
function Te(e, t) {
|
|
676
|
+
if (t.enableCss && t.enableExtendedHtml || !/data-(?:rmd-(?:snapshot|author)-css|extended-html)/i.test(e)) return;
|
|
677
|
+
let n = [...p(e).childNodes];
|
|
678
|
+
for (; n.length;) {
|
|
679
|
+
let e = n.pop();
|
|
680
|
+
if (f.isElementNode(e)) {
|
|
681
|
+
for (let { name: n, value: r } of e.attrs) {
|
|
682
|
+
if (!t.enableCss && (n === "data-rmd-snapshot-css" || e.tagName === "style" && n === "data-rmd-author-css")) throw TypeError("Render staticMarkup with author CSS disabled before exporting with enableCss: false.");
|
|
683
|
+
if (!t.enableExtendedHtml && n === "data-extended-html" && (r === "direct" || r === "sandbox")) throw TypeError("Render staticMarkup with Extended HTML disabled before exporting with enableExtendedHtml: false.");
|
|
684
|
+
}
|
|
685
|
+
for (let t of e.childNodes) n.push(t);
|
|
698
686
|
}
|
|
699
|
-
Oe(i, t, n) && (r = !0);
|
|
700
687
|
}
|
|
701
|
-
return r;
|
|
702
688
|
}
|
|
703
|
-
function
|
|
704
|
-
let t = "";
|
|
705
|
-
for (let n of e.childNodes) t += ee(n, { scriptingEnabled: !1 });
|
|
706
|
-
return t;
|
|
707
|
-
}
|
|
708
|
-
function Ae(e, t, n) {
|
|
709
|
-
try {
|
|
710
|
-
let r = p(e, { scriptingEnabled: !1 });
|
|
711
|
-
if ($(r), Oe(r, t, n)) return ke(r);
|
|
712
|
-
} catch {}
|
|
713
|
-
return `<div class="reactive-md-native-document"><iframe class="reactive-md-native-frame" title="Reactive MD document" sandbox="${Z(n, !0)}" style="display:block;width:100%;min-height:60vh;border:0;background:#fff" srcdoc="${Z(t, !0)}"></iframe></div>`;
|
|
714
|
-
}
|
|
715
|
-
function je(e, t) {
|
|
716
|
-
let n = t?.enableExtendedHtml === !0, r = t ? `frame-src about:${n ? " data: blob: http: https:" : ""}` : "frame-src 'none'", i = n ? "base-uri 'self' http: https:" : "base-uri 'none'", a = n ? "form-action http: https:" : "form-action 'none'";
|
|
717
|
-
return e ? `default-src 'none'; img-src data:; style-src 'unsafe-inline'; script-src 'unsafe-inline'; font-src data:; connect-src 'none'; media-src 'none'; object-src 'none'; ${r}; ${i}; ${a}` : `default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:; object-src 'none'; ${r}; ${i}; ${a}`;
|
|
718
|
-
}
|
|
719
|
-
function Me(e) {
|
|
689
|
+
function Ee(e) {
|
|
720
690
|
if (e === void 0) return;
|
|
721
691
|
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("images must be an object mapping relative URLs to data: image URLs.");
|
|
722
692
|
let t = Object.entries(e);
|
|
723
|
-
if (t.length >
|
|
693
|
+
if (t.length > Y) throw RangeError(`images cannot contain more than ${Y} entries.`);
|
|
724
694
|
let n = 0;
|
|
725
695
|
for (let [e, r] of t) {
|
|
726
|
-
if (!e || e.length >
|
|
727
|
-
if (typeof r != "string" || !
|
|
728
|
-
if (n += r.length, n >
|
|
696
|
+
if (!e || e.length > be || ve.test(e) || e === "__proto__") throw TypeError("Every image key must be a bounded, control-free URL.");
|
|
697
|
+
if (typeof r != "string" || !_e.test(r)) throw TypeError(`The image map for "${e}" must contain a base64 PNG, JPEG, GIF or WebP data URL.`);
|
|
698
|
+
if (n += r.length, n > ye) throw RangeError("The embedded image map exceeds the 40 MiB budget.");
|
|
729
699
|
}
|
|
730
700
|
return Object.fromEntries(t);
|
|
731
701
|
}
|
|
732
|
-
function
|
|
733
|
-
let n =
|
|
702
|
+
function De(e, t) {
|
|
703
|
+
let n = z(e, t);
|
|
734
704
|
if (!n.ok) return n;
|
|
735
705
|
let r = {};
|
|
736
706
|
for (let [t, i] of Object.entries(e.bindings)) r[t] = Object.hasOwn(n.state, t) ? {
|
|
737
707
|
...i,
|
|
738
|
-
initial:
|
|
708
|
+
initial: $(n.state[t])
|
|
739
709
|
} : i;
|
|
740
710
|
let i = { ...e.initialState };
|
|
741
|
-
for (let [e, t] of Object.entries(n.state)) i[e] =
|
|
711
|
+
for (let [e, t] of Object.entries(n.state)) i[e] = $(t);
|
|
742
712
|
return {
|
|
743
713
|
ok: !0,
|
|
744
714
|
baseline: {
|
|
@@ -751,96 +721,91 @@ function Ne(e, t) {
|
|
|
751
721
|
}
|
|
752
722
|
};
|
|
753
723
|
}
|
|
754
|
-
var
|
|
755
|
-
function
|
|
724
|
+
var Oe = "\n:root { color-scheme: light; background: #f5f7fb; }\nhtml, body { margin: 0; }\nbody.reactive-md-export {\n min-height: 100vh;\n padding: clamp(16px, 4vw, 48px);\n background: #f5f7fb;\n color: #17233d;\n font-family: system-ui, -apple-system, \"Segoe UI\", sans-serif;\n}\n.reactive-md-export-root { max-width: 840px; margin: 0 auto; }\n@media print {\n :root, html, body.reactive-md-export { background: #fff !important; }\n body.reactive-md-export { min-height: 0; padding: 0 !important; }\n .reactive-md-export-root { max-width: none !important; margin: 0 !important; }\n}\n";
|
|
725
|
+
function ke(e) {
|
|
756
726
|
let t = e.targetId ?? "reactive-md-document";
|
|
757
|
-
if (!
|
|
727
|
+
if (!he.test(t)) throw TypeError("targetId must start with a letter and contain only letters, digits, underscores or hyphens.");
|
|
758
728
|
let n = e.mode === "static" ? "static" : "interactive";
|
|
759
729
|
if (!e.staticMarkup.trim()) throw TypeError("createShareableHtml requires rendered document markup.");
|
|
760
730
|
if (!e.css.trim()) throw TypeError("createShareableHtml requires the document stylesheet.");
|
|
761
|
-
if (e.state.sourceDigest !==
|
|
731
|
+
if (e.state.sourceDigest !== _(e.source)) throw Error("The state file does not belong to the exported source.");
|
|
762
732
|
if (n === "interactive" && !e.runtimeScript?.trim()) throw TypeError("Interactive HTML requires the standalone runtime script.");
|
|
763
|
-
let r =
|
|
764
|
-
if (i.push(...
|
|
733
|
+
let r = Ce(e.compileOptions), i = ne(e.extensions, r?.config);
|
|
734
|
+
if (i.push(...K(e.restoration, {
|
|
765
735
|
config: r?.config,
|
|
766
736
|
source: e.source,
|
|
767
737
|
resources: e.resources
|
|
768
738
|
})), i.length) throw TypeError(i.map((e) => e.message).join(" "));
|
|
769
|
-
let a =
|
|
739
|
+
let a = g(r);
|
|
770
740
|
if (!a.ok) throw TypeError(`createShareableHtml received invalid compileOptions: ${a.message}`);
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
741
|
+
Te(e.staticMarkup, a.html);
|
|
742
|
+
let o = e.documentId === void 0 ? void 0 : te(e.documentId);
|
|
743
|
+
if (e.documentId !== void 0 && o === void 0) throw TypeError("createShareableHtml received an invalid documentId.");
|
|
744
|
+
let s;
|
|
774
745
|
if (e.randomSeed !== void 0) {
|
|
775
746
|
if (!Number.isInteger(e.randomSeed) || e.randomSeed < 0 || e.randomSeed > 4294967295) throw TypeError("createShareableHtml received an invalid randomSeed; expected a 32-bit unsigned integer.");
|
|
776
|
-
|
|
747
|
+
s = e.randomSeed;
|
|
777
748
|
}
|
|
778
|
-
let
|
|
749
|
+
let c;
|
|
779
750
|
if (e.componentState !== void 0) {
|
|
780
|
-
let t =
|
|
751
|
+
let t = ee(e.componentState);
|
|
781
752
|
if (!t.ok || t.diagnostics.length > 0) {
|
|
782
753
|
let e = t.diagnostics.map((e) => e.message).join(" ");
|
|
783
754
|
throw TypeError(`createShareableHtml received an invalid component state${e ? `: ${e}` : "."}`);
|
|
784
755
|
}
|
|
785
|
-
|
|
756
|
+
c = t.document;
|
|
786
757
|
}
|
|
787
|
-
let u = e.
|
|
788
|
-
if (o && (n === "static" || !a.html.enableJavaScript)) {
|
|
789
|
-
let t = {
|
|
790
|
-
enableCss: a.html.enableCss,
|
|
791
|
-
enableJavaScript: !1,
|
|
792
|
-
enableExtendedHtml: a.html.enableExtendedHtml
|
|
793
|
-
}, n = h(e.source, t, a.maxSyntaxNodes);
|
|
794
|
-
if (!n.markup) throw Error("The native HTML document could not be regenerated without author JavaScript.");
|
|
795
|
-
u = Ae(e.staticMarkup, n.markup, f(t));
|
|
796
|
-
}
|
|
797
|
-
let d = e.locale === "zh" ? "zh" : "en", p = d === "zh" ? "zh-CN" : "en", m = e.colorScheme === "light" || e.colorScheme === "dark" ? e.colorScheme : "auto", ee = e.assets === "omit" ? "omit" : "inline", g = e.generator ?? {
|
|
758
|
+
let l = e.locale === "zh" ? "zh" : "en", u = l === "zh" ? "zh-CN" : "en", d = e.colorScheme === "light" || e.colorScheme === "dark" ? e.colorScheme : "auto", f = e.assets === "omit" ? "omit" : "inline", p = e.generator ?? {
|
|
798
759
|
name: "reactive-md",
|
|
799
760
|
version: "unknown"
|
|
800
|
-
},
|
|
761
|
+
}, m = Ee(e.images), h = Number.isSafeInteger(e.imageCount) && (e.imageCount ?? 0) > 0 ? String(e.imageCount) : String(Object.keys(m ?? {}).length), v = n === "interactive", y = {
|
|
801
762
|
version: e.restoration ? 2 : 1,
|
|
763
|
+
sourceSemantics: "mixed-rmd-v1",
|
|
802
764
|
target: t,
|
|
803
765
|
source: e.source,
|
|
804
766
|
state: e.state,
|
|
805
|
-
locale:
|
|
806
|
-
colorScheme:
|
|
767
|
+
locale: l,
|
|
768
|
+
colorScheme: d,
|
|
807
769
|
hydrate: !0,
|
|
808
|
-
|
|
770
|
+
compileOptions: {
|
|
771
|
+
...r,
|
|
772
|
+
...a.html
|
|
773
|
+
},
|
|
809
774
|
...e.extensions === void 0 ? {} : { extensions: e.extensions },
|
|
810
775
|
...e.restoration === void 0 ? {} : {
|
|
811
776
|
restoration: e.restoration,
|
|
812
777
|
resources: e.resources ?? []
|
|
813
778
|
},
|
|
814
|
-
...
|
|
815
|
-
...
|
|
816
|
-
...
|
|
817
|
-
...
|
|
818
|
-
},
|
|
819
|
-
<script>${
|
|
779
|
+
...m ? { images: m } : {},
|
|
780
|
+
...o === void 0 ? {} : { documentId: o },
|
|
781
|
+
...s === void 0 ? {} : { randomSeed: s },
|
|
782
|
+
...c === void 0 ? {} : { componentState: c }
|
|
783
|
+
}, b = we(v, a.html), x = v ? `<script type="application/reactive-md+json" data-reactive-md-auto>${Q(y)}<\/script>
|
|
784
|
+
<script>${Se(e.runtimeScript)}<\/script>` : "", S = e.notices?.trim() ? `<template id="reactive-md-notices"><pre>${X(e.notices)}</pre></template>` : "", C = !v && e.extensions ? `<template id="reactive-md-extensions">${X(JSON.stringify(e.extensions))}</template>` : "";
|
|
820
785
|
return `<!doctype html>
|
|
821
|
-
<html lang="${
|
|
786
|
+
<html lang="${X(ge.test(u) ? u : "en", !0)}">
|
|
822
787
|
<head>
|
|
823
788
|
<meta charset="utf-8">
|
|
824
789
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
825
790
|
<meta name="referrer" content="no-referrer">
|
|
826
|
-
<meta http-equiv="Content-Security-Policy" content="${
|
|
827
|
-
<meta name="generator" content="${
|
|
828
|
-
<meta name="reactive-md-html-format" content="${e.restoration ?
|
|
829
|
-
<meta name="reactive-md-syntax" content="${
|
|
791
|
+
<meta http-equiv="Content-Security-Policy" content="${Z(b)}">
|
|
792
|
+
<meta name="generator" content="${Z(`${p.name} ${p.version}`)}">
|
|
793
|
+
<meta name="reactive-md-html-format" content="${e.restoration ? J : q}">
|
|
794
|
+
<meta name="reactive-md-syntax" content="${Z(e.state.syntax)}">
|
|
830
795
|
<meta name="reactive-md-output" content="${n}">
|
|
831
|
-
<meta name="reactive-md-state" content="${
|
|
832
|
-
<meta name="reactive-md-images" content="${
|
|
833
|
-
<meta name="reactive-md-image-count" content="${
|
|
834
|
-
<title>${
|
|
835
|
-
<style>${
|
|
796
|
+
<meta name="reactive-md-state" content="${Z(e.state.sourceDigest)}">
|
|
797
|
+
<meta name="reactive-md-images" content="${f}">
|
|
798
|
+
<meta name="reactive-md-image-count" content="${h}">
|
|
799
|
+
<title>${X(e.title || "Reactive MD document")}</title>
|
|
800
|
+
<style>${xe(e.css)}${Oe}</style>
|
|
836
801
|
</head>
|
|
837
802
|
<body class="reactive-md-export">
|
|
838
|
-
<div id="${t}" class="reactive-md-export-root">${
|
|
803
|
+
<div id="${t}" class="reactive-md-export-root">${e.staticMarkup}</div>
|
|
804
|
+
${x}
|
|
839
805
|
${C}
|
|
840
|
-
${
|
|
841
|
-
${w}
|
|
806
|
+
${S}
|
|
842
807
|
</body>
|
|
843
808
|
</html>
|
|
844
809
|
`;
|
|
845
810
|
}
|
|
846
|
-
export {
|
|
811
|
+
export { F as _, Q as a, pe as c, V as d, b as f, de as g, ue as h, De as i, H as l, P as m, J as n, me as o, B as p, ke as r, U as s, q as t, K as u, z as v, fe as y };
|