reactive-md 0.3.1 → 0.4.0

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 (172) hide show
  1. package/CHANGELOG-ch.md +96 -0
  2. package/CHANGELOG.md +82 -39
  3. package/CONTRIBUTING-ch.md +62 -0
  4. package/CONTRIBUTING.md +64 -65
  5. package/README-ch.md +122 -0
  6. package/README-en.md +146 -0
  7. package/README.md +146 -89
  8. package/SECURITY-ch.md +80 -0
  9. package/SECURITY.md +58 -49
  10. package/THIRD_PARTY_NOTICES.md +85 -1
  11. package/bin/reactive-md.mjs +40 -0
  12. package/cli/args.mjs +181 -0
  13. package/cli/assets.mjs +390 -0
  14. package/cli/build.mjs +268 -0
  15. package/cli/document.mjs +130 -0
  16. package/cli/errors.mjs +61 -0
  17. package/cli/fs-utils.mjs +133 -0
  18. package/cli/glob.mjs +203 -0
  19. package/cli/help.mjs +138 -0
  20. package/cli/lint.mjs +177 -0
  21. package/cli/main.mjs +55 -0
  22. package/cli/migrate.mjs +368 -0
  23. package/cli/package.mjs +209 -0
  24. package/dist-library/reactive-md-react.js +3425 -1647
  25. package/dist-library/reactive-md.css +1 -1
  26. package/dist-library/reactive-md.js +1798 -4
  27. package/dist-library/runtime-DtjdPXxJ.js +15410 -0
  28. package/dist-library/types/index.d.ts +1 -0
  29. package/dist-library/types/local/LocalDocumentView.d.ts +66 -3
  30. package/dist-library/types/local/authoring.d.ts +63 -0
  31. package/dist-library/types/local/collection-functions.d.ts +4 -0
  32. package/dist-library/types/local/colors.d.ts +2 -0
  33. package/dist-library/types/local/computations.d.ts +53 -0
  34. package/dist-library/types/local/data-functions.d.ts +22 -0
  35. package/dist-library/types/local/data-table.d.ts +65 -0
  36. package/dist-library/types/local/dates.d.ts +2 -0
  37. package/dist-library/types/local/dependencies.d.ts +31 -0
  38. package/dist-library/types/local/diagnostics.d.ts +1450 -0
  39. package/dist-library/types/local/expression.d.ts +13 -3
  40. package/dist-library/types/local/formatting.d.ts +41 -0
  41. package/dist-library/types/local/heading-anchors.d.ts +13 -2
  42. package/dist-library/types/local/i18n.d.ts +18 -0
  43. package/dist-library/types/local/index.d.ts +18 -1
  44. package/dist-library/types/local/limits.d.ts +32 -1
  45. package/dist-library/types/local/locale.d.ts +1 -0
  46. package/dist-library/types/local/math.d.ts +6 -1
  47. package/dist-library/types/local/parser.d.ts +10 -4
  48. package/dist-library/types/local/render-types.d.ts +5 -1
  49. package/dist-library/types/local/retention.d.ts +23 -0
  50. package/dist-library/types/local/schema.d.ts +25 -3
  51. package/dist-library/types/local/source-migration.d.ts +35 -0
  52. package/dist-library/types/local/state.d.ts +80 -0
  53. package/dist-library/types/local/text-length.d.ts +13 -0
  54. package/dist-library/types/local/theme.d.ts +30 -0
  55. package/dist-library/types/local/types.d.ts +112 -4
  56. package/dist-library/types/local/validation.d.ts +32 -0
  57. package/dist-library/types/local/version.d.ts +1 -1
  58. package/dist-library/types/local/worker.d.ts +82 -0
  59. package/dist-library/types/react/index.d.ts +4 -1
  60. package/dist-library/types/shareable.d.ts +64 -0
  61. package/dist-standalone/reactive-md-standalone.css +2 -0
  62. package/dist-standalone/reactive-md-standalone.js +57 -0
  63. package/docs/author-tools-ch.md +56 -0
  64. package/docs/author-tools-en.md +56 -0
  65. package/docs/compatibility-ch.md +103 -0
  66. package/docs/compatibility-en.md +103 -0
  67. package/docs/{component-development.md → component-development-ch.md} +210 -206
  68. package/docs/component-development-en.md +210 -0
  69. package/docs/{component-protocol.md → component-protocol-ch.md} +710 -685
  70. package/docs/component-protocol-en.md +710 -0
  71. package/docs/computations-formatting-ch.md +87 -0
  72. package/docs/computations-formatting-en.md +87 -0
  73. package/docs/constraints-collections-ch.md +84 -0
  74. package/docs/constraints-collections-en.md +84 -0
  75. package/docs/diagnostics-counting-ch.md +84 -0
  76. package/docs/diagnostics-counting-en.md +84 -0
  77. package/docs/local-components-v2-ch.md +138 -0
  78. package/docs/local-components-v2-en.md +104 -0
  79. package/docs/{local-guide.md → local-guide-ch.md} +28 -8
  80. package/docs/local-guide-en.md +961 -0
  81. package/docs/local-integration-ch.md +363 -0
  82. package/docs/local-integration-en.md +363 -0
  83. package/docs/{local-interaction-syntax.md → local-interaction-syntax-ch.md} +66 -20
  84. package/docs/local-interaction-syntax-en.md +483 -0
  85. package/docs/{performance.md → performance-ch.md} +12 -3
  86. package/docs/performance-en.md +76 -0
  87. package/docs/release-0.4.0-ch.md +89 -0
  88. package/docs/release-0.4.0-en.md +89 -0
  89. package/docs/releasing-ch.md +101 -0
  90. package/docs/releasing-en.md +101 -0
  91. package/docs/shareable-export-ch.md +205 -0
  92. package/docs/shareable-export-en.md +207 -0
  93. package/docs/source-versioning-ch.md +159 -0
  94. package/docs/source-versioning-en.md +159 -0
  95. package/docs/theme-protocol-ch.md +107 -0
  96. package/docs/theme-protocol-en.md +107 -0
  97. package/examples/conformance/README.md +33 -31
  98. package/examples/conformance/component-protocol-1.json +482 -194
  99. package/examples/conformance/component-protocol-1.schema.json +76 -76
  100. package/examples/conformance/history/v0.3.1/catalog.reactive.md +20 -0
  101. package/examples/conformance/history/v0.3.1/charts.reactive.md +73 -0
  102. package/examples/conformance/history/v0.3.1/checklist.reactive.md +32 -0
  103. package/examples/conformance/history/v0.3.1/comparison.reactive.md +47 -0
  104. package/examples/conformance/history/v0.3.1/components.reactive.md +44 -0
  105. package/examples/conformance/history/v0.3.1/counter.reactive.md +7 -0
  106. package/examples/conformance/history/v0.3.1/diagnostics.reactive.md +54 -0
  107. package/examples/conformance/history/v0.3.1/diagram.reactive.md +44 -0
  108. package/examples/conformance/history/v0.3.1/gallery.reactive.md +61 -0
  109. package/examples/conformance/history/v0.3.1/local-draft-1.json +50 -0
  110. package/examples/conformance/history/v0.3.1/parameters.reactive.md +36 -0
  111. package/examples/conformance/history/v0.3.1/planning.reactive.md +24 -0
  112. package/examples/conformance/history/v0.3.1/pricing.reactive.md +20 -0
  113. package/examples/conformance/history/v0.3.1/provenance.json +72 -0
  114. package/examples/conformance/local-draft-2.json +212 -0
  115. package/examples/integration/README.md +45 -29
  116. package/examples/integration/core/index.mjs +32 -19
  117. package/examples/integration/react/index.html +1 -1
  118. package/examples/integration/react/main.jsx +5 -5
  119. package/examples/integration/worker/index.html +19 -0
  120. package/examples/integration/worker/main.js +61 -0
  121. package/examples/integration/worker/package.json +13 -0
  122. package/examples/integration/worker/worker.js +3 -0
  123. package/examples/local/README.md +64 -58
  124. package/examples/local/catalog.reactive.md +14 -14
  125. package/examples/local/charts.reactive.md +34 -34
  126. package/examples/local/checklist.reactive.md +19 -19
  127. package/examples/local/comparison.reactive.md +23 -23
  128. package/examples/local/components.reactive.md +20 -20
  129. package/examples/local/counter.reactive.md +4 -4
  130. package/examples/local/diagnostics.reactive.md +25 -25
  131. package/examples/local/diagram.reactive.md +20 -20
  132. package/examples/local/gallery.reactive.md +31 -31
  133. package/examples/local/parameters.reactive.md +19 -19
  134. package/examples/local/planning.reactive.md +15 -15
  135. package/examples/local/pricing.reactive.md +10 -10
  136. package/examples/local/recipes/invoice-zh.reactive.md +36 -0
  137. package/examples/local/recipes/invoice.reactive.md +36 -0
  138. package/examples/local/recipes/workshop-zh.reactive.md +33 -0
  139. package/examples/local/recipes/workshop.reactive.md +33 -0
  140. package/examples/local/showcase/README.md +25 -0
  141. package/examples/local/showcase/explore.reactive.md +102 -0
  142. package/examples/local/showcase/flow.reactive.md +86 -0
  143. package/examples/local/showcase/forms.reactive.md +126 -0
  144. package/examples/local/showcase/functions.reactive.md +119 -0
  145. package/examples/local/showcase/layout.reactive.md +100 -0
  146. package/examples/local/showcase/statistics.reactive.md +108 -0
  147. package/examples/local/showcase/tasks.reactive.md +89 -0
  148. package/examples/local/showcase/zh/explore.reactive.md +102 -0
  149. package/examples/local/showcase/zh/flow.reactive.md +86 -0
  150. package/examples/local/showcase/zh/forms.reactive.md +126 -0
  151. package/examples/local/showcase/zh/functions.reactive.md +119 -0
  152. package/examples/local/showcase/zh/layout.reactive.md +100 -0
  153. package/examples/local/showcase/zh/statistics.reactive.md +108 -0
  154. package/examples/local/showcase/zh/tasks.reactive.md +89 -0
  155. package/examples/local/zh/catalog.reactive.md +20 -0
  156. package/examples/local/zh/charts.reactive.md +73 -0
  157. package/examples/local/zh/checklist.reactive.md +32 -0
  158. package/examples/local/zh/comparison.reactive.md +47 -0
  159. package/examples/local/zh/components.reactive.md +44 -0
  160. package/examples/local/zh/counter.reactive.md +7 -0
  161. package/examples/local/zh/diagnostics.reactive.md +54 -0
  162. package/examples/local/zh/diagram.reactive.md +44 -0
  163. package/examples/local/zh/gallery.reactive.md +61 -0
  164. package/examples/local/zh/parameters.reactive.md +36 -0
  165. package/examples/local/zh/planning.reactive.md +24 -0
  166. package/examples/local/zh/pricing.reactive.md +20 -0
  167. package/package.json +16 -3
  168. package/README.en.md +0 -76
  169. package/dist-library/runtime-CPzMEMcW.js +0 -11111
  170. package/docs/compatibility.md +0 -68
  171. package/docs/local-integration.md +0 -218
  172. package/docs/releasing.md +0 -92
