@mdsvex/parse 1.0.0-next.0 → 1.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/CHANGELOG.md +213 -0
  2. package/WIRE_FORMAT.md +5 -1
  3. package/dist/buf-utils.js +23 -23
  4. package/dist/buf_utils.d.ts +1 -1
  5. package/dist/cursor.d.ts +17 -13
  6. package/dist/cursor.js +118 -31
  7. package/dist/main.d.ts +362 -26
  8. package/dist/main.js +5841 -3420
  9. package/dist/node_view-bvM0i0-p.js +407 -0
  10. package/dist/node_view.d.ts +11 -12
  11. package/dist/opcodes.d.ts +23 -6
  12. package/dist/plugin_dispatch.d.ts +22 -8
  13. package/dist/tree-builder.js +185 -66
  14. package/dist/tree_builder.d.ts +42 -11
  15. package/dist/undo_log.d.ts +11 -1
  16. package/dist/utils.d.ts +77 -51
  17. package/dist/utils.js +687 -209
  18. package/dist/wire-tree-builder.js +69 -71
  19. package/dist/wire_tree_builder.d.ts +4 -7
  20. package/package.json +1 -1
  21. package/src/buf_utils.ts +10 -14
  22. package/src/cursor.ts +74 -57
  23. package/src/main.ts +9898 -5593
  24. package/src/node_view.ts +159 -140
  25. package/src/opcodes.ts +39 -7
  26. package/src/plugin_dispatch.ts +328 -219
  27. package/src/tree_builder.ts +278 -98
  28. package/src/undo_log.ts +58 -24
  29. package/src/utils.spec.ts +86 -9
  30. package/src/utils.ts +769 -392
  31. package/src/wire_emitter.ts +6 -0
  32. package/src/wire_tree_builder.ts +39 -52
  33. package/test/block_quotes.spec.ts +78 -7
  34. package/test/code_spans.spec.ts +158 -6
  35. package/test/crlf.spec.ts +49 -1
  36. package/test/directives.spec.ts +530 -1
  37. package/test/emphasis.spec.ts +10 -4
  38. package/test/fixtures/pfm/block_quotes/pfm_fence_close.md +4 -0
  39. package/test/fixtures/pfm/block_quotes/pfm_fence_close_compact.md +4 -0
  40. package/test/fixtures/pfm/block_quotes/pfm_fence_close_end_quote.md +5 -0
  41. package/test/fixtures/pfm/block_quotes/pfm_fence_close_info.md +5 -0
  42. package/test/fixtures/pfm/block_quotes/pfm_fence_close_longer.md +4 -0
  43. package/test/fixtures/pfm/block_quotes/pfm_fence_close_nested.md +3 -0
  44. package/test/fixtures/pfm/block_quotes/pfm_fence_close_twice.md +6 -0
  45. package/test/fixtures/pfm/block_quotes/pfm_fence_info_eof.md +1 -0
  46. package/test/fixtures/pfm/block_quotes/pfm_fence_unclosed.md +2 -0
  47. package/test/fixtures/pfm/code_spans/pfm_328_5.md +1 -0
  48. package/test/fixtures/pfm/code_spans/pfm_328_6.md +1 -0
  49. package/test/fixtures/pfm/code_spans/pfm_328_7.md +1 -0
  50. package/test/fixtures/pfm/code_spans/pfm_328_8.md +1 -0
  51. package/test/fixtures/pfm/code_spans/pfm_328_9.md +2 -0
  52. package/test/fixtures/pfm/fenced_code_blocks/pfm_info_eof.md +1 -0
  53. package/test/fixtures/pfm/fenced_code_blocks/pfm_info_eof_no_lf.md +1 -0
  54. package/test/fixtures/pfm/generic_directives/106.md +1 -0
  55. package/test/fixtures/pfm/generic_directives/107.md +3 -0
  56. package/test/fixtures/pfm/generic_directives/108.md +1 -0
  57. package/test/fixtures/pfm/generic_directives/109.md +1 -0
  58. package/test/fixtures/pfm/generic_directives/110.md +1 -0
  59. package/test/fixtures/pfm/generic_directives/111.md +1 -0
  60. package/test/fixtures/pfm/generic_directives/112.md +1 -0
  61. package/test/fixtures/pfm/generic_directives/113.md +1 -0
  62. package/test/fixtures/pfm/generic_directives/114.md +2 -0
  63. package/test/fixtures/pfm/generic_directives/115.md +1 -0
  64. package/test/fixtures/pfm/generic_directives/116.md +6 -0
  65. package/test/fixtures/pfm/generic_directives/117.md +3 -0
  66. package/test/fixtures/pfm/generic_directives/118.md +6 -0
  67. package/test/fixtures/pfm/generic_directives/119.md +3 -0
  68. package/test/fixtures/pfm/generic_directives/120.md +5 -0
  69. package/test/fixtures/pfm/generic_directives/121.md +3 -0
  70. package/test/fixtures/pfm/generic_directives/122.md +4 -0
  71. package/test/fixtures/pfm/generic_directives/123.md +2 -0
  72. package/test/html.spec.ts +44 -1
  73. package/test/html_block_containers.spec.ts +445 -0
  74. package/test/incremental.spec.ts +271 -0
  75. package/test/lists.spec.ts +107 -1
  76. package/test/parser_reuse.spec.ts +40 -0
  77. package/test/plugins.spec.ts +196 -226
  78. package/test/print.ts +2 -3
  79. package/test/run_bytecode.spec.ts +36 -0
  80. package/test/snapshots/hybrid/component-children.snap.ast +9 -16
  81. package/test/snapshots/hybrid/component-simple-00.snap.ast +1 -2
  82. package/test/snapshots/hybrid/component-simple-01.snap.ast +1 -2
  83. package/test/snapshots/hybrid/component-simple-03.snap.ast +13 -13
  84. package/test/snapshots/hybrid/component-simple-04.snap.ast +1 -2
  85. package/test/snapshots/hybrid/error.snap.ast +1 -2
  86. package/test/snapshots/markdown/blockquote-nested-markdown.snap.ast +2 -1
  87. package/test/snapshots/markdown/emphasis.snap.ast +2 -2
  88. package/test/snapshots/markdown/encodeHTMLCodeTags.snap.ast +1 -2
  89. package/test/snapshots/markdown/github-style-codeblock-inside-quote.snap.ast +8 -1
  90. package/test/snapshots/markdown/html-comments.snap.ast +11 -13
  91. package/test/snapshots/markdown/html5-strutural-tags.snap.ast +16 -31
  92. package/test/snapshots/markdown/line-starts-with-html.snap.ast +5 -6
  93. package/test/snapshots/markdown/literal-html-tags.snap.ast +11 -14
  94. package/test/snapshots/markdown/nested-blockquote.snap.ast +3 -3
  95. package/test/snapshots/markdown/pre-code-tags.snap.ast +5 -8
  96. package/test/snapshots/pfm/block_quotes/237.snap.ast +1 -2
  97. package/test/snapshots/pfm/block_quotes/251.snap.ast +5 -5
  98. package/test/snapshots/pfm/block_quotes/pfm_fence_close.snap.ast +6 -0
  99. package/test/snapshots/pfm/block_quotes/pfm_fence_close_compact.snap.ast +6 -0
  100. package/test/snapshots/pfm/block_quotes/pfm_fence_close_end_quote.snap.ast +8 -0
  101. package/test/snapshots/pfm/block_quotes/pfm_fence_close_info.snap.ast +4 -0
  102. package/test/snapshots/pfm/block_quotes/pfm_fence_close_longer.snap.ast +6 -0
  103. package/test/snapshots/pfm/block_quotes/pfm_fence_close_nested.snap.ast +5 -0
  104. package/test/snapshots/pfm/block_quotes/pfm_fence_close_twice.snap.ast +5 -0
  105. package/test/snapshots/pfm/block_quotes/pfm_fence_info_eof.snap.ast +3 -0
  106. package/test/snapshots/pfm/block_quotes/pfm_fence_unclosed.snap.ast +3 -0
  107. package/test/snapshots/pfm/code_spans/344.snap.ast +1 -1
  108. package/test/snapshots/pfm/code_spans/347.snap.ast +1 -2
  109. package/test/snapshots/pfm/code_spans/pfm_328_5.snap.ast +6 -0
  110. package/test/snapshots/pfm/code_spans/pfm_328_6.snap.ast +6 -0
  111. package/test/snapshots/pfm/code_spans/pfm_328_7.snap.ast +6 -0
  112. package/test/snapshots/pfm/code_spans/pfm_328_8.snap.ast +8 -0
  113. package/test/snapshots/pfm/code_spans/pfm_328_9.snap.ast +10 -0
  114. package/test/snapshots/pfm/emphasis_and_strong_emphasis/417.snap.ast +2 -2
  115. package/test/snapshots/pfm/emphasis_and_strong_emphasis/438.snap.ast +1 -1
  116. package/test/snapshots/pfm/emphasis_and_strong_emphasis/441.snap.ast +1 -1
  117. package/test/snapshots/pfm/emphasis_and_strong_emphasis/444.snap.ast +1 -1
  118. package/test/snapshots/pfm/emphasis_and_strong_emphasis/445.snap.ast +1 -1
  119. package/test/snapshots/pfm/emphasis_and_strong_emphasis/450.snap.ast +1 -1
  120. package/test/snapshots/pfm/emphasis_and_strong_emphasis/453.snap.ast +1 -1
  121. package/test/snapshots/pfm/emphasis_and_strong_emphasis/456.snap.ast +1 -1
  122. package/test/snapshots/pfm/emphasis_and_strong_emphasis/457.snap.ast +1 -1
  123. package/test/snapshots/pfm/emphasis_and_strong_emphasis/473.snap.ast +1 -1
  124. package/test/snapshots/pfm/emphasis_and_strong_emphasis/475.snap.ast +1 -1
  125. package/test/snapshots/pfm/emphasis_and_strong_emphasis/476.snap.ast +1 -1
  126. package/test/snapshots/pfm/emphasis_and_strong_emphasis/477.snap.ast +1 -1
  127. package/test/snapshots/pfm/emphasis_and_strong_emphasis/478.snap.ast +3 -4
  128. package/test/snapshots/pfm/emphasis_and_strong_emphasis/479.snap.ast +3 -4
  129. package/test/snapshots/pfm/fenced_code_blocks/126.snap.ast +1 -2
  130. package/test/snapshots/pfm/fenced_code_blocks/pfm_info_eof.snap.ast +2 -0
  131. package/test/snapshots/pfm/fenced_code_blocks/pfm_info_eof_no_lf.snap.ast +2 -0
  132. package/test/snapshots/pfm/generic_directives/011.snap.ast +3 -1
  133. package/test/snapshots/pfm/generic_directives/015.snap.ast +3 -1
  134. package/test/snapshots/pfm/generic_directives/016.snap.ast +3 -1
  135. package/test/snapshots/pfm/generic_directives/017.snap.ast +3 -1
  136. package/test/snapshots/pfm/generic_directives/019.snap.ast +3 -1
  137. package/test/snapshots/pfm/generic_directives/020.snap.ast +3 -1
  138. package/test/snapshots/pfm/generic_directives/030.snap.ast +4 -6
  139. package/test/snapshots/pfm/generic_directives/034.snap.ast +6 -2
  140. package/test/snapshots/pfm/generic_directives/036.snap.ast +5 -1
  141. package/test/snapshots/pfm/generic_directives/038.snap.ast +6 -2
  142. package/test/snapshots/pfm/generic_directives/039.snap.ast +3 -1
  143. package/test/snapshots/pfm/generic_directives/040.snap.ast +3 -1
  144. package/test/snapshots/pfm/generic_directives/044.snap.ast +3 -1
  145. package/test/snapshots/pfm/generic_directives/046.snap.ast +3 -1
  146. package/test/snapshots/pfm/generic_directives/089.snap.ast +1 -1
  147. package/test/snapshots/pfm/generic_directives/103.snap.ast +6 -2
  148. package/test/snapshots/pfm/generic_directives/106.snap.ast +9 -0
  149. package/test/snapshots/pfm/generic_directives/107.snap.ast +9 -0
  150. package/test/snapshots/pfm/generic_directives/108.snap.ast +5 -0
  151. package/test/snapshots/pfm/generic_directives/109.snap.ast +4 -0
  152. package/test/snapshots/pfm/generic_directives/110.snap.ast +10 -0
  153. package/test/snapshots/pfm/generic_directives/111.snap.ast +7 -0
  154. package/test/snapshots/pfm/generic_directives/112.snap.ast +18 -0
  155. package/test/snapshots/pfm/generic_directives/113.snap.ast +7 -0
  156. package/test/snapshots/pfm/generic_directives/114.snap.ast +12 -0
  157. package/test/snapshots/pfm/generic_directives/115.snap.ast +10 -0
  158. package/test/snapshots/pfm/generic_directives/116.snap.ast +13 -0
  159. package/test/snapshots/pfm/generic_directives/117.snap.ast +9 -0
  160. package/test/snapshots/pfm/generic_directives/118.snap.ast +10 -0
  161. package/test/snapshots/pfm/generic_directives/119.snap.ast +9 -0
  162. package/test/snapshots/pfm/generic_directives/120.snap.ast +12 -0
  163. package/test/snapshots/pfm/generic_directives/121.snap.ast +3 -0
  164. package/test/snapshots/pfm/generic_directives/122.snap.ast +3 -0
  165. package/test/snapshots/pfm/generic_directives/123.snap.ast +3 -0
  166. package/test/snapshots/pfm/hard_line_breaks/642.snap.ast +1 -1
  167. package/test/snapshots/pfm/hard_line_breaks/643.snap.ast +1 -1
  168. package/test/snapshots/pfm/html/148.snap.ast +1 -1
  169. package/test/snapshots/pfm/html/150.snap.ast +1 -1
  170. package/test/snapshots/pfm/html/159.snap.ast +2 -3
  171. package/test/snapshots/pfm/html/162.snap.ast +3 -4
  172. package/test/snapshots/pfm/html/163.snap.ast +1 -1
  173. package/test/snapshots/pfm/html/164.snap.ast +3 -4
  174. package/test/snapshots/pfm/html/166.snap.ast +1 -1
  175. package/test/snapshots/pfm/html/168.snap.ast +2 -3
  176. package/test/snapshots/pfm/html/169.snap.ast +5 -7
  177. package/test/snapshots/pfm/html/174.snap.ast +3 -3
  178. package/test/snapshots/pfm/html/182.snap.ast +1 -1
  179. package/test/snapshots/pfm/html/613.snap.ast +2 -2
  180. package/test/snapshots/pfm/html/615.snap.ast +2 -2
  181. package/test/snapshots/pfm/images/585.snap.ast +1 -1
  182. package/test/snapshots/pfm/images/589.snap.ast +1 -1
  183. package/test/snapshots/pfm/link_reference_definitions/201.snap.ast +1 -1
  184. package/test/snapshots/pfm/link_reference_definitions/208.snap.ast +1 -1
  185. package/test/snapshots/pfm/links/491.snap.ast +1 -1
  186. package/test/snapshots/pfm/links/494.snap.ast +2 -2
  187. package/test/snapshots/pfm/links/516.snap.ast +8 -9
  188. package/test/snapshots/pfm/links/521.snap.ast +1 -1
  189. package/test/snapshots/pfm/links/530.snap.ast +8 -12
  190. package/test/snapshots/pfm/links/534.snap.ast +1 -1
  191. package/test/snapshots/pfm/links/552.snap.ast +2 -2
  192. package/test/snapshots/pfm/links/559.snap.ast +1 -1
  193. package/test/snapshots/pfm/links/564.snap.ast +1 -1
  194. package/test/snapshots/pfm/list_items/260.snap.ast +3 -4
  195. package/test/snapshots/pfm/list_items/293.snap.ast +2 -2
  196. package/test/snapshots/pfm/tabs/16.snap.ast +2 -3
  197. package/test/snapshots/pfm/tabs/4.snap.ast +6 -5
  198. package/test/snapshots/svelte/00-introduction/00-hello-world/App.snap.ast +3 -4
  199. package/test/snapshots/svelte/00-introduction/02-styling/App.snap.ast +2 -3
  200. package/test/snapshots/svelte/00-introduction/03-nested-components/App.snap.ast +2 -3
  201. package/test/snapshots/svelte/00-introduction/03-nested-components/Nested.snap.ast +1 -2
  202. package/test/snapshots/svelte/00-introduction/04-html-tags/App.snap.ast +1 -2
  203. package/test/snapshots/svelte/01-reactivity/00-reactive-assignments/App.snap.ast +5 -6
  204. package/test/snapshots/svelte/01-reactivity/01-reactive-declarations/App.snap.ast +11 -14
  205. package/test/snapshots/svelte/01-reactivity/02-reactive-statements/App.snap.ast +5 -6
  206. package/test/snapshots/svelte/02-props/00-declaring-props/Nested.snap.ast +2 -3
  207. package/test/snapshots/svelte/02-props/01-default-values/App.snap.ast +1 -1
  208. package/test/snapshots/svelte/02-props/01-default-values/Nested.snap.ast +2 -3
  209. package/test/snapshots/svelte/02-props/02-spread-props/Info.snap.ast +16 -17
  210. package/test/snapshots/svelte/03-logic/00-if-blocks/App.snap.ast +4 -8
  211. package/test/snapshots/svelte/03-logic/01-else-blocks/App.snap.ast +4 -8
  212. package/test/snapshots/svelte/03-logic/02-else-if-blocks/App.snap.ast +6 -9
  213. package/test/snapshots/svelte/03-logic/03-each-blocks/App.snap.ast +5 -8
  214. package/test/snapshots/svelte/03-logic/04-keyed-each-blocks/App.snap.ast +4 -7
  215. package/test/snapshots/svelte/03-logic/04-keyed-each-blocks/Thing.snap.ast +4 -5
  216. package/test/snapshots/svelte/04-events/02-event-modifiers/App.snap.ast +2 -3
  217. package/test/snapshots/svelte/04-events/03-component-events/Inner.snap.ast +2 -3
  218. package/test/snapshots/svelte/04-events/04-event-forwarding/Inner.snap.ast +2 -3
  219. package/test/snapshots/svelte/04-events/05-dom-event-forwarding/FancyButton.snap.ast +2 -3
  220. package/test/snapshots/svelte/05-bindings/00-text-inputs/App.snap.ast +3 -4
  221. package/test/snapshots/svelte/05-bindings/01-numeric-inputs/App.snap.ast +9 -8
  222. package/test/snapshots/svelte/05-bindings/02-checkbox-inputs/App.snap.ast +7 -11
  223. package/test/snapshots/svelte/05-bindings/03-group-inputs/App.snap.ast +21 -30
  224. package/test/snapshots/svelte/05-bindings/04-textarea-inputs/App.snap.ast +1 -2
  225. package/test/snapshots/svelte/05-bindings/05-select-bindings/App.snap.ast +5 -9
  226. package/test/snapshots/svelte/05-bindings/06-multiple-select-bindings/App.snap.ast +18 -26
  227. package/test/snapshots/svelte/05-bindings/07-each-block-bindings/App.snap.ast +7 -11
  228. package/test/snapshots/svelte/05-bindings/08-media-elements/App.snap.ast +15 -19
  229. package/test/snapshots/svelte/05-bindings/09-dimensions/App.snap.ast +7 -9
  230. package/test/snapshots/svelte/05-bindings/11-component-bindings/App.snap.ast +1 -2
  231. package/test/snapshots/svelte/05-bindings/11-component-bindings/Keypad.snap.ast +32 -34
  232. package/test/snapshots/svelte/06-lifecycle/00-onmount/App.snap.ast +3 -6
  233. package/test/snapshots/svelte/06-lifecycle/01-ondestroy/App.snap.ast +6 -7
  234. package/test/snapshots/svelte/06-lifecycle/02-update/App.snap.ast +2 -4
  235. package/test/snapshots/svelte/07-stores/00-writable-stores/App.snap.ast +4 -5
  236. package/test/snapshots/svelte/07-stores/00-writable-stores/Decrementer.snap.ast +2 -3
  237. package/test/snapshots/svelte/07-stores/00-writable-stores/Incrementer.snap.ast +2 -3
  238. package/test/snapshots/svelte/07-stores/00-writable-stores/Resetter.snap.ast +2 -3
  239. package/test/snapshots/svelte/07-stores/01-auto-subscriptions/App.snap.ast +4 -5
  240. package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Decrementer.snap.ast +2 -3
  241. package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Incrementer.snap.ast +2 -3
  242. package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Resetter.snap.ast +2 -3
  243. package/test/snapshots/svelte/07-stores/02-readable-stores/App.snap.ast +2 -3
  244. package/test/snapshots/svelte/07-stores/03-derived-stores/App.snap.ast +8 -10
  245. package/test/snapshots/svelte/07-stores/04-custom-stores/App.snap.ast +7 -11
  246. package/test/snapshots/svelte/08-motion/00-tweened/App.snap.ast +10 -15
  247. package/test/snapshots/svelte/08-motion/01-spring/App.snap.ast +10 -10
  248. package/test/snapshots/svelte/09-transitions/00-transition/App.snap.ast +3 -5
  249. package/test/snapshots/svelte/09-transitions/01-adding-parameters-to-transitions/App.snap.ast +3 -5
  250. package/test/snapshots/svelte/09-transitions/02-in-and-out/App.snap.ast +3 -5
  251. package/test/snapshots/svelte/09-transitions/03-custom-css-transitions/App.snap.ast +4 -6
  252. package/test/snapshots/svelte/09-transitions/04-custom-js-transitions/App.snap.ast +3 -5
  253. package/test/snapshots/svelte/09-transitions/05-transition-events/App.snap.ast +5 -8
  254. package/test/snapshots/svelte/10-animations/00-animate/App.snap.ast +16 -20
  255. package/test/snapshots/svelte/11-easing/00-easing/App.snap.ast +16 -11
  256. package/test/snapshots/svelte/11-easing/00-easing/Controls.snap.ast +11 -16
  257. package/test/snapshots/svelte/11-easing/00-easing/Grid.snap.ast +2 -2
  258. package/test/snapshots/svelte/12-svg/01-clock/App.snap.ast +2 -1
  259. package/test/snapshots/svelte/12-svg/02-bar-chart/App.snap.ast +7 -9
  260. package/test/snapshots/svelte/12-svg/03-area-chart/App.snap.ast +14 -15
  261. package/test/snapshots/svelte/12-svg/04-scatterplot/App.snap.ast +7 -5
  262. package/test/snapshots/svelte/12-svg/04-scatterplot/Scatterplot.snap.ast +6 -6
  263. package/test/snapshots/svelte/12-svg/05-svg-transitions/App.snap.ast +5 -6
  264. package/test/snapshots/svelte/13-actions/01-adding-parameters-to-actions/App.snap.ast +2 -3
  265. package/test/snapshots/svelte/14-classes/00-classes/App.snap.ast +3 -6
  266. package/test/snapshots/svelte/14-classes/01-class-shorthand/App.snap.ast +2 -3
  267. package/test/snapshots/svelte/15-composition/00-slots/App.snap.ast +3 -5
  268. package/test/snapshots/svelte/15-composition/01-slot-fallbacks/App.snap.ast +3 -5
  269. package/test/snapshots/svelte/15-composition/01-slot-fallbacks/Box.snap.ast +1 -2
  270. package/test/snapshots/svelte/15-composition/02-named-slots/App.snap.ast +7 -11
  271. package/test/snapshots/svelte/15-composition/02-named-slots/ContactCard.snap.ast +3 -6
  272. package/test/snapshots/svelte/15-composition/03-slot-props/App.snap.ast +9 -15
  273. package/test/snapshots/svelte/15-composition/04-modal/App.snap.ast +17 -26
  274. package/test/snapshots/svelte/15-composition/04-modal/Modal.snap.ast +3 -3
  275. package/test/snapshots/svelte/16-context/00-context-api/App.snap.ast +10 -5
  276. package/test/snapshots/svelte/17-special-elements/00-svelte-self/File.snap.ast +1 -2
  277. package/test/snapshots/svelte/17-special-elements/00-svelte-self/Folder.snap.ast +1 -2
  278. package/test/snapshots/svelte/17-special-elements/01-svelte-component/App.snap.ast +1 -2
  279. package/test/snapshots/svelte/17-special-elements/01-svelte-component/BlueThing.snap.ast +1 -2
  280. package/test/snapshots/svelte/17-special-elements/01-svelte-component/GreenThing.snap.ast +1 -2
  281. package/test/snapshots/svelte/17-special-elements/01-svelte-component/RedThing.snap.ast +1 -2
  282. package/test/snapshots/svelte/17-special-elements/02-svelte-window/App.snap.ast +3 -6
  283. package/test/snapshots/svelte/17-special-elements/03-svelte-window-bindings/App.snap.ast +2 -4
  284. package/test/snapshots/svelte/17-special-elements/05-svelte-head/App.snap.ast +6 -12
  285. package/test/snapshots/svelte/18-module-context/01-module-exports/App.snap.ast +2 -3
  286. package/test/snapshots/svelte/18-module-context/01-module-exports/AudioPlayer.snap.ast +4 -7
  287. package/test/snapshots/svelte/19-debugging/00-debug/App.snap.ast +5 -7
  288. package/test/snapshots/svelte/19-debugging/00-debug/Test.snap.ast +7 -11
  289. package/test/snapshots/svelte/20-7guis/01-7guis-counter/App.snap.ast +2 -3
  290. package/test/snapshots/svelte/20-7guis/02-7guis-temperature/App.snap.ast +2 -2
  291. package/test/snapshots/svelte/20-7guis/03-7guis-flight-booker/App.snap.ast +4 -7
  292. package/test/snapshots/svelte/20-7guis/04-7guis-timer/App.snap.ast +13 -17
  293. package/test/snapshots/svelte/20-7guis/05-7guis-crud/App.snap.ast +11 -13
  294. package/test/snapshots/svelte/20-7guis/06-7guis-circles/App.snap.ast +10 -11
  295. package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Comment.snap.ast +4 -6
  296. package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Item.snap.ast +9 -13
  297. package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/List.snap.ast +3 -5
  298. package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Summary.snap.ast +7 -11
  299. package/test/snapshots/svelte/21-miscellaneous/02-immutable-data/App.snap.ast +2 -4
  300. package/test/snapshots/svelte/99-embeds/20181225-blog-svelte-css-in-js/App.snap.ast +6 -7
  301. package/test/snapshots/svelte/99-embeds/20181225-blog-svelte-css-in-js/Hero.snap.ast +3 -5
  302. package/test/snapshots/svelte/99-embeds/20190420-blog-write-less-code/App.snap.ast +6 -7
  303. package/test/svelte_expressions.spec.ts +93 -4
  304. package/test/svelte_tags.spec.ts +27 -12
  305. package/test/tables.spec.ts +347 -0
  306. package/test/tree_builder.spec.ts +286 -1
  307. package/test/unclosed_delimiters.spec.ts +529 -0
  308. package/tsc/buf_utils.d.ts +1 -1
  309. package/tsc/buf_utils.js +9 -9
  310. package/tsc/cursor.d.ts +17 -13
  311. package/tsc/cursor.js +60 -43
  312. package/tsc/main.d.ts +362 -26
  313. package/tsc/main.js +8955 -4891
  314. package/tsc/node_view.d.ts +11 -12
  315. package/tsc/node_view.js +134 -102
  316. package/tsc/opcodes.d.ts +23 -6
  317. package/tsc/plugin_dispatch.d.ts +22 -8
  318. package/tsc/plugin_dispatch.js +292 -170
  319. package/tsc/tree_builder.d.ts +42 -11
  320. package/tsc/tree_builder.js +237 -82
  321. package/tsc/undo_log.d.ts +11 -1
  322. package/tsc/undo_log.js +54 -19
  323. package/tsc/utils.d.ts +77 -51
  324. package/tsc/utils.js +687 -344
  325. package/tsc/utils.spec.js +83 -9
  326. package/tsc/wire_emitter.js +6 -0
  327. package/tsc/wire_tree_builder.d.ts +4 -7
  328. package/tsc/wire_tree_builder.js +34 -37
  329. package/dist/node_view-BEh2-H86.js +0 -373
