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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "Bundler",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"types": ["vite/client"]
|
|
13
|
+
},
|
|
14
|
+
"include": ["src"]
|
|
15
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# 独立集成示例
|
|
2
|
+
|
|
3
|
+
**中文** · [English](README.md)
|
|
4
|
+
|
|
5
|
+
这些目录使用包的公开入口,可以复制到仓库之外。以下命令均从当前目录开始执行。
|
|
6
|
+
|
|
7
|
+
这些示例面向 `reactive-md@0.6.0`,该版本同时发布在 `latest` 和 `next` 渠道。把所需的示例目录复制到仓库之外,然后按下面的方式从 npm 安装固定版本。React 和 Vite 在需要时从示例自身的依赖安装。
|
|
8
|
+
|
|
9
|
+
[扩展 SDK 使用方](extension-sdk/README-ch.md)面向`reactive-md@0.8.0`,通过公开导出验证静态分享和离线交互分享。准备发布时使用本地构建的 tarball,SDK 契约仍为 `0.7.0`。以下较早的示例保留其 0.6.0 固定版本。
|
|
10
|
+
|
|
11
|
+
## Node 核心
|
|
12
|
+
|
|
13
|
+
需要 Node.js 22.12 或更高版本。安装后,核心示例无需 React 或网络访问即可运行。
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
cd core
|
|
17
|
+
npm install reactive-md@0.6.0 --ignore-scripts --no-audit --no-fund
|
|
18
|
+
npm start
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
它应先输出 `People: 2, cost: 200`,然后输出 `People: 5, cost: 500`。源码在 [core/index.mjs](core/index.mjs)。
|
|
22
|
+
|
|
23
|
+
## React 页面
|
|
24
|
+
|
|
25
|
+
需要 Node.js 22.12 或更高版本。首次安装会获取 React 19 和 Vite。
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
cd react
|
|
29
|
+
npm install reactive-md@0.6.0
|
|
30
|
+
npm run dev
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
打开终端输出的本地 URL,调整人数并观察费用变化。示例入口是 [react/main.jsx](react/main.jsx),库样式通过 `reactive-md/styles.css` 导入。
|
|
34
|
+
|
|
35
|
+
## Worker 编译
|
|
36
|
+
|
|
37
|
+
[worker](worker) 是一个可复制的浏览器页面,把编译放在主线程之外。它对编辑做防抖,在模块 Worker 中编译,并在 Worker 无法启动或崩溃时回退到主线程。
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
cd worker
|
|
41
|
+
npm install reactive-md@0.6.0
|
|
42
|
+
npm run dev
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
UI 和调度连接位于 [worker/main.js](worker/main.js);Worker 入口是 [worker/worker.js](worker/worker.js)。
|
|
46
|
+
|
|
47
|
+
## 综合宿主示例
|
|
48
|
+
|
|
49
|
+
[react-comprehensive](react-comprehensive) 在一个页面中组合了面向宿主的各项新增能力:宿主提供的汇率和库存、动态 `max="{{ inventory }}"`、与内置控件共享绑定的 `host-rating` 组块、通过 `initialParameters` 和 `onParametersChange` 保存与恢复公开参数,以及通过 `onSourceNavigate` 从预览导航到源码。
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
cd react-comprehensive
|
|
53
|
+
npm install reactive-md@0.6.0
|
|
54
|
+
npm run dev
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
改变汇率或库存按钮,给课程评分,点击段落或控件标签即可看到上报的源码范围。宿主 schema 与渲染器在 [react-comprehensive/main.jsx](react-comprehensive/main.jsx)。
|
|
58
|
+
|
|
59
|
+
## 本地包验证
|
|
60
|
+
|
|
61
|
+
要试用未发布的构建,在仓库根目录运行 `npm pack`,并把安装命令中的 `reactive-md@0.6.0` 替换为生成的 `reactive-md-0.6.0.tgz` 的绝对路径。
|
|
62
|
+
|
|
63
|
+
在源码仓库根目录,`npm run check` 运行完整门禁,包括从打包 tarball 进行独立离线安装、严格类型检查、组合功能检查、React 渲染和 HTML 导出。构建后可用 `npm run test:boundary` 做聚焦的包检查。API 与宿主策略见[集成指南](../../docs/integration/local-integration-ch.md)。
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# Standalone integration examples
|
|
2
2
|
|
|
3
|
+
**English** · [中文](README-ch.md)
|
|
4
|
+
|
|
3
5
|
These directories use the package's public entry points and can be copied outside the repository. The commands below start from the current directory.
|
|
4
6
|
|
|
5
7
|
These examples target `reactive-md@0.6.0`, published on both `latest` and `next`. Copy the desired example directory outside the repository, then install the pinned version from npm as shown below. React and Vite are installed from the example's own dependencies where needed.
|
|
6
8
|
|
|
9
|
+
The [extension SDK consumer](extension-sdk/README.md) targets `reactive-md@0.8.0` and verifies static and offline interactive sharing through public exports. Release preparation uses a locally built tarball; the SDK contract remains at `0.7.0`. The older examples below retain their 0.6.0 pins.
|
|
10
|
+
|
|
7
11
|
## Node core
|
|
8
12
|
|
|
9
13
|
Requires Node.js 22.12 or newer. The core example runs without React or network access after installation.
|
|
@@ -40,8 +44,20 @@ npm run dev
|
|
|
40
44
|
|
|
41
45
|
The UI and scheduler wiring live in [worker/main.js](worker/main.js); the Worker entry is [worker/worker.js](worker/worker.js).
|
|
42
46
|
|
|
47
|
+
## Comprehensive host example
|
|
48
|
+
|
|
49
|
+
[react-comprehensive](react-comprehensive) combines the host-facing additions in one page: a host-provided exchange rate and inventory, dynamic `max="{{ inventory }}"`, a `host-rating` component that shares its binding with built-in controls, saved and restored public parameters through `initialParameters` and `onParametersChange`, and preview-to-source navigation through `onSourceNavigate`.
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
cd react-comprehensive
|
|
53
|
+
npm install reactive-md@0.6.0
|
|
54
|
+
npm run dev
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Change the rate or inventory buttons, rate the course, and click a paragraph or a control label to see the reported source range. The host schema and renderer are in [react-comprehensive/main.jsx](react-comprehensive/main.jsx).
|
|
58
|
+
|
|
43
59
|
## Local package verification
|
|
44
60
|
|
|
45
61
|
To try an unpublished build, run `npm pack` in the repository root and replace `reactive-md@0.6.0` in the install commands with the absolute path to the generated `reactive-md-0.6.0.tgz`.
|
|
46
62
|
|
|
47
|
-
From the source repository root, `npm run
|
|
63
|
+
From the source repository root, `npm run check` runs the complete gate, including standalone offline installation from the packed tarball, strict type checking, combined-feature checks, React rendering and HTML export. Use `npm run test:boundary` for the focused package check after building. See the [integration guide](../../docs/integration/local-integration-en.md) for the API and host policies.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# 扩展 SDK 使用方
|
|
2
|
+
|
|
3
|
+
**中文** · [English](README.md)
|
|
4
|
+
|
|
5
|
+
该 fixture 通过公开包导出定义了一个评分控件、一个 Markdown 提示容器,以及明暗纸张主题。评分控件与内置数字控件共享数值绑定。
|
|
6
|
+
|
|
7
|
+
`advanced.tsx` 增加了坐标控件、字符串集合、数字集合和 Markdown 容器。坐标、多选和卡片契约来自 `defaultPreset.components`;项目提供自己的 React 实现。其验收检查覆盖原子回滚、数组限制与复制、重置、禁用/隐藏状态、静态输出、SSR,以及离线桌面/移动端恢复。`advanced-standalone.ts` 为该项导出打包同一组已安装实现。
|
|
8
|
+
|
|
9
|
+
本 fixture 面向`reactive-md@0.8.0`,SDK 契约仍为 `0.7.0`。验证器在独立目录中安装引擎和 peer 依赖;准备发布时使用新打包的引擎 tarball,0.8.0 发布后再使用公开包。
|
|
10
|
+
|
|
11
|
+
在仓库根目录:
|
|
12
|
+
|
|
13
|
+
```powershell
|
|
14
|
+
npm.cmd run build:lib
|
|
15
|
+
npm.cmd run test:sdk-consumer
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
验证器把该项目复制到独立的临时目录,安装实际的包与 peer tarball,检查 TypeScript 和 Node SSR,构建宿主专用的独立入口,并在全新的浏览器上下文中验证静态及离线交互 HTML。它不使用源码别名或仓库依赖 junction。结果和使用方目录见 `artifacts/sdk-consumer/verification.json`。
|
|
19
|
+
|
|
20
|
+
手动开发时,在该目录的副本中安装经验证的 tarball,安装其开发依赖,然后运行 `npm run dev`。主题样式表由 `main.tsx` 显式加载。`standalone.ts` 是可信入口,用于在离线输出中恢复同一组已安装实现。
|
|
21
|
+
|
|
22
|
+
运行时不根据文档声明获取组件代码。宿主代码在挂载前导入实现。导出器在生成 HTML 前检查组件契约、能力、主题和声明的资源。
|
|
23
|
+
|
|
24
|
+
中文接口说明:[扩展 SDK 预览](../../../docs/integration/extension-sdk-ch.md)。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Extension SDK consumer
|
|
2
|
+
|
|
3
|
+
**English** · [中文](README-ch.md)
|
|
4
|
+
|
|
5
|
+
This fixture defines a rating control, a Markdown hint container, and a light/dark paper theme through public package exports. The rating shares its numeric binding with the built-in number control.
|
|
6
|
+
|
|
7
|
+
`advanced.tsx` adds a coordinate control, string collection, numeric collection and Markdown container. The coordinate, multi-select and card contracts come from `defaultPreset.components`; the project supplies its own React implementations. Its acceptance checks cover atomic rollback, array limits and copies, reset, disabled/hidden states, static output, SSR and offline desktop/mobile restoration. `advanced-standalone.ts` bundles the same installed implementations for that export.
|
|
8
|
+
|
|
9
|
+
This fixture targets `reactive-md@0.8.0`; its SDK contract remains at `0.7.0`. The verifier installs the engine and peer dependencies in a separate directory. Use a freshly packed engine tarball while preparing the release, then the published package after 0.8.0 is available.
|
|
10
|
+
|
|
11
|
+
From the repository root:
|
|
12
|
+
|
|
13
|
+
```powershell
|
|
14
|
+
npm.cmd run build:lib
|
|
15
|
+
npm.cmd run test:sdk-consumer
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The verifier copies this project to a separate temporary directory, installs the actual package and peer tarballs, checks TypeScript and Node SSR, builds a host-specific standalone entry, and verifies static and offline interactive HTML in fresh browser contexts. It uses no source aliases or repository dependency junctions. See `artifacts/sdk-consumer/verification.json` for the result and consumer directory.
|
|
19
|
+
|
|
20
|
+
For manual development, install the verified tarball in a copy of this directory, install its development dependencies, then run `npm run dev`. The theme stylesheet is loaded explicitly by `main.tsx`. `standalone.ts` is the trusted entry used to restore the same installed implementations in offline output.
|
|
21
|
+
|
|
22
|
+
The runtime does not fetch component code based on document declarations. Host code imports the implementations before mounting. The exporter checks the component contracts, capabilities, theme, and declared resources before producing the HTML.
|
|
23
|
+
|
|
24
|
+
中文接口说明:[扩展 SDK 预览](../../../docs/integration/extension-sdk-ch.md)。
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { mountAll } from 'reactive-md/standalone';
|
|
2
|
+
import { advancedReactConfig } from './advanced';
|
|
3
|
+
|
|
4
|
+
const run = () => mountAll(document, { reactConfig: advancedReactConfig });
|
|
5
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run, { once: true });
|
|
6
|
+
else queueMicrotask(run);
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { createLocalConfig, defineLocalComponent, type LocalComponentDefinition } from 'reactive-md/sdk';
|
|
3
|
+
import { defaultPreset } from 'reactive-md/presets/default';
|
|
4
|
+
import { createReactConfig, defineReactComponent, type LocalComponentContext } from 'reactive-md/react';
|
|
5
|
+
|
|
6
|
+
// Reuse public contracts to prove that their semantics also apply to external names.
|
|
7
|
+
function extend(name: string, next: string): LocalComponentDefinition {
|
|
8
|
+
const original = defaultPreset.components.find(item => item.name === name);
|
|
9
|
+
if (!original) throw new Error(`Missing default component ${name}`);
|
|
10
|
+
return defineLocalComponent({ ...original, id: `example/${next}`, name: next, version: '1.0.0',
|
|
11
|
+
authoring: { title: { en: next, zh: next }, insertText: next === 'vector-pad'
|
|
12
|
+
? '<vector-pad label="Vector" bind-x="pointX" bind-y="pointY">'
|
|
13
|
+
: next === 'basket' ? '<basket label="Basket"><option value="one">One</option></basket>'
|
|
14
|
+
: '<memo-box title="Memo">\n**Markdown**\n</memo-box>' },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export const vector = extend('coordinate', 'vector-pad');
|
|
18
|
+
export const basket = extend('multi-select', 'basket');
|
|
19
|
+
export const memo = extend('card', 'memo-box');
|
|
20
|
+
export const series = defineLocalComponent({
|
|
21
|
+
id: 'example/number-series', name: 'number-series', version: '1.0.0', protocol: 'reactive-md-component/v1', form: 'leaf',
|
|
22
|
+
props: {}, bindings: { value: { kind: 'number-array', family: 'collection', bind: 'bind', initial: 'initial',
|
|
23
|
+
initialRule: 'empty-array', exclusive: true, maxItems: { literal: 2 } } },
|
|
24
|
+
capabilities: { interactive: true, static: true, ssr: true, offline: true },
|
|
25
|
+
authoring: { title: { en: 'Number series' }, insertText: '<number-series bind="samples" initial="[1,2]">' },
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
let mounted = 0;
|
|
29
|
+
export const activeVectors = () => mounted;
|
|
30
|
+
|
|
31
|
+
function Vector(ctx: LocalComponentContext) {
|
|
32
|
+
const [message, setMessage] = useState('');
|
|
33
|
+
useEffect(() => { mounted++; return () => { mounted--; }; }, []);
|
|
34
|
+
useEffect(() => setMessage(''), [ctx.resetToken, ctx.visible]);
|
|
35
|
+
const x = ctx.bindings.get('x');
|
|
36
|
+
const y = ctx.bindings.get('y');
|
|
37
|
+
const move = (nextX: number, nextY: number) => {
|
|
38
|
+
const result = ctx.bindings.setMany({ x: nextX, y: nextY });
|
|
39
|
+
setMessage(result.ok ? 'accepted' : 'rejected');
|
|
40
|
+
};
|
|
41
|
+
return <div data-vector data-reset-token={ctx.resetToken}>
|
|
42
|
+
<output aria-label="Vector value">{String(x)}, {String(y)}</output>
|
|
43
|
+
<button disabled={ctx.disabled || ctx.bindings.isReadOnly} onClick={() => move(2, 3)}>Move vector</button>
|
|
44
|
+
<button disabled={ctx.disabled || ctx.bindings.isReadOnly} onClick={() => move(4, 99)}>Invalid vector</button>
|
|
45
|
+
<output aria-label="Vector result">{message}</output>
|
|
46
|
+
</div>;
|
|
47
|
+
}
|
|
48
|
+
function Basket(ctx: LocalComponentContext) {
|
|
49
|
+
const value = ctx.bindings.value.get();
|
|
50
|
+
const selected = Array.isArray(value) ? value as readonly string[] : [];
|
|
51
|
+
const [message, setMessage] = useState('');
|
|
52
|
+
useEffect(() => setMessage(''), [ctx.resetToken]);
|
|
53
|
+
return <fieldset data-basket disabled={ctx.disabled || ctx.bindings.isReadOnly}><legend>{String(ctx.props.label)}</legend>
|
|
54
|
+
{ctx.children.options().map(option => <label key={option.value}>
|
|
55
|
+
<input type="checkbox" checked={selected.includes(option.value)} onChange={() => {
|
|
56
|
+
const next = selected.includes(option.value) ? selected.filter(item => item !== option.value) : [...selected, option.value];
|
|
57
|
+
const result = ctx.bindings.value.set(next);
|
|
58
|
+
setMessage(result.ok ? 'accepted' : 'rejected');
|
|
59
|
+
}}/>{option.render()}
|
|
60
|
+
</label>)}
|
|
61
|
+
<output aria-label="Basket value">{selected.join(',')}</output>
|
|
62
|
+
<output aria-label="Basket result">{message}</output>
|
|
63
|
+
</fieldset>;
|
|
64
|
+
}
|
|
65
|
+
function Memo(ctx: LocalComponentContext) {
|
|
66
|
+
return <aside data-memo><h3>{String(ctx.props.title)}</h3>{ctx.children.render()}</aside>;
|
|
67
|
+
}
|
|
68
|
+
function Series(ctx: LocalComponentContext) {
|
|
69
|
+
const value = ctx.bindings.value.get();
|
|
70
|
+
const [message, setMessage] = useState('');
|
|
71
|
+
useEffect(() => setMessage(''), [ctx.resetToken]);
|
|
72
|
+
return <div data-series>
|
|
73
|
+
<output aria-label="Series value">{Array.isArray(value) ? value.join(',') : 'invalid'}</output>
|
|
74
|
+
<button disabled={ctx.disabled || ctx.bindings.isReadOnly} onClick={() => setMessage(ctx.bindings.value.set([3, 4]).ok ? 'accepted' : 'rejected')}>Set series</button>
|
|
75
|
+
<button disabled={ctx.disabled || ctx.bindings.isReadOnly} onClick={() => setMessage(ctx.bindings.value.set([3, Infinity]).ok ? 'accepted' : 'rejected')}>Invalid series</button>
|
|
76
|
+
<output aria-label="Series result">{message}</output>
|
|
77
|
+
</div>;
|
|
78
|
+
}
|
|
79
|
+
export const advancedConfig = createLocalConfig({ components: [vector, basket, memo, series] });
|
|
80
|
+
export const advancedReactConfig = createReactConfig(advancedConfig, { components: [
|
|
81
|
+
defineReactComponent(vector, { render: Vector, renderStatic: Vector }),
|
|
82
|
+
defineReactComponent(basket, { render: Basket, renderStatic: Basket }),
|
|
83
|
+
defineReactComponent(memo, { render: Memo, renderStatic: Memo }),
|
|
84
|
+
defineReactComponent(series, { render: Series, renderStatic: Series }),
|
|
85
|
+
] });
|
|
86
|
+
export const advancedSource = `<toggle bind="shown" label="Show vector" initial="true">
|
|
87
|
+
<toggle bind="blocked" label="Disable vector">
|
|
88
|
+
<panel title="Advanced SDK">
|
|
89
|
+
<if when="{{ shown }}">
|
|
90
|
+
<vector-pad label="Vector" bind-x="pointX" bind-y="pointY" disabled="{{ blocked }}">
|
|
91
|
+
</if>
|
|
92
|
+
<basket label="Basket" bind="picked" max-selected="2" initial="one">
|
|
93
|
+
<option value="one">One</option>
|
|
94
|
+
<option value="two">Two</option>
|
|
95
|
+
<option value="three">Three</option>
|
|
96
|
+
</basket>
|
|
97
|
+
<number-series bind="samples" initial="[1,2]">
|
|
98
|
+
<memo-box title="Memo">
|
|
99
|
+
Coordinates: **{{ pointX }}, {{ pointY }}**.
|
|
100
|
+
</memo-box>
|
|
101
|
+
</panel>`;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useEffect, useState, type KeyboardEvent } from 'react';
|
|
2
|
+
import { defineLocalComponent, createLocalConfig, defineLocalTheme } from 'reactive-md/sdk';
|
|
3
|
+
import { defaultPreset } from 'reactive-md/presets/default';
|
|
4
|
+
import { createReactConfig, defineReactComponent, type LocalComponentContext } from 'reactive-md/react';
|
|
5
|
+
|
|
6
|
+
export const rating = defineLocalComponent({
|
|
7
|
+
id: 'example/rating', name: 'rating', version: '1.0.0', protocol: 'reactive-md-component/v1', form: 'leaf',
|
|
8
|
+
props: {
|
|
9
|
+
label: { kind: 'string', required: true },
|
|
10
|
+
max: { kind: 'number', default: 5, integer: true, min: 1, max: 10, dynamic: true },
|
|
11
|
+
},
|
|
12
|
+
styles: ['example/rating.css'],
|
|
13
|
+
bindings: { value: {
|
|
14
|
+
kind: 'number', family: 'number', bind: 'bind', initial: 'initial', initialRule: 'nearest-zero',
|
|
15
|
+
constraints: { min: { literal: 0 }, max: { prop: 'max' }, step: { literal: 1 } },
|
|
16
|
+
} },
|
|
17
|
+
capabilities: { interactive: true, static: true, ssr: true, offline: true },
|
|
18
|
+
authoring: {
|
|
19
|
+
title: { en: 'Rating', zh: '评分' }, category: 'input',
|
|
20
|
+
description: { en: 'A rating sharing a numeric binding.', zh: '与数字控件共享绑定的评分。' },
|
|
21
|
+
insertText: '<rating bind="score" label="评分">',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const hint = defineLocalComponent({
|
|
26
|
+
id: 'example/hint', name: 'hint', version: '1.0.0', protocol: 'reactive-md-component/v1', form: 'container',
|
|
27
|
+
props: { title: { kind: 'string', default: '说明' } }, children: { kind: 'markdown' },
|
|
28
|
+
styles: ['example/hint.css'],
|
|
29
|
+
capabilities: { interactive: true, static: true, ssr: true, offline: true },
|
|
30
|
+
authoring: { title: { en: 'Hint', zh: '提示' }, category: 'content', insertText: '<hint title="说明">\n普通 **Markdown**。\n</hint>' },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Component structure is independent of the optional theme enhancements.
|
|
34
|
+
export const componentResources = [
|
|
35
|
+
{ id: 'example/rating.css', css: `.local-document .example-rating { display:flex; align-items:center; gap:var(--space-2,8px); flex-wrap:wrap; }
|
|
36
|
+
.local-document .example-rating button { padding:8px 12px; color:var(--ink); background:var(--surface); border:1px solid var(--accent); border-radius:var(--radius-control,6px); }
|
|
37
|
+
.local-document .example-rating button[aria-checked="true"] { background:var(--accent); color:var(--surface); }
|
|
38
|
+
.local-document .example-rating button:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
|
|
39
|
+
.local-document .example-rating button:disabled { opacity:var(--disabled-opacity,.5); }` },
|
|
40
|
+
{ id: 'example/hint.css', css: '.local-document .example-hint { border-inline-start:3px solid var(--accent); padding:var(--space-3,12px); background:var(--surface-subtle); }' },
|
|
41
|
+
] as const;
|
|
42
|
+
|
|
43
|
+
export const paper = defineLocalTheme({
|
|
44
|
+
id: 'example/paper', name: 'paper', version: '1.0.0', protocol: 'reactive-md-theme-1', colorSchemes: ['light', 'dark'],
|
|
45
|
+
css: [{ id: 'example/paper.css', css: `
|
|
46
|
+
[data-rmd-theme="paper"] { --surface: #fffdf7; --document-bg: #fffdf7; --ink: #26302d; --accent: #216b54; }
|
|
47
|
+
[data-rmd-theme="paper"][data-color-scheme="dark"] { --surface: #192522; --document-bg: #192522; --ink: #e6f1e9; --accent: #8fd1ab; }
|
|
48
|
+
` }],
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export function RatingControl(ctx: LocalComponentContext) {
|
|
52
|
+
const value = Number(ctx.bindings.value.get());
|
|
53
|
+
const maximum = Number(ctx.props.max);
|
|
54
|
+
const [hovered, setHovered] = useState<number | null>(null);
|
|
55
|
+
useEffect(() => setHovered(null), [ctx.resetToken, ctx.visible]);
|
|
56
|
+
const set = (next: number) => ctx.bindings.value.set(Math.max(0, Math.min(maximum, next)));
|
|
57
|
+
const keyboard = (event: KeyboardEvent<HTMLButtonElement>) => {
|
|
58
|
+
if (event.key === 'ArrowRight' || event.key === 'ArrowUp') { event.preventDefault(); set(value + 1); }
|
|
59
|
+
if (event.key === 'ArrowLeft' || event.key === 'ArrowDown') { event.preventDefault(); set(value - 1); }
|
|
60
|
+
if (event.key === 'Home') { event.preventDefault(); set(0); }
|
|
61
|
+
if (event.key === 'End') { event.preventDefault(); set(maximum); }
|
|
62
|
+
};
|
|
63
|
+
return <div className="example-rating" role="radiogroup" aria-label={String(ctx.props.label)} data-reset-token={ctx.resetToken}>
|
|
64
|
+
<span>{String(ctx.props.label)}</span>
|
|
65
|
+
{Array.from({ length: maximum + 1 }, (_, n) => <button key={n} type="button" role="radio"
|
|
66
|
+
aria-checked={value === n} aria-label={`评分 ${n}`} disabled={ctx.disabled || !ctx.visible}
|
|
67
|
+
tabIndex={value === n ? 0 : -1} onClick={() => set(n)} onKeyDown={keyboard}
|
|
68
|
+
onPointerEnter={() => setHovered(n)} onPointerLeave={() => setHovered(null)}>{n}</button>)}
|
|
69
|
+
<output aria-live="polite" data-rating-value>{hovered ?? value} / {maximum}</output>
|
|
70
|
+
</div>;
|
|
71
|
+
}
|
|
72
|
+
export function RatingText(ctx: LocalComponentContext) {
|
|
73
|
+
return <p className="example-rating-static">{String(ctx.props.label)}: {String(ctx.bindings.value.get())} / {String(ctx.props.max)}</p>;
|
|
74
|
+
}
|
|
75
|
+
export function Hint(ctx: LocalComponentContext) {
|
|
76
|
+
return <aside className="example-hint"><h3>{String(ctx.props.title)}</h3>{ctx.children.render()}</aside>;
|
|
77
|
+
}
|
|
78
|
+
export const config = createLocalConfig({ presets: [defaultPreset], components: [rating, hint], themes: [paper] });
|
|
79
|
+
export const reactConfig = createReactConfig(config, { components: [
|
|
80
|
+
defineReactComponent(rating, { render: RatingControl, renderStatic: RatingText }),
|
|
81
|
+
defineReactComponent(hint, { render: Hint, renderStatic: Hint }),
|
|
82
|
+
] });
|
|
83
|
+
export const source = `<theme name="paper">
|
|
84
|
+
|
|
85
|
+
# SDK 外部消费示例
|
|
86
|
+
|
|
87
|
+
<panel title="评分面板">
|
|
88
|
+
<number bind="score" label="内置评分" min="0" max="5" initial="3">
|
|
89
|
+
<rating bind="score" label="你的评分" max="5">
|
|
90
|
+
|
|
91
|
+
<hint title="说明">
|
|
92
|
+
当前评分为 **{{ score }}**。
|
|
93
|
+
|
|
94
|
+
- 普通 Markdown 与响应式内容共享文档运行时。
|
|
95
|
+
</hint>
|
|
96
|
+
</panel>
|
|
97
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRoot } from 'react-dom/client';
|
|
2
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
3
|
+
import { collectLocalThemeCss } from 'reactive-md/sdk';
|
|
4
|
+
import { reactConfig, paper, source, componentResources } from './extensions';
|
|
5
|
+
import 'reactive-md/styles.css';
|
|
6
|
+
|
|
7
|
+
const style = document.createElement('style');
|
|
8
|
+
style.textContent = componentResources.map(resource => resource.css).join('\n') + '\n' + collectLocalThemeCss(paper);
|
|
9
|
+
document.head.append(style);
|
|
10
|
+
createRoot(document.getElementById('root')!).render(<LocalReactiveDocument source={source} reactConfig={reactConfig} locale="zh" />);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "reactive-md-extension-sdk-consumer", "version": "0.0.0", "private": true, "type": "module",
|
|
3
|
+
"scripts": { "dev": "vite", "build": "vite build", "typecheck": "tsc --noEmit" },
|
|
4
|
+
"dependencies": { "reactive-md": "0.8.0", "react": "^19.0.0", "react-dom": "^19.0.0" },
|
|
5
|
+
"devDependencies": { "typescript": "^7.0.0", "vite": "^8.0.0", "@types/react": "^19.0.0", "@types/react-dom": "^19.0.0" }
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { mountAll } from 'reactive-md/standalone';
|
|
2
|
+
import { reactConfig } from './extensions';
|
|
3
|
+
|
|
4
|
+
// Built by the host into an IIFE before creating the offline HTML.
|
|
5
|
+
const run = () => mountAll(document, { reactConfig });
|
|
6
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', run, { once: true });
|
|
7
|
+
else queueMicrotask(run);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022", "lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
4
|
+
"module": "ESNext", "moduleResolution": "Bundler", "jsx": "react-jsx",
|
|
5
|
+
"strict": true, "skipLibCheck": true, "noEmit": true
|
|
6
|
+
},
|
|
7
|
+
"include": ["extensions.tsx", "main.tsx", "standalone.ts", "advanced.tsx", "advanced-standalone.ts", "env.d.ts"]
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<title>Reactive MD comprehensive host example</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/main.jsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { StrictMode, useMemo, useState } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
4
|
+
import 'reactive-md/styles.css';
|
|
5
|
+
|
|
6
|
+
const SOURCE = `<!-- reactive-md: local-draft-3 -->
|
|
7
|
+
|
|
8
|
+
<external name="exchangeRate" type="number">
|
|
9
|
+
<external name="inventory" type="number">
|
|
10
|
+
|
|
11
|
+
<panel title="Quote">
|
|
12
|
+
<host-rating bind="rating" label="Course rating" initial="4">
|
|
13
|
+
<number bind="quantity" label="Quantity" initial="2" min="1" max="{{ inventory }}">
|
|
14
|
+
<number bind="budget" label="Budget (CNY)" initial="600" min="1">
|
|
15
|
+
<number bind="unitUsd" label="Unit price (USD)" initial="129" min="1">
|
|
16
|
+
</panel>
|
|
17
|
+
|
|
18
|
+
<computed name="totalCny" value="{{ quantity * unitUsd * exchangeRate }}">
|
|
19
|
+
<computed name="withinBudget" value="{{ totalCny <= budget }}">
|
|
20
|
+
|
|
21
|
+
Rating: {{ rating }} / 5
|
|
22
|
+
|
|
23
|
+
Total: **{{ totalCny }} CNY**
|
|
24
|
+
|
|
25
|
+
<if when="{{ withinBudget }}">Within budget.</if>
|
|
26
|
+
<if when="{{ !withinBudget }}">Over budget. Lower the quantity or raise the budget.</if>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const HOST_COMPONENTS = [
|
|
30
|
+
{
|
|
31
|
+
name: 'host-rating',
|
|
32
|
+
form: 'leaf',
|
|
33
|
+
props: { label: { kind: 'string' } },
|
|
34
|
+
binding: { kind: 'number', min: 0, max: 5, step: 1 },
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
const STORAGE_KEY = 'reactive-md-comprehensive-parameters';
|
|
39
|
+
|
|
40
|
+
function readSavedParameters() {
|
|
41
|
+
try {
|
|
42
|
+
const parsed = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? 'null');
|
|
43
|
+
return parsed && typeof parsed === 'object' ? parsed : undefined;
|
|
44
|
+
} catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function RatingRenderer({ ctx }) {
|
|
50
|
+
const value = typeof ctx.value === 'number' ? ctx.value : 0;
|
|
51
|
+
return (
|
|
52
|
+
<div className="host-rating">
|
|
53
|
+
<span>{String(ctx.props.label ?? 'Rating')}</span>
|
|
54
|
+
{[1, 2, 3, 4, 5].map((star) => (
|
|
55
|
+
<button
|
|
56
|
+
key={star}
|
|
57
|
+
type="button"
|
|
58
|
+
disabled={ctx.disabled}
|
|
59
|
+
aria-pressed={value === star}
|
|
60
|
+
onClick={() => ctx.setValue(star)}
|
|
61
|
+
>
|
|
62
|
+
{star <= value ? '★' : '☆'}
|
|
63
|
+
</button>
|
|
64
|
+
))}
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function App() {
|
|
70
|
+
const [exchangeRate, setExchangeRate] = useState(7.2);
|
|
71
|
+
const [inventory, setInventory] = useState(6);
|
|
72
|
+
const [target, setTarget] = useState(null);
|
|
73
|
+
const [instance, setInstance] = useState(0);
|
|
74
|
+
const initialParameters = useMemo(readSavedParameters, [instance]);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<main style={{ fontFamily: 'system-ui, sans-serif', margin: '0 auto', maxWidth: 900, padding: 24 }}>
|
|
78
|
+
<h1>Reactive MD host example</h1>
|
|
79
|
+
<p>
|
|
80
|
+
The host supplies the exchange rate and inventory, saves reader parameters, and receives
|
|
81
|
+
preview-to-source navigation targets.
|
|
82
|
+
</p>
|
|
83
|
+
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', marginBottom: 16 }}>
|
|
84
|
+
<button type="button" onClick={() => setExchangeRate(7.2)}>Rate 7.2</button>
|
|
85
|
+
<button type="button" onClick={() => setExchangeRate(7.3)}>Rate 7.3</button>
|
|
86
|
+
<label>
|
|
87
|
+
Inventory <input type="number" min="1" max="20" value={inventory} onChange={(event) => setInventory(Number(event.target.value))} />
|
|
88
|
+
</label>
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
onClick={() => {
|
|
92
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
93
|
+
setInstance((value) => value + 1);
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
Reset saved parameters
|
|
97
|
+
</button>
|
|
98
|
+
</div>
|
|
99
|
+
<p>
|
|
100
|
+
Last source target:{' '}
|
|
101
|
+
{target ? `${target.nodeType} ${target.componentName ?? ''} [${target.range.start}, ${target.range.end})` : 'click a paragraph or control label'}
|
|
102
|
+
</p>
|
|
103
|
+
<LocalReactiveDocument
|
|
104
|
+
key={instance}
|
|
105
|
+
source={SOURCE}
|
|
106
|
+
compileOptions={{ hostComponents: HOST_COMPONENTS }}
|
|
107
|
+
initialParameters={initialParameters}
|
|
108
|
+
externalValues={{ exchangeRate, inventory }}
|
|
109
|
+
onParametersChange={(parameters) => {
|
|
110
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(parameters));
|
|
111
|
+
}}
|
|
112
|
+
onSourceNavigate={setTarget}
|
|
113
|
+
hostRenderer={(_node, _data, ctx) => <RatingRenderer ctx={ctx} />}
|
|
114
|
+
/>
|
|
115
|
+
</main>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
createRoot(document.getElementById('root')).render(
|
|
120
|
+
<StrictMode>
|
|
121
|
+
<App />
|
|
122
|
+
</StrictMode>,
|
|
123
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "reactive-md-comprehensive-example",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 127.0.0.1 --port 5190 --strictPort"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"reactive-md": "0.6.0",
|
|
11
|
+
"react": "19.3.1",
|
|
12
|
+
"react-dom": "19.3.1"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@vitejs/plugin-react": "6.1.2",
|
|
16
|
+
"vite": "8.3.5"
|
|
17
|
+
}
|
|
18
|
+
}
|