reactive-md 0.5.0 → 0.5.2

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 (59) hide show
  1. package/CHANGELOG-ch.md +34 -0
  2. package/CHANGELOG.md +34 -0
  3. package/README-ch.md +10 -7
  4. package/README-en.md +12 -7
  5. package/README.md +12 -7
  6. package/SECURITY-ch.md +4 -3
  7. package/SECURITY.md +4 -3
  8. package/THIRD_PARTY_NOTICES.md +45 -1
  9. package/dist-library/reactive-md-editor.css +1 -1
  10. package/dist-library/reactive-md-editor.js +739 -615
  11. package/dist-library/reactive-md-react.js +2111 -1903
  12. package/dist-library/reactive-md.js +462 -326
  13. package/dist-library/{runtime-DPuMxM_y.js → runtime-UiQPz5ZV.js} +8780 -2718
  14. package/dist-library/types/editor/editor-i18n.d.ts +7 -0
  15. package/dist-library/types/editor/editor-view-bar.d.ts +11 -0
  16. package/dist-library/types/editor/index.d.ts +1 -1
  17. package/dist-library/types/editor/types.d.ts +8 -1
  18. package/dist-library/types/local/LocalDocumentView.d.ts +19 -4
  19. package/dist-library/types/local/code-block.d.ts +3 -1
  20. package/dist-library/types/local/diagnostics.d.ts +65 -0
  21. package/dist-library/types/local/heading-anchors.d.ts +2 -0
  22. package/dist-library/types/local/html-names.d.ts +6 -0
  23. package/dist-library/types/local/html.d.ts +16 -0
  24. package/dist-library/types/local/image-view.d.ts +3 -1
  25. package/dist-library/types/local/index.d.ts +1 -1
  26. package/dist-library/types/local/limits.d.ts +8 -0
  27. package/dist-library/types/local/options.d.ts +34 -0
  28. package/dist-library/types/local/render-types.d.ts +11 -0
  29. package/dist-library/types/local/types.d.ts +53 -1
  30. package/dist-library/types/local/worker.d.ts +21 -6
  31. package/dist-library/types/react/index.d.ts +1 -1
  32. package/dist-library/types/shareable.d.ts +9 -1
  33. package/dist-standalone/reactive-md-standalone.js +49 -49
  34. package/docs/compatibility-ch.md +8 -6
  35. package/docs/compatibility-en.md +8 -6
  36. package/docs/component-development-ch.md +4 -4
  37. package/docs/component-development-en.md +3 -3
  38. package/docs/component-protocol-ch.md +48 -11
  39. package/docs/component-protocol-en.md +48 -11
  40. package/docs/editor-ch.md +235 -216
  41. package/docs/editor-en.md +235 -216
  42. package/docs/html-compatibility-ch.md +98 -0
  43. package/docs/html-compatibility-en.md +98 -0
  44. package/docs/local-integration-ch.md +29 -2
  45. package/docs/local-integration-en.md +29 -2
  46. package/docs/local-interaction-syntax-ch.md +3 -1
  47. package/docs/local-interaction-syntax-en.md +1 -1
  48. package/docs/release-0.5.1-ch.md +39 -0
  49. package/docs/release-0.5.1-en.md +39 -0
  50. package/docs/release-0.5.2-ch.md +35 -0
  51. package/docs/release-0.5.2-en.md +35 -0
  52. package/docs/releasing-ch.md +7 -7
  53. package/docs/releasing-en.md +8 -8
  54. package/docs/shareable-export-ch.md +2 -0
  55. package/docs/shareable-export-en.md +2 -0
  56. package/examples/conformance/README.md +1 -1
  57. package/examples/local/README.md +2 -0
  58. package/examples/local/html-compat.reactive.md +24 -0
  59. package/package.json +3 -1
@@ -1,16 +1,16 @@
1
1
  # 版本与兼容性
2
2
 
3
- Reactive MD 目前是 0.x 预览版。本页说明包版本、语法版本、可持久化的内容、诊断契约和当前平台范围。显式修订声明、迁移 API 与 `reactive-md migrate` 见[源码修订与迁移](source-versioning-ch.md),公开 API 与样式接入见[本地模式集成](local-integration-ch.md),当前预览见[0.5.0 发布说明](release-0.5.0-ch.md),该 minor 系列见[0.4.0 发布与迁移](release-0.4.0-ch.md)。
3
+ Reactive MD 目前是 0.x 预览版。本页说明包版本、语法版本、可持久化的内容、诊断契约和当前平台范围。显式修订声明、迁移 API 与 `reactive-md migrate` 见[源码修订与迁移](source-versioning-ch.md),公开 API 与样式接入见[本地模式集成](local-integration-ch.md),当前预览见[0.5.2 发布说明](release-0.5.2-ch.md),该 minor 系列见[0.4.0 发布与迁移](release-0.4.0-ch.md)。
4
4
 
5
5
  ## 版本对应
6
6
 
7
7
  | 项目 | 当前值 | 说明 |
8
8
  | --- | --- | --- |
