reactive-md 0.6.1 → 0.8.0
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 +66 -0
- package/CHANGELOG.md +66 -0
- package/CONTRIBUTING-ch.md +6 -62
- package/CONTRIBUTING.md +5 -63
- package/README-ch.md +232 -67
- package/README-en.md +209 -71
- package/README.md +209 -71
- package/SECURITY-ch.md +3 -1
- package/SECURITY.md +3 -1
- package/THIRD_PARTY_NOTICES.md +1909 -87
- package/cli/args.mjs +33 -1
- package/cli/build.mjs +62 -1
- package/cli/check.mjs +444 -0
- package/cli/help.mjs +181 -3
- package/cli/init.mjs +1577 -0
- package/cli/main.mjs +11 -1
- package/cli/package-loader.mjs +41 -0
- package/dist-library/LocalDocumentView-6trX7xJc.js +97920 -0
- package/dist-library/{authoring-BEVyth5X.js → authoring-BsfSwQRm.js} +237 -209
- package/dist-library/compiler--ea2CKQF.js +61 -0
- package/dist-library/compiler-core-kPiH-gOV.js +11805 -0
- package/dist-library/component-state-Cq2K5gkS.js +490 -0
- package/dist-library/component-state-D_cw_EHe.js +54 -0
- package/dist-library/config-validation-DXTynAw7.js +3005 -0
- package/dist-library/default-components-Z_YMio5P.js +2346 -0
- package/dist-library/identity-MYJXKSkB.js +1443 -0
- package/dist-library/math-display-BJz4gbFc.js +24000 -0
- package/dist-library/math-sample-BGEW49zY.js +1124 -0
- package/dist-library/options-CX5m5n-J.js +115 -0
- package/dist-library/parser-standard-DlCk7sLo.js +10122 -0
- package/dist-library/props-DGlBk0e5.js +183 -0
- package/dist-library/react-ByOHunUW.js +122 -0
- package/dist-library/reactive-md-authoring.js +712 -1077
- package/dist-library/reactive-md-build.js +7966 -0
- package/dist-library/reactive-md-compiler-standard.js +33 -0
- package/dist-library/reactive-md-compiler.js +22 -0
- package/dist-library/reactive-md-default-packs.js +71 -0
- package/dist-library/reactive-md-default-preset.js +10 -0
- package/dist-library/reactive-md-export.js +111 -0
- package/dist-library/reactive-md-print.css +18 -3
- package/dist-library/reactive-md-react-runtime.js +251 -0
- package/dist-library/reactive-md-react-server.js +55 -0
- package/dist-library/reactive-md-react-unstyled.js +9 -1
- package/dist-library/reactive-md-react.js +9 -1
- package/dist-library/reactive-md-runtime-browser.js +51 -0
- package/dist-library/reactive-md-runtime.js +3 -0
- package/dist-library/reactive-md-sdk.js +6 -0
- package/dist-library/reactive-md-standalone-host.js +442 -0
- package/dist-library/reactive-md-testing-browser.js +523 -0
- package/dist-library/reactive-md-testing-react.js +221 -0
- package/dist-library/reactive-md-testing.js +638 -0
- package/dist-library/reactive-md-vite.js +959 -0
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1080 -795
- package/dist-library/registry-B9Jc3FVe.js +1174 -0
- package/dist-library/resources-BGt8mpDA.js +204 -0
- package/dist-library/runtime-C-sbfpOX.js +1157 -0
- package/dist-library/runtime-Dkq7ldyg.js +172 -0
- package/dist-library/schema-ZFufO8V0.js +39 -0
- package/dist-library/shareable-DDVL4Fi9.js +844 -0
- package/dist-library/types/authoring/catalog.d.ts +168 -0
- package/dist-library/types/authoring/conformance.d.ts +24 -0
- package/dist-library/types/{editor → authoring}/editor-i18n.d.ts +3 -24
- package/dist-library/types/authoring/extensions.d.ts +13 -0
- package/dist-library/types/authoring/index.d.ts +14 -11
- package/dist-library/types/authoring/insert.d.ts +16 -0
- package/dist-library/types/{editor → authoring}/native-components.d.ts +19 -2
- package/dist-library/types/authoring/templates.d.ts +65 -0
- package/dist-library/types/build/diagnostics.d.ts +8 -0
- package/dist-library/types/build/digest.d.ts +5 -0
- package/dist-library/types/build/entry.d.ts +9 -0
- package/dist-library/types/build/host.d.ts +36 -0
- package/dist-library/types/build/index.d.ts +99 -0
- package/dist-library/types/build/notices.d.ts +29 -0
- package/dist-library/types/build/resources.d.ts +60 -0
- package/dist-library/types/build/vite.d.ts +15 -0
- package/dist-library/types/compiler/index.d.ts +22 -0
- package/dist-library/types/compiler/result.d.ts +30 -0
- package/dist-library/types/compiler/standard.d.ts +16 -0
- package/dist-library/types/compiler/types.d.ts +69 -0
- package/dist-library/types/components/chart-motion.d.ts +12 -0
- package/dist-library/types/components/controls.d.ts +21 -0
- package/dist-library/types/{local → components}/data-table.d.ts +10 -24
- package/dist-library/types/components/default-chart-types.d.ts +22 -0
- package/dist-library/types/components/default-chart.d.ts +2 -0
- package/dist-library/types/components/default-preset.d.ts +10 -0
- package/dist-library/types/components/diagram-inspector.d.ts +24 -0
- package/dist-library/types/components/gallery.d.ts +6 -0
- package/dist-library/types/components/layout.d.ts +23 -0
- package/dist-library/types/components/mafs-plot-grid.d.ts +57 -0
- package/dist-library/types/components/mafs-visuals.d.ts +40 -0
- package/dist-library/types/components/numeric-sliders.d.ts +3 -0
- package/dist-library/types/components/uiarc/calendar/calendar.d.ts +26 -0
- package/dist-library/types/components/uiarc/date-picker/date-picker.d.ts +29 -0
- package/dist-library/types/components/uiarc/lib/motion-tokens.d.ts +2 -0
- package/dist-library/types/components/uiarc/lib/use-today.d.ts +2 -0
- package/dist-library/types/components/uiarc/motion-tokens.d.ts +60 -0
- package/dist-library/types/components/uiarc/rmd-motion.d.ts +12 -0
- package/dist-library/types/components/uiarc/select/select.d.ts +21 -0
- package/dist-library/types/components/uiarc/slider/slider.d.ts +53 -0
- package/dist-library/types/components/use-hydrated.d.ts +6 -0
- package/dist-library/types/components/visuals.d.ts +13 -0
- package/dist-library/types/export/component-state.d.ts +39 -0
- package/dist-library/types/export/index.d.ts +47 -0
- package/dist-library/types/export/requirements.d.ts +23 -0
- package/dist-library/types/export/resources.d.ts +8 -0
- package/dist-library/types/export/restoration.d.ts +52 -0
- package/dist-library/types/index.d.ts +1 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +16 -0
- package/dist-library/types/local/compilation/compiler-services.d.ts +64 -0
- package/dist-library/types/local/compilation/compiler-structure.d.ts +46 -0
- package/dist-library/types/local/compilation/compiler-values.d.ts +9 -0
- package/dist-library/types/local/compilation/compiler.d.ts +34 -0
- package/dist-library/types/local/compilation/component-kernel.d.ts +487 -0
- package/dist-library/types/local/{dependencies.d.ts → compilation/dependencies.d.ts} +4 -3
- package/dist-library/types/local/{diagnostics.d.ts → configuration/diagnostic-messages.d.ts} +193 -65
- package/dist-library/types/local/configuration/diagnostics.d.ts +58 -0
- package/dist-library/types/local/{limits.d.ts → configuration/limits.d.ts} +15 -2
- package/dist-library/types/local/configuration/options-core.d.ts +120 -0
- package/dist-library/types/local/configuration/options.d.ts +17 -0
- package/dist-library/types/local/configuration/portable-options.d.ts +3 -0
- package/dist-library/types/local/configuration/schema-core.d.ts +32 -0
- package/dist-library/types/local/configuration/schema.d.ts +12 -0
- package/dist-library/types/local/contracts/types.d.ts +519 -0
- package/dist-library/types/local/{version.d.ts → contracts/version.d.ts} +1 -1
- package/dist-library/types/local/{computations.d.ts → evaluation/computations.d.ts} +6 -3
- package/dist-library/types/local/{expression.d.ts → evaluation/expression.d.ts} +2 -2
- package/dist-library/types/local/{math-display.d.ts → evaluation/math-display.d.ts} +2 -16
- package/dist-library/types/local/evaluation/math-sample.d.ts +23 -0
- package/dist-library/types/local/evaluation/math.d.ts +73 -0
- package/dist-library/types/local/{validation.d.ts → evaluation/validation.d.ts} +1 -1
- package/dist-library/types/local/html/html-details.d.ts +16 -0
- package/dist-library/types/local/html/html-entities.d.ts +7 -0
- package/dist-library/types/local/html/html-policy.d.ts +43 -0
- package/dist-library/types/local/html/html-recovery.d.ts +16 -0
- package/dist-library/types/local/html/html-table-names.d.ts +9 -0
- package/dist-library/types/local/{html-table.d.ts → html/html-table.d.ts} +2 -6
- package/dist-library/types/local/{html.d.ts → html/html.d.ts} +1 -1
- package/dist-library/types/local/index.d.ts +31 -24
- package/dist-library/types/local/markdown/fast-markdown.d.ts +137 -0
- package/dist-library/types/local/{footnotes.d.ts → markdown/footnotes.d.ts} +1 -1
- package/dist-library/types/local/{heading-anchors.d.ts → markdown/heading-anchors.d.ts} +12 -2
- package/dist-library/types/local/markdown/markdown-blocks.d.ts +55 -0
- package/dist-library/types/local/markdown/markdown-structure.d.ts +3 -0
- package/dist-library/types/local/markdown/plain-paragraphs.d.ts +10 -0
- package/dist-library/types/local/parsing/lexical.d.ts +21 -0
- package/dist-library/types/local/parsing/parse-budget.d.ts +67 -0
- package/dist-library/types/local/parsing/parser-capabilities.d.ts +42 -0
- package/dist-library/types/local/parsing/parser-core.d.ts +65 -0
- package/dist-library/types/local/parsing/parser-standard.d.ts +7 -0
- package/dist-library/types/local/parsing/parser.d.ts +16 -0
- package/dist-library/types/local/parsing/rmd-recovery.d.ts +48 -0
- package/dist-library/types/local/{LocalDocumentView.d.ts → rendering/LocalDocumentView.d.ts} +67 -24
- package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +36 -0
- package/dist-library/types/local/rendering/render-types.d.ts +57 -0
- package/dist-library/types/local/rendering/view-revision.d.ts +75 -0
- package/dist-library/types/local/{retention.d.ts → runtime/retention.d.ts} +1 -1
- package/dist-library/types/local/runtime/runtime.d.ts +34 -0
- package/dist-library/types/local/{state.d.ts → runtime/state.d.ts} +4 -4
- package/dist-library/types/local/session/compiler-cache.d.ts +44 -0
- package/dist-library/types/local/session/incremental.d.ts +48 -0
- package/dist-library/types/local/session/parse-session.d.ts +62 -0
- package/dist-library/types/local/session/row-reuse.d.ts +46 -0
- package/dist-library/types/local/{authoring.d.ts → source/authoring.d.ts} +11 -3
- package/dist-library/types/local/source/node-walk.d.ts +3 -0
- package/dist-library/types/local/source/source-context.d.ts +63 -0
- package/dist-library/types/local/{source-migration.d.ts → source/source-migration.d.ts} +2 -2
- package/dist-library/types/local/{i18n.d.ts → theme/i18n.d.ts} +2 -2
- package/dist-library/types/local/theme/theme-name.d.ts +3 -0
- package/dist-library/types/local/{theme.d.ts → theme/theme.d.ts} +3 -3
- package/dist-library/types/local/transport/compile-patch.d.ts +127 -0
- package/dist-library/types/local/{compiled-data.d.ts → transport/compiled-data.d.ts} +1 -1
- package/dist-library/types/local/transport/flat-compiled-data.d.ts +17 -0
- package/dist-library/types/local/transport/shared-data.d.ts +10 -0
- package/dist-library/types/local/transport/worker.d.ts +265 -0
- package/dist-library/types/local/widgets/visuals.d.ts +25 -0
- package/dist-library/types/presets/default-authoring.d.ts +50 -0
- package/dist-library/types/presets/default-components.d.ts +4 -0
- package/dist-library/types/presets/default-semantics.d.ts +8 -0
- package/dist-library/types/presets/default.d.ts +11 -0
- package/dist-library/types/presets/identity.d.ts +7 -0
- package/dist-library/types/presets/packs.d.ts +4 -0
- package/dist-library/types/react/component-api.d.ts +260 -0
- package/dist-library/types/react/component-primitives.d.ts +21 -0
- package/dist-library/types/react/component-utils.d.ts +125 -0
- package/dist-library/types/react/default-theme.d.ts +6 -0
- package/dist-library/types/react/field-validation.d.ts +11 -0
- package/dist-library/types/react/index.d.ts +17 -5
- package/dist-library/types/react/overflow-text-tooltip.d.ts +6 -0
- package/dist-library/types/react/package.d.ts +69 -0
- package/dist-library/types/react/runtime/common.d.ts +4 -0
- package/dist-library/types/react/runtime/index.d.ts +8 -0
- package/dist-library/types/react/runtime/useComponentState.d.ts +30 -0
- package/dist-library/types/react/runtime/useKeys.d.ts +16 -0
- package/dist-library/types/react/runtime/useSwipe.d.ts +27 -0
- package/dist-library/types/react/runtime/useTicker.d.ts +17 -0
- package/dist-library/types/react/sdk.d.ts +110 -0
- package/dist-library/types/react/server.d.ts +15 -0
- package/dist-library/types/react/tooltip-layer.d.ts +10 -0
- package/dist-library/types/react/use-draft-field.d.ts +17 -0
- package/dist-library/types/runtime-services/browser/index.d.ts +63 -0
- package/dist-library/types/runtime-services/component-state.d.ts +152 -0
- package/dist-library/types/runtime-services/identity.d.ts +41 -0
- package/dist-library/types/runtime-services/index.d.ts +10 -0
- package/dist-library/types/runtime-services/random.d.ts +42 -0
- package/dist-library/types/runtime-services/runtime.d.ts +51 -0
- package/dist-library/types/runtime-services/scheduler.d.ts +44 -0
- package/dist-library/types/sdk/assembly.d.ts +73 -0
- package/dist-library/types/sdk/compat-profile.d.ts +57 -0
- package/dist-library/types/sdk/compiler-config.d.ts +33 -0
- package/dist-library/types/sdk/config-validation.d.ts +33 -0
- package/dist-library/types/sdk/config.d.ts +35 -0
- package/dist-library/types/sdk/hash.d.ts +9 -0
- package/dist-library/types/sdk/index.d.ts +10 -0
- package/dist-library/types/sdk/manifest.d.ts +49 -0
- package/dist-library/types/sdk/pattern.d.ts +11 -0
- package/dist-library/types/sdk/preset-core.d.ts +11 -0
- package/dist-library/types/sdk/preset.d.ts +9 -0
- package/dist-library/types/sdk/props.d.ts +33 -0
- package/dist-library/types/sdk/registry-core.d.ts +16 -0
- package/dist-library/types/sdk/registry.d.ts +18 -0
- package/dist-library/types/sdk/theme.d.ts +73 -0
- package/dist-library/types/sdk/types.d.ts +221 -0
- package/dist-library/types/sdk/version.d.ts +49 -0
- package/dist-library/types/shareable.d.ts +29 -3
- package/dist-library/types/standalone/diagnostics.d.ts +16 -0
- package/dist-library/types/standalone/events.d.ts +4 -0
- package/dist-library/types/standalone/library.d.ts +6 -0
- package/dist-library/types/standalone/payload.d.ts +15 -0
- package/dist-library/types/standalone/prepare.d.ts +21 -0
- package/dist-library/types/standalone/session.d.ts +68 -0
- package/dist-library/types/standalone/version.d.ts +7 -0
- package/dist-library/types/testing/behavior.d.ts +19 -0
- package/dist-library/types/testing/browser.d.ts +126 -0
- package/dist-library/types/testing/cases.d.ts +16 -0
- package/dist-library/types/testing/index.d.ts +13 -0
- package/dist-library/types/testing/manifest.d.ts +10 -0
- package/dist-library/types/testing/react.d.ts +45 -0
- package/dist-library/types/testing/report.d.ts +20 -0
- package/dist-library/types/testing/types.d.ts +125 -0
- package/dist-library/types/testing/values.d.ts +22 -0
- package/dist-library/types/vite/client.d.ts +36 -0
- package/dist-library/types/vite/discovery.d.ts +51 -0
- package/dist-library/types/vite/index.d.ts +31 -0
- package/dist-library/types/vite/registration.d.ts +109 -0
- package/dist-library/types-BFCrMrg0.js +52 -0
- package/dist-library/validation-W-bmny-x.js +2253 -0
- package/dist-library/values-CIt8AjiU.js +134 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +591 -95
- package/docs/README-ch.md +90 -0
- package/docs/README.md +87 -81
- package/docs/compatibility/compatibility-ch.md +22 -14
- package/docs/compatibility/compatibility-en.md +22 -14
- package/docs/compatibility/source-versioning-ch.md +15 -12
- package/docs/compatibility/source-versioning-en.md +16 -13
- package/docs/development/component-development-ch.md +51 -195
- package/docs/development/component-development-en.md +51 -195
- package/docs/development/component-development-reference-ch.md +253 -0
- package/docs/development/component-development-reference-en.md +238 -0
- package/docs/development/component-protocol-ch.md +51 -50
- package/docs/development/component-protocol-en.md +52 -49
- package/docs/development/local-module-layout-ch.md +59 -0
- package/docs/development/local-module-layout-en.md +59 -0
- package/docs/development/performance-overview-ch.md +402 -0
- package/docs/development/performance-overview-en.md +402 -0
- package/docs/development/releasing-ch.md +8 -104
- package/docs/development/releasing-en.md +8 -104
- package/docs/guides/local-guide-ch.md +28 -9
- package/docs/guides/local-guide-en.md +31 -12
- package/docs/integration/author-tools-ch.md +4 -2
- package/docs/integration/author-tools-en.md +4 -2
- package/docs/integration/codemirror-ch.md +52 -0
- package/docs/integration/codemirror-en.md +29 -0
- package/docs/integration/compiler-ch.md +47 -0
- package/docs/integration/compiler-en.md +34 -0
- package/docs/integration/directory-discovery-ch.md +53 -0
- package/docs/integration/directory-discovery-en.md +31 -0
- package/docs/integration/editor-ch.md +48 -21
- package/docs/integration/editor-en.md +48 -21
- package/docs/integration/extension-sdk-ch.md +392 -0
- package/docs/integration/extension-sdk-en.md +377 -0
- package/docs/integration/local-integration-ch.md +63 -9
- package/docs/integration/local-integration-en.md +89 -13
- package/docs/integration/repository-split-ch.md +40 -0
- package/docs/integration/repository-split-en.md +23 -0
- package/docs/integration/shareable-export-ch.md +46 -2
- package/docs/integration/shareable-export-en.md +46 -2
- package/docs/reference/computations-formatting-ch.md +4 -2
- package/docs/reference/computations-formatting-en.md +4 -2
- package/docs/reference/constraints-collections-ch.md +21 -1
- package/docs/reference/constraints-collections-en.md +21 -1
- package/docs/reference/diagnostics-counting-ch.md +1 -1
- package/docs/reference/diagnostics-counting-en.md +1 -1
- package/docs/reference/html-compatibility-ch.md +4 -0
- package/docs/reference/html-compatibility-en.md +4 -0
- package/docs/reference/local-components-v2-ch.md +2 -0
- package/docs/reference/local-components-v2-en.md +2 -0
- package/docs/reference/local-interaction-syntax-ch.md +51 -15
- package/docs/reference/local-interaction-syntax-en.md +58 -14
- package/docs/reference/theme-protocol-ch.md +79 -7
- package/docs/reference/theme-protocol-en.md +79 -7
- package/docs/reference/tolerance-ch.md +64 -0
- package/docs/reference/tolerance-en.md +57 -0
- package/docs/releases/release-0.4.0-ch.md +2 -0
- package/docs/releases/release-0.4.0-en.md +2 -0
- package/docs/releases/release-0.4.1-ch.md +2 -0
- package/docs/releases/release-0.4.1-en.md +2 -0
- package/docs/releases/release-0.5.0-ch.md +2 -0
- package/docs/releases/release-0.5.0-en.md +2 -0
- package/docs/releases/release-0.5.1-ch.md +2 -0
- package/docs/releases/release-0.5.1-en.md +2 -0
- package/docs/releases/release-0.5.2-ch.md +2 -0
- package/docs/releases/release-0.5.2-en.md +2 -0
- package/docs/releases/release-0.5.3-ch.md +2 -0
- package/docs/releases/release-0.5.3-en.md +2 -0
- package/docs/releases/release-0.6.0-ch.md +2 -0
- package/docs/releases/release-0.6.0-en.md +2 -0
- package/docs/releases/release-0.6.1-ch.md +2 -0
- package/docs/releases/release-0.6.1-en.md +2 -0
- package/docs/releases/release-0.7.0-ch.md +86 -0
- package/docs/releases/release-0.7.0-en.md +86 -0
- package/docs/releases/release-0.8.0-ch.md +126 -0
- package/docs/releases/release-0.8.0-en.md +126 -0
- package/examples/component-package/LICENSE +21 -0
- package/examples/component-package/NOTICES.md +12 -0
- package/examples/component-package/README-ch.md +101 -0
- package/examples/component-package/README.md +133 -0
- package/examples/component-package/package.json +35 -0
- package/examples/component-package/sample/document.reactive.md +14 -0
- package/examples/component-package/scripts/build-export.mjs +44 -0
- package/examples/component-package/scripts/build.mjs +130 -0
- package/examples/component-package/scripts/verify.mjs +257 -0
- package/examples/component-package/src/assets/notice.svg +4 -0
- package/examples/component-package/src/component.css +40 -0
- package/examples/component-package/src/components.tsx +105 -0
- package/examples/component-package/src/harness.tsx +34 -0
- package/examples/component-package/src/manifests.ts +71 -0
- package/examples/component-package/src/node-entry.ts +18 -0
- package/examples/component-package/src/sample.ts +4 -0
- package/examples/component-package/src/theme.css +44 -0
- package/examples/component-package/src/theme.ts +22 -0
- package/examples/component-package/tsconfig.json +15 -0
- package/examples/conformance/README-ch.md +55 -0
- package/examples/conformance/README.md +2 -0
- package/examples/conformance/local-draft-3.json +296 -0
- package/examples/game-2048-package/LICENSE +21 -0
- package/examples/game-2048-package/NOTICES.md +11 -0
- package/examples/game-2048-package/README-ch.md +97 -0
- package/examples/game-2048-package/README.md +102 -0
- package/examples/game-2048-package/package.json +35 -0
- package/examples/game-2048-package/sample/document.reactive.md +17 -0
- package/examples/game-2048-package/scripts/build-export.mjs +44 -0
- package/examples/game-2048-package/scripts/build.mjs +130 -0
- package/examples/game-2048-package/scripts/verify.mjs +180 -0
- package/examples/game-2048-package/src/component.css +161 -0
- package/examples/game-2048-package/src/components.tsx +326 -0
- package/examples/game-2048-package/src/game-engine.ts +228 -0
- package/examples/game-2048-package/src/harness.tsx +34 -0
- package/examples/game-2048-package/src/manifest.ts +85 -0
- package/examples/game-2048-package/src/node-entry.ts +30 -0
- package/examples/game-2048-package/src/sample.ts +4 -0
- package/examples/game-2048-package/tsconfig.json +15 -0
- package/examples/integration/README-ch.md +63 -0
- package/examples/integration/README.md +17 -1
- package/examples/integration/extension-sdk/README-ch.md +24 -0
- package/examples/integration/extension-sdk/README.md +24 -0
- package/examples/integration/extension-sdk/advanced-standalone.ts +6 -0
- package/examples/integration/extension-sdk/advanced.tsx +101 -0
- package/examples/integration/extension-sdk/env.d.ts +2 -0
- package/examples/integration/extension-sdk/extensions.tsx +97 -0
- package/examples/integration/extension-sdk/index.html +3 -0
- package/examples/integration/extension-sdk/main.tsx +10 -0
- package/examples/integration/extension-sdk/package.json +6 -0
- package/examples/integration/extension-sdk/standalone.ts +7 -0
- package/examples/integration/extension-sdk/tsconfig.json +8 -0
- package/examples/integration/react-comprehensive/index.html +12 -0
- package/examples/integration/react-comprehensive/main.jsx +123 -0
- package/examples/integration/react-comprehensive/package.json +18 -0
- package/examples/local/README-ch.md +76 -0
- package/examples/local/README.md +4 -2
- package/examples/local/scenarios/blog-zh.reactive.md +71 -0
- package/examples/local/scenarios/blog.reactive.md +71 -0
- package/examples/local/scenarios/classroom-zh.reactive.md +97 -0
- package/examples/local/scenarios/classroom.reactive.md +97 -0
- package/examples/local/scenarios/proposal-zh.reactive.md +79 -0
- package/examples/local/scenarios/proposal.reactive.md +79 -0
- package/examples/local/scenarios/survey-zh.reactive.md +74 -0
- package/examples/local/scenarios/survey.reactive.md +74 -0
- package/examples/local/showcase/README-ch.md +22 -0
- package/examples/local/showcase/README.md +9 -3
- package/examples/local/showcase/features.reactive.md +637 -0
- package/examples/local/showcase/zh/features.reactive.md +637 -0
- package/examples/sci-fi-theme/README-ch.md +131 -0
- package/examples/sci-fi-theme/README.md +146 -0
- package/examples/sci-fi-theme/demo/demo.css +532 -0
- package/examples/sci-fi-theme/demo/document.reactive.md +185 -0
- package/examples/sci-fi-theme/demo/index.html +13 -0
- package/examples/sci-fi-theme/demo/main.tsx +180 -0
- package/examples/sci-fi-theme/docs/design-system-ch.md +245 -0
- package/examples/sci-fi-theme/docs/design-system.md +474 -0
- package/examples/sci-fi-theme/package.json +27 -0
- package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -0
- package/examples/sci-fi-theme/src/components.css +1460 -0
- package/examples/sci-fi-theme/src/index.ts +6 -0
- package/examples/sci-fi-theme/src/sci-fi.css +5 -0
- package/examples/sci-fi-theme/src/theme.ts +37 -0
- package/examples/sci-fi-theme/src/tokens.css +408 -0
- package/examples/sci-fi-theme/tsconfig.json +20 -0
- package/examples/sci-fi-theme/vite.config.ts +24 -0
- package/examples/tetris-package/LICENSE +21 -0
- package/examples/tetris-package/NOTICES.md +11 -0
- package/examples/tetris-package/README-ch.md +91 -0
- package/examples/tetris-package/README.md +95 -0
- package/examples/tetris-package/package.json +35 -0
- package/examples/tetris-package/sample/document.reactive.md +16 -0
- package/examples/tetris-package/scripts/build-export.mjs +44 -0
- package/examples/tetris-package/scripts/build.mjs +130 -0
- package/examples/tetris-package/scripts/verify.mjs +173 -0
- package/examples/tetris-package/src/component.css +145 -0
- package/examples/tetris-package/src/components.tsx +334 -0
- package/examples/tetris-package/src/harness.tsx +34 -0
- package/examples/tetris-package/src/manifests.ts +93 -0
- package/examples/tetris-package/src/node-entry.ts +16 -0
- package/examples/tetris-package/src/sample.ts +4 -0
- package/examples/tetris-package/src/tetris-engine.ts +325 -0
- package/examples/tetris-package/tsconfig.json +15 -0
- package/package.json +98 -44
- package/dist-library/compiler-Cm3ppMxG.js +0 -46044
- package/dist-library/react-Bh7_oxZp.js +0 -59655
- package/dist-library/reactive-md-editor.css +0 -2
- package/dist-library/reactive-md-editor.js +0 -3853
- package/dist-library/runtime-DlFYQ4s_.js +0 -498
- package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +0 -7
- package/dist-library/types/editor/editor-toolbar.d.ts +0 -24
- package/dist-library/types/editor/editor-view-bar.d.ts +0 -11
- package/dist-library/types/editor/extended-native-components.d.ts +0 -58
- package/dist-library/types/editor/index.d.ts +0 -9
- package/dist-library/types/editor/locale.d.ts +0 -13
- package/dist-library/types/editor/source-authoring.d.ts +0 -59
- package/dist-library/types/editor/types.d.ts +0 -48
- package/dist-library/types/editor/use-gutter-metrics.d.ts +0 -5
- package/dist-library/types/editor/use-source-history.d.ts +0 -16
- package/dist-library/types/local/compiler.d.ts +0 -4
- package/dist-library/types/local/math.d.ts +0 -48
- package/dist-library/types/local/options.d.ts +0 -36
- package/dist-library/types/local/parser.d.ts +0 -13
- package/dist-library/types/local/render-types.d.ts +0 -27
- package/dist-library/types/local/runtime.d.ts +0 -2
- package/dist-library/types/local/schema.d.ts +0 -77
- package/dist-library/types/local/types.d.ts +0 -263
- package/dist-library/types/local/visuals.d.ts +0 -12
- package/dist-library/types/local/worker.d.ts +0 -98
- package/docs/development/performance-ch.md +0 -76
- package/docs/development/performance-en.md +0 -76
- /package/dist-library/types/{editor → authoring}/command-types.d.ts +0 -0
- /package/dist-library/types/{editor → authoring}/editor-commands.d.ts +0 -0
- /package/dist-library/types/local/{locale.d.ts → contracts/locale.d.ts} +0 -0
- /package/dist-library/types/local/{collection-functions.d.ts → evaluation/collection-functions.d.ts} +0 -0
- /package/dist-library/types/local/{data-functions.d.ts → evaluation/data-functions.d.ts} +0 -0
- /package/dist-library/types/local/{dates.d.ts → evaluation/dates.d.ts} +0 -0
- /package/dist-library/types/local/{formatting.d.ts → evaluation/formatting.d.ts} +0 -0
- /package/dist-library/types/local/{html-names.d.ts → html/html-names.d.ts} +0 -0
- /package/dist-library/types/local/{text-length.d.ts → source/text-length.d.ts} +0 -0
- /package/dist-library/types/local/{colors.d.ts → theme/colors.d.ts} +0 -0
- /package/dist-library/types/local/{code-block.d.ts → widgets/code-block.d.ts} +0 -0
- /package/dist-library/types/local/{code-languages.d.ts → widgets/code-languages.d.ts} +0 -0
- /package/dist-library/types/local/{diagram-layout.d.ts → widgets/diagram-layout.d.ts} +0 -0
- /package/dist-library/types/local/{image-view.d.ts → widgets/image-view.d.ts} +0 -0
- /package/dist-library/types/local/{math-view.d.ts → widgets/math-view.d.ts} +0 -0
- /package/dist-library/types/local/{table-surface.d.ts → widgets/table-surface.d.ts} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Local mode integration
|
|
2
2
|
|
|
3
|
+
**English** · [中文](local-integration-ch.md)
|
|
4
|
+
|
|
3
5
|
Local interaction mode uses HTML-style tags, in-place parameters and `{{ expressions }}`. Author rules are in the [beginner guide](../guides/local-guide-en.md) and the [syntax specification](../reference/local-interaction-syntax-en.md); complete documents are in the [example index](../../examples/local/README.md). Hosts explicitly select this mode through the `Local` APIs. See [Source revisions and migration](../compatibility/source-versioning-en.md) for the optional revision directive, upgrade checks and `migrateLocalSource`, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the upgrade checklist.
|
|
4
6
|
|
|
5
7
|
## Runtime and entries
|
|
@@ -54,9 +56,24 @@ export function Article() {
|
|
|
54
56
|
| `colorScheme` | `'light' \| 'dark' \| 'auto'` | Both | Defaults to `auto`, following the nearest explicit ancestor preference or the system |
|
|
55
57
|
| `hostData` | `Readonly<Record<string, unknown>>` | Both | JSON-safe host data keyed `${kind}:${ref}` for `hostComponent` nodes; never enters the worker |
|
|
56
58
|
| `hostRenderer` | `LocalHostRenderer` | Both | Client-only renderer for `hostComponent` nodes; a missing renderer or data renders a visible placeholder |
|
|
59
|
+
| `externalValues` | `Readonly<Record<string, LocalValue>>` | `LocalReactiveDocument` | Values for `<external>` declarations; updates never recompile or reset parameters. `LocalDocumentView` also accepts it for host-managed runtimes |
|
|
60
|
+
| `initialParameters` | `Readonly<Record<string, LocalValue>>` | `LocalReactiveDocument` | Public parameter values applied once after each new runtime is created, before interaction; an invalid set is rejected atomically and reported through `onDiagnostics` |
|
|
61
|
+
| `onParametersChange` | `(parameters, snapshot) => void` | `LocalReactiveDocument` | Called once per commit when the public writable parameter set actually changes; initialization, rejected writes, unchanged values and external-only updates do not call it |
|
|
62
|
+
| `onSourceNavigate` | `(target: LocalSourceTarget) => void` | Both | Reports a preview node's source range; enabling it adds source metadata attributes, omitting it leaves the DOM unchanged |
|
|
57
63
|
|
|
58
64
|
Neither component has `className`, `style` or slot props. `LocalReactiveDocument` renders `<article class="md-document local-document">`; `LocalDocumentView` uses the same document container. See below for style overrides.
|
|
59
65
|
|
|
66
|
+
```tsx
|
|
67
|
+
<LocalReactiveDocument
|
|
68
|
+
source={source}
|
|
69
|
+
initialParameters={savedParameters}
|
|
70
|
+
onParametersChange={(parameters) => save(parameters)}
|
|
71
|
+
externalValues={{ exchangeRate: 7.2 }}
|
|
72
|
+
onSourceNavigate={(target) => editor.current?.selectRange(target.range)}
|
|
73
|
+
hostRenderer={(node, data, ctx) => <HostWidget node={node} data={data} ctx={ctx} />}
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
60
77
|
Each component instance manages in-memory state independently. Changing the source recompiles and starts from initial values; disposing an instance clears subscriptions and timers. To carry values across a source change, use the retention helpers or manage the runtime yourself; see [Keeping values when source changes](#keeping-values-when-source-changes). A panel reset in the document restores its internal parameters, input drafts and component state, and displays of same-name parameters outside the panel update as well.
|
|
61
78
|
|
|
62
79
|
When a host React root shares a page with the standalone IIFE, give the host root a distinct `identifierPrefix`, for example `createRoot(container, { identifierPrefix: 'host-' })`. The bundles own separate React instances, so their default `useId` counters can overlap. Independent server-rendered roots need matching unique prefixes on the server and client too.
|
|
@@ -71,6 +88,34 @@ Each document instance has its own anchor prefix, and matching table-of-contents
|
|
|
71
88
|
|
|
72
89
|
Anchors for dynamic headings are computed from source initial values, and parameter changes only update the displayed heading text. Rendered DOM IDs belong to the current mounted instance; when saving a table of contents, keep the fragment links from the source.
|
|
73
90
|
|
|
91
|
+
## Incremental compilation for editing
|
|
92
|
+
|
|
93
|
+
Keep one `createLocalCompileSession()` for repeated edits of the same document:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { createLocalCompileSession } from 'reactive-md';
|
|
97
|
+
|
|
98
|
+
const session = createLocalCompileSession();
|
|
99
|
+
session.compile('First **paragraph**.\n\nSecond paragraph.');
|
|
100
|
+
const result = session.compile('First **paragraph**.\n\nEdited second paragraph.');
|
|
101
|
+
console.log(session.stats); // mode: 'incremental', compiledBlocks: 1, reusedBlocks: 1
|
|
102
|
+
session.dispose(); // when closing the document
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`compile(source, options?)` returns `LocalCompileResult`. `clear()` releases reusable state; `dispose()` releases it and ends the session. Compiling after disposal throws. Each result is an independent, serializable plain-data snapshot, so mutating an earlier result cannot corrupt cached blocks. Unchanged blocks may retain node IDs across edits. Their numbering can differ from a separate `compileLocal()` call; resolve metadata IDs within the same result.
|
|
106
|
+
|
|
107
|
+
With an unchanged declaration and binding context, only affected Markdown blocks are recompiled. Changes to declarations, component contents, options, permissions or host schemas trigger full compilation. Reference definitions, footnotes, navigation anchors, HTML, BOMs, code-delimiter changes and uncertain boundaries also use full compilation. Inputs producing diagnostics return the full compiler's diagnostics. Whole-document source and cumulative node budgets still apply, and only the current version is retained.
|
|
108
|
+
|
|
109
|
+
During consecutive component or declaration edits, the session retains the latest successful full result and defers building its block index. The next independent prose edit builds the index once and reuses the other blocks. Identical source can return an independent cached snapshot. Option changes, errors, `clear()` and `dispose()` discard deferred state.
|
|
110
|
+
|
|
111
|
+
`stats` reports the latest mode (`full`, `incremental`, or `cached`), block counts, reuse counts, compiled characters and an optional invalidation reason. `cacheBuilds` counts block-index construction attempts during the call, including deferred recovery. Changed blocks compile under the unchanged declaration prefix; that work is included in `compiledCharacters`. Source comparison, range relocation and complete result snapshot assembly still scale with document size.
|
|
112
|
+
|
|
113
|
+
A document consisting of one flat list or table can also establish an incremental snapshot. Simple inline plans survive row edits; unchanged rows retain node IDs after semantic validation. Rows at unchanged offsets can share objects; shifted rows are cloned with updated UTF-16 ranges. Dynamic interpolation still uses the general parser. The cumulative `stats.parse.reusedRows` / `reusedItems` counters track inline plans, while `reusedRowNodes` / `reusedItemNodes` track final row subtrees separately.
|
|
114
|
+
|
|
115
|
+
When a result patch costs too much, the Worker can return a complete successful result for the same revision and continue the patch chain from it. `metrics.patchFallback === 'cost'` identifies this choice. `patchBytes` / `fullBytes` estimate JSON UTF-8 size, not structured-clone size. This choice does not trigger a full-request retry.
|
|
116
|
+
|
|
117
|
+
`startLocalCompileWorker()`, the default `LocalCompileScheduler` fallback, and `LocalReactiveDocument` manage their own sessions. A custom `fallbackCompile` remains host-owned. `compileLocal()` remains the one-shot full compiler. See the [implementation and measurements](../development/performance-overview-en.md).
|
|
118
|
+
|
|
74
119
|
## Core API
|
|
75
120
|
|
|
76
121
|
```ts
|
|
@@ -78,13 +123,16 @@ import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
|
78
123
|
|
|
79
124
|
const result = compileLocal(source);
|
|
80
125
|
if (result.ok) {
|
|
81
|
-
const runtime = createLocalRuntime(result.document
|
|
126
|
+
const runtime = createLocalRuntime(result.document, {
|
|
127
|
+
externalValues: { exchangeRate: 7.2 },
|
|
128
|
+
});
|
|
82
129
|
const unsubscribe = runtime.subscribe(() => {
|
|
83
130
|
console.log(runtime.snapshot());
|
|
84
131
|
});
|
|
85
132
|
|
|
86
133
|
console.log(runtime.evaluate('people * 100'));
|
|
87
134
|
console.log(runtime.text('People: {{ people }}'));
|
|
135
|
+
runtime.setExternalValues({ exchangeRate: 7.3 });
|
|
88
136
|
|
|
89
137
|
unsubscribe();
|
|
90
138
|
runtime.dispose();
|
|
@@ -100,7 +148,7 @@ if (result.ok) {
|
|
|
100
148
|
- Success: `{ ok: true; document: LocalDocument; diagnostics: Diagnostic[] }`
|
|
101
149
|
- Failure: `{ ok: false; diagnostics: Diagnostic[] }`
|
|
102
150
|
|
|
103
|
-
Syntax problems are returned through diagnostics; the current build accepts only `local-draft-
|
|
151
|
+
Syntax problems are returned through diagnostics; the current build accepts only `local-draft-3`. An explicit older revision directive is rejected with a `local.version.*` diagnostic; an unversioned source keeps current-revision behavior. The source limit is 1,000,000 characters. `document` is a current runtime object and should not be treated as a persistence format.
|
|
104
152
|
|
|
105
153
|
Hosts can set the syntax node budget for a single compilation:
|
|
106
154
|
|
|
@@ -139,7 +187,7 @@ export default function Page() {
|
|
|
139
187
|
|
|
140
188
|
### Host components
|
|
141
189
|
|
|
142
|
-
A host can register
|
|
190
|
+
A host can register components for one compilation without changing the author syntax revision. A schema declares a `form` and may declare a scalar binding:
|
|
143
191
|
|
|
144
192
|
```ts
|
|
145
193
|
import { compileLocal, type LocalHostComponentSchema } from 'reactive-md';
|
|
@@ -153,11 +201,34 @@ const hostComponents: LocalHostComponentSchema[] = [
|
|
|
153
201
|
ref: { kind: 'string', required: true, pattern: '^[a-z-]+$' },
|
|
154
202
|
},
|
|
155
203
|
},
|
|
204
|
+
{
|
|
205
|
+
name: 'host-rating',
|
|
206
|
+
form: 'leaf',
|
|
207
|
+
props: { label: { kind: 'string' } },
|
|
208
|
+
binding: { kind: 'number', min: 0, max: 5, step: 1 },
|
|
209
|
+
},
|
|
156
210
|
];
|
|
157
211
|
const result = compileLocal(source, { hostComponents });
|
|
158
212
|
```
|
|
159
213
|
|
|
160
|
-
Without `hostComponents`, those tags remain unknown and fall back to source. Names must be unique lowercase kebab-case and cannot reuse one of the
|
|
214
|
+
Without `hostComponents`, those tags remain unknown and fall back to source. Names must be unique lowercase kebab-case and cannot reuse one of the 49 author tag names, a P0 HTML tag name or `theme`; at most 32 schemas are accepted. `pattern` accepts only a linear-time-safe regex subset (no backreferences, lookarounds, named groups, nested quantifiers or quantified alternation). An invalid schema returns `local.options.invalid`, and an invalid authored attribute returns `local.host.attribute`; a valid host node counts as one syntax node.
|
|
215
|
+
|
|
216
|
+
`form` is `leaf`, `inline` or `container`. Inline and container tags are paired; their body is compiled as normal Markdown and ReactiveMD content, and the renderer receives `ctx.render()` for children. `binding` is optional and accepts `string`, `number` or `boolean`, with static `min`, `max`, `step`, `options`, `initialRule` and `exclusive`. A bound host component implicitly accepts `bind`, `initial` and dynamic `disabled`, and shares the built-in binding families. For example, this rating control and the built-in number share one value:
|
|
217
|
+
|
|
218
|
+
```markdown
|
|
219
|
+
<host-rating bind="rating" label="Course rating">
|
|
220
|
+
<number bind="rating" label="Numeric rating" min="0" max="5" step="1">
|
|
221
|
+
|
|
222
|
+
Current rating: {{ rating }}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
The host renderer receives `(node, data, ctx)`. `ctx` extends the render context with `value`, a validating `setValue(value)`, `disabled`, `resetToken`, resolved `props` and `report(diagnostics)`. `setValue` goes through the runtime, so shared constraints and reset behavior still apply. Pass `hostData`, keyed `${kind}:${ref}`, only for components that declare those props; a binding-only or container host does not need host data. A missing renderer, missing declared data or a throwing renderer renders a visible placeholder instead of failing the document. `mode="static"` uses the same dispatch and passes `ctx.mode` to the renderer. Host schemas are plain data and cross the worker boundary; renderers never do.
|
|
226
|
+
|
|
227
|
+
### External data
|
|
228
|
+
|
|
229
|
+
`<external name="exchangeRate" type="number">` declares a read-only value for expressions and computations. Pass initial values to `createLocalRuntime(document, { externalValues })` or the `externalValues` prop. `runtime.setExternalValues(partial)` validates every entry, commits once and increments the revision once; unknown names, wrong types, non-finite numbers and budget overruns return diagnostics and keep the previous state. Equal values do not increment the revision. `getExternal(name)` and `getExternalValues()` are read-only; externals never appear in `getParameters()`, `parameterNames()` or a state file.
|
|
230
|
+
|
|
231
|
+
A missing external makes only expressions that read it fail locally; other content keeps updating, and those expressions recover when the value arrives. Missing values are never coerced to `0`, `false` or an empty string. Static export and SSR use the same rules; the export does not fetch or embed host data.
|
|
161
232
|
|
|
162
233
|
### Version inspection and migration
|
|
163
234
|
|
|
@@ -177,24 +248,24 @@ const migrated = migrateLocalSource(source, { fromVersion: 'local-draft-1' });
|
|
|
177
248
|
|
|
178
249
|
`inspectLocalSourceVersion` reports the declared and effective revision, whether this compiler supports it, the directive range and version diagnostics. `checkLocalUpgrade` reports `ok`, `fromVersion`, `toVersion`, `needsMigration` and diagnostics. `migrateLocalSource` adds `source`, `changed` and precise `edits`.
|
|
179
250
|
|
|
180
|
-
`LocalUpgradeOptions` supplies `fromVersion` and `allowSemanticChanges`. An unversioned historical document needs `fromVersion: 'local-draft-1'`. An explicit `fromVersion` that disagrees with the declaration is rejected.
|
|
251
|
+
`LocalUpgradeOptions` supplies `fromVersion` and `allowSemanticChanges`. An unversioned historical document needs `fromVersion: 'local-draft-1'`. An explicit `fromVersion` that disagrees with the declaration is rejected. `local-draft-1`, `local-draft-2` and `local-draft-3` are accepted migration sources.
|
|
181
252
|
|
|
182
253
|
Migration changes only the metadata directive, preserves body bytes, BOM and CRLF, and is idempotent. It blocks reserved bindings, newly recognized tags, compile errors and text-control length changes before producing output. See [Source revisions and migration](../compatibility/source-versioning-en.md) for the exact checks and the CLI.
|
|
183
254
|
|
|
184
|
-
### `createLocalRuntime(document: LocalDocument)`
|
|
255
|
+
### `createLocalRuntime(document: LocalDocument, options?: LocalRuntimeOptions)`
|
|
185
256
|
|
|
186
257
|
Named read-only values are described by `LocalComputation` in the optional `document.computations` record. `bindings` and `initialState` remain writable controls; `snapshot().state` also includes successful calculated values for its revision. Read a named value with `evaluate(name)` to preserve expression errors; failed values are absent from snapshots. See [calculation and error semantics](../reference/computations-formatting-en.md).
|
|
187
258
|
|
|
188
|
-
|
|
259
|
+
`options.externalValues` seeds declared `<external>` values; invalid entries are treated as unavailable and can be corrected through `setExternalValues`. The runtime creates an independent in-memory instance. Throws if `document` is not a local mode document, if initial values exceed budgets, or if the structure is invalid. Each instance has independent state; the runtime never stores or transmits state by itself.
|
|
189
260
|
|
|
190
261
|
### `LocalRuntime`
|
|
191
262
|
|
|
192
|
-
`validate(): Diagnostic[]` reads advisory cross-field failures for the current revision. It preserves editability and returns copies of cached diagnostics. `document.validations?: LocalValidation[]` holds the serializable rule declarations. Numeric collections add `number[]` to `LocalValue` and `number-array` to `LocalValueKind`; existing writable selection controls keep string arrays. See [constraints and collections](../reference/constraints-collections-en.md).
|
|
263
|
+
`validate(): Diagnostic[]` reads advisory cross-field failures for the current revision. Dynamic `min`/`max`/`required` failures are enforced on writes and displayed on the control; `validate()` keeps its existing meaning. It preserves editability and returns copies of cached diagnostics. `document.validations?: LocalValidation[]` holds the serializable rule declarations. Numeric collections add `number[]` to `LocalValue` and `number-array` to `LocalValueKind`; existing writable selection controls keep string arrays. See [constraints and collections](../reference/constraints-collections-en.md).
|
|
193
264
|
|
|
194
265
|
| Member | Parameters | Returns | Behavior |
|
|
195
266
|
| --- | --- | --- | --- |
|
|
196
267
|
| `document` | — | `LocalDocument` | The compiled result used at creation |
|
|
197
|
-
| `snapshot()` | — | `{ revision: number; state: Readonly<Record<string, LocalValue>> }` | Returns the same snapshot object when state is unchanged; state is frozen |
|
|
268
|
+
| `snapshot()` | — | `{ revision: number; state: Readonly<Record<string, LocalValue>> }` | Returns the same snapshot object when state is unchanged; state is frozen and includes available external values; use `getParameters()` for writable parameters only |
|
|
198
269
|
| `get(node, slot?)` | `LocalNode`, optional slot | `LocalValue` | Reads the value bound to the control; `slot` selects `start`/`end` or `x`/`y`; returns `null` for no binding or an unknown node; arrays are copies |
|
|
199
270
|
| `set(node, value, slot?)` | `LocalNode`, `LocalValue`, optional slot | `Diagnostic[]` | Validates all shared controls; returns an empty array and commits once on success; does not increment revision on failure |
|
|
200
271
|
| `setMany(node, values)` | `LocalNode`, slot values | `Diagnostic[]` | Atomically writes several slots of one multi-slot control; invalid batches leave state and revision unchanged |
|
|
@@ -204,6 +275,9 @@ Creates an independent in-memory runtime for a compiled document. Throws if `doc
|
|
|
204
275
|
| `getParameters()` | — | `Readonly<Record<string, LocalValue>>` | Frozen public-only snapshot; internal `@` keys are never included |
|
|
205
276
|
| `setParameter(name, value)` | `string`, `LocalValue` | `Diagnostic[]` | Validates every control sharing the binding; commits once; state unchanged on failure |
|
|
206
277
|
| `setParameters(values)` | `Readonly<Record<string, LocalValue>>` | `Diagnostic[]` | Validates every public value and multi-slot relation, then commits all or nothing; unknown or internal names return `local.runtime.parameter`; invalid values return `local.runtime.value`; unchanged values do not bump the revision |
|
|
278
|
+
| `getExternal(name)` | `string` | `LocalValue \| undefined` | Value of a declared external, or `undefined` when undeclared or unavailable; arrays are copies |
|
|
279
|
+
| `getExternalValues()` | — | `Readonly<Record<string, LocalValue>>` | Frozen record of the currently available external values |
|
|
280
|
+
| `setExternalValues(values)` | `Readonly<Record<string, LocalValue>>` | `Diagnostic[]` | Atomically validates partial external updates; commits and notifies once; unknown names, wrong types and budgets return `local.runtime.external` without changing state or revision |
|
|
207
281
|
| `evaluate(expression)` | `string` | `LocalValue` | Evaluates with current state; throws `LocalExpressionError` on failure; arrays are copies |
|
|
208
282
|
| `text(template)` | `string` | `string` | Renders text containing `{{ }}`; throws on failure |
|
|
209
283
|
| `reset(node)` | `LocalNode` | `void` | Restores parameters and component state within the node's subtree in one commit, notifying once |
|
|
@@ -314,7 +388,7 @@ scheduler.schedule(source);
|
|
|
314
388
|
|
|
315
389
|
### Other core exports
|
|
316
390
|
|
|
317
|
-
- `LOCAL_SYNTAX_VERSION`: currently the literal `'local-draft-
|
|
391
|
+
- `LOCAL_SYNTAX_VERSION`: currently the literal `'local-draft-3'`. Use it to record the syntax revision a document uses.
|
|
318
392
|
- `compileExpression(source: string)`: returns an object with `source`, `dependencies`, `evaluate(env)` and `inferType(env)`; throws `LocalExpressionError` on failure.
|
|
319
393
|
- `LocalExpressionError`: contains `code` and `offset`.
|
|
320
394
|
- `compileLatex(source: string)`: returns an object with `source`, `dependencies` and `evaluate(x, env, budget?)`; throws an error with `code` and `offset` on failure.
|
|
@@ -323,7 +397,7 @@ scheduler.schedule(source);
|
|
|
323
397
|
- Source revisions: `inspectLocalSourceVersion`, `checkLocalUpgrade` and `migrateLocalSource`; `LocalUpgradeOptions` configures the source revision and semantic-change allowance.
|
|
324
398
|
- Retention: `planLocalStateRetention` and `applyLocalStateRetention`.
|
|
325
399
|
- Background compilation: `LocalCompileScheduler`, `LOCAL_COMPILE_DELAY_MS` and `startLocalCompileWorker`.
|
|
326
|
-
- Type exports: `Diagnostic`, `SourceRange`, `LocalValue`, `LocalValueKind`, `LocalNode`, `LocalBinding`, `LocalComputation`, `LocalValidation`, `LocalDocument`, `LocalCompileLimits`, `LocalCompileOptions`, `LocalCompileResult`, `LocalHostPropKind`, `LocalHostPropSchema`, `LocalHostComponentSchema`, `LocalUpgradeOptions`, `LocalRuntime`, `LocalSnapshot`, `LocalStateFile`, `LocalStateGenerator`, `LocalStateParseResult`, `LocalStateResolution`, `LocalRetainedState`, `LocalStateRetentionReason`, `LocalStateRetentionDrop`, `LocalStateRetentionInput`, `LocalStateRetentionResult`, `LocalCompileWorker`, `LocalCompileWorkerScope`, `LocalCompileRequest`, `LocalCompileResponse`, `LocalCompileOutcome`, `LocalCompileMode`, `LocalCompileSchedulerOptions`.
|
|
400
|
+
- Type exports: `Diagnostic`, `SourceRange`, `LocalValue`, `LocalValueKind`, `LocalNode`, `LocalBinding`, `LocalComputation`, `LocalValidation`, `LocalDocument`, `LocalCompileLimits`, `LocalCompileOptions`, `LocalCompileResult`, `LocalHostPropKind`, `LocalHostPropSchema`, `LocalHostComponentForm`, `LocalHostBindingSchema`, `LocalHostComponentSchema`, `LocalExternal`, `LocalDynamicConstraint`, `LocalDynamicConstraints`, `LocalRuntimeOptions`, `LocalUpgradeOptions`, `LocalRuntime`, `LocalSnapshot`, `LocalStateFile`, `LocalStateGenerator`, `LocalStateParseResult`, `LocalStateResolution`, `LocalRetainedState`, `LocalStateRetentionReason`, `LocalStateRetentionDrop`, `LocalStateRetentionInput`, `LocalStateRetentionResult`, `LocalCompileWorker`, `LocalCompileWorkerScope`, `LocalCompileRequest`, `LocalCompileResponse`, `LocalCompileOutcome`, `LocalCompileMode`, `LocalCompileSchedulerOptions`.
|
|
327
401
|
|
|
328
402
|
`compileExpression`, `compileLatex` and `samplePlot` are lower-level utilities with the same stability level as the core API; usually only `compileLocal` and `createLocalRuntime` are needed.
|
|
329
403
|
|
|
@@ -402,9 +476,11 @@ These limits bound the work for a single document; they do not replace host cont
|
|
|
402
476
|
|
|
403
477
|
## Features not provided
|
|
404
478
|
|
|
405
|
-
The default ReactiveMD path supports P0 HTML. Host options for author CSS, JavaScript and extended HTML use the separate native HTML path described in [HTML compatibility](../reference/html-compatibility-en.md).
|
|
479
|
+
The default ReactiveMD path supports P0 HTML. Host options for author CSS, JavaScript and extended HTML use the separate native HTML path described in [HTML compatibility](../reference/html-compatibility-en.md). Automatic state persistence, unrestricted network/storage calls, Vue, React 18 and CommonJS remain outside the current API. Hosts declare read-only values and invoke state export/import explicitly.
|
|
480
|
+
|
|
481
|
+
The source [extension SDK](extension-sdk-en.md) provides custom component and theme package registration in `reactive-md@0.7.0`; follow the [component plugin development guide](../development/component-development-en.md). On ordinary source edits, `LocalReactiveDocument` tries to adopt the new document and retain compatible bindings. Use a new React `key` for independent documents, or manage documents and runtimes in the host.
|
|
406
482
|
|
|
407
483
|
|
|
408
|
-
See [local-draft-2 components and migration](../reference/local-components-v2-en.md) for new tags, colors and slot state, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the upgrade checklist.
|
|
484
|
+
See [local-draft-2 components and migration](../reference/local-components-v2-en.md) for new tags, colors and slot state, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the upgrade checklist.
|
|
409
485
|
|
|
410
486
|
0.5.3 adds compile-option-aware authoring and explicit screen/print styles. See [0.5.3 host integration](../releases/release-0.5.3-en.md). 0.6.0 makes `compileLocal` return plain data that can cross a React Server Components boundary; see the [0.6.0 release notes](../releases/release-0.6.0-en.md).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# 三仓库迁移
|
|
2
|
+
|
|
3
|
+
**中文** · [English](repository-split-en.md)
|
|
4
|
+
|
|
5
|
+
三个仓库独立安装、构建、维护版本和发布:
|
|
6
|
+
|
|
7
|
+
| 仓库 | 准备发布的版本 | 交付 |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| [ReactiveMD](https://github.com/yao1145/ReactiveMD) | reactive-md@0.8.0 | 编译器、运行时、语言服务、SDK、React/SSR、导出 |
|
|
10
|
+
| [ReactiveMD-Editor](https://github.com/yao1145/ReactiveMD-Editor) | reactive-md-editor@0.1.0(未发布) | CodeMirror、工具栏、导航、诊断呈现、编辑器 Worker |
|
|
11
|
+
| [ReactiveMD-Demo](https://github.com/yao1145/ReactiveMD-Demo) | 私有网站包 0.1.0 | 示例网站、组件装配、静态资源和部署 |
|
|
12
|
+
|
|
13
|
+
## 导入路径
|
|
14
|
+
|
|
15
|
+
引擎 0.8 移除了旧 editor 子路径。这是包 API 的破坏性迁移;文档语法和状态协议版本保持原值。已发布的 0.7 包仍保留原入口。
|
|
16
|
+
|
|
17
|
+
| 原路径 | 新路径 |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| reactive-md/editor | reactive-md-editor |
|
|
20
|
+
| reactive-md/editor/codemirror | reactive-md-editor/codemirror |
|
|
21
|
+
| reactive-md/editor/styles.css | reactive-md-editor/styles.css |
|
|
22
|
+
| reactive-md/editor/codemirror/styles.css | reactive-md-editor/codemirror/styles.css |
|
|
23
|
+
|
|
24
|
+
编辑器只通过 reactive-md 和 reactive-md/authoring 使用引擎。通用 Worker、编译会话和语言服务仍由引擎维护;纯作者命令和组件目录可直接从 reactive-md/authoring 使用。
|
|
25
|
+
|
|
26
|
+
## 独立消费与更新
|
|
27
|
+
|
|
28
|
+
三个仓库已独立维护。发布准备使用真实引擎 tarball 构建编辑器,再让 Demo 安装两个实际 tarball。编辑器按公共 API 的兼容性声明引擎 peer 范围;开发安装与 Demo 用内容哈希 vendor 文件名及 lockfile integrity 固定候选组合。发布顺序为先引擎 0.8.0,再编辑器 0.1.0。
|
|
29
|
+
|
|
30
|
+
更新候选组合时,在引擎运行 npm run check、npm run notices,然后 npm pack --ignore-scripts。将生成包复制到编辑器和 Demo 的 vendor 目录,在各自目录 npm install 更新锁文件。运行编辑器 npm run check,打包编辑器并复制到 Demo/vendor;最后在 Demo npm install、npm test、npm run build,并运行本次涉及的浏览器检查。候选包内容变化时要更新实际 tarball 和锁文件,不能只修改版本字符串。
|
|
31
|
+
|
|
32
|
+
正式发布后,把 vendor 依赖改为对应 registry 版本范围并更新锁文件,在干净目录重新安装验证。编辑器根据引擎公共 API 兼容性声明 peer 范围,三个仓库无需同步版本号。
|
|
33
|
+
|
|
34
|
+
## 验证与发布职责
|
|
35
|
+
|
|
36
|
+
引擎 CI 使用一个 Node24 作业:类型、构建、核心回归、真实打包消费。编辑器负责自身类型、构建、命令/坐标/分析控制回归和公开引擎消费;Demo 负责网站构建、文档/导出回归及桌面和手机交互。删除旧阶段快照验收与重复矩阵,历史可通过拆分前提交追溯。
|
|
37
|
+
|
|
38
|
+
引擎与编辑器各自使用手动 publish.yml 和 npm OIDC。编辑器首次发布前需在 npm 配置对应仓库与工作流的 trusted publisher。Demo 独立构建站点产物,生产发布遵循其 AGENTS.md 的 SHA256 校验、相对软链接原子切换和回滚流程。提交或推送不自动发布 npm 或部署站点。
|
|
39
|
+
|
|
40
|
+
Candidate tarball filenames include a SHA256 prefix. Use the exact vendor filenames in package.json; update those paths and lockfile integrity whenever package contents change.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Repository migration
|
|
2
|
+
|
|
3
|
+
**English** · [中文](repository-split-ch.md)
|
|
4
|
+
|
|
5
|
+
The language engine, editor and website have independent repositories, versions and release workflows:
|
|
6
|
+
|
|
7
|
+
| Repository | Prepared release | Responsibility |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| [ReactiveMD](https://github.com/yao1145/ReactiveMD) | reactive-md@0.8.0 | Compiler, runtime, sessions, Worker, authoring services, SDK, React/SSR, export |
|
|
10
|
+
| [ReactiveMD-Editor](https://github.com/yao1145/ReactiveMD-Editor) | reactive-md-editor@0.1.0 (unpublished) | CodeMirror, toolbar, navigation, diagnostics, editor Worker |
|
|
11
|
+
| [ReactiveMD-Demo](https://github.com/yao1145/ReactiveMD-Demo) | Private website package 0.1.0 | Website, examples, extension assembly, deployment |
|
|
12
|
+
|
|
13
|
+
Engine 0.8 removes the old editor exports. Replace reactive-md/editor with reactive-md-editor, reactive-md/editor/codemirror with reactive-md-editor/codemirror, and the corresponding styles.css imports with the new package paths. Published 0.7 packages retain their original exports. The language syntax and state protocol keep their existing revisions.
|
|
14
|
+
|
|
15
|
+
The editor consumes only public reactive-md and reactive-md/authoring APIs. Pure commands/catalogs remain available from reactive-md/authoring without the editor UI.
|
|
16
|
+
|
|
17
|
+
Candidate consumers commit content-addressed vendor tarballs and lockfile integrity. The editor declares its engine peer range from public API compatibility; its development install and the Demo pin exact tarballs. Publish the 0.8.0 engine before the 0.1.0 editor. To update them: run the engine check and notices scripts, pack with --ignore-scripts, copy the package into the editor vendor directory, install in the editor, run its check and pack it, then update Demo/vendor if a website update is requested. Refresh tarballs and lockfiles whenever candidate contents change. After registry publication, switch to registry version ranges and verify a clean install.
|
|
18
|
+
|
|
19
|
+
Engine CI runs one Node24 job for types, build, retained regressions and actual package consumption. Editor checks own UI services and public-engine consumption. Demo checks the website, export and desktop/mobile interaction. Historical phase matrices and duplicated acceptance tests are retired; Git history preserves them.
|
|
20
|
+
|
|
21
|
+
The engine and editor each publish through a manual publish.yml workflow with npm OIDC. Configure a separate trusted publisher before the editor's first release. Website deployment follows the Demo AGENTS.md with SHA256 verification and an atomic relative-symlink switch. Repository pushes do not publish npm packages or deploy the website.
|
|
22
|
+
|
|
23
|
+
Candidate tarball filenames include a SHA256 prefix. Use the exact vendor filenames in package.json; update those paths and lockfile integrity whenever package contents change.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 可分享文档与静态导出
|
|
2
2
|
|
|
3
|
+
**中文** · [English](shareable-export-en.md)
|
|
4
|
+
|
|
3
5
|
本文说明 `local-draft-2` 新增的单文件 HTML 导出能力。编译与运行时接口见[本地模式集成](local-integration-ch.md),语法见[交互语法规范](../reference/local-interaction-syntax-ch.md),修订声明与迁移见[源码修订与迁移](../compatibility/source-versioning-ch.md),升级说明见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
|
|
4
6
|
|
|
5
7
|
## 两种产物
|
|
@@ -22,6 +24,7 @@
|
|
|
22
24
|
reactive-md build doc.reactive.md -o doc.html
|
|
23
25
|
reactive-md build doc.reactive.md -o doc.html --mode static
|
|
24
26
|
reactive-md build doc.reactive.md -o doc.html --state-file doc.state.json
|
|
27
|
+
reactive-md build doc.reactive.md -o doc.html --component-state-file game.state.json
|
|
25
28
|
reactive-md build doc.reactive.md -o doc.html --assets omit
|
|
26
29
|
reactive-md lint "docs/**/*.reactive.md"
|
|
27
30
|
reactive-md lint "docs/**/*.reactive.md" --json --strict
|
|
@@ -32,6 +35,9 @@ reactive-md lint "docs/**/*.reactive.md" --json --strict
|
|
|
32
35
|
| `-o, --output <file>` | 必填输出路径;父目录必须已存在。 |
|
|
33
36
|
| `--mode interactive\|static` | 输出模式,默认 `interactive`。 |
|
|
34
37
|
| `--state-file <json>` | 使用经过校验的 `reactive-md-state/v1` 文件作为打开和重置基线。 |
|
|
38
|
+
| `--component-state-file <json>` | 将经过校验的 `reactive-md-component-state/v1` sidecar 写入交互式 HTML;静态导出拒绝该选项。 |
|
|
39
|
+
| `--document-id <id>` | 组件状态的稳定文档身份;默认使用源码摘要。 |
|
|
40
|
+
| `--random-seed <uint32>` | 文档级组件随机种子。 |
|
|
35
41
|
| `--assets inline\|omit` | 内联已验证的本地位图(默认),或保留渲染器的替代文本降级。 |
|
|
36
42
|
| `--asset-root <dir>` | 额外允许相对图片路径解析的本地目录。 |
|
|
37
43
|
| `--locale en\|zh` | 渲染标签与校验信息语言,默认 `en`。 |
|
|
@@ -104,6 +110,44 @@ const diagnostics = importLocalState(runtime, saved);
|
|
|
104
110
|
|
|
105
111
|
Demo 导出对话框可以把当前预览参数下载为状态文件,供后续 CLI 构建使用。较低层的 `createLocalStateFile`、`parseLocalState`、`applyLocalState` 和 `serializeLocalState` 仍可从 `reactive-md` 使用。
|
|
106
112
|
|
|
113
|
+
## 组件状态 sidecar
|
|
114
|
+
|
|
115
|
+
参数状态文件只覆盖公开参数。游戏、清单和自定义组件的内部进度使用独立的 `reactive-md-component-state/v1` sidecar:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"format": "reactive-md-component-state-document/v1",
|
|
120
|
+
"records": {
|
|
121
|
+
"doc:fnv1a32%3A0123abcd:state:game": {
|
|
122
|
+
"format": "reactive-md-component-state/v1",
|
|
123
|
+
"component": "example/game",
|
|
124
|
+
"componentVersion": "1.0.0",
|
|
125
|
+
"stateVersion": 1,
|
|
126
|
+
"key": "doc:fnv1a32%3A0123abcd:state:game",
|
|
127
|
+
"documentId": "fnv1a32:0123abcd",
|
|
128
|
+
"data": { "score": 12 },
|
|
129
|
+
"random": { "algorithm": "mulberry32", "version": 1, "state": 123 }
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
交互式导出把 sidecar 写入自动挂载载荷;读者打开 HTML 时,运行时在首次渲染前恢复它。构建时的静态首屏也使用同一状态,因此水合前后看到的内容一致。
|
|
136
|
+
|
|
137
|
+
- 默认文档身份是源码摘要;编辑源码后,旧 sidecar 的记录会因身份不匹配而跳过。需要跨编辑恢复时,给组件加 `state-key`,并用 `--document-id` 指定稳定身份。
|
|
138
|
+
- 只嵌入当前文档中存在的组件记录。未知组件和身份不匹配的记录产生警告并从导出中移除;`--strict` 把警告视为失败。
|
|
139
|
+
- 结构无效的 sidecar 或记录是错误,构建以退出码 `3` 失败。
|
|
140
|
+
- 静态导出不运行组件,`--component-state-file` 与 `--mode static` 互斥。
|
|
141
|
+
- 单独使用 `--document-id` 或 `--random-seed` 不需要 sidecar;它们同样作用于导出 HTML 的组件身份和随机流。
|
|
142
|
+
|
|
143
|
+
宿主可以用 `reactive-md/runtime` 的 `createLocalComponentStateRegistry` 生成或校验 sidecar,用 `resolveLocalComponentStateExport` 按导出的文档身份过滤记录。持久化后端是可替换的端口:`reactive-md/runtime/browser` 提供 Web Storage 实现,宿主也可以传入自己的 `componentStateStorage`。高频保存可传入 `componentStateWriteDelayMs`(例如 `200`):内存状态立即更新,完整 sidecar 在每个时间窗内最多序列化并写入一次。页面隐藏或运行时被替换时调用 `runtime.services.state.flush()` 补写;`reactive-md/runtime/browser` 的 `flushComponentStateOnPageHide` 可以绑定浏览器事件。
|
|
144
|
+
|
|
145
|
+
## 外部数据与宿主组件
|
|
146
|
+
|
|
147
|
+
状态文件只保存公开可写参数。`<external>` 声明的值归宿主所有,不会导出,也不会从上次会话恢复。因此,导出文件中的外部数据相关表达式会显示局部的“数据不可用”状态,除非宿主集成在自己的环境中提供值。静态导出和 SSR 遵循同一规则;文件在渲染时不会抓取数据。
|
|
148
|
+
|
|
149
|
+
宿主组件同样归宿主所有。单文件导出没有宿主 renderer 和 schema,这些标签会降级为可见的不可用占位,文档其余内容继续工作。面向可移植的文档不要依赖宿主组件。
|
|
150
|
+
|
|
107
151
|
## 图片
|
|
108
152
|
|
|
109
153
|
### 浏览器
|
|
@@ -183,7 +227,7 @@ IIFE 会注册一个 Light DOM 自定义元素。简单选项通过属性传递
|
|
|
183
227
|
```
|
|
184
228
|
|
|
185
229
|
- 属性:`src`、`source`、`locale`、`color-scheme`、`theme`。
|
|
186
|
-
- Property:`source`、`state`、`urlPolicy`、`imageResolver`、`themes`。
|
|
230
|
+
- Property:`source`、`state`、`documentId`、`randomSeed`、`componentState`、`urlPolicy`、`imageResolver`、`themes`。
|
|
187
231
|
- 事件:`reactive-md-diagnostics`、`reactive-md-state-change`。
|
|
188
232
|
- `src` 通过可取消的 `fetch` 加载;显式 source 不会产生请求。
|
|
189
233
|
- 断开连接时中止请求、移除订阅、卸载 React root 并释放运行时。两个相同 source 的元素拥有独立状态。
|
|
@@ -214,7 +258,7 @@ IIFE 会注册一个 Light DOM 自定义元素。简单选项通过属性传递
|
|
|
214
258
|
|
|
215
259
|
## 当前范围
|
|
216
260
|
|
|
217
|
-
已实现:CLI 的 `build`/`lint`/`migrate`、交互与静态 HTML
|
|
261
|
+
已实现:CLI 的 `build`/`lint`/`migrate`、交互与静态 HTML、状态文件、组件状态 sidecar、本地位图内联、打印输出、standalone 挂载 API、自动挂载和 Web Component。
|
|
218
262
|
|
|
219
263
|
本版本不包含:`format`、UMD、远程图片抓取、SVG 内联、框架插件(Vite、Astro、Docusaurus、Next.js)、Shadow DOM,以及单文件导出之外的通用 SSR 水合保证。
|
|
220
264
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Shareable documents and static export
|
|
2
2
|
|
|
3
|
+
**English** · [中文](shareable-export-ch.md)
|
|
4
|
+
|
|
3
5
|
This guide covers the single-file HTML exporter introduced with `local-draft-2`. It complements [Local mode integration](local-integration-en.md), the [syntax reference](../reference/local-interaction-syntax-en.md), [Source revisions and migration](../compatibility/source-versioning-en.md) and the [0.4.0 release notes](../releases/release-0.4.0-en.md).
|
|
4
6
|
|
|
5
7
|
## Output modes
|
|
@@ -22,6 +24,7 @@ The package exposes the `reactive-md` command. HTML builds require React 19 and
|
|
|
22
24
|
reactive-md build doc.reactive.md -o doc.html
|
|
23
25
|
reactive-md build doc.reactive.md -o doc.html --mode static
|
|
24
26
|
reactive-md build doc.reactive.md -o doc.html --state-file doc.state.json
|
|
27
|
+
reactive-md build doc.reactive.md -o doc.html --component-state-file game.state.json
|
|
25
28
|
reactive-md build doc.reactive.md -o doc.html --assets omit
|
|
26
29
|
reactive-md lint "docs/**/*.reactive.md"
|
|
27
30
|
reactive-md lint "docs/**/*.reactive.md" --json --strict
|
|
@@ -34,6 +37,9 @@ Build options:
|
|
|
34
37
|
| `-o, --output <file>` | Required output path. Its parent directory must already exist. |
|
|
35
38
|
| `--mode interactive\|static` | Output mode. Default: `interactive`. |
|
|
36
39
|
| `--state-file <json>` | Use a validated `reactive-md-state/v1` file as the starting and reset baseline. |
|
|
40
|
+
| `--component-state-file <json>` | Embed a validated `reactive-md-component-state/v1` sidecar in interactive HTML. Static output rejects it. |
|
|
41
|
+
| `--document-id <id>` | Stable document identity used to scope component state. Default: the source digest. |
|
|
42
|
+
| `--random-seed <uint32>` | Document-level component random seed. |
|
|
37
43
|
| `--assets inline\|omit` | Inline verified local raster images (default) or leave the renderer's alt fallback. |
|
|
38
44
|
| `--asset-root <dir>` | Additional local directory that relative image paths may resolve inside. |
|
|
39
45
|
| `--locale en\|zh` | Renderer labels and validation messages. Default: `en`. |
|
|
@@ -106,6 +112,44 @@ const diagnostics = importLocalState(runtime, saved);
|
|
|
106
112
|
|
|
107
113
|
The demo's export dialog can download the current preview parameters as a state file for a later CLI build. The lower-level `createLocalStateFile`, `parseLocalState`, `applyLocalState` and `serializeLocalState` remain available from `reactive-md`.
|
|
108
114
|
|
|
115
|
+
## Component state sidecar
|
|
116
|
+
|
|
117
|
+
A parameter state file covers public parameters only. Games, checklists and custom components keep internal progress in a separate `reactive-md-component-state/v1` sidecar:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"format": "reactive-md-component-state-document/v1",
|
|
122
|
+
"records": {
|
|
123
|
+
"doc:fnv1a32%3A0123abcd:state:game": {
|
|
124
|
+
"format": "reactive-md-component-state/v1",
|
|
125
|
+
"component": "example/game",
|
|
126
|
+
"componentVersion": "1.0.0",
|
|
127
|
+
"stateVersion": 1,
|
|
128
|
+
"key": "doc:fnv1a32%3A0123abcd:state:game",
|
|
129
|
+
"documentId": "fnv1a32:0123abcd",
|
|
130
|
+
"data": { "score": 12 },
|
|
131
|
+
"random": { "algorithm": "mulberry32", "version": 1, "state": 123 }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
An interactive export embeds the sidecar in the auto-mount payload; the runtime restores it before the first render. The static first screen is built from the same state, so hydration matches what the reader already sees.
|
|
138
|
+
|
|
139
|
+
- The default document identity is the source digest. After a source edit, records from an older sidecar are skipped because the identity no longer matches. To keep state across edits, give the component a `state-key` and pass a stable `--document-id`.
|
|
140
|
+
- Only records for components present in this document are embedded. Unknown components and identity mismatches produce warnings and are removed from the export; `--strict` turns warnings into failures.
|
|
141
|
+
- A structurally invalid sidecar or record is an error; the build exits with code `3`.
|
|
142
|
+
- Static output runs no component runtime, so `--component-state-file` cannot be combined with `--mode static`.
|
|
143
|
+
- `--document-id` and `--random-seed` also work without a sidecar; they set the identity and random stream of the exported HTML.
|
|
144
|
+
|
|
145
|
+
Hosts can produce or validate a sidecar with `createLocalComponentStateRegistry` from `reactive-md/runtime`, and filter records for one export identity with `resolveLocalComponentStateExport`. Persistence is a replaceable port: `reactive-md/runtime/browser` provides a Web Storage backend, and hosts may pass their own `componentStateStorage`. For high-frequency saves, pass `componentStateWriteDelayMs` (for example `200`): memory updates immediately, but the complete sidecar is serialized and stored at most once per window. Call `runtime.services.state.flush()` when the page is hidden or the runtime is replaced; `flushComponentStateOnPageHide` from `reactive-md/runtime/browser` wires the browser events.
|
|
146
|
+
|
|
147
|
+
## External data and host components
|
|
148
|
+
|
|
149
|
+
A state file carries public writable parameters only. Values declared with `<external>` are host-owned, are never exported, and are not restored from a previous session. An export therefore renders external-dependent expressions with their local "data unavailable" state unless the host integration supplies values in its own environment. Static and SSR export follow the same rule; the file never fetches data at render time.
|
|
150
|
+
|
|
151
|
+
Host components are also host-owned. A single-file export has no host renderer or host schema, so those tags fall back to the visible unavailable placeholder while the rest of the document keeps working. Do not rely on host components in documents intended to be portable.
|
|
152
|
+
|
|
109
153
|
## Images
|
|
110
154
|
|
|
111
155
|
### Browser
|
|
@@ -185,7 +229,7 @@ The IIFE registers a light-DOM custom element. Simple options are attributes; co
|
|
|
185
229
|
```
|
|
186
230
|
|
|
187
231
|
- Attributes: `src`, `source`, `locale`, `color-scheme`, `theme`.
|
|
188
|
-
- Properties: `source`, `state`, `urlPolicy`, `imageResolver`, `themes`.
|
|
232
|
+
- Properties: `source`, `state`, `documentId`, `randomSeed`, `componentState`, `urlPolicy`, `imageResolver`, `themes`.
|
|
189
233
|
- Events: `reactive-md-diagnostics` and `reactive-md-state-change`.
|
|
190
234
|
- `src` uses `fetch` with cancellation; an explicit source avoids network access.
|
|
191
235
|
- Disconnecting aborts fetches, removes subscriptions and the React root, and disposes the runtime. Two elements with the same source have independent state.
|
|
@@ -216,7 +260,7 @@ Sizes vary slightly with the minifier and React patch release. The alarm is inte
|
|
|
216
260
|
|
|
217
261
|
## Current scope
|
|
218
262
|
|
|
219
|
-
Included: CLI `build`/`lint`/`migrate`, interactive and static HTML, state files, local raster inlining, print output, standalone mount APIs, auto-mount, and the Web Component.
|
|
263
|
+
Included: CLI `build`/`lint`/`migrate`, interactive and static HTML, state files, component-state sidecars, local raster inlining, print output, standalone mount APIs, auto-mount, and the Web Component.
|
|
220
264
|
|
|
221
265
|
Not included in this release: `format`, UMD, remote image fetching, SVG inlining, framework plugins (Vite, Astro, Docusaurus, Next.js), Shadow DOM, and general SSR hydration guarantees outside the single-file export path.
|
|
222
266
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 复用计算与格式化数值
|
|
2
2
|
|
|
3
|
+
**中文** · [English](computations-formatting-en.md)
|
|
4
|
+
|
|
3
5
|
这些能力属于使用 `local-draft-2` 的 `0.4.0`。完整语法见[语法规范](local-interaction-syntax-ch.md),宿主接口见[集成说明](../integration/local-integration-ch.md),可运行文档见[账单示例](../../examples/local/recipes/invoice-zh.reactive.md)。
|
|
4
6
|
|
|
5
7
|
## 命名值
|
|
@@ -24,7 +26,7 @@
|
|
|
24
26
|
|
|
25
27
|
声明在整个文档中可见,可以先引用后声明。`computed` 可以读取控件、常量和其他计算值。`const` 可以读取其他常量和 `pi` 等内置常量,必须独立于控件与计算值。因此,固定单价、阈值等参数无需显示禁用输入框。常量不提供编辑或重置控件。
|
|
26
28
|
|
|
27
|
-
编译器从表达式 AST
|
|
29
|
+
编译器从表达式 AST 提取全部分支的依赖,按依赖顺序推断类型。未知名称、重名、自引用和间接循环均产生带源码位置的错误;未执行分支里的环也属于编译错误。运算符和函数沿用普通表达式的类型规则。运行时仍可能出现域错误,例如读者把作为分母的控件改为零。顶层 `<external>` 声明的名称可作为 `computed`、文本和条件的只读依赖;`const` 不能依赖外部数据,外部名称也不会成为可写参数。
|
|
28
30
|
|
|
29
31
|
正文、动态属性、条件和图表表格中的数值单元格都可以读取命名值。可计算 LaTeX 公式中的多字母数字名称写为 `\mathrm{total}`,例如 `y = \mathrm{total} x`。格式化字符串用于正文或标签;图表数值单元格和曲线参数使用原始数字。
|
|
30
32
|
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
|
|
35
37
|
消费者读取失败的计算值时,会收到其表达式错误,不会得到零、null 或上次成功值。独立消费者继续工作;有效输入可让失败的消费者恢复。逻辑与条件运算符保留运行时短路语义,未访问的分支不会读取其中的失败值。静态值非法的常量直接产生编译错误。
|
|
36
38
|
|
|
37
|
-
`document.bindings` 与 `document.initialState` 描述可写控件。`document.computations`
|
|
39
|
+
`document.bindings` 与 `document.initialState` 描述可写控件。`document.computations` 保存可序列化的声明元数据,`document.externals` 保存只读外部声明。`runtime.snapshot().state` 还包含本次修订成功求出的命名值,失败值缺席;需要保留错误语义时使用 `runtime.evaluate(name)`。`set` 和 `setMany` 不能修改声明。对外数组继续防止外部修改污染运行时。
|
|
38
40
|
|
|
39
41
|
## 数字格式化
|
|
40
42
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Reusing calculations and formatting values
|
|
2
2
|
|
|
3
|
+
**English** · [中文](computations-formatting-ch.md)
|
|
4
|
+
|
|
3
5
|
These additions belong to `0.4.0`, which uses `local-draft-2`. See the [syntax specification](local-interaction-syntax-en.md), [integration API](../integration/local-integration-en.md) and [working example](../../examples/local/recipes/invoice.reactive.md).
|
|
4
6
|
|
|
5
7
|
## Named values
|
|
@@ -24,7 +26,7 @@ Names follow the same identifier and reserved-name rules as `bind`. Controls, mu
|
|
|
24
26
|
|
|
25
27
|
Declarations are visible throughout the document, including before their source position. A `computed` value may read controls, constants and other computations. A `const` may read other constants and built-in constants such as `pi`; it must remain independent of controls and computations. This supports fixed prices and thresholds without displaying a disabled input. Constants have no editing or reset control.
|
|
26
28
|
|
|
27
|
-
The compiler extracts dependencies from the expression AST, including all conditional branches. It orders declarations by dependency before inferring types. Unknown names, duplicate names, self references and indirect cycles produce source-positioned errors. A cycle in an unused branch is still a compile error. Type checking uses the same operator and function rules as ordinary expressions; runtime domain errors remain possible, for example division by a control that becomes zero.
|
|
29
|
+
The compiler extracts dependencies from the expression AST, including all conditional branches. It orders declarations by dependency before inferring types. Unknown names, duplicate names, self references and indirect cycles produce source-positioned errors. A cycle in an unused branch is still a compile error. Type checking uses the same operator and function rules as ordinary expressions; runtime domain errors remain possible, for example division by a control that becomes zero. Names declared by top-level `<external>` tags are valid read-only dependencies for `computed` values, text and conditions; a `const` cannot depend on external data, and external names never become writable parameters.
|
|
28
30
|
|
|
29
31
|
Use a named value anywhere an expression is accepted: prose, dynamic attributes, conditions and numeric table cells used by charts. Computable LaTeX formulas read multi-letter numeric names as `\mathrm{total}`, for example `y = \mathrm{total} x`. Formatted strings belong in labels or prose; numeric chart cells and plot parameters need the underlying number.
|
|
30
32
|
|
|
@@ -34,7 +36,7 @@ Each runtime owns its calculation cache. Computations are reused within a revisi
|
|
|
34
36
|
|
|
35
37
|
A failed calculation propagates its expression error when a consumer reads it. The runtime never substitutes zero, null or a previous successful value. Independent consumers continue to work, and a valid input edit lets failed consumers recover. Runtime logical and conditional operators keep their usual short-circuit behavior: an unvisited branch does not read its failed value. A constant with an invalid static value is a compile error.
|
|
36
38
|
|
|
37
|
-
`document.bindings` and `document.initialState` describe writable controls. `document.computations` contains serializable declaration metadata. `runtime.snapshot().state` also contains successful named results for the current revision; failed results are absent. Use `runtime.evaluate(name)` to read a result with its error semantics. Declarations cannot be changed through `set` or `setMany`. Returned arrays remain protected from external mutation.
|
|
39
|
+
`document.bindings` and `document.initialState` describe writable controls. `document.computations` contains serializable declaration metadata, and `document.externals` contains the read-only external declarations. `runtime.snapshot().state` also contains successful named results for the current revision; failed results are absent. Use `runtime.evaluate(name)` to read a result with its error semantics. Declarations cannot be changed through `set` or `setMany`. Returned arrays remain protected from external mutation.
|
|
38
40
|
|
|
39
41
|
## Number formatting
|
|
40
42
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# 条件、校验与本地集合
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**中文** · [English](constraints-collections-en.md)
|
|
4
|
+
|
|
5
|
+
这些能力扩展 `0.4.0`,并在 `local-draft-3` 中可用。[工作坊示例](../../examples/local/recipes/workshop-zh.reactive.md)把人数预算、日期区间和已选主题表格放在同一份文档里,[命名计算](computations-formatting-ch.md)保存其中间结果。
|
|
4
6
|
|
|
5
7
|
## 跨字段校验
|
|
6
8
|
|
|
@@ -18,6 +20,24 @@
|
|
|
18
20
|
|
|
19
21
|
渲染器显示失败提示,并通过 `aria-describedby` 和 `aria-invalid` 把提示关联到字段或其可访问分组。提示 ID 属于各自文档实例;通过校验后清除错误文字。隐藏内容中的规则继续生效,但隐藏提示不会主动播报。每份文档最多有 100 条规则,隐藏区域也计入;诊断文字沿用 2,000 字符上限。
|
|
20
22
|
|
|
23
|
+
## 动态输入约束
|
|
24
|
+
|
|
25
|
+
`number` 和 `slider` 的 `min`、`max` 可以动态;`date` 的 `min`、`max`、`required` 可以动态;`input` 和 `textarea` 的 `required` 可以动态。每个动态值都是一个完整插值:
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
<number bind="rooms" label="房间数" initial="2" min="1" max="5">
|
|
29
|
+
<number bind="guests" label="旅客人数" initial="4" min="1" max="{{ rooms * 4 }}">
|
|
30
|
+
|
|
31
|
+
<date bind="departure" label="出发日期" initial="2026-11-10">
|
|
32
|
+
<date bind="return" label="返程日期" initial="2026-11-12" min="{{ departure }}">
|
|
33
|
+
|
|
34
|
+
<input bind="company" label="公司名称" required="{{ business }}">
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
写入时按当时的约束校验,并继续保持原子提交。其他参数使范围收窄、已有值不再合法时,保留该值并在控件上显示约束错误;运行时绝不自动裁剪、重置或吸附到最近的合法值。调小字段以满足新范围,或恢复依赖值后,错误消失。动态 `required` 变为 true 且当前为空时只显示提示,不会自动填值。
|
|
38
|
+
|
|
39
|
+
动态边界无法求值、动态 `min` 大于 `max` 或动态日期边界非法时,相关写入被拒绝,状态和 revision 都不变。同名数值和日期绑定必须声明相同的静态范围;边界为动态时,表达式也必须相同。`step` 和文本长度限制仍为静态。`runtime.validate()` 保持原有跨字段含义;动态约束在写入时强制、在字段上显示。
|
|
40
|
+
|
|
21
41
|
## 受控的条件样式
|
|
22
42
|
|
|
23
43
|
```markdown
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Constraints, conditional tones and local collections
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** · [中文](constraints-collections-ch.md)
|
|
4
|
+
|
|
5
|
+
These additions extend `0.4.0` and are available in `local-draft-3`. The [workshop example](../../examples/local/recipes/workshop.reactive.md) combines a participant budget, a date interval and a selected-subject table. [Named calculations](computations-formatting-en.md) hold its intermediate results.
|
|
4
6
|
|
|
5
7
|
## Cross-field validation
|
|
6
8
|
|
|
@@ -18,6 +20,24 @@ Constraints report the current consistency of a document. Readers can still edit
|
|
|
18
20
|
|
|
19
21
|
The renderer displays failed-rule hints and associates them with the corresponding controls or their accessible groups using `aria-describedby` and `aria-invalid`. Hint IDs belong to the mounted document instance. Success removes the error text. Rules in hidden content remain active, as do their bindings; hidden hints do not announce themselves. A document supports at most 100 validation rules, including hidden regions. Diagnostic messages retain the existing 2,000-character bound.
|
|
20
22
|
|
|
23
|
+
## Dynamic input constraints
|
|
24
|
+
|
|
25
|
+
`number` and `slider` accept dynamic `min` and `max`; `date` accepts dynamic `min`, `max` and `required`; `input` and `textarea` accept dynamic `required`. Each dynamic value is one complete interpolation:
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
<number bind="rooms" label="Rooms" initial="2" min="1" max="5">
|
|
29
|
+
<number bind="guests" label="Guests" initial="4" min="1" max="{{ rooms * 4 }}">
|
|
30
|
+
|
|
31
|
+
<date bind="departure" label="Departure" initial="2026-11-10">
|
|
32
|
+
<date bind="return" label="Return" initial="2026-11-12" min="{{ departure }}">
|
|
33
|
+
|
|
34
|
+
<input bind="company" label="Company" required="{{ business }}">
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Write validation uses the constraints in effect at that moment and still commits atomically. When another parameter narrows a range so that an existing value becomes invalid, the value is kept and the control shows the constraint error; the runtime never clamps, resets or snaps it to a nearby legal value. Reducing a field to satisfy the new range, or restoring the dependency, clears the error. Dynamic `required` switching to true while a value is empty shows a hint and does not fill the field.
|
|
38
|
+
|
|
39
|
+
A dynamic bound that cannot be evaluated, a dynamic `min` greater than `max`, or an invalid dynamic date bound rejects the related write and leaves state and revision unchanged. Shared numeric and date bindings must declare the same static range and, when a bound is dynamic, the same expression. `step` and text-length limits remain static. `runtime.validate()` keeps its cross-field meaning; dynamic constraint failures are enforced on writes and displayed on the field.
|
|
40
|
+
|
|
21
41
|
## Conditional visual emphasis
|
|
22
42
|
|
|
23
43
|
```markdown
|