reactive-md 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG-ch.md +333 -319
  2. package/CHANGELOG.md +334 -320
  3. package/CONTRIBUTING-ch.md +22 -22
  4. package/CONTRIBUTING.md +22 -22
  5. package/README-ch.md +431 -431
  6. package/README-en.md +431 -431
  7. package/README.md +429 -429
  8. package/SECURITY-ch.md +83 -83
  9. package/SECURITY.md +83 -83
  10. package/bin/reactive-md.mjs +39 -39
  11. package/cli/args.mjs +263 -263
  12. package/cli/assets.mjs +395 -395
  13. package/cli/build.mjs +445 -445
  14. package/cli/check.mjs +444 -444
  15. package/cli/document.mjs +130 -130
  16. package/cli/errors.mjs +61 -61
  17. package/cli/fs-utils.mjs +133 -133
  18. package/cli/glob.mjs +203 -203
  19. package/cli/help.mjs +323 -323
  20. package/cli/init.mjs +1577 -1577
  21. package/cli/lint.mjs +177 -177
  22. package/cli/main.mjs +65 -65
  23. package/cli/migrate.mjs +368 -368
  24. package/cli/package-loader.mjs +41 -41
  25. package/cli/package.mjs +211 -211
  26. package/dist-library/{LocalDocumentView-sthUP0ct.js → LocalDocumentView-BuqgJZEY.js} +11 -11
  27. package/dist-library/{LocalDocumentViewCore-GiWV3bey.js → LocalDocumentViewCore-DXE0I0Qc.js} +210 -209
  28. package/dist-library/{LocalReactiveDocumentCore-ZjQSGyHE.js → LocalReactiveDocumentCore-CWBe4Mm5.js} +8 -8
  29. package/dist-library/{authoring-Dsune4Hy.js → authoring-Ci_KzJ0q.js} +53 -53
  30. package/dist-library/{compile-wUv8KEge.js → compile-Dx6Uw3D9.js} +11 -11
  31. package/dist-library/{compiler-core-As_m-MNm.js → compiler-core-DDDdvuLy.js} +883 -818
  32. package/dist-library/compiler-dxLPB9Ym.js +86 -0
  33. package/dist-library/{component-state-C52ZFJGl.js → component-state-BRwvTV0d.js} +15 -14
  34. package/dist-library/component-state-CwKX_SN5.js +763 -0
  35. package/dist-library/{config-BadfhjdP.js → config-DXLvctiZ.js} +68 -66
  36. package/dist-library/config-validation-D3D7Dy2J.js +586 -0
  37. package/dist-library/{controls-CcT6n7k_.js → controls-DoZyLCrV.js} +3 -3
  38. package/dist-library/{coordinate-CWS9p5q_.js → coordinate-B1VFK9fd.js} +2 -2
  39. package/dist-library/{data-table-Bgccxd7h.js → data-table-8-3F15Jf.js} +3 -3
  40. package/dist-library/{default-components-BwQf0oP-.js → default-components-s21NevON.js} +29 -28
  41. package/dist-library/{display-B-VhqVND.js → display-B_uutKkN.js} +1 -1
  42. package/dist-library/{config-validation-F47AcE6o.js → document-theme-C8J6UyNO.js} +193 -731
  43. package/dist-library/{export-BqVmTXm8.js → export-CIAIPBov.js} +35 -34
  44. package/dist-library/{gallery-CY6mTx8i.js → gallery-Dv1rOvL0.js} +1 -1
  45. package/dist-library/{html-CNT4KD-2.js → html-Cr4CBwAH.js} +42 -41
  46. package/dist-library/identity-BUx0Q_-d.js +40 -0
  47. package/dist-library/{incremental-Dv0FSp_U.js → incremental-9nx92u9c.js} +12 -10
  48. package/dist-library/{layout-C0YlEPGr.js → layout-BBB2VF0S.js} +1 -1
  49. package/dist-library/{mount-preset-KxvtKgJb.js → mount-preset-DMZ5wd3t.js} +3 -3
  50. package/dist-library/observability-4KqXhIEU.js +421 -0
  51. package/dist-library/observability-core-Bcu7vpnl.js +24 -0
  52. package/dist-library/{options-1aDLK7JY.js → options-BBp9IcHm.js} +4 -4
  53. package/dist-library/{package-core-WFK1RhAZ.js → package-core-K5xesGqy.js} +30 -29
  54. package/dist-library/{parser-standard-Yuf3A_VI.js → parser-standard-CBA1-hdG.js} +352 -352
  55. package/dist-library/{plugin-packs-B1XPWcFs.js → plugin-packs-Bh1HhLym.js} +3 -2
  56. package/dist-library/preset-core-DeZPA8IE.js +1298 -0
  57. package/dist-library/react-0DCh-Mar.js +7 -0
  58. package/dist-library/reactive-md-authoring.js +19 -19
  59. package/dist-library/reactive-md-build.js +48 -10
  60. package/dist-library/reactive-md-compiler-standard.js +6 -6
  61. package/dist-library/reactive-md-compiler.js +3 -3
  62. package/dist-library/reactive-md-default-packs.js +3 -2
  63. package/dist-library/reactive-md-default-preset.js +3 -2
  64. package/dist-library/reactive-md-export.js +4 -4
  65. package/dist-library/reactive-md-minimal-preset.js +2 -2
  66. package/dist-library/reactive-md-minimal-react-preset.js +3 -3
  67. package/dist-library/reactive-md-observability.js +4 -0
  68. package/dist-library/reactive-md-plugin-chart.js +3 -3
  69. package/dist-library/reactive-md-plugin-data.js +5 -5
  70. package/dist-library/reactive-md-plugin-diagram.js +4 -4
  71. package/dist-library/reactive-md-plugin-forms.js +4 -4
  72. package/dist-library/reactive-md-plugin-gallery.js +3 -3
  73. package/dist-library/reactive-md-plugin-navigation.js +3 -3
  74. package/dist-library/reactive-md-plugin-network.js +4 -3
  75. package/dist-library/reactive-md-plugin-plot.js +4 -4
  76. package/dist-library/reactive-md-print.css +304 -304
  77. package/dist-library/reactive-md-react-minimal.js +4 -4
  78. package/dist-library/reactive-md-react-server.js +6 -6
  79. package/dist-library/reactive-md-react-unstyled.js +11 -11
  80. package/dist-library/reactive-md-react.js +11 -11
  81. package/dist-library/reactive-md-runtime-browser.js +2 -1
  82. package/dist-library/reactive-md-runtime.js +4 -3
  83. package/dist-library/reactive-md-sdk.js +8 -7
  84. package/dist-library/reactive-md-standalone-configured.js +2 -2
  85. package/dist-library/reactive-md-standalone-host.js +2 -2
  86. package/dist-library/reactive-md-testing-browser.js +2 -2
  87. package/dist-library/reactive-md-testing-react.js +6 -6
  88. package/dist-library/reactive-md-testing.js +5 -5
  89. package/dist-library/reactive-md.js +556 -367
  90. package/dist-library/{registry-B9NGct4d.js → registry-D6OGkOcX.js} +3 -3
  91. package/dist-library/{registry-core-Bbad9Bm2.js → registry-core-C9xOunaw.js} +1 -1
  92. package/dist-library/{resources-D2GDQS0p.js → resources-B0x_w3s9.js} +71 -46
  93. package/dist-library/{runtime-B2fxeveq.js → runtime-BDnnimPA.js} +17 -16
  94. package/dist-library/{runtime-kcA7bG7G.js → runtime-BpQdZmFI.js} +311 -305
  95. package/dist-library/{schema-BufhKUSM.js → schema-BryM_VRW.js} +14 -14
  96. package/dist-library/{sdk-core-BoJT1SIt.js → sdk-core-ChslheKs.js} +33 -32
  97. package/dist-library/{session-core-nmJHuR9c.js → session-core-dxQCJBNa.js} +15 -14
  98. package/dist-library/{shareable-DpbE-59H.js → shareable-B8xMoGEa.js} +179 -176
  99. package/dist-library/types/build/diagnostics.d.ts +1 -1
  100. package/dist-library/types/local/index.d.ts +6 -0
  101. package/dist-library/types/local/observability-codes.d.ts +2 -0
  102. package/dist-library/types/local/observability-core.d.ts +25 -0
  103. package/dist-library/types/local/observability-messages.d.ts +6 -0
  104. package/dist-library/types/local/observability.d.ts +43 -0
  105. package/dist-library/types/local/parsing/parser-internals.d.ts +2 -1
  106. package/dist-library/types/local/transport/worker.d.ts +52 -1
  107. package/dist-library/types/local/types.d.ts +8 -0
  108. package/dist-library/types/observability.d.ts +7 -0
  109. package/dist-library/{types-BeNtPqdY.js → types-Ib5kSScP.js} +1 -1
  110. package/dist-library/types-daDo2c_w.js +3 -0
  111. package/dist-library/{validation-BEBA_HvS.js → validation-B3RI0xOk.js} +251 -249
  112. package/dist-library/version-DAxuGOG2.js +147 -0
  113. package/dist-library/{visual-frame-CyV1FXzs.js → visual-frame-_rcd5HUv.js} +1 -1
  114. package/dist-library/{visuals-BZbZYA7w.js → visuals-DkDhNdEZ.js} +17 -17
  115. package/dist-standalone/reactive-md-standalone.js +118 -118
  116. package/docs/README-ch.md +101 -95
  117. package/docs/README.md +101 -95
  118. package/docs/compatibility/api-stability-ch.md +25 -0
  119. package/docs/compatibility/api-stability-en.md +25 -0
  120. package/docs/compatibility/compatibility-ch.md +146 -129
  121. package/docs/compatibility/compatibility-en.md +146 -129
  122. package/docs/compatibility/compatibility-manifest.schema.json +161 -0
  123. package/docs/compatibility/deprecation-ch.md +21 -0
  124. package/docs/compatibility/deprecation-en.md +21 -0
  125. package/docs/compatibility/source-versioning-ch.md +162 -162
  126. package/docs/compatibility/source-versioning-en.md +162 -162
  127. package/docs/compatibility/support-matrix-ch.md +108 -0
  128. package/docs/compatibility/support-matrix-en.md +108 -0
  129. package/docs/development/component-development-ch.md +66 -66
  130. package/docs/development/component-development-en.md +66 -66
  131. package/docs/development/component-development-reference-ch.md +253 -253
  132. package/docs/development/component-development-reference-en.md +238 -238
  133. package/docs/development/component-protocol-ch.md +748 -748
  134. package/docs/development/component-protocol-en.md +750 -750
  135. package/docs/development/extension-tutorial-ch.md +308 -308
  136. package/docs/development/extension-tutorial-en.md +308 -308
  137. package/docs/development/performance-overview-ch.md +422 -422
  138. package/docs/development/performance-overview-en.md +422 -422
  139. package/docs/guides/local-guide-ch.md +532 -532
  140. package/docs/guides/local-guide-en.md +532 -532
  141. package/docs/integration/author-tools-ch.md +64 -64
  142. package/docs/integration/author-tools-en.md +64 -64
  143. package/docs/integration/compiler-ch.md +49 -49
  144. package/docs/integration/compiler-en.md +36 -36
  145. package/docs/integration/directory-discovery-en.md +1 -1
  146. package/docs/integration/editor-ch.md +295 -295
  147. package/docs/integration/editor-en.md +303 -303
  148. package/docs/integration/extension-sdk-ch.md +394 -394
  149. package/docs/integration/extension-sdk-en.md +379 -379
  150. package/docs/integration/local-integration-ch.md +646 -646
  151. package/docs/integration/local-integration-en.md +662 -662
  152. package/docs/integration/shareable-export-ch.md +307 -307
  153. package/docs/integration/shareable-export-en.md +309 -309
  154. package/docs/reference/diagnostics-counting-ch.md +104 -104
  155. package/docs/reference/diagnostics-counting-en.md +104 -104
  156. package/docs/reference/html-compatibility-ch.md +93 -93
  157. package/docs/reference/html-compatibility-en.md +95 -95
  158. package/docs/reference/local-interaction-syntax-ch.md +724 -724
  159. package/docs/reference/local-interaction-syntax-en.md +722 -722
  160. package/docs/reference/public-api-ch.md +33 -4
  161. package/docs/reference/public-api-en.md +33 -4
  162. package/docs/reference/theme-protocol-ch.md +198 -198
  163. package/docs/reference/theme-protocol-en.md +217 -217
  164. package/docs/releases/release-0.4.0-ch.md +91 -91
  165. package/docs/releases/release-0.4.0-en.md +91 -91
  166. package/docs/releases/release-0.4.1-ch.md +25 -25
  167. package/docs/releases/release-0.4.1-en.md +25 -25
  168. package/docs/releases/release-0.5.0-ch.md +43 -43
  169. package/docs/releases/release-0.5.0-en.md +43 -43
  170. package/docs/releases/release-0.5.1-ch.md +41 -41
  171. package/docs/releases/release-0.5.1-en.md +41 -41
  172. package/docs/releases/release-0.5.2-ch.md +37 -37
  173. package/docs/releases/release-0.5.2-en.md +37 -37
  174. package/docs/releases/release-0.5.3-ch.md +26 -26
  175. package/docs/releases/release-0.5.3-en.md +26 -26
  176. package/docs/releases/release-0.6.0-ch.md +59 -59
  177. package/docs/releases/release-0.6.0-en.md +59 -59
  178. package/docs/releases/release-0.6.1-ch.md +29 -29
  179. package/docs/releases/release-0.6.1-en.md +29 -29
  180. package/docs/releases/release-0.7.0-ch.md +86 -86
  181. package/docs/releases/release-0.7.0-en.md +86 -86
  182. package/docs/releases/release-0.9.2-ch.md +33 -0
  183. package/docs/releases/release-0.9.2-en.md +33 -0
  184. package/examples/component-package/README-ch.md +101 -101
  185. package/examples/component-package/README.md +133 -133
  186. package/examples/conformance/README-ch.md +55 -55
  187. package/examples/conformance/README.md +55 -55
  188. package/examples/conformance/component-protocol-1.json +482 -482
  189. package/examples/conformance/component-protocol-1.schema.json +76 -76
  190. package/examples/conformance/local-draft-1.json +50 -50
  191. package/examples/conformance/local-draft-2.json +212 -212
  192. package/examples/game-2048-package/LICENSE +21 -21
  193. package/examples/game-2048-package/NOTICES.md +11 -11
  194. package/examples/game-2048-package/README-ch.md +91 -91
  195. package/examples/game-2048-package/README.md +98 -98
  196. package/examples/game-2048-package/package.json +35 -35
  197. package/examples/game-2048-package/sample/document.reactive.md +17 -17
  198. package/examples/game-2048-package/scripts/build-export.mjs +44 -44
  199. package/examples/game-2048-package/scripts/build.mjs +130 -130
  200. package/examples/game-2048-package/scripts/verify.mjs +180 -180
  201. package/examples/game-2048-package/src/component.css +161 -161
  202. package/examples/game-2048-package/src/components.tsx +326 -326
  203. package/examples/game-2048-package/src/game-engine.ts +228 -228
  204. package/examples/game-2048-package/src/harness.tsx +34 -34
  205. package/examples/game-2048-package/src/manifest.ts +85 -85
  206. package/examples/game-2048-package/src/node-entry.ts +30 -30
  207. package/examples/game-2048-package/src/sample.ts +4 -4
  208. package/examples/game-2048-package/tsconfig.json +15 -15
  209. package/examples/integration/README-ch.md +82 -82
  210. package/examples/integration/README.md +82 -82
  211. package/examples/integration/core/index.mjs +32 -32
  212. package/examples/integration/extension-sdk/README-ch.md +24 -24
  213. package/examples/integration/extension-sdk/README.md +24 -24
  214. package/examples/integration/worker/index.html +19 -19
  215. package/examples/integration/worker/main.js +61 -61
  216. package/examples/integration/worker/package.json +13 -13
  217. package/examples/integration/worker/worker.js +3 -3
  218. package/examples/local/README-ch.md +76 -76
  219. package/examples/local/README.md +76 -76
  220. package/examples/local/charts.reactive.md +73 -73
  221. package/examples/local/recipes/invoice-zh.reactive.md +36 -36
  222. package/examples/local/recipes/invoice.reactive.md +36 -36
  223. package/examples/local/recipes/workshop-zh.reactive.md +33 -33
  224. package/examples/local/recipes/workshop.reactive.md +33 -33
  225. package/examples/local/showcase/README-ch.md +22 -22
  226. package/examples/local/showcase/README.md +31 -31
  227. package/examples/local/showcase/explore.reactive.md +102 -102
  228. package/examples/local/showcase/flow.reactive.md +86 -86
  229. package/examples/local/showcase/forms.reactive.md +126 -126
  230. package/examples/local/showcase/functions.reactive.md +119 -119
  231. package/examples/local/showcase/layout.reactive.md +100 -100
  232. package/examples/local/showcase/statistics.reactive.md +108 -108
  233. package/examples/local/showcase/tasks.reactive.md +89 -89
  234. package/examples/local/showcase/zh/explore.reactive.md +102 -102
  235. package/examples/local/showcase/zh/flow.reactive.md +86 -86
  236. package/examples/local/showcase/zh/forms.reactive.md +126 -126
  237. package/examples/local/showcase/zh/functions.reactive.md +119 -119
  238. package/examples/local/showcase/zh/layout.reactive.md +100 -100
  239. package/examples/local/showcase/zh/statistics.reactive.md +108 -108
  240. package/examples/local/showcase/zh/tasks.reactive.md +89 -89
  241. package/examples/minimal-extension/README-ch.md +78 -78
  242. package/examples/minimal-extension/README.md +78 -78
  243. package/examples/minimal-extension/index.html +15 -15
  244. package/examples/minimal-extension/package.json +26 -26
  245. package/examples/minimal-extension/sample/document.reactive.md +10 -10
  246. package/examples/minimal-extension/scripts/build.mjs +32 -32
  247. package/examples/minimal-extension/scripts/export.mjs +72 -72
  248. package/examples/minimal-extension/scripts/test-node.mjs +75 -75
  249. package/examples/minimal-extension/src/extension.tsx +90 -90
  250. package/examples/minimal-extension/src/preview.tsx +12 -12
  251. package/examples/minimal-extension/src/source.ts +4 -4
  252. package/examples/minimal-extension/tsconfig.json +14 -14
  253. package/examples/sci-fi-theme/README-ch.md +133 -133
  254. package/examples/sci-fi-theme/README.md +148 -148
  255. package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -454
  256. package/examples/sci-fi-theme/demo/demo.css +638 -638
  257. package/examples/sci-fi-theme/demo/document.reactive.md +206 -206
  258. package/examples/sci-fi-theme/demo/index.html +13 -13
  259. package/examples/sci-fi-theme/demo/main.tsx +215 -215
  260. package/examples/sci-fi-theme/docs/design-system-ch.md +245 -245
  261. package/examples/sci-fi-theme/docs/design-system.md +474 -474
  262. package/examples/sci-fi-theme/package.json +28 -28
  263. package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -98
  264. package/examples/sci-fi-theme/src/components.css +2370 -2370
  265. package/examples/sci-fi-theme/src/index.ts +6 -6
  266. package/examples/sci-fi-theme/src/notch.css +142 -142
  267. package/examples/sci-fi-theme/src/sci-fi.css +7 -7
  268. package/examples/sci-fi-theme/src/theme.ts +39 -39
  269. package/examples/sci-fi-theme/tsconfig.json +20 -20
  270. package/examples/sci-fi-theme/vite.config.ts +24 -24
  271. package/examples/tetris-package/LICENSE +21 -21
  272. package/examples/tetris-package/NOTICES.md +11 -11
  273. package/examples/tetris-package/README-ch.md +91 -91
  274. package/examples/tetris-package/README.md +95 -95
  275. package/examples/tetris-package/package.json +35 -35
  276. package/examples/tetris-package/sample/document.reactive.md +16 -16
  277. package/examples/tetris-package/scripts/build-export.mjs +44 -44
  278. package/examples/tetris-package/scripts/build.mjs +130 -130
  279. package/examples/tetris-package/scripts/verify.mjs +173 -173
  280. package/examples/tetris-package/src/component.css +145 -145
  281. package/examples/tetris-package/src/components.tsx +334 -334
  282. package/examples/tetris-package/src/harness.tsx +34 -34
  283. package/examples/tetris-package/src/manifests.ts +93 -93
  284. package/examples/tetris-package/src/node-entry.ts +16 -16
  285. package/examples/tetris-package/src/sample.ts +4 -4
  286. package/examples/tetris-package/src/tetris-engine.ts +325 -325
  287. package/examples/tetris-package/tsconfig.json +15 -15
  288. package/package.json +7 -1
  289. package/dist-library/compiler-eOfcinZs.js +0 -62
  290. package/dist-library/component-state-BoLCGee4.js +0 -801
  291. package/dist-library/preset-core-CKc5YXSM.js +0 -1443
  292. package/dist-library/react-D5iGiUdL.js +0 -7
