reactive-md 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. package/CHANGELOG-ch.md +66 -0
  2. package/CHANGELOG.md +66 -0
  3. package/CONTRIBUTING-ch.md +6 -62
  4. package/CONTRIBUTING.md +5 -63
  5. package/README-ch.md +232 -67
  6. package/README-en.md +209 -71
  7. package/README.md +209 -71
  8. package/SECURITY-ch.md +3 -1
  9. package/SECURITY.md +3 -1
  10. package/THIRD_PARTY_NOTICES.md +1909 -87
  11. package/cli/args.mjs +33 -1
  12. package/cli/build.mjs +62 -1
  13. package/cli/check.mjs +444 -0
  14. package/cli/help.mjs +181 -3
  15. package/cli/init.mjs +1577 -0
  16. package/cli/main.mjs +11 -1
  17. package/cli/package-loader.mjs +41 -0
  18. package/dist-library/LocalDocumentView-6trX7xJc.js +97920 -0
  19. package/dist-library/{authoring-BEVyth5X.js → authoring-BsfSwQRm.js} +237 -209
  20. package/dist-library/compiler--ea2CKQF.js +61 -0
  21. package/dist-library/compiler-core-kPiH-gOV.js +11805 -0
  22. package/dist-library/component-state-Cq2K5gkS.js +490 -0
  23. package/dist-library/component-state-D_cw_EHe.js +54 -0
  24. package/dist-library/config-validation-DXTynAw7.js +3005 -0
  25. package/dist-library/default-components-Z_YMio5P.js +2346 -0
  26. package/dist-library/identity-MYJXKSkB.js +1443 -0
  27. package/dist-library/math-display-BJz4gbFc.js +24000 -0
  28. package/dist-library/math-sample-BGEW49zY.js +1124 -0
  29. package/dist-library/options-CX5m5n-J.js +115 -0
  30. package/dist-library/parser-standard-DlCk7sLo.js +10122 -0
  31. package/dist-library/props-DGlBk0e5.js +183 -0
  32. package/dist-library/react-ByOHunUW.js +122 -0
  33. package/dist-library/reactive-md-authoring.js +712 -1077
  34. package/dist-library/reactive-md-build.js +7966 -0
  35. package/dist-library/reactive-md-compiler-standard.js +33 -0
  36. package/dist-library/reactive-md-compiler.js +22 -0
  37. package/dist-library/reactive-md-default-packs.js +71 -0
  38. package/dist-library/reactive-md-default-preset.js +10 -0
  39. package/dist-library/reactive-md-export.js +111 -0
  40. package/dist-library/reactive-md-print.css +18 -3
  41. package/dist-library/reactive-md-react-runtime.js +251 -0
  42. package/dist-library/reactive-md-react-server.js +55 -0
  43. package/dist-library/reactive-md-react-unstyled.js +9 -1
  44. package/dist-library/reactive-md-react.js +9 -1
  45. package/dist-library/reactive-md-runtime-browser.js +51 -0
  46. package/dist-library/reactive-md-runtime.js +3 -0
  47. package/dist-library/reactive-md-sdk.js +6 -0
  48. package/dist-library/reactive-md-standalone-host.js +442 -0
  49. package/dist-library/reactive-md-testing-browser.js +523 -0
  50. package/dist-library/reactive-md-testing-react.js +221 -0
  51. package/dist-library/reactive-md-testing.js +638 -0
  52. package/dist-library/reactive-md-vite.js +959 -0
  53. package/dist-library/reactive-md.css +1 -1
  54. package/dist-library/reactive-md.js +1080 -795
  55. package/dist-library/registry-B9Jc3FVe.js +1174 -0
  56. package/dist-library/resources-BGt8mpDA.js +204 -0
  57. package/dist-library/runtime-C-sbfpOX.js +1157 -0
  58. package/dist-library/runtime-Dkq7ldyg.js +172 -0
  59. package/dist-library/schema-ZFufO8V0.js +39 -0
  60. package/dist-library/shareable-DDVL4Fi9.js +844 -0
  61. package/dist-library/types/authoring/catalog.d.ts +168 -0
  62. package/dist-library/types/authoring/conformance.d.ts +24 -0
  63. package/dist-library/types/{editor → authoring}/editor-i18n.d.ts +3 -24
  64. package/dist-library/types/authoring/extensions.d.ts +13 -0
  65. package/dist-library/types/authoring/index.d.ts +14 -11
  66. package/dist-library/types/authoring/insert.d.ts +16 -0
  67. package/dist-library/types/{editor → authoring}/native-components.d.ts +19 -2
  68. package/dist-library/types/authoring/templates.d.ts +65 -0
  69. package/dist-library/types/build/diagnostics.d.ts +8 -0
  70. package/dist-library/types/build/digest.d.ts +5 -0
  71. package/dist-library/types/build/entry.d.ts +9 -0
  72. package/dist-library/types/build/host.d.ts +36 -0
  73. package/dist-library/types/build/index.d.ts +99 -0
  74. package/dist-library/types/build/notices.d.ts +29 -0
  75. package/dist-library/types/build/resources.d.ts +60 -0
  76. package/dist-library/types/build/vite.d.ts +15 -0
  77. package/dist-library/types/compiler/index.d.ts +22 -0
  78. package/dist-library/types/compiler/result.d.ts +30 -0
  79. package/dist-library/types/compiler/standard.d.ts +16 -0
  80. package/dist-library/types/compiler/types.d.ts +69 -0
  81. package/dist-library/types/components/chart-motion.d.ts +12 -0
  82. package/dist-library/types/components/controls.d.ts +21 -0
  83. package/dist-library/types/{local → components}/data-table.d.ts +10 -24
  84. package/dist-library/types/components/default-chart-types.d.ts +22 -0
  85. package/dist-library/types/components/default-chart.d.ts +2 -0
  86. package/dist-library/types/components/default-preset.d.ts +10 -0
  87. package/dist-library/types/components/diagram-inspector.d.ts +24 -0
  88. package/dist-library/types/components/gallery.d.ts +6 -0
  89. package/dist-library/types/components/layout.d.ts +23 -0
  90. package/dist-library/types/components/mafs-plot-grid.d.ts +57 -0
  91. package/dist-library/types/components/mafs-visuals.d.ts +40 -0
  92. package/dist-library/types/components/numeric-sliders.d.ts +3 -0
  93. package/dist-library/types/components/uiarc/calendar/calendar.d.ts +26 -0
  94. package/dist-library/types/components/uiarc/date-picker/date-picker.d.ts +29 -0
  95. package/dist-library/types/components/uiarc/lib/motion-tokens.d.ts +2 -0
  96. package/dist-library/types/components/uiarc/lib/use-today.d.ts +2 -0
  97. package/dist-library/types/components/uiarc/motion-tokens.d.ts +60 -0
  98. package/dist-library/types/components/uiarc/rmd-motion.d.ts +12 -0
  99. package/dist-library/types/components/uiarc/select/select.d.ts +21 -0
  100. package/dist-library/types/components/uiarc/slider/slider.d.ts +53 -0
  101. package/dist-library/types/components/use-hydrated.d.ts +6 -0
  102. package/dist-library/types/components/visuals.d.ts +13 -0
  103. package/dist-library/types/export/component-state.d.ts +39 -0
  104. package/dist-library/types/export/index.d.ts +47 -0
  105. package/dist-library/types/export/requirements.d.ts +23 -0
  106. package/dist-library/types/export/resources.d.ts +8 -0
  107. package/dist-library/types/export/restoration.d.ts +52 -0
  108. package/dist-library/types/index.d.ts +1 -0
  109. package/dist-library/types/local/compilation/compiler-core.d.ts +16 -0
  110. package/dist-library/types/local/compilation/compiler-services.d.ts +64 -0
  111. package/dist-library/types/local/compilation/compiler-structure.d.ts +46 -0
  112. package/dist-library/types/local/compilation/compiler-values.d.ts +9 -0
  113. package/dist-library/types/local/compilation/compiler.d.ts +34 -0
  114. package/dist-library/types/local/compilation/component-kernel.d.ts +487 -0
  115. package/dist-library/types/local/{dependencies.d.ts → compilation/dependencies.d.ts} +4 -3
  116. package/dist-library/types/local/{diagnostics.d.ts → configuration/diagnostic-messages.d.ts} +193 -65
  117. package/dist-library/types/local/configuration/diagnostics.d.ts +58 -0
  118. package/dist-library/types/local/{limits.d.ts → configuration/limits.d.ts} +15 -2
  119. package/dist-library/types/local/configuration/options-core.d.ts +120 -0
  120. package/dist-library/types/local/configuration/options.d.ts +17 -0
  121. package/dist-library/types/local/configuration/portable-options.d.ts +3 -0
  122. package/dist-library/types/local/configuration/schema-core.d.ts +32 -0
  123. package/dist-library/types/local/configuration/schema.d.ts +12 -0
  124. package/dist-library/types/local/contracts/types.d.ts +519 -0
  125. package/dist-library/types/local/{version.d.ts → contracts/version.d.ts} +1 -1
  126. package/dist-library/types/local/{computations.d.ts → evaluation/computations.d.ts} +6 -3
  127. package/dist-library/types/local/{expression.d.ts → evaluation/expression.d.ts} +2 -2
  128. package/dist-library/types/local/{math-display.d.ts → evaluation/math-display.d.ts} +2 -16
  129. package/dist-library/types/local/evaluation/math-sample.d.ts +23 -0
  130. package/dist-library/types/local/evaluation/math.d.ts +73 -0
  131. package/dist-library/types/local/{validation.d.ts → evaluation/validation.d.ts} +1 -1
  132. package/dist-library/types/local/html/html-details.d.ts +16 -0
  133. package/dist-library/types/local/html/html-entities.d.ts +7 -0
  134. package/dist-library/types/local/html/html-policy.d.ts +43 -0
  135. package/dist-library/types/local/html/html-recovery.d.ts +16 -0
  136. package/dist-library/types/local/html/html-table-names.d.ts +9 -0
  137. package/dist-library/types/local/{html-table.d.ts → html/html-table.d.ts} +2 -6
  138. package/dist-library/types/local/{html.d.ts → html/html.d.ts} +1 -1
  139. package/dist-library/types/local/index.d.ts +31 -24
  140. package/dist-library/types/local/markdown/fast-markdown.d.ts +137 -0
  141. package/dist-library/types/local/{footnotes.d.ts → markdown/footnotes.d.ts} +1 -1
  142. package/dist-library/types/local/{heading-anchors.d.ts → markdown/heading-anchors.d.ts} +12 -2
  143. package/dist-library/types/local/markdown/markdown-blocks.d.ts +55 -0
  144. package/dist-library/types/local/markdown/markdown-structure.d.ts +3 -0
  145. package/dist-library/types/local/markdown/plain-paragraphs.d.ts +10 -0
  146. package/dist-library/types/local/parsing/lexical.d.ts +21 -0
  147. package/dist-library/types/local/parsing/parse-budget.d.ts +67 -0
  148. package/dist-library/types/local/parsing/parser-capabilities.d.ts +42 -0
  149. package/dist-library/types/local/parsing/parser-core.d.ts +65 -0
  150. package/dist-library/types/local/parsing/parser-standard.d.ts +7 -0
  151. package/dist-library/types/local/parsing/parser.d.ts +16 -0
  152. package/dist-library/types/local/parsing/rmd-recovery.d.ts +48 -0
  153. package/dist-library/types/local/{LocalDocumentView.d.ts → rendering/LocalDocumentView.d.ts} +67 -24
  154. package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +36 -0
  155. package/dist-library/types/local/rendering/render-types.d.ts +57 -0
  156. package/dist-library/types/local/rendering/view-revision.d.ts +75 -0
  157. package/dist-library/types/local/{retention.d.ts → runtime/retention.d.ts} +1 -1
  158. package/dist-library/types/local/runtime/runtime.d.ts +34 -0
  159. package/dist-library/types/local/{state.d.ts → runtime/state.d.ts} +4 -4
  160. package/dist-library/types/local/session/compiler-cache.d.ts +44 -0
  161. package/dist-library/types/local/session/incremental.d.ts +48 -0
  162. package/dist-library/types/local/session/parse-session.d.ts +62 -0
  163. package/dist-library/types/local/session/row-reuse.d.ts +46 -0
  164. package/dist-library/types/local/{authoring.d.ts → source/authoring.d.ts} +11 -3
  165. package/dist-library/types/local/source/node-walk.d.ts +3 -0
  166. package/dist-library/types/local/source/source-context.d.ts +63 -0
  167. package/dist-library/types/local/{source-migration.d.ts → source/source-migration.d.ts} +2 -2
  168. package/dist-library/types/local/{i18n.d.ts → theme/i18n.d.ts} +2 -2
  169. package/dist-library/types/local/theme/theme-name.d.ts +3 -0
  170. package/dist-library/types/local/{theme.d.ts → theme/theme.d.ts} +3 -3
  171. package/dist-library/types/local/transport/compile-patch.d.ts +127 -0
  172. package/dist-library/types/local/{compiled-data.d.ts → transport/compiled-data.d.ts} +1 -1
  173. package/dist-library/types/local/transport/flat-compiled-data.d.ts +17 -0
  174. package/dist-library/types/local/transport/shared-data.d.ts +10 -0
  175. package/dist-library/types/local/transport/worker.d.ts +265 -0
  176. package/dist-library/types/local/widgets/visuals.d.ts +25 -0
  177. package/dist-library/types/presets/default-authoring.d.ts +50 -0
  178. package/dist-library/types/presets/default-components.d.ts +4 -0
  179. package/dist-library/types/presets/default-semantics.d.ts +8 -0
  180. package/dist-library/types/presets/default.d.ts +11 -0
  181. package/dist-library/types/presets/identity.d.ts +7 -0
  182. package/dist-library/types/presets/packs.d.ts +4 -0
  183. package/dist-library/types/react/component-api.d.ts +260 -0
  184. package/dist-library/types/react/component-primitives.d.ts +21 -0
  185. package/dist-library/types/react/component-utils.d.ts +125 -0
  186. package/dist-library/types/react/default-theme.d.ts +6 -0
  187. package/dist-library/types/react/field-validation.d.ts +11 -0
  188. package/dist-library/types/react/index.d.ts +17 -5
  189. package/dist-library/types/react/overflow-text-tooltip.d.ts +6 -0
  190. package/dist-library/types/react/package.d.ts +69 -0
  191. package/dist-library/types/react/runtime/common.d.ts +4 -0
  192. package/dist-library/types/react/runtime/index.d.ts +8 -0
  193. package/dist-library/types/react/runtime/useComponentState.d.ts +30 -0
  194. package/dist-library/types/react/runtime/useKeys.d.ts +16 -0
  195. package/dist-library/types/react/runtime/useSwipe.d.ts +27 -0
  196. package/dist-library/types/react/runtime/useTicker.d.ts +17 -0
  197. package/dist-library/types/react/sdk.d.ts +110 -0
  198. package/dist-library/types/react/server.d.ts +15 -0
  199. package/dist-library/types/react/tooltip-layer.d.ts +10 -0
  200. package/dist-library/types/react/use-draft-field.d.ts +17 -0
  201. package/dist-library/types/runtime-services/browser/index.d.ts +63 -0
  202. package/dist-library/types/runtime-services/component-state.d.ts +152 -0
  203. package/dist-library/types/runtime-services/identity.d.ts +41 -0
  204. package/dist-library/types/runtime-services/index.d.ts +10 -0
  205. package/dist-library/types/runtime-services/random.d.ts +42 -0
  206. package/dist-library/types/runtime-services/runtime.d.ts +51 -0
  207. package/dist-library/types/runtime-services/scheduler.d.ts +44 -0
  208. package/dist-library/types/sdk/assembly.d.ts +73 -0
  209. package/dist-library/types/sdk/compat-profile.d.ts +57 -0
  210. package/dist-library/types/sdk/compiler-config.d.ts +33 -0
  211. package/dist-library/types/sdk/config-validation.d.ts +33 -0
  212. package/dist-library/types/sdk/config.d.ts +35 -0
  213. package/dist-library/types/sdk/hash.d.ts +9 -0
  214. package/dist-library/types/sdk/index.d.ts +10 -0
  215. package/dist-library/types/sdk/manifest.d.ts +49 -0
  216. package/dist-library/types/sdk/pattern.d.ts +11 -0
  217. package/dist-library/types/sdk/preset-core.d.ts +11 -0
  218. package/dist-library/types/sdk/preset.d.ts +9 -0
  219. package/dist-library/types/sdk/props.d.ts +33 -0
  220. package/dist-library/types/sdk/registry-core.d.ts +16 -0
  221. package/dist-library/types/sdk/registry.d.ts +18 -0
  222. package/dist-library/types/sdk/theme.d.ts +73 -0
  223. package/dist-library/types/sdk/types.d.ts +221 -0
  224. package/dist-library/types/sdk/version.d.ts +49 -0
  225. package/dist-library/types/shareable.d.ts +29 -3
  226. package/dist-library/types/standalone/diagnostics.d.ts +16 -0
  227. package/dist-library/types/standalone/events.d.ts +4 -0
  228. package/dist-library/types/standalone/library.d.ts +6 -0
  229. package/dist-library/types/standalone/payload.d.ts +15 -0
  230. package/dist-library/types/standalone/prepare.d.ts +21 -0
  231. package/dist-library/types/standalone/session.d.ts +68 -0
  232. package/dist-library/types/standalone/version.d.ts +7 -0
  233. package/dist-library/types/testing/behavior.d.ts +19 -0
  234. package/dist-library/types/testing/browser.d.ts +126 -0
  235. package/dist-library/types/testing/cases.d.ts +16 -0
  236. package/dist-library/types/testing/index.d.ts +13 -0
  237. package/dist-library/types/testing/manifest.d.ts +10 -0
  238. package/dist-library/types/testing/react.d.ts +45 -0
  239. package/dist-library/types/testing/report.d.ts +20 -0
  240. package/dist-library/types/testing/types.d.ts +125 -0
  241. package/dist-library/types/testing/values.d.ts +22 -0
  242. package/dist-library/types/vite/client.d.ts +36 -0
  243. package/dist-library/types/vite/discovery.d.ts +51 -0
  244. package/dist-library/types/vite/index.d.ts +31 -0
  245. package/dist-library/types/vite/registration.d.ts +109 -0
  246. package/dist-library/types-BFCrMrg0.js +52 -0
  247. package/dist-library/validation-W-bmny-x.js +2253 -0
  248. package/dist-library/values-CIt8AjiU.js +134 -0
  249. package/dist-standalone/reactive-md-standalone.css +1 -1
  250. package/dist-standalone/reactive-md-standalone.js +591 -95
  251. package/docs/README-ch.md +90 -0
  252. package/docs/README.md +87 -81
  253. package/docs/compatibility/compatibility-ch.md +22 -14
  254. package/docs/compatibility/compatibility-en.md +22 -14
  255. package/docs/compatibility/source-versioning-ch.md +15 -12
  256. package/docs/compatibility/source-versioning-en.md +16 -13
  257. package/docs/development/component-development-ch.md +51 -195
  258. package/docs/development/component-development-en.md +51 -195
  259. package/docs/development/component-development-reference-ch.md +253 -0
  260. package/docs/development/component-development-reference-en.md +238 -0
  261. package/docs/development/component-protocol-ch.md +51 -50
  262. package/docs/development/component-protocol-en.md +52 -49
  263. package/docs/development/local-module-layout-ch.md +59 -0
  264. package/docs/development/local-module-layout-en.md +59 -0
  265. package/docs/development/performance-overview-ch.md +402 -0
  266. package/docs/development/performance-overview-en.md +402 -0
  267. package/docs/development/releasing-ch.md +8 -104
  268. package/docs/development/releasing-en.md +8 -104
  269. package/docs/guides/local-guide-ch.md +28 -9
  270. package/docs/guides/local-guide-en.md +31 -12
  271. package/docs/integration/author-tools-ch.md +4 -2
  272. package/docs/integration/author-tools-en.md +4 -2
  273. package/docs/integration/codemirror-ch.md +52 -0
  274. package/docs/integration/codemirror-en.md +29 -0
  275. package/docs/integration/compiler-ch.md +47 -0
  276. package/docs/integration/compiler-en.md +34 -0
  277. package/docs/integration/directory-discovery-ch.md +53 -0
  278. package/docs/integration/directory-discovery-en.md +31 -0
  279. package/docs/integration/editor-ch.md +48 -21
  280. package/docs/integration/editor-en.md +48 -21
  281. package/docs/integration/extension-sdk-ch.md +392 -0
  282. package/docs/integration/extension-sdk-en.md +377 -0
  283. package/docs/integration/local-integration-ch.md +63 -9
  284. package/docs/integration/local-integration-en.md +89 -13
  285. package/docs/integration/repository-split-ch.md +40 -0
  286. package/docs/integration/repository-split-en.md +23 -0
  287. package/docs/integration/shareable-export-ch.md +46 -2
  288. package/docs/integration/shareable-export-en.md +46 -2
  289. package/docs/reference/computations-formatting-ch.md +4 -2
  290. package/docs/reference/computations-formatting-en.md +4 -2
  291. package/docs/reference/constraints-collections-ch.md +21 -1
  292. package/docs/reference/constraints-collections-en.md +21 -1
  293. package/docs/reference/diagnostics-counting-ch.md +1 -1
  294. package/docs/reference/diagnostics-counting-en.md +1 -1
  295. package/docs/reference/html-compatibility-ch.md +4 -0
  296. package/docs/reference/html-compatibility-en.md +4 -0
  297. package/docs/reference/local-components-v2-ch.md +2 -0
  298. package/docs/reference/local-components-v2-en.md +2 -0
  299. package/docs/reference/local-interaction-syntax-ch.md +51 -15
  300. package/docs/reference/local-interaction-syntax-en.md +58 -14
  301. package/docs/reference/theme-protocol-ch.md +79 -7
  302. package/docs/reference/theme-protocol-en.md +79 -7
  303. package/docs/reference/tolerance-ch.md +64 -0
  304. package/docs/reference/tolerance-en.md +57 -0
  305. package/docs/releases/release-0.4.0-ch.md +2 -0
  306. package/docs/releases/release-0.4.0-en.md +2 -0
  307. package/docs/releases/release-0.4.1-ch.md +2 -0
  308. package/docs/releases/release-0.4.1-en.md +2 -0
  309. package/docs/releases/release-0.5.0-ch.md +2 -0
  310. package/docs/releases/release-0.5.0-en.md +2 -0
  311. package/docs/releases/release-0.5.1-ch.md +2 -0
  312. package/docs/releases/release-0.5.1-en.md +2 -0
  313. package/docs/releases/release-0.5.2-ch.md +2 -0
  314. package/docs/releases/release-0.5.2-en.md +2 -0
  315. package/docs/releases/release-0.5.3-ch.md +2 -0
  316. package/docs/releases/release-0.5.3-en.md +2 -0
  317. package/docs/releases/release-0.6.0-ch.md +2 -0
  318. package/docs/releases/release-0.6.0-en.md +2 -0
  319. package/docs/releases/release-0.6.1-ch.md +2 -0
  320. package/docs/releases/release-0.6.1-en.md +2 -0
  321. package/docs/releases/release-0.7.0-ch.md +86 -0
  322. package/docs/releases/release-0.7.0-en.md +86 -0
  323. package/docs/releases/release-0.8.0-ch.md +126 -0
  324. package/docs/releases/release-0.8.0-en.md +126 -0
  325. package/examples/component-package/LICENSE +21 -0
  326. package/examples/component-package/NOTICES.md +12 -0
  327. package/examples/component-package/README-ch.md +101 -0
  328. package/examples/component-package/README.md +133 -0
  329. package/examples/component-package/package.json +35 -0
  330. package/examples/component-package/sample/document.reactive.md +14 -0
  331. package/examples/component-package/scripts/build-export.mjs +44 -0
  332. package/examples/component-package/scripts/build.mjs +130 -0
  333. package/examples/component-package/scripts/verify.mjs +257 -0
  334. package/examples/component-package/src/assets/notice.svg +4 -0
  335. package/examples/component-package/src/component.css +40 -0
  336. package/examples/component-package/src/components.tsx +105 -0
  337. package/examples/component-package/src/harness.tsx +34 -0
  338. package/examples/component-package/src/manifests.ts +71 -0
  339. package/examples/component-package/src/node-entry.ts +18 -0
  340. package/examples/component-package/src/sample.ts +4 -0
  341. package/examples/component-package/src/theme.css +44 -0
  342. package/examples/component-package/src/theme.ts +22 -0
  343. package/examples/component-package/tsconfig.json +15 -0
  344. package/examples/conformance/README-ch.md +55 -0
  345. package/examples/conformance/README.md +2 -0
  346. package/examples/conformance/local-draft-3.json +296 -0
  347. package/examples/game-2048-package/LICENSE +21 -0
  348. package/examples/game-2048-package/NOTICES.md +11 -0
  349. package/examples/game-2048-package/README-ch.md +97 -0
  350. package/examples/game-2048-package/README.md +102 -0
  351. package/examples/game-2048-package/package.json +35 -0
  352. package/examples/game-2048-package/sample/document.reactive.md +17 -0
  353. package/examples/game-2048-package/scripts/build-export.mjs +44 -0
  354. package/examples/game-2048-package/scripts/build.mjs +130 -0
  355. package/examples/game-2048-package/scripts/verify.mjs +180 -0
  356. package/examples/game-2048-package/src/component.css +161 -0
  357. package/examples/game-2048-package/src/components.tsx +326 -0
  358. package/examples/game-2048-package/src/game-engine.ts +228 -0
  359. package/examples/game-2048-package/src/harness.tsx +34 -0
  360. package/examples/game-2048-package/src/manifest.ts +85 -0
  361. package/examples/game-2048-package/src/node-entry.ts +30 -0
  362. package/examples/game-2048-package/src/sample.ts +4 -0
  363. package/examples/game-2048-package/tsconfig.json +15 -0
  364. package/examples/integration/README-ch.md +63 -0
  365. package/examples/integration/README.md +17 -1
  366. package/examples/integration/extension-sdk/README-ch.md +24 -0
  367. package/examples/integration/extension-sdk/README.md +24 -0
  368. package/examples/integration/extension-sdk/advanced-standalone.ts +6 -0
  369. package/examples/integration/extension-sdk/advanced.tsx +101 -0
  370. package/examples/integration/extension-sdk/env.d.ts +2 -0
  371. package/examples/integration/extension-sdk/extensions.tsx +97 -0
  372. package/examples/integration/extension-sdk/index.html +3 -0
  373. package/examples/integration/extension-sdk/main.tsx +10 -0
  374. package/examples/integration/extension-sdk/package.json +6 -0
  375. package/examples/integration/extension-sdk/standalone.ts +7 -0
  376. package/examples/integration/extension-sdk/tsconfig.json +8 -0
  377. package/examples/integration/react-comprehensive/index.html +12 -0
  378. package/examples/integration/react-comprehensive/main.jsx +123 -0
  379. package/examples/integration/react-comprehensive/package.json +18 -0
  380. package/examples/local/README-ch.md +76 -0
  381. package/examples/local/README.md +4 -2
  382. package/examples/local/scenarios/blog-zh.reactive.md +71 -0
  383. package/examples/local/scenarios/blog.reactive.md +71 -0
  384. package/examples/local/scenarios/classroom-zh.reactive.md +97 -0
  385. package/examples/local/scenarios/classroom.reactive.md +97 -0
  386. package/examples/local/scenarios/proposal-zh.reactive.md +79 -0
  387. package/examples/local/scenarios/proposal.reactive.md +79 -0
  388. package/examples/local/scenarios/survey-zh.reactive.md +74 -0
  389. package/examples/local/scenarios/survey.reactive.md +74 -0
  390. package/examples/local/showcase/README-ch.md +22 -0
  391. package/examples/local/showcase/README.md +9 -3
  392. package/examples/local/showcase/features.reactive.md +637 -0
  393. package/examples/local/showcase/zh/features.reactive.md +637 -0
  394. package/examples/sci-fi-theme/README-ch.md +131 -0
  395. package/examples/sci-fi-theme/README.md +146 -0
  396. package/examples/sci-fi-theme/demo/demo.css +532 -0
  397. package/examples/sci-fi-theme/demo/document.reactive.md +185 -0
  398. package/examples/sci-fi-theme/demo/index.html +13 -0
  399. package/examples/sci-fi-theme/demo/main.tsx +180 -0
  400. package/examples/sci-fi-theme/docs/design-system-ch.md +245 -0
  401. package/examples/sci-fi-theme/docs/design-system.md +474 -0
  402. package/examples/sci-fi-theme/package.json +27 -0
  403. package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -0
  404. package/examples/sci-fi-theme/src/components.css +1460 -0
  405. package/examples/sci-fi-theme/src/index.ts +6 -0
  406. package/examples/sci-fi-theme/src/sci-fi.css +5 -0
  407. package/examples/sci-fi-theme/src/theme.ts +37 -0
  408. package/examples/sci-fi-theme/src/tokens.css +408 -0
  409. package/examples/sci-fi-theme/tsconfig.json +20 -0
  410. package/examples/sci-fi-theme/vite.config.ts +24 -0
  411. package/examples/tetris-package/LICENSE +21 -0
  412. package/examples/tetris-package/NOTICES.md +11 -0
  413. package/examples/tetris-package/README-ch.md +91 -0
  414. package/examples/tetris-package/README.md +95 -0
  415. package/examples/tetris-package/package.json +35 -0
  416. package/examples/tetris-package/sample/document.reactive.md +16 -0
  417. package/examples/tetris-package/scripts/build-export.mjs +44 -0
  418. package/examples/tetris-package/scripts/build.mjs +130 -0
  419. package/examples/tetris-package/scripts/verify.mjs +173 -0
  420. package/examples/tetris-package/src/component.css +145 -0
  421. package/examples/tetris-package/src/components.tsx +334 -0
  422. package/examples/tetris-package/src/harness.tsx +34 -0
  423. package/examples/tetris-package/src/manifests.ts +93 -0
  424. package/examples/tetris-package/src/node-entry.ts +16 -0
  425. package/examples/tetris-package/src/sample.ts +4 -0
  426. package/examples/tetris-package/src/tetris-engine.ts +325 -0
  427. package/examples/tetris-package/tsconfig.json +15 -0
  428. package/package.json +98 -44
  429. package/dist-library/compiler-Cm3ppMxG.js +0 -46044
  430. package/dist-library/react-Bh7_oxZp.js +0 -59655
  431. package/dist-library/reactive-md-editor.css +0 -2
  432. package/dist-library/reactive-md-editor.js +0 -3853
  433. package/dist-library/runtime-DlFYQ4s_.js +0 -498
  434. package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +0 -7
  435. package/dist-library/types/editor/editor-toolbar.d.ts +0 -24
  436. package/dist-library/types/editor/editor-view-bar.d.ts +0 -11
  437. package/dist-library/types/editor/extended-native-components.d.ts +0 -58
  438. package/dist-library/types/editor/index.d.ts +0 -9
  439. package/dist-library/types/editor/locale.d.ts +0 -13
  440. package/dist-library/types/editor/source-authoring.d.ts +0 -59
  441. package/dist-library/types/editor/types.d.ts +0 -48
  442. package/dist-library/types/editor/use-gutter-metrics.d.ts +0 -5
  443. package/dist-library/types/editor/use-source-history.d.ts +0 -16
  444. package/dist-library/types/local/compiler.d.ts +0 -4
  445. package/dist-library/types/local/math.d.ts +0 -48
  446. package/dist-library/types/local/options.d.ts +0 -36
  447. package/dist-library/types/local/parser.d.ts +0 -13
  448. package/dist-library/types/local/render-types.d.ts +0 -27
  449. package/dist-library/types/local/runtime.d.ts +0 -2
  450. package/dist-library/types/local/schema.d.ts +0 -77
  451. package/dist-library/types/local/types.d.ts +0 -263
  452. package/dist-library/types/local/visuals.d.ts +0 -12
  453. package/dist-library/types/local/worker.d.ts +0 -98
  454. package/docs/development/performance-ch.md +0 -76
  455. package/docs/development/performance-en.md +0 -76
  456. /package/dist-library/types/{editor → authoring}/command-types.d.ts +0 -0
  457. /package/dist-library/types/{editor → authoring}/editor-commands.d.ts +0 -0
  458. /package/dist-library/types/local/{locale.d.ts → contracts/locale.d.ts} +0 -0
  459. /package/dist-library/types/local/{collection-functions.d.ts → evaluation/collection-functions.d.ts} +0 -0
  460. /package/dist-library/types/local/{data-functions.d.ts → evaluation/data-functions.d.ts} +0 -0
  461. /package/dist-library/types/local/{dates.d.ts → evaluation/dates.d.ts} +0 -0
  462. /package/dist-library/types/local/{formatting.d.ts → evaluation/formatting.d.ts} +0 -0
  463. /package/dist-library/types/local/{html-names.d.ts → html/html-names.d.ts} +0 -0
  464. /package/dist-library/types/local/{text-length.d.ts → source/text-length.d.ts} +0 -0
  465. /package/dist-library/types/local/{colors.d.ts → theme/colors.d.ts} +0 -0
  466. /package/dist-library/types/local/{code-block.d.ts → widgets/code-block.d.ts} +0 -0
  467. /package/dist-library/types/local/{code-languages.d.ts → widgets/code-languages.d.ts} +0 -0
  468. /package/dist-library/types/local/{diagram-layout.d.ts → widgets/diagram-layout.d.ts} +0 -0
  469. /package/dist-library/types/local/{image-view.d.ts → widgets/image-view.d.ts} +0 -0
  470. /package/dist-library/types/local/{math-view.d.ts → widgets/math-view.d.ts} +0 -0
  471. /package/dist-library/types/local/{table-surface.d.ts → widgets/table-surface.d.ts} +0 -0