9
- | 包版本 | `0.5.0` | 0.x 预览版;0.5.0 面向 `next`,`latest` 仍为 `0.4.0` |
10
- | 分发标签 | `latest` → `0.4.0`;`next` → `0.5.0`(预览目标) | 默认安装使用 `latest` |
9
+ | 包版本 | `0.5.2` | 0.x 预览版;0.5.2 面向 `next`,`latest` 仍为 `0.4.0` |
10
+ | 分发标签 | `latest` → `0.4.0`;`next` → `0.5.2`(预览目标) | 默认安装使用 `latest` |
11
11
  | 语法版本 | `local-draft-2` | `LOCAL_SYNTAX_VERSION`;当前构建只接受这一修订 |
12
12
  | 源码修订指令 | 可选 `<!-- reactive-md: local-draft-2 -->` | 文档前导区中的一行;无指令源码继续按当前修订解析 |
13
- | 组块协议 | `component-protocol-1` | 贡献与验收契约,见[组块协议](component-protocol-ch.md);不是运行时版本选择参数 |
13
+ | 组块协议 | `component-protocol-2` | 贡献与验收契约,见[组块协议](component-protocol-ch.md);不是运行时版本选择参数 |
14
14
  | 核心入口 | `reactive-md` | 编译、表达式与运行时,不加载 React |
15
15
  | React 入口 | `reactive-md/react` | `LocalReactiveDocument`、`LocalDocumentView` |
16
16
  | 编辑器入口 | `reactive-md/editor` | `ReactiveMarkdownEditor` 及其类型;需要 React 19 |
@@ -48,7 +48,9 @@ Reactive MD 目前是 0.x 预览版。本页说明包版本、语法版本、可
48
48
 
49
49
  ## 破坏性变更与迁移
50
50
 
51
- `0.5.0` 新增 `reactive-md/editor` 入口及其独立样式表,`local-draft-2`、`component-protocol-1` 和 `reactive-md-theme-1` 保持不变。现有 `reactive-md`、`reactive-md/react` 和 `reactive-md/styles.css` 导入继续有效,为 0.4.x 编写的文档无需迁移。编辑器需要 React 19;历史与渲染边界见[编辑器指南](editor-ch.md)。
51
+ `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;历史与渲染边界见[编辑器指南](editor-ch.md)。
52
+
53
+ `0.5.2` 新增可选的宿主组件扩展轴,并把组块协议提升到 `component-protocol-2`。语法修订和主题协议保持不变,现有导入继续有效,为 0.5.x 编写的文档无需迁移。见[0.5.2 发布说明](release-0.5.2-ch.md)。
52
54
 
53
55
  `0.4.0` 新增[条件、校验与本地集合](constraints-collections-ch.md):`LocalRuntime.validate()`、可序列化的 `LocalValidation` 规则、数字数组及生成表格。自行实现运行时适配器的宿主需补充 `validate()`,值类型穷举需加入 `number-array`;与 `sum`、`average`、`minOf`、`maxOf` 同名的旧绑定应重命名。
54
56
 
@@ -104,4 +106,4 @@ Node 端消费指在 Node 中导入 `reactive-md`、调用 `compileLocal` 和 `c
104
106
  语言范围见[语法规范](local-interaction-syntax-ch.md),安全边界与宿主责任见[安全策略](../SECURITY-ch.md)。
105
107
 
106
108
 
107
- 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。0.5.0 预览版面向 `next`,`latest` 仍为 `0.4.0`。
109
+ 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。0.5.2 预览版面向 `next`,`latest` 仍为 `0.4.0`。
@@ -1,16 +1,16 @@
1
1
  # Versions and compatibility
2
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, [0.5.0 release notes](release-0.5.0-en.md) for the current preview, and [0.4.0 release and migration](release-0.4.0-en.md) for that minor series.
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, [0.5.2 release notes](release-0.5.2-en.md) for the current preview, and [0.4.0 release and migration](release-0.4.0-en.md) for that minor series.
4
4
 
5
5
  ## Version mapping
6
6
 
7
7
  | Item | Current value | Notes |
8
8
  | --- | --- | --- |
9
- | Package version | `0.5.0` | 0.x preview; 0.5.0 targets `next`, while `latest` remains `0.4.0` |
10
- | Distribution tags | `latest` → `0.4.0`; `next` → `0.5.0` (preview target) | Default installs use `latest` |
9
+ | Package version | `0.5.2` | 0.x preview; 0.5.2 targets `next`, while `latest` remains `0.4.0` |
10
+ | Distribution tags | `latest` → `0.4.0`; `next` → `0.5.2` (preview target) | Default installs use `latest` |
11
11
  | Syntax version | `local-draft-2` | `LOCAL_SYNTAX_VERSION`; the current build accepts only this revision |
12
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 |
13
+ | Component protocol | `component-protocol-2` | Contribution and acceptance contract, see [Component protocol](component-protocol-en.md); not a runtime version selection parameter |
14
14
  | Core entry | `reactive-md` | Compilation, expressions and runtime, without loading React |
15
15
  | React entry | `reactive-md/react` | `LocalReactiveDocument`, `LocalDocumentView` |