@@ -1,64 +1,64 @@
1
- # 作者工具
2
-
3
- **中文** · [English](author-tools-en.md)
4
-
5
- 安装 `reactive-md@0.9.1` 即可使用 CLI 和不依赖 React 的 `reactive-md/authoring` 入口。从本仓库开发时,先构建语言包:
6
-
7
- ```sh
8
- npm ci
9
- npm run build
10
- npm run lint -- examples/local/planning.reactive.md
11
- ```
12
-
13
- ## 命令行检查
14
-
15
- 语言包提供 `reactive-md lint`。可以传入多个文件,或用 `-` 读取标准输入:
16
-
17
- ```sh
18
- reactive-md lint "my document.reactive.md" other.reactive.md
19
- reactive-md lint --json --warnings-as-errors document.reactive.md
20
- reactive-md lint --locale zh document.reactive.md
21
- cat document.reactive.md | reactive-md lint -
22
- ```
23
-
24
- 文本输出包含文件、行、列、严重程度和诊断代码。JSON 输出为 `{ file, ok, diagnostics }` 报告数组。诊断沿用编译器的 UTF-16 源码范围,行列从 1 开始。检查过程保留原文件。
25
-
26
- `--locale en|zh` 选择诊断消息语言,默认英文。切换语言保留诊断码、严重程度和位置。兼容契约与预算单位见[诊断与计数规则](../reference/diagnostics-counting-ch.md)。
27
-
28
- | 退出码 | 含义 |
29
- | --- | --- |
30
- | 0 | 没有错误;默认允许警告 |
31
- | 1 | 存在编译错误,或启用 `--warnings-as-errors` 后存在警告 |
32
- | 2 | 参数错误或文件读取失败 |
33
-
34
- ## 接入编辑器
35
-
36
- 核心入口提供与 DOM 无关的函数:
37
-
38
- ```js
39
- import {
40
- analyzeLocalSource, completeLocalSource,
41
- renameLocalBinding, formatLocalSource,
42
- } from 'reactive-md/authoring';
43
-
44
- const analysis = analyzeLocalSource(source, compileOptions);
45
- const suggestions = completeLocalSource(source, cursorOffset, compileOptions);
46
- const renamed = renameLocalBinding(source, 'people', 'attendees', compileOptions);
47
- const formatted = formatLocalSource(renamed.source, compileOptions);
48
- ```
49
-
50
- 分析结果包含按位置排序的高亮 token、绑定声明和引用范围,以及编译诊断。补全项包含 `label`、`kind`、`insertText` 和待替换的 `range`。应用编辑时,应使用生成这些范围的同一版本源码。
51
-
52
- 已有成功编译结果时,可调用 `analyzeLocalSource(source, compileOptions, { document, diagnostics: false })` 复用节点,并省略诊断编译。`document` 必须来自同一源码与编译配置;源码不同会重新解析。省略第三个参数时仍生成完整诊断。内置编辑器使用独立的增量会话复用作者分析节点,诊断由宿主编译结果提供。
53
-
54
- 重命名修改生效的绑定声明、表达式引用和绘图参数,保留普通文字与展示公式。绘图参数在重命名后写为 `\mathrm{newName}`。非法名称和名称冲突会抛出错误。格式化整理已识别组件标签内的空白,保留 Markdown 排版、引号内容、公式、代码与降级区域的源码。编辑器应持续保存原始文档。
55
-
56
- ## Playground
57
-
58
- 运行 `npm run dev`,选择“显示源码”。编辑器提供高亮、补全、绑定定位、重命名、格式化、诊断跳转与实时预览。通过补全按钮或 Ctrl+Space 打开建议列表,方向键选择,Enter 插入,Escape 关闭。重命名与格式化均可撤销、重做。
59
-
60
- ## 宿主编辑器配置
61
-
62
- `reactive-md/authoring` 还导出 `LOCAL_COMPONENTS`、`getLocalComponent`、`getNativeComponentCatalog`、`renderNativeSnippet`、`insertTemplate` 及其类型,无需 React 或 CSS。将预览使用的 `LocalCompileOptions` 传给这些函数的编译配置参数;省略时保持原有默认值。配置包括宿主 schema、HTML 模式、资源预算和 `markdownBreaks`。
63
-
64
- 作者工具入口与样式表接入见[公开接口参考](../reference/public-api-ch.md)的作者工具与样式表两节。
1
+ # 作者工具
2
+
3
+ **中文** · [English](author-tools-en.md)
4
+
5
+ 安装 `reactive-md@0.9.2` 即可使用 CLI 和不依赖 React 的 `reactive-md/authoring` 入口。从本仓库开发时,先构建语言包:
6
+
7
+ ```sh
8
+ npm ci
9
+ npm run build
10
+ npm run lint -- examples/local/planning.reactive.md
11
+ ```
12
+
13
+ ## 命令行检查
14
+
15
+ 语言包提供 `reactive-md lint`。可以传入多个文件,或用 `-` 读取标准输入:
16
+
17
+ ```sh
18
+ reactive-md lint "my document.reactive.md" other.reactive.md
19
+ reactive-md lint --json --warnings-as-errors document.reactive.md
20
+ reactive-md lint --locale zh document.reactive.md
21
+ cat document.reactive.md | reactive-md lint -
22
+ ```
23
+
24
+ 文本输出包含文件、行、列、严重程度和诊断代码。JSON 输出为 `{ file, ok, diagnostics }` 报告数组。诊断沿用编译器的 UTF-16 源码范围,行列从 1 开始。检查过程保留原文件。
25
+
26
+ `--locale en|zh` 选择诊断消息语言,默认英文。切换语言保留诊断码、严重程度和位置。兼容契约与预算单位见[诊断与计数规则](../reference/diagnostics-counting-ch.md)。
27
+
28
+ | 退出码 | 含义 |
29
+ | --- | --- |
30
+ | 0 | 没有错误;默认允许警告 |
31
+ | 1 | 存在编译错误,或启用 `--warnings-as-errors` 后存在警告 |
32
+ | 2 | 参数错误或文件读取失败 |
33
+
34
+ ## 接入编辑器
35
+
36
+ 核心入口提供与 DOM 无关的函数:
37
+
38
+ ```js
39
+ import {
40
+ analyzeLocalSource, completeLocalSource,
41
+ renameLocalBinding, formatLocalSource,
42
+ } from 'reactive-md/authoring';
43
+
44
+ const analysis = analyzeLocalSource(source, compileOptions);
45
+ const suggestions = completeLocalSource(source, cursorOffset, compileOptions);
46
+ const renamed = renameLocalBinding(source, 'people', 'attendees', compileOptions);
47
+ const formatted = formatLocalSource(renamed.source, compileOptions);
48
+ ```
49
+
50
+ 分析结果包含按位置排序的高亮 token、绑定声明和引用范围,以及编译诊断。补全项包含 `label`、`kind`、`insertText` 和待替换的 `range`。应用编辑时,应使用生成这些范围的同一版本源码。
51
+
52
+ 已有成功编译结果时,可调用 `analyzeLocalSource(source, compileOptions, { document, diagnostics: false })` 复用节点,并省略诊断编译。`document` 必须来自同一源码与编译配置;源码不同会重新解析。省略第三个参数时仍生成完整诊断。内置编辑器使用独立的增量会话复用作者分析节点,诊断由宿主编译结果提供。
53
+
54
+ 重命名修改生效的绑定声明、表达式引用和绘图参数,保留普通文字与展示公式。绘图参数在重命名后写为 `\mathrm{newName}`。非法名称和名称冲突会抛出错误。格式化整理已识别组件标签内的空白,保留 Markdown 排版、引号内容、公式、代码与降级区域的源码。编辑器应持续保存原始文档。
55
+
56
+ ## Playground
57
+
58
+ 运行 `npm run dev`,选择“显示源码”。编辑器提供高亮、补全、绑定定位、重命名、格式化、诊断跳转与实时预览。通过补全按钮或 Ctrl+Space 打开建议列表,方向键选择,Enter 插入,Escape 关闭。重命名与格式化均可撤销、重做。
59
+
60
+ ## 宿主编辑器配置
61
+
62
+ `reactive-md/authoring` 还导出 `LOCAL_COMPONENTS`、`getLocalComponent`、`getNativeComponentCatalog`、`renderNativeSnippet`、`insertTemplate` 及其类型,无需 React 或 CSS。将预览使用的 `LocalCompileOptions` 传给这些函数的编译配置参数;省略时保持原有默认值。配置包括宿主 schema、HTML 模式、资源预算和 `markdownBreaks`。
63
+
64
+ 作者工具入口与样式表接入见[公开接口参考](../reference/public-api-ch.md)的作者工具与样式表两节。
@@ -1,64 +1,64 @@
1
- # Author tools
2
-
3
- **English** · [中文](author-tools-ch.md)
4
-
5
- Install `reactive-md@0.9.1` to use the CLI and the React-free `reactive-md/authoring` entry. To work from this repository, build the package first:
6
-
7
- ```sh
8
- npm ci
9
- npm run build
10
- npm run lint -- examples/local/planning.reactive.md
11
- ```
12
-
13
- ## Command line
14
-
15
- The package provides `reactive-md lint`. Pass one or more document paths, or `-` to read stdin:
16
-
17
- ```sh
18
- reactive-md lint "my document.reactive.md" other.reactive.md
19
- reactive-md lint --json --warnings-as-errors document.reactive.md
20
- reactive-md lint --locale zh document.reactive.md
21
- cat document.reactive.md | reactive-md lint -
22
- ```
23
-
24
- Text output includes the file, line, column, severity and diagnostic code. JSON output is an array of `{ file, ok, diagnostics }` reports. Diagnostics use the compiler's original UTF-16 source ranges and one-based line/column positions. The command reads documents without changing them.
25
-
26
- `--locale en|zh` selects diagnostic messages and defaults to English. Codes, severity and locations stay identical across languages. See [Diagnostics and counting rules](../reference/diagnostics-counting-en.md) for the compatibility contract and budget units.
27
-
28
- | Exit code | Meaning |
29
- | --- | --- |
30
- | 0 | No errors; warnings are allowed by default |
31
- | 1 | Compiler errors, or warnings with `--warnings-as-errors` |
32
- | 2 | Invalid arguments or a file-read failure |
33
-
34
- ## Editor integration
35
-
36
- The core entry exposes DOM-independent functions:
37
-
38
- ```js
39
- import {
40
- analyzeLocalSource, completeLocalSource,
41
- renameLocalBinding, formatLocalSource,
42
- } from 'reactive-md/authoring';
43
-
44
- const analysis = analyzeLocalSource(source, compileOptions);
45
- const suggestions = completeLocalSource(source, cursorOffset, compileOptions);
46
- const renamed = renameLocalBinding(source, 'people', 'attendees', compileOptions);
47
- const formatted = formatLocalSource(renamed.source, compileOptions);
48
- ```
49
-
50
- Analysis returns ordered highlight tokens, bindings with declaration/reference ranges, and compiler diagnostics. Completions contain `label`, `kind`, `insertText` and the `range` to replace. Apply edits against the same source version that produced their ranges.
51
-
52
- With a successful compile result, call `analyzeLocalSource(source, compileOptions, { document, diagnostics: false })` to reuse its nodes and skip diagnostic compilation. The document must come from the same source and compile options; a different source is parsed again. Omitting the third argument still produces full diagnostics. The built-in editor uses its own incremental session for analysis nodes, while visible diagnostics come from the host compiler.
53
-
54
- Rename updates active binding declarations, expression references and computed plot parameters, preserving literal text and display formulas. Plot parameters use `\mathrm{newName}` after a rename. Invalid names and collisions throw an error. Formatting normalizes spacing inside recognized component tags; Markdown layout, quoted content, formulas, code and fallback regions retain their source. Keep the original source as the editable document.
55
-
56
- ## Playground
57
-
58
- Run `npm run dev` and choose **Show source**. The source editor provides highlighting, completion, binding locations, rename, formatting, diagnostic navigation and a live preview. Use the completion button or Ctrl+Space, arrow keys and Enter to insert a suggestion, and Escape to close the list. Rename and formatting participate in editor undo/redo.
59
-
60
- ## Host editor configuration
61
-
62
- The `reactive-md/authoring` entry also exports `LOCAL_COMPONENTS`, `getLocalComponent`, `getNativeComponentCatalog`, `renderNativeSnippet`, `insertTemplate` and their types. It loads without React or CSS. Pass the preview's `LocalCompileOptions` to each function's compile-options parameter; omitted options keep the existing defaults. This includes host schemas, HTML mode, resource limits and `markdownBreaks`.
63
-
64
- For the complete export list, see the [authoring tools section of the public API reference](../reference/public-api-en.md#authoring-tools).
1
+ # Author tools
2
+
3
+ **English** · [中文](author-tools-ch.md)
4
+
5
+ Install `reactive-md@0.9.2` to use the CLI and the React-free `reactive-md/authoring` entry. To work from this repository, build the package first:
6
+
7
+ ```sh
8
+ npm ci
9
+ npm run build
10
+ npm run lint -- examples/local/planning.reactive.md
11
+ ```
12
+
13
+ ## Command line
14
+
15
+ The package provides `reactive-md lint`. Pass one or more document paths, or `-` to read stdin:
16
+
17
+ ```sh
18
+ reactive-md lint "my document.reactive.md" other.reactive.md
19
+ reactive-md lint --json --warnings-as-errors document.reactive.md
20
+ reactive-md lint --locale zh document.reactive.md
21
+ cat document.reactive.md | reactive-md lint -
22
+ ```
23
+
24
+ Text output includes the file, line, column, severity and diagnostic code. JSON output is an array of `{ file, ok, diagnostics }` reports. Diagnostics use the compiler's original UTF-16 source ranges and one-based line/column positions. The command reads documents without changing them.
25
+
26
+ `--locale en|zh` selects diagnostic messages and defaults to English. Codes, severity and locations stay identical across languages. See [Diagnostics and counting rules](../reference/diagnostics-counting-en.md) for the compatibility contract and budget units.
27
+
28
+ | Exit code | Meaning |
29
+ | --- | --- |
30
+ | 0 | No errors; warnings are allowed by default |
31
+ | 1 | Compiler errors, or warnings with `--warnings-as-errors` |
32
+ | 2 | Invalid arguments or a file-read failure |
33
+
34
+ ## Editor integration
35
+
36
+ The core entry exposes DOM-independent functions:
37
+
38
+ ```js
39
+ import {
40
+ analyzeLocalSource, completeLocalSource,
41
+ renameLocalBinding, formatLocalSource,
42
+ } from 'reactive-md/authoring';
43
+
44
+ const analysis = analyzeLocalSource(source, compileOptions);
45
+ const suggestions = completeLocalSource(source, cursorOffset, compileOptions);
46
+ const renamed = renameLocalBinding(source, 'people', 'attendees', compileOptions);
47
+ const formatted = formatLocalSource(renamed.source, compileOptions);
48
+ ```
49
+
50
+ Analysis returns ordered highlight tokens, bindings with declaration/reference ranges, and compiler diagnostics. Completions contain `label`, `kind`, `insertText` and the `range` to replace. Apply edits against the same source version that produced their ranges.
51
+
52
+ With a successful compile result, call `analyzeLocalSource(source, compileOptions, { document, diagnostics: false })` to reuse its nodes and skip diagnostic compilation. The document must come from the same source and compile options; a different source is parsed again. Omitting the third argument still produces full diagnostics. The built-in editor uses its own incremental session for analysis nodes, while visible diagnostics come from the host compiler.
53
+
54
+ Rename updates active binding declarations, expression references and computed plot parameters, preserving literal text and display formulas. Plot parameters use `\mathrm{newName}` after a rename. Invalid names and collisions throw an error. Formatting normalizes spacing inside recognized component tags; Markdown layout, quoted content, formulas, code and fallback regions retain their source. Keep the original source as the editable document.
55
+
56
+ ## Playground
57
+
58
+ Run `npm run dev` and choose **Show source**. The source editor provides highlighting, completion, binding locations, rename, formatting, diagnostic navigation and a live preview. Use the completion button or Ctrl+Space, arrow keys and Enter to insert a suggestion, and Escape to close the list. Rename and formatting participate in editor undo/redo.
59
+
60
+ ## Host editor configuration
61
+
62
+ The `reactive-md/authoring` entry also exports `LOCAL_COMPONENTS`, `getLocalComponent`, `getNativeComponentCatalog`, `renderNativeSnippet`, `insertTemplate` and their types. It loads without React or CSS. Pass the preview's `LocalCompileOptions` to each function's compile-options parameter; omitted options keep the existing defaults. This includes host schemas, HTML mode, resource limits and `markdownBreaks`.
63
+
64
+ For the complete export list, see the [authoring tools section of the public API reference](../reference/public-api-en.md#authoring-tools).
@@ -1,49 +1,49 @@
1
- # 单次编译入口
2
-
3
- **中文** · [English](compiler-en.md)
4
-
5
- 当前工作区新增两个单次编译入口。它们返回普通数据,宿主可自行创建运行时或选择呈现方式。这些改动尚未发布到 npm。
6
-
7
- ```ts
8
- import { createCompiler } from 'reactive-md/compiler';
9
- import { createStandardCompiler } from 'reactive-md/compiler/standard';
10
-
11
- const compiler = createCompiler();
12
- const result = compiler.compile('# 说明\n\n普通 Markdown 正文。');
13
-
14
- const standard = createStandardCompiler();
15
- const interactive = standard.compile('<number bind="count" label="数量" initial="2">\n\n{{ count * 3 }}');
16
-
17
- if (interactive.ok) {
18
- console.log(interactive.document.initialState.count);
19
- }
20
- ```
21
-
22
- `createCompiler` 默认不注册组件;`createStandardCompiler` 显式装配默认组件预设和现有 KaTeX 显示预检。两者均执行源码、表达式、结构和资源预算检查,使用原始 UTF-16 源码范围。单次调用不创建编辑会话、Worker 或运行时,也不加载 React、主题实现和 CSS。主题声明只记录名称与源码位置,主题资源由宿主加载。
23
-
24
- 接入现有 React/SSR 宿主时使用 standard。最小入口只采用 `config.components`,`config.presets` 不会隐式安装默认预设;依赖默认组件的扩展应选择 standard。最小结果具有独立的 `componentConfigKey`,直接交给现有默认配置的渲染器会报告 `local.extension.config-mismatch`。支持无预设宿主配置属于后续宿主边界工作。
25
-
26
- 工厂接受 `LocalCompileOptions`,创建时校验并固定有效配置。无效配置抛出 `CompilerConfigurationError`。编译结果用 `status` 区分 `valid`、`recovered` 和 `failed`,同时保留任务 1 的 `ok/document/diagnostics` 读取方式。成功时还提供独立且逐层冻结的 `program`、恢复记录 `recoveries` 与检查覆盖 `checks`;失败时不包含 program。每次 `compile` 都重新编译当前源码,前一次的绑定、诊断和节点不会成为下一次的输入。
27
-
28
- 宽松模式下,每个最终恢复在 `causeRange` 上产生至多一条 warning,使用与记录相同的稳定 `code`,并说明片段被降级为惰性源文本或经过 HTML 修复。warning 受现有诊断预算约束;预算已满时可以省略 warning,`recoveries` 仍保留记录。`valid` 不包含恢复 warning;`recovered` 成功结果包含 program 和这些 warning。无法恢复的语义、类型、绑定、选项、版本和预算错误仍为 error:无效工厂配置抛出 `CompilerConfigurationError`,编译期错误返回 `failed`。失败结果可同时包含此前恢复产生的 warning 和导致失败的 error。严格模式仍为默认,诊断形状不变。恢复记录的字段和公共结果类型不变,恢复策略身份版本为 2。
29
-
30
- ```ts
31
- import { createCompiler, CompilerConfigurationError } from 'reactive-md/compiler';
32
-
33
- try {
34
- const compiler = createCompiler({ limits: { maxSyntaxNodes: 1000 } });
35
- const result = compiler.compile('{{ missing }}');
36
- console.log(result.ok, result.diagnostics);
37
- } catch (error) {
38
- if (error instanceof CompilerConfigurationError) console.error(error.message);
39
- else throw error;
40
- }
41
- ```
42
-
43
- 旧根入口的 `compileLocal(source, options)`、编辑会话和 Worker 默认保持严格语义,并保留原有返回类型。有恢复时会附加 `recoveries` 及对应 warning。显式传入 `strict: false` 可启用[局部恢复](local-integration-ch.md#严格解析与局部恢复)。
44
-
45
- 单次入口始终只做最终编译:`compileLocal`、`createCompiler().compile` 和 `createStandardCompiler().compile` 不承担流式生命周期,不会返回 `status: 'partial'` 或暂态诊断,`sourcePhase` 选项也不会把它们变成流式入口。仍在生成中的源码应交给 `createLocalCompileSession()`、`LocalCompileScheduler`、Worker 或 `LocalReactiveDocument`;见[流式源码编译](local-integration-ch.md#流式源码编译)。
46
-
47
- 最小入口保留 CommonMark、RMD 结构、表达式、绑定与预算。作者能力开关独立于 RMD 解析和绑定。原生 HTML 片段解析和净化、GFM、Lezer 块规划、KaTeX 和绘图公式语义由标准入口与兼容入口提供。最小入口的运行与声明依赖图不包含 `parse5`、`@lezer/markdown`、`remark-gfm`、KaTeX、默认预设及其作者信息。
48
-
49
- 构建后运行 `npm run test:compiler-entry`,检查直接 ESM 导入、生产共享 chunk、声明依赖和浏览器消费。源码行为回归使用 `npm test -- tests/compiler-entry.test.ts`。
1
+ # 单次编译入口
2
+
3
+ **中文** · [English](compiler-en.md)
4
+
5
+ ReactiveMD 提供最小和标准两个单次编译入口。它们返回普通数据,宿主可自行创建运行时或选择呈现方式。
6
+
7
+ ```ts
8
+ import { createCompiler } from 'reactive-md/compiler';
9
+ import { createStandardCompiler } from 'reactive-md/compiler/standard';
10
+
11
+ const compiler = createCompiler();
12
+ const result = compiler.compile('# 说明\n\n普通 Markdown 正文。');
13
+
14
+ const standard = createStandardCompiler();
15
+ const interactive = standard.compile('<number bind="count" label="数量" initial="2">\n\n{{ count * 3 }}');
16
+
17
+ if (interactive.ok) {
18
+ console.log(interactive.document.initialState.count);
19
+ }
20
+ ```
21
+
22
+ `createCompiler` 默认不注册组件;`createStandardCompiler` 显式装配默认组件预设和现有 KaTeX 显示预检。两者均执行源码、表达式、结构和资源预算检查,使用原始 UTF-16 源码范围。单次调用不创建编辑会话、Worker 或运行时,也不加载 React、主题实现和 CSS。主题声明只记录名称与源码位置,主题资源由宿主加载。
23
+
24
+ 接入现有 React/SSR 宿主时使用 standard。最小入口只采用 `config.components`,`config.presets` 不会隐式安装默认预设;依赖默认组件的扩展应选择 standard。最小结果具有独立的 `componentConfigKey`,直接交给现有默认配置的渲染器会报告 `local.extension.config-mismatch`。支持无预设宿主配置属于后续宿主边界工作。
25
+
26
+ 工厂接受 `LocalCompileOptions`,创建时校验并固定有效配置。无效配置抛出 `CompilerConfigurationError`。编译结果用 `status` 区分 `valid`、`recovered` 和 `failed`,同时保留任务 1 的 `ok/document/diagnostics` 读取方式。成功时还提供独立且逐层冻结的 `program`、恢复记录 `recoveries` 与检查覆盖 `checks`;失败时不包含 program。每次 `compile` 都重新编译当前源码,前一次的绑定、诊断和节点不会成为下一次的输入。
27
+
28
+ 宽松模式下,每个最终恢复在 `causeRange` 上产生至多一条 warning,使用与记录相同的稳定 `code`,并说明片段被降级为惰性源文本或经过 HTML 修复。warning 受现有诊断预算约束;预算已满时可以省略 warning,`recoveries` 仍保留记录。`valid` 不包含恢复 warning;`recovered` 成功结果包含 program 和这些 warning。无法恢复的语义、类型、绑定、选项、版本和预算错误仍为 error:无效工厂配置抛出 `CompilerConfigurationError`,编译期错误返回 `failed`。失败结果可同时包含此前恢复产生的 warning 和导致失败的 error。严格模式仍为默认,诊断形状不变。恢复记录的字段和公共结果类型不变,恢复策略身份版本为 2。
29
+
30
+ ```ts
31
+ import { createCompiler, CompilerConfigurationError } from 'reactive-md/compiler';
32
+
33
+ try {
34
+ const compiler = createCompiler({ limits: { maxSyntaxNodes: 1000 } });
35
+ const result = compiler.compile('{{ missing }}');
36
+ console.log(result.ok, result.diagnostics);
37
+ } catch (error) {
38
+ if (error instanceof CompilerConfigurationError) console.error(error.message);
39
+ else throw error;
40
+ }
41
+ ```
42
+
43
+ 旧根入口的 `compileLocal(source, options)`、编辑会话和 Worker 默认保持严格语义,并保留原有返回类型。有恢复时会附加 `recoveries` 及对应 warning。显式传入 `strict: false` 可启用[局部恢复](local-integration-ch.md#严格解析与局部恢复)。
44
+
45
+ 单次入口始终只做最终编译:`compileLocal`、`createCompiler().compile` 和 `createStandardCompiler().compile` 不承担流式生命周期,不会返回 `status: 'partial'` 或暂态诊断,`sourcePhase` 选项也不会把它们变成流式入口。仍在生成中的源码应交给 `createLocalCompileSession()`、`LocalCompileScheduler`、Worker 或 `LocalReactiveDocument`;见[流式源码编译](local-integration-ch.md#流式源码编译)。
46
+
47
+ 最小入口保留 CommonMark、RMD 结构、表达式、绑定与预算。作者能力开关独立于 RMD 解析和绑定。原生 HTML 片段解析和净化、GFM、Lezer 块规划、KaTeX 和绘图公式语义由标准入口与兼容入口提供。最小入口的运行与声明依赖图不包含 `parse5`、`@lezer/markdown`、`remark-gfm`、KaTeX、默认预设及其作者信息。
48
+
49
+ 构建后运行 `npm run test:compiler-entry`,检查直接 ESM 导入、生产共享 chunk、声明依赖和浏览器消费。源码行为回归使用 `npm test -- tests/compiler-entry.test.ts`。
@@ -1,36 +1,36 @@
1
- # One-shot compilation
2
-
3
- **English** · [中文](compiler-ch.md)
4
-
5
- The current workspace adds two compiler entries. They return plain data for a host to run or render. These changes have not been published to npm.
6
-
7
- ```ts
8
- import { createCompiler } from 'reactive-md/compiler';
9
- import { createStandardCompiler } from 'reactive-md/compiler/standard';
10
-
11
- const compiler = createCompiler();
12
- const result = compiler.compile('# Notes\n\nOrdinary Markdown.');
13
-
14
- const standard = createStandardCompiler();
15
- const interactive = standard.compile('<number bind="count" label="Count" initial="2">\n\n{{ count * 3 }}');
16
-
17
- if (interactive.ok) {
18
- console.log(interactive.document.initialState.count);
19
- }
20
- ```
21
-
22
- `createCompiler` registers no components by default. `createStandardCompiler` installs the default component preset and the existing KaTeX display checks. Both enforce source, expression, structure and resource limits and preserve original UTF-16 source ranges. Compilation creates no editing session, Worker or runtime and loads no React, theme implementation or CSS. Theme declarations retain a name and source range; the host loads theme resources.
23
-
24
- Use standard with the existing React/SSR hosts. The minimal entry reads `config.components`; `config.presets` does not implicitly install the default preset. Extensions that depend on default components need standard. A minimal result has its own `componentConfigKey`, so passing it to the existing renderer with its default configuration reports `local.extension.config-mismatch`. Host configurations without a preset are a later integration step.
25
-
26
- Factories accept `LocalCompileOptions`, validate them at creation and retain a snapshot of the effective configuration. Invalid configuration throws `CompilerConfigurationError`. Results use `status: 'valid' | 'recovered' | 'failed'` and retain the task-one `ok/document/diagnostics` read path. Success also includes an independently frozen `program`, recovery records and optional-check coverage. Failure contains no program. Each call compiles its own source without reusing a previous call's bindings, diagnostics or nodes.
27
-
28
- In loose mode, each finalized recovery produces at most one warning at `causeRange` with the same stable `code`, explaining the literal fallback or HTML repair. Warnings use the existing diagnostics budget; when it is full, a warning may be omitted while the record remains in `recoveries`. `valid` has no recovery warning; a `recovered` success includes the program and those warnings. Unrecoverable semantic, type, binding, option, version and budget errors remain errors: invalid factory configuration throws `CompilerConfigurationError`, and compile-time errors return `failed`. A failed result may include warnings from completed recoveries alongside the error that caused failure. Strict mode remains the default with its existing diagnostic shape. Recovery fields and public result types are unchanged, and the recovery strategy identity version is 2.
29
-
30
- The root `compileLocal(source, options)` entry, editing sessions and Workers keep strict semantics by default and retain their existing result types. Results include `recoveries` and their warnings when present. Pass `strict: false` to enable [local recovery](local-integration-en.md#strict-parsing-and-local-recovery).
31
-
32
- One-shot entries always compile a final document: `compileLocal`, `createCompiler().compile` and `createStandardCompiler().compile` do not own a streaming lifecycle, never return `status: 'partial'` or transient diagnostics, and the `sourcePhase` option does not turn them into streaming entries. Submit source that is still being generated through `createLocalCompileSession()`, `LocalCompileScheduler`, a Worker or `LocalReactiveDocument`; see [Streaming source compilation](local-integration-en.md#streaming-source-compilation).
33
-
34
- The minimal entry keeps CommonMark, RMD structure, expressions, bindings and budgets. Author capability switches are independent of RMD parsing and bindings. Use the standard or compatibility entry for native HTML fragment parsing and sanitization, GFM, Lezer block planning, KaTeX and plot formula semantics. The minimal runtime and declaration graphs exclude `parse5`, `@lezer/markdown`, `remark-gfm`, KaTeX, the default preset and its authoring copy.
35
-
36
- After building, run `npm run test:compiler-entry` to check direct ESM imports, production chunks, declaration dependencies and browser consumption. Run `npm test -- tests/compiler-entry.test.ts` for source behavior checks.
1
+ # One-shot compilation
2
+
3
+ **English** · [中文](compiler-ch.md)
4
+
5
+ ReactiveMD provides minimal and standard one-shot compiler entries. They return plain data for a host to run or render.
6
+
7
+ ```ts
8
+ import { createCompiler } from 'reactive-md/compiler';
9
+ import { createStandardCompiler } from 'reactive-md/compiler/standard';
10
+
11
+ const compiler = createCompiler();
12
+ const result = compiler.compile('# Notes\n\nOrdinary Markdown.');
13
+
14
+ const standard = createStandardCompiler();
15
+ const interactive = standard.compile('<number bind="count" label="Count" initial="2">\n\n{{ count * 3 }}');
16
+
17
+ if (interactive.ok) {
18
+ console.log(interactive.document.initialState.count);
19
+ }
20
+ ```
21
+
22
+ `createCompiler` registers no components by default. `createStandardCompiler` installs the default component preset and the existing KaTeX display checks. Both enforce source, expression, structure and resource limits and preserve original UTF-16 source ranges. Compilation creates no editing session, Worker or runtime and loads no React, theme implementation or CSS. Theme declarations retain a name and source range; the host loads theme resources.
23
+
24
+ Use standard with the existing React/SSR hosts. The minimal entry reads `config.components`; `config.presets` does not implicitly install the default preset. Extensions that depend on default components need standard. A minimal result has its own `componentConfigKey`, so passing it to the existing renderer with its default configuration reports `local.extension.config-mismatch`. Host configurations without a preset are a later integration step.
25
+
26
+ Factories accept `LocalCompileOptions`, validate them at creation and retain a snapshot of the effective configuration. Invalid configuration throws `CompilerConfigurationError`. Results use `status: 'valid' | 'recovered' | 'failed'` and retain the task-one `ok/document/diagnostics` read path. Success also includes an independently frozen `program`, recovery records and optional-check coverage. Failure contains no program. Each call compiles its own source without reusing a previous call's bindings, diagnostics or nodes.
27
+
28
+ In loose mode, each finalized recovery produces at most one warning at `causeRange` with the same stable `code`, explaining the literal fallback or HTML repair. Warnings use the existing diagnostics budget; when it is full, a warning may be omitted while the record remains in `recoveries`. `valid` has no recovery warning; a `recovered` success includes the program and those warnings. Unrecoverable semantic, type, binding, option, version and budget errors remain errors: invalid factory configuration throws `CompilerConfigurationError`, and compile-time errors return `failed`. A failed result may include warnings from completed recoveries alongside the error that caused failure. Strict mode remains the default with its existing diagnostic shape. Recovery fields and public result types are unchanged, and the recovery strategy identity version is 2.
29
+
30
+ The root `compileLocal(source, options)` entry, editing sessions and Workers keep strict semantics by default and retain their existing result types. Results include `recoveries` and their warnings when present. Pass `strict: false` to enable [local recovery](local-integration-en.md#strict-parsing-and-local-recovery).
31
+
32
+ One-shot entries always compile a final document: `compileLocal`, `createCompiler().compile` and `createStandardCompiler().compile` do not own a streaming lifecycle, never return `status: 'partial'` or transient diagnostics, and the `sourcePhase` option does not turn them into streaming entries. Submit source that is still being generated through `createLocalCompileSession()`, `LocalCompileScheduler`, a Worker or `LocalReactiveDocument`; see [Streaming source compilation](local-integration-en.md#streaming-source-compilation).
33
+
34
+ The minimal entry keeps CommonMark, RMD structure, expressions, bindings and budgets. Author capability switches are independent of RMD parsing and bindings. Use the standard or compatibility entry for native HTML fragment parsing and sanitization, GFM, Lezer block planning, KaTeX and plot formula semantics. The minimal runtime and declaration graphs exclude `parse5`, `@lezer/markdown`, `remark-gfm`, KaTeX, the default preset and its authoring copy.
35
+
36
+ After building, run `npm run test:compiler-entry` to check direct ESM imports, production chunks, declaration dependencies and browser consumption. Run `npm test -- tests/compiler-entry.test.ts` for source behavior checks.
@@ -32,4 +32,4 @@ The dev server watches entry creation, deletion and renaming. Theme CSS and asse
32
32
 
33
33
  Use `reactiveMd({ themeDir: 'themes', pluginDir: 'components' })` for alternate roots. Advanced hosts can keep `reactiveMd({ extensions: './extensions.ts' })`, whose module exports `host = createReactHost(...)`. Manual and directory options are mutually exclusive. Keep application metadata, such as example navigation, in ordinary application modules.
34
34
 
35
- The Demo uses its existing Tetris and 2048 packages and sci-fi theme through these directories. Its local sci-fi CSS was copied from the installed theme package's public CSS entries; synchronize those files when updating that package.
35
+ The Demo uses its existing Tetris and 2048 packages and sci-fi theme through these directories. Its local sci-fi CSS was copied from the installed theme package's public CSS entries; synchronize those files when updating that package.