@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/utils.js
CHANGED
|
@@ -1,11 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
|
8
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
|
108
|
-
* @param kind
|
|
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
|
|
111
|
-
* @param extra extra metadata stored alongside the
|
|
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(
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
|
339
|
+
return _;
|
|
121
340
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
|
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(
|
|
137
|
-
|
|
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(
|
|
152
|
-
const
|
|
153
|
-
this.
|
|
154
|
-
const
|
|
155
|
-
if (
|
|
156
|
-
this.
|
|
157
|
-
let
|
|
158
|
-
for (;
|
|
159
|
-
this.
|
|
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
|
|
465
|
+
return r;
|
|
162
466
|
}
|
|
163
|
-
commit_node(
|
|
164
|
-
this.
|
|
467
|
+
commit_node(t) {
|
|
468
|
+
this._n[
|
|
469
|
+
t * 12 + 10
|
|
470
|
+
/* NodeField.pending */
|
|
471
|
+
] = 0;
|
|
165
472
|
}
|
|
166
473
|
get_pending() {
|
|
167
|
-
const
|
|
168
|
-
for (let
|
|
169
|
-
|
|
170
|
-
|
|
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,
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
this.unwrap_node(
|
|
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 (
|
|
197
|
-
const
|
|
198
|
-
let
|
|
199
|
-
if (
|
|
200
|
-
|
|
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 (
|
|
203
|
-
let
|
|
204
|
-
for (;
|
|
205
|
-
if (this.
|
|
206
|
-
const
|
|
207
|
-
|
|
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
|
|
210
|
-
|
|
521
|
+
const d = this.end_at(o);
|
|
522
|
+
d !== 4294967295 && (c === 4294967295 || d > c) && (c = d);
|
|
211
523
|
}
|
|
212
|
-
|
|
524
|
+
o = this.next_at(o);
|
|
213
525
|
}
|
|
214
526
|
}
|
|
215
|
-
if (
|
|
216
|
-
this.unwrap_node(
|
|
527
|
+
if (c === 4294967295 || c <= l) {
|
|
528
|
+
this.unwrap_node(t);
|
|
217
529
|
return;
|
|
218
530
|
}
|
|
219
531
|
}
|
|
220
|
-
const
|
|
221
|
-
this.
|
|
222
|
-
|
|
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.
|
|
226
|
-
const
|
|
227
|
-
if (this.
|
|
228
|
-
const
|
|
229
|
-
let
|
|
230
|
-
for (;
|
|
231
|
-
this.
|
|
232
|
-
this.
|
|
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
|
|
548
|
+
const r = this.first_child_at(t);
|
|
237
549
|
if (this.set_kind(
|
|
238
|
-
|
|
550
|
+
t,
|
|
239
551
|
1
|
|
240
552
|
/* NodeKind.text */
|
|
241
|
-
),
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
|
249
|
-
for (;
|
|
250
|
-
this.
|
|
251
|
-
const
|
|
252
|
-
this.
|
|
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 (
|
|
256
|
-
this.
|
|
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
|
|
260
|
-
for (;
|
|
261
|
-
this.
|
|
262
|
-
if (a ===
|
|
263
|
-
this.
|
|
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
|
|
267
|
-
this.
|
|
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
|
-
|
|
271
|
-
|
|
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
|
|
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(
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
const
|
|
286
|
-
|
|
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
|
|
290
|
-
for (;
|
|
291
|
-
this.
|
|
292
|
-
const
|
|
293
|
-
this.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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(
|
|
303
|
-
const
|
|
304
|
-
for (let
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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(
|
|
321
|
-
this.
|
|
647
|
+
set_kind(t, s) {
|
|
648
|
+
const e = this._n, f = t * 12;
|
|
649
|
+
e[f] = e[f] & 16776960 | s & 255;
|
|
322
650
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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(
|
|
337
|
-
this.
|
|
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(
|
|
345
|
-
this.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
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(
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
-
|
|
374
|
-
|
|
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
|
-
|
|
377
|
-
this.
|
|
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(
|
|
385
|
-
const t =
|
|
386
|
-
let
|
|
387
|
-
for (;
|
|
388
|
-
|
|
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:
|
|
391
|
-
start: this.
|
|
392
|
-
end: this.
|
|
866
|
+
kind: N(s),
|
|
867
|
+
start: this.start_at(t),
|
|
868
|
+
end: this.end_at(t),
|
|
393
869
|
metadata: {
|
|
394
|
-
...this.metadata_at(
|
|
395
|
-
...
|
|
870
|
+
...this.metadata_at(t),
|
|
871
|
+
...f
|
|
396
872
|
},
|
|
397
|
-
parent:
|
|
398
|
-
next:
|
|
399
|
-
prev:
|
|
400
|
-
value: [this.
|
|
401
|
-
children:
|
|
402
|
-
index:
|
|
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
|
|
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(
|
|
412
|
-
const
|
|
413
|
-
this.capacity =
|
|
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(
|
|
428
|
-
const
|
|
429
|
-
|
|
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(
|
|
436
|
-
return this.indices[
|
|
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
|
|
445
|
-
|
|
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
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
};
|