@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/tsc/utils.js
CHANGED
|
@@ -1,5 +1,77 @@
|
|
|
1
1
|
/** default number of token entries to preallocate. */
|
|
2
2
|
const DEFAULT_TOKEN_CAPACITY = 128;
|
|
3
|
+
/** under 2 kb of slab, cheaper than a resize for a slightly larger document */
|
|
4
|
+
const MIN_NODE_CAPACITY = 32;
|
|
5
|
+
/**
|
|
6
|
+
* a buffer past the carve cap is its own ArrayBuffer, far costlier than a
|
|
7
|
+
* carve, so small documents should fit the slab
|
|
8
|
+
*/
|
|
9
|
+
const SLAB_BYTES = 1048576;
|
|
10
|
+
/**
|
|
11
|
+
* caps the tail a full slab can waste at a quarter, high since a one shot
|
|
12
|
+
* parse gives back what it does not use
|
|
13
|
+
*/
|
|
14
|
+
const SLAB_MAX_CARVE = 262144;
|
|
15
|
+
const EMPTY_U32 = new Uint32Array(0);
|
|
16
|
+
/** most documents set no metadata, the first set_metadata swaps in a real array */
|
|
17
|
+
const NO_META = Object.freeze([]);
|
|
18
|
+
const NODE_BYTES = 12 /* NodeField.stride */ * 4;
|
|
19
|
+
/** shared empty strings until own_strings, never written */
|
|
20
|
+
const NO_STRINGS = [];
|
|
21
|
+
/**
|
|
22
|
+
* uninitialized where the host allows, the template and a push write every
|
|
23
|
+
* word of a node before anything reads it
|
|
24
|
+
*/
|
|
25
|
+
const host_buffer = globalThis.Buffer;
|
|
26
|
+
const unzeroed = host_buffer !== undefined &&
|
|
27
|
+
typeof host_buffer.allocUnsafeSlow === 'function';
|
|
28
|
+
function new_storage(bytes) {
|
|
29
|
+
return unzeroed
|
|
30
|
+
? host_buffer.allocUnsafeSlow(bytes).buffer
|
|
31
|
+
: new ArrayBuffer(bytes);
|
|
32
|
+
}
|
|
33
|
+
/** a template copy repeats at most this many nodes, a longer source falls out of cache */
|
|
34
|
+
const TEMPLATE_BLOCK = 512;
|
|
35
|
+
/**
|
|
36
|
+
* template slots from up to to, no end, value, links, pending or meta, so a
|
|
37
|
+
* push writes only kind, start, parent and the links it makes
|
|
38
|
+
*/
|
|
39
|
+
function fill_template(n, from, to) {
|
|
40
|
+
// a copy is a runtime call, stores beat it for the few nodes a small document has
|
|
41
|
+
const short = to - from <= 64 ? to : from + 64;
|
|
42
|
+
for (let b = from * 12 /* NodeField.stride */; b < short * 12 /* NodeField.stride */;) {
|
|
43
|
+
n[b + 2 /* NodeField.end */] = 0xffffffff;
|
|
44
|
+
n[b + 3 /* NodeField.value_start */] = 0;
|
|
45
|
+
n[b + 4 /* NodeField.value_end */] = 0;
|
|
46
|
+
n[b + 6 /* NodeField.next */] = 0xffffffff;
|
|
47
|
+
n[b + 7 /* NodeField.prev */] = 0xffffffff;
|
|
48
|
+
n[b + 8 /* NodeField.first_child */] = 0xffffffff;
|
|
49
|
+
n[b + 9 /* NodeField.last_child */] = 0xffffffff;
|
|
50
|
+
n[b + 10 /* NodeField.pending */] = 0;
|
|
51
|
+
n[b + 11 /* NodeField.meta */] = 0;
|
|
52
|
+
b += 12 /* NodeField.stride */;
|
|
53
|
+
}
|
|
54
|
+
let done = short;
|
|
55
|
+
while (done < to) {
|
|
56
|
+
let count = done - from;
|
|
57
|
+
if (count > TEMPLATE_BLOCK)
|
|
58
|
+
count = TEMPLATE_BLOCK;
|
|
59
|
+
if (count > to - done)
|
|
60
|
+
count = to - done;
|
|
61
|
+
n.copyWithin(done * 12 /* NodeField.stride */, from * 12 /* NodeField.stride */, (from + count) * 12 /* NodeField.stride */);
|
|
62
|
+
done += count;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const SLAB_NODES = (SLAB_BYTES / NODE_BYTES) | 0;
|
|
66
|
+
const FILL_CHUNK = 4096;
|
|
67
|
+
/**
|
|
68
|
+
* a carve costs one view not a backing store but keeps its whole slab alive,
|
|
69
|
+
* a slab holds the template from slab_used on, a trim returns only unwritten slots
|
|
70
|
+
*/
|
|
71
|
+
let slab = new ArrayBuffer(0);
|
|
72
|
+
let slab_used = SLAB_BYTES;
|
|
73
|
+
/** the view whose region ends at slab_used, it can grow in place or shrink */
|
|
74
|
+
let last_carve = null;
|
|
3
75
|
/** default number of error entries to preallocate. */
|
|
4
76
|
const DEFAULT_ERROR_CAPACITY = 32;
|
|
5
77
|
/**
|
|
@@ -22,80 +94,82 @@ function next_power_of_two(value) {
|
|
|
22
94
|
export const kind_to_string = (kind) => {
|
|
23
95
|
switch (kind) {
|
|
24
96
|
case 0 /* NodeKind.root */:
|
|
25
|
-
return
|
|
97
|
+
return 'root';
|
|
26
98
|
case 1 /* NodeKind.text */:
|
|
27
|
-
return
|
|
99
|
+
return 'text';
|
|
28
100
|
case 2 /* NodeKind.html */:
|
|
29
|
-
return
|
|
101
|
+
return 'html';
|
|
30
102
|
case 3 /* NodeKind.heading */:
|
|
31
|
-
return
|
|
103
|
+
return 'heading';
|
|
32
104
|
case 4 /* NodeKind.mustache */:
|
|
33
|
-
return
|
|
105
|
+
return 'mustache';
|
|
34
106
|
case 5 /* NodeKind.code_fence */:
|
|
35
|
-
return
|
|
107
|
+
return 'code_fence';
|
|
36
108
|
case 6 /* NodeKind.line_break */:
|
|
37
|
-
return
|
|
109
|
+
return 'line_break';
|
|
38
110
|
case 7 /* NodeKind.paragraph */:
|
|
39
|
-
return
|
|
111
|
+
return 'paragraph';
|
|
40
112
|
case 8 /* NodeKind.code_span */:
|
|
41
|
-
return
|
|
113
|
+
return 'code_span';
|
|
42
114
|
case 9 /* NodeKind.emphasis */:
|
|
43
|
-
return
|
|
115
|
+
return 'emphasis';
|
|
44
116
|
case 10 /* NodeKind.strong_emphasis */:
|
|
45
|
-
return
|
|
117
|
+
return 'strong_emphasis';
|
|
46
118
|
case 11 /* NodeKind.thematic_break */:
|
|
47
|
-
return
|
|
119
|
+
return 'thematic_break';
|
|
48
120
|
case 12 /* NodeKind.link */:
|
|
49
|
-
return
|
|
121
|
+
return 'link';
|
|
50
122
|
case 13 /* NodeKind.image */:
|
|
51
|
-
return
|
|
123
|
+
return 'image';
|
|
52
124
|
case 14 /* NodeKind.block_quote */:
|
|
53
|
-
return
|
|
125
|
+
return 'block_quote';
|
|
54
126
|
case 15 /* NodeKind.list */:
|
|
55
|
-
return
|
|
127
|
+
return 'list';
|
|
56
128
|
case 16 /* NodeKind.list_item */:
|
|
57
|
-
return
|
|
129
|
+
return 'list_item';
|
|
58
130
|
case 17 /* NodeKind.hard_break */:
|
|
59
|
-
return
|
|
131
|
+
return 'hard_break';
|
|
60
132
|
case 18 /* NodeKind.soft_break */:
|
|
61
|
-
return
|
|
133
|
+
return 'soft_break';
|
|
62
134
|
case 19 /* NodeKind.strikethrough */:
|
|
63
|
-
return
|
|
135
|
+
return 'strikethrough';
|
|
64
136
|
case 20 /* NodeKind.superscript */:
|
|
65
|
-
return
|
|
137
|
+
return 'superscript';
|
|
66
138
|
case 21 /* NodeKind.subscript */:
|
|
67
|
-
return
|
|
139
|
+
return 'subscript';
|
|
68
140
|
case 22 /* NodeKind.table */:
|
|
69
|
-
return
|
|
141
|
+
return 'table';
|
|
70
142
|
case 23 /* NodeKind.table_header */:
|
|
71
|
-
return
|
|
143
|
+
return 'table_header';
|
|
72
144
|
case 24 /* NodeKind.table_row */:
|
|
73
|
-
return
|
|
145
|
+
return 'table_row';
|
|
74
146
|
case 25 /* NodeKind.table_cell */:
|
|
75
|
-
return
|
|
147
|
+
return 'table_cell';
|
|
76
148
|
case 26 /* NodeKind.html_comment */:
|
|
77
|
-
return
|
|
149
|
+
return 'html_comment';
|
|
78
150
|
case 27 /* NodeKind.svelte_tag */:
|
|
79
|
-
return
|
|
151
|
+
return 'svelte_tag';
|
|
80
152
|
case 28 /* NodeKind.svelte_block */:
|
|
81
|
-
return
|
|
153
|
+
return 'svelte_block';
|
|
82
154
|
case 29 /* NodeKind.svelte_branch */:
|
|
83
|
-
return
|
|
155
|
+
return 'svelte_branch';
|
|
84
156
|
case 30 /* NodeKind.directive_inline */:
|
|
85
|
-
return
|
|
157
|
+
return 'directive_inline';
|
|
86
158
|
case 31 /* NodeKind.directive_leaf */:
|
|
87
|
-
return
|
|
159
|
+
return 'directive_leaf';
|
|
88
160
|
case 32 /* NodeKind.directive_container */:
|
|
89
|
-
return
|
|
161
|
+
return 'directive_container';
|
|
90
162
|
case 33 /* NodeKind.frontmatter */:
|
|
91
|
-
return
|
|
163
|
+
return 'frontmatter';
|
|
92
164
|
case 34 /* NodeKind.import_statement */:
|
|
93
|
-
return
|
|
165
|
+
return 'import_statement';
|
|
166
|
+
case 35 /* NodeKind.directive_label */:
|
|
167
|
+
return 'directive_label';
|
|
94
168
|
}
|
|
95
169
|
};
|
|
96
170
|
/** reverse mapping from string name to numeric NodeKind. built once at module load. */
|
|
97
171
|
const _string_to_kind = new Map();
|
|
98
|
-
for (let i = 0; i <=
|
|
172
|
+
for (let i = 0; i <= 35; i++) {
|
|
99
173
|
_string_to_kind.set(kind_to_string(i), i);
|
|
100
174
|
}
|
|
101
175
|
/**
|
|
@@ -114,97 +188,327 @@ export const string_to_kind = (name) => {
|
|
|
114
188
|
const extra_to_string = (kind) => {
|
|
115
189
|
switch (kind) {
|
|
116
190
|
case 3 /* NodeKind.heading */:
|
|
117
|
-
return
|
|
191
|
+
return 'depth';
|
|
118
192
|
}
|
|
119
193
|
};
|
|
120
194
|
/**
|
|
121
|
-
*
|
|
195
|
+
* a computed key literal takes a slow generic define, so known keys get
|
|
196
|
+
* constant key literals and other keys a store into an empty literal
|
|
122
197
|
*/
|
|
198
|
+
export function make_meta(key, value) {
|
|
199
|
+
switch (key) {
|
|
200
|
+
case 'tag':
|
|
201
|
+
return { tag: value };
|
|
202
|
+
case 'href':
|
|
203
|
+
return { href: value };
|
|
204
|
+
case 'src':
|
|
205
|
+
return { src: value };
|
|
206
|
+
case 'ordered':
|
|
207
|
+
return { ordered: value };
|
|
208
|
+
case 'info_start':
|
|
209
|
+
return { info_start: value };
|
|
210
|
+
case 'name':
|
|
211
|
+
return { name: value };
|
|
212
|
+
case 'alignments':
|
|
213
|
+
return { alignments: value };
|
|
214
|
+
case 'attributes':
|
|
215
|
+
return { attributes: value };
|
|
216
|
+
case 'self_closing':
|
|
217
|
+
return { self_closing: value };
|
|
218
|
+
case 'title':
|
|
219
|
+
return { title: value };
|
|
220
|
+
case 'start':
|
|
221
|
+
return { start: value };
|
|
222
|
+
case 'tight':
|
|
223
|
+
return { tight: value };
|
|
224
|
+
case 'info_end':
|
|
225
|
+
return { info_end: value };
|
|
226
|
+
case 'args':
|
|
227
|
+
return { args: value };
|
|
228
|
+
case 'col_count':
|
|
229
|
+
return { col_count: value };
|
|
230
|
+
default: {
|
|
231
|
+
// a set would change the prototype, a literal defines an own property
|
|
232
|
+
if (key === '__proto__')
|
|
233
|
+
return { [key]: value };
|
|
234
|
+
const meta = {};
|
|
235
|
+
meta[key] = value;
|
|
236
|
+
return meta;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** named stores stay monomorphic, a keyed store goes megamorphic across shapes */
|
|
241
|
+
export function merge_meta(meta, key, value) {
|
|
242
|
+
switch (key) {
|
|
243
|
+
case 'attributes':
|
|
244
|
+
meta.attributes = value;
|
|
245
|
+
return;
|
|
246
|
+
case 'start':
|
|
247
|
+
meta.start = value;
|
|
248
|
+
return;
|
|
249
|
+
case 'tight':
|
|
250
|
+
meta.tight = value;
|
|
251
|
+
return;
|
|
252
|
+
case 'title':
|
|
253
|
+
meta.title = value;
|
|
254
|
+
return;
|
|
255
|
+
case 'self_closing':
|
|
256
|
+
meta.self_closing = value;
|
|
257
|
+
return;
|
|
258
|
+
case 'info_end':
|
|
259
|
+
meta.info_end = value;
|
|
260
|
+
return;
|
|
261
|
+
case 'col_count':
|
|
262
|
+
meta.col_count = value;
|
|
263
|
+
return;
|
|
264
|
+
case 'args':
|
|
265
|
+
meta.args = value;
|
|
266
|
+
return;
|
|
267
|
+
case 'tag':
|
|
268
|
+
meta.tag = value;
|
|
269
|
+
return;
|
|
270
|
+
case 'href':
|
|
271
|
+
meta.href = value;
|
|
272
|
+
return;
|
|
273
|
+
case 'src':
|
|
274
|
+
meta.src = value;
|
|
275
|
+
return;
|
|
276
|
+
case 'ordered':
|
|
277
|
+
meta.ordered = value;
|
|
278
|
+
return;
|
|
279
|
+
case 'info_start':
|
|
280
|
+
meta.info_start = value;
|
|
281
|
+
return;
|
|
282
|
+
case 'name':
|
|
283
|
+
meta.name = value;
|
|
284
|
+
return;
|
|
285
|
+
case 'alignments':
|
|
286
|
+
meta.alignments = value;
|
|
287
|
+
return;
|
|
288
|
+
default:
|
|
289
|
+
meta[key] = value;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
123
292
|
export class NodeBuffer {
|
|
124
|
-
/**
|
|
125
|
-
* create a buffer that stores token metadata with typed arrays.
|
|
126
|
-
* @param initial_capacity requested starting capacity for tokens.
|
|
127
|
-
*/
|
|
128
293
|
constructor(initial_capacity = DEFAULT_TOKEN_CAPACITY) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.
|
|
133
|
-
|
|
134
|
-
this.
|
|
135
|
-
|
|
136
|
-
this.
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
140
|
-
this._parents = new Uint32Array(capacity);
|
|
141
|
-
this._next_siblings = new Uint32Array(capacity);
|
|
142
|
-
this._prev_siblings = new Uint32Array(capacity);
|
|
143
|
-
this._children_starts = new Uint32Array(capacity);
|
|
144
|
-
this._children_ends = new Uint32Array(capacity);
|
|
145
|
-
this._pending_nodes = new Uint32Array(capacity);
|
|
294
|
+
// v8 sizes in-object slots from constructor stores, so every field is
|
|
295
|
+
// initialized here, not only in alloc, or the tail fields spill out of line
|
|
296
|
+
/** @internal */
|
|
297
|
+
this._capacity = 0;
|
|
298
|
+
/** @internal do not mutate externally */
|
|
299
|
+
this._n = EMPTY_U32;
|
|
300
|
+
/** @internal */
|
|
301
|
+
this._meta = NO_META;
|
|
302
|
+
/** @internal pre-materialized text strings (used by wiretreebuilder). index -> string. */
|
|
303
|
+
this._strings = NO_STRINGS;
|
|
304
|
+
/** @internal read by TreeBuilder to check ids against indices */
|
|
146
305
|
this._size = 0;
|
|
147
|
-
|
|
306
|
+
/** slots from _size up to here hold the template */
|
|
307
|
+
this._filled = 0;
|
|
308
|
+
// the comparison also sends a nan capacity to the floor
|
|
309
|
+
let n = this.alloc(next_power_of_two(initial_capacity > MIN_NODE_CAPACITY
|
|
310
|
+
? initial_capacity
|
|
311
|
+
: MIN_NODE_CAPACITY));
|
|
312
|
+
// the root push by hand, an inlined push_node would count against the
|
|
313
|
+
// inlining budget of every new TreeBuilder caller
|
|
314
|
+
if (this._filled === 0)
|
|
315
|
+
n = this.fill(0);
|
|
316
|
+
n[0] = 0 /* NodeKind.root */;
|
|
317
|
+
n[1 /* NodeField.start */] = 0;
|
|
318
|
+
n[5 /* NodeField.parent */] = 0xffffffff;
|
|
319
|
+
this._size = 1;
|
|
320
|
+
}
|
|
321
|
+
alloc(capacity) {
|
|
322
|
+
// a node is a whole number of words, so every carve stays word aligned
|
|
323
|
+
const bytes = capacity * NODE_BYTES;
|
|
324
|
+
let buffer;
|
|
325
|
+
let base = 0;
|
|
326
|
+
if (bytes <= SLAB_MAX_CARVE) {
|
|
327
|
+
if (slab_used + bytes > SLAB_BYTES) {
|
|
328
|
+
slab = new_storage(SLAB_BYTES);
|
|
329
|
+
slab_used = 0;
|
|
330
|
+
fill_template(new Uint32Array(slab), 0, SLAB_NODES);
|
|
331
|
+
}
|
|
332
|
+
buffer = slab;
|
|
333
|
+
base = slab_used;
|
|
334
|
+
slab_used = base + bytes;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
buffer = new_storage(bytes);
|
|
338
|
+
}
|
|
339
|
+
const n = new Uint32Array(buffer, base, capacity * 12 /* NodeField.stride */);
|
|
340
|
+
if (buffer === slab) {
|
|
341
|
+
last_carve = n;
|
|
342
|
+
this._filled = capacity;
|
|
343
|
+
}
|
|
344
|
+
else
|
|
345
|
+
this._filled = 0;
|
|
346
|
+
this._capacity = capacity;
|
|
347
|
+
this._n = n;
|
|
348
|
+
return n;
|
|
349
|
+
}
|
|
350
|
+
/** @internal */
|
|
351
|
+
own_strings() {
|
|
352
|
+
const strings = this._strings;
|
|
353
|
+
return strings === NO_STRINGS ? (this._strings = []) : strings;
|
|
354
|
+
}
|
|
355
|
+
/** gives the unused tail of the last slab carve back, a later push resizes */
|
|
356
|
+
trim() {
|
|
357
|
+
if (this._n !== last_carve)
|
|
358
|
+
return;
|
|
359
|
+
slab_used -= (this._capacity - this._size) * NODE_BYTES;
|
|
360
|
+
this._capacity = this._size;
|
|
361
|
+
this._filled = this._size;
|
|
148
362
|
}
|
|
149
|
-
/** clear
|
|
363
|
+
/** clear nodes without reallocating storage */
|
|
150
364
|
reset() {
|
|
151
|
-
|
|
365
|
+
// push writes every word of a node, so stale words need no clearing
|
|
366
|
+
// a length store is a runtime call even when already empty
|
|
367
|
+
if (this._meta.length !== 0)
|
|
368
|
+
this._meta.length = 0;
|
|
369
|
+
if (this._strings.length !== 0)
|
|
370
|
+
this._strings.length = 0;
|
|
371
|
+
// make the pushed slots template again, copying the template above them
|
|
372
|
+
// when there is enough, one copy costs about what stores for eight nodes do
|
|
373
|
+
const size = this._size;
|
|
374
|
+
if (size !== 0) {
|
|
375
|
+
if (size > 8 && size << 1 <= this._filled) {
|
|
376
|
+
const n = this._n;
|
|
377
|
+
for (let done = 0; done < size;) {
|
|
378
|
+
let count = size - done;
|
|
379
|
+
if (count > TEMPLATE_BLOCK)
|
|
380
|
+
count = TEMPLATE_BLOCK;
|
|
381
|
+
n.copyWithin(done * 12 /* NodeField.stride */, size * 12 /* NodeField.stride */, (size + count) * 12 /* NodeField.stride */);
|
|
382
|
+
done += count;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
else
|
|
386
|
+
fill_template(this._n, 0, size);
|
|
387
|
+
this._size = 0;
|
|
388
|
+
}
|
|
152
389
|
}
|
|
153
|
-
/** number of tokens currently stored. */
|
|
154
390
|
get size() {
|
|
155
391
|
return this._size;
|
|
156
392
|
}
|
|
157
393
|
/**
|
|
158
|
-
* push a
|
|
159
|
-
* @param kind
|
|
394
|
+
* push a node as the last child of parent
|
|
395
|
+
* @param kind node category.
|
|
160
396
|
* @param cursor cursor position
|
|
161
|
-
* @param parent index of the parent node, or
|
|
162
|
-
* @param extra extra metadata stored alongside the
|
|
397
|
+
* @param parent index of the parent node, or 0xffffffff for none.
|
|
398
|
+
* @param extra extra metadata stored alongside the node.
|
|
163
399
|
* @param metadata optional metadata associated with the node.
|
|
164
400
|
*/
|
|
165
401
|
push(kind, cursor, parent = 0xffffffff, extra = 0, metadata) {
|
|
402
|
+
const index = this.push_node(kind, cursor, parent, extra, false);
|
|
403
|
+
if (metadata !== undefined)
|
|
404
|
+
this.set_metadata(index, metadata);
|
|
405
|
+
return index;
|
|
406
|
+
}
|
|
407
|
+
push_pending(kind, cursor, parent = 0xffffffff, extra = 0, metadata) {
|
|
408
|
+
const index = this.push_node(kind, cursor, parent, extra, true);
|
|
409
|
+
if (metadata !== undefined)
|
|
410
|
+
this.set_metadata(index, metadata);
|
|
411
|
+
return index;
|
|
412
|
+
}
|
|
413
|
+
/** one body for every open so the builder inlines a single copy */
|
|
414
|
+
push_node(kind, cursor, parent, extra, pending) {
|
|
166
415
|
const index = this._size;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
416
|
+
let n = this._n;
|
|
417
|
+
if (index >= this._filled)
|
|
418
|
+
n = this.fill(index);
|
|
419
|
+
// the template holds every other word
|
|
420
|
+
const b = index * 12 /* NodeField.stride */;
|
|
421
|
+
n[b] = (kind & 0xff) | ((extra & 0xffff) << 8);
|
|
422
|
+
n[b + 1 /* NodeField.start */] = cursor;
|
|
423
|
+
n[b + 5 /* NodeField.parent */] = parent;
|
|
424
|
+
if (pending)
|
|
425
|
+
n[b + 10 /* NodeField.pending */] = 1;
|
|
174
426
|
this._size = index + 1;
|
|
175
|
-
this._parents[index] = parent;
|
|
176
|
-
this._next_siblings[index] = 0xffffffff;
|
|
177
|
-
this._prev_siblings[index] = 0xffffffff;
|
|
178
|
-
this._children_starts[index] = 0xffffffff;
|
|
179
|
-
this._children_ends[index] = 0xffffffff;
|
|
180
427
|
if (parent !== 0xffffffff) {
|
|
181
|
-
const
|
|
428
|
+
const p = parent * 12 /* NodeField.stride */;
|
|
429
|
+
const last = n[p + 9 /* NodeField.last_child */];
|
|
182
430
|
if (last === 0xffffffff) {
|
|
183
431
|
// first child
|
|
184
|
-
|
|
432
|
+
n[p + 8 /* NodeField.first_child */] = index;
|
|
185
433
|
}
|
|
186
434
|
else {
|
|
187
435
|
// append after last child, o(1)
|
|
188
|
-
|
|
189
|
-
|
|
436
|
+
n[last * 12 /* NodeField.stride */ + 6 /* NodeField.next */] = index;
|
|
437
|
+
n[b + 7 /* NodeField.prev */] = last;
|
|
190
438
|
}
|
|
191
|
-
|
|
439
|
+
n[p + 9 /* NodeField.last_child */] = index;
|
|
192
440
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
441
|
+
return index;
|
|
442
|
+
}
|
|
443
|
+
/** parent must be a node, not 0xffffffff */
|
|
444
|
+
push_text(start, end, parent) {
|
|
445
|
+
const index = this._size;
|
|
446
|
+
let n = this._n;
|
|
447
|
+
if (index >= this._filled)
|
|
448
|
+
n = this.fill(index);
|
|
449
|
+
const b = index * 12 /* NodeField.stride */;
|
|
450
|
+
n[b] = 1 /* NodeKind.text */;
|
|
451
|
+
n[b + 1 /* NodeField.start */] = start;
|
|
452
|
+
n[b + 2 /* NodeField.end */] = end;
|
|
453
|
+
n[b + 3 /* NodeField.value_start */] = start;
|
|
454
|
+
n[b + 4 /* NodeField.value_end */] = end;
|
|
455
|
+
n[b + 5 /* NodeField.parent */] = parent;
|
|
456
|
+
this._size = index + 1;
|
|
457
|
+
const p = parent * 12 /* NodeField.stride */;
|
|
458
|
+
const last = n[p + 9 /* NodeField.last_child */];
|
|
459
|
+
if (last === 0xffffffff) {
|
|
460
|
+
n[p + 8 /* NodeField.first_child */] = index;
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
n[last * 12 /* NodeField.stride */ + 6 /* NodeField.next */] = index;
|
|
464
|
+
n[b + 7 /* NodeField.prev */] = last;
|
|
197
465
|
}
|
|
466
|
+
n[p + 9 /* NodeField.last_child */] = index;
|
|
198
467
|
return index;
|
|
199
468
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
469
|
+
/** a closed node with no extra and a value range, as open, value and close would leave it */
|
|
470
|
+
push_leaf(kind, start, value_start, value_end, end, parent) {
|
|
471
|
+
const index = this._size;
|
|
472
|
+
let n = this._n;
|
|
473
|
+
if (index >= this._filled)
|
|
474
|
+
n = this.fill(index);
|
|
475
|
+
const b = index * 12 /* NodeField.stride */;
|
|
476
|
+
n[b] = kind;
|
|
477
|
+
n[b + 1 /* NodeField.start */] = start;
|
|
478
|
+
n[b + 2 /* NodeField.end */] = end;
|
|
479
|
+
n[b + 3 /* NodeField.value_start */] = value_start;
|
|
480
|
+
n[b + 4 /* NodeField.value_end */] = value_end;
|
|
481
|
+
n[b + 5 /* NodeField.parent */] = parent;
|
|
482
|
+
this._size = index + 1;
|
|
483
|
+
const p = parent * 12 /* NodeField.stride */;
|
|
484
|
+
const last = n[p + 9 /* NodeField.last_child */];
|
|
485
|
+
if (last === 0xffffffff) {
|
|
486
|
+
n[p + 8 /* NodeField.first_child */] = index;
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
n[last * 12 /* NodeField.stride */ + 6 /* NodeField.next */] = index;
|
|
490
|
+
n[b + 7 /* NodeField.prev */] = last;
|
|
491
|
+
}
|
|
492
|
+
n[p + 9 /* NodeField.last_child */] = index;
|
|
203
493
|
return index;
|
|
204
494
|
}
|
|
495
|
+
fill(index) {
|
|
496
|
+
let n = this._n;
|
|
497
|
+
if (index >= this._capacity)
|
|
498
|
+
n = this.grow();
|
|
499
|
+
let filled = this._filled;
|
|
500
|
+
if (index >= filled) {
|
|
501
|
+
let to = filled + (filled > FILL_CHUNK ? filled : FILL_CHUNK);
|
|
502
|
+
if (to > this._capacity)
|
|
503
|
+
to = this._capacity;
|
|
504
|
+
fill_template(n, filled, to);
|
|
505
|
+
this._filled = filled = to;
|
|
506
|
+
}
|
|
507
|
+
return n;
|
|
508
|
+
}
|
|
205
509
|
/**
|
|
206
510
|
* allocate a node slot without linking it into any parent's child list.
|
|
207
|
-
* the caller is responsible for setting
|
|
511
|
+
* the caller is responsible for setting the parent and linking into the
|
|
208
512
|
* sibling chain manually. used by plugin structural mutations (prepend).
|
|
209
513
|
* @param kind node kind.
|
|
210
514
|
* @param cursor source position.
|
|
@@ -213,25 +517,7 @@ export class NodeBuffer {
|
|
|
213
517
|
* @returns buffer index of the new node.
|
|
214
518
|
*/
|
|
215
519
|
push_unlinked(kind, cursor, extra = 0, metadata) {
|
|
216
|
-
|
|
217
|
-
if (index >= this.capacity) {
|
|
218
|
-
this.grow();
|
|
219
|
-
}
|
|
220
|
-
this._kinds[index] = kind;
|
|
221
|
-
this._starts[index] = cursor >>> 0;
|
|
222
|
-
this._ends[index] = 0xffffffff;
|
|
223
|
-
this._extras[index] = extra & 0xffff;
|
|
224
|
-
this._size = index + 1;
|
|
225
|
-
this._parents[index] = 0xffffffff;
|
|
226
|
-
this._next_siblings[index] = 0xffffffff;
|
|
227
|
-
this._prev_siblings[index] = 0xffffffff;
|
|
228
|
-
this._children_starts[index] = 0xffffffff;
|
|
229
|
-
this._children_ends[index] = 0xffffffff;
|
|
230
|
-
if (metadata !== undefined) {
|
|
231
|
-
this.metadata.set(index, metadata);
|
|
232
|
-
this.has_metadata[index >> 3] |= 1 << (index & 7);
|
|
233
|
-
}
|
|
234
|
-
return index;
|
|
520
|
+
return this.push(kind, cursor, 0xffffffff, extra, metadata);
|
|
235
521
|
}
|
|
236
522
|
/**
|
|
237
523
|
* insert a new wrapper node between a parent and all its current children.
|
|
@@ -245,33 +531,34 @@ export class NodeBuffer {
|
|
|
245
531
|
* @returns buffer index of the new wrapper node.
|
|
246
532
|
*/
|
|
247
533
|
wrap_children(parent_idx, new_kind, extra = 0, metadata) {
|
|
248
|
-
const first_child = this.
|
|
249
|
-
const last_child = this.
|
|
534
|
+
const first_child = this.first_child_at(parent_idx);
|
|
535
|
+
const last_child = this.last_child_at(parent_idx);
|
|
250
536
|
// detach children from parent
|
|
251
|
-
this.
|
|
252
|
-
this.
|
|
537
|
+
this.set_first_child(parent_idx, 0xffffffff);
|
|
538
|
+
this.set_last_child(parent_idx, 0xffffffff);
|
|
253
539
|
// push wrapper as sole child of parent (auto-links via push)
|
|
254
540
|
const wrapper_idx = this.push(new_kind, 0, parent_idx, extra, metadata);
|
|
255
541
|
// reattach old children to wrapper
|
|
256
542
|
if (first_child !== 0xffffffff) {
|
|
257
|
-
this.
|
|
258
|
-
this.
|
|
543
|
+
this.set_first_child(wrapper_idx, first_child);
|
|
544
|
+
this.set_last_child(wrapper_idx, last_child);
|
|
259
545
|
// update parent pointers on all moved children
|
|
260
546
|
let child = first_child;
|
|
261
|
-
while (child !== 0xffffffff && this.
|
|
262
|
-
this.
|
|
263
|
-
child = this.
|
|
547
|
+
while (child !== 0xffffffff && this.parent_at(child) === parent_idx) {
|
|
548
|
+
this.set_parent(child, wrapper_idx);
|
|
549
|
+
child = this.next_at(child);
|
|
264
550
|
}
|
|
265
551
|
}
|
|
266
552
|
return wrapper_idx;
|
|
267
553
|
}
|
|
268
554
|
commit_node(index) {
|
|
269
|
-
this.
|
|
555
|
+
this._n[index * 12 /* NodeField.stride */ + 10 /* NodeField.pending */] = 0;
|
|
270
556
|
}
|
|
271
557
|
get_pending() {
|
|
272
558
|
const result = [];
|
|
559
|
+
const n = this._n;
|
|
273
560
|
for (let i = 0; i < this._size; i++) {
|
|
274
|
-
if (
|
|
561
|
+
if (n[i * 12 /* NodeField.stride */ + 10 /* NodeField.pending */] !== 0) {
|
|
275
562
|
result.push(i);
|
|
276
563
|
}
|
|
277
564
|
}
|
|
@@ -294,16 +581,16 @@ export class NodeBuffer {
|
|
|
294
581
|
* @param delimiter_text optional pre-resolved delimiter string (wire path).
|
|
295
582
|
* if provided, stored in _strings. if absent, value range is set from
|
|
296
583
|
* the node's start position.
|
|
584
|
+
* @param text_start source offset of delimiter_text, at the node start the
|
|
585
|
+
* repaired range slices the same text so it is not stored
|
|
297
586
|
*/
|
|
298
|
-
handle_repair(index, delimiter_text) {
|
|
299
|
-
const parent = this.
|
|
300
|
-
const kind = this.
|
|
301
|
-
const parent_kind = parent !== 0xffffffff ? this.
|
|
302
|
-
// tight
|
|
303
|
-
// a
|
|
304
|
-
|
|
305
|
-
// the wrapper and reparents children to the list_item.
|
|
306
|
-
if (kind === 7 /* NodeKind.paragraph */ && parent_kind === 16 /* NodeKind.list_item */) {
|
|
587
|
+
handle_repair(index, delimiter_text, text_start) {
|
|
588
|
+
const parent = this.parent_at(index);
|
|
589
|
+
const kind = this.kind_at(index);
|
|
590
|
+
const parent_kind = parent !== 0xffffffff ? this.kind_at(parent) : undefined;
|
|
591
|
+
// a revoked paragraph is a wrapper a tight list item or a paragraph of only tags does not need
|
|
592
|
+
// a revoked table cell was a merge marker, the cell it joined spans its column
|
|
593
|
+
if (kind === 7 /* NodeKind.paragraph */ || kind === 25 /* NodeKind.table_cell */) {
|
|
307
594
|
this.unwrap_node(index);
|
|
308
595
|
return;
|
|
309
596
|
}
|
|
@@ -315,7 +602,7 @@ export class NodeBuffer {
|
|
|
315
602
|
if (parent_kind === 0 /* NodeKind.root */ ||
|
|
316
603
|
parent_kind === 14 /* NodeKind.block_quote */ ||
|
|
317
604
|
parent_kind === 16 /* NodeKind.list_item */) {
|
|
318
|
-
const start = this.
|
|
605
|
+
const start = this.start_at(index);
|
|
319
606
|
let end;
|
|
320
607
|
if (delimiter_text !== undefined) {
|
|
321
608
|
// wire path: delimiter_text is the literal open-tag source
|
|
@@ -324,24 +611,24 @@ export class NodeBuffer {
|
|
|
324
611
|
else {
|
|
325
612
|
// source path: prefer the node's recorded end; fall back to the
|
|
326
613
|
// nearest meaningful child position so we never collapse to start.
|
|
327
|
-
end = this.
|
|
614
|
+
end = this.end_at(index);
|
|
328
615
|
if (end === 0xffffffff) {
|
|
329
|
-
let child = this.
|
|
330
|
-
while (child !== 0xffffffff && this.
|
|
331
|
-
if (this.
|
|
332
|
-
const lb_start = this.
|
|
616
|
+
let child = this.first_child_at(index);
|
|
617
|
+
while (child !== 0xffffffff && this.parent_at(child) === index) {
|
|
618
|
+
if (this.kind_at(child) === 6 /* NodeKind.line_break */) {
|
|
619
|
+
const lb_start = this.start_at(child);
|
|
333
620
|
if (lb_start > 0 && (end === 0xffffffff || lb_start > end)) {
|
|
334
621
|
end = lb_start;
|
|
335
622
|
}
|
|
336
623
|
}
|
|
337
624
|
else {
|
|
338
|
-
const child_end = this.
|
|
625
|
+
const child_end = this.end_at(child);
|
|
339
626
|
if (child_end !== 0xffffffff &&
|
|
340
627
|
(end === 0xffffffff || child_end > end)) {
|
|
341
628
|
end = child_end;
|
|
342
629
|
}
|
|
343
630
|
}
|
|
344
|
-
child = this.
|
|
631
|
+
child = this.next_at(child);
|
|
345
632
|
}
|
|
346
633
|
}
|
|
347
634
|
if (end === 0xffffffff || end <= start) {
|
|
@@ -351,45 +638,45 @@ export class NodeBuffer {
|
|
|
351
638
|
}
|
|
352
639
|
// reparent children to the grandparent so trailing parsed content
|
|
353
640
|
// (e.g. block elements that followed the unclosed open tag) is kept.
|
|
354
|
-
const child_chain = this.
|
|
355
|
-
this.
|
|
356
|
-
this.
|
|
641
|
+
const child_chain = this.first_child_at(index);
|
|
642
|
+
this.set_first_child(index, 0xffffffff);
|
|
643
|
+
this.set_last_child(index, 0xffffffff);
|
|
357
644
|
// convert this node into a paragraph holding the literal open-tag text.
|
|
358
645
|
this.set_kind(index, 7 /* NodeKind.paragraph */);
|
|
359
|
-
this.
|
|
360
|
-
this.
|
|
646
|
+
this.delete_metadata(index);
|
|
647
|
+
this.set_end(index, end);
|
|
361
648
|
const text_idx = this.push(1 /* NodeKind.text */, start, index);
|
|
362
|
-
this.
|
|
363
|
-
this.
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
this._strings[text_idx] = delimiter_text;
|
|
649
|
+
this.set_value(text_idx, start, end);
|
|
650
|
+
this.set_end(text_idx, end);
|
|
651
|
+
if (delimiter_text !== undefined && text_start !== start) {
|
|
652
|
+
this.own_strings()[text_idx] = delimiter_text;
|
|
367
653
|
}
|
|
368
654
|
// splice the original children in after the rewritten node so they
|
|
369
655
|
// appear as siblings under the parent.
|
|
370
656
|
if (child_chain !== 0xffffffff) {
|
|
371
|
-
const original_next = this.
|
|
657
|
+
const original_next = this.next_at(index);
|
|
372
658
|
let last_child = child_chain;
|
|
373
659
|
let scan = child_chain;
|
|
374
|
-
while (scan !== 0xffffffff && this.
|
|
375
|
-
this.
|
|
660
|
+
while (scan !== 0xffffffff && this.parent_at(scan) === index) {
|
|
661
|
+
this.set_parent(scan, parent);
|
|
376
662
|
last_child = scan;
|
|
377
|
-
scan = this.
|
|
663
|
+
scan = this.next_at(scan);
|
|
378
664
|
}
|
|
379
|
-
this.
|
|
665
|
+
this.set_next(last_child, original_next);
|
|
380
666
|
if (original_next !== 0xffffffff) {
|
|
381
|
-
this.
|
|
667
|
+
this.set_prev(original_next, last_child);
|
|
382
668
|
}
|
|
383
|
-
else if (parent !== 0xffffffff &&
|
|
384
|
-
this.
|
|
669
|
+
else if (parent !== 0xffffffff &&
|
|
670
|
+
this.last_child_at(parent) === index) {
|
|
671
|
+
this.set_last_child(parent, last_child);
|
|
385
672
|
}
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
673
|
+
this.set_next(index, child_chain);
|
|
674
|
+
this.set_prev(child_chain, index);
|
|
388
675
|
}
|
|
389
676
|
return;
|
|
390
677
|
}
|
|
391
678
|
// inline repair
|
|
392
|
-
const first_child = this.
|
|
679
|
+
const first_child = this.first_child_at(index);
|
|
393
680
|
// convert the wrapper to a plain text node whose value is the
|
|
394
681
|
// literal delimiter (e.g. "~" for subscript, "<div>" for an
|
|
395
682
|
// inline html open tag). any children stay in the document,
|
|
@@ -397,107 +684,116 @@ export class NodeBuffer {
|
|
|
397
684
|
// content is preserved after revocation.
|
|
398
685
|
this.set_kind(index, 1 /* NodeKind.text */);
|
|
399
686
|
if (delimiter_text !== undefined) {
|
|
400
|
-
this.
|
|
401
|
-
|
|
687
|
+
const start = this.start_at(index);
|
|
688
|
+
if (text_start !== start)
|
|
689
|
+
this.own_strings()[index] = delimiter_text;
|
|
402
690
|
const end = start + delimiter_text.length;
|
|
403
|
-
this.
|
|
404
|
-
this.
|
|
405
|
-
this._ends[index] = end;
|
|
691
|
+
this.set_value(index, start, end);
|
|
692
|
+
this.set_end(index, end);
|
|
406
693
|
if (first_child === 0xffffffff) {
|
|
407
|
-
this.
|
|
408
|
-
this.
|
|
694
|
+
this.set_first_child(index, 0xffffffff);
|
|
695
|
+
this.set_last_child(index, 0xffffffff);
|
|
409
696
|
return;
|
|
410
697
|
}
|
|
411
698
|
// reparent children and splice them in after this text node.
|
|
412
699
|
let child = first_child;
|
|
413
700
|
let last_child = first_child;
|
|
414
|
-
while (child !== 0xffffffff && this.
|
|
415
|
-
this.
|
|
701
|
+
while (child !== 0xffffffff && this.parent_at(child) === index) {
|
|
702
|
+
this.set_parent(child, parent);
|
|
416
703
|
last_child = child;
|
|
417
|
-
child = this.
|
|
704
|
+
child = this.next_at(child);
|
|
418
705
|
}
|
|
419
|
-
const node_next = this.
|
|
420
|
-
this.
|
|
421
|
-
this.
|
|
422
|
-
if (node_next !== 0xffffffff && this.
|
|
423
|
-
this.
|
|
424
|
-
this.
|
|
706
|
+
const node_next = this.next_at(index);
|
|
707
|
+
this.set_next(index, first_child);
|
|
708
|
+
this.set_prev(first_child, index);
|
|
709
|
+
if (node_next !== 0xffffffff && this.parent_at(node_next) === parent) {
|
|
710
|
+
this.set_next(last_child, node_next);
|
|
711
|
+
this.set_prev(node_next, last_child);
|
|
425
712
|
}
|
|
426
713
|
else {
|
|
427
|
-
this.
|
|
714
|
+
this.set_next(last_child, 0xffffffff);
|
|
428
715
|
}
|
|
429
|
-
if (this.
|
|
430
|
-
this.
|
|
716
|
+
if (this.last_child_at(parent) === index) {
|
|
717
|
+
this.set_last_child(parent, last_child);
|
|
431
718
|
}
|
|
432
|
-
this.
|
|
433
|
-
this.
|
|
719
|
+
this.set_first_child(index, 0xffffffff);
|
|
720
|
+
this.set_last_child(index, 0xffffffff);
|
|
434
721
|
return;
|
|
435
722
|
}
|
|
436
723
|
// source-based fallback, derive the delimiter byte range from
|
|
437
724
|
// the node's own start offset.
|
|
438
725
|
if (first_child === 0xffffffff) {
|
|
439
|
-
this.
|
|
440
|
-
this.
|
|
441
|
-
|
|
442
|
-
if (this.
|
|
443
|
-
|
|
444
|
-
|
|
726
|
+
this.set_first_child(index, 0xffffffff);
|
|
727
|
+
this.set_last_child(index, 0xffffffff);
|
|
728
|
+
const start = this.start_at(index);
|
|
729
|
+
if (this.end_at(index) === 0xffffffff) {
|
|
730
|
+
// an opener that records where its content starts ends there
|
|
731
|
+
const content_start = this.value_start_at(index);
|
|
732
|
+
const end = content_start > start ? content_start : start + 1;
|
|
733
|
+
this.set_value(index, start, end);
|
|
734
|
+
this.set_end(index, end);
|
|
445
735
|
}
|
|
446
736
|
else {
|
|
447
|
-
this.
|
|
737
|
+
this.set_value_start(index, start);
|
|
738
|
+
this.set_value_end(index, this.end_at(index));
|
|
448
739
|
}
|
|
449
740
|
return;
|
|
450
741
|
}
|
|
451
742
|
// walk sibling chain and reparent only direct children
|
|
452
743
|
let child = first_child;
|
|
453
744
|
let last_child = first_child;
|
|
454
|
-
while (child !== 0xffffffff && this.
|
|
455
|
-
this.
|
|
745
|
+
while (child !== 0xffffffff && this.parent_at(child) === index) {
|
|
746
|
+
this.set_parent(child, parent);
|
|
456
747
|
last_child = child;
|
|
457
|
-
child = this.
|
|
748
|
+
child = this.next_at(child);
|
|
458
749
|
}
|
|
459
|
-
//
|
|
750
|
+
// merge a lone text child into the delimiter, a cell text ends at the pipe past its value
|
|
460
751
|
if (last_child === first_child &&
|
|
461
|
-
this.
|
|
462
|
-
this.
|
|
463
|
-
this.
|
|
464
|
-
this._ends[index] = this._ends[first_child];
|
|
752
|
+
this.kind_at(first_child) === 1 /* NodeKind.text */) {
|
|
753
|
+
this.set_value(index, this.start_at(index), this.value_end_at(first_child));
|
|
754
|
+
this.set_end(index, this.end_at(first_child));
|
|
465
755
|
// skip the child in the sibling chain
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
756
|
+
const after = this.next_at(first_child);
|
|
757
|
+
this.set_next(index, after);
|
|
758
|
+
if (after !== 0xffffffff) {
|
|
759
|
+
this.set_prev(after, index);
|
|
469
760
|
}
|
|
470
|
-
this.
|
|
471
|
-
this.
|
|
761
|
+
this.set_first_child(index, 0xffffffff);
|
|
762
|
+
this.set_last_child(index, 0xffffffff);
|
|
472
763
|
return;
|
|
473
764
|
}
|
|
474
765
|
// insert converted node as sibling before first_child, reparent rest
|
|
475
|
-
const first_child_prev = this.
|
|
476
|
-
this.
|
|
477
|
-
this.
|
|
766
|
+
const first_child_prev = this.prev_at(first_child);
|
|
767
|
+
this.set_next(index, first_child);
|
|
768
|
+
this.set_prev(first_child, index);
|
|
478
769
|
if (first_child_prev !== 0xffffffff) {
|
|
479
|
-
this.
|
|
480
|
-
this.
|
|
770
|
+
this.set_next(first_child_prev, index);
|
|
771
|
+
this.set_prev(index, first_child_prev);
|
|
481
772
|
}
|
|
482
|
-
if (this.
|
|
483
|
-
this.
|
|
773
|
+
if (this.last_child_at(parent) === index) {
|
|
774
|
+
this.set_last_child(parent, last_child);
|
|
484
775
|
}
|
|
485
776
|
// clear children references
|
|
486
|
-
this.
|
|
487
|
-
this.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
777
|
+
this.set_first_child(index, 0xffffffff);
|
|
778
|
+
this.set_last_child(index, 0xffffffff);
|
|
779
|
+
// use start, a soft_break child has no value range
|
|
780
|
+
const value_start = this.start_at(index);
|
|
781
|
+
const value_end = this.start_at(first_child);
|
|
782
|
+
this.set_value(index, value_start, value_end);
|
|
783
|
+
this.set_end(index, value_end);
|
|
491
784
|
}
|
|
492
785
|
repair() {
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
786
|
+
const n = this._n;
|
|
787
|
+
for (let i = 0; i < this._size; i++) {
|
|
788
|
+
if (n[i * 12 /* NodeField.stride */ + 10 /* NodeField.pending */] !== 0) {
|
|
789
|
+
this.handle_repair(i);
|
|
496
790
|
}
|
|
497
|
-
}
|
|
791
|
+
}
|
|
498
792
|
}
|
|
499
793
|
pop() {
|
|
500
|
-
this._size
|
|
794
|
+
const i = --this._size;
|
|
795
|
+
// the popped slot is the template again, as a push expects
|
|
796
|
+
fill_template(this._n, i, i + 1);
|
|
501
797
|
}
|
|
502
798
|
/**
|
|
503
799
|
* remove a node from the tree and reparent its children to its parent.
|
|
@@ -505,88 +801,81 @@ export class NodeBuffer {
|
|
|
505
801
|
* in the parent's child list.
|
|
506
802
|
*/
|
|
507
803
|
unwrap_node(index) {
|
|
508
|
-
const parent = this.
|
|
509
|
-
const first_child = this.
|
|
804
|
+
const parent = this.parent_at(index);
|
|
805
|
+
const first_child = this.first_child_at(index);
|
|
510
806
|
if (first_child === 0xffffffff) {
|
|
511
807
|
// no children, remove from sibling chain
|
|
512
|
-
const prev_sib = this.
|
|
513
|
-
const next_sib = this.
|
|
808
|
+
const prev_sib = this.prev_at(index);
|
|
809
|
+
const next_sib = this.next_at(index);
|
|
514
810
|
if (prev_sib !== 0xffffffff) {
|
|
515
|
-
this.
|
|
811
|
+
this.set_next(prev_sib, next_sib);
|
|
516
812
|
}
|
|
517
813
|
else if (parent !== 0xffffffff) {
|
|
518
|
-
this.
|
|
814
|
+
this.set_first_child(parent, next_sib);
|
|
519
815
|
}
|
|
520
816
|
if (next_sib !== 0xffffffff) {
|
|
521
|
-
this.
|
|
817
|
+
this.set_prev(next_sib, prev_sib);
|
|
522
818
|
}
|
|
523
819
|
// update parent's last child if we removed the tail
|
|
524
|
-
if (parent !== 0xffffffff && this.
|
|
525
|
-
this.
|
|
820
|
+
if (parent !== 0xffffffff && this.last_child_at(parent) === index) {
|
|
821
|
+
this.set_last_child(parent, prev_sib); // 0xffffffff if was only child
|
|
526
822
|
}
|
|
527
823
|
return;
|
|
528
824
|
}
|
|
529
825
|
// reparent all children and find last child
|
|
530
826
|
let child = first_child;
|
|
531
827
|
let last_child = first_child;
|
|
532
|
-
while (child !== 0xffffffff && this.
|
|
533
|
-
this.
|
|
828
|
+
while (child !== 0xffffffff && this.parent_at(child) === index) {
|
|
829
|
+
this.set_parent(child, parent);
|
|
534
830
|
last_child = child;
|
|
535
|
-
child = this.
|
|
831
|
+
child = this.next_at(child);
|
|
536
832
|
}
|
|
537
833
|
// splice children into parent's child list where this node was
|
|
538
|
-
const prev_sib = this.
|
|
539
|
-
const next_sib = this._next_siblings[last_child] !== 0xffffffff &&
|
|
540
|
-
this._parents[this._next_siblings[last_child]] === index
|
|
541
|
-
? 0xffffffff
|
|
542
|
-
: this._next_siblings[last_child];
|
|
834
|
+
const prev_sib = this.prev_at(index);
|
|
543
835
|
// the actual next sibling of the unwrapped node (not of last_child)
|
|
544
|
-
const node_next = this.
|
|
836
|
+
const node_next = this.next_at(index);
|
|
545
837
|
if (prev_sib !== 0xffffffff) {
|
|
546
|
-
this.
|
|
547
|
-
this.
|
|
838
|
+
this.set_next(prev_sib, first_child);
|
|
839
|
+
this.set_prev(first_child, prev_sib);
|
|
548
840
|
}
|
|
549
841
|
else if (parent !== 0xffffffff) {
|
|
550
|
-
this.
|
|
551
|
-
this.
|
|
842
|
+
this.set_first_child(parent, first_child);
|
|
843
|
+
this.set_prev(first_child, 0xffffffff);
|
|
552
844
|
}
|
|
553
845
|
// link last child to the unwrapped node's next sibling
|
|
554
846
|
if (node_next !== 0xffffffff && node_next !== first_child) {
|
|
555
|
-
this.
|
|
556
|
-
this.
|
|
847
|
+
this.set_next(last_child, node_next);
|
|
848
|
+
this.set_prev(node_next, last_child);
|
|
557
849
|
}
|
|
558
850
|
else {
|
|
559
|
-
this.
|
|
851
|
+
this.set_next(last_child, 0xffffffff);
|
|
560
852
|
}
|
|
561
853
|
// update parent's last child if we replaced the tail
|
|
562
|
-
if (parent !== 0xffffffff && this.
|
|
563
|
-
this.
|
|
854
|
+
if (parent !== 0xffffffff && this.last_child_at(parent) === index) {
|
|
855
|
+
this.set_last_child(parent, last_child);
|
|
564
856
|
}
|
|
565
857
|
// clear the unwrapped node's links
|
|
566
|
-
this.
|
|
567
|
-
this.
|
|
858
|
+
this.set_first_child(index, 0xffffffff);
|
|
859
|
+
this.set_last_child(index, 0xffffffff);
|
|
568
860
|
}
|
|
569
861
|
set_parent_kind(index, kind) {
|
|
570
|
-
const parent_index = this.
|
|
862
|
+
const parent_index = this.parent_at(index);
|
|
571
863
|
if (parent_index !== 0xffffffff) {
|
|
572
|
-
this.
|
|
864
|
+
this.set_kind(parent_index, kind);
|
|
573
865
|
}
|
|
574
866
|
}
|
|
575
867
|
/** return indices of all nodes matching the given kind (lazy scan). */
|
|
576
868
|
get_kinds(kind) {
|
|
577
869
|
const result = [];
|
|
870
|
+
const n = this._n;
|
|
578
871
|
for (let i = 0; i < this._size; i++) {
|
|
579
|
-
if (
|
|
872
|
+
if ((n[i * 12 /* NodeField.stride */] & 0xff) === kind)
|
|
580
873
|
result.push(i);
|
|
581
874
|
}
|
|
582
875
|
return result;
|
|
583
876
|
}
|
|
584
|
-
/**
|
|
585
|
-
* get the token kind recorded at the supplied index.
|
|
586
|
-
* @param index token index.
|
|
587
|
-
*/
|
|
588
877
|
kind_at(index) {
|
|
589
|
-
return this.
|
|
878
|
+
return (this._n[index * 12 /* NodeField.stride */] & 0xff);
|
|
590
879
|
}
|
|
591
880
|
/**
|
|
592
881
|
* set the kind of the node at the given index
|
|
@@ -594,15 +883,12 @@ export class NodeBuffer {
|
|
|
594
883
|
* @param kind new kind
|
|
595
884
|
*/
|
|
596
885
|
set_kind(index, kind) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
prev_siblings_set(index, value) {
|
|
601
|
-
this._prev_siblings[index] = value;
|
|
886
|
+
const n = this._n;
|
|
887
|
+
const b = index * 12 /* NodeField.stride */;
|
|
888
|
+
n[b] = (n[b] & 0xffff00) | (kind & 0xff);
|
|
602
889
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
this._children_ends[index] = value;
|
|
890
|
+
extra_at(index) {
|
|
891
|
+
return this._n[index * 12 /* NodeField.stride */] >>> 8;
|
|
606
892
|
}
|
|
607
893
|
/**
|
|
608
894
|
* set the extra of the node at the given index
|
|
@@ -610,7 +896,16 @@ export class NodeBuffer {
|
|
|
610
896
|
* @param extra new extra
|
|
611
897
|
*/
|
|
612
898
|
set_extra(index, extra) {
|
|
613
|
-
|
|
899
|
+
const n = this._n;
|
|
900
|
+
const b = index * 12 /* NodeField.stride */;
|
|
901
|
+
n[b] = (n[b] & 0xff) | ((extra & 0xffff) << 8);
|
|
902
|
+
}
|
|
903
|
+
start_at(index) {
|
|
904
|
+
return this._n[index * 12 /* NodeField.stride */ + 1 /* NodeField.start */];
|
|
905
|
+
}
|
|
906
|
+
/** 0xffffffff while open */
|
|
907
|
+
end_at(index) {
|
|
908
|
+
return this._n[index * 12 /* NodeField.stride */ + 2 /* NodeField.end */];
|
|
614
909
|
}
|
|
615
910
|
/**
|
|
616
911
|
* set the end position of the node at the given index
|
|
@@ -618,87 +913,135 @@ export class NodeBuffer {
|
|
|
618
913
|
* @param end new end position
|
|
619
914
|
*/
|
|
620
915
|
set_end(index, end) {
|
|
621
|
-
this.
|
|
916
|
+
this._n[index * 12 /* NodeField.stride */ + 2 /* NodeField.end */] = end >>> 0;
|
|
622
917
|
}
|
|
623
918
|
gently_set_end(index, end) {
|
|
624
|
-
|
|
919
|
+
const i = index * 12 /* NodeField.stride */ + 2 /* NodeField.end */;
|
|
920
|
+
if (this._n[i] !== 0xffffffff)
|
|
625
921
|
return;
|
|
626
|
-
this.
|
|
922
|
+
this._n[i] = end >>> 0;
|
|
923
|
+
}
|
|
924
|
+
value_start_at(index) {
|
|
925
|
+
return this._n[index * 12 /* NodeField.stride */ + 3 /* NodeField.value_start */];
|
|
926
|
+
}
|
|
927
|
+
value_end_at(index) {
|
|
928
|
+
return this._n[index * 12 /* NodeField.stride */ + 4 /* NodeField.value_end */];
|
|
929
|
+
}
|
|
930
|
+
set_value(index, value_start, value_end) {
|
|
931
|
+
const n = this._n;
|
|
932
|
+
const b = index * 12 /* NodeField.stride */;
|
|
933
|
+
n[b + 3 /* NodeField.value_start */] = value_start;
|
|
934
|
+
n[b + 4 /* NodeField.value_end */] = value_end;
|
|
935
|
+
}
|
|
936
|
+
set_value_start(index, value_start) {
|
|
937
|
+
this._n[index * 12 /* NodeField.stride */ + 3 /* NodeField.value_start */] = value_start;
|
|
938
|
+
}
|
|
939
|
+
set_value_end(index, value_end) {
|
|
940
|
+
this._n[index * 12 /* NodeField.stride */ + 4 /* NodeField.value_end */] = value_end;
|
|
627
941
|
}
|
|
628
942
|
gently_set_value_end(index, end) {
|
|
629
|
-
|
|
943
|
+
const i = index * 12 /* NodeField.stride */ + 4 /* NodeField.value_end */;
|
|
944
|
+
if (this._n[i] !== 0xffffffff)
|
|
630
945
|
return;
|
|
631
|
-
this.
|
|
946
|
+
this._n[i] = end >>> 0;
|
|
947
|
+
}
|
|
948
|
+
parent_at(index) {
|
|
949
|
+
return this._n[index * 12 /* NodeField.stride */ + 5 /* NodeField.parent */];
|
|
950
|
+
}
|
|
951
|
+
set_parent(index, parent) {
|
|
952
|
+
this._n[index * 12 /* NodeField.stride */ + 5 /* NodeField.parent */] = parent;
|
|
953
|
+
}
|
|
954
|
+
next_at(index) {
|
|
955
|
+
return this._n[index * 12 /* NodeField.stride */ + 6 /* NodeField.next */];
|
|
956
|
+
}
|
|
957
|
+
set_next(index, next) {
|
|
958
|
+
this._n[index * 12 /* NodeField.stride */ + 6 /* NodeField.next */] = next;
|
|
959
|
+
}
|
|
960
|
+
prev_at(index) {
|
|
961
|
+
return this._n[index * 12 /* NodeField.stride */ + 7 /* NodeField.prev */];
|
|
962
|
+
}
|
|
963
|
+
set_prev(index, prev) {
|
|
964
|
+
this._n[index * 12 /* NodeField.stride */ + 7 /* NodeField.prev */] = prev;
|
|
965
|
+
}
|
|
966
|
+
first_child_at(index) {
|
|
967
|
+
return this._n[index * 12 /* NodeField.stride */ + 8 /* NodeField.first_child */];
|
|
968
|
+
}
|
|
969
|
+
set_first_child(index, child) {
|
|
970
|
+
this._n[index * 12 /* NodeField.stride */ + 8 /* NodeField.first_child */] = child;
|
|
971
|
+
}
|
|
972
|
+
last_child_at(index) {
|
|
973
|
+
return this._n[index * 12 /* NodeField.stride */ + 9 /* NodeField.last_child */];
|
|
974
|
+
}
|
|
975
|
+
set_last_child(index, child) {
|
|
976
|
+
this._n[index * 12 /* NodeField.stride */ + 9 /* NodeField.last_child */] = child;
|
|
977
|
+
}
|
|
978
|
+
pending_at(index) {
|
|
979
|
+
return this._n[index * 12 /* NodeField.stride */ + 10 /* NodeField.pending */];
|
|
632
980
|
}
|
|
633
981
|
/** pre-grow to avoid repeated resizes when the final size is estimable. */
|
|
634
982
|
ensure_capacity(needed) {
|
|
635
|
-
|
|
636
|
-
|
|
983
|
+
let next = this._capacity;
|
|
984
|
+
if (next >= needed)
|
|
985
|
+
return;
|
|
986
|
+
while (next < needed)
|
|
987
|
+
next <<= 1;
|
|
988
|
+
this.resize(next);
|
|
637
989
|
}
|
|
638
990
|
/** double the backing storage when capacity is exhausted. */
|
|
639
991
|
grow() {
|
|
640
|
-
|
|
641
|
-
const next_kinds = new Uint8Array(next);
|
|
642
|
-
const next_starts = new Uint32Array(next);
|
|
643
|
-
const next_ends = new Uint32Array(next);
|
|
644
|
-
const next_extras = new Uint16Array(next);
|
|
645
|
-
const next_value_starts = new Uint32Array(next);
|
|
646
|
-
const next_value_ends = new Uint32Array(next);
|
|
647
|
-
const next_parents = new Uint32Array(next);
|
|
648
|
-
const next_next_siblings = new Uint32Array(next);
|
|
649
|
-
const next_prev_siblings = new Uint32Array(next);
|
|
650
|
-
const next_children_starts = new Uint32Array(next);
|
|
651
|
-
const next_children_ends = new Uint32Array(next);
|
|
652
|
-
const next_pending_nodes = new Uint32Array(next);
|
|
653
|
-
const next_has_metadata = new Uint8Array(Math.max(1, next >> 3));
|
|
654
|
-
next_kinds.set(this._kinds);
|
|
655
|
-
next_starts.set(this._starts);
|
|
656
|
-
next_ends.set(this._ends);
|
|
657
|
-
next_extras.set(this._extras);
|
|
658
|
-
next_value_starts.set(this._value_starts);
|
|
659
|
-
next_value_ends.set(this._value_ends);
|
|
660
|
-
next_parents.set(this._parents);
|
|
661
|
-
next_next_siblings.set(this._next_siblings);
|
|
662
|
-
next_prev_siblings.set(this._prev_siblings);
|
|
663
|
-
next_children_starts.set(this._children_starts);
|
|
664
|
-
next_children_ends.set(this._children_ends);
|
|
665
|
-
next_pending_nodes.set(this._pending_nodes);
|
|
666
|
-
next_has_metadata.set(this.has_metadata);
|
|
667
|
-
this.capacity = next;
|
|
668
|
-
this._kinds = next_kinds;
|
|
669
|
-
this._starts = next_starts;
|
|
670
|
-
this._ends = next_ends;
|
|
671
|
-
this._extras = next_extras;
|
|
672
|
-
this._value_starts = next_value_starts;
|
|
673
|
-
this._value_ends = next_value_ends;
|
|
674
|
-
this._parents = next_parents;
|
|
675
|
-
this._next_siblings = next_next_siblings;
|
|
676
|
-
this._prev_siblings = next_prev_siblings;
|
|
677
|
-
this._children_starts = next_children_starts;
|
|
678
|
-
this._children_ends = next_children_ends;
|
|
679
|
-
this._pending_nodes = next_pending_nodes;
|
|
680
|
-
this.has_metadata = next_has_metadata;
|
|
681
|
-
}
|
|
682
|
-
set_metadata(index, metadata) {
|
|
683
|
-
this.metadata.set(index, metadata);
|
|
684
|
-
this.has_metadata[index >> 3] |= 1 << (index & 7);
|
|
992
|
+
return this.resize(this._capacity << 1);
|
|
685
993
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
994
|
+
resize(next) {
|
|
995
|
+
const old = this._n;
|
|
996
|
+
const words = this._capacity * 12 /* NodeField.stride */;
|
|
997
|
+
if (old === last_carve) {
|
|
998
|
+
// nothing was carved since, so extend the region in place
|
|
999
|
+
const base = slab_used - words * 4;
|
|
1000
|
+
const bytes = next * NODE_BYTES;
|
|
1001
|
+
if (bytes <= SLAB_MAX_CARVE && base + bytes <= SLAB_BYTES) {
|
|
1002
|
+
const n = new Uint32Array(slab, base, next * 12 /* NodeField.stride */);
|
|
1003
|
+
slab_used = base + bytes;
|
|
1004
|
+
last_carve = n;
|
|
1005
|
+
this._capacity = next;
|
|
1006
|
+
this._filled = next;
|
|
1007
|
+
this._n = n;
|
|
1008
|
+
return n;
|
|
1009
|
+
}
|
|
690
1010
|
}
|
|
691
|
-
|
|
1011
|
+
const n = this.alloc(next);
|
|
1012
|
+
// slots from _size on are template in both, a carve has it already
|
|
1013
|
+
const size = this._size;
|
|
1014
|
+
n.set(old.length === size * 12 /* NodeField.stride */
|
|
1015
|
+
? old
|
|
1016
|
+
: old.subarray(0, size * 12 /* NodeField.stride */));
|
|
1017
|
+
if (this._filled < size)
|
|
1018
|
+
this._filled = size;
|
|
1019
|
+
return n;
|
|
692
1020
|
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
1021
|
+
set_metadata(index, metadata) {
|
|
1022
|
+
const n = this._n;
|
|
1023
|
+
const i = index * 12 /* NodeField.stride */ + 11 /* NodeField.meta */;
|
|
1024
|
+
const slot = n[i];
|
|
1025
|
+
if (slot !== 0)
|
|
1026
|
+
this._meta[slot - 1] = metadata;
|
|
1027
|
+
else {
|
|
1028
|
+
const meta = this._meta;
|
|
1029
|
+
// a literal holds one slot, a push onto an empty array reserves seventeen
|
|
1030
|
+
if (meta === NO_META) {
|
|
1031
|
+
this._meta = [metadata];
|
|
1032
|
+
n[i] = 1;
|
|
1033
|
+
}
|
|
1034
|
+
else
|
|
1035
|
+
n[i] = meta.push(metadata);
|
|
1036
|
+
}
|
|
696
1037
|
}
|
|
697
|
-
|
|
698
|
-
this.
|
|
1038
|
+
metadata_at(index) {
|
|
1039
|
+
const slot = this._n[index * 12 /* NodeField.stride */ + 11 /* NodeField.meta */];
|
|
1040
|
+
// an index past the storage reads undefined, which indexes _meta at nan
|
|
1041
|
+
return slot === 0 ? undefined : this._meta[slot - 1];
|
|
699
1042
|
}
|
|
700
|
-
|
|
701
|
-
this.
|
|
1043
|
+
delete_metadata(index) {
|
|
1044
|
+
this._n[index * 12 /* NodeField.stride */ + 11 /* NodeField.meta */] = 0;
|
|
702
1045
|
}
|
|
703
1046
|
/**
|
|
704
1047
|
* get the node at the given index or the root node if no index is provided
|
|
@@ -706,33 +1049,33 @@ export class NodeBuffer {
|
|
|
706
1049
|
* @returns node
|
|
707
1050
|
*/
|
|
708
1051
|
get_node(index = 0) {
|
|
709
|
-
const
|
|
1052
|
+
const kind = this.kind_at(index);
|
|
1053
|
+
const extra_string = extra_to_string(kind);
|
|
710
1054
|
const extras_object = extra_string
|
|
711
|
-
? { [extra_string]: this.
|
|
1055
|
+
? { [extra_string]: this.extra_at(index) }
|
|
712
1056
|
: {};
|
|
713
1057
|
const _children = [];
|
|
714
1058
|
// walk sibling chain to get all direct children
|
|
715
|
-
let child = this.
|
|
716
|
-
while (child !== 0xffffffff && this.
|
|
1059
|
+
let child = this.first_child_at(index);
|
|
1060
|
+
while (child !== 0xffffffff && this.parent_at(child) === index) {
|
|
717
1061
|
_children.push(child);
|
|
718
|
-
child = this.
|
|
1062
|
+
child = this.next_at(child);
|
|
719
1063
|
}
|
|
1064
|
+
const parent = this.parent_at(index);
|
|
1065
|
+
const next = this.next_at(index);
|
|
1066
|
+
const prev = this.prev_at(index);
|
|
720
1067
|
return {
|
|
721
|
-
kind: kind_to_string(
|
|
722
|
-
start: this.
|
|
723
|
-
end: this.
|
|
1068
|
+
kind: kind_to_string(kind),
|
|
1069
|
+
start: this.start_at(index),
|
|
1070
|
+
end: this.end_at(index),
|
|
724
1071
|
metadata: {
|
|
725
1072
|
...this.metadata_at(index),
|
|
726
1073
|
...extras_object,
|
|
727
1074
|
},
|
|
728
|
-
parent:
|
|
729
|
-
next:
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
prev: this._prev_siblings[index] === 0xffffffff
|
|
733
|
-
? null
|
|
734
|
-
: this._prev_siblings[index],
|
|
735
|
-
value: [this._value_starts[index], this._value_ends[index]],
|
|
1075
|
+
parent: parent === 0xffffffff ? null : parent,
|
|
1076
|
+
next: next === 0xffffffff ? null : next,
|
|
1077
|
+
prev: prev === 0xffffffff ? null : prev,
|
|
1078
|
+
value: [this.value_start_at(index), this.value_end_at(index)],
|
|
736
1079
|
children: _children,
|
|
737
1080
|
index: index,
|
|
738
1081
|
};
|