@@ -0,0 +1,107 @@
1
+ # Reactive MD theme protocol
2
+
3
+ Protocol revision: `reactive-md-theme-1`. This feature ships in `0.4.0`, the preview release on the `next` channel. The built-in `default` preserves the existing appearance.
4
+
5
+ ## Selecting a theme
6
+
7
+ Place a declaration before the document body:
8
+
9
+ ```markdown
10
+ <theme name="default">
11
+
12
+ # Document title
13
+ ```
14
+
15
+ `<theme name="default" />` is also accepted. Omission selects `default`. Whitespace, a BOM and comments may precede the declaration. Declare it once, outside components. The static `name` uses lowercase kebab-case, starts with a letter and has at most 64 characters. Expressions and additional attributes are invalid.
16
+
17
+ The declaration is document metadata, does not count as a component and produces no visible element. Compilation stores `document.theme` and the original declaration's `document.themeRange`. Body nodes retain their original source positions. Fenced code, inline code, comments and escaped examples remain literal.
18
+
19
+ Invalid declarations produce `local.theme.*` warnings and select `default`. Repeated declarations do not change the first selection. Late or nested declarations do not select a theme. Healthy body content and controls remain usable.
20
+
21
+ ## Host registration
22
+
23
+ A developer supplies CSS and registration metadata. Import the shared styles before the theme stylesheet, then pass the allowed themes to the renderer:
24
+
25
+ ```tsx
26
+ import { LOCAL_THEME_PROTOCOL, type LocalThemeDefinition } from 'reactive-md';
27
+ import { LocalReactiveDocument } from 'reactive-md/react';
28
+ import 'reactive-md/styles.css';
29
+ import './paper-theme.css';
30
+
31
+ const paperTheme = {
32
+ name: 'paper',
33
+ protocol: LOCAL_THEME_PROTOCOL,
34
+ colorSchemes: ['light', 'dark'],
35
+ } as const satisfies LocalThemeDefinition;
36
+
37
+ export function Article({ source }: { source: string }) {
38
+ return <LocalReactiveDocument source={source} themes={[paperTheme]} colorScheme="auto" />;
39
+ }
40
+ ```
41
+
42
+ This demonstrates registration. The repository includes only `default`; it does not include a `paper` design or stylesheet.
43
+
44
+ | Field | Requirement |
45
+ | --- | --- |
46
+ | `name` | Follows the document identifier rules; unique in the host list; `default` is reserved |
47
+ | `protocol` | Must be `reactive-md-theme-1`; use `LOCAL_THEME_PROTOCOL` |
48
+ | `colorSchemes` | Must include both `light` and `dark` |
49
+
50
+ The host loads the CSS. Registration does not fetch or inject styles. Documents select a registered name and cannot provide CSS, stylesheet URLs or scripts. Theme CSS is trusted host code; the host reviews its scope and resource references.
51
+
52
+ An unknown name, duplicate selected name, invalid selected registration, unsupported protocol or missing mode produces a renderer warning and falls back to `default`. Core-only hosts can call `resolveLocalTheme(name, themes, range?, source?)` to obtain `{ name, diagnostics }`. Compilation parses declarations independently of host registrations.
53
+
54
+ ## Color schemes and instance scope
55
+
56
+ Both React components accept `themes` and `colorScheme`. The theme selects the visual design; the color scheme selects its light or dark version:
57
+
58
+ | Value | Behavior |
59
+ | --- | --- |
60
+ | `light` | Forces light mode for this document, including inside a dark host |
61
+ | `dark` | Forces dark mode for this document |
62
+ | `auto` (default) | Uses the nearest ancestor's explicit preference, then the system preference; server output starts in light mode |
63
+
64
+ Ancestor preferences support `data-color-scheme="light|dark"` and the existing `data-theme="light|dark"`. Ancestor attribute changes and system preference changes update the document in the browser. An explicit local `colorScheme` takes precedence.
65
+
66
+ The renderer exposes the resolved selection on its document root:
67
+
68
+ ```html
69
+ <article class="md-document local-document"
70
+ data-rmd-theme="paper"
71
+ data-color-scheme="dark">
72
+ ```
73
+
74
+ Each instance chooses independently. Every theme rule must be scoped to its named root or descendants, for example `[data-rmd-theme="paper"][data-color-scheme="dark"]`. Global `body`, `:root` and unscoped element rules must not affect the host.
75
+
76
+ Changing `themes` or `colorScheme` does not create a runtime. Changing `LocalReactiveDocument.source` retains its existing behavior: recompilation and a new runtime. Hosts that retain parameters across source changes can manage `LocalDocumentView` and its runtime themselves.
77
+
78
+ ## Shared style variables
79
+
80
+ Shared component CSS supplies structure, interaction and defaults. Custom themes inherit a complete default variable set and override the values they need. Both light and dark variants must be designed and checked.
81
+
82
+ | Purpose | Public variables |
83
+ | --- | --- |
84
+ | Surfaces | `--paper`, `--surface`, `--document-bg` (defaults to `--surface`), `--surface-subtle`, `--surface-hover`, `--surface-active` |
85
+ | Text and borders | `--ink`, `--ink-soft`, `--ink-muted`, `--line`, `--line-strong` |
86
+ | Accent | `--accent`, `--accent-hover`, `--accent-soft`, `--accent-line` |
87
+ | Status | `--info`, `--info-soft`, `--success`, `--success-soft`, `--success-line`, `--warning`, `--warning-soft`, `--warning-line`, `--danger`, `--danger-soft`, `--danger-line`, `--neutral-soft` |
88
+ | Focus | `--focus`, `--focus-outline`, `--focus-ring` |
89
+ | Data and code | `--chart-1` through `--chart-8`, `--chart-grid`, `--chart-axis`, `--code-bg`, `--code-bg-deep`, `--code-ink` |
90
+ | Fonts | `--font-sans`, `--font-mono`, `--text-xs` through `--text-xl`, `--text-2xl`, `--text-block-title`, `--text-block-subtitle` |
91
+ | Line height and weight | `--leading-tight`, `--leading-snug`, `--leading-normal`, `--leading-relaxed`, `--weight-regular`, `--weight-medium`, `--weight-semibold`, `--weight-bold` |
92
+ | Spacing | `--space-1` through `--space-7`, `--field-gap` |
93
+ | Radius | `--radius-control`, `--radius-card`, `--radius-panel`, `--radius-pill` |
94
+ | Controls | `--control-height-sm`, `--control-height`, `--control-height-lg`, `--control-padding-x`, `--control-padding-y`, `--disabled-opacity` |
95
+ | Motion and elevation | `--motion-fast`, `--motion-base`, `--motion-slow`, `--ease-standard`, `--shadow-sm`, `--shadow-md` |
96
+
97
+ Existing `--blue`, `--blue-deep`, `--blue-soft` and `--blue-line` remain compatible. New themes should use the accent variables. Explicit component `color` attributes override their corresponding local color; other properties continue to use the theme. Series and status colors retain their semantic roles.
98
+
99
+ ## Component CSS and acceptance
100
+
101
+ Themes can supplement variable overrides with existing `.md-*` and `.local-*` component classes. Root classes, component outer classes and semantic state attributes are styling interfaces; internal node ordering is not an extension API. Load scoped theme rules after the shared stylesheet, using sufficiently specific root and component selectors instead of relying on `!important`.
102
+
103
+ Coverage includes Markdown, tables, formulas, controls, containers, feedback, charts and diagrams. New components must consume shared variables and work with `default`. Themes without dedicated rules for a new component inherit its shared styles.
104
+
105
+ A conforming theme must check every component in both modes, including hover, focus, active, disabled, error and selection states. Preserve visible keyboard focus, readable text and controls, a usable 375px layout and reduced-motion preferences. Font changes require checking SVG diagram labels, nodes and bounds.
106
+
107
+ Registration validates protocol and declared modes. Browser acceptance verifies CSS coverage, contrast and layout. Include multiple isolated themes, forced light inside a dark host, system preference changes, retained interaction state and unmount cleanup.
@@ -1,51 +1,53 @@
1
- # 语言验收数据
1
+ # Language conformance data
2
2
 
