@remix-run/ui 0.3.0 → 0.5.0
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/README.md +116 -157
- package/dist/accordion/index.d.ts +46 -0
- package/dist/accordion/index.js +142 -0
- package/dist/accordion/index.js.map +1 -0
- package/dist/accordion/primitives.d.ts +104 -0
- package/dist/accordion/primitives.js +312 -0
- package/dist/accordion/primitives.js.map +1 -0
- package/dist/{components/anchor/anchor.js → anchor/index.js} +1 -1
- package/dist/anchor/index.js.map +1 -0
- package/dist/animation/animate-layout-mixin.js +1 -1
- package/dist/animation/animate-layout-mixin.js.map +1 -1
- package/dist/animation/animate-mixins.js +2 -2
- package/dist/animation/animate-mixins.js.map +1 -1
- package/dist/animation/demos/color-interpolation.js +1 -1
- package/dist/animation/demos/color-interpolation.js.map +1 -1
- package/dist/animation/demos/drag-release.d.ts +1 -1
- package/dist/animation/demos/hold-to-confirm.d.ts +3 -3
- package/dist/animation/demos/material-ripple.js +1 -3
- package/dist/animation/demos/material-ripple.js.map +1 -1
- package/dist/animation/demos/reordering.js +9 -6
- package/dist/animation/demos/reordering.js.map +1 -1
- package/dist/animation/index.js +4 -4
- package/dist/animation/spring.js.map +1 -1
- package/dist/{components/breadcrumbs/breadcrumbs.js → breadcrumbs/index.js} +19 -19
- package/dist/breadcrumbs/index.js.map +1 -0
- package/dist/button/index.d.ts +15 -0
- package/dist/button/index.js +128 -0
- package/dist/button/index.js.map +1 -0
- package/dist/checkbox/index.d.ts +14 -0
- package/dist/checkbox/index.js +127 -0
- package/dist/checkbox/index.js.map +1 -0
- package/dist/combobox/index.d.ts +21 -0
- package/dist/combobox/index.js +58 -0
- package/dist/combobox/index.js.map +1 -0
- package/dist/{components/combobox/combobox.d.ts → combobox/primitives.d.ts} +4 -8
- package/dist/{components/combobox/combobox.js → combobox/primitives.js} +8 -61
- package/dist/combobox/primitives.js.map +1 -0
- package/dist/dev/refresh.d.ts +1 -0
- package/dist/dev/refresh.js +2 -0
- package/dist/dev/refresh.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -14
- package/dist/input/index.d.ts +13 -0
- package/dist/input/index.js +121 -0
- package/dist/input/index.js.map +1 -0
- package/dist/jsx-runtime.js +2 -2
- package/dist/listbox/flash-attribute.js.map +1 -0
- package/dist/{components/listbox/listbox.d.ts → listbox/index.d.ts} +2 -6
- package/dist/{components/listbox/listbox.js → listbox/index.js} +4 -82
- package/dist/listbox/index.js.map +1 -0
- package/dist/menu/hover-aim.js.map +1 -0
- package/dist/menu/index.d.ts +42 -0
- package/dist/menu/index.js +250 -0
- package/dist/menu/index.js.map +1 -0
- package/dist/{components/menu/menu.d.ts → menu/primitives.d.ts} +4 -33
- package/dist/{components/menu/menu.js → menu/primitives.js} +98 -315
- package/dist/menu/primitives.js.map +1 -0
- package/dist/{components/popover/popover.d.ts → popover/index.d.ts} +2 -4
- package/dist/{components/popover/popover.js → popover/index.js} +5 -48
- package/dist/popover/index.js.map +1 -0
- package/dist/{interactions/outside-click/outside-click-mixin.js → popover/outside-click.js} +1 -1
- package/dist/popover/outside-click.js.map +1 -0
- package/dist/popover/scroll-lock.d.ts +1 -0
- package/dist/{utils → popover}/scroll-lock.js +0 -18
- package/dist/popover/scroll-lock.js.map +1 -0
- package/dist/radio/index.d.ts +12 -0
- package/dist/radio/index.js +77 -0
- package/dist/radio/index.js.map +1 -0
- package/dist/runtime/client-entry-boundary.d.ts +14 -0
- package/dist/runtime/client-entry-boundary.js +29 -0
- package/dist/runtime/client-entry-boundary.js.map +1 -0
- package/dist/runtime/component.d.ts +19 -4
- package/dist/runtime/component.js +39 -9
- package/dist/runtime/component.js.map +1 -1
- package/dist/runtime/core/attributes.js +36 -3
- package/dist/runtime/core/attributes.js.map +1 -1
- package/dist/runtime/core/children.d.ts +2 -0
- package/dist/runtime/core/children.js +26 -2
- package/dist/runtime/core/children.js.map +1 -1
- package/dist/runtime/core/props.js +2 -2
- package/dist/runtime/core/vnode.d.ts +3 -3
- package/dist/runtime/core/vnode.js +22 -1
- package/dist/runtime/core/vnode.js.map +1 -1
- package/dist/runtime/create-element.d.ts +2 -2
- package/dist/runtime/create-element.js +3 -2
- package/dist/runtime/create-element.js.map +1 -1
- package/dist/runtime/diff-dom.js +294 -219
- package/dist/runtime/diff-dom.js.map +1 -1
- package/dist/runtime/diff-props.js +3 -3
- package/dist/runtime/dom.d.ts +12 -0
- package/dist/runtime/element-function.d.ts +3 -0
- package/dist/runtime/element-function.js +2 -0
- package/dist/runtime/element-function.js.map +1 -0
- package/dist/runtime/form-navigation.d.ts +25 -0
- package/dist/runtime/form-navigation.js +132 -0
- package/dist/runtime/form-navigation.js.map +1 -0
- package/dist/runtime/frame-resolution.d.ts +5 -0
- package/dist/runtime/frame-resolution.js +10 -0
- package/dist/runtime/frame-resolution.js.map +1 -0
- package/dist/runtime/frame.d.ts +58 -15
- package/dist/runtime/frame.js +367 -114
- package/dist/runtime/frame.js.map +1 -1
- package/dist/runtime/jsx.d.ts +1 -1
- package/dist/runtime/jsx.js +1 -1
- package/dist/runtime/jsx.js.map +1 -1
- package/dist/runtime/key.d.ts +1 -0
- package/dist/runtime/key.js +2 -0
- package/dist/runtime/key.js.map +1 -0
- package/dist/runtime/mixins/attrs-mixin.js +2 -2
- package/dist/runtime/mixins/link-mixin.js +4 -3
- package/dist/runtime/mixins/link-mixin.js.map +1 -1
- package/dist/runtime/mixins/mixin.d.ts +15 -10
- package/dist/runtime/mixins/mixin.js +4 -4
- package/dist/runtime/mixins/mixin.js.map +1 -1
- package/dist/runtime/mixins/on-mixin.js +1 -1
- package/dist/runtime/mixins/ref-mixin.js +1 -1
- package/dist/runtime/navigation.d.ts +4 -1
- package/dist/runtime/navigation.js +157 -32
- package/dist/runtime/navigation.js.map +1 -1
- package/dist/runtime/reconcile.d.ts +11 -10
- package/dist/runtime/reconcile.js +557 -423
- package/dist/runtime/reconcile.js.map +1 -1
- package/dist/runtime/refresh.d.ts +28 -0
- package/dist/runtime/refresh.js +31 -0
- package/dist/runtime/refresh.js.map +1 -0
- package/dist/runtime/render.js +1 -1
- package/dist/runtime/render.js.map +1 -1
- package/dist/runtime/run.d.ts +3 -1
- package/dist/runtime/run.js +15 -7
- package/dist/runtime/run.js.map +1 -1
- package/dist/runtime/scheduler.js +8 -16
- package/dist/runtime/scheduler.js.map +1 -1
- package/dist/runtime/to-vnode.d.ts +2 -2
- package/dist/runtime/to-vnode.js +68 -20
- package/dist/runtime/to-vnode.js.map +1 -1
- package/dist/runtime/vdom.d.ts +4 -2
- package/dist/runtime/vdom.js +89 -41
- package/dist/runtime/vdom.js.map +1 -1
- package/dist/runtime/vnode.d.ts +138 -67
- package/dist/runtime/vnode.js +17 -12
- package/dist/runtime/vnode.js.map +1 -1
- package/dist/select/index.d.ts +19 -0
- package/dist/select/index.js +95 -0
- package/dist/select/index.js.map +1 -0
- package/dist/select/keydown.js.map +1 -0
- package/dist/{components/select/select.d.ts → select/primitives.d.ts} +5 -7
- package/dist/{components/select/select.js → select/primitives.js} +11 -63
- package/dist/select/primitives.js.map +1 -0
- package/dist/server/stream.js +22 -29
- package/dist/server/stream.js.map +1 -1
- package/dist/shared/focus-styles.d.ts +1 -0
- package/dist/shared/focus-styles.js +2 -0
- package/dist/shared/focus-styles.js.map +1 -0
- package/dist/shared/icons.d.ts +9 -0
- package/dist/shared/icons.js +42 -0
- package/dist/shared/icons.js.map +1 -0
- package/dist/shared/listbox-popover-styles.d.ts +6 -0
- package/dist/shared/listbox-popover-styles.js +137 -0
- package/dist/shared/listbox-popover-styles.js.map +1 -0
- package/dist/shared/style-values.d.ts +78 -0
- package/dist/shared/style-values.js +88 -0
- package/dist/shared/style-values.js.map +1 -0
- package/dist/{interactions/typeahead/typeahead-mixin.js → shared/typeahead.js} +1 -1
- package/dist/shared/typeahead.js.map +1 -0
- package/dist/shared/wait-for-css-transition.js.map +1 -0
- package/dist/shared/wait.js.map +1 -0
- package/dist/style/css-mixin.js +3 -3
- package/dist/style/index.js +2 -2
- package/dist/style/style.js +25 -6
- package/dist/style/style.js.map +1 -1
- package/dist/style/stylesheet.d.ts +0 -1
- package/dist/style/stylesheet.js +13 -54
- package/dist/style/stylesheet.js.map +1 -1
- package/dist/tabs/index.d.ts +32 -0
- package/dist/tabs/index.js +157 -0
- package/dist/tabs/index.js.map +1 -0
- package/dist/tabs/primitives.d.ts +57 -0
- package/dist/tabs/primitives.js +238 -0
- package/dist/tabs/primitives.js.map +1 -0
- package/dist/test.js +1 -1
- package/dist/toggle/index.d.ts +9 -0
- package/dist/toggle/index.js +108 -0
- package/dist/toggle/index.js.map +1 -0
- package/dist/toggle/primitives.d.ts +29 -0
- package/dist/toggle/primitives.js +127 -0
- package/dist/toggle/primitives.js.map +1 -0
- package/package.json +81 -49
- package/src/{components/accordion → accordion}/README.md +50 -14
- package/src/accordion/index.tsx +285 -0
- package/src/accordion/primitives.tsx +512 -0
- package/src/{components/anchor → anchor}/README.md +37 -2
- package/src/animation/animate-mixins.ts +3 -3
- package/src/animation/demos/color-interpolation.tsx +1 -1
- package/src/animation/demos/reordering.tsx +9 -6
- package/src/{components/breadcrumbs → breadcrumbs}/README.md +4 -4
- package/src/{components/breadcrumbs/breadcrumbs.tsx → breadcrumbs/index.tsx} +18 -18
- package/src/button/README.md +44 -0
- package/src/button/index.ts +168 -0
- package/src/checkbox/README.md +59 -0
- package/src/checkbox/index.ts +164 -0
- package/src/{components/combobox → combobox}/README.md +58 -9
- package/src/combobox/index.tsx +112 -0
- package/src/{components/combobox/combobox.tsx → combobox/primitives.tsx} +5 -91
- package/src/dev/refresh.ts +1 -0
- package/src/index.ts +1 -1
- package/src/input/README.md +52 -0
- package/src/input/index.ts +147 -0
- package/src/{components/listbox → listbox}/README.md +9 -41
- package/src/{components/listbox/listbox.ts → listbox/index.ts} +2 -87
- package/src/{components/menu → menu}/README.md +55 -14
- package/src/menu/index.tsx +354 -0
- package/src/{components/menu/menu.tsx → menu/primitives.tsx} +99 -413
- package/src/{components/popover → popover}/README.md +20 -39
- package/src/{components/popover/popover.ts → popover/index.ts} +3 -57
- package/src/{utils → popover}/scroll-lock.ts +0 -28
- package/src/radio/README.md +53 -0
- package/src/radio/index.ts +101 -0
- package/src/runtime/client-entry-boundary.ts +54 -0
- package/src/runtime/component.ts +65 -16
- package/src/runtime/core/attributes.ts +35 -1
- package/src/runtime/core/children.ts +24 -2
- package/src/runtime/core/vnode.ts +25 -4
- package/src/runtime/create-element.ts +6 -5
- package/src/runtime/demos/readme.demo.tsx +20 -18
- package/src/runtime/diff-dom.ts +358 -243
- package/src/runtime/dom.ts +331 -214
- package/src/runtime/element-function.ts +1 -0
- package/src/runtime/event-listeners.ts +1 -1
- package/src/runtime/form-navigation.ts +184 -0
- package/src/runtime/frame-resolution.ts +13 -0
- package/src/runtime/frame.ts +482 -124
- package/src/runtime/jsx.ts +3 -5
- package/src/runtime/key.ts +1 -0
- package/src/runtime/mixins/link-mixin.ts +1 -0
- package/src/runtime/mixins/mixin.ts +21 -18
- package/src/runtime/navigation.ts +204 -30
- package/src/runtime/reconcile.ts +769 -760
- package/src/runtime/refresh.ts +46 -0
- package/src/runtime/run.ts +12 -2
- package/src/runtime/scheduler.ts +9 -29
- package/src/runtime/to-vnode.ts +85 -23
- package/src/runtime/vdom.ts +91 -69
- package/src/runtime/vnode.ts +192 -88
- package/src/{components/select → select}/README.md +29 -19
- package/src/select/index.tsx +159 -0
- package/src/{components/select/select.tsx → select/primitives.tsx} +10 -98
- package/src/server/stream.ts +25 -31
- package/src/shared/focus-styles.ts +2 -0
- package/src/shared/icons.tsx +62 -0
- package/src/shared/listbox-popover-styles.ts +146 -0
- package/src/shared/style-values.ts +165 -0
- package/src/style/style.ts +25 -6
- package/src/style/stylesheet.ts +32 -57
- package/src/tabs/README.md +141 -0
- package/src/tabs/index.tsx +245 -0
- package/src/tabs/primitives.ts +365 -0
- package/src/test/README.md +151 -60
- package/src/toggle/README.md +56 -0
- package/src/toggle/index.tsx +136 -0
- package/src/toggle/primitives.ts +192 -0
- package/dist/animation/demos/animation.demo.d.ts +0 -5
- package/dist/animation/demos/animation.demo.js +0 -92
- package/dist/animation/demos/animation.demo.js.map +0 -1
- package/dist/animation/demos/spring.demo.d.ts +0 -6
- package/dist/animation/demos/spring.demo.js +0 -304
- package/dist/animation/demos/spring.demo.js.map +0 -1
- package/dist/components/accordion/accordion.d.ts +0 -92
- package/dist/components/accordion/accordion.js +0 -335
- package/dist/components/accordion/accordion.js.map +0 -1
- package/dist/components/accordion/demos/card.demo.d.ts +0 -7
- package/dist/components/accordion/demos/card.demo.js +0 -59
- package/dist/components/accordion/demos/card.demo.js.map +0 -1
- package/dist/components/accordion/demos/multiple.demo.d.ts +0 -7
- package/dist/components/accordion/demos/multiple.demo.js +0 -20
- package/dist/components/accordion/demos/multiple.demo.js.map +0 -1
- package/dist/components/accordion/demos/overview.demo.d.ts +0 -7
- package/dist/components/accordion/demos/overview.demo.js +0 -20
- package/dist/components/accordion/demos/overview.demo.js.map +0 -1
- package/dist/components/anchor/anchor.js.map +0 -1
- package/dist/components/breadcrumbs/basic.demo.d.ts +0 -6
- package/dist/components/breadcrumbs/basic.demo.js +0 -15
- package/dist/components/breadcrumbs/basic.demo.js.map +0 -1
- package/dist/components/breadcrumbs/breadcrumbs.js.map +0 -1
- package/dist/components/breadcrumbs/separator.demo.d.ts +0 -6
- package/dist/components/breadcrumbs/separator.demo.js +0 -15
- package/dist/components/breadcrumbs/separator.demo.js.map +0 -1
- package/dist/components/button/button.d.ts +0 -105
- package/dist/components/button/button.js +0 -207
- package/dist/components/button/button.js.map +0 -1
- package/dist/components/button/demos/aliases.demo.d.ts +0 -7
- package/dist/components/button/demos/aliases.demo.js +0 -19
- package/dist/components/button/demos/aliases.demo.js.map +0 -1
- package/dist/components/button/demos/basic.demo.d.ts +0 -7
- package/dist/components/button/demos/basic.demo.js +0 -20
- package/dist/components/button/demos/basic.demo.js.map +0 -1
- package/dist/components/button/demos/states.demo.d.ts +0 -7
- package/dist/components/button/demos/states.demo.js +0 -30
- package/dist/components/button/demos/states.demo.js.map +0 -1
- package/dist/components/combobox/combobox.js.map +0 -1
- package/dist/components/combobox/overview.demo.d.ts +0 -7
- package/dist/components/combobox/overview.demo.js +0 -154
- package/dist/components/combobox/overview.demo.js.map +0 -1
- package/dist/components/glyph/glyph.d.ts +0 -14
- package/dist/components/glyph/glyph.js +0 -65
- package/dist/components/glyph/glyph.js.map +0 -1
- package/dist/components/listbox/listbox.js.map +0 -1
- package/dist/components/listbox/overview.demo.d.ts +0 -7
- package/dist/components/listbox/overview.demo.js +0 -65
- package/dist/components/listbox/overview.demo.js.map +0 -1
- package/dist/components/menu/demos/bubbling.demo.d.ts +0 -6
- package/dist/components/menu/demos/bubbling.demo.js +0 -16
- package/dist/components/menu/demos/bubbling.demo.js.map +0 -1
- package/dist/components/menu/demos/context-trigger.demo.d.ts +0 -7
- package/dist/components/menu/demos/context-trigger.demo.js +0 -87
- package/dist/components/menu/demos/context-trigger.demo.js.map +0 -1
- package/dist/components/menu/demos/overview.demo.d.ts +0 -7
- package/dist/components/menu/demos/overview.demo.js +0 -33
- package/dist/components/menu/demos/overview.demo.js.map +0 -1
- package/dist/components/menu/hover-aim.js.map +0 -1
- package/dist/components/menu/menu.js.map +0 -1
- package/dist/components/popover/overview.demo.d.ts +0 -7
- package/dist/components/popover/overview.demo.js +0 -65
- package/dist/components/popover/overview.demo.js.map +0 -1
- package/dist/components/popover/popover.js.map +0 -1
- package/dist/components/select/deconstructed.demo.d.ts +0 -7
- package/dist/components/select/deconstructed.demo.js +0 -54
- package/dist/components/select/deconstructed.demo.js.map +0 -1
- package/dist/components/select/overview.demo.d.ts +0 -6
- package/dist/components/select/overview.demo.js +0 -28
- package/dist/components/select/overview.demo.js.map +0 -1
- package/dist/components/select/select.js.map +0 -1
- package/dist/components/separator/separator.d.ts +0 -2
- package/dist/components/separator/separator.js +0 -15
- package/dist/components/separator/separator.js.map +0 -1
- package/dist/components/tabs/tabs.d.ts +0 -78
- package/dist/components/tabs/tabs.js +0 -339
- package/dist/components/tabs/tabs.js.map +0 -1
- package/dist/interactions/keydown/keydown.js.map +0 -1
- package/dist/interactions/outside-click/outside-click-mixin.js.map +0 -1
- package/dist/interactions/typeahead/typeahead-mixin.js.map +0 -1
- package/dist/runtime/demos/basic.demo.d.ts +0 -6
- package/dist/runtime/demos/basic.demo.js +0 -16
- package/dist/runtime/demos/basic.demo.js.map +0 -1
- package/dist/runtime/demos/controlled-uncontrolled-values.demo.d.ts +0 -6
- package/dist/runtime/demos/controlled-uncontrolled-values.demo.js +0 -77
- package/dist/runtime/demos/controlled-uncontrolled-values.demo.js.map +0 -1
- package/dist/runtime/demos/keyed-list.demo.d.ts +0 -6
- package/dist/runtime/demos/keyed-list.demo.js +0 -62
- package/dist/runtime/demos/keyed-list.demo.js.map +0 -1
- package/dist/runtime/demos/readme.demo.d.ts +0 -5
- package/dist/runtime/demos/readme.demo.js +0 -396
- package/dist/runtime/demos/readme.demo.js.map +0 -1
- package/dist/theme/contract.d.ts +0 -61
- package/dist/theme/contract.js +0 -131
- package/dist/theme/contract.js.map +0 -1
- package/dist/theme/glyph-contract.d.ts +0 -11
- package/dist/theme/glyph-contract.js +0 -34
- package/dist/theme/glyph-contract.js.map +0 -1
- package/dist/theme/presets/rmx-01/glyphs.d.ts +0 -2
- package/dist/theme/presets/rmx-01/glyphs.js +0 -252
- package/dist/theme/presets/rmx-01/glyphs.js.map +0 -1
- package/dist/theme/presets/rmx-01/index.d.ts +0 -4
- package/dist/theme/presets/rmx-01/index.js +0 -119
- package/dist/theme/presets/rmx-01/index.js.map +0 -1
- package/dist/theme/runtime.d.ts +0 -2
- package/dist/theme/runtime.js +0 -84
- package/dist/theme/runtime.js.map +0 -1
- package/dist/theme/theme.d.ts +0 -6
- package/dist/theme/theme.js +0 -5
- package/dist/theme/theme.js.map +0 -1
- package/dist/utils/flash-attribute.js.map +0 -1
- package/dist/utils/scroll-lock.d.ts +0 -3
- package/dist/utils/scroll-lock.js.map +0 -1
- package/dist/utils/wait-for-css-transition.js.map +0 -1
- package/dist/utils/wait.js.map +0 -1
- package/src/animation/demos/animation.demo.tsx +0 -194
- package/src/animation/demos/spring.demo.tsx +0 -385
- package/src/components/accordion/accordion.tsx +0 -565
- package/src/components/accordion/demos/card.demo.tsx +0 -114
- package/src/components/accordion/demos/multiple.demo.tsx +0 -57
- package/src/components/accordion/demos/overview.demo.tsx +0 -57
- package/src/components/breadcrumbs/basic.demo.tsx +0 -18
- package/src/components/breadcrumbs/separator.demo.tsx +0 -19
- package/src/components/button/README.md +0 -44
- package/src/components/button/button.tsx +0 -286
- package/src/components/button/demos/aliases.demo.tsx +0 -28
- package/src/components/button/demos/basic.demo.tsx +0 -31
- package/src/components/button/demos/states.demo.tsx +0 -53
- package/src/components/combobox/overview.demo.tsx +0 -200
- package/src/components/glyph/README.md +0 -72
- package/src/components/glyph/glyph.tsx +0 -110
- package/src/components/listbox/overview.demo.tsx +0 -102
- package/src/components/menu/demos/bubbling.demo.tsx +0 -35
- package/src/components/menu/demos/context-trigger.demo.tsx +0 -133
- package/src/components/menu/demos/overview.demo.tsx +0 -77
- package/src/components/popover/overview.demo.tsx +0 -144
- package/src/components/select/deconstructed.demo.tsx +0 -96
- package/src/components/select/overview.demo.tsx +0 -52
- package/src/components/separator/separator.ts +0 -19
- package/src/components/tabs/README.md +0 -105
- package/src/components/tabs/tabs.tsx +0 -504
- package/src/runtime/demos/basic.demo.tsx +0 -21
- package/src/runtime/demos/controlled-uncontrolled-values.demo.tsx +0 -177
- package/src/runtime/demos/keyed-list.demo.tsx +0 -94
- package/src/theme/README.md +0 -103
- package/src/theme/contract.ts +0 -215
- package/src/theme/glyph-contract.ts +0 -59
- package/src/theme/presets/rmx-01/glyphs.tsx +0 -308
- package/src/theme/presets/rmx-01/index.ts +0 -123
- package/src/theme/runtime.ts +0 -119
- package/src/theme/theme.ts +0 -15
- package/src/utils/scroll-lock/README.md +0 -33
- /package/dist/{components/anchor/anchor.d.ts → anchor/index.d.ts} +0 -0
- /package/dist/{components/breadcrumbs/breadcrumbs.d.ts → breadcrumbs/index.d.ts} +0 -0
- /package/dist/{utils → listbox}/flash-attribute.d.ts +0 -0
- /package/dist/{utils → listbox}/flash-attribute.js +0 -0
- /package/dist/{components/menu → menu}/hover-aim.d.ts +0 -0
- /package/dist/{components/menu → menu}/hover-aim.js +0 -0
- /package/dist/{interactions/outside-click/outside-click-mixin.d.ts → popover/outside-click.d.ts} +0 -0
- /package/dist/{interactions/keydown → select}/keydown.d.ts +0 -0
- /package/dist/{interactions/keydown → select}/keydown.js +0 -0
- /package/dist/{interactions/typeahead/typeahead-mixin.d.ts → shared/typeahead.d.ts} +0 -0
- /package/dist/{utils → shared}/wait-for-css-transition.d.ts +0 -0
- /package/dist/{utils → shared}/wait-for-css-transition.js +0 -0
- /package/dist/{utils → shared}/wait.d.ts +0 -0
- /package/dist/{utils → shared}/wait.js +0 -0
- /package/src/{components/anchor/anchor.ts → anchor/index.ts} +0 -0
- /package/src/{utils → listbox}/flash-attribute.ts +0 -0
- /package/src/{components/menu → menu}/hover-aim.ts +0 -0
- /package/src/{interactions/outside-click/outside-click-mixin.ts → popover/outside-click.ts} +0 -0
- /package/src/{interactions/keydown → select}/keydown.ts +0 -0
- /package/src/{interactions/typeahead/typeahead-mixin.ts → shared/typeahead.ts} +0 -0
- /package/src/{utils → shared}/wait-for-css-transition.ts +0 -0
- /package/src/{utils → shared}/wait.ts +0 -0
package/dist/runtime/diff-dom.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { invariant } from
|
|
1
|
+
import { invariant } from './invariant.js';
|
|
2
|
+
import { disposeClientEntryBoundary, getClientEntryBoundaryOwner } from './client-entry-boundary.js';
|
|
3
|
+
const REMIX_PRESERVE_DOM_ATTRIBUTE = 'rmx-preserve-dom';
|
|
2
4
|
export function diffNodes(curr, next, context) {
|
|
3
5
|
let parent = curr[0]?.parentNode ?? context.regionParent ?? null;
|
|
4
6
|
invariant(parent, 'Parent node not found');
|
|
@@ -6,60 +8,7 @@ export function diffNodes(curr, next, context) {
|
|
|
6
8
|
// nodes before the region tail ref rather than appending to the parent.
|
|
7
9
|
let regionTailRef = context.regionTailRef ??
|
|
8
10
|
(curr.length > 0 ? curr[curr.length - 1].nextSibling : null);
|
|
9
|
-
|
|
10
|
-
let nextIndex = 0;
|
|
11
|
-
while (currentIndex < curr.length || nextIndex < next.length) {
|
|
12
|
-
let c = curr[currentIndex];
|
|
13
|
-
let n = next[nextIndex];
|
|
14
|
-
if (!c && n) {
|
|
15
|
-
if (regionTailRef) {
|
|
16
|
-
parent.insertBefore(n, regionTailRef);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
parent.appendChild(n);
|
|
20
|
-
}
|
|
21
|
-
nextIndex++;
|
|
22
|
-
}
|
|
23
|
-
else if (c && !n) {
|
|
24
|
-
removeNode(c, parent, context);
|
|
25
|
-
currentIndex++;
|
|
26
|
-
}
|
|
27
|
-
else if (c && n) {
|
|
28
|
-
let replacement = getCommentMarkerRangeReplacement(c, n, curr, next, currentIndex, nextIndex, context);
|
|
29
|
-
if (replacement) {
|
|
30
|
-
replaceCommentMarkerRange(replacement, parent, context);
|
|
31
|
-
currentIndex = replacement.currentEndIndex + 1;
|
|
32
|
-
nextIndex = replacement.nextEndIndex + 1;
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
// Skip hydrated client-entry marker ranges; hydration pass re-renders
|
|
36
|
-
// roots with new props from incoming payload
|
|
37
|
-
if (isVirtualRootStartMarker(c) && isVirtualRootStartMarker(n)) {
|
|
38
|
-
let currentEnd = findHydrationEndMarker(c);
|
|
39
|
-
let nextEnd = findHydrationEndMarker(n);
|
|
40
|
-
let nextData = n.data;
|
|
41
|
-
if (c.data !== nextData)
|
|
42
|
-
c.data = nextData;
|
|
43
|
-
let currentEndIndex = curr.indexOf(currentEnd);
|
|
44
|
-
let nextEndIndex = next.indexOf(nextEnd);
|
|
45
|
-
currentIndex = currentEndIndex + 1;
|
|
46
|
-
nextIndex = nextEndIndex + 1;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
let cursor = diffNode(c, n, context);
|
|
50
|
-
if (cursor) {
|
|
51
|
-
let nextEndIndex = next.indexOf(cursor);
|
|
52
|
-
let currentEndIndex = isFrameStartMarker(c) && isFrameEndMarker(cursor)
|
|
53
|
-
? findFrameEndIndex(curr, currentIndex)
|
|
54
|
-
: currentIndex;
|
|
55
|
-
currentIndex = currentEndIndex + 1;
|
|
56
|
-
nextIndex = nextEndIndex + 1;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
currentIndex++;
|
|
60
|
-
nextIndex++;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
11
|
+
diffSiblingUnits(curr, next, parent, regionTailRef, context);
|
|
63
12
|
}
|
|
64
13
|
function diffNode(current, next, context) {
|
|
65
14
|
// Text -> Text
|
|
@@ -80,40 +29,41 @@ function diffNode(current, next, context) {
|
|
|
80
29
|
return end;
|
|
81
30
|
}
|
|
82
31
|
// Comment -> Comment
|
|
83
|
-
if (isCommentNode(current) && isCommentNode(next)) {
|
|
32
|
+
if (isCommentNode(current) && isCommentNode(next) && markerKindsMatch(current, next)) {
|
|
84
33
|
let newData = next.data;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
if (
|
|
34
|
+
let updated = false;
|
|
35
|
+
if (isFrameStartMarker(current)) {
|
|
36
|
+
if (shouldPreserveFrameStartMarker(current, next, context)) {
|
|
37
|
+
if (current.data !== newData) {
|
|
89
38
|
current.data = newData;
|
|
90
|
-
updated = true;
|
|
91
|
-
let frame = context.frameInstances.get(current);
|
|
92
|
-
let nextMarkerData = getFrameMarkerData(next, context);
|
|
93
|
-
if (frame && nextMarkerData) {
|
|
94
|
-
if (nextMarkerData.status === 'resolved') {
|
|
95
|
-
let nextEnd = findFrameEndMarker(next);
|
|
96
|
-
let nextContent = collectFrameContentFragment(current.ownerDocument, next, nextEnd);
|
|
97
|
-
void frame.renderMarkerContent({ ...nextMarkerData, id: getFrameId(next) }, nextContent, {
|
|
98
|
-
signal: context.signal,
|
|
99
|
-
});
|
|
100
|
-
return nextEnd;
|
|
101
|
-
}
|
|
102
|
-
if (frame.isDisplayingResolvedContent()) {
|
|
103
|
-
return findFrameEndMarker(next);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
39
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
40
|
+
updated = true;
|
|
41
|
+
let frame = context.frameInstances.get(current);
|
|
42
|
+
let nextMarkerData = getFrameMarkerData(next, context);
|
|
43
|
+
if (frame && nextMarkerData) {
|
|
44
|
+
if (nextMarkerData.status === 'resolved') {
|
|
45
|
+
let nextEnd = findFrameEndMarker(next);
|
|
46
|
+
let nextContent = collectFrameContentFragment(current.ownerDocument, next, nextEnd);
|
|
47
|
+
void frame.renderMarkerContent({ ...nextMarkerData, id: getFrameId(next) }, nextContent, {
|
|
48
|
+
data: context.data,
|
|
49
|
+
signal: context.signal,
|
|
50
|
+
});
|
|
51
|
+
return nextEnd;
|
|
52
|
+
}
|
|
53
|
+
if (frame.isDisplayingResolvedContent()) {
|
|
54
|
+
return findFrameEndMarker(next);
|
|
55
|
+
}
|
|
111
56
|
}
|
|
112
57
|
}
|
|
113
|
-
if (
|
|
58
|
+
else if (current.data !== newData) {
|
|
59
|
+
disposeFrameStartMarker(current, context);
|
|
114
60
|
current.data = newData;
|
|
61
|
+
updated = true;
|
|
115
62
|
}
|
|
116
63
|
}
|
|
64
|
+
if (!updated && current.data !== newData) {
|
|
65
|
+
current.data = newData;
|
|
66
|
+
}
|
|
117
67
|
return;
|
|
118
68
|
}
|
|
119
69
|
// Element -> Element
|
|
@@ -128,6 +78,8 @@ function diffNode(current, next, context) {
|
|
|
128
78
|
return;
|
|
129
79
|
}
|
|
130
80
|
// Same tag: update attributes then children
|
|
81
|
+
if (shouldPreserveDomElement(current, next))
|
|
82
|
+
return;
|
|
131
83
|
diffElementAttributes(current, next);
|
|
132
84
|
if (shouldPreserveElementChildren(current, next))
|
|
133
85
|
return;
|
|
@@ -164,6 +116,14 @@ function diffElementAttributes(current, next) {
|
|
|
164
116
|
}
|
|
165
117
|
}
|
|
166
118
|
}
|
|
119
|
+
function shouldPreserveDomElement(current, next) {
|
|
120
|
+
if (!next.hasAttribute(REMIX_PRESERVE_DOM_ATTRIBUTE))
|
|
121
|
+
return false;
|
|
122
|
+
if (!current.hasAttribute(REMIX_PRESERVE_DOM_ATTRIBUTE)) {
|
|
123
|
+
current.setAttribute(REMIX_PRESERVE_DOM_ATTRIBUTE, '');
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
167
127
|
function shouldPreserveLiveAttribute(current, next, name) {
|
|
168
128
|
if (name === 'open') {
|
|
169
129
|
if (current instanceof HTMLDetailsElement && next instanceof HTMLDetailsElement) {
|
|
@@ -221,162 +181,239 @@ function isPopoverOpen(element) {
|
|
|
221
181
|
function diffElementChildren(current, next, context) {
|
|
222
182
|
let currentChildren = Array.from(current.childNodes);
|
|
223
183
|
let nextChildren = Array.from(next.childNodes);
|
|
224
|
-
|
|
184
|
+
diffSiblingUnits(currentChildren, nextChildren, current, null, context);
|
|
185
|
+
}
|
|
186
|
+
function diffSiblingUnits(currentNodes, nextNodes, parent, regionTailRef, context) {
|
|
187
|
+
let currentUnits = parseSiblingUnits(currentNodes);
|
|
188
|
+
let nextUnits = parseSiblingUnits(nextNodes);
|
|
225
189
|
let keyToIndex = new Map();
|
|
226
|
-
for (let i = 0; i <
|
|
227
|
-
let
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
let
|
|
236
|
-
|
|
237
|
-
let nextChild = nextChildren[i];
|
|
190
|
+
for (let i = 0; i < currentUnits.length; i++) {
|
|
191
|
+
let key = getSiblingUnitKey(currentUnits[i]);
|
|
192
|
+
if (key !== undefined)
|
|
193
|
+
keyToIndex.set(key, i);
|
|
194
|
+
}
|
|
195
|
+
let used = new Array(currentUnits.length).fill(false);
|
|
196
|
+
let matchIndexForNext = new Array(nextUnits.length).fill(-1);
|
|
197
|
+
// Reserve globally matched keyed elements and semantic boundaries before
|
|
198
|
+
// positionally pairing the remaining ordinary siblings.
|
|
199
|
+
for (let i = 0; i < nextUnits.length; i++) {
|
|
200
|
+
let nextUnit = nextUnits[i];
|
|
238
201
|
let matchIndex = -1;
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
202
|
+
let key = getSiblingUnitKey(nextUnit);
|
|
203
|
+
if (key !== undefined) {
|
|
204
|
+
let keyedIndex = keyToIndex.get(key);
|
|
205
|
+
if (keyedIndex !== undefined &&
|
|
206
|
+
!used[keyedIndex] &&
|
|
207
|
+
siblingUnitsComparable(currentUnits[keyedIndex], nextUnit)) {
|
|
208
|
+
matchIndex = keyedIndex;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Boundary identities behave like implicit keys. Repeated boundaries with
|
|
212
|
+
// the same identity are paired in source order because server markers do
|
|
213
|
+
// not carry a separate application key.
|
|
214
|
+
if (matchIndex === -1 && nextUnit.kind !== 'node') {
|
|
215
|
+
for (let j = 0; j < currentUnits.length; j++) {
|
|
216
|
+
let currentUnit = currentUnits[j];
|
|
217
|
+
if (used[j] || currentUnit.kind !== nextUnit.kind)
|
|
218
|
+
continue;
|
|
219
|
+
if (shouldPreserveBoundaryUnit(currentUnit, nextUnit, context)) {
|
|
242
220
|
matchIndex = j;
|
|
243
221
|
break;
|
|
244
222
|
}
|
|
245
223
|
}
|
|
246
224
|
}
|
|
247
|
-
else if (isElement(nextChild)) {
|
|
248
|
-
let key = nextChild.getAttribute('data-key');
|
|
249
|
-
if (key != null && keyToIndex.has(key)) {
|
|
250
|
-
let idx = keyToIndex.get(key);
|
|
251
|
-
if (!used[idx])
|
|
252
|
-
matchIndex = idx;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
if (matchIndex === -1) {
|
|
256
|
-
let candidateIndex = i;
|
|
257
|
-
if (candidateIndex < currentChildren.length &&
|
|
258
|
-
!used[candidateIndex] &&
|
|
259
|
-
nodeTypesComparable(currentChildren[candidateIndex], nextChild)) {
|
|
260
|
-
matchIndex = candidateIndex;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
225
|
if (matchIndex !== -1)
|
|
264
226
|
used[matchIndex] = true;
|
|
265
227
|
matchIndexForNext[i] = matchIndex;
|
|
266
228
|
}
|
|
267
|
-
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
// the next end marker, so skip the owned interior nodes here.
|
|
290
|
-
let nextEndIdx = nextChildren.indexOf(cursor);
|
|
291
|
-
let currEndIdx = isFrameStartMarker(curChild) && isFrameEndMarker(cursor)
|
|
292
|
-
? findFrameEndIndex(currentChildren, mi)
|
|
293
|
-
: findHydrationEndIndex(currentChildren, mi);
|
|
294
|
-
// Adjacent marker ranges can pre-match into the next range and leave an
|
|
295
|
-
// orphaned end marker behind. Clear those stale matches first.
|
|
296
|
-
for (let j = i + 1; j <= nextEndIdx; j++) {
|
|
297
|
-
let matchedIndex = matchIndexForNext[j];
|
|
298
|
-
if (matchedIndex > currEndIdx) {
|
|
299
|
-
used[matchedIndex] = false;
|
|
300
|
-
}
|
|
301
|
-
matchIndexForNext[j] = -1;
|
|
302
|
-
}
|
|
303
|
-
// Mark the entire current region as used to avoid removals.
|
|
304
|
-
for (let k = mi; k <= currEndIdx; k++)
|
|
305
|
-
used[k] = true;
|
|
306
|
-
// Preserve both comment markers in committed; skip interior in reorder pass.
|
|
307
|
-
committed[i] = curChild; // start marker
|
|
308
|
-
committed[nextEndIdx] = currentChildren[currEndIdx]; // end marker
|
|
309
|
-
for (let j = i + 1; j < nextEndIdx; j++)
|
|
310
|
-
committed[j] = undefined;
|
|
311
|
-
// Jump to end of region.
|
|
312
|
-
i = nextEndIdx;
|
|
313
|
-
continue;
|
|
314
|
-
}
|
|
315
|
-
committed[i] = curChild;
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
committed[i] = nextChildren[i];
|
|
229
|
+
let remainingCurrentIndexes = [];
|
|
230
|
+
for (let i = 0; i < currentUnits.length; i++) {
|
|
231
|
+
if (!used[i])
|
|
232
|
+
remainingCurrentIndexes.push(i);
|
|
233
|
+
}
|
|
234
|
+
let remainingNextIndexes = [];
|
|
235
|
+
for (let i = 0; i < nextUnits.length; i++) {
|
|
236
|
+
if (matchIndexForNext[i] === -1)
|
|
237
|
+
remainingNextIndexes.push(i);
|
|
238
|
+
}
|
|
239
|
+
let remainingLength = Math.min(remainingCurrentIndexes.length, remainingNextIndexes.length);
|
|
240
|
+
for (let i = 0; i < remainingLength; i++) {
|
|
241
|
+
let currentIndex = remainingCurrentIndexes[i];
|
|
242
|
+
let nextIndex = remainingNextIndexes[i];
|
|
243
|
+
let currentUnit = currentUnits[currentIndex];
|
|
244
|
+
let nextUnit = nextUnits[nextIndex];
|
|
245
|
+
if (currentUnit.kind !== 'node' ||
|
|
246
|
+
nextUnit.kind !== 'node' ||
|
|
247
|
+
getSiblingUnitKey(currentUnit) !== undefined ||
|
|
248
|
+
getSiblingUnitKey(nextUnit) !== undefined ||
|
|
249
|
+
!siblingUnitsComparable(currentUnit, nextUnit)) {
|
|
250
|
+
continue;
|
|
319
251
|
}
|
|
252
|
+
used[currentIndex] = true;
|
|
253
|
+
matchIndexForNext[nextIndex] = currentIndex;
|
|
320
254
|
}
|
|
321
|
-
|
|
322
|
-
let
|
|
323
|
-
|
|
324
|
-
let
|
|
325
|
-
if (
|
|
255
|
+
let committed = new Array(nextUnits.length);
|
|
256
|
+
for (let i = 0; i < nextUnits.length; i++) {
|
|
257
|
+
let matchIndex = matchIndexForNext[i];
|
|
258
|
+
let nextUnit = nextUnits[i];
|
|
259
|
+
if (matchIndex === -1) {
|
|
260
|
+
committed[i] = nextUnit;
|
|
326
261
|
continue;
|
|
327
|
-
|
|
328
|
-
let
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (isVirtualRootStartMarker(node) ||
|
|
333
|
-
isVirtualRootEndMarker(node) ||
|
|
334
|
-
isFrameStartMarker(node) ||
|
|
335
|
-
isFrameEndMarker(node)) {
|
|
336
|
-
if (node.parentNode !== current) {
|
|
337
|
-
current.insertBefore(node, ref);
|
|
338
|
-
}
|
|
339
|
-
anchor = node;
|
|
262
|
+
}
|
|
263
|
+
let currentUnit = currentUnits[matchIndex];
|
|
264
|
+
if (currentUnit.kind === 'node' && nextUnit.kind === 'node') {
|
|
265
|
+
diffNode(currentUnit.node, nextUnit.node, context);
|
|
266
|
+
committed[i] = currentUnit;
|
|
340
267
|
continue;
|
|
341
268
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
269
|
+
invariant(currentUnit.kind !== 'node' && nextUnit.kind !== 'node', 'Expected boundaries');
|
|
270
|
+
let replacement = getCommentMarkerRangeReplacement(currentUnit.start, nextUnit.start, currentNodes, nextNodes, currentUnit.startIndex, nextUnit.startIndex, context);
|
|
271
|
+
if (replacement) {
|
|
272
|
+
replaceCommentMarkerRange(replacement, parent, context);
|
|
273
|
+
committed[i] = nextUnit;
|
|
274
|
+
continue;
|
|
349
275
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
276
|
+
let cursor = diffNode(currentUnit.start, nextUnit.start, context);
|
|
277
|
+
if (!cursor && currentUnit.kind === 'frame' && nextUnit.kind === 'frame') {
|
|
278
|
+
diffNodes(collectNodesBetween(currentUnit.start, currentUnit.end), nextNodes.slice(nextUnit.startIndex + 1, nextUnit.endIndex), {
|
|
279
|
+
...context,
|
|
280
|
+
regionParent: parent,
|
|
281
|
+
regionTailRef: currentUnit.end,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
committed[i] = currentUnit;
|
|
285
|
+
}
|
|
286
|
+
let anchor = regionTailRef;
|
|
287
|
+
for (let i = committed.length - 1; i >= 0; i--) {
|
|
288
|
+
let unit = committed[i];
|
|
289
|
+
let first = getSiblingUnitFirstNode(unit);
|
|
290
|
+
let ref = anchor?.parentNode === parent ? anchor : null;
|
|
291
|
+
if (unit.kind === 'node' &&
|
|
292
|
+
isPreservedDomElement(unit.node) &&
|
|
293
|
+
unit.node.parentNode === parent) {
|
|
294
|
+
anchor = unit.node;
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
placeSiblingUnitBefore(unit, parent, ref);
|
|
298
|
+
if (first.parentNode === parent)
|
|
299
|
+
anchor = first;
|
|
300
|
+
}
|
|
301
|
+
for (let i = 0; i < currentUnits.length; i++) {
|
|
302
|
+
if (!used[i])
|
|
303
|
+
removeSiblingUnit(currentUnits[i], parent, context);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function parseSiblingUnits(nodes) {
|
|
307
|
+
let units = [];
|
|
308
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
309
|
+
let node = nodes[i];
|
|
310
|
+
if (isVirtualRootStartMarker(node)) {
|
|
311
|
+
let endIndex = findHydrationEndIndex(nodes, i);
|
|
312
|
+
invariant(endIndex > i, 'Hydration end marker not found');
|
|
313
|
+
let end = nodes[endIndex];
|
|
314
|
+
invariant(isVirtualRootEndMarker(end), 'Expected hydration end marker');
|
|
315
|
+
units.push({ kind: 'hydration', start: node, end, startIndex: i, endIndex });
|
|
316
|
+
i = endIndex;
|
|
317
|
+
continue;
|
|
353
318
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
319
|
+
if (isFrameStartMarker(node)) {
|
|
320
|
+
let endIndex = findFrameEndIndex(nodes, i);
|
|
321
|
+
invariant(endIndex > i, 'Frame end marker not found');
|
|
322
|
+
let end = nodes[endIndex];
|
|
323
|
+
invariant(isFrameEndMarker(end), 'Expected frame end marker');
|
|
324
|
+
units.push({ kind: 'frame', start: node, end, startIndex: i, endIndex });
|
|
325
|
+
i = endIndex;
|
|
326
|
+
continue;
|
|
357
327
|
}
|
|
328
|
+
invariant(!isVirtualRootEndMarker(node), 'Unexpected hydration end marker');
|
|
329
|
+
invariant(!isFrameEndMarker(node), 'Unexpected frame end marker');
|
|
330
|
+
units.push({ kind: 'node', node, startIndex: i, endIndex: i });
|
|
358
331
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
332
|
+
return units;
|
|
333
|
+
}
|
|
334
|
+
function getSiblingUnitKey(unit) {
|
|
335
|
+
if (unit.kind !== 'node' || !isElement(unit.node))
|
|
336
|
+
return;
|
|
337
|
+
return unit.node.getAttribute('data-key') ?? undefined;
|
|
338
|
+
}
|
|
339
|
+
function siblingUnitsComparable(current, next) {
|
|
340
|
+
if (current.kind !== next.kind)
|
|
341
|
+
return false;
|
|
342
|
+
if (current.kind !== 'node' || next.kind !== 'node')
|
|
343
|
+
return true;
|
|
344
|
+
return nodeTypesComparable(current.node, next.node);
|
|
345
|
+
}
|
|
346
|
+
function shouldPreserveBoundaryUnit(current, next, context) {
|
|
347
|
+
if (current.kind !== next.kind)
|
|
348
|
+
return false;
|
|
349
|
+
return current.kind === 'frame'
|
|
350
|
+
? shouldPreserveFrameStartMarker(current.start, next.start, context)
|
|
351
|
+
: shouldPreserveHydrationStartMarker(current.start, next.start, context);
|
|
352
|
+
}
|
|
353
|
+
function getSiblingUnitFirstNode(unit) {
|
|
354
|
+
return unit.kind === 'node' ? unit.node : unit.start;
|
|
355
|
+
}
|
|
356
|
+
function placeSiblingUnitBefore(unit, parent, ref) {
|
|
357
|
+
if (unit.kind === 'node') {
|
|
358
|
+
if (unit.node.parentNode !== parent || unit.node.nextSibling !== ref) {
|
|
359
|
+
parent.insertBefore(unit.node, ref);
|
|
364
360
|
}
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
let nodes = collectNodeRange(unit.start, unit.end);
|
|
364
|
+
if (unit.start.parentNode === parent && unit.end.nextSibling === ref)
|
|
365
|
+
return;
|
|
366
|
+
let fragment = unit.start.ownerDocument.createDocumentFragment();
|
|
367
|
+
for (let node of nodes)
|
|
368
|
+
fragment.appendChild(node);
|
|
369
|
+
parent.insertBefore(fragment, ref);
|
|
370
|
+
}
|
|
371
|
+
function removeSiblingUnit(unit, parent, context) {
|
|
372
|
+
if (unit.kind === 'node') {
|
|
373
|
+
removeNode(unit.node, parent, context);
|
|
374
|
+
return;
|
|
365
375
|
}
|
|
376
|
+
for (let node of collectNodeRange(unit.start, unit.end)) {
|
|
377
|
+
removeNode(node, parent, context);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function collectNodesBetween(start, end) {
|
|
381
|
+
let nodes = [];
|
|
382
|
+
let node = start.nextSibling;
|
|
383
|
+
while (node && node !== end) {
|
|
384
|
+
nodes.push(node);
|
|
385
|
+
node = node.nextSibling;
|
|
386
|
+
}
|
|
387
|
+
return nodes;
|
|
388
|
+
}
|
|
389
|
+
function isPreservedDomElement(node) {
|
|
390
|
+
return isElement(node) && node.hasAttribute(REMIX_PRESERVE_DOM_ATTRIBUTE);
|
|
366
391
|
}
|
|
367
392
|
function nodeTypesComparable(a, b) {
|
|
368
393
|
if (isTextNode(a) && isTextNode(b))
|
|
369
394
|
return true;
|
|
370
395
|
if (isElement(a) && isElement(b))
|
|
371
396
|
return a.tagName === b.tagName;
|
|
372
|
-
if (isVirtualRootStartMarker(a) && isVirtualRootStartMarker(b))
|
|
373
|
-
return true;
|
|
374
|
-
if (isVirtualRootEndMarker(a) && isVirtualRootEndMarker(b))
|
|
375
|
-
return true;
|
|
376
397
|
if (isCommentNode(a) && isCommentNode(b))
|
|
377
|
-
return
|
|
398
|
+
return markerKindsMatch(a, b);
|
|
378
399
|
return false;
|
|
379
400
|
}
|
|
401
|
+
function getMarkerKind(node) {
|
|
402
|
+
if (!isCommentNode(node))
|
|
403
|
+
return undefined;
|
|
404
|
+
if (isFrameStartMarker(node))
|
|
405
|
+
return 'frame-start';
|
|
406
|
+
if (isFrameEndMarker(node))
|
|
407
|
+
return 'frame-end';
|
|
408
|
+
if (isVirtualRootStartMarker(node))
|
|
409
|
+
return 'virtual-root-start';
|
|
410
|
+
if (isVirtualRootEndMarker(node))
|
|
411
|
+
return 'virtual-root-end';
|
|
412
|
+
return undefined;
|
|
413
|
+
}
|
|
414
|
+
function markerKindsMatch(a, b) {
|
|
415
|
+
return getMarkerKind(a) === getMarkerKind(b);
|
|
416
|
+
}
|
|
380
417
|
function isHydrationEndComment(node) {
|
|
381
418
|
return isCommentNode(node) && node.data.trim() === '/rmx:h';
|
|
382
419
|
}
|
|
@@ -398,9 +435,16 @@ function findHydrationEndMarker(start) {
|
|
|
398
435
|
throw new Error('Hydration end marker not found');
|
|
399
436
|
}
|
|
400
437
|
function findHydrationEndIndex(nodes, startIdx) {
|
|
438
|
+
let depth = 1;
|
|
401
439
|
for (let j = startIdx + 1; j < nodes.length; j++) {
|
|
402
|
-
|
|
403
|
-
|
|
440
|
+
let node = nodes[j];
|
|
441
|
+
if (isVirtualRootStartMarker(node))
|
|
442
|
+
depth++;
|
|
443
|
+
if (isHydrationEndComment(node)) {
|
|
444
|
+
depth--;
|
|
445
|
+
if (depth === 0)
|
|
446
|
+
return j;
|
|
447
|
+
}
|
|
404
448
|
}
|
|
405
449
|
return startIdx;
|
|
406
450
|
}
|
|
@@ -451,12 +495,21 @@ function isFrameEndMarker(node) {
|
|
|
451
495
|
function shouldPreserveFrameStartMarker(current, next, context) {
|
|
452
496
|
if (!isFrameStartMarker(next))
|
|
453
497
|
return false;
|
|
454
|
-
let currentData = getFrameMarkerData(current, context);
|
|
455
498
|
let nextData = getFrameMarkerData(next, context);
|
|
456
|
-
|
|
499
|
+
let currentFrame = context.frameInstances.get(current);
|
|
500
|
+
return (currentFrame !== undefined &&
|
|
457
501
|
nextData !== undefined &&
|
|
458
|
-
|
|
459
|
-
|
|
502
|
+
currentFrame.matchesIdentity(nextData.src, nextData.name));
|
|
503
|
+
}
|
|
504
|
+
function shouldPreserveHydrationStartMarker(current, next, context) {
|
|
505
|
+
if (!isVirtualRootStartMarker(next))
|
|
506
|
+
return false;
|
|
507
|
+
let currentOwner = getClientEntryBoundaryOwner(current);
|
|
508
|
+
let nextData = getHydrationMarkerData(next, context);
|
|
509
|
+
return (currentOwner !== undefined &&
|
|
510
|
+
nextData !== undefined &&
|
|
511
|
+
currentOwner.identity.moduleUrl === nextData.moduleUrl &&
|
|
512
|
+
currentOwner.identity.exportName === nextData.exportName);
|
|
460
513
|
}
|
|
461
514
|
function getCommentMarkerRangeReplacement(current, next, currentNodes, nextNodes, currentIndex, nextIndex, context) {
|
|
462
515
|
// Comment markers can represent owned DOM ranges, not standalone comments. If
|
|
@@ -472,6 +525,25 @@ function getCommentMarkerRangeReplacement(current, next, currentNodes, nextNodes
|
|
|
472
525
|
nextEndIndex: findFrameEndIndex(nextNodes, nextIndex),
|
|
473
526
|
};
|
|
474
527
|
}
|
|
528
|
+
if (isVirtualRootStartMarker(current) &&
|
|
529
|
+
isVirtualRootStartMarker(next) &&
|
|
530
|
+
!shouldPreserveHydrationStartMarker(current, next, context)) {
|
|
531
|
+
return {
|
|
532
|
+
currentStart: current,
|
|
533
|
+
nextStart: next,
|
|
534
|
+
currentEndIndex: findHydrationEndIndex(currentNodes, currentIndex),
|
|
535
|
+
nextEndIndex: findHydrationEndIndex(nextNodes, nextIndex),
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
function getHydrationMarkerData(marker, context) {
|
|
540
|
+
let id = getHydrationId(marker);
|
|
541
|
+
return context.data.h?.[id];
|
|
542
|
+
}
|
|
543
|
+
function getHydrationId(marker) {
|
|
544
|
+
let trimmed = marker.data.trim();
|
|
545
|
+
invariant(trimmed.startsWith('rmx:h:'), 'Invalid hydration start marker');
|
|
546
|
+
return trimmed.slice('rmx:h:'.length);
|
|
475
547
|
}
|
|
476
548
|
function getFrameMarkerData(marker, context) {
|
|
477
549
|
let id = getFrameId(marker);
|
|
@@ -483,8 +555,8 @@ function getFrameId(marker) {
|
|
|
483
555
|
return trimmed.slice('rmx:f:'.length);
|
|
484
556
|
}
|
|
485
557
|
function replaceCommentMarkerRange(replacement, parent, context) {
|
|
486
|
-
let currentEnd =
|
|
487
|
-
let nextEnd =
|
|
558
|
+
let currentEnd = findCommentMarkerRangeEnd(replacement.currentStart);
|
|
559
|
+
let nextEnd = findCommentMarkerRangeEnd(replacement.nextStart);
|
|
488
560
|
let nextNodes = collectNodeRange(replacement.nextStart, nextEnd);
|
|
489
561
|
let currentNodes = collectNodeRange(replacement.currentStart, currentEnd);
|
|
490
562
|
for (let node of nextNodes) {
|
|
@@ -494,6 +566,13 @@ function replaceCommentMarkerRange(replacement, parent, context) {
|
|
|
494
566
|
removeNode(node, parent, context);
|
|
495
567
|
}
|
|
496
568
|
}
|
|
569
|
+
function findCommentMarkerRangeEnd(start) {
|
|
570
|
+
if (isFrameStartMarker(start))
|
|
571
|
+
return findFrameEndMarker(start);
|
|
572
|
+
if (isVirtualRootStartMarker(start))
|
|
573
|
+
return findHydrationEndMarker(start);
|
|
574
|
+
throw new Error('Comment marker range start not found');
|
|
575
|
+
}
|
|
497
576
|
function collectNodeRange(start, end) {
|
|
498
577
|
let nodes = [];
|
|
499
578
|
let node = start;
|
|
@@ -528,8 +607,7 @@ function disposeRemovedVirtualRoots(node) {
|
|
|
528
607
|
let next = stack.pop();
|
|
529
608
|
if (!next)
|
|
530
609
|
continue;
|
|
531
|
-
if (
|
|
532
|
-
next.$rmx.dispose();
|
|
610
|
+
if (isVirtualRootStartMarker(next) && disposeClientEntryBoundary(next)) {
|
|
533
611
|
continue;
|
|
534
612
|
}
|
|
535
613
|
for (let child of Array.from(next.childNodes)) {
|
|
@@ -561,9 +639,6 @@ function disposeFrameStartMarker(marker, context) {
|
|
|
561
639
|
function isVirtualRootStartMarker(node) {
|
|
562
640
|
return isCommentNode(node) && node.data.trim().startsWith('rmx:h:');
|
|
563
641
|
}
|
|
564
|
-
function isHydratedVirtualRootStartMarker(node) {
|
|
565
|
-
return isVirtualRootStartMarker(node) && '$rmx' in node;
|
|
566
|
-
}
|
|
567
642
|
function isVirtualRootEndMarker(node) {
|
|
568
643
|
return isCommentNode(node) && node.data.trim() === '/rmx:h';
|
|
569
644
|
}
|