@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
package/dist/utils.js CHANGED
@@ -1,11 +1,61 @@
1
- function b(c) {
2
- let s = 1;
3
- for (; s < c; )
4
- s <<= 1;
5
- return s;
1
+ const U = new Uint32Array(0), S = Object.freeze([]), k = 12 * 4, v = [], T = globalThis.Buffer, O = T !== void 0 && typeof T.allocUnsafeSlow == "function";
2
+ function C(n) {
3
+ return O ? T.allocUnsafeSlow(n).buffer : new ArrayBuffer(n);
6
4
  }
7
- const v = (c) => {
8
- switch (c) {
5
+ const y = 512;
6
+ function z(n, t, s) {
7
+ const e = s - t <= 64 ? s : t + 64;
8
+ for (let i = t * 12; i < e * 12; )
9
+ n[
10
+ i + 2
11
+ /* NodeField.end */
12
+ ] = 4294967295, n[
13
+ i + 3
14
+ /* NodeField.value_start */
15
+ ] = 0, n[
16
+ i + 4
17
+ /* NodeField.value_end */
18
+ ] = 0, n[
19
+ i + 6
20
+ /* NodeField.next */
21
+ ] = 4294967295, n[
22
+ i + 7
23
+ /* NodeField.prev */
24
+ ] = 4294967295, n[
25
+ i + 8
26
+ /* NodeField.first_child */
27
+ ] = 4294967295, n[
28
+ i + 9
29
+ /* NodeField.last_child */
30
+ ] = 4294967295, n[
31
+ i + 10
32
+ /* NodeField.pending */
33
+ ] = 0, n[
34
+ i + 11
35
+ /* NodeField.meta */
36
+ ] = 0, i += 12;
37
+ let f = e;
38
+ for (; f < s; ) {
39
+ let i = f - t;
40
+ i > y && (i = y), i > s - f && (i = s - f), n.copyWithin(
41
+ f * 12,
42
+ t * 12,
43
+ (t + i) * 12
44
+ /* NodeField.stride */
45
+ ), f += i;
46
+ }
47
+ }
48
+ const I = 1048576 / k | 0, L = 4096;
49
+ let x = new ArrayBuffer(0), w = 1048576, E = null;
50
+ const M = 32;
51
+ function m(n) {
52
+ let t = 1;
53
+ for (; t < n; )
54
+ t <<= 1;
55
+ return t;
56
+ }
57
+ const N = (n) => {
58
+ switch (n) {
9
59
  case 0:
10
60
  return "root";
11
61
  case 1:
@@ -76,56 +126,311 @@ const v = (c) => {
76
126
  return "frontmatter";
77
127
  case 34:
78
128
  return "import_statement";
79
- }
80
- }, w = /* @__PURE__ */ new Map();
81
- for (let c = 0; c <= 34; c++)
82
- w.set(v(c), c);
83
- const y = (c) => w.get(c), x = (c) => {
84
- switch (c) {
129
+ case 35:
130
+ return "directive_label";
131
+ }
132
+ }, Y = /* @__PURE__ */ new Map();
133
+ for (let n = 0; n <= 35; n++)
134
+ Y.set(N(n), n);
135
+ const P = (n) => Y.get(n), D = (n) => {
136
+ switch (n) {
85
137
  case 3:
86
138
  return "depth";
87
139
  }
88
140
  };
89
- class A {
90
- /**
91
- * create a buffer that stores token metadata with typed arrays.
92
- * @param initial_capacity requested starting capacity for tokens.
93
- */
94
- constructor(s = 128) {
95
- const t = b(s);
96
- this.capacity = t, this._kinds = new Uint8Array(t), this._starts = new Uint32Array(t), this._ends = new Uint32Array(t), this._extras = new Uint16Array(t), this._value_starts = new Uint32Array(t), this._value_ends = new Uint32Array(t), this.has_metadata = new Uint8Array(Math.max(1, t >> 3)), this.metadata = /* @__PURE__ */ new Map(), this._strings = [], this._parents = new Uint32Array(t), this._next_siblings = new Uint32Array(t), this._prev_siblings = new Uint32Array(t), this._children_starts = new Uint32Array(t), this._children_ends = new Uint32Array(t), this._pending_nodes = new Uint32Array(t), this._size = 0, this.push(0, 0);
141
+ function R(n, t) {
142
+ switch (n) {
143
+ case "tag":
144
+ return { tag: t };
145
+ case "href":
146
+ return { href: t };
147
+ case "src":
148
+ return { src: t };
149
+ case "ordered":
150
+ return { ordered: t };
151
+ case "info_start":
152
+ return { info_start: t };
153
+ case "name":
154
+ return { name: t };
155
+ case "alignments":
156
+ return { alignments: t };
157
+ case "attributes":
158
+ return { attributes: t };
159
+ case "self_closing":
160
+ return { self_closing: t };
161
+ case "title":
162
+ return { title: t };
163
+ case "start":
164
+ return { start: t };
165
+ case "tight":
166
+ return { tight: t };
167
+ case "info_end":
168
+ return { info_end: t };
169
+ case "args":
170
+ return { args: t };
171
+ case "col_count":
172
+ return { col_count: t };
173
+ default: {
174
+ if (n === "__proto__")
175
+ return { [n]: t };
176
+ const s = {};
177
+ return s[n] = t, s;
178
+ }
179
+ }
180
+ }
181
+ function F(n, t, s) {
182
+ switch (t) {
183
+ case "attributes":
184
+ n.attributes = s;
185
+ return;
186
+ case "start":
187
+ n.start = s;
188
+ return;
189
+ case "tight":
190
+ n.tight = s;
191
+ return;
192
+ case "title":
193
+ n.title = s;
194
+ return;
195
+ case "self_closing":
196
+ n.self_closing = s;
197
+ return;
198
+ case "info_end":
199
+ n.info_end = s;
200
+ return;
201
+ case "col_count":
202
+ n.col_count = s;
203
+ return;
204
+ case "args":
205
+ n.args = s;
206
+ return;
207
+ case "tag":
208
+ n.tag = s;
209
+ return;
210
+ case "href":
211
+ n.href = s;
212
+ return;
213
+ case "src":
214
+ n.src = s;
215
+ return;
216
+ case "ordered":
217
+ n.ordered = s;
218
+ return;
219
+ case "info_start":
220
+ n.info_start = s;
221
+ return;
222
+ case "name":
223
+ n.name = s;
224
+ return;
225
+ case "alignments":
226
+ n.alignments = s;
227
+ return;
228
+ default:
229
+ n[t] = s;
97
230
  }
98
- /** clear previously pushed tokens without reallocating storage. */
231
+ }
232
+ class K {
233
+ constructor(t = 128) {
234
+ this._capacity = 0, this._n = U, this._meta = S, this._strings = v, this._size = 0, this._filled = 0;
235
+ let s = this.alloc(m(t > 32 ? t : 32));
236
+ this._filled === 0 && (s = this.fill(0)), s[0] = 0, s[
237
+ 1
238
+ /* NodeField.start */
239
+ ] = 0, s[
240
+ 5
241
+ /* NodeField.parent */
242
+ ] = 4294967295, this._size = 1;
243
+ }
244
+ alloc(t) {
245
+ const s = t * k;
246
+ let e, f = 0;
247
+ s <= 262144 ? (w + s > 1048576 && (x = C(1048576), w = 0, z(new Uint32Array(x), 0, I)), e = x, f = w, w = f + s) : e = C(s);
248
+ const i = new Uint32Array(
249
+ e,
250
+ f,
251
+ t * 12
252
+ /* NodeField.stride */
253
+ );
254
+ return e === x ? (E = i, this._filled = t) : this._filled = 0, this._capacity = t, this._n = i, i;
255
+ }
256
+ /** @internal */
257
+ own_strings() {
258
+ const t = this._strings;
259
+ return t === v ? this._strings = [] : t;
260
+ }
261
+ /** gives the unused tail of the last slab carve back, a later push resizes */
262
+ trim() {
263
+ this._n === E && (w -= (this._capacity - this._size) * k, this._capacity = this._size, this._filled = this._size);
264
+ }
265
+ /** clear nodes without reallocating storage */
99
266
  reset() {
100
- this._size = 0;
267
+ this._meta.length !== 0 && (this._meta.length = 0), this._strings.length !== 0 && (this._strings.length = 0);
268
+ const t = this._size;
269
+ if (t !== 0) {
270
+ if (t > 8 && t << 1 <= this._filled) {
271
+ const s = this._n;
272
+ for (let e = 0; e < t; ) {
273
+ let f = t - e;
274
+ f > y && (f = y), s.copyWithin(
275
+ e * 12,
276
+ t * 12,
277
+ (t + f) * 12
278
+ /* NodeField.stride */
279
+ ), e += f;
280
+ }
281
+ } else
282
+ z(this._n, 0, t);
283
+ this._size = 0;
284
+ }
101
285
  }
102
- /** number of tokens currently stored. */
103
286
  get size() {
104
287
  return this._size;
105
288
  }
106
289
  /**
107
- * push a token descriptor into the buffer.
108
- * @param kind token category.
290
+ * push a node as the last child of parent
291
+ * @param kind node category.
109
292
  * @param cursor cursor position
110
- * @param parent index of the parent node, or -1 for root.
111
- * @param extra extra metadata stored alongside the token.
293
+ * @param parent index of the parent node, or 0xffffffff for none.
294
+ * @param extra extra metadata stored alongside the node.
112
295
  * @param metadata optional metadata associated with the node.
113
296
  */
114
- push(s, t, i = 4294967295, _ = 0, e) {
115
- const f = this._size;
116
- if (f >= this.capacity && this.grow(), this._kinds[f] = s, this._starts[f] = t >>> 0, this._ends[f] = 4294967295, this._extras[f] = _ & 65535, this._size = f + 1, this._parents[f] = i, this._next_siblings[f] = 4294967295, this._prev_siblings[f] = 4294967295, this._children_starts[f] = 4294967295, this._children_ends[f] = 4294967295, i !== 4294967295) {
117
- const n = this._children_ends[i];
118
- n === 4294967295 ? this._children_starts[i] = f : (this._next_siblings[n] = f, this._prev_siblings[f] = n), this._children_ends[i] = f;
297
+ push(t, s, e = 4294967295, f = 0, i) {
298
+ const _ = this.push_node(t, s, e, f, !1);
299
+ return i !== void 0 && this.set_metadata(_, i), _;
300
+ }
301
+ push_pending(t, s, e = 4294967295, f = 0, i) {
302
+ const _ = this.push_node(t, s, e, f, !0);
303
+ return i !== void 0 && this.set_metadata(_, i), _;
304
+ }
305
+ /** one body for every open so the builder inlines a single copy */
306
+ push_node(t, s, e, f, i) {
307
+ const _ = this._size;
308
+ let r = this._n;
309
+ _ >= this._filled && (r = this.fill(_));
310
+ const h = _ * 12;
311
+ if (r[h] = t & 255 | (f & 65535) << 8, r[
312
+ h + 1
313
+ /* NodeField.start */
314
+ ] = s, r[
315
+ h + 5
316
+ /* NodeField.parent */
317
+ ] = e, i && (r[
318
+ h + 10
319
+ /* NodeField.pending */
320
+ ] = 1), this._size = _ + 1, e !== 4294967295) {
321
+ const a = e * 12, p = r[
322
+ a + 9
323
+ /* NodeField.last_child */
324
+ ];
325
+ p === 4294967295 ? r[
326
+ a + 8
327
+ /* NodeField.first_child */
328
+ ] = _ : (r[
329
+ p * 12 + 6
330
+ /* NodeField.next */
331
+ ] = _, r[
332
+ h + 7
333
+ /* NodeField.prev */
334
+ ] = p), r[
335
+ a + 9
336
+ /* NodeField.last_child */
337
+ ] = _;
119
338
  }
120
- return e !== void 0 && (this.metadata.set(f, e), this.has_metadata[f >> 3] |= 1 << (f & 7)), f;
339
+ return _;
121
340
  }
122
- push_pending(s, t, i = 4294967295, _ = 0, e) {
123
- const f = this.push(s, t, i, _, e);
124
- return this._pending_nodes[f] = 1, f;
341
+ /** parent must be a node, not 0xffffffff */
342
+ push_text(t, s, e) {
343
+ const f = this._size;
344
+ let i = this._n;
345
+ f >= this._filled && (i = this.fill(f));
346
+ const _ = f * 12;
347
+ i[_] = 1, i[
348
+ _ + 1
349
+ /* NodeField.start */
350
+ ] = t, i[
351
+ _ + 2
352
+ /* NodeField.end */
353
+ ] = s, i[
354
+ _ + 3
355
+ /* NodeField.value_start */
356
+ ] = t, i[
357
+ _ + 4
358
+ /* NodeField.value_end */
359
+ ] = s, i[
360
+ _ + 5
361
+ /* NodeField.parent */
362
+ ] = e, this._size = f + 1;
363
+ const r = e * 12, h = i[
364
+ r + 9
365
+ /* NodeField.last_child */
366
+ ];
367
+ return h === 4294967295 ? i[
368
+ r + 8
369
+ /* NodeField.first_child */
370
+ ] = f : (i[
371
+ h * 12 + 6
372
+ /* NodeField.next */
373
+ ] = f, i[
374
+ _ + 7
375
+ /* NodeField.prev */
376
+ ] = h), i[
377
+ r + 9
378
+ /* NodeField.last_child */
379
+ ] = f, f;
380
+ }
381
+ /** a closed node with no extra and a value range, as open, value and close would leave it */
382
+ push_leaf(t, s, e, f, i, _) {
383
+ const r = this._size;
384
+ let h = this._n;
385
+ r >= this._filled && (h = this.fill(r));
386
+ const a = r * 12;
387
+ h[a] = t, h[
388
+ a + 1
389
+ /* NodeField.start */
390
+ ] = s, h[
391
+ a + 2
392
+ /* NodeField.end */
393
+ ] = i, h[
394
+ a + 3
395
+ /* NodeField.value_start */
396
+ ] = e, h[
397
+ a + 4
398
+ /* NodeField.value_end */
399
+ ] = f, h[
400
+ a + 5
401
+ /* NodeField.parent */
402
+ ] = _, this._size = r + 1;
403
+ const p = _ * 12, A = h[
404
+ p + 9
405
+ /* NodeField.last_child */
406
+ ];
407
+ return A === 4294967295 ? h[
408
+ p + 8
409
+ /* NodeField.first_child */
410
+ ] = r : (h[
411
+ A * 12 + 6
412
+ /* NodeField.next */
413
+ ] = r, h[
414
+ a + 7
415
+ /* NodeField.prev */
416
+ ] = A), h[
417
+ p + 9
418
+ /* NodeField.last_child */
419
+ ] = r, r;
420
+ }
421
+ fill(t) {
422
+ let s = this._n;
423
+ t >= this._capacity && (s = this.grow());
424
+ let e = this._filled;
425
+ if (t >= e) {
426
+ let f = e + (e > L ? e : L);
427
+ f > this._capacity && (f = this._capacity), z(s, e, f), this._filled = e = f;
428
+ }
429
+ return s;
125
430
  }
126
431
  /**
127
432
  * allocate a node slot without linking it into any parent's child list.
128
- * the caller is responsible for setting _parents and linking into the
433
+ * the caller is responsible for setting the parent and linking into the
129
434
  * sibling chain manually. used by plugin structural mutations (prepend).
130
435
  * @param kind node kind.
131
436
  * @param cursor source position.
@@ -133,9 +438,8 @@ class A {
133
438
  * @param metadata optional metadata.
134
439
  * @returns buffer index of the new node.
135
440
  */
136
- push_unlinked(s, t, i = 0, _) {
137
- const e = this._size;
138
- return e >= this.capacity && this.grow(), this._kinds[e] = s, this._starts[e] = t >>> 0, this._ends[e] = 4294967295, this._extras[e] = i & 65535, this._size = e + 1, this._parents[e] = 4294967295, this._next_siblings[e] = 4294967295, this._prev_siblings[e] = 4294967295, this._children_starts[e] = 4294967295, this._children_ends[e] = 4294967295, _ !== void 0 && (this.metadata.set(e, _), this.has_metadata[e >> 3] |= 1 << (e & 7)), e;
441
+ push_unlinked(t, s, e = 0, f) {
442
+ return this.push(t, s, 4294967295, e, f);
139
443
  }
140
444
  /**
141
445
  * insert a new wrapper node between a parent and all its current children.
@@ -148,26 +452,32 @@ class A {
148
452
  * @param metadata optional metadata for the wrapper.
149
453
  * @returns buffer index of the new wrapper node.
150
454
  */
151
- wrap_children(s, t, i = 0, _) {
152
- const e = this._children_starts[s], f = this._children_ends[s];
153
- this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295;
154
- const n = this.push(t, 0, s, i, _);
155
- if (e !== 4294967295) {
156
- this._children_starts[n] = e, this._children_ends[n] = f;
157
- let a = e;
158
- for (; a !== 4294967295 && this._parents[a] === s; )
159
- this._parents[a] = n, a = this._next_siblings[a];
455
+ wrap_children(t, s, e = 0, f) {
456
+ const i = this.first_child_at(t), _ = this.last_child_at(t);
457
+ this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
458
+ const r = this.push(s, 0, t, e, f);
459
+ if (i !== 4294967295) {
460
+ this.set_first_child(r, i), this.set_last_child(r, _);
461
+ let h = i;
462
+ for (; h !== 4294967295 && this.parent_at(h) === t; )
463
+ this.set_parent(h, r), h = this.next_at(h);
160
464
  }
161
- return n;
465
+ return r;
162
466
  }
163
- commit_node(s) {
164
- this._pending_nodes[s] = 0;
467
+ commit_node(t) {
468
+ this._n[
469
+ t * 12 + 10
470
+ /* NodeField.pending */
471
+ ] = 0;
165
472
  }
166
473
  get_pending() {
167
- const s = [];
168
- for (let t = 0; t < this._size; t++)
169
- this._pending_nodes[t] !== 0 && s.push(t);
170
- return s;
474
+ const t = [], s = this._n;
475
+ for (let e = 0; e < this._size; e++)
476
+ s[
477
+ e * 12 + 10
478
+ /* NodeField.pending */
479
+ ] !== 0 && t.push(e);
480
+ return t;
171
481
  }
172
482
  /**
173
483
  * repair a revoked (pending) node.
@@ -186,231 +496,397 @@ class A {
186
496
  * @param delimiter_text optional pre-resolved delimiter string (wire path).
187
497
  * if provided, stored in _strings. if absent, value range is set from
188
498
  * the node's start position.
499
+ * @param text_start source offset of delimiter_text, at the node start the
500
+ * repaired range slices the same text so it is not stored
189
501
  */
190
- handle_repair(s, t) {
191
- const i = this._parents[s], _ = this._kinds[s], e = i !== 4294967295 ? this._kinds[i] : void 0;
192
- if (_ === 7 && e === 16) {
193
- this.unwrap_node(s);
502
+ handle_repair(t, s, e) {
503
+ const f = this.parent_at(t), i = this.kind_at(t), _ = f !== 4294967295 ? this.kind_at(f) : void 0;
504
+ if (i === 7 || i === 25) {
505
+ this.unwrap_node(t);
194
506
  return;
195
507
  }
196
- if (e === 0 || e === 14 || e === 16) {
197
- const p = this._starts[s];
198
- let r;
199
- if (t !== void 0)
200
- r = p + t.length;
508
+ if (_ === 0 || _ === 14 || _ === 16) {
509
+ const l = this.start_at(t);
510
+ let c;
511
+ if (s !== void 0)
512
+ c = l + s.length;
201
513
  else {
202
- if (r = this._ends[s], r === 4294967295) {
203
- let h = this._children_starts[s];
204
- for (; h !== 4294967295 && this._parents[h] === s; ) {
205
- if (this._kinds[h] === 6) {
206
- const u = this._starts[h];
207
- u > 0 && (r === 4294967295 || u > r) && (r = u);
514
+ if (c = this.end_at(t), c === 4294967295) {
515
+ let o = this.first_child_at(t);
516
+ for (; o !== 4294967295 && this.parent_at(o) === t; ) {
517
+ if (this.kind_at(o) === 6) {
518
+ const d = this.start_at(o);
519
+ d > 0 && (c === 4294967295 || d > c) && (c = d);
208
520
  } else {
209
- const u = this._ends[h];
210
- u !== 4294967295 && (r === 4294967295 || u > r) && (r = u);
521
+ const d = this.end_at(o);
522
+ d !== 4294967295 && (c === 4294967295 || d > c) && (c = d);
211
523
  }
212
- h = this._next_siblings[h];
524
+ o = this.next_at(o);
213
525
  }
214
526
  }
215
- if (r === 4294967295 || r <= p) {
216
- this.unwrap_node(s);
527
+ if (c === 4294967295 || c <= l) {
528
+ this.unwrap_node(t);
217
529
  return;
218
530
  }
219
531
  }
220
- const l = this._children_starts[s];
221
- this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295, this.set_kind(
222
- s,
532
+ const u = this.first_child_at(t);
533
+ this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295), this.set_kind(
534
+ t,
223
535
  7
224
536
  /* NodeKind.paragraph */
225
- ), this.metadata.delete(s), this._ends[s] = r;
226
- const d = this.push(1, p, s);
227
- if (this._value_starts[d] = p, this._value_ends[d] = r, this._ends[d] = r, t !== void 0 && (this._strings[d] = t), l !== 4294967295) {
228
- const h = this._next_siblings[s];
229
- let u = l, g = l;
230
- for (; g !== 4294967295 && this._parents[g] === s; )
231
- this._parents[g] = i, u = g, g = this._next_siblings[g];
232
- this._next_siblings[u] = h, h !== 4294967295 ? this._prev_siblings[h] = u : i !== 4294967295 && this._children_ends[i] === s && (this._children_ends[i] = u), this._next_siblings[s] = l, this._prev_siblings[l] = s;
537
+ ), this.delete_metadata(t), this.set_end(t, c);
538
+ const g = this.push(1, l, t);
539
+ if (this.set_value(g, l, c), this.set_end(g, c), s !== void 0 && e !== l && (this.own_strings()[g] = s), u !== 4294967295) {
540
+ const o = this.next_at(t);
541
+ let d = u, b = u;
542
+ for (; b !== 4294967295 && this.parent_at(b) === t; )
543
+ this.set_parent(b, f), d = b, b = this.next_at(b);
544
+ this.set_next(d, o), o !== 4294967295 ? this.set_prev(o, d) : f !== 4294967295 && this.last_child_at(f) === t && this.set_last_child(f, d), this.set_next(t, u), this.set_prev(u, t);
233
545
  }
234
546
  return;
235
547
  }
236
- const f = this._children_starts[s];
548
+ const r = this.first_child_at(t);
237
549
  if (this.set_kind(
238
- s,
550
+ t,
239
551
  1
240
552
  /* NodeKind.text */
241
- ), t !== void 0) {
242
- this._strings[s] = t;
243
- const p = this._starts[s], r = p + t.length;
244
- if (this._value_starts[s] = p, this._value_ends[s] = r, this._ends[s] = r, f === 4294967295) {
245
- this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295;
553
+ ), s !== void 0) {
554
+ const l = this.start_at(t);
555
+ e !== l && (this.own_strings()[t] = s);
556
+ const c = l + s.length;
557
+ if (this.set_value(t, l, c), this.set_end(t, c), r === 4294967295) {
558
+ this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
246
559
  return;
247
560
  }
248
- let l = f, d = f;
249
- for (; l !== 4294967295 && this._parents[l] === s; )
250
- this._parents[l] = i, d = l, l = this._next_siblings[l];
251
- const h = this._next_siblings[s];
252
- this._next_siblings[s] = f, this._prev_siblings[f] = s, h !== 4294967295 && this._parents[h] === i ? (this._next_siblings[d] = h, this._prev_siblings[h] = d) : this._next_siblings[d] = 4294967295, this._children_ends[i] === s && (this._children_ends[i] = d), this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295;
561
+ let u = r, g = r;
562
+ for (; u !== 4294967295 && this.parent_at(u) === t; )
563
+ this.set_parent(u, f), g = u, u = this.next_at(u);
564
+ const o = this.next_at(t);
565
+ this.set_next(t, r), this.set_prev(r, t), o !== 4294967295 && this.parent_at(o) === f ? (this.set_next(g, o), this.set_prev(o, g)) : this.set_next(g, 4294967295), this.last_child_at(f) === t && this.set_last_child(f, g), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
253
566
  return;
254
567
  }
255
- if (f === 4294967295) {
256
- this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295, this._value_starts[s] = this._starts[s], this._ends[s] === 4294967295 ? (this._value_ends[s] = this._starts[s] + 1, this._ends[s] = this._starts[s] + 1) : this._value_ends[s] = this._ends[s];
568
+ if (r === 4294967295) {
569
+ this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
570
+ const l = this.start_at(t);
571
+ if (this.end_at(t) === 4294967295) {
572
+ const c = this.value_start_at(t), u = c > l ? c : l + 1;
573
+ this.set_value(t, l, u), this.set_end(t, u);
574
+ } else
575
+ this.set_value_start(t, l), this.set_value_end(t, this.end_at(t));
257
576
  return;
258
577
  }
259
- let n = f, a = f;
260
- for (; n !== 4294967295 && this._parents[n] === s; )
261
- this._parents[n] = i, a = n, n = this._next_siblings[n];
262
- if (a === f && this._kinds[f] === 1) {
263
- this._value_starts[s] = this._starts[s], this._value_ends[s] = this._ends[f], this._ends[s] = this._ends[f], this._next_siblings[s] = this._next_siblings[f], this._next_siblings[f] !== 4294967295 && (this._prev_siblings[this._next_siblings[f]] = s), this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295;
578
+ let h = r, a = r;
579
+ for (; h !== 4294967295 && this.parent_at(h) === t; )
580
+ this.set_parent(h, f), a = h, h = this.next_at(h);
581
+ if (a === r && this.kind_at(r) === 1) {
582
+ this.set_value(t, this.start_at(t), this.value_end_at(r)), this.set_end(t, this.end_at(r));
583
+ const l = this.next_at(r);
584
+ this.set_next(t, l), l !== 4294967295 && this.set_prev(l, t), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
264
585
  return;
265
586
  }
266
- const o = this._prev_siblings[f];
267
- this._next_siblings[s] = f, this._prev_siblings[f] = s, o !== 4294967295 && (this._next_siblings[o] = s, this._prev_siblings[s] = o), this._children_ends[i] === s && (this._children_ends[i] = a), this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295, this._value_starts[s] = this._starts[s], this._value_ends[s] = this._value_starts[f], this._ends[s] = this._value_ends[s];
587
+ const p = this.prev_at(r);
588
+ this.set_next(t, r), this.set_prev(r, t), p !== 4294967295 && (this.set_next(p, t), this.set_prev(t, p)), this.last_child_at(f) === t && this.set_last_child(f, a), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
589
+ const A = this.start_at(t), B = this.start_at(r);
590
+ this.set_value(t, A, B), this.set_end(t, B);
268
591
  }
269
592
  repair() {
270
- this._pending_nodes.forEach((s, t) => {
271
- s !== 0 && this.handle_repair(t);
272
- });
593
+ const t = this._n;
594
+ for (let s = 0; s < this._size; s++)
595
+ t[
596
+ s * 12 + 10
597
+ /* NodeField.pending */
598
+ ] !== 0 && this.handle_repair(s);
273
599
  }
274
600
  pop() {
275
- this._size -= 1;
601
+ const t = --this._size;
602
+ z(this._n, t, t + 1);
276
603
  }
277
604
  /**
278
605
  * remove a node from the tree and reparent its children to its parent.
279
606
  * the node is effectively "unwrapped", its children take its place
280
607
  * in the parent's child list.
281
608
  */
282
- unwrap_node(s) {
283
- const t = this._parents[s], i = this._children_starts[s];
284
- if (i === 4294967295) {
285
- const a = this._prev_siblings[s], o = this._next_siblings[s];
286
- a !== 4294967295 ? this._next_siblings[a] = o : t !== 4294967295 && (this._children_starts[t] = o), o !== 4294967295 && (this._prev_siblings[o] = a), t !== 4294967295 && this._children_ends[t] === s && (this._children_ends[t] = a);
609
+ unwrap_node(t) {
610
+ const s = this.parent_at(t), e = this.first_child_at(t);
611
+ if (e === 4294967295) {
612
+ const h = this.prev_at(t), a = this.next_at(t);
613
+ h !== 4294967295 ? this.set_next(h, a) : s !== 4294967295 && this.set_first_child(s, a), a !== 4294967295 && this.set_prev(a, h), s !== 4294967295 && this.last_child_at(s) === t && this.set_last_child(s, h);
287
614
  return;
288
615
  }
289
- let _ = i, e = i;
290
- for (; _ !== 4294967295 && this._parents[_] === s; )
291
- this._parents[_] = t, e = _, _ = this._next_siblings[_];
292
- const f = this._prev_siblings[s];
293
- this._next_siblings[e] !== 4294967295 && this._parents[this._next_siblings[e]] === s || this._next_siblings[e];
294
- const n = this._next_siblings[s];
295
- f !== 4294967295 ? (this._next_siblings[f] = i, this._prev_siblings[i] = f) : t !== 4294967295 && (this._children_starts[t] = i, this._prev_siblings[i] = 4294967295), n !== 4294967295 && n !== i ? (this._next_siblings[e] = n, this._prev_siblings[n] = e) : this._next_siblings[e] = 4294967295, t !== 4294967295 && this._children_ends[t] === s && (this._children_ends[t] = e), this._children_starts[s] = 4294967295, this._children_ends[s] = 4294967295;
296
- }
297
- set_parent_kind(s, t) {
298
- const i = this._parents[s];
299
- i !== 4294967295 && (this._kinds[i] = t);
616
+ let f = e, i = e;
617
+ for (; f !== 4294967295 && this.parent_at(f) === t; )
618
+ this.set_parent(f, s), i = f, f = this.next_at(f);
619
+ const _ = this.prev_at(t), r = this.next_at(t);
620
+ _ !== 4294967295 ? (this.set_next(_, e), this.set_prev(e, _)) : s !== 4294967295 && (this.set_first_child(s, e), this.set_prev(e, 4294967295)), r !== 4294967295 && r !== e ? (this.set_next(i, r), this.set_prev(r, i)) : this.set_next(i, 4294967295), s !== 4294967295 && this.last_child_at(s) === t && this.set_last_child(s, i), this.set_first_child(t, 4294967295), this.set_last_child(t, 4294967295);
621
+ }
622
+ set_parent_kind(t, s) {
623
+ const e = this.parent_at(t);
624
+ e !== 4294967295 && this.set_kind(e, s);
300
625
  }
301
626
  /** return indices of all nodes matching the given kind (lazy scan). */
302
- get_kinds(s) {
303
- const t = [];
304
- for (let i = 0; i < this._size; i++)
305
- this._kinds[i] === s && t.push(i);
306
- return t;
627
+ get_kinds(t) {
628
+ const s = [], e = this._n;
629
+ for (let f = 0; f < this._size; f++)
630
+ (e[
631
+ f * 12
632
+ /* NodeField.stride */
633
+ ] & 255) === t && s.push(f);
634
+ return s;
307
635
  }
308
- /**
309
- * get the token kind recorded at the supplied index.
310
- * @param index token index.
311
- */
312
- kind_at(s) {
313
- return this._kinds[s];
636
+ kind_at(t) {
637
+ return this._n[
638
+ t * 12
639
+ /* NodeField.stride */
640
+ ] & 255;
314
641
  }
315
642
  /**
316
643
  * set the kind of the node at the given index
317
644
  * @param index index of the node whose kind to update
318
645
  * @param kind new kind
319
646
  */
320
- set_kind(s, t) {
321
- this._kinds[s] = t;
647
+ set_kind(t, s) {
648
+ const e = this._n, f = t * 12;
649
+ e[f] = e[f] & 16776960 | s & 255;
322
650
  }
323
- /** @internal set prev_siblings for wiretreebuilder revoke. */
324
- prev_siblings_set(s, t) {
325
- this._prev_siblings[s] = t;
326
- }
327
- /** @internal set children_ends for wiretreebuilder revoke. */
328
- children_ends_set(s, t) {
329
- this._children_ends[s] = t;
651
+ extra_at(t) {
652
+ return this._n[
653
+ t * 12
654
+ /* NodeField.stride */
655
+ ] >>> 8;
330
656
  }
331
657
  /**
332
658
  * set the extra of the node at the given index
333
659
  * @param index index of the node whose extra to update
334
660
  * @param extra new extra
335
661
  */
336
- set_extra(s, t) {
337
- this._extras[s] = t & 65535;
662
+ set_extra(t, s) {
663
+ const e = this._n, f = t * 12;
664
+ e[f] = e[f] & 255 | (s & 65535) << 8;
665
+ }
666
+ start_at(t) {
667
+ return this._n[
668
+ t * 12 + 1
669
+ /* NodeField.start */
670
+ ];
671
+ }
672
+ /** 0xffffffff while open */
673
+ end_at(t) {
674
+ return this._n[
675
+ t * 12 + 2
676
+ /* NodeField.end */
677
+ ];
338
678
  }
339
679
  /**
340
680
  * set the end position of the node at the given index
341
681
  * @param index index of the node whose end position to update
342
682
  * @param end new end position
343
683
  */
344
- set_end(s, t) {
345
- this._ends[s] = t >>> 0;
346
- }
347
- gently_set_end(s, t) {
348
- this._ends[s] === 4294967295 && (this._ends[s] = t >>> 0);
349
- }
350
- gently_set_value_end(s, t) {
351
- this._value_ends[s] === 4294967295 && (this._value_ends[s] = t >>> 0);
684
+ set_end(t, s) {
685
+ this._n[
686
+ t * 12 + 2
687
+ /* NodeField.end */
688
+ ] = s >>> 0;
689
+ }
690
+ gently_set_end(t, s) {
691
+ const e = t * 12 + 2;
692
+ this._n[e] === 4294967295 && (this._n[e] = s >>> 0);
693
+ }
694
+ value_start_at(t) {
695
+ return this._n[
696
+ t * 12 + 3
697
+ /* NodeField.value_start */
698
+ ];
699
+ }
700
+ value_end_at(t) {
701
+ return this._n[
702
+ t * 12 + 4
703
+ /* NodeField.value_end */
704
+ ];
705
+ }
706
+ set_value(t, s, e) {
707
+ const f = this._n, i = t * 12;
708
+ f[
709
+ i + 3
710
+ /* NodeField.value_start */
711
+ ] = s, f[
712
+ i + 4
713
+ /* NodeField.value_end */
714
+ ] = e;
715
+ }
716
+ set_value_start(t, s) {
717
+ this._n[
718
+ t * 12 + 3
719
+ /* NodeField.value_start */
720
+ ] = s;
721
+ }
722
+ set_value_end(t, s) {
723
+ this._n[
724
+ t * 12 + 4
725
+ /* NodeField.value_end */
726
+ ] = s;
727
+ }
728
+ gently_set_value_end(t, s) {
729
+ const e = t * 12 + 4;
730
+ this._n[e] === 4294967295 && (this._n[e] = s >>> 0);
731
+ }
732
+ parent_at(t) {
733
+ return this._n[
734
+ t * 12 + 5
735
+ /* NodeField.parent */
736
+ ];
737
+ }
738
+ set_parent(t, s) {
739
+ this._n[
740
+ t * 12 + 5
741
+ /* NodeField.parent */
742
+ ] = s;
743
+ }
744
+ next_at(t) {
745
+ return this._n[
746
+ t * 12 + 6
747
+ /* NodeField.next */
748
+ ];
749
+ }
750
+ set_next(t, s) {
751
+ this._n[
752
+ t * 12 + 6
753
+ /* NodeField.next */
754
+ ] = s;
755
+ }
756
+ prev_at(t) {
757
+ return this._n[
758
+ t * 12 + 7
759
+ /* NodeField.prev */
760
+ ];
761
+ }
762
+ set_prev(t, s) {
763
+ this._n[
764
+ t * 12 + 7
765
+ /* NodeField.prev */
766
+ ] = s;
767
+ }
768
+ first_child_at(t) {
769
+ return this._n[
770
+ t * 12 + 8
771
+ /* NodeField.first_child */
772
+ ];
773
+ }
774
+ set_first_child(t, s) {
775
+ this._n[
776
+ t * 12 + 8
777
+ /* NodeField.first_child */
778
+ ] = s;
779
+ }
780
+ last_child_at(t) {
781
+ return this._n[
782
+ t * 12 + 9
783
+ /* NodeField.last_child */
784
+ ];
785
+ }
786
+ set_last_child(t, s) {
787
+ this._n[
788
+ t * 12 + 9
789
+ /* NodeField.last_child */
790
+ ] = s;
791
+ }
792
+ pending_at(t) {
793
+ return this._n[
794
+ t * 12 + 10
795
+ /* NodeField.pending */
796
+ ];
352
797
  }
353
798
  /** pre-grow to avoid repeated resizes when the final size is estimable. */
354
- ensure_capacity(s) {
355
- for (; this.capacity < s; )
356
- this.grow();
799
+ ensure_capacity(t) {
800
+ let s = this._capacity;
801
+ if (!(s >= t)) {
802
+ for (; s < t; )
803
+ s <<= 1;
804
+ this.resize(s);
805
+ }
357
806
  }
358
807
  /** double the backing storage when capacity is exhausted. */
359
808
  grow() {
360
- const s = this.capacity << 1, t = new Uint8Array(s), i = new Uint32Array(s), _ = new Uint32Array(s), e = new Uint16Array(s), f = new Uint32Array(s), n = new Uint32Array(s), a = new Uint32Array(s), o = new Uint32Array(s), p = new Uint32Array(s), r = new Uint32Array(s), l = new Uint32Array(s), d = new Uint32Array(s), h = new Uint8Array(Math.max(1, s >> 3));
361
- t.set(this._kinds), i.set(this._starts), _.set(this._ends), e.set(this._extras), f.set(this._value_starts), n.set(this._value_ends), a.set(this._parents), o.set(this._next_siblings), p.set(this._prev_siblings), r.set(this._children_starts), l.set(this._children_ends), d.set(this._pending_nodes), h.set(this.has_metadata), this.capacity = s, this._kinds = t, this._starts = i, this._ends = _, this._extras = e, this._value_starts = f, this._value_ends = n, this._parents = a, this._next_siblings = o, this._prev_siblings = p, this._children_starts = r, this._children_ends = l, this._pending_nodes = d, this.has_metadata = h;
362
- }
363
- set_metadata(s, t) {
364
- this.metadata.set(s, t), this.has_metadata[s >> 3] |= 1 << (s & 7);
365
- }
366
- metadata_at(s) {
367
- if (this.has_metadata[s >> 3] & 1 << (s & 7))
368
- return this.metadata.get(s);
369
- }
370
- set_value(s, t, i) {
371
- this._value_starts[s] = t, this._value_ends[s] = i;
809
+ return this.resize(this._capacity << 1);
810
+ }
811
+ resize(t) {
812
+ const s = this._n, e = this._capacity * 12;
813
+ if (s === E) {
814
+ const _ = w - e * 4, r = t * k;
815
+ if (r <= 262144 && _ + r <= 1048576) {
816
+ const h = new Uint32Array(
817
+ x,
818
+ _,
819
+ t * 12
820
+ /* NodeField.stride */
821
+ );
822
+ return w = _ + r, E = h, this._capacity = t, this._filled = t, this._n = h, h;
823
+ }
824
+ }
825
+ const f = this.alloc(t), i = this._size;
826
+ return f.set(s.length === i * 12 ? s : s.subarray(
827
+ 0,
828
+ i * 12
829
+ /* NodeField.stride */
830
+ )), this._filled < i && (this._filled = i), f;
831
+ }
832
+ set_metadata(t, s) {
833
+ const e = this._n, f = t * 12 + 11, i = e[f];
834
+ if (i !== 0)
835
+ this._meta[i - 1] = s;
836
+ else {
837
+ const _ = this._meta;
838
+ _ === S ? (this._meta = [s], e[f] = 1) : e[f] = _.push(s);
839
+ }
372
840
  }
373
- set_value_start(s, t) {
374
- this._value_starts[s] = t;
841
+ metadata_at(t) {
842
+ const s = this._n[
843
+ t * 12 + 11
844
+ /* NodeField.meta */
845
+ ];
846
+ return s === 0 ? void 0 : this._meta[s - 1];
375
847
  }
376
- set_value_end(s, t) {
377
- this._value_ends[s] = t;
848
+ delete_metadata(t) {
849
+ this._n[
850
+ t * 12 + 11
851
+ /* NodeField.meta */
852
+ ] = 0;
378
853
  }
379
854
  /**
380
855
  * get the node at the given index or the root node if no index is provided
381
856
  * @param index index of the node to get
382
857
  * @returns node
383
858
  */
384
- get_node(s = 0) {
385
- const t = x(this._kinds[s]), i = t ? { [t]: this._extras[s] } : {}, _ = [];
386
- let e = this._children_starts[s];
387
- for (; e !== 4294967295 && this._parents[e] === s; )
388
- _.push(e), e = this._next_siblings[e];
859
+ get_node(t = 0) {
860
+ const s = this.kind_at(t), e = D(s), f = e ? { [e]: this.extra_at(t) } : {}, i = [];
861
+ let _ = this.first_child_at(t);
862
+ for (; _ !== 4294967295 && this.parent_at(_) === t; )
863
+ i.push(_), _ = this.next_at(_);
864
+ const r = this.parent_at(t), h = this.next_at(t), a = this.prev_at(t);
389
865
  return {
390
- kind: v(this._kinds[s]),
391
- start: this._starts[s],
392
- end: this._ends[s],
866
+ kind: N(s),
867
+ start: this.start_at(t),
868
+ end: this.end_at(t),
393
869
  metadata: {
394
- ...this.metadata_at(s),
395
- ...i
870
+ ...this.metadata_at(t),
871
+ ...f
396
872
  },
397
- parent: this._parents[s] === 4294967295 ? null : this._parents[s],
398
- next: this._next_siblings[s] === 4294967295 ? null : this._next_siblings[s],
399
- prev: this._prev_siblings[s] === 4294967295 ? null : this._prev_siblings[s],
400
- value: [this._value_starts[s], this._value_ends[s]],
401
- children: _,
402
- index: s
873
+ parent: r === 4294967295 ? null : r,
874
+ next: h === 4294967295 ? null : h,
875
+ prev: a === 4294967295 ? null : a,
876
+ value: [this.value_start_at(t), this.value_end_at(t)],
877
+ children: i,
878
+ index: t
403
879
  };
404
880
  }
405
881
  }
406
- class k {
882
+ class V {
407
883
  /**
408
884
  * create a collector that records error indices encountered while parsing.
409
885
  * @param initial_capacity requested starting capacity for error indices.
410
886
  */
411
- constructor(s = 32) {
412
- const t = b(s);
413
- this.capacity = t, this.indices = new Uint32Array(t), this._size = 0;
887
+ constructor(t = M) {
888
+ const s = m(t);
889
+ this.capacity = s, this.indices = new Uint32Array(s), this._size = 0;
414
890
  }
415
891
  /** clear previously stored errors. */
416
892
  reset() {
@@ -424,16 +900,16 @@ class k {
424
900
  * append an error position to the collector, growing storage as needed.
425
901
  * @param index offset in the source string where the error occurred.
426
902
  */
427
- push(s) {
428
- const t = this._size;
429
- t >= this.capacity && this.grow(), this.indices[t] = s >>> 0, this._size = t + 1;
903
+ push(t) {
904
+ const s = this._size;
905
+ s >= this.capacity && this.grow(), this.indices[s] = t >>> 0, this._size = s + 1;
430
906
  }
431
907
  /**
432
908
  * get the stored error index at the given position.
433
909
  * @param position position within the collector.
434
910
  */
435
- at(s) {
436
- return this.indices[s];
911
+ at(t) {
912
+ return this.indices[t];
437
913
  }
438
914
  /** create a view over the recorded errors. */
439
915
  slice() {
@@ -441,13 +917,15 @@ class k {
441
917
  }
442
918
  /** double the backing storage when capacity is exhausted. */
443
919
  grow() {
444
- const s = this.capacity << 1, t = new Uint32Array(s);
445
- t.set(this.indices), this.capacity = s, this.indices = t;
920
+ const t = this.capacity << 1, s = new Uint32Array(t);
921
+ s.set(this.indices), this.capacity = t, this.indices = s;
446
922
  }
447
923
  }
448
924
  export {
449
- k as ErrorCollector,
450
- A as NodeBuffer,
451
- v as kind_to_string,
452
- y as string_to_kind
925
+ V as ErrorCollector,
926
+ K as NodeBuffer,
927
+ N as kind_to_string,
928
+ R as make_meta,
929
+ F as merge_meta,
930
+ P as string_to_kind
453
931
  };