@@ -0,0 +1,377 @@
1
+ # Extension SDK
2
+
3
+ **English** · [中文](extension-sdk-ch.md)
4
+
5
+ The `0.7.0` package includes the extension SDK for public extensions and unified default components. Install the published package; use a source-built tarball only when testing unreleased changes.
6
+
7
+ ```sh
8
+ npm install reactive-md@0.7.0
9
+ ```
10
+
11
+ The registry package contains `reactive-md/build`, `reactive-md/testing` and the other phase-three entries. The consumer checks install the published package outside the repository, so the public import surface is exercised as published rather than through source aliases. Version ranges name `^0.7.0`.
12
+
13
+ Component manifests and instance configuration are plain data. React implementations remain explicitly imported host code. The compiler, Worker, authoring tools, build adapter and exporter use the same validated configuration.
14
+
15
+
16
+ See the [development contract](../development/component-development-reference-en.md) for convenience packages, createReactHost, Vite integration and configuration diagnostics, or start with the [five-minute guide](../development/component-development-en.md).
17
+
18
+ ## Define and register a component
19
+
20
+ ```tsx
21
+ import { createLocalConfig, defineLocalComponent } from 'reactive-md/sdk';
22
+ import { createReactConfig, defineReactComponent, LocalReactiveDocument } from 'reactive-md/react';
23
+
24
+ const note = defineLocalComponent({
25
+ id: 'example/note', name: 'note-box', version: '1.0.0',
26
+ protocol: 'reactive-md-component/v1', form: 'container',
27
+ props: { title: { kind: 'string', default: 'Note' } },
28
+ children: { kind: 'markdown' },
29
+ capabilities: { interactive: true, static: true, ssr: true, offline: true },
30
+ authoring: {
31
+ title: { en: 'Note', zh: '提示' }, category: 'content',
32
+ insertText: '<note-box title="Note">\nSome **Markdown**.\n</note-box>',
33
+ },
34
+ });
35
+ const implementation = defineReactComponent(note, {
36
+ render: ctx => <aside><h3>{ctx.props.title}</h3>{ctx.children.render()}</aside>,
37
+ renderStatic: ctx => <aside><h3>{ctx.props.title}</h3>{ctx.children.render()}</aside>,
38
+ });
39
+ const config = createLocalConfig({ components: [note] });
40
+ const reactConfig = createReactConfig(config, { components: [implementation] });
41
+
42
+ export function Reader({ source }: { source: string }) {
43
+ return <LocalReactiveDocument source={source} reactConfig={reactConfig} />;
44
+ }
45
+ ```
46
+
47
+ The default preset remains enabled. `reactive-md/presets/default` exports `defaultPreset` for explicit configuration. Its 46 components pass the public validator and share compilation and rendering with external components. Registration rejects name overrides.
48
+
49
+ Registration validates identities, names, protocol, dependencies and budgets, then copies and freezes the data. `readLocalConfig` revalidates serialized configuration and recomputes its semantic key. React implementations must match their registered manifests.
50
+
51
+ `requires: { kernel: '^0.7.0' }` declares kernel compatibility. Dependencies use `{ id, version }`. Ranges support complete versions, `^`, `~` and whitespace-separated comparisons such as `>=0.7.0 <0.8.0`. Unsupported syntax is rejected.
52
+
53
+ ## Props, bindings and lifecycle
54
+
55
+ Props support strings, numbers, booleans and enums, with defaults, required flags, static/dynamic modes, numeric bounds, integer checks and safe patterns. A valid numeric literal and a full numeric interpolation both reach the component as a number. Defaults apply to omitted attributes; invalid explicit values produce diagnostics. Missing optional props without a default resolve to `null`.
56
+
57
+ The main slot is `bindings.value`. Read through `ctx.bindings.value.get()` and write through `.set(next)`, which returns `{ ok, diagnostics }`. The manifest's `bind` and `initial` fields name the authored attributes. Writes use the kernel's shared constraints. A rating can share a parameter with the built-in number control when their bounds and step agree. Declare an explicit initial value only once per shared parameter.
58
+
59
+ The context also exposes `props`, `children.render()`, `instance`, `mode`, `visible`, `disabled`, `resetToken` and `report`. It contains no internal AST. Components use React effect cleanup for resources and observe `resetToken` for local UI state. Static rendering receives read-only binding handles.
60
+
61
+ React descendant render failures produce a placeholder and diagnostics. `reactive-md/react/server` provides `renderLocalStaticDocument`, a strict adapter that checks SSR capability and returns markup or structured diagnostics. Event and asynchronous failures use the React SDK error-reporting helpers.
62
+
63
+ Use this server adapter's markup as the offline export's `staticMarkup`. It retains React text boundaries for static-first standalone hydration. Supply the same `resources` to server rendering and export when components declare required styles.
64
+
65
+ Numeric bounds may reference props. Dynamic min/max use kernel constraints, including the bound prop's own range and integer checks. A prop used as a step must be static. Binding families declare general value semantics such as numbers, text, dates, choices and collections; implementations provide the interaction and appearance.
66
+
67
+ ## Named slots, collections and structure
68
+
69
+ Phase two places default contracts in `defaultPreset.components`. Every definition passes the same `defineLocalComponent` validator as external definitions. `config.components` remains the external list; `config.registry` contains the complete default and external snapshot.
70
+
71
+ `bindings` is a record keyed by slot name. A coordinate control can declare `x` and `y`, with separate `bind-x`, `bind-y` and initial-value attributes. Its React implementation uses:
72
+
73
+ ```ts
74
+ const x = ctx.bindings.get('x');
75
+ const y = ctx.bindings.slots.y.get();
76
+ const result = ctx.bindings.setMany({ x: 2, y: 3 });
77
+ ```
78
+
79
+ `setMany` commits one kernel transaction after every slot passes validation. Failure preserves all parameters and the revision. The primary `value` slot may coexist with named slots and participate in the same transaction. `slotRelations: [{ lower: 'start', upper: 'end' }]` declares an ordered range. Named slots use exclusive ownership: omitted `exclusive` normalizes to `true`, and explicit `false` is rejected at registration.
80
+
81
+ Collection controls read arrays through the main slot and submit new arrays. Multi-select uses structural options and a selection limit; checklist derives its initial values from a task list. The adapter supplies read-only values, and the kernel owns state copies.
82
+
83
+ Use `family: 'collection'` with `kind: 'array'` or `'number-array'` for general collections. Arrays retain order and duplicates, `initial` accepts a JSON array literal, and `maxItems` limits length through a literal or static numeric prop. Dynamic caps are rejected at registration. State files preserve string arrays and finite-number arrays, with binding validation on restoration. Named slots support `kind: 'number'` with `family: 'number'`; registration rejects other combinations. `required: true` requires an authored binding name. Capabilities describe supported rendering environments, so a display-only container can support an interactive document. Static runtime reset remains read-only.
84
+
85
+ `structure` describes direct children, placement and content shape. `rules` declares reusable compile or state semantics for numeric ranges, dates, option sequences, tables, diagrams, navigation and budgets. External components may reuse default contracts or compose the primitives described by the public types.
86
+
87
+ The React context exposes public content projections through `content` and `children.items()`. Use `children.render()`, `children.options()` and `children.table()` for child content, plus `validation`, `navigation`, `source` and `locale` for shared services. Runtime services expose evaluation, state writes and resets. The adapter owns internal AST access.
88
+
89
+ `examples/integration/extension-sdk/advanced.tsx` implements an external coordinate control, collection control and Markdown container.
90
+
91
+ ## Authoring and themes
92
+
93
+ Pass `{ config }` to `compileLocal`, `completeLocalSource` and other authoring services. `createLocalComponentCatalog(config, locale)` from `reactive-md/authoring` derives the insertion catalog from the same manifests. Paired components receive closing-tag completion.
94
+
95
+ ```ts
96
+ import { compileLocal, completeLocalSource } from 'reactive-md';
97
+ import { createLocalComponentCatalog, insertLocalComponent, validateLocalComponentInsertTemplates } from 'reactive-md/authoring';
98
+
99
+ const result = compileLocal(source, { config });
100
+ const candidates = completeLocalSource(source, offset, { config });
101
+ const catalog = createLocalComponentCatalog(config, 'zh');
102
+ const edit = insertLocalComponent(config, 'example/note', source, selection, 'zh');
103
+ ```
104
+
105
+ `insertLocalComponent` resolves insertion tokens and allocates fresh binding names. `validateLocalComponentInsertTemplates` compiles actual insertion output under the same configuration. Props can carry localized descriptions; editor copy and theme changes do not alter the compilation key.
106
+
107
+ `defineLocalTheme`, `composeLocalTheme` and `collectLocalThemeCss` define, combine and collect independent theme packages. A theme package is plain data: identity, protocol `reactive-md-theme-1`, both light and dark color schemes, and bounded inline CSS resources. Every selector is scoped to `[data-rmd-theme="name"]`. Component structural styles remain independent of theme enhancements and use shared semantic variables.
108
+
109
+ ```ts
110
+ import { defineLocalTheme, composeLocalTheme, collectLocalThemeCss } from 'reactive-md/sdk';
111
+
112
+ const paper = defineLocalTheme({
113
+ id: 'example/paper', name: 'paper', version: '1.0.0',
114
+ protocol: 'reactive-md-theme-1', colorSchemes: ['light', 'dark'],
115
+ css: [{ id: 'example/paper.css', css: paperCss }],
116
+ });
117
+ const highContrast = composeLocalTheme({
118
+ id: 'example/paper-contrast', name: 'paper-contrast', version: '1.0.0',
119
+ base: paper, overrides: [{ id: 'example/paper-contrast.css', css: overrideCss }],
120
+ });
121
+ const stylesheet = collectLocalThemeCss(highContrast);
122
+ ```
123
+
124
+ Theme CSS accepts inline `data:` URLs and rejects network references, `@import` and CSS escapes outside strings. Theme packages namespace `@font-face` names and matching literal `font-family` and `font` references. `@keyframes` remains unsupported. The directory loader inlines local fonts and images as `data:` resources before theme validation.
125
+
126
+ Font reference rewriting covers nested rules, `var()` family-list fallbacks, and `font` shorthands with `calc()`, `min()`, `max()` or `clamp()` sizes. With local font declarations, ambiguous shorthands such as `font: var(--size) Brand` and unsupported family functions raise a theme error. Use an explicit size and `font-family` in those cases.
127
+
128
+ `composeLocalTheme` appends overrides after the base stylesheet. An override must use a resource id the base does not declare. `collectLocalThemeCss` concatenates resources in stylesheet order.
129
+
130
+ Components declare required resource ids through `styles`; the host supplies corresponding `{ id, css }` resources to build and export. Component defaults precede theme enhancements.
131
+
132
+ ## Build a standalone bundle
133
+
134
+ `reactive-md/build` is a Node adapter. It reads only modules the host names explicitly, so third-party code stays a host-installed dependency. Names or URLs in a document never trigger a download.
135
+
136
+ ### Host entry module
137
+
138
+ The entry is Node-loadable ESM: an `.mjs` file, or a `.js` file inside a module package. It exports two prepared objects plus the filesystem contract:
139
+
140
+ ```js
141
+ // build-host.mjs
142
+ export { config, reactConfig } from './dist/node/entry.mjs';
143
+ export const root = new URL('.', import.meta.url);
144
+ export const allowlist = ['src'];
145
+ export const resources = [
146
+ { id: 'example/component.css', path: 'src/component.css' },
147
+ ];
148
+ export const notices = [
149
+ { id: 'example/package', license: 'MIT', text: 'Attribution text.' },
150
+ ];
151
+ ```
152
+
153
+ `root` is the only directory the adapter reads from. Every `allowlist` directory must be inside `root`, and every resource file must resolve inside both. The entry module must also be inside `root`. `resources` (or `styles`) is optional; `notices` accepts an array of records or a string. The same `resources` and `notices` options passed to the build call are merged with host exports. Identical declarations deduplicate; conflicting contents produce a diagnostic.
154
+
155
+ ### Preflight and build
156
+
157
+ ```ts
158
+ import { preflightLocalStandaloneBuild, buildLocalStandaloneBundle } from 'reactive-md/build';
159
+
160
+ const preflight = await preflightLocalStandaloneBuild({
161
+ entry: './build-host.mjs',
162
+ themes: ['paper'],
163
+ budgets: { maxResources: 64 },
164
+ });
165
+ if (!preflight.ok) {
166
+ for (const item of preflight.diagnostics) console.error(item.code, item.message);
167
+ }
168
+ const bundle = await buildLocalStandaloneBundle({ entry: './build-host.mjs', themes: ['paper'] });
169
+ ```
170
+
171
+ `preflightLocalStandaloneBuild` validates the host module, the `LocalConfig` key, React implementations against their manifests, offline capabilities and every CSS reference. It returns `ok`, `diagnostics`, `entry`, `root`, `allowlist`, `config`, `configKey`, `resources`, `assets`, `css` and `notices`. It does not load Vite or produce a script.
172
+
173
+ `buildLocalStandaloneBundle` runs the same preflight, bundles one IIFE script and returns a flat object:
174
+
175
+ | Field | Contents |
176
+ | --- | --- |
177
+ | `script` | The single inline IIFE source. |
178
+ | `extensions` | Component requirements compatible with `LocalStandaloneBundle`. |
179
+ | `seal` | Bundle manifest used by export integrity checks. |
180
+ | `configKey` | Semantic key of the installed configuration. |
181
+ | `resources` | Collected style resources with id, origin, digest and byte length. |
182
+ | `assets` | Inlined CSS, font and image files with path, MIME and digest. |
183
+ | `css` | Concatenated resource CSS. |
184
+ | `notices` | Formatted notice text. |
185
+ | `manifest` | Full build manifest, protocol `reactive-md-build/v1`. |
186
+
187
+ The build manifest records `sdkVersion`, `configKey`, `format: 'iife'`, the script digest and byte length, resource identities, inlined assets, component requirements, every installed theme and notice entries. Keep it with archived bundles for external verification.
188
+
189
+ A failed preflight or build throws `LocalBuildError` with every diagnostic attached. Budget overrides are validated; invalid values fall back per key with a diagnostic.
190
+
191
+ The Vite output must contain exactly one chunk and no assets. The adapter rejects chunks with imports, dynamic imports or implicitly loaded chunks, script text containing `import.meta`, dynamic imports, Worker constructors, service workers, `fetch`/`XMLHttpRequest` or remote module specifiers, an empty script, and a script over 32 MiB. Extension modules that construct a Worker fail the build; the installed kernel's optional ELK worker path is replaced by the in-process factory.
192
+
193
+ ### Resources and budgets
194
+
195
+ A resource input declares exactly one of inline CSS or a file path. Relative `url()` values in inline CSS need an explicit `base` directory inside `root`.
196
+
197
+ ```ts
198
+ { id: 'example/component.css', css: inlineCss, base: 'src' }
199
+ { id: 'example/theme.css', path: 'src/theme.css' }
200
+ ```
201
+
202
+ The collector inlines local `@import` and `url()` targets, keeps `data:` URLs, and reports missing files, remote references, paths outside `root` or the allowlist, symbolic-link escapes, import cycles, duplicate ids with different contents and budget overruns. Output order is deterministic: component style ids, host declarations, then selected themes. Theme selection defaults to every installed theme; listing the reserved `default` name explicitly adds no package.
203
+
204
+ Default budgets are 128 resources, 4 MiB of CSS, 8 MiB per file, 24 MiB of inlined data, 256 files and import depth 16. The absolute ceilings are 512, 32 MiB, 32 MiB, 64 MiB, 1024 and 32. `maxImportDepth` and `maxInlinedBytes` accept zero.
205
+
206
+ ### Optional Vite peer
207
+
208
+ Vite 8 is an optional peer dependency. The adapter imports `vite` only when a build actually runs, so consumers that only preflight or read manifests do not install it. For tests or nonstandard hosts, pass `vite` as a `{ build }` facade or a factory returning one. The injected facade is checked before use.
209
+
210
+ ## Offline export and the bundle seal
211
+
212
+ `defineLocalStandaloneBundle(script, config)` binds a trusted host-built script to the installed manifest set. The seal uses protocol `reactive-md-bundle/v1` and records the SDK version, configuration key, script digest and every theme contract digest.
213
+
214
+ ```ts
215
+ import { createLocalExportPlan, createLocalShareableHtml } from 'reactive-md/export';
216
+ import { buildLocalStandaloneBundle } from 'reactive-md/build';
217
+
218
+ const bundle = await buildLocalStandaloneBundle({ entry: './build-host.mjs' });
219
+ // `buildLocalStandaloneBundle` already returns a compatible bundle plus resources.
220
+
221
+ const plan = createLocalExportPlan({
222
+ document, config, target: 'offline', bundle,
223
+ resources: bundle.resources,
224
+ });
225
+ if (!plan.ok) throw new Error(plan.diagnostics.map(item => item.message).join('\n'));
226
+
227
+ const html = createLocalShareableHtml({
228
+ source, document, config, state, title: 'My document',
229
+ staticMarkup, css,
230
+ bundle, resources: bundle.resources, notices: bundle.notices,
231
+ mode: 'interactive',
232
+ });
233
+ ```
234
+
235
+ `createLocalExportPlan` checks target capabilities, component identities and versions, semantic digests, theme selection and style resources before any output or state serialization. It also revalidates carried component definitions and the requirements for every external component the document uses. Targets are `static`, `ssr` and `offline`. An offline target requires a bundle script, validates the bundle's extension requirements and seal, checks that the bundle includes every component the document requires, and compares the selected theme against the sealed themes.
236
+
237
+ `createLocalShareableHtml` requires `staticMarkup` from `renderLocalStaticDocument` and rejects markup containing an unavailable extension placeholder. It embeds configuration, requirements, styles and the optional runtime script, and records `reactive-md-restore/v1` requirements for the next host.
238
+
239
+ The standalone entry imports the host's implementations and calls `mountAll`:
240
+
241
+ ```ts
242
+ import { mountAll } from 'reactive-md/standalone';
243
+ import { reactConfig } from './extensions';
244
+
245
+ mountAll(document, { reactConfig });
246
+ ```
247
+
248
+ Bundle this entry into an IIFE before export. The generated build entry also exports `mountReactiveMD` and `unmountReactiveMD`, and checks the baked configuration key before mounting. Document requirements never trigger code downloads.
249
+
250
+ ## Restoration and versions
251
+
252
+ SDK exports use a v2 HTML payload that records `reactive-md-restore/v1` requirements. Plain exports keep the existing v1 default behavior. The `reactive-md-state/v1` parameter file is unchanged.
253
+
254
+ `createLocalRestorationRequirements(document, config, target, resources)` records the SDK range (`^0.7.0`), configuration key, source digest, target, the components the document actually uses with version, range and contract digest, the selected theme, and style resource digests.
255
+
256
+ `validateLocalRestorationRequirements(value, { config, source, resources, document })` runs before any state is applied or React is mounted. It checks the restoration protocol and size bounds, SDK range, configuration key, source digest, installed component identity and version range, contract digest, target capabilities, theme contract, and resource presence and digest. Missing or mismatched entries block restoration.
257
+
258
+ A version range may allow an upgrade. A changed component contract still requires recompilation and state validation before the state is applied. The bundle seal catches a script or configuration that differs from its build; the build manifest carries SHA-256 digests for archiving and external checks.
259
+
260
+ ## Compliance testing
261
+
262
+ `reactive-md/testing` is framework-neutral and has no React, DOM or browser dependency. `reactive-md/testing/react` adds static and SSR execution through React. `reactive-md/testing/browser` runs a portable browser scenario, with an optional Playwright adapter.
263
+
264
+ The core entry validates manifests and executes real compiler and runtime behavior:
265
+
266
+ ```ts
267
+ import {
268
+ createLocalComplianceReport,
269
+ runLocalBehaviorCompliance,
270
+ runLocalManifestCompliance,
271
+ } from 'reactive-md/testing';
272
+
273
+ const manifest = runLocalManifestCompliance(rating);
274
+ const behavior = runLocalBehaviorCompliance({
275
+ protocol: 'reactive-md-behavior-spec/v1',
276
+ component: 'rating',
277
+ source: '<rating bind="score" label="Score" max="5" initial="3">',
278
+ writes: [
279
+ { id: 'increment', value: 4, accepted: true, expect: { score: 4 } },
280
+ { id: 'over-max', value: 6, accepted: false },
281
+ ],
282
+ }, config);
283
+
284
+ const report = createLocalComplianceReport({
285
+ config, component: 'rating', suites: [manifest, behavior],
286
+ requireCapabilities: false,
287
+ });
288
+ ```
289
+
290
+ Manifest cases re-read the definition, check key-order stability, defaults, required props, unknown fields and illegal values. Behavior cases compile the source, perform real `set` and `setMany` calls, prove rollback and revision behavior, reset authored initials, and verify defensive copies for collection arrays. A write spec sets `value` for one slot or `values` for an atomic multi-slot write, and records whether the runtime must accept it plus optional expected parameters.
291
+
292
+ `runLocalReactCompliance` executes static rendering, two strict SSR passes and an optional server error probe:
293
+
294
+ ```ts
295
+ import { runLocalReactCompliance } from 'reactive-md/testing/react';
296
+
297
+ const react = runLocalReactCompliance({
298
+ config, reactConfig, resources,
299
+ component: 'rating',
300
+ spec: {
301
+ protocol: 'reactive-md-react-spec/v1',
302
+ source,
303
+ staticMarkupIncludes: ['data-rating-static'],
304
+ ssrMarkupIncludes: ['data-rating-static'],
305
+ },
306
+ locale: 'en',
307
+ });
308
+ ```
309
+
310
+ The `resources` value is the canonical list from the build step. Pass the same array to `renderLocalStaticDocument`, `runLocalReactCompliance` and the export plan, so every stage validates and renders with identical CSS.
311
+
312
+ Browser compliance takes a driver and a bounded spec. `createPlaywrightBrowserDriver` adapts an existing Playwright context without importing Playwright:
313
+
314
+ ```ts
315
+ import {
316
+ createPlaywrightBrowserDriver,
317
+ runLocalBrowserCompliance,
318
+ } from 'reactive-md/testing/browser';
319
+
320
+ const context = await browser.newContext({ offline: true, viewport: { width: 1280, height: 900 } });
321
+ const browser = await runLocalBrowserCompliance({
322
+ driver: createPlaywrightBrowserDriver(context),
323
+ spec: {
324
+ protocol: 'reactive-md-browser-spec/v1',
325
+ url: 'file:///path/to/interactive.html',
326
+ offline: true,
327
+ cases: [
328
+ { id: 'ready', phase: 'mount', kind: 'visible', selector: '[data-rating]', expected: true },
329
+ { id: 'up', phase: 'edit', kind: 'click', selector: '[data-rating-up]' },
330
+ { id: 'edited', phase: 'edit', kind: 'text', selector: '[data-rating-value]', expected: '4' },
331
+ { id: 'unmount', phase: 'unmount', kind: 'unmount' },
332
+ ],
333
+ },
334
+ config, component: 'rating',
335
+ });
336
+ ```
337
+
338
+ Browser phases are `mount`, `hydration`, `edit`, `hide-show`, `disabled`, `reset`, `descendant-error` and `unmount`. Case kinds are `visible`, `text`, `attribute`, `count`, `enabled`, `wait`, `click`, `fill`, `press`, `evaluate`, `isolation` and `unmount`. A spec URL must use `file:` or `data:`. The suite reports every phase in `requiredPhases`, which defaults to all eight; a missing phase becomes skipped. Interactive evidence needs the seven lifecycle phases, which exclude hydration, to pass without failures. Offline evidence additionally needs a hydration pass, an offline context, zero http(s)/ws requests and no unexpected page errors.
339
+
340
+ Every report separates `passed`, `failed`, `skipped` and `unsupported`. A declared capability is satisfied only by a passed case tagged with that capability. Without such a case, evidence stays missing and the aggregate report fails. `complete` is true only when every declared capability has executed evidence. `compareLocalComplianceParity` compares two suite results by case id, status and observed values, which lets an external alias of a default contract be checked against the built-in implementation.
341
+
342
+ ## Copyable component package
343
+
344
+ The [component package template](../../examples/component-package/README.md) is a complete external consumer. It defines a rating control, a Markdown note container, a package theme and an inlined SVG, then runs the public compliance tools against the installed tarball.
345
+
346
+ ```sh
347
+ cd ../reactive-md-component-package
348
+ npm install
349
+ npm run build
350
+ npm test
351
+ ```
352
+
353
+ `npm test` builds actual single-file offline HTML, runs the rating and a separate note lifecycle in an offline browser, and writes reports to `dist/compliance.json`. The package exposes compiled JavaScript and type declarations through its `exports` map. The template stays private; rename it, choose a license and remove `private` only when you intend to publish.
354
+
355
+ ## Migration from legacy registration
356
+
357
+ Legacy `hostComponents`, `hostRenderer` and `hostData` remain available. Combining legacy registration with the new configuration is rejected. Legacy declarations enter the common schema through an input adapter, while legacy render callbacks retain their prop behavior.
358
+
359
+ To migrate:
360
+
361
+ 1. Replace each host component schema with `defineLocalComponent` and the same name, version, props and capabilities.
362
+ 2. Move the render function to `defineReactComponent` and read `props`, `bindings` and `children` from the context.
363
+ 3. Create one `LocalConfig` and one `LocalReactConfig`, then pass them to every compiler, authoring, server and export call.
364
+ 4. Recompile documents and rebuild standalone bundles. The configuration key changes, and a sealed bundle or restoration requirement from the old configuration no longer matches.
365
+
366
+ Follow the [component plugin development guide](../development/component-development-en.md) for the workflow.
367
+
368
+ ## Verify a real consumer
369
+
370
+ The [consumer fixture](../../examples/integration/extension-sdk/README.md) defines a rating, a Markdown hint container and a paper theme through public exports.
371
+
372
+ ```powershell
373
+ npm.cmd run build:lib
374
+ npm.cmd run test:sdk-consumer
375
+ ```
376
+
377
+ The verifier installs tarballs outside the repository, checks types and SSR, builds the standalone bundle, and opens static and interactive HTML in fresh offline browser contexts. Results, exports and screenshots are retained in `artifacts/sdk-consumer`.
@@ -1,5 +1,7 @@
1
1
  # 本地交互文档集成