3
- [local-draft-1.json](local-draft-1.json) 是可复制的最小语义验收集,包含源码、编译结果、初始参数、状态写入和预期文本。数据随 npm 包分发,其他工具或实现可以读取同一份 JSON。
3
+ [local-draft-2.json](local-draft-2.json) is a copyable minimal semantic conformance suite containing source documents, compilation results, initial parameters, state writes and expected text. The data is distributed with the npm package so other tools or implementations can read the same JSON.
4
4
 
5
- - `syntaxVersion` 对应核心导出的 `LOCAL_SYNTAX_VERSION`。
6
- - `ok` 是预期编译结果;`codes` 是去重后的预期诊断码集合,省略时应无诊断。编译成功时也可能包含降级警告。
7
- - `initial` 检查公开参数的初值;`bindingNames` 在出现时检查完整绑定名集合。
8
- - `actions` 按 `bind` 查找控件并提交 `value`;有 `codes` 时预期写入被拒绝,否则预期成功。
9
- - `text` 用更新后的状态求值,结果应等于 `expectedText`。
5
+ - `syntaxVersion` matches the core export `LOCAL_SYNTAX_VERSION`.
6
+ - `ok` is the expected compilation result; `codes` is the deduplicated set of expected diagnostic codes, and when omitted no diagnostics are expected. A successful compile can still contain degradation warnings.
7
+ - `initial` checks the initial values of public parameters; `bindingNames`, when present, checks the complete set of binding names.
8
+ - `actions` finds controls by `bind` and submits `value`; when `codes` is present the write is expected to be rejected, otherwise it is expected to succeed.
9
+ - `text` is evaluated with the updated state and the result should equal `expectedText`.
10
10
 