@@ -0,0 +1,407 @@
1
+ import { kind_to_string as x, string_to_kind as l, merge_meta as k, make_meta as m } from "./utils.js";
2
+ const o = 4294967295, p = Symbol("ATTR_DID_NOT_EXIST");
3
+ function v(r, t, e) {
4
+ const s = r.prev_at(e), n = r.next_at(e);
5
+ s !== o ? r.set_next(s, n) : r.first_child_at(t) === e && r.set_first_child(t, n !== o && r.parent_at(n) === t ? n : o), n !== o && r.parent_at(n) === t && r.set_prev(n, s), r.last_child_at(t) === e && r.set_last_child(t, s !== o ? s : o), r.set_parent(e, o), r.set_next(e, o), r.set_prev(e, o);
6
+ }
7
+ const g = /* @__PURE__ */ new Map();
8
+ class S {
9
+ constructor() {
10
+ this.logs = g, this.active_node = o, this.kind_changes = null;
11
+ }
12
+ log_kind(t, e) {
13
+ const s = this.kind_changes;
14
+ s === null ? this.kind_changes = [t, e] : s.push(t, e);
15
+ }
16
+ /** called by dispatcher before invoking plugin handlers for a node. */
17
+ set_active_node(t) {
18
+ this.active_node = t;
19
+ }
20
+ /** called by dispatcher after handlers complete. */
21
+ clear_active_node() {
22
+ this.active_node = o;
23
+ }
24
+ /** false while nothing would keep an entry */
25
+ get recording() {
26
+ return this.active_node !== o;
27
+ }
28
+ record_attr_set(t, e, s) {
29
+ this.active_node !== o && this._append({
30
+ kind: 0,
31
+ target: t,
32
+ key: e,
33
+ prior_value: s
34
+ });
35
+ }
36
+ record_attr_delete(t, e, s) {
37
+ this._append({
38
+ kind: 1,
39
+ target: t,
40
+ key: e,
41
+ prior_value: s
42
+ });
43
+ }
44
+ record_type_change(t, e) {
45
+ this.log_kind(t, e), this.active_node !== o && this._append({
46
+ kind: 2,
47
+ target: t,
48
+ prior_kind: e
49
+ });
50
+ }
51
+ record_wrap_inner(t, e, s, n) {
52
+ this._append({
53
+ kind: 3,
54
+ parent: t,
55
+ wrapper: e,
56
+ prior_first_child: s,
57
+ prior_last_child: n
58
+ });
59
+ }
60
+ record_prepend(t, e, s) {
61
+ this._append({
62
+ kind: 4,
63
+ parent: t,
64
+ created: e,
65
+ prior_first_child: s
66
+ });
67
+ }
68
+ record_append(t, e, s) {
69
+ this._append({
70
+ kind: 5,
71
+ parent: t,
72
+ created: e,
73
+ prior_last_child: s
74
+ });
75
+ }
76
+ _append(t) {
77
+ const e = this.active_node;
78
+ if (e === o)
79
+ return;
80
+ let s = this.logs;
81
+ s === g && (s = this.logs = /* @__PURE__ */ new Map());
82
+ let n = s.get(e);
83
+ n === void 0 && (n = [], s.set(e, n)), n.push(t);
84
+ }
85
+ /**
86
+ * revoke all mutations attributed to the given handler node.
87
+ * walks the undo log in reverse order, restoring prior state.
88
+ */
89
+ revoke(t, e) {
90
+ const s = this.logs.get(t);
91
+ if (s !== void 0) {
92
+ for (let n = s.length - 1; n >= 0; n--) {
93
+ const i = s[n];
94
+ switch (i.kind) {
95
+ case 0: {
96
+ const _ = e.metadata_at(i.target);
97
+ _ && (i.prior_value === p ? delete _[i.key] : _[i.key] = i.prior_value, e.set_metadata(i.target, _));
98
+ break;
99
+ }
100
+ case 1: {
101
+ const _ = e.metadata_at(i.target) ?? {};
102
+ _[i.key] = i.prior_value, e.set_metadata(i.target, _);
103
+ break;
104
+ }
105
+ case 2: {
106
+ e.set_kind(i.target, i.prior_kind);
107
+ break;
108
+ }
109
+ case 3: {
110
+ i.parent;
111
+ const _ = i.wrapper;
112
+ e.unwrap_node(_), e.set_parent(_, o);
113
+ break;
114
+ }
115
+ case 4:
116
+ case 5: {
117
+ const _ = i.parent, a = i.created;
118
+ v(e, _, a);
119
+ break;
120
+ }
121
+ }
122
+ }
123
+ this.logs.delete(t);
124
+ }
125
+ }
126
+ /**
127
+ * commit a node, discard its undo log, making mutations permanent.
128
+ */
129
+ commit(t) {
130
+ this.logs.size !== 0 && this.logs.delete(t);
131
+ }
132
+ /** true when no node holds a mutation that a revoke would undo */
133
+ get empty() {
134
+ return this.logs.size === 0;
135
+ }
136
+ /** check whether a node has any recorded mutations. */
137
+ has(t) {
138
+ return this.logs.has(t);
139
+ }
140
+ /** get undo entries for a node (for redirect detection). */
141
+ get_entries(t) {
142
+ if (this.logs.size !== 0)
143
+ return this.logs.get(t);
144
+ }
145
+ /** discard all logs. */
146
+ clear() {
147
+ this.logs.clear(), this.kind_changes = null, this.active_node = o;
148
+ }
149
+ }
150
+ const d = 4294967295;
151
+ class N {
152
+ constructor(t) {
153
+ this.source = t;
154
+ }
155
+ slice(t, e) {
156
+ return this.source.slice(t, e);
157
+ }
158
+ get_string(t) {
159
+ }
160
+ /** update source for incremental parsing. */
161
+ set_source(t) {
162
+ this.source = t;
163
+ }
164
+ }
165
+ class O {
166
+ constructor(t) {
167
+ this.strings = t;
168
+ }
169
+ slice(t, e) {
170
+ return "";
171
+ }
172
+ get_string(t) {
173
+ return this.strings[t];
174
+ }
175
+ }
176
+ class D {
177
+ constructor(t, e, s) {
178
+ this.first = null, this.views = null, this.buf = t, this.text_source = e, this.undo = s;
179
+ }
180
+ /** get or create a NodeView for the given buffer index. */
181
+ get(t) {
182
+ if (t === d)
183
+ return null;
184
+ const e = this.first;
185
+ if (e === null)
186
+ return this.first = this.make(t);
187
+ if (e._index === t)
188
+ return e;
189
+ let s = this.views;
190
+ s === null && (s = this.views = /* @__PURE__ */ new Map());
191
+ let n = s.get(t);
192
+ return n === void 0 && (n = this.make(t), s.set(t, n)), n;
193
+ }
194
+ make(t) {
195
+ return new y(t, this.buf, this.text_source, this, this.undo);
196
+ }
197
+ /** discard all cached views. */
198
+ clear() {
199
+ this.first = null, this.views !== null && this.views.clear();
200
+ }
201
+ /** views made from here on read this buffer and text source */
202
+ rebind(t, e) {
203
+ this.buf = t, this.text_source = e;
204
+ }
205
+ }
206
+ const h = Symbol("buf"), u = Symbol("idx"), f = Symbol("undo");
207
+ class w {
208
+ constructor(t, e, s) {
209
+ this[h] = t, this[u] = e, this[f] = s;
210
+ }
211
+ }
212
+ const b = {
213
+ get(r, t) {
214
+ const e = r[h].metadata_at(r[u]);
215
+ return e ? e[t] : void 0;
216
+ },
217
+ set(r, t, e) {
218
+ const s = r[h], n = r[u], i = s.metadata_at(n), _ = r[f];
219
+ if (_.recording) {
220
+ const a = i && t in i ? i[t] : p;
221
+ _.record_attr_set(n, t, a);
222
+ }
223
+ return i ? k(i, t, e) : s.set_metadata(n, m(t, e)), !0;
224
+ },
225
+ deleteProperty(r, t) {
226
+ const e = r[h], s = r[u], n = e.metadata_at(s);
227
+ if (!n || !(t in n))
228
+ return !0;
229
+ const i = n[t];
230
+ return r[f].record_attr_delete(s, t, i), delete n[t], e.set_metadata(s, n), !0;
231
+ },
232
+ has(r, t) {
233
+ const e = r[h].metadata_at(r[u]);
234
+ return e ? t in e : !1;
235
+ },
236
+ ownKeys(r) {
237
+ const t = r[h].metadata_at(r[u]);
238
+ return t ? Object.keys(t) : [];
239
+ },
240
+ getOwnPropertyDescriptor(r, t) {
241
+ const e = r[h].metadata_at(r[u]);
242
+ if (e && t in e)
243
+ return {
244
+ configurable: !0,
245
+ enumerable: !0,
246
+ value: e[t]
247
+ };
248
+ }
249
+ };
250
+ class y {
251
+ constructor(t, e, s, n, i) {
252
+ this._attrs = null, this._index = t, this._buf = e, this._text_source = s, this._cache = n, this._undo = i;
253
+ }
254
+ get type() {
255
+ return x(this._buf.kind_at(this._index));
256
+ }
257
+ set type(t) {
258
+ const e = l(t);
259
+ if (e === void 0)
260
+ return;
261
+ const s = this._buf.kind_at(this._index);
262
+ this._undo.record_type_change(this._index, s), this._buf.set_kind(this._index, e);
263
+ }
264
+ get parent() {
265
+ return this._cache.get(this._buf.parent_at(this._index));
266
+ }
267
+ get first_child() {
268
+ return this._cache.get(this._buf.first_child_at(this._index));
269
+ }
270
+ get last_child() {
271
+ return this._cache.get(this._buf.last_child_at(this._index));
272
+ }
273
+ get next() {
274
+ const t = this._buf.next_at(this._index);
275
+ return t === d || this._buf.parent_at(t) !== this._buf.parent_at(this._index) ? null : this._cache.get(t);
276
+ }
277
+ get prev() {
278
+ const t = this._buf.prev_at(this._index);
279
+ return t === d ? null : this._cache.get(t);
280
+ }
281
+ /**
282
+ * flattened text of all descendants.
283
+ * only guaranteed complete in the close callback.
284
+ */
285
+ get text_content() {
286
+ return this._collect_text(this._index);
287
+ }
288
+ _collect_text(t) {
289
+ const e = this._buf, s = e.kind_at(t);
290
+ if (s === 1) {
291
+ const _ = this._text_source.get_string(t);
292
+ if (_ !== void 0)
293
+ return _;
294
+ const a = e.value_start_at(t), c = e.value_end_at(t);
295
+ return a === d || c === d || c <= a ? "" : this._text_source.slice(a, c);
296
+ }
297
+ if (s === 5 || s === 8 || s === 26) {
298
+ const _ = this._text_source.get_string(t);
299
+ if (_ !== void 0)
300
+ return _;
301
+ const a = e.value_start_at(t), c = e.value_end_at(t);
302
+ return a === d || c === d || c <= a ? "" : this._text_source.slice(a, c);
303
+ }
304
+ if (s === 3) {
305
+ const _ = this._text_source.get_string(t);
306
+ if (_ !== void 0)
307
+ return _;
308
+ const a = e.value_start_at(t), c = e.value_end_at(t);
309
+ if (a !== d && c !== d && c > a)
310
+ return this._text_source.slice(a, c);
311
+ }
312
+ let n = "", i = e.first_child_at(t);
313
+ for (; i !== d && e.parent_at(i) === t; )
314
+ n += this._collect_text(i), i = e.next_at(i);
315
+ return n;
316
+ }
317
+ /** heading depth (1-6). only meaningful when type === 'heading'. */
318
+ get depth() {
319
+ if (this._buf.kind_at(this._index) === 3)
320
+ return this._buf.extra_at(this._index);
321
+ }
322
+ /** code block language/info string. */
323
+ get lang() {
324
+ if (this._buf.kind_at(this._index) !== 5)
325
+ return;
326
+ const e = this._buf.metadata_at(this._index);
327
+ if (e) {
328
+ if (e.info)
329
+ return e.info;
330
+ if (e.info_start != null && e.info_end != null)
331
+ return this._text_source.slice(e.info_start, e.info_end);
332
+ }
333
+ }
334
+ /** link/image href. */
335
+ get href() {
336
+ const t = this._buf.metadata_at(this._index);
337
+ return t == null ? void 0 : t.href;
338
+ }
339
+ /** link/image title. */
340
+ get title() {
341
+ const t = this._buf.metadata_at(this._index);
342
+ return t == null ? void 0 : t.title;
343
+ }
344
+ /** list: ordered flag. */
345
+ get ordered() {
346
+ const t = this._buf.metadata_at(this._index);
347
+ return t == null ? void 0 : t.ordered;
348
+ }
349
+ /** list: start number. */
350
+ get start() {
351
+ const t = this._buf.metadata_at(this._index);
352
+ return t == null ? void 0 : t.start;
353
+ }
354
+ /** list: tight flag. */
355
+ get tight() {
356
+ const t = this._buf.metadata_at(this._index);
357
+ return t == null ? void 0 : t.tight;
358
+ }
359
+ get attrs() {
360
+ return this._attrs !== null ? this._attrs : this._attrs = new Proxy(new w(this._buf, this._index, this._undo), b);
361
+ }
362
+ /**
363
+ * insert a new node between this node and its current children.
364
+ * all current children become children of the new wrapper.
365
+ * returns a view for the new wrapper node.
366
+ */
367
+ wrap_inner(t, e) {
368
+ const s = l(t);
369
+ if (s === void 0)
370
+ throw new Error(`Unknown node type: ${t}`);
371
+ const n = this._buf, i = this._index, _ = n.first_child_at(i), a = n.last_child_at(i), c = n.wrap_children(i, s, 0, e);
372
+ return this._undo.record_wrap_inner(i, c, _, a), this._cache.get(c);
373
+ }
374
+ /**
375
+ * insert a new node as the first child of this node.
376
+ * returns a view for the new node.
377
+ */
378
+ prepend(t, e) {
379
+ const s = l(t);
380
+ if (s === void 0)
381
+ throw new Error(`Unknown node type: ${t}`);
382
+ const n = this._buf, i = this._index, _ = n.first_child_at(i);
383
+ if (_ === d) {
384
+ const c = n.push(s, 0, i, 0, e);
385
+ return this._undo.record_prepend(i, c, _), this._cache.get(c);
386
+ }
387
+ const a = n.push_unlinked(s, 0, 0, e);
388
+ return n.set_parent(a, i), n.set_next(a, _), n.set_prev(_, a), n.set_first_child(i, a), this._undo.record_prepend(i, a, _), this._cache.get(a);
389
+ }
390
+ /**
391
+ * insert a new node as the last child of this node.
392
+ * returns a view for the new node.
393
+ */
394
+ append(t, e) {
395
+ const s = l(t);
396
+ if (s === void 0)
397
+ throw new Error(`Unknown node type: ${t}`);
398
+ const n = this._buf, i = this._index, _ = n.last_child_at(i), a = n.push(s, 0, i, 0, e);
399
+ return this._undo.record_append(i, a, _), this._cache.get(a);
400
+ }
401
+ }
402
+ export {
403
+ N as S,
404
+ S as U,
405
+ D as V,
406
+ O as W
407
+ };
@@ -1,5 +1,5 @@
1
- import { type NodeBuffer } from "./utils";
2
- import { type UndoLog } from "./undo_log";
1
+ import { type NodeBuffer } from './utils';
2
+ import { type UndoLog } from './undo_log';
3
3
  /**
4
4
  * abstracts text resolution between batch mode (source string slicing)
5
5
  * and wire mode (pre-materialized _strings).
@@ -30,24 +30,25 @@ export declare class WireTextSource implements TextSource {
30
30
  * short-lived: created before handler invocation, cleared after.
31
31
  */
