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.
Files changed (105) hide show
  1. package/CHANGELOG-ch.md +203 -194
  2. package/CHANGELOG.md +203 -194
  3. package/CONTRIBUTING-ch.md +67 -67
  4. package/CONTRIBUTING.md +69 -69
  5. package/README-ch.md +157 -157
  6. package/README-en.md +184 -184
  7. package/README.md +184 -184
  8. package/SECURITY-ch.md +81 -81
  9. package/SECURITY.md +81 -81
  10. package/THIRD_PARTY_NOTICES.md +313 -209
  11. package/bin/reactive-md.mjs +39 -39
  12. package/cli/args.mjs +181 -181
  13. package/cli/assets.mjs +390 -390
  14. package/cli/build.mjs +268 -268
  15. package/cli/document.mjs +130 -130
  16. package/cli/errors.mjs +61 -61
  17. package/cli/fs-utils.mjs +133 -133
  18. package/cli/glob.mjs +203 -203
  19. package/cli/help.mjs +138 -138
  20. package/cli/lint.mjs +177 -177
  21. package/cli/main.mjs +55 -55
  22. package/cli/migrate.mjs +368 -368
  23. package/cli/package.mjs +210 -210
  24. package/dist-library/{authoring-DSC0VsNK.js → authoring-BEVyth5X.js} +1 -1
  25. package/dist-library/compiler-Cm3ppMxG.js +46044 -0
  26. package/dist-library/{react-Dk94rcOp.js → react-Bh7_oxZp.js} +20110 -20113
  27. package/dist-library/reactive-md-authoring.js +2 -2
  28. package/dist-library/reactive-md-print.css +284 -284
  29. package/dist-library/reactive-md-react-unstyled.js +1 -1
  30. package/dist-library/reactive-md-react.js +1 -1
  31. package/dist-library/reactive-md.css +1 -1
  32. package/dist-library/reactive-md.js +3 -3
  33. package/dist-library/{runtime-D8KbnCd0.js → runtime-DlFYQ4s_.js} +1 -1
  34. package/dist-library/types/local/math-display.d.ts +22 -23
  35. package/dist-library/types/local/math-view.d.ts +6 -7
  36. package/dist-standalone/reactive-md-standalone.css +1 -1
  37. package/dist-standalone/reactive-md-standalone.js +318 -62
  38. package/docs/compatibility/compatibility-ch.md +121 -119
  39. package/docs/compatibility/compatibility-en.md +121 -119
  40. package/docs/compatibility/source-versioning-ch.md +159 -159
  41. package/docs/compatibility/source-versioning-en.md +159 -159
  42. package/docs/development/component-development-ch.md +210 -210
  43. package/docs/development/component-development-en.md +210 -210
  44. package/docs/development/component-protocol-ch.md +747 -747
  45. package/docs/development/component-protocol-en.md +747 -747
  46. package/docs/development/performance-ch.md +76 -76
  47. package/docs/development/performance-en.md +76 -76
  48. package/docs/development/releasing-ch.md +108 -108
  49. package/docs/development/releasing-en.md +108 -108
  50. package/docs/integration/author-tools-ch.md +62 -62
  51. package/docs/integration/author-tools-en.md +62 -62
  52. package/docs/integration/shareable-export-ch.md +209 -209
  53. package/docs/integration/shareable-export-en.md +211 -211
  54. package/docs/reference/computations-formatting-ch.md +87 -87
  55. package/docs/reference/computations-formatting-en.md +87 -87
  56. package/docs/reference/constraints-collections-ch.md +84 -84
  57. package/docs/reference/constraints-collections-en.md +84 -84
  58. package/docs/reference/diagnostics-counting-ch.md +104 -104
  59. package/docs/reference/diagnostics-counting-en.md +104 -104
  60. package/docs/reference/local-components-v2-ch.md +138 -138
  61. package/docs/reference/local-components-v2-en.md +104 -104
  62. package/docs/reference/local-interaction-syntax-ch.md +515 -511
  63. package/docs/reference/local-interaction-syntax-en.md +511 -507
  64. package/docs/reference/theme-protocol-ch.md +107 -107
  65. package/docs/reference/theme-protocol-en.md +107 -107
  66. package/docs/releases/release-0.4.0-ch.md +89 -89
  67. package/docs/releases/release-0.4.0-en.md +89 -89
  68. package/docs/releases/release-0.4.1-ch.md +23 -23
  69. package/docs/releases/release-0.4.1-en.md +23 -23
  70. package/docs/releases/release-0.6.1-ch.md +27 -0
  71. package/docs/releases/release-0.6.1-en.md +27 -0
  72. package/examples/conformance/README.md +53 -53
  73. package/examples/conformance/component-protocol-1.json +482 -482
  74. package/examples/conformance/component-protocol-1.schema.json +76 -76
  75. package/examples/conformance/local-draft-1.json +50 -50
  76. package/examples/conformance/local-draft-2.json +212 -212
  77. package/examples/integration/README.md +47 -47
  78. package/examples/integration/core/index.mjs +32 -32
  79. package/examples/integration/worker/index.html +19 -19
  80. package/examples/integration/worker/main.js +61 -61
  81. package/examples/integration/worker/package.json +13 -13
  82. package/examples/integration/worker/worker.js +3 -3
  83. package/examples/local/README.md +74 -74
  84. package/examples/local/charts.reactive.md +73 -73
  85. package/examples/local/recipes/invoice-zh.reactive.md +36 -36
  86. package/examples/local/recipes/invoice.reactive.md +36 -36
  87. package/examples/local/recipes/workshop-zh.reactive.md +33 -33
  88. package/examples/local/recipes/workshop.reactive.md +33 -33
  89. package/examples/local/showcase/README.md +25 -25
  90. package/examples/local/showcase/explore.reactive.md +102 -102
  91. package/examples/local/showcase/flow.reactive.md +86 -86
  92. package/examples/local/showcase/forms.reactive.md +126 -126
  93. package/examples/local/showcase/functions.reactive.md +119 -119
  94. package/examples/local/showcase/layout.reactive.md +100 -100
  95. package/examples/local/showcase/statistics.reactive.md +108 -108
  96. package/examples/local/showcase/tasks.reactive.md +89 -89
  97. package/examples/local/showcase/zh/explore.reactive.md +102 -102
  98. package/examples/local/showcase/zh/flow.reactive.md +86 -86
  99. package/examples/local/showcase/zh/forms.reactive.md +126 -126
  100. package/examples/local/showcase/zh/functions.reactive.md +119 -119
  101. package/examples/local/showcase/zh/layout.reactive.md +100 -100
  102. package/examples/local/showcase/zh/statistics.reactive.md +108 -108
  103. package/examples/local/showcase/zh/tasks.reactive.md +89 -89
  104. package/package.json +152 -152
  105. package/dist-library/compiler-CRD88BMt.js +0 -24964