11
- 运行器见仓库中的 `tests/conformance.test.ts`,执行 `npm test` 即可检查。本集覆盖共享参数、隐藏初始化、写入约束、代码隔离和诊断;完整语法验收还包含其他语言测试及浏览器检查,规则见[语法规范](../../docs/local-interaction-syntax.md)。诊断码的跨版本约定见[兼容说明](../../docs/compatibility.md)。
11
+ The runner lives at `tests/conformance.test.ts` in the repository; run `npm test` to check it. This suite covers shared parameters, hidden initialization, write constraints, code isolation, diagnostics, multi-slot controls, multiple selection, generated-table selection and a computed-value aggregate recalculation. It does not cover validation hints, generated table rendering, HTML export, author tooling or browser behavior; those have dedicated tests and the release gate. Full syntax conformance also includes other language tests and browser checks, with rules in the [syntax specification](../../docs/local-interaction-syntax-en.md). See the [compatibility notes](../../docs/compatibility-en.md) for cross-version guarantees on diagnostic codes.
12
12
 
13
- ## 组块协议验收
13
+ The conformance sources are unversioned and use the current `local-draft-2` revision. The optional prologue version declaration is compile metadata and does not change these semantic cases. Version rejection and migration behavior have dedicated tests and historical fixtures. See [Source revisions and migration](../../docs/source-versioning-en.md).
14
14
 
