reactive-md 0.3.1 → 0.4.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 +113 -0
- package/CHANGELOG.md +113 -53
- package/CONTRIBUTING-ch.md +62 -0
- package/CONTRIBUTING.md +64 -65
- package/LICENSE +21 -21
- package/README-ch.md +123 -0
- package/README-en.md +147 -0
- package/README.md +96 -38
- 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 +3525 -1651
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1798 -4
- package/dist-library/runtime-D3QTVYaz.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/release-0.4.1-ch.md +23 -0
- package/docs/release-0.4.1-en.md +23 -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/core/package.json +7 -7
- package/examples/integration/react/index.html +12 -12
- package/examples/integration/react/main.jsx +21 -21
- package/examples/integration/react/package.json +9 -9
- 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 +20 -20
- package/examples/local/charts.reactive.md +34 -34
- package/examples/local/checklist.reactive.md +32 -32
- package/examples/local/comparison.reactive.md +47 -47
- package/examples/local/components.reactive.md +44 -44
- package/examples/local/counter.reactive.md +7 -7
- package/examples/local/diagnostics.reactive.md +54 -54
- package/examples/local/diagram.reactive.md +44 -44
- package/examples/local/gallery.reactive.md +61 -61
- package/examples/local/parameters.reactive.md +36 -36
- package/examples/local/planning.reactive.md +24 -24
- package/examples/local/pricing.reactive.md +20 -20
- 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 +91 -77
- 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
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# 作者工具
|
|
2
|
+
|
|
3
|
+
[English](author-tools-en.md)
|
|
4
|
+
|
|
5
|
+
作者工具包含在 `0.4.0` 源码树中。本地使用前先构建语言包:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm ci
|
|
9
|
+
npm run build
|
|
10
|
+
npm run lint -- examples/local/planning.reactive.md
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 命令行检查
|
|
14
|
+
|
|
15
|
+
语言包提供 `reactive-md lint`。可以传入多个文件,或用 `-` 读取标准输入:
|
|
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
|
+
文本输出包含文件、行、列、严重程度和诊断代码。JSON 输出为 `{ file, ok, diagnostics }` 报告数组。诊断沿用编译器的 UTF-16 源码范围,行列从 1 开始。检查过程保留原文件。
|
|
25
|
+
|
|
26
|
+
`--locale en|zh` 选择诊断消息语言,默认英文。切换语言保留诊断码、严重程度和位置。兼容契约与预算单位见[诊断与计数规则](diagnostics-counting-ch.md)。
|
|
27
|
+
|
|
28
|
+
| 退出码 | 含义 |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| 0 | 没有错误;默认允许警告 |
|
|
31
|
+
| 1 | 存在编译错误,或启用 `--warnings-as-errors` 后存在警告 |
|
|
32
|
+
| 2 | 参数错误或文件读取失败 |
|
|
33
|
+
|
|
34
|
+
## 接入编辑器
|
|
35
|
+
|
|
36
|
+
核心入口提供与 DOM 无关的函数:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import {
|
|
40
|
+
analyzeLocalSource, completeLocalSource,
|
|
41
|
+
renameLocalBinding, formatLocalSource,
|
|
42
|
+
} from 'reactive-md';
|
|
43
|
+
|
|
44
|
+
const analysis = analyzeLocalSource(source);
|
|
45
|
+
const suggestions = completeLocalSource(source, cursorOffset);
|
|
46
|
+
const renamed = renameLocalBinding(source, 'people', 'attendees');
|
|
47
|
+
const formatted = formatLocalSource(renamed.source);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
分析结果包含按位置排序的高亮 token、绑定声明和引用范围,以及编译诊断。补全项包含 `label`、`kind`、`insertText` 和待替换的 `range`。应用编辑时,应使用生成这些范围的同一版本源码。
|
|
51
|
+
|
|
52
|
+
重命名修改生效的绑定声明、表达式引用和绘图参数,保留普通文字与展示公式。绘图参数在重命名后写为 `\mathrm{newName}`。非法名称和名称冲突会抛出错误。格式化整理已识别组件标签内的空白,保留 Markdown 排版、引号内容、公式、代码与降级区域的源码。编辑器应持续保存原始文档。
|
|
53
|
+
|
|
54
|
+
## Playground
|
|
55
|
+
|
|
56
|
+
运行 `npm run dev`,选择“显示源码”。编辑器提供高亮、补全、绑定定位、重命名、格式化、诊断跳转与实时预览。通过补全按钮或 Ctrl+Space 打开建议列表,方向键选择,Enter 插入,Escape 关闭。重命名与格式化均可撤销、重做。
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Author tools
|
|
2
|
+
|
|
3
|
+
[中文](author-tools-ch.md)
|
|
4
|
+
|
|
5
|
+
These tools are included in the `0.4.0` source tree. Build the package before using them locally:
|
|
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';
|
|
43
|
+
|
|
44
|
+
const analysis = analyzeLocalSource(source);
|
|
45
|
+
const suggestions = completeLocalSource(source, cursorOffset);
|
|
46
|
+
const renamed = renameLocalBinding(source, 'people', 'attendees');
|
|
47
|
+
const formatted = formatLocalSource(renamed.source);
|
|
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.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# 版本与兼容性
|
|
2
|
+
|
|
3
|
+
Reactive MD 目前是 0.x 预览版。本页说明包版本、语法版本、可持久化的内容、诊断契约和当前平台范围。显式修订声明、迁移 API 与 `reactive-md migrate` 见[源码修订与迁移](source-versioning-ch.md),公开 API 与样式接入见[本地模式集成](local-integration-ch.md),本次发布的升级摘要见[0.4.0 发布与迁移](release-0.4.0-ch.md)。
|
|
4
|
+
|
|
5
|
+
## 版本对应
|
|
6
|
+
|
|
7
|
+
| 项目 | 当前值 | 说明 |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| 包版本 | `0.4.0` | 0.x 预览版,同时提供于 `latest` 和 `next` 渠道 |
|
|
10
|
+
| 分发标签 | `latest` → `0.4.0`;`next` → `0.4.0` | 默认安装使用 `latest` |
|
|
11
|
+
| 语法版本 | `local-draft-2` | `LOCAL_SYNTAX_VERSION`;当前构建只接受这一修订 |
|
|
12
|
+
| 源码修订指令 | 可选 `<!-- reactive-md: local-draft-2 -->` | 文档前导区中的一行;无指令源码继续按当前修订解析 |
|
|
13
|
+
| 组块协议 | `component-protocol-1` | 贡献与验收契约,见[组块协议](component-protocol-ch.md);不是运行时版本选择参数 |
|
|
14
|
+
| 核心入口 | `reactive-md` | 编译、表达式与运行时,不加载 React |
|
|
15
|
+
| React 入口 | `reactive-md/react` | `LocalReactiveDocument`、`LocalDocumentView` |
|
|
16
|
+
| 样式入口 | `reactive-md/styles.css` | 一份全局样式表,由宿主显式引入 |
|
|
17
|
+
|
|
18
|
+
一个包版本只对应一个语法修订。升级包之前,记录应用使用的 `LOCAL_SYNTAX_VERSION`。如果文档源码来自另一个语法修订,保留旧包版本渲染,或按下面的迁移说明改写。`compileLocal(source, options?)` 不提供语法版本参数;宿主可以通过 `options.limits.maxSyntaxNodes` 调整单次编译的语法节点预算,见[本地模式集成](local-integration-ch.md)。
|
|
19
|
+
|
|
20
|
+
## 显式源码修订
|
|
21
|
+
|
|
22
|
+
源码可以在前导区用一行 `<!-- reactive-md: local-draft-2 -->` 声明修订。无指令源码按当前修订读取,不新增警告。显式 `local-draft-1` 或未知修订会以 `local.version.*` 诊断拒绝,不创建运行时;声明旧修订不会选择旧解析器。格式错误、重复和位置错误的指令同样被拒绝。
|
|
23
|
+
|
|
24
|
+
在这一指令出现之前构建的读者(包括 `0.3.1`)会把它当作普通注释,不执行这项检查。依赖检查前请先迁移旧文档。`inspectLocalSourceVersion`、`checkLocalUpgrade` 和 `migrateLocalSource` 在编译器之外读取声明,`reactive-md migrate` 对单份源码执行元数据迁移。见[源码修订与迁移](source-versioning-ch.md)。
|
|
25
|
+
|
|
26
|
+
## 0.x 的兼容规则
|
|
27
|
+
|
|
28
|
+
- 次版本(`0.3` 到 `0.4`)可能包含破坏性变更;补丁版本只做兼容修复和安全修复。
|
|
29
|
+
- 0.x 阶段不承诺固定弃用周期。每项破坏性变更都会写入 [变更记录](../CHANGELOG-ch.md),说明旧写法、新写法和迁移步骤。
|
|
30
|
+
- 1.0 之前,把每次升级都当成可能需要修改文档源码或宿主代码。
|
|
31
|
+
- 应用应固定包版本,保留原始 `.reactive.md` 源码,并在升级后用自己的文档和示例重新运行编译与渲染检查。
|
|
32
|
+
|
|
33
|
+
## 核心语义兼容范围
|
|
34
|
+
|
|
35
|
+
同一语法修订内,兼容的包更新保留已接受源码的含义:
|
|
36
|
+
|
|
37
|
+
- 控件的公开值类型、初值规则、同名绑定约束和校验规则保持一致。隐藏控件仍会初始化,再次显示不会自动重置其值。
|
|
38
|
+
- 表达式保持严格操作数类型、运算符优先级、短路求值和有限数值规则。局部计算失败不替换有效输入,也不阻止无关内容更新。
|
|
39
|
+
- 非法参数写入保留上一次有效状态;多值写入原子提交。面板重置自己的控件与组件状态,依赖这些值的内容同步更新。
|
|
40
|
+
- 正文、公式和可视化读取相同的参数值;代码与惰性降级区域保持原文。源码位置仍从 1 开始,按 UTF-16 单元和半开区间定位。
|
|
41
|
+
- 渲染内容、控件标签和交互行为属于语义输出;生成的节点/DOM ID、内部 `@` 键、AST 布局、缓存、像素排版和诊断措辞不属于稳定的源码契约。
|
|
42
|
+
|
|
43
|
+
从 `local-draft-1` 升级到 `local-draft-2` 时,这一承诺适用于通过升级检查的共同语言子集。新增保留名和新激活标签需要人工修改源码;文本长度计数是必须显式接受的兼容例外,清单完成样式属于视觉例外。超出这些已记录例外的语义变化需要新的语法修订与迁移说明。
|
|
44
|
+
|
|
45
|
+
[历史语料](../examples/conformance/history/v0.3.1/provenance.json) 保留实际 `v0.3.1` 源码、来源提交和 SHA256。回归测试检查原一致性预期、公开值、非法写入拒绝、初始化、重置和迁移渲染;比较中明确排除内部 ID。
|
|
46
|
+
|
|
47
|
+
## 破坏性变更与迁移
|
|
48
|
+
|
|
49
|
+
`0.4.0` 新增[条件、校验与本地集合](constraints-collections-ch.md):`LocalRuntime.validate()`、可序列化的 `LocalValidation` 规则、数字数组及生成表格。自行实现运行时适配器的宿主需补充 `validate()`,值类型穷举需加入 `number-array`;与 `sum`、`average`、`minOf`、`maxOf` 同名的旧绑定应重命名。
|
|
50
|
+
|
|
51
|
+
`0.4.0` 新增[命名计算与格式化函数](computations-formatting-ch.md)。`computed`/`const` 使用现有本地标签形式;新函数名成为保留字,使用本版本前需重命名冲突的输入绑定并同步修改引用。`document.bindings` 和 `initialState` 继续只包含可写控件,快照同时提供成功求值的计算结果。
|
|
52
|
+
|
|
53
|
+
`0.4.0` 建立 `local-draft-2`。使用受支持 `local-draft-1` 写法的无指令源码继续有效;显式 `local-draft-1` 声明在迁移前会被拒绝。构建新增识别 15 个标签名:十个 `local-draft-2` 组块,以及 `computed`、`const`、`validation`、`data-table`、`column`。以前作为未知标签或普通文字显示的内容现在会解析为组块或声明;字面示例应移入行内代码或代码围栏。开头的 `<theme>` 声明是文档元数据,不计入组块。完整的重命名与升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。
|
|
54
|
+
|
|
55
|
+
作者可见的语法变化会建立新的语法修订,例如本次的 `local-draft-2`,并提升次版本、更新 `LOCAL_SYNTAX_VERSION`。核心或 React API 的变化也会记录在变更记录中。项目不自动改写文档正文。`reactive-md migrate` 迁移单份源码的元数据声明,并阻止正文级冲突;升级后由作者或宿主按记录完成其余源码修改。
|
|
56
|
+
|
|
57
|
+
旧版配置语法不属于 `local-draft-2`。常见替换如下:
|
|
58
|
+
|
|
59
|
+
| 旧写法 | `local-draft-2` 中的做法 |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| `:::card`、`:::row` 等 directive | `<card>`、`<grid>` 等标签 |
|
|
62
|
+
| YAML `state:` 声明参数 | 控件上的 `bind` 与 `initial` |
|
|
63
|
+
| YAML `computed:` | 正文中的 `{{ 表达式 }}` |
|
|
64
|
+
| `actions:`、按钮动作、`on-*` 事件 | 没有等价入口;使用组件自带的交互和面板重置 |
|
|
65
|
+
| `data:` 或外部接口数据 | 直接写在正文的 Markdown 表格;参数由控件声明 |
|
|
66
|
+
| 持久化运行状态 | 宿主保存原始源码;公开参数还可以导出为经过校验的 `reactive-md-state/v1` 文件。该文件绑定源码摘要、语法修订和完整公开参数集合,不是文档格式。 |
|
|
67
|
+
|
|
68
|
+
## 持久化什么
|
|
69
|
+
|
|
70
|
+
持久化原始 `.reactive.md` 源码。`reactive-md-state/v1` 文件可以为同一源码和语法修订保存公开参数值;摘要、修订或参数集合不一致时会拒绝整个文件。迁移会改变源码摘要,迁移后应重新导出状态文件;迁移不会改写状态文件。不要持久化 `LocalDocument`、`LocalNode`、`node.id`、`initialState`、`LocalSnapshot` 或内部 `@` 运行时键:它们属于当前运行时对象,跨版本不保证结构,也不保证字段含义。`node.id` 在源码变化后会重新生成。诊断中的行号、列号和偏移量用于定位当前源码,不是稳定的持久化标识。
|
|
71
|
+
|
|
72
|
+
## 诊断契约
|
|
73
|
+
|
|
74
|
+
`Diagnostic` 包含 `code`、`message`、`severity`、`range`、`line` 和 `column`。
|
|
75
|
+
|
|
76
|
+
- `line` 和 `column` 从 1 开始;列和 `range` 均按原始源码的 UTF-16 代码单元计数,范围为半开区间。
|
|
77
|
+
- `line`、`column` 和 `range` 可以用于程序定位和编辑器跳转。
|
|
78
|
+
- `code` 是字符串标识,例如 `local.type`、`expression-type`、`latex-plot-range`。同一 0.x minor 系列内,现有诊断码的含义保持稳定;可以新增码,删除、改名或改变含义须在新 minor 版本中说明迁移。
|
|
79
|
+
- `message` 是默认英文显示文本,使用 `formatLocalDiagnostic(diagnostic, 'zh')` 可取得中文。文案可以改进;不要解析 message 或按完整文本做业务判断。语言切换保留机器字段。
|
|
80
|
+
- `severity` 为 `warning` 或 `error`。结构完整的未知标签和脚注保留源码并给出降级警告,编译仍可成功;编译错误会让 `result.ok` 为 `false` 并停用预览。运行时局部错误只影响对应内容。
|
|
81
|
+
|
|
82
|
+
完整规则和资源单位见[诊断与计数规则](diagnostics-counting-ch.md)。
|
|
83
|
+
|
|
84
|
+
## 平台与运行环境
|
|
85
|
+
|
|
86
|
+
| 环境 | 当前状态 |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| Node.js 22.12+ | 开发和 Node 端消费的最低版本;CI 目标为 22.12 与 24 |
|
|
89
|
+
| ESM | 唯一模块格式;不提供 CommonJS 入口 |
|
|
90
|
+
| React 19 | `reactive-md/react` 的要求;核心入口不依赖 React |
|
|
91
|
+
| Microsoft Edge(Chromium 内核) | 本地浏览器验证使用 Edge |
|
|
92
|
+
| Playwright Chromium | Linux CI 浏览器目标 |
|
|
93
|
+
| Firefox、Safari/WebKit | 未验证,不作支持声明 |
|
|
94
|
+
| 可分享状态格式 | `reactive-md-state/v1`:公开参数、语法版本与源码摘要;见[可分享文档](shareable-export-ch.md) |
|
|
95
|
+
| 单文件 HTML 格式 | `reactive-md-html/v1`:交互或静态导出;仅交互模式内嵌独立运行时 |
|
|
96
|
+
| SSR | `react-dom/server` 静态渲染由 packed 检查覆盖。单文件导出的静态首屏水合已在 Playwright Chromium/Edge 验证;通用 SSR 水合未验证,使用前需自行检查 |
|
|
97
|
+
|
|
98
|
+
Node 端消费指在 Node 中导入 `reactive-md`、调用 `compileLocal` 和 `createLocalRuntime`,不需要 DOM。React 渲染要求浏览器环境或宿主自行处理服务端输出。
|
|
99
|
+
|
|
100
|
+
语言范围见[语法规范](local-interaction-syntax-ch.md),安全边界与宿主责任见[安全策略](../SECURITY-ch.md)。
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。`0.4.0` 同时提供于 `latest` 和 `next` 渠道。
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Versions and compatibility
|
|
2
|
+
|
|
3
|
+
Reactive MD is currently a 0.x preview. This page covers package versions, syntax versions, what can be persisted, the diagnostics contract and the current platform scope. See [Source revisions and migration](source-versioning-en.md) for explicit revision declarations, the migration API and `reactive-md migrate`, [Local mode integration](local-integration-en.md) for the public API and style integration, and [0.4.0 release and migration](release-0.4.0-en.md) for this release's upgrade summary.
|
|
4
|
+
|
|
5
|
+
## Version mapping
|
|
6
|
+
|
|
7
|
+
| Item | Current value | Notes |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Package version | `0.4.0` | 0.x preview, available on both `latest` and `next` |
|
|
10
|
+
| Distribution tags | `latest` → `0.4.0`; `next` → `0.4.0` | Default installs use `latest` |
|
|
11
|
+
| Syntax version | `local-draft-2` | `LOCAL_SYNTAX_VERSION`; the current build accepts only this revision |
|
|
12
|
+
| Source revision directive | Optional `<!-- reactive-md: local-draft-2 -->` | One line in the document prologue; unversioned source keeps current-revision behavior |
|
|
13
|
+
| Component protocol | `component-protocol-1` | Contribution and acceptance contract, see [Component protocol](component-protocol-en.md); not a runtime version selection parameter |
|
|
14
|
+
| Core entry | `reactive-md` | Compilation, expressions and runtime, without loading React |
|
|
15
|
+
| React entry | `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView` |
|
|
16
|
+
| Style entry | `reactive-md/styles.css` | One global stylesheet, explicitly imported by the host |
|
|
17
|
+
|
|
18
|
+
One package version corresponds to exactly one syntax revision. Before upgrading the package, record the `LOCAL_SYNTAX_VERSION` your application uses. If document sources come from another syntax revision, keep rendering them with the old package version or rewrite them according to the migration notes below. `compileLocal(source, options?)` has no syntax version parameter; hosts can adjust the syntax node budget for a single compilation through `options.limits.maxSyntaxNodes`, see [Local mode integration](local-integration-en.md).
|
|
19
|
+
|
|
20
|
+
## Explicit source revisions
|
|
21
|
+
|
|
22
|
+
A source may declare its revision with one `<!-- reactive-md: local-draft-2 -->` line in the prologue. Unversioned source is read as the current revision, without a new warning. An explicit `local-draft-1` or unknown revision is rejected with a `local.version.*` diagnostic and no runtime is created; declaring an old revision does not select an old parser. Malformed, duplicate and misplaced directives are rejected the same way.
|
|
23
|
+
|
|
24
|
+
Readers built before this directive existed, including `0.3.1`, treat it as an ordinary comment and do not enforce the check. Migrate old documents before relying on it. `inspectLocalSourceVersion`, `checkLocalUpgrade` and `migrateLocalSource` expose the declaration outside the compiler, and `reactive-md migrate` performs the single-source metadata migration. See [Source revisions and migration](source-versioning-en.md).
|
|
25
|
+
|
|
26
|
+
## Compatibility rules for 0.x
|
|
27
|
+
|
|
28
|
+
- Minor versions (`0.3` to `0.4`) may contain breaking changes; patch versions contain only compatibility and security fixes.
|
|
29
|
+
- The 0.x phase does not promise a fixed deprecation period. Every breaking change is recorded in the [changelog](../CHANGELOG.md), with the old form, new form and migration steps.
|
|
30
|
+
- Before 1.0, treat every upgrade as potentially requiring changes to document sources or host code.
|
|
31
|
+
- Applications should pin the package version, keep the original `.reactive.md` sources, and rerun compile and render checks with their own documents and examples after upgrading.
|
|
32
|
+
|
|
33
|
+
## Core semantic compatibility
|
|
34
|
+
|
|
35
|
+
Within a syntax revision, compatible package updates preserve the meaning of accepted source:
|
|
36
|
+
|
|
37
|
+
- Controls keep their public value types, initial-value rules, shared-binding constraints and validation rules. Hidden controls still initialize, and showing them again does not reset their values.
|
|
38
|
+
- Expressions keep strict operand types, operator precedence, short-circuit evaluation and finite-number rules. A failed local calculation does not replace a valid input or stop unrelated content.
|
|
39
|
+
- Invalid parameter writes leave the last valid state unchanged; multi-value writes commit atomically. Panel reset restores its own controls and component state, and dependent content updates consistently.
|
|
40
|
+
- Prose, formulas and visualizations read the same parameter values. Code and inert fallback regions stay literal. Source locations remain one-based with UTF-16 offsets and half-open ranges.
|
|
41
|
+
- Rendered content, control labels and interactions are semantic outputs. Generated node/DOM IDs, internal `@` keys, AST layout, caches, pixel layout and diagnostic wording are outside the stable source contract.
|
|
42
|
+
|
|
43
|
+
From `local-draft-1` to `local-draft-2`, this promise covers the common supported language after upgrade checks. New reserved identifiers and newly active tags require manual source changes. Text-length counting is an explicit compatibility exception that the migrator requires you to accept; completed-checklist styling is a visual exception. A semantic change outside these recorded exceptions requires a syntax revision and migration notes.
|
|
44
|
+
|
|
45
|
+
Regression data in [the historical corpus](../examples/conformance/history/v0.3.1/provenance.json) preserves actual `v0.3.1` sources, their source commit and SHA256 digests. The regression suite checks the original conformance expectations, public values, rejected writes, initialization, resets and migration rendering. Internal IDs are excluded from comparisons.
|
|
46
|
+
|
|
47
|
+
## Breaking changes and migration
|
|
48
|
+
|
|
49
|
+
`0.4.0` adds [constraints and collections](constraints-collections-en.md): `LocalRuntime.validate()`, serializable `LocalValidation` rules, numeric arrays and generated tables. Hosts implementing a runtime adapter need the new `validate()` method; exhaustive value-kind checks need `number-array`. Rename bindings colliding with `sum`, `average`, `minOf` or `maxOf`.
|
|
50
|
+
|
|
51
|
+
`0.4.0` adds [named calculations and formatting functions](computations-formatting-en.md). `computed`/`const` use the existing local tag syntax. The new built-in function names become reserved; rename colliding input bindings and their references before using this release. `document.bindings` and `initialState` still contain writable controls; snapshots also expose successful calculated values.
|
|
52
|
+
|
|
53
|
+
`0.4.0` establishes `local-draft-2`. Unversioned source that uses supported `local-draft-1` forms remains valid; an explicit `local-draft-1` declaration is rejected until migrated. The build now recognizes 15 additional tag names: the ten `local-draft-2` components plus `computed`, `const`, `validation`, `data-table` and `column`. Text that previously displayed as an unknown or literal tag now parses as a component or declaration; move literal examples into code spans or fences. The leading `<theme>` declaration is document metadata and is not counted as a component. See [0.4.0 release and migration](release-0.4.0-en.md) for the complete rename and upgrade checklist.
|
|
54
|
+
|
|
55
|
+
Author-visible syntax changes establish a new syntax revision, such as `local-draft-2`, and raise the minor version and update `LOCAL_SYNTAX_VERSION`. Changes to the core or React API are also recorded in the changelog. The project does not rewrite document bodies automatically. `reactive-md migrate` moves one source's metadata declaration and blocks body-level conflicts; after upgrading, authors or hosts complete any remaining source changes according to the record.
|
|
56
|
+
|
|
57
|
+
Legacy configuration syntax is not part of `local-draft-2`. Common replacements:
|
|
58
|
+
|
|
59
|
+
| Old form | What to do in `local-draft-2` |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| Directives such as `:::card`, `:::row` | Tags such as `<card>`, `<grid>` |
|
|
62
|
+
| YAML `state:` declaring parameters | `bind` and `initial` on controls |
|
|
63
|
+
| YAML `computed:` | `{{ expression }}` in the prose |
|
|
64
|
+
| `actions:`, button actions, `on-*` events | No equivalent entry point; use component built-in interactions and panel reset |
|
|
65
|
+
| `data:` or external API data | Markdown tables written directly in the prose; parameters are declared by controls |
|
|
66
|
+
| Persisted runtime state | The host saves the original source. Public parameters may additionally be exported as a validated `reactive-md-state/v1` file; it is tied to the source digest, syntax revision and exact public parameter set and is not a document format. |
|
|
67
|
+
|
|
68
|
+
## What to persist
|
|
69
|
+
|
|
70
|
+
Persist the original `.reactive.md` source. A `reactive-md-state/v1` file may preserve public parameter values for the same source and syntax revision; it is rejected when the digest, revision or parameter set differs. Migration changes the source digest, so export a fresh state file after migrating; migration never rewrites state files. Do not persist `LocalDocument`, `LocalNode`, `node.id`, `initialState`, `LocalSnapshot` or internal `@` runtime keys: they belong to the current runtime object and their structure and field meanings are not guaranteed across versions. `node.id` is regenerated when the source changes. Diagnostic line numbers, columns and offsets locate the current source and are not stable persistence identifiers.
|
|
71
|
+
|
|
72
|
+
## Diagnostics contract
|
|
73
|
+
|
|
74
|
+
`Diagnostic` contains `code`, `message`, `severity`, `range`, `line` and `column`.
|
|
75
|
+
|
|
76
|
+
- Lines and columns are one-based. Columns and half-open ranges count UTF-16 code units in the original source.
|
|
77
|
+
- `line`, `column` and `range` can be used for programmatic location and editor jumps.
|
|
78
|
+
- `code` is a string identifier, such as `local.type`, `expression-type` or `latex-plot-range`. Existing codes keep their meaning within one 0.x minor series. New codes may be added; removal, renaming or a change of meaning requires a new minor version and migration notes.
|
|
79
|
+
- `message` contains default English display text. Use `formatLocalDiagnostic(diagnostic, 'zh')` for Chinese. Wording may improve; do not parse messages or make business decisions based on their complete text. Language changes preserve machine fields.
|
|
80
|
+
- `severity` is `warning` or `error`. Structurally complete unknown tags and footnotes keep their source and produce fallback warnings, and compilation can still succeed; compile errors make `result.ok` `false` and disable the preview. Runtime local errors affect only the corresponding content.
|
|
81
|
+
|
|
82
|
+
See [Diagnostics and counting rules](diagnostics-counting-en.md) for units and resource-budget scopes.
|
|
83
|
+
|
|
84
|
+
## Platforms and runtimes
|
|
85
|
+
|
|
86
|
+
| Environment | Current status |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| Node.js 22.12+ | Minimum for development and Node-side consumption; CI targets both 22.12 and 24 |
|
|
89
|
+
| ESM | The only module format; no CommonJS entry |
|
|
90
|
+
| React 19 | Required by `reactive-md/react`; the core entry does not depend on React |
|
|
91
|
+
| Microsoft Edge (Chromium-based) | Local browser verification has used Edge |
|
|
92
|
+
| Playwright Chromium | Linux CI browser target |
|
|
93
|
+
| Firefox, Safari/WebKit | Unverified; no support claim |
|
|
94
|
+
| Shareable state format | `reactive-md-state/v1`: public parameter values with a syntax version and source digest; see [Shareable documents](shareable-export-en.md) |
|
|
95
|
+
| Single-file HTML format | `reactive-md-html/v1`: interactive or static export, with an inline standalone runtime only in interactive mode |
|
|
96
|
+
| SSR | `react-dom/server` static rendering is covered by the packed check. Static-first hydration of the single-file export is covered in Playwright Chromium/Edge; general SSR hydration is unverified and should be checked before use |
|
|
97
|
+
|
|
98
|
+
Node-side consumption means importing `reactive-md` in Node and calling `compileLocal` and `createLocalRuntime` without a DOM. React rendering requires a browser environment, or the host must handle server output itself.
|
|
99
|
+
|
|
100
|
+
See the [syntax specification](local-interaction-syntax-en.md) for the language scope, and the [security policy](../SECURITY.md) for the security boundary and host responsibilities.
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
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.4.0` is available on both `latest` and `next`.
|