32
32
  export declare class ViewCache {
33
+ private first;
33
34
  private views;
34
35
  private buf;
35
36
  private text_source;
36
37
  private undo;
37
- private handler_node;
38
- constructor(buf: NodeBuffer, text_source: TextSource, undo: UndoLog, handler_node: number);
38
+ constructor(buf: NodeBuffer, text_source: TextSource, undo: UndoLog);
39
39
  /** get or create a NodeView for the given buffer index. */
40
40
  get(index: number): NodeView | null;
41
+ private make;
41
42
  /** discard all cached views. */
42
43
  clear(): void;
43
- /** update the handler node (for re-use across dispatches). */
44
- set_handler_node(handler_node: number): void;
44
+ /** views made from here on read this buffer and text source */
45
+ rebind(buf: NodeBuffer, text_source: TextSource): void;
45
46
  }
46
47
  /**
47
- * a view over a single node in the SoA backing store.
48
+ * a view over a single node in the NodeBuffer.
48
49
  *
49
50
  * reads are getters that look up the current state of the node
50
- * in the soa. writes are setters that update the backing store
51
+ * in the buffer. writes are setters that update the backing store
51
52
  * and record in the undo log for revocation.
52
53
  *
53
54
  * plugin handlers receive node views and interact with the tree
@@ -56,7 +57,7 @@ export declare class ViewCache {
56
57
  export declare class NodeView {
57
58
  /** @internal buffer index of this node. */