15
- [component-protocol-1.json](component-protocol-1.json) 为[组块协议](../../docs/component-protocol.md)提供代表性用例,覆盖 `slider`、`tabs`、`plot` 以及未知组块的惰性降级。[JSON Schema](component-protocol-1.schema.json) 定义验收文件格式,可供其他实现的工具读取。这个 JSON 是测试输入和预期结果,组件提案的声明模板见[开发指南](../../docs/component-development.md)。
15
+ ## Component protocol conformance
16
+
17
+ [component-protocol-1.json](component-protocol-1.json) provides representative cases for the [component protocol](../../docs/component-protocol-en.md), covering `slider`, `tabs`, `plot` and lazy degradation of unknown components. The [JSON Schema](component-protocol-1.schema.json) defines the conformance file format so tools from other implementations can read it. This JSON is test input and expected results; see the [development guide](../../docs/component-development-en.md) for the declaration template of a component proposal.
16
18
 
17
19
  ```sh
18
20
  npm run test:components
19
21
  ```
20
22
 
21
- 该命令运行组块协议用例和原有语言验收数据。新增组块应补充自己的用例、单元测试和受影响的渲染器检查;通过本集合只证明这些具体用例通过。
23
+ That command runs the component protocol cases and the existing language conformance data. A new component should add its own cases, unit tests and affected renderer checks; passing this suite only proves these specific cases pass.
22
24
 
