@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.
- package/CHANGELOG.md +213 -0
- package/WIRE_FORMAT.md +5 -1
- package/dist/buf-utils.js +23 -23
- package/dist/buf_utils.d.ts +1 -1
- package/dist/cursor.d.ts +17 -13
- package/dist/cursor.js +118 -31
- package/dist/main.d.ts +362 -26
- package/dist/main.js +5841 -3420
- package/dist/node_view-bvM0i0-p.js +407 -0
- package/dist/node_view.d.ts +11 -12
- package/dist/opcodes.d.ts +23 -6
- package/dist/plugin_dispatch.d.ts +22 -8
- package/dist/tree-builder.js +185 -66
- package/dist/tree_builder.d.ts +42 -11
- package/dist/undo_log.d.ts +11 -1
- package/dist/utils.d.ts +77 -51
- package/dist/utils.js +687 -209
- package/dist/wire-tree-builder.js +69 -71
- package/dist/wire_tree_builder.d.ts +4 -7
- package/package.json +1 -1
- package/src/buf_utils.ts +10 -14
- package/src/cursor.ts +74 -57
- package/src/main.ts +9898 -5593
- package/src/node_view.ts +159 -140
- package/src/opcodes.ts +39 -7
- package/src/plugin_dispatch.ts +328 -219
- package/src/tree_builder.ts +278 -98
- package/src/undo_log.ts +58 -24
- package/src/utils.spec.ts +86 -9
- package/src/utils.ts +769 -392
- package/src/wire_emitter.ts +6 -0
- package/src/wire_tree_builder.ts +39 -52
- package/test/block_quotes.spec.ts +78 -7
- package/test/code_spans.spec.ts +158 -6
- package/test/crlf.spec.ts +49 -1
- package/test/directives.spec.ts +530 -1
- package/test/emphasis.spec.ts +10 -4
- package/test/fixtures/pfm/block_quotes/pfm_fence_close.md +4 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_compact.md +4 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_end_quote.md +5 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_info.md +5 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_longer.md +4 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_nested.md +3 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_close_twice.md +6 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_info_eof.md +1 -0
- package/test/fixtures/pfm/block_quotes/pfm_fence_unclosed.md +2 -0
- package/test/fixtures/pfm/code_spans/pfm_328_5.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_6.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_7.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_8.md +1 -0
- package/test/fixtures/pfm/code_spans/pfm_328_9.md +2 -0
- package/test/fixtures/pfm/fenced_code_blocks/pfm_info_eof.md +1 -0
- package/test/fixtures/pfm/fenced_code_blocks/pfm_info_eof_no_lf.md +1 -0
- package/test/fixtures/pfm/generic_directives/106.md +1 -0
- package/test/fixtures/pfm/generic_directives/107.md +3 -0
- package/test/fixtures/pfm/generic_directives/108.md +1 -0
- package/test/fixtures/pfm/generic_directives/109.md +1 -0
- package/test/fixtures/pfm/generic_directives/110.md +1 -0
- package/test/fixtures/pfm/generic_directives/111.md +1 -0
- package/test/fixtures/pfm/generic_directives/112.md +1 -0
- package/test/fixtures/pfm/generic_directives/113.md +1 -0
- package/test/fixtures/pfm/generic_directives/114.md +2 -0
- package/test/fixtures/pfm/generic_directives/115.md +1 -0
- package/test/fixtures/pfm/generic_directives/116.md +6 -0
- package/test/fixtures/pfm/generic_directives/117.md +3 -0
- package/test/fixtures/pfm/generic_directives/118.md +6 -0
- package/test/fixtures/pfm/generic_directives/119.md +3 -0
- package/test/fixtures/pfm/generic_directives/120.md +5 -0
- package/test/fixtures/pfm/generic_directives/121.md +3 -0
- package/test/fixtures/pfm/generic_directives/122.md +4 -0
- package/test/fixtures/pfm/generic_directives/123.md +2 -0
- package/test/html.spec.ts +44 -1
- package/test/html_block_containers.spec.ts +445 -0
- package/test/incremental.spec.ts +271 -0
- package/test/lists.spec.ts +107 -1
- package/test/parser_reuse.spec.ts +40 -0
- package/test/plugins.spec.ts +196 -226
- package/test/print.ts +2 -3
- package/test/run_bytecode.spec.ts +36 -0
- package/test/snapshots/hybrid/component-children.snap.ast +9 -16
- package/test/snapshots/hybrid/component-simple-00.snap.ast +1 -2
- package/test/snapshots/hybrid/component-simple-01.snap.ast +1 -2
- package/test/snapshots/hybrid/component-simple-03.snap.ast +13 -13
- package/test/snapshots/hybrid/component-simple-04.snap.ast +1 -2
- package/test/snapshots/hybrid/error.snap.ast +1 -2
- package/test/snapshots/markdown/blockquote-nested-markdown.snap.ast +2 -1
- package/test/snapshots/markdown/emphasis.snap.ast +2 -2
- package/test/snapshots/markdown/encodeHTMLCodeTags.snap.ast +1 -2
- package/test/snapshots/markdown/github-style-codeblock-inside-quote.snap.ast +8 -1
- package/test/snapshots/markdown/html-comments.snap.ast +11 -13
- package/test/snapshots/markdown/html5-strutural-tags.snap.ast +16 -31
- package/test/snapshots/markdown/line-starts-with-html.snap.ast +5 -6
- package/test/snapshots/markdown/literal-html-tags.snap.ast +11 -14
- package/test/snapshots/markdown/nested-blockquote.snap.ast +3 -3
- package/test/snapshots/markdown/pre-code-tags.snap.ast +5 -8
- package/test/snapshots/pfm/block_quotes/237.snap.ast +1 -2
- package/test/snapshots/pfm/block_quotes/251.snap.ast +5 -5
- package/test/snapshots/pfm/block_quotes/pfm_fence_close.snap.ast +6 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_compact.snap.ast +6 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_end_quote.snap.ast +8 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_info.snap.ast +4 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_longer.snap.ast +6 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_nested.snap.ast +5 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_close_twice.snap.ast +5 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_info_eof.snap.ast +3 -0
- package/test/snapshots/pfm/block_quotes/pfm_fence_unclosed.snap.ast +3 -0
- package/test/snapshots/pfm/code_spans/344.snap.ast +1 -1
- package/test/snapshots/pfm/code_spans/347.snap.ast +1 -2
- package/test/snapshots/pfm/code_spans/pfm_328_5.snap.ast +6 -0
- package/test/snapshots/pfm/code_spans/pfm_328_6.snap.ast +6 -0
- package/test/snapshots/pfm/code_spans/pfm_328_7.snap.ast +6 -0
- package/test/snapshots/pfm/code_spans/pfm_328_8.snap.ast +8 -0
- package/test/snapshots/pfm/code_spans/pfm_328_9.snap.ast +10 -0
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/417.snap.ast +2 -2
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/438.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/441.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/444.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/445.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/450.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/453.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/456.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/457.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/473.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/475.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/476.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/477.snap.ast +1 -1
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/478.snap.ast +3 -4
- package/test/snapshots/pfm/emphasis_and_strong_emphasis/479.snap.ast +3 -4
- package/test/snapshots/pfm/fenced_code_blocks/126.snap.ast +1 -2
- package/test/snapshots/pfm/fenced_code_blocks/pfm_info_eof.snap.ast +2 -0
- package/test/snapshots/pfm/fenced_code_blocks/pfm_info_eof_no_lf.snap.ast +2 -0
- package/test/snapshots/pfm/generic_directives/011.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/015.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/016.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/017.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/019.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/020.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/030.snap.ast +4 -6
- package/test/snapshots/pfm/generic_directives/034.snap.ast +6 -2
- package/test/snapshots/pfm/generic_directives/036.snap.ast +5 -1
- package/test/snapshots/pfm/generic_directives/038.snap.ast +6 -2
- package/test/snapshots/pfm/generic_directives/039.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/040.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/044.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/046.snap.ast +3 -1
- package/test/snapshots/pfm/generic_directives/089.snap.ast +1 -1
- package/test/snapshots/pfm/generic_directives/103.snap.ast +6 -2
- package/test/snapshots/pfm/generic_directives/106.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/107.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/108.snap.ast +5 -0
- package/test/snapshots/pfm/generic_directives/109.snap.ast +4 -0
- package/test/snapshots/pfm/generic_directives/110.snap.ast +10 -0
- package/test/snapshots/pfm/generic_directives/111.snap.ast +7 -0
- package/test/snapshots/pfm/generic_directives/112.snap.ast +18 -0
- package/test/snapshots/pfm/generic_directives/113.snap.ast +7 -0
- package/test/snapshots/pfm/generic_directives/114.snap.ast +12 -0
- package/test/snapshots/pfm/generic_directives/115.snap.ast +10 -0
- package/test/snapshots/pfm/generic_directives/116.snap.ast +13 -0
- package/test/snapshots/pfm/generic_directives/117.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/118.snap.ast +10 -0
- package/test/snapshots/pfm/generic_directives/119.snap.ast +9 -0
- package/test/snapshots/pfm/generic_directives/120.snap.ast +12 -0
- package/test/snapshots/pfm/generic_directives/121.snap.ast +3 -0
- package/test/snapshots/pfm/generic_directives/122.snap.ast +3 -0
- package/test/snapshots/pfm/generic_directives/123.snap.ast +3 -0
- package/test/snapshots/pfm/hard_line_breaks/642.snap.ast +1 -1
- package/test/snapshots/pfm/hard_line_breaks/643.snap.ast +1 -1
- package/test/snapshots/pfm/html/148.snap.ast +1 -1
- package/test/snapshots/pfm/html/150.snap.ast +1 -1
- package/test/snapshots/pfm/html/159.snap.ast +2 -3
- package/test/snapshots/pfm/html/162.snap.ast +3 -4
- package/test/snapshots/pfm/html/163.snap.ast +1 -1
- package/test/snapshots/pfm/html/164.snap.ast +3 -4
- package/test/snapshots/pfm/html/166.snap.ast +1 -1
- package/test/snapshots/pfm/html/168.snap.ast +2 -3
- package/test/snapshots/pfm/html/169.snap.ast +5 -7
- package/test/snapshots/pfm/html/174.snap.ast +3 -3
- package/test/snapshots/pfm/html/182.snap.ast +1 -1
- package/test/snapshots/pfm/html/613.snap.ast +2 -2
- package/test/snapshots/pfm/html/615.snap.ast +2 -2
- package/test/snapshots/pfm/images/585.snap.ast +1 -1
- package/test/snapshots/pfm/images/589.snap.ast +1 -1
- package/test/snapshots/pfm/link_reference_definitions/201.snap.ast +1 -1
- package/test/snapshots/pfm/link_reference_definitions/208.snap.ast +1 -1
- package/test/snapshots/pfm/links/491.snap.ast +1 -1
- package/test/snapshots/pfm/links/494.snap.ast +2 -2
- package/test/snapshots/pfm/links/516.snap.ast +8 -9
- package/test/snapshots/pfm/links/521.snap.ast +1 -1
- package/test/snapshots/pfm/links/530.snap.ast +8 -12
- package/test/snapshots/pfm/links/534.snap.ast +1 -1
- package/test/snapshots/pfm/links/552.snap.ast +2 -2
- package/test/snapshots/pfm/links/559.snap.ast +1 -1
- package/test/snapshots/pfm/links/564.snap.ast +1 -1
- package/test/snapshots/pfm/list_items/260.snap.ast +3 -4
- package/test/snapshots/pfm/list_items/293.snap.ast +2 -2
- package/test/snapshots/pfm/tabs/16.snap.ast +2 -3
- package/test/snapshots/pfm/tabs/4.snap.ast +6 -5
- package/test/snapshots/svelte/00-introduction/00-hello-world/App.snap.ast +3 -4
- package/test/snapshots/svelte/00-introduction/02-styling/App.snap.ast +2 -3
- package/test/snapshots/svelte/00-introduction/03-nested-components/App.snap.ast +2 -3
- package/test/snapshots/svelte/00-introduction/03-nested-components/Nested.snap.ast +1 -2
- package/test/snapshots/svelte/00-introduction/04-html-tags/App.snap.ast +1 -2
- package/test/snapshots/svelte/01-reactivity/00-reactive-assignments/App.snap.ast +5 -6
- package/test/snapshots/svelte/01-reactivity/01-reactive-declarations/App.snap.ast +11 -14
- package/test/snapshots/svelte/01-reactivity/02-reactive-statements/App.snap.ast +5 -6
- package/test/snapshots/svelte/02-props/00-declaring-props/Nested.snap.ast +2 -3
- package/test/snapshots/svelte/02-props/01-default-values/App.snap.ast +1 -1
- package/test/snapshots/svelte/02-props/01-default-values/Nested.snap.ast +2 -3
- package/test/snapshots/svelte/02-props/02-spread-props/Info.snap.ast +16 -17
- package/test/snapshots/svelte/03-logic/00-if-blocks/App.snap.ast +4 -8
- package/test/snapshots/svelte/03-logic/01-else-blocks/App.snap.ast +4 -8
- package/test/snapshots/svelte/03-logic/02-else-if-blocks/App.snap.ast +6 -9
- package/test/snapshots/svelte/03-logic/03-each-blocks/App.snap.ast +5 -8
- package/test/snapshots/svelte/03-logic/04-keyed-each-blocks/App.snap.ast +4 -7
- package/test/snapshots/svelte/03-logic/04-keyed-each-blocks/Thing.snap.ast +4 -5
- package/test/snapshots/svelte/04-events/02-event-modifiers/App.snap.ast +2 -3
- package/test/snapshots/svelte/04-events/03-component-events/Inner.snap.ast +2 -3
- package/test/snapshots/svelte/04-events/04-event-forwarding/Inner.snap.ast +2 -3
- package/test/snapshots/svelte/04-events/05-dom-event-forwarding/FancyButton.snap.ast +2 -3
- package/test/snapshots/svelte/05-bindings/00-text-inputs/App.snap.ast +3 -4
- package/test/snapshots/svelte/05-bindings/01-numeric-inputs/App.snap.ast +9 -8
- package/test/snapshots/svelte/05-bindings/02-checkbox-inputs/App.snap.ast +7 -11
- package/test/snapshots/svelte/05-bindings/03-group-inputs/App.snap.ast +21 -30
- package/test/snapshots/svelte/05-bindings/04-textarea-inputs/App.snap.ast +1 -2
- package/test/snapshots/svelte/05-bindings/05-select-bindings/App.snap.ast +5 -9
- package/test/snapshots/svelte/05-bindings/06-multiple-select-bindings/App.snap.ast +18 -26
- package/test/snapshots/svelte/05-bindings/07-each-block-bindings/App.snap.ast +7 -11
- package/test/snapshots/svelte/05-bindings/08-media-elements/App.snap.ast +15 -19
- package/test/snapshots/svelte/05-bindings/09-dimensions/App.snap.ast +7 -9
- package/test/snapshots/svelte/05-bindings/11-component-bindings/App.snap.ast +1 -2
- package/test/snapshots/svelte/05-bindings/11-component-bindings/Keypad.snap.ast +32 -34
- package/test/snapshots/svelte/06-lifecycle/00-onmount/App.snap.ast +3 -6
- package/test/snapshots/svelte/06-lifecycle/01-ondestroy/App.snap.ast +6 -7
- package/test/snapshots/svelte/06-lifecycle/02-update/App.snap.ast +2 -4
- package/test/snapshots/svelte/07-stores/00-writable-stores/App.snap.ast +4 -5
- package/test/snapshots/svelte/07-stores/00-writable-stores/Decrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/00-writable-stores/Incrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/00-writable-stores/Resetter.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/App.snap.ast +4 -5
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Decrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Incrementer.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/01-auto-subscriptions/Resetter.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/02-readable-stores/App.snap.ast +2 -3
- package/test/snapshots/svelte/07-stores/03-derived-stores/App.snap.ast +8 -10
- package/test/snapshots/svelte/07-stores/04-custom-stores/App.snap.ast +7 -11
- package/test/snapshots/svelte/08-motion/00-tweened/App.snap.ast +10 -15
- package/test/snapshots/svelte/08-motion/01-spring/App.snap.ast +10 -10
- package/test/snapshots/svelte/09-transitions/00-transition/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/01-adding-parameters-to-transitions/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/02-in-and-out/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/03-custom-css-transitions/App.snap.ast +4 -6
- package/test/snapshots/svelte/09-transitions/04-custom-js-transitions/App.snap.ast +3 -5
- package/test/snapshots/svelte/09-transitions/05-transition-events/App.snap.ast +5 -8
- package/test/snapshots/svelte/10-animations/00-animate/App.snap.ast +16 -20
- package/test/snapshots/svelte/11-easing/00-easing/App.snap.ast +16 -11
- package/test/snapshots/svelte/11-easing/00-easing/Controls.snap.ast +11 -16
- package/test/snapshots/svelte/11-easing/00-easing/Grid.snap.ast +2 -2
- package/test/snapshots/svelte/12-svg/01-clock/App.snap.ast +2 -1
- package/test/snapshots/svelte/12-svg/02-bar-chart/App.snap.ast +7 -9
- package/test/snapshots/svelte/12-svg/03-area-chart/App.snap.ast +14 -15
- package/test/snapshots/svelte/12-svg/04-scatterplot/App.snap.ast +7 -5
- package/test/snapshots/svelte/12-svg/04-scatterplot/Scatterplot.snap.ast +6 -6
- package/test/snapshots/svelte/12-svg/05-svg-transitions/App.snap.ast +5 -6
- package/test/snapshots/svelte/13-actions/01-adding-parameters-to-actions/App.snap.ast +2 -3
- package/test/snapshots/svelte/14-classes/00-classes/App.snap.ast +3 -6
- package/test/snapshots/svelte/14-classes/01-class-shorthand/App.snap.ast +2 -3
- package/test/snapshots/svelte/15-composition/00-slots/App.snap.ast +3 -5
- package/test/snapshots/svelte/15-composition/01-slot-fallbacks/App.snap.ast +3 -5
- package/test/snapshots/svelte/15-composition/01-slot-fallbacks/Box.snap.ast +1 -2
- package/test/snapshots/svelte/15-composition/02-named-slots/App.snap.ast +7 -11
- package/test/snapshots/svelte/15-composition/02-named-slots/ContactCard.snap.ast +3 -6
- package/test/snapshots/svelte/15-composition/03-slot-props/App.snap.ast +9 -15
- package/test/snapshots/svelte/15-composition/04-modal/App.snap.ast +17 -26
- package/test/snapshots/svelte/15-composition/04-modal/Modal.snap.ast +3 -3
- package/test/snapshots/svelte/16-context/00-context-api/App.snap.ast +10 -5
- package/test/snapshots/svelte/17-special-elements/00-svelte-self/File.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/00-svelte-self/Folder.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/App.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/BlueThing.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/GreenThing.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/01-svelte-component/RedThing.snap.ast +1 -2
- package/test/snapshots/svelte/17-special-elements/02-svelte-window/App.snap.ast +3 -6
- package/test/snapshots/svelte/17-special-elements/03-svelte-window-bindings/App.snap.ast +2 -4
- package/test/snapshots/svelte/17-special-elements/05-svelte-head/App.snap.ast +6 -12
- package/test/snapshots/svelte/18-module-context/01-module-exports/App.snap.ast +2 -3
- package/test/snapshots/svelte/18-module-context/01-module-exports/AudioPlayer.snap.ast +4 -7
- package/test/snapshots/svelte/19-debugging/00-debug/App.snap.ast +5 -7
- package/test/snapshots/svelte/19-debugging/00-debug/Test.snap.ast +7 -11
- package/test/snapshots/svelte/20-7guis/01-7guis-counter/App.snap.ast +2 -3
- package/test/snapshots/svelte/20-7guis/02-7guis-temperature/App.snap.ast +2 -2
- package/test/snapshots/svelte/20-7guis/03-7guis-flight-booker/App.snap.ast +4 -7
- package/test/snapshots/svelte/20-7guis/04-7guis-timer/App.snap.ast +13 -17
- package/test/snapshots/svelte/20-7guis/05-7guis-crud/App.snap.ast +11 -13
- package/test/snapshots/svelte/20-7guis/06-7guis-circles/App.snap.ast +10 -11
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Comment.snap.ast +4 -6
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Item.snap.ast +9 -13
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/List.snap.ast +3 -5
- package/test/snapshots/svelte/21-miscellaneous/01-hacker-news/Summary.snap.ast +7 -11
- package/test/snapshots/svelte/21-miscellaneous/02-immutable-data/App.snap.ast +2 -4
- package/test/snapshots/svelte/99-embeds/20181225-blog-svelte-css-in-js/App.snap.ast +6 -7
- package/test/snapshots/svelte/99-embeds/20181225-blog-svelte-css-in-js/Hero.snap.ast +3 -5
- package/test/snapshots/svelte/99-embeds/20190420-blog-write-less-code/App.snap.ast +6 -7
- package/test/svelte_expressions.spec.ts +93 -4
- package/test/svelte_tags.spec.ts +27 -12
- package/test/tables.spec.ts +347 -0
- package/test/tree_builder.spec.ts +286 -1
- package/test/unclosed_delimiters.spec.ts +529 -0
- package/tsc/buf_utils.d.ts +1 -1
- package/tsc/buf_utils.js +9 -9
- package/tsc/cursor.d.ts +17 -13
- package/tsc/cursor.js +60 -43
- package/tsc/main.d.ts +362 -26
- package/tsc/main.js +8955 -4891
- package/tsc/node_view.d.ts +11 -12
- package/tsc/node_view.js +134 -102
- package/tsc/opcodes.d.ts +23 -6
- package/tsc/plugin_dispatch.d.ts +22 -8
- package/tsc/plugin_dispatch.js +292 -170
- package/tsc/tree_builder.d.ts +42 -11
- package/tsc/tree_builder.js +237 -82
- package/tsc/undo_log.d.ts +11 -1
- package/tsc/undo_log.js +54 -19
- package/tsc/utils.d.ts +77 -51
- package/tsc/utils.js +687 -344
- package/tsc/utils.spec.js +83 -9
- package/tsc/wire_emitter.js +6 -0
- package/tsc/wire_tree_builder.d.ts +4 -7
- package/tsc/wire_tree_builder.js +34 -37
- package/dist/node_view-BEh2-H86.js +0 -373
package/dist/tree-builder.js
CHANGED
|
@@ -1,94 +1,213 @@
|
|
|
1
|
-
import { NodeBuffer as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { NodeBuffer as c, merge_meta as u, make_meta as p } from "./utils.js";
|
|
2
|
+
const _ = 4294967295, m = new Uint8Array(64);
|
|
3
|
+
class w {
|
|
4
|
+
constructor(i, e) {
|
|
5
|
+
this.id_to_index = null, this.revoked = null, this.revoked_map = null, this.revoked_mapped = 0, this.nodes = new c(i), this.dispatcher = e ?? null, this.wants = e !== void 0 ? e.open_wants : m;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Reset a no-plugin builder for another complete document.
|
|
9
|
+
*
|
|
10
|
+
* A plugin dispatcher owns a source-specific TextSource, so those builders
|
|
11
|
+
* cannot be safely reused for a different document.
|
|
12
|
+
*/
|
|
13
|
+
reset() {
|
|
14
|
+
if (this.dispatcher !== null)
|
|
15
|
+
throw new Error("TreeBuilder with plugins cannot be reset");
|
|
16
|
+
this.nodes.reset(), this.nodes.push(0, 0), this.id_to_index = null, this.revoked !== null && (this.revoked = null, this.revoked_map = null, this.revoked_mapped = 0);
|
|
17
|
+
}
|
|
18
|
+
index_of(i) {
|
|
19
|
+
const e = this.id_to_index;
|
|
20
|
+
return e === null ? i : e[i];
|
|
21
|
+
}
|
|
22
|
+
start_id_map() {
|
|
23
|
+
const i = this.nodes._size, e = [];
|
|
24
|
+
for (let s = 0; s < i; s++)
|
|
25
|
+
e.push(s);
|
|
26
|
+
return this.id_to_index = e, e;
|
|
27
|
+
}
|
|
28
|
+
/** for callers that do not pass the kind, a revoke may have rewritten it */
|
|
29
|
+
opened_kind(i) {
|
|
30
|
+
const e = this.dispatcher !== null ? this.dispatcher.kind_log() : this.revoked;
|
|
31
|
+
if (e !== null) {
|
|
32
|
+
let s = this.revoked_map;
|
|
33
|
+
s === null && (s = this.revoked_map = /* @__PURE__ */ new Map());
|
|
34
|
+
for (let n = this.revoked_mapped; n < e.length; n += 2)
|
|
35
|
+
s.has(e[n]) || s.set(e[n], e[n + 1]);
|
|
36
|
+
this.revoked_mapped = e.length;
|
|
37
|
+
const t = s.get(i);
|
|
38
|
+
if (t !== void 0)
|
|
39
|
+
return t;
|
|
40
|
+
}
|
|
41
|
+
return this.nodes._n[
|
|
42
|
+
i * 12
|
|
43
|
+
/* NodeField.stride */
|
|
44
|
+
] & 255;
|
|
45
|
+
}
|
|
46
|
+
open(i, e, s, t, n, o) {
|
|
47
|
+
const d = this.nodes;
|
|
48
|
+
if (this.id_to_index === null && i === d._size && !this.wants[e]) {
|
|
49
|
+
d.push_node(e, s, t >>> 0, n, o);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
i !== 0 && this.open_slow(i, e, s, t, n, o);
|
|
53
|
+
}
|
|
54
|
+
open_slow(i, e, s, t, n, o) {
|
|
55
|
+
const d = this.nodes, h = this.dispatcher;
|
|
56
|
+
if (h !== null && this.id_to_index === null && i === d._size) {
|
|
57
|
+
let r = t === -1 ? _ : t;
|
|
58
|
+
if (!h.wants_open(e)) {
|
|
59
|
+
d.push_node(e, s, r, n, o);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (r !== _) {
|
|
63
|
+
const l = h.get_redirect(r);
|
|
64
|
+
l !== void 0 && (r = l);
|
|
65
|
+
}
|
|
66
|
+
const a = d.push_node(e, s, r, n, o);
|
|
67
|
+
h.has_handlers(e) && (h.dispatch_open(a, e, d), this.wants = h.open_wants);
|
|
10
68
|
return;
|
|
11
|
-
let o = s === -1 ? 4294967295 : this.id_to_index[s] ?? 4294967295;
|
|
12
|
-
if (this.dispatcher && o !== 4294967295) {
|
|
13
|
-
const _ = this.dispatcher.get_redirect(o);
|
|
14
|
-
_ !== void 0 && (o = _);
|
|
15
69
|
}
|
|
16
|
-
|
|
17
|
-
this.id_to_index[e] = h, this.id_to_kind[e] = i, this.dispatcher && this.dispatcher.has_handlers(i) && this.dispatcher.dispatch_open(h, i, this.nodes, this.register_id);
|
|
70
|
+
this.open_mapped(i, e, s, t, n, o);
|
|
18
71
|
}
|
|
19
|
-
|
|
20
|
-
|
|
72
|
+
/** an open once a plugin pushed nodes without ids or ids skipped a slot */
|
|
73
|
+
open_mapped(i, e, s, t, n, o) {
|
|
74
|
+
const d = this.nodes, h = this.dispatcher, r = this.id_to_index ?? this.start_id_map();
|
|
75
|
+
let a = t === -1 ? _ : r[t] ?? _;
|
|
76
|
+
if (h !== null && a !== _) {
|
|
77
|
+
const f = h.get_redirect(a);
|
|
78
|
+
f !== void 0 && (a = f);
|
|
79
|
+
}
|
|
80
|
+
const l = d.push_node(e, s, a, n, o);
|
|
81
|
+
r[i] = l, h !== null && h.has_handlers(e) && (h.dispatch_open(l, e, d), this.wants = h.open_wants);
|
|
82
|
+
}
|
|
83
|
+
close(i, e, s) {
|
|
84
|
+
const t = this.index_of(i);
|
|
21
85
|
if (t === void 0)
|
|
22
86
|
return;
|
|
23
|
-
this.nodes.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
87
|
+
const n = t * 12, o = this.nodes._n;
|
|
88
|
+
if (o[
|
|
89
|
+
n + 2
|
|
90
|
+
/* NodeField.end */
|
|
91
|
+
] = e, this.dispatcher === null && s !== void 0 && s !== 15 && (s !== 7 || o[
|
|
92
|
+
n + 10
|
|
93
|
+
/* NodeField.pending */
|
|
94
|
+
] === 0)) {
|
|
95
|
+
o[
|
|
96
|
+
n + 10
|
|
97
|
+
/* NodeField.pending */
|
|
98
|
+
] = 0;
|
|
99
|
+
return;
|
|
37
100
|
}
|
|
101
|
+
this.close_rest(t, n, s);
|
|
38
102
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
103
|
+
close_rest(i, e, s) {
|
|
104
|
+
const t = this.nodes, n = this.dispatcher;
|
|
105
|
+
n !== null && !n.quiet() && n.dispatch_close(i, t), s === void 0 && (s = this.opened_kind(i));
|
|
106
|
+
const o = t._n;
|
|
107
|
+
s === 7 && o[
|
|
108
|
+
e + 10
|
|
109
|
+
/* NodeField.pending */
|
|
110
|
+
] === 1 && (o[
|
|
111
|
+
o[
|
|
112
|
+
e + 5
|
|
113
|
+
/* NodeField.parent */
|
|
114
|
+
] * 12
|
|
115
|
+
/* NodeField.stride */
|
|
116
|
+
] & 255) === 16 || (o[
|
|
117
|
+
e + 10
|
|
118
|
+
/* NodeField.pending */
|
|
119
|
+
] = 0, s === 15 && this.unwrap_tight_list(i));
|
|
120
|
+
}
|
|
121
|
+
/** a no op when finalize_list_pending_paras already revoked the paragraphs */
|
|
122
|
+
unwrap_tight_list(i) {
|
|
123
|
+
const e = this.nodes, s = e.metadata_at(i);
|
|
124
|
+
if (!s || !s.tight)
|
|
42
125
|
return;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
126
|
+
let t = e.first_child_at(i), n = t !== _ && e.parent_at(t) === i;
|
|
127
|
+
for (; n; ) {
|
|
128
|
+
const o = e.next_at(t);
|
|
129
|
+
n = o !== _ && e.parent_at(o) === i;
|
|
130
|
+
let d = e.first_child_at(t), h = d !== _ && e.parent_at(d) === t;
|
|
131
|
+
for (; h; ) {
|
|
132
|
+
const r = e.next_at(d);
|
|
133
|
+
h = r !== _ && e.parent_at(r) === t, e.kind_at(d) === 7 && e.unwrap_node(d), d = r;
|
|
134
|
+
}
|
|
135
|
+
t = o;
|
|
46
136
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
137
|
+
}
|
|
138
|
+
text(i, e, s, t) {
|
|
139
|
+
let n = this.index_of(i);
|
|
140
|
+
if (n !== void 0) {
|
|
141
|
+
if (this.dispatcher !== null) {
|
|
142
|
+
t === void 0 && (t = this.opened_kind(n));
|
|
143
|
+
const o = this.dispatcher.get_redirect(n);
|
|
144
|
+
o !== void 0 && (n = o);
|
|
145
|
+
} else t === void 0 && (t = this.opened_kind(n));
|
|
146
|
+
t === 3 || t === 5 || t === 8 || t === 26 ? this.nodes.set_value(n, e, s) : this.nodes.push_text(e, s, n);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
leaf(i, e, s, t, n, o, d) {
|
|
150
|
+
const h = this.nodes, r = this.dispatcher;
|
|
151
|
+
if (this.id_to_index === null && i === h._size && (r === null || !this.wants[e] && r.quiet())) {
|
|
152
|
+
h.push_leaf(e, s, n, o, d, t);
|
|
153
|
+
return;
|
|
53
154
|
}
|
|
155
|
+
this.open(i, e, s, t, 0, !1), this.set_value_start(i, n), this.set_value_end(i, o), this.close(i, d, e);
|
|
54
156
|
}
|
|
55
|
-
attr(
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
switch (
|
|
157
|
+
attr(i, e, s) {
|
|
158
|
+
const t = this.index_of(i);
|
|
159
|
+
if (t !== void 0)
|
|
160
|
+
switch (e) {
|
|
59
161
|
case "value":
|
|
60
|
-
this.nodes.set_value(
|
|
162
|
+
this.nodes.set_value(t, s[0], s[1]);
|
|
61
163
|
break;
|
|
62
164
|
case "value_start":
|
|
63
|
-
this.nodes.set_value_start(
|
|
165
|
+
this.nodes.set_value_start(t, s);
|
|
64
166
|
break;
|
|
65
167
|
case "value_end":
|
|
66
|
-
this.nodes.set_value_end(
|
|
168
|
+
this.nodes.set_value_end(t, s);
|
|
67
169
|
break;
|
|
68
170
|
default: {
|
|
69
|
-
const
|
|
70
|
-
|
|
171
|
+
const n = this.nodes, o = n.metadata_at(t);
|
|
172
|
+
o ? u(o, e, s) : n.set_metadata(t, p(e, s));
|
|
71
173
|
break;
|
|
72
174
|
}
|
|
73
175
|
}
|
|
74
176
|
}
|
|
75
|
-
set_value_start(
|
|
76
|
-
const
|
|
77
|
-
|
|
177
|
+
set_value_start(i, e) {
|
|
178
|
+
const s = this.index_of(i);
|
|
179
|
+
s !== void 0 && this.nodes.set_value_start(s, e);
|
|
180
|
+
}
|
|
181
|
+
set_value_end(i, e) {
|
|
182
|
+
const s = this.index_of(i);
|
|
183
|
+
s !== void 0 && this.nodes.set_value_end(s, e);
|
|
78
184
|
}
|
|
79
|
-
|
|
80
|
-
const t = this.
|
|
81
|
-
t
|
|
185
|
+
revoke(i, e, s) {
|
|
186
|
+
const t = this.index_of(i);
|
|
187
|
+
if (t === void 0)
|
|
188
|
+
return;
|
|
189
|
+
const n = this.nodes;
|
|
190
|
+
if (this.dispatcher !== null) {
|
|
191
|
+
this.dispatcher.dispatch_revoke(t, n);
|
|
192
|
+
const d = n.kind_at(t);
|
|
193
|
+
n.handle_repair(t, e, s), n.kind_at(t) !== d && this.dispatcher.log_kind(t, d);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const o = n.kind_at(t);
|
|
197
|
+
if (n.handle_repair(t, e, s), n.kind_at(t) !== o) {
|
|
198
|
+
const d = this.revoked;
|
|
199
|
+
d === null ? this.revoked = [t, o] : d.push(t, o);
|
|
200
|
+
}
|
|
82
201
|
}
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
202
|
+
commit(i) {
|
|
203
|
+
const e = this.index_of(i);
|
|
204
|
+
e !== void 0 && (this.nodes.commit_node(e), this.dispatcher && this.dispatcher.dispatch_commit(e));
|
|
86
205
|
}
|
|
87
|
-
|
|
88
|
-
const i = this.id_to_index[e];
|
|
89
|
-
i !== void 0 && (this.nodes.commit_node(i), this.dispatcher && this.dispatcher.dispatch_commit(i));
|
|
206
|
+
cursor(i) {
|
|
90
207
|
}
|
|
91
|
-
|
|
208
|
+
/** an incremental document is complete, give its unused slab tail back */
|
|
209
|
+
end() {
|
|
210
|
+
this.nodes.trim();
|
|
92
211
|
}
|
|
93
212
|
/** extract the built NodeBuffer. */
|
|
94
213
|
get_buffer() {
|
|
@@ -96,5 +215,5 @@ class u {
|
|
|
96
215
|
}
|
|
97
216
|
}
|
|
98
217
|
export {
|
|
99
|
-
|
|
218
|
+
w as TreeBuilder
|
|
100
219
|
};
|
package/dist/tree_builder.d.ts
CHANGED
|
@@ -1,31 +1,62 @@
|
|
|
1
|
-
import type { Emitter } from
|
|
2
|
-
import { NodeBuffer, NodeKind } from
|
|
3
|
-
import type { PluginDispatcher } from
|
|
1
|
+
import type { Emitter } from './opcodes';
|
|
2
|
+
import { NodeBuffer, NodeKind } from './utils';
|
|
3
|
+
import type { PluginDispatcher } from './plugin_dispatch';
|
|
4
4
|
/**
|
|
5
5
|
* consumes opcodes from PFMParser and builds a NodeBuffer.
|
|
6
6
|
* this is the backward-compatibility layer: the opcode stream is the
|
|
7
7
|
* primary output, but existing tests and consumers expect a NodeBuffer.
|
|
8
|
+
*
|
|
9
|
+
* ids are dense so each id is its own buffer index, an id that misses the next
|
|
10
|
+
* free slot, as after a revoke pushes a repair node, switches to an id map for
|
|
11
|
+
* the rest of the document, plugins always use the map since they push
|
|
12
|
+
* synthetic nodes
|
|
8
13
|
*/
|
|
9
14
|
export declare class TreeBuilder implements Emitter {
|
|
10
15
|
private nodes;
|
|
11
|
-
/**
|
|
16
|
+
/** null while ids equal buffer indices */
|
|
12
17
|
private id_to_index;
|
|
13
|
-
/**
|
|
14
|
-
|
|
18
|
+
/**
|
|
19
|
+
* buffer index and kind at open of each node a revoke rewrote, read only
|
|
20
|
+
* for a close or text that does not pass the kind
|
|
21
|
+
*/
|
|
22
|
+
private revoked;
|
|
23
|
+
/** kind at open by index, built from revoked on the first read */
|
|
24
|
+
private revoked_map;
|
|
25
|
+
/** entries of revoked already copied into revoked_map */
|
|
26
|
+
private revoked_mapped;
|
|
15
27
|
/** optional plugin dispatcher. null when no plugins registered. */
|
|
16
28
|
private dispatcher;
|
|
17
|
-
|
|
18
|
-
private register_id;
|
|
29
|
+
private wants;
|
|
19
30
|
constructor(capacity: number, dispatcher?: PluginDispatcher);
|
|
31
|
+
/**
|
|
32
|
+
* Reset a no-plugin builder for another complete document.
|
|
33
|
+
*
|
|
34
|
+
* A plugin dispatcher owns a source-specific TextSource, so those builders
|
|
35
|
+
* cannot be safely reused for a different document.
|
|
36
|
+
*/
|
|
37
|
+
reset(): void;
|
|
38
|
+
private index_of;
|
|
39
|
+
private start_id_map;
|
|
40
|
+
/** for callers that do not pass the kind, a revoke may have rewritten it */
|
|
41
|
+
private opened_kind;
|
|
20
42
|
open(id: number, kind: NodeKind, start: number, parent: number, extra: number, pending: boolean): void;
|
|
21
|
-
|
|
22
|
-
|
|
43
|
+
private open_slow;
|
|
44
|
+
/** an open once a plugin pushed nodes without ids or ids skipped a slot */
|
|
45
|
+
private open_mapped;
|
|
46
|
+
close(id: number, end: number, kind?: NodeKind): void;
|
|
47
|
+
private close_rest;
|
|
48
|
+
/** a no op when finalize_list_pending_paras already revoked the paragraphs */
|
|
49
|
+
private unwrap_tight_list;
|
|
50
|
+
text(parent: number, start: number, end: number, parent_kind?: NodeKind): void;
|
|
51
|
+
leaf(id: number, kind: NodeKind, start: number, parent: number, value_start: number, value_end: number, end: number): void;
|
|
23
52
|
attr(id: number, key: string, value: any): void;
|
|
24
53
|
set_value_start(id: number, pos: number): void;
|
|
25
54
|
set_value_end(id: number, pos: number): void;
|
|
26
|
-
revoke(id: number, source_text?: string): void;
|
|
55
|
+
revoke(id: number, source_text?: string, text_start?: number): void;
|
|
27
56
|
commit(id: number): void;
|
|
28
57
|
cursor(_pos: number): void;
|
|
58
|
+
/** an incremental document is complete, give its unused slab tail back */
|
|
59
|
+
end(): void;
|
|
29
60
|
/** extract the built NodeBuffer. */
|
|
30
61
|
get_buffer(): NodeBuffer;
|
|
31
62
|
}
|
package/dist/undo_log.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NodeBuffer } from
|
|
1
|
+
import type { NodeBuffer } from './utils';
|
|
2
2
|
/** sentinel: the attribute key did not exist before this write. */
|
|
3
3
|
export declare const ATTR_DID_NOT_EXIST: unique symbol;
|
|
4
4
|
export declare const enum UndoEntryKind {
|
|
@@ -74,10 +74,18 @@ export declare class UndoLog {
|
|
|
74
74
|
* attribute their entries to this node.
|
|
75
75
|
*/
|
|
76
76
|
private active_node;
|
|
77
|
+
/**
|
|
78
|
+
* buffer index and prior kind of every kind rewrite, recorded or not, in
|
|
79
|
+
* order, so the first entry of an index holds its kind at open
|
|
80
|
+
*/
|
|
81
|
+
kind_changes: number[] | null;
|
|
82
|
+
log_kind(target: number, prior_kind: number): void;
|
|
77
83
|
/** called by dispatcher before invoking plugin handlers for a node. */
|
|
78
84
|
set_active_node(index: number): void;
|
|
79
85
|
/** called by dispatcher after handlers complete. */
|
|
80
86
|
clear_active_node(): void;
|
|
87
|
+
/** false while nothing would keep an entry */
|
|
88
|
+
get recording(): boolean;
|
|
81
89
|
record_attr_set(target: number, key: string, prior_value: any): void;
|
|
82
90
|
record_attr_delete(target: number, key: string, prior_value: any): void;
|
|
83
91
|
record_type_change(target: number, prior_kind: number): void;
|
|
@@ -94,6 +102,8 @@ export declare class UndoLog {
|
|
|
94
102
|
* commit a node, discard its undo log, making mutations permanent.
|
|
95
103
|
*/
|
|
96
104
|
commit(handler_node: number): void;
|
|
105
|
+
/** true when no node holds a mutation that a revoke would undo */
|
|
106
|
+
get empty(): boolean;
|
|
97
107
|
/** check whether a node has any recorded mutations. */
|
|
98
108
|
has(handler_node: number): boolean;
|
|
99
109
|
/** get undo entries for a node (for redirect detection). */
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/** push writes and the cursor reads fields together, so they share one stride */
|
|
2
|
+
export declare const enum NodeField {
|
|
3
|
+
/** kind in the low byte, extra in the sixteen bits above it */
|
|
4
|
+
kind = 0,
|
|
5
|
+
start = 1,
|
|
6
|
+
end = 2,
|
|
7
|
+
value_start = 3,
|
|
8
|
+
value_end = 4,
|
|
9
|
+
parent = 5,
|
|
10
|
+
next = 6,
|
|
11
|
+
prev = 7,
|
|
12
|
+
first_child = 8,
|
|
13
|
+
last_child = 9,
|
|
14
|
+
/** one while the node may still be revoked */
|
|
15
|
+
pending = 10,
|
|
16
|
+
/** one plus the slot in NodeBuffer._meta, zero without metadata */
|
|
17
|
+
meta = 11,
|
|
18
|
+
stride = 12
|
|
19
|
+
}
|
|
1
20
|
export declare const enum NodeKind {
|
|
2
21
|
root = 0,
|
|
3
22
|
text = 1,
|
|
@@ -33,7 +52,8 @@ export declare const enum NodeKind {
|
|
|
33
52
|
directive_leaf = 31,
|
|
34
53
|
directive_container = 32,
|
|
35
54
|
frontmatter = 33,
|
|
36
|
-
import_statement = 34
|
|
55
|
+
import_statement = 34,
|
|
56
|
+
directive_label = 35
|
|
37
57
|
}
|
|
38
58
|
/**
|
|
39
59
|
* convert a node kind to a string
|
|
@@ -48,61 +68,54 @@ export declare const kind_to_string: (kind: NodeKind) => string;
|
|
|
48
68
|
*/
|
|
49
69
|
export declare const string_to_kind: (name: string) => NodeKind | undefined;
|
|
50
70
|
/**
|
|
51
|
-
*
|
|
71
|
+
* a computed key literal takes a slow generic define, so known keys get
|
|
72
|
+
* constant key literals and other keys a store into an empty literal
|
|
52
73
|
*/
|
|
74
|
+
export declare function make_meta(key: string, value: any): Record<string, any>;
|
|
75
|
+
/** named stores stay monomorphic, a keyed store goes megamorphic across shapes */
|
|
76
|
+
export declare function merge_meta(meta: Record<string, any>, key: string, value: any): void;
|
|
53
77
|
export declare class NodeBuffer {
|
|
54
|
-
private capacity;
|
|
55
|
-
/** @internal exposed for cursor access. do not mutate externally. */
|
|
56
|
-
_kinds: Uint8Array;
|
|
57
|
-
/** @internal exposed for cursor access. do not mutate externally. */
|
|
58
|
-
_starts: Uint32Array;
|
|
59
|
-
/** @internal */
|
|
60
|
-
_ends: Uint32Array;
|
|
61
78
|
/** @internal */
|
|
62
|
-
|
|
79
|
+
_capacity: number;
|
|
80
|
+
/** @internal do not mutate externally */
|
|
81
|
+
_n: Uint32Array;
|
|
63
82
|
/** @internal */
|
|
64
|
-
|
|
65
|
-
/** @internal */
|
|
66
|
-
_value_ends: Uint32Array;
|
|
67
|
-
private has_metadata;
|
|
68
|
-
private metadata;
|
|
83
|
+
_meta: any[];
|
|
69
84
|
/** @internal pre-materialized text strings (used by wiretreebuilder). index -> string. */
|
|
70
85
|
_strings: (string | undefined)[];
|
|
71
|
-
/** @internal */
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
/** @internal */
|
|
76
|
-
_prev_siblings: Uint32Array;
|
|
77
|
-
/** @internal */
|
|
78
|
-
_children_starts: Uint32Array;
|
|
79
|
-
/** @internal */
|
|
80
|
-
_children_ends: Uint32Array;
|
|
81
|
-
/** @internal */
|
|
82
|
-
_pending_nodes: Uint32Array;
|
|
83
|
-
private _size;
|
|
84
|
-
/**
|
|
85
|
-
* create a buffer that stores token metadata with typed arrays.
|
|
86
|
-
* @param initial_capacity requested starting capacity for tokens.
|
|
87
|
-
*/
|
|
86
|
+
/** @internal read by TreeBuilder to check ids against indices */
|
|
87
|
+
_size: number;
|
|
88
|
+
/** slots from _size up to here hold the template */
|
|
89
|
+
private _filled;
|
|
88
90
|
constructor(initial_capacity?: number);
|
|
89
|
-
|
|
91
|
+
private alloc;
|
|
92
|
+
/** @internal */
|
|
93
|
+
own_strings(): (string | undefined)[];
|
|
94
|
+
/** gives the unused tail of the last slab carve back, a later push resizes */
|
|
95
|
+
trim(): void;
|
|
96
|
+
/** clear nodes without reallocating storage */
|
|
90
97
|
reset(): void;
|
|
91
|
-
/** number of tokens currently stored. */
|
|
92
98
|
get size(): number;
|
|
93
99
|
/**
|
|
94
|
-
* push a
|
|
95
|
-
* @param kind
|
|
100
|
+
* push a node as the last child of parent
|
|
101
|
+
* @param kind node category.
|
|
96
102
|
* @param cursor cursor position
|
|
97
|
-
* @param parent index of the parent node, or
|
|
98
|
-
* @param extra extra metadata stored alongside the
|
|
103
|
+
* @param parent index of the parent node, or 0xffffffff for none.
|
|
104
|
+
* @param extra extra metadata stored alongside the node.
|
|
99
105
|
* @param metadata optional metadata associated with the node.
|
|
100
106
|
*/
|
|
101
107
|
push(kind: NodeKind, cursor: number, parent?: number, extra?: number, metadata?: any): number;
|
|
102
108
|
push_pending(kind: NodeKind, cursor: number, parent?: number, extra?: number, metadata?: any): number;
|
|
109
|
+
/** one body for every open so the builder inlines a single copy */
|
|
110
|
+
push_node(kind: NodeKind, cursor: number, parent: number, extra: number, pending: boolean): number;
|
|
111
|
+
/** parent must be a node, not 0xffffffff */
|
|
112
|
+
push_text(start: number, end: number, parent: number): number;
|
|
113
|
+
/** a closed node with no extra and a value range, as open, value and close would leave it */
|
|
114
|
+
push_leaf(kind: NodeKind, start: number, value_start: number, value_end: number, end: number, parent: number): number;
|
|
115
|
+
private fill;
|
|
103
116
|
/**
|
|
104
117
|
* allocate a node slot without linking it into any parent's child list.
|
|
105
|
-
* the caller is responsible for setting
|
|
118
|
+
* the caller is responsible for setting the parent and linking into the
|
|
106
119
|
* sibling chain manually. used by plugin structural mutations (prepend).
|
|
107
120
|
* @param kind node kind.
|
|
108
121
|
* @param cursor source position.
|
|
@@ -142,8 +155,10 @@ export declare class NodeBuffer {
|
|
|
142
155
|
* @param delimiter_text optional pre-resolved delimiter string (wire path).
|
|
143
156
|
* if provided, stored in _strings. if absent, value range is set from
|
|
144
157
|
* the node's start position.
|
|
158
|
+
* @param text_start source offset of delimiter_text, at the node start the
|
|
159
|
+
* repaired range slices the same text so it is not stored
|
|
145
160
|
*/
|
|
146
|
-
handle_repair(index: number, delimiter_text?: string): void;
|
|
161
|
+
handle_repair(index: number, delimiter_text?: string, text_start?: number): void;
|
|
147
162
|
repair(): void;
|
|
148
163
|
pop(): void;
|
|
149
164
|
/**
|
|
@@ -155,10 +170,6 @@ export declare class NodeBuffer {
|
|
|
155
170
|
set_parent_kind(index: number, kind: NodeKind): void;
|
|
156
171
|
/** return indices of all nodes matching the given kind (lazy scan). */
|
|
157
172
|
get_kinds(kind: NodeKind): number[];
|
|
158
|
-
/**
|
|
159
|
-
* get the token kind recorded at the supplied index.
|
|
160
|
-
* @param index token index.
|
|
161
|
-
*/
|
|
162
173
|
kind_at(index: number): NodeKind;
|
|
163
174
|
/**
|
|
164
175
|
* set the kind of the node at the given index
|
|
@@ -166,16 +177,16 @@ export declare class NodeBuffer {
|
|
|
166
177
|
* @param kind new kind
|
|
167
178
|
*/
|
|
168
179
|
set_kind(index: number, kind: NodeKind): void;
|
|
169
|
-
|
|
170
|
-
prev_siblings_set(index: number, value: number): void;
|
|
171
|
-
/** @internal set children_ends for wiretreebuilder revoke. */
|
|
172
|
-
children_ends_set(index: number, value: number): void;
|
|
180
|
+
extra_at(index: number): number;
|
|
173
181
|
/**
|
|
174
182
|
* set the extra of the node at the given index
|
|
175
183
|
* @param index index of the node whose extra to update
|
|
176
184
|
* @param extra new extra
|
|
177
185
|
*/
|
|
178
186
|
set_extra(index: number, extra: number): void;
|
|
187
|
+
start_at(index: number): number;
|
|
188
|
+
/** 0xffffffff while open */
|
|
189
|
+
end_at(index: number): number;
|
|
179
190
|
/**
|
|
180
191
|
* set the end position of the node at the given index
|
|
181
192
|
* @param index index of the node whose end position to update
|
|
@@ -183,16 +194,31 @@ export declare class NodeBuffer {
|
|
|
183
194
|
*/
|
|
184
195
|
set_end(index: number, end: number): void;
|
|
185
196
|
gently_set_end(index: number, end: number): void;
|
|
197
|
+
value_start_at(index: number): number;
|
|
198
|
+
value_end_at(index: number): number;
|
|
199
|
+
set_value(index: number, value_start: number, value_end: number): void;
|
|
200
|
+
set_value_start(index: number, value_start: number): void;
|
|
201
|
+
set_value_end(index: number, value_end: number): void;
|
|
186
202
|
gently_set_value_end(index: number, end: number): void;
|
|
203
|
+
parent_at(index: number): number;
|
|
204
|
+
set_parent(index: number, parent: number): void;
|
|
205
|
+
next_at(index: number): number;
|
|
206
|
+
set_next(index: number, next: number): void;
|
|
207
|
+
prev_at(index: number): number;
|
|
208
|
+
set_prev(index: number, prev: number): void;
|
|
209
|
+
first_child_at(index: number): number;
|
|
210
|
+
set_first_child(index: number, child: number): void;
|
|
211
|
+
last_child_at(index: number): number;
|
|
212
|
+
set_last_child(index: number, child: number): void;
|
|
213
|
+
pending_at(index: number): number;
|
|
187
214
|
/** pre-grow to avoid repeated resizes when the final size is estimable. */
|
|
188
215
|
ensure_capacity(needed: number): void;
|
|
189
216
|
/** double the backing storage when capacity is exhausted. */
|
|
190
217
|
private grow;
|
|
218
|
+
private resize;
|
|
191
219
|
set_metadata(index: number, metadata: any): void;
|
|
192
220
|
metadata_at(index: number): any | undefined;
|
|
193
|
-
|
|
194
|
-
set_value_start(index: number, value_start: number): void;
|
|
195
|
-
set_value_end(index: number, value_end: number): void;
|
|
221
|
+
delete_metadata(index: number): void;
|
|
196
222
|
/**
|
|
197
223
|
* get the node at the given index or the root node if no index is provided
|
|
198
224
|
* @param index index of the node to get
|