reactive-md 0.6.0 → 0.6.1
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 +203 -194
- package/CHANGELOG.md +203 -194
- package/CONTRIBUTING-ch.md +67 -67
- package/CONTRIBUTING.md +69 -69
- package/README-ch.md +157 -157
- package/README-en.md +184 -184
- package/README.md +184 -184
- package/SECURITY-ch.md +81 -81
- package/SECURITY.md +81 -81
- package/THIRD_PARTY_NOTICES.md +313 -209
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +181 -181
- package/cli/assets.mjs +390 -390
- package/cli/build.mjs +268 -268
- 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 +138 -138
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +55 -55
- package/cli/migrate.mjs +368 -368
- package/cli/package.mjs +210 -210
- package/dist-library/{authoring-DSC0VsNK.js → authoring-BEVyth5X.js} +1 -1
- package/dist-library/compiler-Cm3ppMxG.js +46044 -0
- package/dist-library/{react-Dk94rcOp.js → react-Bh7_oxZp.js} +20110 -20113
- package/dist-library/reactive-md-authoring.js +2 -2
- package/dist-library/reactive-md-print.css +284 -284
- package/dist-library/reactive-md-react-unstyled.js +1 -1
- package/dist-library/reactive-md-react.js +1 -1
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +3 -3
- package/dist-library/{runtime-D8KbnCd0.js → runtime-DlFYQ4s_.js} +1 -1
- package/dist-library/types/local/math-display.d.ts +22 -23
- package/dist-library/types/local/math-view.d.ts +6 -7
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +318 -62
- package/docs/compatibility/compatibility-ch.md +121 -119
- package/docs/compatibility/compatibility-en.md +121 -119
- package/docs/compatibility/source-versioning-ch.md +159 -159
- package/docs/compatibility/source-versioning-en.md +159 -159
- package/docs/development/component-development-ch.md +210 -210
- package/docs/development/component-development-en.md +210 -210
- package/docs/development/component-protocol-ch.md +747 -747
- package/docs/development/component-protocol-en.md +747 -747
- package/docs/development/performance-ch.md +76 -76
- package/docs/development/performance-en.md +76 -76
- package/docs/development/releasing-ch.md +108 -108
- package/docs/development/releasing-en.md +108 -108
- package/docs/integration/author-tools-ch.md +62 -62
- package/docs/integration/author-tools-en.md +62 -62
- package/docs/integration/shareable-export-ch.md +209 -209
- package/docs/integration/shareable-export-en.md +211 -211
- package/docs/reference/computations-formatting-ch.md +87 -87
- package/docs/reference/computations-formatting-en.md +87 -87
- package/docs/reference/constraints-collections-ch.md +84 -84
- package/docs/reference/constraints-collections-en.md +84 -84
- package/docs/reference/diagnostics-counting-ch.md +104 -104
- package/docs/reference/diagnostics-counting-en.md +104 -104
- package/docs/reference/local-components-v2-ch.md +138 -138
- package/docs/reference/local-components-v2-en.md +104 -104
- package/docs/reference/local-interaction-syntax-ch.md +515 -511
- package/docs/reference/local-interaction-syntax-en.md +511 -507
- package/docs/reference/theme-protocol-ch.md +107 -107
- package/docs/reference/theme-protocol-en.md +107 -107
- package/docs/releases/release-0.4.0-ch.md +89 -89
- package/docs/releases/release-0.4.0-en.md +89 -89
- package/docs/releases/release-0.4.1-ch.md +23 -23
- package/docs/releases/release-0.4.1-en.md +23 -23
- package/docs/releases/release-0.6.1-ch.md +27 -0
- package/docs/releases/release-0.6.1-en.md +27 -0
- package/examples/conformance/README.md +53 -53
- 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/integration/README.md +47 -47
- package/examples/integration/core/index.mjs +32 -32
- 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.md +74 -74
- 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.md +25 -25
- 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/package.json +152 -152
- package/dist-library/compiler-CRD88BMt.js +0 -24964
package/README.md
CHANGED
|
@@ -1,184 +1,184 @@
|
|
|
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.6.
|
|
8
|
-
|
|
9
|
-
## Start here
|
|
10
|
-
|
|
11
|
-
- [Documentation index](docs/README.md): guides, references, integration, compatibility, development and releases.
|
|
12
|
-
- [Beginner guide](docs/guides/local-guide-en.md): move from Markdown to interactive documents, with a complete exercise and an error quick reference.
|
|
13
|
-
- [Local interaction syntax specification](docs/reference/local-interaction-syntax-en.md) · [Feature tours and examples](examples/local/README.md): 48 tag names, tags, in-place parameters and LaTeX plots.
|
|
14
|
-
- [Local mode integration](docs/integration/local-integration-en.md): `compileLocal`, the state runtime, React embedding, URL policy and style scoping.
|
|
15
|
-
- [HTML compatibility](docs/reference/html-compatibility-en.md): P0 HTML and the next release's temporary routing policy for author CSS, JavaScript and extended HTML.
|
|
16
|
-
- [Shareable documents and static export](docs/integration/shareable-export-en.md): single-file interactive HTML, static output, versioned state files, assets, the CLI and the standalone browser API.
|
|
17
|
-
- [Theme protocol](docs/reference/theme-protocol-en.md): document theme selection, custom CSS and light/dark modes.
|
|
18
|
-
- [Author tools](docs/integration/author-tools-en.md): source highlighting, completion, binding navigation, rename, formatting and command-line lint.
|
|
19
|
-
- [React source editor](docs/integration/editor-en.md): controlled editor, props, ref handle, diagnostics, locale, theme and history.
|
|
20
|
-
- [Standalone integration examples](examples/integration/README.md): Node core and React pages you can copy and run outside the repository.
|
|
21
|
-
- [Versions and compatibility](docs/compatibility/compatibility-en.md): 0.x rules, migration, the diagnostics contract and supported platforms.
|
|
22
|
-
- [Component protocol](docs/development/component-protocol-en.md) · [Component development guide](docs/development/component-development-en.md): declarations, behavior contracts and compatibility acceptance for new components.
|
|
23
|
-
- [0.6.
|
|
24
|
-
- [0.5.3 release notes](docs/releases/release-0.5.3-en.md): host integration and authoring patches.
|
|
25
|
-
- [0.5.1 release notes](docs/releases/release-0.5.1-en.md): editor views and themes, plus HTML compatibility.
|
|
26
|
-
- [0.5.0 release notes](docs/releases/release-0.5.0-en.md): the editor entry and document rendering fixes.
|
|
27
|
-
- [0.4.1 release notes](docs/releases/release-0.4.1-en.md): visual and interaction fixes, compatible with 0.4.0.
|
|
28
|
-
- [0.4.0 release and migration](docs/releases/release-0.4.0-en.md): what the minor series adds and how to upgrade from `0.3.1` / `local-draft-1`.
|
|
29
|
-
|
|
30
|
-
## Write a document
|
|
31
|
-
|
|
32
|
-
```markdown
|
|
33
|
-
<panel title="Cost estimate">
|
|
34
|
-
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
35
|
-
<toggle bind="annual" label="Annual billing">
|
|
36
|
-
</panel>
|
|
37
|
-
|
|
38
|
-
Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Inputs update the result immediately, and the panel includes a restore-defaults action. A standalone counter is a single line: `<counter label="People">`.
|
|
42
|
-
|
|
43
|
-
`0.4.0` adds `local-draft-2`, named calculations, validation, collections, themes and offline HTML export. The earlier `0.3.1` release uses `local-draft-1`. See [0.4.0 release and migration](docs/releases/release-0.4.0-en.md).
|
|
44
|
-
|
|
45
|
-
## Install
|
|
46
|
-
|
|
47
|
-
Reactive MD requires Node.js 22.12 or newer and ships only ESM entries:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
npm install reactive-md
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
`latest` and `next` both resolve to `0.6.
|
|
54
|
-
|
|
55
|
-
```sh
|
|
56
|
-
npm install reactive-md
|
|
57
|
-
# or pin the version
|
|
58
|
-
npm install reactive-md@0.6.
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Read the [0.6.
|
|
62
|
-
|
|
63
|
-
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`. Existing renderer and style imports are unchanged in 0.6.
|
|
64
|
-
|
|
65
|
-
The core `reactive-md` entry does not depend on React:
|
|
66
|
-
|
|
67
|
-
```js
|
|
68
|
-
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
69
|
-
|
|
70
|
-
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
71
|
-
if (result.ok) {
|
|
72
|
-
const runtime = createLocalRuntime(result.document);
|
|
73
|
-
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
74
|
-
finally { runtime.dispose(); }
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
See [Local mode integration](docs/integration/local-integration-en.md) for the full compile and runtime APIs, host URL policy, lifecycle and style overrides.
|
|
79
|
-
|
|
80
|
-
0.x minor releases may contain breaking changes. Before upgrading, read the [changelog](CHANGELOG.md) and [compatibility rules](docs/compatibility/compatibility-en.md), and keep the original `.reactive.md` sources.
|
|
81
|
-
|
|
82
|
-
## Use with React
|
|
83
|
-
|
|
84
|
-
The React entry requires React 19:
|
|
85
|
-
|
|
86
|
-
```sh
|
|
87
|
-
npm install react@19 react-dom@19
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
```tsx
|
|
91
|
-
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
92
|
-
import 'reactive-md/styles.css';
|
|
93
|
-
|
|
94
|
-
export function Article({ source }: { source: string }) {
|
|
95
|
-
return <LocalReactiveDocument source={source} />;
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
`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).
|
|
100
|
-
|
|
101
|
-
## Edit source with React
|
|
102
|
-
|
|
103
|
-
The 0.5.x preview adds a reusable source editor at `reactive-md/editor`, with its own stylesheet at `reactive-md/editor/styles.css`. The component is controlled and requires React 19:
|
|
104
|
-
|
|
105
|
-
```tsx
|
|
106
|
-
import { useState } from 'react';
|
|
107
|
-
import { ReactiveMarkdownEditor } from 'reactive-md/editor';
|
|
108
|
-
import 'reactive-md/editor/styles.css';
|
|
109
|
-
|
|
110
|
-
export function Editor() {
|
|
111
|
-
const [source, setSource] = useState('# Notes');
|
|
112
|
-
return <ReactiveMarkdownEditor value={source} onChange={setSource} />;
|
|
113
|
-
}
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
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 the props, ref handle, diagnostics, themes, locales and history.
|
|
117
|
-
|
|
118
|
-
## Share documents
|
|
119
|
-
|
|
120
|
-
Build a self-contained HTML file that readers can open offline, or a script-free static snapshot:
|
|
121
|
-
|
|
122
|
-
```sh
|
|
123
|
-
npm run build
|
|
124
|
-
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
125
|
-
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
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.
|
|
129
|
-
|
|
130
|
-
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>`.
|
|
131
|
-
|
|
132
|
-
## Try the demo
|
|
133
|
-
|
|
134
|
-
```sh
|
|
135
|
-
npm ci
|
|
136
|
-
npm run dev
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
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.
|
|
140
|
-
|
|
141
|
-
## Repository layout
|
|
142
|
-
|
|
143
|
-
```text
|
|
144
|
-
src/ Local syntax compilation, expressions, runtime and React renderer
|
|
145
|
-
examples/ Copyable local interactive examples, independent of the demo app
|
|
146
|
-
docs/ Local syntax specification, integration and release documentation
|
|
147
|
-
tests/ Language and renderer tests
|
|
148
|
-
demo/ Standalone Playground app
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Documentation
|
|
152
|
-
|
|
153
|
-
- [Beginner guide](docs/guides/local-guide-en.md) and [local interaction syntax specification](docs/reference/local-interaction-syntax-en.md).
|
|
154
|
-
- [Local mode integration](docs/integration/local-integration-en.md): core and React API, URL policy, lifecycle, styling and version pinning.
|
|
155
|
-
- [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.
|
|
156
|
-
- [Feature tours and examples](examples/local/README.md) and [standalone integrations](examples/integration/README.md).
|
|
157
|
-
- [React source editor](docs/integration/editor-en.md): controlled editor for `.reactive.md` source, with its own stylesheet.
|
|
158
|
-
- [Versions and compatibility](docs/compatibility/compatibility-en.md): 0.x rules, migration, diagnostics and supported platforms.
|
|
159
|
-
- [0.6.
|
|
160
|
-
- [0.5.3 release notes](docs/releases/release-0.5.3-en.md): host integration and authoring patches.
|
|
161
|
-
- [0.5.1 release notes](docs/releases/release-0.5.1-en.md): editor views and themes, plus HTML compatibility.
|
|
162
|
-
- [0.5.0 release notes](docs/releases/release-0.5.0-en.md): the editor entry and document rendering fixes.
|
|
163
|
-
- [0.4.0 release and migration](docs/releases/release-0.4.0-en.md): the upgrade checklist for that minor series.
|
|
164
|
-
- [Component protocol](docs/development/component-protocol-en.md) and [component development guide](docs/development/component-development-en.md): contribution contracts, a proposal template and acceptance cases.
|
|
165
|
-
- [Performance measurements](docs/development/performance-en.md) and [release checklist](docs/development/releasing-en.md).
|
|
166
|
-
|
|
167
|
-
See the [contributing guide](CONTRIBUTING.md) for development and test commands.
|
|
168
|
-
|
|
169
|
-
## Support and status
|
|
170
|
-
|
|
171
|
-
- CI targets Node 22.12 and Node 24 with Playwright Chromium for the full browser gate and Firefox/WebKit for core workflows; 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 and the full Firefox/WebKit interaction suites remain unverified.
|
|
172
|
-
- 0.x minor releases may contain breaking changes. Persist the original `.reactive.md` source, not the runtime AST or in-memory state.
|
|
173
|
-
- `latest` and `next` are both `0.6.
|
|
174
|
-
|
|
175
|
-
## Contributing and security
|
|
176
|
-
|
|
177
|
-
- [Contributing guide](CONTRIBUTING.md): environment, check commands and change requirements.
|
|
178
|
-
- [Security policy](SECURITY.md): threat boundary, resource limits, host responsibilities and vulnerability reporting.
|
|
179
|
-
- [Changelog](CHANGELOG.md).
|
|
180
|
-
- [Release checklist](docs/development/releasing-en.md): the verification gate, notices, tarball and the manual release flow for maintainers.
|
|
181
|
-
|
|
182
|
-
## License
|
|
183
|
-
|
|
184
|
-
[MIT](LICENSE)
|
|
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.6.1` is available on both `latest` and `next` and switches formula display to KaTeX with bundled math fonts and offline HTML support. Syntax revision stays `local-draft-2`, and the component protocol is `component-protocol-2`. See [README-ch.md](README-ch.md) for the Chinese overview.
|
|
8
|
+
|
|
9
|
+
## Start here
|
|
10
|
+
|
|
11
|
+
- [Documentation index](docs/README.md): guides, references, integration, compatibility, development and releases.
|
|
12
|
+
- [Beginner guide](docs/guides/local-guide-en.md): move from Markdown to interactive documents, with a complete exercise and an error quick reference.
|
|
13
|
+
- [Local interaction syntax specification](docs/reference/local-interaction-syntax-en.md) · [Feature tours and examples](examples/local/README.md): 48 tag names, tags, in-place parameters and LaTeX plots.
|
|
14
|
+
- [Local mode integration](docs/integration/local-integration-en.md): `compileLocal`, the state runtime, React embedding, URL policy and style scoping.
|
|
15
|
+
- [HTML compatibility](docs/reference/html-compatibility-en.md): P0 HTML and the next release's temporary routing policy for author CSS, JavaScript and extended HTML.
|
|
16
|
+
- [Shareable documents and static export](docs/integration/shareable-export-en.md): single-file interactive HTML, static output, versioned state files, assets, the CLI and the standalone browser API.
|
|
17
|
+
- [Theme protocol](docs/reference/theme-protocol-en.md): document theme selection, custom CSS and light/dark modes.
|
|
18
|
+
- [Author tools](docs/integration/author-tools-en.md): source highlighting, completion, binding navigation, rename, formatting and command-line lint.
|
|
19
|
+
- [React source editor](docs/integration/editor-en.md): controlled editor, props, ref handle, diagnostics, locale, theme and history.
|
|
20
|
+
- [Standalone integration examples](examples/integration/README.md): Node core and React pages you can copy and run outside the repository.
|
|
21
|
+
- [Versions and compatibility](docs/compatibility/compatibility-en.md): 0.x rules, migration, the diagnostics contract and supported platforms.
|
|
22
|
+
- [Component protocol](docs/development/component-protocol-en.md) · [Component development guide](docs/development/component-development-en.md): declarations, behavior contracts and compatibility acceptance for new components.
|
|
23
|
+
- [0.6.1 release notes](docs/releases/release-0.6.1-en.md): KaTeX formula display, bundled fonts and offline math.
|
|
24
|
+
- [0.5.3 release notes](docs/releases/release-0.5.3-en.md): host integration and authoring patches.
|
|
25
|
+
- [0.5.1 release notes](docs/releases/release-0.5.1-en.md): editor views and themes, plus HTML compatibility.
|
|
26
|
+
- [0.5.0 release notes](docs/releases/release-0.5.0-en.md): the editor entry and document rendering fixes.
|
|
27
|
+
- [0.4.1 release notes](docs/releases/release-0.4.1-en.md): visual and interaction fixes, compatible with 0.4.0.
|
|
28
|
+
- [0.4.0 release and migration](docs/releases/release-0.4.0-en.md): what the minor series adds and how to upgrade from `0.3.1` / `local-draft-1`.
|
|
29
|
+
|
|
30
|
+
## Write a document
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
<panel title="Cost estimate">
|
|
34
|
+
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
35
|
+
<toggle bind="annual" label="Annual billing">
|
|
36
|
+
</panel>
|
|
37
|
+
|
|
38
|
+
Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Inputs update the result immediately, and the panel includes a restore-defaults action. A standalone counter is a single line: `<counter label="People">`.
|
|
42
|
+
|
|
43
|
+
`0.4.0` adds `local-draft-2`, named calculations, validation, collections, themes and offline HTML export. The earlier `0.3.1` release uses `local-draft-1`. See [0.4.0 release and migration](docs/releases/release-0.4.0-en.md).
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
Reactive MD requires Node.js 22.12 or newer and ships only ESM entries:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm install reactive-md
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`latest` and `next` both resolve to `0.6.1`:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm install reactive-md
|
|
57
|
+
# or pin the version
|
|
58
|
+
npm install reactive-md@0.6.1
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Read the [0.6.1 release notes](docs/releases/release-0.6.1-en.md) for this release, and the [migration guide](docs/releases/release-0.4.0-en.md) before upgrading from `0.3.1` / `local-draft-1`.
|
|
62
|
+
|
|
63
|
+
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`. Existing renderer and style imports are unchanged in 0.6.1.
|
|
64
|
+
|
|
65
|
+
The core `reactive-md` entry does not depend on React:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { compileLocal, createLocalRuntime } from 'reactive-md';
|
|
69
|
+
|
|
70
|
+
const result = compileLocal('<number bind="n" label="Count" initial="2">');
|
|
71
|
+
if (result.ok) {
|
|
72
|
+
const runtime = createLocalRuntime(result.document);
|
|
73
|
+
try { console.log(runtime.text('Total: {{ n * 100 }}')); }
|
|
74
|
+
finally { runtime.dispose(); }
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
See [Local mode integration](docs/integration/local-integration-en.md) for the full compile and runtime APIs, host URL policy, lifecycle and style overrides.
|
|
79
|
+
|
|
80
|
+
0.x minor releases may contain breaking changes. Before upgrading, read the [changelog](CHANGELOG.md) and [compatibility rules](docs/compatibility/compatibility-en.md), and keep the original `.reactive.md` sources.
|
|
81
|
+
|
|
82
|
+
## Use with React
|
|
83
|
+
|
|
84
|
+
The React entry requires React 19:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
npm install react@19 react-dom@19
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { LocalReactiveDocument } from 'reactive-md/react';
|
|
92
|
+
import 'reactive-md/styles.css';
|
|
93
|
+
|
|
94
|
+
export function Article({ source }: { source: string }) {
|
|
95
|
+
return <LocalReactiveDocument source={source} />;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`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).
|
|
100
|
+
|
|
101
|
+
## Edit source with React
|
|
102
|
+
|
|
103
|
+
The 0.5.x preview adds a reusable source editor at `reactive-md/editor`, with its own stylesheet at `reactive-md/editor/styles.css`. The component is controlled and requires React 19:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { useState } from 'react';
|
|
107
|
+
import { ReactiveMarkdownEditor } from 'reactive-md/editor';
|
|
108
|
+
import 'reactive-md/editor/styles.css';
|
|
109
|
+
|
|
110
|
+
export function Editor() {
|
|
111
|
+
const [source, setSource] = useState('# Notes');
|
|
112
|
+
return <ReactiveMarkdownEditor value={source} onChange={setSource} />;
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
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 the props, ref handle, diagnostics, themes, locales and history.
|
|
117
|
+
|
|
118
|
+
## Share documents
|
|
119
|
+
|
|
120
|
+
Build a self-contained HTML file that readers can open offline, or a script-free static snapshot:
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
npm run build
|
|
124
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter.html
|
|
125
|
+
npx reactive-md build examples/local/counter.reactive.md -o counter-static.html --mode static
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
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.
|
|
129
|
+
|
|
130
|
+
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>`.
|
|
131
|
+
|
|
132
|
+
## Try the demo
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
npm ci
|
|
136
|
+
npm run dev
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
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.
|
|
140
|
+
|
|
141
|
+
## Repository layout
|
|
142
|
+
|
|
143
|
+
```text
|
|
144
|
+
src/ Local syntax compilation, expressions, runtime and React renderer
|
|
145
|
+
examples/ Copyable local interactive examples, independent of the demo app
|
|
146
|
+
docs/ Local syntax specification, integration and release documentation
|
|
147
|
+
tests/ Language and renderer tests
|
|
148
|
+
demo/ Standalone Playground app
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Documentation
|
|
152
|
+
|
|
153
|
+
- [Beginner guide](docs/guides/local-guide-en.md) and [local interaction syntax specification](docs/reference/local-interaction-syntax-en.md).
|
|
154
|
+
- [Local mode integration](docs/integration/local-integration-en.md): core and React API, URL policy, lifecycle, styling and version pinning.
|
|
155
|
+
- [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.
|
|
156
|
+
- [Feature tours and examples](examples/local/README.md) and [standalone integrations](examples/integration/README.md).
|
|
157
|
+
- [React source editor](docs/integration/editor-en.md): controlled editor for `.reactive.md` source, with its own stylesheet.
|
|
158
|
+
- [Versions and compatibility](docs/compatibility/compatibility-en.md): 0.x rules, migration, diagnostics and supported platforms.
|
|
159
|
+
- [0.6.1 release notes](docs/releases/release-0.6.1-en.md): KaTeX formula display, bundled fonts and offline math.
|
|
160
|
+
- [0.5.3 release notes](docs/releases/release-0.5.3-en.md): host integration and authoring patches.
|
|
161
|
+
- [0.5.1 release notes](docs/releases/release-0.5.1-en.md): editor views and themes, plus HTML compatibility.
|
|
162
|
+
- [0.5.0 release notes](docs/releases/release-0.5.0-en.md): the editor entry and document rendering fixes.
|
|
163
|
+
- [0.4.0 release and migration](docs/releases/release-0.4.0-en.md): the upgrade checklist for that minor series.
|
|
164
|
+
- [Component protocol](docs/development/component-protocol-en.md) and [component development guide](docs/development/component-development-en.md): contribution contracts, a proposal template and acceptance cases.
|
|
165
|
+
- [Performance measurements](docs/development/performance-en.md) and [release checklist](docs/development/releasing-en.md).
|
|
166
|
+
|
|
167
|
+
See the [contributing guide](CONTRIBUTING.md) for development and test commands.
|
|
168
|
+
|
|
169
|
+
## Support and status
|
|
170
|
+
|
|
171
|
+
- CI targets Node 22.12 and Node 24 with Playwright Chromium for the full browser gate and Firefox/WebKit for core workflows; 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 and the full Firefox/WebKit interaction suites remain unverified.
|
|
172
|
+
- 0.x minor releases may contain breaking changes. Persist the original `.reactive.md` source, not the runtime AST or in-memory state.
|
|
173
|
+
- `latest` and `next` are both `0.6.1`. Security fixes may ship in minor releases.
|
|
174
|
+
|
|
175
|
+
## Contributing and security
|
|
176
|
+
|
|
177
|
+
- [Contributing guide](CONTRIBUTING.md): environment, check commands and change requirements.
|
|
178
|
+
- [Security policy](SECURITY.md): threat boundary, resource limits, host responsibilities and vulnerability reporting.
|
|
179
|
+
- [Changelog](CHANGELOG.md).
|
|
180
|
+
- [Release checklist](docs/development/releasing-en.md): the verification gate, notices, tarball and the manual release flow for maintainers.
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
[MIT](LICENSE)
|
package/SECURITY-ch.md
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
# 安全策略
|
|
2
|
-
|
|
3
|
-
Reactive MD 渲染作者编写的本地交互文档。文档是不可信输入时,渲染器、表达式和数学求值都按下面的边界处理。宿主仍然负责授权、网络策略和服务端数据。
|
|
4
|
-
|
|
5
|
-
## 支持范围
|
|
6
|
-
|
|
7
|
-
当前维护最新的 0.x 预览版本。安全修复可能随次版本发布,并在[变更记录](CHANGELOG-ch.md)中说明影响和迁移步骤。
|
|
8
|
-
|
|
9
|
-
## 威胁边界
|
|
10
|
-
|
|
11
|
-
以下保证有编译器、运行时和渲染器测试覆盖;未列出的能力不做承诺。
|
|
12
|
-
|
|
13
|
-
### 文档内容
|
|
14
|
-
|
|
15
|
-
- 三个 HTML 能力开关全部关闭时,作者脚本、事件属性和 CSS 保持惰性。P0 HTML 重建为受控节点和 React 元素。见 [HTML 部分兼容与暂时性分流政策](docs/reference/html-compatibility-ch.md)。
|
|
16
|
-
- 开启 `enableCss`、`enableJavaScript` 或 `enableExtendedHtml` 中任意一个,整篇源码会在不带 `allow-same-origin` 的沙箱 iframe 中按原生 HTML 处理。其他开关继续约束作者源码;允许任意 JavaScript 后,脚本可以动态创建元素和样式,源码开关不构成运行时 DOM 权限。网络、表单和导航继续受 CSP 与沙箱限制。
|
|
17
|
-
- 默认 React
|
|
18
|
-
- 表达式使用自己的解析器和 AST 求值器,不使用 `eval`、`new Function`,不支持赋值、方法调用、属性访问、原型路径或导入。表达式只能读取文档声明的参数和内置函数。
|
|
19
|
-
-
|
|
20
|
-
- 表达式、模板、表格和图表不会发起网络请求;图表数据必须写在文档里。
|
|
21
|
-
|
|
22
|
-
### URL 与网络
|
|
23
|
-
|
|
24
|
-
- 图片默认全部拒绝,包括相对路径和协议相对地址,因此加载文档本身不会触发图片请求。
|
|
25
|
-
- 只有宿主传入 `urlPolicy` 且策略返回 `true` 时,图片才会加载。带协议的图片地址仍先检查协议,只允许 `http:` 和 `https:`;相对地址则由策略决定。`javascript:`、危险的 `data:` 等地址即使策略放行也会被拒绝。
|
|
26
|
-
- 链接默认允许相对地址和 `http:`、`https:`、`mailto:`、`tel:`;外部 HTTP 链接以新标签打开并带 `noopener noreferrer`。危险协议始终拒绝。
|
|
27
|
-
- 策略抛出异常时拒绝该地址。获准加载的图片使用 `referrerPolicy="no-referrer"`;同源图片仍可能携带 Cookie,图片白名单应避开业务 API。
|
|
28
|
-
- 受信任的 `imageResolver` 只在图片地址通过协议检查和 `urlPolicy` 后运行,把允许的地址映射为宿主控制的输出;导出文件只使用经过验证的 `data:image/png|jpeg|gif|webp;base64` 值,链接不会进入该回调。
|
|
29
|
-
- `urlPolicy` 是 URL 允许列表,不是服务端授权。宿主仍需配置 CSP、网络出口、图片代理或沙箱 iframe(当作者完全不可信时)。
|
|
30
|
-
|
|
31
|
-
### 资源上限
|
|
32
|
-
|
|
33
|
-
`src/local/limits.ts` 定义共享上限,编译、运行时和可视化共同使用:
|
|
34
|
-
|
|
35
|
-
| 限制 | 值 |
|
|
36
|
-
| --- | --- |
|
|
37
|
-
| 单份文档源码 | 1,000,000 字符 |
|
|
38
|
-
| 解析期间累计创建的语法节点 | 默认 10,000,由宿主按次配置 |
|
|
39
|
-
| 单个字符串值或模板 | 100,000 字符 |
|
|
40
|
-
| 单个数组 | 10,000 项 |
|
|
41
|
-
| 数组内字符串总长度 | 100,000 字符 |
|
|
42
|
-
| 邮箱地址 | 254 字符,线性校验 |
|
|
43
|
-
| 诊断数量 | 100 条 |
|
|
44
|
-
| 单条诊断文本 | 2,000 字符 |
|
|
45
|
-
| 每个绘图组件的曲线数 | 16 |
|
|
46
|
-
| 整篇文档请求的曲线采样点 | 20,000 |
|
|
47
|
-
| 绘图共享计算步数 | 2,000,000 |
|
|
48
|
-
|
|
49
|
-
超限写入会被拒绝,运行时保持上一次合法状态;编译期超限返回诊断。绘图和数学计算还有各自的深度、记号和节点预算。预算用于限制单个文档的工作量,不替代宿主对请求大小、并发和超时的控制。
|
|
50
|
-
|
|
51
|
-
宿主通过 `compileLocal(source, { limits: { maxSyntaxNodes } })` 为单次编译调整语法节点预算,取值必须是正的安全整数。文档内容不能修改该设置。省略时保留 10,000 的默认预算;提高节点预算不会改变源码长度、数组、表达式或绘图的其他上限。计数覆盖解析中创建的全部 `LocalNode`,包含部分最终未保留的中间节点。
|
|
52
|
-
|
|
53
|
-
### 状态与隔离
|
|
54
|
-
|
|
55
|
-
- 参数状态只存在于当前文档实例的内存中。每个 `LocalReactiveDocument` 或 `LocalDocumentView` 实例独立;销毁时会清理订阅、表达式缓存和计时器。
|
|
56
|
-
- `createLocalRuntime` 会校验初值和共享控件的约束;`set` 以文档中登记的控件为准,忽略调用方伪造的节点元数据,并且只有在所有共享控件都接受时才原子提交。
|
|
57
|
-
- `snapshot()` 返回稳定的冻结快照,其中的数组也被冻结;`get()` 和 `evaluate()` 返回数组副本。状态更新通过 `set()` 校验后提交。
|
|
58
|
-
- `disabled` 和 `if` 只是界面展示状态,不是权限控制。业务权限和值校验必须由宿主在提交到服务端时执行。
|
|
59
|
-
|
|
60
|
-
### 可分享 HTML 导出
|
|
61
|
-
|
|
62
|
-
- `reactive-md-state/v1` 只保存公开绑定名和可序列化值,不保存 `@` 内部绑定、revision、节点 ID、AST、UI 状态或计时器。导入前会校验源码摘要、语法、参数集合和每个值;未知或冲突键会拒绝整个文件。
|
|
63
|
-
- 默认 ReactiveMD 交互导出内嵌固定版本的独立运行时,CSP 禁止网络连接、frame、object、base 注入和表单提交。原生 HTML 导出额外允许承载文档的沙箱 `srcdoc` frame,其内部 CSP 控制作者 CSS 与脚本。JSON、源码、标题和 notices 会按 HTML/脚本上下文转义。
|
|
64
|
-
- CLI 只内联位于文档目录或显式资源根内的相对位图。它拒绝远程图片、URL scheme、绝对路径、路径穿越、符号链接逃逸、SVG、伪造格式和超限资源。Demo 导出对话框在包含图片时会禁用 HTML 导出。
|
|
65
|
-
- 静态 HTML 不包含运行时脚本或自动挂载载荷。静态首屏水合目前只在单文件 Chromium/Edge 路径验证,不构成通用水合或沙箱保证。作者完全不可信时应使用 sandboxed iframe。
|
|
66
|
-
- 导出当前参数是宿主/读者的显式动作。生成的状态文件和 HTML 可能包含敏感信息;除非确实要分享当前值,否则应选择作者初值。
|
|
67
|
-
|
|
68
|
-
## 宿主责任
|
|
69
|
-
|
|
70
|
-
- 决定谁可以编写、提交和分享文档;限制不可信作者的请求大小、并发和执行时间。编译 1,000,000 字符的文档仍是真实的 CPU 工作。
|
|
71
|
-
- 为图片和链接配置 `urlPolicy`;维持 CSP、网络出口控制和图片白名单。
|
|
72
|
-
- 在服务端重新校验表单值、权限和业务约束,不信任文档中的 `disabled`、条件显示或客户端状态。
|
|
73
|
-
- 需要持久化时,安全地保存原始 `.reactive.md` 源码;运行时状态和 `LocalDocument` 不应当作持久化格式。
|
|
74
|
-
- 在服务端静态渲染不可信文档之前,评估渲染进程的资源上限;通用 SSR 水合仍未验证,只有单文件静态首屏路径在 Chromium/Edge 有覆盖。水合不应作为安全边界。
|
|
75
|
-
- 第三方依赖漏洞应同时报告给上游项目;本包只负责自身集成代码。
|
|
76
|
-
|
|
77
|
-
## 报告漏洞
|
|
78
|
-
|
|
79
|
-
仓库已启用 GitHub 私密漏洞报告。请通过 [Report a vulnerability](https://github.com/yao1145/ReactiveMD/security/advisories/new) 提交受影响版本、最小复现、预期影响和修复建议。
|
|
80
|
-
|
|
81
|
-
使用私密渠道报告漏洞细节;公开 issue 和 PR 中请移除利用代码、凭据、用户数据及受影响部署的信息。
|
|
1
|
+
# 安全策略
|
|
2
|
+
|
|
3
|
+
Reactive MD 渲染作者编写的本地交互文档。文档是不可信输入时,渲染器、表达式和数学求值都按下面的边界处理。宿主仍然负责授权、网络策略和服务端数据。
|
|
4
|
+
|
|
5
|
+
## 支持范围
|
|
6
|
+
|
|
7
|
+
当前维护最新的 0.x 预览版本。安全修复可能随次版本发布,并在[变更记录](CHANGELOG-ch.md)中说明影响和迁移步骤。
|
|
8
|
+
|
|
9
|
+
## 威胁边界
|
|
10
|
+
|
|
11
|
+
以下保证有编译器、运行时和渲染器测试覆盖;未列出的能力不做承诺。
|
|
12
|
+
|
|
13
|
+
### 文档内容
|
|
14
|
+
|
|
15
|
+
- 三个 HTML 能力开关全部关闭时,作者脚本、事件属性和 CSS 保持惰性。P0 HTML 重建为受控节点和 React 元素。见 [HTML 部分兼容与暂时性分流政策](docs/reference/html-compatibility-ch.md)。
|
|
16
|
+
- 开启 `enableCss`、`enableJavaScript` 或 `enableExtendedHtml` 中任意一个,整篇源码会在不带 `allow-same-origin` 的沙箱 iframe 中按原生 HTML 处理。其他开关继续约束作者源码;允许任意 JavaScript 后,脚本可以动态创建元素和样式,源码开关不构成运行时 DOM 权限。网络、表单和导航继续受 CSP 与沙箱限制。
|
|
17
|
+
- 默认 React 渲染器仅注入按固定选项配置的 KaTeX 排版结果;作者源码与错误消息均作为转义文本处理。原生 HTML 通过解析和过滤后的 iframe `srcdoc` 渲染,与宿主 DOM 分离。
|
|
18
|
+
- 表达式使用自己的解析器和 AST 求值器,不使用 `eval`、`new Function`,不支持赋值、方法调用、属性访问、原型路径或导入。表达式只能读取文档声明的参数和内置函数。
|
|
19
|
+
- KaTeX 将公式排版为 HTML 和用于辅助技术的 MathML。输入、宏展开及作者指定的尺寸受限;作者自定义宏、文件、网络和 HTML 入口关闭。无效或不支持的公式回退为有界的原始文本。绘图求值保留独立的受预算限制解析器。
|
|
20
|
+
- 表达式、模板、表格和图表不会发起网络请求;图表数据必须写在文档里。
|
|
21
|
+
|
|
22
|
+
### URL 与网络
|
|
23
|
+
|
|
24
|
+
- 图片默认全部拒绝,包括相对路径和协议相对地址,因此加载文档本身不会触发图片请求。
|
|
25
|
+
- 只有宿主传入 `urlPolicy` 且策略返回 `true` 时,图片才会加载。带协议的图片地址仍先检查协议,只允许 `http:` 和 `https:`;相对地址则由策略决定。`javascript:`、危险的 `data:` 等地址即使策略放行也会被拒绝。
|
|
26
|
+
- 链接默认允许相对地址和 `http:`、`https:`、`mailto:`、`tel:`;外部 HTTP 链接以新标签打开并带 `noopener noreferrer`。危险协议始终拒绝。
|
|
27
|
+
- 策略抛出异常时拒绝该地址。获准加载的图片使用 `referrerPolicy="no-referrer"`;同源图片仍可能携带 Cookie,图片白名单应避开业务 API。
|
|
28
|
+
- 受信任的 `imageResolver` 只在图片地址通过协议检查和 `urlPolicy` 后运行,把允许的地址映射为宿主控制的输出;导出文件只使用经过验证的 `data:image/png|jpeg|gif|webp;base64` 值,链接不会进入该回调。
|
|
29
|
+
- `urlPolicy` 是 URL 允许列表,不是服务端授权。宿主仍需配置 CSP、网络出口、图片代理或沙箱 iframe(当作者完全不可信时)。
|
|
30
|
+
|
|
31
|
+
### 资源上限
|
|
32
|
+
|
|
33
|
+
`src/local/limits.ts` 定义共享上限,编译、运行时和可视化共同使用:
|
|
34
|
+
|
|
35
|
+
| 限制 | 值 |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| 单份文档源码 | 1,000,000 字符 |
|
|
38
|
+
| 解析期间累计创建的语法节点 | 默认 10,000,由宿主按次配置 |
|
|
39
|
+
| 单个字符串值或模板 | 100,000 字符 |
|
|
40
|
+
| 单个数组 | 10,000 项 |
|
|
41
|
+
| 数组内字符串总长度 | 100,000 字符 |
|
|
42
|
+
| 邮箱地址 | 254 字符,线性校验 |
|
|
43
|
+
| 诊断数量 | 100 条 |
|
|
44
|
+
| 单条诊断文本 | 2,000 字符 |
|
|
45
|
+
| 每个绘图组件的曲线数 | 16 |
|
|
46
|
+
| 整篇文档请求的曲线采样点 | 20,000 |
|
|
47
|
+
| 绘图共享计算步数 | 2,000,000 |
|
|
48
|
+
|
|
49
|
+
超限写入会被拒绝,运行时保持上一次合法状态;编译期超限返回诊断。绘图和数学计算还有各自的深度、记号和节点预算。预算用于限制单个文档的工作量,不替代宿主对请求大小、并发和超时的控制。
|
|
50
|
+
|
|
51
|
+
宿主通过 `compileLocal(source, { limits: { maxSyntaxNodes } })` 为单次编译调整语法节点预算,取值必须是正的安全整数。文档内容不能修改该设置。省略时保留 10,000 的默认预算;提高节点预算不会改变源码长度、数组、表达式或绘图的其他上限。计数覆盖解析中创建的全部 `LocalNode`,包含部分最终未保留的中间节点。
|
|
52
|
+
|
|
53
|
+
### 状态与隔离
|
|
54
|
+
|
|
55
|
+
- 参数状态只存在于当前文档实例的内存中。每个 `LocalReactiveDocument` 或 `LocalDocumentView` 实例独立;销毁时会清理订阅、表达式缓存和计时器。
|
|
56
|
+
- `createLocalRuntime` 会校验初值和共享控件的约束;`set` 以文档中登记的控件为准,忽略调用方伪造的节点元数据,并且只有在所有共享控件都接受时才原子提交。
|
|
57
|
+
- `snapshot()` 返回稳定的冻结快照,其中的数组也被冻结;`get()` 和 `evaluate()` 返回数组副本。状态更新通过 `set()` 校验后提交。
|
|
58
|
+
- `disabled` 和 `if` 只是界面展示状态,不是权限控制。业务权限和值校验必须由宿主在提交到服务端时执行。
|
|
59
|
+
|
|
60
|
+
### 可分享 HTML 导出
|
|
61
|
+
|
|
62
|
+
- `reactive-md-state/v1` 只保存公开绑定名和可序列化值,不保存 `@` 内部绑定、revision、节点 ID、AST、UI 状态或计时器。导入前会校验源码摘要、语法、参数集合和每个值;未知或冲突键会拒绝整个文件。
|
|
63
|
+
- 默认 ReactiveMD 交互导出内嵌固定版本的独立运行时,CSP 禁止网络连接、frame、object、base 注入和表单提交。原生 HTML 导出额外允许承载文档的沙箱 `srcdoc` frame,其内部 CSP 控制作者 CSS 与脚本。JSON、源码、标题和 notices 会按 HTML/脚本上下文转义。
|
|
64
|
+
- CLI 只内联位于文档目录或显式资源根内的相对位图。它拒绝远程图片、URL scheme、绝对路径、路径穿越、符号链接逃逸、SVG、伪造格式和超限资源。Demo 导出对话框在包含图片时会禁用 HTML 导出。
|
|
65
|
+
- 静态 HTML 不包含运行时脚本或自动挂载载荷。静态首屏水合目前只在单文件 Chromium/Edge 路径验证,不构成通用水合或沙箱保证。作者完全不可信时应使用 sandboxed iframe。
|
|
66
|
+
- 导出当前参数是宿主/读者的显式动作。生成的状态文件和 HTML 可能包含敏感信息;除非确实要分享当前值,否则应选择作者初值。
|
|
67
|
+
|
|
68
|
+
## 宿主责任
|
|
69
|
+
|
|
70
|
+
- 决定谁可以编写、提交和分享文档;限制不可信作者的请求大小、并发和执行时间。编译 1,000,000 字符的文档仍是真实的 CPU 工作。
|
|
71
|
+
- 为图片和链接配置 `urlPolicy`;维持 CSP、网络出口控制和图片白名单。
|
|
72
|
+
- 在服务端重新校验表单值、权限和业务约束,不信任文档中的 `disabled`、条件显示或客户端状态。
|
|
73
|
+
- 需要持久化时,安全地保存原始 `.reactive.md` 源码;运行时状态和 `LocalDocument` 不应当作持久化格式。
|
|
74
|
+
- 在服务端静态渲染不可信文档之前,评估渲染进程的资源上限;通用 SSR 水合仍未验证,只有单文件静态首屏路径在 Chromium/Edge 有覆盖。水合不应作为安全边界。
|
|
75
|
+
- 第三方依赖漏洞应同时报告给上游项目;本包只负责自身集成代码。
|
|
76
|
+
|
|
77
|
+
## 报告漏洞
|
|
78
|
+
|
|
79
|
+
仓库已启用 GitHub 私密漏洞报告。请通过 [Report a vulnerability](https://github.com/yao1145/ReactiveMD/security/advisories/new) 提交受影响版本、最小复现、预期影响和修复建议。
|
|
80
|
+
|
|
81
|
+
使用私密渠道报告漏洞细节;公开 issue 和 PR 中请移除利用代码、凭据、用户数据及受影响部署的信息。
|