23
- ### 文件与用例字段
25
+ ### File and case fields
24
26
 
25
- 文件根对象包含 `protocolVersion`、`syntaxVersion` 和非空的 `cases`。当前分别为 `component-protocol-1` 和 `local-draft-1`。包版本另由 `package.json` 标识,不由这两个字段推断。
27
+ The file root object contains `protocolVersion`, `syntaxVersion` and a non-empty `cases` array. Currently these are `component-protocol-1` and `local-draft-2`. The package version is identified separately by `package.json` and is not inferred from these two fields.
26
28
 
27
- | 字段 | 规则 |
29
+ | Field | Rule |
28
30
  | --- | --- |
29
- | `id` | 必填,在文件内唯一;描述一个可观察的行为 |
30
- | `component` | 必填,标明主要验收的组块;源码可同时使用其他组块 |
31
- | `source` | 必填,原始文档源码 |
32
- | `ok` | 必填,预期编译是否成功 |
33
- | `codes` | 必填,编译诊断码的去重集合;无诊断时为 `[]`,忽略顺序、精确比较集合 |
34
- | `initial` | 可选,编译成功后的初始状态期望,按给定键部分匹配 |
35
- | `bindingNames` | 可选,完整公开绑定名集合;不包含匿名组块的内部状态键 |
36
- | `actions` | 可选,依次写入命名绑定;每项必填 `bind`、`value`、`codes`,可选 `expectedState` |
37
- | `reset` | 可选,写入完成后重置指定节点;必填 `component` 和 `expectedState`,`index` 默认为同名组件源码顺序中的第 0 个 |
38
- | `text`、`expectedText` | 可选,必须成对;在写入和重置后求值并精确比较结果 |
39
- | `htmlIncludes`、`htmlExcludes` | 可选,在最终状态做 React 静态渲染,逐项检查包含或不包含的片段 |
31
+ | `id` | Required, unique within the file; describes one observable behavior |
32
+ | `component` | Required, names the component primarily under test; the source may use other components too |
33
+ | `source` | Required, the original document source |
34
+ | `ok` | Required, whether compilation is expected to succeed |
35
+ | `codes` | Required, the deduplicated set of compilation diagnostic codes; `[]` when there are none, order ignored, the set compared exactly |
36
+ | `initial` | Optional, initial state expectations after successful compilation, partially matched by the given keys |
37
+ | `bindingNames` | Optional, the complete set of public binding names; excludes internal state keys of anonymous components |
38
+ | `actions` | Optional, writes to named bindings in order; each entry requires `bind`, `value`, `codes` and may include `expectedState` |
39
+ | `reset` | Optional, resets the named node after the writes; requires `component` and `expectedState`, `index` defaults to the 0th in source order among components with that name |
40
+ | `text`, `expectedText` | Optional, must be paired; evaluated after writes and reset with the result compared exactly |
41
+ | `htmlIncludes`, `htmlExcludes` | Optional, performs React static rendering in the final state and checks each listed fragment is present or absent |
40
42
 
