@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
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-queue.d.ts
|
|
4
|
+
/** What happens when an item arrives while a bounded queue is full. */
|
|
5
|
+
type QueueOverflowPolicy = "drop-oldest" | "reject";
|
|
6
|
+
/** Options for {@link useQueue}. */
|
|
7
|
+
interface UseQueueOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Maximum number of queued items. A positive integer, or
|
|
10
|
+
* `Number.POSITIVE_INFINITY` for an unbounded queue.
|
|
11
|
+
*
|
|
12
|
+
* @default Number.POSITIVE_INFINITY
|
|
13
|
+
*/
|
|
14
|
+
readonly capacity?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Policy applied when an item arrives at capacity: `"drop-oldest"` evicts
|
|
17
|
+
* the head to make room, `"reject"` refuses the new item.
|
|
18
|
+
*
|
|
19
|
+
* @default "drop-oldest"
|
|
20
|
+
*/
|
|
21
|
+
readonly overflow?: QueueOverflowPolicy;
|
|
22
|
+
}
|
|
23
|
+
/** Reactive first-in, first-out queue returned by {@link useQueue}. */
|
|
24
|
+
interface QueueControls<Item> {
|
|
25
|
+
/** Snapshot of the queued items, head first. Recomputed after every change. */
|
|
26
|
+
readonly items: ComputedRef<readonly Item[]>;
|
|
27
|
+
/** Number of queued items. */
|
|
28
|
+
readonly size: ComputedRef<number>;
|
|
29
|
+
/** Whether the queue holds no items. */
|
|
30
|
+
readonly isEmpty: ComputedRef<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Read the head without removing it. Reactive when read inside an effect.
|
|
33
|
+
*
|
|
34
|
+
* @returns The head item, or `undefined` when empty.
|
|
35
|
+
*/
|
|
36
|
+
readonly peek: () => Item | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Append items at the tail in argument order, applying the overflow policy.
|
|
39
|
+
*
|
|
40
|
+
* @param items Items to append.
|
|
41
|
+
* @returns How many of the given items were accepted.
|
|
42
|
+
*/
|
|
43
|
+
readonly enqueue: (...items: Item[]) => number;
|
|
44
|
+
/**
|
|
45
|
+
* Remove and return the head.
|
|
46
|
+
*
|
|
47
|
+
* @returns The removed item, or `undefined` when empty.
|
|
48
|
+
*/
|
|
49
|
+
readonly dequeue: () => Item | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Remove and return every queued item, head first.
|
|
52
|
+
*
|
|
53
|
+
* @returns The removed items.
|
|
54
|
+
*/
|
|
55
|
+
readonly drain: () => Item[];
|
|
56
|
+
/** Remove every item. */
|
|
57
|
+
readonly clear: () => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create a typed reactive FIFO queue.
|
|
61
|
+
*
|
|
62
|
+
* Dequeueing is amortized O(1): the head advances through a backing buffer
|
|
63
|
+
* that is compacted only after enough slots have been consumed, so large
|
|
64
|
+
* queues never pay for `Array.prototype.shift`. Reactivity is driven by a
|
|
65
|
+
* single version counter; `items`, `size`, `isEmpty`, and `peek` all
|
|
66
|
+
* re-evaluate after each mutation.
|
|
67
|
+
*
|
|
68
|
+
* Purely synchronous state: safe during server rendering (no host globals,
|
|
69
|
+
* no timers) and nothing to dispose.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const jobs = useQueue<string>([], { capacity: 100, overflow: "reject" });
|
|
74
|
+
* jobs.enqueue("a", "b");
|
|
75
|
+
* jobs.dequeue(); // "a"
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @typeParam Item Queued item type, inferred from `initial` when given.
|
|
79
|
+
* @param initial Items enqueued at creation, head first (overflow applies).
|
|
80
|
+
* @param options Capacity and overflow policy.
|
|
81
|
+
* @default initial []
|
|
82
|
+
* @default options {}
|
|
83
|
+
* @throws {RangeError} `[VIZE_COMPOSE_QUEUE_INVALID_CAPACITY]` when `capacity`
|
|
84
|
+
* is not a positive integer or `Infinity`.
|
|
85
|
+
* @returns The reactive queue and its controls.
|
|
86
|
+
*/
|
|
87
|
+
declare function useQueue<Item>(initial?: Iterable<Item>, options?: UseQueueOptions): QueueControls<Item>;
|
|
88
|
+
//#endregion
|
|
89
|
+
export { QueueControls, QueueOverflowPolicy, UseQueueOptions, useQueue };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { computed, shallowRef } from "vue";
|
|
2
|
+
//#region src/use-queue.ts
|
|
3
|
+
/** Compact the backing buffer once this many dequeued slots accumulate. */
|
|
4
|
+
const COMPACT_THRESHOLD = 32;
|
|
5
|
+
function validateCapacity(capacity) {
|
|
6
|
+
if (capacity === Number.POSITIVE_INFINITY) return capacity;
|
|
7
|
+
if (!Number.isSafeInteger(capacity) || capacity < 1) throw new RangeError(`[VIZE_COMPOSE_QUEUE_INVALID_CAPACITY] capacity must be a positive integer or Infinity; received ${String(capacity)}`);
|
|
8
|
+
return capacity;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create a typed reactive FIFO queue.
|
|
12
|
+
*
|
|
13
|
+
* Dequeueing is amortized O(1): the head advances through a backing buffer
|
|
14
|
+
* that is compacted only after enough slots have been consumed, so large
|
|
15
|
+
* queues never pay for `Array.prototype.shift`. Reactivity is driven by a
|
|
16
|
+
* single version counter; `items`, `size`, `isEmpty`, and `peek` all
|
|
17
|
+
* re-evaluate after each mutation.
|
|
18
|
+
*
|
|
19
|
+
* Purely synchronous state: safe during server rendering (no host globals,
|
|
20
|
+
* no timers) and nothing to dispose.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const jobs = useQueue<string>([], { capacity: 100, overflow: "reject" });
|
|
25
|
+
* jobs.enqueue("a", "b");
|
|
26
|
+
* jobs.dequeue(); // "a"
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @typeParam Item Queued item type, inferred from `initial` when given.
|
|
30
|
+
* @param initial Items enqueued at creation, head first (overflow applies).
|
|
31
|
+
* @param options Capacity and overflow policy.
|
|
32
|
+
* @default initial []
|
|
33
|
+
* @default options {}
|
|
34
|
+
* @throws {RangeError} `[VIZE_COMPOSE_QUEUE_INVALID_CAPACITY]` when `capacity`
|
|
35
|
+
* is not a positive integer or `Infinity`.
|
|
36
|
+
* @returns The reactive queue and its controls.
|
|
37
|
+
*/
|
|
38
|
+
function useQueue(initial = [], options = {}) {
|
|
39
|
+
const capacity = validateCapacity(options.capacity ?? Number.POSITIVE_INFINITY);
|
|
40
|
+
const overflow = options.overflow ?? "drop-oldest";
|
|
41
|
+
let buffer = [];
|
|
42
|
+
let head = 0;
|
|
43
|
+
const version = shallowRef(0);
|
|
44
|
+
const touch = () => {
|
|
45
|
+
version.value += 1;
|
|
46
|
+
};
|
|
47
|
+
const length = () => buffer.length - head;
|
|
48
|
+
const compact = () => {
|
|
49
|
+
if (head >= COMPACT_THRESHOLD && head * 2 >= buffer.length) {
|
|
50
|
+
buffer = buffer.slice(head);
|
|
51
|
+
head = 0;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const append = (items) => {
|
|
55
|
+
let accepted = 0;
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
if (length() >= capacity) {
|
|
58
|
+
if (overflow === "reject") continue;
|
|
59
|
+
head += 1;
|
|
60
|
+
}
|
|
61
|
+
buffer.push(item);
|
|
62
|
+
accepted += 1;
|
|
63
|
+
}
|
|
64
|
+
compact();
|
|
65
|
+
return accepted;
|
|
66
|
+
};
|
|
67
|
+
append([...initial]);
|
|
68
|
+
const items = computed(() => {
|
|
69
|
+
version.value;
|
|
70
|
+
return buffer.slice(head);
|
|
71
|
+
});
|
|
72
|
+
const size = computed(() => {
|
|
73
|
+
version.value;
|
|
74
|
+
return length();
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
items,
|
|
78
|
+
size,
|
|
79
|
+
isEmpty: computed(() => size.value === 0),
|
|
80
|
+
peek: () => {
|
|
81
|
+
version.value;
|
|
82
|
+
return length() > 0 ? buffer[head] : void 0;
|
|
83
|
+
},
|
|
84
|
+
enqueue: (...added) => {
|
|
85
|
+
const accepted = append(added);
|
|
86
|
+
if (accepted > 0) touch();
|
|
87
|
+
return accepted;
|
|
88
|
+
},
|
|
89
|
+
dequeue: () => {
|
|
90
|
+
if (length() === 0) return void 0;
|
|
91
|
+
const item = buffer[head];
|
|
92
|
+
head += 1;
|
|
93
|
+
if (head === buffer.length) {
|
|
94
|
+
buffer = [];
|
|
95
|
+
head = 0;
|
|
96
|
+
} else compact();
|
|
97
|
+
touch();
|
|
98
|
+
return item;
|
|
99
|
+
},
|
|
100
|
+
drain: () => {
|
|
101
|
+
const drained = buffer.slice(head);
|
|
102
|
+
buffer = [];
|
|
103
|
+
head = 0;
|
|
104
|
+
if (drained.length > 0) touch();
|
|
105
|
+
return drained;
|
|
106
|
+
},
|
|
107
|
+
clear: () => {
|
|
108
|
+
if (length() === 0) return;
|
|
109
|
+
buffer = [];
|
|
110
|
+
head = 0;
|
|
111
|
+
touch();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { useQueue };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { r as PausableControls } from "./use-interval-BA55gTHT.mjs";
|
|
2
|
+
import { MaybeRefOrGetter } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/use-raf-fn.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Animation-frame host used by {@link useRafFn}.
|
|
7
|
+
*
|
|
8
|
+
* Implement this interface to drive frames from a deterministic test clock,
|
|
9
|
+
* a native display link, or an offscreen renderer.
|
|
10
|
+
*/
|
|
11
|
+
interface FrameScheduler {
|
|
12
|
+
/** Requests one frame callback and returns its opaque cancellation handle. */
|
|
13
|
+
readonly requestAnimationFrame: (callback: (timestamp: number) => void) => unknown;
|
|
14
|
+
/** Cancels a handle previously returned by {@link FrameScheduler.requestAnimationFrame}. */
|
|
15
|
+
readonly cancelAnimationFrame: (handle: unknown) => void;
|
|
16
|
+
}
|
|
17
|
+
/** Timing information passed to every {@link useRafFn} callback. */
|
|
18
|
+
interface RafFrame {
|
|
19
|
+
/** Milliseconds since the previous delivered frame (`0` for the first). */
|
|
20
|
+
readonly delta: number;
|
|
21
|
+
/** High-resolution frame timestamp supplied by the host. */
|
|
22
|
+
readonly timestamp: number;
|
|
23
|
+
}
|
|
24
|
+
/** Options for {@link useRafFn}. */
|
|
25
|
+
interface UseRafFnOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Start the frame loop as soon as the composable is created.
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
readonly immediate?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Maximum callback rate in frames per second. Frames arriving sooner than
|
|
34
|
+
* `1000 / fpsLimit` ms after the last delivered frame are skipped.
|
|
35
|
+
* `undefined` delivers every frame. Reactive.
|
|
36
|
+
*
|
|
37
|
+
* @default undefined
|
|
38
|
+
*/
|
|
39
|
+
readonly fpsLimit?: MaybeRefOrGetter<number | undefined>;
|
|
40
|
+
/**
|
|
41
|
+
* Deliver a single frame and then pause.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
readonly once?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Requests frames when no browser `window` is available, for example from
|
|
48
|
+
* a native or offscreen frame host passed as `scheduler`.
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
readonly runOnServer?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Frame host. When omitted, `globalThis.requestAnimationFrame` is used if
|
|
55
|
+
* it exists; without one (server rendering, workers without frames) the
|
|
56
|
+
* loop only tracks its requested state.
|
|
57
|
+
*
|
|
58
|
+
* @default globalThis animation-frame functions when available
|
|
59
|
+
*/
|
|
60
|
+
readonly scheduler?: FrameScheduler;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Run a callback on every animation frame, with pause/resume controls and an
|
|
64
|
+
* optional frame-rate cap.
|
|
65
|
+
*
|
|
66
|
+
* The host is resolved lazily on `resume()`, so importing and calling this
|
|
67
|
+
* during server rendering is safe: without a browser `window` (and without
|
|
68
|
+
* {@link UseRafFnOptions.runOnServer}), or without any frame host,
|
|
69
|
+
* `isActive` reports the requested state and no callbacks run, matching the
|
|
70
|
+
* client's initial render. The pending frame is cancelled when the owning reactive scope
|
|
71
|
+
* stops.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const { pause } = useRafFn(({ delta }) => step(delta), { fpsLimit: 30 });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @param callback Invoked with frame timing for every delivered frame.
|
|
79
|
+
* @param options Start, rate-limit, and host policy.
|
|
80
|
+
* @default options {}
|
|
81
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_RAF_INVALID_FPS_LIMIT` when a
|
|
82
|
+
* resolved `fpsLimit` is not finite and greater than zero.
|
|
83
|
+
* @returns Pause/resume controls.
|
|
84
|
+
*/
|
|
85
|
+
declare function useRafFn(callback: (frame: RafFrame) => void, options?: UseRafFnOptions): PausableControls;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { FrameScheduler, RafFrame, UseRafFnOptions, useRafFn };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { shallowRef, toValue } from "vue";
|
|
3
|
+
//#region src/use-raf-fn.ts
|
|
4
|
+
function resolveHost(scheduler) {
|
|
5
|
+
if (scheduler !== void 0) return scheduler;
|
|
6
|
+
if (typeof globalThis.requestAnimationFrame !== "function") return void 0;
|
|
7
|
+
return {
|
|
8
|
+
requestAnimationFrame: (callback) => globalThis.requestAnimationFrame(callback),
|
|
9
|
+
cancelAnimationFrame: (handle) => {
|
|
10
|
+
globalThis.cancelAnimationFrame(handle);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Run a callback on every animation frame, with pause/resume controls and an
|
|
16
|
+
* optional frame-rate cap.
|
|
17
|
+
*
|
|
18
|
+
* The host is resolved lazily on `resume()`, so importing and calling this
|
|
19
|
+
* during server rendering is safe: without a browser `window` (and without
|
|
20
|
+
* {@link UseRafFnOptions.runOnServer}), or without any frame host,
|
|
21
|
+
* `isActive` reports the requested state and no callbacks run, matching the
|
|
22
|
+
* client's initial render. The pending frame is cancelled when the owning reactive scope
|
|
23
|
+
* stops.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const { pause } = useRafFn(({ delta }) => step(delta), { fpsLimit: 30 });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param callback Invoked with frame timing for every delivered frame.
|
|
31
|
+
* @param options Start, rate-limit, and host policy.
|
|
32
|
+
* @default options {}
|
|
33
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_RAF_INVALID_FPS_LIMIT` when a
|
|
34
|
+
* resolved `fpsLimit` is not finite and greater than zero.
|
|
35
|
+
* @returns Pause/resume controls.
|
|
36
|
+
*/
|
|
37
|
+
function useRafFn(callback, options = {}) {
|
|
38
|
+
const isActive = shallowRef(false);
|
|
39
|
+
let host;
|
|
40
|
+
let handle;
|
|
41
|
+
let requested = false;
|
|
42
|
+
let previous;
|
|
43
|
+
const readInterval = () => {
|
|
44
|
+
const limit = toValue(options.fpsLimit);
|
|
45
|
+
if (limit === void 0) return 0;
|
|
46
|
+
if (!Number.isFinite(limit) || limit <= 0) throw new RangeError(`[VIZE_COMPOSE_RAF_INVALID_FPS_LIMIT] fpsLimit must be finite and greater than zero; received ${String(limit)}`);
|
|
47
|
+
return 1e3 / limit;
|
|
48
|
+
};
|
|
49
|
+
readInterval();
|
|
50
|
+
const request = () => {
|
|
51
|
+
if (host === void 0) return;
|
|
52
|
+
requested = true;
|
|
53
|
+
handle = host.requestAnimationFrame(loop);
|
|
54
|
+
};
|
|
55
|
+
function loop(timestamp) {
|
|
56
|
+
requested = false;
|
|
57
|
+
if (!isActive.value) return;
|
|
58
|
+
previous ??= timestamp;
|
|
59
|
+
const delta = timestamp - previous;
|
|
60
|
+
const interval = readInterval();
|
|
61
|
+
if (interval > 0 && delta > 0 && delta < interval) {
|
|
62
|
+
request();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
previous = timestamp;
|
|
66
|
+
callback({
|
|
67
|
+
delta,
|
|
68
|
+
timestamp
|
|
69
|
+
});
|
|
70
|
+
if (options.once ?? false) {
|
|
71
|
+
pause();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
request();
|
|
75
|
+
}
|
|
76
|
+
const pause = () => {
|
|
77
|
+
isActive.value = false;
|
|
78
|
+
if (requested && host !== void 0) host.cancelAnimationFrame(handle);
|
|
79
|
+
requested = false;
|
|
80
|
+
handle = void 0;
|
|
81
|
+
};
|
|
82
|
+
const resume = () => {
|
|
83
|
+
if (isActive.value) return;
|
|
84
|
+
isActive.value = true;
|
|
85
|
+
previous = void 0;
|
|
86
|
+
if (typeof window === "undefined" && !(options.runOnServer ?? false)) return;
|
|
87
|
+
host ??= resolveHost(options.scheduler);
|
|
88
|
+
request();
|
|
89
|
+
};
|
|
90
|
+
if (options.immediate ?? true) resume();
|
|
91
|
+
tryOnScopeDispose(pause);
|
|
92
|
+
return {
|
|
93
|
+
isActive,
|
|
94
|
+
pause,
|
|
95
|
+
resume
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { useRafFn };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-relative-time-format.d.ts
|
|
4
|
+
/** Units selected by {@link selectRelativeTimeUnit}. */
|
|
5
|
+
type RelativeTimeUnitSelection = "second" | "minute" | "hour" | "day" | "week" | "month" | "year";
|
|
6
|
+
/** A signed amount in one relative-time unit. */
|
|
7
|
+
interface RelativeTimeValue {
|
|
8
|
+
/** Signed, rounded amount; negative values are in the past. */
|
|
9
|
+
readonly value: number;
|
|
10
|
+
/** Unit the amount is expressed in. */
|
|
11
|
+
readonly unit: RelativeTimeUnitSelection;
|
|
12
|
+
}
|
|
13
|
+
/** Options for {@link useRelativeTimeFormat}. */
|
|
14
|
+
interface UseRelativeTimeFormatOptions extends Intl.RelativeTimeFormatOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Locale used for formatting. Pass it explicitly for hydration-stable
|
|
17
|
+
* server rendering.
|
|
18
|
+
*
|
|
19
|
+
* @default the browser language, otherwise "en"
|
|
20
|
+
*/
|
|
21
|
+
readonly locale?: string | Intl.Locale;
|
|
22
|
+
}
|
|
23
|
+
/** Options for {@link RelativeTimeFormatControls.formatFrom}. */
|
|
24
|
+
interface RelativeTimeFromOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Reference time in Unix milliseconds. Pass it explicitly to keep server
|
|
27
|
+
* and client output identical.
|
|
28
|
+
*
|
|
29
|
+
* @default Date.now()
|
|
30
|
+
*/
|
|
31
|
+
readonly now?: number;
|
|
32
|
+
}
|
|
33
|
+
/** Reactive relative-time formatting returned by {@link useRelativeTimeFormat}. */
|
|
34
|
+
interface RelativeTimeFormatControls {
|
|
35
|
+
/** Canonical locale in use. */
|
|
36
|
+
readonly locale: ComputedRef<string>;
|
|
37
|
+
/** Cached formatter for the current locale and options. */
|
|
38
|
+
readonly formatter: ComputedRef<Intl.RelativeTimeFormat>;
|
|
39
|
+
/** Formatted `value` in `unit`, or `""` while either is missing. */
|
|
40
|
+
readonly formatted: ComputedRef<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Format an amount in a unit.
|
|
43
|
+
*
|
|
44
|
+
* @param value Signed amount; negative is in the past.
|
|
45
|
+
* @param unit Relative-time unit.
|
|
46
|
+
* @returns The formatted string.
|
|
47
|
+
*/
|
|
48
|
+
readonly format: (value: number, unit: Intl.RelativeTimeFormatUnit) => string;
|
|
49
|
+
/**
|
|
50
|
+
* Format an amount in a unit into parts.
|
|
51
|
+
*
|
|
52
|
+
* @param value Signed amount.
|
|
53
|
+
* @param unit Relative-time unit.
|
|
54
|
+
* @returns The formatted parts.
|
|
55
|
+
*/
|
|
56
|
+
readonly formatToParts: (value: number, unit: Intl.RelativeTimeFormatUnit) => Intl.RelativeTimeFormatPart[];
|
|
57
|
+
/**
|
|
58
|
+
* Format a signed millisecond difference using the best-fitting unit
|
|
59
|
+
* (see {@link selectRelativeTimeUnit}).
|
|
60
|
+
*
|
|
61
|
+
* @param diffMs Signed difference; negative is in the past.
|
|
62
|
+
* @returns The formatted string.
|
|
63
|
+
*/
|
|
64
|
+
readonly formatDiff: (diffMs: number) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Format a date relative to a reference time using the best-fitting unit.
|
|
67
|
+
*
|
|
68
|
+
* @param date Date or Unix milliseconds.
|
|
69
|
+
* @param options Reference time.
|
|
70
|
+
* @default options {}
|
|
71
|
+
* @returns The formatted string.
|
|
72
|
+
*/
|
|
73
|
+
readonly formatFrom: (date: Date | number, options?: RelativeTimeFromOptions) => string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Pick the largest unit that expresses a millisecond difference as a
|
|
77
|
+
* non-zero rounded amount: seconds below a minute, minutes below an hour,
|
|
78
|
+
* hours below a day, days below a week, weeks below a month, months below
|
|
79
|
+
* a year, and years otherwise (Gregorian average month/year lengths).
|
|
80
|
+
*
|
|
81
|
+
* @param diffMs Signed difference; negative is in the past.
|
|
82
|
+
* @returns The rounded amount and its unit.
|
|
83
|
+
* @throws {RangeError} `[VIZE_COMPOSE_RELATIVE_TIME_INVALID_DIFF]` for a
|
|
84
|
+
* non-finite difference.
|
|
85
|
+
*/
|
|
86
|
+
declare function selectRelativeTimeUnit(diffMs: number): RelativeTimeValue;
|
|
87
|
+
/**
|
|
88
|
+
* Format relative times ("in 3 days", "yesterday") with `Intl.RelativeTimeFormat`.
|
|
89
|
+
*
|
|
90
|
+
* A pure formatting wrapper: it owns no clock or timer, so it never
|
|
91
|
+
* re-renders on its own and stays deterministic during server rendering
|
|
92
|
+
* (pair it with a clock composable for live "time ago" labels). The
|
|
93
|
+
* formatter follows the reactive options and is cached per locale and
|
|
94
|
+
* option set through {@link useLocale}; invalid options surface as the
|
|
95
|
+
* platform's `RangeError`.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const { formatted } = useRelativeTimeFormat(-1, "day", { locale: "en", numeric: "auto" });
|
|
100
|
+
* formatted.value; // "yesterday"
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @param value Reactive signed amount; `null`/`undefined` format as `""`.
|
|
104
|
+
* @param unit Reactive unit.
|
|
105
|
+
* @param options Reactive locale and `Intl.RelativeTimeFormat` options.
|
|
106
|
+
* @default options {}
|
|
107
|
+
* @returns Reactive formatted output and formatting helpers.
|
|
108
|
+
*/
|
|
109
|
+
declare function useRelativeTimeFormat(value: MaybeRefOrGetter<number | null | undefined>, unit: MaybeRefOrGetter<Intl.RelativeTimeFormatUnit>, options?: MaybeRefOrGetter<UseRelativeTimeFormatOptions>): RelativeTimeFormatControls;
|
|
110
|
+
//#endregion
|
|
111
|
+
export { RelativeTimeFormatControls, RelativeTimeFromOptions, RelativeTimeUnitSelection, RelativeTimeValue, UseRelativeTimeFormatOptions, selectRelativeTimeUnit, useRelativeTimeFormat };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { useLocale } from "./locale.mjs";
|
|
2
|
+
import { computed, toValue } from "vue";
|
|
3
|
+
//#region src/use-relative-time-format.ts
|
|
4
|
+
const SECOND = 1e3;
|
|
5
|
+
const MINUTE = 6e4;
|
|
6
|
+
const HOUR = 36e5;
|
|
7
|
+
const DAY = 864e5;
|
|
8
|
+
const WEEK = 6048e5;
|
|
9
|
+
/** Gregorian average month: 30.436875 days. */
|
|
10
|
+
const MONTH = 2629746e3;
|
|
11
|
+
/** Gregorian average year: 365.2425 days. */
|
|
12
|
+
const YEAR = 31556952e3;
|
|
13
|
+
const thresholds = [
|
|
14
|
+
[
|
|
15
|
+
MINUTE,
|
|
16
|
+
SECOND,
|
|
17
|
+
"second"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
HOUR,
|
|
21
|
+
MINUTE,
|
|
22
|
+
"minute"
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
DAY,
|
|
26
|
+
HOUR,
|
|
27
|
+
"hour"
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
WEEK,
|
|
31
|
+
DAY,
|
|
32
|
+
"day"
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
MONTH,
|
|
36
|
+
WEEK,
|
|
37
|
+
"week"
|
|
38
|
+
],
|
|
39
|
+
[
|
|
40
|
+
YEAR,
|
|
41
|
+
MONTH,
|
|
42
|
+
"month"
|
|
43
|
+
]
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Pick the largest unit that expresses a millisecond difference as a
|
|
47
|
+
* non-zero rounded amount: seconds below a minute, minutes below an hour,
|
|
48
|
+
* hours below a day, days below a week, weeks below a month, months below
|
|
49
|
+
* a year, and years otherwise (Gregorian average month/year lengths).
|
|
50
|
+
*
|
|
51
|
+
* @param diffMs Signed difference; negative is in the past.
|
|
52
|
+
* @returns The rounded amount and its unit.
|
|
53
|
+
* @throws {RangeError} `[VIZE_COMPOSE_RELATIVE_TIME_INVALID_DIFF]` for a
|
|
54
|
+
* non-finite difference.
|
|
55
|
+
*/
|
|
56
|
+
function selectRelativeTimeUnit(diffMs) {
|
|
57
|
+
if (!Number.isFinite(diffMs)) throw new RangeError(`[VIZE_COMPOSE_RELATIVE_TIME_INVALID_DIFF] the difference must be finite; received ${String(diffMs)}`);
|
|
58
|
+
const magnitude = Math.abs(diffMs);
|
|
59
|
+
for (const [limit, size, unit] of thresholds) if (magnitude < limit) return {
|
|
60
|
+
value: Math.round(diffMs / size) + 0,
|
|
61
|
+
unit
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
value: Math.round(diffMs / YEAR) + 0,
|
|
65
|
+
unit: "year"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function browserLanguage() {
|
|
69
|
+
return typeof window === "undefined" ? void 0 : window.navigator.language;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Format relative times ("in 3 days", "yesterday") with `Intl.RelativeTimeFormat`.
|
|
73
|
+
*
|
|
74
|
+
* A pure formatting wrapper: it owns no clock or timer, so it never
|
|
75
|
+
* re-renders on its own and stays deterministic during server rendering
|
|
76
|
+
* (pair it with a clock composable for live "time ago" labels). The
|
|
77
|
+
* formatter follows the reactive options and is cached per locale and
|
|
78
|
+
* option set through {@link useLocale}; invalid options surface as the
|
|
79
|
+
* platform's `RangeError`.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const { formatted } = useRelativeTimeFormat(-1, "day", { locale: "en", numeric: "auto" });
|
|
84
|
+
* formatted.value; // "yesterday"
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param value Reactive signed amount; `null`/`undefined` format as `""`.
|
|
88
|
+
* @param unit Reactive unit.
|
|
89
|
+
* @param options Reactive locale and `Intl.RelativeTimeFormat` options.
|
|
90
|
+
* @default options {}
|
|
91
|
+
* @returns Reactive formatted output and formatting helpers.
|
|
92
|
+
*/
|
|
93
|
+
function useRelativeTimeFormat(value, unit, options = {}) {
|
|
94
|
+
const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
|
|
95
|
+
const formatter = computed(() => {
|
|
96
|
+
const { locale: _locale, ...formatOptions } = toValue(options);
|
|
97
|
+
return localeControls.relativeTime(formatOptions);
|
|
98
|
+
});
|
|
99
|
+
const formatDiff = (diffMs) => {
|
|
100
|
+
const selected = selectRelativeTimeUnit(diffMs);
|
|
101
|
+
return formatter.value.format(selected.value, selected.unit);
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
locale: localeControls.locale,
|
|
105
|
+
formatter,
|
|
106
|
+
formatted: computed(() => {
|
|
107
|
+
const current = toValue(value);
|
|
108
|
+
return current === null || current === void 0 ? "" : formatter.value.format(current, toValue(unit));
|
|
109
|
+
}),
|
|
110
|
+
format: (amount, amountUnit) => formatter.value.format(amount, amountUnit),
|
|
111
|
+
formatToParts: (amount, amountUnit) => formatter.value.formatToParts(amount, amountUnit),
|
|
112
|
+
formatDiff,
|
|
113
|
+
formatFrom: (date, fromOptions = {}) => {
|
|
114
|
+
return formatDiff((date instanceof Date ? date.getTime() : date) - (fromOptions.now ?? Date.now()));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
export { selectRelativeTimeUnit, useRelativeTimeFormat };
|