16
16
  | Editor entry | `reactive-md/editor` | `ReactiveMarkdownEditor` and its types; requires React 19 |
@@ -48,7 +48,9 @@ Regression data in [the historical corpus](../examples/conformance/history/v0.3.
48
48
 
49
49
  ## Breaking changes and migration
50
50
 
51
- `0.5.0` adds the `reactive-md/editor` entry and its independent stylesheet. It keeps `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](editor-en.md) for its history and rendering boundaries.
51
+ `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](editor-en.md) for its history and rendering boundaries.
52
+
53
+ `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](release-0.5.2-en.md).
52
54
 
53
55
  `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`.
54
56
 
@@ -104,4 +106,4 @@ Node-side consumption means importing `reactive-md` in Node and calling `compile
104
106
  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.
105
107
 
106
108
 
107
- 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. The 0.5.0 preview targets `next`; `latest` remains `0.4.0`.
109
+ 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. The 0.5.2 preview targets `next`; `latest` remains `0.4.0`.
@@ -2,7 +2,7 @@
2
2
 
3
3
  本指南面向为 Reactive MD 新增或修改组件的贡献者。组块包括输入控件、容器、可视化和结构子项。共同契约见[组块协议](component-protocol-ch.md),作者写法见[本地交互语法规范](local-interaction-syntax-ch.md)。
4
4
 
5
- 当前协议为 `component-protocol-1`,适用语法为 `local-draft-2`,当前包版本为 `0.4.0`,即发布在 `next` 渠道的预览版。这三个版本分别表示贡献契约、作者语法和 npm 发布。协议文档更新不自动改变语法或公开 API。
5
+ 当前协议为 `component-protocol-2`,适用语法为 `local-draft-2`,当前包版本为 `0.5.2`,即发布在 `next` 渠道的预览版。这三个版本分别表示贡献契约、作者语法和 npm 发布。协议文档更新不自动改变语法或公开 API。
6
6
 
7
7
  ## 1. 提交什么
8
8
 
@@ -49,7 +49,7 @@
49
49
 
50
50
  新标签还有一项迁移影响:旧实现会把完整的未知区域按惰性原文显示,新实现识别该名称后可能开始执行内部内容。必须在提案中记录这一点,并给出前后用例。名称是否加入核心组件集由维护者评审;不得覆盖现有名称的含义或偷偷添加别名。
51
51
 
52
- 协议格式保持 component-protocol-1;此次能力新增将语法提升到 local-draft-2,包版本提升到 0.4.0。
52
+ 本协议自身不新增作者标签或属性,因此保持 `local-draft-2` 和当前包版本。
53
53
 
54
54
  ## 4. 用现有组块填写声明
55
55
 
@@ -121,7 +121,7 @@ $$ y = a \sin x $$
121
121
  | --- | --- |
122
122
  | 包版本 | 当前值、目标值和理由 |
123
123
  | 语法修订 | 当前值、目标值和迁移影响 |
124
- | 协议修订 | component-protocol-1,或说明新修订 |
124
+ | 协议修订 | component-protocol-2,或说明新修订 |
125
125
  | 名称 | 小写 kebab-case;冲突检查和维护者决定 |
126
126
  | 形态 | leaf / inline / container |
127
127
  | 父级、直接子项 | 允许范围、数量、嵌套及空白规则 |
@@ -207,4 +207,4 @@ $$ y = a \sin x $$
207
207
  在 PR 中列出实际运行的命令和观察结果。未运行、失败、不适用分别写明,不把清单勾选当成验证证据。
208
208
 
209
209
 
210
- 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md)。`0.4.0` 是 `next` 渠道的预览版。
210
+ 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md)。`0.5.2` 是 `next` 渠道的预览版。
@@ -2,7 +2,7 @@
2
2
 
3
3
  This guide is for contributors adding or changing components in Reactive MD. Components include input controls, containers, visualizations and structural children. The shared contract is in the [component protocol](component-protocol-en.md); the author syntax is in the [local interaction syntax specification](local-interaction-syntax-en.md).
4
4
 
5
- The current protocol is `component-protocol-1`, the applicable syntax is `local-draft-2`, and the current package version is `0.4.0`, the preview release on the `next` channel. These three versions represent the contribution contract, the author syntax and the npm release. Updating the protocol document does not automatically change the syntax or public API.
5
+ The current protocol is `component-protocol-2`, the applicable syntax is `local-draft-2`, and the current package version is `0.5.2`, the preview release on the `next` channel. These three versions represent the contribution contract, the author syntax and the npm release. Updating the protocol document does not automatically change the syntax or public API.
6
6
 
7
7
  ## 1. What to submit
8
8
 
@@ -121,7 +121,7 @@ Copy the following into an issue, a PR description or a standalone design docume
121
121
  | --- | --- |
122
122
  | Package version | Current value, target value and rationale |
123
123
  | Syntax revision | Current value, target value and migration impact |
