reactive-md 0.3.1 → 0.4.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 +96 -0
- package/CHANGELOG.md +82 -39
- package/CONTRIBUTING-ch.md +62 -0
- package/CONTRIBUTING.md +64 -65
- package/README-ch.md +122 -0
- package/README-en.md +146 -0
- package/README.md +146 -89
- package/SECURITY-ch.md +80 -0
- package/SECURITY.md +58 -49
- package/THIRD_PARTY_NOTICES.md +85 -1
- package/bin/reactive-md.mjs +40 -0
- package/cli/args.mjs +181 -0
- package/cli/assets.mjs +390 -0
- package/cli/build.mjs +268 -0
- package/cli/document.mjs +130 -0
- package/cli/errors.mjs +61 -0
- package/cli/fs-utils.mjs +133 -0
- package/cli/glob.mjs +203 -0
- package/cli/help.mjs +138 -0
- package/cli/lint.mjs +177 -0
- package/cli/main.mjs +55 -0
- package/cli/migrate.mjs +368 -0
- package/cli/package.mjs +209 -0
- package/dist-library/reactive-md-react.js +3425 -1647
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1798 -4
- package/dist-library/runtime-DtjdPXxJ.js +15410 -0
- package/dist-library/types/index.d.ts +1 -0
- package/dist-library/types/local/LocalDocumentView.d.ts +66 -3
- package/dist-library/types/local/authoring.d.ts +63 -0
- package/dist-library/types/local/collection-functions.d.ts +4 -0
- package/dist-library/types/local/colors.d.ts +2 -0
- package/dist-library/types/local/computations.d.ts +53 -0
- package/dist-library/types/local/data-functions.d.ts +22 -0
- package/dist-library/types/local/data-table.d.ts +65 -0
- package/dist-library/types/local/dates.d.ts +2 -0
- package/dist-library/types/local/dependencies.d.ts +31 -0
- package/dist-library/types/local/diagnostics.d.ts +1450 -0
- package/dist-library/types/local/expression.d.ts +13 -3
- package/dist-library/types/local/formatting.d.ts +41 -0
- package/dist-library/types/local/heading-anchors.d.ts +13 -2
- package/dist-library/types/local/i18n.d.ts +18 -0
- package/dist-library/types/local/index.d.ts +18 -1
- package/dist-library/types/local/limits.d.ts +32 -1
- package/dist-library/types/local/locale.d.ts +1 -0
- package/dist-library/types/local/math.d.ts +6 -1
- package/dist-library/types/local/parser.d.ts +10 -4
- package/dist-library/types/local/render-types.d.ts +5 -1
- package/dist-library/types/local/retention.d.ts +23 -0
- package/dist-library/types/local/schema.d.ts +25 -3
- package/dist-library/types/local/source-migration.d.ts +35 -0
- package/dist-library/types/local/state.d.ts +80 -0
- package/dist-library/types/local/text-length.d.ts +13 -0
- package/dist-library/types/local/theme.d.ts +30 -0
- package/dist-library/types/local/types.d.ts +112 -4
- package/dist-library/types/local/validation.d.ts +32 -0
- package/dist-library/types/local/version.d.ts +1 -1
- package/dist-library/types/local/worker.d.ts +82 -0
- package/dist-library/types/react/index.d.ts +4 -1
- package/dist-library/types/shareable.d.ts +64 -0
- package/dist-standalone/reactive-md-standalone.css +2 -0
- package/dist-standalone/reactive-md-standalone.js +57 -0
- package/docs/author-tools-ch.md +56 -0
- package/docs/author-tools-en.md +56 -0
- package/docs/compatibility-ch.md +103 -0
- package/docs/compatibility-en.md +103 -0
- package/docs/{component-development.md → component-development-ch.md} +210 -206
- package/docs/component-development-en.md +210 -0
- package/docs/{component-protocol.md → component-protocol-ch.md} +710 -685
- package/docs/component-protocol-en.md +710 -0
- package/docs/computations-formatting-ch.md +87 -0
- package/docs/computations-formatting-en.md +87 -0
- package/docs/constraints-collections-ch.md +84 -0
- package/docs/constraints-collections-en.md +84 -0
- package/docs/diagnostics-counting-ch.md +84 -0
- package/docs/diagnostics-counting-en.md +84 -0
- package/docs/local-components-v2-ch.md +138 -0
- package/docs/local-components-v2-en.md +104 -0
- package/docs/{local-guide.md → local-guide-ch.md} +28 -8
- package/docs/local-guide-en.md +961 -0
- package/docs/local-integration-ch.md +363 -0
- package/docs/local-integration-en.md +363 -0
- package/docs/{local-interaction-syntax.md → local-interaction-syntax-ch.md} +66 -20
- package/docs/local-interaction-syntax-en.md +483 -0
- package/docs/{performance.md → performance-ch.md} +12 -3
- package/docs/performance-en.md +76 -0
- package/docs/release-0.4.0-ch.md +89 -0
- package/docs/release-0.4.0-en.md +89 -0
- package/docs/releasing-ch.md +101 -0
- package/docs/releasing-en.md +101 -0
- package/docs/shareable-export-ch.md +205 -0
- package/docs/shareable-export-en.md +207 -0
- package/docs/source-versioning-ch.md +159 -0
- package/docs/source-versioning-en.md +159 -0
- package/docs/theme-protocol-ch.md +107 -0
- package/docs/theme-protocol-en.md +107 -0
- package/examples/conformance/README.md +33 -31
- package/examples/conformance/component-protocol-1.json +482 -194
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/history/v0.3.1/catalog.reactive.md +20 -0
- package/examples/conformance/history/v0.3.1/charts.reactive.md +73 -0
- package/examples/conformance/history/v0.3.1/checklist.reactive.md +32 -0
- package/examples/conformance/history/v0.3.1/comparison.reactive.md +47 -0
- package/examples/conformance/history/v0.3.1/components.reactive.md +44 -0
- package/examples/conformance/history/v0.3.1/counter.reactive.md +7 -0
- package/examples/conformance/history/v0.3.1/diagnostics.reactive.md +54 -0
- package/examples/conformance/history/v0.3.1/diagram.reactive.md +44 -0
- package/examples/conformance/history/v0.3.1/gallery.reactive.md +61 -0
- package/examples/conformance/history/v0.3.1/local-draft-1.json +50 -0
- package/examples/conformance/history/v0.3.1/parameters.reactive.md +36 -0
- package/examples/conformance/history/v0.3.1/planning.reactive.md +24 -0
- package/examples/conformance/history/v0.3.1/pricing.reactive.md +20 -0
- package/examples/conformance/history/v0.3.1/provenance.json +72 -0
- package/examples/conformance/local-draft-2.json +212 -0
- package/examples/integration/README.md +45 -29
- package/examples/integration/core/index.mjs +32 -19
- package/examples/integration/react/index.html +1 -1
- package/examples/integration/react/main.jsx +5 -5
- package/examples/integration/worker/index.html +19 -0
- package/examples/integration/worker/main.js +61 -0
- package/examples/integration/worker/package.json +13 -0
- package/examples/integration/worker/worker.js +3 -0
- package/examples/local/README.md +64 -58
- package/examples/local/catalog.reactive.md +14 -14
- package/examples/local/charts.reactive.md +34 -34
- package/examples/local/checklist.reactive.md +19 -19
- package/examples/local/comparison.reactive.md +23 -23
- package/examples/local/components.reactive.md +20 -20
- package/examples/local/counter.reactive.md +4 -4
- package/examples/local/diagnostics.reactive.md +25 -25
- package/examples/local/diagram.reactive.md +20 -20
- package/examples/local/gallery.reactive.md +31 -31
- package/examples/local/parameters.reactive.md +19 -19
- package/examples/local/planning.reactive.md +15 -15
- package/examples/local/pricing.reactive.md +10 -10
- package/examples/local/recipes/invoice-zh.reactive.md +36 -0
- package/examples/local/recipes/invoice.reactive.md +36 -0
- package/examples/local/recipes/workshop-zh.reactive.md +33 -0
- package/examples/local/recipes/workshop.reactive.md +33 -0
- package/examples/local/showcase/README.md +25 -0
- package/examples/local/showcase/explore.reactive.md +102 -0
- package/examples/local/showcase/flow.reactive.md +86 -0
- package/examples/local/showcase/forms.reactive.md +126 -0
- package/examples/local/showcase/functions.reactive.md +119 -0
- package/examples/local/showcase/layout.reactive.md +100 -0
- package/examples/local/showcase/statistics.reactive.md +108 -0
- package/examples/local/showcase/tasks.reactive.md +89 -0
- package/examples/local/showcase/zh/explore.reactive.md +102 -0
- package/examples/local/showcase/zh/flow.reactive.md +86 -0
- package/examples/local/showcase/zh/forms.reactive.md +126 -0
- package/examples/local/showcase/zh/functions.reactive.md +119 -0
- package/examples/local/showcase/zh/layout.reactive.md +100 -0
- package/examples/local/showcase/zh/statistics.reactive.md +108 -0
- package/examples/local/showcase/zh/tasks.reactive.md +89 -0
- package/examples/local/zh/catalog.reactive.md +20 -0
- package/examples/local/zh/charts.reactive.md +73 -0
- package/examples/local/zh/checklist.reactive.md +32 -0
- package/examples/local/zh/comparison.reactive.md +47 -0
- package/examples/local/zh/components.reactive.md +44 -0
- package/examples/local/zh/counter.reactive.md +7 -0
- package/examples/local/zh/diagnostics.reactive.md +54 -0
- package/examples/local/zh/diagram.reactive.md +44 -0
- package/examples/local/zh/gallery.reactive.md +61 -0
- package/examples/local/zh/parameters.reactive.md +36 -0
- package/examples/local/zh/planning.reactive.md +24 -0
- package/examples/local/zh/pricing.reactive.md +20 -0
- package/package.json +16 -3
- package/README.en.md +0 -76
- package/dist-library/runtime-CPzMEMcW.js +0 -11111
- package/docs/compatibility.md +0 -68
- package/docs/local-integration.md +0 -218
- package/docs/releasing.md +0 -92
package/README-en.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Reactive MD
|
|
2
|
+
|
|
3
|
+
[中文](README-ch.md)
|
|
4
|
+
|
|
5
|
+
Write local interactive documents in Markdown. Add input controls, name parameters with `bind`, and connect prose, formulas, charts and diagrams with `{{ expressions }}`. Document authors do not write JavaScript or CSS.
|
|
6
|
+
|
|
7
|
+
Local mode uses HTML-style tags, with parameters and table data written directly in the prose; LaTeX formulas can drive function plots. The TypeScript core and the React renderer can be integrated independently. `0.4.0` is the preview release on the `next` channel, with syntax revision `local-draft-2`. See [README-ch.md](README-ch.md) for the Chinese overview.
|
|
8
|
+
|
|
9
|
+
## Start here
|
|
10
|
+
|
|
11
|
+
- [Beginner guide](docs/local-guide-en.md): move from Markdown to interactive documents, with a complete exercise and an error quick reference.
|
|
12
|
+
- [Local interaction syntax specification](docs/local-interaction-syntax-en.md) · [Feature tours and examples](examples/local/README.md): 48 tag names, tags, in-place parameters and LaTeX plots.
|
|
13
|
+
- [Local mode integration](docs/local-integration-en.md): `compileLocal`, the state runtime, React embedding, URL policy and style scoping.
|
|
14
|
+
- [Shareable documents and static export](docs/shareable-export-en.md): single-file interactive HTML, static output, versioned state files, assets, the CLI and the standalone browser API.
|
|
15
|
+
- [Theme protocol](docs/theme-protocol-en.md): document theme selection, custom CSS and light/dark modes.
|
|
16
|
+
- [Author tools](docs/author-tools-en.md): source highlighting, completion, binding navigation, rename, formatting and command-line lint.
|
|
17
|
+
- [Standalone integration examples](examples/integration/README.md): Node core and React pages you can copy and run outside the repository.
|
|
18
|
+
- [Versions and compatibility](docs/compatibility-en.md): 0.x rules, migration, the diagnostics contract and supported platforms.
|
|
19
|
+
- [Component protocol](docs/component-protocol-en.md) · [Component development guide](docs/component-development-en.md): declarations, behavior contracts and compatibility acceptance for new components.
|
|
20
|
+
- [0.4.0 release and migration](docs/release-0.4.0-en.md): what this release adds and how to upgrade from `0.3.1` / `local-draft-1`.
|
|
21
|
+
|
|
22
|
+
## Write a document
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
<panel title="Cost estimate">
|
|
26
|
+
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
27
|
+
<toggle bind="annual" label="Annual billing">
|
|
28
|
+
</panel>
|
|
29
|
+
|
|
30
|
+
Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Inputs update the result immediately, and the panel includes a restore-defaults action. A standalone counter is a single line: `<counter label="People">`.
|
|
34
|
+
|
|
35
|
+
`0.4.0` adds `local-draft-2`, named calculations, validation, collections, themes and offline HTML export. `0.3.1`, still the `latest` package, uses `local-draft-1`. See [0.4.0 release and migration](docs/release-0.4.0-en.md).
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
Reactive MD requires Node.js 22.12 or newer and ships only ESM entries:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm install reactive-md@next
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The `next` channel resolves to `0.4.0`; pin it with `npm install reactive-md@0.4.0`. The `latest` tag remains `0.3.1`, which uses `local-draft-1` and needs no migration from `0.3.x`.
|
|
46
|
+
|
|
47
|
+
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`.
|
|
48
|
+
|
|
49
|
+
The core `reactive-md` entry does not depend on React:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
53
|
+
|
|
54
|
+
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
55
|
+
if (result.ok) {
|
|
56
|
+
const runtime = createLocalRuntime(result.document);
|
|
57
|
+
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
58
|
+
finally { runtime.dispose(); }
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
See [Local mode integration](docs/local-integration-en.md) for the full compile and runtime APIs, host URL policy, lifecycle and style overrides.
|
|
63
|
+
|
|
64
|
+
0.x minor releases may contain breaking changes. Before upgrading, read the [changelog](CHANGELOG.md) and [compatibility rules](docs/compatibility-en.md), and keep the original `.reactive.md` sources.
|
|
65
|
+
|
|
66
|
+
## Use with React
|
|
67
|
+
|
|
68
|
+
The React entry requires React 19:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
npm install react@19 react-dom@19
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
76
|
+
import 'reactive-md/styles.css';
|
|
77
|
+
|
|
78
|
+
export function Article({ source }: { source: string }) {
|
|
79
|
+
return <LocalReactiveDocument source={source} />;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`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/local-integration-en.md).
|
|
84
|
+
|
|
85
|
+
## Share documents
|
|
86
|
+
|
|
87
|
+
Build a self-contained HTML file that readers can open offline, or a script-free static snapshot:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npm run build
|
|
91
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
92
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
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. The demo export dialog can save the current preview parameters as such a file.
|
|
96
|
+
|
|
97
|
+
See [Shareable documents and static export](docs/shareable-export-en.md) for image limits, CSP/security, printing, exit codes, `ReactiveMD.mount`/`mountAll` and `<reactive-md-doc>`.
|
|
98
|
+
|
|
99
|
+
## Try the demo
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
npm ci
|
|
103
|
+
npm run dev
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The command builds the language package first, then starts the standalone `demo/` app at `http://127.0.0.1:5173`. `/embed.html` demonstrates the embedding approach. The masthead language toggle switches the demo between English and Chinese, and the choice is saved in the browser. The demo pages, editor, demo server, assets and browser checks all live in `demo/` and integrate through the package's public entries.
|
|
107
|
+
|
|
108
|
+
## Repository layout
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
src/ Local syntax compilation, expressions, runtime and React renderer
|
|
112
|
+
examples/ Copyable local interactive examples, independent of the demo app
|
|
113
|
+
docs/ Local syntax specification, integration and release documentation
|
|
114
|
+
tests/ Language and renderer tests
|
|
115
|
+
demo/ Standalone Playground app
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Documentation
|
|
119
|
+
|
|
120
|
+
- [Beginner guide](docs/local-guide-en.md) and [local interaction syntax specification](docs/local-interaction-syntax-en.md).
|
|
121
|
+
- [Local mode integration](docs/local-integration-en.md): core and React API, URL policy, lifecycle, styling and version pinning.
|
|
122
|
+
- [Shareable documents and static export](docs/shareable-export-en.md): CLI build/lint, state files, local image inlining, printing and the standalone browser runtime.
|
|
123
|
+
- [Feature tours and examples](examples/local/README.md) and [standalone integrations](examples/integration/README.md).
|
|
124
|
+
- [Versions and compatibility](docs/compatibility-en.md): 0.x rules, migration, diagnostics and supported platforms.
|
|
125
|
+
- [0.4.0 release and migration](docs/release-0.4.0-en.md): the upgrade checklist for this release.
|
|
126
|
+
- [Component protocol](docs/component-protocol-en.md) and [component development guide](docs/component-development-en.md): contribution contracts, a proposal template and acceptance cases.
|
|
127
|
+
- [Performance measurements](docs/performance-en.md) and [release checklist](docs/releasing-en.md).
|
|
128
|
+
|
|
129
|
+
See the [contributing guide](CONTRIBUTING.md) for development and test commands.
|
|
130
|
+
|
|
131
|
+
## Support and status
|
|
132
|
+
|
|
133
|
+
- CI targets Node 22.12 and Node 24 with Playwright Chromium; local browser checks use Microsoft Edge. The packed check covers static SSR, and `npm run test:shareable` covers the single-file export's static-first hydration. General SSR hydration outside that path, Firefox and WebKit remain unverified.
|
|
134
|
+
- 0.x minor releases may contain breaking changes. Persist the original `.reactive.md` source, not the runtime AST or in-memory state.
|
|
135
|
+
- `0.4.0` is published on the `next` channel; `0.3.1` remains `latest` until a separate promotion decision. Security fixes may ship in minor releases.
|
|
136
|
+
|
|
137
|
+
## Contributing and security
|
|
138
|
+
|
|
139
|
+
- [Contributing guide](CONTRIBUTING.md): environment, check commands and change requirements.
|
|
140
|
+
- [Security policy](SECURITY.md): threat boundary, resource limits, host responsibilities and vulnerability reporting.
|
|
141
|
+
- [Changelog](CHANGELOG.md).
|
|
142
|
+
- [Release checklist](docs/releasing-en.md): the verification gate, notices, tarball and the manual release flow for maintainers.
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
[MIT](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,89 +1,146 @@
|
|
|
1
|
-
# Reactive MD
|
|
2
|
-
|
|
3
|
-
[English](README
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
15
|
-
- [
|
|
16
|
-
- [
|
|
17
|
-
- [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
npm install
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
1
|
+
# Reactive MD
|
|
2
|
+
|
|
3
|
+
[English](README-en.md) · [中文](README-ch.md)
|
|
4
|
+
|
|
5
|
+
Write local interactive documents in Markdown. Add input controls, name parameters with `bind`, and connect prose, formulas, charts and diagrams with `{{ expressions }}`. Document authors do not write JavaScript or CSS.
|
|
6
|
+
|
|
7
|
+
Local mode uses HTML-style tags, with parameters and table data written directly in the prose; LaTeX formulas can drive function plots. The TypeScript core and the React renderer can be integrated independently. `0.4.0` is the preview release on the `next` channel, with syntax revision `local-draft-2`. See [README-ch.md](README-ch.md) for the Chinese overview.
|
|
8
|
+
|
|
9
|
+
## Start here
|
|
10
|
+
|
|
11
|
+
- [Beginner guide](docs/local-guide-en.md): move from Markdown to interactive documents, with a complete exercise and an error quick reference.
|
|
12
|
+
- [Local interaction syntax specification](docs/local-interaction-syntax-en.md) · [Feature tours and examples](examples/local/README.md): 48 tag names, tags, in-place parameters and LaTeX plots.
|
|
13
|
+
- [Local mode integration](docs/local-integration-en.md): `compileLocal`, the state runtime, React embedding, URL policy and style scoping.
|
|
14
|
+
- [Shareable documents and static export](docs/shareable-export-en.md): single-file interactive HTML, static output, versioned state files, assets, the CLI and the standalone browser API.
|
|
15
|
+
- [Theme protocol](docs/theme-protocol-en.md): document theme selection, custom CSS and light/dark modes.
|
|
16
|
+
- [Author tools](docs/author-tools-en.md): source highlighting, completion, binding navigation, rename, formatting and command-line lint.
|
|
17
|
+
- [Standalone integration examples](examples/integration/README.md): Node core and React pages you can copy and run outside the repository.
|
|
18
|
+
- [Versions and compatibility](docs/compatibility-en.md): 0.x rules, migration, the diagnostics contract and supported platforms.
|
|
19
|
+
- [Component protocol](docs/component-protocol-en.md) · [Component development guide](docs/component-development-en.md): declarations, behavior contracts and compatibility acceptance for new components.
|
|
20
|
+
- [0.4.0 release and migration](docs/release-0.4.0-en.md): what this release adds and how to upgrade from `0.3.1` / `local-draft-1`.
|
|
21
|
+
|
|
22
|
+
## Write a document
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
<panel title="Cost estimate">
|
|
26
|
+
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
27
|
+
<toggle bind="annual" label="Annual billing">
|
|
28
|
+
</panel>
|
|
29
|
+
|
|
30
|
+
Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Inputs update the result immediately, and the panel includes a restore-defaults action. A standalone counter is a single line: `<counter label="People">`.
|
|
34
|
+
|
|
35
|
+
`0.4.0` adds `local-draft-2`, named calculations, validation, collections, themes and offline HTML export. `0.3.1`, still the `latest` package, uses `local-draft-1`. See [0.4.0 release and migration](docs/release-0.4.0-en.md).
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
Reactive MD requires Node.js 22.12 or newer and ships only ESM entries:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm install reactive-md@next
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The `next` channel resolves to `0.4.0`; pin it with `npm install reactive-md@0.4.0`. The `latest` tag remains `0.3.1`, which uses `local-draft-1` and needs no migration from `0.3.x`.
|
|
46
|
+
|
|
47
|
+
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`.
|
|
48
|
+
|
|
49
|
+
The core `reactive-md` entry does not depend on React:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
53
|
+
|
|
54
|
+
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
55
|
+
if (result.ok) {
|
|
56
|
+
const runtime = createLocalRuntime(result.document);
|
|
57
|
+
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
58
|
+
finally { runtime.dispose(); }
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
See [Local mode integration](docs/local-integration-en.md) for the full compile and runtime APIs, host URL policy, lifecycle and style overrides.
|
|
63
|
+
|
|
64
|
+
0.x minor releases may contain breaking changes. Before upgrading, read the [changelog](CHANGELOG.md) and [compatibility rules](docs/compatibility-en.md), and keep the original `.reactive.md` sources.
|
|
65
|
+
|
|
66
|
+
## Use with React
|
|
67
|
+
|
|
68
|
+
The React entry requires React 19:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
npm install react@19 react-dom@19
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
76
|
+
import 'reactive-md/styles.css';
|
|
77
|
+
|
|
78
|
+
export function Article({ source }: { source: string }) {
|
|
79
|
+
return <LocalReactiveDocument source={source} />;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`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/local-integration-en.md).
|
|
84
|
+
|
|
85
|
+
## Share documents
|
|
86
|
+
|
|
87
|
+
Build a self-contained HTML file that readers can open offline, or a script-free static snapshot:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
npm run build
|
|
91
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
92
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
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. The demo export dialog can save the current preview parameters as such a file.
|
|
96
|
+
|
|
97
|
+
See [Shareable documents and static export](docs/shareable-export-en.md) for image limits, CSP/security, printing, exit codes, `ReactiveMD.mount`/`mountAll` and `<reactive-md-doc>`.
|
|
98
|
+
|
|
99
|
+
## Try the demo
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
npm ci
|
|
103
|
+
npm run dev
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The command builds the language package first, then starts the standalone `demo/` app at `http://127.0.0.1:5173`. `/embed.html` demonstrates the embedding approach. The masthead language toggle switches the demo between English and Chinese, and the choice is saved in the browser. The demo pages, editor, demo server, assets and browser checks all live in `demo/` and integrate through the package's public entries.
|
|
107
|
+
|
|
108
|
+
## Repository layout
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
src/ Local syntax compilation, expressions, runtime and React renderer
|
|
112
|
+
examples/ Copyable local interactive examples, independent of the demo app
|
|
113
|
+
docs/ Local syntax specification, integration and release documentation
|
|
114
|
+
tests/ Language and renderer tests
|
|
115
|
+
demo/ Standalone Playground app
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Documentation
|
|
119
|
+
|
|
120
|
+
- [Beginner guide](docs/local-guide-en.md) and [local interaction syntax specification](docs/local-interaction-syntax-en.md).
|
|
121
|
+
- [Local mode integration](docs/local-integration-en.md): core and React API, URL policy, lifecycle, styling and version pinning.
|
|
122
|
+
- [Shareable documents and static export](docs/shareable-export-en.md): CLI build/lint, state files, local image inlining, printing and the standalone browser runtime.
|
|
123
|
+
- [Feature tours and examples](examples/local/README.md) and [standalone integrations](examples/integration/README.md).
|
|
124
|
+
- [Versions and compatibility](docs/compatibility-en.md): 0.x rules, migration, diagnostics and supported platforms.
|
|
125
|
+
- [0.4.0 release and migration](docs/release-0.4.0-en.md): the upgrade checklist for this release.
|
|
126
|
+
- [Component protocol](docs/component-protocol-en.md) and [component development guide](docs/component-development-en.md): contribution contracts, a proposal template and acceptance cases.
|
|
127
|
+
- [Performance measurements](docs/performance-en.md) and [release checklist](docs/releasing-en.md).
|
|
128
|
+
|
|
129
|
+
See the [contributing guide](CONTRIBUTING.md) for development and test commands.
|
|
130
|
+
|
|
131
|
+
## Support and status
|
|
132
|
+
|
|
133
|
+
- CI targets Node 22.12 and Node 24 with Playwright Chromium; local browser checks use Microsoft Edge. The packed check covers static SSR, and `npm run test:shareable` covers the single-file export's static-first hydration. General SSR hydration outside that path, Firefox and WebKit remain unverified.
|
|
134
|
+
- 0.x minor releases may contain breaking changes. Persist the original `.reactive.md` source, not the runtime AST or in-memory state.
|
|
135
|
+
- `0.4.0` is published on the `next` channel; `0.3.1` remains `latest` until a separate promotion decision. Security fixes may ship in minor releases.
|
|
136
|
+
|
|
137
|
+
## Contributing and security
|
|
138
|
+
|
|
139
|
+
- [Contributing guide](CONTRIBUTING.md): environment, check commands and change requirements.
|
|
140
|
+
- [Security policy](SECURITY.md): threat boundary, resource limits, host responsibilities and vulnerability reporting.
|
|
141
|
+
- [Changelog](CHANGELOG.md).
|
|
142
|
+
- [Release checklist](docs/releasing-en.md): the verification gate, notices, tarball and the manual release flow for maintainers.
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
[MIT](LICENSE)
|
package/SECURITY-ch.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# 安全策略
|
|
2
|
+
|
|
3
|
+
Reactive MD 渲染作者编写的本地交互文档。文档是不可信输入时,渲染器、表达式和数学求值都按下面的边界处理。宿主仍然负责授权、网络策略和服务端数据。
|
|
4
|
+
|
|
5
|
+
## 支持范围
|
|
6
|
+
|
|
7
|
+
当前维护最新的 0.x 预览版本。安全修复可能随次版本发布,并在[变更记录](CHANGELOG-ch.md)中说明影响和迁移步骤。
|
|
8
|
+
|
|
9
|
+
## 威胁边界
|
|
10
|
+
|
|
11
|
+
以下保证有编译器、运行时和渲染器测试覆盖;未列出的能力不做承诺。
|
|
12
|
+
|
|
13
|
+
### 文档内容
|
|
14
|
+
|
|
15
|
+
- 作者不能执行脚本。`<script>`、原始 HTML、`on-*` 事件属性和作者 CSS 不属于 `local-draft-2`,会作为语法诊断或文本处理,不会作为 HTML 执行。
|
|
16
|
+
- React 渲染器不调用 `dangerouslySetInnerHTML`,也不把文档内容写入 `innerHTML`。
|
|
17
|
+
- 表达式使用自己的解析器和 AST 求值器,不使用 `eval`、`new Function`,不支持赋值、方法调用、属性访问、原型路径或导入。表达式只能读取文档声明的参数和内置函数。
|
|
18
|
+
- LaTeX 通过受预算限制的解析器计算,并由原生 MathML 渲染;渲染器不执行宏、文件、网络或 HTML 入口。未知命令显示为文本。
|
|
19
|
+
- 表达式、模板、表格和图表不会发起网络请求;图表数据必须写在文档里。
|
|
20
|
+
|
|
21
|
+
### URL 与网络
|
|
22
|
+
|
|
23
|
+
- 图片默认全部拒绝,包括相对路径和协议相对地址,因此加载文档本身不会触发图片请求。
|
|
24
|
+
- 只有宿主传入 `urlPolicy` 且策略返回 `true` 时,图片才会加载。带协议的图片地址仍先检查协议,只允许 `http:` 和 `https:`;相对地址则由策略决定。`javascript:`、危险的 `data:` 等地址即使策略放行也会被拒绝。
|
|
25
|
+
- 链接默认允许相对地址和 `http:`、`https:`、`mailto:`、`tel:`;外部 HTTP 链接以新标签打开并带 `noopener noreferrer`。危险协议始终拒绝。
|
|
26
|
+
- 策略抛出异常时拒绝该地址。获准加载的图片使用 `referrerPolicy="no-referrer"`;同源图片仍可能携带 Cookie,图片白名单应避开业务 API。
|
|
27
|
+
- 受信任的 `imageResolver` 只在图片地址通过协议检查和 `urlPolicy` 后运行,把允许的地址映射为宿主控制的输出;导出文件只使用经过验证的 `data:image/png|jpeg|gif|webp;base64` 值,链接不会进入该回调。
|
|
28
|
+
- `urlPolicy` 是 URL 允许列表,不是服务端授权。宿主仍需配置 CSP、网络出口、图片代理或沙箱 iframe(当作者完全不可信时)。
|
|
29
|
+
|
|
30
|
+
### 资源上限
|
|
31
|
+
|
|
32
|
+
`src/local/limits.ts` 定义共享上限,编译、运行时和可视化共同使用:
|
|
33
|
+
|
|
34
|
+
| 限制 | 值 |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| 单份文档源码 | 1,000,000 字符 |
|
|
37
|
+
| 解析期间累计创建的语法节点 | 默认 10,000,由宿主按次配置 |
|
|
38
|
+
| 单个字符串值或模板 | 100,000 字符 |
|
|
39
|
+
| 单个数组 | 10,000 项 |
|
|
40
|
+
| 数组内字符串总长度 | 100,000 字符 |
|
|
41
|
+
| 邮箱地址 | 254 字符,线性校验 |
|
|
42
|
+
| 诊断数量 | 100 条 |
|
|
43
|
+
| 单条诊断文本 | 2,000 字符 |
|
|
44
|
+
| 每个绘图组件的曲线数 | 16 |
|
|
45
|
+
| 整篇文档请求的曲线采样点 | 20,000 |
|
|
46
|
+
| 绘图共享计算步数 | 2,000,000 |
|
|
47
|
+
|
|
48
|
+
超限写入会被拒绝,运行时保持上一次合法状态;编译期超限返回诊断。绘图和数学计算还有各自的深度、记号和节点预算。预算用于限制单个文档的工作量,不替代宿主对请求大小、并发和超时的控制。
|
|
49
|
+
|
|
50
|
+
宿主通过 `compileLocal(source, { limits: { maxSyntaxNodes } })` 为单次编译调整语法节点预算,取值必须是正的安全整数。文档内容不能修改该设置。省略时保留 10,000 的默认预算;提高节点预算不会改变源码长度、数组、表达式或绘图的其他上限。计数覆盖解析中创建的全部 `LocalNode`,包含部分最终未保留的中间节点。
|
|
51
|
+
|
|
52
|
+
### 状态与隔离
|
|
53
|
+
|
|
54
|
+
- 参数状态只存在于当前文档实例的内存中。每个 `LocalReactiveDocument` 或 `LocalDocumentView` 实例独立;销毁时会清理订阅、表达式缓存和计时器。
|
|
55
|
+
- `createLocalRuntime` 会校验初值和共享控件的约束;`set` 以文档中登记的控件为准,忽略调用方伪造的节点元数据,并且只有在所有共享控件都接受时才原子提交。
|
|
56
|
+
- `snapshot()` 返回稳定的冻结快照,其中的数组也被冻结;`get()` 和 `evaluate()` 返回数组副本。状态更新通过 `set()` 校验后提交。
|
|
57
|
+
- `disabled` 和 `if` 只是界面展示状态,不是权限控制。业务权限和值校验必须由宿主在提交到服务端时执行。
|
|
58
|
+
|
|
59
|
+
### 可分享 HTML 导出
|
|
60
|
+
|
|
61
|
+
- `reactive-md-state/v1` 只保存公开绑定名和可序列化值,不保存 `@` 内部绑定、revision、节点 ID、AST、UI 状态或计时器。导入前会校验源码摘要、语法、参数集合和每个值;未知或冲突键会拒绝整个文件。
|
|
62
|
+
- 交互式 HTML 内嵌固定版本的独立运行时,CSP 禁止网络连接、frame、object、base 注入和表单提交,只允许内联样式/运行时与 `data:` 图片。JSON、源码、标题和 notices 会按 HTML/脚本上下文转义。
|
|
63
|
+
- CLI 只内联位于文档目录或显式资源根内的相对位图。它拒绝远程图片、URL scheme、绝对路径、路径穿越、符号链接逃逸、SVG、伪造格式和超限资源。Demo 导出对话框在包含图片时会禁用 HTML 导出。
|
|
64
|
+
- 静态 HTML 不包含运行时脚本或自动挂载载荷。静态首屏水合目前只在单文件 Chromium/Edge 路径验证,不构成通用水合或沙箱保证。作者完全不可信时应使用 sandboxed iframe。
|
|
65
|
+
- 导出当前参数是宿主/读者的显式动作。生成的状态文件和 HTML 可能包含敏感信息;除非确实要分享当前值,否则应选择作者初值。
|
|
66
|
+
|
|
67
|
+
## 宿主责任
|
|
68
|
+
|
|
69
|
+
- 决定谁可以编写、提交和分享文档;限制不可信作者的请求大小、并发和执行时间。编译 1,000,000 字符的文档仍是真实的 CPU 工作。
|
|
70
|
+
- 为图片和链接配置 `urlPolicy`;维持 CSP、网络出口控制和图片白名单。
|
|
71
|
+
- 在服务端重新校验表单值、权限和业务约束,不信任文档中的 `disabled`、条件显示或客户端状态。
|
|
72
|
+
- 需要持久化时,安全地保存原始 `.reactive.md` 源码;运行时状态和 `LocalDocument` 不应当作持久化格式。
|
|
73
|
+
- 在服务端静态渲染不可信文档之前,评估渲染进程的资源上限;通用 SSR 水合仍未验证,只有单文件静态首屏路径在 Chromium/Edge 有覆盖。水合不应作为安全边界。
|
|
74
|
+
- 第三方依赖漏洞应同时报告给上游项目;本包只负责自身集成代码。
|
|
75
|
+
|
|
76
|
+
## 报告漏洞
|
|
77
|
+
|
|
78
|
+
仓库已启用 GitHub 私密漏洞报告。请通过 [Report a vulnerability](https://github.com/yao1145/ReactiveMD/security/advisories/new) 提交受影响版本、最小复现、预期影响和修复建议。
|
|
79
|
+
|
|
80
|
+
使用私密渠道报告漏洞细节;公开 issue 和 PR 中请移除利用代码、凭据、用户数据及受影响部署的信息。
|
package/SECURITY.md
CHANGED
|
@@ -1,71 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Security policy
|
|
2
2
|
|
|
3
|
-
Reactive MD
|
|
3
|
+
Reactive MD renders local interactive documents written by authors. When document content is untrusted input, the renderer, expressions and math evaluation all stay within the boundaries below. The host remains responsible for authorization, network policy and server-side data.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Supported versions
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Current maintenance covers the latest 0.x preview. Security fixes may ship in minor releases and are described in the [changelog](CHANGELOG.md) with impact and migration steps.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Threat boundary
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The guarantees below are covered by compiler, runtime and renderer tests; capabilities not listed here are not promised.
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### Document content
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
- React
|
|
17
|
-
-
|
|
18
|
-
- LaTeX
|
|
19
|
-
-
|
|
15
|
+
- Authors cannot execute scripts. `<script>`, raw HTML, `on-*` event attributes and author CSS are not part of `local-draft-2`; they are treated as syntax diagnostics or text, never executed as HTML.
|
|
16
|
+
- The React renderer does not call `dangerouslySetInnerHTML` and does not write document content into `innerHTML`.
|
|
17
|
+
- Expressions use their own parser and AST evaluator, with no `eval` or `new Function`, and no support for assignment, method calls, property access, prototype paths or imports. Expressions can only read parameters declared by the document and built-in functions.
|
|
18
|
+
- LaTeX is evaluated by a budget-limited parser and rendered as native MathML; the renderer does not execute macros, files, network or HTML entry points. Unknown commands are displayed as text.
|
|
19
|
+
- Expressions, templates, tables and charts do not make network requests; chart data must be written in the document.
|
|
20
20
|
|
|
21
|
-
###
|
|
21
|
+
### URLs and networking
|
|
22
22
|
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
- `
|
|
23
|
+
- All images are rejected by default, including relative paths and protocol-relative addresses, so loading the document itself triggers no image requests.
|
|
24
|
+
- Images load only when the host passes `urlPolicy` and the policy returns `true`. Images with a protocol still have that protocol checked first: only `http:` and `https:` are allowed. Relative addresses are decided by the policy. Addresses such as `javascript:` or dangerous `data:` URLs are rejected even if the policy allows them.
|
|
25
|
+
- Links allow relative addresses and `http:`, `https:`, `mailto:` and `tel:` by default; external HTTP links open in a new tab with `noopener noreferrer`. Dangerous protocols are always rejected.
|
|
26
|
+
- If the policy throws, the address is rejected. Images that are allowed to load use `referrerPolicy="no-referrer"`; same-origin images may still carry cookies, so image allowlists should avoid business APIs.
|
|
27
|
+
- A trusted `imageResolver` runs only after the image URL passes protocol checks and `urlPolicy`. It maps an accepted URL to host-controlled output; exported files use only verified `data:image/png|jpeg|gif|webp;base64` values, and links never reach it.
|
|
28
|
+
- `urlPolicy` is a URL allowlist, not server-side authorization. The host still needs to configure CSP, network egress, an image proxy or a sandboxed iframe (when authors are fully untrusted).
|
|
28
29
|
|
|
29
|
-
###
|
|
30
|
+
### Resource limits
|
|
30
31
|
|
|
31
|
-
`src/local/limits.ts`
|
|
32
|
+
`src/local/limits.ts` defines shared limits used by compilation, the runtime and visualizations:
|
|
32
33
|
|
|
33
|
-
|
|
|
34
|
+
| Limit | Value |
|
|
34
35
|
| --- | --- |
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
36
|
+
| Source per document | 1,000,000 characters |
|
|
37
|
+
| Syntax nodes created cumulatively during parsing | 10,000 by default, configured per call by the host |
|
|
38
|
+
| A single string value or template | 100,000 characters |
|
|
39
|
+
| A single array | 10,000 items |
|
|
40
|
+
| Total string length within an array | 100,000 characters |
|
|
41
|
+
| Email address | 254 characters, validated in linear time |
|
|
42
|
+
| Number of diagnostics | 100 |
|
|
43
|
+
| Text of a single diagnostic | 2,000 characters |
|
|
44
|
+
| Curves per plot component | 16 |
|
|
45
|
+
| Curve sample points requested by the whole document | 20,000 |
|
|
46
|
+
| Shared computation steps for plotting | 2,000,000 |
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
Writes over a limit are rejected and the runtime keeps the last valid state; compile-time overruns return diagnostics. Plotting and math evaluation also have their own depth, token and node budgets. Budgets bound the work for a single document; they do not replace host control over request size, concurrency and timeouts.
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
Hosts can adjust the syntax node budget for a single compilation with `compileLocal(source, { limits: { maxSyntaxNodes } })`; the value must be a positive safe integer. Document content cannot change this setting. When omitted, the default budget of 10,000 applies; raising the node budget does not change the source length, array, expression or plotting limits. The count covers every `LocalNode` created during parsing, including intermediate nodes that are not kept in the final tree.
|
|
50
51
|
|
|
51
|
-
###
|
|
52
|
+
### State and isolation
|
|
52
53
|
|
|
53
|
-
-
|
|
54
|
-
- `createLocalRuntime`
|
|
55
|
-
- `snapshot()`
|
|
56
|
-
- `disabled`
|
|
54
|
+
- Parameter state exists only in the memory of the current document instance. Each `LocalReactiveDocument` or `LocalDocumentView` instance is independent; disposal clears subscriptions, expression caches and timers.
|
|
55
|
+
- `createLocalRuntime` validates initial values and constraints on shared controls; `set` relies on the controls registered in the document, ignores forged node metadata from the caller, and commits atomically only when every shared control accepts the write.
|
|
56
|
+
- `snapshot()` returns a stable frozen snapshot, including frozen arrays; `get()` and `evaluate()` return array copies. State updates are committed through validated `set()` calls.
|
|
57
|
+
- `disabled` and `if` are display states only, not permission control. Business permissions and value validation must be enforced by the host when submitting to the server.
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
### Shareable HTML export
|
|
59
60
|
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
- 第三方依赖漏洞应同时报告给上游项目;本包只负责自身集成代码。
|
|
61
|
+
- `reactive-md-state/v1` stores only public binding names and serializable values. It excludes `@` internal bindings, revisions, node IDs, AST data, UI state and timers. Source digest, syntax, parameter set and every value are validated before import; unknown or conflicting keys reject the whole file.
|
|
62
|
+
- Interactive HTML embeds a fixed standalone runtime and a CSP with no network connections, frames, objects, base injection or form submission. Only inline styles/runtime and `data:` images are allowed. JSON, source, titles and notices are escaped for their HTML/script context.
|
|
63
|
+
- The CLI inlines only relative raster files that resolve inside the document directory or an explicit asset root. It rejects remote images, URL schemes, absolute paths, traversal, symlink escapes, SVG, forged formats and oversized assets. The demo export dialog disables HTML export when images are present.
|
|
64
|
+
- Static HTML contains no runtime script or auto-mount payload. Static-first hydration is covered only in the single-file Chromium/Edge path; it is not a general hydration or sandboxing guarantee. Use a sandboxed iframe for fully untrusted authors.
|
|
65
|
+
- Exporting current parameters is an explicit host/reader action. Treat the generated state file and HTML as potentially sensitive; choose initial values unless current values are intentionally meant to be shared.
|
|
66
66
|
|
|
67
|
-
##
|
|
67
|
+
## Host responsibilities
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
- Decide who may write, submit and share documents; limit request size, concurrency and execution time for untrusted authors. Compiling a 1,000,000-character document is still real CPU work.
|
|
70
|
+
- Configure `urlPolicy` for images and links; maintain CSP, network egress control and image allowlists.
|
|
71
|
+
- Revalidate form values, permissions and business constraints on the server; do not trust `disabled`, conditional visibility or client state inside the document.
|
|
72
|
+
- When persistence is needed, store the original `.reactive.md` source securely; runtime state and `LocalDocument` should not be treated as a persistence format.
|
|
73
|
+
- Before statically rendering untrusted documents on the server, assess the resource limits of the rendering process. General SSR hydration remains unverified; only the single-file static-first path has Chromium/Edge coverage. Hydration is not a security boundary.
|
|
74
|
+
- Report vulnerabilities in third-party dependencies upstream as well; this package is responsible only for its own integration code.
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
## Reporting vulnerabilities
|
|
77
|
+
|
|
78
|
+
The repository has GitHub private vulnerability reporting enabled. Submit affected versions, a minimal reproduction, expected impact and remediation suggestions through [Report a vulnerability](https://github.com/yao1145/ReactiveMD/security/advisories/new).
|
|
79
|
+
|
|
80
|
+
Use the private channel to report vulnerability details; remove exploit code, credentials, user data and information about affected deployments from public issues and PRs.
|