2
2
 
3
+ **中文** · [English](local-integration-en.md)
4
+
3
5
  本地交互模式使用 HTML 风格标签、就地参数和 `{{ 表达式 }}`。作者规则见 [新用户入门指南](../guides/local-guide-ch.md) 和 [语法规范](../reference/local-interaction-syntax-ch.md),完整文档见[示例索引](../../examples/local/README.md)。宿主通过带 `Local` 的 API 明确选择此模式。可选修订指令、升级检查与 `migrateLocalSource` 见[源码修订与迁移](../compatibility/source-versioning-ch.md),升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
4
6
 
5
7
  ## 运行环境与入口
@@ -54,9 +56,24 @@ export function Article() {
54
56
  | `colorScheme` | `'light' \| 'dark' \| 'auto'` | 两者 | 默认 `auto`,跟随最近祖先的显式模式或系统偏好 |
55
57
  | `hostData` | `Readonly<Record<string, unknown>>` | 两者 | 按 `${kind}:${ref}` 索引的 JSON 安全宿主数据,用于 `hostComponent` 节点;不进入 worker |
56
58
  | `hostRenderer` | `LocalHostRenderer` | 两者 | `hostComponent` 的客户端渲染函数;缺少 renderer 或数据时显示占位 |
59
+ | `externalValues` | `Readonly<Record<string, LocalValue>>` | `LocalReactiveDocument` | `<external>` 声明的值;更新不重新编译、不重置参数。`LocalDocumentView` 也接受该属性以更新宿主自管的运行时 |
60
+ | `initialParameters` | `Readonly<Record<string, LocalValue>>` | `LocalReactiveDocument` | 每次创建新运行时后、首次交互前应用一次的公开参数;非法集合原子拒绝并通过 `onDiagnostics` 报告 |
61
+ | `onParametersChange` | `(parameters, snapshot) => void` | `LocalReactiveDocument` | 公开可写参数实际变化时每次提交调用一次;初始化、被拒绝的写入、未变化的值和纯 external 更新不触发 |
62
+ | `onSourceNavigate` | `(target: LocalSourceTarget) => void` | 两者 | 报告预览节点的源码范围;启用时输出 source 元数据,省略时 DOM 保持不变 |
57
63
 
58
64
  两个组件都没有 `className`、`style` 或插槽属性。`LocalReactiveDocument` 渲染 `<article class="md-document local-document">`;`LocalDocumentView` 使用同样的文档容器。样式覆盖见下文。
59
65
 
66
+ ```tsx
67
+ <LocalReactiveDocument
68
+ source={source}
69
+ initialParameters={savedParameters}
70
+ onParametersChange={(parameters) => save(parameters)}
71
+ externalValues={{ exchangeRate: 7.2 }}
72
+ onSourceNavigate={(target) => editor.current?.selectRange(target.range)}
73
+ hostRenderer={(node, data, ctx) => <HostWidget node={node} data={data} ctx={ctx} />}
74
+ />
75
+ ```
76
+
60
77
  每个组件实例独立管理内存状态。修改源码会重新编译并从初值开始;销毁实例会清理订阅和计时器。需要在源码变化时保留值时,使用保留工具或自行管理运行时,见[源码变化时保留参数](#源码变化时保留参数)。文档中的面板重置其内部参数、输入草稿和组件状态,同名参数在面板外的显示也会同步更新。
61
78
 
62
79
  宿主 React 根与 standalone IIFE 共存于同一页面时,为宿主根设置独立的 `identifierPrefix`,例如 `createRoot(container, { identifierPrefix: 'host-' })`。两个 bundle 各自拥有 React 实例,默认 `useId` 计数可能重叠。独立的服务端渲染根也应在服务端和客户端使用相同且互不重复的前缀。
@@ -71,6 +88,34 @@ export function Article() {
71
88
 
72
89
  动态标题的锚点根据源码初值计算,参数变化只更新标题显示文字。渲染后的 DOM ID 属于当前挂载实例;保存目录时应保留源码中的片段链接。
73
90
 
91
+ ## 持续编辑的增量编译
92
+
93
+ 持续编辑同一份文档时,复用一个 `createLocalCompileSession()`,让未变化的顶层块保留解析与编译产物:
94
+
95
+ ```ts
96
+ import { createLocalCompileSession } from 'reactive-md';
97
+
98
+ const session = createLocalCompileSession();
99
+ session.compile('第一段 **文字**。\n\n第二段。');
100
+ const result = session.compile('第一段 **文字**。\n\n第二段有修改。');
101
+ console.log(session.stats); // mode: 'incremental', compiledBlocks: 1, reusedBlocks: 1
102
+ session.dispose(); // 关闭文档时释放会话缓存
103
+ ```
104
+
105
+ `compile(source, options?)` 返回 `LocalCompileResult`。`clear()` 清空复用数据,`dispose()` 释放缓存并结束会话;销毁后的会话不能再次编译。结果是可序列化的普通数据,每次返回独立快照,修改旧结果不会污染缓存。会话内未修改块的节点 ID 可跨编辑保持稳定,编号不要求与独立 `compileLocal()` 调用相同;节点 ID 及其元数据关联始终以同一份结果为准。
106
+
107
+ 同一会话内,参数与声明上下文保持不变时,只重新编译受影响的 Markdown 块。改变声明、组件内容、编译选项、权限或宿主 schema 时执行完整编译。引用定义、脚注、导航锚点、HTML、BOM、代码定界符变化及无法确认安全边界的输入也保守回到完整编译。出现诊断时返回完整编译的诊断。整篇源码和累计节点预算仍然生效,缓存只保留当前版本。
108
+
109
+ 连续修改组件或声明时,会话保留最新的成功编译结果,延迟建立块索引。恢复编辑独立正文块时,再建立一次索引并复用其他块。相同源码可直接返回独立快照;选项变化、错误、`clear()` 和 `dispose()` 都会清除待恢复状态。
110
+
111
+ `stats` 提供最近一次调用的 `mode`(`full`、`incremental`、`cached`)、块数、复用数、编译字符数与可选失效原因,用于观测实际复用。`cacheBuilds` 记录本次调用尝试建立块索引的次数,包括延迟恢复。修改块会在不变的声明前缀下编译,前缀工作量计入 `compiledCharacters`。差异检测、范围重定位和完整结果快照组装仍随文档规模增长;会话不保证每次编辑都是常数时间。
112
+
113
+ 扁平单行列表、表格即使占满整个文档,也可建立增量快照。修改一行后,会话复用上一版的简单行解析计划,并在完整语义校验后保留未修改行的节点 ID。位置不变的行可共享对象;位置变化时克隆并更新 UTF-16 范围。动态插值仍由通用解析器处理。`stats.parse` 中的 `reusedRows` / `reusedItems` 累计解析计划复用,`reusedRowNodes` / `reusedItemNodes` 单独累计最终行节点复用。
114
+
115
+ Worker 判断结果补丁不划算时,可对同一修订返回完整成功结果,并以该结果继续后续补丁链。`metrics.patchFallback === 'cost'` 表示成本选择;`patchBytes` / `fullBytes` 为 JSON UTF-8 估算,不是结构化克隆的实际大小。这种切换不会触发完整请求重试。
116
+
117
+ 内置 `startLocalCompileWorker()`、`LocalCompileScheduler` 默认降级编译和 `LocalReactiveDocument` 已管理各自会话。自定义 `fallbackCompile` 继续由宿主管理。`compileLocal()` 保持单次完整编译 API。测试与性能数据见[块级增量编译](../development/performance-overview-ch.md)。
118
+
74
119
  ## 核心 API
75
120
 
76
121
  ```ts
@@ -100,7 +145,7 @@ if (result.ok) {
100
145
  - 成功:`{ ok: true; document: LocalDocument; diagnostics: Diagnostic[] }`
101
146
  - 失败:`{ ok: false; diagnostics: Diagnostic[] }`
102
147
 
103
- 语法问题通过诊断返回;当前构建只接受 `local-draft-2`。显式旧修订指令会以 `local.version.*` 诊断拒绝;无指令源码保持当前修订的行为。源码上限为 1,000,000 字符。`document` 是当前运行时对象,不应当作持久化格式。
148
+ 语法问题通过诊断返回;当前构建只接受 `local-draft-3`。显式旧修订指令会以 `local.version.*` 诊断拒绝;无指令源码保持当前修订的行为。源码上限为 1,000,000 字符。`document` 是当前运行时对象,不应当作持久化格式。
104
149
 
105
150
  宿主可以为单次编译设置语法节点预算:
106
151
 
@@ -139,7 +184,7 @@ export default function Page() {
139
184
 
140
185
  ### 宿主组件
141
186
 
142
- 宿主可以为单次编译登记叶子标签,不改变 `local-draft-2` 语法修订:
187
+ 宿主可以为单次编译登记组件,不改变作者语法修订。schema 声明 `form`,并可声明标量绑定:
143
188
 
144
189
  ```ts
145
190
  import { compileLocal, type LocalHostComponentSchema } from 'reactive-md';
@@ -157,7 +202,11 @@ const hostComponents: LocalHostComponentSchema[] = [
157
202
  const result = compileLocal(source, { hostComponents });
158
203
  ```
159
204
 
160
- 不传 `hostComponents` 时,这些标签仍是未知标签并按原文降级。名称必须是唯一的小写 kebab-case,且不得复用 48 个作者标签名、P0 HTML 标签名或 `theme`;一次最多接受 32 个 schema。`pattern` 只接受线性时间安全的正则子集(拒绝反向引用、环视、命名组、嵌套量词和被量词修饰的分支)。schema 不合法返回 `local.options.invalid`,作者写出的属性不合法返回 `local.host.attribute`。一个合法宿主节点计为一个语法节点。把 `hostData`(按 `${kind}:${ref}` 索引)和 `hostRenderer` 传给 `LocalDocumentView`;两者都不进入 worker。缺少 renderer、缺少数据或 renderer 抛错时显示可见占位,不会让整个文档失败。`mode="static"` 走同一分派,并把 `ctx.mode` 传给 renderer。
205
+ 不传 `hostComponents` 时,这些标签仍是未知标签并按原文降级。名称必须是唯一的小写 kebab-case,且不得复用 49 个作者标签名、P0 HTML 标签名或 `theme`;一次最多接受 32 个 schema。`pattern` 只接受线性时间安全的正则子集(拒绝反向引用、环视、命名组、嵌套量词和被量词修饰的分支)。schema 不合法返回 `local.options.invalid`,作者写出的属性不合法返回 `local.host.attribute`。一个合法宿主节点计为一个语法节点。
206
+
207
+ `form` 为 `leaf`、`inline` 或 `container`;inline 和 container 使用成对标签,正文按普通 Markdown 与 ReactiveMD 规则编译,container renderer 可通过 `ctx.render()` 渲染子节点。`binding` 可选,接受 `string`、`number`、`boolean`,可声明静态 `min`、`max`、`step`、`options`、`initialRule` 和 `exclusive`。带绑定的宿主组件隐式接受 `bind`、`initial` 和动态 `disabled`,并与内置控件共享绑定族;例如宿主评分控件可与 `<number>` 共用同一个值。
208
+
209
+ renderer 接收 `(node, data, ctx)`。`ctx` 在渲染上下文之外提供 `value`、经运行时校验的 `setValue(value)`、`disabled`、`resetToken`、解析后的 `props` 和 `report(diagnostics)`。`setValue` 不会绕过共享约束或 reset。只有声明了 `kind`/`ref` 的组件才需要 `hostData`;纯绑定组件和 container 不需要伪造宿主数据。缺少 renderer、缺少其声明的数据或 renderer 抛错时显示可见占位,不会让整个文档失败。schema 是普通数据,可进入 worker;renderer 永远不进入。
161
210
 
162
211
  ### 版本查看与迁移
163
212
 
@@ -177,11 +226,11 @@ const migrated = migrateLocalSource(source, { fromVersion: 'local-draft-1' });
177
226
 
178
227
  `inspectLocalSourceVersion` 返回声明修订、用于判定的修订、当前编译器是否支持、指令位置和版本诊断。`checkLocalUpgrade` 返回 `ok`、`fromVersion`、`toVersion`、`needsMigration` 和诊断。`migrateLocalSource` 在此基础上增加 `source`、`changed` 和准确的 `edits`。
179
228
 
180
- `LocalUpgradeOptions` 提供 `fromVersion` 和 `allowSemanticChanges`。无版本声明的历史文档需要 `fromVersion: 'local-draft-1'`。显式 `fromVersion` 与声明不一致时被拒绝。迁移源只接受 `local-draft-1` 和 `local-draft-2`。
229
+ `LocalUpgradeOptions` 提供 `fromVersion` 和 `allowSemanticChanges`。无版本声明的历史文档需要 `fromVersion: 'local-draft-1'`。显式 `fromVersion` 与声明不一致时被拒绝。迁移源接受 `local-draft-1`、`local-draft-2` 和 `local-draft-3`。
181
230
 
182
231
  迁移只改元数据指令,保留正文原始字节、BOM 和 CRLF,并且幂等。生成结果前会阻止保留绑定、新增可识别标签、编译错误和文本控件长度语义变化。完整检查与 CLI 见[源码修订与迁移](../compatibility/source-versioning-ch.md)。
183
232
 
184
- ### `createLocalRuntime(document: LocalDocument)`
233
+ ### `createLocalRuntime(document: LocalDocument, options?: LocalRuntimeOptions)`
185
234
 
186
235
  只读命名值在可选的 `document.computations` 记录中用 `LocalComputation` 描述。`bindings` 和 `initialState` 继续只包含可写控件;`snapshot().state` 还包含该修订成功求值的计算结果。需要保留表达式错误语义时用 `evaluate(name)` 读取,失败值不会出现在快照里。见[计算与错误规则](../reference/computations-formatting-ch.md)。
187
236
 
@@ -194,7 +243,7 @@ const migrated = migrateLocalSource(source, { fromVersion: 'local-draft-1' });
194
243
  | 成员 | 参数 | 返回 | 行为 |
195
244
  | --- | --- | --- | --- |
196
245
  | `document` | — | `LocalDocument` | 创建时使用的编译结果 |
197
- | `snapshot()` | — | `{ revision: number; state: Readonly<Record<string, LocalValue>> }` | 状态未变时返回同一快照对象;状态冻结 |
246
+ | `snapshot()` | — | `{ revision: number; state: Readonly<Record<string, LocalValue>> }` | 状态未变时返回同一快照对象;状态冻结并包含可用的 external 值;可写参数请用 `getParameters()` |
198
247
  | `get(node, slot?)` | `LocalNode`、可选槽位 | `LocalValue` | 读取该控件绑定的值;`slot` 选择 `start`/`end` 或 `x`/`y`;无绑定或未知节点返回 `null`;数组为副本 |
199
248
  | `set(node, value, slot?)` | `LocalNode`、`LocalValue`、可选槽位 | `Diagnostic[]` | 校验所有共享控件;成功返回空数组并提交一次;失败不增加 revision |
200
249
  | `setMany(node, values)` | `LocalNode`、槽位值对象 | `Diagnostic[]` | 原子写入同一多槽控件的多个槽位;非法批次保持状态与 revision 不变 |
@@ -204,6 +253,9 @@ const migrated = migrateLocalSource(source, { fromVersion: 'local-draft-1' });
204
253
  | `getParameters()` | — | `Readonly<Record<string, LocalValue>>` | 只含公开参数的冻结快照;永不含内部 `@` 键 |
205
254
  | `setParameter(name, value)` | `string`, `LocalValue` | `Diagnostic[]` | 校验共享该绑定的所有控件;成功只提交一次;失败时状态不变 |
206
255
  | `setParameters(values)` | `Readonly<Record<string, LocalValue>>` | `Diagnostic[]` | 校验每个公开值和多槽关系后全部提交或全部不提交;未知或内部名称返回 `local.runtime.parameter`;非法值返回 `local.runtime.value`;值未变化不增加 revision |
256
+ | `getExternal(name)` | `string` | `LocalValue \| undefined` | 已声明 external 的当前值;未声明或不可用时为 `undefined`;数组为副本 |
257
+ | `getExternalValues()` | — | `Readonly<Record<string, LocalValue>>` | 当前可用 external 值的冻结记录 |
258
+ | `setExternalValues(values)` | `Readonly<Record<string, LocalValue>>` | `Diagnostic[]` | 原子校验部分更新;只提交并通知一次;未知名称、类型错误或超预算返回 `local.runtime.external`,不改变状态或 revision |
207
259
  | `evaluate(expression)` | `string` | `LocalValue` | 用当前状态求值;失败抛出 `LocalExpressionError`;数组为副本 |
208
260
  | `text(template)` | `string` | `string` | 渲染带 `{{ }}` 的文本;失败抛出错误 |
209
261
  | `reset(node)` | `LocalNode` | `void` | 一次恢复该节点子树内的参数和组件状态,只通知一次 |
@@ -314,7 +366,7 @@ scheduler.schedule(source);
314
366
 
315
367
  ### 其他核心导出
316
368
 
317
- - `LOCAL_SYNTAX_VERSION`:当前为字面量 `'local-draft-2'`。用它记录文档所用的语法修订。
369
+ - `LOCAL_SYNTAX_VERSION`:当前为字面量 `'local-draft-3'`。用它记录文档所用的语法修订。
318
370
  - `compileExpression(source: string)`:返回带 `source`、`dependencies`、`evaluate(env)` 和 `inferType(env)` 的对象;失败抛出 `LocalExpressionError`。
319
371
  - `LocalExpressionError`:包含 `code` 和 `offset`。
320
372
  - `compileLatex(source: string)`:返回带 `source`、`dependencies` 和 `evaluate(x, env, budget?)` 的对象;失败抛出带 `code`、`offset` 的错误。
@@ -402,9 +454,11 @@ const urlPolicy: LocalUrlPolicy = (raw, kind) => {
402
454
 
403
455
  ## 不提供的功能
404
456
 
405
- 默认 ReactiveMD 路径支持 P0 HTML。作者 CSS、JavaScript 和扩展 HTML 的宿主开关使用独立的原生 HTML 路径,见 [HTML 部分兼容](../reference/html-compatibility-ch.md)。本地模式仍不提供自动状态持久化或不受限的网络访问、插件或自定义组件注册、外部数据接口、Vue 支持、React 18 支持或 CommonJS 入口。状态导出与导入是宿主的显式调用。`LocalReactiveDocument` 在源码变化时从初值开始;需要保留参数时使用保留工具,或自行管理运行时和文档。
457
+ 默认 ReactiveMD 路径支持 P0 HTML。作者 CSS、JavaScript 和扩展 HTML 的宿主开关使用独立的原生 HTML 路径,见 [HTML 部分兼容](../reference/html-compatibility-ch.md)。自动状态持久化、不受限的网络或存储调用、Vue、React 18 和 CommonJS 仍不在当前接口范围内。宿主数据使用显式只读声明,状态导出与导入由宿主调用。
458
+
459
+ [扩展 SDK](extension-sdk-ch.md)随 `reactive-md@0.7.0` 提供自定义组件和主题包注册,开发流程见[组件插件开发指南](../development/component-development-ch.md)。`LocalReactiveDocument` 在普通源码编辑中尝试采用新文档并保留兼容绑定;切换独立文档时更换 React `key`,或由宿主管理文档与运行时。
406
460
 
407
461
 
408
- 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](../reference/local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。`0.6.0` 同时提供于 `latest` 与 `next` 渠道。
462
+ 新增组块、颜色、槽位状态与迁移规则见[local-draft-2 扩展说明](../reference/local-components-v2-ch.md),升级清单见[0.4.0 发布与迁移](../releases/release-0.4.0-ch.md)。
409
463
 
410
464
  0.5.3 新增接受编译配置的作者工具及显式屏幕、打印样式入口,见 [0.5.3 宿主集成](../releases/release-0.5.3-ch.md)。0.6.0 让 `compileLocal` 返回可跨 React Server Components 边界的普通数据,见 [0.6.0 发布说明](../releases/release-0.6.0-ch.md)。