@@ -1,119 +1,121 @@
1
- # 版本与兼容性
2
-
3
- Reactive MD 目前是 0.x 预览版。本页说明包版本、语法版本、可持久化的内容、诊断契约和当前平台范围。显式修订声明、迁移 API 与 `reactive-md migrate` 见[源码修订与迁移](source-versioning-ch.md),公开 API 与样式接入见[本地模式集成](../integration/local-integration-ch.md),当前版本见[0.6.0 发布说明](../releases/release-0.6.0-ch.md),该 minor 系列见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
4
-
5
- ## 版本对应
6
-
7
- | 项目 | 当前值 | 说明 |
8
- | --- | --- | --- |
9
- | 包版本 | `0.6.0` | 0.x 预览版;0.6.0 同时提供于 `latest` 与 `next` |
10
- | 分发标签 | `latest` → `0.6.0`;`next` → `0.6.0` | 默认安装使用 `latest` |
11
- | 语法版本 | `local-draft-2` | `LOCAL_SYNTAX_VERSION`;当前构建只接受这一修订 |
12
- | 源码修订指令 | 可选 `<!-- reactive-md: local-draft-2 -->` | 文档前导区中的一行;无指令源码继续按当前修订解析 |
13
- | 组块协议 | `component-protocol-2` | 贡献与验收契约,见[组块协议](../development/component-protocol-ch.md);不是运行时版本选择参数 |
14
- | 主题协议 | `reactive-md-theme-1` | 文档主题与宿主 CSS 接入 |
15
- | 作者工具入口 | `reactive-md/authoring` | schema、目录与编辑辅助函数,不加载 React 或 CSS |
16
- | 无样式 React 入口 | `reactive-md/react/unstyled` | 不依赖样式表的 React 渲染器 |
17
- | 核心入口 | `reactive-md` | 编译、表达式与运行时,不加载 React |
18
- | React 入口 | `reactive-md/react` | `LocalReactiveDocument`、`LocalDocumentView` |
19
- | 编辑器入口 | `reactive-md/editor` | `ReactiveMarkdownEditor` 及其类型;需要 React 19 |
20
- | 渲染器样式入口 | `reactive-md/styles.css` | 文档与组块样式,由宿主显式引入 |
21
- | 屏幕样式入口 | `reactive-md/screen.css` | `reactive-md/styles.css` 的别名 |
22
- | 打印样式入口 | `reactive-md/print.css` | 可选的文档打印布局与页边距 |
23
- | 编辑器样式入口 | `reactive-md/editor/styles.css` | 独立编辑器样式,作用域限定在编辑器根节点 |
24
-
25
- 一个包版本只对应一个语法修订。升级包之前,记录应用使用的 `LOCAL_SYNTAX_VERSION`。如果文档源码来自另一个语法修订,保留旧包版本渲染,或按下面的迁移说明改写。`compileLocal(source, options?)` 不提供语法版本参数;宿主可以通过 `options.limits.maxSyntaxNodes` 调整单次编译的语法节点预算,见[本地模式集成](../integration/local-integration-ch.md)。
26
-
27
- ## 显式源码修订
28
-
29
- 源码可以在前导区用一行 `<!-- reactive-md: local-draft-2 -->` 声明修订。无指令源码按当前修订读取,不新增警告。显式 `local-draft-1` 或未知修订会以 `local.version.*` 诊断拒绝,不创建运行时;声明旧修订不会选择旧解析器。格式错误、重复和位置错误的指令同样被拒绝。
30
-
31
- 在这一指令出现之前构建的读者(包括 `0.3.1`)会把它当作普通注释,不执行这项检查。依赖检查前请先迁移旧文档。`inspectLocalSourceVersion`、`checkLocalUpgrade` 和 `migrateLocalSource` 在编译器之外读取声明,`reactive-md migrate` 对单份源码执行元数据迁移。见[源码修订与迁移](source-versioning-ch.md)。
32
-
33
- ## 0.x 的兼容规则
34
-
35
- - 次版本(`0.3` 到 `0.4`)可能包含破坏性变更;补丁版本只做兼容修复和安全修复。
36
- - 0.x 阶段不承诺固定弃用周期。每项破坏性变更都会写入 [变更记录](../../CHANGELOG-ch.md),说明旧写法、新写法和迁移步骤。
37
- - 1.0 之前,把每次升级都当成可能需要修改文档源码或宿主代码。
38
- - 应用应固定包版本,保留原始 `.reactive.md` 源码,并在升级后用自己的文档和示例重新运行编译与渲染检查。
39
-
40
- ## 核心语义兼容范围
41
-
42
- 同一语法修订内,兼容的包更新保留已接受源码的含义:
43
-
44
- - 控件的公开值类型、初值规则、同名绑定约束和校验规则保持一致。隐藏控件仍会初始化,再次显示不会自动重置其值。
45
- - 表达式保持严格操作数类型、运算符优先级、短路求值和有限数值规则。局部计算失败不替换有效输入,也不阻止无关内容更新。
46
- - 非法参数写入保留上一次有效状态;多值写入原子提交。面板重置自己的控件与组件状态,依赖这些值的内容同步更新。
47
- - 正文、公式和可视化读取相同的参数值;代码与惰性降级区域保持原文。源码位置仍从 1 开始,按 UTF-16 单元和半开区间定位。
48
- - 渲染内容、控件标签和交互行为属于语义输出;生成的节点/DOM ID、内部 `@` 键、AST 布局、缓存、像素排版和诊断措辞不属于稳定的源码契约。
49
-
50
- 从 `local-draft-1` 升级到 `local-draft-2` 时,这一承诺适用于通过升级检查的共同语言子集。新增保留名和新激活标签需要人工修改源码;文本长度计数是必须显式接受的兼容例外,清单完成样式属于视觉例外。超出这些已记录例外的语义变化需要新的语法修订与迁移说明。
51
-
52
- [历史语料](../../examples/conformance/history/v0.3.1/provenance.json) 保留实际 `v0.3.1` 源码、来源提交和 SHA256。回归测试检查原一致性预期、公开值、非法写入拒绝、初始化、重置和迁移渲染;比较中明确排除内部 ID。
53
-
54
- ## 破坏性变更与迁移
55
-
56
- `0.5.0` 新增 `reactive-md/editor` 入口及其独立样式表;`0.5.1` 新增编辑器视图、主题配色和 HTML 兼容。`local-draft-2`、`component-protocol-1` 和 `reactive-md-theme-1` 保持不变。现有 `reactive-md`、`reactive-md/react` 和 `reactive-md/styles.css` 导入继续有效,为 0.4.x 编写的文档无需迁移。编辑器需要 React 19;历史与渲染边界见[编辑器指南](../integration/editor-ch.md)。
57
-
58
- `0.6.0` 新增原生 HTML 表格、`align` 与链接 `target`/`rel`、更多数学环境与命令、mhchem 化学式和扩展代码高亮,并把图解改为分层布局。无法解析的原生 HTML 改为按原文回退。`compileLocal` 的返回值只包含普通对象和数组,编辑器新增 `insertText`。语法、组块和主题修订均保持不变,现有导入继续有效。见[0.6.0 发布说明](../releases/release-0.6.0-ch.md)。
59
-
60
- `0.5.3` 新增宿主作者工具、统一编译选项、数学降级诊断,以及独立的屏幕与打印样式。现有入口继续有效;需要文档打印布局时显式引入 `reactive-md/print.css`。语法、组块和主题修订均保持不变。见[0.5.3 发布说明](../releases/release-0.5.3-ch.md)。
61
-
62
- `0.5.2` 新增可选的宿主组件扩展轴,并把组块协议提升到 `component-protocol-2`。语法修订和主题协议保持不变,现有导入继续有效,为 0.5.x 编写的文档无需迁移。见[0.5.2 发布说明](../releases/release-0.5.2-ch.md)。
63
-
64
- `0.4.0` 新增[条件、校验与本地集合](../reference/constraints-collections-ch.md):`LocalRuntime.validate()`、可序列化的 `LocalValidation` 规则、数字数组及生成表格。自行实现运行时适配器的宿主需补充 `validate()`,值类型穷举需加入 `number-array`;与 `sum`、`average`、`minOf`、`maxOf` 同名的旧绑定应重命名。
65
-
66
- `0.4.0` 新增[命名计算与格式化函数](../reference/computations-formatting-ch.md)。`computed`/`const` 使用现有本地标签形式;新函数名成为保留字,使用本版本前需重命名冲突的输入绑定并同步修改引用。`document.bindings` 和 `initialState` 继续只包含可写控件,快照同时提供成功求值的计算结果。
67
-
68
- `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 发布与迁移](../releases/release-0.4.0-ch.md)。
69
-
70
- 作者可见的语法变化会建立新的语法修订,例如本次的 `local-draft-2`,并提升次版本、更新 `LOCAL_SYNTAX_VERSION`。核心或 React API 的变化也会记录在变更记录中。项目不自动改写文档正文。`reactive-md migrate` 迁移单份源码的元数据声明,并阻止正文级冲突;升级后由作者或宿主按记录完成其余源码修改。
71
-
72
- 旧版配置语法不属于 `local-draft-2`。常见替换如下:
73
-
74
- | 旧写法 | `local-draft-2` 中的做法 |
75
- | --- | --- |
76
- | `:::card`、`:::row` 等 directive | `<card>`、`<grid>` 等标签 |
77
- | YAML `state:` 声明参数 | 控件上的 `bind` 与 `initial` |
78
- | YAML `computed:` | 正文中的 `{{ 表达式 }}` |
79
- | `actions:`、按钮动作、`on-*` 事件 | 没有等价入口;使用组件自带的交互和面板重置 |
80
- | `data:` 或外部接口数据 | 直接写在正文的 Markdown 表格;参数由控件声明 |
81
- | 持久化运行状态 | 宿主保存原始源码;公开参数还可以导出为经过校验的 `reactive-md-state/v1` 文件。该文件绑定源码摘要、语法修订和完整公开参数集合,不是文档格式。 |
82
-
83
- ## 持久化什么
84
-
85
- 持久化原始 `.reactive.md` 源码。`reactive-md-state/v1` 文件可以为同一源码和语法修订保存公开参数值;摘要、修订或参数集合不一致时会拒绝整个文件。迁移会改变源码摘要,迁移后应重新导出状态文件;迁移不会改写状态文件。不要持久化 `LocalDocument`、`LocalNode`、`node.id`、`initialState`、`LocalSnapshot` 或内部 `@` 运行时键:它们属于当前运行时对象,跨版本不保证结构,也不保证字段含义。`node.id` 在源码变化后会重新生成。诊断中的行号、列号和偏移量用于定位当前源码,不是稳定的持久化标识。
86
-
87
- ## 诊断契约
88
-
89
- `Diagnostic` 包含 `code`、`message`、`severity`、`range`、`line` 和 `column`。
90
-
91
- - `line` 和 `column` 从 1 开始;列和 `range` 均按原始源码的 UTF-16 代码单元计数,范围为半开区间。
92
- - `line`、`column` 和 `range` 可以用于程序定位和编辑器跳转。
93
- - `code` 是字符串标识,例如 `local.type`、`expression-type`、`latex-plot-range`。同一 0.x minor 系列内,现有诊断码的含义保持稳定;可以新增码,删除、改名或改变含义须在新 minor 版本中说明迁移。
94
- - `message` 是默认英文显示文本,使用 `formatLocalDiagnostic(diagnostic, 'zh')` 可取得中文。文案可以改进;不要解析 message 或按完整文本做业务判断。语言切换保留机器字段。
95
- - `severity` 为 `warning` 或 `error`。结构完整的未知标签保留源码并给出降级警告,编译仍可成功;脚注正常排版。编译错误会让 `result.ok` 为 `false` 并停用预览。运行时局部错误只影响对应内容。
96
-
97
- 完整规则和资源单位见[诊断与计数规则](../reference/diagnostics-counting-ch.md)。
98
-
99
- ## 平台与运行环境
100
-
101
- | 环境 | 当前状态 |
102
- | --- | --- |
103
- | Node.js 22.12+ | 开发和 Node 端消费的最低版本;CI 目标为 22.12 与 24 |
104
- | ESM | 唯一模块格式;不提供 CommonJS 入口 |
105
- | React 19 | `reactive-md/react` 和 `reactive-md/editor` 的要求;核心入口不依赖 React |
106
- | Microsoft Edge(Chromium 内核) | 本地浏览器验证使用 Edge |
107
- | Playwright Chromium | Linux CI 的完整浏览器验证 |
108
- | Playwright Firefox、WebKit | 1280px、375px 核心流程,包含个人文档和交互 HTML 导出;纳入浏览器发布门禁与 CI |
109
- | Apple 设备上的 Safari | 实机测试与 Playwright WebKit 引擎验证分开进行 |
110
- | 可分享状态格式 | `reactive-md-state/v1`:公开参数、语法版本与源码摘要;见[可分享文档](../integration/shareable-export-ch.md) |
111
- | 单文件 HTML 格式 | `reactive-md-html/v1`:交互或静态导出;仅交互模式内嵌独立运行时 |
112
- | SSR | `react-dom/server` 静态渲染由 packed 检查覆盖。编辑器入口没有顶层 DOM 访问,可在服务端导入和渲染;编辑交互在客户端运行。单文件导出的静态首屏水合已在 Playwright Chromium/Edge 验证;通用 SSR 水合未验证,使用前需自行检查 |
113
-
114
- Node 端消费指在 Node 中导入 `reactive-md`、调用 `compileLocal` 和 `createLocalRuntime`,不需要 DOM。React 渲染要求浏览器环境或宿主自行处理服务端输出。
115
-
116
- 语言范围见[语法规范](../reference/local-interaction-syntax-ch.md),安全边界与宿主责任见[安全策略](../../SECURITY-ch.md)。
117
-
118
-
119
- 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](../reference/local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。0.6.0 同时提供于 `latest` 与 `next`。
1
+ # 版本与兼容性
2
+
3
+ Reactive MD 目前是 0.x 预览版。本页说明包版本、语法版本、可持久化的内容、诊断契约和当前平台范围。显式修订声明、迁移 API 与 `reactive-md migrate` 见[源码修订与迁移](source-versioning-ch.md),公开 API 与样式接入见[本地模式集成](../integration/local-integration-ch.md),当前版本见[0.6.1 发布说明](../releases/release-0.6.1-ch.md),该 minor 系列见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
4
+
5
+ ## 版本对应
6
+
7
+ | 项目 | 当前值 | 说明 |
8
+ | --- | --- | --- |
9
+ | 包版本 | `0.6.1` | 0.x 预览版;0.6.1 同时提供于 `latest` 与 `next` |
10
+ | 分发标签 | `latest` → `0.6.1`;`next` → `0.6.1` | 默认安装使用 `latest` |
11
+ | 语法版本 | `local-draft-2` | `LOCAL_SYNTAX_VERSION`;当前构建只接受这一修订 |
12
+ | 源码修订指令 | 可选 `<!-- reactive-md: local-draft-2 -->` | 文档前导区中的一行;无指令源码继续按当前修订解析 |
13
+ | 组块协议 | `component-protocol-2` | 贡献与验收契约,见[组块协议](../development/component-protocol-ch.md);不是运行时版本选择参数 |
14
+ | 主题协议 | `reactive-md-theme-1` | 文档主题与宿主 CSS 接入 |
15
+ | 作者工具入口 | `reactive-md/authoring` | schema、目录与编辑辅助函数,不加载 React 或 CSS |
16
+ | 无样式 React 入口 | `reactive-md/react/unstyled` | 不依赖样式表的 React 渲染器 |
17
+ | 核心入口 | `reactive-md` | 编译、表达式与运行时,不加载 React |
18
+ | React 入口 | `reactive-md/react` | `LocalReactiveDocument`、`LocalDocumentView` |
19
+ | 编辑器入口 | `reactive-md/editor` | `ReactiveMarkdownEditor` 及其类型;需要 React 19 |
20
+ | 渲染器样式入口 | `reactive-md/styles.css` | 文档与组块样式,由宿主显式引入 |
21
+ | 屏幕样式入口 | `reactive-md/screen.css` | `reactive-md/styles.css` 的别名 |
22
+ | 打印样式入口 | `reactive-md/print.css` | 可选的文档打印布局与页边距 |
23
+ | 编辑器样式入口 | `reactive-md/editor/styles.css` | 独立编辑器样式,作用域限定在编辑器根节点 |
24
+
25
+ 一个包版本只对应一个语法修订。升级包之前,记录应用使用的 `LOCAL_SYNTAX_VERSION`。如果文档源码来自另一个语法修订,保留旧包版本渲染,或按下面的迁移说明改写。`compileLocal(source, options?)` 不提供语法版本参数;宿主可以通过 `options.limits.maxSyntaxNodes` 调整单次编译的语法节点预算,见[本地模式集成](../integration/local-integration-ch.md)。
26
+
27
+ ## 显式源码修订
28
+
29
+ 源码可以在前导区用一行 `<!-- reactive-md: local-draft-2 -->` 声明修订。无指令源码按当前修订读取,不新增警告。显式 `local-draft-1` 或未知修订会以 `local.version.*` 诊断拒绝,不创建运行时;声明旧修订不会选择旧解析器。格式错误、重复和位置错误的指令同样被拒绝。
30
+
31
+ 在这一指令出现之前构建的读者(包括 `0.3.1`)会把它当作普通注释,不执行这项检查。依赖检查前请先迁移旧文档。`inspectLocalSourceVersion`、`checkLocalUpgrade` 和 `migrateLocalSource` 在编译器之外读取声明,`reactive-md migrate` 对单份源码执行元数据迁移。见[源码修订与迁移](source-versioning-ch.md)。
32
+
33
+ ## 0.x 的兼容规则
34
+
35
+ - 次版本(`0.3` 到 `0.4`)可能包含破坏性变更;补丁版本只做兼容修复和安全修复。
36
+ - 0.x 阶段不承诺固定弃用周期。每项破坏性变更都会写入 [变更记录](../../CHANGELOG-ch.md),说明旧写法、新写法和迁移步骤。
37
+ - 1.0 之前,把每次升级都当成可能需要修改文档源码或宿主代码。
38
+ - 应用应固定包版本,保留原始 `.reactive.md` 源码,并在升级后用自己的文档和示例重新运行编译与渲染检查。
39
+
40
+ ## 核心语义兼容范围
41
+
42
+ 同一语法修订内,兼容的包更新保留已接受源码的含义:
43
+
44
+ - 控件的公开值类型、初值规则、同名绑定约束和校验规则保持一致。隐藏控件仍会初始化,再次显示不会自动重置其值。
45
+ - 表达式保持严格操作数类型、运算符优先级、短路求值和有限数值规则。局部计算失败不替换有效输入,也不阻止无关内容更新。
46
+ - 非法参数写入保留上一次有效状态;多值写入原子提交。面板重置自己的控件与组件状态,依赖这些值的内容同步更新。
47
+ - 正文、公式和可视化读取相同的参数值;代码与惰性降级区域保持原文。源码位置仍从 1 开始,按 UTF-16 单元和半开区间定位。
48
+ - 渲染内容、控件标签和交互行为属于语义输出;生成的节点/DOM ID、内部 `@` 键、AST 布局、缓存、像素排版和诊断措辞不属于稳定的源码契约。
49
+
50
+ 从 `local-draft-1` 升级到 `local-draft-2` 时,这一承诺适用于通过升级检查的共同语言子集。新增保留名和新激活标签需要人工修改源码;文本长度计数是必须显式接受的兼容例外,清单完成样式属于视觉例外。超出这些已记录例外的语义变化需要新的语法修订与迁移说明。
51
+
52
+ [历史语料](../../examples/conformance/history/v0.3.1/provenance.json) 保留实际 `v0.3.1` 源码、来源提交和 SHA256。回归测试检查原一致性预期、公开值、非法写入拒绝、初始化、重置和迁移渲染;比较中明确排除内部 ID。
53
+
54
+ ## 破坏性变更与迁移
55
+
56
+ `0.5.0` 新增 `reactive-md/editor` 入口及其独立样式表;`0.5.1` 新增编辑器视图、主题配色和 HTML 兼容。`local-draft-2`、`component-protocol-1` 和 `reactive-md-theme-1` 保持不变。现有 `reactive-md`、`reactive-md/react` 和 `reactive-md/styles.css` 导入继续有效,为 0.4.x 编写的文档无需迁移。编辑器需要 React 19;历史与渲染边界见[编辑器指南](../integration/editor-ch.md)。
57
+
58
+ `0.6.1` 将公式展示改为 KaTeX,随包提供 WOFF2 数学字体和用于辅助技术的 MathML。绘图求值与协议修订保持不变。无效公式给出警告,并回退为有界原文。`align` 现在自动按行编号;使用 `align*` 或 `aligned` 可省略自动编号。见[0.6.1 发布说明](../releases/release-0.6.1-ch.md)。
59
+
60
+ `0.6.0` 新增原生 HTML 表格、`align` 与链接 `target`/`rel`、更多数学环境与命令、mhchem 化学式和扩展代码高亮,并把图解改为分层布局。无法解析的原生 HTML 改为按原文回退。`compileLocal` 的返回值只包含普通对象和数组,编辑器新增 `insertText`。语法、组块和主题修订均保持不变,现有导入继续有效。见[0.6.0 发布说明](../releases/release-0.6.0-ch.md)。
61
+
62
+ `0.5.3` 新增宿主作者工具、统一编译选项、数学降级诊断,以及独立的屏幕与打印样式。现有入口继续有效;需要文档打印布局时显式引入 `reactive-md/print.css`。语法、组块和主题修订均保持不变。见[0.5.3 发布说明](../releases/release-0.5.3-ch.md)。
63
+
64
+ `0.5.2` 新增可选的宿主组件扩展轴,并把组块协议提升到 `component-protocol-2`。语法修订和主题协议保持不变,现有导入继续有效,为 0.5.x 编写的文档无需迁移。见[0.5.2 发布说明](../releases/release-0.5.2-ch.md)。
65
+
66
+ `0.4.0` 新增[条件、校验与本地集合](../reference/constraints-collections-ch.md):`LocalRuntime.validate()`、可序列化的 `LocalValidation` 规则、数字数组及生成表格。自行实现运行时适配器的宿主需补充 `validate()`,值类型穷举需加入 `number-array`;与 `sum`、`average`、`minOf`、`maxOf` 同名的旧绑定应重命名。
67
+
68
+ `0.4.0` 新增[命名计算与格式化函数](../reference/computations-formatting-ch.md)。`computed`/`const` 使用现有本地标签形式;新函数名成为保留字,使用本版本前需重命名冲突的输入绑定并同步修改引用。`document.bindings` 和 `initialState` 继续只包含可写控件,快照同时提供成功求值的计算结果。
69
+
70
+ `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 发布与迁移](../releases/release-0.4.0-ch.md)。
71
+
72
+ 作者可见的语法变化会建立新的语法修订,例如本次的 `local-draft-2`,并提升次版本、更新 `LOCAL_SYNTAX_VERSION`。核心或 React API 的变化也会记录在变更记录中。项目不自动改写文档正文。`reactive-md migrate` 迁移单份源码的元数据声明,并阻止正文级冲突;升级后由作者或宿主按记录完成其余源码修改。
73
+
74
+ 旧版配置语法不属于 `local-draft-2`。常见替换如下:
75
+
76
+ | 旧写法 | `local-draft-2` 中的做法 |
77
+ | --- | --- |
78
+ | `:::card`、`:::row` 等 directive | `<card>`、`<grid>` 等标签 |
79
+ | YAML `state:` 声明参数 | 控件上的 `bind` 与 `initial` |
80
+ | YAML `computed:` | 正文中的 `{{ 表达式 }}` |
81
+ | `actions:`、按钮动作、`on-*` 事件 | 没有等价入口;使用组件自带的交互和面板重置 |
82
+ | `data:` 或外部接口数据 | 直接写在正文的 Markdown 表格;参数由控件声明 |
83
+ | 持久化运行状态 | 宿主保存原始源码;公开参数还可以导出为经过校验的 `reactive-md-state/v1` 文件。该文件绑定源码摘要、语法修订和完整公开参数集合,不是文档格式。 |
84
+
85
+ ## 持久化什么
86
+
87
+ 持久化原始 `.reactive.md` 源码。`reactive-md-state/v1` 文件可以为同一源码和语法修订保存公开参数值;摘要、修订或参数集合不一致时会拒绝整个文件。迁移会改变源码摘要,迁移后应重新导出状态文件;迁移不会改写状态文件。不要持久化 `LocalDocument`、`LocalNode`、`node.id`、`initialState`、`LocalSnapshot` 或内部 `@` 运行时键:它们属于当前运行时对象,跨版本不保证结构,也不保证字段含义。`node.id` 在源码变化后会重新生成。诊断中的行号、列号和偏移量用于定位当前源码,不是稳定的持久化标识。
88
+
89
+ ## 诊断契约
90
+
91
+ `Diagnostic` 包含 `code`、`message`、`severity`、`range`、`line` 和 `column`。
92
+
93
+ - `line` 和 `column` 从 1 开始;列和 `range` 均按原始源码的 UTF-16 代码单元计数,范围为半开区间。
94
+ - `line`、`column` 和 `range` 可以用于程序定位和编辑器跳转。
95
+ - `code` 是字符串标识,例如 `local.type`、`expression-type`、`latex-plot-range`。同一 0.x minor 系列内,现有诊断码的含义保持稳定;可以新增码,删除、改名或改变含义须在新 minor 版本中说明迁移。
96
+ - `message` 是默认英文显示文本,使用 `formatLocalDiagnostic(diagnostic, 'zh')` 可取得中文。文案可以改进;不要解析 message 或按完整文本做业务判断。语言切换保留机器字段。
97
+ - `severity` 为 `warning` 或 `error`。结构完整的未知标签保留源码并给出降级警告,编译仍可成功;脚注正常排版。编译错误会让 `result.ok` 为 `false` 并停用预览。运行时局部错误只影响对应内容。
98
+
99
+ 完整规则和资源单位见[诊断与计数规则](../reference/diagnostics-counting-ch.md)。
100
+
101
+ ## 平台与运行环境
102
+
103
+ | 环境 | 当前状态 |
104
+ | --- | --- |
105
+ | Node.js 22.12+ | 开发和 Node 端消费的最低版本;CI 目标为 22.12 与 24 |
106
+ | ESM | 唯一模块格式;不提供 CommonJS 入口 |
107
+ | React 19 | `reactive-md/react` 和 `reactive-md/editor` 的要求;核心入口不依赖 React |
108
+ | Microsoft Edge(Chromium 内核) | 本地浏览器验证使用 Edge |
109
+ | Playwright Chromium | Linux CI 的完整浏览器验证 |
110
+ | Playwright Firefox、WebKit | 1280px、375px 核心流程,包含个人文档和交互 HTML 导出;纳入浏览器发布门禁与 CI |
111
+ | Apple 设备上的 Safari | 实机测试与 Playwright WebKit 引擎验证分开进行 |
112
+ | 可分享状态格式 | `reactive-md-state/v1`:公开参数、语法版本与源码摘要;见[可分享文档](../integration/shareable-export-ch.md) |
113
+ | 单文件 HTML 格式 | `reactive-md-html/v1`:交互或静态导出;仅交互模式内嵌独立运行时 |
114
+ | SSR | `react-dom/server` 静态渲染由 packed 检查覆盖。编辑器入口没有顶层 DOM 访问,可在服务端导入和渲染;编辑交互在客户端运行。单文件导出的静态首屏水合已在 Playwright Chromium/Edge 验证;通用 SSR 水合未验证,使用前需自行检查 |
115
+
116
+ Node 端消费指在 Node 中导入 `reactive-md`、调用 `compileLocal` 和 `createLocalRuntime`,不需要 DOM。React 渲染要求浏览器环境或宿主自行处理服务端输出。
117
+
118
+ 语言范围见[语法规范](../reference/local-interaction-syntax-ch.md),安全边界与宿主责任见[安全策略](../../SECURITY-ch.md)。
119
+
120
+
121
+ 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](../reference/local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。0.6.1 同时提供于 `latest` 与 `next`。
@@ -1,119 +1,121 @@
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](../integration/local-integration-en.md) for the public API and style integration, the [0.6.0 release notes](../releases/release-0.6.0-en.md) for the current release, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for that minor series.
4
-
5
- ## Version mapping
6
-
7
- | Item | Current value | Notes |
8
- | --- | --- | --- |
9
- | Package version | `0.6.0` | 0.x preview; 0.6.0 is available on both `latest` and `next` |
10
- | Distribution tags | `latest` → `0.6.0`; `next` → `0.6.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-2` | Contribution and acceptance contract, see [Component protocol](../development/component-protocol-en.md); not a runtime version selection parameter |
14
- | Theme protocol | `reactive-md-theme-1` | Document themes and host CSS integration |
15
- | Authoring entry | `reactive-md/authoring` | Schema, catalog and editor helpers, without React or CSS |
16
- | Unstyled React entry | `reactive-md/react/unstyled` | React renderer without a stylesheet dependency |
17
- | Core entry | `reactive-md` | Compilation, expressions and runtime, without loading React |
18
- | React entry | `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView` |
19
- | Editor entry | `reactive-md/editor` | `ReactiveMarkdownEditor` and its types; requires React 19 |
20
- | Renderer style entry | `reactive-md/styles.css` | Document and component styles, explicitly imported by the host |
21
- | Screen style entry | `reactive-md/screen.css` | Alias of `reactive-md/styles.css` |
22
- | Print style entry | `reactive-md/print.css` | Optional document print layout and page margins |
23
- | Editor style entry | `reactive-md/editor/styles.css` | Independent editor styles, scoped to the editor root |
24
-
25
- 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](../integration/local-integration-en.md).
26
-
27
- ## Explicit source revisions
28
-
29
- 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.
30
-
31
- 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).
32
-
33
- ## Compatibility rules for 0.x
34
-
35
- - Minor versions (`0.3` to `0.4`) may contain breaking changes; patch versions contain only compatibility and security fixes.
36
- - 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.
37
- - Before 1.0, treat every upgrade as potentially requiring changes to document sources or host code.
38
- - 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.
39
-
40
- ## Core semantic compatibility
41
-
42
- Within a syntax revision, compatible package updates preserve the meaning of accepted source:
43
-
44
- - 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.
45
- - 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.
46
- - 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.
47
- - 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.
48
- - 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.
49
-
50
- 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.
51
-
52
- 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.
53
-
54
- ## Breaking changes and migration
55
-
56
- `0.5.0` added the `reactive-md/editor` entry and its independent stylesheet. `0.5.1` adds editor views, theme palettes and HTML compatibility. They keep `local-draft-2`, `component-protocol-1` and `reactive-md-theme-1`. Existing `reactive-md`, `reactive-md/react` and `reactive-md/styles.css` imports keep working, and documents written for 0.4.x need no migration. The editor requires React 19; see the [editor guide](../integration/editor-en.md) for its history and rendering boundaries.
57
-
58
- `0.6.0` adds native HTML tables, `align` and link `target`/`rel`, more math environments and commands, mhchem chemistry and expanded code highlighting, and switches diagrams to a layered layout. Unparseable native HTML now falls back to source. `compileLocal` returns only plain objects and arrays, and the editor adds `insertText`. Syntax, component and theme revisions remain unchanged, and existing imports keep working. See the [0.6.0 release notes](../releases/release-0.6.0-en.md).
59
-
60
- `0.5.3` adds host authoring tools, consistent compile options, math fallback diagnostics and separate screen/print stylesheets. Existing entries remain available; import `reactive-md/print.css` explicitly for document print layout. Syntax, component and theme revisions remain unchanged. See the [0.5.3 release notes](../releases/release-0.5.3-en.md).
61
-
62
- `0.5.2` adds the opt-in host component extension axis and raises the component protocol to `component-protocol-2`. The syntax revision and theme protocol remain unchanged, existing imports keep working, and documents written for 0.5.x need no migration. See the [0.5.2 release notes](../releases/release-0.5.2-en.md).
63
-
64
- `0.4.0` adds [constraints and collections](../reference/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`.
65
-
66
- `0.4.0` adds [named calculations and formatting functions](../reference/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.
67
-
68
- `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](../releases/release-0.4.0-en.md) for the complete rename and upgrade checklist.
69
-
70
- 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.
71
-
72
- Legacy configuration syntax is not part of `local-draft-2`. Common replacements:
73
-
74
- | Old form | What to do in `local-draft-2` |
75
- | --- | --- |
76
- | Directives such as `:::card`, `:::row` | Tags such as `<card>`, `<grid>` |
77
- | YAML `state:` declaring parameters | `bind` and `initial` on controls |
78
- | YAML `computed:` | `{{ expression }}` in the prose |
79
- | `actions:`, button actions, `on-*` events | No equivalent entry point; use component built-in interactions and panel reset |
80
- | `data:` or external API data | Markdown tables written directly in the prose; parameters are declared by controls |
81
- | 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. |
82
-
83
- ## What to persist
84
-
85
- 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.
86
-
87
- ## Diagnostics contract
88
-
89
- `Diagnostic` contains `code`, `message`, `severity`, `range`, `line` and `column`.
90
-
91
- - Lines and columns are one-based. Columns and half-open ranges count UTF-16 code units in the original source.
92
- - `line`, `column` and `range` can be used for programmatic location and editor jumps.
93
- - `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.
94
- - `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.
95
- - `severity` is `warning` or `error`. Structurally complete unknown tags keep their source and produce fallback warnings, and compilation can still succeed; footnotes render normally. Compile errors make `result.ok` `false` and disable the preview. Runtime local errors affect only the corresponding content.
96
-
97
- See [Diagnostics and counting rules](../reference/diagnostics-counting-en.md) for units and resource-budget scopes.
98
-
99
- ## Platforms and runtimes
100
-
101
- | Environment | Current status |
102
- | --- | --- |
103
- | Node.js 22.12+ | Minimum for development and Node-side consumption; CI targets both 22.12 and 24 |
104
- | ESM | The only module format; no CommonJS entry |
105
- | React 19 | Required by `reactive-md/react` and `reactive-md/editor`; the core entry does not depend on React |
106
- | Microsoft Edge (Chromium-based) | Local browser verification has used Edge |
107
- | Playwright Chromium | Full Linux CI browser suite |
108
- | Playwright Firefox and WebKit | Core workflows at 1280px and 375px, including personal documents and interactive HTML export; included in the browser release gate and CI |
109
- | Safari on Apple devices | Device testing remains separate from Playwright WebKit engine checks |
110
- | Shareable state format | `reactive-md-state/v1`: public parameter values with a syntax version and source digest; see [Shareable documents](../integration/shareable-export-en.md) |
111
- | Single-file HTML format | `reactive-md-html/v1`: interactive or static export, with an inline standalone runtime only in interactive mode |
112
- | SSR | `react-dom/server` static rendering is covered by the packed check. The editor entry has no top-level DOM access and can be imported and rendered on the server; editing interactions run on the client. 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 |
113
-
114
- 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.
115
-
116
- See the [syntax specification](../reference/local-interaction-syntax-en.md) for the language scope, and the [security policy](../../SECURITY.md) for the security boundary and host responsibilities.
117
-
118
-
119
- 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 `latest` and `next`.
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](../integration/local-integration-en.md) for the public API and style integration, the [0.6.1 release notes](../releases/release-0.6.1-en.md) for the current release, and [0.4.0 release and migration](../releases/release-0.4.0-en.md) for that minor series.
4
+
5
+ ## Version mapping
6
+
7
+ | Item | Current value | Notes |
8
+ | --- | --- | --- |
9
+ | Package version | `0.6.1` | 0.x preview; 0.6.1 is available on both `latest` and `next` |
10
+ | Distribution tags | `latest` → `0.6.1`; `next` → `0.6.1` | 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-2` | Contribution and acceptance contract, see [Component protocol](../development/component-protocol-en.md); not a runtime version selection parameter |
14
+ | Theme protocol | `reactive-md-theme-1` | Document themes and host CSS integration |
15
+ | Authoring entry | `reactive-md/authoring` | Schema, catalog and editor helpers, without React or CSS |
16
+ | Unstyled React entry | `reactive-md/react/unstyled` | React renderer without a stylesheet dependency |
17
+ | Core entry | `reactive-md` | Compilation, expressions and runtime, without loading React |
18
+ | React entry | `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView` |
19
+ | Editor entry | `reactive-md/editor` | `ReactiveMarkdownEditor` and its types; requires React 19 |
20
+ | Renderer style entry | `reactive-md/styles.css` | Document and component styles, explicitly imported by the host |
21
+ | Screen style entry | `reactive-md/screen.css` | Alias of `reactive-md/styles.css` |
22
+ | Print style entry | `reactive-md/print.css` | Optional document print layout and page margins |
23
+ | Editor style entry | `reactive-md/editor/styles.css` | Independent editor styles, scoped to the editor root |
24
+
25
+ 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](../integration/local-integration-en.md).
26
+
27
+ ## Explicit source revisions
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Compatibility rules for 0.x
34
+
35
+ - Minor versions (`0.3` to `0.4`) may contain breaking changes; patch versions contain only compatibility and security fixes.
36
+ - 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.
37
+ - Before 1.0, treat every upgrade as potentially requiring changes to document sources or host code.
38
+ - 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.
39
+
40
+ ## Core semantic compatibility
41
+
42
+ Within a syntax revision, compatible package updates preserve the meaning of accepted source:
43
+
44
+ - 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.
45
+ - 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.
46
+ - 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.
47
+ - 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.
48
+ - 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.
49
+
50
+ 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.
51
+
52
+ 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.
53
+
54
+ ## Breaking changes and migration
55
+
56
+ `0.5.0` added the `reactive-md/editor` entry and its independent stylesheet. `0.5.1` adds editor views, theme palettes and HTML compatibility. They keep `local-draft-2`, `component-protocol-1` and `reactive-md-theme-1`. Existing `reactive-md`, `reactive-md/react` and `reactive-md/styles.css` imports keep working, and documents written for 0.4.x need no migration. The editor requires React 19; see the [editor guide](../integration/editor-en.md) for its history and rendering boundaries.
57
+
58
+ `0.6.1` switches formula display to KaTeX with bundled WOFF2 fonts and accessible MathML. Plot evaluation and protocol revisions are unchanged. Invalid formulas fall back to bounded source text with a warning. `align` now numbers rows; use `align*` or `aligned` to omit automatic numbers. See the [0.6.1 release notes](../releases/release-0.6.1-en.md).
59
+
60
+ `0.6.0` adds native HTML tables, `align` and link `target`/`rel`, more math environments and commands, mhchem chemistry and expanded code highlighting, and switches diagrams to a layered layout. Unparseable native HTML now falls back to source. `compileLocal` returns only plain objects and arrays, and the editor adds `insertText`. Syntax, component and theme revisions remain unchanged, and existing imports keep working. See the [0.6.0 release notes](../releases/release-0.6.0-en.md).
61
+
62
+ `0.5.3` adds host authoring tools, consistent compile options, math fallback diagnostics and separate screen/print stylesheets. Existing entries remain available; import `reactive-md/print.css` explicitly for document print layout. Syntax, component and theme revisions remain unchanged. See the [0.5.3 release notes](../releases/release-0.5.3-en.md).
63
+
64
+ `0.5.2` adds the opt-in host component extension axis and raises the component protocol to `component-protocol-2`. The syntax revision and theme protocol remain unchanged, existing imports keep working, and documents written for 0.5.x need no migration. See the [0.5.2 release notes](../releases/release-0.5.2-en.md).
65
+
66
+ `0.4.0` adds [constraints and collections](../reference/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`.
67
+
68
+ `0.4.0` adds [named calculations and formatting functions](../reference/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.
69
+
70
+ `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](../releases/release-0.4.0-en.md) for the complete rename and upgrade checklist.
71
+
72
+ 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.
73
+
74
+ Legacy configuration syntax is not part of `local-draft-2`. Common replacements:
75
+
76
+ | Old form | What to do in `local-draft-2` |
77
+ | --- | --- |
78
+ | Directives such as `:::card`, `:::row` | Tags such as `<card>`, `<grid>` |
79
+ | YAML `state:` declaring parameters | `bind` and `initial` on controls |
80
+ | YAML `computed:` | `{{ expression }}` in the prose |
81
+ | `actions:`, button actions, `on-*` events | No equivalent entry point; use component built-in interactions and panel reset |
82
+ | `data:` or external API data | Markdown tables written directly in the prose; parameters are declared by controls |
83
+ | 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. |
84
+
85
+ ## What to persist
86
+
87
+ 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.
88
+
89
+ ## Diagnostics contract
90
+
91
+ `Diagnostic` contains `code`, `message`, `severity`, `range`, `line` and `column`.
92
+
93
+ - Lines and columns are one-based. Columns and half-open ranges count UTF-16 code units in the original source.
94
+ - `line`, `column` and `range` can be used for programmatic location and editor jumps.
95
+ - `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.
96
+ - `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.
97
+ - `severity` is `warning` or `error`. Structurally complete unknown tags keep their source and produce fallback warnings, and compilation can still succeed; footnotes render normally. Compile errors make `result.ok` `false` and disable the preview. Runtime local errors affect only the corresponding content.
98
+
99
+ See [Diagnostics and counting rules](../reference/diagnostics-counting-en.md) for units and resource-budget scopes.
100
+
101
+ ## Platforms and runtimes
102
+
103
+ | Environment | Current status |
104
+ | --- | --- |
105
+ | Node.js 22.12+ | Minimum for development and Node-side consumption; CI targets both 22.12 and 24 |
106
+ | ESM | The only module format; no CommonJS entry |
107
+ | React 19 | Required by `reactive-md/react` and `reactive-md/editor`; the core entry does not depend on React |
108
+ | Microsoft Edge (Chromium-based) | Local browser verification has used Edge |
109
+ | Playwright Chromium | Full Linux CI browser suite |
110
+ | Playwright Firefox and WebKit | Core workflows at 1280px and 375px, including personal documents and interactive HTML export; included in the browser release gate and CI |
111
+ | Safari on Apple devices | Device testing remains separate from Playwright WebKit engine checks |
112
+ | Shareable state format | `reactive-md-state/v1`: public parameter values with a syntax version and source digest; see [Shareable documents](../integration/shareable-export-en.md) |
113
+ | Single-file HTML format | `reactive-md-html/v1`: interactive or static export, with an inline standalone runtime only in interactive mode |
114
+ | SSR | `react-dom/server` static rendering is covered by the packed check. The editor entry has no top-level DOM access and can be imported and rendered on the server; editing interactions run on the client. 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 |
115
+
116
+ 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.
117
+
118
+ See the [syntax specification](../reference/local-interaction-syntax-en.md) for the language scope, and the [security policy](../../SECURITY.md) for the security boundary and host responsibilities.
119
+
120
+
121
+ 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.1 is available on both `latest` and `next`.