reactive-md 0.9.1 → 0.9.3

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 (428) hide show
  1. package/CHANGELOG-ch.md +44 -0
  2. package/CHANGELOG.md +44 -0
  3. package/README-ch.md +7 -7
  4. package/README-en.md +6 -6
  5. package/README.md +7 -7
  6. package/cli/init.mjs +1 -1
  7. package/dist-library/LocalDocumentView-D6zQkTkt.js +112 -0
  8. package/dist-library/{LocalDocumentViewCore-GiWV3bey.js → LocalDocumentViewCore-CmJhemcA.js} +387 -9471
  9. package/dist-library/LocalReactiveDocumentCore-lAKOGAZ7.js +283 -0
  10. package/dist-library/LocalStaticDocumentView-2J7w0sKm.js +143 -0
  11. package/dist-library/{authoring-Dsune4Hy.js → authoring-B14SsOXZ.js} +68 -67
  12. package/dist-library/chart-B1TUtzm-.js +3 -0
  13. package/dist-library/color-values-r8Wf7ALn.js +6 -0
  14. package/dist-library/{compile-wUv8KEge.js → compile-D50B5_Ww.js} +32 -32
  15. package/dist-library/compile-cache-key-6GgpETz_.js +28 -0
  16. package/dist-library/compiler-DLkKUK4t.js +98 -0
  17. package/dist-library/{compiler-core-As_m-MNm.js → compiler-core-Niqhp9wV.js} +2963 -3283
  18. package/dist-library/{registry-core-Bbad9Bm2.js → component-kernel-IG4wOO0i.js} +72 -195
  19. package/dist-library/component-state-CwKX_SN5.js +763 -0
  20. package/dist-library/{component-state-C52ZFJGl.js → component-state-Ht-hOK0W.js} +15 -14
  21. package/dist-library/component-utils-eSj5IdG4.js +338 -0
  22. package/dist-library/computations-CffoW7Ff.js +340 -0
  23. package/dist-library/config-validation-Cpol91_M.js +456 -0
  24. package/dist-library/controls-B-CLSK8Q.js +5927 -0
  25. package/dist-library/controls-DWlx-AQl.js +3 -0
  26. package/dist-library/{coordinate-CWS9p5q_.js → coordinate-PyLPMIQK.js} +85 -85
  27. package/dist-library/data-BtFlkJzp.js +3 -0
  28. package/dist-library/{data-table-Bgccxd7h.js → data-table-Kv_ZA2Z2.js} +14 -13
  29. package/dist-library/data-visuals-_Z7QqYTk.js +384 -0
  30. package/dist-library/{default-components-BwQf0oP-.js → default-components-jugH7Ubr.js} +333 -331
  31. package/dist-library/{config-BadfhjdP.js → default-config-DIrRpuQz.js} +96 -79
  32. package/dist-library/default-options-DU5dxuU6.js +125 -0
  33. package/dist-library/{registry-B9NGct4d.js → default-registry-BlloaZi7.js} +4 -4
  34. package/dist-library/default-schema-Ch-Vznpm.js +33 -0
  35. package/dist-library/diagram-BLepzI8l.js +3 -0
  36. package/dist-library/{display-B-VhqVND.js → display-y4v9v0Qd.js} +1 -1
  37. package/dist-library/dist-Cueh1Psp.js +4761 -0
  38. package/dist-library/{config-validation-F47AcE6o.js → document-theme-DBAfnk7y.js} +248 -731
  39. package/dist-library/{export-BqVmTXm8.js → export-heVBqgxA.js} +46 -44
  40. package/dist-library/gallery-BC6FYTqw.js +3 -0
  41. package/dist-library/{gallery-CY6mTx8i.js → gallery-Q6VPS2ep.js} +1 -1
  42. package/dist-library/{html-CNT4KD-2.js → html-CCnvzan1.js} +56 -54
  43. package/dist-library/identity-BUx0Q_-d.js +40 -0
  44. package/dist-library/{incremental-Dv0FSp_U.js → incremental-Bzvh8_lB.js} +529 -380
  45. package/dist-library/{layout-C0YlEPGr.js → layout-BfUzzO2b.js} +147 -156
  46. package/dist-library/layout-BnfDeUNy.js +3 -0
  47. package/dist-library/limits-CFERRrlC.js +10 -0
  48. package/dist-library/localization-COdJ6lw2.js +6 -0
  49. package/dist-library/mafs-CnzDC5CR.js +3 -0
  50. package/dist-library/math-view-B0jthpRw.js +20 -0
  51. package/dist-library/motion-tokens-Czk0RDmS.js +283 -0
  52. package/dist-library/mount-preset-C_i37FvY.js +24 -0
  53. package/dist-library/numeric-sliders-CkWS0-ja.js +542 -0
  54. package/dist-library/observability-CYLuvFfL.js +502 -0
  55. package/dist-library/observability-core-Bcu7vpnl.js +24 -0
  56. package/dist-library/{package-core-WFK1RhAZ.js → package-core-9UK5ZdqB.js} +57 -46
  57. package/dist-library/parser-9yNJxGip.js +8 -0
  58. package/dist-library/parser-standard-BPIy4HOu.js +4872 -0
  59. package/dist-library/plugin-packs-CZb46nuv.js +19 -0
  60. package/dist-library/preset-core-BW3NWZJ9.js +1300 -0
  61. package/dist-library/props-pJRrfDc6.js +179 -0
  62. package/dist-library/react-BSo0o998.js +32 -0
  63. package/dist-library/reactive-md-authoring.js +274 -263
  64. package/dist-library/reactive-md-build.js +55 -20
  65. package/dist-library/reactive-md-compiler-session.js +4 -0
  66. package/dist-library/reactive-md-compiler-standard.js +6 -6
  67. package/dist-library/reactive-md-compiler.js +3 -3
  68. package/dist-library/reactive-md-contracts.js +6 -0
  69. package/dist-library/reactive-md-default-packs.js +31 -14
  70. package/dist-library/reactive-md-default-preset.js +7 -6
  71. package/dist-library/reactive-md-export.js +6 -5
  72. package/dist-library/reactive-md-minimal-preset.js +2 -2
  73. package/dist-library/reactive-md-minimal-react-preset.js +22 -20
  74. package/dist-library/reactive-md-minimal.css +1 -1
  75. package/dist-library/reactive-md-observability.js +126 -0
  76. package/dist-library/reactive-md-pack-style-manifest.js +797 -0
  77. package/dist-library/reactive-md-plugin-chart.js +6 -5
  78. package/dist-library/reactive-md-plugin-data.js +8 -8
  79. package/dist-library/reactive-md-plugin-diagram.js +7 -6
  80. package/dist-library/reactive-md-plugin-forms.js +14 -13
  81. package/dist-library/reactive-md-plugin-gallery.js +6 -5
  82. package/dist-library/reactive-md-plugin-navigation.js +9 -9
  83. package/dist-library/reactive-md-plugin-network.js +13 -12
  84. package/dist-library/reactive-md-plugin-plot.js +7 -6
  85. package/dist-library/reactive-md-react-component-accordion.js +10 -0
  86. package/dist-library/reactive-md-react-component-alert.js +10 -0
  87. package/dist-library/reactive-md-react-component-anchor.js +10 -0
  88. package/dist-library/reactive-md-react-component-badge.js +10 -0
  89. package/dist-library/reactive-md-react-component-card.js +10 -0
  90. package/dist-library/reactive-md-react-component-chart.js +22 -0
  91. package/dist-library/reactive-md-react-component-checkbox.js +10 -0
  92. package/dist-library/reactive-md-react-component-checklist.js +10 -0
  93. package/dist-library/reactive-md-react-component-choices.js +10 -0
  94. package/dist-library/reactive-md-react-component-column.js +6 -0
  95. package/dist-library/reactive-md-react-component-coordinate.js +21 -0
  96. package/dist-library/reactive-md-react-component-counter.js +10 -0
  97. package/dist-library/reactive-md-react-component-data-table.js +14 -0
  98. package/dist-library/reactive-md-react-component-date.js +10 -0
  99. package/dist-library/reactive-md-react-component-diagram.js +22 -0
  100. package/dist-library/reactive-md-react-component-disclosure.js +10 -0
  101. package/dist-library/reactive-md-react-component-edge.js +22 -0
  102. package/dist-library/reactive-md-react-component-gallery-item.js +10 -0
  103. package/dist-library/reactive-md-react-component-gallery.js +10 -0
  104. package/dist-library/reactive-md-react-component-grid.js +10 -0
  105. package/dist-library/reactive-md-react-component-if.js +10 -0
  106. package/dist-library/reactive-md-react-component-input.js +10 -0
  107. package/dist-library/reactive-md-react-component-jump.js +10 -0
  108. package/dist-library/reactive-md-react-component-multi-select.js +10 -0
  109. package/dist-library/reactive-md-react-component-node.js +22 -0
  110. package/dist-library/reactive-md-react-component-number.js +10 -0
  111. package/dist-library/reactive-md-react-component-option.js +10 -0
  112. package/dist-library/reactive-md-react-component-panel.js +10 -0
  113. package/dist-library/reactive-md-react-component-plot.js +26 -0
  114. package/dist-library/reactive-md-react-component-progress.js +10 -0
  115. package/dist-library/reactive-md-react-component-quiz.js +10 -0
  116. package/dist-library/reactive-md-react-component-radio-group.js +10 -0
  117. package/dist-library/reactive-md-react-component-range-slider.js +10 -0
  118. package/dist-library/reactive-md-react-component-section.js +10 -0
  119. package/dist-library/reactive-md-react-component-select.js +10 -0
  120. package/dist-library/reactive-md-react-component-slider.js +10 -0
  121. package/dist-library/reactive-md-react-component-step.js +10 -0
  122. package/dist-library/reactive-md-react-component-steps.js +10 -0
  123. package/dist-library/reactive-md-react-component-tab.js +10 -0
  124. package/dist-library/reactive-md-react-component-table.js +14 -0
  125. package/dist-library/reactive-md-react-component-tabs.js +10 -0
  126. package/dist-library/reactive-md-react-component-text.js +10 -0
  127. package/dist-library/reactive-md-react-component-textarea.js +10 -0
  128. package/dist-library/reactive-md-react-component-timeline.js +14 -0
  129. package/dist-library/reactive-md-react-component-timer.js +10 -0
  130. package/dist-library/reactive-md-react-component-toggle.js +10 -0
  131. package/dist-library/reactive-md-react-component-tooltip.js +10 -0
  132. package/dist-library/reactive-md-react-component-validation.js +10 -0
  133. package/dist-library/reactive-md-react-minimal.js +4 -4
  134. package/dist-library/reactive-md-react-pack-controls.js +44 -0
  135. package/dist-library/reactive-md-react-pack-data.js +21 -0
  136. package/dist-library/reactive-md-react-pack-layout.js +36 -0
  137. package/dist-library/reactive-md-react-pack-visuals.js +43 -0
  138. package/dist-library/reactive-md-react-packed.js +50 -0
  139. package/dist-library/reactive-md-react-server.js +26 -25
  140. package/dist-library/reactive-md-react-static-server.js +24 -0
  141. package/dist-library/reactive-md-react-static.js +1 -0
  142. package/dist-library/reactive-md-react-unstyled.js +15 -12
  143. package/dist-library/reactive-md-react.js +15 -12
  144. package/dist-library/reactive-md-runtime-browser.js +2 -1
  145. package/dist-library/reactive-md-runtime.js +4 -3
  146. package/dist-library/reactive-md-scan.js +1 -0
  147. package/dist-library/reactive-md-sdk.js +9 -8
  148. package/dist-library/reactive-md-standalone-configured.js +2 -2
  149. package/dist-library/reactive-md-standalone-host.js +2 -2
  150. package/dist-library/reactive-md-testing-browser.js +2 -2
  151. package/dist-library/reactive-md-testing-react.js +32 -32
  152. package/dist-library/reactive-md-testing.js +12 -12
  153. package/dist-library/reactive-md-worker-pool.js +401 -0
  154. package/dist-library/reactive-md.css +1 -1
  155. package/dist-library/reactive-md.js +84 -1361
  156. package/dist-library/registry-core-CziAIP5P.js +125 -0
  157. package/dist-library/render-nodes-DKjg_TR1.js +9369 -0
  158. package/dist-library/{resources-D2GDQS0p.js → requirements-DhIkxAbl.js} +37 -84
  159. package/dist-library/resources-B_nbROgj.js +74 -0
  160. package/dist-library/rmd-pack-controls.css +1032 -0
  161. package/dist-library/rmd-pack-data.css +724 -0
  162. package/dist-library/rmd-pack-layout.css +1825 -0
  163. package/dist-library/rmd-pack-resource-chart.css +300 -0
  164. package/dist-library/rmd-pack-resource-controls.css +781 -0
  165. package/dist-library/rmd-pack-resource-data-visuals.css +501 -0
  166. package/dist-library/rmd-pack-resource-diagram.css +106 -0
  167. package/dist-library/rmd-pack-resource-gallery.css +346 -0
  168. package/dist-library/rmd-pack-resource-graphics.css +516 -0
  169. package/dist-library/rmd-pack-resource-layout.css +1480 -0
  170. package/dist-library/rmd-pack-resource-mafs-core.css +124 -0
  171. package/dist-library/rmd-pack-resource-mafs.css +129 -0
  172. package/dist-library/rmd-pack-resource-visual-base.css +224 -0
  173. package/dist-library/rmd-pack-visuals.css +1394 -0
  174. package/dist-library/{runtime-B2fxeveq.js → runtime-BDnnimPA.js} +17 -16
  175. package/dist-library/{runtime-kcA7bG7G.js → runtime-CuJndKqK.js} +320 -313
  176. package/dist-library/runtime-requirement-C4-vNcf5.js +769 -0
  177. package/dist-library/schema-core-4sd1Vu7V.js +132 -0
  178. package/dist-library/{sdk-core-BoJT1SIt.js → sdk-core-BLsW9cCy.js} +494 -520
  179. package/dist-library/{session-core-nmJHuR9c.js → session-core-DLBRPV7f.js} +33 -31
  180. package/dist-library/{shareable-DpbE-59H.js → shareable-C6mUerpQ.js} +215 -209
  181. package/dist-library/shared-bTzN-F4g.js +3 -0
  182. package/dist-library/structural-views-30-YD_TJ.js +11 -0
  183. package/dist-library/table-surface-CfZn_tk-.js +13 -0
  184. package/dist-library/types/assemblies/compile-cache-key.d.ts +11 -0
  185. package/dist-library/types/assemblies/default-config.d.ts +35 -0
  186. package/dist-library/types/{local/configuration/options.d.ts → assemblies/default-options.d.ts} +4 -4
  187. package/dist-library/types/assemblies/default-registry.d.ts +18 -0
  188. package/dist-library/types/{local/configuration/schema.d.ts → assemblies/default-schema.d.ts} +4 -4
  189. package/dist-library/types/authoring/catalog.d.ts +11 -1
  190. package/dist-library/types/authoring/extensions.d.ts +1 -1
  191. package/dist-library/types/authoring/index.d.ts +3 -3
  192. package/dist-library/types/authoring/templates.d.ts +1 -1
  193. package/dist-library/types/build/diagnostics.d.ts +1 -1
  194. package/dist-library/types/compiler/index.d.ts +1 -0
  195. package/dist-library/types/compiler/session.d.ts +19 -0
  196. package/dist-library/types/compiler/standard.d.ts +1 -0
  197. package/dist-library/types/components/entries/accordion.d.ts +3 -0
  198. package/dist-library/types/components/entries/alert.d.ts +3 -0
  199. package/dist-library/types/components/entries/anchor.d.ts +3 -0
  200. package/dist-library/types/components/entries/badge.d.ts +3 -0
  201. package/dist-library/types/components/entries/card.d.ts +3 -0
  202. package/dist-library/types/components/entries/chart.d.ts +3 -0
  203. package/dist-library/types/components/entries/checkbox.d.ts +3 -0
  204. package/dist-library/types/components/entries/checklist.d.ts +3 -0
  205. package/dist-library/types/components/entries/choices.d.ts +3 -0
  206. package/dist-library/types/components/entries/column.d.ts +3 -0
  207. package/dist-library/types/components/entries/coordinate.d.ts +3 -0
  208. package/dist-library/types/components/entries/counter.d.ts +3 -0
  209. package/dist-library/types/components/entries/data-table.d.ts +3 -0
  210. package/dist-library/types/components/entries/date.d.ts +3 -0
  211. package/dist-library/types/components/entries/diagram.d.ts +3 -0
  212. package/dist-library/types/components/entries/disclosure.d.ts +3 -0
  213. package/dist-library/types/components/entries/edge.d.ts +3 -0
  214. package/dist-library/types/components/entries/gallery-item.d.ts +3 -0
  215. package/dist-library/types/components/entries/gallery.d.ts +3 -0
  216. package/dist-library/types/components/entries/grid.d.ts +3 -0
  217. package/dist-library/types/components/entries/if.d.ts +3 -0
  218. package/dist-library/types/components/entries/input.d.ts +3 -0
  219. package/dist-library/types/components/entries/jump.d.ts +3 -0
  220. package/dist-library/types/components/entries/multi-select.d.ts +3 -0
  221. package/dist-library/types/components/entries/node.d.ts +3 -0
  222. package/dist-library/types/components/entries/number.d.ts +3 -0
  223. package/dist-library/types/components/entries/option.d.ts +3 -0
  224. package/dist-library/types/components/entries/panel.d.ts +3 -0
  225. package/dist-library/types/components/entries/plot.d.ts +3 -0
  226. package/dist-library/types/components/entries/progress.d.ts +3 -0
  227. package/dist-library/types/components/entries/quiz.d.ts +3 -0
  228. package/dist-library/types/components/entries/radio-group.d.ts +3 -0
  229. package/dist-library/types/components/entries/range-slider.d.ts +3 -0
  230. package/dist-library/types/components/entries/section.d.ts +3 -0
  231. package/dist-library/types/components/entries/select.d.ts +3 -0
  232. package/dist-library/types/components/entries/slider.d.ts +3 -0
  233. package/dist-library/types/components/entries/step.d.ts +3 -0
  234. package/dist-library/types/components/entries/steps.d.ts +3 -0
  235. package/dist-library/types/components/entries/tab.d.ts +3 -0
  236. package/dist-library/types/components/entries/table.d.ts +3 -0
  237. package/dist-library/types/components/entries/tabs.d.ts +3 -0
  238. package/dist-library/types/components/entries/text.d.ts +3 -0
  239. package/dist-library/types/components/entries/textarea.d.ts +3 -0
  240. package/dist-library/types/components/entries/timeline.d.ts +3 -0
  241. package/dist-library/types/components/entries/timer.d.ts +3 -0
  242. package/dist-library/types/components/entries/toggle.d.ts +3 -0
  243. package/dist-library/types/components/entries/tooltip.d.ts +3 -0
  244. package/dist-library/types/components/entries/validation.d.ts +3 -0
  245. package/dist-library/types/components/layout/layout.d.ts +1 -3
  246. package/dist-library/types/components/layout/structural-views.d.ts +3 -0
  247. package/dist-library/types/components/mount-preset.d.ts +2 -0
  248. package/dist-library/types/components/packs/controls.d.ts +2 -0
  249. package/dist-library/types/components/packs/data.d.ts +2 -0
  250. package/dist-library/types/components/packs/layout.d.ts +2 -0
  251. package/dist-library/types/components/packs/visuals.d.ts +2 -0
  252. package/dist-library/types/components/shared/data-visuals.d.ts +3 -0
  253. package/dist-library/types/components/shared/table-surface.d.ts +10 -0
  254. package/dist-library/types/components/shared/visual-helpers.d.ts +24 -0
  255. package/dist-library/types/components/shared/visuals.d.ts +0 -2
  256. package/dist-library/types/components/table/data-table-model.d.ts +48 -0
  257. package/dist-library/types/components/table/data-table.d.ts +1 -48
  258. package/dist-library/types/{local/configuration → contracts}/component-kernel.d.ts +4 -2
  259. package/dist-library/types/contracts/index.d.ts +8 -0
  260. package/dist-library/types/{local/configuration → contracts}/limits.d.ts +9 -1
  261. package/dist-library/types/contracts/localization.d.ts +6 -0
  262. package/dist-library/types/contracts/runtime-types.d.ts +19 -0
  263. package/dist-library/types/local/compilation/cache-version.d.ts +1 -0
  264. package/dist-library/types/local/compilation/compile-status.d.ts +2 -0
  265. package/dist-library/types/local/compilation/compiler-bindings.d.ts +1 -1
  266. package/dist-library/types/local/compilation/compiler-capabilities.d.ts +4 -1
  267. package/dist-library/types/local/compilation/compiler-core.d.ts +1 -1
  268. package/dist-library/types/local/compilation/compiler-embedding.d.ts +20 -0
  269. package/dist-library/types/local/compilation/compiler-expressions.d.ts +5 -4
  270. package/dist-library/types/local/compilation/compiler-structure.d.ts +1 -1
  271. package/dist-library/types/local/compilation/compiler-tables.d.ts +3 -2
  272. package/dist-library/types/local/compilation/compiler-validation.d.ts +5 -9
  273. package/dist-library/types/local/compilation/compiler-values.d.ts +1 -1
  274. package/dist-library/types/local/compilation/compiler.d.ts +1 -1
  275. package/dist-library/types/local/compilation/component-usage.d.ts +2 -0
  276. package/dist-library/types/local/compilation/runtime-requirement.d.ts +3 -0
  277. package/dist-library/types/local/compilation/session/incremental.d.ts +5 -1
  278. package/dist-library/types/local/compilation/streaming.d.ts +1 -1
  279. package/dist-library/types/local/configuration/diagnostic-messages.d.ts +55 -0
  280. package/dist-library/types/local/configuration/embedding.d.ts +4 -0
  281. package/dist-library/types/local/configuration/kernel-value-rules.d.ts +1 -1
  282. package/dist-library/types/local/configuration/options-core.d.ts +8 -2
  283. package/dist-library/types/local/index.d.ts +12 -1
  284. package/dist-library/types/local/observability-codes.d.ts +2 -0
  285. package/dist-library/types/local/observability-core.d.ts +44 -0
  286. package/dist-library/types/local/observability-messages.d.ts +6 -0
  287. package/dist-library/types/local/observability.d.ts +45 -0
  288. package/dist-library/types/local/parsing/parse-budget.d.ts +18 -2
  289. package/dist-library/types/local/parsing/parser-internals.d.ts +2 -1
  290. package/dist-library/types/local/parsing/parser-region.d.ts +13 -2
  291. package/dist-library/types/local/parsing/parser-tags.d.ts +6 -1
  292. package/dist-library/types/local/parsing/rmd-recovery.d.ts +8 -0
  293. package/dist-library/types/local/performance-report.d.ts +70 -0
  294. package/dist-library/types/local/runtime/runtime-pool.d.ts +14 -0
  295. package/dist-library/types/local/transport/worker-handler.d.ts +3 -0
  296. package/dist-library/types/local/transport/worker-job.d.ts +12 -2
  297. package/dist-library/types/local/transport/worker-pool.d.ts +68 -0
  298. package/dist-library/types/local/transport/worker.d.ts +66 -1
  299. package/dist-library/types/local/types.d.ts +45 -25
  300. package/dist-library/types/observability.d.ts +8 -0
  301. package/dist-library/types/presets/default-semantics.d.ts +1 -1
  302. package/dist-library/types/presets/identity.d.ts +1 -8
  303. package/dist-library/types/presets/pack-style-entry.d.ts +3 -0
  304. package/dist-library/types/presets/pack-style-manifest.d.ts +11 -0
  305. package/dist-library/types/react/component-api.d.ts +3 -2
  306. package/dist-library/types/react/component-loader.d.ts +61 -0
  307. package/dist-library/types/react/component-primitives.d.ts +5 -5
  308. package/dist-library/types/react/index.d.ts +9 -5
  309. package/dist-library/types/react/localization.d.ts +5 -6
  310. package/dist-library/types/react/minimal.d.ts +2 -2
  311. package/dist-library/types/react/package-core.d.ts +3 -0
  312. package/dist-library/types/react/packed.d.ts +17 -0
  313. package/dist-library/types/react/render-lifecycle.d.ts +9 -0
  314. package/dist-library/types/{local → react}/rendering/document/ExtendedHtmlFragment.d.ts +1 -1
  315. package/dist-library/types/{local → react}/rendering/document/LocalDocumentViewCore.d.ts +11 -4
  316. package/dist-library/types/react/rendering/document/LocalPooledDocumentView.d.ts +8 -0
  317. package/dist-library/types/react/rendering/document/LocalReactiveDocumentCore.d.ts +6 -0
  318. package/dist-library/types/react/rendering/document/LocalStaticDocumentView.d.ts +18 -0
  319. package/dist-library/types/react/rendering/document/StaticExternalSlot.d.ts +25 -0
  320. package/dist-library/types/react/rendering/document/StaticHostData.d.ts +14 -0
  321. package/dist-library/types/{local → react}/rendering/document/render-nodes.d.ts +8 -8
  322. package/dist-library/types/react/rendering/document/static-runtime.d.ts +11 -0
  323. package/dist-library/types/{local → react}/rendering/document/use-author-script.d.ts +2 -2
  324. package/dist-library/types/{local → react}/rendering/document/validation-state.d.ts +2 -2
  325. package/dist-library/types/{local → react}/rendering/document/view-render-context.d.ts +40 -8
  326. package/dist-library/types/{local → react}/rendering/document/view-revision.d.ts +2 -2
  327. package/dist-library/types/{local → react}/rendering/render-types.d.ts +5 -5
  328. package/dist-library/types/react/rendering/table/data-table.d.ts +5 -0
  329. package/dist-library/types/{local → react}/rendering/table/table-numeric-columns.d.ts +3 -3
  330. package/dist-library/types/react/sdk-core.d.ts +12 -3
  331. package/dist-library/types/react/sdk.d.ts +2 -1
  332. package/dist-library/types/react/server.d.ts +3 -10
  333. package/dist-library/types/react/static-server.d.ts +12 -0
  334. package/dist-library/types/scan/index.d.ts +15 -0
  335. package/dist-library/types/sdk/config.d.ts +2 -35
  336. package/dist-library/types/sdk/default-identity.d.ts +3 -0
  337. package/dist-library/types/sdk/index.d.ts +1 -1
  338. package/dist-library/types/sdk/preset.d.ts +9 -0
  339. package/dist-library/types/sdk/props.d.ts +8 -3
  340. package/dist-library/types/sdk/registry-core.d.ts +2 -2
  341. package/dist-library/types/sdk/registry.d.ts +2 -18
  342. package/dist-library/types/sdk/types.d.ts +2 -2
  343. package/dist-library/types/sdk/version.d.ts +2 -0
  344. package/dist-library/types/standalone/session-core.d.ts +1 -1
  345. package/dist-library/{types-BeNtPqdY.js → types-Bza88SGK.js} +1 -1
  346. package/dist-library/types-daDo2c_w.js +3 -0
  347. package/dist-library/use-hydrated-W-laKPhY.js +22975 -0
  348. package/dist-library/validation-XXlb-spV.js +860 -0
  349. package/dist-library/version-B0G1699c.js +138 -0
  350. package/dist-library/visual-frame-y5RFhJ0_.js +19 -0
  351. package/dist-library/visual-helpers-CRmaqCHX.js +75 -0
  352. package/dist-library/visuals-CdHezgh5.js +3 -0
  353. package/dist-library/visuals-CoVSjVD8.js +49159 -0
  354. package/dist-library/worker-D6WMV8xJ.js +1632 -0
  355. package/dist-standalone/reactive-md-standalone.css +1 -1
  356. package/dist-standalone/reactive-md-standalone.js +119 -118
  357. package/docs/README-ch.md +8 -1
  358. package/docs/README.md +8 -1
  359. package/docs/compatibility/api-stability-ch.md +25 -0
  360. package/docs/compatibility/api-stability-en.md +25 -0
  361. package/docs/compatibility/compatibility-ch.md +32 -15
  362. package/docs/compatibility/compatibility-en.md +32 -15
  363. package/docs/compatibility/compatibility-manifest.schema.json +161 -0
  364. package/docs/compatibility/deprecation-ch.md +21 -0
  365. package/docs/compatibility/deprecation-en.md +21 -0
  366. package/docs/compatibility/source-versioning-ch.md +1 -1
  367. package/docs/compatibility/source-versioning-en.md +1 -1
  368. package/docs/compatibility/support-matrix-ch.md +108 -0
  369. package/docs/compatibility/support-matrix-en.md +108 -0
  370. package/docs/development/component-development-ch.md +2 -2
  371. package/docs/development/component-development-en.md +2 -2
  372. package/docs/development/component-development-reference-ch.md +16 -0
  373. package/docs/development/component-development-reference-en.md +16 -0
  374. package/docs/development/component-protocol-ch.md +31 -11
  375. package/docs/development/component-protocol-en.md +31 -11
  376. package/docs/integration/author-tools-ch.md +3 -1
  377. package/docs/integration/author-tools-en.md +3 -1
  378. package/docs/integration/compiler-ch.md +42 -1
  379. package/docs/integration/compiler-en.md +42 -1
  380. package/docs/integration/editor-ch.md +2 -2
  381. package/docs/integration/editor-en.md +2 -2
  382. package/docs/integration/extension-sdk-ch.md +6 -2
  383. package/docs/integration/extension-sdk-en.md +6 -2
  384. package/docs/integration/local-integration-ch.md +4 -2
  385. package/docs/integration/local-integration-en.md +4 -2
  386. package/docs/reference/public-api-ch.md +143 -7
  387. package/docs/reference/public-api-en.md +143 -7
  388. package/docs/releases/release-0.9.2-ch.md +33 -0
  389. package/docs/releases/release-0.9.2-en.md +33 -0
  390. package/docs/releases/release-0.9.3-ch.md +45 -0
  391. package/docs/releases/release-0.9.3-en.md +45 -0
  392. package/examples/integration/README-ch.md +36 -4
  393. package/examples/integration/README.md +36 -4
  394. package/examples/integration/chat-session/index.mjs +91 -0
  395. package/examples/integration/chat-session/package.json +10 -0
  396. package/examples/integration/static-embed/embed.mjs +44 -0
  397. package/examples/integration/static-embed/index.html +12 -0
  398. package/examples/integration/static-embed/main.mjs +24 -0
  399. package/examples/integration/static-embed/references.mjs +5 -0
  400. package/examples/integration/static-embed/render.mjs +10 -0
  401. package/package.json +67 -2
  402. package/dist-library/LocalDocumentView-sthUP0ct.js +0 -109
  403. package/dist-library/LocalReactiveDocumentCore-ZjQSGyHE.js +0 -275
  404. package/dist-library/compiler-eOfcinZs.js +0 -62
  405. package/dist-library/component-state-BoLCGee4.js +0 -801
  406. package/dist-library/controls-CcT6n7k_.js +0 -6740
  407. package/dist-library/mount-preset-KxvtKgJb.js +0 -13
  408. package/dist-library/options-1aDLK7JY.js +0 -121
  409. package/dist-library/parser-standard-Yuf3A_VI.js +0 -9630
  410. package/dist-library/plugin-packs-B1XPWcFs.js +0 -18
  411. package/dist-library/preset-core-CKc5YXSM.js +0 -1443
  412. package/dist-library/props-sJ8vk0cr.js +0 -183
  413. package/dist-library/react-D5iGiUdL.js +0 -7
  414. package/dist-library/schema-BufhKUSM.js +0 -40
  415. package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +0 -6
  416. package/dist-library/types/local/rendering/table/data-table.d.ts +0 -13
  417. package/dist-library/validation-BEBA_HvS.js +0 -1121
  418. package/dist-library/visual-frame-CyV1FXzs.js +0 -48
  419. package/dist-library/visuals-BZbZYA7w.js +0 -72572
  420. /package/dist-library/types/{local/configuration → contracts}/color-values.d.ts +0 -0
  421. /package/dist-library/types/{local/html → contracts}/html-names.d.ts +0 -0
  422. /package/dist-library/types/{local/configuration → contracts}/schema-core.d.ts +0 -0
  423. /package/dist-library/types/{local → react}/rendering/code/code-block.d.ts +0 -0
  424. /package/dist-library/types/{local → react}/rendering/code/code-languages.d.ts +0 -0
  425. /package/dist-library/types/{local → react}/rendering/document/LocalDocumentView.d.ts +0 -0
  426. /package/dist-library/types/{local → react}/rendering/document/use-color-scheme.d.ts +0 -0
  427. /package/dist-library/types/{local → react}/rendering/image/image-view.d.ts +0 -0
  428. /package/dist-library/types/{local → react}/rendering/math-view.d.ts +0 -0
