@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/undo_log.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
const NONE = 0xffffffff;
|
|
2
2
|
/** sentinel: the attribute key did not exist before this write. */
|
|
3
|
-
export const ATTR_DID_NOT_EXIST = Symbol(
|
|
3
|
+
export const ATTR_DID_NOT_EXIST = Symbol('ATTR_DID_NOT_EXIST');
|
|
4
4
|
/**
|
|
5
5
|
* unlink a child node from its parent's sibling chain and orphan it.
|
|
6
6
|
* unlike unwrap_node, this does NOT reparent the child's own children,
|
|
7
7
|
* the entire subtree is detached.
|
|
8
8
|
*/
|
|
9
9
|
function _unlink_child(buf, parent, child) {
|
|
10
|
-
const prev = buf.
|
|
11
|
-
const next = buf.
|
|
10
|
+
const prev = buf.prev_at(child);
|
|
11
|
+
const next = buf.next_at(child);
|
|
12
12
|
if (prev !== NONE) {
|
|
13
|
-
buf.
|
|
13
|
+
buf.set_next(prev, next);
|
|
14
14
|
}
|
|
15
|
-
else if (buf.
|
|
16
|
-
buf.
|
|
15
|
+
else if (buf.first_child_at(parent) === child) {
|
|
16
|
+
buf.set_first_child(parent, next !== NONE && buf.parent_at(next) === parent ? next : NONE);
|
|
17
17
|
}
|
|
18
|
-
if (next !== NONE && buf.
|
|
19
|
-
buf.
|
|
18
|
+
if (next !== NONE && buf.parent_at(next) === parent) {
|
|
19
|
+
buf.set_prev(next, prev);
|
|
20
20
|
}
|
|
21
|
-
if (buf.
|
|
22
|
-
buf.
|
|
21
|
+
if (buf.last_child_at(parent) === child) {
|
|
22
|
+
buf.set_last_child(parent, prev !== NONE ? prev : NONE);
|
|
23
23
|
}
|
|
24
|
-
buf.
|
|
25
|
-
buf.
|
|
26
|
-
buf.
|
|
24
|
+
buf.set_parent(child, NONE);
|
|
25
|
+
buf.set_next(child, NONE);
|
|
26
|
+
buf.set_prev(child, NONE);
|
|
27
27
|
}
|
|
28
|
+
/** never written, every write swaps in a map of its own first */
|
|
29
|
+
const NO_LOGS = new Map();
|
|
28
30
|
/**
|
|
29
31
|
* per-node undo log for plugin mutations.
|
|
30
32
|
*
|
|
@@ -38,13 +40,26 @@ function _unlink_child(buf, parent, child) {
|
|
|
38
40
|
export class UndoLog {
|
|
39
41
|
constructor() {
|
|
40
42
|
/** per-handler-node logs. maps buffer index -> append-only entry array. */
|
|
41
|
-
|
|
43
|
+
// a shared empty map until the first entry, most documents record none
|
|
44
|
+
this.logs = NO_LOGS;
|
|
42
45
|
/**
|
|
43
46
|
* the buffer index of the node whose handler is currently running.
|
|
44
47
|
* set by the dispatcher before calling handlers. all record* calls
|
|
45
48
|
* attribute their entries to this node.
|
|
46
49
|
*/
|
|
47
50
|
this.active_node = NONE;
|
|
51
|
+
/**
|
|
52
|
+
* buffer index and prior kind of every kind rewrite, recorded or not, in
|
|
53
|
+
* order, so the first entry of an index holds its kind at open
|
|
54
|
+
*/
|
|
55
|
+
this.kind_changes = null;
|
|
56
|
+
}
|
|
57
|
+
log_kind(target, prior_kind) {
|
|
58
|
+
const log = this.kind_changes;
|
|
59
|
+
if (log === null)
|
|
60
|
+
this.kind_changes = [target, prior_kind];
|
|
61
|
+
else
|
|
62
|
+
log.push(target, prior_kind);
|
|
48
63
|
}
|
|
49
64
|
/** called by dispatcher before invoking plugin handlers for a node. */
|
|
50
65
|
set_active_node(index) {
|
|
@@ -54,7 +69,13 @@ export class UndoLog {
|
|
|
54
69
|
clear_active_node() {
|
|
55
70
|
this.active_node = NONE;
|
|
56
71
|
}
|
|
72
|
+
/** false while nothing would keep an entry */
|
|
73
|
+
get recording() {
|
|
74
|
+
return this.active_node !== NONE;
|
|
75
|
+
}
|
|
57
76
|
record_attr_set(target, key, prior_value) {
|
|
77
|
+
if (this.active_node === NONE)
|
|
78
|
+
return;
|
|
58
79
|
this._append({
|
|
59
80
|
kind: 0 /* UndoEntryKind.AttrSet */,
|
|
60
81
|
target,
|
|
@@ -71,6 +92,9 @@ export class UndoLog {
|
|
|
71
92
|
});
|
|
72
93
|
}
|
|
73
94
|
record_type_change(target, prior_kind) {
|
|
95
|
+
this.log_kind(target, prior_kind);
|
|
96
|
+
if (this.active_node === NONE)
|
|
97
|
+
return;
|
|
74
98
|
this._append({
|
|
75
99
|
kind: 2 /* UndoEntryKind.TypeChange */,
|
|
76
100
|
target,
|
|
@@ -106,10 +130,13 @@ export class UndoLog {
|
|
|
106
130
|
const node = this.active_node;
|
|
107
131
|
if (node === NONE)
|
|
108
132
|
return;
|
|
109
|
-
let
|
|
133
|
+
let logs = this.logs;
|
|
134
|
+
if (logs === NO_LOGS)
|
|
135
|
+
logs = this.logs = new Map();
|
|
136
|
+
let log = logs.get(node);
|
|
110
137
|
if (log === undefined) {
|
|
111
138
|
log = [];
|
|
112
|
-
|
|
139
|
+
logs.set(node, log);
|
|
113
140
|
}
|
|
114
141
|
log.push(entry);
|
|
115
142
|
}
|
|
@@ -144,7 +171,7 @@ export class UndoLog {
|
|
|
144
171
|
break;
|
|
145
172
|
}
|
|
146
173
|
case 2 /* UndoEntryKind.TypeChange */: {
|
|
147
|
-
buf.
|
|
174
|
+
buf.set_kind(entry.target, entry.prior_kind);
|
|
148
175
|
break;
|
|
149
176
|
}
|
|
150
177
|
case 3 /* UndoEntryKind.WrapInner */: {
|
|
@@ -154,7 +181,7 @@ export class UndoLog {
|
|
|
154
181
|
const parent = entry.parent;
|
|
155
182
|
const wrapper = entry.wrapper;
|
|
156
183
|
buf.unwrap_node(wrapper);
|
|
157
|
-
buf.
|
|
184
|
+
buf.set_parent(wrapper, NONE);
|
|
158
185
|
break;
|
|
159
186
|
}
|
|
160
187
|
case 4 /* UndoEntryKind.Prepend */:
|
|
@@ -176,7 +203,12 @@ export class UndoLog {
|
|
|
176
203
|
* commit a node, discard its undo log, making mutations permanent.
|
|
177
204
|
*/
|
|
178
205
|
commit(handler_node) {
|
|
179
|
-
this.logs.
|
|
206
|
+
if (this.logs.size !== 0)
|
|
207
|
+
this.logs.delete(handler_node);
|
|
208
|
+
}
|
|
209
|
+
/** true when no node holds a mutation that a revoke would undo */
|
|
210
|
+
get empty() {
|
|
211
|
+
return this.logs.size === 0;
|
|
180
212
|
}
|
|
181
213
|
/** check whether a node has any recorded mutations. */
|
|
182
214
|
has(handler_node) {
|
|
@@ -184,11 +216,14 @@ export class UndoLog {
|
|
|
184
216
|
}
|
|
185
217
|
/** get undo entries for a node (for redirect detection). */
|
|
186
218
|
get_entries(handler_node) {
|
|
219
|
+
if (this.logs.size === 0)
|
|
220
|
+
return undefined;
|
|
187
221
|
return this.logs.get(handler_node);
|
|
188
222
|
}
|
|
189
223
|
/** discard all logs. */
|
|
190
224
|
clear() {
|
|
191
225
|
this.logs.clear();
|
|
226
|
+
this.kind_changes = null;
|
|
192
227
|
this.active_node = NONE;
|
|
193
228
|
}
|
|
194
229
|
}
|
package/tsc/utils.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/** push writes and the cursor reads fields together, so they share one stride */
|
|
2
|
+
export declare const enum NodeField {
|
|
3
|
+
/** kind in the low byte, extra in the sixteen bits above it */
|
|
4
|
+
kind = 0,
|
|
5
|
+
start = 1,
|
|
6
|
+
end = 2,
|
|
7
|
+
value_start = 3,
|
|
8
|
+
value_end = 4,
|
|
9
|
+
parent = 5,
|
|
10
|
+
next = 6,
|
|
11
|
+
prev = 7,
|
|
12
|
+
first_child = 8,
|
|
13
|
+
last_child = 9,
|
|
14
|
+
/** one while the node may still be revoked */
|
|
15
|
+
pending = 10,
|
|
16
|
+
/** one plus the slot in NodeBuffer._meta, zero without metadata */
|
|
17
|
+
meta = 11,
|
|
18
|
+
stride = 12
|
|
19
|
+
}
|
|
1
20
|
export declare const enum NodeKind {
|
|
2
21
|
root = 0,
|
|
3
22
|
text = 1,
|
|
@@ -33,7 +52,8 @@ export declare const enum NodeKind {
|
|
|
33
52
|
directive_leaf = 31,
|
|
34
53
|
directive_container = 32,
|
|
35
54
|
frontmatter = 33,
|
|
36
|
-
import_statement = 34
|
|
55
|
+
import_statement = 34,
|
|
56
|
+
directive_label = 35
|
|
37
57
|
}
|
|
38
58
|
/**
|
|
39
59
|
* convert a node kind to a string
|
|
@@ -48,61 +68,54 @@ export declare const kind_to_string: (kind: NodeKind) => string;
|
|
|
48
68
|
*/
|
|
49
69
|
export declare const string_to_kind: (name: string) => NodeKind | undefined;
|
|
50
70
|
/**
|
|
51
|
-
*
|
|
71
|
+
* a computed key literal takes a slow generic define, so known keys get
|
|
72
|
+
* constant key literals and other keys a store into an empty literal
|
|
52
73
|
*/
|
|
74
|
+
export declare function make_meta(key: string, value: any): Record<string, any>;
|
|
75
|
+
/** named stores stay monomorphic, a keyed store goes megamorphic across shapes */
|
|
76
|
+
export declare function merge_meta(meta: Record<string, any>, key: string, value: any): void;
|
|
53
77
|
export declare class NodeBuffer {
|
|
54
|
-
private capacity;
|
|
55
|
-
/** @internal exposed for cursor access. do not mutate externally. */
|
|
56
|
-
_kinds: Uint8Array;
|
|
57
|
-
/** @internal exposed for cursor access. do not mutate externally. */
|
|
58
|
-
_starts: Uint32Array;
|
|
59
|
-
/** @internal */
|
|
60
|
-
_ends: Uint32Array;
|
|
61
78
|
/** @internal */
|
|
62
|
-
|
|
79
|
+
_capacity: number;
|
|
80
|
+
/** @internal do not mutate externally */
|
|
81
|
+
_n: Uint32Array;
|
|
63
82
|
/** @internal */
|
|
64
|
-
|
|
65
|
-
/** @internal */
|
|
66
|
-
_value_ends: Uint32Array;
|
|
67
|
-
private has_metadata;
|
|
68
|
-
private metadata;
|
|
83
|
+
_meta: any[];
|
|
69
84
|
/** @internal pre-materialized text strings (used by wiretreebuilder). index -> string. */
|
|
70
85
|
_strings: (string | undefined)[];
|
|
71
|
-
/** @internal */
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
/** @internal */
|
|
76
|
-
_prev_siblings: Uint32Array;
|
|
77
|
-
/** @internal */
|
|
78
|
-
_children_starts: Uint32Array;
|
|
79
|
-
/** @internal */
|
|
80
|
-
_children_ends: Uint32Array;
|
|
81
|
-
/** @internal */
|
|
82
|
-
_pending_nodes: Uint32Array;
|
|
83
|
-
private _size;
|
|
84
|
-
/**
|
|
85
|
-
* create a buffer that stores token metadata with typed arrays.
|
|
86
|
-
* @param initial_capacity requested starting capacity for tokens.
|
|
87
|
-
*/
|
|
86
|
+
/** @internal read by TreeBuilder to check ids against indices */
|
|
87
|
+
_size: number;
|
|
88
|
+
/** slots from _size up to here hold the template */
|
|
89
|
+
private _filled;
|
|
88
90
|
constructor(initial_capacity?: number);
|
|
89
|
-
|
|
91
|
+
private alloc;
|
|
92
|
+
/** @internal */
|
|
93
|
+
own_strings(): (string | undefined)[];
|
|
94
|
+
/** gives the unused tail of the last slab carve back, a later push resizes */
|
|
95
|
+
trim(): void;
|
|
96
|
+
/** clear nodes without reallocating storage */
|
|
90
97
|
reset(): void;
|
|
91
|
-
/** number of tokens currently stored. */
|
|
92
98
|
get size(): number;
|
|
93
99
|
/**
|
|
94
|
-
* push a
|
|
95
|
-
* @param kind
|
|
100
|
+
* push a node as the last child of parent
|
|
101
|
+
* @param kind node category.
|
|
96
102
|
* @param cursor cursor position
|
|
97
|
-
* @param parent index of the parent node, or
|
|
98
|
-
* @param extra extra metadata stored alongside the
|
|
103
|
+
* @param parent index of the parent node, or 0xffffffff for none.
|
|
104
|
+
* @param extra extra metadata stored alongside the node.
|
|
99
105
|
* @param metadata optional metadata associated with the node.
|
|
100
106
|
*/
|
|
101
107
|
push(kind: NodeKind, cursor: number, parent?: number, extra?: number, metadata?: any): number;
|
|
102
108
|
push_pending(kind: NodeKind, cursor: number, parent?: number, extra?: number, metadata?: any): number;
|
|
109
|
+
/** one body for every open so the builder inlines a single copy */
|
|
110
|
+
push_node(kind: NodeKind, cursor: number, parent: number, extra: number, pending: boolean): number;
|
|
111
|
+
/** parent must be a node, not 0xffffffff */
|
|
112
|
+
push_text(start: number, end: number, parent: number): number;
|
|
113
|
+
/** a closed node with no extra and a value range, as open, value and close would leave it */
|
|
114
|
+
push_leaf(kind: NodeKind, start: number, value_start: number, value_end: number, end: number, parent: number): number;
|
|
115
|
+
private fill;
|
|
103
116
|
/**
|
|
104
117
|
* allocate a node slot without linking it into any parent's child list.
|
|
105
|
-
* the caller is responsible for setting
|
|
118
|
+
* the caller is responsible for setting the parent and linking into the
|
|
106
119
|
* sibling chain manually. used by plugin structural mutations (prepend).
|
|
107
120
|
* @param kind node kind.
|
|
108
121
|
* @param cursor source position.
|
|
@@ -142,8 +155,10 @@ export declare class NodeBuffer {
|
|
|
142
155
|
* @param delimiter_text optional pre-resolved delimiter string (wire path).
|
|
143
156
|
* if provided, stored in _strings. if absent, value range is set from
|
|
144
157
|
* the node's start position.
|
|
158
|
+
* @param text_start source offset of delimiter_text, at the node start the
|
|
159
|
+
* repaired range slices the same text so it is not stored
|
|
145
160
|
*/
|
|
146
|
-
handle_repair(index: number, delimiter_text?: string): void;
|
|
161
|
+
handle_repair(index: number, delimiter_text?: string, text_start?: number): void;
|
|
147
162
|
repair(): void;
|
|
148
163
|
pop(): void;
|
|
149
164
|
/**
|
|
@@ -155,10 +170,6 @@ export declare class NodeBuffer {
|
|
|
155
170
|
set_parent_kind(index: number, kind: NodeKind): void;
|
|
156
171
|
/** return indices of all nodes matching the given kind (lazy scan). */
|
|
157
172
|
get_kinds(kind: NodeKind): number[];
|
|
158
|
-
/**
|
|
159
|
-
* get the token kind recorded at the supplied index.
|
|
160
|
-
* @param index token index.
|
|
161
|
-
*/
|
|
162
173
|
kind_at(index: number): NodeKind;
|
|
163
174
|
/**
|
|
164
175
|
* set the kind of the node at the given index
|
|
@@ -166,16 +177,16 @@ export declare class NodeBuffer {
|
|
|
166
177
|
* @param kind new kind
|
|
167
178
|
*/
|
|
168
179
|
set_kind(index: number, kind: NodeKind): void;
|
|
169
|
-
|
|
170
|
-
prev_siblings_set(index: number, value: number): void;
|
|
171
|
-
/** @internal set children_ends for wiretreebuilder revoke. */
|
|
172
|
-
children_ends_set(index: number, value: number): void;
|
|
180
|
+
extra_at(index: number): number;
|
|
173
181
|
/**
|
|
174
182
|
* set the extra of the node at the given index
|
|
175
183
|
* @param index index of the node whose extra to update
|
|
176
184
|
* @param extra new extra
|
|
177
185
|
*/
|
|
178
186
|
set_extra(index: number, extra: number): void;
|
|
187
|
+
start_at(index: number): number;
|
|
188
|
+
/** 0xffffffff while open */
|
|
189
|
+
end_at(index: number): number;
|
|
179
190
|
/**
|
|
180
191
|
* set the end position of the node at the given index
|
|
181
192
|
* @param index index of the node whose end position to update
|
|
@@ -183,16 +194,31 @@ export declare class NodeBuffer {
|
|
|
183
194
|
*/
|
|
184
195
|
set_end(index: number, end: number): void;
|
|
185
196
|
gently_set_end(index: number, end: number): void;
|
|
197
|
+
value_start_at(index: number): number;
|
|
198
|
+
value_end_at(index: number): number;
|
|
199
|
+
set_value(index: number, value_start: number, value_end: number): void;
|
|
200
|
+
set_value_start(index: number, value_start: number): void;
|
|
201
|
+
set_value_end(index: number, value_end: number): void;
|
|
186
202
|
gently_set_value_end(index: number, end: number): void;
|
|
203
|
+
parent_at(index: number): number;
|
|
204
|
+
set_parent(index: number, parent: number): void;
|
|
205
|
+
next_at(index: number): number;
|
|
206
|
+
set_next(index: number, next: number): void;
|
|
207
|
+
prev_at(index: number): number;
|
|
208
|
+
set_prev(index: number, prev: number): void;
|
|
209
|
+
first_child_at(index: number): number;
|
|
210
|
+
set_first_child(index: number, child: number): void;
|
|
211
|
+
last_child_at(index: number): number;
|
|
212
|
+
set_last_child(index: number, child: number): void;
|
|
213
|
+
pending_at(index: number): number;
|
|
187
214
|
/** pre-grow to avoid repeated resizes when the final size is estimable. */
|
|
188
215
|
ensure_capacity(needed: number): void;
|
|
189
216
|
/** double the backing storage when capacity is exhausted. */
|
|
190
217
|
private grow;
|
|
218
|
+
private resize;
|
|
191
219
|
set_metadata(index: number, metadata: any): void;
|
|
192
220
|
metadata_at(index: number): any | undefined;
|
|
193
|
-
|
|
194
|
-
set_value_start(index: number, value_start: number): void;
|
|
195
|
-
set_value_end(index: number, value_end: number): void;
|
|
221
|
+
delete_metadata(index: number): void;
|
|
196
222
|
/**
|
|
197
223
|
* get the node at the given index or the root node if no index is provided
|
|
198
224
|
* @param index index of the node to get
|