124
- | Protocol revision | component-protocol-1, or describe the new revision |
124
+ | Protocol revision | component-protocol-2, or describe the new revision |
125
125
  | Name | Lowercase kebab-case; conflict check and maintainer decision |
126
126
  | Shape | leaf / inline / container |
127
127
  | Parent, direct children | Allowed scope, count, nesting and whitespace rules |
@@ -207,4 +207,4 @@ Browser checks must record the specific environment and actions. Check real keyb
207
207
  List the commands actually run and observations in the PR. State not run, failed and not applicable separately; do not treat checked boxes as verification evidence.
208
208
 
209
209
 
210
- See [local-draft-2 components and migration](local-components-v2-en.md) for new tags, colors and slot state. `0.4.0` is the preview release on the `next` channel.
210
+ See [local-draft-2 components and migration](local-components-v2-en.md) for new tags, colors and slot state. `0.5.2` is the preview release on the `next` channel.
@@ -1,6 +1,6 @@
1
1
  # Reactive MD 组块协议
2
2
 
3
- 协议修订 `component-protocol-1` · 适用语法 `local-draft-2` · 当前包版本 `0.4.0`(预览)
3
+ 协议修订 `component-protocol-2` · 适用语法 `local-draft-2` · 当前包版本 `0.5.2`(预览)
4
4
 
5
5
  Reactive MD 的组块就是语言中的组件。本协议规定组块在贡献、实现和验收中的共同契约,连接作者语法、编译器、运行时、React 参考适配器和机器验收数据。作者写文档时以[本地交互语法规范](local-interaction-syntax-ch.md)为准;宿主接入以[本地模式集成](local-integration-ch.md)为准;本文供贡献者、评审和测试使用。
6
6
 
@@ -20,9 +20,9 @@ Reactive MD 分别维护以下版本轴:
20
20
 
21
21
  | 版本轴 | 当前值 | 决定什么 |
22
22
  | --- | --- | --- |
23
- | 包版本 | `0.4.0` | npm 发布、核心与 React 入口、升级兼容规则 |
23
+ | 包版本 | `0.5.2` | npm 发布、核心与 React 入口、升级兼容规则 |
24
24
  | 语法修订 | `local-draft-2` | 作者可以写出的标签、属性和表达式 |
25
- | 协议修订 | `component-protocol-1` | 组块贡献要求、验收门槛和机器数据语义 |
25
+ | 协议修订 | `component-protocol-2` | 组块贡献要求、验收门槛和机器数据语义 |
26
26
  | 主题协议 | `reactive-md-theme-1` | 主题登记、样式变量、深浅模式与主题验收 |
27
27
 
28
28
  协议修订独立于包版本和语法版本。一个包版本只接受一个语法修订。协议修订可以在不改变作者语法的前提下提高贡献和验收要求;语法修订变化也不必自动提升协议修订。
@@ -458,7 +458,7 @@ range-slider 和 coordinate 的每个数值槽位也独占拥有绑定;范围
458
458
 
459
459
  ### CP-SEC-05 扩展信任边界(边界)
460
460
 
461
- 本语言不为可信宿主扩展代码提供沙箱。若宿主自行注册或包装组块,安全边界由宿主负责,不能把作者文档中的 `disabled`、条件显示或客户端状态当作权限控制。当前修订不提供公开的运行时注册接口;未来 SDK 需要单独定义信任模型。
461
+ 本语言不为可信宿主扩展代码提供沙箱。若宿主自行注册或包装组块,安全边界由宿主负责,不能把作者文档中的 `disabled`、条件显示或客户端状态当作权限控制。`hostComponents` 选项只为单次编译登记纯 schema 数据,不携带可执行代码。宿主 renderer 是文档沙箱之外的可信宿主代码,安全边界仍由宿主负责;更完整的 SDK 需要单独定义信任模型。
462
462
 
463
463
  ## 9. 核心与渲染器分离
464
464
 
@@ -493,7 +493,7 @@ range-slider 和 coordinate 的每个数值槽位也独占拥有绑定;范围
493
493
 
494
494
  ### CP-CORE-05 扩展接口边界(边界)
495
495
 
496
- 当前修订没有运行时可装载的组块 JSON、`registerComponent` API 或作者插件入口。`LOCAL_COMPONENTS` 是内部冻结表,公共入口不导出注册器。未来 SDK 若提供运行时注册,需要新的协议修订,并明确信任模型、版本协商、预算和验收方式。
496
+ 当前修订没有运行时可装载的组块实现、`registerComponent` API、全局注册器或作者插件入口。`LOCAL_COMPONENTS` 是内部冻结表。`hostComponents` 选项(第 14 节)只为单次编译接受纯 schema 数据;组块实现留在宿主代码中,绝不从文档内容装载。未来 SDK 若提供通用注册接口,需要新的协议修订,并明确信任模型、版本协商、预算和验收方式。
497
497
 
498
498
  ## 10. 兼容、名称治理、修订和迁移
499
499
 
@@ -563,7 +563,7 @@ range-slider 和 coordinate 的每个数值槽位也独占拥有绑定;范围
563
563
 
564
564
  ### CP-ACCEPT-02 机器验收数据(要求)
