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,108 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Engine release
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** · [中文](releasing-ch.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
reactive-md has an independent version. The editor publishes reactive-md-editor from its own repository and the Demo builds its own website artifact. See [repository migration](../integration/repository-split-en.md) for candidate updates and import changes.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
1. Confirm branch, clean intended diff, target version and registry state. Update package.json, package-lock.json, changelog and relevant compatibility notes. Package and syntax/protocol versions are independent.
|
|
8
|
+
2. Run npm ci, npm run check, npm run notices. Review the packed exports, declaration paths and notices. The public-package check installs an actual tarball in an independent consumer; no Demo/editor checkout is needed.
|
|
9
|
+
3. Commit/push the authorized release source. Trigger publish.yml on that ref with the chosen dist_tag and update_latest. The workflow uses Node24, npm ^11.21 and npm trusted publishing (OIDC); preserve the workflow filename configured on npm. It checks/builds the package before packing and publishes only if that version does not exist. Existing versions only update the requested tags. Do not publish or change tags through a local npm login.
|
|
10
|
+
4. Confirm workflow success, registry version, tags and integrity. Tag/release the matching source when authorized. Verify the published package in a clean consumer before upgrading downstream registry dependencies.
|
|
8
11
|
|
|
9
|
-
The
|
|
10
|
-
|
|
11
|
-
1. Keep `reactive-md` unless maintainers explicitly decide on a scoped rename. A scope requires the corresponding npm account or organization permissions.
|
|
12
|
-
2. If renaming, update `name` in `package.json`, import statements in the documentation, tarball filename references, examples and the relevant subpaths, then record the change as breaking in the changelog.
|
|
13
|
-
3. Check release metadata in `package.json`: `repository`, `homepage`, `bugs`, `license`, `engines` and similar fields. They are currently set; before releasing, confirm the URLs and minimum Node version are still correct and that `private` remains removed.
|
|
14
|
-
4. Confirm `files` covers what needs to be published. It currently includes `dist-library`, `dist-standalone`, `bin`, `cli`, the READMEs (`README.md`, `README-en.md`, `README-ch.md`), the contributing, changelog and security guides in both languages, `THIRD_PARTY_NOTICES.md`, `docs` and `examples`; add any new documentation or notices to `files` as well.
|
|
15
|
-
|
|
16
|
-
The package name and version determine the tarball name. The expected filename for `0.6.1` is `reactive-md-0.6.1.tgz`; after renaming or changing the version, use the actual output of `npm pack`.
|
|
17
|
-
|
|
18
|
-
### Third-party notices
|
|
19
|
-
|
|
20
|
-
The library bundles `remark-gfm@4.0.1`, `remark-parse@11.0.0`, `unified@11.0.5`, `elkjs@0.12.0`, `katex@0.19.1` and their dependencies. KaTeX includes math fonts and the mhchem extension. The standalone HTML runtime also bundles React, React DOM and scheduler; the library React entry uses host-provided peers. All these bundles retain their copyright and license notices in `THIRD_PARTY_NOTICES.md`.
|
|
21
|
-
|
|
22
|
-
Before releasing, maintainers:
|
|
23
|
-
|
|
24
|
-
1. Run `npm run notices` to regenerate `THIRD_PARTY_NOTICES.md` from installed dependencies. The script covers `remark-gfm`, `remark-parse`, `unified`, `parse5`, `lowlight`, `elkjs`, `katex`, `react` and `react-dom`, including scheduler, plus the upstream mhchem attribution and Apache-2.0 license.
|
|
25
|
-
2. Confirm `files` in `package.json` includes `THIRD_PARTY_NOTICES.md` so it ships in the tarball.
|
|
26
|
-
3. Inspect the output of `npm pack --dry-run` and confirm there is no `node_modules`, `demo/`, `demo/artifacts/`, test output or local cache.
|
|
27
|
-
4. Check that dependency licenses match the packaged content; regenerate notices after adding or upgrading Markdown dependencies.
|
|
28
|
-
|
|
29
|
-
## Local tarball installation
|
|
30
|
-
|
|
31
|
-
The complete local gate is:
|
|
32
|
-
|
|
33
|
-
```sh
|
|
34
|
-
npm ci
|
|
35
|
-
npm run verify:release
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
`verify:release` runs the Node-side and browser checks, builds the package, installs the real tarball outside the repository and exercises combined document behavior. It manages the preview server and browser lifecycle itself. The gate also covers the editor entry, its stylesheet and two editor instances on one page. CI splits the same gate with `verify:release:node` and `verify:release:browser`. A browser must already be installed locally.
|
|
39
|
-
|
|
40
|
-
The packed check retains the exact verified archive in `artifacts/release-package/` and records its SHA256 and npm integrity in `package-verification.json` there. Publish that archive after the complete gate passes. Re-run verification if source, package metadata or packaged documentation changes.
|
|
41
|
-
|
|
42
|
-
To inspect the package manually, use the tarball directly. In the repository root:
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
npm pack
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
`npm pack` runs the build and `npm run notices` through `prepack` first, producing `dist-library/` and `THIRD_PARTY_NOTICES.md`. `dist-library/` is the directory targeted by `exports` in `package.json`. Then verify installation in an empty directory:
|
|
49
|
-
|
|
50
|
-
```sh
|
|
51
|
-
mkdir /tmp/reactive-md-consumer
|
|
52
|
-
cd /tmp/reactive-md-consumer
|
|
53
|
-
npm init -y
|
|
54
|
-
npm install /path/to/reactive-md-0.6.1.tgz
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
The core entry can be checked directly in Node:
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
node --input-type=module -e "import { compileLocal, LOCAL_SYNTAX_VERSION } from 'reactive-md'; console.log(LOCAL_SYNTAX_VERSION, compileLocal('# ok').ok)"
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
The React entry requires React 19 to be installed separately:
|
|
64
|
-
|
|
65
|
-
```sh
|
|
66
|
-
npm install react@19 react-dom@19
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
```tsx
|
|
70
|
-
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
71
|
-
import 'reactive-md/styles.css';
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
The editor entry uses the same React peer and a separate stylesheet:
|
|
75
|
-
|
|
76
|
-
```tsx
|
|
77
|
-
import { ReactiveMarkdownEditor } from 'reactive-md/editor';
|
|
78
|
-
import 'reactive-md/editor/styles.css';
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Static SSR rendering is covered by the packed check. The editor entry is imported in the server-render check and exercised in the browser check. Single-file export static-first hydration is covered by the Playwright Chromium and local Edge browser checks; general SSR hydration outside that path is unverified. Installation verification should also confirm that the tarball contains complete `dist-library/types`, including the editor entry and stylesheet, `dist-standalone`, `bin`, `cli`, `README.md`, `README-en.md`, `README-ch.md`, `CHANGELOG.md`, `SECURITY.md`, `THIRD_PARTY_NOTICES.md`, `docs` and `examples`, and check that `docs` contains no local links to unpackaged `demo/`, `src/`, `tests/` or `.tasks/` files.
|
|
82
|
-
|
|
83
|
-
## Release notes
|
|
84
|
-
|
|
85
|
-
Release notes are for users and must include at least:
|
|
86
|
-
|
|
87
|
-
- The package version, `LOCAL_SYNTAX_VERSION`, component protocol revision and theme protocol revision; these are different version numbers.
|
|
88
|
-
- The install command `npm install reactive-md`, `npm install reactive-md@next`, or `npm install reactive-md@<version>` to pin the release, with a downloadable tarball as an offline installation option.
|
|
89
|
-
- User-visible changes, breaking changes and migration steps; link directly to the [changelog](../../CHANGELOG.md) and the [0.6.1 release notes](../releases/release-0.6.1-en.md) for this cycle.
|
|
90
|
-
- Verified platforms, plus unverified browsers, general SSR hydration and other scope.
|
|
91
|
-
- Known limitations and a link to [SECURITY.md](../../SECURITY.md).
|
|
92
|
-
|
|
93
|
-
Do not write results for checks that have not run, and do not present the existence of CI configuration as CI passing.
|
|
94
|
-
|
|
95
|
-
## Manual release checklist
|
|
96
|
-
|
|
97
|
-
1. Confirm the working tree is clean, changes have been reviewed, and `npm ci` installs successfully from the lockfile.
|
|
98
|
-
2. On Node 22.12 and a supported newer LTS (currently 24), run `npm run verify:release`. This is the same complete gate local maintainers and CI use; do not replace it with a list of hand-picked commands.
|
|
99
|
-
3. Confirm the version number, `CHANGELOG.md` and the release notes agree. `0.6.1` switches formula display to KaTeX with bundled math fonts; syntax revision `local-draft-2`, component protocol `component-protocol-2` and theme protocol `reactive-md-theme-1` are unchanged. Update a version axis only when its own contract changes.
|
|
100
|
-
4. Inspect the verified archive retained by the gate, including its file list, size and license files. A fresh manual `npm pack` produces a new candidate that needs its own installation verification.
|
|
101
|
-
5. Compare the archive's SHA256 with `artifacts/release-package/package-verification.json` and record it in the release notes or an internal release record.
|
|
102
|
-
6. Merge the release commit and wait for all CI on `main` to pass.
|
|
103
|
-
7. Create and push the tag manually, for example `v0.6.1`. Do not store npm tokens in an automated release workflow.
|
|
104
|
-
8. Attach the verified tarball, `package-verification.json` and a `release-manifest.json` containing `version`, source `commit`, `sha256` and `integrity` to a draft GitHub Release for the tag. Trigger `publish.yml` with `ref=v0.6.1`, `dist_tag=next`, `update_latest=true` and `use_verified_release=true`. npm trusted publishing uses OIDC; local npm login and OTP are not required. The workflow validates the source commit and archive hashes before publishing the attached file. Wait for success and confirm both dist-tags. When `latest` is outside the authorized scope, pass `update_latest=false`.
|
|
105
|
-
9. Verify the package contents, version, README, license and release notes on npm and GitHub Releases; reinstall once from the public registry.
|
|
106
|
-
10. Verify that the install command in the README works from the registry, and that the registry integrity digest matches the released tarball.
|
|
107
|
-
|
|
108
|
-
The version and install command in the README should be ready before packaging and verified after release. Do not commit tokens, `.npmrc` credentials or local paths during the release process.
|
|
12
|
+
The editor needs its own npm trusted publisher for its repository and publish.yml. Candidate tarballs remain locked in consumer vendor directories until registry publication. Pushing code does not authorize npm publication or site deployment.
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Reactive MD 新用户指南
|
|
2
2
|
|
|
3
|
+
**中文** · [English](local-guide-en.md)
|
|
4
|
+
|
|
3
5
|
在 Markdown 中加入控件,正文、计算结果和图表就会随读者的操作更新。打开[在线 Playground](https://yaozi.raricy.com/),把示例粘贴到编辑器,在预览中直接试用。
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
本文对应当前工作区,语法修订为 `local-draft-3`。每一节先给一份可运行的示例,再解释其中的写法;文末汇总全部组块。
|
|
6
8
|
|
|
7
9
|
## 1. 第一份交互文档
|
|
8
10
|
|
|
@@ -215,7 +217,7 @@
|
|
|
215
217
|
|
|
216
218
|
### 函数曲线
|
|
217
219
|
|
|
218
|
-
|
|
220
|
+
绘图使用 LaTeX。每个 `$$...$$` 公式块定义一条曲线,可以是显式 `y = f(x)`、参数方程 `cases` 块,或关于 `x` 和 `y` 的隐式方程。
|
|
219
221
|
|
|
220
222
|
```markdown
|
|
221
223
|
<slider bind="a" label="振幅" initial="1" min="0" max="3" step="0.5">
|
|
@@ -227,7 +229,23 @@ $$ y = a \sin x $$
|
|
|
227
229
|
|
|
228
230
|
公式中的参数直接使用数学名称,不写 `{{ }}`。单个字母对应同名 `bind`,例如 `a` 对应 `bind="a"`。多字母参数写成 `\mathrm{amplitude}`,对应 `bind="amplitude"`。
|
|
229
231
|
|
|
230
|
-
`x` 是绘图自变量,`y`
|
|
232
|
+
`x` 是绘图自变量,`y` 是输出标记,两者不能绑定到控件。参数方程写在 `cases` 块中,用 `t` 作参数:
|
|
233
|
+
|
|
234
|
+
```markdown
|
|
235
|
+
<plot min="0" max="12.566" label="摆线">
|
|
236
|
+
$$ \begin{cases} x = t - \sin t \\ y = 1 - \cos t \end{cases} $$
|
|
237
|
+
</plot>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
隐式方程把两个变量写进同一个方程。`min` 和 `max` 同时决定追踪用的方形区域:
|
|
241
|
+
|
|
242
|
+
```markdown
|
|
243
|
+
<plot min="-2" max="2" label="双纽线">
|
|
244
|
+
$$ (x^2 + y^2)^2 = 2a^2(x^2 - y^2) $$
|
|
245
|
+
</plot>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
`plot` 的 `min` 和 `max` 对显式曲线是横轴范围,对参数方程是 `t` 的范围,对隐式方程决定方形追踪区域。
|
|
231
249
|
|
|
232
250
|
## 7. 模块化布局
|
|
233
251
|
|
|
@@ -412,7 +430,7 @@ $$ y = a \sin x $$
|
|
|
412
430
|
|
|
413
431
|
## 组块全集
|
|
414
432
|
|
|
415
|
-
下面按用途列出 `local-draft-
|
|
433
|
+
下面按用途列出 `local-draft-3` 的全部 49 个标签。“形态”一列说明写法:无正文组件不写结束标签,容器必须显式闭合,行内组件可以放进句子,子项只能出现在指定父容器内,声明不渲染为界面。
|
|
416
434
|
|
|
417
435
|
多数交互控件都支持 `label`、可选 `bind`、可选 `initial` 和动态 `disabled`。表中只列出常用的关键属性。
|
|
418
436
|
|
|
@@ -428,7 +446,7 @@ $$ y = a \sin x $$
|
|
|
428
446
|
| `coordinate` | 无正文 | `label`、`bind-x`、`bind-y`、`initial-x`、`initial-y`、`x-min`、`x-max`、`y-min`、`y-max`、`step`、`color` | 二维坐标 |
|
|
429
447
|
| `toggle` | 无正文 | `label`、`bind`、`initial`、`color` | 开关;布尔值,默认 `false` |
|
|
430
448
|
| `checkbox` | 无正文 | `label`、`bind`、`initial`、`color` | 勾选框;布尔值,默认 `false` |
|
|
431
|
-
| `date` | 无正文 | `label`、`bind`、`initial`、`min`、`max`、`required
|
|
449
|
+
| `date` | 无正文 | `label`、`bind`、`initial`、`min`、`max`、`required`(三者均可动态) | 日期;值为 `YYYY-MM-DD` 或空字符串 |
|
|
432
450
|
| `counter` | 无正文 | `label`、`bind`、`initial`、`min=0`、`max`、`step=1` | 数字加减;自带减、加、恢复 |
|
|
433
451
|
| `select` | 容器 | `label`、`bind`、`initial`、`color`;子项 `option` | 下拉单选;默认第一项 |
|
|
434
452
|
| `choices` | 容器 | `label`、`bind`、`initial`、`color`;子项 `option` | 选项卡片单选 |
|
|
@@ -486,6 +504,7 @@ $$ y = a \sin x $$
|
|
|
486
504
|
|
|
487
505
|
| 标签 | 形态 | 主要属性 | 用途 |
|
|
488
506
|
| --- | --- | --- | --- |
|
|
507
|
+
| `external` | 声明 | `name`、`type=string/number/boolean/string-array/number-array` 必填 | 顶层只读宿主数据;可被表达式和计算读取,阅读器不能写入 |
|
|
489
508
|
| `computed` | 声明 | `name`、`value` 必填 | 顶层计算值;可读控件、常量和其他计算值;不渲染 |
|
|
490
509
|
| `const` | 声明 | `name`、`value` 必填 | 顶层常量;只能读常量和内置常量;不渲染 |
|
|
491
510
|
| `validation` | 声明 | `when`、`message`、`fields` 必填 | 跨字段校验;失败时显示提示 |
|
|
@@ -504,10 +523,10 @@ $$ y = a \sin x $$
|
|
|
504
523
|
| `node` | 子项 | `id` 必填且唯一、`label` 必填、`tone` 可动态 | 图解节点 |
|
|
505
524
|
| `edge` | 子项 | `from`、`to` 必填、`label` | 图解连线 |
|
|
506
525
|
|
|
507
|
-
以上共
|
|
526
|
+
以上共 49 个标签。`option`、`tab`、`disclosure`、`node`、`edge`、`step`、`column` 是结构子项,只能放在对应父容器内,不能单独使用。
|
|
508
527
|
|
|
509
|
-
`table` 和 `chart` 的 `bind`、`initial` 需要同时提供 `key`,用于公开选中行的稳定标识。`plot` 的每个 `$$...$$`
|
|
528
|
+
`table` 和 `chart` 的 `bind`、`initial` 需要同时提供 `key`,用于公开选中行的稳定标识。`plot` 的每个 `$$...$$` 块定义一条显式、参数或隐式曲线,每个 `plot` 最多 16 条曲线。
|
|
510
529
|
|
|
511
|
-
另有 `<theme name="default">`,写在正文之前,用于选择整份文档的主题。它是文档级元数据,不计入
|
|
530
|
+
另有 `<theme name="default">`,写在正文之前,用于选择整份文档的主题。它是文档级元数据,不计入 49 个标签。
|
|
512
531
|
|
|
513
|
-
默认模式还支持 P0 HTML 的 `div`、`span`、`p`、`h1` 至 `h6` 等元素。其中 `div`、`p` 和 `h1` 至 `h6` 接受静态 `align`(`left`、`center`、`right`、`justify`)。这些是 HTML 元素,不计入上面的
|
|
532
|
+
默认模式还支持 P0 HTML 的 `div`、`span`、`p`、`h1` 至 `h6` 等元素。其中 `div`、`p` 和 `h1` 至 `h6` 接受静态 `align`(`left`、`center`、`right`、`justify`)。这些是 HTML 元素,不计入上面的 49 个标签。
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Reactive MD beginner guide
|
|
2
2
|
|
|
3
|
+
**English** · [中文](local-guide-ch.md)
|
|
4
|
+
|
|
3
5
|
Add controls to Markdown, and the prose, calculations and charts update as the reader changes them. Open the [online Playground](https://yaozi.raricy.com/) and paste an example into the editor to try it in the preview.
|
|
4
6
|
|
|
5
|
-
This guide uses
|
|
7
|
+
This guide uses the current working tree with syntax revision `local-draft-3`. Each section starts with a runnable example, then explains it. The complete tag reference is at the end.
|
|
6
8
|
|
|
7
9
|
## 1. Your first interactive document
|
|
8
10
|
|
|
@@ -215,7 +217,7 @@ Charts update automatically. For search, sorting and paging, place the same Mark
|
|
|
215
217
|
|
|
216
218
|
### Function curves
|
|
217
219
|
|
|
218
|
-
|
|
220
|
+
Plots use LaTeX. Each `$$...$$` block defines one curve: explicit `y = f(x)`, a parametric `cases` block, or an implicit equation in `x` and `y`.
|
|
219
221
|
|
|
220
222
|
```markdown
|
|
221
223
|
<slider bind="a" label="Amplitude" initial="1" min="0" max="3" step="0.5">
|
|
@@ -227,7 +229,23 @@ $$ y = a \sin x $$
|
|
|
227
229
|
|
|
228
230
|
Use math parameter names directly in formulas, without `{{ }}`. A single letter maps to the same `bind`, so `a` maps to `bind="a"`. Write a multi-letter parameter as `\mathrm{amplitude}`, which maps to `bind="amplitude"`.
|
|
229
231
|
|
|
230
|
-
`x` is the plot variable and `y` is the output marker; neither can bind to a control.
|
|
232
|
+
`x` is the plot variable and `y` is the output marker; neither can bind to a control. For a parametric curve, write a `cases` block and use `t` as the parameter:
|
|
233
|
+
|
|
234
|
+
```markdown
|
|
235
|
+
<plot min="0" max="12.566" label="Cycloid">
|
|
236
|
+
$$ \begin{cases} x = t - \sin t \\ y = 1 - \cos t \end{cases} $$
|
|
237
|
+
</plot>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
For an implicit curve, write both variables in one equation. `min` and `max` set the square region used to trace it:
|
|
241
|
+
|
|
242
|
+
```markdown
|
|
243
|
+
<plot min="-2" max="2" label="Lemniscate">
|
|
244
|
+
$$ (x^2 + y^2)^2 = 2a^2(x^2 - y^2) $$
|
|
245
|
+
</plot>
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
`plot`'s `min` and `max` set the horizontal range for explicit curves, the `t` range for parametric curves, and the square tracing region for implicit curves.
|
|
231
249
|
|
|
232
250
|
## 7. Modular layout
|
|
233
251
|
|
|
@@ -412,9 +430,9 @@ Use inline code or code fences to show literal tags and expressions. Write `\{{
|
|
|
412
430
|
|
|
413
431
|
## Complete component reference
|
|
414
432
|
|
|
415
|
-
The following tables list all
|
|
433
|
+
The following tables list all 49 tags in `local-draft-3`, grouped by purpose. The "Form" column shows how each tag is written: a no-body component has no closing tag, a container must close explicitly, an inline component can sit inside a sentence, a child tag belongs inside its parent, and a declaration does not render as interface content.
|
|
416
434
|
|
|
417
|
-
Most interactive controls support `label`, optional `bind`, optional `initial` and dynamic `disabled`. The tables list the key attributes only.
|
|
435
|
+
Most interactive controls support `label`, optional `bind`, optional `initial` and dynamic `disabled`. The tables list the key attributes only. `number`/`slider` and `date` bounds and `required` may use one interpolation, such as `max="{{ rooms * 4 }}"`; narrowing a range keeps the current value and shows a field error instead of clamping it.
|
|
418
436
|
|
|
419
437
|
### Inputs and choices
|
|
420
438
|
|
|
@@ -422,13 +440,13 @@ Most interactive controls support `label`, optional `bind`, optional `initial` a
|
|
|
422
440
|
| --- | --- | --- | --- |
|
|
423
441
|
| `input` | No body | `label`, `bind`, `initial`, `type=text/email`, `placeholder`, `required`, `min-length`, `max-length` | Single-line text; value is a string |
|
|
424
442
|
| `textarea` | No body | `label`, `bind`, `initial`, `placeholder`, `rows=4`, `required`, `min-length`, `max-length` | Multiline text; text goes in `initial` |
|
|
425
|
-
| `number` | No body | `label`, `bind`, `initial`, `min`, `max
|
|
426
|
-
| `slider` | No body | `label`, `bind`, `initial`, `min=0`, `max=100
|
|
443
|
+
| `number` | No body | `label`, `bind`, `initial`, `min`, `max` (both dynamic), `step=1` | Numeric input; default is the closest valid value to 0 |
|
|
444
|
+
| `slider` | No body | `label`, `bind`, `initial`, `min=0`, `max=100` (both dynamic), `step=1`, `color` | Slider number; default is `min` |
|
|
427
445
|
| `range-slider` | No body | `label`, `bind-start`, `bind-end`, `initial-start`, `initial-end`, `min`, `max`, `step`, `color` | Two numbers forming a range |
|
|
428
446
|
| `coordinate` | No body | `label`, `bind-x`, `bind-y`, `initial-x`, `initial-y`, `x-min`, `x-max`, `y-min`, `y-max`, `step`, `color` | Two-dimensional coordinate |
|
|
429
447
|
| `toggle` | No body | `label`, `bind`, `initial`, `color` | Toggle; boolean, default `false` |
|
|
430
448
|
| `checkbox` | No body | `label`, `bind`, `initial`, `color` | Checkbox; boolean, default `false` |
|
|
431
|
-
| `date` | No body | `label`, `bind`, `initial`, `min`, `max`, `required` | Date; value is `YYYY-MM-DD` or an empty string |
|
|
449
|
+
| `date` | No body | `label`, `bind`, `initial`, `min`, `max`, `required` (all three dynamic) | Date; value is `YYYY-MM-DD` or an empty string |
|
|
432
450
|
| `counter` | No body | `label`, `bind`, `initial`, `min=0`, `max`, `step=1` | Number stepper; built-in decrease, increase and reset |
|
|
433
451
|
| `select` | Container | `label`, `bind`, `initial`, `color`; child `option` | Dropdown single choice; first option by default |
|
|
434
452
|
| `choices` | Container | `label`, `bind`, `initial`, `color`; child `option` | Option-card single choice |
|
|
@@ -486,6 +504,7 @@ Most interactive controls support `label`, optional `bind`, optional `initial` a
|
|
|
486
504
|
|
|
487
505
|
| Tag | Form | Key attributes | Purpose |
|
|
488
506
|
| --- | --- | --- | --- |
|
|
507
|
+
| `external` | Declaration | `name`, `type=string/number/boolean/string-array/number-array` required | Top-level read-only host value; read by expressions and computations, never written by the reader |
|
|
489
508
|
| `computed` | Declaration | `name`, `value` required | Top-level computed value; can read controls, constants and other computed values; not rendered |
|
|
490
509
|
| `const` | Declaration | `name`, `value` required | Top-level constant; can read only constants and built-in constants; not rendered |
|
|
491
510
|
| `validation` | Declaration | `when`, `message`, `fields` required | Cross-field validation; shows a message when it fails |
|
|
@@ -504,10 +523,10 @@ Most interactive controls support `label`, optional `bind`, optional `initial` a
|
|
|
504
523
|
| `node` | Child | `id` required and unique, `label` required, `tone` can be dynamic | Diagram node |
|
|
505
524
|
| `edge` | Child | `from`, `to` required, `label` | Diagram edge |
|
|
506
525
|
|
|
507
|
-
These
|
|
526
|
+
These 49 tags are the full set. `option`, `tab`, `disclosure`, `node`, `edge`, `step` and `column` are structural children; they must appear inside their matching parent and cannot be used alone.
|
|
508
527
|
|
|
509
|
-
`table` and `chart` require `key` together with `bind` or `initial`; `key` identifies the selected row. Each `$$...$$` block in a `plot` defines one
|
|
528
|
+
`table` and `chart` require `key` together with `bind` or `initial`; `key` identifies the selected row. Each `$$...$$` block in a `plot` defines one explicit, parametric or implicit curve, with up to 16 curves per plot.
|
|
510
529
|
|
|
511
|
-
In addition, `<theme name="default">` before the body selects the document theme. It is document metadata and is not counted among the
|
|
530
|
+
In addition, `<theme name="default">` before the body selects the document theme. It is document metadata and is not counted among the 49 tags.
|
|
512
531
|
|
|
513
|
-
Default mode also supports P0 HTML elements such as `div`, `span`, `p` and `h1` through `h6`. Among them, `div`, `p` and `h1` through `h6` accept a static `align` value (`left`, `center`, `right` or `justify`). These are HTML elements, not part of the
|
|
532
|
+
Default mode also supports P0 HTML elements such as `div`, `span`, `p` and `h1` through `h6`. Among them, `div`, `p` and `h1` through `h6` accept a static `align` value (`left`, `center`, `right` or `justify`). These are HTML elements, not part of the 49 tags above.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 作者工具
|
|
2
2
|
|
|
3
|
-
[English](author-tools-en.md)
|
|
3
|
+
**中文** · [English](author-tools-en.md)
|
|
4
4
|
|
|
5
5
|
安装 `reactive-md@0.6.0` 即可使用 CLI 和不依赖 React 的 `reactive-md/authoring` 入口。从本仓库开发时,先构建语言包:
|
|
6
6
|
|
|
@@ -49,6 +49,8 @@ const formatted = formatLocalSource(renamed.source, compileOptions);
|
|
|
49
49
|
|
|
50
50
|
分析结果包含按位置排序的高亮 token、绑定声明和引用范围,以及编译诊断。补全项包含 `label`、`kind`、`insertText` 和待替换的 `range`。应用编辑时,应使用生成这些范围的同一版本源码。
|
|
51
51
|
|
|
52
|
+
已有成功编译结果时,可调用 `analyzeLocalSource(source, compileOptions, { document, diagnostics: false })` 复用节点,并省略诊断编译。`document` 必须来自同一源码与编译配置;源码不同会重新解析。省略第三个参数时仍生成完整诊断。内置编辑器使用独立的增量会话复用作者分析节点,诊断由宿主编译结果提供。
|
|
53
|
+
|
|
52
54
|
重命名修改生效的绑定声明、表达式引用和绘图参数,保留普通文字与展示公式。绘图参数在重命名后写为 `\mathrm{newName}`。非法名称和名称冲突会抛出错误。格式化整理已识别组件标签内的空白,保留 Markdown 排版、引号内容、公式、代码与降级区域的源码。编辑器应持续保存原始文档。
|
|
53
55
|
|
|
54
56
|
## Playground
|
|
@@ -57,6 +59,6 @@ const formatted = formatLocalSource(renamed.source, compileOptions);
|
|
|
57
59
|
|
|
58
60
|
## 宿主编辑器配置
|
|
59
61
|
|
|
60
|
-
`reactive-md/authoring` 还导出 `LOCAL_COMPONENTS`、`getLocalComponent`、`getNativeComponentCatalog`、`renderNativeSnippet`、`insertTemplate` 及其类型,无需 React 或 CSS。将预览使用的 `LocalCompileOptions`
|
|
62
|
+
`reactive-md/authoring` 还导出 `LOCAL_COMPONENTS`、`getLocalComponent`、`getNativeComponentCatalog`、`renderNativeSnippet`、`insertTemplate` 及其类型,无需 React 或 CSS。将预览使用的 `LocalCompileOptions` 传给这些函数的编译配置参数;省略时保持原有默认值。配置包括宿主 schema、HTML 模式、资源预算和 `markdownBreaks`。
|
|
61
63
|
|
|
62
64
|
入口与样式接入方式见 [0.5.3 发布说明](../releases/release-0.5.3-ch.md)。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Author tools
|
|
2
2
|
|
|
3
|
-
[中文](author-tools-ch.md)
|
|
3
|
+
**English** · [中文](author-tools-ch.md)
|
|
4
4
|
|
|
5
5
|
Install `reactive-md@0.6.0` to use the CLI and the React-free `reactive-md/authoring` entry. To work from this repository, build the package first:
|
|
6
6
|
|
|
@@ -49,6 +49,8 @@ const formatted = formatLocalSource(renamed.source, compileOptions);
|
|
|
49
49
|
|
|
50
50
|
Analysis returns ordered highlight tokens, bindings with declaration/reference ranges, and compiler diagnostics. Completions contain `label`, `kind`, `insertText` and the `range` to replace. Apply edits against the same source version that produced their ranges.
|
|
51
51
|
|
|
52
|
+
With a successful compile result, call `analyzeLocalSource(source, compileOptions, { document, diagnostics: false })` to reuse its nodes and skip diagnostic compilation. The document must come from the same source and compile options; a different source is parsed again. Omitting the third argument still produces full diagnostics. The built-in editor uses its own incremental session for analysis nodes, while visible diagnostics come from the host compiler.
|
|
53
|
+
|
|
52
54
|
Rename updates active binding declarations, expression references and computed plot parameters, preserving literal text and display formulas. Plot parameters use `\mathrm{newName}` after a rename. Invalid names and collisions throw an error. Formatting normalizes spacing inside recognized component tags; Markdown layout, quoted content, formulas, code and fallback regions retain their source. Keep the original source as the editable document.
|
|
53
55
|
|
|
54
56
|
## Playground
|
|
@@ -57,6 +59,6 @@ Run `npm run dev` and choose **Show source**. The source editor provides highlig
|
|
|
57
59
|
|
|
58
60
|
## Host editor configuration
|
|
59
61
|
|
|
60
|
-
The `reactive-md/authoring` entry also exports `LOCAL_COMPONENTS`, `getLocalComponent`, `getNativeComponentCatalog`, `renderNativeSnippet`, `insertTemplate` and their types. It loads without React or CSS. Pass the preview's `LocalCompileOptions`
|
|
62
|
+
The `reactive-md/authoring` entry also exports `LOCAL_COMPONENTS`, `getLocalComponent`, `getNativeComponentCatalog`, `renderNativeSnippet`, `insertTemplate` and their types. It loads without React or CSS. Pass the preview's `LocalCompileOptions` to each function's compile-options parameter; omitted options keep the existing defaults. This includes host schemas, HTML mode, resource limits and `markdownBreaks`.
|
|
61
63
|
|
|
62
64
|
For full entry and stylesheet details, see the [0.5.3 release notes](../releases/release-0.5.3-en.md).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# CodeMirror 6 编辑器集成
|
|
2
|
+
|
|
3
|
+
**中文** · [English](codemirror-en.md)
|
|
4
|
+
|
|
5
|
+
`0.7.0` 已统一使用 CM6。推荐从 [`reactive-md-editor`](editor-ch.md) 导入 `ReactiveMarkdownEditor`;本页的 `/editor/codemirror` 路径保留为同一组件的兼容别名。CM6 按视口创建源码行 DOM,使用原生历史和搜索,并提供工具栏、作者面板及视图切换。
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { useRef, useState } from 'react';
|
|
9
|
+
import { ReactiveMarkdownCodeEditor, type ReactiveMarkdownCodeEditorHandle } from 'reactive-md-editor/codemirror';
|
|
10
|
+
import 'reactive-md-editor/codemirror/styles.css';
|
|
11
|
+
|
|
12
|
+
export function LongSourceEditor() {
|
|
13
|
+
const [source, setSource] = useState('# 文档');
|
|
14
|
+
const editor = useRef<ReactiveMarkdownCodeEditorHandle>(null);
|
|
15
|
+
return <ReactiveMarkdownCodeEditor ref={editor} value={source} onChange={setSource}
|
|
16
|
+
locale="zh" ariaLabel="文档源码" documentKey="document-1" />;
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
CM6 依赖随编辑器入口打包,公共类型不要求消费者安装 CodeMirror。组件可在服务端导入并渲染外框;编辑视图在客户端挂载。两条编辑器路径共用运行时代码和样式,基础文档渲染入口保持独立。
|
|
21
|
+
|
|
22
|
+
ref 支持 `focus`、`selectRange`、`insertText`、`undo`、`redo`、`getSelection`、`getSource`、`getEditorElement` 和 `getVisibleRanges`。旧版 `textareaRef`、`getTextarea` 已移除;完整源码和选区通过 ref 读取。
|
|
23
|
+
|
|
24
|
+
所有范围均为原始源码中的 UTF-16 偏移。未修改的 CRLF、LF、CR、BOM 和 emoji 会保留;原生输入的新换行使用文档第一个换行的样式。CRLF 内部的偏移映射到该换行之前。受控回传保留历史;外部替换和 `documentKey` 变化重置历史及滚动位置。宿主可延迟回传;超过 120 次未确认修改的旧回传会作为外部替换处理。待确认队列保存逆向编辑。
|
|
25
|
+
|
|
26
|
+
`onTransaction` 返回 `previousSource`、`source`、修订号、`changes`、选区和组合输入状态。`changes` 的所有范围对应 `previousSource`。多处编辑可合并为覆盖首末变化的替换,再交给 `LocalCompileScheduler.schedule(source, options, {baseSource, edit})`。提示会被验证;基线不同或提示无效时,沿用源码差分和完整请求恢复。
|
|
27
|
+
|
|
28
|
+
作者分析默认使用私有模块 Worker。宿主已有预览 Worker 时,在现有调度器生命周期启用分析:
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { LocalCompileScheduler, localCompileOptionsKey } from 'reactive-md';
|
|
32
|
+
|
|
33
|
+
// 放入宿主已有的调度器生命周期,不要在 render 中创建。
|
|
34
|
+
const scheduler = new LocalCompileScheduler({
|
|
35
|
+
createWorker: createCompileWorker,
|
|
36
|
+
includeAuthorAnalysis: true,
|
|
37
|
+
onResult(outcome) {
|
|
38
|
+
setAnalysis(outcome.analysis ? {
|
|
39
|
+
source: outcome.source,
|
|
40
|
+
optionsKey: localCompileOptionsKey(outcome.options),
|
|
41
|
+
analysis: outcome.analysis,
|
|
42
|
+
} : null);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
// <ReactiveMarkdownCodeEditor analysis={analysis} ... />
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`analysis={null}` 表示宿主结果待定,阻止创建私有 Worker;省略 `analysis` 启用私有 Worker。只接受与当前源码和选项签名一致的分析。成功编译复用同一文档及声明元数据生成作者分析;临时语义错误在 Worker 内按相同预算恢复语法高亮,预算或选项失败返回空分析。编译诊断仍通过 `diagnostics` 显示。旧 Worker 可继续编译;未提供分析时,作者面板等待支持分析的结果。
|
|
49
|
+
|
|
50
|
+
`createAnalysisWorker` 可提供符合宿主 CSP 的工厂。默认模块 Worker 无法启动时使用现有主线程编译降级。分析时间记录在 `metrics.worker.analysisMs`。编辑器只装饰可见语法范围,绑定和引用每页显示 50 项。预览由宿主提供,在视图切换时保留 DOM。
|
|
51
|
+
|
|
52
|
+
自动检查覆盖组合事件与原生文字插入;物理中文输入法、移动端键盘和辅助技术需在目标设备验收。`npm run test:codemirror-browser` 复现生产 Edge 对照。性能与边界见 [实施报告](../development/performance-overview-ch.md)。
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# CodeMirror 6 editor integration
|
|
2
|
+
|
|
3
|
+
**English** · [中文](codemirror-ch.md)
|
|
4
|
+
|
|
5
|
+
`0.7.0` uses CM6 throughout. Prefer `ReactiveMarkdownEditor` from [`reactive-md-editor`](editor-en.md). The `/editor/codemirror` path remains a compatibility alias for the same component.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import { ReactiveMarkdownCodeEditor } from 'reactive-md-editor/codemirror';
|
|
10
|
+
import 'reactive-md-editor/codemirror/styles.css';
|
|
11
|
+
|
|
12
|
+
export function LongSourceEditor() {
|
|
13
|
+
const [source, setSource] = useState('# Document');
|
|
14
|
+
return <ReactiveMarkdownCodeEditor value={source} onChange={setSource}
|
|
15
|
+
documentKey="document-1" ariaLabel="Source" />;
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
CM6 renders source lines around the viewport and provides native history, search, a toolbar, authoring panel and view controls. Both editor paths share the same runtime and stylesheet. Consumers do not need CM6 packages for public types. Server rendering produces the frame; the editing view mounts on the client. Core document rendering remains independent of the editor bundle.
|
|
20
|
+
|
|
21
|
+
The ref supports `focus`, `selectRange`, `insertText`, `undo`, `redo`, `getSelection`, `getSource`, `getEditorElement` and `getVisibleRanges`. The old `textareaRef` and `getTextarea` APIs have been removed. Ranges use UTF-16 offsets in the original source. Untouched CRLF/LF/CR breaks, BOM and emoji are preserved. Native input uses the first line-break style for new breaks. Positions inside CRLF map to its beginning. Controlled acknowledgements retain history. External replacements and `documentKey` changes reset history and scroll. Up to 120 unacknowledged edits are tracked using inverse edits; older echoes become external replacements.
|
|
22
|
+
|
|
23
|
+
`onTransaction` provides `previousSource`, `source`, revisions, `changes`, selection and composition state. All change ranges address `previousSource`. A host may merge them into one replacement and pass `{baseSource, edit}` as the third argument to `LocalCompileScheduler.schedule`. Invalid hints or different baselines use the existing diff and full-request recovery.
|
|
24
|
+
|
|
25
|
+
For a shared preview Worker, enable scheduler `includeAuthorAnalysis: true`. Pass `analysis={{source: outcome.source, optionsKey: localCompileOptionsKey(outcome.options), analysis: outcome.analysis}}` when analysis exists. Both scheduler and key function come from `reactive-md`. Pass `analysis={null}` while waiting to disable the private analysis Worker; omitting `analysis` enables it. Source and options signatures must match. Analysis reuses the successful compiled document and declaration metadata. Temporary semantic errors recover syntax on the Worker with the same limits. Budget or options failures return empty analysis; diagnostics still appear through `diagnostics`. Older Workers keep compiling, but authoring waits for analysis-capable results.
|
|
26
|
+
|
|
27
|
+
`createAnalysisWorker` can supply a CSP-compatible factory. If the default Worker cannot start, the scheduler uses its main-thread fallback. Analysis time is reported as `metrics.worker.analysisMs`. Only visible syntax ranges receive decorations; binding and reference lists show 50 items per page. Host-supplied preview DOM stays mounted across view changes.
|
|
28
|
+
|
|
29
|
+
Physical IME, mobile keyboards and assistive technology need target-device acceptance; automation covers composition events and native text insertion. Run `npm run test:codemirror-browser` for production Edge checks. See the [implementation report](../development/performance-overview-en.md) for performance and limits.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# 单次编译入口
|
|
2
|
+
|
|
3
|
+
**中文** · [English](compiler-en.md)
|
|
4
|
+
|
|
5
|
+
当前工作区新增两个单次编译入口。它们返回普通数据,宿主可自行创建运行时或选择呈现方式。这些改动尚未发布到 npm。
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createCompiler } from 'reactive-md/compiler';
|
|
9
|
+
import { createStandardCompiler } from 'reactive-md/compiler/standard';
|
|
10
|
+
|
|
11
|
+
const compiler = createCompiler();
|
|
12
|
+
const result = compiler.compile('# 说明\n\n普通 Markdown 正文。');
|
|
13
|
+
|
|
14
|
+
const standard = createStandardCompiler();
|
|
15
|
+
const interactive = standard.compile('<number bind="count" label="数量" initial="2">\n\n{{ count * 3 }}');
|
|
16
|
+
|
|
17
|
+
if (interactive.ok) {
|
|
18
|
+
console.log(interactive.document.initialState.count);
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`createCompiler` 默认不注册组件;`createStandardCompiler` 显式装配默认组件预设和现有 KaTeX 显示预检。两者均执行源码、表达式、结构和资源预算检查,使用原始 UTF-16 源码范围。单次调用不创建编辑会话、Worker 或运行时,也不加载 React、主题实现和 CSS。主题声明只记录名称与源码位置,主题资源由宿主加载。
|
|
23
|
+
|
|
24
|
+
接入现有 React/SSR 宿主时使用 standard。最小入口只采用 `config.components`,`config.presets` 不会隐式安装默认预设;依赖默认组件的扩展应选择 standard。最小结果具有独立的 `componentConfigKey`,直接交给现有默认配置的渲染器会报告 `local.extension.config-mismatch`。支持无预设宿主配置属于后续宿主边界工作。
|
|
25
|
+
|
|
26
|
+
工厂接受 `LocalCompileOptions`,创建时校验并固定有效配置。无效配置抛出 `CompilerConfigurationError`。编译结果用 `status` 区分 `valid`、`recovered` 和 `failed`,同时保留任务 1 的 `ok/document/diagnostics` 读取方式。成功时还提供独立且逐层冻结的 `program`、恢复记录 `recoveries` 与检查覆盖 `checks`;失败时不包含 program。每次 `compile` 都重新编译当前源码,前一次的绑定、诊断和节点不会成为下一次的输入。
|
|
27
|
+
|
|
28
|
+
宽松模式下,每个最终恢复在 `causeRange` 上产生至多一条 warning,使用与记录相同的稳定 `code`,并说明片段被降级为惰性源文本或经过 HTML 修复。warning 受现有诊断预算约束;预算已满时可以省略 warning,`recoveries` 仍保留记录。`valid` 不包含恢复 warning;`recovered` 成功结果包含 program 和这些 warning。无法恢复的语义、类型、绑定、选项、版本和预算错误仍为 error:无效工厂配置抛出 `CompilerConfigurationError`,编译期错误返回 `failed`。失败结果可同时包含此前恢复产生的 warning 和导致失败的 error。严格模式仍为默认,诊断形状不变。恢复记录的字段和公共结果类型不变,恢复策略身份版本为 2。
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createCompiler, CompilerConfigurationError } from 'reactive-md/compiler';
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const compiler = createCompiler({ limits: { maxSyntaxNodes: 1000 } });
|
|
35
|
+
const result = compiler.compile('{{ missing }}');
|
|
36
|
+
console.log(result.ok, result.diagnostics);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
if (error instanceof CompilerConfigurationError) console.error(error.message);
|
|
39
|
+
else throw error;
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
旧根入口的 `compileLocal(source, options)`、编辑会话和 Worker 默认保持严格语义,并保留原有返回类型。有恢复时会附加 `recoveries` 及对应 warning。显式传入 `strict: false` 可启用[局部恢复](../reference/tolerance-ch.md)。
|
|
44
|
+
|
|
45
|
+
最小入口保留 CommonMark、RMD 结构、表达式、绑定与预算。GFM 语法、原生 HTML 解析与修复、Lezer 块规划、KaTeX 显示和绘图公式语义由 standard 与兼容入口显式装配;缺少某项能力时返回明确的能力诊断,而不是静默改变含义,例如最小入口会以 `local.capability.html` 拒绝 `enableCss`。最小入口的运行与声明依赖图不再包含 `parse5`、`@lezer/markdown`、`remark-gfm` 或 KaTeX,也不再加载默认预设及其作者信息。standard 保留完整行为。
|
|
46
|
+
|
|
47
|
+
构建后运行 `npm run test:compiler-entry`,检查直接 ESM 导入、生产共享 chunk、声明依赖和浏览器消费。源码行为回归使用 `npm test -- tests/compiler-entry.test.ts`。
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# One-shot compilation
|
|
2
|
+
|
|
3
|
+
**English** · [中文](compiler-ch.md)
|
|
4
|
+
|
|
5
|
+
The current workspace adds two compiler entries. They return plain data for a host to run or render. These changes have not been published to npm.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createCompiler } from 'reactive-md/compiler';
|
|
9
|
+
import { createStandardCompiler } from 'reactive-md/compiler/standard';
|
|
10
|
+
|
|
11
|
+
const compiler = createCompiler();
|
|
12
|
+
const result = compiler.compile('# Notes\n\nOrdinary Markdown.');
|
|
13
|
+
|
|
14
|
+
const standard = createStandardCompiler();
|
|
15
|
+
const interactive = standard.compile('<number bind="count" label="Count" initial="2">\n\n{{ count * 3 }}');
|
|
16
|
+
|
|
17
|
+
if (interactive.ok) {
|
|
18
|
+
console.log(interactive.document.initialState.count);
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`createCompiler` registers no components by default. `createStandardCompiler` installs the default component preset and the existing KaTeX display checks. Both enforce source, expression, structure and resource limits and preserve original UTF-16 source ranges. Compilation creates no editing session, Worker or runtime and loads no React, theme implementation or CSS. Theme declarations retain a name and source range; the host loads theme resources.
|
|
23
|
+
|
|
24
|
+
Use standard with the existing React/SSR hosts. The minimal entry reads `config.components`; `config.presets` does not implicitly install the default preset. Extensions that depend on default components need standard. A minimal result has its own `componentConfigKey`, so passing it to the existing renderer with its default configuration reports `local.extension.config-mismatch`. Host configurations without a preset are a later integration step.
|
|
25
|
+
|
|
26
|
+
Factories accept `LocalCompileOptions`, validate them at creation and retain a snapshot of the effective configuration. Invalid configuration throws `CompilerConfigurationError`. Results use `status: 'valid' | 'recovered' | 'failed'` and retain the task-one `ok/document/diagnostics` read path. Success also includes an independently frozen `program`, recovery records and optional-check coverage. Failure contains no program. Each call compiles its own source without reusing a previous call's bindings, diagnostics or nodes.
|
|
27
|
+
|
|
28
|
+
In loose mode, each finalized recovery produces at most one warning at `causeRange` with the same stable `code`, explaining the literal fallback or HTML repair. Warnings use the existing diagnostics budget; when it is full, a warning may be omitted while the record remains in `recoveries`. `valid` has no recovery warning; a `recovered` success includes the program and those warnings. Unrecoverable semantic, type, binding, option, version and budget errors remain errors: invalid factory configuration throws `CompilerConfigurationError`, and compile-time errors return `failed`. A failed result may include warnings from completed recoveries alongside the error that caused failure. Strict mode remains the default with its existing diagnostic shape. Recovery fields and public result types are unchanged, and the recovery strategy identity version is 2.
|
|
29
|
+
|
|
30
|
+
The root `compileLocal(source, options)` entry, editing sessions and Workers keep strict semantics by default and retain their existing result types. Results include `recoveries` and their warnings when present. Pass `strict: false` to enable [local recovery](../reference/tolerance-en.md).
|
|
31
|
+
|
|
32
|
+
The minimal entry keeps CommonMark, RMD structure, expressions, bindings and budgets. GFM syntax, native HTML parsing and repair, Lezer block planning, KaTeX display and plot formula semantics are capabilities installed by the standard and compatibility assemblies. Omitting one produces an explicit capability diagnostic instead of silently changing meaning; for example, the minimal entry rejects `enableCss` with `local.capability.html`. The minimal runtime and declaration graphs no longer reach `parse5`, `@lezer/markdown`, `remark-gfm` or KaTeX, and they no longer load the default preset or its authoring copy. The standard entry keeps the full experience.
|
|
33
|
+
|
|
34
|
+
After building, run `npm run test:compiler-entry` to check direct ESM imports, production chunks, declaration dependencies and browser consumption. Run `npm test -- tests/compiler-entry.test.ts` for source behavior checks.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# 按目录接入主题和组件
|
|
2
|
+
|
|
3
|
+
宿主项目启用一次 Vite 插件:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { reactiveMd } from 'reactive-md/vite';
|
|
7
|
+
export default { plugins: [reactiveMd()] };
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
目录属于使用 ReactiveMD 的项目。默认扫描 Vite root 下的 `theme/` 和 `plugin/` 的直接子目录:
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
theme/paper/theme.css
|
|
14
|
+
theme/paper/theme.json # 可选
|
|
15
|
+
plugin/tetris/index.ts
|
|
16
|
+
plugin/tetris/component.css # 可选
|
|
17
|
+
plugin/tetris/assets/
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`theme.css` 是主题的最小入口。主题名默认取目录名,包 ID 为 `local/theme/<目录名>`,版本为 `0.0.0`。可选 `theme.json` 可以声明 `id`、`name`、`version`、`protocol` 和 `colorSchemes`。内部用 `defineLocalTheme` 校验、作用域化并冻结。作者按主题协议编写深浅模式;发现主题后,文档通过 `<theme name="paper">` 选择它。
|
|
21
|
+
|
|
22
|
+
```css
|
|
23
|
+
[data-rmd-theme="paper"][data-color-scheme="light"] { --accent: #345678; }
|
|
24
|
+
[data-rmd-theme="paper"][data-color-scheme="dark"] { --accent: #abcdef; }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
组件入口导出一个 `LocalReactPackage`。推荐默认导出;也接受唯一的命名包导出,同一对象的别名只计算一次。组件继续用 `defineReactComponentPackage` 声明标签、属性、能力和渲染函数。辅助代码由入口正常导入。
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// plugin/tetris/index.ts
|
|
31
|
+
export { tetrisPackage as default } from 'reactive-md-tetris-package/react';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
入口识别 `index.ts`、`index.tsx`、`index.js`、`index.jsx`、`index.mts`、`index.mjs`。同一目录有多个入口会报错。`component.css` 自动加入资源;包自身的 CSS、主题和 notices 继续生效。入口还可导出 `notices` 数组。注册组件后,文档中使用对应标签才会创建实例。
|
|
35
|
+
|
|
36
|
+
应用保持原来的读取方式:
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { host } from 'virtual:reactive-md/host';
|
|
40
|
+
// React: host.reactConfig
|
|
41
|
+
// 编译、编辑器和 Worker: host.compileOptions
|
|
42
|
+
// SSR/导出: host.resources、host.notices
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Worker 接收可序列化的 `host.config`,React 实现留在主线程。`virtual:reactive-md/bundle` 和生产输出的离线包使用同一发现结果。基础样式仍由应用导入 `reactive-md/styles.css`。虚拟模块类型使用 `reactive-md/vite/client`。
|
|
46
|
+
|
|
47
|
+
资源按目录名固定排序。CSS 相对引用和本地 `@import` 在构建期解析、内联,资源清单记录来源、摘要和字节数。远程引用、超出允许目录的路径和超预算资源会报错;CSS 继续遵循 SDK 的作用域与安全规则。主题名、主题 ID、组件 ID、标签冲突会指出双方入口。同 ID、不同 CSS 的资源也会报错。
|
|
48
|
+
|
|
49
|
+
开发服务器监听入口增删和重命名。主题 CSS 及其资源变化更新样式并失效离线包缓存;注册结构变化触发重载。浏览器和纯编译器均不扫描文件系统。
|
|
50
|
+
|
|
51
|
+
需要自定义目录时用 `reactiveMd({ themeDir: 'themes', pluginDir: 'components' })`。高级宿主仍可选择 `reactiveMd({ extensions: './extensions.ts' })`,由该模块导出 `host = createReactHost(...)`。手动模式与目录选项互斥。宿主自己的样例导航等元数据可从普通应用模块导入。
|
|
52
|
+
|
|
53
|
+
Demo 的 `plugin/tetris/`、`plugin/game-2048/` 和 `theme/sci-fi/` 是现有包的目录接入案例。主题 CSS 来自已安装 sci-fi 包的公开 CSS 入口;更新主题包后应同步这份宿主主题资源。
|