@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,102 @@
|
|
|
1
|
+
import { customRef, toValue } from "vue";
|
|
2
|
+
import type { MaybeRefOrGetter, Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
import { tryOnScopeDispose } from "./scope.ts";
|
|
5
|
+
import type { TimeoutScheduler } from "./timeout-scheduler.ts";
|
|
6
|
+
|
|
7
|
+
/** Options for {@link refAutoReset}. */
|
|
8
|
+
export interface RefAutoResetOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Applies the reset timer when no browser `window` is available. When
|
|
11
|
+
* disabled, written values persist on the server (a render is a snapshot).
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
readonly runOnServer?: boolean;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Owns the reset timer.
|
|
19
|
+
*
|
|
20
|
+
* @default globalThis timer functions
|
|
21
|
+
*/
|
|
22
|
+
readonly scheduler?: TimeoutScheduler;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const defaultScheduler: TimeoutScheduler = {
|
|
26
|
+
setTimeout: (callback, delayMs) => globalThis.setTimeout(callback, delayMs),
|
|
27
|
+
clearTimeout: (handle) => {
|
|
28
|
+
globalThis.clearTimeout(handle as ReturnType<typeof setTimeout>);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function resolveResetMs(value: number): number {
|
|
33
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
34
|
+
throw new RangeError(
|
|
35
|
+
`[VIZE_COMPOSE_REF_AUTO_RESET_INVALID_DELAY] afterMs must be finite and at least zero; received ${String(value)}`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return Math.trunc(value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Writable ref that falls back to a default value `afterMs` milliseconds
|
|
43
|
+
* after each write.
|
|
44
|
+
*
|
|
45
|
+
* Typical for transient UI state such as "Copied!" labels. Every write
|
|
46
|
+
* restarts the timer; the default (itself possibly reactive) is read when the
|
|
47
|
+
* reset happens, and the ref reads the current default until the first write.
|
|
48
|
+
* The pending reset is cancelled when the owning reactive scope stops.
|
|
49
|
+
* Without a browser `window` (and without `runOnServer`) no timer starts.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const message = refAutoReset("", 2_000);
|
|
54
|
+
* message.value = "Copied!"; // back to "" after two seconds
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @param defaultValue Reactive value restored after the delay.
|
|
58
|
+
* @param afterMs Reactive delay in milliseconds, finite and at least zero.
|
|
59
|
+
* @param options Server and scheduler policy.
|
|
60
|
+
* @default options {}
|
|
61
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_REF_AUTO_RESET_INVALID_DELAY` for
|
|
62
|
+
* invalid delays, synchronously at creation and on every write.
|
|
63
|
+
* @returns A writable ref.
|
|
64
|
+
*/
|
|
65
|
+
export function refAutoReset<Value>(
|
|
66
|
+
defaultValue: MaybeRefOrGetter<Value>,
|
|
67
|
+
afterMs: MaybeRefOrGetter<number>,
|
|
68
|
+
options: RefAutoResetOptions = {},
|
|
69
|
+
): Ref<Value> {
|
|
70
|
+
const scheduler = options.scheduler ?? defaultScheduler;
|
|
71
|
+
resolveResetMs(toValue(afterMs));
|
|
72
|
+
let handle: unknown;
|
|
73
|
+
let written = false;
|
|
74
|
+
let current = toValue(defaultValue);
|
|
75
|
+
|
|
76
|
+
const cancel = (): void => {
|
|
77
|
+
if (handle !== undefined) scheduler.clearTimeout(handle);
|
|
78
|
+
handle = undefined;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
tryOnScopeDispose(cancel);
|
|
82
|
+
|
|
83
|
+
return customRef<Value>((track, trigger) => ({
|
|
84
|
+
get: () => {
|
|
85
|
+
track();
|
|
86
|
+
return written ? current : toValue(defaultValue);
|
|
87
|
+
},
|
|
88
|
+
set: (next) => {
|
|
89
|
+
const delay = resolveResetMs(toValue(afterMs));
|
|
90
|
+
current = next;
|
|
91
|
+
written = true;
|
|
92
|
+
trigger();
|
|
93
|
+
cancel();
|
|
94
|
+
if (typeof window === "undefined" && !(options.runOnServer ?? false)) return;
|
|
95
|
+
handle = scheduler.setTimeout(() => {
|
|
96
|
+
handle = undefined;
|
|
97
|
+
written = false;
|
|
98
|
+
trigger();
|
|
99
|
+
}, delay);
|
|
100
|
+
},
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, ShallowRef } from "vue";
|
|
2
|
+
|
|
3
|
+
import { useDebounced } from "./use-debounced.ts";
|
|
4
|
+
import type { UseDebouncedOptions } from "./use-debounced.ts";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Readonly ref that follows `source` after it stayed quiet for `waitMs`.
|
|
8
|
+
*
|
|
9
|
+
* Shorthand for `useDebounced(source, waitMs, options).debounced` when the
|
|
10
|
+
* pending flag and cancel/flush controls are not needed. Inherits every rule
|
|
11
|
+
* of {@link useDebounced}: synchronous mirroring on the server, reactive
|
|
12
|
+
* wait, and scope-bound cleanup.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const query = ref("");
|
|
17
|
+
* const debouncedQuery = refDebounced(query, 300);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param source Reactive source.
|
|
21
|
+
* @param waitMs Reactive quiet period in milliseconds.
|
|
22
|
+
* @param options Server and scheduler policy.
|
|
23
|
+
* @default options {}
|
|
24
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_DEBOUNCE_INVALID_WAIT` for invalid
|
|
25
|
+
* waits (see {@link useDebounced}).
|
|
26
|
+
* @returns The debounced readonly ref.
|
|
27
|
+
*/
|
|
28
|
+
export function refDebounced<Value>(
|
|
29
|
+
source: MaybeRefOrGetter<Value>,
|
|
30
|
+
waitMs: MaybeRefOrGetter<number>,
|
|
31
|
+
options: UseDebouncedOptions = {},
|
|
32
|
+
): Readonly<ShallowRef<Value>> {
|
|
33
|
+
return useDebounced(source, waitMs, options).debounced;
|
|
34
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
import type { MaybeRefOrGetter, Ref, WritableComputedRef } from "vue";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* View a nullable ref through a default value.
|
|
6
|
+
*
|
|
7
|
+
* Reads return the source value, or the (possibly reactive) default while the
|
|
8
|
+
* source holds `null` or `undefined`, so the read type drops those members.
|
|
9
|
+
* Writes go straight to the source and accept its full type, including
|
|
10
|
+
* `null`/`undefined` to fall back to the default again. Pure derived state:
|
|
11
|
+
* SSR-safe and nothing to dispose.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const raw = ref<string | undefined>();
|
|
16
|
+
* const name = refDefault(raw, "Anonymous");
|
|
17
|
+
* name.value; // "Anonymous"
|
|
18
|
+
* name.value = "Ada"; // raw.value === "Ada"
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param source Writable nullable ref.
|
|
22
|
+
* @param defaultValue Reactive fallback.
|
|
23
|
+
* @returns A writable computed ref whose reads never yield `null`/`undefined`.
|
|
24
|
+
*/
|
|
25
|
+
export function refDefault<Value>(
|
|
26
|
+
source: Ref<Value>,
|
|
27
|
+
defaultValue: MaybeRefOrGetter<NonNullable<Value>>,
|
|
28
|
+
): WritableComputedRef<NonNullable<Value>, Value> {
|
|
29
|
+
return computed<NonNullable<Value>, Value>({
|
|
30
|
+
get: () => source.value ?? toValue(defaultValue),
|
|
31
|
+
set: (value) => {
|
|
32
|
+
source.value = value;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
hasInjectionContext,
|
|
4
|
+
readonly,
|
|
5
|
+
ref,
|
|
6
|
+
shallowRef,
|
|
7
|
+
toValue,
|
|
8
|
+
watch,
|
|
9
|
+
watchPostEffect,
|
|
10
|
+
} from "vue";
|
|
11
|
+
import type { MaybeRefOrGetter, Ref, WatchHandle } from "vue";
|
|
12
|
+
|
|
13
|
+
import { resolveElement, resolveElements } from "./element-target.ts";
|
|
14
|
+
import type { MaybeElementTarget, MaybeElementTargets } from "./element-target.ts";
|
|
15
|
+
import { tryOnScopeDispose } from "./scope.ts";
|
|
16
|
+
|
|
17
|
+
/** Runtime capability that supplies the `ResizeObserver` constructor. */
|
|
18
|
+
export interface ResizeObserverHost {
|
|
19
|
+
/** `ResizeObserver` constructor, absent in unsupported runtimes. */
|
|
20
|
+
readonly ResizeObserver?: new (callback: ResizeObserverCallback) => ResizeObserver;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Options for {@link useResizeObserver}. */
|
|
24
|
+
export interface UseResizeObserverOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Box model reported by the observer.
|
|
27
|
+
*
|
|
28
|
+
* @default "content-box"
|
|
29
|
+
*/
|
|
30
|
+
readonly box?: ResizeObserverBoxOptions;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reactive constructor capability for alternate runtimes and tests.
|
|
34
|
+
*
|
|
35
|
+
* @default window when it provides `ResizeObserver`
|
|
36
|
+
*/
|
|
37
|
+
readonly host?: MaybeRefOrGetter<ResizeObserverHost | null | undefined>;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Target resolution timing. `"post"` observes template refs after mount.
|
|
41
|
+
*
|
|
42
|
+
* @default "post"
|
|
43
|
+
*/
|
|
44
|
+
readonly flush?: "pre" | "post" | "sync";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Controls returned by {@link useResizeObserver}. */
|
|
48
|
+
export interface ResizeObserverControls {
|
|
49
|
+
/** Whether the host provides `ResizeObserver`. `false` during server rendering. */
|
|
50
|
+
readonly isSupported: Readonly<Ref<boolean>>;
|
|
51
|
+
|
|
52
|
+
/** Disconnect the observer and stop following the reactive targets. Idempotent. */
|
|
53
|
+
readonly stop: () => void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Observe size changes of one or more reactive elements.
|
|
58
|
+
*
|
|
59
|
+
* A single observer is (re)created whenever the resolved targets, the box
|
|
60
|
+
* option, or the host change; unresolved targets are skipped. The observer is
|
|
61
|
+
* disconnected when the owning reactive scope stops or `stop` is called.
|
|
62
|
+
* During server rendering no host resolves, `isSupported` stays `false`, and
|
|
63
|
+
* the callback never runs.
|
|
64
|
+
*
|
|
65
|
+
* Inside a component the host is read after mounting, so hydration renders
|
|
66
|
+
* the server fallback first and never mismatches.
|
|
67
|
+
*
|
|
68
|
+
* @param targets Reactive element target or list of targets.
|
|
69
|
+
* @param callback Native `ResizeObserver` callback.
|
|
70
|
+
* @param options Box model, runtime capability, and watcher timing.
|
|
71
|
+
* @default options {}
|
|
72
|
+
* @returns Support flag and stop control.
|
|
73
|
+
*/
|
|
74
|
+
export function useResizeObserver(
|
|
75
|
+
targets: MaybeElementTargets,
|
|
76
|
+
callback: ResizeObserverCallback,
|
|
77
|
+
options: UseResizeObserverOptions = {},
|
|
78
|
+
): ResizeObserverControls {
|
|
79
|
+
const isSupported = ref(false);
|
|
80
|
+
// Inside a component the host is attached by a post-flush job (after the
|
|
81
|
+
// component mounted), so a hydrating client first renders the same server
|
|
82
|
+
// fallback. Outside components it is attached synchronously.
|
|
83
|
+
const hydrated = shallowRef(!hasInjectionContext());
|
|
84
|
+
if (!hydrated.value) {
|
|
85
|
+
watchPostEffect(() => {
|
|
86
|
+
hydrated.value = true;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
let stopWatch: WatchHandle | undefined = watch(
|
|
90
|
+
() =>
|
|
91
|
+
[
|
|
92
|
+
hydrated.value
|
|
93
|
+
? options.host === undefined
|
|
94
|
+
? browserResizeObserverHost()
|
|
95
|
+
: toValue(options.host)
|
|
96
|
+
: undefined,
|
|
97
|
+
resolveElements(targets),
|
|
98
|
+
] as const,
|
|
99
|
+
([host, elements], _previous, onCleanup) => {
|
|
100
|
+
const Observer = host?.ResizeObserver;
|
|
101
|
+
isSupported.value = Observer !== undefined;
|
|
102
|
+
if (!Observer || elements.length === 0) return;
|
|
103
|
+
const observer = new Observer(callback);
|
|
104
|
+
const observeOptions: ResizeObserverOptions = { box: options.box ?? "content-box" };
|
|
105
|
+
for (const element of elements) observer.observe(element, observeOptions);
|
|
106
|
+
onCleanup(() => observer.disconnect());
|
|
107
|
+
},
|
|
108
|
+
{ immediate: true, flush: options.flush ?? "post" },
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const stop = (): void => {
|
|
112
|
+
stopWatch?.stop();
|
|
113
|
+
stopWatch = undefined;
|
|
114
|
+
};
|
|
115
|
+
tryOnScopeDispose(stop);
|
|
116
|
+
return { isSupported: readonly(isSupported), stop };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Element dimensions reported by {@link useElementSize}. */
|
|
120
|
+
export interface ElementSize {
|
|
121
|
+
/** Inline size in CSS pixels. */
|
|
122
|
+
readonly width: number;
|
|
123
|
+
/** Block size in CSS pixels. */
|
|
124
|
+
readonly height: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Options for {@link useElementSize}. */
|
|
128
|
+
export interface UseElementSizeOptions extends UseResizeObserverOptions {
|
|
129
|
+
/**
|
|
130
|
+
* Size exposed before the first observation and during server rendering.
|
|
131
|
+
* Keep it identical on server and client to avoid hydration mismatches.
|
|
132
|
+
*
|
|
133
|
+
* @default { width: 0, height: 0 }
|
|
134
|
+
*/
|
|
135
|
+
readonly initialSize?: ElementSize;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** Reactive size returned by {@link useElementSize}. */
|
|
139
|
+
export interface ElementSizeControls extends ResizeObserverControls {
|
|
140
|
+
/** Observed inline size in CSS pixels. */
|
|
141
|
+
readonly width: Readonly<Ref<number>>;
|
|
142
|
+
/** Observed block size in CSS pixels. */
|
|
143
|
+
readonly height: Readonly<Ref<number>>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Track the rendered size of a reactive element.
|
|
148
|
+
*
|
|
149
|
+
* Reads the requested box from `contentBoxSize`/`borderBoxSize` (summing
|
|
150
|
+
* fragments) and falls back to `contentRect` for older engines. When the
|
|
151
|
+
* target unmounts the size resets to the initial value so stale geometry never
|
|
152
|
+
* leaks into the next render. Server renders expose `initialSize`.
|
|
153
|
+
*
|
|
154
|
+
* @param target Reactive element target.
|
|
155
|
+
* @param options Initial size, box model, capability, and watcher timing.
|
|
156
|
+
* @default options {}
|
|
157
|
+
* @returns Reactive width/height plus observer controls.
|
|
158
|
+
*/
|
|
159
|
+
export function useElementSize(
|
|
160
|
+
target: MaybeElementTarget,
|
|
161
|
+
options: UseElementSizeOptions = {},
|
|
162
|
+
): ElementSizeControls {
|
|
163
|
+
const initial = options.initialSize ?? { width: 0, height: 0 };
|
|
164
|
+
const width = ref(initial.width);
|
|
165
|
+
const height = ref(initial.height);
|
|
166
|
+
const box = options.box ?? "content-box";
|
|
167
|
+
|
|
168
|
+
const controls = useResizeObserver(
|
|
169
|
+
target,
|
|
170
|
+
(entries) => {
|
|
171
|
+
const entry = entries.at(-1);
|
|
172
|
+
if (!entry) return;
|
|
173
|
+
const sizes =
|
|
174
|
+
box === "border-box"
|
|
175
|
+
? entry.borderBoxSize
|
|
176
|
+
: box === "content-box"
|
|
177
|
+
? entry.contentBoxSize
|
|
178
|
+
: entry.devicePixelContentBoxSize;
|
|
179
|
+
if (sizes && sizes.length > 0) {
|
|
180
|
+
let inline = 0;
|
|
181
|
+
let block = 0;
|
|
182
|
+
for (const size of sizes) {
|
|
183
|
+
inline += size.inlineSize;
|
|
184
|
+
block += size.blockSize;
|
|
185
|
+
}
|
|
186
|
+
width.value = inline;
|
|
187
|
+
height.value = block;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
width.value = entry.contentRect.width;
|
|
191
|
+
height.value = entry.contentRect.height;
|
|
192
|
+
},
|
|
193
|
+
options,
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const mounted = computed(() => resolveElement(target) !== null);
|
|
197
|
+
const stopReset = watch(mounted, (isMounted) => {
|
|
198
|
+
if (isMounted) return;
|
|
199
|
+
width.value = initial.width;
|
|
200
|
+
height.value = initial.height;
|
|
201
|
+
});
|
|
202
|
+
const stop = (): void => {
|
|
203
|
+
stopReset.stop();
|
|
204
|
+
controls.stop();
|
|
205
|
+
};
|
|
206
|
+
tryOnScopeDispose(stop);
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
width: readonly(width),
|
|
210
|
+
height: readonly(height),
|
|
211
|
+
isSupported: controls.isSupported,
|
|
212
|
+
stop,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function browserResizeObserverHost(): ResizeObserverHost | undefined {
|
|
217
|
+
return typeof window !== "undefined" && typeof window.ResizeObserver === "function"
|
|
218
|
+
? window
|
|
219
|
+
: undefined;
|
|
220
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { timeoutAbortSignal } from "./abort-signal.ts";
|
|
2
|
+
import { calculateRetryDelay, type RetryDelayOptions } from "./retry-delay.ts";
|
|
3
|
+
import type { TimeoutScheduler } from "./timeout-scheduler.ts";
|
|
4
|
+
|
|
5
|
+
/** Context supplied to every invocation of a retried operation. */
|
|
6
|
+
export interface RetryAttemptContext {
|
|
7
|
+
/** One-based operation attempt, including the initial call. */
|
|
8
|
+
readonly attempt: number;
|
|
9
|
+
|
|
10
|
+
/** Shared cancellation signal for the complete retry execution. */
|
|
11
|
+
readonly signal: AbortSignal;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Context supplied after an operation fails and before retry policy runs. */
|
|
15
|
+
export interface RetryFailureContext extends RetryAttemptContext {
|
|
16
|
+
/** Exact value thrown or rejected by the failed operation. */
|
|
17
|
+
readonly error: unknown;
|
|
18
|
+
|
|
19
|
+
/** One-based retry that would follow this failure. */
|
|
20
|
+
readonly retryAttempt: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Context supplied when an approved retry is about to wait. */
|
|
24
|
+
export interface RetryScheduledContext extends RetryFailureContext {
|
|
25
|
+
/** One-based operation attempt that will run after the wait. */
|
|
26
|
+
readonly nextAttempt: number;
|
|
27
|
+
|
|
28
|
+
/** Calculated backoff delay in integer milliseconds. */
|
|
29
|
+
readonly delayMs: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Options for {@link retryAsync}. */
|
|
33
|
+
export interface RetryAsyncOptions extends RetryDelayOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Maximum retries after the initial operation attempt.
|
|
36
|
+
*
|
|
37
|
+
* @default 3
|
|
38
|
+
*/
|
|
39
|
+
readonly maximumRetries?: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Cancels the active operation, policy hook, notification hook, or backoff
|
|
43
|
+
* wait. The returned promise rejects with the signal's exact reason.
|
|
44
|
+
*
|
|
45
|
+
* @default a private non-aborting signal
|
|
46
|
+
*/
|
|
47
|
+
readonly signal?: AbortSignal;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Deterministic or host-specific scheduler used for backoff waits.
|
|
51
|
+
*
|
|
52
|
+
* @default globalThis timer functions
|
|
53
|
+
*/
|
|
54
|
+
readonly scheduler?: TimeoutScheduler;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Decide whether an operation failure is retryable. Returning `false`
|
|
58
|
+
* rejects with the original operation error without calculating a delay.
|
|
59
|
+
* The decision may be asynchronous and remains abortable.
|
|
60
|
+
*
|
|
61
|
+
* @default every failure is retryable while retries remain
|
|
62
|
+
*/
|
|
63
|
+
readonly shouldRetry?: (context: RetryFailureContext) => boolean | PromiseLike<boolean>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Observe an approved retry before its backoff wait begins. The hook may be
|
|
67
|
+
* asynchronous and remains abortable; a hook failure is propagated exactly
|
|
68
|
+
* and the next operation attempt is not started.
|
|
69
|
+
*
|
|
70
|
+
* @default undefined
|
|
71
|
+
*/
|
|
72
|
+
readonly onRetry?: (context: RetryScheduledContext) => void | PromiseLike<void>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Execute an operation with bounded, abortable retries and deterministic delay policy.
|
|
77
|
+
*
|
|
78
|
+
* Synchronous throws and asynchronous rejections follow the same path. A
|
|
79
|
+
* successful value is returned unchanged. Exhaustion rejects with the final
|
|
80
|
+
* operation error, a negative retry decision rejects with the error that was
|
|
81
|
+
* evaluated, and cancellation rejects with the signal's exact reason. These
|
|
82
|
+
* values are deliberately not wrapped.
|
|
83
|
+
*
|
|
84
|
+
* Cancellation races every asynchronous stage, so callers are not forced to
|
|
85
|
+
* wait for an operation or hook that ignores its signal. Late settlements are
|
|
86
|
+
* still observed internally and cannot become unhandled rejections. Backoff
|
|
87
|
+
* options and entropy are evaluated lazily only after a failure is approved
|
|
88
|
+
* for retry.
|
|
89
|
+
*
|
|
90
|
+
* @typeParam Value Value produced by the operation.
|
|
91
|
+
* @param operation Work to invoke with a one-based attempt and shared signal.
|
|
92
|
+
* @param options Retry count, cancellation, policy, hooks, and delay options.
|
|
93
|
+
* @default options {}
|
|
94
|
+
* @throws {RangeError} A tagged error when `maximumRetries` or inherited delay
|
|
95
|
+
* options are outside their documented ranges.
|
|
96
|
+
* @throws {TypeError} A tagged error when `options` is not an object, a
|
|
97
|
+
* callback is not callable, or a retry decision does not resolve to a boolean.
|
|
98
|
+
* @returns The first successful operation value.
|
|
99
|
+
*/
|
|
100
|
+
export async function retryAsync<Value>(
|
|
101
|
+
operation: (context: RetryAttemptContext) => Value | PromiseLike<Value>,
|
|
102
|
+
options: RetryAsyncOptions = {},
|
|
103
|
+
): Promise<Value> {
|
|
104
|
+
if (typeof operation !== "function") {
|
|
105
|
+
throw new TypeError(
|
|
106
|
+
`[VIZE_COMPOSE_RETRY_INVALID_OPERATION] operation must be a function; received ${typeof operation}`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
if (options === null || typeof options !== "object") {
|
|
110
|
+
throw new TypeError(
|
|
111
|
+
`[VIZE_COMPOSE_RETRY_INVALID_OPTIONS] options must be an object; received ${options === null ? "null" : typeof options}`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
const maximumRetries = options.maximumRetries === undefined ? 3 : options.maximumRetries;
|
|
115
|
+
if (
|
|
116
|
+
!Number.isSafeInteger(maximumRetries) ||
|
|
117
|
+
maximumRetries < 0 ||
|
|
118
|
+
maximumRetries >= Number.MAX_SAFE_INTEGER
|
|
119
|
+
) {
|
|
120
|
+
throw new RangeError(
|
|
121
|
+
`[VIZE_COMPOSE_RETRY_INVALID_MAXIMUM_RETRIES] maximumRetries must be an integer from 0 through ${String(Number.MAX_SAFE_INTEGER - 1)}; received ${String(maximumRetries)}`,
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
const shouldRetryPolicy = options.shouldRetry;
|
|
125
|
+
const retryObserver = options.onRetry;
|
|
126
|
+
if (shouldRetryPolicy !== undefined && typeof shouldRetryPolicy !== "function") {
|
|
127
|
+
throw new TypeError(
|
|
128
|
+
`[VIZE_COMPOSE_RETRY_INVALID_CALLBACK] shouldRetry must be a function; received ${typeof shouldRetryPolicy}`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (retryObserver !== undefined && typeof retryObserver !== "function") {
|
|
132
|
+
throw new TypeError(
|
|
133
|
+
`[VIZE_COMPOSE_RETRY_INVALID_CALLBACK] onRetry must be a function; received ${typeof retryObserver}`,
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const signal = options.signal === undefined ? new AbortController().signal : options.signal;
|
|
138
|
+
let attempt = 1;
|
|
139
|
+
while (true) {
|
|
140
|
+
throwIfAborted(signal);
|
|
141
|
+
const outcome = await capture(
|
|
142
|
+
raceWithAbort(
|
|
143
|
+
Promise.resolve().then(() => operation({ attempt, signal })),
|
|
144
|
+
signal,
|
|
145
|
+
),
|
|
146
|
+
);
|
|
147
|
+
if (outcome.status === "success") return outcome.value;
|
|
148
|
+
if (signal.aborted) throw signal.reason;
|
|
149
|
+
if (attempt > maximumRetries) throw outcome.error;
|
|
150
|
+
|
|
151
|
+
const failure: RetryFailureContext = {
|
|
152
|
+
attempt,
|
|
153
|
+
error: outcome.error,
|
|
154
|
+
retryAttempt: attempt,
|
|
155
|
+
signal,
|
|
156
|
+
};
|
|
157
|
+
if (shouldRetryPolicy !== undefined) {
|
|
158
|
+
const shouldRetry = await raceWithAbort(
|
|
159
|
+
Promise.resolve().then(() => shouldRetryPolicy(failure)),
|
|
160
|
+
signal,
|
|
161
|
+
);
|
|
162
|
+
if (typeof shouldRetry !== "boolean") {
|
|
163
|
+
throw new TypeError(
|
|
164
|
+
`[VIZE_COMPOSE_RETRY_INVALID_DECISION] shouldRetry must resolve to a boolean; received ${typeof shouldRetry}`,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
if (!shouldRetry) throw outcome.error;
|
|
168
|
+
}
|
|
169
|
+
throwIfAborted(signal);
|
|
170
|
+
|
|
171
|
+
const delayMs = calculateRetryDelay(attempt, options);
|
|
172
|
+
const scheduled: RetryScheduledContext = {
|
|
173
|
+
...failure,
|
|
174
|
+
delayMs,
|
|
175
|
+
nextAttempt: attempt + 1,
|
|
176
|
+
};
|
|
177
|
+
if (retryObserver !== undefined) {
|
|
178
|
+
await raceWithAbort(
|
|
179
|
+
Promise.resolve().then(() => retryObserver(scheduled)),
|
|
180
|
+
signal,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
await waitForRetry(delayMs, signal, options.scheduler);
|
|
184
|
+
attempt += 1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
type Captured<Value> =
|
|
189
|
+
| { readonly status: "success"; readonly value: Value }
|
|
190
|
+
| { readonly status: "error"; readonly error: unknown };
|
|
191
|
+
|
|
192
|
+
async function capture<Value>(promise: Promise<Value>): Promise<Captured<Value>> {
|
|
193
|
+
try {
|
|
194
|
+
return { status: "success", value: await promise };
|
|
195
|
+
} catch (error) {
|
|
196
|
+
return { status: "error", error };
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function raceWithAbort<Value>(promise: Promise<Value>, signal: AbortSignal): Promise<Value> {
|
|
201
|
+
if (signal.aborted) return Promise.reject(signal.reason);
|
|
202
|
+
|
|
203
|
+
return new Promise((resolve, reject) => {
|
|
204
|
+
let listening = false;
|
|
205
|
+
let settled = false;
|
|
206
|
+
const cleanup = () => {
|
|
207
|
+
if (!listening) return;
|
|
208
|
+
listening = false;
|
|
209
|
+
try {
|
|
210
|
+
signal.removeEventListener("abort", onAbort);
|
|
211
|
+
} catch {
|
|
212
|
+
// A broken adapter cannot be allowed to strand the primary promise.
|
|
213
|
+
// Native AbortSignal removal is non-throwing.
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const settle = (callback: () => void) => {
|
|
217
|
+
if (settled) return;
|
|
218
|
+
settled = true;
|
|
219
|
+
cleanup();
|
|
220
|
+
callback();
|
|
221
|
+
};
|
|
222
|
+
const onAbort = () => settle(() => reject(signal.reason));
|
|
223
|
+
|
|
224
|
+
// Attach handlers before registering with a potentially non-standard
|
|
225
|
+
// signal so the work remains observed even if registration throws.
|
|
226
|
+
void promise.then(
|
|
227
|
+
(value) => settle(() => resolve(value)),
|
|
228
|
+
(error: unknown) => settle(() => reject(error)),
|
|
229
|
+
);
|
|
230
|
+
try {
|
|
231
|
+
listening = true;
|
|
232
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
233
|
+
if (settled) cleanup();
|
|
234
|
+
else if (signal.aborted) onAbort();
|
|
235
|
+
} catch (error) {
|
|
236
|
+
settle(() => reject(error));
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async function waitForRetry(
|
|
242
|
+
delayMs: number,
|
|
243
|
+
signal: AbortSignal,
|
|
244
|
+
scheduler: TimeoutScheduler | undefined,
|
|
245
|
+
): Promise<void> {
|
|
246
|
+
const elapsed = {};
|
|
247
|
+
const delaySignal = timeoutAbortSignal(
|
|
248
|
+
delayMs,
|
|
249
|
+
scheduler === undefined ? { reason: elapsed, signal } : { reason: elapsed, scheduler, signal },
|
|
250
|
+
);
|
|
251
|
+
try {
|
|
252
|
+
await raceWithAbort(new Promise<never>(() => undefined), delaySignal);
|
|
253
|
+
} catch (reason) {
|
|
254
|
+
if (reason === elapsed) return;
|
|
255
|
+
throw reason;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function throwIfAborted(signal: AbortSignal): void {
|
|
260
|
+
if (signal.aborted) throw signal.reason;
|
|
261
|
+
}
|