@vizejs/composable 0.426.3 → 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,200 @@
|
|
|
1
|
+
import { hasInjectionContext, isRef, onMounted, readonly, ref, toValue, watch } from "vue";
|
|
2
|
+
import type { MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
import { tryOnScopeDispose } from "./scope.ts";
|
|
5
|
+
|
|
6
|
+
/** `<style>` subset used by {@link useStyleTag}. */
|
|
7
|
+
export interface StyleTagElement {
|
|
8
|
+
/** Style sheet text. */
|
|
9
|
+
textContent: string | null;
|
|
10
|
+
|
|
11
|
+
/** Write an attribute. */
|
|
12
|
+
setAttribute(name: string, value: string): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Document capability used by {@link useStyleTag}. */
|
|
16
|
+
export interface StyleTagHost {
|
|
17
|
+
/** Find an existing `<style>` with the given `id`. */
|
|
18
|
+
findStyle(id: string): StyleTagElement | undefined;
|
|
19
|
+
|
|
20
|
+
/** Create a detached `<style>`. */
|
|
21
|
+
createStyle(): StyleTagElement;
|
|
22
|
+
|
|
23
|
+
/** Attach a style element to `<head>`. */
|
|
24
|
+
append(element: StyleTagElement): void;
|
|
25
|
+
|
|
26
|
+
/** Detach a style element. */
|
|
27
|
+
remove(element: StyleTagElement): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Options for {@link useStyleTag}. */
|
|
31
|
+
export interface UseStyleTagOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Element `id`. Instances sharing an id share one element (last write
|
|
34
|
+
* wins, first unload removes it), so give every independent style sheet
|
|
35
|
+
* its own stable id. The default is a constant rather than a generated
|
|
36
|
+
* counter because generated ids differ between server and client.
|
|
37
|
+
*
|
|
38
|
+
* @default "vize-style"
|
|
39
|
+
*/
|
|
40
|
+
readonly id?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* `media` attribute.
|
|
44
|
+
*
|
|
45
|
+
* @default undefined
|
|
46
|
+
*/
|
|
47
|
+
readonly media?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* CSP nonce.
|
|
51
|
+
*
|
|
52
|
+
* @default undefined
|
|
53
|
+
*/
|
|
54
|
+
readonly nonce?: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Attach the style element when created.
|
|
58
|
+
*
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
readonly immediate?: boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Document capability for alternate runtimes and tests.
|
|
65
|
+
*
|
|
66
|
+
* @default window.document's `<head>`
|
|
67
|
+
*/
|
|
68
|
+
readonly host?: MaybeRefOrGetter<StyleTagHost | null | undefined>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Reactive state and actions returned by {@link useStyleTag}. */
|
|
72
|
+
export interface StyleTagControls {
|
|
73
|
+
/** Element id in use. */
|
|
74
|
+
readonly id: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Style sheet text. Writable; when a getter was passed, the next getter
|
|
78
|
+
* change overwrites manual assignments.
|
|
79
|
+
*/
|
|
80
|
+
readonly css: Ref<string>;
|
|
81
|
+
|
|
82
|
+
/** Whether the style element is attached. */
|
|
83
|
+
readonly loaded: Readonly<Ref<boolean>>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Attach (or adopt an existing element with the same id) and apply `css`.
|
|
87
|
+
*
|
|
88
|
+
* @returns Whether a style element is attached afterwards.
|
|
89
|
+
*/
|
|
90
|
+
readonly load: () => boolean;
|
|
91
|
+
|
|
92
|
+
/** Remove the style element. */
|
|
93
|
+
readonly unload: () => void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function browserStyleHost(): StyleTagHost | undefined {
|
|
97
|
+
if (typeof window === "undefined") return undefined;
|
|
98
|
+
const { document, HTMLStyleElement } = window;
|
|
99
|
+
return {
|
|
100
|
+
findStyle: (id) => {
|
|
101
|
+
const found = document.getElementById(id);
|
|
102
|
+
return found instanceof HTMLStyleElement ? found : undefined;
|
|
103
|
+
},
|
|
104
|
+
createStyle: () => document.createElement("style"),
|
|
105
|
+
append: (element) => {
|
|
106
|
+
if (element instanceof HTMLStyleElement) document.head.append(element);
|
|
107
|
+
},
|
|
108
|
+
remove: (element) => {
|
|
109
|
+
if (element instanceof HTMLStyleElement) element.remove();
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Inject a reactive `<style>` element.
|
|
116
|
+
*
|
|
117
|
+
* The element's text follows `css`. An existing `<style>` with the same
|
|
118
|
+
* id — for example one emitted in server-rendered HTML — is adopted instead
|
|
119
|
+
* of duplicated, which keeps hydration free of flashes. The element is
|
|
120
|
+
* removed when the owning reactive scope stops or `unload` is called.
|
|
121
|
+
*
|
|
122
|
+
* Server rendering: nothing is injected and `loaded` is false. Emit the
|
|
123
|
+
* server-side `<style id>` through the application's head manager using the
|
|
124
|
+
* same id to make the client adopt it.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const { css } = useStyleTag(() => `:root { --accent: ${accent.value} }`, { id: "theme" });
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @param css Reactive style sheet text.
|
|
132
|
+
* @param options Id, attributes, timing, and capability.
|
|
133
|
+
* @default options {}
|
|
134
|
+
* @returns Style state and actions.
|
|
135
|
+
*/
|
|
136
|
+
export function useStyleTag(
|
|
137
|
+
css: MaybeRefOrGetter<string>,
|
|
138
|
+
options: UseStyleTagOptions = {},
|
|
139
|
+
): StyleTagControls {
|
|
140
|
+
const id = options.id ?? "vize-style";
|
|
141
|
+
const state: Ref<string> = isRef(css) ? css : ref(toValue(css));
|
|
142
|
+
const loaded = ref(false);
|
|
143
|
+
let element: StyleTagElement | undefined;
|
|
144
|
+
|
|
145
|
+
const resolveHost = (): StyleTagHost | undefined =>
|
|
146
|
+
options.host === undefined ? browserStyleHost() : (toValue(options.host) ?? undefined);
|
|
147
|
+
|
|
148
|
+
if (typeof css === "function") {
|
|
149
|
+
watch(css, (next) => {
|
|
150
|
+
state.value = next;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const load = (): boolean => {
|
|
155
|
+
if (element) return true;
|
|
156
|
+
const host = resolveHost();
|
|
157
|
+
if (!host) return false;
|
|
158
|
+
const existing = host.findStyle(id);
|
|
159
|
+
const target = existing ?? host.createStyle();
|
|
160
|
+
if (!existing) {
|
|
161
|
+
target.setAttribute("id", id);
|
|
162
|
+
if (options.media !== undefined) target.setAttribute("media", options.media);
|
|
163
|
+
if (options.nonce !== undefined) target.setAttribute("nonce", options.nonce);
|
|
164
|
+
}
|
|
165
|
+
if (target.textContent !== state.value) target.textContent = state.value;
|
|
166
|
+
if (!existing) host.append(target);
|
|
167
|
+
element = target;
|
|
168
|
+
loaded.value = true;
|
|
169
|
+
return true;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const unload = (): void => {
|
|
173
|
+
if (element) resolveHost()?.remove(element);
|
|
174
|
+
element = undefined;
|
|
175
|
+
loaded.value = false;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
watch(
|
|
179
|
+
state,
|
|
180
|
+
(next) => {
|
|
181
|
+
if (element && element.textContent !== next) element.textContent = next;
|
|
182
|
+
},
|
|
183
|
+
{ flush: "sync" },
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
if (options.immediate ?? true) {
|
|
187
|
+
// Inside a component the tag is attached after mounting, so a hydrating
|
|
188
|
+
// client renders `loaded: false` exactly like the server did.
|
|
189
|
+
if (hasInjectionContext()) {
|
|
190
|
+
onMounted(() => {
|
|
191
|
+
load();
|
|
192
|
+
});
|
|
193
|
+
} else {
|
|
194
|
+
load();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
tryOnScopeDispose(unload);
|
|
198
|
+
|
|
199
|
+
return { id, css: state, loaded: readonly(loaded), load, unload };
|
|
200
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { computed, hasInjectionContext, shallowRef } from "vue";
|
|
2
|
+
import type { ComputedRef } from "vue";
|
|
3
|
+
|
|
4
|
+
import { useMounted } from "./use-mounted.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hydration-stable feature detection.
|
|
8
|
+
*
|
|
9
|
+
* Inside a component the result is `false` until the component mounts and
|
|
10
|
+
* then reflects `check()`, so server and hydrating client render the same
|
|
11
|
+
* fallback first. Outside a component it is evaluated right away when a
|
|
12
|
+
* browser `window` exists and stays `false` otherwise. `check` may read
|
|
13
|
+
* reactive state; the result recomputes when it changes.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const isSupported = useSupported(() => "share" in navigator);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param check Returns a truthy value when the feature is available.
|
|
21
|
+
* @returns Computed support flag.
|
|
22
|
+
*/
|
|
23
|
+
export function useSupported(check: () => unknown): ComputedRef<boolean> {
|
|
24
|
+
const ready = hasInjectionContext() ? useMounted() : shallowRef(typeof window !== "undefined");
|
|
25
|
+
return computed(() => ready.value && Boolean(check()));
|
|
26
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { shallowRef, toValue, watch } from "vue";
|
|
2
|
+
import type { MaybeRefOrGetter, ShallowRef } from "vue";
|
|
3
|
+
|
|
4
|
+
import { tryOnScopeDispose } from "./scope.ts";
|
|
5
|
+
import type { TimeoutScheduler } from "./timeout-scheduler.ts";
|
|
6
|
+
|
|
7
|
+
/** Options for {@link useThrottled}. */
|
|
8
|
+
export interface UseThrottledOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Apply the first change of a cooldown window immediately.
|
|
11
|
+
*
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
readonly leading?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Apply the newest change collected during a cooldown window when the
|
|
18
|
+
* window ends. When disabled, changes inside a window are dropped.
|
|
19
|
+
*
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
readonly trailing?: boolean;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Applies the timing policy when no browser `window` is available.
|
|
26
|
+
*
|
|
27
|
+
* Keep this disabled during server rendering, where the throttled view
|
|
28
|
+
* mirrors the source synchronously instead of starting timers. Enable it
|
|
29
|
+
* for native, desktop, worker, and test runtimes whose scheduler is
|
|
30
|
+
* lifecycle-bound.
|
|
31
|
+
*
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
readonly runOnServer?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Owns the single-shot cooldown timer.
|
|
38
|
+
*
|
|
39
|
+
* @default globalThis timer functions
|
|
40
|
+
*/
|
|
41
|
+
readonly scheduler?: TimeoutScheduler;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Reactive throttled view and controls returned by {@link useThrottled}. */
|
|
45
|
+
export interface ThrottledControls<Value> {
|
|
46
|
+
/** Readonly view of the source updated at most once per cooldown window. */
|
|
47
|
+
readonly throttled: Readonly<ShallowRef<Value>>;
|
|
48
|
+
|
|
49
|
+
/** Whether a trailing update is waiting for the current window to end. */
|
|
50
|
+
readonly pending: Readonly<ShallowRef<boolean>>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Discard the waiting trailing update and close the cooldown window, so
|
|
54
|
+
* the next change starts fresh on a leading edge.
|
|
55
|
+
*
|
|
56
|
+
* @returns Whether a waiting trailing update was discarded.
|
|
57
|
+
*/
|
|
58
|
+
readonly cancel: () => boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Apply the waiting trailing update immediately and close the cooldown
|
|
62
|
+
* window. Without a waiting update the window is left untouched.
|
|
63
|
+
*
|
|
64
|
+
* @returns Whether a waiting trailing update was applied.
|
|
65
|
+
*/
|
|
66
|
+
readonly flush: () => boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const defaultScheduler: TimeoutScheduler = {
|
|
70
|
+
setTimeout: (callback, delayMs) => globalThis.setTimeout(callback, delayMs),
|
|
71
|
+
clearTimeout: (handle) => {
|
|
72
|
+
globalThis.clearTimeout(handle as ReturnType<typeof setTimeout>);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Create a readonly throttled view of a reactive source.
|
|
78
|
+
*
|
|
79
|
+
* Changes are observed with `flush: "sync"`, so every synchronous write
|
|
80
|
+
* counts. Outside a cooldown window, a change applies immediately when
|
|
81
|
+
* {@link UseThrottledOptions.leading} is enabled (otherwise it waits as a
|
|
82
|
+
* trailing update) and opens a window of `waitMs` milliseconds. Changes
|
|
83
|
+
* inside a window are collected as the trailing candidate; when the window
|
|
84
|
+
* ends with a candidate waiting, the source value current at that moment is
|
|
85
|
+
* applied and the next window opens back to back, keeping applications
|
|
86
|
+
* spaced by `waitMs`. A window that ends without a candidate closes silently.
|
|
87
|
+
* `waitMs` is reactive and is read each time a window opens; changing it
|
|
88
|
+
* never disturbs an already-open window. A wait of `0` still defers trailing
|
|
89
|
+
* updates to the next scheduler tick.
|
|
90
|
+
*
|
|
91
|
+
* Server rendering is explicit: without a browser `window` (and with
|
|
92
|
+
* {@link UseThrottledOptions.runOnServer} disabled) no timer ever starts and
|
|
93
|
+
* the view mirrors the source synchronously, so server-rendered output shows
|
|
94
|
+
* current values and nothing leaks. `pending` stays `false` and the controls
|
|
95
|
+
* report `false` in that mode.
|
|
96
|
+
*
|
|
97
|
+
* Cleanup rule: the watcher and any open window timer are released when the
|
|
98
|
+
* owning reactive scope stops; call inside an active scope. Outside one, the
|
|
99
|
+
* watcher lives as long as the source and `cancel()` only clears the window.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const scrollY = shallowRef(0);
|
|
104
|
+
* const { throttled } = useThrottled(scrollY, 100);
|
|
105
|
+
* scrollY.value = 40; // applied immediately (leading edge)
|
|
106
|
+
* scrollY.value = 80; // applied when the 100ms window ends
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @param source Reactive source to throttle.
|
|
110
|
+
* @param waitMs Reactive cooldown in milliseconds; must be finite and at
|
|
111
|
+
* least zero. Fractions are truncated.
|
|
112
|
+
* @param options Edge policy and runtime scheduling overrides.
|
|
113
|
+
* @default options {}
|
|
114
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_THROTTLE_INVALID_WAIT` when the
|
|
115
|
+
* resolved wait is not finite or is negative, both synchronously at creation
|
|
116
|
+
* (even in mirror mode) and again each time a window opens.
|
|
117
|
+
* @throws `TypeError` tagged `VIZE_COMPOSE_THROTTLE_INVALID_EDGES` when both
|
|
118
|
+
* `leading` and `trailing` are disabled, because updates could then never
|
|
119
|
+
* propagate.
|
|
120
|
+
* @returns Readonly throttled view, pending flag, and cancel/flush controls.
|
|
121
|
+
*/
|
|
122
|
+
export function useThrottled<Value>(
|
|
123
|
+
source: MaybeRefOrGetter<Value>,
|
|
124
|
+
waitMs: MaybeRefOrGetter<number>,
|
|
125
|
+
options: UseThrottledOptions = {},
|
|
126
|
+
): ThrottledControls<Value> {
|
|
127
|
+
const leading = options.leading ?? true;
|
|
128
|
+
const trailing = options.trailing ?? true;
|
|
129
|
+
if (!leading && !trailing) {
|
|
130
|
+
throw new TypeError(
|
|
131
|
+
"[VIZE_COMPOSE_THROTTLE_INVALID_EDGES] at least one of leading or trailing must be enabled",
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
const scheduler = options.scheduler ?? defaultScheduler;
|
|
135
|
+
const throttled = shallowRef(toValue(source));
|
|
136
|
+
const pending = shallowRef(false);
|
|
137
|
+
let windowHandle: unknown;
|
|
138
|
+
let windowOpen = false;
|
|
139
|
+
|
|
140
|
+
// Fail synchronously for invalid initial input, even in mirror mode.
|
|
141
|
+
resolveWaitMs(toValue(waitMs));
|
|
142
|
+
|
|
143
|
+
const openWindow = (): void => {
|
|
144
|
+
windowOpen = true;
|
|
145
|
+
windowHandle = scheduler.setTimeout(
|
|
146
|
+
() => {
|
|
147
|
+
windowHandle = undefined;
|
|
148
|
+
if (!pending.value) {
|
|
149
|
+
windowOpen = false;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
pending.value = false;
|
|
153
|
+
throttled.value = toValue(source);
|
|
154
|
+
openWindow();
|
|
155
|
+
},
|
|
156
|
+
resolveWaitMs(toValue(waitMs)),
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const closeWindow = (): void => {
|
|
161
|
+
if (windowOpen) scheduler.clearTimeout(windowHandle);
|
|
162
|
+
windowHandle = undefined;
|
|
163
|
+
windowOpen = false;
|
|
164
|
+
pending.value = false;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const cancel = (): boolean => {
|
|
168
|
+
const hadTrailing = pending.value;
|
|
169
|
+
closeWindow();
|
|
170
|
+
return hadTrailing;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const flush = (): boolean => {
|
|
174
|
+
if (!pending.value) return false;
|
|
175
|
+
closeWindow();
|
|
176
|
+
throttled.value = toValue(source);
|
|
177
|
+
return true;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
watch(
|
|
181
|
+
() => toValue(source),
|
|
182
|
+
(next) => {
|
|
183
|
+
if (typeof window === "undefined" && !(options.runOnServer ?? false)) {
|
|
184
|
+
throttled.value = next;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (windowOpen) {
|
|
188
|
+
if (trailing) pending.value = true;
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (leading) {
|
|
192
|
+
throttled.value = next;
|
|
193
|
+
} else {
|
|
194
|
+
pending.value = true;
|
|
195
|
+
}
|
|
196
|
+
openWindow();
|
|
197
|
+
},
|
|
198
|
+
{ flush: "sync" },
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
tryOnScopeDispose(() => {
|
|
202
|
+
cancel();
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
return { throttled, pending, cancel, flush };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function resolveWaitMs(value: number): number {
|
|
209
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
210
|
+
throw new RangeError(
|
|
211
|
+
`[VIZE_COMPOSE_THROTTLE_INVALID_WAIT] waitMs must be finite and at least zero; received ${String(value)}`,
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
return Math.trunc(value);
|
|
215
|
+
}
|