565
565
 
566
- 机器验收集的根对象只包含 `protocolVersion`、`syntaxVersion` 和非空 `cases`。前两者固定为 `component-protocol-1` 和 `local-draft-2`;包版本由 `package.json` 标识,不从这两个字段推断。
566
+ 机器验收集的根对象只包含 `protocolVersion`、`syntaxVersion` 和非空 `cases`。现有作者组块集把前两者固定为 `component-protocol-1` 和 `local-draft-2`,并作为第 14 节所述的 v1 冻结基线;包版本由 `package.json` 标识,不从这两个字段推断。
567
567
 
568
568
  每个 case 至少包含唯一字符串 `id`、组块名 `component`、源码 `source`、布尔 `ok` 和去重诊断码集合 `codes`。可选字段 `initial`、`bindingNames`、`actions`、`reset`、`text`、`expectedText`、`htmlIncludes`、`htmlExcludes` 按[语言验收数据说明](../examples/conformance/README.md)和仓库附带的 JSON Schema 使用。完整格式以该说明和 Schema 为准,本协议只规定语义门槛。
569
569
 
@@ -578,7 +578,7 @@ range-slider 和 coordinate 的每个数值槽位也独占拥有绑定;范围
578
578
 
579
579
  `initial` 和 `reset.expectedState` 做部分匹配;`bindingNames` 检查完整公开绑定名集合;`text` 与 `expectedText` 必须成对。
580
580
 
581
- 本修订的验收数据应当覆盖 `slider`、`tabs`、`plot` 的代表性用例和至少一个完整未知标签降级用例。它是代表性门槛,不是 48 个标签名的全面认证。
581
+ 冻结的作者组块集覆盖 `slider`、`tabs`、`plot` 的代表性用例和至少一个完整未知标签降级用例。它仍是代表性门槛,不是 48 个标签名的全面认证;宿主组块没有可移植机器用例。
582
582
 
583
583
  ### CP-ACCEPT-03 组件级证据(要求)
584
584
 
@@ -634,7 +634,7 @@ range-slider 和 coordinate 的每个数值槽位也独占拥有绑定;范围
634
634
 
635
635
  ### CP-IMPL-03 扩展接口(边界)
636
636
 
637
- 未来若提供 SDK,需要单独定义:
637
+ 除第 14 节的编译期 schema 和 React renderer 扩展轴外,更完整的 SDK 还需要单独定义:
638
638
 
639
639
  - 组块声明的机器格式和版本协商。
640
640
  - 宿主注册 API 的信任模型和沙箱边界。
@@ -652,7 +652,7 @@ range-slider 和 coordinate 的每个数值槽位也独占拥有绑定;范围
652
652
  | 项目 | 填写内容 |
653
653
  | --- | --- |
654
654
  | 组块名 | `<name>`(小写 kebab-case) |
655
- | 协议修订 | `component-protocol-1` |
655
+ | 协议修订 | `component-protocol-2` |
656
656
  | 用途 | 解决什么问题,读者如何使用 |
657
657
  | 非目标 | 本组块不承担的能力 |
658
658
  | 版本影响 | 包版本、语法修订、协议修订 |
@@ -700,11 +700,48 @@ range-slider 和 coordinate 的每个数值槽位也独占拥有绑定;范围
700
700
  | CP-COMPAT-01 至 05 | 兼容说明、迁移示例 | 通过/待补 |
701
701
  | CP-ACCEPT-01 至 05 | 验收矩阵和命令结果 | 通过/待补 |
702
702
 
