@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/node_view.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type NodeBuffer } from
|
|
2
|
-
import { type UndoLog } from
|
|
1
|
+
import { type NodeBuffer } from './utils';
|
|
2
|
+
import { type UndoLog } from './undo_log';
|
|
3
3
|
/**
|
|
4
4
|
* abstracts text resolution between batch mode (source string slicing)
|
|
5
5
|
* and wire mode (pre-materialized _strings).
|
|
@@ -30,24 +30,25 @@ export declare class WireTextSource implements TextSource {
|
|
|
30
30
|
* short-lived: created before handler invocation, cleared after.
|
|
31
31
|
*/
|
|
32
32
|
export declare class ViewCache {
|
|
33
|
+
private first;
|
|
33
34
|
private views;
|
|
34
35
|
private buf;
|
|
35
36
|
private text_source;
|
|
36
37
|
private undo;
|
|
37
|
-
|
|
38
|
-
constructor(buf: NodeBuffer, text_source: TextSource, undo: UndoLog, handler_node: number);
|
|
38
|
+
constructor(buf: NodeBuffer, text_source: TextSource, undo: UndoLog);
|
|
39
39
|
/** get or create a NodeView for the given buffer index. */
|
|
40
40
|
get(index: number): NodeView | null;
|
|
41
|
+
private make;
|
|
41
42
|
/** discard all cached views. */
|
|
42
43
|
clear(): void;
|
|
43
|
-
/**
|
|
44
|
-
|
|
44
|
+
/** views made from here on read this buffer and text source */
|
|
45
|
+
rebind(buf: NodeBuffer, text_source: TextSource): void;
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
|
-
* a view over a single node in the
|
|
48
|
+
* a view over a single node in the NodeBuffer.
|
|
48
49
|
*
|
|
49
50
|
* reads are getters that look up the current state of the node
|
|
50
|
-
* in the
|
|
51
|
+
* in the buffer. writes are setters that update the backing store
|
|
51
52
|
* and record in the undo log for revocation.
|
|
52
53
|
*
|
|
53
54
|
* plugin handlers receive node views and interact with the tree
|
|
@@ -56,7 +57,7 @@ export declare class ViewCache {
|
|
|
56
57
|
export declare class NodeView {
|
|
57
58
|
/** @internal buffer index of this node. */
|
|
58
59
|
readonly _index: number;
|
|
59
|
-
/** @internal
|
|
60
|
+
/** @internal */
|
|
60
61
|
private _buf;
|
|
61
62
|
/** @internal text resolution strategy. */
|
|
62
63
|
private _text_source;
|
|
@@ -64,11 +65,9 @@ export declare class NodeView {
|
|
|
64
65
|
private _cache;
|
|
65
66
|
/** @internal undo log for recording mutations. */
|
|
66
67
|
private _undo;
|
|
67
|
-
/** @internal which handler node's undo log to attribute mutations to. */
|
|
68
|
-
private _handler_node;
|
|
69
68
|
/** lazily created attrs proxy. */
|
|
70
69
|
private _attrs;
|
|
71
|
-
constructor(index: number, buf: NodeBuffer, text_source: TextSource, cache: ViewCache, undo: UndoLog
|
|
70
|
+
constructor(index: number, buf: NodeBuffer, text_source: TextSource, cache: ViewCache, undo: UndoLog);
|
|
72
71
|
get type(): string;
|
|
73
72
|
set type(value: string);
|
|
74
73
|
get parent(): NodeView | null;
|
package/tsc/node_view.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { kind_to_string, string_to_kind } from
|
|
2
|
-
import { ATTR_DID_NOT_EXIST } from
|
|
1
|
+
import { kind_to_string, make_meta, merge_meta, string_to_kind, } from './utils';
|
|
2
|
+
import { ATTR_DID_NOT_EXIST } from './undo_log';
|
|
3
3
|
const NONE = 0xffffffff;
|
|
4
4
|
/** treebuilder text source: slices from the source string. */
|
|
5
5
|
export class SourceTextSource {
|
|
@@ -23,7 +23,7 @@ export class WireTextSource {
|
|
|
23
23
|
this.strings = strings;
|
|
24
24
|
}
|
|
25
25
|
slice(_start, _end) {
|
|
26
|
-
return
|
|
26
|
+
return '';
|
|
27
27
|
}
|
|
28
28
|
get_string(index) {
|
|
29
29
|
return this.strings[index];
|
|
@@ -35,45 +35,129 @@ export class WireTextSource {
|
|
|
35
35
|
* short-lived: created before handler invocation, cleared after.
|
|
36
36
|
*/
|
|
37
37
|
export class ViewCache {
|
|
38
|
-
constructor(buf, text_source, undo
|
|
39
|
-
|
|
38
|
+
constructor(buf, text_source, undo) {
|
|
39
|
+
// most dispatches only view the handler node, so the map waits for a second view
|
|
40
|
+
this.first = null;
|
|
41
|
+
this.views = null;
|
|
40
42
|
this.buf = buf;
|
|
41
43
|
this.text_source = text_source;
|
|
42
44
|
this.undo = undo;
|
|
43
|
-
this.handler_node = handler_node;
|
|
44
45
|
}
|
|
45
46
|
/** get or create a NodeView for the given buffer index. */
|
|
46
47
|
get(index) {
|
|
47
48
|
if (index === NONE)
|
|
48
49
|
return null;
|
|
49
|
-
|
|
50
|
+
const first = this.first;
|
|
51
|
+
if (first === null) {
|
|
52
|
+
return (this.first = this.make(index));
|
|
53
|
+
}
|
|
54
|
+
if (first._index === index)
|
|
55
|
+
return first;
|
|
56
|
+
let views = this.views;
|
|
57
|
+
if (views === null)
|
|
58
|
+
views = this.views = new Map();
|
|
59
|
+
let view = views.get(index);
|
|
50
60
|
if (view === undefined) {
|
|
51
|
-
view =
|
|
52
|
-
|
|
61
|
+
view = this.make(index);
|
|
62
|
+
views.set(index, view);
|
|
53
63
|
}
|
|
54
64
|
return view;
|
|
55
65
|
}
|
|
66
|
+
make(index) {
|
|
67
|
+
return new NodeView(index, this.buf, this.text_source, this, this.undo);
|
|
68
|
+
}
|
|
56
69
|
/** discard all cached views. */
|
|
57
70
|
clear() {
|
|
58
|
-
this.
|
|
71
|
+
this.first = null;
|
|
72
|
+
if (this.views !== null)
|
|
73
|
+
this.views.clear();
|
|
59
74
|
}
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
this.
|
|
75
|
+
/** views made from here on read this buffer and text source */
|
|
76
|
+
rebind(buf, text_source) {
|
|
77
|
+
this.buf = buf;
|
|
78
|
+
this.text_source = text_source;
|
|
63
79
|
}
|
|
64
80
|
}
|
|
65
81
|
/**
|
|
66
|
-
*
|
|
82
|
+
* attrs proxy target fields, symbol keyed so reflection through the traps
|
|
83
|
+
* never meets them, one handler serves every proxy
|
|
84
|
+
*/
|
|
85
|
+
const BUF = Symbol('buf');
|
|
86
|
+
const IDX = Symbol('idx');
|
|
87
|
+
const UNDO = Symbol('undo');
|
|
88
|
+
class AttrsTarget {
|
|
89
|
+
constructor(buf, idx, undo) {
|
|
90
|
+
this[BUF] = buf;
|
|
91
|
+
this[IDX] = idx;
|
|
92
|
+
this[UNDO] = undo;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const ATTRS_HANDLER = {
|
|
96
|
+
get(target, prop) {
|
|
97
|
+
const meta = target[BUF].metadata_at(target[IDX]);
|
|
98
|
+
return meta ? meta[prop] : undefined;
|
|
99
|
+
},
|
|
100
|
+
set(target, prop, value) {
|
|
101
|
+
const buf = target[BUF];
|
|
102
|
+
const idx = target[IDX];
|
|
103
|
+
const meta = buf.metadata_at(idx);
|
|
104
|
+
const undo = target[UNDO];
|
|
105
|
+
if (undo.recording) {
|
|
106
|
+
const prior = meta && prop in meta ? meta[prop] : ATTR_DID_NOT_EXIST;
|
|
107
|
+
undo.record_attr_set(idx, prop, prior);
|
|
108
|
+
}
|
|
109
|
+
if (meta) {
|
|
110
|
+
merge_meta(meta, prop, value);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
buf.set_metadata(idx, make_meta(prop, value));
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
117
|
+
deleteProperty(target, prop) {
|
|
118
|
+
const buf = target[BUF];
|
|
119
|
+
const idx = target[IDX];
|
|
120
|
+
const meta = buf.metadata_at(idx);
|
|
121
|
+
if (!meta || !(prop in meta))
|
|
122
|
+
return true;
|
|
123
|
+
const prior = meta[prop];
|
|
124
|
+
target[UNDO].record_attr_delete(idx, prop, prior);
|
|
125
|
+
delete meta[prop];
|
|
126
|
+
buf.set_metadata(idx, meta);
|
|
127
|
+
return true;
|
|
128
|
+
},
|
|
129
|
+
has(target, prop) {
|
|
130
|
+
const meta = target[BUF].metadata_at(target[IDX]);
|
|
131
|
+
return meta ? prop in meta : false;
|
|
132
|
+
},
|
|
133
|
+
ownKeys(target) {
|
|
134
|
+
const meta = target[BUF].metadata_at(target[IDX]);
|
|
135
|
+
return meta ? Object.keys(meta) : [];
|
|
136
|
+
},
|
|
137
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
138
|
+
const meta = target[BUF].metadata_at(target[IDX]);
|
|
139
|
+
if (meta && prop in meta) {
|
|
140
|
+
return {
|
|
141
|
+
configurable: true,
|
|
142
|
+
enumerable: true,
|
|
143
|
+
value: meta[prop],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* a view over a single node in the NodeBuffer.
|
|
67
151
|
*
|
|
68
152
|
* reads are getters that look up the current state of the node
|
|
69
|
-
* in the
|
|
153
|
+
* in the buffer. writes are setters that update the backing store
|
|
70
154
|
* and record in the undo log for revocation.
|
|
71
155
|
*
|
|
72
156
|
* plugin handlers receive node views and interact with the tree
|
|
73
157
|
* exclusively through them.
|
|
74
158
|
*/
|
|
75
159
|
export class NodeView {
|
|
76
|
-
constructor(index, buf, text_source, cache, undo
|
|
160
|
+
constructor(index, buf, text_source, cache, undo) {
|
|
77
161
|
/** lazily created attrs proxy. */
|
|
78
162
|
this._attrs = null;
|
|
79
163
|
this._index = index;
|
|
@@ -81,38 +165,37 @@ export class NodeView {
|
|
|
81
165
|
this._text_source = text_source;
|
|
82
166
|
this._cache = cache;
|
|
83
167
|
this._undo = undo;
|
|
84
|
-
this._handler_node = handler_node;
|
|
85
168
|
}
|
|
86
169
|
get type() {
|
|
87
|
-
return kind_to_string(this._buf.
|
|
170
|
+
return kind_to_string(this._buf.kind_at(this._index));
|
|
88
171
|
}
|
|
89
172
|
set type(value) {
|
|
90
173
|
const numeric = string_to_kind(value);
|
|
91
174
|
if (numeric === undefined)
|
|
92
175
|
return;
|
|
93
|
-
const prior = this._buf.
|
|
176
|
+
const prior = this._buf.kind_at(this._index);
|
|
94
177
|
this._undo.record_type_change(this._index, prior);
|
|
95
|
-
this._buf.
|
|
178
|
+
this._buf.set_kind(this._index, numeric);
|
|
96
179
|
}
|
|
97
180
|
get parent() {
|
|
98
|
-
return this._cache.get(this._buf.
|
|
181
|
+
return this._cache.get(this._buf.parent_at(this._index));
|
|
99
182
|
}
|
|
100
183
|
get first_child() {
|
|
101
|
-
return this._cache.get(this._buf.
|
|
184
|
+
return this._cache.get(this._buf.first_child_at(this._index));
|
|
102
185
|
}
|
|
103
186
|
get last_child() {
|
|
104
|
-
return this._cache.get(this._buf.
|
|
187
|
+
return this._cache.get(this._buf.last_child_at(this._index));
|
|
105
188
|
}
|
|
106
189
|
get next() {
|
|
107
|
-
const n = this._buf.
|
|
190
|
+
const n = this._buf.next_at(this._index);
|
|
108
191
|
if (n === NONE)
|
|
109
192
|
return null;
|
|
110
|
-
if (this._buf.
|
|
193
|
+
if (this._buf.parent_at(n) !== this._buf.parent_at(this._index))
|
|
111
194
|
return null;
|
|
112
195
|
return this._cache.get(n);
|
|
113
196
|
}
|
|
114
197
|
get prev() {
|
|
115
|
-
const p = this._buf.
|
|
198
|
+
const p = this._buf.prev_at(this._index);
|
|
116
199
|
if (p === NONE)
|
|
117
200
|
return null;
|
|
118
201
|
return this._cache.get(p);
|
|
@@ -126,16 +209,16 @@ export class NodeView {
|
|
|
126
209
|
}
|
|
127
210
|
_collect_text(idx) {
|
|
128
211
|
const buf = this._buf;
|
|
129
|
-
const kind = buf.
|
|
212
|
+
const kind = buf.kind_at(idx);
|
|
130
213
|
// leaf text node
|
|
131
214
|
if (kind === 1 /* NodeKind.text */) {
|
|
132
215
|
const s = this._text_source.get_string(idx);
|
|
133
216
|
if (s !== undefined)
|
|
134
217
|
return s;
|
|
135
|
-
const vs = buf.
|
|
136
|
-
const ve = buf.
|
|
218
|
+
const vs = buf.value_start_at(idx);
|
|
219
|
+
const ve = buf.value_end_at(idx);
|
|
137
220
|
if (vs === NONE || ve === NONE || ve <= vs)
|
|
138
|
-
return
|
|
221
|
+
return '';
|
|
139
222
|
return this._text_source.slice(vs, ve);
|
|
140
223
|
}
|
|
141
224
|
// content-leaf nodes: text stored as value range or string on the node itself.
|
|
@@ -147,10 +230,10 @@ export class NodeView {
|
|
|
147
230
|
const s = this._text_source.get_string(idx);
|
|
148
231
|
if (s !== undefined)
|
|
149
232
|
return s;
|
|
150
|
-
const vs = buf.
|
|
151
|
-
const ve = buf.
|
|
233
|
+
const vs = buf.value_start_at(idx);
|
|
234
|
+
const ve = buf.value_end_at(idx);
|
|
152
235
|
if (vs === NONE || ve === NONE || ve <= vs)
|
|
153
|
-
return
|
|
236
|
+
return '';
|
|
154
237
|
return this._text_source.slice(vs, ve);
|
|
155
238
|
}
|
|
156
239
|
// heading: try value range first (batch mode), fall through to
|
|
@@ -159,31 +242,31 @@ export class NodeView {
|
|
|
159
242
|
const s = this._text_source.get_string(idx);
|
|
160
243
|
if (s !== undefined)
|
|
161
244
|
return s;
|
|
162
|
-
const vs = buf.
|
|
163
|
-
const ve = buf.
|
|
245
|
+
const vs = buf.value_start_at(idx);
|
|
246
|
+
const ve = buf.value_end_at(idx);
|
|
164
247
|
if (vs !== NONE && ve !== NONE && ve > vs) {
|
|
165
248
|
return this._text_source.slice(vs, ve);
|
|
166
249
|
}
|
|
167
250
|
// fall through to child walk
|
|
168
251
|
}
|
|
169
252
|
// container node: walk children, concatenate
|
|
170
|
-
let result =
|
|
171
|
-
let child = buf.
|
|
172
|
-
while (child !== NONE && buf.
|
|
253
|
+
let result = '';
|
|
254
|
+
let child = buf.first_child_at(idx);
|
|
255
|
+
while (child !== NONE && buf.parent_at(child) === idx) {
|
|
173
256
|
result += this._collect_text(child);
|
|
174
|
-
child = buf.
|
|
257
|
+
child = buf.next_at(child);
|
|
175
258
|
}
|
|
176
259
|
return result;
|
|
177
260
|
}
|
|
178
261
|
/** heading depth (1-6). only meaningful when type === 'heading'. */
|
|
179
262
|
get depth() {
|
|
180
|
-
if (this._buf.
|
|
263
|
+
if (this._buf.kind_at(this._index) !== 3 /* NodeKind.heading */)
|
|
181
264
|
return undefined;
|
|
182
|
-
return this._buf.
|
|
265
|
+
return this._buf.extra_at(this._index);
|
|
183
266
|
}
|
|
184
267
|
/** code block language/info string. */
|
|
185
268
|
get lang() {
|
|
186
|
-
const kind = this._buf.
|
|
269
|
+
const kind = this._buf.kind_at(this._index);
|
|
187
270
|
if (kind !== 5 /* NodeKind.code_fence */)
|
|
188
271
|
return undefined;
|
|
189
272
|
const meta = this._buf.metadata_at(this._index);
|
|
@@ -224,58 +307,7 @@ export class NodeView {
|
|
|
224
307
|
get attrs() {
|
|
225
308
|
if (this._attrs !== null)
|
|
226
309
|
return this._attrs;
|
|
227
|
-
|
|
228
|
-
const idx = this._index;
|
|
229
|
-
const undo = this._undo;
|
|
230
|
-
this._attrs = new Proxy({}, {
|
|
231
|
-
get(_target, prop) {
|
|
232
|
-
const meta = buf.metadata_at(idx);
|
|
233
|
-
return meta ? meta[prop] : undefined;
|
|
234
|
-
},
|
|
235
|
-
set(_target, prop, value) {
|
|
236
|
-
const meta = buf.metadata_at(idx);
|
|
237
|
-
const prior = meta && prop in meta ? meta[prop] : ATTR_DID_NOT_EXIST;
|
|
238
|
-
undo.record_attr_set(idx, prop, prior);
|
|
239
|
-
if (meta) {
|
|
240
|
-
meta[prop] = value;
|
|
241
|
-
buf.set_metadata(idx, meta);
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
buf.set_metadata(idx, { [prop]: value });
|
|
245
|
-
}
|
|
246
|
-
return true;
|
|
247
|
-
},
|
|
248
|
-
deleteProperty(_target, prop) {
|
|
249
|
-
const meta = buf.metadata_at(idx);
|
|
250
|
-
if (!meta || !(prop in meta))
|
|
251
|
-
return true;
|
|
252
|
-
const prior = meta[prop];
|
|
253
|
-
undo.record_attr_delete(idx, prop, prior);
|
|
254
|
-
delete meta[prop];
|
|
255
|
-
buf.set_metadata(idx, meta);
|
|
256
|
-
return true;
|
|
257
|
-
},
|
|
258
|
-
has(_target, prop) {
|
|
259
|
-
const meta = buf.metadata_at(idx);
|
|
260
|
-
return meta ? prop in meta : false;
|
|
261
|
-
},
|
|
262
|
-
ownKeys() {
|
|
263
|
-
const meta = buf.metadata_at(idx);
|
|
264
|
-
return meta ? Object.keys(meta) : [];
|
|
265
|
-
},
|
|
266
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
267
|
-
const meta = buf.metadata_at(idx);
|
|
268
|
-
if (meta && prop in meta) {
|
|
269
|
-
return {
|
|
270
|
-
configurable: true,
|
|
271
|
-
enumerable: true,
|
|
272
|
-
value: meta[prop],
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
return undefined;
|
|
276
|
-
},
|
|
277
|
-
});
|
|
278
|
-
return this._attrs;
|
|
310
|
+
return (this._attrs = new Proxy(new AttrsTarget(this._buf, this._index, this._undo), ATTRS_HANDLER));
|
|
279
311
|
}
|
|
280
312
|
/**
|
|
281
313
|
* insert a new node between this node and its current children.
|
|
@@ -289,8 +321,8 @@ export class NodeView {
|
|
|
289
321
|
const buf = this._buf;
|
|
290
322
|
const idx = this._index;
|
|
291
323
|
// capture prior state
|
|
292
|
-
const prior_first_child = buf.
|
|
293
|
-
const prior_last_child = buf.
|
|
324
|
+
const prior_first_child = buf.first_child_at(idx);
|
|
325
|
+
const prior_last_child = buf.last_child_at(idx);
|
|
294
326
|
// wrap_children does the atomic operation
|
|
295
327
|
const wrapper_idx = buf.wrap_children(idx, kind_num, 0, attrs);
|
|
296
328
|
// record undo
|
|
@@ -307,7 +339,7 @@ export class NodeView {
|
|
|
307
339
|
throw new Error(`Unknown node type: ${type}`);
|
|
308
340
|
const buf = this._buf;
|
|
309
341
|
const idx = this._index;
|
|
310
|
-
const prior_first_child = buf.
|
|
342
|
+
const prior_first_child = buf.first_child_at(idx);
|
|
311
343
|
if (prior_first_child === NONE) {
|
|
312
344
|
// no existing children: push is equivalent to prepend
|
|
313
345
|
const new_idx = buf.push(kind_num, 0, idx, 0, attrs);
|
|
@@ -316,10 +348,10 @@ export class NodeView {
|
|
|
316
348
|
}
|
|
317
349
|
// allocate unlinked and manually wire as first child
|
|
318
350
|
const new_idx = buf.push_unlinked(kind_num, 0, 0, attrs);
|
|
319
|
-
buf.
|
|
320
|
-
buf.
|
|
321
|
-
buf.
|
|
322
|
-
buf.
|
|
351
|
+
buf.set_parent(new_idx, idx);
|
|
352
|
+
buf.set_next(new_idx, prior_first_child);
|
|
353
|
+
buf.set_prev(prior_first_child, new_idx);
|
|
354
|
+
buf.set_first_child(idx, new_idx);
|
|
323
355
|
this._undo.record_prepend(idx, new_idx, prior_first_child);
|
|
324
356
|
return this._cache.get(new_idx);
|
|
325
357
|
}
|
|
@@ -333,7 +365,7 @@ export class NodeView {
|
|
|
333
365
|
throw new Error(`Unknown node type: ${type}`);
|
|
334
366
|
const buf = this._buf;
|
|
335
367
|
const idx = this._index;
|
|
336
|
-
const prior_last_child = buf.
|
|
368
|
+
const prior_last_child = buf.last_child_at(idx);
|
|
337
369
|
// push() already appends as last child
|
|
338
370
|
const new_idx = buf.push(kind_num, 0, idx, 0, attrs);
|
|
339
371
|
this._undo.record_append(idx, new_idx, prior_last_child);
|
package/tsc/opcodes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NodeKind } from
|
|
1
|
+
import type { NodeKind } from './utils';
|
|
2
2
|
/**
|
|
3
3
|
* emitter interface for pfm parser opcodes.
|
|
4
4
|
*
|
|
@@ -10,6 +10,9 @@ import type { NodeKind } from "./utils";
|
|
|
10
10
|
export interface Emitter {
|
|
11
11
|
/**
|
|
12
12
|
* open a new node.
|
|
13
|
+
*
|
|
14
|
+
* ids are dense from root 0, each open and each text that creates a child
|
|
15
|
+
* node takes the next id, so a builder can use ids as slot indices
|
|
13
16
|
* @param id monotonic node id (unique within this parse).
|
|
14
17
|
* @param kind node kind (heading, paragraph, emphasis, etc.).
|
|
15
18
|
* @param start source byte offset where this node starts.
|
|
@@ -22,17 +25,27 @@ export interface Emitter {
|
|
|
22
25
|
* close a previously opened node. implicitly commits pending nodes.
|
|
23
26
|
* @param id id of the node to close.
|
|
24
27
|
* @param end source byte offset where this node ends.
|
|
28
|
+
* @param kind kind at open, a revoke may have rewritten it since, omitting
|
|
29
|
+
* it makes the builder track revokes
|
|
25
30
|
*/
|
|
26
|
-
close(id: number, end: number): void;
|
|
31
|
+
close(id: number, end: number, kind?: NodeKind): void;
|
|
27
32
|
/**
|
|
28
33
|
* emit leaf text content within a node.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
34
|
+
* paragraphs, emphasis, links and table cells get a child text node, which
|
|
35
|
+
* takes the next id although no open names it
|
|
36
|
+
* headings, code fences, code spans and html comments get a value range and
|
|
37
|
+
* take no id
|
|
31
38
|
* @param parent id of the parent node.
|
|
32
39
|
* @param start source byte offset of text start.
|
|
33
40
|
* @param end source byte offset of text end.
|
|
41
|
+
* @param parent_kind parent kind at open, as for close
|
|
34
42
|
*/
|
|
35
|
-
text(parent: number, start: number, end: number): void;
|
|
43
|
+
text(parent: number, start: number, end: number, parent_kind?: NodeKind): void;
|
|
44
|
+
/**
|
|
45
|
+
* open, set_value_start, set_value_end and close of a node with no extra in
|
|
46
|
+
* one call, when it is missing the parser emits those four opcodes
|
|
47
|
+
*/
|
|
48
|
+
leaf?(id: number, kind: NodeKind, start: number, parent: number, value_start: number, value_end: number, end: number): void;
|
|
36
49
|
/**
|
|
37
50
|
* set or update an attribute on a node.
|
|
38
51
|
* used for metadata (href, title, info), value ranges, and list properties.
|
|
@@ -54,8 +67,10 @@ export interface Emitter {
|
|
|
54
67
|
* @param source_text optional raw source text for the revoked node.
|
|
55
68
|
* used for block-level revocations where the content must be
|
|
56
69
|
* reconstructed (e.g. failed html tags becoming paragraph text).
|
|
70
|
+
* @param text_start source offset of source_text, at the node start a tree
|
|
71
|
+
* that reads the source need not keep source_text
|
|
57
72
|
*/
|
|
58
|
-
revoke(id: number, source_text?: string): void;
|
|
73
|
+
revoke(id: number, source_text?: string, text_start?: number): void;
|
|
59
74
|
/**
|
|
60
75
|
* clear the pending flag on a node without touching its structure.
|
|
61
76
|
* used for tight-list speculation: paragraphs inside list_items are
|
|
@@ -72,4 +87,6 @@ export interface Emitter {
|
|
|
72
87
|
* @param pos current byte offset in the source.
|
|
73
88
|
*/
|
|
74
89
|
cursor(pos: number): void;
|
|
90
|
+
/** the incremental finish emitted the last opcode, reserved storage can go */
|
|
91
|
+
end?(): void;
|
|
75
92
|
}
|
package/tsc/plugin_dispatch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type NodeBuffer, NodeKind } from
|
|
2
|
-
import { type TextSource } from
|
|
3
|
-
import type { ParsePlugin
|
|
1
|
+
import { type NodeBuffer, NodeKind } from './utils';
|
|
2
|
+
import { type TextSource } from './node_view';
|
|
3
|
+
import type { ParsePlugin } from './plugin_types';
|
|
4
4
|
/**
|
|
5
5
|
* orchestrates plugin dispatch for both TreeBuilder and WireTreeBuilder.
|
|
6
6
|
*
|
|
@@ -21,15 +21,29 @@ export declare class PluginDispatcher {
|
|
|
21
21
|
*/
|
|
22
22
|
private redirects;
|
|
23
23
|
private next_synthetic_id;
|
|
24
|
+
/** one cache serves every dispatch, a view only holds an index */
|
|
25
|
+
private cache;
|
|
26
|
+
/**
|
|
27
|
+
* 1 for each kind whose open needs the dispatcher, every kind once a redirect
|
|
28
|
+
* exists, redirects only start in dispatch_open so builders reread it after one
|
|
29
|
+
*/
|
|
30
|
+
open_wants: Uint8Array;
|
|
24
31
|
constructor(plugins: ParsePlugin[], text_source: TextSource);
|
|
32
|
+
/** cleared since a callback view may have filled it after the last dispatch */
|
|
33
|
+
private views;
|
|
34
|
+
/** buffer index and prior kind of each kind rewrite, see UndoLog */
|
|
35
|
+
kind_log(): number[] | null;
|
|
36
|
+
/** a kind rewrite outside the plugins, such as a revoke repair */
|
|
37
|
+
log_kind(buf_idx: number, prior_kind: number): void;
|
|
38
|
+
/** an open of this kind needs a handler call or a redirect lookup */
|
|
39
|
+
wants_open(kind: NodeKind): boolean;
|
|
40
|
+
/** a close needs no dispatch */
|
|
41
|
+
quiet(): boolean;
|
|
25
42
|
/** check whether any fused handlers exist for this kind. */
|
|
26
43
|
has_handlers(kind: NodeKind): boolean;
|
|
27
44
|
/** check if a parent index has a redirect (wrap_inner). */
|
|
28
45
|
get_redirect(parent_idx: number): number | undefined;
|
|
29
|
-
|
|
30
|
-
set_redirect(parent_idx: number, wrapper_idx: number): void;
|
|
31
|
-
/** clear a redirect (on parent close). */
|
|
32
|
-
clear_redirect(parent_idx: number): void;
|
|
46
|
+
private own_redirects;
|
|
33
47
|
/** allocate a new synthetic node id. */
|
|
34
48
|
allocate_synthetic_id(): number;
|
|
35
49
|
/** update text source (for incremental parsing). */
|
|
@@ -38,7 +52,7 @@ export declare class PluginDispatcher {
|
|
|
38
52
|
* dispatch fused plugin handlers on node open.
|
|
39
53
|
* creates a ViewCache, runs handlers, stores close callbacks.
|
|
40
54
|
*/
|
|
41
|
-
dispatch_open(buf_idx: number, kind: NodeKind, buf: NodeBuffer
|
|
55
|
+
dispatch_open(buf_idx: number, kind: NodeKind, buf: NodeBuffer): void;
|
|
42
56
|
/**
|
|
43
57
|
* dispatch close callbacks for a node.
|
|
44
58
|
* fires callbacks with undo attribution.
|