reactive-md 0.8.0 → 0.9.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 (441) hide show
  1. package/CHANGELOG-ch.md +54 -4
  2. package/CHANGELOG.md +55 -4
  3. package/CONTRIBUTING-ch.md +13 -2
  4. package/CONTRIBUTING.md +13 -2
  5. package/README-ch.md +132 -23
  6. package/README-en.md +130 -21
  7. package/README.md +128 -21
  8. package/SECURITY-ch.md +3 -3
  9. package/SECURITY.md +3 -3
  10. package/THIRD_PARTY_NOTICES.md +111 -1
  11. package/cli/args.mjs +51 -1
  12. package/cli/assets.mjs +6 -1
  13. package/cli/build.mjs +125 -9
  14. package/cli/fs-utils.mjs +3 -3
  15. package/cli/help.mjs +12 -5
  16. package/cli/init.mjs +1 -1
  17. package/cli/package.mjs +1 -0
  18. package/dist-library/LocalDocumentView-sthUP0ct.js +109 -0
  19. package/dist-library/LocalDocumentViewCore-GiWV3bey.js +9829 -0
  20. package/dist-library/LocalReactiveDocumentCore-ZjQSGyHE.js +275 -0
  21. package/dist-library/{authoring-BsfSwQRm.js → authoring-Dsune4Hy.js} +240 -218
  22. package/dist-library/compile-wUv8KEge.js +1249 -0
  23. package/dist-library/{compiler-core-kPiH-gOV.js → compiler-core-As_m-MNm.js} +5372 -5559
  24. package/dist-library/compiler-eOfcinZs.js +62 -0
  25. package/dist-library/component-state-BoLCGee4.js +801 -0
  26. package/dist-library/{component-state-D_cw_EHe.js → component-state-C52ZFJGl.js} +2 -2
  27. package/dist-library/{registry-B9Jc3FVe.js → config-BadfhjdP.js} +374 -457
  28. package/dist-library/{config-validation-DXTynAw7.js → config-validation-F47AcE6o.js} +549 -751
  29. package/dist-library/controls-CcT6n7k_.js +6740 -0
  30. package/dist-library/coordinate-CWS9p5q_.js +293 -0
  31. package/dist-library/data-table-Bgccxd7h.js +296 -0
  32. package/dist-library/{default-components-Z_YMio5P.js → default-components-BwQf0oP-.js} +344 -334
  33. package/dist-library/{math-display-BJz4gbFc.js → display-B-VhqVND.js} +1299 -1299
  34. package/dist-library/export-BqVmTXm8.js +369 -0
  35. package/dist-library/gallery-CY6mTx8i.js +360 -0
  36. package/dist-library/html-CNT4KD-2.js +757 -0
  37. package/dist-library/{math-sample-BGEW49zY.js → incremental-Dv0FSp_U.js} +476 -394
  38. package/dist-library/latex-1w7aQgD5.js +928 -0
  39. package/dist-library/layout-C0YlEPGr.js +562 -0
  40. package/dist-library/mount-preset-KxvtKgJb.js +13 -0
  41. package/dist-library/options-1aDLK7JY.js +121 -0
  42. package/dist-library/{react-ByOHunUW.js → package-core-WFK1RhAZ.js} +49 -55
  43. package/dist-library/{parser-standard-DlCk7sLo.js → parser-standard-Yuf3A_VI.js} +6605 -7097
  44. package/dist-library/plugin-packs-B1XPWcFs.js +18 -0
  45. package/dist-library/{identity-MYJXKSkB.js → preset-core-CKc5YXSM.js} +31 -31
  46. package/dist-library/{props-DGlBk0e5.js → props-sJ8vk0cr.js} +1 -1
  47. package/dist-library/react-BbyAgeXc.js +6070 -0
  48. package/dist-library/react-D5iGiUdL.js +7 -0
  49. package/dist-library/reactive-md-authoring.js +222 -223
  50. package/dist-library/reactive-md-build.js +126 -72
  51. package/dist-library/reactive-md-compiler-standard.js +12 -10
  52. package/dist-library/reactive-md-compiler.js +3 -3
  53. package/dist-library/reactive-md-default-packs.js +2 -2
  54. package/dist-library/reactive-md-default-preset.js +4 -4
  55. package/dist-library/reactive-md-export-assets.js +57 -0
  56. package/dist-library/reactive-md-export.js +5 -111
  57. package/dist-library/reactive-md-minimal-preset.js +24 -0
  58. package/dist-library/reactive-md-minimal-react-preset.js +26 -0
  59. package/dist-library/reactive-md-minimal-styles.js +80 -0
  60. package/dist-library/reactive-md-minimal.css +2 -0
  61. package/dist-library/reactive-md-pdf.js +7582 -0
  62. package/dist-library/reactive-md-plugin-chart.js +13 -0
  63. package/dist-library/reactive-md-plugin-data.js +17 -0
  64. package/dist-library/reactive-md-plugin-diagram.js +18 -0
  65. package/dist-library/reactive-md-plugin-forms.js +18 -0
  66. package/dist-library/reactive-md-plugin-gallery.js +12 -0
  67. package/dist-library/reactive-md-plugin-navigation.js +15 -0
  68. package/dist-library/reactive-md-plugin-network.js +222 -0
  69. package/dist-library/reactive-md-plugin-plot.js +24 -0
  70. package/dist-library/reactive-md-print.css +5 -0
  71. package/dist-library/reactive-md-react-minimal.js +28 -0
  72. package/dist-library/reactive-md-react-server.js +34 -32
  73. package/dist-library/reactive-md-react-unstyled.js +14 -9
  74. package/dist-library/reactive-md-react.js +14 -9
  75. package/dist-library/reactive-md-runtime-browser.js +847 -15
  76. package/dist-library/reactive-md-runtime.js +3 -3
  77. package/dist-library/reactive-md-sdk.js +8 -6
  78. package/dist-library/reactive-md-standalone-configured.js +16 -0
  79. package/dist-library/reactive-md-standalone-host.js +9 -438
  80. package/dist-library/reactive-md-testing-browser.js +5 -4
  81. package/dist-library/reactive-md-testing-react.js +46 -44
  82. package/dist-library/reactive-md-testing.js +45 -44
  83. package/dist-library/reactive-md-vite.js +135 -37
  84. package/dist-library/reactive-md.css +1 -1
  85. package/dist-library/reactive-md.js +590 -498
  86. package/dist-library/registry-B9NGct4d.js +20 -0
  87. package/dist-library/registry-core-Bbad9Bm2.js +479 -0
  88. package/dist-library/{resources-BGt8mpDA.js → resources-D2GDQS0p.js} +45 -45
  89. package/dist-library/{runtime-Dkq7ldyg.js → runtime-B2fxeveq.js} +1 -1
  90. package/dist-library/runtime-kcA7bG7G.js +1282 -0
  91. package/dist-library/sample-bP4zHB3L.js +289 -0
  92. package/dist-library/{schema-ZFufO8V0.js → schema-BufhKUSM.js} +12 -11
  93. package/dist-library/sdk-core-BoJT1SIt.js +1166 -0
  94. package/dist-library/session-core-nmJHuR9c.js +452 -0
  95. package/dist-library/{shareable-DDVL4Fi9.js → shareable-DpbE-59H.js} +250 -283
  96. package/dist-library/tooltip-layer-HDLrSWs0.js +28 -0
  97. package/dist-library/types/authoring/catalog.d.ts +2 -3
  98. package/dist-library/types/authoring/editor-i18n.d.ts +1 -1
  99. package/dist-library/types/authoring/index.d.ts +1 -1
  100. package/dist-library/types/authoring/insert.d.ts +1 -1
  101. package/dist-library/types/authoring/templates.d.ts +2 -2
  102. package/dist-library/types/build/diagnostics.d.ts +1 -1
  103. package/dist-library/types/build/host.d.ts +1 -1
  104. package/dist-library/types/build/index.d.ts +1 -1
  105. package/dist-library/types/build/notices.d.ts +1 -1
  106. package/dist-library/types/build/resources.d.ts +1 -1
  107. package/dist-library/types/build/vite.d.ts +1 -1
  108. package/dist-library/types/compiler/index.d.ts +2 -2
  109. package/dist-library/types/compiler/result.d.ts +1 -1
  110. package/dist-library/types/compiler/standard.d.ts +2 -2
  111. package/dist-library/types/compiler/types.d.ts +1 -1
  112. package/dist-library/types/components/{controls.d.ts → controls/controls.d.ts} +2 -3
  113. package/dist-library/types/components/{numeric-sliders.d.ts → controls/numeric-sliders.d.ts} +1 -1
  114. package/dist-library/types/components/{gallery.d.ts → gallery/gallery.d.ts} +1 -1
  115. package/dist-library/types/components/{layout.d.ts → layout/layout.d.ts} +1 -1
  116. package/dist-library/types/components/minimal-preset.d.ts +2 -0
  117. package/dist-library/types/components/mount-preset.d.ts +4 -0
  118. package/dist-library/types/components/network/submit-button.d.ts +10 -0
  119. package/dist-library/types/components/plot/coordinate.d.ts +2 -0
  120. package/dist-library/types/components/plugins/chart.d.ts +2 -0
  121. package/dist-library/types/components/plugins/data.d.ts +2 -0
  122. package/dist-library/types/components/plugins/diagram.d.ts +2 -0
  123. package/dist-library/types/components/plugins/forms.d.ts +2 -0
  124. package/dist-library/types/components/plugins/gallery.d.ts +2 -0
  125. package/dist-library/types/components/plugins/navigation.d.ts +2 -0
  126. package/dist-library/types/components/plugins/network.d.ts +2 -0
  127. package/dist-library/types/components/plugins/plot.d.ts +2 -0
  128. package/dist-library/types/components/shared/visual-frame.d.ts +12 -0
  129. package/dist-library/types/components/{visuals.d.ts → shared/visuals.d.ts} +1 -7
  130. package/dist-library/types/components/{data-table.d.ts → table/data-table.d.ts} +2 -2
  131. package/dist-library/types/export/component-state.d.ts +1 -1
  132. package/dist-library/types/export/index.d.ts +2 -1
  133. package/dist-library/types/export/print-document.d.ts +18 -0
  134. package/dist-library/types/export/render-markup.d.ts +23 -0
  135. package/dist-library/types/export/requirements.d.ts +1 -1
  136. package/dist-library/types/export/resources.d.ts +1 -1
  137. package/dist-library/types/export/restoration.d.ts +1 -1
  138. package/dist-library/types/export-assets/index.d.ts +25 -0
  139. package/dist-library/types/local/compilation/compiler-attributes.d.ts +8 -0
  140. package/dist-library/types/local/compilation/compiler-bindings.d.ts +19 -0
  141. package/dist-library/types/local/compilation/compiler-capabilities.d.ts +3 -0
  142. package/dist-library/types/local/compilation/compiler-core.d.ts +11 -3
  143. package/dist-library/types/local/compilation/compiler-declarations.d.ts +32 -0
  144. package/dist-library/types/local/compilation/compiler-expressions.d.ts +32 -0
  145. package/dist-library/types/local/compilation/compiler-services.d.ts +62 -16
  146. package/dist-library/types/local/compilation/compiler-structure.d.ts +38 -3
  147. package/dist-library/types/local/compilation/compiler-tables.d.ts +30 -0
  148. package/dist-library/types/local/compilation/compiler-validation.d.ts +15 -0
  149. package/dist-library/types/local/compilation/compiler-values.d.ts +39 -1
  150. package/dist-library/types/local/compilation/compiler.d.ts +7 -14
  151. package/dist-library/types/local/compilation/dependencies.d.ts +1 -1
  152. package/dist-library/types/local/compilation/session/incremental.d.ts +75 -0
  153. package/dist-library/types/local/{session → compilation/session}/row-reuse.d.ts +1 -1
  154. package/dist-library/types/local/{session/compiler-cache.d.ts → compilation/session/semantic-cache.d.ts} +5 -19
  155. package/dist-library/types/local/compilation/streaming.d.ts +27 -0
  156. package/dist-library/types/local/configuration/capability-policy.d.ts +3 -0
  157. package/dist-library/types/local/{compilation → configuration}/component-kernel.d.ts +3 -79
  158. package/dist-library/types/local/configuration/diagnostic-messages.d.ts +1104 -1056
  159. package/dist-library/types/local/configuration/diagnostic-runtime-messages.d.ts +731 -0
  160. package/dist-library/types/local/configuration/diagnostics.d.ts +1 -1
  161. package/dist-library/types/local/configuration/kernel-value-rules.d.ts +66 -0
  162. package/dist-library/types/local/configuration/official-leaf-syntax.d.ts +24 -0
  163. package/dist-library/types/local/configuration/options-core.d.ts +5 -4
  164. package/dist-library/types/local/configuration/options.d.ts +2 -1
  165. package/dist-library/types/local/configuration/portable-options.d.ts +1 -1
  166. package/dist-library/types/local/configuration/schema-core.d.ts +1 -1
  167. package/dist-library/types/local/configuration/schema.d.ts +1 -1
  168. package/dist-library/types/local/css/author-css.d.ts +66 -0
  169. package/dist-library/types/local/evaluation/computations.d.ts +2 -2
  170. package/dist-library/types/local/evaluation/expression/compile.d.ts +30 -0
  171. package/dist-library/types/local/evaluation/expression/evaluation.d.ts +3 -0
  172. package/dist-library/types/local/evaluation/expression/inference.d.ts +4 -0
  173. package/dist-library/types/local/evaluation/expression/syntax.d.ts +72 -0
  174. package/dist-library/types/local/evaluation/expression/values.d.ts +56 -0
  175. package/dist-library/types/local/evaluation/{math-display.d.ts → math/display.d.ts} +2 -2
  176. package/dist-library/types/local/evaluation/math/evaluation.d.ts +10 -0
  177. package/dist-library/types/local/evaluation/{math.d.ts → math/latex.d.ts} +58 -17
  178. package/dist-library/types/local/evaluation/{math-sample.d.ts → math/sample.d.ts} +4 -2
  179. package/dist-library/types/local/evaluation/math/syntax.d.ts +72 -0
  180. package/dist-library/types/local/evaluation/validation.d.ts +1 -1
  181. package/dist-library/types/local/html/extended-fragment.d.ts +41 -0
  182. package/dist-library/types/local/html/html-details.d.ts +1 -1
  183. package/dist-library/types/local/html/html-entities.d.ts +11 -2
  184. package/dist-library/types/local/html/html-recovery.d.ts +1 -1
  185. package/dist-library/types/local/html/html-table.d.ts +1 -1
  186. package/dist-library/types/local/html/html.d.ts +40 -4
  187. package/dist-library/types/local/index.d.ts +14 -13
  188. package/dist-library/types/local/parsing/author-markdown.d.ts +11 -0
  189. package/dist-library/types/local/{markdown → parsing}/fast-markdown.d.ts +1 -1
  190. package/dist-library/types/local/{markdown → parsing}/footnotes.d.ts +1 -1
  191. package/dist-library/types/local/{markdown → parsing}/heading-anchors.d.ts +1 -1
  192. package/dist-library/types/local/parsing/html-attributes.d.ts +14 -0
  193. package/dist-library/types/local/parsing/parse-budget.d.ts +1 -1
  194. package/dist-library/types/local/{session → parsing}/parse-session.d.ts +5 -5
  195. package/dist-library/types/local/parsing/parser-capabilities.d.ts +7 -2
  196. package/dist-library/types/local/parsing/parser-convert.d.ts +26 -0
  197. package/dist-library/types/local/parsing/parser-core.d.ts +10 -4
  198. package/dist-library/types/local/parsing/parser-internals.d.ts +54 -0
  199. package/dist-library/types/local/parsing/parser-region.d.ts +46 -0
  200. package/dist-library/types/local/parsing/parser-standard.d.ts +3 -0
  201. package/dist-library/types/local/parsing/parser-tags.d.ts +108 -0
  202. package/dist-library/types/local/parsing/parser.d.ts +3 -3
  203. package/dist-library/types/local/{markdown → parsing}/plain-paragraphs.d.ts +1 -1
  204. package/dist-library/types/local/parsing/rmd-recovery.d.ts +1 -1
  205. package/dist-library/types/local/parsing/theme-declaration.d.ts +22 -0
  206. package/dist-library/types/local/rendering/document/ExtendedHtmlFragment.d.ts +14 -0
  207. package/dist-library/types/local/rendering/document/LocalDocumentView.d.ts +5 -0
  208. package/dist-library/types/local/rendering/{LocalDocumentView.d.ts → document/LocalDocumentViewCore.d.ts} +48 -9
  209. package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +6 -0
  210. package/dist-library/types/local/rendering/document/render-nodes.d.ts +24 -0
  211. package/dist-library/types/local/rendering/document/use-author-script.d.ts +3 -0
  212. package/dist-library/types/local/rendering/document/use-color-scheme.d.ts +10 -0
  213. package/dist-library/types/local/rendering/document/validation-state.d.ts +31 -0
  214. package/dist-library/types/local/rendering/document/view-render-context.d.ts +146 -0
  215. package/dist-library/types/local/rendering/{view-revision.d.ts → document/view-revision.d.ts} +31 -4
  216. package/dist-library/types/local/rendering/render-types.d.ts +1 -1
  217. package/dist-library/types/local/{widgets/table-surface.d.ts → rendering/table/data-table.d.ts} +3 -0
  218. package/dist-library/types/local/rendering/table/table-numeric-columns.d.ts +7 -0
  219. package/dist-library/types/local/runtime/author-script-protocol.d.ts +59 -0
  220. package/dist-library/types/local/runtime/retention.d.ts +1 -1
  221. package/dist-library/types/local/runtime/runtime-document.d.ts +71 -0
  222. package/dist-library/types/local/runtime/runtime-migration.d.ts +19 -0
  223. package/dist-library/types/local/runtime/runtime-values.d.ts +39 -0
  224. package/dist-library/types/local/runtime/runtime.d.ts +4 -2
  225. package/dist-library/types/local/runtime/state.d.ts +1 -1
  226. package/dist-library/types/local/source/authoring-syntax.d.ts +48 -0
  227. package/dist-library/types/local/source/authoring.d.ts +1 -1
  228. package/dist-library/types/local/source/source-context.d.ts +23 -0
  229. package/dist-library/types/local/source/source-migration.d.ts +2 -2
  230. package/dist-library/types/local/transport/compile-patch.d.ts +1 -1
  231. package/dist-library/types/local/transport/flat-compiled-data.d.ts +1 -1
  232. package/dist-library/types/local/transport/shared-data.d.ts +1 -1
  233. package/dist-library/types/local/transport/worker-handler.d.ts +30 -0
  234. package/dist-library/types/local/transport/worker-job.d.ts +28 -0
  235. package/dist-library/types/local/transport/worker.d.ts +32 -46
  236. package/dist-library/types/local/{contracts/types.d.ts → types.d.ts} +78 -21
  237. package/dist-library/types/pdf.d.ts +22 -0
  238. package/dist-library/types/presets/identity.d.ts +1 -0
  239. package/dist-library/types/presets/minimal.d.ts +2 -0
  240. package/dist-library/types/presets/plugin-packs.d.ts +1 -0
  241. package/dist-library/types/react/component-api.d.ts +20 -4
  242. package/dist-library/types/react/component-primitives.d.ts +10 -10
  243. package/dist-library/types/react/component-utils.d.ts +9 -1
  244. package/dist-library/types/react/index.d.ts +6 -5
  245. package/dist-library/types/{local/theme/i18n.d.ts → react/localization.d.ts} +2 -2
  246. package/dist-library/types/react/minimal.d.ts +13 -0
  247. package/dist-library/types/react/package-core.d.ts +67 -0
  248. package/dist-library/types/react/package.d.ts +3 -67
  249. package/dist-library/types/react/runtime/common.d.ts +1 -1
  250. package/dist-library/types/react/sdk-core.d.ts +115 -0
  251. package/dist-library/types/react/sdk.d.ts +4 -110
  252. package/dist-library/types/react/server.d.ts +2 -2
  253. package/dist-library/types/react/use-draft-field.d.ts +5 -1
  254. package/dist-library/types/runtime-services/browser/duplex.d.ts +163 -0
  255. package/dist-library/types/runtime-services/browser/http-sse.d.ts +117 -0
  256. package/dist-library/types/runtime-services/browser/index.d.ts +2 -1
  257. package/dist-library/types/runtime-services/component-state.d.ts +1 -1
  258. package/dist-library/types/runtime-services/index.d.ts +2 -0
  259. package/dist-library/types/runtime-services/network.d.ts +86 -0
  260. package/dist-library/types/runtime-services/runtime.d.ts +1 -1
  261. package/dist-library/types/sdk/config.d.ts +1 -1
  262. package/dist-library/types/sdk/index.d.ts +1 -0
  263. package/dist-library/types/sdk/props.d.ts +1 -1
  264. package/dist-library/types/sdk/registry-core.d.ts +1 -1
  265. package/dist-library/types/sdk/theme.d.ts +5 -4
  266. package/dist-library/types/sdk/types.d.ts +2 -2
  267. package/dist-library/types/shareable.d.ts +6 -5
  268. package/dist-library/types/standalone/diagnostics.d.ts +1 -1
  269. package/dist-library/types/standalone/host.d.ts +5 -0
  270. package/dist-library/types/standalone/payload.d.ts +1 -1
  271. package/dist-library/types/standalone/prepare.d.ts +2 -2
  272. package/dist-library/types/standalone/session-core.d.ts +68 -0
  273. package/dist-library/types/standalone/session.d.ts +6 -68
  274. package/dist-library/types/themes/contract.d.ts +7 -0
  275. package/dist-library/types/{local/theme/theme.d.ts → themes/document-theme.d.ts} +4 -3
  276. package/dist-library/types/vite/client.d.ts +19 -0
  277. package/dist-library/types/vite/index.d.ts +18 -3
  278. package/dist-library/types/vite/registration.d.ts +2 -2
  279. package/dist-library/{types-BFCrMrg0.js → types-BeNtPqdY.js} +1 -1
  280. package/dist-library/validation-BEBA_HvS.js +1121 -0
  281. package/dist-library/visual-frame-CyV1FXzs.js +48 -0
  282. package/dist-library/visuals-B5KSafVk.js +3 -0
  283. package/dist-library/visuals-BZbZYA7w.js +72572 -0
  284. package/dist-standalone/reactive-md-standalone.css +1 -1
  285. package/dist-standalone/reactive-md-standalone.js +146 -137
  286. package/docs/README-ch.md +16 -11
  287. package/docs/README.md +16 -11
  288. package/docs/compatibility/compatibility-ch.md +8 -8
  289. package/docs/compatibility/compatibility-en.md +8 -8
  290. package/docs/compatibility/source-versioning-ch.md +1 -1
  291. package/docs/compatibility/source-versioning-en.md +1 -1
  292. package/docs/development/component-development-ch.md +2 -2
  293. package/docs/development/component-development-en.md +2 -2
  294. package/docs/development/component-development-reference-ch.md +4 -4
  295. package/docs/development/component-development-reference-en.md +4 -4
  296. package/docs/development/component-protocol-ch.md +14 -14
  297. package/docs/development/component-protocol-en.md +14 -14
  298. package/docs/development/extension-tutorial-ch.md +308 -0
  299. package/docs/development/extension-tutorial-en.md +308 -0
  300. package/docs/development/local-module-layout-ch.md +10 -50
  301. package/docs/development/local-module-layout-en.md +9 -49
  302. package/docs/development/performance-overview-ch.md +174 -154
  303. package/docs/development/performance-overview-en.md +174 -154
  304. package/docs/guides/local-guide-ch.md +2 -2
  305. package/docs/guides/local-guide-en.md +2 -2
  306. package/docs/integration/author-tools-ch.md +2 -2
  307. package/docs/integration/author-tools-en.md +2 -2
  308. package/docs/integration/compiler-ch.md +4 -2
  309. package/docs/integration/compiler-en.md +4 -2
  310. package/docs/integration/directory-discovery-ch.md +5 -1
  311. package/docs/integration/directory-discovery-en.md +5 -1
  312. package/docs/integration/editor-ch.md +35 -5
  313. package/docs/integration/editor-en.md +42 -4
  314. package/docs/integration/extension-sdk-ch.md +6 -4
  315. package/docs/integration/extension-sdk-en.md +6 -4
  316. package/docs/integration/local-integration-ch.md +201 -19
  317. package/docs/integration/local-integration-en.md +194 -18
  318. package/docs/integration/network-host-ch.md +75 -0
  319. package/docs/integration/network-host-en.md +75 -0
  320. package/docs/integration/shareable-export-ch.md +58 -16
  321. package/docs/integration/shareable-export-en.md +57 -15
  322. package/docs/reference/html-compatibility-ch.md +20 -67
  323. package/docs/reference/html-compatibility-en.md +19 -64
  324. package/docs/reference/local-interaction-syntax-ch.md +199 -26
  325. package/docs/reference/local-interaction-syntax-en.md +194 -27
  326. package/docs/reference/public-api-ch.md +416 -0
  327. package/docs/reference/public-api-en.md +416 -0
  328. package/docs/reference/theme-protocol-ch.md +27 -8
  329. package/docs/reference/theme-protocol-en.md +46 -8
  330. package/docs/releases/release-0.4.0-ch.md +2 -2
  331. package/docs/releases/release-0.4.0-en.md +2 -2
  332. package/docs/releases/release-0.8.0-ch.md +19 -3
  333. package/docs/releases/release-0.8.0-en.md +19 -3
  334. package/docs/releases/release-0.9.0-ch.md +44 -0
  335. package/docs/releases/release-0.9.0-en.md +44 -0
  336. package/docs/releases/release-0.9.1-ch.md +29 -0
  337. package/docs/releases/release-0.9.1-en.md +29 -0
  338. package/examples/component-package/README-ch.md +1 -1
  339. package/examples/component-package/README.md +1 -1
  340. package/examples/conformance/README-ch.md +3 -3
  341. package/examples/conformance/README.md +3 -3
  342. package/examples/game-2048-package/README-ch.md +3 -9
  343. package/examples/game-2048-package/README.md +8 -12
  344. package/examples/integration/README-ch.md +21 -2
  345. package/examples/integration/README.md +21 -2
  346. package/examples/integration/extension-sdk/README-ch.md +1 -1
  347. package/examples/integration/extension-sdk/README.md +1 -1
  348. package/examples/integration/streaming/index.html +48 -0
  349. package/examples/integration/streaming/main.js +175 -0
  350. package/examples/integration/streaming/package.json +13 -0
  351. package/examples/integration/streaming/worker.js +3 -0
  352. package/examples/local/README-ch.md +3 -3
  353. package/examples/local/README.md +2 -2
  354. package/examples/local/minimal-budget.reactive.md +48 -0
  355. package/examples/minimal-extension/README-ch.md +78 -0
  356. package/examples/minimal-extension/README.md +78 -0
  357. package/examples/minimal-extension/index.html +15 -0
  358. package/examples/minimal-extension/package.json +26 -0
  359. package/examples/minimal-extension/sample/document.reactive.md +10 -0
  360. package/examples/minimal-extension/scripts/build.mjs +32 -0
  361. package/examples/minimal-extension/scripts/export.mjs +72 -0
  362. package/examples/minimal-extension/scripts/test-node.mjs +75 -0
  363. package/examples/minimal-extension/src/extension.tsx +90 -0
  364. package/examples/minimal-extension/src/preview.tsx +12 -0
  365. package/examples/minimal-extension/src/source.ts +4 -0
  366. package/examples/minimal-extension/tsconfig.json +14 -0
  367. package/examples/network-survey/README.md +200 -0
  368. package/examples/network-survey/index.html +49 -0
  369. package/examples/network-survey/package.json +26 -0
  370. package/examples/network-survey/sample/document.reactive.md +51 -0
  371. package/examples/network-survey/src/components.tsx +325 -0
  372. package/examples/network-survey/src/host.ts +316 -0
  373. package/examples/network-survey/src/main.tsx +91 -0
  374. package/examples/network-survey/src/source.ts +1 -0
  375. package/examples/network-survey/tsconfig.json +26 -0
  376. package/examples/network-survey/vite.config.ts +227 -0
  377. package/examples/sci-fi-theme/README-ch.md +4 -2
  378. package/examples/sci-fi-theme/README.md +4 -2
  379. package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -0
  380. package/examples/sci-fi-theme/demo/demo.css +129 -23
  381. package/examples/sci-fi-theme/demo/document.reactive.md +27 -6
  382. package/examples/sci-fi-theme/demo/main.tsx +45 -10
  383. package/examples/sci-fi-theme/docs/design-system-ch.md +6 -6
  384. package/examples/sci-fi-theme/package.json +2 -1
  385. package/examples/sci-fi-theme/src/components.css +1064 -154
  386. package/examples/sci-fi-theme/src/notch.css +142 -0
  387. package/examples/sci-fi-theme/src/sci-fi.css +3 -1
  388. package/examples/sci-fi-theme/src/theme.ts +2 -0
  389. package/examples/sci-fi-theme/src/tokens.css +512 -408
  390. package/examples/tetris-package/README-ch.md +4 -4
  391. package/examples/tetris-package/README.md +4 -4
  392. package/package.json +70 -3
  393. package/dist-library/LocalDocumentView-6trX7xJc.js +0 -97920
  394. package/dist-library/compiler--ea2CKQF.js +0 -61
  395. package/dist-library/component-state-Cq2K5gkS.js +0 -490
  396. package/dist-library/options-CX5m5n-J.js +0 -115
  397. package/dist-library/runtime-C-sbfpOX.js +0 -1157
  398. package/dist-library/types/local/contracts/locale.d.ts +0 -1
  399. package/dist-library/types/local/contracts/version.d.ts +0 -2
  400. package/dist-library/types/local/evaluation/dates.d.ts +0 -2
  401. package/dist-library/types/local/evaluation/expression.d.ts +0 -47
  402. package/dist-library/types/local/markdown/markdown-structure.d.ts +0 -3
  403. package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +0 -36
  404. package/dist-library/types/local/session/incremental.d.ts +0 -48
  405. package/dist-library/types/local/source/node-walk.d.ts +0 -3
  406. package/dist-library/types/local/source/text-length.d.ts +0 -13
  407. package/dist-library/types/local/theme/theme-name.d.ts +0 -3
  408. package/dist-library/types/local/widgets/visuals.d.ts +0 -25
  409. package/dist-library/types/react/default-theme.d.ts +0 -6
  410. package/dist-library/validation-W-bmny-x.js +0 -2253
  411. package/docs/development/releasing-ch.md +0 -12
  412. package/docs/development/releasing-en.md +0 -12
  413. package/docs/integration/codemirror-ch.md +0 -52
  414. package/docs/integration/codemirror-en.md +0 -29
  415. package/docs/integration/repository-split-ch.md +0 -40
  416. package/docs/integration/repository-split-en.md +0 -23
  417. package/docs/reference/computations-formatting-ch.md +0 -89
  418. package/docs/reference/computations-formatting-en.md +0 -89
  419. package/docs/reference/constraints-collections-ch.md +0 -104
  420. package/docs/reference/constraints-collections-en.md +0 -104
  421. package/docs/reference/local-components-v2-ch.md +0 -140
  422. package/docs/reference/local-components-v2-en.md +0 -106
  423. package/docs/reference/tolerance-ch.md +0 -64
  424. package/docs/reference/tolerance-en.md +0 -57
  425. /package/dist-library/types/components/{chart-motion.d.ts → chart/chart-motion.d.ts} +0 -0
  426. /package/dist-library/types/components/{default-chart-types.d.ts → chart/default-chart-types.d.ts} +0 -0
  427. /package/dist-library/types/components/{default-chart.d.ts → chart/default-chart.d.ts} +0 -0
  428. /package/dist-library/types/components/{diagram-inspector.d.ts → diagram/diagram-inspector.d.ts} +0 -0
  429. /package/dist-library/types/{local/widgets/diagram-layout.d.ts → components/diagram/layout.d.ts} +0 -0
  430. /package/dist-library/types/components/{mafs-plot-grid.d.ts → plot/mafs-plot-grid.d.ts} +0 -0
  431. /package/dist-library/types/components/{mafs-visuals.d.ts → plot/mafs-visuals.d.ts} +0 -0
  432. /package/dist-library/types/components/{use-hydrated.d.ts → shared/use-hydrated.d.ts} +0 -0
  433. /package/dist-library/types/local/{theme/colors.d.ts → configuration/color-values.d.ts} +0 -0
  434. /package/dist-library/types/local/evaluation/{collection-functions.d.ts → expression/collection-functions.d.ts} +0 -0
  435. /package/dist-library/types/local/evaluation/{data-functions.d.ts → expression/data-functions.d.ts} +0 -0
  436. /package/dist-library/types/local/evaluation/{formatting.d.ts → expression/formatting.d.ts} +0 -0
  437. /package/dist-library/types/local/{markdown → parsing}/markdown-blocks.d.ts +0 -0
  438. /package/dist-library/types/local/{widgets → rendering/code}/code-block.d.ts +0 -0
  439. /package/dist-library/types/local/{widgets → rendering/code}/code-languages.d.ts +0 -0
  440. /package/dist-library/types/local/{widgets → rendering/image}/image-view.d.ts +0 -0
  441. /package/dist-library/types/local/{widgets → rendering}/math-view.d.ts +0 -0