703
- ## 14. 修订记录
703
+ ## 14. 宿主组件扩展轴
704
+
705
+ ### CP-HOST-01 宿主组件是可选扩展(现有)
706
+
707
+ `compileLocal(source, { hostComponents })` 为编译器增加一条宿主拥有的扩展轴。不传 `hostComponents` 时,作者行为不变:48 个作者标签名照常解析,集合之外的标签仍是未知标签,并按 CP-DIAG-03 降级为原文。该选项只改变本次调用识别的标签名,不增加作者语法。语法修订仍为 `local-draft-2`,协议修订变为 `component-protocol-2`。
708
+
709
+ ### CP-HOST-02 宿主 Schema 是普通数据(要求)
710
+
711
+ `LocalHostComponentSchema` 是宿主提供的普通、可结构化克隆的数据,不含函数、类实例或运行时句柄。
712
+
713
+ | 字段 | 内容 |
714
+ | --- | --- |
715
+ | `name` | 小写 kebab-case,在集合内唯一,不能是 48 个作者标签名、P0 HTML 标签名或主题声明名 `theme` |
716
+ | `form` | `'leaf'`;宿主组块没有正文 |
717
+ | `props` | 宿主属性表;属性名使用小写 kebab-case |
718
+
719
+ 每次编译最多接受 32 个宿主组块 Schema。每个属性声明 `kind`(`string`、`number`、`boolean` 或 `enum`)、`required`、`static`、`enum` 和 `pattern`。`enum` 用于 `enum` 属性,`pattern` 用于 `string` 属性。P0 HTML 标签名保留给解析器优先处理的 HTML,不得复用。`pattern` 限制在线性时间安全子集内:拒绝反向引用、环视、命名组、嵌套量词和被量词修饰的分支。非法 Schema 以 `local.options.invalid` 诊断拒绝;编译失败,该集合不会部分生效。
720
+
721
+ ### CP-HOST-03 宿主组块不是作者语法(边界)
722
+
723
+ 宿主组块不属于 `local-draft-2`,不能当作可移植的作者语法。使用它们的文档只有在登记了相同名称和兼容 Schema 的宿主中才能渲染;普通读者会把每个名称当作未知组块,按 CP-DIAG-03 的既有降级处理。作者不能假定宿主组块一定存在,面向可移植的文档不应使用它们。
724
+
725
+ ### CP-HOST-04 属性校验与预算(要求)
726
+
727
+ 编译器按登记的 Schema 校验每个宿主属性:必填属性必须存在,`enum` 值必须属于声明的集合,`pattern` 必须匹配字面字符串值,字面值必须符合声明的 `kind`,声明为 `static` 的属性拒绝 `{{ ... }}`。声明了 `pattern` 的属性,非静态值只能用恰好一个完整插值代替字面值;混合字面文本与插值会被拒绝。其他字符串属性可以混合字面文本和插值。校验失败在属性位置产生 `local.host.attribute` 诊断。
728
+
729
+ 合法宿主节点在既有语法节点预算中只计为一个语法节点;属性、props 和 leaf 形态不增加更多节点,也不改变其他预算的计算。
730
+
731
+ ### CP-HOST-05 React 分发与宿主数据(要求)
732
+
733
+ React 视图把 `hostComponent` 节点分发给 `hostRenderer(node, data, ctx)`。`data` 从 `hostData` 读取,后者是 JSON 安全的宿主数据,按节点属性中的 `${kind}:${ref}` 索引。这两个 props 都留在宿主/React 一侧:渲染函数不进入 worker,`hostData` 也不进入 worker,因为编译只需要 Schema。
734
+
735
+ 缺少渲染器、缺少 `${kind}:${ref}` 键或渲染器抛出异常时,显示可见的诊断占位,不得让异常冒出文档或使其余内容变空白。`mode === 'static'` 走同一分发路径,因此宿主未提供渲染器或数据时,静态渲染显示相同的占位。
736
+
737
+ 可移植的机器用例仍是 `examples/conformance/component-protocol-1.json`,它作为 48 个作者组块的基线保持冻结。宿主组块不提供可移植验收用例,因为渲染由宿主拥有,普通读者只能看到未知组块降级。
738
+
739
+ ## 15. 修订记录
704
740
 
705
741
  | 修订 | 日期 | 说明 |
706
742
  | --- | --- | --- |
743
+ | `component-protocol-2` | 2026-10-25 | 新增宿主组件扩展轴;作者语法仍为 `local-draft-2`。 |
707
744
  | `component-protocol-1` | 2026-10-23 | 初版;最初适用于 `local-draft-1` 和包版本 `0.3.0`,定义组块贡献、验收和扩展边界。现在适用于 `local-draft-2` 和 `0.4.0` 预览版,MUST 条款和机器格式不变。 |
708
745
 
709
746
 
710
- 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。`0.4.0` 是 `next` 渠道的预览版。
747
+ 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](release-0.4.0-ch.md)。`0.5.2` 是 `next` 渠道的预览版。
@@ -1,6 +1,6 @@
1
1
  # Reactive MD component protocol
2
2
 
3
- Protocol revision `component-protocol-1` · applicable syntax `local-draft-2` · current package version `0.4.0` (preview)
3
+ Protocol revision `component-protocol-2` · applicable syntax `local-draft-2` · current package version `0.5.2` (preview)
4
4
 
5
5
  Components are the building blocks of the Reactive MD language. This protocol defines the shared contract for contribution, implementation and acceptance, connecting author syntax, the compiler, the runtime, the React reference adapter and machine conformance data. Authors writing documents follow the [local interaction syntax specification](local-interaction-syntax-en.md); hosts integrating follow [local mode integration](local-integration-en.md); this document is for contributors, reviewers and tests.
6
6
 
@@ -20,9 +20,9 @@ Reactive MD maintains the following independent version axes:
20
20
 
21
21
  | Version axis | Current value | Determines |
22
22
  | --- | --- | --- |
23
- | Package version | `0.4.0` | npm release, core and React entries, upgrade compatibility rules |
23
+ | Package version | `0.5.2` | npm release, core and React entries, upgrade compatibility rules |
24
24
  | Syntax revision | `local-draft-2` | Tags, attributes and expressions authors can write |
25
- | Protocol revision | `component-protocol-1` | Component contribution requirements, acceptance gates and machine data semantics |
25
+ | Protocol revision | `component-protocol-2` | Component contribution requirements, acceptance gates and machine data semantics |
26
26
  | Theme protocol | `reactive-md-theme-1` | Theme registration, style variables, color schemes and theme acceptance |
27
27
 
