@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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { VirtualRoot } from './vdom.ts'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Reports whether an existing component instance must remount instead of reconciling during a
|
|
5
|
+
* development refresh.
|
|
6
|
+
*
|
|
7
|
+
* @param type Component function being considered for reuse.
|
|
8
|
+
* @returns `true` when existing instances must be remounted.
|
|
9
|
+
*/
|
|
10
|
+
export type ComponentStalenessCheck = (type: Function) => boolean
|
|
11
|
+
|
|
12
|
+
export let componentStalenessCheck: ComponentStalenessCheck | null = null
|
|
13
|
+
|
|
14
|
+
const roots = new Set<VirtualRoot>()
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Installs the process-wide component compatibility check used during development refreshes.
|
|
18
|
+
*
|
|
19
|
+
* When the check returns `true`, reconciliation replaces existing instances of that component
|
|
20
|
+
* instead of preserving their state. This is a low-level integration point for HMR runtimes.
|
|
21
|
+
*
|
|
22
|
+
* @param check Callback that returns `true` when instances of a component must be remounted.
|
|
23
|
+
*/
|
|
24
|
+
export function setComponentStalenessCheck(check: ComponentStalenessCheck): void {
|
|
25
|
+
componentStalenessCheck = check
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function registerRoot(root: VirtualRoot): void {
|
|
29
|
+
roots.add(root)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function unregisterRoot(root: VirtualRoot): void {
|
|
33
|
+
roots.delete(root)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Immediately schedules reconciliation for every active Remix UI root using its current element.
|
|
38
|
+
*
|
|
39
|
+
* HMR runtimes call this after installing updated component implementations so mounted trees render
|
|
40
|
+
* the new code while preserving compatible component state.
|
|
41
|
+
*/
|
|
42
|
+
export function reconcileRoots(): void {
|
|
43
|
+
for (let root of roots) {
|
|
44
|
+
root.reconcile()
|
|
45
|
+
}
|
|
46
|
+
}
|
package/src/runtime/run.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createFrame, type Frame } from './frame.ts'
|
|
2
2
|
import { createScheduler } from './vdom.ts'
|
|
3
3
|
import { createStyleManager } from '../style/index.ts'
|
|
4
|
-
import type { FrameHandle } from './component.ts'
|
|
4
|
+
import type { FrameHandle, Handle } from './component.ts'
|
|
5
5
|
import { createComponentErrorEvent } from './error-event.ts'
|
|
6
6
|
import type { ComponentErrorEvent } from './error-event.ts'
|
|
7
7
|
import type { LoadModule, ResolveFrame } from './frame.ts'
|
|
@@ -40,6 +40,8 @@ export type AppRuntimeEventMap = {
|
|
|
40
40
|
* Client runtime returned by {@link run}.
|
|
41
41
|
*/
|
|
42
42
|
export type AppRuntime = TypedEventTarget<AppRuntimeEventMap> & {
|
|
43
|
+
/** Access top-level and named frames in the application runtime. */
|
|
44
|
+
frames: Handle['frames']
|
|
43
45
|
/** Resolves after the current document finishes hydrating. */
|
|
44
46
|
ready(): Promise<void>
|
|
45
47
|
/** Flushes any queued component updates synchronously. */
|
|
@@ -99,18 +101,26 @@ export function run(init: RunInit): AppRuntime {
|
|
|
99
101
|
})
|
|
100
102
|
|
|
101
103
|
let appController = new AbortController()
|
|
102
|
-
|
|
104
|
+
let frames: Handle['frames'] = {
|
|
105
|
+
top: topFrame.handle,
|
|
106
|
+
get(name) {
|
|
107
|
+
return namedFrames.get(name)
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
startNavigationListener(appController.signal, init.resolveFrame !== undefined)
|
|
103
111
|
let readyPromise = topFrame.ready().catch((error) => {
|
|
104
112
|
errorTarget.dispatchEvent(createComponentErrorEvent(error))
|
|
105
113
|
throw error
|
|
106
114
|
})
|
|
107
115
|
|
|
108
116
|
return Object.assign(errorTarget, {
|
|
117
|
+
frames,
|
|
109
118
|
ready: () => readyPromise,
|
|
110
119
|
flush: () => topFrame.flush(),
|
|
111
120
|
dispose: () => {
|
|
112
121
|
appController.abort()
|
|
113
122
|
topFrame.dispose()
|
|
123
|
+
styleManager.dispose()
|
|
114
124
|
},
|
|
115
125
|
})
|
|
116
126
|
}
|
package/src/runtime/scheduler.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createDocumentState } from './document-state.ts'
|
|
2
2
|
import { createComponentErrorEvent } from './error-event.ts'
|
|
3
|
-
import type { CommittedComponentNode,
|
|
3
|
+
import type { CommittedComponentNode, VNodeParent } from './vnode.ts'
|
|
4
4
|
import { isCommittedComponentNode } from './vnode.ts'
|
|
5
5
|
import {
|
|
6
6
|
findNextSiblingDomAnchor,
|
|
@@ -87,11 +87,6 @@ export function createScheduler(
|
|
|
87
87
|
}, 0)
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
function getFrameStyleManager(vnode: CommittedComponentNode): StyleManager {
|
|
91
|
-
let runtime = vnode._handle?.frame.$runtime as { styleManager?: StyleManager } | undefined
|
|
92
|
-
return runtime?.styleManager ?? styles
|
|
93
|
-
}
|
|
94
|
-
|
|
95
90
|
function flush() {
|
|
96
91
|
if (flushing) return
|
|
97
92
|
flushing = true
|
|
@@ -126,32 +121,18 @@ export function createScheduler(
|
|
|
126
121
|
|
|
127
122
|
if (batch.size > 0) {
|
|
128
123
|
let vnodes = Array.from(batch)
|
|
129
|
-
let noScheduledAncestor = new Set<
|
|
124
|
+
let noScheduledAncestor = new Set<VNodeParent>()
|
|
130
125
|
|
|
131
126
|
for (let [vnode, domParent] of vnodes) {
|
|
132
127
|
if (ancestorIsScheduled(vnode, batch, noScheduledAncestor)) continue
|
|
133
|
-
let handle = vnode._handle
|
|
134
128
|
let curr = vnode._content
|
|
135
|
-
let vParent = vnode._parent!
|
|
136
129
|
// Calculate anchor at render time from current vdom position (never stale).
|
|
137
130
|
// Needed for fragment self-updates that add children - without this, new children
|
|
138
131
|
// would be appended after siblings. The keyed diff has placement logic, but unkeyed
|
|
139
132
|
// diff relies on anchor for correct positioning.
|
|
140
133
|
let anchor = findNextSiblingDomAnchor(vnode) || undefined
|
|
141
134
|
try {
|
|
142
|
-
|
|
143
|
-
renderComponent(
|
|
144
|
-
handle,
|
|
145
|
-
curr,
|
|
146
|
-
vnode,
|
|
147
|
-
domParent,
|
|
148
|
-
handle.frame,
|
|
149
|
-
scheduler,
|
|
150
|
-
updateStyles,
|
|
151
|
-
rootTarget,
|
|
152
|
-
vParent,
|
|
153
|
-
anchor,
|
|
154
|
-
)
|
|
135
|
+
renderComponent(curr, vnode, domParent, vnode._context, anchor)
|
|
155
136
|
} catch (error) {
|
|
156
137
|
dispatchError(error)
|
|
157
138
|
}
|
|
@@ -177,8 +158,7 @@ export function createScheduler(
|
|
|
177
158
|
|
|
178
159
|
function dispatchPhaseEvent(type: SchedulerPhaseType, parents: ParentNode[]) {
|
|
179
160
|
if (phaseListenerCounts[type] === 0) return
|
|
180
|
-
let event = new Event(type)
|
|
181
|
-
event.parents = parents
|
|
161
|
+
let event: SchedulerPhaseEvent = Object.assign(new Event(type), { parents })
|
|
182
162
|
phaseEvents.dispatchEvent(event)
|
|
183
163
|
}
|
|
184
164
|
|
|
@@ -201,12 +181,12 @@ export function createScheduler(
|
|
|
201
181
|
}
|
|
202
182
|
|
|
203
183
|
function ancestorIsScheduled(
|
|
204
|
-
vnode:
|
|
184
|
+
vnode: CommittedComponentNode,
|
|
205
185
|
batch: Map<CommittedComponentNode, ParentNode>,
|
|
206
|
-
safe: Set<
|
|
186
|
+
safe: Set<VNodeParent>,
|
|
207
187
|
): boolean {
|
|
208
|
-
let path:
|
|
209
|
-
let current = vnode._parent
|
|
188
|
+
let path: VNodeParent[] = []
|
|
189
|
+
let current: VNodeParent | undefined = vnode._parent
|
|
210
190
|
|
|
211
191
|
while (current) {
|
|
212
192
|
// Already verified this node has no scheduled ancestor above it
|
|
@@ -221,7 +201,7 @@ export function createScheduler(
|
|
|
221
201
|
return true
|
|
222
202
|
}
|
|
223
203
|
|
|
224
|
-
current = current._parent
|
|
204
|
+
current = current.kind === 'root' ? undefined : current._parent
|
|
225
205
|
}
|
|
226
206
|
|
|
227
207
|
// Reached root - mark entire path as safe for future lookups
|
package/src/runtime/to-vnode.ts
CHANGED
|
@@ -1,48 +1,110 @@
|
|
|
1
1
|
import { Fragment } from './component.ts'
|
|
2
|
+
import { Frame } from './component.ts'
|
|
2
3
|
import { invariant } from './invariant.ts'
|
|
3
|
-
import { isEmptyChild, isPrimitiveChild, normalizeChildren } from './core/children.ts'
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
4
|
+
import { isEmptyChild, isPrimitiveChild, isRemixNode, normalizeChildren } from './core/children.ts'
|
|
5
|
+
import type { RemixNode } from './jsx.ts'
|
|
6
|
+
import type { ElementFunction } from './element-function.ts'
|
|
7
|
+
import type { FrameProps } from './component.ts'
|
|
8
|
+
import { isMixinDescriptor } from './mixins/mixin.ts'
|
|
9
|
+
import {
|
|
10
|
+
isRemixElement,
|
|
11
|
+
NON_RENDER_NODE,
|
|
12
|
+
TEXT_NODE,
|
|
13
|
+
type RuntimeElementProps,
|
|
14
|
+
type RuntimeHostProps,
|
|
15
|
+
type VNodeInput,
|
|
16
|
+
} from './vnode.ts'
|
|
6
17
|
|
|
7
|
-
function flatMapChildrenToVNodes(
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
function flatMapChildrenToVNodes(props: RuntimeHostProps): VNodeInput[] {
|
|
19
|
+
let children = props.children
|
|
20
|
+
if (children === undefined) return []
|
|
10
21
|
if (!Array.isArray(children)) return [toVNode(children)]
|
|
11
|
-
let vnodes:
|
|
22
|
+
let vnodes: VNodeInput[] = []
|
|
12
23
|
flattenChildrenToVNodes(children, vnodes)
|
|
13
24
|
return vnodes
|
|
14
25
|
}
|
|
15
26
|
|
|
16
|
-
function flattenChildrenToVNodes(nodes: RemixNode[], out:
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
function flattenChildrenToVNodes(nodes: RemixNode[], out: VNodeInput[]): void {
|
|
28
|
+
let children = normalizeChildren(nodes)
|
|
29
|
+
for (let i = 0; i < children.length; i++) {
|
|
30
|
+
out.push(toVNode(children[i]))
|
|
19
31
|
}
|
|
20
32
|
}
|
|
21
33
|
|
|
22
|
-
export function toVNode(node: RemixNode):
|
|
34
|
+
export function toVNode(node: RemixNode): VNodeInput {
|
|
23
35
|
if (isEmptyChild(node)) {
|
|
24
|
-
return { type: NON_RENDER_NODE }
|
|
36
|
+
return { kind: 'empty', type: NON_RENDER_NODE }
|
|
25
37
|
}
|
|
26
38
|
|
|
27
39
|
if (isPrimitiveChild(node)) {
|
|
28
|
-
return { type: TEXT_NODE, _text: String(node) }
|
|
40
|
+
return { kind: 'text', type: TEXT_NODE, _text: String(node) }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isRemixElement(node)) {
|
|
44
|
+
if (node.type === Fragment) {
|
|
45
|
+
let props = parseHostProps(node.props)
|
|
46
|
+
return {
|
|
47
|
+
kind: 'fragment',
|
|
48
|
+
type: Fragment,
|
|
49
|
+
key: node.key,
|
|
50
|
+
_children: flatMapChildrenToVNodes(props),
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (node.type === Frame) {
|
|
55
|
+
invariant(isFrameProps(node.props), '<Frame /> requires a src prop')
|
|
56
|
+
return { kind: 'frame', type: Frame, key: node.key, props: node.props }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (typeof node.type === 'string') {
|
|
60
|
+
let props = parseHostProps(node.props)
|
|
61
|
+
// When innerHTML is set, ignore children
|
|
62
|
+
let children = props.innerHTML != null ? [] : flatMapChildrenToVNodes(props)
|
|
63
|
+
return {
|
|
64
|
+
kind: 'host',
|
|
65
|
+
type: node.type,
|
|
66
|
+
key: node.key,
|
|
67
|
+
props,
|
|
68
|
+
_children: children,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
invariant(isElementFunction(node.type), 'Expected component element type')
|
|
72
|
+
return { kind: 'component', type: node.type, key: node.key, props: node.props }
|
|
29
73
|
}
|
|
30
74
|
|
|
31
75
|
if (Array.isArray(node)) {
|
|
32
|
-
let children:
|
|
76
|
+
let children: VNodeInput[] = []
|
|
33
77
|
flattenChildrenToVNodes(node, children)
|
|
34
|
-
return { type: Fragment, _children: children }
|
|
78
|
+
return { kind: 'fragment', type: Fragment, _children: children }
|
|
35
79
|
}
|
|
36
80
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
81
|
+
invariant(false, 'Unexpected RemixNode')
|
|
82
|
+
}
|
|
40
83
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
84
|
+
function isFrameProps(props: RuntimeElementProps): props is RuntimeElementProps & FrameProps {
|
|
85
|
+
return typeof props.src === 'string' && props.src.length > 0
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function parseHostProps(props: RuntimeElementProps): RuntimeHostProps {
|
|
89
|
+
let children = props.children
|
|
90
|
+
invariant(children === undefined || isRemixNode(children), 'Invalid host children')
|
|
91
|
+
|
|
92
|
+
let innerHTML = props.innerHTML
|
|
93
|
+
invariant(innerHTML === undefined || typeof innerHTML === 'string', 'Invalid innerHTML prop')
|
|
94
|
+
|
|
95
|
+
let mix = props.mix
|
|
96
|
+
invariant(mix === undefined || isRuntimeMixValue(mix), 'Invalid mix prop')
|
|
97
|
+
return props
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function isRuntimeMixValue(value: unknown): value is RuntimeHostProps['mix'] {
|
|
101
|
+
if (!Array.isArray(value)) return isMixinDescriptor(value)
|
|
102
|
+
for (let descriptor of value) {
|
|
103
|
+
if (!isMixinDescriptor(descriptor)) return false
|
|
45
104
|
}
|
|
105
|
+
return true
|
|
106
|
+
}
|
|
46
107
|
|
|
47
|
-
|
|
108
|
+
function isElementFunction(value: unknown): value is ElementFunction {
|
|
109
|
+
return typeof value === 'function'
|
|
48
110
|
}
|
package/src/runtime/vdom.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FrameHandle } from './component.ts'
|
|
2
2
|
import { createFrameHandle } from './component.ts'
|
|
3
3
|
import { invariant } from './invariant.ts'
|
|
4
4
|
import type { RemixNode } from './jsx.ts'
|
|
5
|
+
import { createFrameRuntime, type ResolveFrame } from './frame.ts'
|
|
5
6
|
import {
|
|
6
7
|
createComponentErrorEvent,
|
|
7
8
|
getComponentError,
|
|
@@ -11,8 +12,9 @@ import { createScheduler, type Scheduler } from './scheduler.ts'
|
|
|
11
12
|
import { diffVNodes, remove as removeVNode } from './reconcile.ts'
|
|
12
13
|
import { toVNode } from './to-vnode.ts'
|
|
13
14
|
import { TypedEventTarget } from './typed-event-target.ts'
|
|
14
|
-
import { ROOT_VNODE, type
|
|
15
|
+
import { ROOT_VNODE, type CommittedVNode, type ReconcileContext, type RootVNode } from './vnode.ts'
|
|
15
16
|
import { resetStyleState, defaultStyleManager } from './diff-props.ts'
|
|
17
|
+
import { registerRoot, unregisterRoot } from './refresh.ts'
|
|
16
18
|
import type { StyleManager } from '../style/index.ts'
|
|
17
19
|
|
|
18
20
|
/**
|
|
@@ -27,6 +29,7 @@ export type VirtualRootEventMap = {
|
|
|
27
29
|
*/
|
|
28
30
|
export type VirtualRoot = TypedEventTarget<VirtualRootEventMap> & {
|
|
29
31
|
render: (element: RemixNode) => void
|
|
32
|
+
reconcile: () => void
|
|
30
33
|
dispose: () => void
|
|
31
34
|
flush: () => void
|
|
32
35
|
}
|
|
@@ -40,11 +43,7 @@ export type VirtualRootOptions = {
|
|
|
40
43
|
styleManager?: StyleManager
|
|
41
44
|
frameInit?: {
|
|
42
45
|
src?: string
|
|
43
|
-
resolveFrame:
|
|
44
|
-
src: string,
|
|
45
|
-
signal?: AbortSignal,
|
|
46
|
-
target?: string,
|
|
47
|
-
) => Promise<FrameContent> | FrameContent
|
|
46
|
+
resolveFrame: ResolveFrame
|
|
48
47
|
loadModule?: (moduleUrl: string, exportName: string) => Promise<Function> | Function
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -73,7 +72,8 @@ export function createRangeRoot(
|
|
|
73
72
|
options: VirtualRootOptions = {},
|
|
74
73
|
): VirtualRoot {
|
|
75
74
|
let [start, end] = boundaries
|
|
76
|
-
let vroot:
|
|
75
|
+
let vroot: CommittedVNode | null = null
|
|
76
|
+
let currentElement: RemixNode | undefined
|
|
77
77
|
let styles = options.styleManager ?? defaultStyleManager
|
|
78
78
|
|
|
79
79
|
let container = end.parentNode
|
|
@@ -96,6 +96,12 @@ export function createRangeRoot(
|
|
|
96
96
|
scheduler,
|
|
97
97
|
styleManager: styles,
|
|
98
98
|
})
|
|
99
|
+
let context: ReconcileContext = {
|
|
100
|
+
frame: frameStub,
|
|
101
|
+
scheduler,
|
|
102
|
+
styles,
|
|
103
|
+
rootTarget: eventTarget,
|
|
104
|
+
}
|
|
99
105
|
|
|
100
106
|
let isErrorForwardingAttached = false
|
|
101
107
|
function forwardDomError(event: Event) {
|
|
@@ -113,13 +119,16 @@ export function createRangeRoot(
|
|
|
113
119
|
}
|
|
114
120
|
attachDomErrorForwarding()
|
|
115
121
|
|
|
116
|
-
|
|
122
|
+
let root = Object.assign(eventTarget, {
|
|
117
123
|
render(element: RemixNode) {
|
|
118
124
|
attachDomErrorForwarding()
|
|
125
|
+
currentElement = element
|
|
119
126
|
|
|
120
127
|
let vnode = toVNode(element)
|
|
121
|
-
let vParent:
|
|
128
|
+
let vParent: RootVNode = {
|
|
129
|
+
kind: 'root',
|
|
122
130
|
type: ROOT_VNODE,
|
|
131
|
+
_children: [],
|
|
123
132
|
_svg: false,
|
|
124
133
|
_rangeStart: start,
|
|
125
134
|
_rangeEnd: end,
|
|
@@ -127,32 +136,30 @@ export function createRangeRoot(
|
|
|
127
136
|
}
|
|
128
137
|
scheduler.enqueueWork([
|
|
129
138
|
() => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
frameStub,
|
|
135
|
-
scheduler,
|
|
136
|
-
styles,
|
|
137
|
-
vParent,
|
|
138
|
-
eventTarget,
|
|
139
|
-
end,
|
|
140
|
-
hydrationCursor,
|
|
141
|
-
)
|
|
142
|
-
vroot = vnode
|
|
139
|
+
let cursor = hydrationCursor === null ? undefined : { current: hydrationCursor }
|
|
140
|
+
let committed = diffVNodes(vroot, vnode, parent, vParent, context, end, cursor)
|
|
141
|
+
vParent._children = [committed]
|
|
142
|
+
vroot = committed
|
|
143
143
|
hydrationCursor = null
|
|
144
144
|
},
|
|
145
145
|
])
|
|
146
146
|
scheduler.dequeue()
|
|
147
147
|
},
|
|
148
148
|
|
|
149
|
+
reconcile() {
|
|
150
|
+
if (currentElement === undefined) return
|
|
151
|
+
root.render(currentElement)
|
|
152
|
+
},
|
|
153
|
+
|
|
149
154
|
dispose() {
|
|
150
155
|
detachDomErrorForwarding()
|
|
156
|
+
unregisterRoot(root)
|
|
157
|
+
currentElement = undefined
|
|
151
158
|
|
|
152
159
|
if (!vroot) return
|
|
153
160
|
let current = vroot
|
|
154
161
|
vroot = null
|
|
155
|
-
scheduler.enqueueWork([() => removeVNode(current, parent,
|
|
162
|
+
scheduler.enqueueWork([() => removeVNode(current, parent, context)])
|
|
156
163
|
scheduler.dequeue()
|
|
157
164
|
},
|
|
158
165
|
|
|
@@ -160,6 +167,9 @@ export function createRangeRoot(
|
|
|
160
167
|
scheduler.dequeue()
|
|
161
168
|
},
|
|
162
169
|
})
|
|
170
|
+
|
|
171
|
+
registerRoot(root)
|
|
172
|
+
return root
|
|
163
173
|
}
|
|
164
174
|
|
|
165
175
|
/**
|
|
@@ -170,8 +180,15 @@ export function createRangeRoot(
|
|
|
170
180
|
* @returns A virtual root controller.
|
|
171
181
|
*/
|
|
172
182
|
export function createRoot(container: HTMLElement, options: VirtualRootOptions = {}): VirtualRoot {
|
|
173
|
-
let vroot:
|
|
183
|
+
let vroot: CommittedVNode | null = null
|
|
184
|
+
let currentElement: RemixNode | undefined
|
|
174
185
|
let styles = options.styleManager ?? defaultStyleManager
|
|
186
|
+
if (container.innerHTML.trim() !== '') {
|
|
187
|
+
// Adopt additively: multiple roots hydrating separate islands may share
|
|
188
|
+
// the default style manager, and adopting a later island must not release
|
|
189
|
+
// the server styles an earlier island still depends on.
|
|
190
|
+
styles.adoptServerStyles(container)
|
|
191
|
+
}
|
|
175
192
|
let hydrationCursor = container.innerHTML.trim() !== '' ? container.firstChild : undefined
|
|
176
193
|
|
|
177
194
|
let eventTarget = new TypedEventTarget<VirtualRootEventMap>()
|
|
@@ -187,6 +204,12 @@ export function createRoot(container: HTMLElement, options: VirtualRootOptions =
|
|
|
187
204
|
scheduler,
|
|
188
205
|
styleManager: styles,
|
|
189
206
|
})
|
|
207
|
+
let context: ReconcileContext = {
|
|
208
|
+
frame: frameStub,
|
|
209
|
+
scheduler,
|
|
210
|
+
styles,
|
|
211
|
+
rootTarget: eventTarget,
|
|
212
|
+
}
|
|
190
213
|
|
|
191
214
|
let isErrorForwardingAttached = false
|
|
192
215
|
function forwardDomError(event: Event) {
|
|
@@ -204,40 +227,44 @@ export function createRoot(container: HTMLElement, options: VirtualRootOptions =
|
|
|
204
227
|
}
|
|
205
228
|
attachDomErrorForwarding()
|
|
206
229
|
|
|
207
|
-
|
|
230
|
+
let root = Object.assign(eventTarget, {
|
|
208
231
|
render(element: RemixNode) {
|
|
209
232
|
attachDomErrorForwarding()
|
|
233
|
+
currentElement = element
|
|
210
234
|
|
|
211
235
|
let vnode = toVNode(element)
|
|
212
|
-
let vParent:
|
|
236
|
+
let vParent: RootVNode = {
|
|
237
|
+
kind: 'root',
|
|
238
|
+
type: ROOT_VNODE,
|
|
239
|
+
_children: [],
|
|
240
|
+
_svg: false,
|
|
241
|
+
}
|
|
213
242
|
scheduler.enqueueWork([
|
|
214
243
|
() => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
frameStub,
|
|
220
|
-
scheduler,
|
|
221
|
-
styles,
|
|
222
|
-
vParent,
|
|
223
|
-
eventTarget,
|
|
224
|
-
undefined,
|
|
225
|
-
hydrationCursor,
|
|
226
|
-
)
|
|
227
|
-
vroot = vnode
|
|
244
|
+
let cursor = hydrationCursor === undefined ? undefined : { current: hydrationCursor }
|
|
245
|
+
let committed = diffVNodes(vroot, vnode, container, vParent, context, undefined, cursor)
|
|
246
|
+
vParent._children = [committed]
|
|
247
|
+
vroot = committed
|
|
228
248
|
hydrationCursor = undefined
|
|
229
249
|
},
|
|
230
250
|
])
|
|
231
251
|
scheduler.dequeue()
|
|
232
252
|
},
|
|
233
253
|
|
|
254
|
+
reconcile() {
|
|
255
|
+
if (currentElement === undefined) return
|
|
256
|
+
root.render(currentElement)
|
|
257
|
+
},
|
|
258
|
+
|
|
234
259
|
dispose() {
|
|
235
260
|
detachDomErrorForwarding()
|
|
261
|
+
unregisterRoot(root)
|
|
262
|
+
currentElement = undefined
|
|
236
263
|
|
|
237
264
|
if (!vroot) return
|
|
238
265
|
let current = vroot
|
|
239
266
|
vroot = null
|
|
240
|
-
scheduler.enqueueWork([() => removeVNode(current, container,
|
|
267
|
+
scheduler.enqueueWork([() => removeVNode(current, container, context)])
|
|
241
268
|
scheduler.dequeue()
|
|
242
269
|
},
|
|
243
270
|
|
|
@@ -245,15 +272,14 @@ export function createRoot(container: HTMLElement, options: VirtualRootOptions =
|
|
|
245
272
|
scheduler.dequeue()
|
|
246
273
|
},
|
|
247
274
|
})
|
|
275
|
+
|
|
276
|
+
registerRoot(root)
|
|
277
|
+
return root
|
|
248
278
|
}
|
|
249
279
|
|
|
250
280
|
function createRootFrameHandle(init: {
|
|
251
281
|
src?: string
|
|
252
|
-
resolveFrame?:
|
|
253
|
-
src: string,
|
|
254
|
-
signal?: AbortSignal,
|
|
255
|
-
target?: string,
|
|
256
|
-
) => Promise<FrameContent> | FrameContent
|
|
282
|
+
resolveFrame?: ResolveFrame
|
|
257
283
|
loadModule?: (moduleUrl: string, exportName: string) => Promise<Function> | Function
|
|
258
284
|
errorTarget: EventTarget
|
|
259
285
|
scheduler: Scheduler
|
|
@@ -267,29 +293,25 @@ function createRootFrameHandle(init: {
|
|
|
267
293
|
)
|
|
268
294
|
})
|
|
269
295
|
|
|
270
|
-
let
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
moduleCache: new Map(),
|
|
287
|
-
moduleLoads: new Map(),
|
|
288
|
-
frameInstances: new WeakMap(),
|
|
289
|
-
namedFrames: new Map(),
|
|
290
|
-
},
|
|
296
|
+
let runtime = createFrameRuntime({
|
|
297
|
+
topFrame: undefined,
|
|
298
|
+
loadModule:
|
|
299
|
+
init.loadModule ??
|
|
300
|
+
(() => {
|
|
301
|
+
throw new Error('loadModule is required to hydrate client entries inside <Frame />')
|
|
302
|
+
}),
|
|
303
|
+
resolveFrame,
|
|
304
|
+
errorTarget: init.errorTarget,
|
|
305
|
+
pendingClientEntries: new Map(),
|
|
306
|
+
scheduler: init.scheduler,
|
|
307
|
+
styleManager: init.styleManager,
|
|
308
|
+
moduleCache: new Map(),
|
|
309
|
+
moduleLoads: new Map(),
|
|
310
|
+
frameInstances: new WeakMap(),
|
|
311
|
+
namedFrames: new Map(),
|
|
291
312
|
})
|
|
292
|
-
|
|
293
|
-
|
|
313
|
+
runtime.canResolveFrames = !!init.resolveFrame
|
|
314
|
+
let frame = createFrameHandle({ src: init.src ?? '/', $runtime: runtime })
|
|
315
|
+
runtime.topFrame = frame
|
|
294
316
|
return frame
|
|
295
317
|
}
|