@vizejs/composable 0.426.2 → 0.427.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/dist/abort-signal.d.mts +1 -1
- package/dist/active-element.d.mts +37 -0
- package/dist/active-element.mjs +56 -0
- package/dist/animate.d.mts +114 -0
- package/dist/animate.mjs +157 -0
- package/dist/battery.d.mts +61 -0
- package/dist/battery.mjs +90 -0
- package/dist/breakpoints.d.mts +82 -0
- package/dist/breakpoints.mjs +91 -0
- package/dist/catalog-BeTXFKxF.d.mts +4188 -0
- package/dist/catalog-r4Z5nptX.mjs +5144 -0
- package/dist/catalog.d.mts +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/color-mode.d.mts +131 -0
- package/dist/color-mode.mjs +133 -0
- package/dist/computed-async.d.mts +63 -0
- package/dist/computed-async.mjs +43 -0
- package/dist/computed-with-control.d.mts +44 -0
- package/dist/computed-with-control.mjs +54 -0
- package/dist/create-event-hook.d.mts +77 -0
- package/dist/create-event-hook.mjs +66 -0
- package/dist/create-global-state.d.mts +24 -0
- package/dist/create-global-state.mjs +34 -0
- package/dist/create-injection-state.d.mts +51 -0
- package/dist/create-injection-state.mjs +19 -0
- package/dist/create-shared-composable.d.mts +38 -0
- package/dist/create-shared-composable.mjs +54 -0
- package/dist/device-motion.d.mts +71 -0
- package/dist/device-motion.mjs +75 -0
- package/dist/device-orientation.d.mts +82 -0
- package/dist/device-orientation.mjs +86 -0
- package/dist/device-pixel-ratio.d.mts +45 -0
- package/dist/device-pixel-ratio.mjs +50 -0
- package/dist/document-visibility.mjs +6 -2
- package/dist/draggable.d.mts +121 -0
- package/dist/draggable.mjs +153 -0
- package/dist/element-bounding.d.mts +87 -0
- package/dist/element-bounding.mjs +95 -0
- package/dist/element-by-point.d.mts +70 -0
- package/dist/element-by-point.mjs +69 -0
- package/dist/element-hover.d.mts +42 -0
- package/dist/element-hover.mjs +70 -0
- package/dist/element-ref.d.mts +34 -0
- package/dist/element-ref.mjs +23 -0
- package/dist/element-target-Crpxl4D9.d.mts +60 -0
- package/dist/element-target.d.mts +2 -0
- package/dist/element-target.mjs +58 -0
- package/dist/event-listener.mjs +7 -3
- package/dist/focus.d.mts +69 -0
- package/dist/focus.mjs +124 -0
- package/dist/fps.d.mts +59 -0
- package/dist/fps.mjs +64 -0
- package/dist/geolocation.d.mts +98 -0
- package/dist/geolocation.mjs +86 -0
- package/dist/i18n.d.mts +237 -0
- package/dist/i18n.mjs +215 -0
- package/dist/icu-message.d.mts +235 -0
- package/dist/icu-message.mjs +343 -0
- package/dist/idle.d.mts +79 -0
- package/dist/idle.mjs +90 -0
- package/dist/index.d.mts +172 -6
- package/dist/index.mjs +173 -7
- package/dist/infinite-scroll.d.mts +56 -0
- package/dist/infinite-scroll.mjs +72 -0
- package/dist/intersection-observer.d.mts +122 -0
- package/dist/intersection-observer.mjs +117 -0
- package/dist/magic-keys.d.mts +121 -0
- package/dist/magic-keys.mjs +163 -0
- package/dist/math.d.mts +96 -0
- package/dist/math.mjs +84 -0
- package/dist/media-query.d.mts +3 -1
- package/dist/media-query.mjs +5 -3
- package/dist/mouse-in-element.d.mts +49 -0
- package/dist/mouse-in-element.mjs +66 -0
- package/dist/mouse.d.mts +77 -0
- package/dist/mouse.mjs +100 -0
- package/dist/mutation-observer.d.mts +98 -0
- package/dist/mutation-observer.mjs +69 -0
- package/dist/network.d.mts +96 -0
- package/dist/network.mjs +117 -0
- package/dist/on-click-outside.d.mts +69 -0
- package/dist/on-click-outside.mjs +115 -0
- package/dist/on-key-stroke.d.mts +71 -0
- package/dist/on-key-stroke.mjs +79 -0
- package/dist/on-long-press.d.mts +82 -0
- package/dist/on-long-press.mjs +105 -0
- package/dist/on-start-typing.d.mts +44 -0
- package/dist/on-start-typing.mjs +61 -0
- package/dist/page-leave.d.mts +26 -0
- package/dist/page-leave.mjs +40 -0
- package/dist/parent-element.d.mts +16 -0
- package/dist/parent-element.mjs +27 -0
- package/dist/pinch.d.mts +73 -0
- package/dist/pinch.mjs +138 -0
- package/dist/pointer-lock.d.mts +79 -0
- package/dist/pointer-lock.mjs +126 -0
- package/dist/pointer.d.mts +78 -0
- package/dist/pointer.mjs +95 -0
- package/dist/preferences.d.mts +55 -0
- package/dist/preferences.mjs +63 -0
- package/dist/preferred-languages.d.mts +43 -0
- package/dist/preferred-languages.mjs +44 -0
- package/dist/reactify.d.mts +28 -0
- package/dist/reactify.mjs +7 -0
- package/dist/ref-auto-reset.d.mts +47 -0
- package/dist/ref-auto-reset.mjs +70 -0
- package/dist/ref-debounced.d.mts +29 -0
- package/dist/ref-debounced.mjs +29 -0
- package/dist/ref-default.d.mts +27 -0
- package/dist/ref-default.mjs +33 -0
- package/dist/resize-observer.d.mts +96 -0
- package/dist/resize-observer.mjs +111 -0
- package/dist/resolver.d.mts +124 -0
- package/dist/resolver.mjs +138 -0
- package/dist/retry-async.d.mts +2 -2
- package/dist/retry-delay-DYsdq4SE.d.mts +73 -0
- package/dist/retry-delay.d.mts +1 -72
- package/dist/screen-orientation.d.mts +77 -0
- package/dist/screen-orientation.mjs +74 -0
- package/dist/scroll-lock.d.mts +37 -0
- package/dist/scroll-lock.mjs +50 -0
- package/dist/scroll.d.mts +158 -0
- package/dist/scroll.mjs +172 -0
- package/dist/standard-schema-DmNgFVK5.d.mts +107 -0
- package/dist/standard-schema.d.mts +2 -0
- package/dist/standard-schema.mjs +60 -0
- package/dist/swipe.d.mts +125 -0
- package/dist/swipe.mjs +225 -0
- package/dist/sync-ref.d.mts +80 -0
- package/dist/sync-ref.mjs +43 -0
- package/dist/text-selection.d.mts +46 -0
- package/dist/text-selection.mjs +62 -0
- package/dist/textarea-autosize.d.mts +58 -0
- package/dist/textarea-autosize.mjs +54 -0
- package/dist/timeout-scheduler-CI8RVLZs.d.mts +18 -0
- package/dist/timeout-scheduler.d.mts +1 -17
- package/dist/to-reactive.d.mts +26 -0
- package/dist/to-reactive.mjs +46 -0
- package/dist/transition.d.mts +125 -0
- package/dist/transition.mjs +266 -0
- package/dist/until.d.mts +177 -0
- package/dist/until.mjs +111 -0
- package/dist/use-array.d.mts +112 -0
- package/dist/use-array.mjs +90 -0
- package/dist/use-async-queue.d.mts +109 -0
- package/dist/use-async-queue.mjs +96 -0
- package/dist/use-async-state.d.mts +86 -0
- package/dist/use-async-state.mjs +41 -0
- package/dist/use-barcode-detector.d.mts +159 -0
- package/dist/use-barcode-detector.mjs +143 -0
- package/dist/use-bluetooth.d.mts +164 -0
- package/dist/use-bluetooth.mjs +183 -0
- package/dist/use-broadcast-channel.d.mts +115 -0
- package/dist/use-broadcast-channel.mjs +121 -0
- package/dist/use-builtin-ai.d.mts +342 -0
- package/dist/use-builtin-ai.mjs +261 -0
- package/dist/use-clipboard.d.mts +169 -0
- package/dist/use-clipboard.mjs +226 -0
- package/dist/use-compression-stream.d.mts +173 -0
- package/dist/use-compression-stream.mjs +166 -0
- package/dist/use-confirm-dialog.d.mts +70 -0
- package/dist/use-confirm-dialog.mjs +57 -0
- package/dist/use-contact-picker.d.mts +117 -0
- package/dist/use-contact-picker.mjs +103 -0
- package/dist/use-cookie.d.mts +196 -0
- package/dist/use-cookie.mjs +259 -0
- package/dist/use-countdown.d.mts +85 -0
- package/dist/use-countdown.mjs +74 -0
- package/dist/use-css-var.d.mts +96 -0
- package/dist/use-css-var.mjs +104 -0
- package/dist/use-cycle-list.d.mts +76 -0
- package/dist/use-cycle-list.mjs +39 -0
- package/dist/use-date-format.d.mts +103 -0
- package/dist/use-date-format.mjs +147 -0
- package/dist/use-date-time-format.d.mts +75 -0
- package/dist/use-date-time-format.mjs +53 -0
- package/dist/use-debounced.d.mts +1 -1
- package/dist/use-display-media.d.mts +62 -0
- package/dist/use-display-media.mjs +46 -0
- package/dist/use-display-names.d.mts +75 -0
- package/dist/use-display-names.mjs +52 -0
- package/dist/use-document-title.d.mts +88 -0
- package/dist/use-document-title.mjs +100 -0
- package/dist/use-drop-zone.d.mts +128 -0
- package/dist/use-drop-zone.mjs +154 -0
- package/dist/use-event-source.d.mts +184 -0
- package/dist/use-event-source.mjs +226 -0
- package/dist/use-eye-dropper.d.mts +79 -0
- package/dist/use-eye-dropper.mjs +68 -0
- package/dist/use-favicon.d.mts +78 -0
- package/dist/use-favicon.mjs +68 -0
- package/dist/use-fetch.d.mts +230 -0
- package/dist/use-fetch.mjs +263 -0
- package/dist/use-field.d.mts +107 -0
- package/dist/use-field.mjs +117 -0
- package/dist/use-file-dialog.d.mts +139 -0
- package/dist/use-file-dialog.mjs +101 -0
- package/dist/use-file-system-access.d.mts +184 -0
- package/dist/use-file-system-access.mjs +151 -0
- package/dist/use-form-field-props.d.mts +235 -0
- package/dist/use-form-field-props.mjs +164 -0
- package/dist/use-form.d.mts +324 -0
- package/dist/use-form.mjs +482 -0
- package/dist/use-fullscreen.d.mts +104 -0
- package/dist/use-fullscreen.mjs +95 -0
- package/dist/use-gamepad.d.mts +242 -0
- package/dist/use-gamepad.mjs +218 -0
- package/dist/use-hid.d.mts +160 -0
- package/dist/use-hid.mjs +156 -0
- package/dist/use-id-generator.d.mts +44 -0
- package/dist/use-id-generator.mjs +38 -0
- package/dist/use-image.d.mts +125 -0
- package/dist/use-image.mjs +109 -0
- package/dist/use-indexed-db.d.mts +207 -0
- package/dist/use-indexed-db.mjs +251 -0
- package/dist/use-interval-BA55gTHT.d.mts +140 -0
- package/dist/use-interval.d.mts +2 -0
- package/dist/use-interval.mjs +100 -0
- package/dist/use-list-format.d.mts +60 -0
- package/dist/use-list-format.mjs +40 -0
- package/dist/use-machine.d.mts +90 -0
- package/dist/use-machine.mjs +78 -0
- package/dist/use-map.d.mts +90 -0
- package/dist/use-map.mjs +70 -0
- package/dist/use-media-controls.d.mts +198 -0
- package/dist/use-media-controls.mjs +264 -0
- package/dist/use-memoize.d.mts +73 -0
- package/dist/use-memoize.mjs +28 -0
- package/dist/use-mounted.d.mts +24 -0
- package/dist/use-mounted.mjs +29 -0
- package/dist/use-navigation-api.d.mts +360 -0
- package/dist/use-navigation-api.mjs +231 -0
- package/dist/use-notification.d.mts +139 -0
- package/dist/use-notification.mjs +131 -0
- package/dist/use-now.d.mts +137 -0
- package/dist/use-now.mjs +44 -0
- package/dist/use-number-format.d.mts +73 -0
- package/dist/use-number-format.mjs +58 -0
- package/dist/use-object-url.d.mts +47 -0
- package/dist/use-object-url.mjs +54 -0
- package/dist/use-offset-pagination.d.mts +91 -0
- package/dist/use-offset-pagination.mjs +80 -0
- package/dist/use-payment-request.d.mts +239 -0
- package/dist/use-payment-request.mjs +206 -0
- package/dist/use-performance-observer.d.mts +285 -0
- package/dist/use-performance-observer.mjs +132 -0
- package/dist/use-permission.d.mts +99 -0
- package/dist/use-permission.mjs +92 -0
- package/dist/use-plural-rules.d.mts +79 -0
- package/dist/use-plural-rules.mjs +59 -0
- package/dist/use-push-subscription.d.mts +154 -0
- package/dist/use-push-subscription.mjs +146 -0
- package/dist/use-queue.d.mts +89 -0
- package/dist/use-queue.mjs +116 -0
- package/dist/use-raf-fn.d.mts +87 -0
- package/dist/use-raf-fn.mjs +99 -0
- package/dist/use-relative-time-format.d.mts +111 -0
- package/dist/use-relative-time-format.mjs +119 -0
- package/dist/use-request-idle-callback.d.mts +122 -0
- package/dist/use-request-idle-callback.mjs +147 -0
- package/dist/use-route-query.d.mts +149 -0
- package/dist/use-route-query.mjs +86 -0
- package/dist/use-scheduler-post-task.d.mts +156 -0
- package/dist/use-scheduler-post-task.mjs +182 -0
- package/dist/use-screen-details.d.mts +205 -0
- package/dist/use-screen-details.mjs +188 -0
- package/dist/use-script-tag.d.mts +162 -0
- package/dist/use-script-tag.mjs +171 -0
- package/dist/use-segmenter.d.mts +78 -0
- package/dist/use-segmenter.mjs +66 -0
- package/dist/use-selection.d.mts +125 -0
- package/dist/use-selection.mjs +77 -0
- package/dist/use-serial.d.mts +165 -0
- package/dist/use-serial.mjs +205 -0
- package/dist/use-service-worker.d.mts +177 -0
- package/dist/use-service-worker.mjs +178 -0
- package/dist/use-set.d.mts +96 -0
- package/dist/use-set.mjs +74 -0
- package/dist/use-share.d.mts +92 -0
- package/dist/use-share.mjs +99 -0
- package/dist/use-sorted-locale.d.mts +62 -0
- package/dist/use-sorted-locale.mjs +52 -0
- package/dist/use-sorted.d.mts +29 -0
- package/dist/use-sorted.mjs +14 -0
- package/dist/use-speech-recognition.d.mts +150 -0
- package/dist/use-speech-recognition.mjs +168 -0
- package/dist/use-speech-synthesis.d.mts +148 -0
- package/dist/use-speech-synthesis.mjs +152 -0
- package/dist/use-stack.d.mts +83 -0
- package/dist/use-stack.mjs +93 -0
- package/dist/use-stepper.d.mts +79 -0
- package/dist/use-stepper.mjs +52 -0
- package/dist/use-storage-estimate.d.mts +151 -0
- package/dist/use-storage-estimate.mjs +170 -0
- package/dist/use-storage.d.mts +214 -0
- package/dist/use-storage.mjs +415 -0
- package/dist/use-style-tag.d.mts +102 -0
- package/dist/use-style-tag.mjs +91 -0
- package/dist/use-supported.d.mts +23 -0
- package/dist/use-supported.mjs +26 -0
- package/dist/use-throttled.d.mts +1 -1
- package/dist/use-time-ago.d.mts +163 -0
- package/dist/use-time-ago.mjs +95 -0
- package/dist/use-timeout.d.mts +122 -0
- package/dist/use-timeout.mjs +65 -0
- package/dist/use-url-hash.d.mts +88 -0
- package/dist/use-url-hash.mjs +145 -0
- package/dist/use-url-search-params.d.mts +223 -0
- package/dist/use-url-search-params.mjs +295 -0
- package/dist/use-usb.d.mts +212 -0
- package/dist/use-usb.mjs +137 -0
- package/dist/use-user-activation.d.mts +83 -0
- package/dist/use-user-activation.mjs +113 -0
- package/dist/use-user-media.d.mts +194 -0
- package/dist/use-user-media.mjs +214 -0
- package/dist/use-v-model.d.mts +113 -0
- package/dist/use-v-model.mjs +40 -0
- package/dist/use-vibrate.d.mts +81 -0
- package/dist/use-vibrate.mjs +90 -0
- package/dist/use-view-transition.d.mts +106 -0
- package/dist/use-view-transition.mjs +101 -0
- package/dist/use-visual-viewport.d.mts +105 -0
- package/dist/use-visual-viewport.mjs +104 -0
- package/dist/use-wake-lock.d.mts +96 -0
- package/dist/use-wake-lock.mjs +106 -0
- package/dist/use-web-authn.d.mts +404 -0
- package/dist/use-web-authn.mjs +323 -0
- package/dist/use-web-locks.d.mts +180 -0
- package/dist/use-web-locks.mjs +136 -0
- package/dist/use-web-midi.d.mts +148 -0
- package/dist/use-web-midi.mjs +140 -0
- package/dist/use-web-vitals.d.mts +142 -0
- package/dist/use-web-vitals.mjs +248 -0
- package/dist/use-websocket.d.mts +218 -0
- package/dist/use-websocket.mjs +257 -0
- package/dist/use-worker-fn.d.mts +119 -0
- package/dist/use-worker-fn.mjs +162 -0
- package/dist/virtual-list.d.mts +105 -0
- package/dist/virtual-list.mjs +128 -0
- package/dist/watch-debounced.d.mts +84 -0
- package/dist/watch-debounced.mjs +84 -0
- package/dist/watch-ignorable.d.mts +47 -0
- package/dist/watch-ignorable.mjs +61 -0
- package/dist/watch-once.d.mts +29 -0
- package/dist/watch-once.mjs +10 -0
- package/dist/watch-pausable.d.mts +51 -0
- package/dist/watch-pausable.mjs +23 -0
- package/dist/watch-source.d.mts +29 -0
- package/dist/watch-source.mjs +1 -0
- package/dist/watch-throttled.d.mts +70 -0
- package/dist/watch-throttled.mjs +94 -0
- package/dist/whenever.d.mts +39 -0
- package/dist/whenever.mjs +41 -0
- package/dist/window-size.d.mts +87 -0
- package/dist/window-size.mjs +65 -0
- package/package.json +846 -5
- package/registry/files/abort-signal.ts +292 -0
- package/registry/files/active-element.ts +93 -0
- package/registry/files/animate.ts +322 -0
- package/registry/files/async-resource.ts +190 -0
- package/registry/files/battery.ts +166 -0
- package/registry/files/breakpoints.ts +166 -0
- package/registry/files/capability.ts +171 -0
- package/registry/files/color-mode.ts +274 -0
- package/registry/files/computed-async.ts +123 -0
- package/registry/files/computed-with-control.ts +80 -0
- package/registry/files/create-event-hook.ts +139 -0
- package/registry/files/create-global-state.ts +34 -0
- package/registry/files/create-injection-state.ts +75 -0
- package/registry/files/create-shared-composable.ts +74 -0
- package/registry/files/device-motion.ts +152 -0
- package/registry/files/device-orientation.ts +168 -0
- package/registry/files/device-pixel-ratio.ts +100 -0
- package/registry/files/disposal-scope.ts +201 -0
- package/registry/files/document-visibility.ts +152 -0
- package/registry/files/draggable.ts +273 -0
- package/registry/files/element-bounding.ts +175 -0
- package/registry/files/element-by-point.ts +149 -0
- package/registry/files/element-hover.ts +104 -0
- package/registry/files/element-ref.ts +58 -0
- package/registry/files/element-target.ts +99 -0
- package/registry/files/event-listener.ts +188 -0
- package/registry/files/focus.ts +181 -0
- package/registry/files/fps.ts +133 -0
- package/registry/files/geolocation.ts +214 -0
- package/registry/files/i18n.ts +524 -0
- package/registry/files/icu-message.ts +701 -0
- package/registry/files/idle.ts +176 -0
- package/registry/files/infinite-scroll.ts +135 -0
- package/registry/files/intersection-observer.ts +261 -0
- package/registry/files/locale.ts +148 -0
- package/registry/files/magic-keys.ts +298 -0
- package/registry/files/math.ts +175 -0
- package/registry/files/media-query.ts +102 -0
- package/registry/files/mouse-in-element.ts +107 -0
- package/registry/files/mouse.ts +167 -0
- package/registry/files/mutation-observer.ts +183 -0
- package/registry/files/network.ts +229 -0
- package/registry/files/on-click-outside.ts +178 -0
- package/registry/files/on-key-stroke.ts +135 -0
- package/registry/files/on-long-press.ts +188 -0
- package/registry/files/on-start-typing.ts +88 -0
- package/registry/files/page-leave.ts +57 -0
- package/registry/files/parent-element.ts +29 -0
- package/registry/files/pinch.ts +187 -0
- package/registry/files/pointer-lock.ts +232 -0
- package/registry/files/pointer.ts +153 -0
- package/registry/files/preferences.ts +98 -0
- package/registry/files/preferred-languages.ts +88 -0
- package/registry/files/reactify.ts +39 -0
- package/registry/files/ref-auto-reset.ts +102 -0
- package/registry/files/ref-debounced.ts +34 -0
- package/registry/files/ref-default.ts +35 -0
- package/registry/files/resize-observer.ts +220 -0
- package/registry/files/retry-async.ts +261 -0
- package/registry/files/retry-delay.ts +132 -0
- package/registry/files/scope.ts +21 -0
- package/registry/files/screen-orientation.ts +165 -0
- package/registry/files/scroll-lock.ts +80 -0
- package/registry/files/scroll.ts +338 -0
- package/registry/files/standard-schema.ts +163 -0
- package/registry/files/swipe.ts +321 -0
- package/registry/files/sync-ref.ts +166 -0
- package/registry/files/temporal.ts +182 -0
- package/registry/files/text-selection.ts +110 -0
- package/registry/files/textarea-autosize.ts +114 -0
- package/registry/files/timeout-scheduler.ts +16 -0
- package/registry/files/to-reactive.ts +44 -0
- package/registry/files/transition.ts +271 -0
- package/registry/files/until.ts +352 -0
- package/registry/files/use-array.ts +201 -0
- package/registry/files/use-async-queue.ts +278 -0
- package/registry/files/use-async-state.ts +139 -0
- package/registry/files/use-barcode-detector.ts +321 -0
- package/registry/files/use-bluetooth.ts +409 -0
- package/registry/files/use-broadcast-channel.ts +250 -0
- package/registry/files/use-builtin-ai.ts +674 -0
- package/registry/files/use-clipboard.ts +425 -0
- package/registry/files/use-compression-stream.ts +364 -0
- package/registry/files/use-confirm-dialog.ts +137 -0
- package/registry/files/use-contact-picker.ts +246 -0
- package/registry/files/use-cookie.ts +500 -0
- package/registry/files/use-countdown.ts +161 -0
- package/registry/files/use-counter.ts +147 -0
- package/registry/files/use-css-var.ts +191 -0
- package/registry/files/use-cycle-list.ts +136 -0
- package/registry/files/use-date-format.ts +281 -0
- package/registry/files/use-date-time-format.ts +113 -0
- package/registry/files/use-debounced.ts +163 -0
- package/registry/files/use-display-media.ts +89 -0
- package/registry/files/use-display-names.ts +122 -0
- package/registry/files/use-document-title.ts +196 -0
- package/registry/files/use-drop-zone.ts +287 -0
- package/registry/files/use-event-source.ts +470 -0
- package/registry/files/use-eye-dropper.ts +134 -0
- package/registry/files/use-favicon.ts +140 -0
- package/registry/files/use-fetch.ts +578 -0
- package/registry/files/use-field.ts +247 -0
- package/registry/files/use-file-dialog.ts +257 -0
- package/registry/files/use-file-system-access.ts +383 -0
- package/registry/files/use-form-field-props.ts +381 -0
- package/registry/files/use-form.ts +980 -0
- package/registry/files/use-fullscreen.ts +214 -0
- package/registry/files/use-gamepad.ts +463 -0
- package/registry/files/use-hid.ts +359 -0
- package/registry/files/use-history.ts +231 -0
- package/registry/files/use-id-generator.ts +61 -0
- package/registry/files/use-image.ts +253 -0
- package/registry/files/use-indexed-db.ts +508 -0
- package/registry/files/use-interval.ts +253 -0
- package/registry/files/use-list-format.ts +85 -0
- package/registry/files/use-machine.ts +171 -0
- package/registry/files/use-map.ts +145 -0
- package/registry/files/use-media-controls.ts +545 -0
- package/registry/files/use-memoize.ts +118 -0
- package/registry/files/use-mounted.ts +30 -0
- package/registry/files/use-navigation-api.ts +641 -0
- package/registry/files/use-notification.ts +285 -0
- package/registry/files/use-now.ts +194 -0
- package/registry/files/use-number-format.ts +120 -0
- package/registry/files/use-object-url.ts +87 -0
- package/registry/files/use-offset-pagination.ts +168 -0
- package/registry/files/use-payment-request.ts +465 -0
- package/registry/files/use-performance-observer.ts +469 -0
- package/registry/files/use-permission.ts +220 -0
- package/registry/files/use-plural-rules.ts +134 -0
- package/registry/files/use-previous.ts +62 -0
- package/registry/files/use-push-subscription.ts +352 -0
- package/registry/files/use-queue.ts +197 -0
- package/registry/files/use-raf-fn.ts +176 -0
- package/registry/files/use-relative-time-format.ts +201 -0
- package/registry/files/use-request-idle-callback.ts +278 -0
- package/registry/files/use-route-query.ts +300 -0
- package/registry/files/use-scheduler-post-task.ts +397 -0
- package/registry/files/use-screen-details.ts +393 -0
- package/registry/files/use-script-tag.ts +341 -0
- package/registry/files/use-segmenter.ts +147 -0
- package/registry/files/use-selection.ts +233 -0
- package/registry/files/use-serial.ts +404 -0
- package/registry/files/use-service-worker.ts +413 -0
- package/registry/files/use-set.ts +154 -0
- package/registry/files/use-share.ts +168 -0
- package/registry/files/use-sorted-locale.ts +130 -0
- package/registry/files/use-sorted.ts +49 -0
- package/registry/files/use-speech-recognition.ts +357 -0
- package/registry/files/use-speech-synthesis.ts +333 -0
- package/registry/files/use-stack.ts +164 -0
- package/registry/files/use-stepper.ts +166 -0
- package/registry/files/use-storage-estimate.ts +352 -0
- package/registry/files/use-storage.ts +635 -0
- package/registry/files/use-style-tag.ts +200 -0
- package/registry/files/use-supported.ts +26 -0
- package/registry/files/use-throttled.ts +215 -0
- package/registry/files/use-time-ago.ts +276 -0
- package/registry/files/use-timeout.ts +218 -0
- package/registry/files/use-toggle.ts +54 -0
- package/registry/files/use-url-hash.ts +280 -0
- package/registry/files/use-url-search-params.ts +497 -0
- package/registry/files/use-usb.ts +395 -0
- package/registry/files/use-user-activation.ts +215 -0
- package/registry/files/use-user-media.ts +422 -0
- package/registry/files/use-v-model.ts +210 -0
- package/registry/files/use-vibrate.ts +174 -0
- package/registry/files/use-view-transition.ts +229 -0
- package/registry/files/use-visual-viewport.ts +228 -0
- package/registry/files/use-wake-lock.ts +206 -0
- package/registry/files/use-web-authn.ts +793 -0
- package/registry/files/use-web-locks.ts +363 -0
- package/registry/files/use-web-midi.ts +306 -0
- package/registry/files/use-web-vitals.ts +409 -0
- package/registry/files/use-websocket.ts +553 -0
- package/registry/files/use-worker-fn.ts +306 -0
- package/registry/files/virtual-list.ts +230 -0
- package/registry/files/watch-debounced.ts +206 -0
- package/registry/files/watch-ignorable.ts +128 -0
- package/registry/files/watch-once.ts +46 -0
- package/registry/files/watch-pausable.ts +93 -0
- package/registry/files/watch-source.ts +51 -0
- package/registry/files/watch-throttled.ts +201 -0
- package/registry/files/whenever.ts +70 -0
- package/registry/files/window-size.ts +151 -0
- package/registry/registry.json +5792 -0
- package/dist/catalog-D2AL3xYl.d.mts +0 -523
- package/dist/catalog-D5SYCsgW.mjs +0 -549
package/dist/abort-signal.d.mts
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, ShallowRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/active-element.d.ts
|
|
4
|
+
/** Document-like capability observed by {@link useActiveElement}. */
|
|
5
|
+
interface ActiveElementHost extends EventTarget {
|
|
6
|
+
/** Currently focused element. */
|
|
7
|
+
readonly activeElement: Element | null;
|
|
8
|
+
}
|
|
9
|
+
/** Options for {@link useActiveElement}. */
|
|
10
|
+
interface UseActiveElementOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Descend into open shadow roots to report the innermost focused element.
|
|
13
|
+
*
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
readonly deep?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Reactive document capability for alternate runtimes and tests.
|
|
19
|
+
*
|
|
20
|
+
* @default globalThis.document when available
|
|
21
|
+
*/
|
|
22
|
+
readonly host?: MaybeRefOrGetter<ActiveElementHost | null | undefined>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Track the focused element of a document.
|
|
26
|
+
*
|
|
27
|
+
* Listens for capturing `focus`/`blur` events on the document, so focus
|
|
28
|
+
* changes anywhere (including inside shadow trees) update the ref.
|
|
29
|
+
* Server renders expose `null`. Listeners are removed with the owning scope.
|
|
30
|
+
*
|
|
31
|
+
* @param options Shadow-DOM traversal and document capability.
|
|
32
|
+
* @default options {}
|
|
33
|
+
* @returns Readonly shallow ref of the active element.
|
|
34
|
+
*/
|
|
35
|
+
declare function useActiveElement(options?: UseActiveElementOptions): Readonly<ShallowRef<Element | null>>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ActiveElementHost, UseActiveElementOptions, useActiveElement };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { hasInjectionContext, onMounted, shallowRef, toValue, watch } from "vue";
|
|
3
|
+
//#region src/active-element.ts
|
|
4
|
+
/**
|
|
5
|
+
* Track the focused element of a document.
|
|
6
|
+
*
|
|
7
|
+
* Listens for capturing `focus`/`blur` events on the document, so focus
|
|
8
|
+
* changes anywhere (including inside shadow trees) update the ref.
|
|
9
|
+
* Server renders expose `null`. Listeners are removed with the owning scope.
|
|
10
|
+
*
|
|
11
|
+
* @param options Shadow-DOM traversal and document capability.
|
|
12
|
+
* @default options {}
|
|
13
|
+
* @returns Readonly shallow ref of the active element.
|
|
14
|
+
*/
|
|
15
|
+
function useActiveElement(options = {}) {
|
|
16
|
+
const deep = options.deep ?? true;
|
|
17
|
+
const active = shallowRef(null);
|
|
18
|
+
const mounted = shallowRef(!hasInjectionContext());
|
|
19
|
+
if (!mounted.value) onMounted(() => {
|
|
20
|
+
mounted.value = true;
|
|
21
|
+
});
|
|
22
|
+
const stop = watch(() => !mounted.value ? void 0 : options.host === void 0 ? browserActiveElementHost() : toValue(options.host), (host, _previous, onCleanup) => {
|
|
23
|
+
if (!host) {
|
|
24
|
+
active.value = null;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const update = () => {
|
|
28
|
+
active.value = readActive(host.activeElement, deep);
|
|
29
|
+
};
|
|
30
|
+
update();
|
|
31
|
+
host.addEventListener("focus", update, {
|
|
32
|
+
capture: true,
|
|
33
|
+
passive: true
|
|
34
|
+
});
|
|
35
|
+
host.addEventListener("blur", update, {
|
|
36
|
+
capture: true,
|
|
37
|
+
passive: true
|
|
38
|
+
});
|
|
39
|
+
onCleanup(() => {
|
|
40
|
+
host.removeEventListener("focus", update, { capture: true });
|
|
41
|
+
host.removeEventListener("blur", update, { capture: true });
|
|
42
|
+
});
|
|
43
|
+
}, { immediate: true });
|
|
44
|
+
tryOnScopeDispose(() => stop.stop());
|
|
45
|
+
return active;
|
|
46
|
+
}
|
|
47
|
+
function readActive(element, deep) {
|
|
48
|
+
let current = element;
|
|
49
|
+
while (deep && current?.shadowRoot?.activeElement) current = current.shadowRoot.activeElement;
|
|
50
|
+
return current;
|
|
51
|
+
}
|
|
52
|
+
function browserActiveElementHost() {
|
|
53
|
+
return typeof document !== "undefined" ? document : void 0;
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { useActiveElement };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { n as MaybeElementTarget } from "./element-target-Crpxl4D9.mjs";
|
|
2
|
+
import { MaybeRefOrGetter, Ref, ShallowRef, WritableComputedRef } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/animate.d.ts
|
|
5
|
+
/** CSS property names (camelCase) that accept string values on `CSSStyleDeclaration`. */
|
|
6
|
+
type AnimatableCssProperty = { [Key in keyof CSSStyleDeclaration]: Key extends string ? CSSStyleDeclaration[Key] extends string ? Key : never : never }[keyof CSSStyleDeclaration];
|
|
7
|
+
type KeyframeProperty = Exclude<AnimatableCssProperty, "offset" | "cssText">;
|
|
8
|
+
/** Keyframe whose property names are checked against `CSSStyleDeclaration`. */
|
|
9
|
+
type TypedKeyframe = { readonly [Key in KeyframeProperty]?: string | number | null } & {
|
|
10
|
+
/** Position of the keyframe in `[0, 1]`. */readonly offset?: number | null; /** Easing applied from this keyframe to the next. */
|
|
11
|
+
readonly easing?: string; /** Composite operation for this keyframe. */
|
|
12
|
+
readonly composite?: CompositeOperationOrAuto; /** CSS `offset` shorthand (motion path); WAAPI names it `cssOffset` to avoid the keyframe offset. */
|
|
13
|
+
readonly cssOffset?: string;
|
|
14
|
+
};
|
|
15
|
+
/** Value list of one property in property-indexed keyframes. */
|
|
16
|
+
type IndexedKeyframeValue = string | number | null | readonly string[] | readonly (number | null)[];
|
|
17
|
+
/** Property-indexed keyframes with checked property names. */
|
|
18
|
+
type TypedPropertyIndexedKeyframes = { readonly [Key in KeyframeProperty]?: IndexedKeyframeValue } & {
|
|
19
|
+
/** Keyframe positions. */readonly offset?: number | null | readonly (number | null)[]; /** Easings. */
|
|
20
|
+
readonly easing?: string | readonly string[]; /** Composite operations. */
|
|
21
|
+
readonly composite?: CompositeOperationOrAuto | readonly CompositeOperationOrAuto[];
|
|
22
|
+
};
|
|
23
|
+
/** Keyframes accepted by {@link useAnimate}. */
|
|
24
|
+
type AnimationKeyframes = readonly TypedKeyframe[] | TypedPropertyIndexedKeyframes;
|
|
25
|
+
/** Frame scheduler used to keep `currentTime` in sync while running. */
|
|
26
|
+
interface AnimateFrameHost {
|
|
27
|
+
/** Schedule a callback before the next repaint. */
|
|
28
|
+
readonly requestAnimationFrame: (callback: FrameRequestCallback) => number;
|
|
29
|
+
/** Cancel a scheduled frame. */
|
|
30
|
+
readonly cancelAnimationFrame: (handle: number) => void;
|
|
31
|
+
}
|
|
32
|
+
/** Options for {@link useAnimate}. */
|
|
33
|
+
interface UseAnimateOptions extends KeyframeAnimationOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Start playing as soon as the element resolves.
|
|
36
|
+
*
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
readonly immediate?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Commit the final computed styles to the element's `style` on finish.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
readonly commitStyles?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Keep the animation from being auto-removed by the browser when it is
|
|
48
|
+
* replaced by another filling animation.
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
readonly persist?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Called once the animation object is created.
|
|
55
|
+
*
|
|
56
|
+
* @default undefined
|
|
57
|
+
*/
|
|
58
|
+
readonly onReady?: (animation: Animation) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Called when creating the animation throws (e.g. invalid keyframes).
|
|
61
|
+
*
|
|
62
|
+
* @default undefined
|
|
63
|
+
*/
|
|
64
|
+
readonly onError?: (error: unknown) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Frame scheduler used to sync `currentTime` while running.
|
|
67
|
+
*
|
|
68
|
+
* @default globalThis.window when available
|
|
69
|
+
*/
|
|
70
|
+
readonly frameHost?: MaybeRefOrGetter<AnimateFrameHost | null | undefined>;
|
|
71
|
+
}
|
|
72
|
+
/** Reactive animation state returned by {@link useAnimate}. */
|
|
73
|
+
interface AnimateControls {
|
|
74
|
+
/** Whether the resolved element supports `animate()`. `false` during server rendering. */
|
|
75
|
+
readonly isSupported: Readonly<Ref<boolean>>;
|
|
76
|
+
/** Underlying `Animation`, once created. */
|
|
77
|
+
readonly animation: Readonly<ShallowRef<Animation | null>>;
|
|
78
|
+
/** Playback state. */
|
|
79
|
+
readonly playState: Readonly<Ref<AnimationPlayState>>;
|
|
80
|
+
/** Whether a play/pause is pending. */
|
|
81
|
+
readonly pending: Readonly<Ref<boolean>>;
|
|
82
|
+
/** Current time in milliseconds (writable to seek). */
|
|
83
|
+
readonly currentTime: WritableComputedRef<number | null>;
|
|
84
|
+
/** Playback rate (writable). */
|
|
85
|
+
readonly playbackRate: WritableComputedRef<number>;
|
|
86
|
+
/** Play (creating the animation if needed). */
|
|
87
|
+
readonly play: () => void;
|
|
88
|
+
/** Pause. */
|
|
89
|
+
readonly pause: () => void;
|
|
90
|
+
/** Reverse the playback direction. */
|
|
91
|
+
readonly reverse: () => void;
|
|
92
|
+
/** Jump to the end. */
|
|
93
|
+
readonly finish: () => void;
|
|
94
|
+
/** Cancel and clear effects. */
|
|
95
|
+
readonly cancel: () => void;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Drive the Web Animations API reactively with typed keyframes.
|
|
99
|
+
*
|
|
100
|
+
* Keyframe property names are checked against `CSSStyleDeclaration`, so typos
|
|
101
|
+
* are compile errors. Changing keyframes updates the running effect in place.
|
|
102
|
+
* Playback state is synced after every control call, on `finish`/`cancel`/
|
|
103
|
+
* `remove`, and every animation frame while running. The animation is
|
|
104
|
+
* cancelled when the owning reactive scope stops. Nothing runs during server
|
|
105
|
+
* rendering (`playState` is `"idle"`).
|
|
106
|
+
*
|
|
107
|
+
* @param target Reactive element target.
|
|
108
|
+
* @param keyframes Reactive typed keyframes (`null` to pause creation).
|
|
109
|
+
* @param options Duration in milliseconds, or timing plus lifecycle options.
|
|
110
|
+
* @returns Reactive playback state and controls.
|
|
111
|
+
*/
|
|
112
|
+
declare function useAnimate(target: MaybeElementTarget, keyframes: MaybeRefOrGetter<AnimationKeyframes | null>, options: number | UseAnimateOptions): AnimateControls;
|
|
113
|
+
//#endregion
|
|
114
|
+
export { AnimatableCssProperty, AnimateControls, AnimateFrameHost, AnimationKeyframes, IndexedKeyframeValue, TypedKeyframe, TypedPropertyIndexedKeyframes, UseAnimateOptions, useAnimate };
|
package/dist/animate.mjs
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { resolveElement } from "./element-target.mjs";
|
|
3
|
+
import { computed, readonly, ref, shallowRef, toValue, watch } from "vue";
|
|
4
|
+
//#region src/animate.ts
|
|
5
|
+
/**
|
|
6
|
+
* Drive the Web Animations API reactively with typed keyframes.
|
|
7
|
+
*
|
|
8
|
+
* Keyframe property names are checked against `CSSStyleDeclaration`, so typos
|
|
9
|
+
* are compile errors. Changing keyframes updates the running effect in place.
|
|
10
|
+
* Playback state is synced after every control call, on `finish`/`cancel`/
|
|
11
|
+
* `remove`, and every animation frame while running. The animation is
|
|
12
|
+
* cancelled when the owning reactive scope stops. Nothing runs during server
|
|
13
|
+
* rendering (`playState` is `"idle"`).
|
|
14
|
+
*
|
|
15
|
+
* @param target Reactive element target.
|
|
16
|
+
* @param keyframes Reactive typed keyframes (`null` to pause creation).
|
|
17
|
+
* @param options Duration in milliseconds, or timing plus lifecycle options.
|
|
18
|
+
* @returns Reactive playback state and controls.
|
|
19
|
+
*/
|
|
20
|
+
function useAnimate(target, keyframes, options) {
|
|
21
|
+
const { immediate = true, commitStyles = false, persist = false, onReady, onError, frameHost, ...timing } = typeof options === "number" ? { duration: options } : options;
|
|
22
|
+
const animation = shallowRef(null);
|
|
23
|
+
const isSupported = ref(false);
|
|
24
|
+
const playState = ref("idle");
|
|
25
|
+
const pending = ref(false);
|
|
26
|
+
const time = ref(null);
|
|
27
|
+
const rate = ref(timing.playbackRate ?? 1);
|
|
28
|
+
let stopFrames = () => void 0;
|
|
29
|
+
const readTime = (value) => typeof value === "number" ? value : null;
|
|
30
|
+
const sync = () => {
|
|
31
|
+
const current = animation.value;
|
|
32
|
+
if (!current) return;
|
|
33
|
+
playState.value = current.playState;
|
|
34
|
+
pending.value = current.pending;
|
|
35
|
+
time.value = readTime(current.currentTime);
|
|
36
|
+
rate.value = current.playbackRate;
|
|
37
|
+
if (current.playState === "running") startFrames();
|
|
38
|
+
else stopFrames();
|
|
39
|
+
};
|
|
40
|
+
const startFrames = () => {
|
|
41
|
+
const frames = frameHost === void 0 ? browserFrameHost() : toValue(frameHost);
|
|
42
|
+
if (!frames) return;
|
|
43
|
+
stopFrames();
|
|
44
|
+
let handle = frames.requestAnimationFrame(function tick() {
|
|
45
|
+
sync();
|
|
46
|
+
if (animation.value?.playState === "running") handle = frames.requestAnimationFrame(tick);
|
|
47
|
+
});
|
|
48
|
+
stopFrames = () => {
|
|
49
|
+
frames.cancelAnimationFrame(handle);
|
|
50
|
+
stopFrames = () => void 0;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const create = () => {
|
|
54
|
+
const element = resolveElement(target);
|
|
55
|
+
const frames = toValue(keyframes);
|
|
56
|
+
isSupported.value = element !== null && typeof element.animate === "function";
|
|
57
|
+
if (!element || !frames || !isSupported.value) return null;
|
|
58
|
+
try {
|
|
59
|
+
const created = element.animate(toPlatformKeyframes(frames), timing);
|
|
60
|
+
if (persist) created.persist();
|
|
61
|
+
if (commitStyles) created.addEventListener("finish", () => {
|
|
62
|
+
try {
|
|
63
|
+
created.commitStyles();
|
|
64
|
+
} catch {}
|
|
65
|
+
});
|
|
66
|
+
for (const type of [
|
|
67
|
+
"finish",
|
|
68
|
+
"cancel",
|
|
69
|
+
"remove"
|
|
70
|
+
]) created.addEventListener(type, sync);
|
|
71
|
+
animation.value = created;
|
|
72
|
+
onReady?.(created);
|
|
73
|
+
return created;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
onError?.(error);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const stopTarget = watch(() => resolveElement(target), (element, _previous, onCleanup) => {
|
|
80
|
+
if (!element) return;
|
|
81
|
+
const created = create();
|
|
82
|
+
if (created && !immediate) created.pause();
|
|
83
|
+
sync();
|
|
84
|
+
onCleanup(() => {
|
|
85
|
+
stopFrames();
|
|
86
|
+
created?.cancel();
|
|
87
|
+
if (animation.value === created) animation.value = null;
|
|
88
|
+
playState.value = "idle";
|
|
89
|
+
});
|
|
90
|
+
}, {
|
|
91
|
+
immediate: true,
|
|
92
|
+
flush: "post"
|
|
93
|
+
});
|
|
94
|
+
const stopKeyframes = watch(() => toValue(keyframes), (frames) => {
|
|
95
|
+
const effect = animation.value?.effect;
|
|
96
|
+
if (frames && effect && isKeyframeEffect(effect)) effect.setKeyframes(toPlatformKeyframes(frames));
|
|
97
|
+
}, { deep: true });
|
|
98
|
+
tryOnScopeDispose(() => {
|
|
99
|
+
stopTarget.stop();
|
|
100
|
+
stopKeyframes.stop();
|
|
101
|
+
stopFrames();
|
|
102
|
+
});
|
|
103
|
+
const control = (action) => () => {
|
|
104
|
+
const current = animation.value ?? create();
|
|
105
|
+
if (!current) return;
|
|
106
|
+
action(current);
|
|
107
|
+
sync();
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
isSupported: readonly(isSupported),
|
|
111
|
+
animation,
|
|
112
|
+
playState: readonly(playState),
|
|
113
|
+
pending: readonly(pending),
|
|
114
|
+
currentTime: computed({
|
|
115
|
+
get: () => time.value,
|
|
116
|
+
set: (value) => {
|
|
117
|
+
if (!animation.value) return;
|
|
118
|
+
animation.value.currentTime = value;
|
|
119
|
+
sync();
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
playbackRate: computed({
|
|
123
|
+
get: () => rate.value,
|
|
124
|
+
set: (value) => {
|
|
125
|
+
rate.value = value;
|
|
126
|
+
if (!animation.value) return;
|
|
127
|
+
animation.value.playbackRate = value;
|
|
128
|
+
sync();
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
play: control((current) => current.play()),
|
|
132
|
+
pause: control((current) => current.pause()),
|
|
133
|
+
reverse: control((current) => current.reverse()),
|
|
134
|
+
finish: control((current) => current.finish()),
|
|
135
|
+
cancel: control((current) => current.cancel())
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function toPlatformKeyframes(frames) {
|
|
139
|
+
if (isKeyframeList(frames)) return frames.map((frame) => ({ ...frame }));
|
|
140
|
+
const indexed = {};
|
|
141
|
+
for (const [key, value] of Object.entries(frames)) if (value !== void 0) indexed[key] = copyIndexedValue(value);
|
|
142
|
+
return indexed;
|
|
143
|
+
}
|
|
144
|
+
function copyIndexedValue(value) {
|
|
145
|
+
return typeof value === "object" && value !== null ? value.slice() : value;
|
|
146
|
+
}
|
|
147
|
+
function isKeyframeList(frames) {
|
|
148
|
+
return Array.isArray(frames);
|
|
149
|
+
}
|
|
150
|
+
function isKeyframeEffect(effect) {
|
|
151
|
+
return "setKeyframes" in effect && typeof effect.setKeyframes === "function";
|
|
152
|
+
}
|
|
153
|
+
function browserFrameHost() {
|
|
154
|
+
return typeof window !== "undefined" ? window : void 0;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
export { useAnimate };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, Ref, ShallowRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/battery.d.ts
|
|
4
|
+
/** Subset of the Battery Status API `BatteryManager`. */
|
|
5
|
+
interface BatteryManagerLike extends EventTarget {
|
|
6
|
+
/** Whether the battery is charging. */
|
|
7
|
+
readonly charging: boolean;
|
|
8
|
+
/** Seconds until fully charged (`Infinity` when discharging). */
|
|
9
|
+
readonly chargingTime: number;
|
|
10
|
+
/** Seconds until empty (`Infinity` when charging). */
|
|
11
|
+
readonly dischargingTime: number;
|
|
12
|
+
/** Charge level in `[0, 1]`. */
|
|
13
|
+
readonly level: number;
|
|
14
|
+
}
|
|
15
|
+
/** Navigator-like capability used by {@link useBattery}. */
|
|
16
|
+
interface BatteryHost {
|
|
17
|
+
/** Resolve the battery manager, where supported. */
|
|
18
|
+
readonly getBattery?: () => Promise<BatteryManagerLike>;
|
|
19
|
+
}
|
|
20
|
+
/** Options for {@link useBattery}. */
|
|
21
|
+
interface UseBatteryOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Reactive navigator capability for alternate runtimes and tests.
|
|
24
|
+
*
|
|
25
|
+
* @default globalThis.window.navigator when available
|
|
26
|
+
*/
|
|
27
|
+
readonly host?: MaybeRefOrGetter<BatteryHost | null | undefined>;
|
|
28
|
+
}
|
|
29
|
+
/** Reactive battery state returned by {@link useBattery}. */
|
|
30
|
+
interface BatteryControls {
|
|
31
|
+
/** Whether the host exposes `getBattery`. `false` during server rendering. */
|
|
32
|
+
readonly isSupported: Readonly<Ref<boolean>>;
|
|
33
|
+
/** Whether the battery manager has resolved. */
|
|
34
|
+
readonly isReady: Readonly<Ref<boolean>>;
|
|
35
|
+
/** Whether the battery is charging. */
|
|
36
|
+
readonly charging: Readonly<Ref<boolean>>;
|
|
37
|
+
/** Seconds until fully charged. */
|
|
38
|
+
readonly chargingTime: Readonly<Ref<number>>;
|
|
39
|
+
/** Seconds until empty. */
|
|
40
|
+
readonly dischargingTime: Readonly<Ref<number>>;
|
|
41
|
+
/** Charge level in `[0, 1]`. */
|
|
42
|
+
readonly level: Readonly<Ref<number>>;
|
|
43
|
+
/** Rejection from `getBattery`, if any (for example a permissions policy). */
|
|
44
|
+
readonly error: Readonly<ShallowRef<unknown>>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Track the device battery with the Battery Status API.
|
|
48
|
+
*
|
|
49
|
+
* Server renders (and unsupported browsers) expose a full, charging battery
|
|
50
|
+
* (`level: 1`, `charging: true`, times `0`/`Infinity`), which is the
|
|
51
|
+
* least alarming deterministic default. Late resolutions after the host
|
|
52
|
+
* changed or the scope stopped are ignored, and listeners are removed with
|
|
53
|
+
* the owning reactive scope.
|
|
54
|
+
*
|
|
55
|
+
* @param options Navigator capability.
|
|
56
|
+
* @default options {}
|
|
57
|
+
* @returns Reactive battery state.
|
|
58
|
+
*/
|
|
59
|
+
declare function useBattery(options?: UseBatteryOptions): BatteryControls;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { BatteryControls, BatteryHost, BatteryManagerLike, UseBatteryOptions, useBattery };
|
package/dist/battery.mjs
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { hasInjectionContext, onMounted, readonly, ref, shallowRef, toValue, watch } from "vue";
|
|
3
|
+
//#region src/battery.ts
|
|
4
|
+
const batteryEvents = [
|
|
5
|
+
"chargingchange",
|
|
6
|
+
"chargingtimechange",
|
|
7
|
+
"dischargingtimechange",
|
|
8
|
+
"levelchange"
|
|
9
|
+
];
|
|
10
|
+
/**
|
|
11
|
+
* Track the device battery with the Battery Status API.
|
|
12
|
+
*
|
|
13
|
+
* Server renders (and unsupported browsers) expose a full, charging battery
|
|
14
|
+
* (`level: 1`, `charging: true`, times `0`/`Infinity`), which is the
|
|
15
|
+
* least alarming deterministic default. Late resolutions after the host
|
|
16
|
+
* changed or the scope stopped are ignored, and listeners are removed with
|
|
17
|
+
* the owning reactive scope.
|
|
18
|
+
*
|
|
19
|
+
* @param options Navigator capability.
|
|
20
|
+
* @default options {}
|
|
21
|
+
* @returns Reactive battery state.
|
|
22
|
+
*/
|
|
23
|
+
function useBattery(options = {}) {
|
|
24
|
+
const isSupported = ref(false);
|
|
25
|
+
const isReady = ref(false);
|
|
26
|
+
const charging = ref(true);
|
|
27
|
+
const chargingTime = ref(0);
|
|
28
|
+
const dischargingTime = ref(Number.POSITIVE_INFINITY);
|
|
29
|
+
const level = ref(1);
|
|
30
|
+
const error = shallowRef(void 0);
|
|
31
|
+
const mounted = shallowRef(!hasInjectionContext());
|
|
32
|
+
if (!mounted.value) onMounted(() => {
|
|
33
|
+
mounted.value = true;
|
|
34
|
+
});
|
|
35
|
+
const stop = watch(() => !mounted.value ? void 0 : options.host === void 0 ? browserBatteryHost() : toValue(options.host), (host, _previous, onCleanup) => {
|
|
36
|
+
const getBattery = host?.getBattery;
|
|
37
|
+
isSupported.value = typeof getBattery === "function";
|
|
38
|
+
isReady.value = false;
|
|
39
|
+
if (!host || typeof getBattery !== "function") return;
|
|
40
|
+
let cancelled = false;
|
|
41
|
+
let release = () => void 0;
|
|
42
|
+
onCleanup(() => {
|
|
43
|
+
cancelled = true;
|
|
44
|
+
release();
|
|
45
|
+
});
|
|
46
|
+
getBattery.call(host).then((battery) => {
|
|
47
|
+
if (cancelled) return;
|
|
48
|
+
const update = () => {
|
|
49
|
+
charging.value = battery.charging;
|
|
50
|
+
chargingTime.value = battery.chargingTime;
|
|
51
|
+
dischargingTime.value = battery.dischargingTime;
|
|
52
|
+
level.value = battery.level;
|
|
53
|
+
};
|
|
54
|
+
update();
|
|
55
|
+
isReady.value = true;
|
|
56
|
+
for (const type of batteryEvents) battery.addEventListener(type, update);
|
|
57
|
+
release = () => {
|
|
58
|
+
for (const type of batteryEvents) battery.removeEventListener(type, update);
|
|
59
|
+
};
|
|
60
|
+
}, (cause) => {
|
|
61
|
+
if (!cancelled) error.value = cause;
|
|
62
|
+
});
|
|
63
|
+
}, { immediate: true });
|
|
64
|
+
tryOnScopeDispose(() => stop.stop());
|
|
65
|
+
return {
|
|
66
|
+
isSupported: readonly(isSupported),
|
|
67
|
+
isReady: readonly(isReady),
|
|
68
|
+
charging: readonly(charging),
|
|
69
|
+
chargingTime: readonly(chargingTime),
|
|
70
|
+
dischargingTime: readonly(dischargingTime),
|
|
71
|
+
level: readonly(level),
|
|
72
|
+
error
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function browserBatteryHost() {
|
|
76
|
+
if (typeof window === "undefined") return void 0;
|
|
77
|
+
const navigator = window.navigator;
|
|
78
|
+
if (!("getBattery" in navigator) || typeof navigator.getBattery !== "function") return {};
|
|
79
|
+
const request = navigator.getBattery;
|
|
80
|
+
return { getBattery: async () => {
|
|
81
|
+
const battery = await Reflect.apply(request, navigator, []);
|
|
82
|
+
if (isBatteryManager(battery)) return battery;
|
|
83
|
+
throw new TypeError("navigator.getBattery() resolved to an unexpected value.");
|
|
84
|
+
} };
|
|
85
|
+
}
|
|
86
|
+
function isBatteryManager(value) {
|
|
87
|
+
return typeof value === "object" && value !== null && "level" in value && "charging" in value && "addEventListener" in value;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { useBattery };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { UseMediaQueryOptions } from "./media-query.mjs";
|
|
2
|
+
import { ComputedRef, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/breakpoints.d.ts
|
|
5
|
+
/** Breakpoint width: pixels as a number, or a CSS length in `px`, `rem`, or `em`. */
|
|
6
|
+
type BreakpointValue = number | `${number}px` | `${number}rem` | `${number}em`;
|
|
7
|
+
/** Named breakpoint map. */
|
|
8
|
+
type Breakpoints<Name extends string = string> = Readonly<Record<Name, BreakpointValue>>;
|
|
9
|
+
/** Tailwind CSS default breakpoints. */
|
|
10
|
+
declare const breakpointsTailwind: {
|
|
11
|
+
readonly sm: 640;
|
|
12
|
+
readonly md: 768;
|
|
13
|
+
readonly lg: 1024;
|
|
14
|
+
readonly xl: 1280;
|
|
15
|
+
readonly "2xl": 1536;
|
|
16
|
+
};
|
|
17
|
+
/** Bootstrap 5 default breakpoints. */
|
|
18
|
+
declare const breakpointsBootstrapV5: {
|
|
19
|
+
readonly xs: 0;
|
|
20
|
+
readonly sm: 576;
|
|
21
|
+
readonly md: 768;
|
|
22
|
+
readonly lg: 992;
|
|
23
|
+
readonly xl: 1200;
|
|
24
|
+
readonly xxl: 1400;
|
|
25
|
+
};
|
|
26
|
+
/** Names reserved for the helper methods returned by {@link useBreakpoints}. */
|
|
27
|
+
type ReservedBreakpointName = "greaterOrEqual" | "greater" | "smaller" | "smallerOrEqual" | "between" | "current" | "active";
|
|
28
|
+
/** Options for {@link useBreakpoints}. */
|
|
29
|
+
interface UseBreakpointsOptions extends Omit<UseMediaQueryOptions, "ssrValue"> {
|
|
30
|
+
/**
|
|
31
|
+
* Viewport width assumed during server rendering (and whenever no media
|
|
32
|
+
* capability exists). Queries are evaluated against it arithmetically, so
|
|
33
|
+
* the server output matches a client of that width.
|
|
34
|
+
*
|
|
35
|
+
* @default undefined (every query is `false` on the server)
|
|
36
|
+
*/
|
|
37
|
+
readonly ssrWidth?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Root font size used to convert `rem`/`em` values for `ssrWidth`.
|
|
40
|
+
*
|
|
41
|
+
* @default 16
|
|
42
|
+
*/
|
|
43
|
+
readonly rootFontSize?: number;
|
|
44
|
+
}
|
|
45
|
+
/** Reactive breakpoint helpers returned by {@link useBreakpoints}. */
|
|
46
|
+
type BreakpointsControls<Name extends string> = {
|
|
47
|
+
/** `true` when the viewport is at least this breakpoint (mobile-first). */
|
|
48
|
+
readonly [Key in Name]: Readonly<Ref<boolean>> } & {
|
|
49
|
+
/** Viewport width ≥ breakpoint. */readonly greaterOrEqual: (name: Name) => Readonly<Ref<boolean>>; /** Viewport width > breakpoint. */
|
|
50
|
+
readonly greater: (name: Name) => Readonly<Ref<boolean>>; /** Viewport width < breakpoint. */
|
|
51
|
+
readonly smaller: (name: Name) => Readonly<Ref<boolean>>; /** Viewport width ≤ breakpoint. */
|
|
52
|
+
readonly smallerOrEqual: (name: Name) => Readonly<Ref<boolean>>; /** `lower` ≤ width < `upper`. */
|
|
53
|
+
readonly between: (lower: Name, upper: Name) => ComputedRef<boolean>; /** Every breakpoint currently matched (mobile-first), in ascending order. */
|
|
54
|
+
readonly current: ComputedRef<readonly Name[]>; /** Largest matched breakpoint, or `null` below the smallest one. */
|
|
55
|
+
readonly active: ComputedRef<Name | null>;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Reactive, typed breakpoint helpers built on media queries.
|
|
59
|
+
*
|
|
60
|
+
* Breakpoint names are inferred from the map, so typos are compile errors.
|
|
61
|
+
* `greater` and `smaller` use fractional offsets (`width > 767.98px`) so
|
|
62
|
+
* adjacent breakpoints never overlap. With `ssrWidth`, the server evaluates
|
|
63
|
+
* each query arithmetically for deterministic, hydration-stable output.
|
|
64
|
+
* Subscriptions are released with the owning reactive scope.
|
|
65
|
+
*
|
|
66
|
+
* @param breakpoints Named breakpoint map, e.g. {@link breakpointsTailwind}.
|
|
67
|
+
* @param options SSR width, font size, and media capability.
|
|
68
|
+
* @default options {}
|
|
69
|
+
* @returns Per-breakpoint refs plus comparison helpers.
|
|
70
|
+
*/
|
|
71
|
+
declare function useBreakpoints<const Name extends string>(breakpoints: Breakpoints<Name> & { readonly [Reserved in ReservedBreakpointName]?: never }, options?: UseBreakpointsOptions): BreakpointsControls<Name>;
|
|
72
|
+
/**
|
|
73
|
+
* Convert a {@link BreakpointValue} to CSS pixels.
|
|
74
|
+
*
|
|
75
|
+
* @param value Number of pixels or a `px`/`rem`/`em` length.
|
|
76
|
+
* @param rootFontSize Pixels per `rem`/`em`.
|
|
77
|
+
* @default rootFontSize 16
|
|
78
|
+
* @returns Width in CSS pixels.
|
|
79
|
+
*/
|
|
80
|
+
declare function toPixels(value: BreakpointValue, rootFontSize?: number): number;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { BreakpointValue, Breakpoints, BreakpointsControls, ReservedBreakpointName, UseBreakpointsOptions, breakpointsBootstrapV5, breakpointsTailwind, toPixels, useBreakpoints };
|