28
28
  The protocol revision is independent of the package version and syntax version. One package version accepts only one syntax revision. A protocol revision may raise contribution and acceptance requirements without changing author syntax; a syntax revision change does not automatically require a protocol revision.
@@ -458,7 +458,7 @@ The host decides who may write, submit and share documents; limits request size,
458
458
 
459
459
  ### CP-SEC-05 Extension trust boundary (boundary)
460
460
 
461
- This language does not provide a sandbox for trusted host extension code. If the host registers or wraps components itself, the host is responsible for the security boundary; `disabled`, conditional visibility or client state in author documents must not be treated as permission control. This revision does not provide a public runtime registration interface; a future SDK would need a separately defined trust model.
461
+ This language does not provide a sandbox for trusted host extension code. If the host registers or wraps components itself, the host is responsible for the security boundary; `disabled`, conditional visibility or client state in author documents must not be treated as permission control. The `hostComponents` option registers plain schema data for one compilation only and carries no executable code. A host renderer is trusted host code outside the document sandbox, so the host remains responsible for its security boundary; a fuller SDK would need a separately defined trust model.
462
462
 
463
463
  ## 9. Core and renderer separation
464
464
 
@@ -493,7 +493,7 @@ Adding only a `schema.ts` entry does not automatically provide parsing, validati
493
493
 
494
494
  ### CP-CORE-05 Extension interface boundary (boundary)
495
495
 
496
- This revision has no runtime-loadable component JSON, `registerComponent` API or author plugin entry point. `LOCAL_COMPONENTS` is an internal frozen table, and public entries do not export a registrar. If a future SDK provides runtime registration, it needs a new protocol revision that defines the trust model, version negotiation, budgets and acceptance methods.
496
+ This revision has no runtime-loadable component implementation, `registerComponent` API, global registrar or author plugin entry point. `LOCAL_COMPONENTS` is an internal frozen table. The `hostComponents` option (section 14) accepts plain schema data for a single compile; component implementations stay in host code and are never loaded from document content. A future SDK that provides a general registration interface needs a new protocol revision that defines the trust model, version negotiation, budgets and acceptance methods.
497
497
 
498
498
  ## 10. Compatibility, name governance, revisions and migration
499
499
 