58
59
  readonly _index: number;
59
- /** @internal the backing soa buffer. */
60
+ /** @internal */
60
61
  private _buf;
61
62
  /** @internal text resolution strategy. */
62
63
  private _text_source;
@@ -64,11 +65,9 @@ export declare class NodeView {
64
65
  private _cache;
65
66
  /** @internal undo log for recording mutations. */
66
67
  private _undo;
67
- /** @internal which handler node's undo log to attribute mutations to. */
68
- private _handler_node;
69
68
  /** lazily created attrs proxy. */
70
69
  private _attrs;
71
- constructor(index: number, buf: NodeBuffer, text_source: TextSource, cache: ViewCache, undo: UndoLog, handler_node: number);
70
+ constructor(index: number, buf: NodeBuffer, text_source: TextSource, cache: ViewCache, undo: UndoLog);
72
71
  get type(): string;
73
72
  set type(value: string);
74
73
  get parent(): NodeView | null;
package/dist/opcodes.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { NodeKind } from "./utils";
1
+ import type { NodeKind } from './utils';
2
2
  /**
3
3
  * emitter interface for pfm parser opcodes.
4
4
  *
@@ -10,6 +10,9 @@ import type { NodeKind } from "./utils";
10
10
  export interface Emitter {
11
11
  /**
12
12
  * open a new node.
13
+ *
14
+ * ids are dense from root 0, each open and each text that creates a child
15
+ * node takes the next id, so a builder can use ids as slot indices
13
16
  * @param id monotonic node id (unique within this parse).
14
17
  * @param kind node kind (heading, paragraph, emphasis, etc.).
15
18
  * @param start source byte offset where this node starts.
@@ -22,17 +25,27 @@ export interface Emitter {
22
25
  * close a previously opened node. implicitly commits pending nodes.
23
26
  * @param id id of the node to close.
24
27
  * @param end source byte offset where this node ends.
28
+ * @param kind kind at open, a revoke may have rewritten it since, omitting
29
+ * it makes the builder track revokes
25
30
  */
26
- close(id: number, end: number): void;
31
+ close(id: number, end: number, kind?: NodeKind): void;
27
32
  /**
28
33
  * emit leaf text content within a node.
29
- * for paragraphs/emphasis/links: creates a child text node.
30
- * for headings/code_fences/code_spans: sets the node's value range.
34
+ * paragraphs, emphasis, links and table cells get a child text node, which
35
+ * takes the next id although no open names it
36
+ * headings, code fences, code spans and html comments get a value range and
37
+ * take no id
31
38
  * @param parent id of the parent node.
32
39
  * @param start source byte offset of text start.
33
40
  * @param end source byte offset of text end.
41
+ * @param parent_kind parent kind at open, as for close
34
42
  */
35
- text(parent: number, start: number, end: number): void;
43
+ text(parent: number, start: number, end: number, parent_kind?: NodeKind): void;
44
+ /**
45
+ * open, set_value_start, set_value_end and close of a node with no extra in
46
+ * one call, when it is missing the parser emits those four opcodes
47
+ */
48
+ leaf?(id: number, kind: NodeKind, start: number, parent: number, value_start: number, value_end: number, end: number): void;
36
49
  /**
37
50
  * set or update an attribute on a node.
38
51
  * used for metadata (href, title, info), value ranges, and list properties.
@@ -54,8 +67,10 @@ export interface Emitter {
54
67
  * @param source_text optional raw source text for the revoked node.
55
68
  * used for block-level revocations where the content must be
56
69
  * reconstructed (e.g. failed html tags becoming paragraph text).
70
+ * @param text_start source offset of source_text, at the node start a tree
71
+ * that reads the source need not keep source_text
57
72
  */
58
- revoke(id: number, source_text?: string): void;
73
+ revoke(id: number, source_text?: string, text_start?: number): void;
59
74
  /**
60
75
  * clear the pending flag on a node without touching its structure.
61
76
  * used for tight-list speculation: paragraphs inside list_items are
@@ -72,4 +87,6 @@ export interface Emitter {
72
87
  * @param pos current byte offset in the source.
73
88
  */
74
89
  cursor(pos: number): void;
90
+ /** the incremental finish emitted the last opcode, reserved storage can go */
91
+ end?(): void;
75
92
  }
