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,138 +1,138 @@
1
- # 新增组块与迁移:local-draft-2
2
-
3
- 本页说明 `0.4.0` 的新增组块与 `local-draft-2` 语法。它是[本地交互语法规范](local-interaction-syntax-ch.md)的补充。贡献与验收继续使用 `component-protocol-1`,机器格式保持不变。
4
-
5
- ## 跳转与正文颜色
6
-
7
- ```markdown
8
- <jump to="result" appearance="button" color="#2563eb">查看结果</jump>
9
-
10
- <section color="#45536f">
11
- 普通正文,<text color="#a2273a">**重点提醒**</text>。
12
-
13
- 第二段继承外层颜色,支持 {{ count }} 等插值。
14
- </section>
15
-
16
- <anchor id="result">
17
-
18
- ## 结果
19
-
20
- 结果显示在这里。
21
- ```
22
-
23
- 本例中的 `count` 需由一个控件声明,例如 `<counter bind="count" label="数量">`。
24
-
25
- | 组块 | 形态 | 属性与规则 |
26
- | --- | --- | --- |
27
- | jump | 行内、成对标签 | `to` 必填,为静态文档内目标名;`appearance=link/button`,默认 link;可选 color;正文为行内 Markdown |
28
- | anchor | 无正文标签 | `id` 必填,匹配 `[A-Za-z_][A-Za-z0-9_-]*`,当前文档内唯一 |
29
- | text | 行内、成对标签 | color 必填,正文为行内 Markdown 与插值 |
30
- | section | 块容器、成对标签 | color 必填,内部继续解析 Markdown;不添加边框和背景 |
31
-
32
- jump 可以指向自动生成的标题锚点或显式 anchor,不写前导 `#`。普通 Markdown 链接仍使用 `[结果](#result)`。实际 DOM ID 按文档实例隔离;显式 ID 与标题锚点冲突、跳转目标不存在时编译失败。点击后滚动并移动焦点,隐藏目标显示局部提示,保留读者已填写的参数。
33
-
34
- color 是静态颜色名或 `#RGB`、`#RRGGBB`。它不接受表达式、CSS 函数、变量或声明。颜色名由共享校验表限定;无效值给出编译诊断。text/section 的 color 控制文字,内层显式颜色覆盖继承;链接和交互控件保留自身配色。jump/badge 使用文字或强调色;progress 使用填充色;slider、toggle、checkbox、select、choices、radio-group、checklist 以及新输入组块使用激活色。省略时沿用主题。tone 的语义保持不变。
35
-
36
- ## 待办与多选
37
-
38
- checklist 继续接受原有 Markdown 任务列表。勾选后仅该项正文加删除线并变淡,取消勾选后恢复;初始 `[x]` 也呈现完成样式。绑定、隐藏与面板重置保持原有规则。
39
-
40
- ```markdown
41
- <multi-select bind="subjects" label="主题" max-selected="2" initial="math">
42
- <option value="math">数学</option>
43
- <option value="physics">物理</option>
44
- <option value="chemistry">化学</option>
45
- </multi-select>
46
-
47
- 已选择 {{ len(subjects) }} 项。
48
- ```
49
-
50
- multi-select 是有正文容器,只接受 option 子项,label 必填;bind 可省略。公开值为按源码顺序排列的字符串数组,默认空数组;initial 为逗号分隔的静态 value。value 非空、唯一,且不含逗号。max-selected 为非负整数,默认选项数。组件内置搜索、清空,达到上限仍可取消已选项;disabled 可以使用布尔表达式。该绑定为独占 family,保留已有数组大小和字符串预算。
51
-
52
- ## 区间与二维坐标
53
-
54
- ```markdown
55
- <range-slider label="观察区间" bind-start="low" bind-end="high"
56
- initial-start="20" initial-end="80" min="0" max="100" step="1">
57
-
58
- 区间宽度:{{ high - low }}。
59
-
60
- <coordinate label="坐标点" bind-x="px" bind-y="py"
61
- initial-x="1" initial-y="2"
62
- x-min="-5" x-max="5" y-min="-5" y-max="5" step="1">
63
-
64
- 坐标:({{ px }}, {{ py }})。
65
- ```
66
-
67
- 这两个组块均为无正文标签,label 必填,支持 color 与动态 disabled。范围和步长都是静态有限数,step 必须为正。
68
-
69
- - range-slider 默认 min=0、max=100、step=1;起点默认 min,终点默认不超过 max 的最大合法步长值。始终满足起点不大于终点,交叉写入被拒绝,不交换端点。
70
- - coordinate 默认两个轴范围均为 -5 到 5,step=1;各轴初值取最接近零的合法值。支持拖动、键盘和数值输入,指针输入吸附到合法步长。
71
- - 每个绑定名独立可选,省略时仍有内部状态;首版各槽位独占拥有绑定,不能与其他控件共享。`x`、`y` 仍是保留名,示例使用 px、py。
72
- - 所有槽位在编译时初始化;多值写入和重置均为原子更新,拒绝写入时状态与 revision 保持不变。
73
-
74
- 宿主 API 扩展:`runtime.get(node, slot?)`、`runtime.set(node, value, slot?)` 保留原调用方式,新增 `runtime.setMany(node, values)`。range-slider 的 slot 为 start/end,coordinate 为 x/y;setMany 使用 slot 名作为对象键。运行时根据已登记的节点和槽位校验,调用方提供的伪造属性不改变权限或约束。
75
-
76
- ## 练习与分步阅读
77
-
78
- ```markdown
79
- <quiz type="choice" label="2 + 3 等于多少?" answer="b" explanation="相加得到 5。">
80
- <option value="a">4</option>
81
- <option value="b">5</option>
82
- </quiz>
83
-
84
- <quiz type="number" label="圆周率近似值" answer="3.14" tolerance="0.01">
85
- </quiz>
86
-
87
- <steps label="学习路线" bind="lesson">
88
- <step label="观察" value="observe">
89
- 调整参数,观察结果。
90
- </step>
91
- <step label="练习" value="practice">
92
- 检查一道练习题。
93
- </step>
94
- </steps>
95
- ```
96
-
97
- quiz 的 type 默认 choice,label/answer 必填;choice 接受 option,answer 必须是现有 value。number 的正文为空,answer 为有限数,tolerance 默认为 0 且非负。explanation 可选,可含文本插值。组件内置检查答案、反馈与重试,首版不公开 bind;答案随源码提供,适合自学练习。隐藏后保留草稿与反馈,面板重置清除它们。
98
-
99
- steps 只接受一个或多个 step。steps.label 可选,bind 可选且独占;initial 默认第一步 value。step.label 必填,value 可省略,按顺序生成 step-1、step-2 等,同组唯一。组件提供上一步、下一步和当前位置;仅当前内容显示,所有子控件仍参与编译和初始化。切换保留内容状态,隐藏计时器暂停;面板重置恢复初始步骤和子内容。
100
-
101
- ## 表格与图表选择
102
-
103
- ```markdown
104
- <table bind="project" key="项目" initial="内容">
105
- | 项目 | 费用 |
106
- | --- | ---: |
107
- | 内容 | 120 |
108
- | 视觉 | 230 |
109
- </table>
110
-
111
- <chart bind="project" key="项目">
112
- | 项目 | 费用 |
113
- | --- | ---: |
114
- | 内容 | 120 |
115
- | 视觉 | 230 |
116
- </chart>
117
-
118
- 当前项目:{{ project }}。
119
- ```
120
-
121
- key 指定静态标识列,值必须非空、唯一且没有插值。提供 key 才启用选择状态,bind/initial 要求同时提供 key。默认空字符串表示未选;显式 initial 必须是现有标识。表格和图表可以共享 selection family,前提是标识集合与顺序一致,且最多一处显式 initial。
122
-
123
- 点击或键盘选择写入稳定标识,排序、搜索、分页和隐藏图例都保留选择。表格搜索仍只影响该表。省略 key 的旧文档保持原行为,不增加隐含绑定。
124
-
125
- ## 兼容、迁移与验收
126
-
127
- local-draft-1 中已支持的写法继续有效。本扩展引入 10 个新组块名:jump、anchor、text、section、multi-select、range-slider、coordinate、quiz、steps、step。同一版本还增加声明标签 computed、const、validation 和结构标签 data-table、column,`local-draft-2` 的完整集合为 48 个标签名;开头的 `<theme>` 声明是元数据,不计入组块。新名称以前会作为未知源码惰性显示,现在开始解释其中的受支持内容;若原文用于演示标签,放进代码围栏或行内代码。checklist 的完成样式是可见变化。
128
-
129
- 机器验收沿用 component-protocol-1 的格式,syntaxVersion 更新为 local-draft-2;旧 local-draft-1.json 留作历史数据,新构建运行 local-draft-2.json。新组件另有核心、渲染和可视化用例。错误仍使用带源码位置的 Diagnostic,未知标签、脚注、安全与资源预算保持已有契约。同一版本还新增表达式函数保留名;完整重命名清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
130
-
131
- | 协议条款 | 实现与证据入口 |
132
- | --- | --- |
133
- | CP-SYNTAX、CP-DIAG、CP-SEC | parser/schema/compiler/colors;local-v2-core 与 local-v2-acceptance 测试 |
134
- | CP-STATE、CP-LIFE、CP-VIS | runtime 的规范槽位、数组校验、原子写入与重置;核心测试、浏览器检查 |
135
- | CP-A11Y、CP-STYLE | LocalDocumentView、visuals 及相应样式;SSR 与浏览器检查 |
136
- | CP-CORE、CP-COMPAT、CP-ACCEPT | 独立 core/React 构建、机器验收、打包和本页迁移说明 |
137
-
138
- 双语可运行示例分布在[六个场景](../../examples/local/showcase/README.md):函数场景包含区间、坐标与数值题;表单场景包含多选;统计场景包含表格与图表选择联动;布局场景包含跳转与正文颜色;流程场景包含分步阅读与选择题;清单场景包含待办与计时。自动检查命令为 `npm test`、`npm run test:components`、`npm run build:demo`、`npm run test:docs`;浏览器检查和完整发布门禁使用 `npm run verify:release`,见[贡献指南](../../CONTRIBUTING-ch.md)。实际结果以该门禁的执行记录为准,不要沿用旧脚本名。
1
+ # 新增组块与迁移:local-draft-2
2
+
3
+ 本页说明 `0.4.0` 的新增组块与 `local-draft-2` 语法。它是[本地交互语法规范](local-interaction-syntax-ch.md)的补充。贡献与验收继续使用 `component-protocol-1`,机器格式保持不变。
4
+
5
+ ## 跳转与正文颜色
6
+
7
+ ```markdown
8
+ <jump to="result" appearance="button" color="#2563eb">查看结果</jump>
9
+
10
+ <section color="#45536f">
11
+ 普通正文,<text color="#a2273a">**重点提醒**</text>。
12
+
13
+ 第二段继承外层颜色,支持 {{ count }} 等插值。
14
+ </section>
15
+
16
+ <anchor id="result">
17
+
18
+ ## 结果
19
+
20
+ 结果显示在这里。
21
+ ```
22
+
23
+ 本例中的 `count` 需由一个控件声明,例如 `<counter bind="count" label="数量">`。
24
+
25
+ | 组块 | 形态 | 属性与规则 |
26
+ | --- | --- | --- |
27
+ | jump | 行内、成对标签 | `to` 必填,为静态文档内目标名;`appearance=link/button`,默认 link;可选 color;正文为行内 Markdown |
28
+ | anchor | 无正文标签 | `id` 必填,匹配 `[A-Za-z_][A-Za-z0-9_-]*`,当前文档内唯一 |
29
+ | text | 行内、成对标签 | color 必填,正文为行内 Markdown 与插值 |
30
+ | section | 块容器、成对标签 | color 必填,内部继续解析 Markdown;不添加边框和背景 |
31
+
32
+ jump 可以指向自动生成的标题锚点或显式 anchor,不写前导 `#`。普通 Markdown 链接仍使用 `[结果](#result)`。实际 DOM ID 按文档实例隔离;显式 ID 与标题锚点冲突、跳转目标不存在时编译失败。点击后滚动并移动焦点,隐藏目标显示局部提示,保留读者已填写的参数。
33
+
34
+ color 是静态颜色名或 `#RGB`、`#RRGGBB`。它不接受表达式、CSS 函数、变量或声明。颜色名由共享校验表限定;无效值给出编译诊断。text/section 的 color 控制文字,内层显式颜色覆盖继承;链接和交互控件保留自身配色。jump/badge 使用文字或强调色;progress 使用填充色;slider、toggle、checkbox、select、choices、radio-group、checklist 以及新输入组块使用激活色。省略时沿用主题。tone 的语义保持不变。
35
+
36
+ ## 待办与多选
37
+
38
+ checklist 继续接受原有 Markdown 任务列表。勾选后仅该项正文加删除线并变淡,取消勾选后恢复;初始 `[x]` 也呈现完成样式。绑定、隐藏与面板重置保持原有规则。
39
+
40
+ ```markdown
41
+ <multi-select bind="subjects" label="主题" max-selected="2" initial="math">
42
+ <option value="math">数学</option>
43
+ <option value="physics">物理</option>
44
+ <option value="chemistry">化学</option>
45
+ </multi-select>
46
+
47
+ 已选择 {{ len(subjects) }} 项。
48
+ ```
49
+
50
+ multi-select 是有正文容器,只接受 option 子项,label 必填;bind 可省略。公开值为按源码顺序排列的字符串数组,默认空数组;initial 为逗号分隔的静态 value。value 非空、唯一,且不含逗号。max-selected 为非负整数,默认选项数。组件内置搜索、清空,达到上限仍可取消已选项;disabled 可以使用布尔表达式。该绑定为独占 family,保留已有数组大小和字符串预算。
51
+
52
+ ## 区间与二维坐标
53
+
54
+ ```markdown
55
+ <range-slider label="观察区间" bind-start="low" bind-end="high"
56
+ initial-start="20" initial-end="80" min="0" max="100" step="1">
57
+
58
+ 区间宽度:{{ high - low }}。
59
+
60
+ <coordinate label="坐标点" bind-x="px" bind-y="py"
61
+ initial-x="1" initial-y="2"
62
+ x-min="-5" x-max="5" y-min="-5" y-max="5" step="1">
63
+
64
+ 坐标:({{ px }}, {{ py }})。
65
+ ```
66
+
67
+ 这两个组块均为无正文标签,label 必填,支持 color 与动态 disabled。范围和步长都是静态有限数,step 必须为正。
68
+
69
+ - range-slider 默认 min=0、max=100、step=1;起点默认 min,终点默认不超过 max 的最大合法步长值。始终满足起点不大于终点,交叉写入被拒绝,不交换端点。
70
+ - coordinate 默认两个轴范围均为 -5 到 5,step=1;各轴初值取最接近零的合法值。支持拖动、键盘和数值输入,指针输入吸附到合法步长。
71
+ - 每个绑定名独立可选,省略时仍有内部状态;首版各槽位独占拥有绑定,不能与其他控件共享。`x`、`y` 仍是保留名,示例使用 px、py。
72
+ - 所有槽位在编译时初始化;多值写入和重置均为原子更新,拒绝写入时状态与 revision 保持不变。
73
+
74
+ 宿主 API 扩展:`runtime.get(node, slot?)`、`runtime.set(node, value, slot?)` 保留原调用方式,新增 `runtime.setMany(node, values)`。range-slider 的 slot 为 start/end,coordinate 为 x/y;setMany 使用 slot 名作为对象键。运行时根据已登记的节点和槽位校验,调用方提供的伪造属性不改变权限或约束。
75
+
76
+ ## 练习与分步阅读
77
+
78
+ ```markdown
79
+ <quiz type="choice" label="2 + 3 等于多少?" answer="b" explanation="相加得到 5。">
80
+ <option value="a">4</option>
81
+ <option value="b">5</option>
82
+ </quiz>
83
+
84
+ <quiz type="number" label="圆周率近似值" answer="3.14" tolerance="0.01">
85
+ </quiz>
86
+
87
+ <steps label="学习路线" bind="lesson">
88
+ <step label="观察" value="observe">
89
+ 调整参数,观察结果。
90
+ </step>
91
+ <step label="练习" value="practice">
92
+ 检查一道练习题。
93
+ </step>
94
+ </steps>
95
+ ```
96
+
97
+ quiz 的 type 默认 choice,label/answer 必填;choice 接受 option,answer 必须是现有 value。number 的正文为空,answer 为有限数,tolerance 默认为 0 且非负。explanation 可选,可含文本插值。组件内置检查答案、反馈与重试,首版不公开 bind;答案随源码提供,适合自学练习。隐藏后保留草稿与反馈,面板重置清除它们。
98
+
99
+ steps 只接受一个或多个 step。steps.label 可选,bind 可选且独占;initial 默认第一步 value。step.label 必填,value 可省略,按顺序生成 step-1、step-2 等,同组唯一。组件提供上一步、下一步和当前位置;仅当前内容显示,所有子控件仍参与编译和初始化。切换保留内容状态,隐藏计时器暂停;面板重置恢复初始步骤和子内容。
100
+
101
+ ## 表格与图表选择
102
+
103
+ ```markdown
104
+ <table bind="project" key="项目" initial="内容">
105
+ | 项目 | 费用 |
106
+ | --- | ---: |
107
+ | 内容 | 120 |
108
+ | 视觉 | 230 |
109
+ </table>
110
+
111
+ <chart bind="project" key="项目">
112
+ | 项目 | 费用 |
113
+ | --- | ---: |
114
+ | 内容 | 120 |
115
+ | 视觉 | 230 |
116
+ </chart>
117
+
118
+ 当前项目:{{ project }}。
119
+ ```
120
+
121
+ key 指定静态标识列,值必须非空、唯一且没有插值。提供 key 才启用选择状态,bind/initial 要求同时提供 key。默认空字符串表示未选;显式 initial 必须是现有标识。表格和图表可以共享 selection family,前提是标识集合与顺序一致,且最多一处显式 initial。
122
+
123
+ 点击或键盘选择写入稳定标识,排序、搜索、分页和隐藏图例都保留选择。表格搜索仍只影响该表。省略 key 的旧文档保持原行为,不增加隐含绑定。
124
+
125
+ ## 兼容、迁移与验收
126
+
127
+ local-draft-1 中已支持的写法继续有效。本扩展引入 10 个新组块名:jump、anchor、text、section、multi-select、range-slider、coordinate、quiz、steps、step。同一版本还增加声明标签 computed、const、validation 和结构标签 data-table、column,`local-draft-2` 的完整集合为 48 个标签名;开头的 `<theme>` 声明是元数据,不计入组块。新名称以前会作为未知源码惰性显示,现在开始解释其中的受支持内容;若原文用于演示标签,放进代码围栏或行内代码。checklist 的完成样式是可见变化。
128
+
129
+ 机器验收沿用 component-protocol-1 的格式,syntaxVersion 更新为 local-draft-2;旧 local-draft-1.json 留作历史数据,新构建运行 local-draft-2.json。新组件另有核心、渲染和可视化用例。错误仍使用带源码位置的 Diagnostic,未知标签、脚注、安全与资源预算保持已有契约。同一版本还新增表达式函数保留名;完整重命名清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
130
+
131
+ | 协议条款 | 实现与证据入口 |
132
+ | --- | --- |
133
+ | CP-SYNTAX、CP-DIAG、CP-SEC | parser/schema/compiler/colors;local-v2-core 与 local-v2-acceptance 测试 |
134
+ | CP-STATE、CP-LIFE、CP-VIS | runtime 的规范槽位、数组校验、原子写入与重置;核心测试、浏览器检查 |
135
+ | CP-A11Y、CP-STYLE | LocalDocumentView、visuals 及相应样式;SSR 与浏览器检查 |
136
+ | CP-CORE、CP-COMPAT、CP-ACCEPT | 独立 core/React 构建、机器验收、打包和本页迁移说明 |
137
+
138
+ 双语可运行示例分布在[六个场景](../../examples/local/showcase/README.md):函数场景包含区间、坐标与数值题;表单场景包含多选;统计场景包含表格与图表选择联动;布局场景包含跳转与正文颜色;流程场景包含分步阅读与选择题;清单场景包含待办与计时。自动检查命令为 `npm test`、`npm run test:components`、`npm run build:demo`、`npm run test:docs`;浏览器检查和完整发布门禁使用 `npm run verify:release`,见[贡献指南](../../CONTRIBUTING-ch.md)。实际结果以该门禁的执行记录为准,不要沿用旧脚本名。
@@ -1,104 +1,104 @@
1
- # New components and migration: local-draft-2
2
-
3
- This page describes the new components in `0.4.0` and the `local-draft-2` syntax. It supplements the [syntax reference](local-interaction-syntax-en.md). The contribution protocol remains component-protocol-1; its portable fixture format is unchanged.
4
-
5
- ## Navigation and text color
6
-
7
- ```markdown
8
- <jump to="result" appearance="button" color="#2563eb">View results</jump>
9
-
10
- <section color="#45536f">
11
- Ordinary prose with <text color="#a2273a">**an important reminder**</text>.
12
-
13
- Another paragraph inherits the section color.
14
- </section>
15
-
16
- <anchor id="result">
17
-
18
- ## Results
19
- ```
20
-
21
- jump and text are paired inline components with inline Markdown children. section is a paired block container with no extra border or background. anchor is a leaf. jump.to is a static heading slug or explicit anchor ID without a leading #. appearance is link (default) or button. Explicit IDs match `[A-Za-z_][A-Za-z0-9_-]*`; duplicates, heading collisions and missing targets are compile errors. DOM IDs are namespaced per rendered document. Jumps scroll and move focus; hidden targets show local feedback. Existing Markdown fragment links also resolve explicit anchors.
22
-
23
- text/section require color. Other supported components accept an optional color: jump, badge, progress, slider, toggle, checkbox, select, choices, radio-group, checklist, multi-select, range-slider and coordinate. Static named colors from the shared table and #RGB/#RRGGBB are accepted. Expressions, CSS functions, variables and declarations are rejected. Text containers set foreground color; inner values override inheritance. Links and controls keep their own appearance. Other components use color for their accent, selected state or progress fill; tone keeps its semantic meaning. Omitted values use the theme.
24
-
25
- ## Todo lists and multiple selection
26
-
27
- Existing checklist syntax is unchanged. Checked item text is struck through and muted, including initial `[x]` items; unchecking restores it. Only the checked item changes.
28
-
29
- ```markdown
30
- <multi-select bind="subjects" label="Subjects" max-selected="2" initial="math">
31
- <option value="math">Math</option>
32
- <option value="physics">Physics</option>
33
- </multi-select>
34
- ```
35
-
36
- multi-select requires a label and one or more option children; bind is optional. Its exclusive string-array binding defaults to empty. initial is a comma-separated list of static values; values must be nonempty, unique and comma-free. max-selected is a nonnegative integer, defaulting to the option count. Writes normalize to source order and obey existing array budgets. Search and Clear are built in. Selected items remain removable at the limit. disabled may be dynamic; reset clears local search and restores initial selection, while hiding preserves them.
37
-
38
- ## Range and coordinate inputs
39
-
40
- ```markdown
41
- <range-slider label="Interval" bind-start="low" bind-end="high"
42
- initial-start="20" initial-end="80" min="0" max="100" step="1">
43
-
44
- <coordinate label="Point" bind-x="px" bind-y="py"
45
- initial-x="1" initial-y="2"
46
- x-min="-5" x-max="5" y-min="-5" y-max="5" step="1">
47
- ```
48
-
49
- Both are leaves with required label, optional color and dynamic disabled. Bounds and positive step are static finite numbers. range-slider defaults to 0/100/1, with start=min and end=the largest valid step not exceeding max. Crossing is rejected rather than swapping endpoints. coordinate defaults to -5…5 on both axes, step 1, and the nearest legal zero per axis. It supports pointer dragging, keyboard control and numeric alternatives.
50
-
51
- Each optional bind names one exclusive numeric slot; omitted names use internal state. x/y remain reserved parameter names. Slots initialize at compile time and reset atomically. Host APIs extend to `runtime.get(node, slot?)`, `runtime.set(node, value, slot?)` and `runtime.setMany(node, values)`. Slots are start/end for ranges and x/y for coordinates. Every write validates canonical registered slots; invalid batches preserve the entire snapshot and revision. Existing one-value calls remain valid.
52
-
53
- ## Questions and guided reading
54
-
55
- ```markdown
56
- <quiz type="choice" label="What is 2 + 3?" answer="b" explanation="The sum is 5.">
57
- <option value="a">4</option>
58
- <option value="b">5</option>
59
- </quiz>
60
-
61
- <quiz type="number" label="Approximate pi" answer="3.14" tolerance="0.01">
62
- </quiz>
63
-
64
- <steps label="Learning path" bind="lesson">
65
- <step label="Observe" value="observe">
66
- Change a parameter.
67
- </step>
68
- <step label="Practice" value="practice">
69
- Check an answer.
70
- </step>
71
- </steps>
72
- ```
73
-
74
- quiz requires label/answer. type defaults to choice, with option children and a matching answer. Numeric quizzes have an empty body, finite answer and nonnegative absolute tolerance (default 0). explanation is optional and supports text interpolation. Check answer, feedback and Try again are built in. Draft and feedback stay internal; this revision has no quiz bind. Hiding preserves them and panel reset clears them. Answers are supplied in source for self-study.
75
-
76
- steps accepts one or more step children, optional label and exclusive string bind. initial defaults to the first step. Each step requires label; omitted values become step-1, step-2 and so on. Values are unique within a group. Previous/Next and position are built in. Only active content is visible; all bindings still initialize, state persists between steps, and hidden timers pause. Reset restores the initial step and its subtree.
77
-
78
- ## Table and chart selection
79
-
80
- ```markdown
81
- <table bind="project" key="Project" initial="Content">
82
- | Project | Cost |
83
- | --- | ---: |
84
- | Content | 120 |
85
- | Visual | 230 |
86
- </table>
87
-
88
- <chart bind="project" key="Project">
89
- | Project | Cost |
90
- | --- | ---: |
91
- | Content | 120 |
92
- | Visual | 230 |
93
- </chart>
94
- ```
95
-
96
- key names a column of static, nonempty, unique text identifiers. Selection is enabled only when key is present; bind/initial require key. Empty string means no selection by default. Explicit initial must match a row. Table/chart can share a selection binding only with identical ordered keys and at most one explicit initial. Mouse or keyboard selection writes row identity. Sorting, searching, pagination and hidden legends preserve selection; table filters still affect only that table. Existing components without key gain no implicit binding.
97
-
98
- ## Compatibility and acceptance
99
-
100
- Previously supported local-draft-1 source remains valid. Ten new names arrive with this extension: jump, anchor, text, section, multi-select, range-slider, coordinate, quiz, steps and step. The same release also adds the declaration tags computed, const and validation and the structural tags data-table and column, for 48 tag names in the complete `local-draft-2` set; the leading `<theme>` declaration is metadata, not a component. Old builds displayed these unknown regions as inert source; this build interprets their supported content. Put literal examples inside code spans or fences. Checklist completion appearance changes visibly.
101
-
102
- Portable fixture syntaxVersion advances to local-draft-2; component-protocol-1 and its data format stay unchanged. local-draft-1.json is retained as historical data. New tests cover compiler/runtime, SSR rendering and visual selection. Canonical state, atomic rejection/reset, instance isolation, hidden-state retention, positioned diagnostics, existing resource budgets and the core/React boundary follow the component protocol. The same release also reserves new expression function names; see [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the full rename list.
103
-
104
- Run `npm test`, `npm run test:components`, `npm run build:demo` and `npm run test:docs`. Browser checks and the complete release gate use `npm run verify:release`; see the [contributing guide](../../CONTRIBUTING.md). Record actual run results with the gate rather than copying an old script name. The bilingual [six scenarios](../../examples/local/showcase/README.md) cover all components: ranges, coordinates and numeric questions in Functions; multiple selection in Forms; linked selection in Data; jumps and prose colors in Layout; steps and choice questions in Flow; todos and timing in Checklists.
1
+ # New components and migration: local-draft-2
2
+
3
+ This page describes the new components in `0.4.0` and the `local-draft-2` syntax. It supplements the [syntax reference](local-interaction-syntax-en.md). The contribution protocol remains component-protocol-1; its portable fixture format is unchanged.
4
+
5
+ ## Navigation and text color
6
+
7
+ ```markdown
8
+ <jump to="result" appearance="button" color="#2563eb">View results</jump>
9
+
10
+ <section color="#45536f">
11
+ Ordinary prose with <text color="#a2273a">**an important reminder**</text>.
12
+
13
+ Another paragraph inherits the section color.
14
+ </section>
15
+
16
+ <anchor id="result">
17
+
18
+ ## Results
19
+ ```
20
+
21
+ jump and text are paired inline components with inline Markdown children. section is a paired block container with no extra border or background. anchor is a leaf. jump.to is a static heading slug or explicit anchor ID without a leading #. appearance is link (default) or button. Explicit IDs match `[A-Za-z_][A-Za-z0-9_-]*`; duplicates, heading collisions and missing targets are compile errors. DOM IDs are namespaced per rendered document. Jumps scroll and move focus; hidden targets show local feedback. Existing Markdown fragment links also resolve explicit anchors.
22
+
23
+ text/section require color. Other supported components accept an optional color: jump, badge, progress, slider, toggle, checkbox, select, choices, radio-group, checklist, multi-select, range-slider and coordinate. Static named colors from the shared table and #RGB/#RRGGBB are accepted. Expressions, CSS functions, variables and declarations are rejected. Text containers set foreground color; inner values override inheritance. Links and controls keep their own appearance. Other components use color for their accent, selected state or progress fill; tone keeps its semantic meaning. Omitted values use the theme.
24
+
25
+ ## Todo lists and multiple selection
26
+
27
+ Existing checklist syntax is unchanged. Checked item text is struck through and muted, including initial `[x]` items; unchecking restores it. Only the checked item changes.
28
+
29
+ ```markdown
30
+ <multi-select bind="subjects" label="Subjects" max-selected="2" initial="math">
31
+ <option value="math">Math</option>
32
+ <option value="physics">Physics</option>
33
+ </multi-select>
34
+ ```
35
+
36
+ multi-select requires a label and one or more option children; bind is optional. Its exclusive string-array binding defaults to empty. initial is a comma-separated list of static values; values must be nonempty, unique and comma-free. max-selected is a nonnegative integer, defaulting to the option count. Writes normalize to source order and obey existing array budgets. Search and Clear are built in. Selected items remain removable at the limit. disabled may be dynamic; reset clears local search and restores initial selection, while hiding preserves them.
37
+
38
+ ## Range and coordinate inputs
39
+
40
+ ```markdown
41
+ <range-slider label="Interval" bind-start="low" bind-end="high"
42
+ initial-start="20" initial-end="80" min="0" max="100" step="1">
43
+
44
+ <coordinate label="Point" bind-x="px" bind-y="py"
45
+ initial-x="1" initial-y="2"
46
+ x-min="-5" x-max="5" y-min="-5" y-max="5" step="1">
47
+ ```
48
+
49
+ Both are leaves with required label, optional color and dynamic disabled. Bounds and positive step are static finite numbers. range-slider defaults to 0/100/1, with start=min and end=the largest valid step not exceeding max. Crossing is rejected rather than swapping endpoints. coordinate defaults to -5…5 on both axes, step 1, and the nearest legal zero per axis. It supports pointer dragging, keyboard control and numeric alternatives.
50
+
51
+ Each optional bind names one exclusive numeric slot; omitted names use internal state. x/y remain reserved parameter names. Slots initialize at compile time and reset atomically. Host APIs extend to `runtime.get(node, slot?)`, `runtime.set(node, value, slot?)` and `runtime.setMany(node, values)`. Slots are start/end for ranges and x/y for coordinates. Every write validates canonical registered slots; invalid batches preserve the entire snapshot and revision. Existing one-value calls remain valid.
52
+
53
+ ## Questions and guided reading
54
+
55
+ ```markdown
56
+ <quiz type="choice" label="What is 2 + 3?" answer="b" explanation="The sum is 5.">
57
+ <option value="a">4</option>
58
+ <option value="b">5</option>
59
+ </quiz>
60
+
61
+ <quiz type="number" label="Approximate pi" answer="3.14" tolerance="0.01">
62
+ </quiz>
63
+
64
+ <steps label="Learning path" bind="lesson">
65
+ <step label="Observe" value="observe">
66
+ Change a parameter.
67
+ </step>
68
+ <step label="Practice" value="practice">
69
+ Check an answer.
70
+ </step>
71
+ </steps>
72
+ ```
73
+
74
+ quiz requires label/answer. type defaults to choice, with option children and a matching answer. Numeric quizzes have an empty body, finite answer and nonnegative absolute tolerance (default 0). explanation is optional and supports text interpolation. Check answer, feedback and Try again are built in. Draft and feedback stay internal; this revision has no quiz bind. Hiding preserves them and panel reset clears them. Answers are supplied in source for self-study.
75
+
76
+ steps accepts one or more step children, optional label and exclusive string bind. initial defaults to the first step. Each step requires label; omitted values become step-1, step-2 and so on. Values are unique within a group. Previous/Next and position are built in. Only active content is visible; all bindings still initialize, state persists between steps, and hidden timers pause. Reset restores the initial step and its subtree.
77
+
78
+ ## Table and chart selection
79
+
80
+ ```markdown
81
+ <table bind="project" key="Project" initial="Content">
82
+ | Project | Cost |
83
+ | --- | ---: |
84
+ | Content | 120 |
85
+ | Visual | 230 |
86
+ </table>
87
+
88
+ <chart bind="project" key="Project">
89
+ | Project | Cost |
90
+ | --- | ---: |
91
+ | Content | 120 |
92
+ | Visual | 230 |
93
+ </chart>
94
+ ```
95
+
96
+ key names a column of static, nonempty, unique text identifiers. Selection is enabled only when key is present; bind/initial require key. Empty string means no selection by default. Explicit initial must match a row. Table/chart can share a selection binding only with identical ordered keys and at most one explicit initial. Mouse or keyboard selection writes row identity. Sorting, searching, pagination and hidden legends preserve selection; table filters still affect only that table. Existing components without key gain no implicit binding.
97
+
98
+ ## Compatibility and acceptance
99
+
100
+ Previously supported local-draft-1 source remains valid. Ten new names arrive with this extension: jump, anchor, text, section, multi-select, range-slider, coordinate, quiz, steps and step. The same release also adds the declaration tags computed, const and validation and the structural tags data-table and column, for 48 tag names in the complete `local-draft-2` set; the leading `<theme>` declaration is metadata, not a component. Old builds displayed these unknown regions as inert source; this build interprets their supported content. Put literal examples inside code spans or fences. Checklist completion appearance changes visibly.
101
+
102
+ Portable fixture syntaxVersion advances to local-draft-2; component-protocol-1 and its data format stay unchanged. local-draft-1.json is retained as historical data. New tests cover compiler/runtime, SSR rendering and visual selection. Canonical state, atomic rejection/reset, instance isolation, hidden-state retention, positioned diagnostics, existing resource budgets and the core/React boundary follow the component protocol. The same release also reserves new expression function names; see [0.4.0 release and migration](../releases/release-0.4.0-en.md) for the full rename list.
103
+
104
+ Run `npm test`, `npm run test:components`, `npm run build:demo` and `npm run test:docs`. Browser checks and the complete release gate use `npm run verify:release`; see the [contributing guide](../../CONTRIBUTING.md). Record actual run results with the gate rather than copying an old script name. The bilingual [six scenarios](../../examples/local/showcase/README.md) cover all components: ranges, coordinates and numeric questions in Functions; multiple selection in Forms; linked selection in Data; jumps and prose colors in Layout; steps and choice questions in Flow; todos and timing in Checklists.