reactive-md 0.9.1 → 0.9.2
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 +333 -319
- package/CHANGELOG.md +334 -320
- package/CONTRIBUTING-ch.md +22 -22
- package/CONTRIBUTING.md +22 -22
- package/README-ch.md +431 -431
- package/README-en.md +431 -431
- package/README.md +429 -429
- package/SECURITY-ch.md +83 -83
- package/SECURITY.md +83 -83
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +263 -263
- package/cli/assets.mjs +395 -395
- package/cli/build.mjs +445 -445
- package/cli/check.mjs +444 -444
- package/cli/document.mjs +130 -130
- package/cli/errors.mjs +61 -61
- package/cli/fs-utils.mjs +133 -133
- package/cli/glob.mjs +203 -203
- package/cli/help.mjs +323 -323
- package/cli/init.mjs +1577 -1577
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +65 -65
- package/cli/migrate.mjs +368 -368
- package/cli/package-loader.mjs +41 -41
- package/cli/package.mjs +211 -211
- package/dist-library/{LocalDocumentView-sthUP0ct.js → LocalDocumentView-BuqgJZEY.js} +11 -11
- package/dist-library/{LocalDocumentViewCore-GiWV3bey.js → LocalDocumentViewCore-DXE0I0Qc.js} +210 -209
- package/dist-library/{LocalReactiveDocumentCore-ZjQSGyHE.js → LocalReactiveDocumentCore-CWBe4Mm5.js} +8 -8
- package/dist-library/{authoring-Dsune4Hy.js → authoring-Ci_KzJ0q.js} +53 -53
- package/dist-library/{compile-wUv8KEge.js → compile-Dx6Uw3D9.js} +11 -11
- package/dist-library/{compiler-core-As_m-MNm.js → compiler-core-DDDdvuLy.js} +883 -818
- package/dist-library/compiler-dxLPB9Ym.js +86 -0
- package/dist-library/{component-state-C52ZFJGl.js → component-state-BRwvTV0d.js} +15 -14
- package/dist-library/component-state-CwKX_SN5.js +763 -0
- package/dist-library/{config-BadfhjdP.js → config-DXLvctiZ.js} +68 -66
- package/dist-library/config-validation-D3D7Dy2J.js +586 -0
- package/dist-library/{controls-CcT6n7k_.js → controls-DoZyLCrV.js} +3 -3
- package/dist-library/{coordinate-CWS9p5q_.js → coordinate-B1VFK9fd.js} +2 -2
- package/dist-library/{data-table-Bgccxd7h.js → data-table-8-3F15Jf.js} +3 -3
- package/dist-library/{default-components-BwQf0oP-.js → default-components-s21NevON.js} +29 -28
- package/dist-library/{display-B-VhqVND.js → display-B_uutKkN.js} +1 -1
- package/dist-library/{config-validation-F47AcE6o.js → document-theme-C8J6UyNO.js} +193 -731
- package/dist-library/{export-BqVmTXm8.js → export-CIAIPBov.js} +35 -34
- package/dist-library/{gallery-CY6mTx8i.js → gallery-Dv1rOvL0.js} +1 -1
- package/dist-library/{html-CNT4KD-2.js → html-Cr4CBwAH.js} +42 -41
- package/dist-library/identity-BUx0Q_-d.js +40 -0
- package/dist-library/{incremental-Dv0FSp_U.js → incremental-9nx92u9c.js} +12 -10
- package/dist-library/{layout-C0YlEPGr.js → layout-BBB2VF0S.js} +1 -1
- package/dist-library/{mount-preset-KxvtKgJb.js → mount-preset-DMZ5wd3t.js} +3 -3
- package/dist-library/observability-4KqXhIEU.js +421 -0
- package/dist-library/observability-core-Bcu7vpnl.js +24 -0
- package/dist-library/{options-1aDLK7JY.js → options-BBp9IcHm.js} +4 -4
- package/dist-library/{package-core-WFK1RhAZ.js → package-core-K5xesGqy.js} +30 -29
- package/dist-library/{parser-standard-Yuf3A_VI.js → parser-standard-CBA1-hdG.js} +352 -352
- package/dist-library/{plugin-packs-B1XPWcFs.js → plugin-packs-Bh1HhLym.js} +3 -2
- package/dist-library/preset-core-DeZPA8IE.js +1298 -0
- package/dist-library/react-0DCh-Mar.js +7 -0
- package/dist-library/reactive-md-authoring.js +19 -19
- package/dist-library/reactive-md-build.js +48 -10
- package/dist-library/reactive-md-compiler-standard.js +6 -6
- package/dist-library/reactive-md-compiler.js +3 -3
- package/dist-library/reactive-md-default-packs.js +3 -2
- package/dist-library/reactive-md-default-preset.js +3 -2
- package/dist-library/reactive-md-export.js +4 -4
- package/dist-library/reactive-md-minimal-preset.js +2 -2
- package/dist-library/reactive-md-minimal-react-preset.js +3 -3
- package/dist-library/reactive-md-observability.js +4 -0
- package/dist-library/reactive-md-plugin-chart.js +3 -3
- package/dist-library/reactive-md-plugin-data.js +5 -5
- package/dist-library/reactive-md-plugin-diagram.js +4 -4
- package/dist-library/reactive-md-plugin-forms.js +4 -4
- package/dist-library/reactive-md-plugin-gallery.js +3 -3
- package/dist-library/reactive-md-plugin-navigation.js +3 -3
- package/dist-library/reactive-md-plugin-network.js +4 -3
- package/dist-library/reactive-md-plugin-plot.js +4 -4
- package/dist-library/reactive-md-print.css +304 -304
- 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 +11 -11
- package/dist-library/reactive-md-react.js +11 -11
- package/dist-library/reactive-md-runtime-browser.js +2 -1
- package/dist-library/reactive-md-runtime.js +4 -3
- package/dist-library/reactive-md-sdk.js +8 -7
- 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 +5 -5
- package/dist-library/reactive-md.js +556 -367
- package/dist-library/{registry-B9NGct4d.js → registry-D6OGkOcX.js} +3 -3
- package/dist-library/{registry-core-Bbad9Bm2.js → registry-core-C9xOunaw.js} +1 -1
- package/dist-library/{resources-D2GDQS0p.js → resources-B0x_w3s9.js} +71 -46
- package/dist-library/{runtime-B2fxeveq.js → runtime-BDnnimPA.js} +17 -16
- package/dist-library/{runtime-kcA7bG7G.js → runtime-BpQdZmFI.js} +311 -305
- package/dist-library/{schema-BufhKUSM.js → schema-BryM_VRW.js} +14 -14
- package/dist-library/{sdk-core-BoJT1SIt.js → sdk-core-ChslheKs.js} +33 -32
- package/dist-library/{session-core-nmJHuR9c.js → session-core-dxQCJBNa.js} +15 -14
- package/dist-library/{shareable-DpbE-59H.js → shareable-B8xMoGEa.js} +179 -176
- package/dist-library/types/build/diagnostics.d.ts +1 -1
- package/dist-library/types/local/index.d.ts +6 -0
- package/dist-library/types/local/observability-codes.d.ts +2 -0
- package/dist-library/types/local/observability-core.d.ts +25 -0
- package/dist-library/types/local/observability-messages.d.ts +6 -0
- package/dist-library/types/local/observability.d.ts +43 -0
- package/dist-library/types/local/parsing/parser-internals.d.ts +2 -1
- package/dist-library/types/local/transport/worker.d.ts +52 -1
- package/dist-library/types/local/types.d.ts +8 -0
- package/dist-library/types/observability.d.ts +7 -0
- package/dist-library/{types-BeNtPqdY.js → types-Ib5kSScP.js} +1 -1
- package/dist-library/types-daDo2c_w.js +3 -0
- package/dist-library/{validation-BEBA_HvS.js → validation-B3RI0xOk.js} +251 -249
- package/dist-library/version-DAxuGOG2.js +147 -0
- package/dist-library/{visual-frame-CyV1FXzs.js → visual-frame-_rcd5HUv.js} +1 -1
- package/dist-library/{visuals-BZbZYA7w.js → visuals-DkDhNdEZ.js} +17 -17
- package/dist-standalone/reactive-md-standalone.js +118 -118
- package/docs/README-ch.md +101 -95
- package/docs/README.md +101 -95
- package/docs/compatibility/api-stability-ch.md +25 -0
- package/docs/compatibility/api-stability-en.md +25 -0
- package/docs/compatibility/compatibility-ch.md +146 -129
- package/docs/compatibility/compatibility-en.md +146 -129
- package/docs/compatibility/compatibility-manifest.schema.json +161 -0
- package/docs/compatibility/deprecation-ch.md +21 -0
- package/docs/compatibility/deprecation-en.md +21 -0
- package/docs/compatibility/source-versioning-ch.md +162 -162
- package/docs/compatibility/source-versioning-en.md +162 -162
- package/docs/compatibility/support-matrix-ch.md +108 -0
- package/docs/compatibility/support-matrix-en.md +108 -0
- package/docs/development/component-development-ch.md +66 -66
- package/docs/development/component-development-en.md +66 -66
- package/docs/development/component-development-reference-ch.md +253 -253
- package/docs/development/component-development-reference-en.md +238 -238
- package/docs/development/component-protocol-ch.md +748 -748
- package/docs/development/component-protocol-en.md +750 -750
- package/docs/development/extension-tutorial-ch.md +308 -308
- package/docs/development/extension-tutorial-en.md +308 -308
- package/docs/development/performance-overview-ch.md +422 -422
- package/docs/development/performance-overview-en.md +422 -422
- package/docs/guides/local-guide-ch.md +532 -532
- package/docs/guides/local-guide-en.md +532 -532
- package/docs/integration/author-tools-ch.md +64 -64
- package/docs/integration/author-tools-en.md +64 -64
- package/docs/integration/compiler-ch.md +49 -49
- package/docs/integration/compiler-en.md +36 -36
- package/docs/integration/directory-discovery-en.md +1 -1
- package/docs/integration/editor-ch.md +295 -295
- package/docs/integration/editor-en.md +303 -303
- package/docs/integration/extension-sdk-ch.md +394 -394
- package/docs/integration/extension-sdk-en.md +379 -379
- package/docs/integration/local-integration-ch.md +646 -646
- package/docs/integration/local-integration-en.md +662 -662
- package/docs/integration/shareable-export-ch.md +307 -307
- package/docs/integration/shareable-export-en.md +309 -309
- package/docs/reference/diagnostics-counting-ch.md +104 -104
- package/docs/reference/diagnostics-counting-en.md +104 -104
- package/docs/reference/html-compatibility-ch.md +93 -93
- package/docs/reference/html-compatibility-en.md +95 -95
- package/docs/reference/local-interaction-syntax-ch.md +724 -724
- package/docs/reference/local-interaction-syntax-en.md +722 -722
- package/docs/reference/public-api-ch.md +33 -4
- package/docs/reference/public-api-en.md +33 -4
- package/docs/reference/theme-protocol-ch.md +198 -198
- package/docs/reference/theme-protocol-en.md +217 -217
- package/docs/releases/release-0.4.0-ch.md +91 -91
- package/docs/releases/release-0.4.0-en.md +91 -91
- package/docs/releases/release-0.4.1-ch.md +25 -25
- package/docs/releases/release-0.4.1-en.md +25 -25
- package/docs/releases/release-0.5.0-ch.md +43 -43
- package/docs/releases/release-0.5.0-en.md +43 -43
- package/docs/releases/release-0.5.1-ch.md +41 -41
- package/docs/releases/release-0.5.1-en.md +41 -41
- package/docs/releases/release-0.5.2-ch.md +37 -37
- package/docs/releases/release-0.5.2-en.md +37 -37
- package/docs/releases/release-0.5.3-ch.md +26 -26
- package/docs/releases/release-0.5.3-en.md +26 -26
- package/docs/releases/release-0.6.0-ch.md +59 -59
- package/docs/releases/release-0.6.0-en.md +59 -59
- package/docs/releases/release-0.6.1-ch.md +29 -29
- package/docs/releases/release-0.6.1-en.md +29 -29
- package/docs/releases/release-0.7.0-ch.md +86 -86
- package/docs/releases/release-0.7.0-en.md +86 -86
- package/docs/releases/release-0.9.2-ch.md +33 -0
- package/docs/releases/release-0.9.2-en.md +33 -0
- package/examples/component-package/README-ch.md +101 -101
- package/examples/component-package/README.md +133 -133
- package/examples/conformance/README-ch.md +55 -55
- package/examples/conformance/README.md +55 -55
- package/examples/conformance/component-protocol-1.json +482 -482
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/local-draft-1.json +50 -50
- package/examples/conformance/local-draft-2.json +212 -212
- package/examples/game-2048-package/LICENSE +21 -21
- package/examples/game-2048-package/NOTICES.md +11 -11
- package/examples/game-2048-package/README-ch.md +91 -91
- package/examples/game-2048-package/README.md +98 -98
- package/examples/game-2048-package/package.json +35 -35
- package/examples/game-2048-package/sample/document.reactive.md +17 -17
- package/examples/game-2048-package/scripts/build-export.mjs +44 -44
- package/examples/game-2048-package/scripts/build.mjs +130 -130
- package/examples/game-2048-package/scripts/verify.mjs +180 -180
- package/examples/game-2048-package/src/component.css +161 -161
- package/examples/game-2048-package/src/components.tsx +326 -326
- package/examples/game-2048-package/src/game-engine.ts +228 -228
- package/examples/game-2048-package/src/harness.tsx +34 -34
- package/examples/game-2048-package/src/manifest.ts +85 -85
- package/examples/game-2048-package/src/node-entry.ts +30 -30
- package/examples/game-2048-package/src/sample.ts +4 -4
- package/examples/game-2048-package/tsconfig.json +15 -15
- package/examples/integration/README-ch.md +82 -82
- package/examples/integration/README.md +82 -82
- package/examples/integration/core/index.mjs +32 -32
- package/examples/integration/extension-sdk/README-ch.md +24 -24
- package/examples/integration/extension-sdk/README.md +24 -24
- package/examples/integration/worker/index.html +19 -19
- package/examples/integration/worker/main.js +61 -61
- package/examples/integration/worker/package.json +13 -13
- package/examples/integration/worker/worker.js +3 -3
- package/examples/local/README-ch.md +76 -76
- package/examples/local/README.md +76 -76
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/recipes/invoice-zh.reactive.md +36 -36
- package/examples/local/recipes/invoice.reactive.md +36 -36
- package/examples/local/recipes/workshop-zh.reactive.md +33 -33
- package/examples/local/recipes/workshop.reactive.md +33 -33
- package/examples/local/showcase/README-ch.md +22 -22
- package/examples/local/showcase/README.md +31 -31
- package/examples/local/showcase/explore.reactive.md +102 -102
- package/examples/local/showcase/flow.reactive.md +86 -86
- package/examples/local/showcase/forms.reactive.md +126 -126
- package/examples/local/showcase/functions.reactive.md +119 -119
- package/examples/local/showcase/layout.reactive.md +100 -100
- package/examples/local/showcase/statistics.reactive.md +108 -108
- package/examples/local/showcase/tasks.reactive.md +89 -89
- package/examples/local/showcase/zh/explore.reactive.md +102 -102
- package/examples/local/showcase/zh/flow.reactive.md +86 -86
- package/examples/local/showcase/zh/forms.reactive.md +126 -126
- package/examples/local/showcase/zh/functions.reactive.md +119 -119
- package/examples/local/showcase/zh/layout.reactive.md +100 -100
- package/examples/local/showcase/zh/statistics.reactive.md +108 -108
- package/examples/local/showcase/zh/tasks.reactive.md +89 -89
- package/examples/minimal-extension/README-ch.md +78 -78
- package/examples/minimal-extension/README.md +78 -78
- package/examples/minimal-extension/index.html +15 -15
- package/examples/minimal-extension/package.json +26 -26
- package/examples/minimal-extension/sample/document.reactive.md +10 -10
- package/examples/minimal-extension/scripts/build.mjs +32 -32
- package/examples/minimal-extension/scripts/export.mjs +72 -72
- package/examples/minimal-extension/scripts/test-node.mjs +75 -75
- package/examples/minimal-extension/src/extension.tsx +90 -90
- package/examples/minimal-extension/src/preview.tsx +12 -12
- package/examples/minimal-extension/src/source.ts +4 -4
- package/examples/minimal-extension/tsconfig.json +14 -14
- package/examples/sci-fi-theme/README-ch.md +133 -133
- package/examples/sci-fi-theme/README.md +148 -148
- package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -454
- package/examples/sci-fi-theme/demo/demo.css +638 -638
- package/examples/sci-fi-theme/demo/document.reactive.md +206 -206
- package/examples/sci-fi-theme/demo/index.html +13 -13
- package/examples/sci-fi-theme/demo/main.tsx +215 -215
- package/examples/sci-fi-theme/docs/design-system-ch.md +245 -245
- package/examples/sci-fi-theme/docs/design-system.md +474 -474
- package/examples/sci-fi-theme/package.json +28 -28
- package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -98
- package/examples/sci-fi-theme/src/components.css +2370 -2370
- package/examples/sci-fi-theme/src/index.ts +6 -6
- package/examples/sci-fi-theme/src/notch.css +142 -142
- package/examples/sci-fi-theme/src/sci-fi.css +7 -7
- package/examples/sci-fi-theme/src/theme.ts +39 -39
- package/examples/sci-fi-theme/tsconfig.json +20 -20
- package/examples/sci-fi-theme/vite.config.ts +24 -24
- package/examples/tetris-package/LICENSE +21 -21
- package/examples/tetris-package/NOTICES.md +11 -11
- package/examples/tetris-package/README-ch.md +91 -91
- package/examples/tetris-package/README.md +95 -95
- package/examples/tetris-package/package.json +35 -35
- package/examples/tetris-package/sample/document.reactive.md +16 -16
- package/examples/tetris-package/scripts/build-export.mjs +44 -44
- package/examples/tetris-package/scripts/build.mjs +130 -130
- package/examples/tetris-package/scripts/verify.mjs +173 -173
- package/examples/tetris-package/src/component.css +145 -145
- package/examples/tetris-package/src/components.tsx +334 -334
- package/examples/tetris-package/src/harness.tsx +34 -34
- package/examples/tetris-package/src/manifests.ts +93 -93
- package/examples/tetris-package/src/node-entry.ts +16 -16
- package/examples/tetris-package/src/sample.ts +4 -4
- package/examples/tetris-package/src/tetris-engine.ts +325 -325
- package/examples/tetris-package/tsconfig.json +15 -15
- package/package.json +7 -1
- package/dist-library/compiler-eOfcinZs.js +0 -62
- package/dist-library/component-state-BoLCGee4.js +0 -801
- package/dist-library/preset-core-CKc5YXSM.js +0 -1443
- package/dist-library/react-D5iGiUdL.js +0 -7
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { c as e, m as t, p as n, w as r } from "./version-DAxuGOG2.js";
|
|
2
|
+
import { v as i } from "./document-theme-C8J6UyNO.js";
|
|
3
|
+
import { f as a, l as o, u as s } from "./config-validation-D3D7Dy2J.js";
|
|
4
|
+
import { t as c } from "./types-daDo2c_w.js";
|
|
5
|
+
import { A as l, O as u, P as d } from "./preset-core-DeZPA8IE.js";
|
|
6
|
+
import { l as f, o as p } from "./parser-standard-CBA1-hdG.js";
|
|
7
|
+
import { i as m, s as h } from "./config-DXLvctiZ.js";
|
|
8
|
+
import { r as g } from "./options-BBp9IcHm.js";
|
|
9
|
+
import { u as _ } from "./component-state-CwKX_SN5.js";
|
|
10
|
+
import { n as v } from "./runtime-BpQdZmFI.js";
|
|
11
|
+
import { a as ee, i as y } from "./identity-BUx0Q_-d.js";
|
|
12
|
+
import { i as te, t as b } from "./resources-B0x_w3s9.js";
|
|
10
13
|
// src/local/runtime/state.ts
|
|
11
|
-
var
|
|
14
|
+
var x = "reactive-md-state/v1", S = 1048576, C = /^fnv1a32:[0-9a-f]{8}$/, w = /* @__PURE__ */ new Set([
|
|
12
15
|
"format",
|
|
13
16
|
"syntax",
|
|
14
17
|
"sourceDigest",
|
|
15
18
|
"parameters",
|
|
16
19
|
"generator"
|
|
17
|
-
]),
|
|
18
|
-
function
|
|
20
|
+
]), ne = /* @__PURE__ */ new Set(["name", "version"]), re = new TextEncoder();
|
|
21
|
+
function T(e, t) {
|
|
19
22
|
return {
|
|
20
23
|
code: e,
|
|
21
|
-
message: t.length > 2e3 ? `${
|
|
24
|
+
message: t.length > 2e3 ? `${i(t, r - 1)}…` : t,
|
|
22
25
|
severity: "error",
|
|
23
26
|
range: {
|
|
24
27
|
start: 0,
|
|
@@ -28,13 +31,13 @@ function w(e, t) {
|
|
|
28
31
|
column: 1
|
|
29
32
|
};
|
|
30
33
|
}
|
|
31
|
-
function
|
|
32
|
-
e.length < 100 && e.push(
|
|
34
|
+
function E(e, t, n) {
|
|
35
|
+
e.length < 100 && e.push(T(t, n));
|
|
33
36
|
}
|
|
34
|
-
function
|
|
37
|
+
function D(e) {
|
|
35
38
|
return e instanceof Error ? e.message : String(e);
|
|
36
39
|
}
|
|
37
|
-
function
|
|
40
|
+
function O(e) {
|
|
38
41
|
for (let t = 0; t < e.length; t += 1) {
|
|
39
42
|
let n = e.charCodeAt(t);
|
|
40
43
|
if (n >= 55296 && n <= 56319) {
|
|
@@ -49,8 +52,8 @@ function D(e) {
|
|
|
49
52
|
}
|
|
50
53
|
return !0;
|
|
51
54
|
}
|
|
52
|
-
function
|
|
53
|
-
if (typeof e == "string") return
|
|
55
|
+
function k(e) {
|
|
56
|
+
if (typeof e == "string") return O(e) ? {
|
|
54
57
|
ok: !0,
|
|
55
58
|
value: e
|
|
56
59
|
} : {
|
|
@@ -73,7 +76,7 @@ function O(e) {
|
|
|
73
76
|
for (let r = 0; r < e.length; r += 1) {
|
|
74
77
|
let i = e[r];
|
|
75
78
|
if (n === "string" && typeof i == "string") {
|
|
76
|
-
if (!
|
|
79
|
+
if (!O(i)) return {
|
|
77
80
|
ok: !1,
|
|
78
81
|
message: "contains malformed Unicode."
|
|
79
82
|
};
|
|
@@ -94,30 +97,30 @@ function O(e) {
|
|
|
94
97
|
message: "must be a string, finite number, boolean, null or homogeneous primitive array."
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
|
-
function
|
|
100
|
+
function A(e) {
|
|
98
101
|
if (typeof e != "object" || !e || Array.isArray(e)) return !1;
|
|
99
102
|
let t = Object.getPrototypeOf(e);
|
|
100
103
|
return t === Object.prototype || t === null;
|
|
101
104
|
}
|
|
102
|
-
function
|
|
105
|
+
function j(e) {
|
|
103
106
|
return Object.freeze(e.parameters), e.generator && Object.freeze(e.generator), Object.freeze(e);
|
|
104
107
|
}
|
|
105
|
-
function
|
|
108
|
+
function M(e) {
|
|
106
109
|
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("generator must be an object with string name and version.");
|
|
107
110
|
if (typeof e.name != "string" || typeof e.version != "string") throw TypeError("generator must have string name and version.");
|
|
108
|
-
if (!
|
|
111
|
+
if (!O(e.name) || !O(e.version)) throw TypeError("generator name and version must be well-formed Unicode strings.");
|
|
109
112
|
return Object.freeze({
|
|
110
113
|
name: e.name,
|
|
111
114
|
version: e.version
|
|
112
115
|
});
|
|
113
116
|
}
|
|
114
|
-
function
|
|
115
|
-
return typeof e == "string" ? `"${e.length > 48 ? `${
|
|
117
|
+
function N(e) {
|
|
118
|
+
return typeof e == "string" ? `"${e.length > 48 ? `${i(e, 48)}…` : e}"` : e === null ? "null" : Array.isArray(e) ? "an array" : typeof e;
|
|
116
119
|
}
|
|
117
|
-
function
|
|
118
|
-
return e.length > t ? e.length :
|
|
120
|
+
function P(e, t) {
|
|
121
|
+
return e.length > t ? e.length : re.encode(e).byteLength;
|
|
119
122
|
}
|
|
120
|
-
function
|
|
123
|
+
function ie(e, t) {
|
|
121
124
|
let n;
|
|
122
125
|
try {
|
|
123
126
|
let t = JSON.stringify(e);
|
|
@@ -126,17 +129,17 @@ function ae(e, t) {
|
|
|
126
129
|
} catch {
|
|
127
130
|
return null;
|
|
128
131
|
}
|
|
129
|
-
return
|
|
132
|
+
return P(n, t);
|
|
130
133
|
}
|
|
131
|
-
function
|
|
132
|
-
if (e === void 0) return
|
|
134
|
+
function ae(e) {
|
|
135
|
+
if (e === void 0) return S;
|
|
133
136
|
if (typeof e != "object" || !e) throw TypeError("parseLocalState options must be an object.");
|
|
134
137
|
let { maxLength: t } = e;
|
|
135
|
-
if (t === void 0) return
|
|
138
|
+
if (t === void 0) return S;
|
|
136
139
|
if (typeof t != "number" || !Number.isSafeInteger(t) || t <= 0) throw RangeError("maxLength must be a finite positive integer.");
|
|
137
140
|
return t;
|
|
138
141
|
}
|
|
139
|
-
function
|
|
142
|
+
function F(e, t, n) {
|
|
140
143
|
if (!e || e.syntax !== "local" || typeof e.source != "string") throw TypeError("createLocalStateFile requires a compiled local document.");
|
|
141
144
|
if (!t || typeof t != "object" || Array.isArray(t)) throw TypeError("createLocalStateFile requires a state object.");
|
|
142
145
|
let r = Object.keys(e.bindings).filter((e) => !e.startsWith("@")).sort(), i = new Set(r), a = /* @__PURE__ */ new Map();
|
|
@@ -147,7 +150,7 @@ function P(e, t, n) {
|
|
|
147
150
|
continue;
|
|
148
151
|
}
|
|
149
152
|
if (!i.has(n)) throw Error(`Cannot persist parameter "${n}": it is not a public binding of this document.`);
|
|
150
|
-
let r =
|
|
153
|
+
let r = k(t[n]);
|
|
151
154
|
if (!r.ok) throw TypeError(`Cannot persist parameter "${n}": the value ${r.message}`);
|
|
152
155
|
a.set(n, r.value);
|
|
153
156
|
}
|
|
@@ -157,58 +160,58 @@ function P(e, t, n) {
|
|
|
157
160
|
o[e] = a.get(e);
|
|
158
161
|
}
|
|
159
162
|
let s = {
|
|
160
|
-
format:
|
|
161
|
-
syntax:
|
|
162
|
-
sourceDigest:
|
|
163
|
+
format: x,
|
|
164
|
+
syntax: c,
|
|
165
|
+
sourceDigest: y(e.source),
|
|
163
166
|
parameters: o
|
|
164
167
|
};
|
|
165
|
-
return n !== void 0 && (s.generator =
|
|
168
|
+
return n !== void 0 && (s.generator = M(n)), j(s);
|
|
166
169
|
}
|
|
167
|
-
function
|
|
168
|
-
let n = [], r = (e, t) =>
|
|
170
|
+
function oe(e, t) {
|
|
171
|
+
let n = [], r = (e, t) => E(n, e, t), i = e;
|
|
169
172
|
if (typeof e == "string") {
|
|
170
|
-
if (
|
|
173
|
+
if (P(e, t) > t) return {
|
|
171
174
|
ok: !1,
|
|
172
|
-
diagnostics: [
|
|
175
|
+
diagnostics: [T("local.state.size", `The state payload exceeds the ${t}-byte limit.`)]
|
|
173
176
|
};
|
|
174
|
-
if (!
|
|
177
|
+
if (!O(e)) return {
|
|
175
178
|
ok: !1,
|
|
176
|
-
diagnostics: [
|
|
179
|
+
diagnostics: [T("local.state.utf", "The state payload contains malformed Unicode.")]
|
|
177
180
|
};
|
|
178
181
|
try {
|
|
179
182
|
i = JSON.parse(e);
|
|
180
183
|
} catch (e) {
|
|
181
184
|
return {
|
|
182
185
|
ok: !1,
|
|
183
|
-
diagnostics: [
|
|
186
|
+
diagnostics: [T("local.state.json", `The state payload is not valid JSON: ${D(e)}`)]
|
|
184
187
|
};
|
|
185
188
|
}
|
|
186
189
|
} else {
|
|
187
|
-
let n =
|
|
190
|
+
let n = ie(e, t);
|
|
188
191
|
if (n === null) return {
|
|
189
192
|
ok: !1,
|
|
190
|
-
diagnostics: [
|
|
193
|
+
diagnostics: [T("local.state.shape", "The state payload must be a JSON object.")]
|
|
191
194
|
};
|
|
192
195
|
if (n > t) return {
|
|
193
196
|
ok: !1,
|
|
194
|
-
diagnostics: [
|
|
197
|
+
diagnostics: [T("local.state.size", `The state payload exceeds the ${t}-byte limit.`)]
|
|
195
198
|
};
|
|
196
199
|
}
|
|
197
|
-
if (!
|
|
200
|
+
if (!A(i)) return {
|
|
198
201
|
ok: !1,
|
|
199
|
-
diagnostics: [
|
|
202
|
+
diagnostics: [T("local.state.shape", "The state payload must be a JSON object.")]
|
|
200
203
|
};
|
|
201
204
|
Object.getOwnPropertySymbols(i).length > 0 && r("local.state.shape", "The state payload cannot use symbol keys.");
|
|
202
|
-
for (let e of Object.keys(i))
|
|
205
|
+
for (let e of Object.keys(i)) w.has(e) || r("local.state.key", `Unknown top-level state key "${e}".`);
|
|
203
206
|
let a = i.format;
|
|
204
|
-
a !== "reactive-md-state/v1" && r("local.state.format", `Unsupported state format ${
|
|
207
|
+
a !== "reactive-md-state/v1" && r("local.state.format", `Unsupported state format ${N(a)}; expected "${x}".`);
|
|
205
208
|
let o = i.syntax;
|
|
206
|
-
o !== "local-draft-3" && r("local.state.syntax", `Unsupported state syntax ${
|
|
209
|
+
o !== "local-draft-3" && r("local.state.syntax", `Unsupported state syntax ${N(o)}; expected "${c}".`);
|
|
207
210
|
let s = i.sourceDigest;
|
|
208
|
-
typeof s == "string" &&
|
|
209
|
-
let
|
|
210
|
-
if (!
|
|
211
|
-
else for (let e of Object.keys(
|
|
211
|
+
typeof s == "string" && C.test(s) || r("local.state.digest", "sourceDigest must match \"fnv1a32:\" followed by 8 lowercase hexadecimal digits.");
|
|
212
|
+
let l = {}, u = i.parameters;
|
|
213
|
+
if (!A(u)) r("local.state.parameters", "parameters must be a JSON object of public binding values.");
|
|
214
|
+
else for (let e of Object.keys(u).sort()) {
|
|
212
215
|
if (e === "__proto__") {
|
|
213
216
|
r("local.state.parameter.prototype", "Parameter names cannot be \"__proto__\".");
|
|
214
217
|
continue;
|
|
@@ -217,16 +220,16 @@ function se(e, t) {
|
|
|
217
220
|
r("local.state.parameter.internal", `Internal parameter "${e}" cannot be persisted.`);
|
|
218
221
|
continue;
|
|
219
222
|
}
|
|
220
|
-
let t =
|
|
221
|
-
t.ok ?
|
|
223
|
+
let t = k(u[e]);
|
|
224
|
+
t.ok ? l[e] = t.value : r("local.state.parameter.value", `Parameter "${e}" ${t.message}`);
|
|
222
225
|
}
|
|
223
|
-
let
|
|
226
|
+
let d;
|
|
224
227
|
if (Object.hasOwn(i, "generator")) {
|
|
225
228
|
let e = i.generator;
|
|
226
|
-
if (!
|
|
229
|
+
if (!A(e)) r("local.state.generator", "generator must be an object with string name and version.");
|
|
227
230
|
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.") : !
|
|
231
|
+
for (let t of Object.keys(e)) ne.has(t) || r("local.state.generator", `generator has unknown key "${t}".`);
|
|
232
|
+
typeof e.name != "string" || typeof e.version != "string" ? r("local.state.generator", "generator must have string name and version.") : !O(e.name) || !O(e.version) ? r("local.state.utf", "generator contains malformed Unicode.") : d = Object.freeze({
|
|
230
233
|
name: e.name,
|
|
231
234
|
version: e.version
|
|
232
235
|
});
|
|
@@ -237,35 +240,35 @@ function se(e, t) {
|
|
|
237
240
|
diagnostics: n
|
|
238
241
|
};
|
|
239
242
|
let f = {
|
|
240
|
-
format:
|
|
241
|
-
syntax:
|
|
243
|
+
format: x,
|
|
244
|
+
syntax: c,
|
|
242
245
|
sourceDigest: s,
|
|
243
|
-
parameters:
|
|
246
|
+
parameters: l
|
|
244
247
|
};
|
|
245
|
-
return
|
|
248
|
+
return d && (f.generator = d), {
|
|
246
249
|
ok: !0,
|
|
247
|
-
file:
|
|
250
|
+
file: j(f)
|
|
248
251
|
};
|
|
249
252
|
}
|
|
250
|
-
function
|
|
251
|
-
let n =
|
|
253
|
+
function I(e, t) {
|
|
254
|
+
let n = ae(t);
|
|
252
255
|
try {
|
|
253
|
-
return
|
|
256
|
+
return oe(e, n);
|
|
254
257
|
} catch (e) {
|
|
255
258
|
return {
|
|
256
259
|
ok: !1,
|
|
257
|
-
diagnostics: [
|
|
260
|
+
diagnostics: [T("local.state.invalid", `Cannot read the local state: ${D(e)}`)]
|
|
258
261
|
};
|
|
259
262
|
}
|
|
260
263
|
}
|
|
261
|
-
function
|
|
264
|
+
function se(e) {
|
|
262
265
|
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
263
266
|
for (let r of e) t.set(r.id, r), r.children && n(r.children);
|
|
264
267
|
};
|
|
265
268
|
return n(e.nodes), t;
|
|
266
269
|
}
|
|
267
|
-
function
|
|
268
|
-
let t =
|
|
270
|
+
function ce(e) {
|
|
271
|
+
let t = se(e), n = /* @__PURE__ */ new Map(), r = [];
|
|
269
272
|
for (let [i, a] of Object.entries(e.bindingSlots ?? {})) {
|
|
270
273
|
let e = t.get(i);
|
|
271
274
|
if (!e) continue;
|
|
@@ -309,7 +312,7 @@ function I(e) {
|
|
|
309
312
|
}
|
|
310
313
|
function L(e, t, n) {
|
|
311
314
|
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(
|
|
315
|
+
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(T("local.state.document", `The document has no component for parameter "${a.key}".`)));
|
|
313
316
|
if (r.length) return r;
|
|
314
317
|
r.push(...e.setParameters(i));
|
|
315
318
|
for (let i of t.groups) {
|
|
@@ -328,45 +331,45 @@ function le(e, t) {
|
|
|
328
331
|
return Object.freeze(r);
|
|
329
332
|
}
|
|
330
333
|
function R(e, t, n, r) {
|
|
331
|
-
let i =
|
|
334
|
+
let i = I(t, r);
|
|
332
335
|
if (!i.ok) return i;
|
|
333
336
|
if (!e || e.syntax !== "local" || typeof e.source != "string" || !Array.isArray(e.nodes) || !e.bindings) return {
|
|
334
337
|
ok: !1,
|
|
335
|
-
diagnostics: [
|
|
338
|
+
diagnostics: [T("local.state.document", "resolveLocalState requires a compiled local document.")]
|
|
336
339
|
};
|
|
337
340
|
if (i.file.syntax !== "local-draft-3") return {
|
|
338
341
|
ok: !1,
|
|
339
|
-
diagnostics: [
|
|
342
|
+
diagnostics: [T("local.state.syntax", `This state file uses syntax "${i.file.syntax}", but this build accepts "${c}".`)]
|
|
340
343
|
};
|
|
341
|
-
if (i.file.sourceDigest !==
|
|
344
|
+
if (i.file.sourceDigest !== y(e.source)) return {
|
|
342
345
|
ok: !1,
|
|
343
|
-
diagnostics: [
|
|
346
|
+
diagnostics: [T("local.state.source", "This state file was created for a different document (source digest mismatch).")]
|
|
344
347
|
};
|
|
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) ||
|
|
348
|
+
let a = ce(e), o = new Set(a.plans.map((e) => e.key)), s = [];
|
|
349
|
+
for (let e of Object.keys(i.file.parameters)) o.has(e) || E(s, "local.state.parameter.unknown", `The state contains unknown parameter "${e}" for this document.`);
|
|
350
|
+
for (let e of o) Object.hasOwn(i.file.parameters, e) || E(s, "local.state.parameter.missing", `The state is missing parameter "${e}".`);
|
|
348
351
|
if (s.length) return {
|
|
349
352
|
ok: !1,
|
|
350
353
|
diagnostics: s
|
|
351
354
|
};
|
|
352
|
-
let
|
|
355
|
+
let l;
|
|
353
356
|
try {
|
|
354
|
-
|
|
357
|
+
l = v(e);
|
|
355
358
|
} catch (e) {
|
|
356
359
|
return {
|
|
357
360
|
ok: !1,
|
|
358
|
-
diagnostics: [
|
|
361
|
+
diagnostics: [T("local.state.document", `Cannot validate this document: ${D(e)}`)]
|
|
359
362
|
};
|
|
360
363
|
}
|
|
361
364
|
try {
|
|
362
365
|
if (n) {
|
|
363
|
-
let e = L(
|
|
366
|
+
let e = L(l, a, n);
|
|
364
367
|
if (e.length) return {
|
|
365
368
|
ok: !1,
|
|
366
369
|
diagnostics: e
|
|
367
370
|
};
|
|
368
371
|
}
|
|
369
|
-
let e = L(
|
|
372
|
+
let e = L(l, a, i.file.parameters);
|
|
370
373
|
if (e.length) return {
|
|
371
374
|
ok: !1,
|
|
372
375
|
diagnostics: e
|
|
@@ -375,10 +378,10 @@ function R(e, t, n, r) {
|
|
|
375
378
|
return {
|
|
376
379
|
ok: !0,
|
|
377
380
|
file: i.file,
|
|
378
|
-
state: le(
|
|
381
|
+
state: le(l, t)
|
|
379
382
|
};
|
|
380
383
|
} finally {
|
|
381
|
-
|
|
384
|
+
l.dispose();
|
|
382
385
|
}
|
|
383
386
|
}
|
|
384
387
|
function z(e, t, n) {
|
|
@@ -387,7 +390,7 @@ function z(e, t, n) {
|
|
|
387
390
|
} catch (e) {
|
|
388
391
|
return {
|
|
389
392
|
ok: !1,
|
|
390
|
-
diagnostics: [
|
|
393
|
+
diagnostics: [T("local.state.invalid", `Cannot resolve the local state: ${D(e)}`)]
|
|
391
394
|
};
|
|
392
395
|
}
|
|
393
396
|
}
|
|
@@ -396,21 +399,21 @@ function B(e, t, n) {
|
|
|
396
399
|
try {
|
|
397
400
|
r = R(e.document, t, e.snapshot().state, n);
|
|
398
401
|
} catch (e) {
|
|
399
|
-
return [
|
|
402
|
+
return [T("local.state.invalid", `Cannot apply the local state: ${D(e)}`)];
|
|
400
403
|
}
|
|
401
404
|
if (!r.ok) return r.diagnostics;
|
|
402
|
-
let i =
|
|
405
|
+
let i = ce(e.document);
|
|
403
406
|
try {
|
|
404
407
|
return L(e, i, r.state);
|
|
405
408
|
} catch (e) {
|
|
406
|
-
return [
|
|
409
|
+
return [T("local.state.invalid", `Cannot apply the local state: ${D(e)}`)];
|
|
407
410
|
}
|
|
408
411
|
}
|
|
409
412
|
function ue(e, t) {
|
|
410
|
-
return
|
|
413
|
+
return F(e.document, e.getParameters(), t);
|
|
411
414
|
}
|
|
412
415
|
function de(e, t, n) {
|
|
413
|
-
let r =
|
|
416
|
+
let r = I(t, n);
|
|
414
417
|
return r.ok ? B(e, r.file, n) : r.diagnostics;
|
|
415
418
|
}
|
|
416
419
|
function fe(e) {
|
|
@@ -419,7 +422,7 @@ function fe(e) {
|
|
|
419
422
|
let t = Object.create(null);
|
|
420
423
|
for (let n of Object.keys(e.parameters).sort()) {
|
|
421
424
|
if (n === "__proto__" || n.startsWith("@")) throw TypeError(`Cannot serialize parameter "${n}".`);
|
|
422
|
-
let r =
|
|
425
|
+
let r = k(e.parameters[n]);
|
|
423
426
|
if (!r.ok) throw TypeError(`Cannot serialize parameter "${n}": the value ${r.message}`);
|
|
424
427
|
t[n] = r.value;
|
|
425
428
|
}
|
|
@@ -430,7 +433,7 @@ function fe(e) {
|
|
|
430
433
|
parameters: t
|
|
431
434
|
};
|
|
432
435
|
if (e.generator !== void 0) {
|
|
433
|
-
let t =
|
|
436
|
+
let t = M(e.generator);
|
|
434
437
|
n.generator = {
|
|
435
438
|
name: t.name,
|
|
436
439
|
version: t.version
|
|
@@ -458,9 +461,9 @@ function V(e) {
|
|
|
458
461
|
};
|
|
459
462
|
}
|
|
460
463
|
// src/export/restoration.ts
|
|
461
|
-
var pe =
|
|
464
|
+
var pe = d;
|
|
462
465
|
function H(e) {
|
|
463
|
-
return
|
|
466
|
+
return d(JSON.stringify([
|
|
464
467
|
e.id,
|
|
465
468
|
e.name,
|
|
466
469
|
e.version,
|
|
@@ -469,16 +472,16 @@ function H(e) {
|
|
|
469
472
|
e.css.map(({ id: e, css: t }) => [e, t])
|
|
470
473
|
]));
|
|
471
474
|
}
|
|
472
|
-
function me(
|
|
473
|
-
let
|
|
475
|
+
function me(t, n) {
|
|
476
|
+
let r = h(n), i = o(r);
|
|
474
477
|
return Object.freeze({
|
|
475
478
|
protocol: "reactive-md-bundle/v1",
|
|
476
|
-
sdkVersion:
|
|
477
|
-
configKey:
|
|
478
|
-
scriptDigest:
|
|
479
|
-
assembly:
|
|
480
|
-
seal:
|
|
481
|
-
themes: Object.freeze(
|
|
479
|
+
sdkVersion: e,
|
|
480
|
+
configKey: r.key,
|
|
481
|
+
scriptDigest: d(t),
|
|
482
|
+
assembly: i,
|
|
483
|
+
seal: s(r),
|
|
484
|
+
themes: Object.freeze(r.themes.map((e) => Object.freeze({
|
|
482
485
|
id: e.id,
|
|
483
486
|
name: e.name,
|
|
484
487
|
version: e.version,
|
|
@@ -486,19 +489,19 @@ function me(e, n) {
|
|
|
486
489
|
})))
|
|
487
490
|
});
|
|
488
491
|
}
|
|
489
|
-
function U(
|
|
490
|
-
let
|
|
491
|
-
for (;
|
|
492
|
-
let e =
|
|
493
|
-
(e.type === "component" || e.type === "hostComponent") && e.name &&
|
|
492
|
+
function U(t, n, r, i = []) {
|
|
493
|
+
let a = h(n), s = /* @__PURE__ */ new Set(), c = [...t.nodes];
|
|
494
|
+
for (; c.length;) {
|
|
495
|
+
let e = c.pop();
|
|
496
|
+
(e.type === "component" || e.type === "hostComponent") && e.name && s.add(e.name), e.children && c.push(...e.children);
|
|
494
497
|
}
|
|
495
|
-
let
|
|
498
|
+
let l = a.registry.filter((e) => s.has(e.name)).map((e) => Object.freeze({
|
|
496
499
|
id: e.id,
|
|
497
500
|
name: e.name,
|
|
498
501
|
version: e.version,
|
|
499
502
|
range: e.version,
|
|
500
|
-
digest:
|
|
501
|
-
})).sort((e, t) => e.id.localeCompare(t.id)), f =
|
|
503
|
+
digest: u(e)
|
|
504
|
+
})).sort((e, t) => e.id.localeCompare(t.id)), f = a.themes.filter((e) => e.name === t.theme).map((e) => Object.freeze({
|
|
502
505
|
id: e.id,
|
|
503
506
|
name: e.name,
|
|
504
507
|
version: e.version,
|
|
@@ -506,16 +509,16 @@ function U(e, n, i, o = []) {
|
|
|
506
509
|
}));
|
|
507
510
|
return Object.freeze({
|
|
508
511
|
protocol: "reactive-md-restore/v1",
|
|
509
|
-
sdk: `^${
|
|
510
|
-
configKey:
|
|
511
|
-
sourceDigest:
|
|
512
|
-
target:
|
|
513
|
-
components: Object.freeze(
|
|
512
|
+
sdk: `^${e}`,
|
|
513
|
+
configKey: a.key,
|
|
514
|
+
sourceDigest: d(t.source),
|
|
515
|
+
target: r,
|
|
516
|
+
components: Object.freeze(l),
|
|
514
517
|
themes: Object.freeze(f),
|
|
515
|
-
assembly:
|
|
516
|
-
resources: Object.freeze(
|
|
518
|
+
assembly: o(a),
|
|
519
|
+
resources: Object.freeze(i.map((e) => Object.freeze({
|
|
517
520
|
id: e.id,
|
|
518
|
-
digest:
|
|
521
|
+
digest: d(e.css)
|
|
519
522
|
})))
|
|
520
523
|
});
|
|
521
524
|
}
|
|
@@ -525,9 +528,9 @@ function W(e) {
|
|
|
525
528
|
function G(e) {
|
|
526
529
|
return typeof e == "string" && e.length > 0 && e.length <= 256;
|
|
527
530
|
}
|
|
528
|
-
function K(
|
|
529
|
-
if (
|
|
530
|
-
let
|
|
531
|
+
function K(r, i) {
|
|
532
|
+
if (r === void 0) return [];
|
|
533
|
+
let o = [], s = (e, t) => o.push({
|
|
531
534
|
code: `local.extension.restore-${e}`,
|
|
532
535
|
message: t,
|
|
533
536
|
severity: "error",
|
|
@@ -539,12 +542,12 @@ function K(o, s) {
|
|
|
539
542
|
column: 1
|
|
540
543
|
});
|
|
541
544
|
try {
|
|
542
|
-
if (!W(
|
|
545
|
+
if (!W(r) || l(r) > 262144 || r.protocol !== "reactive-md-restore/v1" || !G(r.sdk) || !G(r.configKey) || !G(r.sourceDigest) || ![
|
|
543
546
|
"static",
|
|
544
547
|
"ssr",
|
|
545
548
|
"offline"
|
|
546
|
-
].includes(
|
|
547
|
-
let
|
|
549
|
+
].includes(r.target) || !Array.isArray(r.components) || r.components.length > 192 || !Array.isArray(r.themes) || r.themes.length > 16 || !Array.isArray(r.resources) || r.resources.length > 128) return s("metadata", "Invalid or oversized restoration requirements."), o;
|
|
550
|
+
let c = /* @__PURE__ */ new Set([
|
|
548
551
|
"protocol",
|
|
549
552
|
"sdk",
|
|
550
553
|
"configKey",
|
|
@@ -555,80 +558,80 @@ function K(o, s) {
|
|
|
555
558
|
"resources",
|
|
556
559
|
"assembly"
|
|
557
560
|
]);
|
|
558
|
-
Object.keys(
|
|
559
|
-
let f =
|
|
560
|
-
|
|
561
|
+
Object.keys(r).some((e) => !c.has(e)) && s("metadata", "Unknown restoration requirement field.");
|
|
562
|
+
let f = i.config === void 0 ? m() : h(i.config);
|
|
563
|
+
t(r.sdk) && n("0.7.0", r.sdk) || s("sdk", `SDK ${e} does not satisfy ${r.sdk}.`), a(f, r.configKey) || s("config", "The installed configuration differs from the exported configuration."), r.assembly !== void 0 && (W(r.assembly) && r.assembly.protocol === "reactive-md-assembly-seal/v1" && G(r.assembly.configKey) && a(f, r.assembly.configKey) || s("assembly", "The exported assembly identity is invalid or belongs to another configuration.")), d(i.source) !== r.sourceDigest && s("source", "The source differs from the exported source. Recompile before restoring state.");
|
|
561
564
|
let p = /* @__PURE__ */ new Set();
|
|
562
|
-
for (let e of
|
|
565
|
+
for (let e of r.components) {
|
|
563
566
|
if (!W(e) || ![
|
|
564
567
|
"id",
|
|
565
568
|
"name",
|
|
566
569
|
"version",
|
|
567
570
|
"range",
|
|
568
571
|
"digest"
|
|
569
|
-
].every((t) => G(e[t])) || !
|
|
570
|
-
|
|
572
|
+
].every((t) => G(e[t])) || !t(e.range) || p.has(e.id)) {
|
|
573
|
+
s("metadata", "Invalid or duplicate component restoration requirement.");
|
|
571
574
|
continue;
|
|
572
575
|
}
|
|
573
576
|
p.add(e.id);
|
|
574
|
-
let
|
|
575
|
-
if (!
|
|
576
|
-
|
|
577
|
+
let i = f.registry.find((t) => t.id === e.id);
|
|
578
|
+
if (!i) {
|
|
579
|
+
s("component-missing", `Required component ${e.id}@${e.version} is not installed.`);
|
|
577
580
|
continue;
|
|
578
581
|
}
|
|
579
|
-
n(
|
|
580
|
-
let
|
|
582
|
+
n(i.version, e.range) || s("version", `Component ${e.id}@${i.version} does not satisfy ${e.range}.`), (i.version !== e.version || i.name !== e.name || u(i) !== e.digest) && s("contract", `Component ${e.id}@${e.version} differs from the installed contract. Recompile and validate state before upgrading.`);
|
|
583
|
+
let a = r.target === "offline" ? [
|
|
581
584
|
"interactive",
|
|
582
585
|
"static",
|
|
583
586
|
"offline"
|
|
584
|
-
] : [
|
|
585
|
-
for (let
|
|
587
|
+
] : [r.target];
|
|
588
|
+
for (let t of a) i.capabilities[t] || s("capability", `Component ${e.id} cannot render ${t}.`);
|
|
586
589
|
}
|
|
587
|
-
if (
|
|
588
|
-
let e = U(
|
|
589
|
-
for (let t of e.components) p.has(t.id) ||
|
|
590
|
+
if (i.document) {
|
|
591
|
+
let e = U(i.document, f, r.target);
|
|
592
|
+
for (let t of e.components) p.has(t.id) || s("component-missing", `Used component ${t.id} is missing from restoration requirements.`);
|
|
590
593
|
}
|
|
591
594
|
p.clear();
|
|
592
|
-
for (let e of
|
|
595
|
+
for (let e of r.themes) {
|
|
593
596
|
if (!W(e) || ![
|
|
594
597
|
"id",
|
|
595
598
|
"name",
|
|
596
599
|
"version",
|
|
597
600
|
"digest"
|
|
598
601
|
].every((t) => G(e[t])) || p.has(e.id)) {
|
|
599
|
-
|
|
602
|
+
s("metadata", "Invalid or duplicate theme restoration requirement.");
|
|
600
603
|
continue;
|
|
601
604
|
}
|
|
602
605
|
p.add(e.id);
|
|
603
606
|
let t = f.themes.find((t) => t.id === e.id);
|
|
604
|
-
t && t.name === e.name && t.version === e.version && H(t) === e.digest ||
|
|
607
|
+
t && t.name === e.name && t.version === e.version && H(t) === e.digest || s("theme", `Required theme ${e.id}@${e.version} does not match the installed theme.`);
|
|
605
608
|
}
|
|
606
|
-
if (
|
|
607
|
-
let e = f.themes.find((e) => e.name ===
|
|
608
|
-
e && !p.has(e.id) &&
|
|
609
|
+
if (i.document) {
|
|
610
|
+
let e = f.themes.find((e) => e.name === i.document.theme);
|
|
611
|
+
e && !p.has(e.id) && s("theme", `Selected theme ${e.id} is missing from restoration requirements.`);
|
|
609
612
|
}
|
|
610
|
-
let g =
|
|
611
|
-
|
|
613
|
+
let g = b(i.resources ?? []);
|
|
614
|
+
o.push(...g.diagnostics);
|
|
612
615
|
let _ = new Map(g.resources.map((e) => [e.id, e.css]));
|
|
613
616
|
p.clear();
|
|
614
|
-
for (let e of
|
|
617
|
+
for (let e of r.resources) {
|
|
615
618
|
if (!W(e) || !G(e.id) || !G(e.digest) || p.has(e.id)) {
|
|
616
|
-
|
|
619
|
+
s("metadata", "Invalid or duplicate style restoration requirement.");
|
|
617
620
|
continue;
|
|
618
621
|
}
|
|
619
622
|
p.add(e.id);
|
|
620
623
|
let t = _.get(e.id);
|
|
621
|
-
t === void 0 ?
|
|
624
|
+
t === void 0 ? s("resource-missing", `Required style resource ${e.id} is missing before state restoration.`) : d(t) !== e.digest && s("resource-digest", `Style resource ${e.id} differs from the exported content.`);
|
|
622
625
|
}
|
|
623
|
-
if (
|
|
624
|
-
let e = U(
|
|
625
|
-
n.push(...f.themes.filter((e) => e.name ===
|
|
626
|
-
for (let e of n) p.has(e) && _.has(e) ||
|
|
626
|
+
if (i.document) {
|
|
627
|
+
let e = U(i.document, f, r.target), t = new Set(e.components.map((e) => e.id)), n = f.registry.filter((e) => t.has(e.id)).flatMap((e) => e.styles ?? []);
|
|
628
|
+
n.push(...f.themes.filter((e) => e.name === i.document.theme).flatMap((e) => e.css.map((e) => e.id)));
|
|
629
|
+
for (let e of n) p.has(e) && _.has(e) || s("resource-missing", `Used style resource ${e} is required before state restoration.`);
|
|
627
630
|
}
|
|
628
631
|
} catch (e) {
|
|
629
|
-
|
|
632
|
+
s("metadata", e instanceof Error ? e.message : String(e));
|
|
630
633
|
}
|
|
631
|
-
return
|
|
634
|
+
return o;
|
|
632
635
|
}
|
|
633
636
|
// src/shareable.ts
|
|
634
637
|
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;
|
|
@@ -728,9 +731,9 @@ function ke(e) {
|
|
|
728
731
|
let n = e.mode === "static" ? "static" : "interactive";
|
|
729
732
|
if (!e.staticMarkup.trim()) throw TypeError("createShareableHtml requires rendered document markup.");
|
|
730
733
|
if (!e.css.trim()) throw TypeError("createShareableHtml requires the document stylesheet.");
|
|
731
|
-
if (e.state.sourceDigest !==
|
|
734
|
+
if (e.state.sourceDigest !== y(e.source)) throw Error("The state file does not belong to the exported source.");
|
|
732
735
|
if (n === "interactive" && !e.runtimeScript?.trim()) throw TypeError("Interactive HTML requires the standalone runtime script.");
|
|
733
|
-
let r = Ce(e.compileOptions), i =
|
|
736
|
+
let r = Ce(e.compileOptions), i = te(e.extensions, r?.config);
|
|
734
737
|
if (i.push(...K(e.restoration, {
|
|
735
738
|
config: r?.config,
|
|
736
739
|
source: e.source,
|
|
@@ -739,7 +742,7 @@ function ke(e) {
|
|
|
739
742
|
let a = g(r);
|
|
740
743
|
if (!a.ok) throw TypeError(`createShareableHtml received invalid compileOptions: ${a.message}`);
|
|
741
744
|
Te(e.staticMarkup, a.html);
|
|
742
|
-
let o = e.documentId === void 0 ? void 0 :
|
|
745
|
+
let o = e.documentId === void 0 ? void 0 : ee(e.documentId);
|
|
743
746
|
if (e.documentId !== void 0 && o === void 0) throw TypeError("createShareableHtml received an invalid documentId.");
|
|
744
747
|
let s;
|
|
745
748
|
if (e.randomSeed !== void 0) {
|
|
@@ -748,7 +751,7 @@ function ke(e) {
|
|
|
748
751
|
}
|
|
749
752
|
let c;
|
|
750
753
|
if (e.componentState !== void 0) {
|
|
751
|
-
let t =
|
|
754
|
+
let t = _(e.componentState);
|
|
752
755
|
if (!t.ok || t.diagnostics.length > 0) {
|
|
753
756
|
let e = t.diagnostics.map((e) => e.message).join(" ");
|
|
754
757
|
throw TypeError(`createShareableHtml received an invalid component state${e ? `: ${e}` : "."}`);
|
|
@@ -758,7 +761,7 @@ function ke(e) {
|
|
|
758
761
|
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 ?? {
|
|
759
762
|
name: "reactive-md",
|
|
760
763
|
version: "unknown"
|
|
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",
|
|
764
|
+
}, m = Ee(e.images), h = Number.isSafeInteger(e.imageCount) && (e.imageCount ?? 0) > 0 ? String(e.imageCount) : String(Object.keys(m ?? {}).length), v = n === "interactive", b = {
|
|
762
765
|
version: e.restoration ? 2 : 1,
|
|
763
766
|
sourceSemantics: "mixed-rmd-v1",
|
|
764
767
|
target: t,
|
|
@@ -780,15 +783,15 @@ function ke(e) {
|
|
|
780
783
|
...o === void 0 ? {} : { documentId: o },
|
|
781
784
|
...s === void 0 ? {} : { randomSeed: s },
|
|
782
785
|
...c === void 0 ? {} : { componentState: c }
|
|
783
|
-
},
|
|
784
|
-
<script>${Se(e.runtimeScript)}<\/script>` : "",
|
|
786
|
+
}, x = we(v, a.html), S = v ? `<script type="application/reactive-md+json" data-reactive-md-auto>${Q(b)}<\/script>
|
|
787
|
+
<script>${Se(e.runtimeScript)}<\/script>` : "", C = e.notices?.trim() ? `<template id="reactive-md-notices"><pre>${X(e.notices)}</pre></template>` : "", w = !v && e.extensions ? `<template id="reactive-md-extensions">${X(JSON.stringify(e.extensions))}</template>` : "";
|
|
785
788
|
return `<!doctype html>
|
|
786
789
|
<html lang="${X(ge.test(u) ? u : "en", !0)}">
|
|
787
790
|
<head>
|
|
788
791
|
<meta charset="utf-8">
|
|
789
792
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
790
793
|
<meta name="referrer" content="no-referrer">
|
|
791
|
-
<meta http-equiv="Content-Security-Policy" content="${Z(
|
|
794
|
+
<meta http-equiv="Content-Security-Policy" content="${Z(x)}">
|
|
792
795
|
<meta name="generator" content="${Z(`${p.name} ${p.version}`)}">
|
|
793
796
|
<meta name="reactive-md-html-format" content="${e.restoration ? J : q}">
|
|
794
797
|
<meta name="reactive-md-syntax" content="${Z(e.state.syntax)}">
|
|
@@ -801,11 +804,11 @@ function ke(e) {
|
|
|
801
804
|
</head>
|
|
802
805
|
<body class="reactive-md-export">
|
|
803
806
|
<div id="${t}" class="reactive-md-export-root">${e.staticMarkup}</div>
|
|
804
|
-
${x}
|
|
805
|
-
${C}
|
|
806
807
|
${S}
|
|
808
|
+
${w}
|
|
809
|
+
${C}
|
|
807
810
|
</body>
|
|
808
811
|
</html>
|
|
809
812
|
`;
|
|
810
813
|
}
|
|
811
|
-
export {
|
|
814
|
+
export { I as _, Q as a, pe as c, V as d, x as f, de as g, ue as h, De as i, H as l, F 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 };
|