@@ -1,6 +1,6 @@
1
- import { type NodeBuffer, NodeKind } from "./utils";
2
- import { type TextSource } from "./node_view";
3
- import type { ParsePlugin, IdRegister } from "./plugin_types";
1
+ import { type NodeBuffer, NodeKind } from './utils';
2
+ import { type TextSource } from './node_view';
3
+ import type { ParsePlugin } from './plugin_types';
4
4
  /**
5
5
  * orchestrates plugin dispatch for both TreeBuilder and WireTreeBuilder.
6
6
  *
@@ -21,15 +21,29 @@ export declare class PluginDispatcher {
21
21
  */
22
22
  private redirects;
23
23
  private next_synthetic_id;
24
+ /** one cache serves every dispatch, a view only holds an index */
25
+ private cache;
26
+ /**
27
+ * 1 for each kind whose open needs the dispatcher, every kind once a redirect
28
+ * exists, redirects only start in dispatch_open so builders reread it after one
29
+ */
30
+ open_wants: Uint8Array;
24
31
  constructor(plugins: ParsePlugin[], text_source: TextSource);
32
+ /** cleared since a callback view may have filled it after the last dispatch */
33
+ private views;
34
+ /** buffer index and prior kind of each kind rewrite, see UndoLog */
35
+ kind_log(): number[] | null;
36
+ /** a kind rewrite outside the plugins, such as a revoke repair */
37
+ log_kind(buf_idx: number, prior_kind: number): void;
38
+ /** an open of this kind needs a handler call or a redirect lookup */
39
+ wants_open(kind: NodeKind): boolean;
40
+ /** a close needs no dispatch */
41
+ quiet(): boolean;
25
42
  /** check whether any fused handlers exist for this kind. */
26
43
  has_handlers(kind: NodeKind): boolean;
27
44
  /** check if a parent index has a redirect (wrap_inner). */
28
45
  get_redirect(parent_idx: number): number | undefined;
29
- /** register a wrap_inner redirect. */
30
- set_redirect(parent_idx: number, wrapper_idx: number): void;
31
- /** clear a redirect (on parent close). */
32
- clear_redirect(parent_idx: number): void;
46
+ private own_redirects;
33
47
  /** allocate a new synthetic node id. */
34
48
  allocate_synthetic_id(): number;
35
49
  /** update text source (for incremental parsing). */
@@ -38,7 +52,7 @@ export declare class PluginDispatcher {
38
52
  * dispatch fused plugin handlers on node open.
39
53
  * creates a ViewCache, runs handlers, stores close callbacks.
40
54
  */
41
- dispatch_open(buf_idx: number, kind: NodeKind, buf: NodeBuffer, id_register: IdRegister): void;
55
+ dispatch_open(buf_idx: number, kind: NodeKind, buf: NodeBuffer): void;
42
56
  /**
43
57
  * dispatch close callbacks for a node.
44
58
  * fires callbacks with undo attribution.