reactive-md 0.5.3 → 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 +195 -165
- package/CHANGELOG.md +195 -165
- package/CONTRIBUTING-ch.md +67 -62
- package/CONTRIBUTING.md +69 -64
- package/README-ch.md +157 -155
- package/README-en.md +184 -181
- package/README.md +184 -181
- package/SECURITY-ch.md +81 -81
- package/SECURITY.md +81 -81
- package/THIRD_PARTY_NOTICES.md +585 -1
- 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-DJJjKYg9.js → authoring-BEVyth5X.js} +58 -58
- package/dist-library/compiler-Cm3ppMxG.js +46044 -0
- package/dist-library/react-Bh7_oxZp.js +59655 -0
- package/dist-library/reactive-md-authoring.js +2 -2
- package/dist-library/reactive-md-editor.js +13 -0
- 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 +123 -123
- package/dist-library/{runtime-DXtle_6c.js → runtime-DlFYQ4s_.js} +151 -151
- package/dist-library/types/editor/types.d.ts +2 -0
- package/dist-library/types/local/code-block.d.ts +3 -1
- package/dist-library/types/local/code-languages.d.ts +7 -0
- package/dist-library/types/local/compiled-data.d.ts +6 -0
- package/dist-library/types/local/compiler.d.ts +1 -0
- package/dist-library/types/local/diagnostics.d.ts +31 -0
- package/dist-library/types/local/diagram-layout.d.ts +69 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/html-table.d.ts +25 -0
- package/dist-library/types/local/math-display.d.ts +22 -22
- package/dist-library/types/local/math-view.d.ts +6 -7
- package/dist-library/types/local/table-surface.d.ts +10 -0
- package/dist-library/types/local/types.d.ts +2 -0
- package/dist-library/types/local/visuals.d.ts +9 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +331 -51
- package/docs/README.md +84 -0
- package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +121 -109
- package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +121 -109
- package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +159 -159
- package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +159 -159
- package/docs/{component-development-ch.md → development/component-development-ch.md} +210 -210
- package/docs/{component-development-en.md → development/component-development-en.md} +210 -210
- package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +747 -747
- package/docs/{component-protocol-en.md → development/component-protocol-en.md} +747 -747
- package/docs/{performance-ch.md → development/performance-ch.md} +76 -76
- package/docs/{performance-en.md → development/performance-en.md} +76 -76
- package/docs/{releasing-ch.md → development/releasing-ch.md} +108 -108
- package/docs/{releasing-en.md → development/releasing-en.md} +108 -108
- package/docs/guides/local-guide-ch.md +513 -0
- package/docs/guides/local-guide-en.md +513 -0
- package/docs/{author-tools-ch.md → integration/author-tools-ch.md} +57 -57
- package/docs/{author-tools-en.md → integration/author-tools-en.md} +57 -57
- package/docs/{editor-ch.md → integration/editor-ch.md} +7 -6
- package/docs/{editor-en.md → integration/editor-en.md} +7 -6
- package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +33 -15
- package/docs/{local-integration-en.md → integration/local-integration-en.md} +33 -15
- package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +221 -209
- package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +223 -211
- package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +87 -87
- package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +87 -87
- package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +84 -84
- package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +84 -84
- package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +104 -84
- package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +104 -84
- package/docs/{html-compatibility-ch.md → reference/html-compatibility-ch.md} +42 -4
- package/docs/{html-compatibility-en.md → reference/html-compatibility-en.md} +42 -4
- package/docs/{local-components-v2-ch.md → reference/local-components-v2-ch.md} +138 -138
- package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +104 -104
- package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +515 -492
- package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +511 -488
- package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +107 -107
- package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +107 -107
- package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +89 -89
- package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +89 -89
- package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +23 -23
- package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +23 -23
- package/docs/{release-0.5.0-ch.md → releases/release-0.5.0-ch.md} +4 -4
- package/docs/{release-0.5.0-en.md → releases/release-0.5.0-en.md} +4 -4
- package/docs/{release-0.5.1-ch.md → releases/release-0.5.1-ch.md} +4 -4
- package/docs/{release-0.5.1-en.md → releases/release-0.5.1-en.md} +4 -4
- package/docs/{release-0.5.2-ch.md → releases/release-0.5.2-ch.md} +3 -3
- package/docs/{release-0.5.2-en.md → releases/release-0.5.2-en.md} +3 -3
- package/docs/{release-0.5.3-ch.md → releases/release-0.5.3-ch.md} +1 -1
- package/docs/{release-0.5.3-en.md → releases/release-0.5.3-en.md} +1 -1
- package/docs/releases/release-0.6.0-ch.md +57 -0
- package/docs/releases/release-0.6.0-en.md +57 -0
- 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 -45
- 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/html-compat.reactive.md +19 -0
- 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 -145
- package/dist-library/compiler-UyPwGzJZ.js +0 -22109
- package/dist-library/react-fizgU3i8.js +0 -12764
- package/docs/local-guide-ch.md +0 -967
- package/docs/local-guide-en.md +0 -967
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# Author tools
|
|
2
|
-
|
|
3
|
-
[中文](author-tools-ch.md)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```sh
|
|
8
|
-
npm ci
|
|
9
|
-
npm run build
|
|
10
|
-
npm run lint -- examples/local/planning.reactive.md
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Command line
|
|
14
|
-
|
|
15
|
-
The package provides `reactive-md lint`. Pass one or more document paths, or `-` to read stdin:
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
reactive-md lint "my document.reactive.md" other.reactive.md
|
|
19
|
-
reactive-md lint --json --warnings-as-errors document.reactive.md
|
|
20
|
-
reactive-md lint --locale zh document.reactive.md
|
|
21
|
-
cat document.reactive.md | reactive-md lint -
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Text output includes the file, line, column, severity and diagnostic code. JSON output is an array of `{ file, ok, diagnostics }` reports. Diagnostics use the compiler's original UTF-16 source ranges and one-based line/column positions. The command reads documents without changing them.
|
|
25
|
-
|
|
26
|
-
`--locale en|zh` selects diagnostic messages and defaults to English. Codes, severity and locations stay identical across languages. See [Diagnostics and counting rules](diagnostics-counting-en.md) for the compatibility contract and budget units.
|
|
27
|
-
|
|
28
|
-
| Exit code | Meaning |
|
|
29
|
-
| --- | --- |
|
|
30
|
-
| 0 | No errors; warnings are allowed by default |
|
|
31
|
-
| 1 | Compiler errors, or warnings with `--warnings-as-errors` |
|
|
32
|
-
| 2 | Invalid arguments or a file-read failure |
|
|
33
|
-
|
|
34
|
-
## Editor integration
|
|
35
|
-
|
|
36
|
-
The core entry exposes DOM-independent functions:
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
import {
|
|
40
|
-
analyzeLocalSource, completeLocalSource,
|
|
41
|
-
renameLocalBinding, formatLocalSource,
|
|
42
|
-
} from 'reactive-md/authoring';
|
|
43
|
-
|
|
44
|
-
const analysis = analyzeLocalSource(source, compileOptions);
|
|
45
|
-
const suggestions = completeLocalSource(source, cursorOffset, compileOptions);
|
|
46
|
-
const renamed = renameLocalBinding(source, 'people', 'attendees', compileOptions);
|
|
47
|
-
const formatted = formatLocalSource(renamed.source, compileOptions);
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Analysis returns ordered highlight tokens, bindings with declaration/reference ranges, and compiler diagnostics. Completions contain `label`, `kind`, `insertText` and the `range` to replace. Apply edits against the same source version that produced their ranges.
|
|
51
|
-
|
|
52
|
-
Rename updates active binding declarations, expression references and computed plot parameters, preserving literal text and display formulas. Plot parameters use `\mathrm{newName}` after a rename. Invalid names and collisions throw an error. Formatting normalizes spacing inside recognized component tags; Markdown layout, quoted content, formulas, code and fallback regions retain their source. Keep the original source as the editable document.
|
|
53
|
-
|
|
54
|
-
## Playground
|
|
55
|
-
|
|
56
|
-
Run `npm run dev` and choose **Show source**. The source editor provides highlighting, completion, binding locations, rename, formatting, diagnostic navigation and a live preview. Use the completion button or Ctrl+Space, arrow keys and Enter to insert a suggestion, and Escape to close the list. Rename and formatting participate in editor undo/redo.
|
|
1
|
+
# Author tools
|
|
2
|
+
|
|
3
|
+
[中文](author-tools-ch.md)
|
|
4
|
+
|
|
5
|
+
Install `reactive-md@0.6.0` to use the CLI and the React-free `reactive-md/authoring` entry. To work from this repository, build the package first:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm ci
|
|
9
|
+
npm run build
|
|
10
|
+
npm run lint -- examples/local/planning.reactive.md
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Command line
|
|
14
|
+
|
|
15
|
+
The package provides `reactive-md lint`. Pass one or more document paths, or `-` to read stdin:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
reactive-md lint "my document.reactive.md" other.reactive.md
|
|
19
|
+
reactive-md lint --json --warnings-as-errors document.reactive.md
|
|
20
|
+
reactive-md lint --locale zh document.reactive.md
|
|
21
|
+
cat document.reactive.md | reactive-md lint -
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Text output includes the file, line, column, severity and diagnostic code. JSON output is an array of `{ file, ok, diagnostics }` reports. Diagnostics use the compiler's original UTF-16 source ranges and one-based line/column positions. The command reads documents without changing them.
|
|
25
|
+
|
|
26
|
+
`--locale en|zh` selects diagnostic messages and defaults to English. Codes, severity and locations stay identical across languages. See [Diagnostics and counting rules](../reference/diagnostics-counting-en.md) for the compatibility contract and budget units.
|
|
27
|
+
|
|
28
|
+
| Exit code | Meaning |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| 0 | No errors; warnings are allowed by default |
|
|
31
|
+
| 1 | Compiler errors, or warnings with `--warnings-as-errors` |
|
|
32
|
+
| 2 | Invalid arguments or a file-read failure |
|
|
33
|
+
|
|
34
|
+
## Editor integration
|
|
35
|
+
|
|
36
|
+
The core entry exposes DOM-independent functions:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import {
|
|
40
|
+
analyzeLocalSource, completeLocalSource,
|
|
41
|
+
renameLocalBinding, formatLocalSource,
|
|
42
|
+
} from 'reactive-md/authoring';
|
|
43
|
+
|
|
44
|
+
const analysis = analyzeLocalSource(source, compileOptions);
|
|
45
|
+
const suggestions = completeLocalSource(source, cursorOffset, compileOptions);
|
|
46
|
+
const renamed = renameLocalBinding(source, 'people', 'attendees', compileOptions);
|
|
47
|
+
const formatted = formatLocalSource(renamed.source, compileOptions);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Analysis returns ordered highlight tokens, bindings with declaration/reference ranges, and compiler diagnostics. Completions contain `label`, `kind`, `insertText` and the `range` to replace. Apply edits against the same source version that produced their ranges.
|
|
51
|
+
|
|
52
|
+
Rename updates active binding declarations, expression references and computed plot parameters, preserving literal text and display formulas. Plot parameters use `\mathrm{newName}` after a rename. Invalid names and collisions throw an error. Formatting normalizes spacing inside recognized component tags; Markdown layout, quoted content, formulas, code and fallback regions retain their source. Keep the original source as the editable document.
|
|
53
|
+
|
|
54
|
+
## Playground
|
|
55
|
+
|
|
56
|
+
Run `npm run dev` and choose **Show source**. The source editor provides highlighting, completion, binding locations, rename, formatting, diagnostic navigation and a live preview. Use the completion button or Ctrl+Space, arrow keys and Enter to insert a suggestion, and Escape to close the list. Rename and formatting participate in editor undo/redo.
|
|
57
57
|
|
|
58
58
|
## Host editor configuration
|
|
59
59
|
|
|
60
60
|
The `reactive-md/authoring` entry also exports `LOCAL_COMPONENTS`, `getLocalComponent`, `getNativeComponentCatalog`, `renderNativeSnippet`, `insertTemplate` and their types. It loads without React or CSS. Pass the preview's `LocalCompileOptions` as the last argument to analysis, completion, rename and formatting; omitted options keep the existing defaults. This includes host schemas, HTML mode, resource limits and `markdownBreaks`.
|
|
61
61
|
|
|
62
|
-
For full entry and stylesheet details, see the [0.5.3 release notes](release-0.5.3-en.md).
|
|
62
|
+
For full entry and stylesheet details, see the [0.5.3 release notes](../releases/release-0.5.3-en.md).
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
编辑器有独立样式表 `reactive-md/editor/styles.css`,与 `reactive-md/styles.css` 分开。只编辑源码的页面不会加载文档渲染样式。
|
|
6
6
|
|
|
7
|
-
编辑器属于 `0.
|
|
7
|
+
编辑器属于 `0.6.0`,同时提供于 `latest` 与 `next` 渠道。现有 `reactive-md`、`reactive-md/react` 和 `reactive-md/styles.css` 导入保持不变。
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install reactive-md
|
|
12
|
+
npm install reactive-md
|
|
13
13
|
npm install react@19 react-dom@19
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
需要固定版本时使用 `npm install reactive-md@0.6.0`。包只提供 ESM,工具和服务端渲染需要 Node.js 22.12 或更新版本。
|
|
17
17
|
|
|
18
18
|
## 最小受控编辑器
|
|
19
19
|
|
|
@@ -82,6 +82,7 @@ export function SourceEditor() {
|
|
|
82
82
|
| --- | --- |
|
|
83
83
|
| `focus(selection?)` | 聚焦 textarea,可同时应用选区。 |
|
|
84
84
|
| `selectRange(range)` | 选中一段源码。区间与编译诊断一样使用 UTF-16 半开区间偏移。 |
|
|
85
|
+
| `insertText(text)` | 用文本替换当前选区,记录为一次可撤销编辑,并将光标放到插入内容之后。只读或禁用时不执行。 |
|
|
85
86
|
| `getSelection()` | 返回当前选区。 |
|
|
86
87
|
| `getTextarea()` | 返回底层 textarea;挂载前为 `null`。 |
|
|
87
88
|
| `undo()` / `redo()` | 在该实例的历史中前后移动,并通过 `onChange` 发出结果值。到达历史两端或 `readOnly`、`disabled` 时不执行操作。 |
|
|
@@ -218,7 +219,7 @@ const result = compileLocal(source);
|
|
|
218
219
|
- 持久化:保存源码。编辑器不自动保存、不写入本地存储,也不把源码发送到任何地方。
|
|
219
220
|
- 导出:通过 `onExport` 把工具栏操作接到 HTML 导出、下载对话框或文件服务。编辑器不生成可分享的 HTML 文件。
|
|
220
221
|
|
|
221
|
-
编译调度和防抖同样属于宿主。见[本地模式集成](local-integration-ch.md)与[可分享文档与静态导出](shareable-export-ch.md)。包含编辑器、预览和文档切换的完整示例见 [react-editor.tsx](
|
|
222
|
+
编译调度和防抖同样属于宿主。见[本地模式集成](local-integration-ch.md)与[可分享文档与静态导出](shareable-export-ch.md)。包含编辑器、预览和文档切换的完整示例见 [react-editor.tsx](../../examples/integration/react-editor.tsx)。
|
|
222
223
|
|
|
223
224
|
## 服务端渲染
|
|
224
225
|
|
|
@@ -232,6 +233,6 @@ const result = compileLocal(source);
|
|
|
232
233
|
|
|
233
234
|
## 兼容性
|
|
234
235
|
|
|
235
|
-
`0.5.0` 新增编辑器入口,`local-draft-2`、`component-protocol-1` 和 `reactive-md-theme-1` 保持不变。只渲染文档的项目升级时无需修改导入或源码。编辑器是新增入口,没有旧 API 需要迁移。见[0.5.0 发布说明](release-0.5.0-ch.md)与[版本与兼容性](compatibility-ch.md)。
|
|
236
|
+
`0.5.0` 新增编辑器入口,`local-draft-2`、`component-protocol-1` 和 `reactive-md-theme-1` 保持不变。只渲染文档的项目升级时无需修改导入或源码。编辑器是新增入口,没有旧 API 需要迁移。见[0.5.0 发布说明](../releases/release-0.5.0-ch.md)与[版本与兼容性](../compatibility/compatibility-ch.md)。
|
|
236
237
|
|
|
237
|
-
|
|
238
|
+
0.5.3 新增接受编译配置的作者工具及显式屏幕、打印样式入口,见 [0.5.3 宿主集成](../releases/release-0.5.3-ch.md)。0.6.0 为 ref 句柄新增 `insertText`,见 [0.6.0 发布说明](../releases/release-0.6.0-ch.md)。
|
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
The editor has its own stylesheet at `reactive-md/editor/styles.css`. It is separate from `reactive-md/styles.css`, so a page that only edits source does not load document rendering styles.
|
|
6
6
|
|
|
7
|
-
The editor is part of the `0.
|
|
7
|
+
The editor is part of the `0.6.0` release, available on both `latest` and `next`. Existing `reactive-md`, `reactive-md/react` and `reactive-md/styles.css` imports are unchanged.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install reactive-md
|
|
12
|
+
npm install reactive-md
|
|
13
13
|
npm install react@19 react-dom@19
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Pin the
|
|
16
|
+
Pin the version with `npm install reactive-md@0.6.0`. The package ships ESM only and needs Node.js 22.12 or newer for tooling and server rendering.
|
|
17
17
|
|
|
18
18
|
## Minimal controlled editor
|
|
19
19
|
|
|
@@ -82,6 +82,7 @@ export function SourceEditor() {
|
|
|
82
82
|
| --- | --- |
|
|
83
83
|
| `focus(selection?)` | Focuses the textarea. Applies the optional selection. |
|
|
84
84
|
| `selectRange(range)` | Selects a source range. Ranges use the same UTF-16 half-open offsets as compile diagnostics. |
|
|
85
|
+
| `insertText(text)` | Replaces the current selection with text as one undoable edit, then places the caret after it. Read-only and disabled editors ignore the call. |
|
|
85
86
|
| `getSelection()` | Returns the current selection. |
|
|
86
87
|
| `getTextarea()` | Returns the underlying textarea, or `null` before mount. |
|
|
87
88
|
| `undo()` / `redo()` | Moves through this instance's history and emits the resulting value through `onChange`. Both are no-ops at the ends of the history and while `readOnly` or `disabled` is set. |
|
|
@@ -218,7 +219,7 @@ The editor edits source. The host handles the rest:
|
|
|
218
219
|
- Persistence: store the source. The editor does not auto-save, write local storage or send the source anywhere.
|
|
219
220
|
- Export: pass `onExport` to connect the toolbar action to your HTML export, download dialog or file service. The editor does not build a shareable HTML file.
|
|
220
221
|
|
|
221
|
-
Compilation scheduling and debouncing also stay in the host. See [Local mode integration](local-integration-en.md) and [Shareable documents and static export](shareable-export-en.md). A complete editor, preview and document-switching example is in [react-editor.tsx](
|
|
222
|
+
Compilation scheduling and debouncing also stay in the host. See [Local mode integration](local-integration-en.md) and [Shareable documents and static export](shareable-export-en.md). A complete editor, preview and document-switching example is in [react-editor.tsx](../../examples/integration/react-editor.tsx).
|
|
222
223
|
|
|
223
224
|
## Server rendering
|
|
224
225
|
|
|
@@ -232,6 +233,6 @@ If the same page also renders a document preview, import `reactive-md/styles.css
|
|
|
232
233
|
|
|
233
234
|
## Compatibility
|
|
234
235
|
|
|
235
|
-
`0.5.0` adds the editor entry and keeps `local-draft-2`, `component-protocol-1` and `reactive-md-theme-1`. Projects that only render documents can upgrade without changing imports or source. The editor is new, so it has no older API to migrate from. See the [0.5.0 release notes](release-0.5.0-en.md) and [Versions and compatibility](compatibility-en.md).
|
|
236
|
+
`0.5.0` adds the editor entry and keeps `local-draft-2`, `component-protocol-1` and `reactive-md-theme-1`. Projects that only render documents can upgrade without changing imports or source. The editor is new, so it has no older API to migrate from. See the [0.5.0 release notes](../releases/release-0.5.0-en.md) and [Versions and compatibility](../compatibility/compatibility-en.md).
|
|
236
237
|
|
|
237
|
-
|
|
238
|
+
0.5.3 adds compile-option-aware authoring and explicit screen/print styles. See [0.5.3 host integration](../releases/release-0.5.3-en.md). 0.6.0 adds `insertText` to the ref handle; see the [0.6.0 release notes](../releases/release-0.6.0-en.md).
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# 本地交互文档集成
|
|
2
2
|
|
|
3
|
-
本地交互模式使用 HTML 风格标签、就地参数和 `{{ 表达式 }}`。作者规则见 [新用户入门指南](local-guide-ch.md) 和 [语法规范](local-interaction-syntax-ch.md),完整文档见[示例索引](
|
|
3
|
+
本地交互模式使用 HTML 风格标签、就地参数和 `{{ 表达式 }}`。作者规则见 [新用户入门指南](../guides/local-guide-ch.md) 和 [语法规范](../reference/local-interaction-syntax-ch.md),完整文档见[示例索引](../../examples/local/README.md)。宿主通过带 `Local` 的 API 明确选择此模式。可选修订指令、升级检查与 `migrateLocalSource` 见[源码修订与迁移](../compatibility/source-versioning-ch.md),升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
|
|
4
4
|
|
|
5
5
|
## 运行环境与入口
|
|
6
6
|
|
|
7
|
-
下个发行版的 P0 HTML 和三个宿主能力开关见 [HTML 部分兼容](html-compatibility-ch.md)。本版采用暂时性分流政策:任意开启作者 CSS、JavaScript 或扩展 HTML,整篇文档即按原生 HTML 渲染,停止解析 Markdown 和 ReactiveMD。
|
|
7
|
+
下个发行版的 P0 HTML 和三个宿主能力开关见 [HTML 部分兼容](../reference/html-compatibility-ch.md)。本版采用暂时性分流政策:任意开启作者 CSS、JavaScript 或扩展 HTML,整篇文档即按原生 HTML 渲染,停止解析 Markdown 和 ReactiveMD。
|
|
8
8
|
|
|
9
9
|
| 入口 | 内容 | 依赖 |
|
|
10
10
|
| --- | --- | --- |
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
| `reactive-md/react` | `LocalReactiveDocument`、`LocalDocumentView` | React 19 |
|
|
13
13
|
| `reactive-md/styles.css` | 组件、主题和文档样式 | 由宿主显式引入 |
|
|
14
14
|
|
|
15
|
-
包只提供 ESM。Node.js 22.12+ 可用于开发和 Node 端编译、运行。本地浏览器检查使用 Edge;静态 SSR 由 packed 检查覆盖;完整矩阵见[版本与兼容性](compatibility-ch.md)。可复制的项目见[独立接入示例](
|
|
15
|
+
包只提供 ESM。Node.js 22.12+ 可用于开发和 Node 端编译、运行。本地浏览器检查使用 Edge;静态 SSR 由 packed 检查覆盖;完整矩阵见[版本与兼容性](../compatibility/compatibility-ch.md)。可复制的项目见[独立接入示例](../../examples/integration/README.md)。单文件 HTML、状态文件与独立浏览器运行时见[可分享文档与静态导出](shareable-export-ch.md)。
|
|
16
16
|
|
|
17
17
|
## React
|
|
18
18
|
|
|
@@ -119,6 +119,24 @@ const result = compileLocal(source, options);
|
|
|
119
119
|
|
|
120
120
|
需要在 React 中使用自定义预算时,先调用 `compileLocal`,再把编译文档和运行时交给 `LocalDocumentView`。`LocalReactiveDocument` 和 Playground 的编译线程使用默认预算。提高节点预算后,宿主应结合实际文档测量内存和预览渲染耗时。
|
|
121
121
|
|
|
122
|
+
#### Next.js Server Components
|
|
123
|
+
|
|
124
|
+
`compileLocal` 的返回值在每一层都使用普通数据,包括 `document.dependencies`、节点 `attrs`、绑定及诊断。记录对象的原型为 `Object.prototype`,数组为 `Array.prototype`;内部字典仍可使用空原型。已有的冻结元数据和 `undefined` 字段会保留。
|
|
125
|
+
|
|
126
|
+
在服务端编译并检查 `result.ok` 后,可以直接把 `result.document` 作为属性交给 Client Component,无需 JSON 往返转换。这满足 React 对[可序列化属性中普通对象的要求](https://react.dev/reference/rsc/use-client#serializable-types-returned-by-server-components)。客户端组件负责创建、销毁 `createLocalRuntime(document)`,并把运行时交给 `LocalDocumentView`。运行时实例及宿主回调留在客户端;普通数据保证适用于编译产物。
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
// Server Component;ClientDocument 是宿主的 'use client' 包装组件。
|
|
130
|
+
import { compileLocal } from 'reactive-md';
|
|
131
|
+
import ClientDocument from './ClientDocument';
|
|
132
|
+
|
|
133
|
+
export default function Page() {
|
|
134
|
+
const result = compileLocal('<counter bind="n" label="计数" initial="2">');
|
|
135
|
+
if (!result.ok) throw new Error('编译失败');
|
|
136
|
+
return <ClientDocument document={result.document} />;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
122
140
|
### 宿主组件
|
|
123
141
|
|
|
124
142
|
宿主可以为单次编译登记叶子标签,不改变 `local-draft-2` 语法修订:
|
|
@@ -161,17 +179,17 @@ const migrated = migrateLocalSource(source, { fromVersion: 'local-draft-1' });
|
|
|
161
179
|
|
|
162
180
|
`LocalUpgradeOptions` 提供 `fromVersion` 和 `allowSemanticChanges`。无版本声明的历史文档需要 `fromVersion: 'local-draft-1'`。显式 `fromVersion` 与声明不一致时被拒绝。迁移源只接受 `local-draft-1` 和 `local-draft-2`。
|
|
163
181
|
|
|
164
|
-
迁移只改元数据指令,保留正文原始字节、BOM 和 CRLF,并且幂等。生成结果前会阻止保留绑定、新增可识别标签、编译错误和文本控件长度语义变化。完整检查与 CLI 见[源码修订与迁移](source-versioning-ch.md)。
|
|
182
|
+
迁移只改元数据指令,保留正文原始字节、BOM 和 CRLF,并且幂等。生成结果前会阻止保留绑定、新增可识别标签、编译错误和文本控件长度语义变化。完整检查与 CLI 见[源码修订与迁移](../compatibility/source-versioning-ch.md)。
|
|
165
183
|
|
|
166
184
|
### `createLocalRuntime(document: LocalDocument)`
|
|
167
185
|
|
|
168
|
-
只读命名值在可选的 `document.computations` 记录中用 `LocalComputation` 描述。`bindings` 和 `initialState` 继续只包含可写控件;`snapshot().state` 还包含该修订成功求值的计算结果。需要保留表达式错误语义时用 `evaluate(name)` 读取,失败值不会出现在快照里。见[计算与错误规则](computations-formatting-ch.md)。
|
|
186
|
+
只读命名值在可选的 `document.computations` 记录中用 `LocalComputation` 描述。`bindings` 和 `initialState` 继续只包含可写控件;`snapshot().state` 还包含该修订成功求值的计算结果。需要保留表达式错误语义时用 `evaluate(name)` 读取,失败值不会出现在快照里。见[计算与错误规则](../reference/computations-formatting-ch.md)。
|
|
169
187
|
|
|
170
188
|
为已编译文档创建独立的内存运行时。`document` 不是本地模式文档、初值超出预算或结构无效时会抛出错误。每个实例拥有独立状态;运行时本身不会保存或发送状态。
|
|
171
189
|
|
|
172
190
|
### `LocalRuntime`
|
|
173
191
|
|
|
174
|
-
`validate(): Diagnostic[]` 读取当前修订的跨字段失败提示,保留字段可编辑性,并返回缓存诊断的副本。`document.validations?: LocalValidation[]` 保存可序列化规则。数字集合为 `LocalValue` 增加 `number[]`、为 `LocalValueKind` 增加 `number-array`,原有可写选择控件继续使用字符串数组。见[条件、校验与本地集合](constraints-collections-ch.md)。
|
|
192
|
+
`validate(): Diagnostic[]` 读取当前修订的跨字段失败提示,保留字段可编辑性,并返回缓存诊断的副本。`document.validations?: LocalValidation[]` 保存可序列化规则。数字集合为 `LocalValue` 增加 `number[]`、为 `LocalValueKind` 增加 `number-array`,原有可写选择控件继续使用字符串数组。见[条件、校验与本地集合](../reference/constraints-collections-ch.md)。
|
|
175
193
|
|
|
176
194
|
| 成员 | 参数 | 返回 | 行为 |
|
|
177
195
|
| --- | --- | --- | --- |
|
|
@@ -265,7 +283,7 @@ const { retained, dropped, diagnostics } = applyLocalStateRetention(runtime, pla
|
|
|
265
283
|
|
|
266
284
|
### 在 Worker 中后台编译
|
|
267
285
|
|
|
268
|
-
Worker 由宿主提供:用你的打包工具创建 worker 入口,并保留 `compileLocal` 作为回退。可复制的浏览器示例见[独立接入示例](
|
|
286
|
+
Worker 由宿主提供:用你的打包工具创建 worker 入口,并保留 `compileLocal` 作为回退。可复制的浏览器示例见[独立接入示例](../../examples/integration/README.md)。
|
|
269
287
|
|
|
270
288
|
```ts
|
|
271
289
|
// compile.worker.ts
|
|
@@ -311,7 +329,7 @@ scheduler.schedule(source);
|
|
|
311
329
|
|
|
312
330
|
## 诊断
|
|
313
331
|
|
|
314
|
-
`Diagnostic` 的字段与稳定级别见[版本与兼容性](compatibility-ch.md)中的诊断契约。要点:`line`、`column` 和 `range` 用于程序定位;`code` 可用于当前版本的粗分类,但 0.x 不承诺跨版本稳定;`message` 是默认英文显示文本,不要解析。渲染器和 CLI 可通过共享诊断目录显示中文,回调仍收到结构化字段。
|
|
332
|
+
`Diagnostic` 的字段与稳定级别见[版本与兼容性](../compatibility/compatibility-ch.md)中的诊断契约。要点:`line`、`column` 和 `range` 用于程序定位;`code` 可用于当前版本的粗分类,但 0.x 不承诺跨版本稳定;`message` 是默认英文显示文本,不要解析。渲染器和 CLI 可通过共享诊断目录显示中文,回调仍收到结构化字段。
|
|
315
333
|
|
|
316
334
|
`onDiagnostics` 会在编译结果变化时收到编译诊断,也会收到控件写入被拒绝时的运行时诊断。编译错误文档不激活交互;运行时局部错误只替换对应内容。
|
|
317
335
|
|
|
@@ -359,7 +377,7 @@ const urlPolicy: LocalUrlPolicy = (raw, kind) => {
|
|
|
359
377
|
|
|
360
378
|
- 样式选择器以 `.md-document`、`.local-document` 和 `.md-*`、`.local-*` 类名为主。组件渲染的文档根节点是 `.md-document.local-document`。
|
|
361
379
|
- 主题变量声明在 `.md-document` 和 `.reactive-md-theme` 上,包括 `--ink`、`--surface`、`--line`、`--blue`、`--teal`、`--danger`、`--radius-*` 和字体变量。在库样式之后用 `.my-article .md-document { --blue: #245c98; }` 等规则覆盖;文档根节点自带默认值,只在祖先容器上设置变量不会覆盖根节点上的同名值。
|
|
362
|
-
- 文档开头可写 `<theme name="default">`,省略时选择 `default`。自定义主题通过 `themes` 登记;完整要求见[主题协议](theme-protocol-ch.md)。
|
|
380
|
+
- 文档开头可写 `<theme name="default">`,省略时选择 `default`。自定义主题通过 `themes` 登记;完整要求见[主题协议](../reference/theme-protocol-ch.md)。
|
|
363
381
|
- `colorScheme` 可强制深浅模式;默认 `auto` 跟随最近祖先的 `data-color-scheme` 或兼容的 `data-theme`,再跟随系统偏好。文档根节点输出独立的 `data-rmd-theme` 和已解析的 `data-color-scheme`。
|
|
364
382
|
- 文档默认 `max-width: 720px` 且水平居中。需要铺满宿主容器时,在自己的作用域内覆盖 `.md-document` 的宽度和边距。
|
|
365
383
|
- 主题优先覆盖公共变量;组件外层 `.md-*`、`.local-*` 类和语义状态属性可用于主题样式。内部节点排列不属于扩展接口;兼容要求见主题协议。
|
|
@@ -371,22 +389,22 @@ const urlPolicy: LocalUrlPolicy = (raw, kind) => {
|
|
|
371
389
|
|
|
372
390
|
单个文档源码最多 1,000,000 字符。诊断最多 100 条,单条消息最多 2,000 字符。
|
|
373
391
|
|
|
374
|
-
每个绘图组件最多 16 条曲线,整篇文档最多请求 20,000 个曲线采样点,包括隐藏区域。绘图计算还受 2,000,000 步的共享执行预算限制。每份文档最多 100 条校验规则。`data-table` 的生成行、列数和文本有单表及整篇文档预算,见[条件、校验与本地集合](constraints-collections-ch.md)。超限文档会收到诊断;表达式和数学渲染也有各自的深度与记号预算。
|
|
392
|
+
每个绘图组件最多 16 条曲线,整篇文档最多请求 20,000 个曲线采样点,包括隐藏区域。绘图计算还受 2,000,000 步的共享执行预算限制。每份文档最多 100 条校验规则。`data-table` 的生成行、列数和文本有单表及整篇文档预算,见[条件、校验与本地集合](../reference/constraints-collections-ch.md)。超限文档会收到诊断;表达式和数学渲染也有各自的深度与记号预算。
|
|
375
393
|
|
|
376
|
-
这些上限限制单个文档的工作量,不替代宿主对请求大小、并发和执行时间的控制。完整威胁边界见[安全策略](
|
|
394
|
+
这些上限限制单个文档的工作量,不替代宿主对请求大小、并发和执行时间的控制。完整威胁边界见[安全策略](../../SECURITY-ch.md)。
|
|
377
395
|
|
|
378
396
|
## 版本固定与升级
|
|
379
397
|
|
|
380
398
|
- 在 0.x 阶段固定准确的包版本,并提交 lockfile。`^0.3.0` 只允许补丁版本,但生产接入仍建议写死版本或固定 tarball 的 SHA256。
|
|
381
399
|
- 用一个包版本同时提供核心和 React 入口;不要混用不同版本的 `reactive-md` 和 `reactive-md/react`。
|
|
382
|
-
- 在应用配置或文档元数据中记录 `LOCAL_SYNTAX_VERSION`,与持久化的 `.reactive.md` 源码一起保存。语法修订变化时按[版本与兼容性](compatibility-ch.md)迁移。
|
|
400
|
+
- 在应用配置或文档元数据中记录 `LOCAL_SYNTAX_VERSION`,与持久化的 `.reactive.md` 源码一起保存。语法修订变化时按[版本与兼容性](../compatibility/compatibility-ch.md)迁移。
|
|
383
401
|
- 升级后重新编译自有文档,检查 `result.diagnostics`、渲染结果和浏览器交互。不要依赖诊断 `message` 的文本。
|
|
384
402
|
|
|
385
403
|
## 不提供的功能
|
|
386
404
|
|
|
387
|
-
默认 ReactiveMD 路径支持 P0 HTML。作者 CSS、JavaScript 和扩展 HTML 的宿主开关使用独立的原生 HTML 路径,见 [HTML 部分兼容](html-compatibility-ch.md)。本地模式仍不提供自动状态持久化或不受限的网络访问、插件或自定义组件注册、外部数据接口、Vue 支持、React 18 支持或 CommonJS 入口。状态导出与导入是宿主的显式调用。`LocalReactiveDocument` 在源码变化时从初值开始;需要保留参数时使用保留工具,或自行管理运行时和文档。
|
|
405
|
+
默认 ReactiveMD 路径支持 P0 HTML。作者 CSS、JavaScript 和扩展 HTML 的宿主开关使用独立的原生 HTML 路径,见 [HTML 部分兼容](../reference/html-compatibility-ch.md)。本地模式仍不提供自动状态持久化或不受限的网络访问、插件或自定义组件注册、外部数据接口、Vue 支持、React 18 支持或 CommonJS 入口。状态导出与导入是宿主的显式调用。`LocalReactiveDocument` 在源码变化时从初值开始;需要保留参数时使用保留工具,或自行管理运行时和文档。
|
|
388
406
|
|
|
389
407
|
|
|
390
|
-
新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。`0.
|
|
408
|
+
新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](../reference/local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。`0.6.0` 同时提供于 `latest` 与 `next` 渠道。
|
|
391
409
|
|
|
392
|
-
|
|
410
|
+
0.5.3 新增接受编译配置的作者工具及显式屏幕、打印样式入口,见 [0.5.3 宿主集成](../releases/release-0.5.3-ch.md)。0.6.0 让 `compileLocal` 返回可跨 React Server Components 边界的普通数据,见 [0.6.0 发布说明](../releases/release-0.6.0-ch.md)。
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Local mode integration
|
|
2
2
|
|
|
3
|
-
Local interaction mode uses HTML-style tags, in-place parameters and `{{ expressions }}`. Author rules are in the [beginner guide](local-guide-en.md) and the [syntax specification](local-interaction-syntax-en.md); complete documents are in the [example index](
|
|
3
|
+
Local interaction mode uses HTML-style tags, in-place parameters and `{{ expressions }}`. Author rules are in the [beginner guide](../guides/local-guide-en.md) and the [syntax specification](../reference/local-interaction-syntax-en.md); complete documents are in the [example index](../../examples/local/README.md). Hosts explicitly select this mode through the `Local` APIs. See [Source revisions and migration](../compatibility/source-versioning-en.md) for the optional revision directive, upgrade checks and `migrateLocalSource`, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the upgrade checklist.
|
|
4
4
|
|
|
5
5
|
## Runtime and entries
|
|
6
6
|
|
|
7
|
-
See [HTML compatibility](html-compatibility-en.md) for the next release's P0 HTML support and host capability options. The temporary routing policy sends the entire document to native HTML when author CSS, JavaScript or extended HTML is enabled. Markdown and ReactiveMD interpretation stop in that path.
|
|
7
|
+
See [HTML compatibility](../reference/html-compatibility-en.md) for the next release's P0 HTML support and host capability options. The temporary routing policy sends the entire document to native HTML when author CSS, JavaScript or extended HTML is enabled. Markdown and ReactiveMD interpretation stop in that path.
|
|
8
8
|
|
|
9
9
|
| Entry | Contents | Dependency |
|
|
10
10
|
| --- | --- | --- |
|
|
@@ -12,7 +12,7 @@ See [HTML compatibility](html-compatibility-en.md) for the next release's P0 HTM
|
|
|
12
12
|
| `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView` | React 19 |
|
|
13
13
|
| `reactive-md/styles.css` | Component, theme and document styles | Explicitly imported by the host |
|
|
14
14
|
|
|
15
|
-
The package ships ESM only. Node.js 22.12+ can be used for development and Node-side compilation and runtime. Local browser checks use Edge; static SSR is covered by the packed check; see [Versions and compatibility](compatibility-en.md) for the full matrix. Copyable projects are in [Standalone integration examples](
|
|
15
|
+
The package ships ESM only. Node.js 22.12+ can be used for development and Node-side compilation and runtime. Local browser checks use Edge; static SSR is covered by the packed check; see [Versions and compatibility](../compatibility/compatibility-en.md) for the full matrix. Copyable projects are in [Standalone integration examples](../../examples/integration/README.md). For single-file HTML, state files and the standalone browser runtime, see [Shareable documents and static export](shareable-export-en.md).
|
|
16
16
|
|
|
17
17
|
## React
|
|
18
18
|
|
|
@@ -119,6 +119,24 @@ The budget counts `LocalNode` instances created cumulatively during parsing, inc
|
|
|
119
119
|
|
|
120
120
|
To use a custom budget in React, call `compileLocal` first and pass the compiled document and runtime to `LocalDocumentView`. `LocalReactiveDocument` and the Playground compilation thread use the default budget. After raising the node budget, hosts should measure memory and preview rendering time with their actual documents.
|
|
121
121
|
|
|
122
|
+
#### Next.js Server Components
|
|
123
|
+
|
|
124
|
+
`compileLocal` returns plain data at every depth, including `document.dependencies`, node `attrs`, bindings and diagnostics. Records use `Object.prototype`; arrays use `Array.prototype`. Internal dictionaries may still use null prototypes. Existing frozen metadata and `undefined` fields are preserved.
|
|
125
|
+
|
|
126
|
+
Compile on the server, check `result.ok`, then pass `result.document` directly to a Client Component as a prop. A JSON round trip is unnecessary. This meets React's [plain-object requirement for serializable props](https://react.dev/reference/rsc/use-client#serializable-types-returned-by-server-components). In the Client Component, create and dispose `createLocalRuntime(document)` and render `LocalDocumentView` with that runtime. Runtime instances and host callbacks stay on the client; the plain-data guarantee applies to compiler output.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
// Server Component; ClientDocument is the host's 'use client' wrapper.
|
|
130
|
+
import { compileLocal } from 'reactive-md';
|
|
131
|
+
import ClientDocument from './ClientDocument';
|
|
132
|
+
|
|
133
|
+
export default function Page() {
|
|
134
|
+
const result = compileLocal('<counter bind="n" label="Count" initial="2">');
|
|
135
|
+
if (!result.ok) throw new Error('Compilation failed');
|
|
136
|
+
return <ClientDocument document={result.document} />;
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
122
140
|
### Host components
|
|
123
141
|
|
|
124
142
|
A host can register leaf tags for one compilation without changing the `local-draft-2` syntax revision:
|
|
@@ -161,17 +179,17 @@ const migrated = migrateLocalSource(source, { fromVersion: 'local-draft-1' });
|
|
|
161
179
|
|
|
162
180
|
`LocalUpgradeOptions` supplies `fromVersion` and `allowSemanticChanges`. An unversioned historical document needs `fromVersion: 'local-draft-1'`. An explicit `fromVersion` that disagrees with the declaration is rejected. Only `local-draft-1` and `local-draft-2` are accepted migration sources.
|
|
163
181
|
|
|
164
|
-
Migration changes only the metadata directive, preserves body bytes, BOM and CRLF, and is idempotent. It blocks reserved bindings, newly recognized tags, compile errors and text-control length changes before producing output. See [Source revisions and migration](source-versioning-en.md) for the exact checks and the CLI.
|
|
182
|
+
Migration changes only the metadata directive, preserves body bytes, BOM and CRLF, and is idempotent. It blocks reserved bindings, newly recognized tags, compile errors and text-control length changes before producing output. See [Source revisions and migration](../compatibility/source-versioning-en.md) for the exact checks and the CLI.
|
|
165
183
|
|
|
166
184
|
### `createLocalRuntime(document: LocalDocument)`
|
|
167
185
|
|
|
168
|
-
Named read-only values are described by `LocalComputation` in the optional `document.computations` record. `bindings` and `initialState` remain writable controls; `snapshot().state` also includes successful calculated values for its revision. Read a named value with `evaluate(name)` to preserve expression errors; failed values are absent from snapshots. See [calculation and error semantics](computations-formatting-en.md).
|
|
186
|
+
Named read-only values are described by `LocalComputation` in the optional `document.computations` record. `bindings` and `initialState` remain writable controls; `snapshot().state` also includes successful calculated values for its revision. Read a named value with `evaluate(name)` to preserve expression errors; failed values are absent from snapshots. See [calculation and error semantics](../reference/computations-formatting-en.md).
|
|
169
187
|
|
|
170
188
|
Creates an independent in-memory runtime for a compiled document. Throws if `document` is not a local mode document, if initial values exceed budgets, or if the structure is invalid. Each instance has independent state; the runtime never stores or transmits state by itself.
|
|
171
189
|
|
|
172
190
|
### `LocalRuntime`
|
|
173
191
|
|
|
174
|
-
`validate(): Diagnostic[]` reads advisory cross-field failures for the current revision. It preserves editability and returns copies of cached diagnostics. `document.validations?: LocalValidation[]` holds the serializable rule declarations. Numeric collections add `number[]` to `LocalValue` and `number-array` to `LocalValueKind`; existing writable selection controls keep string arrays. See [constraints and collections](constraints-collections-en.md).
|
|
192
|
+
`validate(): Diagnostic[]` reads advisory cross-field failures for the current revision. It preserves editability and returns copies of cached diagnostics. `document.validations?: LocalValidation[]` holds the serializable rule declarations. Numeric collections add `number[]` to `LocalValue` and `number-array` to `LocalValueKind`; existing writable selection controls keep string arrays. See [constraints and collections](../reference/constraints-collections-en.md).
|
|
175
193
|
|
|
176
194
|
| Member | Parameters | Returns | Behavior |
|
|
177
195
|
| --- | --- | --- | --- |
|
|
@@ -265,7 +283,7 @@ Anonymous `@` bindings, removed or renamed parameters, timers and positional che
|
|
|
265
283
|
|
|
266
284
|
### Background compilation in a Worker
|
|
267
285
|
|
|
268
|
-
Worker support is host-provided: create the worker entry with your bundler and keep `compileLocal` as the fallback. A copyable browser example is in [Standalone integration examples](
|
|
286
|
+
Worker support is host-provided: create the worker entry with your bundler and keep `compileLocal` as the fallback. A copyable browser example is in [Standalone integration examples](../../examples/integration/README.md).
|
|
269
287
|
|
|
270
288
|
```ts
|
|
271
289
|
// compile.worker.ts
|
|
@@ -311,7 +329,7 @@ scheduler.schedule(source);
|
|
|
311
329
|
|
|
312
330
|
## Diagnostics
|
|
313
331
|
|
|
314
|
-
The fields and stability levels of `Diagnostic` are described in the diagnostics contract in [Versions and compatibility](compatibility-en.md). Key points: `line`, `column` and `range` are for programmatic location; `code` can be used for coarse classification in the current version, but 0.x does not promise cross-version stability; `message` is display text and should not be parsed.
|
|
332
|
+
The fields and stability levels of `Diagnostic` are described in the diagnostics contract in [Versions and compatibility](../compatibility/compatibility-en.md). Key points: `line`, `column` and `range` are for programmatic location; `code` can be used for coarse classification in the current version, but 0.x does not promise cross-version stability; `message` is display text and should not be parsed.
|
|
315
333
|
|
|
316
334
|
`onDiagnostics` receives compile diagnostics when the compilation result changes, and runtime diagnostics when control writes are rejected. Documents with compile errors do not activate interaction; runtime local errors replace only the corresponding content.
|
|
317
335
|
|
|
@@ -359,7 +377,7 @@ The policy receives the raw URL with leading and trailing whitespace removed, an
|
|
|
359
377
|
|
|
360
378
|
- Style selectors are mainly `.md-document`, `.local-document` and `.md-*`, `.local-*` class names. The document root rendered by components is `.md-document.local-document`.
|
|
361
379
|
- Theme variables are declared on `.md-document` and `.reactive-md-theme`, including `--ink`, `--surface`, `--line`, `--blue`, `--teal`, `--danger`, `--radius-*` and font variables. Override them after the library styles with rules such as `.my-article .md-document { --blue: #245c98; }`; the document root carries default values, so setting variables only on an ancestor container will not override same-name values on the root.
|
|
362
|
-
- Documents may start with `<theme name="default">`; omission selects `default`. Register custom themes through `themes`; see the [theme protocol](theme-protocol-en.md).
|
|
380
|
+
- Documents may start with `<theme name="default">`; omission selects `default`. Register custom themes through `themes`; see the [theme protocol](../reference/theme-protocol-en.md).
|
|
363
381
|
- `colorScheme` forces light or dark mode. The default `auto` reads the nearest ancestor's `data-color-scheme` or legacy `data-theme`, then the system preference. Each document exposes independent `data-rmd-theme` and resolved `data-color-scheme` attributes.
|
|
364
382
|
- Documents default to `max-width: 720px` and are horizontally centered. To fill the host container, override the width and margins of `.md-document` within your own scope.
|
|
365
383
|
- Prefer public variables for theme styling. Component outer `.md-*` and `.local-*` classes and semantic state attributes are theme hooks; internal node ordering is not an extension API. See the theme protocol for compatibility requirements.
|
|
@@ -371,22 +389,22 @@ A single string is limited to 100,000 characters, an array to 10,000 items, and
|
|
|
371
389
|
|
|
372
390
|
A single document source is limited to 1,000,000 characters. There are at most 100 diagnostics, and a single message is at most 2,000 characters.
|
|
373
391
|
|
|
374
|
-
Each plot component has at most 16 curves; the whole document requests at most 20,000 curve sample points, including hidden regions. Plotting computation is also limited by a shared execution budget of 2,000,000 steps. A document has at most 100 validation rules. Generated `data-table` rows, columns and text have per-table and whole-document budgets described in [constraints and collections](constraints-collections-en.md). Documents over a limit receive diagnostics; expression and math rendering also have their own depth and token budgets.
|
|
392
|
+
Each plot component has at most 16 curves; the whole document requests at most 20,000 curve sample points, including hidden regions. Plotting computation is also limited by a shared execution budget of 2,000,000 steps. A document has at most 100 validation rules. Generated `data-table` rows, columns and text have per-table and whole-document budgets described in [constraints and collections](../reference/constraints-collections-en.md). Documents over a limit receive diagnostics; expression and math rendering also have their own depth and token budgets.
|
|
375
393
|
|
|
376
|
-
These limits bound the work for a single document; they do not replace host control over request size, concurrency and execution time. See the [security policy](
|
|
394
|
+
These limits bound the work for a single document; they do not replace host control over request size, concurrency and execution time. See the [security policy](../../SECURITY.md) for the full threat boundary.
|
|
377
395
|
|
|
378
396
|
## Version pinning and upgrades
|
|
379
397
|
|
|
380
398
|
- During 0.x, pin the exact package version and commit the lockfile. `^0.3.0` allows only patch versions, but production integrations should still pin the version or the tarball SHA256.
|
|
381
399
|
- Use one package version for both the core and React entries; do not mix different versions of `reactive-md` and `reactive-md/react`.
|
|
382
|
-
- Record `LOCAL_SYNTAX_VERSION` in application configuration or document metadata, alongside the persisted `.reactive.md` source. Migrate according to [Versions and compatibility](compatibility-en.md) when the syntax revision changes.
|
|
400
|
+
- Record `LOCAL_SYNTAX_VERSION` in application configuration or document metadata, alongside the persisted `.reactive.md` source. Migrate according to [Versions and compatibility](../compatibility/compatibility-en.md) when the syntax revision changes.
|
|
383
401
|
- After upgrading, recompile your own documents and check `result.diagnostics`, rendered output and browser interactions. Do not depend on the text of diagnostic `message`.
|
|
384
402
|
|
|
385
403
|
## Features not provided
|
|
386
404
|
|
|
387
|
-
The default ReactiveMD path supports P0 HTML. Host options for author CSS, JavaScript and extended HTML use the separate native HTML path described in [HTML compatibility](html-compatibility-en.md). Local mode still provides no automatic state persistence or unrestricted network access, plugins or custom component registration, external data APIs, Vue support, React 18 support or a CommonJS entry. State export and import are explicit host calls. `LocalReactiveDocument` starts from initial values when the source changes; use retention helpers or manage the runtime and document yourself.
|
|
405
|
+
The default ReactiveMD path supports P0 HTML. Host options for author CSS, JavaScript and extended HTML use the separate native HTML path described in [HTML compatibility](../reference/html-compatibility-en.md). Local mode still provides no automatic state persistence or unrestricted network access, plugins or custom component registration, external data APIs, Vue support, React 18 support or a CommonJS entry. State export and import are explicit host calls. `LocalReactiveDocument` starts from initial values when the source changes; use retention helpers or manage the runtime and document yourself.
|
|
388
406
|
|
|
389
407
|
|
|
390
|
-
See [local-draft-2 components and migration](local-components-v2-en.md) for new tags, colors and slot state, and [0.4.0 release and migration](release-0.4.0-en.md) for the upgrade checklist. `0.
|
|
408
|
+
See [local-draft-2 components and migration](../reference/local-components-v2-en.md) for new tags, colors and slot state, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the upgrade checklist. `0.6.0` is available on both the `latest` and `next` channels.
|
|
391
409
|
|
|
392
|
-
|
|
410
|
+
0.5.3 adds compile-option-aware authoring and explicit screen/print styles. See [0.5.3 host integration](../releases/release-0.5.3-en.md). 0.6.0 makes `compileLocal` return plain data that can cross a React Server Components boundary; see the [0.6.0 release notes](../releases/release-0.6.0-en.md).
|