@@ -1,21 +1,62 @@
1
1
  import { a as e, i as t, r as n, s as r } from "./latex-1w7aQgD5.js";
2
- import { A as i, B as a, C as o, F as s, I as c, M as l, N as u, P as d, S as f, j as p, w as m, x as h } from "./config-validation-F47AcE6o.js";
3
- import { a as g, t as _ } from "./compile-wUv8KEge.js";
4
- import { d as v } from "./compiler-core-As_m-MNm.js";
5
- import { S as y, g as b } from "./validation-BEBA_HvS.js";
6
- import { c as x } from "./config-BadfhjdP.js";
7
- import { t as S } from "./options-1aDLK7JY.js";
8
- import { t as ee } from "./compiler-eOfcinZs.js";
9
- import { i as te, n as ne, r as re, t as C } from "./authoring-Dsune4Hy.js";
10
- import { c as w } from "./schema-BufhKUSM.js";
11
- import { n as T, t as ie } from "./incremental-Dv0FSp_U.js";
12
- import { C as ae } from "./component-state-BoLCGee4.js";
13
- import { a as oe, i as se, n as ce, o as le, r as ue } from "./runtime-kcA7bG7G.js";
14
- import { i as de, n as fe, r as pe, t as me } from "./sample-bP4zHB3L.js";
15
- import { _ as he, a as ge, f as _e, g as ve, h as ye, i as be, m as xe, n as Se, p as Ce, r as we, t as Te, v as Ee, y as De } from "./shareable-DpbE-59H.js";
16
- import { t as Oe } from "./component-state-C52ZFJGl.js";
2
+ import "./limits-CFERRrlC.js";
3
+ import { _ as i, a, c as o, d as s, i as c, l, m as u, n as d, o as f, p, r as m, s as ee, t as te, u as h } from "./document-theme-DBAfnk7y.js";
4
+ import { a as g, t as ne } from "./compile-D50B5_Ww.js";
5
+ import { t as _ } from "./types-daDo2c_w.js";
6
+ import { t as v } from "./compiler-DLkKUK4t.js";
7
+ import { t as re } from "./default-options-DU5dxuU6.js";
8
+ import { n as ie, r as y, t as b } from "./observability-core-Bcu7vpnl.js";
9
+ import { i as x, n as S, r as C, t as w } from "./authoring-B14SsOXZ.js";
10
+ import { t as T } from "./parser-9yNJxGip.js";
11
+ import { n as E, t as D } from "./incremental-Bzvh8_lB.js";
12
+ import { t as O } from "./compile-cache-key-6GgpETz_.js";
13
+ import { a as k, i as A, n as j, o as M, r as N } from "./runtime-CuJndKqK.js";
14
+ import { i as P } from "./identity-BUx0Q_-d.js";
15
+ import { a as F, b as I, c as L, g as R, h as z, i as B, m as V, n as H, o as U, t as W, v as G, y as K } from "./worker-D6WMV8xJ.js";
16
+ import { i as ae, n as q, r as J, t as oe } from "./sample-bP4zHB3L.js";
17
+ import { _ as se, a as ce, f as le, g as ue, h as de, i as fe, m as pe, n as me, p as he, r as ge, t as _e, v as ve, y as ye } from "./shareable-C6mUerpQ.js";
18
+ import { n as be, t as xe } from "./observability-CYLuvFfL.js";
19
+ import { t as Se } from "./component-state-Ht-hOK0W.js";
20
+ // src/local/runtime/runtime-pool.ts
21
+ function Ce(e, t) {
22
+ return [.../* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)])].every((n) => Object.is(e[n], t[n]));
23
+ }
24
+ function we({ idleDisposeMs: e = 0, maxIdle: t = 8 } = {}) {
25
+ if (!Number.isInteger(t) || t < 0 || !Number.isFinite(e) || e < 0 || e > 2147483647) throw RangeError("Invalid runtime pool capacity or idle delay.");
26
+ let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = !1;
27
+ function a(e) {
28
+ n.delete(e), r.delete(e), clearTimeout(e.timer), e.runtime.dispose();
29
+ }
30
+ return {
31
+ acquire(o, s = {}) {
32
+ if (i) throw Error("The local runtime pool is disposed.");
33
+ let c = [...n].find((e) => e.runtime.document.source === o.source && Ce(e.options, s) && I(e.runtime.document, o));
34
+ c || (c = {
35
+ runtime: j(o, s),
36
+ options: { ...s },
37
+ leases: 0
38
+ }, n.add(c));
39
+ let l = c;
40
+ r.delete(l), clearTimeout(l.timer), l.leases++;
41
+ let u = !1;
42
+ return {
43
+ runtime: l.runtime,
44
+ release() {
45
+ if (!u && (u = !0, !--l.leases)) {
46
+ if (i) a(l);
47
+ else for (r.add(l), l.timer = setTimeout(() => a(l), e); r.size > t;) a(r.values().next().value);
48
+ }
49
+ }
50
+ };
51
+ },
52
+ dispose() {
53
+ i = !0;
54
+ for (let e of r) a(e);
55
+ }
56
+ };
57
+ }
17
58
  // src/local/source/source-migration.ts
18
- var E = /* @__PURE__ */ new Set([
59
+ var Y = /* @__PURE__ */ new Set([
19
60
  "sum",
20
61
  "average",
21
62
  "minOf",
@@ -33,7 +74,7 @@ var E = /* @__PURE__ */ new Set([
33
74
  "slice",
34
75
  "dateCompare",
35
76
  "dateDiff"
36
- ]), ke = /* @__PURE__ */ new Set([
77
+ ]), Te = /* @__PURE__ */ new Set([
37
78
  "jump",
38
79
  "anchor",
39
80
  "text",
@@ -50,12 +91,12 @@ var E = /* @__PURE__ */ new Set([
50
91
  "data-table",
51
92
  "column",
52
93
  "external"
53
- ]), Ae = /* @__PURE__ */ new Set(["external"]), je = /* @__PURE__ */ new Set([
94
+ ]), Ee = /* @__PURE__ */ new Set(["external"]), X = /* @__PURE__ */ new Set([
54
95
  "local-draft-1",
55
96
  "local-draft-2",
56
- y
57
- ]), Me = `<!-- reactive-md: ${y} -->`;
58
- function Ne(e) {
97
+ _
98
+ ]), Z = `<!-- reactive-md: ${_} -->`;
99
+ function Q(e) {
59
100
  let t = e.diagnostics.filter((t) => t.code.startsWith("local.version.") || t.code === "local.budget" || t.code === "local.parse" && !e.nodes.length), n = e.versionDeclaration?.version ?? null;
60
101
  return {
61
102
  declaredVersion: n,
@@ -65,27 +106,27 @@ function Ne(e) {
65
106
  diagnostics: t
66
107
  };
67
108
  }
68
- function Pe(e) {
69
- return Ne(w(e));
109
+ function De(e) {
110
+ return Q(T(e));
70
111
  }
71
- function Fe(e, t, n, r, i = "error") {
72
- let a = d(t, r), o = e.slice(0, n.start), s = o.lastIndexOf("\n");
112
+ function Oe(e, t, n, r, i = "error") {
113
+ let a = l(t, r), o = e.slice(0, n.start), s = o.lastIndexOf("\n");
73
114
  return {
74
115
  code: t,
75
116
  severity: i,
76
117
  range: { ...n },
77
- message: p(a),
118
+ message: f(a),
78
119
  line: o.split("\n").length,
79
120
  column: n.start - s,
80
121
  messageKey: a.key,
81
122
  ...a.params ? { params: a.params } : {}
82
123
  };
83
124
  }
84
- function Ie(e, t = {}) {
85
- let n = w(e), r = Ne(n), i = typeof t == "object" && !!t && !Array.isArray(t), a = i ? t.fromVersion ?? r.effectiveVersion : r.effectiveVersion, o = typeof a == "string" ? a : "", s = {
125
+ function $(e, t = {}) {
126
+ let n = T(e), r = Q(n), i = typeof t == "object" && !!t && !Array.isArray(t), a = i ? t.fromVersion ?? r.effectiveVersion : r.effectiveVersion, o = typeof a == "string" ? a : "", s = {
86
127
  ok: !1,
87
128
  fromVersion: o,
88
- toVersion: y,
129
+ toVersion: _,
89
130
  needsMigration: !n.versionDeclaration || o !== "local-draft-3",
90
131
  diagnostics: r.diagnostics.filter((e) => e.code !== "local.version.unsupported")
91
132
  }, c = {
@@ -106,15 +147,15 @@ function Ie(e, t = {}) {
106
147
  }
107
148
  s.diagnostics.push(e);
108
149
  }, d = (t, n, r, i) => {
109
- u(Fe(e, t, n, r, i));
150
+ u(Oe(e, t, n, r, i));
110
151
  };
111
- if (!i || typeof a != "string" || !je.has(o) || t.allowSemanticChanges !== void 0 && typeof t.allowSemanticChanges != "boolean" || t.fromVersion !== void 0 && r.declaredVersion !== null && o !== r.declaredVersion) return d("local.upgrade.from-version", l, {
152
+ if (!i || typeof a != "string" || !X.has(o) || t.allowSemanticChanges !== void 0 && typeof t.allowSemanticChanges != "boolean" || t.fromVersion !== void 0 && r.declaredVersion !== null && o !== r.declaredVersion) return d("local.upgrade.from-version", l, {
112
153
  from: o,
113
154
  detail: "use local-draft-1, local-draft-2 or local-draft-3 and match the source declaration"
114
155
  }), c;
115
- let f = n.versionDeclaration ? e.slice(0, l.start) + e.slice(l.start, l.end).replace(/[^\r\n]/g, " ") + e.slice(l.end) : e, p = n.versionDeclaration ? w(f) : n;
156
+ let f = n.versionDeclaration ? e.slice(0, l.start) + e.slice(l.start, l.end).replace(/[^\r\n]/g, " ") + e.slice(l.end) : e, p = n.versionDeclaration ? T(f) : n;
116
157
  if (o === "local-draft-1" || o === "local-draft-2") {
117
- let e = o === "local-draft-1" ? ke : Ae, n = (r) => {
158
+ let e = o === "local-draft-1" ? Te : Ee, n = (r) => {
118
159
  for (let i of r) if (i.name && e.has(i.name)) d("local.upgrade.tag", i.range, { name: i.name });
119
160
  else {
120
161
  if (o === "local-draft-1") {
@@ -126,13 +167,13 @@ function Ie(e, t = {}) {
126
167
  "bind-y"
127
168
  ]) {
128
169
  let t = i.attrs?.[e];
129
- t && E.has(t) && d("local.upgrade.reserved-binding", i.range, { name: t });
170
+ t && Y.has(t) && d("local.upgrade.reserved-binding", i.range, { name: t });
130
171
  }
131
172
  (i.name === "input" || i.name === "textarea") && (i.attrs?.["max-length"] !== void 0 || Number(i.attrs?.["min-length"] ?? 0) > 0) && d("local.upgrade.text-length", i.range, void 0, t.allowSemanticChanges ? "warning" : "error");
132
173
  let e = [...i.type === "interpolation" ? [i.value ?? ""] : [], ...Object.values(i.attrs ?? {}).flatMap((e) => [...e.matchAll(/\{\{([\s\S]*?)\}\}/g)].map((e) => e[1]))];
133
174
  for (let t of e) {
134
175
  let e = t.replace(/'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"/g, "");
135
- (e.includes("[") || [...E].some((t) => RegExp(`\\b${t}\\s*\\(`).test(e))) && d("local.upgrade.expression", i.range);
176
+ (e.includes("[") || [...Y].some((t) => RegExp(`\\b${t}\\s*\\(`).test(e))) && d("local.upgrade.expression", i.range);
136
177
  }
137
178
  }
138
179
  i.type !== "fallback" && i.children && n(i.children);
@@ -141,18 +182,18 @@ function Ie(e, t = {}) {
141
182
  n(p.nodes);
142
183
  }
143
184
  if (s.diagnostics.some((e) => e.severity === "error")) return c;
144
- let m = ee(f);
185
+ let m = v(f);
145
186
  for (let e of m.diagnostics) u(e);
146
187
  return m.ok && (!n.versionDeclaration && s.diagnostics.length < 100 && d("local.upgrade.version-missing", {
147
188
  start: +(e.charCodeAt(0) === 65279),
148
189
  end: +(e.charCodeAt(0) === 65279)
149
- }, { version: y }, "warning"), s.ok = !0), c;
190
+ }, { version: _ }, "warning"), s.ok = !0), c;
150
191
  }
151
- function Le(e, t) {
152
- return Ie(e, t).report;
192
+ function ke(e, t) {
193
+ return $(e, t).report;
153
194
  }
154
- function Re(e, t) {
155
- let { report: n, declaration: r } = Ie(e, t), i = {
195
+ function Ae(e, t) {
196
+ let { report: n, declaration: r } = $(e, t), i = {
156
197
  ...n,
157
198
  source: e,
158
199
  changed: !1,
@@ -162,7 +203,7 @@ function Re(e, t) {
162
203
  let a = +(e.charCodeAt(0) === 65279), o = r?.range ?? {
163
204
  start: a,
164
205
  end: a
165
- }, s = e.includes("\r\n") ? "\r\n" : "\n", c = r ? Me : `${Me}${s}${s}`, l = e.slice(0, o.start) + c + e.slice(o.end);
206
+ }, s = e.includes("\r\n") ? "\r\n" : "\n", c = r ? Z : `${Z}${s}${s}`, l = e.slice(0, o.start) + c + e.slice(o.end);
166
207
  return {
167
208
  ...n,
168
209
  source: l,
@@ -173,1322 +214,4 @@ function Re(e, t) {
173
214
  }]
174
215
  };
175
216
  }
176
- // src/local/transport/compile-patch.ts
177
- var D = "patch-v1", O = 1, ze = 4096, k = [
178
- "initialState",
179
- "bindings",
180
- "bindingSlots",
181
- "computations",
182
- "dependencies",
183
- "tableShapes"
184
- ];
185
- function A(e) {
186
- return typeof e == "object" && !!e && !Array.isArray(e);
187
- }
188
- function j(e) {
189
- return A(e) && typeof e.start == "number" && Number.isFinite(e.start) && typeof e.end == "number" && Number.isFinite(e.end);
190
- }
191
- function M() {
192
- throw TypeError("Invalid local compile result patch");
193
- }
194
- function N(e, t) {
195
- if (e === t) return !0;
196
- if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
197
- let n = Array.isArray(e);
198
- if (n !== Array.isArray(t)) return !1;
199
- if (n) {
200
- let n = e, r = t;
201
- if (n.length !== r.length) return !1;
202
- for (let e = 0; e < n.length; e += 1) if (!N(n[e], r[e])) return !1;
203
- return !0;
204
- }
205
- let r = e, i = t, a = Object.keys(r);
206
- if (a.length !== Object.keys(i).length) return !1;
207
- for (let e of a) if (!Object.hasOwn(i, e) || !N(r[e], i[e])) return !1;
208
- return !0;
209
- }
210
- function P(e) {
211
- return v(e, !1);
212
- }
213
- function F(e, t) {
214
- if (typeof e != "string" || typeof t != "string" || e === t) return null;
215
- let n = Math.min(e.length, t.length), r = 0;
216
- for (; r < n && e.charCodeAt(r) === t.charCodeAt(r);) r += 1;
217
- let i = e.length, a = t.length;
218
- for (; i > r && a > r && e.charCodeAt(i - 1) === t.charCodeAt(a - 1);) --i, --a;
219
- return {
220
- from: r,
221
- to: i,
222
- insert: t.slice(r, a)
223
- };
224
- }
225
- function Be(e) {
226
- if (!A(e)) return null;
227
- let { from: t, to: n, insert: r } = e;
228
- return typeof t != "number" || !Number.isSafeInteger(t) || typeof n != "number" || !Number.isSafeInteger(n) || typeof r != "string" || t < 0 || n < t ? null : {
229
- from: t,
230
- to: n,
231
- insert: r
232
- };
233
- }
234
- function Ve(e, t) {
235
- let n = Be(t);
236
- return n === null || typeof e != "string" || n.to > e.length ? null : e.slice(0, n.from) + n.insert + e.slice(n.to);
237
- }
238
- function I(e) {
239
- let t = {};
240
- for (let [n, r] of Object.entries(e)) n !== "children" && (t[n] = r);
241
- return t;
242
- }
243
- function L(e, t) {
244
- let n = Object.keys(e).filter((e) => e !== "children"), r = Object.keys(t).filter((e) => e !== "children");
245
- if (n.length !== r.length) return !1;
246
- for (let r of n) if (!Object.hasOwn(t, r) || !N(e[r], t[r])) return !1;
247
- return !0;
248
- }
249
- function R(e) {
250
- return e.children === void 0 ? void 0 : e.children.map((e) => e.id);
251
- }
252
- function z(e, t) {
253
- let n = R(e), r = R(t);
254
- if (n === void 0 || r === void 0) return n === r;
255
- if (n.length !== r.length) return !1;
256
- for (let e = 0; e < n.length; e += 1) if (n[e] !== r[e]) return !1;
257
- return !0;
258
- }
259
- function He(e, t) {
260
- if (!L(e, t) || !z(e, t)) return !1;
261
- if (!e.children || !t.children) return !0;
262
- for (let n = 0; n < e.children.length; n += 1) if (!He(e.children[n], t.children[n])) return !1;
263
- return !0;
264
- }
265
- function Ue(e, t) {
266
- let n = Object.keys(e).filter((e) => e !== "children" && e !== "range"), r = Object.keys(t).filter((e) => e !== "children" && e !== "range");
267
- if (n.length !== r.length) return null;
268
- for (let r of n) if (!Object.hasOwn(t, r) || !N(e[r], t[r])) return null;
269
- if (!j(e.range) || !j(t.range)) return null;
270
- let i = e.range.start - t.range.start;
271
- if (e.range.end !== t.range.end + i) return null;
272
- let a = R(e), o = R(t);
273
- if (a === void 0 || o === void 0) {
274
- if (a !== o) return null;
275
- } else {
276
- if (a.length !== o.length) return null;
277
- for (let n = 0; n < a.length; n += 1) if (a[n] !== o[n] || Ue(e.children[n], t.children[n]) !== i) return null;
278
- }
279
- return i;
280
- }
281
- function We(e, t) {
282
- let n = Object.keys(e).filter((e) => e !== "children" && e !== "range"), r = Object.keys(t).filter((e) => e !== "children" && e !== "range");
283
- if (n.length !== r.length) return null;
284
- for (let r of n) if (!Object.hasOwn(t, r) || !N(e[r], t[r])) return null;
285
- if (!j(e.range) || !j(t.range)) return null;
286
- let i = e.range.start - t.range.start;
287
- return e.range.end === t.range.end + i ? i : null;
288
- }
289
- function Ge(e) {
290
- let t = /* @__PURE__ */ new Map(), n = [...e].reverse();
291
- for (; n.length > 0;) {
292
- let e = n.pop();
293
- if (t.set(e.id, e), e.children) for (let t = e.children.length - 1; t >= 0; --t) n.push(e.children[t]);
294
- }
295
- return t;
296
- }
297
- function Ke(e, t, n, r) {
298
- if (t !== void 0 && He(e, t)) return;
299
- if (t === void 0) {
300
- r.push({
301
- id: e.id,
302
- node: e
303
- });
304
- return;
305
- }
306
- let i = Ue(e, t);
307
- if (i !== null) {
308
- i !== 0 && r.push({
309
- id: e.id,
310
- shift: i,
311
- subtree: !0
312
- });
313
- return;
314
- }
315
- let a = { id: e.id };
316
- if (!L(e, t)) {
317
- let n = We(e, t);
318
- n !== null && n !== 0 ? a.shift = n : a.data = I(e);
319
- }
320
- z(e, t) || (a.children = e.children === void 0 ? null : e.children.map((e) => e.id));
321
- let o = r.length;
322
- if (e.children) for (let t of e.children) Ke(t, n.get(t.id), n, r);
323
- Object.keys(a).length > 1 ? r.splice(o, 0, a) : r.length > o && r.splice(o, 0, { id: e.id });
324
- }
325
- function qe(e, t) {
326
- if (!A(e)) return { set: t };
327
- let n = {}, r = [];
328
- for (let [r, i] of Object.entries(t)) Object.hasOwn(e, r) && N(e[r], i) || (n[r] = i);
329
- for (let n of Object.keys(e)) Object.hasOwn(t, n) || r.push(n);
330
- return Object.keys(n).length === 0 && r.length === 0 ? null : {
331
- ...Object.keys(n).length === 0 ? {} : { set: n },
332
- ...r.length === 0 ? {} : { remove: r }
333
- };
334
- }
335
- var Je = /* @__PURE__ */ new WeakMap();
336
- function Ye(e) {
337
- let t = 2;
338
- for (let n = 0; n < e.length; n++) {
339
- let r = e.charCodeAt(n);
340
- if (r === 34 || r === 92) t += 2;
341
- else if (r < 32) t += r === 8 || r === 9 || r === 10 || r === 12 || r === 13 ? 2 : 6;
342
- else if (r < 128) t++;
343
- else if (r < 2048) t += 2;
344
- else if (r >= 55296 && r <= 56319) {
345
- let r = e.charCodeAt(n + 1);
346
- r >= 56320 && r <= 57343 ? (t += 4, n++) : t += 6;
347
- } else t += r >= 56320 && r <= 57343 ? 6 : 3;
348
- }
349
- return t;
350
- }
351
- function B(e, t) {
352
- if (e === null) return {
353
- bytes: 4,
354
- nodes: 0
355
- };
356
- let n = typeof e;
357
- if (n === "string") return {
358
- bytes: Ye(e),
359
- nodes: 0
360
- };
361
- if (n === "number") return {
362
- bytes: Number.isFinite(e) ? String(e).length : 4,
363
- nodes: 0
364
- };
365
- if (n === "boolean") return {
366
- bytes: e === !0 ? 4 : 5,
367
- nodes: 0
368
- };
369
- if (n !== "object") return {
370
- bytes: 0,
371
- nodes: 0
372
- };
373
- let r = e, i = Je.get(r);
374
- if (i !== void 0) return i;
375
- if (t.has(r)) return {
376
- bytes: 0,
377
- nodes: 0
378
- };
379
- t.add(r);
380
- let a, o = +!!nt(e);
381
- if (Array.isArray(e)) {
382
- a = 2;
383
- for (let n = 0; n < e.length; n += 1) {
384
- n > 0 && (a += 1);
385
- let r = B(e[n], t);
386
- a += r.bytes || 4, o += r.nodes;
387
- }
388
- } else {
389
- a = 2;
390
- let e = 0;
391
- for (let n in r) {
392
- if (!Object.hasOwn(r, n)) continue;
393
- let i = r[n];
394
- if (i === void 0) continue;
395
- e > 0 && (a += 1), e += 1, a += Ye(n) + 1;
396
- let s = B(i, t);
397
- a += s.bytes, o += s.nodes;
398
- }
399
- }
400
- t.delete(r);
401
- let s = {
402
- bytes: a,
403
- nodes: o
404
- };
405
- return Je.set(r, s), s;
406
- }
407
- function Xe(e, t) {
408
- let n = e.document.nodes ?? [];
409
- try {
410
- let r = B(e, /* @__PURE__ */ new Set()), i = t.ok && typeof t.document.source == "string" ? t.document.source.length : 0;
411
- if (r.bytes <= Math.max(i, ze)) return {
412
- patchBytes: r.bytes,
413
- patchNodes: n.length,
414
- preferFull: !1
415
- };
416
- let a = B(t, /* @__PURE__ */ new Set()), o = 0;
417
- for (let e of n) e.node === void 0 ? e.data !== void 0 && (o += 1) : o += B(e.node, /* @__PURE__ */ new Set()).nodes;
418
- let s = r.bytes * O >= a.bytes, c = a.nodes > 0 && o * O >= a.nodes;
419
- return {
420
- patchBytes: r.bytes,
421
- fullBytes: a.bytes,
422
- patchNodes: n.length,
423
- fullNodes: a.nodes,
424
- preferFull: s || c,
425
- ...s ? { reason: "bytes" } : c ? { reason: "nodes" } : {}
426
- };
427
- } catch {
428
- return {
429
- patchBytes: 0,
430
- patchNodes: n.length,
431
- preferFull: !1
432
- };
433
- }
434
- }
435
- function Ze(e, t) {
436
- return et(e, t);
437
- }
438
- function Qe(e, t) {
439
- let n = et(e, t);
440
- return n ? {
441
- patch: n,
442
- cost: Xe(n, t)
443
- } : null;
444
- }
445
- function $e(e, t) {
446
- let n = e.recoveries, r = t.recoveries;
447
- return n === void 0 ? r === void 0 ? {} : { recoveries: r } : r !== void 0 && N(n, r) ? {} : { recoveries: r === void 0 ? null : r };
448
- }
449
- function et(e, t) {
450
- try {
451
- if (!e.ok || !t.ok) return null;
452
- let n = e.document, r = t.document;
453
- if (!A(n) || !A(r)) return null;
454
- let i = {};
455
- if (typeof n.source == "string" && typeof r.source == "string") {
456
- let e = F(n.source, r.source);
457
- e !== null && (i.source = e);
458
- } else if (n.source !== r.source) return null;
459
- let a = [], o = {}, s = {}, c = new Set(k), l = /* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)]);
460
- for (let e of l) {
461
- if (e === "source" || e === "nodes" || c.has(e)) continue;
462
- let t = Object.hasOwn(r, e) && r[e] !== void 0, i = Object.hasOwn(n, e) && n[e] !== void 0;
463
- t ? i && N(n[e], r[e]) || (o[e] = r[e]) : i && a.push(e);
464
- }
465
- for (let e of k) {
466
- let t = Object.hasOwn(r, e) && r[e] !== void 0, i = Object.hasOwn(n, e) && n[e] !== void 0, c = i ? n[e] : void 0, l = t ? r[e] : void 0;
467
- if (!t) {
468
- i && a.push(e);
469
- continue;
470
- }
471
- if (!A(l)) {
472
- i && N(c, l) || (o[e] = l);
473
- continue;
474
- }
475
- if (!i) {
476
- s[e] = { set: l };
477
- continue;
478
- }
479
- if (!A(c)) {
480
- o[e] = l;
481
- continue;
482
- }
483
- let u = qe(c, l);
484
- u !== null && (s[e] = u);
485
- }
486
- let u = Array.isArray(n.nodes) ? n.nodes : [], d = Array.isArray(r.nodes) ? r.nodes : [], f = u.map((e) => e.id), p = d.map((e) => e.id), m = f.length !== p.length;
487
- if (!m) {
488
- for (let e = 0; e < f.length; e += 1) if (f[e] !== p[e]) {
489
- m = !0;
490
- break;
491
- }
492
- }
493
- let h = [], g = Ge(u);
494
- for (let e of d) Ke(e, g.get(e.id), g, h);
495
- return m && (i.roots = p), h.length > 0 && (i.nodes = h), a.length > 0 && (i.removed = a), Object.keys(o).length > 0 && (i.values = o), Object.keys(s).length > 0 && (i.records = s), {
496
- kind: "result-patch",
497
- protocol: D,
498
- document: i,
499
- ...N(e.diagnostics, t.diagnostics) ? {} : { diagnostics: t.diagnostics },
500
- ...$e(e, t)
501
- };
502
- } catch {
503
- return null;
504
- }
505
- }
506
- function tt(e, t) {
507
- let n = I(e);
508
- return j(n.range) || M(), n.range = {
509
- start: n.range.start + t,
510
- end: n.range.end + t
511
- }, e.children && (n.children = e.children.map((e) => tt(e, t))), n;
512
- }
513
- function nt(e) {
514
- return A(e) && typeof e.id == "string" && typeof e.type == "string" && j(e.range);
515
- }
516
- function rt(e, t) {
517
- A(t) || M(), t.set !== void 0 && !A(t.set) && M(), t.remove !== void 0 && !Array.isArray(t.remove) && M();
518
- let n = {};
519
- if (A(e)) for (let [t, r] of Object.entries(e)) Object.defineProperty(n, t, {
520
- value: r,
521
- enumerable: !0,
522
- configurable: !0,
523
- writable: !0
524
- });
525
- else e !== void 0 && M();
526
- if (t.set) for (let [e, r] of Object.entries(t.set)) Object.defineProperty(n, e, {
527
- value: P(r),
528
- enumerable: !0,
529
- configurable: !0,
530
- writable: !0
531
- });
532
- if (t.remove) for (let e of t.remove) typeof e != "string" && M(), delete n[e];
533
- return n;
534
- }
535
- function it(e, t) {
536
- try {
537
- if (!e.ok || !A(t) || t.kind !== "result-patch" || t.protocol !== "patch-v1") return null;
538
- let n = t.document;
539
- if (!A(n)) return null;
540
- let r = e.document;
541
- if (!A(r)) return null;
542
- let i = {};
543
- for (let [e, t] of Object.entries(r)) Object.defineProperty(i, e, {
544
- value: t,
545
- enumerable: !0,
546
- configurable: !0,
547
- writable: !0
548
- });
549
- if (n.removed !== void 0) {
550
- if (!Array.isArray(n.removed)) return null;
551
- for (let e of n.removed) {
552
- if (typeof e != "string" || e === "nodes" || e === "source") return null;
553
- delete i[e];
554
- }
555
- }
556
- if (n.values !== void 0) {
557
- if (!A(n.values)) return null;
558
- for (let [e, t] of Object.entries(n.values)) {
559
- if (e === "nodes" || e === "source") return null;
560
- Object.defineProperty(i, e, {
561
- value: P(t),
562
- enumerable: !0,
563
- configurable: !0,
564
- writable: !0
565
- });
566
- }
567
- }
568
- if (n.records !== void 0) {
569
- if (!A(n.records)) return null;
570
- for (let e of Object.keys(n.records)) {
571
- if (!k.includes(e)) return null;
572
- let t = n.records[e];
573
- t !== void 0 && (i[e] = rt(r[e], t));
574
- }
575
- }
576
- let a = typeof r.source == "string" ? r.source : null;
577
- if (a === null) return null;
578
- if (n.source !== void 0) {
579
- let e = Be(n.source);
580
- if (e === null) return null;
581
- let t = Ve(a, e);
582
- if (t === null) return null;
583
- a = t;
584
- }
585
- i.source = a;
586
- let o = Array.isArray(r.nodes) ? r.nodes : [], s = Ge(o), c = /* @__PURE__ */ new Map();
587
- if (n.nodes !== void 0) {
588
- if (!Array.isArray(n.nodes)) return null;
589
- for (let e of n.nodes) {
590
- if (!A(e) || typeof e.id != "string" || c.has(e.id)) return null;
591
- c.set(e.id, e);
592
- }
593
- }
594
- let l;
595
- if (n.roots !== void 0) {
596
- if (!Array.isArray(n.roots)) return null;
597
- l = [];
598
- for (let e of n.roots) {
599
- if (typeof e != "string") return null;
600
- l.push(e);
601
- }
602
- } else l = o.map((e) => e.id);
603
- let u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), f = (e) => {
604
- let t = u.get(e);
605
- if (t !== void 0) return t;
606
- d.has(e) && M();
607
- let n = c.get(e), r = s.get(e);
608
- if (n === void 0) return r === void 0 && M(), u.set(e, r), r;
609
- if (A(n) || M(), n.node !== void 0) {
610
- (n.data !== void 0 || n.children !== void 0 || n.shift !== void 0 || n.subtree) && M(), nt(n.node) && n.node.id === e || M();
611
- let t = P(n.node);
612
- return u.set(e, t), t;
613
- }
614
- r === void 0 && n.data === void 0 && M(), n.subtree !== void 0 && n.subtree !== !0 && M(), n.shift !== void 0 && !Number.isSafeInteger(n.shift) && M(), n.data !== void 0 && n.shift !== void 0 && M(), n.children !== void 0 && n.children !== null && (!Array.isArray(n.children) || n.children.some((e) => typeof e != "string")) && M(), d.add(e);
615
- let i;
616
- if (n.subtree === !0) (r === void 0 || n.shift === void 0 || n.data !== void 0 || n.children !== void 0) && M(), i = tt(r, n.shift);
617
- else {
618
- let t;
619
- n.data === void 0 ? (r === void 0 && M(), t = I(r), n.shift !== void 0 && (j(t.range) || M(), t.range = {
620
- start: t.range.start + n.shift,
621
- end: t.range.end + n.shift
622
- })) : (A(n.data) || M(), t = P(n.data), delete t.children, t.id !== e && M());
623
- let a;
624
- if (n.children !== void 0) a = n.children === null ? null : [...n.children];
625
- else {
626
- let e = r?.children;
627
- a = e === void 0 ? void 0 : e.map((e) => e.id);
628
- }
629
- a === null ? delete t.children : a !== void 0 && (t.children = a.map(f)), i = t;
630
- }
631
- return d.delete(e), u.set(e, i), i;
632
- }, p = l.map(f);
633
- i.nodes = n.roots === void 0 && n.nodes === void 0 ? r.nodes : p;
634
- let m = t.diagnostics === void 0 ? e.diagnostics : Array.isArray(t.diagnostics) ? P(t.diagnostics) : M();
635
- if (t.recoveries !== void 0 && t.recoveries !== null && !Array.isArray(t.recoveries)) return null;
636
- let h = e.status === void 0 ? {} : { status: e.status };
637
- if (t.recoveries === null) return {
638
- ok: !0,
639
- document: i,
640
- diagnostics: m,
641
- ...h
642
- };
643
- let g = t.recoveries === void 0 ? e.recoveries : P([...t.recoveries]);
644
- return {
645
- ok: !0,
646
- document: i,
647
- diagnostics: m,
648
- ...h,
649
- ...g === void 0 ? {} : { recoveries: g }
650
- };
651
- } catch {
652
- return null;
653
- }
654
- }
655
- // src/local/transport/flat-compiled-data.ts
656
- var V = "flat-v1";
657
- function at(e) {
658
- if (!e.ok) return !1;
659
- let t = e.document.nodes.map((e) => ({
660
- node: e,
661
- depth: 0
662
- }));
663
- for (; t.length;) {
664
- let { node: e, depth: n } = t.pop();
665
- if (n >= 100) return !0;
666
- if (e.children) for (let r of e.children) t.push({
667
- node: r,
668
- depth: n + 1
669
- });
670
- }
671
- return !1;
672
- }
673
- function ot(e) {
674
- let t = [], n = /* @__PURE__ */ new Map(), r = [], i = (e) => {
675
- if (typeof e == "object" && e) {
676
- let i = n.get(e);
677
- if (i !== void 0) return i;
678
- let a = t.length, o = Array.isArray(e) ? [
679
- 1,
680
- e.length,
681
- []
682
- ] : [2, []];
683
- return n.set(e, a), t.push(o), r.push({
684
- value: e,
685
- record: o
686
- }), a;
687
- }
688
- if (e !== null && ![
689
- "string",
690
- "number",
691
- "boolean",
692
- "undefined"
693
- ].includes(typeof e)) throw TypeError("Unsupported compiler wire value");
694
- let i = t.length;
695
- return t.push([0, e]), i;
696
- };
697
- for (i(e); r.length;) {
698
- let { value: e, record: t } = r.pop(), n = t[0] === 1 ? t[2] : t[1];
699
- for (let t of Object.keys(e)) n.push([t, i(e[t])]);
700
- }
701
- return {
702
- version: V,
703
- records: t
704
- };
705
- }
706
- function st(e) {
707
- if (!e || typeof e != "object") return null;
708
- let t = e;
709
- if (t.version !== "flat-v1" || !Array.isArray(t.records) || t.records.length === 0 || t.records.length > 2e6) return null;
710
- let n = t.records, r = Array(n.length), i = Array(n.length), a = 0;
711
- for (let e = 0; e < n.length; e++) {
712
- let t = n[e];
713
- if (!Array.isArray(t)) return null;
714
- if (t[0] === 0) {
715
- if (t.length !== 2 || t[1] !== null && ![
716
- "string",
717
- "number",
718
- "boolean",
719
- "undefined"
720
- ].includes(typeof t[1])) return null;
721
- r[e] = t[1], i[e] = [];
722
- continue;
723
- }
724
- let o = t[0] === 1;
725
- if (!o && t[0] !== 2 || t.length !== (o ? 3 : 2) || o && (!Number.isSafeInteger(t[1]) || t[1] < 0 || t[1] > 1e6)) return null;
726
- let s = o ? t[2] : t[1];
727
- if (!Array.isArray(s)) return null;
728
- let c = /* @__PURE__ */ new Set(), l = [];
729
- for (let e of s) if (!Array.isArray(e) || e.length !== 2 || typeof e[0] != "string" || !Number.isSafeInteger(e[1]) || e[1] < 0 || e[1] >= n.length || c.has(e[0]) || o && (e[0] === "length" || !/^(0|[1-9][0-9]*)$/.test(e[0]) || Number(e[0]) >= t[1]) || (c.add(e[0]), l.push(e[1]), ++a > 4e6)) return null;
730
- r[e] = o ? Array(t[1]) : {}, i[e] = l;
731
- }
732
- let o = new Uint8Array(n.length), s = [{
733
- index: 0,
734
- child: 0
735
- }];
736
- o[0] = 1;
737
- let c = 1;
738
- for (; s.length;) {
739
- let e = s[s.length - 1], t = i[e.index];
740
- if (e.child === t.length) {
741
- o[e.index] = 2, s.pop();
742
- continue;
743
- }
744
- let n = t[e.child++];
745
- if (o[n] === 1) return null;
746
- o[n] === 0 && (o[n] = 1, c++, s.push({
747
- index: n,
748
- child: 0
749
- }));
750
- }
751
- if (c !== n.length) return null;
752
- for (let e = 0; e < n.length; e++) {
753
- let t = n[e];
754
- if (t[0] === 0) continue;
755
- let i = t[0] === 1 ? t[2] : t[1];
756
- for (let [t, n] of i) Object.defineProperty(r[e], t, {
757
- value: r[n],
758
- enumerable: !0,
759
- writable: !0,
760
- configurable: !0
761
- });
762
- }
763
- return r[0];
764
- }
765
- // src/local/transport/worker-job.ts
766
- var ct = 150, lt = 200, ut = [
767
- "maxSyntaxNodes",
768
- "maxParseWork",
769
- "maxMarkdownDepth"
770
- ];
771
- function H(e) {
772
- return e instanceof Error ? e.message : String(e);
773
- }
774
- function U() {
775
- return typeof performance < "u" ? performance.now() : Date.now();
776
- }
777
- function W(e) {
778
- return Number.isFinite(e) ? Math.max(0, Math.round(e)) : 0;
779
- }
780
- function G(e, t, n) {
781
- let r = {
782
- tokens: [],
783
- bindings: [],
784
- diagnostics: []
785
- };
786
- if (n.ok && n.document.source !== e || !n.ok && n.diagnostics.some((e) => e.code.startsWith("local.budget") || e.code.startsWith("local.options."))) return r;
787
- try {
788
- return C(e, t, {
789
- ...n.ok ? { document: n.document } : {},
790
- diagnostics: !1
791
- });
792
- } catch {
793
- return {
794
- tokens: [],
795
- bindings: [],
796
- diagnostics: []
797
- };
798
- }
799
- }
800
- function dt(e) {
801
- return Array.isArray(e) ? e.length > 32 ? Array(33) : e.map((e) => {
802
- if (!e || typeof e != "object" || Array.isArray(e)) return e;
803
- let t = e, n = { ...t }, r = t.props;
804
- if (!r || typeof r != "object" || Array.isArray(r)) return n.props = r, n;
805
- let i = {};
806
- for (let [e, t] of Object.entries(r)) {
807
- if (!t || typeof t != "object" || Array.isArray(t)) {
808
- i[e] = t;
809
- continue;
810
- }
811
- let n = t, r = { ...n };
812
- Array.isArray(n.enum) && n.enum.length <= 64 && (r.enum = [...n.enum]), i[e] = r;
813
- }
814
- return n.props = i, n;
815
- }) : e;
816
- }
817
- function ft(e) {
818
- if (e !== void 0) try {
819
- if (typeof e != "object" || !e || Array.isArray(e)) return e;
820
- let t = e, n = {};
821
- for (let e of b) Object.hasOwn(t, e) && (n[e] = t[e]);
822
- if (Object.hasOwn(t, "markdownBreaks") && (n.markdownBreaks = t.markdownBreaks), Object.hasOwn(t, "sourcePhase") && (n.sourcePhase = t.sourcePhase), Object.hasOwn(t, "strict") && (n.strict = t.strict), Object.hasOwn(t, "limits")) {
823
- let e = t.limits;
824
- if (e && typeof e == "object" && !Array.isArray(e)) {
825
- let t = {};
826
- for (let n of ut) Object.hasOwn(e, n) && (t[n] = e[n]);
827
- n.limits = t;
828
- } else n.limits = e;
829
- }
830
- return Object.hasOwn(t, "hostComponents") && (n.hostComponents = dt(t.hostComponents)), Object.hasOwn(t, "config") && (n.config = x(t.config)), n;
831
- } catch {
832
- return e;
833
- }
834
- }
835
- function pt(e) {
836
- try {
837
- if (!e || typeof e != "object" || Array.isArray(e)) return "";
838
- let t = e.limits;
839
- if (!t || typeof t != "object" || Array.isArray(t)) return "";
840
- let n = (e) => {
841
- let n = t;
842
- if (!Object.hasOwn(n, e) || n[e] === void 0) return "-";
843
- let r = n[e];
844
- return `${typeof r}:${String(r)}`;
845
- };
846
- return `:${n("maxParseWork")}:${n("maxMarkdownDepth")}`;
847
- } catch {
848
- return ":unreadable";
849
- }
850
- }
851
- function mt(e) {
852
- let t = S(e);
853
- if (t !== "invalid") return t;
854
- try {
855
- return `invalid:${JSON.stringify(e)}`;
856
- } catch {
857
- return "invalid";
858
- }
859
- }
860
- function K(e) {
861
- return `${mt(e)}${pt(e)}`;
862
- }
863
- // src/local/transport/worker-handler.ts
864
- function ht(e, t, n, r) {
865
- let i = e;
866
- return typeof i.compileShared == "function" ? i.compileShared(t, n, r) : e.compile(t, n, r);
867
- }
868
- function gt(e) {
869
- return e === "streaming" || e === "final";
870
- }
871
- function q(e) {
872
- return e.stats;
873
- }
874
- function J(e, t, n) {
875
- try {
876
- e.postMessage({
877
- id: t,
878
- ok: !1,
879
- message: n
880
- });
881
- } catch {}
882
- }
883
- function _t(e, t, n, r, i) {
884
- try {
885
- e.postMessage({
886
- id: t,
887
- ok: !1,
888
- message: n,
889
- retryFull: !0,
890
- code: r,
891
- ...i === void 0 ? {} : { revision: i }
892
- });
893
- } catch {}
894
- }
895
- function vt(e) {
896
- return !!e && typeof e == "object" && (e.control === "dispose" || e.control === "cancel-preparation");
897
- }
898
- function yt(e) {
899
- if (!e || typeof e != "object") return !1;
900
- let t = e;
901
- return typeof t.from == "number" && Number.isSafeInteger(t.from) && typeof t.to == "number" && Number.isSafeInteger(t.to) && t.from >= 0 && t.to >= t.from && typeof t.insert == "string";
902
- }
903
- function bt(e, t = {}) {
904
- let n = e === void 0 ? globalThis : e;
905
- if (!n || typeof n.postMessage != "function") throw TypeError("startLocalCompileWorker requires a worker scope with postMessage");
906
- let r = t.createSession ? t.createSession() : T(), i = r, a = t.preparationDelay, o = typeof a == "number" && Number.isFinite(a) ? Math.max(0, a) : 200, s = typeof i.prepareAsync == "function", c = null, l = 0, u = !1, d = null, f = null, p = 0, m, h = () => {
907
- p += 1, f !== null && (f.aborted = !0, f = null), d !== null && (clearTimeout(d), d = null);
908
- }, g = () => new Promise((e) => {
909
- typeof setTimeout == "function" ? setTimeout(e, 0) : e();
910
- }), _ = async (e) => {
911
- if (u || e !== p) return;
912
- let t = i.prepareAsync;
913
- if (typeof t != "function") return;
914
- let n = { aborted: !1 };
915
- f = n;
916
- let r = U(), a = !1;
917
- try {
918
- a = await t.call(i, n, g);
919
- } catch {} finally {
920
- f === n && (f = null), a && !n.aborted && !u && e === p && (m = W(U() - r));
921
- }
922
- }, v = () => {
923
- if (u || !s) return;
924
- h();
925
- let e = p;
926
- d = setTimeout(() => {
927
- d = null, _(e);
928
- }, o);
929
- }, y = () => {
930
- if (!u) {
931
- u = !0, h();
932
- try {
933
- r.dispose();
934
- } catch {}
935
- n.onmessage = null;
936
- }
937
- }, b = (e) => ({
938
- compileMs: e,
939
- ...m === void 0 ? {} : { preparationMs: m }
940
- }), x = (e) => {
941
- let t = typeof e == "number" && Number.isSafeInteger(e) && e > 0 ? e : null;
942
- return t === null ? l + 1 : t > l ? t : l + 1;
943
- }, S = (e, t, i, a, o = !1, s) => {
944
- let l = c;
945
- if (l === null) return !1;
946
- let u = W(i), d = s === void 0 ? b(u) : {
947
- ...b(u),
948
- ...s
949
- };
950
- try {
951
- let i = a ? {
952
- id: e,
953
- ok: !0,
954
- result: l.result,
955
- duration: u,
956
- incremental: q(r),
957
- ...l.sourcePhase === void 0 ? {} : { sourcePhase: l.sourcePhase },
958
- protocol: D,
959
- revision: t,
960
- metrics: d
961
- } : {
962
- id: e,
963
- ok: !0,
964
- result: l.result,
965
- duration: u,
966
- incremental: q(r),
967
- ...l.sourcePhase === void 0 ? {} : { sourcePhase: l.sourcePhase }
968
- };
969
- if (o && i.ok) {
970
- let e = U();
971
- i.analysis = G(l.source, l.options, l.result), i.metrics = {
972
- ...i.metrics,
973
- analysisMs: W(U() - e)
974
- };
975
- }
976
- if (l.deep && l.flatResults && i.ok) {
977
- let { result: e, ...t } = i, r = {
978
- ...t,
979
- flatResult: ot(e)
980
- };
981
- n.postMessage(r);
982
- } else n.postMessage(i);
983
- return !0;
984
- } catch (t) {
985
- return J(n, e, `Could not return the compile result: ${H(t)}`), !1;
986
- }
987
- };
988
- return n.onmessage = (e) => {
989
- let t = e?.data;
990
- if (vt(t)) {
991
- t.control === "dispose" ? y() : h();
992
- return;
993
- }
994
- if (!t || typeof t.id != "number") return;
995
- if (typeof t.source == "string") {
996
- let e = t, i = ft(e.options), a = e.sourcePhase === void 0 ? i?.sourcePhase : e.sourcePhase;
997
- if (a !== void 0 && !gt(a)) {
998
- J(n, e.id, "The requested source phase is not supported: expected \"streaming\" or \"final\"");
999
- return;
1000
- }
1001
- let o = a;
1002
- h();
1003
- let s = K(i), u = e.protocol === D, d = x(e.revision), f = U();
1004
- try {
1005
- if (c !== null && c.optionsKey !== s) try {
1006
- r.clear();
1007
- } catch {}
1008
- let t = ht(r, e.source, i, o), n = W(U() - f);
1009
- l = d, c = {
1010
- source: e.source,
1011
- revision: d,
1012
- options: i,
1013
- optionsKey: s,
1014
- result: t,
1015
- deep: at(t),
1016
- flatResults: e.flatResults === V,
1017
- ...o === void 0 ? {} : { sourcePhase: o }
1018
- }, S(e.id, d, n, u, e.includeAuthorAnalysis === !0) && v();
1019
- } catch (t) {
1020
- J(n, e.id, H(t));
1021
- }
1022
- return;
1023
- }
1024
- if (t.protocol !== "patch-v1") return;
1025
- h();
1026
- let i = t, a = c, o = (e, t) => {
1027
- _t(n, i.id, e, t, a?.revision);
1028
- };
1029
- if (a === null) {
1030
- o("No complete compile is available to patch", "stale-base");
1031
- return;
1032
- }
1033
- if ((a.sourcePhase ?? "final") !== "final") {
1034
- o("The baseline was compiled from a streaming snapshot", "phase-mismatch");
1035
- return;
1036
- }
1037
- if (typeof i.baseRevision != "number" || i.baseRevision !== a.revision) {
1038
- o("The requested base revision is not current", "stale-base");
1039
- return;
1040
- }
1041
- if (i.optionsKey !== void 0 && i.optionsKey !== a.optionsKey) {
1042
- o("The options signature changed since the baseline", "options-mismatch");
1043
- return;
1044
- }
1045
- if (!yt(i.edit)) {
1046
- o("The source edit is invalid", "invalid-edit");
1047
- return;
1048
- }
1049
- let s = i.edit;
1050
- if (s.to > a.source.length) {
1051
- o("The source edit does not fit the baseline", "invalid-edit");
1052
- return;
1053
- }
1054
- let u = a.source.slice(0, s.from) + s.insert + a.source.slice(s.to);
1055
- if (typeof i.targetLength == "number" && u.length !== i.targetLength) {
1056
- o("The source edit produced an unexpected length", "invalid-edit");
1057
- return;
1058
- }
1059
- let d = x(i.revision), f = U();
1060
- try {
1061
- let e = ht(r, u, a.options, a.sourcePhase), t = W(U() - f), o = a.revision, s = a.result;
1062
- l = d, c = {
1063
- source: u,
1064
- revision: d,
1065
- options: a.options,
1066
- optionsKey: a.optionsKey,
1067
- result: e,
1068
- deep: at(e),
1069
- flatResults: a.flatResults,
1070
- ...a.sourcePhase === void 0 ? {} : { sourcePhase: a.sourcePhase }
1071
- };
1072
- let p = null, h = 0;
1073
- if (e.ok && s.ok && !c.deep && !a.deep) {
1074
- let t = U();
1075
- p = Qe(s, e), h = W(U() - t);
1076
- }
1077
- let g = p?.patch ?? null;
1078
- if (g === null) {
1079
- S(i.id, d, t, !0, i.includeAuthorAnalysis === !0) && v();
1080
- return;
1081
- }
1082
- if (p !== null && p.cost.preferFull) {
1083
- let e = p.cost, n = {
1084
- patchEncodeMs: h,
1085
- patchFallback: "cost",
1086
- patchBytes: e.patchBytes,
1087
- ...e.fullBytes === void 0 ? {} : { fullBytes: e.fullBytes }
1088
- };
1089
- S(i.id, d, t, !0, i.includeAuthorAnalysis === !0, n) && v();
1090
- return;
1091
- }
1092
- let _ = {
1093
- compileMs: t,
1094
- patchEncodeMs: h,
1095
- patchNodes: g.document.nodes?.length ?? 0,
1096
- ...m === void 0 ? {} : { preparationMs: m }
1097
- };
1098
- try {
1099
- let s = {
1100
- id: i.id,
1101
- ok: !0,
1102
- protocol: D,
1103
- baseRevision: o,
1104
- revision: d,
1105
- patch: g,
1106
- duration: t,
1107
- incremental: q(r),
1108
- ...a.sourcePhase === void 0 ? {} : { sourcePhase: a.sourcePhase },
1109
- metrics: _
1110
- };
1111
- if (i.includeAuthorAnalysis === !0) {
1112
- let t = U();
1113
- s.analysis = G(u, a.options, e), _.analysisMs = W(U() - t);
1114
- }
1115
- n.postMessage(s), v();
1116
- } catch (e) {
1117
- J(n, i.id, `Could not return the compile result: ${H(e)}`);
1118
- }
1119
- } catch (e) {
1120
- J(n, i.id, H(e));
1121
- }
1122
- }, {
1123
- dispose: y,
1124
- cancelPreparation: h,
1125
- get disposed() {
1126
- return u;
1127
- }
1128
- };
1129
- }
1130
- // src/local/transport/worker.ts
1131
- function xt(e, t) {
1132
- if (!e || typeof e != "object") return !1;
1133
- let n = e, r = (e) => e && Number.isSafeInteger(e.start) && Number.isSafeInteger(e.end) && e.start >= 0 && e.end >= e.start && e.end <= t;
1134
- if (!Array.isArray(n.tokens) || n.tokens.length > t + 1 || !Array.isArray(n.bindings) || n.bindings.length > t + 1 || !Array.isArray(n.diagnostics)) return !1;
1135
- let i = 0, a = 0;
1136
- for (let e of n.tokens) {
1137
- if (!e || typeof e.kind != "string" || !r(e.range) || e.range.start < i) return !1;
1138
- i = e.range.end;
1139
- }
1140
- for (let e of n.bindings) if (!e || typeof e.name != "string" || !Array.isArray(e.declarations) || !Array.isArray(e.references) || (a += e.declarations.length + e.references.length, a > t + 1 || !e.declarations.every(r) || !e.references.every(r))) return !1;
1141
- return !0;
1142
- }
1143
- function St(e, t, n) {
1144
- let r = ft(t), i = n === void 0 ? Ct(t) : n, a = i === "streaming" || i === "final" ? i : void 0, o = i !== void 0 && a === void 0 ? i : void 0;
1145
- return {
1146
- source: e,
1147
- options: r,
1148
- optionsKey: K(r),
1149
- scheduledAt: U(),
1150
- sourcePhase: a === "streaming" ? "streaming" : "final",
1151
- explicitPhase: i !== void 0,
1152
- ...o === void 0 ? {} : { invalidPhase: o }
1153
- };
1154
- }
1155
- function Ct(e) {
1156
- try {
1157
- return !e || typeof e != "object" || Array.isArray(e) ? void 0 : e.sourcePhase;
1158
- } catch {
1159
- return;
1160
- }
1161
- }
1162
- function Y(e, t) {
1163
- return e.source === t.source && e.optionsKey === t.optionsKey && e.sourcePhase === t.sourcePhase && e.explicitPhase === t.explicitPhase && e.invalidPhase === t.invalidPhase;
1164
- }
1165
- function X(e) {
1166
- return e.sourcePhase === "streaming" || e.explicitPhase ? { sourcePhase: e.sourcePhase } : {};
1167
- }
1168
- function Z(e, t) {
1169
- return e.explicitPhase ? {
1170
- ok: !1,
1171
- diagnostics: [t],
1172
- status: "failed"
1173
- } : {
1174
- ok: !1,
1175
- diagnostics: [t]
1176
- };
1177
- }
1178
- function wt() {
1179
- return {
1180
- ok: !1,
1181
- status: "failed",
1182
- diagnostics: [{
1183
- code: "local.options.invalid",
1184
- message: "Compile option sourcePhase must be \"streaming\" or \"final\".",
1185
- severity: "error",
1186
- range: {
1187
- start: 0,
1188
- end: 0
1189
- },
1190
- line: 1,
1191
- column: 1,
1192
- messageKey: "local.options.invalid.source-phase"
1193
- }]
1194
- };
1195
- }
1196
- function Q(e) {
1197
- if (!e || typeof e != "object") return !1;
1198
- let t = e;
1199
- return !(typeof t.ok != "boolean" || !Array.isArray(t.diagnostics) || t.ok && (!t.document || typeof t.document != "object"));
1200
- }
1201
- function Tt(e) {
1202
- return e.ok && "patch" in e && e.patch !== void 0;
1203
- }
1204
- function $(e) {
1205
- return {
1206
- code: "local.worker.compile",
1207
- message: `Compilation failed: ${H(e)}`,
1208
- severity: "error",
1209
- range: {
1210
- start: 0,
1211
- end: 0
1212
- },
1213
- line: 1,
1214
- column: 1
1215
- };
1216
- }
1217
- var Et = class {
1218
- options;
1219
- delay;
1220
- worker = null;
1221
- timer = null;
1222
- queued = null;
1223
- inFlight = null;
1224
- nextId = 1;
1225
- nextRevision = 1;
1226
- pending = !1;
1227
- fallbackSession = null;
1228
- disposed = !1;
1229
- baseline = null;
1230
- patchState = "unknown";
1231
- constructor(e) {
1232
- this.options = e;
1233
- let t = e.delay;
1234
- this.delay = typeof t == "number" && Number.isFinite(t) ? Math.max(0, t) : 150;
1235
- try {
1236
- let t = e.createWorker();
1237
- t.onmessage = (e) => this.receive(e.data), t.onerror = (e) => {
1238
- let t = e && typeof e.message == "string" ? String(e.message) : "";
1239
- this.handleWorkerFailure(t || "The compile worker encountered an error");
1240
- }, t.onmessageerror = () => this.handleWorkerFailure("The compile worker could not deliver the compile result"), this.worker = t;
1241
- } catch (t) {
1242
- this.worker = null, e.onModeChange?.("fallback", `Could not start the compile worker: ${H(t)}`);
1243
- }
1244
- }
1245
- schedule(e, t, n, r) {
1246
- if (this.disposed) return;
1247
- let i = St(e, t, r);
1248
- this.queued = i, n && typeof n.baseSource == "string" && yt(n.edit) && n.edit.to <= n.baseSource.length && n.baseSource.slice(0, n.edit.from) + n.edit.insert + n.baseSource.slice(n.edit.to) === e && (this.queued.editHint = {
1249
- baseSource: n.baseSource,
1250
- edit: { ...n.edit }
1251
- }), this.clearTimer(), i.sourcePhase === "streaming" && (this.baseline = null), this.setPending(!0), i.sourcePhase === "streaming" || !i.explicitPhase ? this.timer = setTimeout(() => {
1252
- this.timer = null, this.drain();
1253
- }, this.delay) : this.drain();
1254
- }
1255
- dispose() {
1256
- if (this.disposed) return;
1257
- this.disposed = !0, this.clearTimer(), this.queued = null, this.inFlight = null, this.resetProtocol();
1258
- let e = this.worker;
1259
- if (this.worker = null, e) {
1260
- e.onmessage = null, e.onerror = null, e.onmessageerror = null;
1261
- try {
1262
- e.terminate();
1263
- } catch {}
1264
- }
1265
- this.pending = !1, this.fallbackSession?.dispose(), this.fallbackSession = null;
1266
- }
1267
- drain() {
1268
- if (this.disposed || this.timer !== null || this.inFlight !== null) return;
1269
- let e = this.queued;
1270
- e === null ? this.setPending(!1) : (this.queued = null, this.compile(e));
1271
- }
1272
- compile(e) {
1273
- if (e.invalidPhase !== void 0) {
1274
- this.deliver({
1275
- source: e.source,
1276
- result: wt(),
1277
- duration: 0,
1278
- mode: this.worker === null ? "fallback" : "worker",
1279
- ...e.options === void 0 ? {} : { options: e.options },
1280
- metrics: { queueMs: W(U() - e.scheduledAt) }
1281
- }), this.finishRun();
1282
- return;
1283
- }
1284
- let t = this.worker;
1285
- if (!t) {
1286
- this.compileFallback(e);
1287
- return;
1288
- }
1289
- e.sourcePhase === "streaming" && (this.baseline = null);
1290
- let n = this.nextId++, r = this.nextRevision++, i = U(), a = this.baseline, o = e.sourcePhase === "final" && this.patchState === "enabled" && a !== null && a.optionsKey === e.optionsKey ? {
1291
- id: n,
1292
- protocol: D,
1293
- baseRevision: a.revision,
1294
- revision: r,
1295
- edit: e.editHint?.baseSource === a.source ? e.editHint.edit : F(a.source, e.source) ?? {
1296
- from: 0,
1297
- to: 0,
1298
- insert: ""
1299
- },
1300
- targetLength: e.source.length,
1301
- optionsKey: e.optionsKey
1302
- } : {
1303
- id: n,
1304
- source: e.source,
1305
- ...e.options === void 0 ? {} : { options: e.options },
1306
- protocol: D,
1307
- revision: r,
1308
- flatResults: V,
1309
- ...e.sourcePhase === "streaming" || e.explicitPhase ? { sourcePhase: e.sourcePhase } : {}
1310
- };
1311
- this.inFlight = {
1312
- id: n,
1313
- job: e,
1314
- startedAt: i,
1315
- revision: r
1316
- }, this.options.includeAuthorAnalysis && (o.includeAuthorAnalysis = !0);
1317
- try {
1318
- t.postMessage(o);
1319
- } catch (t) {
1320
- this.inFlight = null;
1321
- let n = `Could not send the source to the compile worker: ${H(t)}`, r = this.queued;
1322
- if (r !== null && !Y(r, e)) {
1323
- this.resetProtocol(), this.degrade(n), this.finishRun();
1324
- return;
1325
- }
1326
- r !== null && (this.queued = null, this.clearTimer()), this.resetProtocol(), this.degrade(n), this.compileFallback(e);
1327
- }
1328
- }
1329
- compileFallback(e) {
1330
- if (this.disposed) return;
1331
- e.sourcePhase === "streaming" && (this.baseline = null);
1332
- let t = U(), n;
1333
- try {
1334
- let t = this.options.fallbackCompile ?? ((e, t, n) => (this.fallbackSession ??= T(), this.fallbackSession.compile(e, t, n)));
1335
- n = e.explicitPhase ? t(e.source, e.options, e.sourcePhase) : e.options === void 0 ? t(e.source) : t(e.source, e.options);
1336
- } catch (t) {
1337
- n = Z(e, $(t));
1338
- }
1339
- this.deliver({
1340
- source: e.source,
1341
- result: n,
1342
- duration: W(U() - t),
1343
- mode: "fallback",
1344
- ...this.options.includeAuthorAnalysis ? { analysis: G(e.source, e.options, n) } : {},
1345
- ...e.options === void 0 ? {} : { options: e.options },
1346
- ...X(e),
1347
- metrics: { queueMs: W(t - e.scheduledAt) }
1348
- }), this.finishRun();
1349
- }
1350
- receive(e) {
1351
- if (this.disposed) return;
1352
- let t = this.inFlight;
1353
- if (!t || !e || e.id !== t.id) return;
1354
- let n, r = 0;
1355
- if (e.ok && "flatResult" in e) {
1356
- let t = U(), i = st(e.flatResult);
1357
- r = W(U() - t), n = Q(i) ? {
1358
- ...e,
1359
- result: i
1360
- } : {
1361
- id: e.id,
1362
- ok: !1,
1363
- retryFull: !0,
1364
- message: "Invalid flat compile result"
1365
- };
1366
- } else n = e;
1367
- this.inFlight = null;
1368
- let i = t.job, a = W(U() - t.startedAt), o = W(t.startedAt - i.scheduledAt), s = null, c = r, l = null, u = "worker", d;
1369
- if (n.ok) {
1370
- if (Tt(n)) {
1371
- let e = U(), t = this.applyResponsePatch(i, n);
1372
- c = W(U() - e), t !== null && (s = t, d = n.revision);
1373
- } else {
1374
- let e = n;
1375
- Q(e.result) ? (s = e.result, d = typeof e.revision == "number" ? e.revision : void 0, i.sourcePhase === "streaming" || e.sourcePhase === "streaming" ? this.baseline = null : e.protocol === "patch-v1" && typeof e.revision == "number" && Number.isSafeInteger(e.revision) ? (this.patchState = "enabled", this.baseline = e.result.ok ? {
1376
- source: i.source,
1377
- optionsKey: i.optionsKey,
1378
- revision: e.revision,
1379
- result: e.result
1380
- } : null) : (this.patchState = "legacy", this.baseline = null)) : l = "The compile worker returned an invalid result";
1381
- }
1382
- } else n.retryFull !== !0 && (l = n.message);
1383
- let f = this.queued, p = f !== null && !Y(f, i);
1384
- f !== null && !p && (this.queued = null, this.clearTimer()), s === null ? l === null ? (p || !this.recoverWithFullResult(i)) && (p ? this.resetProtocol() : (this.patchState = "disabled", this.baseline = null, this.deliver({
1385
- source: i.source,
1386
- result: Z(i, $("The compile worker could not apply an incremental result patch")),
1387
- duration: 0,
1388
- mode: u,
1389
- ...i.options === void 0 ? {} : { options: i.options },
1390
- ...X(i),
1391
- metrics: {
1392
- queueMs: o,
1393
- roundTripMs: a,
1394
- ...c > 0 ? { applyMs: c } : {}
1395
- }
1396
- })), this.finishRun()) : (p || this.deliver({
1397
- source: i.source,
1398
- result: Z(i, $(l)),
1399
- duration: 0,
1400
- mode: u,
1401
- ...i.options === void 0 ? {} : { options: i.options },
1402
- ...X(i),
1403
- metrics: {
1404
- queueMs: o,
1405
- roundTripMs: a
1406
- }
1407
- }), this.finishRun()) : (p || this.deliver({
1408
- source: i.source,
1409
- result: s,
1410
- duration: W(n.ok ? n.duration : 0),
1411
- mode: u,
1412
- ...n.ok && this.options.includeAuthorAnalysis && xt(n.analysis, i.source.length) ? { analysis: n.analysis } : {},
1413
- ...i.options === void 0 ? {} : { options: i.options },
1414
- ...X(i),
1415
- metrics: {
1416
- queueMs: o,
1417
- roundTripMs: a,
1418
- ...c > 0 ? { applyMs: c } : {},
1419
- ...n.ok && n.metrics ? { worker: n.metrics } : {}
1420
- },
1421
- ...d === void 0 ? {} : { revision: d }
1422
- }), this.finishRun());
1423
- }
1424
- applyResponsePatch(e, t) {
1425
- if (e.sourcePhase !== "final") return null;
1426
- let n = this.baseline;
1427
- if (n === null || n.optionsKey !== e.optionsKey || !Number.isSafeInteger(t.revision) || t.revision <= n.revision || t.baseRevision !== n.revision || t.protocol !== "patch-v1") return null;
1428
- let r = it(n.result, t.patch);
1429
- if (r === null || !r.ok || r.document.source !== e.source) return null;
1430
- let i;
1431
- if (e.sourcePhase === "final" && e.explicitPhase) i = r.recoveries === void 0 ? {
1432
- ...r,
1433
- status: "valid"
1434
- } : {
1435
- ...r,
1436
- status: "recovered"
1437
- };
1438
- else if (r.ok && r.status !== void 0) {
1439
- let e = { ...r };
1440
- delete e.status, i = e;
1441
- } else i = r;
1442
- return this.baseline = {
1443
- source: e.source,
1444
- optionsKey: e.optionsKey,
1445
- revision: t.revision,
1446
- result: i
1447
- }, i;
1448
- }
1449
- recoverWithFullResult(e) {
1450
- if (this.worker === null || (e.recovery ?? 0) >= 1) return !1;
1451
- let t = this.queued;
1452
- return t !== null && !Y(t, e) ? !1 : (t !== null && (this.queued = null, this.clearTimer()), this.resetProtocol(), this.compile({
1453
- ...e,
1454
- recovery: (e.recovery ?? 0) + 1
1455
- }), !0);
1456
- }
1457
- handleWorkerFailure(e) {
1458
- if (this.disposed) return;
1459
- this.resetProtocol(), this.degrade(e);
1460
- let t = this.inFlight;
1461
- this.inFlight = null, t && (this.queued === null || Y(this.queued, t.job)) && (this.queued !== null && (this.queued = null, this.clearTimer()), this.compileFallback(t.job)), this.finishRun();
1462
- }
1463
- degrade(e) {
1464
- let t = this.worker;
1465
- if (t) {
1466
- this.worker = null, t.onmessage = null, t.onerror = null, t.onmessageerror = null;
1467
- try {
1468
- t.terminate();
1469
- } catch {}
1470
- this.options.onModeChange?.("fallback", e);
1471
- }
1472
- }
1473
- resetProtocol() {
1474
- this.baseline = null, this.patchState = "unknown";
1475
- }
1476
- finishRun() {
1477
- this.disposed || (this.drain(), !this.disposed && this.setPending(this.timer !== null || this.inFlight !== null || this.queued !== null));
1478
- }
1479
- deliver(e) {
1480
- if (this.disposed) return;
1481
- let t = this.baseline !== null && this.baseline.result === e.result, n = this.options.shareResults === !0 || !t ? e.result : P(e.result);
1482
- this.options.onResult({
1483
- ...e,
1484
- result: n
1485
- });
1486
- }
1487
- setPending(e) {
1488
- this.pending !== e && (this.pending = e, this.options.onPendingChange?.(e));
1489
- }
1490
- clearTimer() {
1491
- this.timer !== null && (clearTimeout(this.timer), this.timer = null);
1492
- }
1493
- };
1494
- export { h as DEFAULT_LOCAL_THEME, ct as LOCAL_COMPILE_DELAY_MS, lt as LOCAL_COMPILE_PREPARATION_DELAY_MS, i as LOCAL_DIAGNOSTIC_CODES, D as LOCAL_RESULT_PATCH_PROTOCOL, _e as LOCAL_STATE_FORMAT, y as LOCAL_SYNTAX_VERSION, f as LOCAL_THEME_PROTOCOL, Et as LocalCompileScheduler, ie as LocalCompileSession, g as LocalExpressionError, Te as SHAREABLE_HTML_FORMAT, Se as SHAREABLE_HTML_FORMAT_V2, C as analyzeLocalSource, it as applyLocalResultPatch, Ce as applyLocalState, oe as applyLocalStateRetention, Ve as applySourceEdit, Le as checkLocalUpgrade, _ as compileExpression, $ as compileFailureDiagnostic, n as compileLatex, ee as compileLocal, t as compilePlotFormula, ne as completeLocalSource, a as countLocalCodePoints, T as createLocalCompileSession, ce as createLocalRuntime, xe as createLocalStateFile, we as createShareableHtml, F as diffSourceEdit, Ze as encodeLocalResultPatch, ye as exportLocalState, l as formatLocalDiagnostic, re as formatLocalSource, e as implicitGridSize, ve as importLocalState, Pe as inspectLocalSourceVersion, u as isLocalDiagnosticCode, o as isLocalThemeName, S as localCompileOptionsKey, s as localDiagnosticTemplate, c as localDiagnosticTemplateKeys, ae as localSourceDigest, K as localWorkerOptionsKey, Re as migrateLocalSource, ue as notifyLocalRuntime, he as parseLocalState, le as planLocalStateRetention, r as plotFormulaKind, te as renameLocalBinding, Oe as resolveLocalComponentStateExport, Ee as resolveLocalState, be as resolveLocalStateBaseline, m as resolveLocalTheme, me as sampleImplicit, fe as sampleParametric, pe as samplePlot, de as samplePolar, ge as serializeForScript, De as serializeLocalState, bt as startLocalCompileWorker, se as updateLocalRuntime };
217
+ export { te as DEFAULT_LOCAL_THEME, F as LOCAL_COMPILE_DELAY_MS, U as LOCAL_COMPILE_PREPARATION_DELAY_MS, a as LOCAL_DIAGNOSTIC_CODES, p as LOCAL_OBSERVABILITY_MESSAGES, V as LOCAL_RESULT_PATCH_PROTOCOL, le as LOCAL_STATE_FORMAT, _ as LOCAL_SYNTAX_VERSION, d as LOCAL_THEME_PROTOCOL, W as LocalCompileScheduler, D as LocalCompileSession, g as LocalExpressionError, _e as SHAREABLE_HTML_FORMAT, me as SHAREABLE_HTML_FORMAT_V2, w as analyzeLocalSource, z as applyLocalResultPatch, he as applyLocalState, k as applyLocalStateRetention, R as applySourceEdit, ke as checkLocalUpgrade, ne as compileExpression, H as compileFailureDiagnostic, n as compileLatex, v as compileLocal, t as compilePlotFormula, S as completeLocalSource, i as countLocalCodePoints, xe as createDiagnosticReport, E as createLocalCompileSession, be as createLocalObservabilityDiagnostic, j as createLocalRuntime, we as createLocalRuntimePool, pe as createLocalStateFile, b as createLocalTraceId, ge as createShareableHtml, G as diffSourceEdit, ie as emitLocalDiagnostic, y as emitLocalTrace, K as encodeLocalResultPatch, de as exportLocalState, ee as formatLocalDiagnostic, C as formatLocalSource, u as formatObservabilityMessage, e as implicitGridSize, ue as importLocalState, De as inspectLocalSourceVersion, o as isLocalDiagnosticCode, m as isLocalThemeName, O as localCompileCacheKey, re as localCompileOptionsKey, h as localDiagnosticTemplate, s as localDiagnosticTemplateKeys, P as localSourceDigest, L as localWorkerOptionsKey, Ae as migrateLocalSource, N as notifyLocalRuntime, se as parseLocalState, M as planLocalStateRetention, r as plotFormulaKind, x as renameLocalBinding, Se as resolveLocalComponentStateExport, ve as resolveLocalState, fe as resolveLocalStateBaseline, c as resolveLocalTheme, oe as sampleImplicit, q as sampleParametric, J as samplePlot, ae as samplePolar, ce as serializeForScript, ye as serializeLocalState, B as startLocalCompileWorker, A as updateLocalRuntime };