@@ -563,7 +563,7 @@ Persist only the original `.reactive.md` source and the syntax revision used. `L
563
563
 
564
564
  ### CP-ACCEPT-02 Machine conformance data (required)
565
565
 
566
- The root object of a machine conformance set contains only `protocolVersion`, `syntaxVersion` and a non-empty `cases` array. The first two are fixed to `component-protocol-1` and `local-draft-2`; the package version is identified by `package.json` and is not inferred from these fields.
566
+ The root object of a machine conformance set contains only `protocolVersion`, `syntaxVersion` and a non-empty `cases` array. The current author-component set fixes them to `component-protocol-1` and `local-draft-2`; it remains the frozen v1 baseline described in section 14. The package version is identified by `package.json` and is not inferred from these fields.
567
567
 
568
568
  Each case contains at least a unique string `id`, component name `component`, source `source`, boolean `ok` and a deduplicated diagnostic code set `codes`. Optional fields `initial`, `bindingNames`, `actions`, `reset`, `text`, `expectedText`, `htmlIncludes` and `htmlExcludes` follow the [language conformance data notes](../examples/conformance/README.md) and the JSON Schema shipped with the repository. The full format follows that document and the Schema; this protocol defines only the semantic gates.
569
569
 
@@ -578,7 +578,7 @@ The runner must:
578
578
 
579
579
  `initial` and `reset.expectedState` use partial matching; `bindingNames` checks the complete public binding name set; `text` and `expectedText` must appear in pairs.
580
580
 
581
- The conformance data of this revision should cover representative `slider`, `tabs` and `plot` cases and at least one complete unknown-tag fallback case. It is a representative gate, not full certification of the 48 tag names.
581
+ The frozen author-component set covers representative `slider`, `tabs` and `plot` cases and at least one complete unknown-tag fallback case. It remains a representative gate, not full certification of the 48 tag names; host components have no portable machine cases.
582
582
 
583
583
  ### CP-ACCEPT-03 Component-level evidence (required)
584
584
 
@@ -634,7 +634,7 @@ The current implementation covers parsing, declarations, compilation, runtime, R
634
634
 
635
635
  ### CP-IMPL-03 Extension interfaces (boundary)
636
636
 
637
- If an SDK is provided in the future, it needs a separately defined:
637
+ Beyond the compile-time schema and React renderer axis in section 14, a fuller SDK would need separately defined:
638
638
 
639
639
  - Machine format and version negotiation for component declarations.
640
640
  - Trust model and sandbox boundary for the host registration API.
@@ -652,7 +652,7 @@ The tables below are for review. See the [component development guide](component
652
652
  | Item | Content |
653
653
  | --- | --- |
654
654
  | Component name | `<name>` (lowercase kebab-case) |
655
- | Protocol revision | `component-protocol-1` |
655
+ | Protocol revision | `component-protocol-2` |
656
656
  | Purpose | What problem it solves and how readers use it |
657
657
  | Non-goals | Capabilities this component does not take on |
658
658
  | Version impact | Package version, syntax revision, protocol revision |
@@ -700,11 +700,48 @@ The tables below are for review. See the [component development guide](component
700
700
  | CP-COMPAT-01 to 05 | Compatibility notes, migration examples | Pass/outstanding |
701
701
  | CP-ACCEPT-01 to 05 | Acceptance matrix and command results | Pass/outstanding |
702
702
 
703
- ## 14. Revision history
703
+ ## 14. Host component extension axis
704
+
705
+ ### CP-HOST-01 Host components are opt-in (existing)
706
+
707
+ `compileLocal(source, { hostComponents })` adds a host-owned extension axis to the compiler. Without the `hostComponents` option, author behavior is unchanged: the 48 author tag names parse as before, and a tag outside that set remains unknown and falls back to source under CP-DIAG-03. The option changes only which tag names the compiler recognizes for that call; it does not add author syntax. The syntax revision remains `local-draft-2`; the protocol revision becomes `component-protocol-2`.
708
+
709
+ ### CP-HOST-02 Host schemas are plain data (required)
710
+
711
+ `LocalHostComponentSchema` is plain, structured-clone-safe data supplied by the host. It contains no functions, class instances or runtime handles.
712
+
713
+ | Field | Content |
714
+ | --- | --- |
715
+ | `name` | Lowercase kebab-case, unique within the set, not one of the 48 author tag names, a P0 HTML tag name or the theme declaration name |
716
+ | `form` | `'leaf'`; host components have no body |
717
+ | `props` | A table of host properties; property names use lowercase kebab-case |
718
+
719
+ One compilation accepts at most 32 host component schemas. Each property declares `kind` (`string`, `number`, `boolean` or `enum`), `required`, `static`, `enum` and `pattern`. `enum` applies to `enum` properties, and `pattern` applies to `string` properties. P0 HTML tag names are reserved because the parser handles them before component tags. `pattern` is restricted to a linear-time-safe subset: backreferences, lookarounds, named groups, nested quantifiers and quantified alternation are rejected. Invalid schemas are rejected with a `local.options.invalid` diagnostic; compilation fails and no host component from that set is partially registered.
720
+
721
+ ### CP-HOST-03 Host components are not author syntax (boundary)
722
+
723
+ Host components are not part of `local-draft-2` and cannot be used as portable author syntax. A document that uses them is portable only with a host that registers the same names and compatible schemas; a plain reader treats each name as an unknown component and applies the existing fallback in CP-DIAG-03. Authors cannot rely on host components being present, so documents intended to be portable must not use them.
724
+
725
+ ### CP-HOST-04 Attribute validation and budget (required)
726
+
727
+ The compiler validates every host attribute against the registered schema: required properties must be present, `enum` values must belong to the declared set, `pattern` must match literal string values, literal values must match the declared `kind`, and a property declared `static` rejects `{{ ... }}`. For a property with a `pattern`, a non-static value may be exactly one full interpolation in place of the literal; mixed literal text with interpolation is rejected. Other string properties may mix literals and interpolations. Failures produce a `local.host.attribute` diagnostic at the attribute location.
728
+
729
+ A valid host node counts as exactly one syntax node in the existing syntax-node budget; its attributes, props and leaf form add no further nodes and do not change other budget accounting.
730
+
731
+ ### CP-HOST-05 React dispatch and host-owned data (required)
732
+
733
+ The React view dispatches a `hostComponent` node to `hostRenderer(node, data, ctx)`. `data` is read from `hostData`, JSON-safe host data indexed by `${kind}:${ref}` from the node attributes. Both props stay on the host/React side: the renderer function never enters a worker, and `hostData` never enters the worker either, because compilation needs only the schemas.
734
+
735
+ A missing renderer, a missing `${kind}:${ref}` key or a renderer that throws renders a visible diagnostic placeholder. It must not throw out of the document or blank the rest of the content. `mode === 'static'` goes through the same dispatch, so static rendering shows the same placeholder when the host has not supplied a renderer or data.
736
+
737
+ Portable machine cases remain `examples/conformance/component-protocol-1.json`, frozen as the baseline for the 48 author components. Host components get no portable conformance cases, because rendering is host-owned and a plain reader only sees the unknown-component fallback.
738
+
739
+ ## 15. Revision history
704
740
 
705
741
  | Revision | Date | Notes |
706
742
  | --- | --- | --- |
743
+ | `component-protocol-2` | 2026-10-25 | Added the host component extension axis; author syntax remains `local-draft-2`. |
707
744
  | `component-protocol-1` | 2026-10-23 | Initial version; originally applied to `local-draft-1` and package version `0.3.0`, defining component contribution, acceptance and extension boundaries. It now applies to `local-draft-2` and the `0.4.0` preview release without changing its MUST clauses or machine format. |
708
745
 
709
746
 
710
- 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 the preview release on the `next` channel.
747
+ 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.5.2` is the preview release on the `next` channel.