@getcortexlabs/mavis-core 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +2 -2
- package/dist/accordion.d.ts +17 -0
- package/dist/accordion.d.ts.map +1 -0
- package/dist/accordion.js +42 -0
- package/dist/accordion.js.map +1 -0
- package/dist/alert.d.ts +21 -0
- package/dist/alert.d.ts.map +1 -0
- package/dist/alert.js +13 -0
- package/dist/alert.js.map +1 -0
- package/dist/app-icons.d.ts +27 -0
- package/dist/app-icons.d.ts.map +1 -0
- package/dist/app-icons.js +42 -0
- package/dist/app-icons.js.map +1 -0
- package/dist/avatar.d.ts +10 -0
- package/dist/avatar.d.ts.map +1 -0
- package/dist/avatar.js +11 -0
- package/dist/avatar.js.map +1 -0
- package/dist/badge.d.ts +7 -0
- package/dist/badge.d.ts.map +1 -0
- package/dist/badge.js +11 -0
- package/dist/badge.js.map +1 -0
- package/dist/capabilities.d.ts +132 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +180 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chart.d.ts +40 -0
- package/dist/chart.d.ts.map +1 -0
- package/dist/chart.js +73 -0
- package/dist/chart.js.map +1 -0
- package/dist/chip.d.ts +9 -0
- package/dist/chip.d.ts.map +1 -0
- package/dist/chip.js +16 -0
- package/dist/chip.js.map +1 -0
- package/dist/choice-motion.d.ts +14 -0
- package/dist/choice-motion.d.ts.map +1 -0
- package/dist/choice-motion.js +5 -0
- package/dist/choice-motion.js.map +1 -0
- package/dist/choice.d.ts +15 -0
- package/dist/choice.d.ts.map +1 -0
- package/dist/choice.js +27 -0
- package/dist/choice.js.map +1 -0
- package/dist/collections.d.ts +46 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +48 -0
- package/dist/collections.js.map +1 -0
- package/dist/combobox.d.ts +42 -0
- package/dist/combobox.d.ts.map +1 -0
- package/dist/combobox.js +159 -0
- package/dist/combobox.js.map +1 -0
- package/dist/contracts.d.ts +1321 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +268 -0
- package/dist/contracts.js.map +1 -0
- package/dist/date-input.d.ts +10 -0
- package/dist/date-input.d.ts.map +1 -0
- package/dist/date-input.js +58 -0
- package/dist/date-input.js.map +1 -0
- package/dist/date-time.d.ts +19 -0
- package/dist/date-time.d.ts.map +1 -0
- package/dist/date-time.js +27 -0
- package/dist/date-time.js.map +1 -0
- package/dist/date.d.ts +96 -0
- package/dist/date.d.ts.map +1 -0
- package/dist/date.js +235 -0
- package/dist/date.js.map +1 -0
- package/dist/dialog.d.ts +4 -0
- package/dist/dialog.d.ts.map +1 -0
- package/dist/dialog.js +21 -0
- package/dist/dialog.js.map +1 -0
- package/dist/discovery.d.ts +49 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +80 -0
- package/dist/discovery.js.map +1 -0
- package/dist/empty-state.d.ts +2 -0
- package/dist/empty-state.d.ts.map +1 -0
- package/dist/empty-state.js +5 -0
- package/dist/empty-state.js.map +1 -0
- package/dist/experimental-collections.d.ts +82 -0
- package/dist/experimental-collections.d.ts.map +1 -0
- package/dist/experimental-collections.js +8 -0
- package/dist/experimental-collections.js.map +1 -0
- package/dist/experimental-effects.d.ts +107 -0
- package/dist/experimental-effects.d.ts.map +1 -0
- package/dist/experimental-effects.js +24 -0
- package/dist/experimental-effects.js.map +1 -0
- package/dist/experimental-platforms.d.ts +94 -0
- package/dist/experimental-platforms.d.ts.map +1 -0
- package/dist/experimental-platforms.js +2 -0
- package/dist/experimental-platforms.js.map +1 -0
- package/dist/experimental-playback.d.ts +63 -0
- package/dist/experimental-playback.d.ts.map +1 -0
- package/dist/experimental-playback.js +46 -0
- package/dist/experimental-playback.js.map +1 -0
- package/dist/experimental-regions.d.ts +179 -0
- package/dist/experimental-regions.d.ts.map +1 -0
- package/dist/experimental-regions.js +554 -0
- package/dist/experimental-regions.js.map +1 -0
- package/dist/experimental-sensors.d.ts +42 -0
- package/dist/experimental-sensors.d.ts.map +1 -0
- package/dist/experimental-sensors.js +2 -0
- package/dist/experimental-sensors.js.map +1 -0
- package/dist/experimental-surfaces.d.ts +127 -0
- package/dist/experimental-surfaces.d.ts.map +1 -0
- package/dist/experimental-surfaces.js +2 -0
- package/dist/experimental-surfaces.js.map +1 -0
- package/dist/experimental.d.ts +197 -0
- package/dist/experimental.d.ts.map +1 -0
- package/dist/experimental.js +855 -0
- package/dist/experimental.js.map +1 -0
- package/dist/files.d.ts +87 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +328 -0
- package/dist/files.js.map +1 -0
- package/dist/form.d.ts +39 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +170 -0
- package/dist/form.js.map +1 -0
- package/dist/grid.d.ts +3 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +16 -0
- package/dist/grid.js.map +1 -0
- package/dist/icon.d.ts +15 -0
- package/dist/icon.d.ts.map +1 -0
- package/dist/icon.js +28 -0
- package/dist/icon.js.map +1 -0
- package/dist/icons.d.ts +2002 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +2003 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +59 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -1
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +14 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +12 -0
- package/dist/input.js.map +1 -1
- package/dist/link.d.ts +36 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +60 -0
- package/dist/link.js.map +1 -0
- package/dist/list-item.d.ts +3 -0
- package/dist/list-item.d.ts.map +1 -0
- package/dist/list-item.js +7 -0
- package/dist/list-item.js.map +1 -0
- package/dist/motion.d.ts +58 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +73 -0
- package/dist/motion.js.map +1 -0
- package/dist/multi-select.d.ts +4 -0
- package/dist/multi-select.d.ts.map +1 -0
- package/dist/multi-select.js +23 -0
- package/dist/multi-select.js.map +1 -0
- package/dist/navigation-transition.d.ts +10 -0
- package/dist/navigation-transition.d.ts.map +1 -0
- package/dist/navigation-transition.js +10 -0
- package/dist/navigation-transition.js.map +1 -0
- package/dist/navigation.d.ts +22 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +54 -0
- package/dist/navigation.js.map +1 -0
- package/dist/number-input.d.ts +21 -0
- package/dist/number-input.d.ts.map +1 -0
- package/dist/number-input.js +63 -0
- package/dist/number-input.js.map +1 -0
- package/dist/popover.d.ts +17 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +19 -0
- package/dist/popover.js.map +1 -0
- package/dist/progress.d.ts +19 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +19 -0
- package/dist/progress.js.map +1 -0
- package/dist/responsive.d.ts +18 -0
- package/dist/responsive.d.ts.map +1 -0
- package/dist/responsive.js +35 -0
- package/dist/responsive.js.map +1 -0
- package/dist/section-scroll.d.ts +14 -0
- package/dist/section-scroll.d.ts.map +1 -0
- package/dist/section-scroll.js +28 -0
- package/dist/section-scroll.js.map +1 -0
- package/dist/segmented.d.ts +11 -0
- package/dist/segmented.d.ts.map +1 -0
- package/dist/segmented.js +30 -0
- package/dist/segmented.js.map +1 -0
- package/dist/sheet.d.ts +19 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/sheet.js +15 -0
- package/dist/sheet.js.map +1 -0
- package/dist/tabs.d.ts +11 -0
- package/dist/tabs.d.ts.map +1 -0
- package/dist/tabs.js +28 -0
- package/dist/tabs.js.map +1 -0
- package/dist/theme/themes.d.ts.map +1 -1
- package/dist/theme/themes.js +85 -12
- package/dist/theme/themes.js.map +1 -1
- package/dist/theme/types.d.ts +64 -4
- package/dist/theme/types.d.ts.map +1 -1
- package/dist/theme/typography.d.ts +10 -0
- package/dist/theme/typography.d.ts.map +1 -0
- package/dist/theme/typography.js +90 -0
- package/dist/theme/typography.js.map +1 -0
- package/dist/time.d.ts +34 -0
- package/dist/time.d.ts.map +1 -0
- package/dist/time.js +78 -0
- package/dist/time.js.map +1 -0
- package/dist/toast.d.ts +43 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +228 -0
- package/dist/toast.js.map +1 -0
- package/dist/vue/button-content.d.ts +10 -0
- package/dist/vue/button-content.d.ts.map +1 -0
- package/dist/vue/button-content.js +54 -0
- package/dist/vue/button-content.js.map +1 -0
- package/dist/vue/cached-activity.d.ts +3 -0
- package/dist/vue/cached-activity.d.ts.map +1 -0
- package/dist/vue/cached-activity.js +13 -0
- package/dist/vue/cached-activity.js.map +1 -0
- package/dist/vue/carousel.d.ts +11 -0
- package/dist/vue/carousel.d.ts.map +1 -0
- package/dist/vue/carousel.js +115 -0
- package/dist/vue/carousel.js.map +1 -0
- package/dist/vue/chart.d.ts +194 -0
- package/dist/vue/chart.d.ts.map +1 -0
- package/dist/vue/chart.js +246 -0
- package/dist/vue/chart.js.map +1 -0
- package/dist/vue/combobox.d.ts +155 -0
- package/dist/vue/combobox.d.ts.map +1 -0
- package/dist/vue/combobox.js +195 -0
- package/dist/vue/combobox.js.map +1 -0
- package/dist/vue/command-palette.d.ts +129 -0
- package/dist/vue/command-palette.d.ts.map +1 -0
- package/dist/vue/command-palette.js +187 -0
- package/dist/vue/command-palette.js.map +1 -0
- package/dist/vue/component-props.d.ts +3310 -0
- package/dist/vue/component-props.d.ts.map +1 -0
- package/dist/vue/component-props.js +43 -0
- package/dist/vue/component-props.js.map +1 -0
- package/dist/vue/configurator-props.d.ts +277 -0
- package/dist/vue/configurator-props.d.ts.map +1 -0
- package/dist/vue/configurator-props.js +63 -0
- package/dist/vue/configurator-props.js.map +1 -0
- package/dist/vue/configurator.d.ts +403 -0
- package/dist/vue/configurator.d.ts.map +1 -0
- package/dist/vue/configurator.js +287 -0
- package/dist/vue/configurator.js.map +1 -0
- package/dist/vue/contracts.d.ts +18 -0
- package/dist/vue/contracts.d.ts.map +1 -0
- package/dist/vue/contracts.js +24 -0
- package/dist/vue/contracts.js.map +1 -0
- package/dist/vue/data-table.d.ts +17 -0
- package/dist/vue/data-table.d.ts.map +1 -0
- package/dist/vue/data-table.js +133 -0
- package/dist/vue/data-table.js.map +1 -0
- package/dist/vue/date-calendar.d.ts +64 -0
- package/dist/vue/date-calendar.d.ts.map +1 -0
- package/dist/vue/date-calendar.js +65 -0
- package/dist/vue/date-calendar.js.map +1 -0
- package/dist/vue/date-picker.d.ts +1000 -0
- package/dist/vue/date-picker.d.ts.map +1 -0
- package/dist/vue/date-picker.js +334 -0
- package/dist/vue/date-picker.js.map +1 -0
- package/dist/vue/date-props.d.ts +278 -0
- package/dist/vue/date-props.d.ts.map +1 -0
- package/dist/vue/date-props.js +81 -0
- package/dist/vue/date-props.js.map +1 -0
- package/dist/vue/dialog.d.ts +21 -0
- package/dist/vue/dialog.d.ts.map +1 -0
- package/dist/vue/dialog.js +58 -0
- package/dist/vue/dialog.js.map +1 -0
- package/dist/vue/discovery-components.d.ts +50 -0
- package/dist/vue/discovery-components.d.ts.map +1 -0
- package/dist/vue/discovery-components.js +2 -0
- package/dist/vue/discovery-components.js.map +1 -0
- package/dist/vue/discovery-controls.d.ts +197 -0
- package/dist/vue/discovery-controls.d.ts.map +1 -0
- package/dist/vue/discovery-controls.js +166 -0
- package/dist/vue/discovery-controls.js.map +1 -0
- package/dist/vue/discovery-props.d.ts +249 -0
- package/dist/vue/discovery-props.d.ts.map +1 -0
- package/dist/vue/discovery-props.js +87 -0
- package/dist/vue/discovery-props.js.map +1 -0
- package/dist/vue/files.d.ts +53 -0
- package/dist/vue/files.d.ts.map +1 -0
- package/dist/vue/files.js +40 -0
- package/dist/vue/files.js.map +1 -0
- package/dist/vue/forms.d.ts +4 -0
- package/dist/vue/forms.d.ts.map +1 -0
- package/dist/vue/forms.js +15 -0
- package/dist/vue/forms.js.map +1 -0
- package/dist/vue/global-components.d.ts +259 -3
- package/dist/vue/global-components.d.ts.map +1 -1
- package/dist/vue/index.d.ts +54 -4
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +45 -2
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/inline-content.d.ts +54 -0
- package/dist/vue/inline-content.d.ts.map +1 -0
- package/dist/vue/inline-content.js +64 -0
- package/dist/vue/inline-content.js.map +1 -0
- package/dist/vue/layout-context.d.ts +4 -2
- package/dist/vue/layout-context.d.ts.map +1 -1
- package/dist/vue/layout-context.js +7 -2
- package/dist/vue/layout-context.js.map +1 -1
- package/dist/vue/list-motion.d.ts +7 -0
- package/dist/vue/list-motion.d.ts.map +1 -0
- package/dist/vue/list-motion.js +28 -0
- package/dist/vue/list-motion.js.map +1 -0
- package/dist/vue/loading-effect.d.ts +7 -0
- package/dist/vue/loading-effect.d.ts.map +1 -0
- package/dist/vue/loading-effect.js +32 -0
- package/dist/vue/loading-effect.js.map +1 -0
- package/dist/vue/menu.d.ts +122 -0
- package/dist/vue/menu.d.ts.map +1 -0
- package/dist/vue/menu.js +79 -0
- package/dist/vue/menu.js.map +1 -0
- package/dist/vue/navigation-controls.d.ts +124 -0
- package/dist/vue/navigation-controls.d.ts.map +1 -0
- package/dist/vue/navigation-controls.js +117 -0
- package/dist/vue/navigation-controls.js.map +1 -0
- package/dist/vue/navigation-props.d.ts +283 -0
- package/dist/vue/navigation-props.d.ts.map +1 -0
- package/dist/vue/navigation-props.js +82 -0
- package/dist/vue/navigation-props.js.map +1 -0
- package/dist/vue/navigation.d.ts +7 -0
- package/dist/vue/navigation.d.ts.map +1 -0
- package/dist/vue/navigation.js +15 -0
- package/dist/vue/navigation.js.map +1 -0
- package/dist/vue/platform.d.ts +37 -0
- package/dist/vue/platform.d.ts.map +1 -0
- package/dist/vue/platform.js +46 -0
- package/dist/vue/platform.js.map +1 -0
- package/dist/vue/props.d.ts +3326 -510
- package/dist/vue/props.d.ts.map +1 -1
- package/dist/vue/props.js +314 -83
- package/dist/vue/props.js.map +1 -1
- package/dist/vue/reveal-state.d.ts +18 -0
- package/dist/vue/reveal-state.d.ts.map +1 -0
- package/dist/vue/reveal-state.js +76 -0
- package/dist/vue/reveal-state.js.map +1 -0
- package/dist/vue/theme-provider.d.ts +58 -0
- package/dist/vue/theme-provider.d.ts.map +1 -0
- package/dist/vue/theme-provider.js +69 -0
- package/dist/vue/theme-provider.js.map +1 -0
- package/dist/vue/theme.d.ts +1029 -19
- package/dist/vue/theme.d.ts.map +1 -1
- package/dist/vue/theme.js +47 -2
- package/dist/vue/theme.js.map +1 -1
- package/dist/vue/time-picker.d.ts +488 -0
- package/dist/vue/time-picker.d.ts.map +1 -0
- package/dist/vue/time-picker.js +190 -0
- package/dist/vue/time-picker.js.map +1 -0
- package/dist/vue/toast.d.ts +29 -0
- package/dist/vue/toast.d.ts.map +1 -0
- package/dist/vue/toast.js +79 -0
- package/dist/vue/toast.js.map +1 -0
- package/dist/vue/tree-view.d.ts +111 -0
- package/dist/vue/tree-view.d.ts.map +1 -0
- package/dist/vue/tree-view.js +180 -0
- package/dist/vue/tree-view.js.map +1 -0
- package/dist/vue/virtual-list.d.ts +26 -0
- package/dist/vue/virtual-list.d.ts.map +1 -0
- package/dist/vue/virtual-list.js +2 -0
- package/dist/vue/virtual-list.js.map +1 -0
- package/dist/vue/wayfinding-controls.d.ts +198 -0
- package/dist/vue/wayfinding-controls.d.ts.map +1 -0
- package/dist/vue/wayfinding-controls.js +310 -0
- package/dist/vue/wayfinding-controls.js.map +1 -0
- package/dist/vue/wayfinding-props.d.ts +221 -0
- package/dist/vue/wayfinding-props.d.ts.map +1 -0
- package/dist/vue/wayfinding-props.js +86 -0
- package/dist/vue/wayfinding-props.js.map +1 -0
- package/dist/vue/workflow-props.d.ts +110 -0
- package/dist/vue/workflow-props.d.ts.map +1 -0
- package/dist/vue/workflow-props.js +37 -0
- package/dist/vue/workflow-props.js.map +1 -0
- package/dist/vue/workflows.d.ts +267 -0
- package/dist/vue/workflows.d.ts.map +1 -0
- package/dist/vue/workflows.js +200 -0
- package/dist/vue/workflows.js.map +1 -0
- package/dist/wayfinding.d.ts +50 -0
- package/dist/wayfinding.d.ts.map +1 -0
- package/dist/wayfinding.js +54 -0
- package/dist/wayfinding.js.map +1 -0
- package/package.json +5 -1
- package/src/accordion.ts +66 -0
- package/src/alert.ts +16 -0
- package/src/app-icons.ts +57 -0
- package/src/avatar.ts +11 -0
- package/src/badge.ts +11 -0
- package/src/capabilities.ts +183 -0
- package/src/chart.ts +112 -0
- package/src/chip.ts +20 -0
- package/src/choice-motion.ts +12 -0
- package/src/choice.ts +41 -0
- package/src/collections.ts +87 -0
- package/src/combobox.ts +198 -0
- package/src/contracts.ts +324 -0
- package/src/date-input.ts +87 -0
- package/src/date-time.ts +37 -0
- package/src/date.ts +280 -0
- package/src/dialog.ts +22 -0
- package/src/discovery.ts +139 -0
- package/src/empty-state.ts +4 -0
- package/src/experimental-collections.ts +87 -0
- package/src/experimental-effects.ts +146 -0
- package/src/experimental-platforms.ts +96 -0
- package/src/experimental-playback.ts +115 -0
- package/src/experimental-regions.ts +777 -0
- package/src/experimental-sensors.ts +50 -0
- package/src/experimental-surfaces.ts +124 -0
- package/src/experimental.ts +1102 -0
- package/src/files.ts +408 -0
- package/src/form.ts +190 -0
- package/src/grid.ts +19 -0
- package/src/icon.ts +30 -0
- package/src/icons.ts +2002 -0
- package/src/index.ts +93 -2
- package/src/input.ts +27 -0
- package/src/link.ts +91 -0
- package/src/list-item.ts +5 -0
- package/src/motion.ts +80 -0
- package/src/multi-select.ts +30 -0
- package/src/navigation-transition.ts +14 -0
- package/src/navigation.ts +61 -0
- package/src/number-input.ts +80 -0
- package/src/popover.ts +38 -0
- package/src/progress.ts +22 -0
- package/src/responsive.ts +61 -0
- package/src/section-scroll.ts +46 -0
- package/src/segmented.ts +39 -0
- package/src/sheet.ts +31 -0
- package/src/tabs.ts +35 -0
- package/src/theme/themes.ts +89 -12
- package/src/theme/types.ts +55 -2
- package/src/theme/typography.ts +84 -0
- package/src/time.ts +83 -0
- package/src/toast.ts +249 -0
- package/src/vue/button-content.ts +60 -0
- package/src/vue/cached-activity.ts +13 -0
- package/src/vue/carousel.ts +173 -0
- package/src/vue/chart.ts +338 -0
- package/src/vue/combobox.ts +238 -0
- package/src/vue/command-palette.ts +232 -0
- package/src/vue/component-props.ts +70 -0
- package/src/vue/configurator-props.ts +67 -0
- package/src/vue/configurator.ts +350 -0
- package/src/vue/contracts.ts +39 -0
- package/src/vue/data-table.ts +190 -0
- package/src/vue/date-calendar.ts +76 -0
- package/src/vue/date-picker.ts +410 -0
- package/src/vue/date-props.ts +89 -0
- package/src/vue/dialog.ts +63 -0
- package/src/vue/discovery-components.ts +60 -0
- package/src/vue/discovery-controls.ts +218 -0
- package/src/vue/discovery-props.ts +92 -0
- package/src/vue/files.ts +53 -0
- package/src/vue/forms.ts +20 -0
- package/src/vue/global-components.ts +248 -4
- package/src/vue/index.ts +97 -4
- package/src/vue/inline-content.ts +71 -0
- package/src/vue/layout-context.ts +10 -3
- package/src/vue/list-motion.ts +31 -0
- package/src/vue/loading-effect.ts +44 -0
- package/src/vue/menu.ts +100 -0
- package/src/vue/navigation-controls.ts +138 -0
- package/src/vue/navigation-props.ts +87 -0
- package/src/vue/navigation.ts +16 -0
- package/src/vue/platform.ts +73 -0
- package/src/vue/props.ts +348 -96
- package/src/vue/reveal-state.ts +83 -0
- package/src/vue/theme-provider.ts +74 -0
- package/src/vue/theme.ts +65 -3
- package/src/vue/time-picker.ts +227 -0
- package/src/vue/toast.ts +99 -0
- package/src/vue/tree-view.ts +220 -0
- package/src/vue/virtual-list.ts +28 -0
- package/src/vue/wayfinding-controls.ts +412 -0
- package/src/vue/wayfinding-props.ts +97 -0
- package/src/vue/workflow-props.ts +41 -0
- package/src/vue/workflows.ts +257 -0
- package/src/wayfinding.ts +85 -0
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
import {
|
|
2
|
+
controlledMotionPlayback,
|
|
3
|
+
motionPlaybackAdapter,
|
|
4
|
+
type MotionStep,
|
|
5
|
+
type MotionTimelineStep,
|
|
6
|
+
type MotionTimeline,
|
|
7
|
+
type MotionStateDefinitions,
|
|
8
|
+
type MotionStates,
|
|
9
|
+
type MotionStateTransition,
|
|
10
|
+
type MotionStatesAdapter,
|
|
11
|
+
} from './experimental-playback.js'
|
|
12
|
+
import type { MotionPlayback } from './experimental.js'
|
|
13
|
+
import type {
|
|
14
|
+
MotionKeyboardState,
|
|
15
|
+
MotionKeyboard,
|
|
16
|
+
MotionCircleBody,
|
|
17
|
+
MotionPhysicsOptions,
|
|
18
|
+
MotionPhysicsWorld,
|
|
19
|
+
} from './experimental-platforms.js'
|
|
20
|
+
import {
|
|
21
|
+
mapMotionItems,
|
|
22
|
+
type MotionHeaderOptions,
|
|
23
|
+
type MotionHeader,
|
|
24
|
+
type MotionReorderOptions,
|
|
25
|
+
type MotionReorder,
|
|
26
|
+
} from './experimental-collections.js'
|
|
27
|
+
import {
|
|
28
|
+
motionSurfaceAdapter,
|
|
29
|
+
motionScrollAdapter,
|
|
30
|
+
type MotionSurface,
|
|
31
|
+
type MotionSurfaceAdapter,
|
|
32
|
+
type MotionBinding,
|
|
33
|
+
type MotionReadable,
|
|
34
|
+
type MotionFrames,
|
|
35
|
+
type MotionOptions,
|
|
36
|
+
type MotionSpringOptions,
|
|
37
|
+
type MotionScrollSource,
|
|
38
|
+
type MotionScrollAdapter,
|
|
39
|
+
} from './experimental.js'
|
|
40
|
+
|
|
41
|
+
export interface MotionPointerOptions {
|
|
42
|
+
axis?: 'x' | 'y' | 'both'
|
|
43
|
+
coordinates?: 'normalized' | 'pixels'
|
|
44
|
+
range?: { x?: readonly [number, number]; y?: readonly [number, number] }
|
|
45
|
+
rest?: { x?: number; y?: number }
|
|
46
|
+
spring?: MotionSpringOptions | false
|
|
47
|
+
disabled?: boolean
|
|
48
|
+
}
|
|
49
|
+
export interface MotionPointer extends MotionBinding {
|
|
50
|
+
readonly x: MotionReadable
|
|
51
|
+
readonly y: MotionReadable
|
|
52
|
+
readonly active: boolean
|
|
53
|
+
readonly execution: 'hover' | 'static'
|
|
54
|
+
update(state: { disabled: boolean }): void
|
|
55
|
+
refresh(): void
|
|
56
|
+
}
|
|
57
|
+
export type MotionPointerAdapter = Omit<MotionPointer, 'disposed' | 'x' | 'y'> & {
|
|
58
|
+
x: Pick<MotionReadable, 'get' | 'dispose'>
|
|
59
|
+
y: Pick<MotionReadable, 'get' | 'dispose'>
|
|
60
|
+
}
|
|
61
|
+
export interface MotionViewportOptions {
|
|
62
|
+
frames?: MotionFrames
|
|
63
|
+
transition?: MotionOptions
|
|
64
|
+
stagger?: number
|
|
65
|
+
root?: MotionScrollSource
|
|
66
|
+
/** CSS pixels/DIPs; positive expands the observed viewport. */
|
|
67
|
+
margin?: number
|
|
68
|
+
threshold?: number
|
|
69
|
+
once?: boolean
|
|
70
|
+
disabled?: boolean
|
|
71
|
+
}
|
|
72
|
+
export interface MotionViewport extends MotionBinding {
|
|
73
|
+
readonly execution: 'intersection-observer' | 'native-layout' | 'static'
|
|
74
|
+
readonly pending: number
|
|
75
|
+
readonly completed: number
|
|
76
|
+
update(state: { disabled: boolean }): void
|
|
77
|
+
refresh(): void
|
|
78
|
+
}
|
|
79
|
+
export interface MotionSharedResult {
|
|
80
|
+
status: 'completed' | 'cancelled' | 'unavailable'
|
|
81
|
+
reason?:
|
|
82
|
+
| 'interrupted'
|
|
83
|
+
| 'cancelled'
|
|
84
|
+
| 'unloaded'
|
|
85
|
+
| 'suspended'
|
|
86
|
+
| 'reduced-motion'
|
|
87
|
+
| 'missing-source'
|
|
88
|
+
| 'missing-target'
|
|
89
|
+
| 'unsupported-target'
|
|
90
|
+
| 'layout-timeout'
|
|
91
|
+
| 'geometry-changed'
|
|
92
|
+
}
|
|
93
|
+
export interface MotionSharedPlayback {
|
|
94
|
+
readonly finished: Promise<MotionSharedResult>
|
|
95
|
+
cancel(): void
|
|
96
|
+
stop(): void
|
|
97
|
+
}
|
|
98
|
+
export interface MotionSharedOptions {
|
|
99
|
+
transition?: Exclude<MotionOptions, { type: 'gravity' }>
|
|
100
|
+
layoutTimeout?: number
|
|
101
|
+
}
|
|
102
|
+
export interface MotionLayoutOptions {
|
|
103
|
+
transition?: Exclude<MotionOptions, { type: 'gravity' }>
|
|
104
|
+
size?: 'scale' | false
|
|
105
|
+
enter?: boolean
|
|
106
|
+
}
|
|
107
|
+
export interface MotionSharedLayout extends MotionBinding {
|
|
108
|
+
readonly active: boolean
|
|
109
|
+
/** Explicit identity; follows replacement of this declared surface. */
|
|
110
|
+
attach(surface: MotionSurface, identity: string): () => void
|
|
111
|
+
/** Host mutation is synchronous; Jolt waits for renderer layout. */
|
|
112
|
+
transition(
|
|
113
|
+
change: () => void,
|
|
114
|
+
options?: Exclude<MotionOptions, { type: 'gravity' }>,
|
|
115
|
+
): MotionSharedPlayback
|
|
116
|
+
cancel(): void
|
|
117
|
+
}
|
|
118
|
+
export interface MotionDiagnosticsOptions {
|
|
119
|
+
development: true
|
|
120
|
+
identity: string
|
|
121
|
+
maxEvents?: number
|
|
122
|
+
}
|
|
123
|
+
export interface MotionDiagnosticSnapshot {
|
|
124
|
+
identity: string
|
|
125
|
+
execution: 'jolt-web' | 'lifecycle-only'
|
|
126
|
+
disposed: boolean
|
|
127
|
+
resources: Record<string, number | boolean>
|
|
128
|
+
targets: {
|
|
129
|
+
id: number
|
|
130
|
+
execution: string
|
|
131
|
+
channels: {
|
|
132
|
+
property: string
|
|
133
|
+
layer?: string
|
|
134
|
+
kind: 'animation' | 'value' | 'rest'
|
|
135
|
+
owner?: number
|
|
136
|
+
paused?: boolean
|
|
137
|
+
}[]
|
|
138
|
+
}[]
|
|
139
|
+
events: {
|
|
140
|
+
sequence: number
|
|
141
|
+
time: number
|
|
142
|
+
reason: string
|
|
143
|
+
owner?: number
|
|
144
|
+
target?: number
|
|
145
|
+
scope?: number
|
|
146
|
+
property?: string
|
|
147
|
+
layer?: string
|
|
148
|
+
}[]
|
|
149
|
+
}
|
|
150
|
+
export interface MotionDiagnostics extends MotionBinding {
|
|
151
|
+
snapshot(): MotionDiagnosticSnapshot
|
|
152
|
+
clear(): void
|
|
153
|
+
}
|
|
154
|
+
type Available = {
|
|
155
|
+
readonly available: boolean
|
|
156
|
+
onAvailable(setup: () => void | (() => void)): () => void
|
|
157
|
+
}
|
|
158
|
+
export interface MotionRegion extends Available {
|
|
159
|
+
/** Animate keyed direct children after a synchronous data mutation. Not a virtual-list API. */
|
|
160
|
+
animateLayout(change: () => void, options?: MotionLayoutOptions): MotionPlayback
|
|
161
|
+
onKeyboard(callback: (state: MotionKeyboardState) => void): MotionKeyboard
|
|
162
|
+
/** Waits for initial native layout; the engine owns simulation and later geometry. */
|
|
163
|
+
physicsWorld(
|
|
164
|
+
bodies: readonly MotionCircleBody[],
|
|
165
|
+
options?: MotionPhysicsOptions,
|
|
166
|
+
): Promise<MotionPhysicsWorld>
|
|
167
|
+
scrollHeader(source: MotionScrollSource, options: MotionHeaderOptions): MotionHeader
|
|
168
|
+
reorder(options: MotionReorderOptions): MotionReorder
|
|
169
|
+
sequence(steps: readonly MotionStep[]): MotionPlayback
|
|
170
|
+
timeline(steps: readonly MotionTimelineStep[]): MotionTimeline
|
|
171
|
+
states<const S extends MotionStateDefinitions>(
|
|
172
|
+
targets: Record<string, MotionSurface>,
|
|
173
|
+
definitions: S,
|
|
174
|
+
options?: { transition?: MotionStateTransition },
|
|
175
|
+
): MotionStates<Extract<keyof S, string>>
|
|
176
|
+
viewportEnter(surfaces: readonly MotionSurface[], options?: MotionViewportOptions): MotionViewport
|
|
177
|
+
sharedLayout(options?: MotionSharedOptions): MotionSharedLayout
|
|
178
|
+
diagnostics(options: MotionDiagnosticsOptions): MotionDiagnostics
|
|
179
|
+
}
|
|
180
|
+
export interface MotionRegionAdapter {
|
|
181
|
+
animateLayout?(change: () => void, options: MotionLayoutOptions): MotionPlayback
|
|
182
|
+
onKeyboard?(callback: (state: MotionKeyboardState) => void): Omit<MotionKeyboard, 'disposed'>
|
|
183
|
+
physicsWorld?(
|
|
184
|
+
bodies: readonly MotionCircleBody<MotionSurfaceAdapter>[],
|
|
185
|
+
options?: MotionPhysicsOptions,
|
|
186
|
+
): Promise<Omit<MotionPhysicsWorld, 'disposed'>>
|
|
187
|
+
scrollHeader?(
|
|
188
|
+
source: MotionScrollAdapter,
|
|
189
|
+
options: MotionHeaderOptions<MotionSurfaceAdapter>,
|
|
190
|
+
): Omit<MotionHeader, 'disposed'>
|
|
191
|
+
reorder?(
|
|
192
|
+
options: MotionReorderOptions<MotionSurfaceAdapter, MotionScrollAdapter>,
|
|
193
|
+
): Omit<MotionReorder, 'disposed'>
|
|
194
|
+
readonly kind: 'web' | 'native'
|
|
195
|
+
sequence?(steps: readonly MotionStep<MotionSurfaceAdapter>[]): MotionPlayback
|
|
196
|
+
timeline?(steps: readonly MotionTimelineStep<MotionSurfaceAdapter>[]): MotionPlayback
|
|
197
|
+
states?(
|
|
198
|
+
targets: Record<string, MotionSurfaceAdapter | null>,
|
|
199
|
+
definitions: MotionStateDefinitions,
|
|
200
|
+
options?: { transition?: MotionStateTransition },
|
|
201
|
+
): MotionStatesAdapter
|
|
202
|
+
viewportEnter(
|
|
203
|
+
surfaces: readonly MotionSurfaceAdapter[],
|
|
204
|
+
options: Omit<MotionViewportOptions, 'root'> & {
|
|
205
|
+
root?: MotionScrollAdapter
|
|
206
|
+
},
|
|
207
|
+
): Omit<MotionViewport, 'disposed'>
|
|
208
|
+
sharedLayout(options: MotionSharedOptions): Omit<MotionSharedLayout, 'disposed' | 'attach'> & {
|
|
209
|
+
attach(surface: MotionSurfaceAdapter, identity: string): () => void
|
|
210
|
+
}
|
|
211
|
+
diagnostics?(options: MotionDiagnosticsOptions): Omit<MotionDiagnostics, 'disposed'>
|
|
212
|
+
}
|
|
213
|
+
type Resource = { dispose(): void }
|
|
214
|
+
type RegionState = {
|
|
215
|
+
adapter: MotionRegionAdapter
|
|
216
|
+
resources: Set<Resource>
|
|
217
|
+
cleanup: Set<() => void>
|
|
218
|
+
valid: boolean
|
|
219
|
+
}
|
|
220
|
+
const regions = new WeakMap<MotionRegion, { state?: RegionState; setups: Set<() => () => void> }>()
|
|
221
|
+
export function regionState(region: MotionRegion): RegionState {
|
|
222
|
+
const state = regions.get(region)?.state
|
|
223
|
+
if (!state?.valid) throw new Error('Motion region is unavailable. Mount its MBox first.')
|
|
224
|
+
return state
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Subscribe to a fixed set of explicit, potentially replacing surfaces. */
|
|
228
|
+
export function whenMotionAvailable(
|
|
229
|
+
sources: readonly Available[],
|
|
230
|
+
setup: () => void | (() => void),
|
|
231
|
+
) {
|
|
232
|
+
let cleanup: void | (() => void),
|
|
233
|
+
active = false
|
|
234
|
+
const clear = () => {
|
|
235
|
+
const previous = cleanup
|
|
236
|
+
cleanup = undefined
|
|
237
|
+
active = false
|
|
238
|
+
previous?.()
|
|
239
|
+
}
|
|
240
|
+
const start = () => {
|
|
241
|
+
if (!active && sources.every((source) => source.available)) {
|
|
242
|
+
active = true
|
|
243
|
+
try {
|
|
244
|
+
cleanup = setup()
|
|
245
|
+
} catch (error) {
|
|
246
|
+
active = false
|
|
247
|
+
throw error
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return clear
|
|
251
|
+
}
|
|
252
|
+
const subscriptions: (() => void)[] = []
|
|
253
|
+
try {
|
|
254
|
+
for (const source of new Set(sources)) subscriptions.push(source.onAvailable(start))
|
|
255
|
+
} catch (error) {
|
|
256
|
+
for (const stop of subscriptions) stop()
|
|
257
|
+
clear()
|
|
258
|
+
throw error
|
|
259
|
+
}
|
|
260
|
+
return () => {
|
|
261
|
+
for (const stop of subscriptions) stop()
|
|
262
|
+
clear()
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function owned<T extends Resource>(state: RegionState, raw: T): T & MotionBinding {
|
|
267
|
+
let disposed = false
|
|
268
|
+
const handle = new Proxy(raw, {
|
|
269
|
+
get(target, key) {
|
|
270
|
+
if (key === 'disposed') return disposed || !state.valid
|
|
271
|
+
if (key === 'dispose')
|
|
272
|
+
return () => {
|
|
273
|
+
if (disposed) return
|
|
274
|
+
disposed = true
|
|
275
|
+
state.resources.delete(handle)
|
|
276
|
+
raw.dispose()
|
|
277
|
+
}
|
|
278
|
+
// Diagnostics retain a final, detached snapshot after teardown.
|
|
279
|
+
if (key !== 'snapshot' && (disposed || !state.valid))
|
|
280
|
+
throw new Error('Motion region resource is disposed.')
|
|
281
|
+
const value = Reflect.get(target, key, target)
|
|
282
|
+
return typeof value === 'function' ? value.bind(target) : value
|
|
283
|
+
},
|
|
284
|
+
}) as T & MotionBinding
|
|
285
|
+
state.resources.add(handle)
|
|
286
|
+
return handle
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function diagnosticsHandle(
|
|
290
|
+
state: RegionState,
|
|
291
|
+
options: MotionDiagnosticsOptions,
|
|
292
|
+
): MotionDiagnostics {
|
|
293
|
+
let owner: RegionState | undefined = state
|
|
294
|
+
let raw = state.adapter.diagnostics?.(options)
|
|
295
|
+
let final: MotionDiagnosticSnapshot | undefined
|
|
296
|
+
const read = (): MotionDiagnosticSnapshot =>
|
|
297
|
+
raw?.snapshot() ?? {
|
|
298
|
+
identity: options.identity,
|
|
299
|
+
execution: 'lifecycle-only',
|
|
300
|
+
disposed: !owner,
|
|
301
|
+
resources: { regionResources: owner?.resources.size ?? 0 },
|
|
302
|
+
targets: [],
|
|
303
|
+
events: [],
|
|
304
|
+
}
|
|
305
|
+
const handle: MotionDiagnostics = {
|
|
306
|
+
get disposed() {
|
|
307
|
+
return !owner
|
|
308
|
+
},
|
|
309
|
+
snapshot: () => {
|
|
310
|
+
const snapshot = final ?? read()
|
|
311
|
+
return {
|
|
312
|
+
...snapshot,
|
|
313
|
+
resources: { ...snapshot.resources },
|
|
314
|
+
targets: snapshot.targets.map((target) => ({
|
|
315
|
+
...target,
|
|
316
|
+
channels: target.channels.map((channel) => ({ ...channel })),
|
|
317
|
+
})),
|
|
318
|
+
events: snapshot.events.map((event) => ({ ...event })),
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
clear() {
|
|
322
|
+
raw?.clear()
|
|
323
|
+
if (final) final.events = []
|
|
324
|
+
},
|
|
325
|
+
dispose() {
|
|
326
|
+
if (!owner) return
|
|
327
|
+
owner.resources.delete(handle)
|
|
328
|
+
owner = undefined
|
|
329
|
+
try {
|
|
330
|
+
raw?.dispose()
|
|
331
|
+
final = { ...read(), disposed: true }
|
|
332
|
+
} finally {
|
|
333
|
+
raw = undefined
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
}
|
|
337
|
+
state.resources.add(handle)
|
|
338
|
+
return handle
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Translate targets and factories only; all timing belongs to Jolt. */
|
|
342
|
+
function group(
|
|
343
|
+
region: MotionRegion,
|
|
344
|
+
steps: readonly (MotionStep | MotionTimelineStep)[],
|
|
345
|
+
controlled: boolean,
|
|
346
|
+
) {
|
|
347
|
+
const state = regionState(region)
|
|
348
|
+
const surfaces = new Set<MotionSurface>()
|
|
349
|
+
const factory = (run: () => MotionPlayback) => () => {
|
|
350
|
+
if (!state.valid) throw new Error('This motion region is disposed.')
|
|
351
|
+
return motionPlaybackAdapter(run())
|
|
352
|
+
}
|
|
353
|
+
const mapped = steps.map((step) => {
|
|
354
|
+
if (typeof step === 'function') return factory(step)
|
|
355
|
+
if ('run' in step) return { ...step, run: factory(step.run) }
|
|
356
|
+
const [surface, frames, options] = step
|
|
357
|
+
surfaces.add(surface)
|
|
358
|
+
return [motionSurfaceAdapter(surface), frames, options] as const
|
|
359
|
+
})
|
|
360
|
+
const create = controlled ? state.adapter.timeline : state.adapter.sequence
|
|
361
|
+
if (!create) throw new Error('Motion orchestration is unavailable.')
|
|
362
|
+
const raw = controlled
|
|
363
|
+
? state.adapter.timeline!(mapped as readonly MotionTimelineStep<MotionSurfaceAdapter>[])
|
|
364
|
+
: state.adapter.sequence!(mapped as readonly MotionStep<MotionSurfaceAdapter>[])
|
|
365
|
+
const releases: (() => void)[] = []
|
|
366
|
+
let ended = false
|
|
367
|
+
const dispose = () => {
|
|
368
|
+
if (ended) return
|
|
369
|
+
ended = true
|
|
370
|
+
raw.stop()
|
|
371
|
+
for (const release of releases) release()
|
|
372
|
+
state.resources.delete(resource)
|
|
373
|
+
}
|
|
374
|
+
const resource = { dispose }
|
|
375
|
+
state.resources.add(resource)
|
|
376
|
+
try {
|
|
377
|
+
for (const surface of surfaces)
|
|
378
|
+
releases.push(
|
|
379
|
+
surface.onAvailable(() => () => {
|
|
380
|
+
if (!ended) raw.stop()
|
|
381
|
+
}),
|
|
382
|
+
)
|
|
383
|
+
} catch (error) {
|
|
384
|
+
dispose()
|
|
385
|
+
throw error
|
|
386
|
+
}
|
|
387
|
+
const forget = () => {
|
|
388
|
+
ended = true
|
|
389
|
+
for (const release of releases) release()
|
|
390
|
+
state.resources.delete(resource)
|
|
391
|
+
}
|
|
392
|
+
void raw.finished.then(forget, forget)
|
|
393
|
+
const playback = controlledMotionPlayback(raw, () => state.valid)
|
|
394
|
+
return controlled
|
|
395
|
+
? playback
|
|
396
|
+
: {
|
|
397
|
+
finished: raw.finished,
|
|
398
|
+
stop: () => {
|
|
399
|
+
if (state.valid) raw.stop()
|
|
400
|
+
},
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export function createMotionRegion(): MotionRegion {
|
|
405
|
+
const entry: { state?: RegionState; setups: Set<() => () => void> } = { setups: new Set() }
|
|
406
|
+
const region: MotionRegion = {
|
|
407
|
+
animateLayout(change, options = {}) {
|
|
408
|
+
const state = regionState(region)
|
|
409
|
+
if (typeof change !== 'function')
|
|
410
|
+
throw new TypeError('Layout motion needs a synchronous change callback.')
|
|
411
|
+
if (options.size !== undefined && options.size !== false && options.size !== 'scale')
|
|
412
|
+
throw new TypeError('Layout size must be scale or false.')
|
|
413
|
+
if (options.enter !== undefined && typeof options.enter !== 'boolean')
|
|
414
|
+
throw new TypeError('Layout enter must be a boolean.')
|
|
415
|
+
if (!state.adapter.animateLayout) throw new Error('Layout motion is unavailable.')
|
|
416
|
+
const raw = state.adapter.animateLayout(change, options)
|
|
417
|
+
const resource = { dispose: () => raw.stop() }
|
|
418
|
+
state.resources.add(resource)
|
|
419
|
+
const forget = () => state.resources.delete(resource)
|
|
420
|
+
void raw.finished.then(forget, forget)
|
|
421
|
+
return {
|
|
422
|
+
finished: raw.finished,
|
|
423
|
+
stop() {
|
|
424
|
+
if (state.valid && state.resources.has(resource)) raw.stop()
|
|
425
|
+
},
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
get available() {
|
|
429
|
+
return Boolean(entry.state?.valid)
|
|
430
|
+
},
|
|
431
|
+
onKeyboard(callback) {
|
|
432
|
+
const state = regionState(region)
|
|
433
|
+
if (!state.adapter.onKeyboard) throw new Error('Keyboard observation is unavailable.')
|
|
434
|
+
return owned(state, state.adapter.onKeyboard(callback))
|
|
435
|
+
},
|
|
436
|
+
async physicsWorld(bodies, options) {
|
|
437
|
+
const state = regionState(region)
|
|
438
|
+
if (!state.adapter.physicsWorld) throw new Error('Circle physics is unavailable.')
|
|
439
|
+
const mapped = bodies.map(({ target, ...body }) => ({
|
|
440
|
+
...body,
|
|
441
|
+
target: motionSurfaceAdapter(target),
|
|
442
|
+
}))
|
|
443
|
+
const raw = await state.adapter.physicsWorld(mapped, options)
|
|
444
|
+
if (
|
|
445
|
+
!state.valid ||
|
|
446
|
+
bodies.some(
|
|
447
|
+
(body, index) =>
|
|
448
|
+
!body.target.available || motionSurfaceAdapter(body.target) !== mapped[index]!.target,
|
|
449
|
+
)
|
|
450
|
+
) {
|
|
451
|
+
raw.dispose()
|
|
452
|
+
throw new Error('Physics presentation changed while waiting for layout.')
|
|
453
|
+
}
|
|
454
|
+
let stop: (() => void) | undefined
|
|
455
|
+
const control = owned(state, {
|
|
456
|
+
...raw,
|
|
457
|
+
get paused() {
|
|
458
|
+
return raw.paused
|
|
459
|
+
},
|
|
460
|
+
dispose() {
|
|
461
|
+
stop?.()
|
|
462
|
+
raw.dispose()
|
|
463
|
+
},
|
|
464
|
+
})
|
|
465
|
+
stop = whenMotionAvailable(
|
|
466
|
+
bodies.map((body) => body.target),
|
|
467
|
+
() => () => control.dispose(),
|
|
468
|
+
)
|
|
469
|
+
return control
|
|
470
|
+
},
|
|
471
|
+
onAvailable(setup) {
|
|
472
|
+
let cleanup: (() => void) | undefined
|
|
473
|
+
const invoke = () => {
|
|
474
|
+
const state = regionState(region)
|
|
475
|
+
const before = new Set(state.resources)
|
|
476
|
+
let release: void | (() => void)
|
|
477
|
+
try {
|
|
478
|
+
release = setup()
|
|
479
|
+
} catch (error) {
|
|
480
|
+
for (const resource of [...state.resources].reverse())
|
|
481
|
+
if (!before.has(resource)) resource.dispose()
|
|
482
|
+
throw error
|
|
483
|
+
}
|
|
484
|
+
const resources = [...state.resources].filter((value) => !before.has(value))
|
|
485
|
+
let ended = false
|
|
486
|
+
cleanup = () => {
|
|
487
|
+
if (ended) return
|
|
488
|
+
ended = true
|
|
489
|
+
state.cleanup.delete(cleanup!)
|
|
490
|
+
const errors: unknown[] = []
|
|
491
|
+
for (const dispose of [
|
|
492
|
+
() => release?.(),
|
|
493
|
+
...resources.reverse().map((resource) => () => resource.dispose()),
|
|
494
|
+
]) {
|
|
495
|
+
try {
|
|
496
|
+
dispose()
|
|
497
|
+
} catch (error) {
|
|
498
|
+
errors.push(error)
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (errors.length) throw new AggregateError(errors, 'Motion region setup cleanup failed.')
|
|
502
|
+
}
|
|
503
|
+
return cleanup
|
|
504
|
+
}
|
|
505
|
+
entry.setups.add(invoke)
|
|
506
|
+
try {
|
|
507
|
+
if (entry.state?.valid) entry.state.cleanup.add(invoke())
|
|
508
|
+
} catch (error) {
|
|
509
|
+
entry.setups.delete(invoke)
|
|
510
|
+
throw error
|
|
511
|
+
}
|
|
512
|
+
return () => {
|
|
513
|
+
entry.setups.delete(invoke)
|
|
514
|
+
cleanup?.()
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
sequence: (steps) => group(region, steps, false),
|
|
518
|
+
scrollHeader(source, options) {
|
|
519
|
+
const state = regionState(region)
|
|
520
|
+
if (!state.adapter.scrollHeader) throw new Error('Scroll headers are unavailable.')
|
|
521
|
+
const { header, artwork, title, toolbar, toolbarTitle, section, items, ...rest } = options
|
|
522
|
+
const raw = state.adapter.scrollHeader(motionScrollAdapter(source), {
|
|
523
|
+
...rest,
|
|
524
|
+
header: motionSurfaceAdapter(header),
|
|
525
|
+
artwork: motionSurfaceAdapter(artwork),
|
|
526
|
+
title: motionSurfaceAdapter(title),
|
|
527
|
+
toolbar: motionSurfaceAdapter(toolbar),
|
|
528
|
+
toolbarTitle: motionSurfaceAdapter(toolbarTitle),
|
|
529
|
+
section: motionSurfaceAdapter(section),
|
|
530
|
+
items: () => mapMotionItems(items(), motionSurfaceAdapter),
|
|
531
|
+
})
|
|
532
|
+
let off: (() => void) | undefined
|
|
533
|
+
const control = owned(state, {
|
|
534
|
+
...raw,
|
|
535
|
+
get ready() {
|
|
536
|
+
return raw.ready
|
|
537
|
+
},
|
|
538
|
+
get state() {
|
|
539
|
+
return raw.state
|
|
540
|
+
},
|
|
541
|
+
dispose() {
|
|
542
|
+
off?.()
|
|
543
|
+
raw.dispose()
|
|
544
|
+
},
|
|
545
|
+
})
|
|
546
|
+
off = whenMotionAvailable(
|
|
547
|
+
[source, header, artwork, title, toolbar, toolbarTitle, section],
|
|
548
|
+
() => () => control.dispose(),
|
|
549
|
+
)
|
|
550
|
+
return control
|
|
551
|
+
},
|
|
552
|
+
reorder(options) {
|
|
553
|
+
const state = regionState(region)
|
|
554
|
+
if (!state.adapter.reorder) throw new Error('Interactive reorder is unavailable.')
|
|
555
|
+
const raw = state.adapter.reorder({
|
|
556
|
+
...options,
|
|
557
|
+
scroll: motionScrollAdapter(options.scroll),
|
|
558
|
+
container: motionSurfaceAdapter(options.container),
|
|
559
|
+
items: () => mapMotionItems(options.items(), motionSurfaceAdapter),
|
|
560
|
+
})
|
|
561
|
+
let off: (() => void) | undefined
|
|
562
|
+
const control = owned(state, {
|
|
563
|
+
...raw,
|
|
564
|
+
get activeKey() {
|
|
565
|
+
return raw.activeKey
|
|
566
|
+
},
|
|
567
|
+
dispose() {
|
|
568
|
+
off?.()
|
|
569
|
+
raw.dispose()
|
|
570
|
+
},
|
|
571
|
+
})
|
|
572
|
+
off = whenMotionAvailable([options.scroll, options.container], () => () => control.dispose())
|
|
573
|
+
return control
|
|
574
|
+
},
|
|
575
|
+
timeline: (steps) => group(region, steps, true) as MotionTimeline,
|
|
576
|
+
states(targets, definitions, options) {
|
|
577
|
+
const state = regionState(region)
|
|
578
|
+
if (!state.adapter.states) throw new Error('Named motion states are unavailable.')
|
|
579
|
+
const entries = Object.entries(targets)
|
|
580
|
+
if (
|
|
581
|
+
!entries.length ||
|
|
582
|
+
entries.length > 64 ||
|
|
583
|
+
new Set(entries.map(([, surface]) => surface)).size !== entries.length
|
|
584
|
+
)
|
|
585
|
+
throw new TypeError('Use 1–64 distinct named surfaces.')
|
|
586
|
+
const raw = state.adapter.states(
|
|
587
|
+
Object.fromEntries(
|
|
588
|
+
entries.map(([name, surface]) => [
|
|
589
|
+
name,
|
|
590
|
+
surface.available ? motionSurfaceAdapter(surface) : null,
|
|
591
|
+
]),
|
|
592
|
+
),
|
|
593
|
+
definitions,
|
|
594
|
+
options,
|
|
595
|
+
)
|
|
596
|
+
const releases: (() => void)[] = []
|
|
597
|
+
let disposed = false
|
|
598
|
+
try {
|
|
599
|
+
for (const [name, surface] of entries)
|
|
600
|
+
releases.push(
|
|
601
|
+
surface.onAvailable(() => {
|
|
602
|
+
if (disposed) return
|
|
603
|
+
raw.attach(name, motionSurfaceAdapter(surface))
|
|
604
|
+
return () => {
|
|
605
|
+
if (!disposed) raw.attach(name, null)
|
|
606
|
+
}
|
|
607
|
+
}),
|
|
608
|
+
)
|
|
609
|
+
} catch (error) {
|
|
610
|
+
disposed = true
|
|
611
|
+
for (const release of releases) release()
|
|
612
|
+
raw.dispose()
|
|
613
|
+
throw error
|
|
614
|
+
}
|
|
615
|
+
return owned(state, {
|
|
616
|
+
get current() {
|
|
617
|
+
return raw.current
|
|
618
|
+
},
|
|
619
|
+
get settled() {
|
|
620
|
+
return raw.settled
|
|
621
|
+
},
|
|
622
|
+
get paused() {
|
|
623
|
+
return raw.paused
|
|
624
|
+
},
|
|
625
|
+
to: (name: string, transition?: MotionStateTransition) => raw.to(name, transition),
|
|
626
|
+
pause: () => raw.pause(),
|
|
627
|
+
resume: () => raw.play(),
|
|
628
|
+
stop: () => raw.stop(),
|
|
629
|
+
dispose() {
|
|
630
|
+
disposed = true
|
|
631
|
+
for (const release of releases) release()
|
|
632
|
+
raw.dispose()
|
|
633
|
+
},
|
|
634
|
+
}) as MotionStates<Extract<keyof typeof definitions, string>>
|
|
635
|
+
},
|
|
636
|
+
viewportEnter(surfaces, options = {}) {
|
|
637
|
+
const state = regionState(region)
|
|
638
|
+
if (!surfaces.length || surfaces.length > 64 || new Set(surfaces).size !== surfaces.length)
|
|
639
|
+
throw new RangeError('Use 1–64 distinct viewport surfaces in their entrance order.')
|
|
640
|
+
for (const [key, value] of Object.entries({
|
|
641
|
+
margin: options.margin,
|
|
642
|
+
stagger: options.stagger,
|
|
643
|
+
}))
|
|
644
|
+
if (
|
|
645
|
+
value !== undefined &&
|
|
646
|
+
(!Number.isFinite(value) || Math.abs(value) > 10000 || (key === 'stagger' && value < 0))
|
|
647
|
+
)
|
|
648
|
+
throw new RangeError('Viewport margin/stagger must be finite and bounded by 10000.')
|
|
649
|
+
if (
|
|
650
|
+
options.threshold !== undefined &&
|
|
651
|
+
(!Number.isFinite(options.threshold) || options.threshold < 0 || options.threshold > 1)
|
|
652
|
+
)
|
|
653
|
+
throw new RangeError('Viewport threshold must be between zero and one.')
|
|
654
|
+
return owned(
|
|
655
|
+
state,
|
|
656
|
+
state.adapter.viewportEnter(surfaces.map(motionSurfaceAdapter), {
|
|
657
|
+
...options,
|
|
658
|
+
root: options.root && motionScrollAdapter(options.root),
|
|
659
|
+
}),
|
|
660
|
+
)
|
|
661
|
+
},
|
|
662
|
+
sharedLayout(options = {}) {
|
|
663
|
+
const state = regionState(region)
|
|
664
|
+
const raw = state.adapter.sharedLayout(options)
|
|
665
|
+
const attachments = new Set<() => void>()
|
|
666
|
+
const identities = new Map<string, MotionSurface>()
|
|
667
|
+
return owned<Omit<MotionSharedLayout, 'disposed'>>(state, {
|
|
668
|
+
get active() {
|
|
669
|
+
return raw.active
|
|
670
|
+
},
|
|
671
|
+
attach(surface, identity) {
|
|
672
|
+
if (
|
|
673
|
+
!identity.trim() ||
|
|
674
|
+
identity.length > 100 ||
|
|
675
|
+
identities.has(identity) ||
|
|
676
|
+
[...identities.values()].includes(surface)
|
|
677
|
+
)
|
|
678
|
+
throw new TypeError(
|
|
679
|
+
'Use a unique nonempty identity and surface (up to 100 characters).',
|
|
680
|
+
)
|
|
681
|
+
identities.set(identity, surface)
|
|
682
|
+
let stop: () => void
|
|
683
|
+
try {
|
|
684
|
+
stop = surface.onAvailable(() => raw.attach(motionSurfaceAdapter(surface), identity))
|
|
685
|
+
} catch (error) {
|
|
686
|
+
identities.delete(identity)
|
|
687
|
+
throw error
|
|
688
|
+
}
|
|
689
|
+
const detach = () => {
|
|
690
|
+
attachments.delete(detach)
|
|
691
|
+
identities.delete(identity)
|
|
692
|
+
stop()
|
|
693
|
+
}
|
|
694
|
+
attachments.add(detach)
|
|
695
|
+
return detach
|
|
696
|
+
},
|
|
697
|
+
transition: (change, options) => raw.transition(change, options),
|
|
698
|
+
cancel: () => raw.cancel(),
|
|
699
|
+
dispose() {
|
|
700
|
+
for (const detach of [...attachments]) detach()
|
|
701
|
+
raw.dispose()
|
|
702
|
+
},
|
|
703
|
+
})
|
|
704
|
+
},
|
|
705
|
+
diagnostics(options) {
|
|
706
|
+
const state = regionState(region)
|
|
707
|
+
if (
|
|
708
|
+
options?.development !== true ||
|
|
709
|
+
!options.identity?.trim() ||
|
|
710
|
+
options.identity.length > 100
|
|
711
|
+
)
|
|
712
|
+
throw new TypeError('Diagnostics need development: true and a short region identity.')
|
|
713
|
+
const max = options.maxEvents ?? 200
|
|
714
|
+
if (!Number.isInteger(max) || max < 1 || max > 2000)
|
|
715
|
+
throw new RangeError('Use 1–2000 diagnostic events.')
|
|
716
|
+
return diagnosticsHandle(state, options)
|
|
717
|
+
},
|
|
718
|
+
}
|
|
719
|
+
regions.set(region, entry)
|
|
720
|
+
return region
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
export function bindMotionRegion(region: MotionRegion, adapter: MotionRegionAdapter): () => void {
|
|
724
|
+
const entry = regions.get(region)
|
|
725
|
+
if (!entry) throw new TypeError('Use createMotionRegion().')
|
|
726
|
+
const clear = (state: RegionState) => {
|
|
727
|
+
if (!state.valid) return
|
|
728
|
+
state.valid = false
|
|
729
|
+
if (entry.state === state) entry.state = undefined
|
|
730
|
+
const errors: unknown[] = []
|
|
731
|
+
for (const release of [
|
|
732
|
+
...state.cleanup,
|
|
733
|
+
...[...state.resources].reverse().map((resource) => () => resource.dispose()),
|
|
734
|
+
])
|
|
735
|
+
try {
|
|
736
|
+
release()
|
|
737
|
+
} catch (error) {
|
|
738
|
+
errors.push(error)
|
|
739
|
+
}
|
|
740
|
+
state.cleanup.clear()
|
|
741
|
+
state.resources.clear()
|
|
742
|
+
if (errors.length) throw new AggregateError(errors, 'Motion region cleanup failed.')
|
|
743
|
+
}
|
|
744
|
+
if (entry.state) clear(entry.state)
|
|
745
|
+
const state: RegionState = { adapter, valid: true, resources: new Set(), cleanup: new Set() }
|
|
746
|
+
entry.state = state
|
|
747
|
+
try {
|
|
748
|
+
for (const setup of [...entry.setups]) state.cleanup.add(setup())
|
|
749
|
+
} catch (error) {
|
|
750
|
+
clear(state)
|
|
751
|
+
throw error
|
|
752
|
+
}
|
|
753
|
+
return () => clear(state)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
export function validatePointer(options: MotionPointerOptions) {
|
|
757
|
+
if (options.axis !== undefined && !['x', 'y', 'both'].includes(options.axis))
|
|
758
|
+
throw new TypeError('Unknown pointer axis.')
|
|
759
|
+
if (options.coordinates !== undefined && !['normalized', 'pixels'].includes(options.coordinates))
|
|
760
|
+
throw new TypeError('Unknown pointer coordinates.')
|
|
761
|
+
if (options.disabled !== undefined && typeof options.disabled !== 'boolean')
|
|
762
|
+
throw new TypeError('disabled must be boolean.')
|
|
763
|
+
for (const axis of ['x', 'y'] as const) {
|
|
764
|
+
const rest = options.rest?.[axis] ?? 0,
|
|
765
|
+
range = options.range?.[axis]
|
|
766
|
+
if (
|
|
767
|
+
!Number.isFinite(rest) ||
|
|
768
|
+
(range &&
|
|
769
|
+
(range.length !== 2 ||
|
|
770
|
+
!range.every(Number.isFinite) ||
|
|
771
|
+
range[0] >= range[1] ||
|
|
772
|
+
rest < range[0] ||
|
|
773
|
+
rest > range[1]))
|
|
774
|
+
)
|
|
775
|
+
throw new RangeError('Pointer bounds must increase and contain the resting value.')
|
|
776
|
+
}
|
|
777
|
+
}
|