@@ -1,12 +0,0 @@
1
- # 引擎发布
2
-
3
- **中文** · [English](releasing-en.md)
4
-
5
- reactive-md 独立维护版本;编辑器从自己的仓库发布 reactive-md-editor,Demo 独立构建站点。候选包更新与导入迁移见[三仓库迁移](../integration/repository-split-ch.md)。
6
-
7
- 1. 核对分支、本次 diff、目标版本与 registry 状态。更新 package.json、package-lock.json、变更记录及兼容说明;包版本与语法、协议版本分别管理。
8
- 2. 运行 npm ci、npm run check、npm run notices,检查 tarball 的 exports、声明路径与 notice。公开包检查在独立目录安装实际 tarball,不需要检出编辑器或 Demo。
9
- 3. 提交并推送已授权的发布源码。在对应 ref 手动触发 publish.yml,选择 dist_tag 与 update_latest。工作流使用 Node24、npm ^11.21 和 npm trusted publishing(OIDC);保留 npm 已配置的工作流文件名。工作流完成检查和构建后打包,仅发布不存在的版本;已存在的版本只更新请求的标签。本机不执行 npm publish 或 npm dist-tag。
10
- 4. 确认工作流成功,核对 registry 的版本、渠道和 integrity。授权后给对应源码创建 tag/Release;升级下游 registry 依赖前,在干净消费目录验证公开包。
11
-
12
- 编辑器首次发包前需单独配置其仓库与 publish.yml 的 npm trusted publisher。正式发布前,下游通过 vendor tarball 和锁文件固定候选组合。推送代码不自动发布 npm 或部署站点。
@@ -1,12 +0,0 @@
1
- # Engine release
2
-
3
- **English** · [中文](releasing-ch.md)
4
-
5
- reactive-md has an independent version. The editor publishes reactive-md-editor from its own repository and the Demo builds its own website artifact. See [repository migration](../integration/repository-split-en.md) for candidate updates and import changes.
6
-
7
- 1. Confirm branch, clean intended diff, target version and registry state. Update package.json, package-lock.json, changelog and relevant compatibility notes. Package and syntax/protocol versions are independent.
8
- 2. Run npm ci, npm run check, npm run notices. Review the packed exports, declaration paths and notices. The public-package check installs an actual tarball in an independent consumer; no Demo/editor checkout is needed.
9
- 3. Commit/push the authorized release source. Trigger publish.yml on that ref with the chosen dist_tag and update_latest. The workflow uses Node24, npm ^11.21 and npm trusted publishing (OIDC); preserve the workflow filename configured on npm. It checks/builds the package before packing and publishes only if that version does not exist. Existing versions only update the requested tags. Do not publish or change tags through a local npm login.
10
- 4. Confirm workflow success, registry version, tags and integrity. Tag/release the matching source when authorized. Verify the published package in a clean consumer before upgrading downstream registry dependencies.
11
-
12
- The editor needs its own npm trusted publisher for its repository and publish.yml. Candidate tarballs remain locked in consumer vendor directories until registry publication. Pushing code does not authorize npm publication or site deployment.
@@ -1,52 +0,0 @@
1
- # CodeMirror 6 编辑器集成
2
-
3
- **中文** · [English](codemirror-en.md)
4
-
5
- `0.7.0` 已统一使用 CM6。推荐从 [`reactive-md-editor`](editor-ch.md) 导入 `ReactiveMarkdownEditor`;本页的 `/editor/codemirror` 路径保留为同一组件的兼容别名。CM6 按视口创建源码行 DOM,使用原生历史和搜索,并提供工具栏、作者面板及视图切换。
6
-
7
- ```tsx
8
- import { useRef, useState } from 'react';
9
- import { ReactiveMarkdownCodeEditor, type ReactiveMarkdownCodeEditorHandle } from 'reactive-md-editor/codemirror';
10
- import 'reactive-md-editor/codemirror/styles.css';
11
-
12
- export function LongSourceEditor() {
13
- const [source, setSource] = useState('# 文档');
14
- const editor = useRef<ReactiveMarkdownCodeEditorHandle>(null);
15
- return <ReactiveMarkdownCodeEditor ref={editor} value={source} onChange={setSource}
16
- locale="zh" ariaLabel="文档源码" documentKey="document-1" />;
17
- }
18
- ```
19
-
20
- CM6 依赖随编辑器入口打包,公共类型不要求消费者安装 CodeMirror。组件可在服务端导入并渲染外框;编辑视图在客户端挂载。两条编辑器路径共用运行时代码和样式,基础文档渲染入口保持独立。
21
-
22
- ref 支持 `focus`、`selectRange`、`insertText`、`undo`、`redo`、`getSelection`、`getSource`、`getEditorElement` 和 `getVisibleRanges`。旧版 `textareaRef`、`getTextarea` 已移除;完整源码和选区通过 ref 读取。
23
-
24
- 所有范围均为原始源码中的 UTF-16 偏移。未修改的 CRLF、LF、CR、BOM 和 emoji 会保留;原生输入的新换行使用文档第一个换行的样式。CRLF 内部的偏移映射到该换行之前。受控回传保留历史;外部替换和 `documentKey` 变化重置历史及滚动位置。宿主可延迟回传;超过 120 次未确认修改的旧回传会作为外部替换处理。待确认队列保存逆向编辑。
25
-
26
- `onTransaction` 返回 `previousSource`、`source`、修订号、`changes`、选区和组合输入状态。`changes` 的所有范围对应 `previousSource`。多处编辑可合并为覆盖首末变化的替换,再交给 `LocalCompileScheduler.schedule(source, options, {baseSource, edit})`。提示会被验证;基线不同或提示无效时,沿用源码差分和完整请求恢复。
27
-
28
- 作者分析默认使用私有模块 Worker。宿主已有预览 Worker 时,在现有调度器生命周期启用分析:
29
-
30
- ```tsx
31
- import { LocalCompileScheduler, localCompileOptionsKey } from 'reactive-md';
32
-
33
- // 放入宿主已有的调度器生命周期,不要在 render 中创建。
34
- const scheduler = new LocalCompileScheduler({
35
- createWorker: createCompileWorker,
36
- includeAuthorAnalysis: true,
37
- onResult(outcome) {
38
- setAnalysis(outcome.analysis ? {
39
- source: outcome.source,
40
- optionsKey: localCompileOptionsKey(outcome.options),
41
- analysis: outcome.analysis,
42
- } : null);
43
- },
44
- });
45
- // <ReactiveMarkdownCodeEditor analysis={analysis} ... />
46
- ```
47
-
48
- `analysis={null}` 表示宿主结果待定,阻止创建私有 Worker;省略 `analysis` 启用私有 Worker。只接受与当前源码和选项签名一致的分析。成功编译复用同一文档及声明元数据生成作者分析;临时语义错误在 Worker 内按相同预算恢复语法高亮,预算或选项失败返回空分析。编译诊断仍通过 `diagnostics` 显示。旧 Worker 可继续编译;未提供分析时,作者面板等待支持分析的结果。
49
-
50
- `createAnalysisWorker` 可提供符合宿主 CSP 的工厂。默认模块 Worker 无法启动时使用现有主线程编译降级。分析时间记录在 `metrics.worker.analysisMs`。编辑器只装饰可见语法范围,绑定和引用每页显示 50 项。预览由宿主提供,在视图切换时保留 DOM。
51
-
52
- 自动检查覆盖组合事件与原生文字插入;物理中文输入法、移动端键盘和辅助技术需在目标设备验收。`npm run test:codemirror-browser` 复现生产 Edge 对照。性能与边界见 [实施报告](../development/performance-overview-ch.md)。
@@ -1,29 +0,0 @@
1
- # CodeMirror 6 editor integration
2
-
3
- **English** · [中文](codemirror-ch.md)
4
-
5
- `0.7.0` uses CM6 throughout. Prefer `ReactiveMarkdownEditor` from [`reactive-md-editor`](editor-en.md). The `/editor/codemirror` path remains a compatibility alias for the same component.
6
-
7
- ```tsx
8
- import { useState } from 'react';
9
- import { ReactiveMarkdownCodeEditor } from 'reactive-md-editor/codemirror';
10
- import 'reactive-md-editor/codemirror/styles.css';
11
-
12
- export function LongSourceEditor() {
13
- const [source, setSource] = useState('# Document');
14
- return <ReactiveMarkdownCodeEditor value={source} onChange={setSource}
15
- documentKey="document-1" ariaLabel="Source" />;
16
- }
17
- ```
18
-
19
- CM6 renders source lines around the viewport and provides native history, search, a toolbar, authoring panel and view controls. Both editor paths share the same runtime and stylesheet. Consumers do not need CM6 packages for public types. Server rendering produces the frame; the editing view mounts on the client. Core document rendering remains independent of the editor bundle.
20
-
21
- The ref supports `focus`, `selectRange`, `insertText`, `undo`, `redo`, `getSelection`, `getSource`, `getEditorElement` and `getVisibleRanges`. The old `textareaRef` and `getTextarea` APIs have been removed. Ranges use UTF-16 offsets in the original source. Untouched CRLF/LF/CR breaks, BOM and emoji are preserved. Native input uses the first line-break style for new breaks. Positions inside CRLF map to its beginning. Controlled acknowledgements retain history. External replacements and `documentKey` changes reset history and scroll. Up to 120 unacknowledged edits are tracked using inverse edits; older echoes become external replacements.
22
-
23
- `onTransaction` provides `previousSource`, `source`, revisions, `changes`, selection and composition state. All change ranges address `previousSource`. A host may merge them into one replacement and pass `{baseSource, edit}` as the third argument to `LocalCompileScheduler.schedule`. Invalid hints or different baselines use the existing diff and full-request recovery.
24
-
25
- For a shared preview Worker, enable scheduler `includeAuthorAnalysis: true`. Pass `analysis={{source: outcome.source, optionsKey: localCompileOptionsKey(outcome.options), analysis: outcome.analysis}}` when analysis exists. Both scheduler and key function come from `reactive-md`. Pass `analysis={null}` while waiting to disable the private analysis Worker; omitting `analysis` enables it. Source and options signatures must match. Analysis reuses the successful compiled document and declaration metadata. Temporary semantic errors recover syntax on the Worker with the same limits. Budget or options failures return empty analysis; diagnostics still appear through `diagnostics`. Older Workers keep compiling, but authoring waits for analysis-capable results.
26
-
27
- `createAnalysisWorker` can supply a CSP-compatible factory. If the default Worker cannot start, the scheduler uses its main-thread fallback. Analysis time is reported as `metrics.worker.analysisMs`. Only visible syntax ranges receive decorations; binding and reference lists show 50 items per page. Host-supplied preview DOM stays mounted across view changes.
28
-
29
- Physical IME, mobile keyboards and assistive technology need target-device acceptance; automation covers composition events and native text insertion. Run `npm run test:codemirror-browser` for production Edge checks. See the [implementation report](../development/performance-overview-en.md) for performance and limits.
@@ -1,40 +0,0 @@
1
- # 三仓库迁移
2
-
3
- **中文** · [English](repository-split-en.md)
4
-
5
- 三个仓库独立安装、构建、维护版本和发布:
6
-
7
- | 仓库 | 准备发布的版本 | 交付 |
8
- | --- | --- | --- |
9
- | [ReactiveMD](https://github.com/yao1145/ReactiveMD) | reactive-md@0.8.0 | 编译器、运行时、语言服务、SDK、React/SSR、导出 |
10
- | [ReactiveMD-Editor](https://github.com/yao1145/ReactiveMD-Editor) | reactive-md-editor@0.1.0(未发布) | CodeMirror、工具栏、导航、诊断呈现、编辑器 Worker |
11
- | [ReactiveMD-Demo](https://github.com/yao1145/ReactiveMD-Demo) | 私有网站包 0.1.0 | 示例网站、组件装配、静态资源和部署 |
12
-
13
- ## 导入路径
14
-
15
- 引擎 0.8 移除了旧 editor 子路径。这是包 API 的破坏性迁移;文档语法和状态协议版本保持原值。已发布的 0.7 包仍保留原入口。
16
-
17
- | 原路径 | 新路径 |
18
- | --- | --- |
19
- | reactive-md/editor | reactive-md-editor |
20
- | reactive-md/editor/codemirror | reactive-md-editor/codemirror |
21
- | reactive-md/editor/styles.css | reactive-md-editor/styles.css |
22
- | reactive-md/editor/codemirror/styles.css | reactive-md-editor/codemirror/styles.css |
23
-
24
- 编辑器只通过 reactive-md 和 reactive-md/authoring 使用引擎。通用 Worker、编译会话和语言服务仍由引擎维护;纯作者命令和组件目录可直接从 reactive-md/authoring 使用。
25
-
26
- ## 独立消费与更新
27
-
28
- 三个仓库已独立维护。发布准备使用真实引擎 tarball 构建编辑器,再让 Demo 安装两个实际 tarball。编辑器按公共 API 的兼容性声明引擎 peer 范围;开发安装与 Demo 用内容哈希 vendor 文件名及 lockfile integrity 固定候选组合。发布顺序为先引擎 0.8.0,再编辑器 0.1.0。
29
-
30
- 更新候选组合时,在引擎运行 npm run check、npm run notices,然后 npm pack --ignore-scripts。将生成包复制到编辑器和 Demo 的 vendor 目录,在各自目录 npm install 更新锁文件。运行编辑器 npm run check,打包编辑器并复制到 Demo/vendor;最后在 Demo npm install、npm test、npm run build,并运行本次涉及的浏览器检查。候选包内容变化时要更新实际 tarball 和锁文件,不能只修改版本字符串。
31
-
32
- 正式发布后,把 vendor 依赖改为对应 registry 版本范围并更新锁文件,在干净目录重新安装验证。编辑器根据引擎公共 API 兼容性声明 peer 范围,三个仓库无需同步版本号。
33
-
34
- ## 验证与发布职责
35
-
36
- 引擎 CI 使用一个 Node24 作业:类型、构建、核心回归、真实打包消费。编辑器负责自身类型、构建、命令/坐标/分析控制回归和公开引擎消费;Demo 负责网站构建、文档/导出回归及桌面和手机交互。删除旧阶段快照验收与重复矩阵,历史可通过拆分前提交追溯。
37
-
38
- 引擎与编辑器各自使用手动 publish.yml 和 npm OIDC。编辑器首次发布前需在 npm 配置对应仓库与工作流的 trusted publisher。Demo 独立构建站点产物,生产发布遵循其 AGENTS.md 的 SHA256 校验、相对软链接原子切换和回滚流程。提交或推送不自动发布 npm 或部署站点。
39
-
40
- Candidate tarball filenames include a SHA256 prefix. Use the exact vendor filenames in package.json; update those paths and lockfile integrity whenever package contents change.
@@ -1,23 +0,0 @@
1
- # Repository migration
2
-
3
- **English** · [中文](repository-split-ch.md)
4
-
5
- The language engine, editor and website have independent repositories, versions and release workflows:
6
-
7
- | Repository | Prepared release | Responsibility |
8
- | --- | --- | --- |
9
- | [ReactiveMD](https://github.com/yao1145/ReactiveMD) | reactive-md@0.8.0 | Compiler, runtime, sessions, Worker, authoring services, SDK, React/SSR, export |
10
- | [ReactiveMD-Editor](https://github.com/yao1145/ReactiveMD-Editor) | reactive-md-editor@0.1.0 (unpublished) | CodeMirror, toolbar, navigation, diagnostics, editor Worker |
11
- | [ReactiveMD-Demo](https://github.com/yao1145/ReactiveMD-Demo) | Private website package 0.1.0 | Website, examples, extension assembly, deployment |
12
-
13
- Engine 0.8 removes the old editor exports. Replace reactive-md/editor with reactive-md-editor, reactive-md/editor/codemirror with reactive-md-editor/codemirror, and the corresponding styles.css imports with the new package paths. Published 0.7 packages retain their original exports. The language syntax and state protocol keep their existing revisions.
14
-
15
- The editor consumes only public reactive-md and reactive-md/authoring APIs. Pure commands/catalogs remain available from reactive-md/authoring without the editor UI.
16
-
17
- Candidate consumers commit content-addressed vendor tarballs and lockfile integrity. The editor declares its engine peer range from public API compatibility; its development install and the Demo pin exact tarballs. Publish the 0.8.0 engine before the 0.1.0 editor. To update them: run the engine check and notices scripts, pack with --ignore-scripts, copy the package into the editor vendor directory, install in the editor, run its check and pack it, then update Demo/vendor if a website update is requested. Refresh tarballs and lockfiles whenever candidate contents change. After registry publication, switch to registry version ranges and verify a clean install.
18
-
19
- Engine CI runs one Node24 job for types, build, retained regressions and actual package consumption. Editor checks own UI services and public-engine consumption. Demo checks the website, export and desktop/mobile interaction. Historical phase matrices and duplicated acceptance tests are retired; Git history preserves them.
20
-
21
- The engine and editor each publish through a manual publish.yml workflow with npm OIDC. Configure a separate trusted publisher before the editor's first release. Website deployment follows the Demo AGENTS.md with SHA256 verification and an atomic relative-symlink switch. Repository pushes do not publish npm packages or deploy the website.
22
-
23
- Candidate tarball filenames include a SHA256 prefix. Use the exact vendor filenames in package.json; update those paths and lockfile integrity whenever package contents change.
@@ -1,89 +0,0 @@
1
- # 复用计算与格式化数值
2
-
3
- **中文** · [English](computations-formatting-en.md)
4
-
5
- 这些能力属于使用 `local-draft-2` 的 `0.4.0`。完整语法见[语法规范](local-interaction-syntax-ch.md),宿主接口见[集成说明](../integration/local-integration-ch.md),可运行文档见[账单示例](../../examples/local/recipes/invoice-zh.reactive.md)。
6
-
7
- ## 命名值
8
-
9
- ```markdown
10
- <const name="unitPrice" value="{{ 12.5 }}">
11
- <computed name="total" value="{{ quantity * unitPrice }}">
12
- <computed name="invoice" value="{{ formatCurrency(total, 'CNY', 2, 'zh-CN') }}">
13
-
14
- <number bind="quantity" label="数量" initial="2" min="0" max="100">
15
-
16
- 账单:**{{ invoice }}**。
17
-
18
- <if when="{{ total >= 100 }}">
19
- 达到批量配送门槛。
20
- </if>
21
- ```
22
-
23
- `computed` 和 `const` 是不可见的无结束标签声明。每条声明独占文档顶层的一行,也接受 `/>`。两者都必须提供 `name` 和完整的 `value="{{ 表达式 }}"`。值支持数字、字符串、布尔值、null、字符串数组或数字数组。编译器推断类型,无需类型标注,也不进行隐式转换。数组字面量与聚合见[集合说明](constraints-collections-ch.md)。
24
-
25
- 名称沿用 `bind` 的标识符和保留字规则。控件、槽位绑定与声明共用命名空间,声明不能覆盖其他声明或控件。容器内声明是编译错误。代码块、行内代码和注释内的声明保持原有的字面显示或惰性行为。
26
-
27
- 声明在整个文档中可见,可以先引用后声明。`computed` 可以读取控件、常量和其他计算值。`const` 可以读取其他常量和 `pi` 等内置常量,必须独立于控件与计算值。因此,固定单价、阈值等参数无需显示禁用输入框。常量不提供编辑或重置控件。
28
-
29
- 编译器从表达式 AST 提取全部分支的依赖,按依赖顺序推断类型。未知名称、重名、自引用和间接循环均产生带源码位置的错误;未执行分支里的环也属于编译错误。运算符和函数沿用普通表达式的类型规则。运行时仍可能出现域错误,例如读者把作为分母的控件改为零。顶层 `<external>` 声明的名称可作为 `computed`、文本和条件的只读依赖;`const` 不能依赖外部数据,外部名称也不会成为可写参数。
30
-
31
- 正文、动态属性、条件和图表表格中的数值单元格都可以读取命名值。可计算 LaTeX 公式中的多字母数字名称写为 `\mathrm{total}`,例如 `y = \mathrm{total} x`。格式化字符串用于正文或标签;图表数值单元格和曲线参数使用原始数字。
32
-
33
- ## 更新与错误
34
-
35
- 每个运行时独立缓存计算结果。同一修订内复用中间值;控件修改、原子槽位修改或面板重置成功后更新计算。常量在编译时求值,创建运行时时复制。隐藏内容保留其输入与计算;重置范围沿用现有控件子树规则。
36
-
37
- 消费者读取失败的计算值时,会收到其表达式错误,不会得到零、null 或上次成功值。独立消费者继续工作;有效输入可让失败的消费者恢复。逻辑与条件运算符保留运行时短路语义,未访问的分支不会读取其中的失败值。静态值非法的常量直接产生编译错误。
38
-
39
- `document.bindings` 与 `document.initialState` 描述可写控件。`document.computations` 保存可序列化的声明元数据,`document.externals` 保存只读外部声明。`runtime.snapshot().state` 还包含本次修订成功求出的命名值,失败值缺席;需要保留错误语义时使用 `runtime.evaluate(name)`。`set` 和 `setMany` 不能修改声明。对外数组继续防止外部修改污染运行时。
40
-
41
- ## 数字格式化
42
-
43
- 四个函数都返回字符串,可选参数按位置传入。
44
-
45
- | 函数 | 默认值与示例 |
46
- | --- | --- |
47
- | `formatNumber(value, digits, locale, grouping)` | `digits=2`、`locale="en-US"`、`grouping=true`;`formatNumber(1234.5)` 得到 `"1,234.50"` |
48
- | `formatPercent(value, digits, locale)` | `digits=0`、`locale="en-US"`;`formatPercent(0.125, 1)` 得到 `"12.5%"` |
49
- | `formatScientific(value, digits, locale)` | `digits=2`、`locale="en-US"`;`formatScientific(1234)` 得到 `"1.23E3"` |
50
- | `formatCurrency(value, currency, digits, locale)` | `currency="USD"`、`digits=2`、`locale="en-US"`;`formatCurrency(12.5)` 得到 `"$12.50"` |
51
-
52
- `digits` 必须是 0 至 20 的整数,同时固定最少与最多小数位;JPY 等货币也遵守该规则。`grouping` 必须是布尔值。地区只接受 `en-US`、`zh-CN`、`de-DE`、`fr-FR`、`ja-JP`,省略时固定为 `en-US`,与界面语言、设备设置无关;不支持的地区会报错。货币代码必须是 `Intl.NumberFormat` 接受的三个大写 ASCII 字母。这是代码形式检查,不是流通货币名录验证。
53
-
54
- 格式化采用十进制 `halfExpand` 舍入,中点向远离零的方向舍入:`formatNumber(1.005)` 为 `"1.01"`,`formatNumber(-1.005)` 为 `"-1.01"`。零不显示负号。表达式运算仍使用有限的 JavaScript 数字;原有 `round(x)` 保留 `Math.round` 的中点向正无穷规则。格式化只改变显示,不改变源数值。
55
-
56
- null 格式化为空字符串,其余参数严格检查类型,不把字符串自动转为数字。地区对应的标点、货币符号与空格来自宿主的 `Intl` 数据;跨平台需要逐字一致时,宿主应固定运行时及地区数据版本。
57
-
58
- ## 字符串
59
-
60
- | 函数 | 规则 |
61
- | --- | --- |
62
- | `trim(text)` | 去除首尾 JavaScript Unicode 空白 |
63
- | `lower(text)`、`upper(text)` | 使用不依赖地区的默认 Unicode 大小写映射 |
64
- | `startsWith(text, search)`、`endsWith(text, search)` | 区分大小写的字面匹配,空搜索串匹配成功 |
65
- | `replace(text, search, replacement)` | 替换全部不重叠的字面匹配;空搜索串报错;`$&` 等替换文本保持字面含义 |
66
- | `slice(text, start, end)` | 按 Unicode 码点索引,终点不包含在结果内,默认到末尾;负索引从末尾计算;索引必须为整数,超界时截到边界 |
67
-
68
- 这些函数要求字符串,null 也会产生类型错误。函数不接受正则表达式或属性访问。码点不等于字素簇,一个组合表情或带组合重音的字母可能包含多个码点。所有结果沿用 100,000 个 UTF-16 代码单元的字符串预算;替换函数在分配超大结果前检查扩张长度。
69
-
70
- ## 日期
71
-
72
- `dateCompare(a, b)` 返回 `-1`、`0` 或 `1`。`dateDiff(a, b, unit)` 返回有符号的 **a 减 b**,默认单位为 `"days"`,还支持 `"hours"`、`"minutes"`、`"seconds"`、`"milliseconds"`。
73
-
74
- 两项输入必须是有效的 `YYYY-MM-DD` 字符串,年份为 `0001` 至 `9999`,与日期控件一致,按公历校验闰日。每个日期表示 UTC 零点,因此设备时区和夏令时不会改变结果:`dateDiff("2026-03-09", "2026-03-08", "hours")` 为 `24`。时间戳、时区后缀和有歧义的地区日期格式会被拒绝。
75
-
76
- 空日期控件的值为 `""`,表示未选择日期。空串或非法日期产生域错误,null 产生类型错误。可选日期应先判断:
77
-
78
- ```markdown
79
- <computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
80
- 天数:{{ days == null ? '请选择两个日期' : formatNumber(days, 0) }}
81
- ```
82
-
83
- ## 诊断与预算
84
-
85
- 声明诊断采用 `local.computation.*`:`placement`、`name`、`reserved`、`duplicate`、`value`、`unknown`、`cycle`、`const`、`expression`、`budget`。表达式类型错误沿用 `local.expression.*`。诊断包含源码范围、行号和列号。计算图采用迭代式依赖排序,长链不依赖递归求值。源码、语法节点、表达式和值继续遵守现有预算,循环诊断数量也受诊断预算限制。
86
-
87
- ## 兼容性
88
-
89
- 现有表达式和 `round(x)` 保持原有行为。新增函数名称成为本版本的保留标识符;升级前应重命名使用这些名称的旧绑定,并同步修改引用。[变更记录](../../CHANGELOG-ch.md)记载了此次扩展。
@@ -1,89 +0,0 @@
1
- # Reusing calculations and formatting values
2
-
3
- **English** · [中文](computations-formatting-ch.md)
4
-
5
- These additions belong to `0.4.0`, which uses `local-draft-2`. See the [syntax specification](local-interaction-syntax-en.md), [integration API](../integration/local-integration-en.md) and [working example](../../examples/local/recipes/invoice.reactive.md).
6
-
7
- ## Named values
8
-
9
- ```markdown
10
- <const name="unitPrice" value="{{ 12.5 }}">
11
- <computed name="total" value="{{ quantity * unitPrice }}">
12
- <computed name="invoice" value="{{ formatCurrency(total) }}">
13
-
14
- <number bind="quantity" label="Quantity" initial="2" min="0" max="100">
15
-
16
- Invoice: **{{ invoice }}**.
17
-
18
- <if when="{{ total >= 100 }}">
19
- Eligible for bulk delivery.
20
- </if>
21
- ```
22
-
23
- `computed` and `const` are invisible, void declarations. Write each on its own line at document top level; `/>` is accepted too. Both require `name` and a complete `value="{{ expression }}"`. Their values use the expression types: number, string, boolean, null, string array or numeric array. The compiler infers the type; there is no type annotation or implicit conversion. See [collections](constraints-collections-en.md) for array literals and aggregates.
24
-
25
- Names follow the same identifier and reserved-name rules as `bind`. Controls, multi-slot bindings and declarations share one namespace. A declaration cannot replace another declaration or a control. Declarations inside containers are compile errors. Code fences, inline code and comments remain literal or inert.
26
-
27
- Declarations are visible throughout the document, including before their source position. A `computed` value may read controls, constants and other computations. A `const` may read other constants and built-in constants such as `pi`; it must remain independent of controls and computations. This supports fixed prices and thresholds without displaying a disabled input. Constants have no editing or reset control.
28
-
29
- The compiler extracts dependencies from the expression AST, including all conditional branches. It orders declarations by dependency before inferring types. Unknown names, duplicate names, self references and indirect cycles produce source-positioned errors. A cycle in an unused branch is still a compile error. Type checking uses the same operator and function rules as ordinary expressions; runtime domain errors remain possible, for example division by a control that becomes zero. Names declared by top-level `<external>` tags are valid read-only dependencies for `computed` values, text and conditions; a `const` cannot depend on external data, and external names never become writable parameters.
30
-
31
- Use a named value anywhere an expression is accepted: prose, dynamic attributes, conditions and numeric table cells used by charts. Computable LaTeX formulas read multi-letter numeric names as `\mathrm{total}`, for example `y = \mathrm{total} x`. Formatted strings belong in labels or prose; numeric chart cells and plot parameters need the underlying number.
32
-
33
- ## Updates and errors
34
-
35
- Each runtime owns its calculation cache. Computations are reused within a revision and refreshed after a successful control edit, atomic multi-slot edit or panel reset. Constants are evaluated at compilation and copied into each runtime. Hiding a section keeps its inputs and calculations; reset follows the existing control subtree rules.
36
-
37
- A failed calculation propagates its expression error when a consumer reads it. The runtime never substitutes zero, null or a previous successful value. Independent consumers continue to work, and a valid input edit lets failed consumers recover. Runtime logical and conditional operators keep their usual short-circuit behavior: an unvisited branch does not read its failed value. A constant with an invalid static value is a compile error.
38
-
39
- `document.bindings` and `document.initialState` describe writable controls. `document.computations` contains serializable declaration metadata, and `document.externals` contains the read-only external declarations. `runtime.snapshot().state` also contains successful named results for the current revision; failed results are absent. Use `runtime.evaluate(name)` to read a result with its error semantics. Declarations cannot be changed through `set` or `setMany`. Returned arrays remain protected from external mutation.
40
-
41
- ## Number formatting
42
-
43
- All four functions return strings. Optional arguments are positional.
44
-
45
- | Function | Defaults and example |
46
- | --- | --- |
47
- | `formatNumber(value, digits, locale, grouping)` | `digits=2`, `locale="en-US"`, `grouping=true`; `formatNumber(1234.5)` gives `"1,234.50"` |
48
- | `formatPercent(value, digits, locale)` | `digits=0`, `locale="en-US"`; `formatPercent(0.125, 1)` gives `"12.5%"` |
49
- | `formatScientific(value, digits, locale)` | `digits=2`, `locale="en-US"`; `formatScientific(1234)` gives `"1.23E3"` |
50
- | `formatCurrency(value, currency, digits, locale)` | `currency="USD"`, `digits=2`, `locale="en-US"`; `formatCurrency(12.5)` gives `"$12.50"` |
51
-
52
- `digits` must be an integer from 0 to 20. It fixes both minimum and maximum fraction digits, including for currencies such as JPY. `grouping` must be a boolean. Supported locales are exactly `en-US`, `zh-CN`, `de-DE`, `fr-FR` and `ja-JP`; omission always uses `en-US`, independently of the renderer's UI language or device settings. Unsupported locales are errors. Currency codes must be three uppercase ASCII letters accepted by `Intl.NumberFormat`; this is a syntax check, not a registry of circulating currencies.
53
-
54
- Formatting uses decimal `halfExpand` rounding: ties round away from zero, so `formatNumber(1.005)` gives `"1.01"` and `formatNumber(-1.005)` gives `"-1.01"`. Zero displays without a negative sign. Arithmetic still uses finite JavaScript numbers; `round(x)` retains its existing `Math.round` rule, with ties toward positive infinity. Formatting changes presentation, not the source number.
55
-
56
- A null value formats as an empty string. Other argument types remain strict: strings are not converted into numbers. Explicitly guard optional dates or text before applying their functions. Locale-specific punctuation, currency symbols and spacing follow the host's `Intl` data; hosts that need byte-identical text across platforms should pin their runtime and locale data.
57
-
58
- ## Strings
59
-
60
- | Function | Behavior |
61
- | --- | --- |
62
- | `trim(text)` | Remove leading and trailing JavaScript Unicode whitespace |
63
- | `lower(text)`, `upper(text)` | Default Unicode case conversion, independent of locale |
64
- | `startsWith(text, search)`, `endsWith(text, search)` | Case-sensitive literal checks; empty search matches |
65
- | `replace(text, search, replacement)` | Replace every non-overlapping literal match; empty search is an error; replacement text such as `$&` stays literal |
66
- | `slice(text, start, end)` | Unicode code point indices; end is exclusive and defaults to the length; negative indices count from the end; indices are integers and clamp to bounds |
67
-
68
- These functions require strings, including when the value is null. No regular expressions or property access are available. Code points are distinct from grapheme clusters: a combined emoji or an accented letter can contain several code points. All results keep the existing string budget of 100,000 UTF-16 code units. Replacement expansion is checked before constructing an oversized result.
69
-
70
- ## Dates
71
-
72
- `dateCompare(a, b)` returns `-1`, `0` or `1`. `dateDiff(a, b, unit)` returns the signed difference **a minus b**; the default unit is `"days"`. Other units are `"hours"`, `"minutes"`, `"seconds"` and `"milliseconds"`.
73
-
74
- Both arguments must be valid `YYYY-MM-DD` strings in years `0001` through `9999`, matching date controls. The calendar is Gregorian; leap days are validated. Each date means midnight UTC. Device timezone and daylight saving changes therefore do not change the result: `dateDiff("2026-03-09", "2026-03-08", "hours")` is `24`. Timestamps, timezone suffixes and ambiguous regional date strings are rejected.
75
-
76
- An empty date control contains `""`; this is an absent date, not epoch zero. Empty or invalid dates produce a domain error; null produces a type error. Guard optional dates explicitly:
77
-
78
- ```markdown
79
- <computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
80
- Days: {{ days == null ? 'Choose both dates' : formatNumber(days, 0) }}
81
- ```
82
-
83
- ## Diagnostics and limits
84
-
85
- Declaration diagnostics use `local.computation.*`: `placement`, `name`, `reserved`, `duplicate`, `value`, `unknown`, `cycle`, `const`, `expression` and `budget`. Expression type errors keep the existing `local.expression.*` codes. Diagnostics include source ranges, lines and columns. The graph uses an iterative dependency order, so long chains do not require recursive evaluation. Existing source, syntax-node, expression and value budgets still apply; cycle reports are capped by the diagnostic budget.
86
-
87
- ## Compatibility
88
-
89
- Existing expressions and `round(x)` keep their behavior. The new function names are reserved identifiers in this release. Rename any pre-existing bindings with these names and update their references before upgrading. The [changelog](../../CHANGELOG.md) lists this addition.
@@ -1,104 +0,0 @@
1
- # 条件、校验与本地集合
2
-
3
- **中文** · [English](constraints-collections-en.md)
4
-
5
- 这些能力扩展 `0.4.0`,并在 `local-draft-3` 中可用。[工作坊示例](../../examples/local/recipes/workshop-zh.reactive.md)把人数预算、日期区间和已选主题表格放在同一份文档里,[命名计算](computations-formatting-ch.md)保存其中间结果。
6
-
7
- ## 跨字段校验
8
-
9
- ```markdown
10
- <number bind="people" label="人数" initial="4" min="1" max="20">
11
- <number bind="capacity" label="房间容量" initial="3" min="1" max="20">
12
- <validation when="{{ people <= capacity }}" message="请选择能容纳 {{ people }} 人的房间。" fields="people capacity">
13
- ```
14
-
15
- `validation` 是无结束标签的块组件,必须提供 `when`、`message`、`fields`。`when` 包含一个完整的布尔表达式;`message` 是提示文字,可以包含普通插值;`fields` 以空白分隔关联的公开可写绑定名,名称不能重复,也可使用多槽位控件的绑定。规则能读取控件和计算值,允许前向引用。只读声明不能作为关联字段。
16
-
17
- 约束提示文档当前是否一致。读者可以继续编辑不一致的计划,初始值不满足跨字段规则也能正常显示和修改。例如,人数从四人改为六人后可能暂时超过容量,再换房间即可消除提示。单个控件原有的数字范围、日期合法性等规则继续拒绝非法写入。
18
-
19
- `runtime.validate()` 按源码顺序返回当前失败规则的诊断。条件为 false 时使用 `local.validation.failed`,表达式无法求值时使用 `local.validation.expression`,错误也视为失败。一条失败规则不会阻断其他规则。结果按运行时修订缓存,对外返回副本;编辑、原子槽位更新及重置会同步刷新计算与校验。
20
-
21
- 渲染器显示失败提示,并通过 `aria-describedby` 和 `aria-invalid` 把提示关联到字段或其可访问分组。提示 ID 属于各自文档实例;通过校验后清除错误文字。隐藏内容中的规则继续生效,但隐藏提示不会主动播报。每份文档最多有 100 条规则,隐藏区域也计入;诊断文字沿用 2,000 字符上限。
22
-
23
- ## 动态输入约束
24
-
25
- `number` 和 `slider` 的 `min`、`max` 可以动态;`date` 的 `min`、`max`、`required` 可以动态;`input` 和 `textarea` 的 `required` 可以动态。每个动态值都是一个完整插值:
26
-
27
- ```markdown
28
- <number bind="rooms" label="房间数" initial="2" min="1" max="5">
29
- <number bind="guests" label="旅客人数" initial="4" min="1" max="{{ rooms * 4 }}">
30
-
31
- <date bind="departure" label="出发日期" initial="2026-11-10">
32
- <date bind="return" label="返程日期" initial="2026-11-12" min="{{ departure }}">
33
-
34
- <input bind="company" label="公司名称" required="{{ business }}">
35
- ```
36
-
37
- 写入时按当时的约束校验,并继续保持原子提交。其他参数使范围收窄、已有值不再合法时,保留该值并在控件上显示约束错误;运行时绝不自动裁剪、重置或吸附到最近的合法值。调小字段以满足新范围,或恢复依赖值后,错误消失。动态 `required` 变为 true 且当前为空时只显示提示,不会自动填值。
38
-
39
- 动态边界无法求值、动态 `min` 大于 `max` 或动态日期边界非法时,相关写入被拒绝,状态和 revision 都不变。同名数值和日期绑定必须声明相同的静态范围;边界为动态时,表达式也必须相同。`step` 和文本长度限制仍为静态。`runtime.validate()` 保持原有跨字段含义;动态约束在写入时强制、在字段上显示。
40
-
41
- ## 受控的条件样式
42
-
43
- ```markdown
44
- <badge tone="{{ total <= budget ? 'success' : 'warning' }}">{{ formatCurrency(total) }}</badge>
45
- <alert tone="{{ total <= budget ? 'info' : 'warning' }}">预订前请核对预算。</alert>
46
- ```
47
-
48
- 本版本允许两个现有组件动态设置 `tone`:`badge` 接受 `neutral`、`success`、`warning`,`alert` 接受 `info`、`success`、`warning`。静态值保持原有行为。动态表达式必须是字符串类型,渲染器还会检查结果是否属于组件允许的枚举。表达式错误或非法值会使用默认样式并显示计算提示。这个条件接口不接受作者 CSS 类、样式字符串或动态颜色。
49
-
50
- 有限枚举可表达警告和成功状态,同时让主题继续控制颜色与对比度。更广泛的条件样式需要另行确定可访问性与主题规则。
51
-
52
- ## 数组与索引
53
-
54
- ```markdown
55
- <const name="fixedFees" value="{{ [100, 20, 5] }}">
56
- <computed name="fees" value="{{ [people * 80, includeKit ? people * 20 : 0] }}">
57
-
58
- 第一项:{{ fees[0] }}。合计:{{ sum(fees) }}。
59
- ```
60
-
61
- 数组字面量只能包含同一种类型的字符串或有限数字,元素表达式可以读取文档命名值。嵌套数组、混合类型、布尔值和 null 元素会被拒绝。`[]` 默认是空数字数组;条件分支直接写空字面量时,可采用另一分支的字符串数组类型,因此字符串多选值也可使用 `show ? subjects : []`。已有清单与多选控件继续产生字符串数组。公开类型 `LocalValue` 增加 `number[]`,`LocalValueKind` 增加 `number-array`,原来的 `array` 继续表示字符串数组。
62
-
63
- 索引从零开始,`values[0]` 读取第一项。索引必须是有限的安全整数;超出范围的整数(包括负数)返回 null,非整数报错。字符串和其他标量不能作为数组索引。数组不能直接插值显示,应使用索引、`len`、聚合或数据表格。
64
-
65
- `len` 支持两种数组;`contains` 在字符串数组中接受字符串,在数字数组中接受数字,原有字符串子串检查不变。每个数组最多 10,000 项;数组字面量还计入既有表达式长度、AST 节点和求值预算。字符串数组内容继续受字符预算限制。运行时返回数组副本,快照数组被冻结。
66
-
67
- ## 简单数字聚合
68
-
69
- | 函数 | 结果 |
70
- | --- | --- |
71
- | `sum(values)` | 数字数组之和,空数组返回 `0` |
72
- | `average(values)` | 算术平均值,空数组返回 null |
73
- | `minOf(values)` | 最小项,空数组返回 null |
74
- | `maxOf(values)` | 最大项,空数组返回 null |
75
-
76
- 聚合只接受数字数组,不自动转换看起来像数字的字符串。结果使用有限的 JavaScript 数字,求和或结果溢出会产生表达式错误;`average` 先求和再除以项数,中间求和溢出也会报错。空聚合产生的 null 沿用现有可空表达式规则,需要时先判断再参与数值运算。标量 `min`、`max`、`round` 保持原有签名与行为。
77
-
78
- ## 从本地值生成表格行
79
-
80
- ```markdown
81
- <const name="subjects" value="{{ ['mathematics', 'physics', 'chemistry'] }}">
82
-
83
- <data-table label="主题准备工作" rows="{{ subjects }}" key="{{ item }}" max-rows="3">
84
- <column label="主题" value="{{ item }}">
85
- <column label="序号" value="{{ index + 1 }}">
86
- <column label="准备工作" value="{{ item == 'chemistry' ? '准备材料' : '准备例题' }}">
87
- </data-table>
88
- ```
89
-
90
- `data-table` 是成对的块组件,必须提供可访问名称 `label`、完整数组表达式 `rows`,以及完整字符串或数字表达式 `key`。子内容只能是 1 至 20 个无结束标签的 `column` 声明。列必须提供静态标题 `label` 和完整的标量 `value` 表达式;单元格只输出文本,null 为空单元格。
91
-
92
- 每行有两个局部名称:`item` 是当前字符串或数字,`index` 是当前从零开始的位置。列表达式中这两个名称覆盖同名全局值,其他引用仍读取文档环境。`rows` 自身使用普通文档作用域。
93
-
94
- 键表达式只能依赖 `item`,且至少引用它一次,不能依赖 `index` 或其他文档值。表格检查键是否为非空字符串或有限数字,并确保唯一。数字键和字符串键属于不同标识,数字正负零视为同一标识;条目重排时保留 React 行身份。需要重复显示值时,应以不同的本地 ID 组成 `rows`,再根据 ID 生成显示列。重复键或非法键会使整张表显示错误。
95
-
96
- `max-rows` 是 1 至 1,000 的静态整数,默认 100。整份文档各表声明的行预算总和最多 2,000,行预算乘列数的总和最多 10,000 个单元格,隐藏表格也计入。每张生成表还有 100,000 个 UTF-16 代码单元的预算,覆盖表头、单元格、错误或空状态占位文字及编码后的行键。渲染器在显示行之前检查预算,超出时显示错误,不截断数据。
97
-
98
- 空数组显示表头与空状态。数据源或键求值失败时清除表格行并显示错误;单元格表达式失败只影响该单元格,其余内容继续显示。组件只生成原生表格行,不重复任意文档区块或控件。原有 Markdown 表格及其图表输入保持原有行为。
99
-
100
- ## 集成与兼容性
101
-
102
- `LocalDocument.validations` 保存可序列化的 `LocalValidation` 元数据,宿主可随时调用 `runtime.validate()`,调用不会修改状态。编译后的文档仍可用 `structuredClone` 传递给 Worker。对象生命周期和持久化规则见[集成说明](../integration/local-integration-ch.md)。
103
-
104
- 新增聚合函数名 `sum`、`average`、`minOf`、`maxOf` 成为保留字,升级前需重命名冲突绑定及其引用。对 `LocalValueKind` 做穷举检查的宿主应加入 `number-array`;可写多选与清单控件仍只接受字符串。预览版发布在 `next` 渠道。
@@ -1,104 +0,0 @@
1
- # Constraints, conditional tones and local collections
2
-
3
- **English** · [中文](constraints-collections-ch.md)
4
-
5
- These additions extend `0.4.0` and are available in `local-draft-3`. The [workshop example](../../examples/local/recipes/workshop.reactive.md) combines a participant budget, a date interval and a selected-subject table. [Named calculations](computations-formatting-en.md) hold its intermediate results.
6
-
7
- ## Cross-field validation
8
-
9
- ```markdown
10
- <number bind="people" label="Participants" initial="4" min="1" max="20">
11
- <number bind="capacity" label="Room capacity" initial="3" min="1" max="20">
12
- <validation when="{{ people <= capacity }}" message="Choose a room for at least {{ people }} people." fields="people capacity">
13
- ```
14
-
15
- `validation` is a void block component with required `when`, `message` and `fields` attributes. `when` must contain one complete boolean expression. `message` is text with optional ordinary interpolations. `fields` lists distinct public writable binding names, separated by whitespace; names from multi-slot controls are accepted too. A rule can read controls and computed values, including values declared later. Fields identify the controls associated with its hint; read-only declarations cannot be fields.
16
-
17
- Constraints report the current consistency of a document. Readers can still edit an inconsistent plan, including one whose initial values fail a cross-field rule. For example, changing the participant count from four to six can temporarily exceed room capacity; changing the room then clears the hint. Existing individual control rules, such as numeric bounds and invalid calendar dates, keep their write-rejection behavior.
18
-
19
- `runtime.validate()` returns diagnostics for all current failed rules in source order. It reports `local.validation.failed` when `when` is false and `local.validation.expression` when an expression cannot be evaluated. Errors count as failures. One failed rule does not stop independent rules. The result is cached for the current runtime revision and returned as defensive copies. Edits, atomic slot updates and resets refresh calculations and validation together.
20
-
21
- The renderer displays failed-rule hints and associates them with the corresponding controls or their accessible groups using `aria-describedby` and `aria-invalid`. Hint IDs belong to the mounted document instance. Success removes the error text. Rules in hidden content remain active, as do their bindings; hidden hints do not announce themselves. A document supports at most 100 validation rules, including hidden regions. Diagnostic messages retain the existing 2,000-character bound.
22
-
23
- ## Dynamic input constraints
24
-
25
- `number` and `slider` accept dynamic `min` and `max`; `date` accepts dynamic `min`, `max` and `required`; `input` and `textarea` accept dynamic `required`. Each dynamic value is one complete interpolation:
26
-
27
- ```markdown
28
- <number bind="rooms" label="Rooms" initial="2" min="1" max="5">
29
- <number bind="guests" label="Guests" initial="4" min="1" max="{{ rooms * 4 }}">
30
-
31
- <date bind="departure" label="Departure" initial="2026-11-10">
32
- <date bind="return" label="Return" initial="2026-11-12" min="{{ departure }}">
33
-
34
- <input bind="company" label="Company" required="{{ business }}">
35
- ```
36
-
37
- Write validation uses the constraints in effect at that moment and still commits atomically. When another parameter narrows a range so that an existing value becomes invalid, the value is kept and the control shows the constraint error; the runtime never clamps, resets or snaps it to a nearby legal value. Reducing a field to satisfy the new range, or restoring the dependency, clears the error. Dynamic `required` switching to true while a value is empty shows a hint and does not fill the field.
38
-
39
- A dynamic bound that cannot be evaluated, a dynamic `min` greater than `max`, or an invalid dynamic date bound rejects the related write and leaves state and revision unchanged. Shared numeric and date bindings must declare the same static range and, when a bound is dynamic, the same expression. `step` and text-length limits remain static. `runtime.validate()` keeps its cross-field meaning; dynamic constraint failures are enforced on writes and displayed on the field.
40
-
41
- ## Conditional visual emphasis
42
-
43
- ```markdown
44
- <badge tone="{{ total <= budget ? 'success' : 'warning' }}">{{ formatCurrency(total) }}</badge>
45
- <alert tone="{{ total <= budget ? 'info' : 'warning' }}">Review the estimate before booking.</alert>
46
- ```
47
-
48
- This build supports dynamic `tone` on two existing components. `badge` accepts `neutral`, `success` and `warning`; `alert` accepts `info`, `success` and `warning`. Static values retain their existing behavior. Dynamic expressions must have string type, and the renderer checks the returned value against the component's allowed tones. An error or unsupported value uses the default tone and a visible computation hint. CSS classes, author styles and colors remain outside this conditional API.
49
-
50
- The limited enum covers warning and success emphasis while keeping theme colors and contrast under host control. More general conditional styling would need separate accessibility and theme rules.
51
-
52
- ## Arrays and indexing
53
-
54
- ```markdown
55
- <const name="fixedFees" value="{{ [100, 20, 5] }}">
56
- <computed name="fees" value="{{ [people * 80, includeKit ? people * 20 : 0] }}">
57
-
58
- First fee: {{ fees[0] }}. Total: {{ sum(fees) }}.
59
- ```
60
-
61
- Array literals contain only strings or only finite numbers. Expressions inside a literal can read the document's named values. Nested arrays, mixed element types, booleans and null elements are rejected. `[]` is an empty numeric array by default; a direct empty literal in a conditional branch adopts a string-array sibling's kind, so `show ? subjects : []` works for string selections. Existing checklist and multi-select values remain string arrays. The public type `LocalValue` gains `number[]`, and `LocalValueKind` gains `number-array`; its existing `array` kind continues to mean a string array.
62
-
63
- Indexing is zero based: `values[0]` reads the first element. The index must be a finite safe integer. An integer outside the collection, including a negative index, returns null; a non-integer index is an error. Indexing a string or a scalar is a type error. Arrays themselves cannot be interpolated as text; use an index, `len`, an aggregate or a data table.
64
-
65
- `len` counts both kinds of array. `contains` accepts a string member for a string array and a number for a numeric array. String containment keeps its existing behavior. Every array is bounded by 10,000 elements; array literals also consume the existing expression-length, AST-node and evaluation budgets. The total contents of a string array keep the existing character budget. Returned runtime arrays are copied, and snapshot arrays are frozen.
66
-
67
- ## Numeric aggregates
68
-
69
- | Function | Result |
70
- | --- | --- |
71
- | `sum(values)` | Sum of a numeric array; empty input gives `0` |
72
- | `average(values)` | Arithmetic mean; empty input gives null |
73
- | `minOf(values)` | Smallest numeric member; empty input gives null |
74
- | `maxOf(values)` | Largest numeric member; empty input gives null |
75
-
76
- Aggregates accept numeric arrays, with no conversion of numeric-looking strings. Results use finite JavaScript numbers; an overflow in the sum or result is an expression error. `average` divides the sum by the count, so an overflowing intermediate sum is also an error. Null from an empty aggregate follows existing nullable-expression rules, so guard it before numeric operations when needed. Scalar `min`, `max` and `round` keep their existing signatures and behavior.
77
-
78
- ## Generate table rows from local values
79
-
80
- ```markdown
81
- <const name="subjects" value="{{ ['mathematics', 'physics', 'chemistry'] }}">
82
-
83
- <data-table label="Subject preparation" rows="{{ subjects }}" key="{{ item }}" max-rows="3">
84
- <column label="Subject" value="{{ item }}">
85
- <column label="Position" value="{{ index + 1 }}">
86
- <column label="Preparation" value="{{ item == 'chemistry' ? 'Prepare materials' : 'Prepare examples' }}">
87
- </data-table>
88
- ```
89
-
90
- `data-table` is a paired block component. It requires an accessible `label`, a complete array expression in `rows`, and a complete string or number expression in `key`. Its only children are 1 to 20 void `column` declarations. A column requires a static `label` and a complete scalar `value` expression. Cells output plain text; null gives an empty cell.
91
-
92
- Each row has two local names: `item` is the current string or number, and `index` is its current zero-based position. These names shadow same-named document values inside column expressions. Other references use the normal document environment. The source `rows` expression uses ordinary document scope.
93
-
94
- Keys depend only on `item`, including at least one reference to it. They cannot depend on `index` or other document values. The table checks that every evaluated key is a nonempty string or finite number and is unique. Numeric and string keys have distinct identities; signed numeric zeros have the same identity. React rows retain their identities when their items reorder. For records with repeated display values, use a collection of distinct local IDs as `rows` and derive the display cells from those IDs. Duplicate or invalid keys produce a whole-table error.
95
-
96
- `max-rows` is a static integer from 1 to 1,000, defaulting to 100. Across the document, declared row budgets may total at most 2,000 and row budgets multiplied by their column counts may total at most 10,000 cells. Hidden tables count too. Each generated table also has a budget of 100,000 UTF-16 code units for header text, cell text, error/empty placeholders and encoded row keys. The renderer checks budgets before exposing rows; exceeding them reports an error without truncating the data.
97
-
98
- An empty array displays the headers and an empty-state message. Failure of the row source or a key clears the table's rows and displays an error. A cell-expression failure is shown in that cell while independent cells remain readable. The component creates native table rows, not arbitrary repeated document sections or controls. Markdown tables and their existing chart inputs keep their original behavior.
99
-
100
- ## Integration and compatibility
101
-
102
- `LocalDocument.validations` contains serializable `LocalValidation` metadata. Hosts can call `runtime.validate()` at any time without changing state. The compiled document remains transferable to a Worker with `structuredClone`. The [core integration guide](../integration/local-integration-en.md) describes its lifetime and persistence rules.
103
-
104
- The aggregate names `sum`, `average`, `minOf` and `maxOf` become reserved identifiers. Rename conflicting bindings and their references before using this release. Hosts with exhaustive `LocalValueKind` checks should add `number-array`; writable multi-select and checklist controls still require strings. The preview is published on the `next` channel.