reactive-md 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG-ch.md +333 -319
- package/CHANGELOG.md +334 -320
- package/CONTRIBUTING-ch.md +22 -22
- package/CONTRIBUTING.md +22 -22
- package/README-ch.md +431 -431
- package/README-en.md +431 -431
- package/README.md +429 -429
- package/SECURITY-ch.md +83 -83
- package/SECURITY.md +83 -83
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +263 -263
- package/cli/assets.mjs +395 -395
- package/cli/build.mjs +445 -445
- package/cli/check.mjs +444 -444
- package/cli/document.mjs +130 -130
- package/cli/errors.mjs +61 -61
- package/cli/fs-utils.mjs +133 -133
- package/cli/glob.mjs +203 -203
- package/cli/help.mjs +323 -323
- package/cli/init.mjs +1577 -1577
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +65 -65
- package/cli/migrate.mjs +368 -368
- package/cli/package-loader.mjs +41 -41
- package/cli/package.mjs +211 -211
- package/dist-library/{LocalDocumentView-sthUP0ct.js → LocalDocumentView-BuqgJZEY.js} +11 -11
- package/dist-library/{LocalDocumentViewCore-GiWV3bey.js → LocalDocumentViewCore-DXE0I0Qc.js} +210 -209
- package/dist-library/{LocalReactiveDocumentCore-ZjQSGyHE.js → LocalReactiveDocumentCore-CWBe4Mm5.js} +8 -8
- package/dist-library/{authoring-Dsune4Hy.js → authoring-Ci_KzJ0q.js} +53 -53
- package/dist-library/{compile-wUv8KEge.js → compile-Dx6Uw3D9.js} +11 -11
- package/dist-library/{compiler-core-As_m-MNm.js → compiler-core-DDDdvuLy.js} +883 -818
- package/dist-library/compiler-dxLPB9Ym.js +86 -0
- package/dist-library/{component-state-C52ZFJGl.js → component-state-BRwvTV0d.js} +15 -14
- package/dist-library/component-state-CwKX_SN5.js +763 -0
- package/dist-library/{config-BadfhjdP.js → config-DXLvctiZ.js} +68 -66
- package/dist-library/config-validation-D3D7Dy2J.js +586 -0
- package/dist-library/{controls-CcT6n7k_.js → controls-DoZyLCrV.js} +3 -3
- package/dist-library/{coordinate-CWS9p5q_.js → coordinate-B1VFK9fd.js} +2 -2
- package/dist-library/{data-table-Bgccxd7h.js → data-table-8-3F15Jf.js} +3 -3
- package/dist-library/{default-components-BwQf0oP-.js → default-components-s21NevON.js} +29 -28
- package/dist-library/{display-B-VhqVND.js → display-B_uutKkN.js} +1 -1
- package/dist-library/{config-validation-F47AcE6o.js → document-theme-C8J6UyNO.js} +193 -731
- package/dist-library/{export-BqVmTXm8.js → export-CIAIPBov.js} +35 -34
- package/dist-library/{gallery-CY6mTx8i.js → gallery-Dv1rOvL0.js} +1 -1
- package/dist-library/{html-CNT4KD-2.js → html-Cr4CBwAH.js} +42 -41
- package/dist-library/identity-BUx0Q_-d.js +40 -0
- package/dist-library/{incremental-Dv0FSp_U.js → incremental-9nx92u9c.js} +12 -10
- package/dist-library/{layout-C0YlEPGr.js → layout-BBB2VF0S.js} +1 -1
- package/dist-library/{mount-preset-KxvtKgJb.js → mount-preset-DMZ5wd3t.js} +3 -3
- package/dist-library/observability-4KqXhIEU.js +421 -0
- package/dist-library/observability-core-Bcu7vpnl.js +24 -0
- package/dist-library/{options-1aDLK7JY.js → options-BBp9IcHm.js} +4 -4
- package/dist-library/{package-core-WFK1RhAZ.js → package-core-K5xesGqy.js} +30 -29
- package/dist-library/{parser-standard-Yuf3A_VI.js → parser-standard-CBA1-hdG.js} +352 -352
- package/dist-library/{plugin-packs-B1XPWcFs.js → plugin-packs-Bh1HhLym.js} +3 -2
- package/dist-library/preset-core-DeZPA8IE.js +1298 -0
- package/dist-library/react-0DCh-Mar.js +7 -0
- package/dist-library/reactive-md-authoring.js +19 -19
- package/dist-library/reactive-md-build.js +48 -10
- package/dist-library/reactive-md-compiler-standard.js +6 -6
- package/dist-library/reactive-md-compiler.js +3 -3
- package/dist-library/reactive-md-default-packs.js +3 -2
- package/dist-library/reactive-md-default-preset.js +3 -2
- package/dist-library/reactive-md-export.js +4 -4
- package/dist-library/reactive-md-minimal-preset.js +2 -2
- package/dist-library/reactive-md-minimal-react-preset.js +3 -3
- package/dist-library/reactive-md-observability.js +4 -0
- package/dist-library/reactive-md-plugin-chart.js +3 -3
- package/dist-library/reactive-md-plugin-data.js +5 -5
- package/dist-library/reactive-md-plugin-diagram.js +4 -4
- package/dist-library/reactive-md-plugin-forms.js +4 -4
- package/dist-library/reactive-md-plugin-gallery.js +3 -3
- package/dist-library/reactive-md-plugin-navigation.js +3 -3
- package/dist-library/reactive-md-plugin-network.js +4 -3
- package/dist-library/reactive-md-plugin-plot.js +4 -4
- package/dist-library/reactive-md-print.css +304 -304
- package/dist-library/reactive-md-react-minimal.js +4 -4
- package/dist-library/reactive-md-react-server.js +6 -6
- package/dist-library/reactive-md-react-unstyled.js +11 -11
- package/dist-library/reactive-md-react.js +11 -11
- package/dist-library/reactive-md-runtime-browser.js +2 -1
- package/dist-library/reactive-md-runtime.js +4 -3
- package/dist-library/reactive-md-sdk.js +8 -7
- package/dist-library/reactive-md-standalone-configured.js +2 -2
- package/dist-library/reactive-md-standalone-host.js +2 -2
- package/dist-library/reactive-md-testing-browser.js +2 -2
- package/dist-library/reactive-md-testing-react.js +6 -6
- package/dist-library/reactive-md-testing.js +5 -5
- package/dist-library/reactive-md.js +556 -367
- package/dist-library/{registry-B9NGct4d.js → registry-D6OGkOcX.js} +3 -3
- package/dist-library/{registry-core-Bbad9Bm2.js → registry-core-C9xOunaw.js} +1 -1
- package/dist-library/{resources-D2GDQS0p.js → resources-B0x_w3s9.js} +71 -46
- package/dist-library/{runtime-B2fxeveq.js → runtime-BDnnimPA.js} +17 -16
- package/dist-library/{runtime-kcA7bG7G.js → runtime-BpQdZmFI.js} +311 -305
- package/dist-library/{schema-BufhKUSM.js → schema-BryM_VRW.js} +14 -14
- package/dist-library/{sdk-core-BoJT1SIt.js → sdk-core-ChslheKs.js} +33 -32
- package/dist-library/{session-core-nmJHuR9c.js → session-core-dxQCJBNa.js} +15 -14
- package/dist-library/{shareable-DpbE-59H.js → shareable-B8xMoGEa.js} +179 -176
- package/dist-library/types/build/diagnostics.d.ts +1 -1
- package/dist-library/types/local/index.d.ts +6 -0
- package/dist-library/types/local/observability-codes.d.ts +2 -0
- package/dist-library/types/local/observability-core.d.ts +25 -0
- package/dist-library/types/local/observability-messages.d.ts +6 -0
- package/dist-library/types/local/observability.d.ts +43 -0
- package/dist-library/types/local/parsing/parser-internals.d.ts +2 -1
- package/dist-library/types/local/transport/worker.d.ts +52 -1
- package/dist-library/types/local/types.d.ts +8 -0
- package/dist-library/types/observability.d.ts +7 -0
- package/dist-library/{types-BeNtPqdY.js → types-Ib5kSScP.js} +1 -1
- package/dist-library/types-daDo2c_w.js +3 -0
- package/dist-library/{validation-BEBA_HvS.js → validation-B3RI0xOk.js} +251 -249
- package/dist-library/version-DAxuGOG2.js +147 -0
- package/dist-library/{visual-frame-CyV1FXzs.js → visual-frame-_rcd5HUv.js} +1 -1
- package/dist-library/{visuals-BZbZYA7w.js → visuals-DkDhNdEZ.js} +17 -17
- package/dist-standalone/reactive-md-standalone.js +118 -118
- package/docs/README-ch.md +101 -95
- package/docs/README.md +101 -95
- package/docs/compatibility/api-stability-ch.md +25 -0
- package/docs/compatibility/api-stability-en.md +25 -0
- package/docs/compatibility/compatibility-ch.md +146 -129
- package/docs/compatibility/compatibility-en.md +146 -129
- package/docs/compatibility/compatibility-manifest.schema.json +161 -0
- package/docs/compatibility/deprecation-ch.md +21 -0
- package/docs/compatibility/deprecation-en.md +21 -0
- package/docs/compatibility/source-versioning-ch.md +162 -162
- package/docs/compatibility/source-versioning-en.md +162 -162
- package/docs/compatibility/support-matrix-ch.md +108 -0
- package/docs/compatibility/support-matrix-en.md +108 -0
- package/docs/development/component-development-ch.md +66 -66
- package/docs/development/component-development-en.md +66 -66
- package/docs/development/component-development-reference-ch.md +253 -253
- package/docs/development/component-development-reference-en.md +238 -238
- package/docs/development/component-protocol-ch.md +748 -748
- package/docs/development/component-protocol-en.md +750 -750
- package/docs/development/extension-tutorial-ch.md +308 -308
- package/docs/development/extension-tutorial-en.md +308 -308
- package/docs/development/performance-overview-ch.md +422 -422
- package/docs/development/performance-overview-en.md +422 -422
- package/docs/guides/local-guide-ch.md +532 -532
- package/docs/guides/local-guide-en.md +532 -532
- package/docs/integration/author-tools-ch.md +64 -64
- package/docs/integration/author-tools-en.md +64 -64
- package/docs/integration/compiler-ch.md +49 -49
- package/docs/integration/compiler-en.md +36 -36
- package/docs/integration/directory-discovery-en.md +1 -1
- package/docs/integration/editor-ch.md +295 -295
- package/docs/integration/editor-en.md +303 -303
- package/docs/integration/extension-sdk-ch.md +394 -394
- package/docs/integration/extension-sdk-en.md +379 -379
- package/docs/integration/local-integration-ch.md +646 -646
- package/docs/integration/local-integration-en.md +662 -662
- package/docs/integration/shareable-export-ch.md +307 -307
- package/docs/integration/shareable-export-en.md +309 -309
- package/docs/reference/diagnostics-counting-ch.md +104 -104
- package/docs/reference/diagnostics-counting-en.md +104 -104
- package/docs/reference/html-compatibility-ch.md +93 -93
- package/docs/reference/html-compatibility-en.md +95 -95
- package/docs/reference/local-interaction-syntax-ch.md +724 -724
- package/docs/reference/local-interaction-syntax-en.md +722 -722
- package/docs/reference/public-api-ch.md +33 -4
- package/docs/reference/public-api-en.md +33 -4
- package/docs/reference/theme-protocol-ch.md +198 -198
- package/docs/reference/theme-protocol-en.md +217 -217
- package/docs/releases/release-0.4.0-ch.md +91 -91
- package/docs/releases/release-0.4.0-en.md +91 -91
- package/docs/releases/release-0.4.1-ch.md +25 -25
- package/docs/releases/release-0.4.1-en.md +25 -25
- package/docs/releases/release-0.5.0-ch.md +43 -43
- package/docs/releases/release-0.5.0-en.md +43 -43
- package/docs/releases/release-0.5.1-ch.md +41 -41
- package/docs/releases/release-0.5.1-en.md +41 -41
- package/docs/releases/release-0.5.2-ch.md +37 -37
- package/docs/releases/release-0.5.2-en.md +37 -37
- package/docs/releases/release-0.5.3-ch.md +26 -26
- package/docs/releases/release-0.5.3-en.md +26 -26
- package/docs/releases/release-0.6.0-ch.md +59 -59
- package/docs/releases/release-0.6.0-en.md +59 -59
- package/docs/releases/release-0.6.1-ch.md +29 -29
- package/docs/releases/release-0.6.1-en.md +29 -29
- package/docs/releases/release-0.7.0-ch.md +86 -86
- package/docs/releases/release-0.7.0-en.md +86 -86
- package/docs/releases/release-0.9.2-ch.md +33 -0
- package/docs/releases/release-0.9.2-en.md +33 -0
- package/examples/component-package/README-ch.md +101 -101
- package/examples/component-package/README.md +133 -133
- package/examples/conformance/README-ch.md +55 -55
- package/examples/conformance/README.md +55 -55
- package/examples/conformance/component-protocol-1.json +482 -482
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/local-draft-1.json +50 -50
- package/examples/conformance/local-draft-2.json +212 -212
- package/examples/game-2048-package/LICENSE +21 -21
- package/examples/game-2048-package/NOTICES.md +11 -11
- package/examples/game-2048-package/README-ch.md +91 -91
- package/examples/game-2048-package/README.md +98 -98
- package/examples/game-2048-package/package.json +35 -35
- package/examples/game-2048-package/sample/document.reactive.md +17 -17
- package/examples/game-2048-package/scripts/build-export.mjs +44 -44
- package/examples/game-2048-package/scripts/build.mjs +130 -130
- package/examples/game-2048-package/scripts/verify.mjs +180 -180
- package/examples/game-2048-package/src/component.css +161 -161
- package/examples/game-2048-package/src/components.tsx +326 -326
- package/examples/game-2048-package/src/game-engine.ts +228 -228
- package/examples/game-2048-package/src/harness.tsx +34 -34
- package/examples/game-2048-package/src/manifest.ts +85 -85
- package/examples/game-2048-package/src/node-entry.ts +30 -30
- package/examples/game-2048-package/src/sample.ts +4 -4
- package/examples/game-2048-package/tsconfig.json +15 -15
- package/examples/integration/README-ch.md +82 -82
- package/examples/integration/README.md +82 -82
- package/examples/integration/core/index.mjs +32 -32
- package/examples/integration/extension-sdk/README-ch.md +24 -24
- package/examples/integration/extension-sdk/README.md +24 -24
- package/examples/integration/worker/index.html +19 -19
- package/examples/integration/worker/main.js +61 -61
- package/examples/integration/worker/package.json +13 -13
- package/examples/integration/worker/worker.js +3 -3
- package/examples/local/README-ch.md +76 -76
- package/examples/local/README.md +76 -76
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/recipes/invoice-zh.reactive.md +36 -36
- package/examples/local/recipes/invoice.reactive.md +36 -36
- package/examples/local/recipes/workshop-zh.reactive.md +33 -33
- package/examples/local/recipes/workshop.reactive.md +33 -33
- package/examples/local/showcase/README-ch.md +22 -22
- package/examples/local/showcase/README.md +31 -31
- package/examples/local/showcase/explore.reactive.md +102 -102
- package/examples/local/showcase/flow.reactive.md +86 -86
- package/examples/local/showcase/forms.reactive.md +126 -126
- package/examples/local/showcase/functions.reactive.md +119 -119
- package/examples/local/showcase/layout.reactive.md +100 -100
- package/examples/local/showcase/statistics.reactive.md +108 -108
- package/examples/local/showcase/tasks.reactive.md +89 -89
- package/examples/local/showcase/zh/explore.reactive.md +102 -102
- package/examples/local/showcase/zh/flow.reactive.md +86 -86
- package/examples/local/showcase/zh/forms.reactive.md +126 -126
- package/examples/local/showcase/zh/functions.reactive.md +119 -119
- package/examples/local/showcase/zh/layout.reactive.md +100 -100
- package/examples/local/showcase/zh/statistics.reactive.md +108 -108
- package/examples/local/showcase/zh/tasks.reactive.md +89 -89
- package/examples/minimal-extension/README-ch.md +78 -78
- package/examples/minimal-extension/README.md +78 -78
- package/examples/minimal-extension/index.html +15 -15
- package/examples/minimal-extension/package.json +26 -26
- package/examples/minimal-extension/sample/document.reactive.md +10 -10
- package/examples/minimal-extension/scripts/build.mjs +32 -32
- package/examples/minimal-extension/scripts/export.mjs +72 -72
- package/examples/minimal-extension/scripts/test-node.mjs +75 -75
- package/examples/minimal-extension/src/extension.tsx +90 -90
- package/examples/minimal-extension/src/preview.tsx +12 -12
- package/examples/minimal-extension/src/source.ts +4 -4
- package/examples/minimal-extension/tsconfig.json +14 -14
- package/examples/sci-fi-theme/README-ch.md +133 -133
- package/examples/sci-fi-theme/README.md +148 -148
- package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -454
- package/examples/sci-fi-theme/demo/demo.css +638 -638
- package/examples/sci-fi-theme/demo/document.reactive.md +206 -206
- package/examples/sci-fi-theme/demo/index.html +13 -13
- package/examples/sci-fi-theme/demo/main.tsx +215 -215
- package/examples/sci-fi-theme/docs/design-system-ch.md +245 -245
- package/examples/sci-fi-theme/docs/design-system.md +474 -474
- package/examples/sci-fi-theme/package.json +28 -28
- package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -98
- package/examples/sci-fi-theme/src/components.css +2370 -2370
- package/examples/sci-fi-theme/src/index.ts +6 -6
- package/examples/sci-fi-theme/src/notch.css +142 -142
- package/examples/sci-fi-theme/src/sci-fi.css +7 -7
- package/examples/sci-fi-theme/src/theme.ts +39 -39
- package/examples/sci-fi-theme/tsconfig.json +20 -20
- package/examples/sci-fi-theme/vite.config.ts +24 -24
- package/examples/tetris-package/LICENSE +21 -21
- package/examples/tetris-package/NOTICES.md +11 -11
- package/examples/tetris-package/README-ch.md +91 -91
- package/examples/tetris-package/README.md +95 -95
- package/examples/tetris-package/package.json +35 -35
- package/examples/tetris-package/sample/document.reactive.md +16 -16
- package/examples/tetris-package/scripts/build-export.mjs +44 -44
- package/examples/tetris-package/scripts/build.mjs +130 -130
- package/examples/tetris-package/scripts/verify.mjs +173 -173
- package/examples/tetris-package/src/component.css +145 -145
- package/examples/tetris-package/src/components.tsx +334 -334
- package/examples/tetris-package/src/harness.tsx +34 -34
- package/examples/tetris-package/src/manifests.ts +93 -93
- package/examples/tetris-package/src/node-entry.ts +16 -16
- package/examples/tetris-package/src/sample.ts +4 -4
- package/examples/tetris-package/src/tetris-engine.ts +325 -325
- package/examples/tetris-package/tsconfig.json +15 -15
- package/package.json +7 -1
- package/dist-library/compiler-eOfcinZs.js +0 -62
- package/dist-library/component-state-BoLCGee4.js +0 -801
- package/dist-library/preset-core-CKc5YXSM.js +0 -1443
- package/dist-library/react-D5iGiUdL.js +0 -7
package/README-en.md
CHANGED
|
@@ -1,431 +1,431 @@
|
|
|
1
|
-
# Reactive MD
|
|
2
|
-
|
|
3
|
-
**English** · [中文](README-ch.md)
|
|
4
|
-
|
|
5
|
-
> Repository split: this checkout is the language engine. The [editor](https://github.com/yao1145/ReactiveMD-Editor) and [Demo](https://github.com/yao1145/ReactiveMD-Demo) build independently. Engine 0.8 uses the separate reactive-md-editor package. See the [migration guide](docs/releases/release-0.8.0-en.md#repository-split-and-import-migration).
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/reactive-md)
|
|
8
|
-
[](LICENSE)
|
|
9
|
-
|
|
10
|
-
**Interactive Markdown documents that run on the reader's device.**
|
|
11
|
-
|
|
12
|
-
Reactive MD turns ordinary Markdown into a small application: named inputs, live calculations, charts, tables, diagrams, quizzes and formula-driven plots. Authors write tags and expressions in the document; readers get a responsive document with no server, no account and no build step. When the document is finished, export one HTML file that still works offline.
|
|
13
|
-
|
|
14
|
-
- **Local-first by design.** Parameters and state stay in the browser. There is no backend runtime and no round trip for an interaction.
|
|
15
|
-
- **Markdown-native authoring.** Inputs are HTML-style tags, values are `bind` names, and results are `{{ expressions }}`. Authors do not write JavaScript or CSS.
|
|
16
|
-
- **A real expression language.** Arithmetic, comparisons, logic, conditionals, math and formatting functions, aggregates, date helpers and read-only host values.
|
|
17
|
-
- **Rich output without glue code.** Tables, five chart kinds, LaTeX-driven plots, diagrams, steps, tabs and quizzes share the same parameters.
|
|
18
|
-
- **Fast where it matters.** A Worker compiler, block reuse, row-level patches and hard input budgets keep long documents responsive.
|
|
19
|
-
- **Extensible.** Ship an npm component package with a manifest, a React renderer and CSS; it appears in the editor catalog and can be exported offline.
|
|
20
|
-
- **One file to share.** Build a self-contained interactive HTML file or a script-free static snapshot.
|
|
21
|
-
|
|
22
|
-
Themes and components can be loaded from `theme/` and `plugin/` with `reactiveMd()`. See [directory integration](docs/integration/directory-discovery-en.md).
|
|
23
|
-
|
|
24
|
-
## At a glance
|
|
25
|
-
|
|
26
|
-
| Area | What you get |
|
|
27
|
-
| --- | --- |
|
|
28
|
-
| Authoring | `.reactive.md` with HTML-style tags and `{{ expressions }}` |
|
|
29
|
-
| Runtime | Local-first state; no backend required |
|
|
30
|
-
| Views | 51 built-in tags, 5 chart kinds, tables, plots, diagrams, galleries, steps and quizzes |
|
|
31
|
-
| Integration | TypeScript core, React 19 renderer, CM6 source editor, CLI |
|
|
32
|
-
| Extensions | npm component packages, themes, authoring catalog, offline bundles |
|
|
33
|
-
| Sharing | Single-file interactive HTML, static HTML, versioned state files |
|
|
34
|
-
|
|
35
|
-
## Syntax in one example
|
|
36
|
-
|
|
37
|
-
```markdown
|
|
38
|
-
<const name="rate" value="{{ 80 }}">
|
|
39
|
-
<computed name="total" value="{{ people * rate }}">
|
|
40
|
-
|
|
41
|
-
<panel title="Workshop estimate">
|
|
42
|
-
<slider bind="people" label="People" initial="4" min="1" max="12">
|
|
43
|
-
<toggle bind="annual" label="Annual billing">
|
|
44
|
-
</panel>
|
|
45
|
-
|
|
46
|
-
**{{ people }} people × {{ rate }} = {{ total }} USD.**
|
|
47
|
-
|
|
48
|
-
Annual price: **{{ formatCurrency(annual ? total * 0.8 : total, 'USD', 2, 'en-US') }}**.
|
|
49
|
-
|
|
50
|
-
<if when="{{ annual }}">
|
|
51
|
-
<alert tone="success" title="Annual billing">The 20% discount is applied.</alert>
|
|
52
|
-
</if>
|
|
53
|
-
|
|
54
|
-
<chart kind="bar" title="Cost and budget">
|
|
55
|
-
| Category | Cost | Budget |
|
|
56
|
-
| --- | ---: | ---: |
|
|
57
|
-
| Venue | 400 | 500 |
|
|
58
|
-
| Catering | {{ total }} | 900 |
|
|
59
|
-
</chart>
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
The slider and toggle create parameters. `const` and `computed` name derived values. Prose, conditions and the chart read the same state, and every view updates together.
|
|
63
|
-
|
|
64
|
-
| Idea | Syntax |
|
|
65
|
-
| --- | --- |
|
|
66
|
-
| Parameters | `<slider bind="people">`, `<number>`, `<input>`, `<select>`, `<date>`, `<toggle>` |
|
|
67
|
-
| Named values | `<const name="rate" value="{{ 80 }}">`, `<computed name="total" value="{{ people * rate }}">` |
|
|
68
|
-
| Expressions | `{{ people * rate }}`, `{{ annual ? total * 0.8 : total }}` |
|
|
69
|
-
| Formatting | `formatCurrency`, `formatPercent`, `formatNumber`, `formatScientific` |
|
|
70
|
-
| Data views | Markdown tables inside `<table>` and `<chart>`; `bar`, `line`, `area`, `scatter`, `donut` |
|
|
71
|
-
| Structure | `<panel>`, `<card>`, `<grid>`, `<tabs>`, `<accordion>`, `<disclosure>` |
|
|
72
|
-
| Flow and teaching | `<if>`, `<diagram>`, `<steps>`, `<quiz>` |
|
|
73
|
-
| Formulas | LaTeX inside prose and `<plot>`; curves follow shared parameters |
|
|
74
|
-
| Themes | `<theme name="paper">`, light/dark modes, scoped custom CSS |
|
|
75
|
-
|
|
76
|
-
Expressions are deliberately small and safe: no assignment, method calls, property access, custom functions or imports. The full function set is listed in the [syntax specification](docs/reference/local-interaction-syntax-en.md#51-expression-set).
|
|
77
|
-
|
|
78
|
-
## Performance
|
|
79
|
-
|
|
80
|
-
Reactive MD is built for long documents and continuous editing. The current measurements (2026-11-20) use Node 22.17 on an Intel Core Ultra 5 125H and headless Edge 135 at 1440×1000. The machine was not frequency-pinned, so these numbers are reproducible evidence, not a guarantee.
|
|
81
|
-
|
|
82
|
-
| Workload | Result |
|
|
83
|
-
| --- | --- |
|
|
84
|
-
| 1,000,000-character plain document | 12.26 ms first compile, 5.15 ms steady median |
|
|
85
|
-
| 600-section article | 282 ms full compile → 62 ms incremental session (1 block compiled, 1,799 reused) |
|
|
86
|
-
| 500-row dynamic table | input-to-preview 286 ms → 134 ms in the latest comparison |
|
|
87
|
-
| 1,000-item dynamic list, 500 consecutive edits | 0.463 MiB post-GC heap growth |
|
|
88
|
-
| 600-section article through Worker + React | 193 ms round-trip |
|
|
89
|
-
| 1,000 controls through Worker + React | 70 ms round-trip |
|
|
90
|
-
| Parameter write / three-curve plot resample | 0.0004 ms / 0.28 ms |
|
|
91
|
-
|
|
92
|
-
The compiler runs in a Worker, reuses unchanged blocks, publishes row-level patches and negotiates a flat result format for deep trees. Hard budgets stop pathological input before it can freeze the interface: 10,000 nodes by default, 1,000,000 characters and 100 component nesting levels.
|
|
93
|
-
|
|
94
|
-
See [Performance measurements](docs/development/performance-overview-en.md) for the full 45-scenario matrix, regressions, memory checks and reproduction commands, and `benchmarks/performance-overview-2026-11-20.json` for the condensed data.
|
|
95
|
-
|
|
96
|
-
## Try the demo
|
|
97
|
-
|
|
98
|
-
Live demo: [yaozi.raricy.com](https://yaozi.raricy.com/)
|
|
99
|
-
|
|
100
|
-
From the ReactiveMD-Demo repository root:
|
|
101
|
-
|
|
102
|
-
```sh
|
|
103
|
-
npm ci --legacy-peer-deps
|
|
104
|
-
npm run dev
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
This installs the locked engine/editor candidates and starts the standalone app at `http://127.0.0.1:5173`. `/embed.html` shows the embedding path. The language toggle in the masthead switches the whole Demo between English and Chinese and remembers the choice.
|
|
108
|
-
|
|
109
|
-
What to try:
|
|
110
|
-
|
|
111
|
-
- Work through the guided tours: pricing, functions, forms, data and charts, layout, diagrams, checklists and timing.
|
|
112
|
-
- Drag a slider or change a table cell and watch prose, cards and charts update from the same parameters.
|
|
113
|
-
- Open the source editor to see highlighting, completion, binding navigation and diagnostics.
|
|
114
|
-
- Insert a component from the editor toolbar; external packages appear in the catalog with their authoring metadata.
|
|
115
|
-
- Open the Tetris and 2048 plugin examples to see timer-driven and turn-based external components.
|
|
116
|
-
- Export the current preview as a single-file interactive HTML or a static snapshot, then open it offline.
|
|
117
|
-
|
|
118
|
-
Check the integration from the ReactiveMD-Demo repository root:
|
|
119
|
-
|
|
120
|
-
```sh
|
|
121
|
-
npm run build
|
|
122
|
-
npm run test:runtime-extensions
|
|
123
|
-
npm run test:runtime-extensions -- --dev
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
The script starts and stops its own server, exercises the real Worker, both plugin examples, the editor catalog, mobile layout and offline exports, and writes results to `artifacts/demo-extensions/`.
|
|
127
|
-
|
|
128
|
-
## Extend with your own components
|
|
129
|
-
|
|
130
|
-
A plugin is an npm package with three parts: a plain-data manifest, a React implementation and optional CSS. The manifest declares the tag, props, bindings, capabilities and authoring metadata; the implementation reads normalized props and writes through binding handles.
|
|
131
|
-
|
|
132
|
-
```tsx
|
|
133
|
-
// src/my-widget.tsx
|
|
134
|
-
import { defineReactComponentPackage, type LocalComponentContext } from 'reactive-md/react';
|
|
135
|
-
import { manifest } from './manifest.js';
|
|
136
|
-
|
|
137
|
-
export const widgetPackage = defineReactComponentPackage({
|
|
138
|
-
...manifest,
|
|
139
|
-
render: (ctx: LocalComponentContext) => (
|
|
140
|
-
<button onClick={() => ctx.bindings.value.set(1)}>Activate</button>
|
|
141
|
-
),
|
|
142
|
-
css: '.local-document .my-widget { color: var(--ink); }',
|
|
143
|
-
});
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Assemble the host once, and let Vite load the same registration module:
|
|
147
|
-
|
|
148
|
-
```ts
|
|
149
|
-
// extensions.ts
|
|
150
|
-
import { createReactHost } from 'reactive-md/react';
|
|
151
|
-
import { widgetPackage } from 'my-widget/react';
|
|
152
|
-
|
|
153
|
-
export const host = createReactHost({ packages: [widgetPackage] });
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
```ts
|
|
157
|
-
// vite.config.ts
|
|
158
|
-
import { reactiveMd } from 'reactive-md/vite';
|
|
159
|
-
|
|
160
|
-
export default { plugins: [reactiveMd({ extensions: './extensions.ts' })] };
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
The Demo ships two complete installed-package cases:
|
|
164
|
-
|
|
165
|
-
| Package | Tag | Demonstrates | Update guide |
|
|
166
|
-
| --- | --- | --- | --- |
|
|
167
|
-
| `reactive-md-tetris-package` | `<tetris>` | Timer-driven game, keyboard and pointer input, seeded pieces, offline export | [Demo candidate guide](https://github.com/yao1145/ReactiveMD-Demo/blob/main/docs/candidate-package-updates-en.md) |
|
|
168
|
-
| `reactive-md-game-2048-package` | `<game-2048>` | Turn-based state, deterministic spawns, keyboard and pointer input, static preview | [Demo candidate guide](https://github.com/yao1145/ReactiveMD-Demo/blob/main/docs/candidate-package-updates-en.md) |
|
|
169
|
-
|
|
170
|
-
The Demo site runs local copies under `ReactiveMD-Demo/plugin/`; the committed tarballs under `vendor/` are installed-package fixtures for compatibility tests. Both package entries are read through their public `./react` and `./notices` entries. Their authoring metadata feeds the editor catalog, and their capability evidence supports offline export.
|
|
171
|
-
|
|
172
|
-
Component tags must start with a letter, so the 2048 plugin registers `<game-2048>` rather than `<2048>`. See the [component plugin development guide](docs/development/component-development-en.md) and the [full development contract](docs/development/component-development-reference-en.md) for manifests, bindings, themes, resources, compliance tools and packaging.
|
|
173
|
-
|
|
174
|
-
## Where it fits
|
|
175
|
-
|
|
176
|
-
| Scenario | What Reactive MD gives you |
|
|
177
|
-
| --- | --- |
|
|
178
|
-
| Interactive reports and dashboards | One source for prose, parameters, tables and charts; links to related views stay in sync |
|
|
179
|
-
| Teaching, tutorials and courseware | Formula-driven plots, diagrams, guided steps, quizzes and self-checking examples |
|
|
180
|
-
| Pricing, planning and calculators | Shared named calculations, validation, currency and percentage formatting |
|
|
181
|
-
| Forms, checklists and onboarding | Scoped inputs, required fields, checklists and timers without a server |
|
|
182
|
-
| Offline handouts and proposals | A single HTML file with embedded styles, images and runtime; readable without JavaScript |
|
|
183
|
-
| Embedded widgets in apps and docs | React renderer, standalone browser API or `<reactive-md-doc>` elements |
|
|
184
|
-
| Games and experimental interfaces | Component SDK with local React state, keyboard input, timers and offline bundles |
|
|
185
|
-
| Internal tools and living documentation | Local-first state, no account or backend, source stays in plain `.reactive.md` |
|
|
186
|
-
|
|
187
|
-
## Install
|
|
188
|
-
|
|
189
|
-
Reactive MD requires Node.js 22.12 or newer and ships only ESM entries:
|
|
190
|
-
|
|
191
|
-
```sh
|
|
192
|
-
npm install reactive-md
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
The 0.9.
|
|
196
|
-
|
|
197
|
-
```sh
|
|
198
|
-
npm install reactive-md
|
|
199
|
-
# or pin the version
|
|
200
|
-
npm install reactive-md@0.9.
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Read the [0.9.
|
|
204
|
-
|
|
205
|
-
### Upgrade to 0.8.0
|
|
206
|
-
|
|
207
|
-
`reactive-md@0.8.0` moves the source editor to the separate `reactive-md-editor@0.1.0` package. Install the engine and editor separately:
|
|
208
|
-
|
|
209
|
-
```sh
|
|
210
|
-
npm install reactive-md@0.8.0
|
|
211
|
-
npm install reactive-md-editor@0.1.0
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
Read the [0.8.0 release notes](docs/releases/release-0.8.0-en.md) and the [repository migration guide](docs/releases/release-0.8.0-en.md#repository-split-and-import-migration) before replacing `reactive-md/editor` imports. `0.8.0` keeps syntax `local-draft-3`, the `0.7.0` SDK contract and the existing state protocols, so document sources need no migration.
|
|
215
|
-
|
|
216
|
-
The `reactive-md` entry provides the local compiler, expressions and runtime; `reactive-md/react` provides the React renderer. Import component styles from `reactive-md/styles.css`. The `reactive-md-editor` entry provides the source editor with its own stylesheet at `reactive-md-editor/styles.css`. Engine 0.8 removes the old `reactive-md/editor` entries; published 0.7 packages keep them.
|
|
217
|
-
|
|
218
|
-
The core entry does not depend on React:
|
|
219
|
-
|
|
220
|
-
```js
|
|
221
|
-
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
222
|
-
|
|
223
|
-
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
224
|
-
if (result.ok) {
|
|
225
|
-
const runtime = createLocalRuntime(result.document);
|
|
226
|
-
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
227
|
-
finally { runtime.dispose(); }
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
See [Local mode integration](docs/integration/local-integration-en.md) for the full compile and runtime APIs, host URL policy, lifecycle and style overrides.
|
|
232
|
-
|
|
233
|
-
## Choose an entry point by task
|
|
234
|
-
|
|
235
|
-
[Public API reference](docs/reference/public-api-en.md) lists every entry, export, CLI command, browser protocol and the editor package with its detailed purpose. The table below covers the engine subpaths by task.
|
|
236
|
-
|
|
237
|
-
Every subpath is an ESM entry with its own declarations. Pick the one that matches the job; optional peers appear only in the last column.
|
|
238
|
-
|
|
239
|
-
| Task | Entry | What it gives you | What it leaves out | React / Vite |
|
|
240
|
-
| --- | --- | --- | --- | --- |
|
|
241
|
-
| Compile once and run in memory | `reactive-md` | `compileLocal`, `createLocalCompileSession`, `createLocalRuntime`, expressions and plot sampling, state import/export and retention, the host-supplied Worker protocol (`startLocalCompileWorker`, `LocalCompileScheduler`), `createShareableHtml`, the default preset | React, CSS, Vite, the component catalog and toolbar commands, export planning | — |
|
|
242
|
-
| Compile in a Worker or a size-sensitive bundle | `reactive-md/compiler` | `createCompiler` and the `CompileResult` contract: CommonMark, ReactiveMD structure, expressions, bindings, budgets | React, CSS, the compile-worker protocol, session, retention, shareable/export code, default preset, GFM, native HTML, Lezer planning, KaTeX display, plot sampling | — |
|
|
243
|
-
| Keep the full language in one pass | `reactive-md/compiler/standard` | `createStandardCompiler`: adds GFM, native HTML, Lezer block planning, the KaTeX display check, plot formula sampling and the default preset | React, CSS, the compile-worker protocol, session, retention, shareable/export code | — |
|
|
244
|
-
| Render in React | `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView`, `defineReactComponentPackage`, `createReactHost`; the build extracts the stylesheet instead of injecting it | Node build and export tooling, the editor | React 19, plus `reactive-md/styles.css` |
|
|
245
|
-
| Render on a server | `reactive-md/react/server` | `renderLocalStaticDocument` with capability preflight and diagnostics | client runtime, DOM, stylesheet | React 19 + react-dom 19 |
|
|
246
|
-
| Render without the stylesheet import | `reactive-md/react/unstyled` | the same components without the CSS side effect | `styles.css` | React 19 |
|
|
247
|
-
| Build interactive components | `reactive-md/react/runtime` | `useTicker`, `useFrame`, `useSwipe`, `useKeys`, `useComponentState` | the document renderer, the compiler | React 19 |
|
|
248
|
-
| Publish a component package | `reactive-md/sdk` | `defineLocalComponent`, `defineLocalPreset`, manifest, config, registry and theme contracts with validation | React renderers, document rendering, DOM | — |
|
|
249
|
-
| Drive an editor | `reactive-md/authoring` | `analyzeLocalSource`, `completeLocalSource`, `formatLocalSource`, `renameLocalBinding`, the component catalog and toolbar insert commands | React, CSS, DOM, compile sessions | — |
|
|
250
|
-
| Preflight an export | `reactive-md/export` | `createLocalExportPlan`, `createLocalShareableHtml`, restoration requirements, component-state files, style resources | Vite build, React rendering (the caller supplies markup), the CLI | — |
|
|
251
|
-
| Build an offline bundle | `reactive-md/build` | `buildLocalStandaloneBundle`, preflight, manifest and seal, resource and notice collection | browser rendering, the CLI | Vite 8 (optional peer, loaded on demand), Node |
|
|
252
|
-
| Resolve the files an export embeds | `reactive-md/export-assets` | `listExportAssets`, `resolveExportAsset`, `readExportAsset` for the stylesheets, notices, package metadata and standalone runtime | the compiler, React, browser code | Node |
|
|
253
|
-
| Wire Vite | `reactive-md/vite` | `reactiveMd()` registration, the dev host, `reactive-md-standalone.js` and `reactive-md-export.json` assets | the runtime API, browser code | Vite 8, Node |
|
|
254
|
-
| Mount an exported document | `reactive-md/standalone` | `mount`, `mountAll`, `isReactiveMDMounted`, payload parsing, mount diagnostics and events | the compiler surface, automatic mounting, build tooling | React 19, plus `reactive-md/styles.css` |
|
|
255
|
-
| Share identity, randomness, timers and component state | `reactive-md/runtime` | document identity and seeds, seeded random, the scheduler, the component-state registry and runtime services | rendering, web storage, network | — |
|
|
256
|
-
| Persist component state in a browser | `reactive-md/runtime/browser` | `createLocalBrowserStateStorage`, `flushComponentStateOnPageHide` | Node persistence, the runtime entry | a browser storage object |
|
|
257
|
-
| Verify a component package | `reactive-md/testing` | manifest and behavior compliance runners, report and parity helpers | React, DOM, a browser | — |
|
|
258
|
-
| Verify SSR output | `reactive-md/testing/react` | `runLocalReactCompliance`, `readLocalReactSpec`, error probes, `checkLocalComplianceMarkup` | a browser driver | React 19 + react-dom 19 |
|
|
259
|
-
| Verify the browser lifecycle | `reactive-md/testing/browser` | `runLocalBrowserCompliance`, the driver contract, `createPlaywrightBrowserDriver` | Playwright as a dependency | a browser context |
|
|
260
|
-
| Install the built-in components | `reactive-md/presets/default` | `defaultPreset`: manifest data for the built-in tags | the engine runtime, React renderers | — |
|
|
261
|
-
| Install a subset of them | `reactive-md/presets/default/packs` | `controlsPack`, `layoutPack`, `dataPack`, `visualsPack` | the components outside the pack | — |
|
|
262
|
-
| Style a document | `reactive-md/styles.css` | component, theme and document layers in the published cascade order | JavaScript | — |
|
|
263
|
-
| Print a document | `reactive-md/print.css` | print rules that hide controls and reveal `.local-print-value` | screen layout | load after `styles.css` |
|
|
264
|
-
| Ship third-party notices | `reactive-md/notices` | the generated `THIRD_PARTY_NOTICES.md` text | code | — |
|
|
265
|
-
| Drop in a prebuilt runtime | `reactive-md/assets/standalone.js` | the IIFE build with `ReactiveMD.mount`, `mountAll` and auto-mount for exported payloads | ESM imports, tree shaking, the compiler | a script tag, plus `reactive-md/styles.css` |
|
|
266
|
-
|
|
267
|
-
`reactive-md` (root) is the full core surface: default preset, incremental session, state and retention tools, the Worker protocol and the shareable HTML envelope. `reactive-md/compiler` is the light entry, with no React, CSS, Worker, session or default preset. `reactive-md/compiler/standard` adds GFM, native HTML, Lezer block planning, the KaTeX display check, plot sampling and the default preset, and keeps React, CSS, Worker and session out. `npm run test:compiler-entry` enforces that split on every build: it walks the root, compiler and standard graphs, records file count and byte size per entry, and fails when a compiler graph reaches a worker, session, retention, shareable, export, React, standalone or preset module, a stylesheet or the theme protocol.
|
|
268
|
-
|
|
269
|
-
### Smallest useful code
|
|
270
|
-
|
|
271
|
-
**Compile and run in memory**
|
|
272
|
-
|
|
273
|
-
```js
|
|
274
|
-
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
275
|
-
|
|
276
|
-
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
277
|
-
if (!result.ok) throw new Error(result.diagnostics.map(item => item.message).join('\n'));
|
|
278
|
-
|
|
279
|
-
const runtime = createLocalRuntime(result.document);
|
|
280
|
-
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
281
|
-
finally { runtime.dispose(); }
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
**Compile without a runtime**
|
|
285
|
-
|
|
286
|
-
```js
|
|
287
|
-
import { createCompiler } from 'reactive-md/compiler';
|
|
288
|
-
import { createStandardCompiler } from 'reactive-md/compiler/standard';
|
|
289
|
-
|
|
290
|
-
console.log(createCompiler().compile('# Title\n\nPlain **Markdown**.').status); // 'valid'
|
|
291
|
-
console.log(createStandardCompiler().compile('| a | b |\n| - | - |\n| 1 | 2 |').status); // 'valid'
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
**Render in React**
|
|
295
|
-
|
|
296
|
-
```tsx
|
|
297
|
-
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
298
|
-
import 'reactive-md/styles.css';
|
|
299
|
-
|
|
300
|
-
export function Article({ source }: { source: string }) {
|
|
301
|
-
return <LocalReactiveDocument source={source} />;
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
**Author in an editor**
|
|
306
|
-
|
|
307
|
-
```ts
|
|
308
|
-
import { analyzeLocalSource, insertLocalComponentFromOptions } from 'reactive-md/authoring';
|
|
309
|
-
|
|
310
|
-
const analysis = analyzeLocalSource(source);
|
|
311
|
-
const edit = insertLocalComponentFromOptions(undefined, 'chart', source, { start: 0, end: 0 });
|
|
312
|
-
console.log(analysis.bindings, edit.value);
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
**Export and build**
|
|
316
|
-
|
|
317
|
-
```ts
|
|
318
|
-
import { buildLocalStandaloneBundle } from 'reactive-md/build';
|
|
319
|
-
import { createLocalExportPlan } from 'reactive-md/export';
|
|
320
|
-
|
|
321
|
-
const bundle = await buildLocalStandaloneBundle({ entry: '.reactive-md/host.mjs' });
|
|
322
|
-
const plan = createLocalExportPlan({ document, config, target: 'offline', bundle });
|
|
323
|
-
if (!plan.ok) throw new Error(plan.diagnostics.map(item => item.message).join('\n'));
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
**Test a component package**
|
|
327
|
-
|
|
328
|
-
```ts
|
|
329
|
-
import { LOCAL_BEHAVIOR_SPEC_PROTOCOL, runLocalBehaviorCompliance, runLocalManifestCompliance } from 'reactive-md/testing';
|
|
330
|
-
|
|
331
|
-
const manifest = runLocalManifestCompliance(widgetManifest);
|
|
332
|
-
const behavior = runLocalBehaviorCompliance({
|
|
333
|
-
protocol: LOCAL_BEHAVIOR_SPEC_PROTOCOL,
|
|
334
|
-
component: 'my-widget',
|
|
335
|
-
source,
|
|
336
|
-
binding: 'value',
|
|
337
|
-
}, config);
|
|
338
|
-
console.log([...manifest.cases, ...behavior.cases].filter(item => item.status === 'failed'));
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
## Use with React
|
|
342
|
-
|
|
343
|
-
The React entry requires React 19:
|
|
344
|
-
|
|
345
|
-
```sh
|
|
346
|
-
npm install react@19 react-dom@19
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
```tsx
|
|
350
|
-
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
351
|
-
import 'reactive-md/styles.css';
|
|
352
|
-
|
|
353
|
-
export function Article({ source }: { source: string }) {
|
|
354
|
-
return <LocalReactiveDocument source={source} />;
|
|
355
|
-
}
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
`LocalReactiveDocument` compiles and manages the runtime for you. To control compilation, lifecycle or URL policy yourself, use `LocalDocumentView` as described in [Local mode integration](docs/integration/local-integration-en.md).
|
|
359
|
-
|
|
360
|
-
## Edit source with React
|
|
361
|
-
|
|
362
|
-
The reusable source editor lives in the separate `reactive-md-editor` package (`0.2.
|
|
363
|
-
|
|
364
|
-
```tsx
|
|
365
|
-
import { useState } from 'react';
|
|
366
|
-
import { ReactiveMarkdownEditor } from 'reactive-md-editor';
|
|
367
|
-
import 'reactive-md-editor/styles.css';
|
|
368
|
-
|
|
369
|
-
export function Editor() {
|
|
370
|
-
const [source, setSource] = useState('# Notes');
|
|
371
|
-
return <ReactiveMarkdownEditor value={source} onChange={setSource} />;
|
|
372
|
-
}
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
The editor handles highlighting, formatting and insertion tools, completion, binding tools, undo and redo, and line numbers. It does not compile or render a preview; keep the source in your app and render it with `reactive-md/react`. See [React source editor](docs/integration/editor-en.md) for props, the ref handle, diagnostics, themes, locales and history.
|
|
376
|
-
|
|
377
|
-
## Share documents
|
|
378
|
-
|
|
379
|
-
Build a self-contained HTML file that readers can open offline, or a script-free static snapshot:
|
|
380
|
-
|
|
381
|
-
```sh
|
|
382
|
-
npm run build
|
|
383
|
-
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
384
|
-
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
The interactive file embeds the original source, React 19, the runtime, styles and any verified local images. It hydrates a static first screen, so it remains readable with JavaScript disabled. Use `--state-file doc.state.json` to export a saved `reactive-md-state/v1` baseline; without it, the author initial values are used and become the reader's reset baseline. Use `--component-state-file game.state.json` to embed component progress, and `--document-id` or `--random-seed` to set its identity and random stream. The Demo export dialog can save the current preview parameters as such a file.
|
|
388
|
-
|
|
389
|
-
See [Shareable documents and static export](docs/integration/shareable-export-en.md) for image limits, CSP/security, printing, exit codes, `ReactiveMD.mount`/`mountAll` and `<reactive-md-doc>`.
|
|
390
|
-
|
|
391
|
-
## Repository layout
|
|
392
|
-
|
|
393
|
-
```text
|
|
394
|
-
src/ Local syntax compilation, expressions, runtime and React renderer
|
|
395
|
-
examples/ Copyable local interactive examples and component packages
|
|
396
|
-
docs/ Syntax specification, integration, development and release documentation
|
|
397
|
-
tests/ Language and renderer tests
|
|
398
|
-
ReactiveMD-Demo/ Separate repository: website and plugin integrations
|
|
399
|
-
benchmarks/ Condensed performance measurements with provenance
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
## Documentation
|
|
403
|
-
|
|
404
|
-
- [Documentation index](docs/README.md) and [beginner guide](docs/guides/local-guide-en.md).
|
|
405
|
-
- [Local interaction syntax specification](docs/reference/local-interaction-syntax-en.md) and [feature tours](examples/local/README.md).
|
|
406
|
-
- [Local mode integration](docs/integration/local-integration-en.md): core and React API, URL policy, lifecycle, styling and version pinning.
|
|
407
|
-
- [Shareable documents and static export](docs/integration/shareable-export-en.md): CLI build/lint, state files, local image inlining, printing and the standalone browser runtime.
|
|
408
|
-
- [React source editor](docs/integration/editor-en.md) and [author tools](docs/integration/author-tools-en.md).
|
|
409
|
-
- [Component protocol](docs/development/component-protocol-en.md) and [component plugin development guide](docs/development/component-development-en.md).
|
|
410
|
-
- [Extension tutorial](docs/development/extension-tutorial-en.md): choose an entry, build a component package and verify it.
|
|
411
|
-
- [Versions and compatibility](docs/compatibility/compatibility-en.md).
|
|
412
|
-
- [Performance measurements](docs/development/performance-overview-en.md) and [release checklist](CONTRIBUTING.md#releasing).
|
|
413
|
-
- [0.9.
|
|
414
|
-
|
|
415
|
-
## Support and status
|
|
416
|
-
|
|
417
|
-
- CI runs the engine checks and preset scaffold verification on Node 24. The packed-consumer check covers static SSR. Run `node scripts/verify-shareable.mjs` after building to test single-file hydration in Chromium and measure the standalone bundle.
|
|
418
|
-
- 0.x minor releases may contain breaking changes. Persist the original `.reactive.md` source, not the runtime AST or in-memory state.
|
|
419
|
-
- `0.9.
|
|
420
|
-
- The extension SDK contract is `0.7.0`. Component packages, themes, the Vite adapter, offline builds and compliance tools use the public entries.
|
|
421
|
-
|
|
422
|
-
## Contributing and security
|
|
423
|
-
|
|
424
|
-
- [Contributing guide](CONTRIBUTING.md): environment, check commands and change requirements.
|
|
425
|
-
- [Security policy](SECURITY.md): threat boundary, resource limits, host responsibilities and vulnerability reporting.
|
|
426
|
-
- [Changelog](CHANGELOG.md).
|
|
427
|
-
- [Release checklist](CONTRIBUTING.md#releasing): the verification gate, notices, tarball and the manual release flow for maintainers.
|
|
428
|
-
|
|
429
|
-
## License
|
|
430
|
-
|
|
431
|
-
[MIT](LICENSE)
|
|
1
|
+
# Reactive MD
|
|
2
|
+
|
|
3
|
+
**English** · [中文](README-ch.md)
|
|
4
|
+
|
|
5
|
+
> Repository split: this checkout is the language engine. The [editor](https://github.com/yao1145/ReactiveMD-Editor) and [Demo](https://github.com/yao1145/ReactiveMD-Demo) build independently. Engine 0.8 uses the separate reactive-md-editor package. See the [migration guide](docs/releases/release-0.8.0-en.md#repository-split-and-import-migration).
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/reactive-md)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
**Interactive Markdown documents that run on the reader's device.**
|
|
11
|
+
|
|
12
|
+
Reactive MD turns ordinary Markdown into a small application: named inputs, live calculations, charts, tables, diagrams, quizzes and formula-driven plots. Authors write tags and expressions in the document; readers get a responsive document with no server, no account and no build step. When the document is finished, export one HTML file that still works offline.
|
|
13
|
+
|
|
14
|
+
- **Local-first by design.** Parameters and state stay in the browser. There is no backend runtime and no round trip for an interaction.
|
|
15
|
+
- **Markdown-native authoring.** Inputs are HTML-style tags, values are `bind` names, and results are `{{ expressions }}`. Authors do not write JavaScript or CSS.
|
|
16
|
+
- **A real expression language.** Arithmetic, comparisons, logic, conditionals, math and formatting functions, aggregates, date helpers and read-only host values.
|
|
17
|
+
- **Rich output without glue code.** Tables, five chart kinds, LaTeX-driven plots, diagrams, steps, tabs and quizzes share the same parameters.
|
|
18
|
+
- **Fast where it matters.** A Worker compiler, block reuse, row-level patches and hard input budgets keep long documents responsive.
|
|
19
|
+
- **Extensible.** Ship an npm component package with a manifest, a React renderer and CSS; it appears in the editor catalog and can be exported offline.
|
|
20
|
+
- **One file to share.** Build a self-contained interactive HTML file or a script-free static snapshot.
|
|
21
|
+
|
|
22
|
+
Themes and components can be loaded from `theme/` and `plugin/` with `reactiveMd()`. See [directory integration](docs/integration/directory-discovery-en.md).
|
|
23
|
+
|
|
24
|
+
## At a glance
|
|
25
|
+
|
|
26
|
+
| Area | What you get |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Authoring | `.reactive.md` with HTML-style tags and `{{ expressions }}` |
|
|
29
|
+
| Runtime | Local-first state; no backend required |
|
|
30
|
+
| Views | 51 built-in tags, 5 chart kinds, tables, plots, diagrams, galleries, steps and quizzes |
|
|
31
|
+
| Integration | TypeScript core, React 19 renderer, CM6 source editor, CLI |
|
|
32
|
+
| Extensions | npm component packages, themes, authoring catalog, offline bundles |
|
|
33
|
+
| Sharing | Single-file interactive HTML, static HTML, versioned state files |
|
|
34
|
+
|
|
35
|
+
## Syntax in one example
|
|
36
|
+
|
|
37
|
+
```markdown
|
|
38
|
+
<const name="rate" value="{{ 80 }}">
|
|
39
|
+
<computed name="total" value="{{ people * rate }}">
|
|
40
|
+
|
|
41
|
+
<panel title="Workshop estimate">
|
|
42
|
+
<slider bind="people" label="People" initial="4" min="1" max="12">
|
|
43
|
+
<toggle bind="annual" label="Annual billing">
|
|
44
|
+
</panel>
|
|
45
|
+
|
|
46
|
+
**{{ people }} people × {{ rate }} = {{ total }} USD.**
|
|
47
|
+
|
|
48
|
+
Annual price: **{{ formatCurrency(annual ? total * 0.8 : total, 'USD', 2, 'en-US') }}**.
|
|
49
|
+
|
|
50
|
+
<if when="{{ annual }}">
|
|
51
|
+
<alert tone="success" title="Annual billing">The 20% discount is applied.</alert>
|
|
52
|
+
</if>
|
|
53
|
+
|
|
54
|
+
<chart kind="bar" title="Cost and budget">
|
|
55
|
+
| Category | Cost | Budget |
|
|
56
|
+
| --- | ---: | ---: |
|
|
57
|
+
| Venue | 400 | 500 |
|
|
58
|
+
| Catering | {{ total }} | 900 |
|
|
59
|
+
</chart>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The slider and toggle create parameters. `const` and `computed` name derived values. Prose, conditions and the chart read the same state, and every view updates together.
|
|
63
|
+
|
|
64
|
+
| Idea | Syntax |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| Parameters | `<slider bind="people">`, `<number>`, `<input>`, `<select>`, `<date>`, `<toggle>` |
|
|
67
|
+
| Named values | `<const name="rate" value="{{ 80 }}">`, `<computed name="total" value="{{ people * rate }}">` |
|
|
68
|
+
| Expressions | `{{ people * rate }}`, `{{ annual ? total * 0.8 : total }}` |
|
|
69
|
+
| Formatting | `formatCurrency`, `formatPercent`, `formatNumber`, `formatScientific` |
|
|
70
|
+
| Data views | Markdown tables inside `<table>` and `<chart>`; `bar`, `line`, `area`, `scatter`, `donut` |
|
|
71
|
+
| Structure | `<panel>`, `<card>`, `<grid>`, `<tabs>`, `<accordion>`, `<disclosure>` |
|
|
72
|
+
| Flow and teaching | `<if>`, `<diagram>`, `<steps>`, `<quiz>` |
|
|
73
|
+
| Formulas | LaTeX inside prose and `<plot>`; curves follow shared parameters |
|
|
74
|
+
| Themes | `<theme name="paper">`, light/dark modes, scoped custom CSS |
|
|
75
|
+
|
|
76
|
+
Expressions are deliberately small and safe: no assignment, method calls, property access, custom functions or imports. The full function set is listed in the [syntax specification](docs/reference/local-interaction-syntax-en.md#51-expression-set).
|
|
77
|
+
|
|
78
|
+
## Performance
|
|
79
|
+
|
|
80
|
+
Reactive MD is built for long documents and continuous editing. The current measurements (2026-11-20) use Node 22.17 on an Intel Core Ultra 5 125H and headless Edge 135 at 1440×1000. The machine was not frequency-pinned, so these numbers are reproducible evidence, not a guarantee.
|
|
81
|
+
|
|
82
|
+
| Workload | Result |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| 1,000,000-character plain document | 12.26 ms first compile, 5.15 ms steady median |
|
|
85
|
+
| 600-section article | 282 ms full compile → 62 ms incremental session (1 block compiled, 1,799 reused) |
|
|
86
|
+
| 500-row dynamic table | input-to-preview 286 ms → 134 ms in the latest comparison |
|
|
87
|
+
| 1,000-item dynamic list, 500 consecutive edits | 0.463 MiB post-GC heap growth |
|
|
88
|
+
| 600-section article through Worker + React | 193 ms round-trip |
|
|
89
|
+
| 1,000 controls through Worker + React | 70 ms round-trip |
|
|
90
|
+
| Parameter write / three-curve plot resample | 0.0004 ms / 0.28 ms |
|
|
91
|
+
|
|
92
|
+
The compiler runs in a Worker, reuses unchanged blocks, publishes row-level patches and negotiates a flat result format for deep trees. Hard budgets stop pathological input before it can freeze the interface: 10,000 nodes by default, 1,000,000 characters and 100 component nesting levels.
|
|
93
|
+
|
|
94
|
+
See [Performance measurements](docs/development/performance-overview-en.md) for the full 45-scenario matrix, regressions, memory checks and reproduction commands, and `benchmarks/performance-overview-2026-11-20.json` for the condensed data.
|
|
95
|
+
|
|
96
|
+
## Try the demo
|
|
97
|
+
|
|
98
|
+
Live demo: [yaozi.raricy.com](https://yaozi.raricy.com/)
|
|
99
|
+
|
|
100
|
+
From the ReactiveMD-Demo repository root:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
npm ci --legacy-peer-deps
|
|
104
|
+
npm run dev
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This installs the locked engine/editor candidates and starts the standalone app at `http://127.0.0.1:5173`. `/embed.html` shows the embedding path. The language toggle in the masthead switches the whole Demo between English and Chinese and remembers the choice.
|
|
108
|
+
|
|
109
|
+
What to try:
|
|
110
|
+
|
|
111
|
+
- Work through the guided tours: pricing, functions, forms, data and charts, layout, diagrams, checklists and timing.
|
|
112
|
+
- Drag a slider or change a table cell and watch prose, cards and charts update from the same parameters.
|
|
113
|
+
- Open the source editor to see highlighting, completion, binding navigation and diagnostics.
|
|
114
|
+
- Insert a component from the editor toolbar; external packages appear in the catalog with their authoring metadata.
|
|
115
|
+
- Open the Tetris and 2048 plugin examples to see timer-driven and turn-based external components.
|
|
116
|
+
- Export the current preview as a single-file interactive HTML or a static snapshot, then open it offline.
|
|
117
|
+
|
|
118
|
+
Check the integration from the ReactiveMD-Demo repository root:
|
|
119
|
+
|
|
120
|
+
```sh
|
|
121
|
+
npm run build
|
|
122
|
+
npm run test:runtime-extensions
|
|
123
|
+
npm run test:runtime-extensions -- --dev
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The script starts and stops its own server, exercises the real Worker, both plugin examples, the editor catalog, mobile layout and offline exports, and writes results to `artifacts/demo-extensions/`.
|
|
127
|
+
|
|
128
|
+
## Extend with your own components
|
|
129
|
+
|
|
130
|
+
A plugin is an npm package with three parts: a plain-data manifest, a React implementation and optional CSS. The manifest declares the tag, props, bindings, capabilities and authoring metadata; the implementation reads normalized props and writes through binding handles.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
// src/my-widget.tsx
|
|
134
|
+
import { defineReactComponentPackage, type LocalComponentContext } from 'reactive-md/react';
|
|
135
|
+
import { manifest } from './manifest.js';
|
|
136
|
+
|
|
137
|
+
export const widgetPackage = defineReactComponentPackage({
|
|
138
|
+
...manifest,
|
|
139
|
+
render: (ctx: LocalComponentContext) => (
|
|
140
|
+
<button onClick={() => ctx.bindings.value.set(1)}>Activate</button>
|
|
141
|
+
),
|
|
142
|
+
css: '.local-document .my-widget { color: var(--ink); }',
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Assemble the host once, and let Vite load the same registration module:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
// extensions.ts
|
|
150
|
+
import { createReactHost } from 'reactive-md/react';
|
|
151
|
+
import { widgetPackage } from 'my-widget/react';
|
|
152
|
+
|
|
153
|
+
export const host = createReactHost({ packages: [widgetPackage] });
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
// vite.config.ts
|
|
158
|
+
import { reactiveMd } from 'reactive-md/vite';
|
|
159
|
+
|
|
160
|
+
export default { plugins: [reactiveMd({ extensions: './extensions.ts' })] };
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The Demo ships two complete installed-package cases:
|
|
164
|
+
|
|
165
|
+
| Package | Tag | Demonstrates | Update guide |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| `reactive-md-tetris-package` | `<tetris>` | Timer-driven game, keyboard and pointer input, seeded pieces, offline export | [Demo candidate guide](https://github.com/yao1145/ReactiveMD-Demo/blob/main/docs/candidate-package-updates-en.md) |
|
|
168
|
+
| `reactive-md-game-2048-package` | `<game-2048>` | Turn-based state, deterministic spawns, keyboard and pointer input, static preview | [Demo candidate guide](https://github.com/yao1145/ReactiveMD-Demo/blob/main/docs/candidate-package-updates-en.md) |
|
|
169
|
+
|
|
170
|
+
The Demo site runs local copies under `ReactiveMD-Demo/plugin/`; the committed tarballs under `vendor/` are installed-package fixtures for compatibility tests. Both package entries are read through their public `./react` and `./notices` entries. Their authoring metadata feeds the editor catalog, and their capability evidence supports offline export.
|
|
171
|
+
|
|
172
|
+
Component tags must start with a letter, so the 2048 plugin registers `<game-2048>` rather than `<2048>`. See the [component plugin development guide](docs/development/component-development-en.md) and the [full development contract](docs/development/component-development-reference-en.md) for manifests, bindings, themes, resources, compliance tools and packaging.
|
|
173
|
+
|
|
174
|
+
## Where it fits
|
|
175
|
+
|
|
176
|
+
| Scenario | What Reactive MD gives you |
|
|
177
|
+
| --- | --- |
|
|
178
|
+
| Interactive reports and dashboards | One source for prose, parameters, tables and charts; links to related views stay in sync |
|
|
179
|
+
| Teaching, tutorials and courseware | Formula-driven plots, diagrams, guided steps, quizzes and self-checking examples |
|
|
180
|
+
| Pricing, planning and calculators | Shared named calculations, validation, currency and percentage formatting |
|
|
181
|
+
| Forms, checklists and onboarding | Scoped inputs, required fields, checklists and timers without a server |
|
|
182
|
+
| Offline handouts and proposals | A single HTML file with embedded styles, images and runtime; readable without JavaScript |
|
|
183
|
+
| Embedded widgets in apps and docs | React renderer, standalone browser API or `<reactive-md-doc>` elements |
|
|
184
|
+
| Games and experimental interfaces | Component SDK with local React state, keyboard input, timers and offline bundles |
|
|
185
|
+
| Internal tools and living documentation | Local-first state, no account or backend, source stays in plain `.reactive.md` |
|
|
186
|
+
|
|
187
|
+
## Install
|
|
188
|
+
|
|
189
|
+
Reactive MD requires Node.js 22.12 or newer and ships only ESM entries:
|
|
190
|
+
|
|
191
|
+
```sh
|
|
192
|
+
npm install reactive-md
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The 0.9.2 stable release uses the `latest` channel. Pin the version if your project requires it.
|
|
196
|
+
|
|
197
|
+
```sh
|
|
198
|
+
npm install reactive-md
|
|
199
|
+
# or pin the version
|
|
200
|
+
npm install reactive-md@0.9.2
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Read the [0.9.2 release notes](docs/releases/release-0.9.2-en.md) and the [compatibility guide](docs/compatibility/compatibility-en.md) before upgrading.
|
|
204
|
+
|
|
205
|
+
### Upgrade to 0.8.0
|
|
206
|
+
|
|
207
|
+
`reactive-md@0.8.0` moves the source editor to the separate `reactive-md-editor@0.1.0` package. Install the engine and editor separately:
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
npm install reactive-md@0.8.0
|
|
211
|
+
npm install reactive-md-editor@0.1.0
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Read the [0.8.0 release notes](docs/releases/release-0.8.0-en.md) and the [repository migration guide](docs/releases/release-0.8.0-en.md#repository-split-and-import-migration) before replacing `reactive-md/editor` imports. `0.8.0` keeps syntax `local-draft-3`, the `0.7.0` SDK contract and the existing state protocols, so document sources need no migration.
|
|
215
|
+
|
|
216
|
+
The `reactive-md` entry provides the local compiler, expressions and runtime; `reactive-md/react` provides the React renderer. Import component styles from `reactive-md/styles.css`. The `reactive-md-editor` entry provides the source editor with its own stylesheet at `reactive-md-editor/styles.css`. Engine 0.8 removes the old `reactive-md/editor` entries; published 0.7 packages keep them.
|
|
217
|
+
|
|
218
|
+
The core entry does not depend on React:
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
222
|
+
|
|
223
|
+
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
224
|
+
if (result.ok) {
|
|
225
|
+
const runtime = createLocalRuntime(result.document);
|
|
226
|
+
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
227
|
+
finally { runtime.dispose(); }
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
See [Local mode integration](docs/integration/local-integration-en.md) for the full compile and runtime APIs, host URL policy, lifecycle and style overrides.
|
|
232
|
+
|
|
233
|
+
## Choose an entry point by task
|
|
234
|
+
|
|
235
|
+
[Public API reference](docs/reference/public-api-en.md) lists every entry, export, CLI command, browser protocol and the editor package with its detailed purpose. The table below covers the engine subpaths by task.
|
|
236
|
+
|
|
237
|
+
Every subpath is an ESM entry with its own declarations. Pick the one that matches the job; optional peers appear only in the last column.
|
|
238
|
+
|
|
239
|
+
| Task | Entry | What it gives you | What it leaves out | React / Vite |
|
|
240
|
+
| --- | --- | --- | --- | --- |
|
|
241
|
+
| Compile once and run in memory | `reactive-md` | `compileLocal`, `createLocalCompileSession`, `createLocalRuntime`, expressions and plot sampling, state import/export and retention, the host-supplied Worker protocol (`startLocalCompileWorker`, `LocalCompileScheduler`), `createShareableHtml`, the default preset | React, CSS, Vite, the component catalog and toolbar commands, export planning | — |
|
|
242
|
+
| Compile in a Worker or a size-sensitive bundle | `reactive-md/compiler` | `createCompiler` and the `CompileResult` contract: CommonMark, ReactiveMD structure, expressions, bindings, budgets | React, CSS, the compile-worker protocol, session, retention, shareable/export code, default preset, GFM, native HTML, Lezer planning, KaTeX display, plot sampling | — |
|
|
243
|
+
| Keep the full language in one pass | `reactive-md/compiler/standard` | `createStandardCompiler`: adds GFM, native HTML, Lezer block planning, the KaTeX display check, plot formula sampling and the default preset | React, CSS, the compile-worker protocol, session, retention, shareable/export code | — |
|
|
244
|
+
| Render in React | `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView`, `defineReactComponentPackage`, `createReactHost`; the build extracts the stylesheet instead of injecting it | Node build and export tooling, the editor | React 19, plus `reactive-md/styles.css` |
|
|
245
|
+
| Render on a server | `reactive-md/react/server` | `renderLocalStaticDocument` with capability preflight and diagnostics | client runtime, DOM, stylesheet | React 19 + react-dom 19 |
|
|
246
|
+
| Render without the stylesheet import | `reactive-md/react/unstyled` | the same components without the CSS side effect | `styles.css` | React 19 |
|
|
247
|
+
| Build interactive components | `reactive-md/react/runtime` | `useTicker`, `useFrame`, `useSwipe`, `useKeys`, `useComponentState` | the document renderer, the compiler | React 19 |
|
|
248
|
+
| Publish a component package | `reactive-md/sdk` | `defineLocalComponent`, `defineLocalPreset`, manifest, config, registry and theme contracts with validation | React renderers, document rendering, DOM | — |
|
|
249
|
+
| Drive an editor | `reactive-md/authoring` | `analyzeLocalSource`, `completeLocalSource`, `formatLocalSource`, `renameLocalBinding`, the component catalog and toolbar insert commands | React, CSS, DOM, compile sessions | — |
|
|
250
|
+
| Preflight an export | `reactive-md/export` | `createLocalExportPlan`, `createLocalShareableHtml`, restoration requirements, component-state files, style resources | Vite build, React rendering (the caller supplies markup), the CLI | — |
|
|
251
|
+
| Build an offline bundle | `reactive-md/build` | `buildLocalStandaloneBundle`, preflight, manifest and seal, resource and notice collection | browser rendering, the CLI | Vite 8 (optional peer, loaded on demand), Node |
|
|
252
|
+
| Resolve the files an export embeds | `reactive-md/export-assets` | `listExportAssets`, `resolveExportAsset`, `readExportAsset` for the stylesheets, notices, package metadata and standalone runtime | the compiler, React, browser code | Node |
|
|
253
|
+
| Wire Vite | `reactive-md/vite` | `reactiveMd()` registration, the dev host, `reactive-md-standalone.js` and `reactive-md-export.json` assets | the runtime API, browser code | Vite 8, Node |
|
|
254
|
+
| Mount an exported document | `reactive-md/standalone` | `mount`, `mountAll`, `isReactiveMDMounted`, payload parsing, mount diagnostics and events | the compiler surface, automatic mounting, build tooling | React 19, plus `reactive-md/styles.css` |
|
|
255
|
+
| Share identity, randomness, timers and component state | `reactive-md/runtime` | document identity and seeds, seeded random, the scheduler, the component-state registry and runtime services | rendering, web storage, network | — |
|
|
256
|
+
| Persist component state in a browser | `reactive-md/runtime/browser` | `createLocalBrowserStateStorage`, `flushComponentStateOnPageHide` | Node persistence, the runtime entry | a browser storage object |
|
|
257
|
+
| Verify a component package | `reactive-md/testing` | manifest and behavior compliance runners, report and parity helpers | React, DOM, a browser | — |
|
|
258
|
+
| Verify SSR output | `reactive-md/testing/react` | `runLocalReactCompliance`, `readLocalReactSpec`, error probes, `checkLocalComplianceMarkup` | a browser driver | React 19 + react-dom 19 |
|
|
259
|
+
| Verify the browser lifecycle | `reactive-md/testing/browser` | `runLocalBrowserCompliance`, the driver contract, `createPlaywrightBrowserDriver` | Playwright as a dependency | a browser context |
|
|
260
|
+
| Install the built-in components | `reactive-md/presets/default` | `defaultPreset`: manifest data for the built-in tags | the engine runtime, React renderers | — |
|
|
261
|
+
| Install a subset of them | `reactive-md/presets/default/packs` | `controlsPack`, `layoutPack`, `dataPack`, `visualsPack` | the components outside the pack | — |
|
|
262
|
+
| Style a document | `reactive-md/styles.css` | component, theme and document layers in the published cascade order | JavaScript | — |
|
|
263
|
+
| Print a document | `reactive-md/print.css` | print rules that hide controls and reveal `.local-print-value` | screen layout | load after `styles.css` |
|
|
264
|
+
| Ship third-party notices | `reactive-md/notices` | the generated `THIRD_PARTY_NOTICES.md` text | code | — |
|
|
265
|
+
| Drop in a prebuilt runtime | `reactive-md/assets/standalone.js` | the IIFE build with `ReactiveMD.mount`, `mountAll` and auto-mount for exported payloads | ESM imports, tree shaking, the compiler | a script tag, plus `reactive-md/styles.css` |
|
|
266
|
+
|
|
267
|
+
`reactive-md` (root) is the full core surface: default preset, incremental session, state and retention tools, the Worker protocol and the shareable HTML envelope. `reactive-md/compiler` is the light entry, with no React, CSS, Worker, session or default preset. `reactive-md/compiler/standard` adds GFM, native HTML, Lezer block planning, the KaTeX display check, plot sampling and the default preset, and keeps React, CSS, Worker and session out. `npm run test:compiler-entry` enforces that split on every build: it walks the root, compiler and standard graphs, records file count and byte size per entry, and fails when a compiler graph reaches a worker, session, retention, shareable, export, React, standalone or preset module, a stylesheet or the theme protocol.
|
|
268
|
+
|
|
269
|
+
### Smallest useful code
|
|
270
|
+
|
|
271
|
+
**Compile and run in memory**
|
|
272
|
+
|
|
273
|
+
```js
|
|
274
|
+
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
275
|
+
|
|
276
|
+
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
277
|
+
if (!result.ok) throw new Error(result.diagnostics.map(item => item.message).join('\n'));
|
|
278
|
+
|
|
279
|
+
const runtime = createLocalRuntime(result.document);
|
|
280
|
+
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
281
|
+
finally { runtime.dispose(); }
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Compile without a runtime**
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
import { createCompiler } from 'reactive-md/compiler';
|
|
288
|
+
import { createStandardCompiler } from 'reactive-md/compiler/standard';
|
|
289
|
+
|
|
290
|
+
console.log(createCompiler().compile('# Title\n\nPlain **Markdown**.').status); // 'valid'
|
|
291
|
+
console.log(createStandardCompiler().compile('| a | b |\n| - | - |\n| 1 | 2 |').status); // 'valid'
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Render in React**
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
298
|
+
import 'reactive-md/styles.css';
|
|
299
|
+
|
|
300
|
+
export function Article({ source }: { source: string }) {
|
|
301
|
+
return <LocalReactiveDocument source={source} />;
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Author in an editor**
|
|
306
|
+
|
|
307
|
+
```ts
|
|
308
|
+
import { analyzeLocalSource, insertLocalComponentFromOptions } from 'reactive-md/authoring';
|
|
309
|
+
|
|
310
|
+
const analysis = analyzeLocalSource(source);
|
|
311
|
+
const edit = insertLocalComponentFromOptions(undefined, 'chart', source, { start: 0, end: 0 });
|
|
312
|
+
console.log(analysis.bindings, edit.value);
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Export and build**
|
|
316
|
+
|
|
317
|
+
```ts
|
|
318
|
+
import { buildLocalStandaloneBundle } from 'reactive-md/build';
|
|
319
|
+
import { createLocalExportPlan } from 'reactive-md/export';
|
|
320
|
+
|
|
321
|
+
const bundle = await buildLocalStandaloneBundle({ entry: '.reactive-md/host.mjs' });
|
|
322
|
+
const plan = createLocalExportPlan({ document, config, target: 'offline', bundle });
|
|
323
|
+
if (!plan.ok) throw new Error(plan.diagnostics.map(item => item.message).join('\n'));
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Test a component package**
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
import { LOCAL_BEHAVIOR_SPEC_PROTOCOL, runLocalBehaviorCompliance, runLocalManifestCompliance } from 'reactive-md/testing';
|
|
330
|
+
|
|
331
|
+
const manifest = runLocalManifestCompliance(widgetManifest);
|
|
332
|
+
const behavior = runLocalBehaviorCompliance({
|
|
333
|
+
protocol: LOCAL_BEHAVIOR_SPEC_PROTOCOL,
|
|
334
|
+
component: 'my-widget',
|
|
335
|
+
source,
|
|
336
|
+
binding: 'value',
|
|
337
|
+
}, config);
|
|
338
|
+
console.log([...manifest.cases, ...behavior.cases].filter(item => item.status === 'failed'));
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Use with React
|
|
342
|
+
|
|
343
|
+
The React entry requires React 19:
|
|
344
|
+
|
|
345
|
+
```sh
|
|
346
|
+
npm install react@19 react-dom@19
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
351
|
+
import 'reactive-md/styles.css';
|
|
352
|
+
|
|
353
|
+
export function Article({ source }: { source: string }) {
|
|
354
|
+
return <LocalReactiveDocument source={source} />;
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
`LocalReactiveDocument` compiles and manages the runtime for you. To control compilation, lifecycle or URL policy yourself, use `LocalDocumentView` as described in [Local mode integration](docs/integration/local-integration-en.md).
|
|
359
|
+
|
|
360
|
+
## Edit source with React
|
|
361
|
+
|
|
362
|
+
The reusable source editor lives in the separate `reactive-md-editor` package (`0.2.1`, requiring the `reactive-md@^0.9.2` engine peer), with its own stylesheet. Install it alongside the engine. In 0.7 it shipped as `reactive-md/editor`; it has been a separate package since 0.8. The component is controlled and requires React 19:
|
|
363
|
+
|
|
364
|
+
```tsx
|
|
365
|
+
import { useState } from 'react';
|
|
366
|
+
import { ReactiveMarkdownEditor } from 'reactive-md-editor';
|
|
367
|
+
import 'reactive-md-editor/styles.css';
|
|
368
|
+
|
|
369
|
+
export function Editor() {
|
|
370
|
+
const [source, setSource] = useState('# Notes');
|
|
371
|
+
return <ReactiveMarkdownEditor value={source} onChange={setSource} />;
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
The editor handles highlighting, formatting and insertion tools, completion, binding tools, undo and redo, and line numbers. It does not compile or render a preview; keep the source in your app and render it with `reactive-md/react`. See [React source editor](docs/integration/editor-en.md) for props, the ref handle, diagnostics, themes, locales and history.
|
|
376
|
+
|
|
377
|
+
## Share documents
|
|
378
|
+
|
|
379
|
+
Build a self-contained HTML file that readers can open offline, or a script-free static snapshot:
|
|
380
|
+
|
|
381
|
+
```sh
|
|
382
|
+
npm run build
|
|
383
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
384
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
The interactive file embeds the original source, React 19, the runtime, styles and any verified local images. It hydrates a static first screen, so it remains readable with JavaScript disabled. Use `--state-file doc.state.json` to export a saved `reactive-md-state/v1` baseline; without it, the author initial values are used and become the reader's reset baseline. Use `--component-state-file game.state.json` to embed component progress, and `--document-id` or `--random-seed` to set its identity and random stream. The Demo export dialog can save the current preview parameters as such a file.
|
|
388
|
+
|
|
389
|
+
See [Shareable documents and static export](docs/integration/shareable-export-en.md) for image limits, CSP/security, printing, exit codes, `ReactiveMD.mount`/`mountAll` and `<reactive-md-doc>`.
|
|
390
|
+
|
|
391
|
+
## Repository layout
|
|
392
|
+
|
|
393
|
+
```text
|
|
394
|
+
src/ Local syntax compilation, expressions, runtime and React renderer
|
|
395
|
+
examples/ Copyable local interactive examples and component packages
|
|
396
|
+
docs/ Syntax specification, integration, development and release documentation
|
|
397
|
+
tests/ Language and renderer tests
|
|
398
|
+
ReactiveMD-Demo/ Separate repository: website and plugin integrations
|
|
399
|
+
benchmarks/ Condensed performance measurements with provenance
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
## Documentation
|
|
403
|
+
|
|
404
|
+
- [Documentation index](docs/README.md) and [beginner guide](docs/guides/local-guide-en.md).
|
|
405
|
+
- [Local interaction syntax specification](docs/reference/local-interaction-syntax-en.md) and [feature tours](examples/local/README.md).
|
|
406
|
+
- [Local mode integration](docs/integration/local-integration-en.md): core and React API, URL policy, lifecycle, styling and version pinning.
|
|
407
|
+
- [Shareable documents and static export](docs/integration/shareable-export-en.md): CLI build/lint, state files, local image inlining, printing and the standalone browser runtime.
|
|
408
|
+
- [React source editor](docs/integration/editor-en.md) and [author tools](docs/integration/author-tools-en.md).
|
|
409
|
+
- [Component protocol](docs/development/component-protocol-en.md) and [component plugin development guide](docs/development/component-development-en.md).
|
|
410
|
+
- [Extension tutorial](docs/development/extension-tutorial-en.md): choose an entry, build a component package and verify it.
|
|
411
|
+
- [Versions and compatibility](docs/compatibility/compatibility-en.md).
|
|
412
|
+
- [Performance measurements](docs/development/performance-overview-en.md) and [release checklist](CONTRIBUTING.md#releasing).
|
|
413
|
+
- [0.9.2 release notes](docs/releases/release-0.9.2-en.md) and [previous releases](docs/releases).
|
|
414
|
+
|
|
415
|
+
## Support and status
|
|
416
|
+
|
|
417
|
+
- CI runs the engine checks and preset scaffold verification on Node 24. The packed-consumer check covers static SSR. Run `node scripts/verify-shareable.mjs` after building to test single-file hydration in Chromium and measure the standalone bundle.
|
|
418
|
+
- 0.x minor releases may contain breaking changes. Persist the original `.reactive.md` source, not the runtime AST or in-memory state.
|
|
419
|
+
- `0.9.2` is the stable release on `latest`. Security fixes may ship in minor releases.
|
|
420
|
+
- The extension SDK contract is `0.7.0`. Component packages, themes, the Vite adapter, offline builds and compliance tools use the public entries.
|
|
421
|
+
|
|
422
|
+
## Contributing and security
|
|
423
|
+
|
|
424
|
+
- [Contributing guide](CONTRIBUTING.md): environment, check commands and change requirements.
|
|
425
|
+
- [Security policy](SECURITY.md): threat boundary, resource limits, host responsibilities and vulnerability reporting.
|
|
426
|
+
- [Changelog](CHANGELOG.md).
|
|
427
|
+
- [Release checklist](CONTRIBUTING.md#releasing): the verification gate, notices, tarball and the manual release flow for maintainers.
|
|
428
|
+
|
|
429
|
+
## License
|
|
430
|
+
|
|
431
|
+
[MIT](LICENSE)
|