41
- `initial`、`expectedState` 的值使用语言现有的 `LocalValue`:字符串、有限数字、布尔值、`null` 或字符串数组。`actions[].codes` 是该次写入返回的诊断码集合,无诊断仍须写 `[]`;被拒绝的写入应保留上一次合法状态。运行器通过 `bind` 查找已编译的控件,调用 `runtime.set`,不模拟浏览器输入事件。
43
+ `initial` and `expectedState` values use the language's existing `LocalValue`: a string, finite number, boolean, `null` or string array. Public writable controls do not produce numeric arrays; numeric arrays are available to expressions and computed values. `actions[].codes` is the set of diagnostic codes returned by that write; still write `[]` when there are none. A rejected write should keep the last valid state. The runner finds compiled controls by `bind` and calls `runtime.set`; it does not simulate browser input events.
42
44
 
43
- 执行顺序固定为:校验数据格式及唯一 ID,编译并比较诊断,检查初始状态及公开绑定名,依序写入,再重置,最后检查文本和可选渲染结果。创建的运行时均在结束时销毁。`ok: false` 的用例只允许编译期字段,不能附加状态、动作或渲染期望;未知字段、缺失字段和不合法值应当让验收失败。
45
+ Execution order is fixed: validate the data format and unique IDs, compile and compare diagnostics, check the initial state and public binding names, perform writes in order, then reset, and finally check text and optional rendering results. Every created runtime is disposed at the end. Cases with `ok: false` may only use compile-time fields and cannot add state, action or rendering expectations; unknown fields, missing fields and invalid values should fail conformance.
44
46
 
45
- `reset` 调用当前实例的 `runtime.reset(node)`,节点按组块名和索引查找;验收文件不保存 `node.id`。这项检查验证运行时重置语义,点击重置按钮仍需渲染器或浏览器检查。
47
+ `reset` calls `runtime.reset(node)` on the current instance; nodes are found by component name and index, and the conformance file does not store `node.id`. This check verifies runtime reset semantics; clicking a reset button still needs a renderer or browser check.
46
48
 
47
- ### 可移植范围
49
+ ### Portable scope
48
50
 
49
- 编译结果、诊断集合、状态变化和表达式文本是可移植的语义期望。HTML 片段只检查本仓库的 React 参考渲染器;其他渲染器应验证同等用户行为,无需生成相同 DOM 或 CSS 类名。
51
+ Compilation results, diagnostic sets, state changes and expression text are portable semantic expectations. HTML fragments only check this repository's React reference renderer; other renderers should verify equivalent user behavior and need not generate the same DOM or CSS class names.
50
52
 
51
- 这些用例不会证明真实键盘操作、焦点移动、中文输入法、375px 布局、计时器暂停或销毁后的计时清理。涉及这些行为的贡献仍需提交相应浏览器证据,检查方法见[开发指南](../../docs/component-development.md)。诊断码的跨版本稳定性继续遵守[兼容说明](../../docs/compatibility.md)。
53
+ These cases do not prove real keyboard operation, focus movement, Chinese input methods, 375px layout, timer pause, or timer cleanup after disposal. Contributions involving those behaviors still need corresponding browser evidence; see the [development guide](../../docs/component-development-en.md) for verification methods. Cross-version stability of diagnostic codes continues to follow the [compatibility notes](../../docs/compatibility-en.md).