@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,251 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { readonly, ref, shallowRef, toRaw, toValue, watch } from "vue";
|
|
3
|
+
//#region src/use-indexed-db.ts
|
|
4
|
+
function browserFactory() {
|
|
5
|
+
try {
|
|
6
|
+
return typeof window !== "undefined" ? window.indexedDB ?? void 0 : void 0;
|
|
7
|
+
} catch {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function request(pending) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
pending.addEventListener("success", () => resolve(pending.result));
|
|
14
|
+
pending.addEventListener("error", () => reject(pending.error));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function committed(transaction) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
transaction.addEventListener("complete", () => resolve());
|
|
20
|
+
transaction.addEventListener("error", () => reject(transaction.error));
|
|
21
|
+
transaction.addEventListener("abort", () => reject(transaction.error));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function openDatabase(factory, name, store, version) {
|
|
25
|
+
const opening = factory.open(name, version);
|
|
26
|
+
opening.addEventListener("upgradeneeded", () => {
|
|
27
|
+
const database = opening.result;
|
|
28
|
+
if (!database.objectStoreNames.contains(store)) database.createObjectStore(store);
|
|
29
|
+
});
|
|
30
|
+
return request(opening).then((database) => {
|
|
31
|
+
if (database.objectStoreNames.contains(store)) return database;
|
|
32
|
+
const next = database.version + 1;
|
|
33
|
+
database.close();
|
|
34
|
+
return openDatabase(factory, name, store, next);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a small promise-based key-value store on one IndexedDB object
|
|
39
|
+
* store. The connection opens lazily on the first operation, the store is
|
|
40
|
+
* created on demand, and writes resolve once their transaction commits.
|
|
41
|
+
* Without IndexedDB (server rendering, privacy modes) every operation
|
|
42
|
+
* rejects with a tagged `[VIZE_COMPOSE_INDEXED_DB_UNAVAILABLE]` error.
|
|
43
|
+
*
|
|
44
|
+
* @param options Database, store, and implementation.
|
|
45
|
+
* @default options {}
|
|
46
|
+
* @returns Key-value operations.
|
|
47
|
+
*/
|
|
48
|
+
function createIndexedDBKeyval(options = {}) {
|
|
49
|
+
const name = options.database ?? "vize-keyval";
|
|
50
|
+
const store = options.store ?? "keyval";
|
|
51
|
+
let connection;
|
|
52
|
+
const database = () => {
|
|
53
|
+
if (connection !== void 0) return connection;
|
|
54
|
+
const factory = options.factory === void 0 ? browserFactory() : options.factory;
|
|
55
|
+
if (!factory) return Promise.reject(/* @__PURE__ */ new Error("[VIZE_COMPOSE_INDEXED_DB_UNAVAILABLE] IndexedDB is not available"));
|
|
56
|
+
const opened = openDatabase(factory, name, store);
|
|
57
|
+
connection = opened;
|
|
58
|
+
opened.catch(() => {
|
|
59
|
+
if (connection === opened) connection = void 0;
|
|
60
|
+
});
|
|
61
|
+
return opened;
|
|
62
|
+
};
|
|
63
|
+
const read = async (operation) => {
|
|
64
|
+
return request(operation((await database()).transaction(store, "readonly").objectStore(store)));
|
|
65
|
+
};
|
|
66
|
+
const write = async (operation) => {
|
|
67
|
+
const transaction = (await database()).transaction(store, "readwrite");
|
|
68
|
+
const done = committed(transaction);
|
|
69
|
+
operation(transaction.objectStore(store));
|
|
70
|
+
await done;
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
get: (key) => read((objects) => objects.get(key)),
|
|
74
|
+
set: (key, value) => write((objects) => objects.put(value, key)),
|
|
75
|
+
delete: (key) => write((objects) => objects.delete(key)),
|
|
76
|
+
keys: () => read((objects) => objects.getAllKeys()),
|
|
77
|
+
clear: () => write((objects) => objects.clear()),
|
|
78
|
+
close: () => {
|
|
79
|
+
const current = connection;
|
|
80
|
+
connection = void 0;
|
|
81
|
+
current?.then((db) => db.close(), () => void 0);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function sameKind(defaults, candidate) {
|
|
86
|
+
if (defaults === null || defaults === void 0) return true;
|
|
87
|
+
if (defaults instanceof Map) return candidate instanceof Map;
|
|
88
|
+
if (defaults instanceof Set) return candidate instanceof Set;
|
|
89
|
+
if (defaults instanceof Date) return candidate instanceof Date;
|
|
90
|
+
if (Array.isArray(defaults)) return Array.isArray(candidate);
|
|
91
|
+
if (typeof defaults === "object") return typeof candidate === "object" && candidate !== null && !Array.isArray(candidate);
|
|
92
|
+
return typeof candidate === typeof defaults;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Synchronize a reactive value with one IndexedDB key.
|
|
96
|
+
*
|
|
97
|
+
* Values are stored by structured clone, so objects, arrays, `Map`, `Set`,
|
|
98
|
+
* `Date`, typed arrays, and `Blob`s round-trip without a serializer. The
|
|
99
|
+
* value is loaded asynchronously: `state` holds the default until `ready`
|
|
100
|
+
* becomes `true`. Loaded values pass `validate` before they are accepted.
|
|
101
|
+
* Assignments and nested mutations are written back; changing the reactive
|
|
102
|
+
* `key` loads the new key (stale loads are discarded).
|
|
103
|
+
*
|
|
104
|
+
* Server rendering: without a browser `window` nothing is opened, `state`
|
|
105
|
+
* is the default, and `ready` stays `false`, so server and client first
|
|
106
|
+
* render identically. The connection closes and watchers stop with the
|
|
107
|
+
* owning reactive scope. Failures never reject; they are exposed through
|
|
108
|
+
* `error` and `onError`.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const { state: draft, ready } = useIndexedDB("draft", { title: "", body: "" });
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @typeParam Value Stored value type, inferred from `defaultValue`.
|
|
116
|
+
* @param key Reactive IndexedDB key.
|
|
117
|
+
* @param defaultValue Value used until loaded, and when absent or invalid.
|
|
118
|
+
* @param options Database, store, implementation, and validation.
|
|
119
|
+
* @default options {}
|
|
120
|
+
* @returns The synchronized value and its controls.
|
|
121
|
+
*/
|
|
122
|
+
function useIndexedDB(key, defaultValue, options = {}) {
|
|
123
|
+
const state = ref(defaultValue);
|
|
124
|
+
const supported = ref(false);
|
|
125
|
+
const ready = ref(false);
|
|
126
|
+
const error = shallowRef(void 0);
|
|
127
|
+
const validate = options.validate ?? ((candidate) => sameKind(defaultValue, candidate));
|
|
128
|
+
let keyval;
|
|
129
|
+
let generation = 0;
|
|
130
|
+
let applying = false;
|
|
131
|
+
let dirty = false;
|
|
132
|
+
const fail = (code, cause) => {
|
|
133
|
+
const failure = {
|
|
134
|
+
code,
|
|
135
|
+
key: toValue(key),
|
|
136
|
+
cause
|
|
137
|
+
};
|
|
138
|
+
error.value = failure;
|
|
139
|
+
options.onError?.(failure);
|
|
140
|
+
};
|
|
141
|
+
const assign = (value) => {
|
|
142
|
+
applying = true;
|
|
143
|
+
try {
|
|
144
|
+
state.value = value;
|
|
145
|
+
} finally {
|
|
146
|
+
applying = false;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const persist = async (value) => {
|
|
150
|
+
if (keyval === void 0) return;
|
|
151
|
+
try {
|
|
152
|
+
await keyval.set(toValue(key), toRaw(value));
|
|
153
|
+
error.value = void 0;
|
|
154
|
+
} catch (cause) {
|
|
155
|
+
fail("write-failed", cause);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
const refresh = async () => {
|
|
159
|
+
const current = ++generation;
|
|
160
|
+
if (keyval === void 0) return;
|
|
161
|
+
const store = keyval;
|
|
162
|
+
let stored;
|
|
163
|
+
try {
|
|
164
|
+
stored = await store.get(toValue(key));
|
|
165
|
+
} catch (cause) {
|
|
166
|
+
if (current === generation) fail("read-failed", cause);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (current !== generation) return;
|
|
170
|
+
if (stored === void 0) {
|
|
171
|
+
assign(defaultValue);
|
|
172
|
+
ready.value = true;
|
|
173
|
+
if (options.writeDefaults ?? true) await persist(defaultValue);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!validate(stored)) {
|
|
177
|
+
fail("invalid-value", stored);
|
|
178
|
+
assign(defaultValue);
|
|
179
|
+
} else {
|
|
180
|
+
error.value = void 0;
|
|
181
|
+
assign(stored);
|
|
182
|
+
}
|
|
183
|
+
ready.value = true;
|
|
184
|
+
};
|
|
185
|
+
const remove = async () => {
|
|
186
|
+
generation += 1;
|
|
187
|
+
assign(defaultValue);
|
|
188
|
+
if (keyval === void 0) return;
|
|
189
|
+
try {
|
|
190
|
+
await keyval.delete(toValue(key));
|
|
191
|
+
error.value = void 0;
|
|
192
|
+
} catch (cause) {
|
|
193
|
+
fail("write-failed", cause);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
let currentFactory;
|
|
197
|
+
const stopSource = watch([() => (options.factory === void 0 ? browserFactory() : toValue(options.factory)) ?? void 0, () => toValue(key)], ([factory]) => {
|
|
198
|
+
ready.value = false;
|
|
199
|
+
supported.value = factory !== void 0;
|
|
200
|
+
if (factory !== currentFactory) {
|
|
201
|
+
keyval?.close();
|
|
202
|
+
currentFactory = factory;
|
|
203
|
+
keyval = factory === void 0 ? void 0 : createIndexedDBKeyval({
|
|
204
|
+
factory,
|
|
205
|
+
...options.database === void 0 ? {} : { database: options.database },
|
|
206
|
+
...options.store === void 0 ? {} : { store: options.store }
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (keyval === void 0) {
|
|
210
|
+
generation += 1;
|
|
211
|
+
assign(defaultValue);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
refresh();
|
|
215
|
+
}, {
|
|
216
|
+
immediate: true,
|
|
217
|
+
flush: "sync"
|
|
218
|
+
});
|
|
219
|
+
const stopDirty = watch(state, () => {
|
|
220
|
+
if (!applying) dirty = true;
|
|
221
|
+
}, {
|
|
222
|
+
deep: options.deep ?? true,
|
|
223
|
+
flush: "sync"
|
|
224
|
+
});
|
|
225
|
+
const stopWrite = watch(state, (value) => {
|
|
226
|
+
if (!dirty) return;
|
|
227
|
+
dirty = false;
|
|
228
|
+
persist(value);
|
|
229
|
+
}, {
|
|
230
|
+
deep: options.deep ?? true,
|
|
231
|
+
flush: options.flush ?? "pre"
|
|
232
|
+
});
|
|
233
|
+
tryOnScopeDispose(() => {
|
|
234
|
+
generation += 1;
|
|
235
|
+
stopSource();
|
|
236
|
+
stopDirty();
|
|
237
|
+
stopWrite();
|
|
238
|
+
keyval?.close();
|
|
239
|
+
keyval = void 0;
|
|
240
|
+
});
|
|
241
|
+
return {
|
|
242
|
+
state,
|
|
243
|
+
supported: readonly(supported),
|
|
244
|
+
ready: readonly(ready),
|
|
245
|
+
error,
|
|
246
|
+
refresh,
|
|
247
|
+
remove
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { createIndexedDBKeyval, useIndexedDB };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { MaybeRefOrGetter, ShallowRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-interval.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Repeating timer host used by {@link useIntervalFn} and the clocks built
|
|
6
|
+
* on it.
|
|
7
|
+
*
|
|
8
|
+
* Implement this interface to integrate a deterministic test clock, a native
|
|
9
|
+
* runtime timer, or an application-owned scheduler. Handles are opaque: they
|
|
10
|
+
* are only handed back to {@link IntervalScheduler.clearInterval}.
|
|
11
|
+
*/
|
|
12
|
+
interface IntervalScheduler {
|
|
13
|
+
/** Starts a repeating callback and returns its opaque cancellation handle. */
|
|
14
|
+
readonly setInterval: (callback: () => void, intervalMs: number) => unknown;
|
|
15
|
+
/** Cancels a handle previously returned by {@link IntervalScheduler.setInterval}. */
|
|
16
|
+
readonly clearInterval: (handle: unknown) => void;
|
|
17
|
+
}
|
|
18
|
+
/** Pause/resume controls shared by the repeating timing composables. */
|
|
19
|
+
interface PausableControls {
|
|
20
|
+
/**
|
|
21
|
+
* Whether the timer is logically running.
|
|
22
|
+
*
|
|
23
|
+
* On the server (without `runOnServer`) this reflects the requested state
|
|
24
|
+
* without starting a host timer, so server and client render the same
|
|
25
|
+
* initial value.
|
|
26
|
+
*/
|
|
27
|
+
readonly isActive: Readonly<ShallowRef<boolean>>;
|
|
28
|
+
/** Stop ticking. Idempotent. */
|
|
29
|
+
readonly pause: () => void;
|
|
30
|
+
/** Start (or keep) ticking. Idempotent. */
|
|
31
|
+
readonly resume: () => void;
|
|
32
|
+
}
|
|
33
|
+
/** Options for {@link useIntervalFn}. */
|
|
34
|
+
interface UseIntervalFnOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Start ticking as soon as the composable is created.
|
|
37
|
+
*
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
readonly immediate?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Invoke the callback synchronously whenever the timer (re)starts, in
|
|
43
|
+
* addition to every tick.
|
|
44
|
+
*
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
readonly immediateCallback?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Starts host timers when no browser `window` is available.
|
|
50
|
+
*
|
|
51
|
+
* Keep this disabled during server rendering: the controls then track the
|
|
52
|
+
* requested state but never schedule work. Enable it for native, desktop,
|
|
53
|
+
* worker, and test runtimes whose scheduler is lifecycle-bound.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
readonly runOnServer?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Owns the repeating timer.
|
|
60
|
+
*
|
|
61
|
+
* @default globalThis timer functions
|
|
62
|
+
*/
|
|
63
|
+
readonly scheduler?: IntervalScheduler;
|
|
64
|
+
}
|
|
65
|
+
/** Options for {@link useInterval}. */
|
|
66
|
+
interface UseIntervalOptions<Controls extends boolean = false> extends UseIntervalFnOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Return the full control object instead of the bare counter ref.
|
|
69
|
+
*
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
readonly controls?: Controls;
|
|
73
|
+
/**
|
|
74
|
+
* Invoked after every increment with the new count.
|
|
75
|
+
*
|
|
76
|
+
* @default undefined
|
|
77
|
+
*/
|
|
78
|
+
readonly callback?: (count: number) => void;
|
|
79
|
+
}
|
|
80
|
+
/** Counter and controls returned by `useInterval(ms, { controls: true })`. */
|
|
81
|
+
interface IntervalControls extends PausableControls {
|
|
82
|
+
/** Number of ticks since creation or the last {@link IntervalControls.reset}. */
|
|
83
|
+
readonly counter: Readonly<ShallowRef<number>>;
|
|
84
|
+
/** Reset the counter to zero without touching the timer. */
|
|
85
|
+
readonly reset: () => void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Call a function on a fixed, pausable interval.
|
|
89
|
+
*
|
|
90
|
+
* `intervalMs` is reactive: while active, a change replaces the running timer
|
|
91
|
+
* with one using the new period. The timer is cleared when the owning
|
|
92
|
+
* reactive scope stops; call inside an active scope, or call `pause()`
|
|
93
|
+
* yourself.
|
|
94
|
+
*
|
|
95
|
+
* Server rendering is hydration-stable: without a browser `window` (and
|
|
96
|
+
* with {@link UseIntervalFnOptions.runOnServer} disabled) `isActive` reports
|
|
97
|
+
* the requested state but no host timer is created, so nothing leaks and
|
|
98
|
+
* the server snapshot matches the client's initial render.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const { pause, resume, isActive } = useIntervalFn(() => poll(), 5_000);
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param callback Invoked on every tick.
|
|
106
|
+
* @param intervalMs Reactive period in milliseconds; must be finite and
|
|
107
|
+
* greater than zero. Fractions are truncated.
|
|
108
|
+
* @param options Start, server, and scheduler policy.
|
|
109
|
+
* @default options {}
|
|
110
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_INTERVAL_INVALID_DELAY` when the
|
|
111
|
+
* resolved period is invalid, synchronously at creation and whenever a timer
|
|
112
|
+
* would start.
|
|
113
|
+
* @returns Pause/resume controls.
|
|
114
|
+
*/
|
|
115
|
+
declare function useIntervalFn(callback: () => void, intervalMs: MaybeRefOrGetter<number>, options?: UseIntervalFnOptions): PausableControls;
|
|
116
|
+
/**
|
|
117
|
+
* Count interval ticks reactively.
|
|
118
|
+
*
|
|
119
|
+
* A thin wrapper over {@link useIntervalFn} whose state is a counter. Pass
|
|
120
|
+
* `{ controls: true }` to receive pause/resume/reset alongside the counter;
|
|
121
|
+
* the return type follows the literal flag.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* const ticks = useInterval(1_000); // Readonly<ShallowRef<number>>
|
|
126
|
+
* const { counter, pause, reset } = useInterval(1_000, { controls: true });
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* @param intervalMs Reactive period in milliseconds.
|
|
130
|
+
* @param options Interval options plus the `controls` flag.
|
|
131
|
+
* @default intervalMs 1000
|
|
132
|
+
* @default options {}
|
|
133
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_INTERVAL_INVALID_DELAY` for
|
|
134
|
+
* invalid periods (see {@link useIntervalFn}).
|
|
135
|
+
* @returns The counter ref, or the full controls when `controls` is `true`.
|
|
136
|
+
*/
|
|
137
|
+
declare function useInterval(intervalMs?: MaybeRefOrGetter<number>, options?: UseIntervalOptions<false>): Readonly<ShallowRef<number>>;
|
|
138
|
+
declare function useInterval(intervalMs: MaybeRefOrGetter<number>, options: UseIntervalOptions<true>): IntervalControls;
|
|
139
|
+
//#endregion
|
|
140
|
+
export { UseIntervalOptions as a, UseIntervalFnOptions as i, IntervalScheduler as n, useInterval as o, PausableControls as r, useIntervalFn as s, IntervalControls as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as UseIntervalOptions, i as UseIntervalFnOptions, n as IntervalScheduler, o as useInterval, r as PausableControls, s as useIntervalFn, t as IntervalControls } from "./use-interval-BA55gTHT.mjs";
|
|
2
|
+
export { IntervalControls, IntervalScheduler, PausableControls, UseIntervalFnOptions, UseIntervalOptions, useInterval, useIntervalFn };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { shallowRef, toValue, watch } from "vue";
|
|
3
|
+
//#region src/use-interval.ts
|
|
4
|
+
const defaultScheduler = {
|
|
5
|
+
setInterval: (callback, intervalMs) => globalThis.setInterval(callback, intervalMs),
|
|
6
|
+
clearInterval: (handle) => {
|
|
7
|
+
globalThis.clearInterval(handle);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function resolveIntervalMs(value) {
|
|
11
|
+
if (!Number.isFinite(value) || value <= 0) throw new RangeError(`[VIZE_COMPOSE_INTERVAL_INVALID_DELAY] intervalMs must be finite and greater than zero; received ${String(value)}`);
|
|
12
|
+
return Math.max(1, Math.trunc(value));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Call a function on a fixed, pausable interval.
|
|
16
|
+
*
|
|
17
|
+
* `intervalMs` is reactive: while active, a change replaces the running timer
|
|
18
|
+
* with one using the new period. The timer is cleared when the owning
|
|
19
|
+
* reactive scope stops; call inside an active scope, or call `pause()`
|
|
20
|
+
* yourself.
|
|
21
|
+
*
|
|
22
|
+
* Server rendering is hydration-stable: without a browser `window` (and
|
|
23
|
+
* with {@link UseIntervalFnOptions.runOnServer} disabled) `isActive` reports
|
|
24
|
+
* the requested state but no host timer is created, so nothing leaks and
|
|
25
|
+
* the server snapshot matches the client's initial render.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const { pause, resume, isActive } = useIntervalFn(() => poll(), 5_000);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param callback Invoked on every tick.
|
|
33
|
+
* @param intervalMs Reactive period in milliseconds; must be finite and
|
|
34
|
+
* greater than zero. Fractions are truncated.
|
|
35
|
+
* @param options Start, server, and scheduler policy.
|
|
36
|
+
* @default options {}
|
|
37
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_INTERVAL_INVALID_DELAY` when the
|
|
38
|
+
* resolved period is invalid, synchronously at creation and whenever a timer
|
|
39
|
+
* would start.
|
|
40
|
+
* @returns Pause/resume controls.
|
|
41
|
+
*/
|
|
42
|
+
function useIntervalFn(callback, intervalMs, options = {}) {
|
|
43
|
+
const scheduler = options.scheduler ?? defaultScheduler;
|
|
44
|
+
const isActive = shallowRef(false);
|
|
45
|
+
let handle;
|
|
46
|
+
let running = false;
|
|
47
|
+
resolveIntervalMs(toValue(intervalMs));
|
|
48
|
+
const canSchedule = () => typeof window !== "undefined" || (options.runOnServer ?? false);
|
|
49
|
+
const clear = () => {
|
|
50
|
+
if (!running) return;
|
|
51
|
+
running = false;
|
|
52
|
+
scheduler.clearInterval(handle);
|
|
53
|
+
handle = void 0;
|
|
54
|
+
};
|
|
55
|
+
const start = () => {
|
|
56
|
+
const period = resolveIntervalMs(toValue(intervalMs));
|
|
57
|
+
clear();
|
|
58
|
+
if (!canSchedule()) return;
|
|
59
|
+
if (options.immediateCallback ?? false) callback();
|
|
60
|
+
if (!isActive.value) return;
|
|
61
|
+
running = true;
|
|
62
|
+
handle = scheduler.setInterval(callback, period);
|
|
63
|
+
};
|
|
64
|
+
const pause = () => {
|
|
65
|
+
isActive.value = false;
|
|
66
|
+
clear();
|
|
67
|
+
};
|
|
68
|
+
const resume = () => {
|
|
69
|
+
if (isActive.value) return;
|
|
70
|
+
isActive.value = true;
|
|
71
|
+
start();
|
|
72
|
+
};
|
|
73
|
+
watch(() => toValue(intervalMs), () => {
|
|
74
|
+
if (isActive.value) start();
|
|
75
|
+
});
|
|
76
|
+
if (options.immediate ?? true) resume();
|
|
77
|
+
tryOnScopeDispose(pause);
|
|
78
|
+
return {
|
|
79
|
+
isActive,
|
|
80
|
+
pause,
|
|
81
|
+
resume
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function useInterval(intervalMs = 1e3, options = {}) {
|
|
85
|
+
const counter = shallowRef(0);
|
|
86
|
+
const controls = useIntervalFn(() => {
|
|
87
|
+
counter.value += 1;
|
|
88
|
+
options.callback?.(counter.value);
|
|
89
|
+
}, intervalMs, options);
|
|
90
|
+
if (options.controls !== true) return counter;
|
|
91
|
+
return {
|
|
92
|
+
...controls,
|
|
93
|
+
counter,
|
|
94
|
+
reset: () => {
|
|
95
|
+
counter.value = 0;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { useInterval, useIntervalFn };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-list-format.d.ts
|
|
4
|
+
/** Options for {@link useListFormat}. */
|
|
5
|
+
interface UseListFormatOptions extends Intl.ListFormatOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Locale used for formatting. Pass it explicitly for hydration-stable
|
|
8
|
+
* server rendering.
|
|
9
|
+
*
|
|
10
|
+
* @default the browser language, otherwise "en"
|
|
11
|
+
*/
|
|
12
|
+
readonly locale?: string | Intl.Locale;
|
|
13
|
+
}
|
|
14
|
+
/** Reactive list formatting returned by {@link useListFormat}. */
|
|
15
|
+
interface ListFormatControls {
|
|
16
|
+
/** Canonical locale in use. */
|
|
17
|
+
readonly locale: ComputedRef<string>;
|
|
18
|
+
/** Cached formatter for the current locale and options. */
|
|
19
|
+
readonly formatter: ComputedRef<Intl.ListFormat>;
|
|
20
|
+
/** Formatted list, for example `"apples, pears, and plums"`. */
|
|
21
|
+
readonly formatted: ComputedRef<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Format any list with the current formatter.
|
|
24
|
+
*
|
|
25
|
+
* @param items Items to join.
|
|
26
|
+
* @returns The formatted list.
|
|
27
|
+
*/
|
|
28
|
+
readonly format: (items: Iterable<string>) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Format any list into element and literal parts (for rich rendering).
|
|
31
|
+
*
|
|
32
|
+
* @param items Items to join.
|
|
33
|
+
* @returns The formatted parts.
|
|
34
|
+
*/
|
|
35
|
+
readonly formatToParts: (items: Iterable<string>) => {
|
|
36
|
+
type: "element" | "literal";
|
|
37
|
+
value: string;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Join strings into a locale-aware list with `Intl.ListFormat`
|
|
42
|
+
* (`"a, b, and c"`, `"a、b、c"`, `"a, b or c"`).
|
|
43
|
+
*
|
|
44
|
+
* Follows reactive items and options; formatters are cached per locale and
|
|
45
|
+
* option set through {@link useLocale}. Invalid options surface as the
|
|
46
|
+
* platform's `RangeError`. No listeners or timers are created.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const { formatted } = useListFormat(names, { locale: "en", type: "disjunction" });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param items Reactive list of strings.
|
|
54
|
+
* @param options Reactive locale and `Intl.ListFormat` options.
|
|
55
|
+
* @default options {}
|
|
56
|
+
* @returns Reactive formatted output and formatting helpers.
|
|
57
|
+
*/
|
|
58
|
+
declare function useListFormat(items: MaybeRefOrGetter<readonly string[]>, options?: MaybeRefOrGetter<UseListFormatOptions>): ListFormatControls;
|
|
59
|
+
//#endregion
|
|
60
|
+
export { ListFormatControls, UseListFormatOptions, useListFormat };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useLocale } from "./locale.mjs";
|
|
2
|
+
import { computed, toValue } from "vue";
|
|
3
|
+
//#region src/use-list-format.ts
|
|
4
|
+
function browserLanguage() {
|
|
5
|
+
return typeof window === "undefined" ? void 0 : window.navigator.language;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Join strings into a locale-aware list with `Intl.ListFormat`
|
|
9
|
+
* (`"a, b, and c"`, `"a、b、c"`, `"a, b or c"`).
|
|
10
|
+
*
|
|
11
|
+
* Follows reactive items and options; formatters are cached per locale and
|
|
12
|
+
* option set through {@link useLocale}. Invalid options surface as the
|
|
13
|
+
* platform's `RangeError`. No listeners or timers are created.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const { formatted } = useListFormat(names, { locale: "en", type: "disjunction" });
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param items Reactive list of strings.
|
|
21
|
+
* @param options Reactive locale and `Intl.ListFormat` options.
|
|
22
|
+
* @default options {}
|
|
23
|
+
* @returns Reactive formatted output and formatting helpers.
|
|
24
|
+
*/
|
|
25
|
+
function useListFormat(items, options = {}) {
|
|
26
|
+
const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
|
|
27
|
+
const formatter = computed(() => {
|
|
28
|
+
const { locale: _locale, ...formatOptions } = toValue(options);
|
|
29
|
+
return localeControls.list(formatOptions);
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
locale: localeControls.locale,
|
|
33
|
+
formatter,
|
|
34
|
+
formatted: computed(() => formatter.value.format(toValue(items))),
|
|
35
|
+
format: (list) => formatter.value.format(list),
|
|
36
|
+
formatToParts: (list) => formatter.value.formatToParts(list)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { useListFormat };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ComputedRef, ShallowRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-machine.d.ts
|
|
4
|
+
/** Guarded, effectful transition to `target`. */
|
|
5
|
+
interface MachineTransition<State extends string, Context> {
|
|
6
|
+
/** State entered when the transition is taken. */
|
|
7
|
+
readonly target: State;
|
|
8
|
+
/** Take the transition only when this returns `true`. */
|
|
9
|
+
readonly guard?: (context: Context) => boolean;
|
|
10
|
+
/** Produce the next context while transitioning. */
|
|
11
|
+
readonly action?: (context: Context) => Context;
|
|
12
|
+
}
|
|
13
|
+
/** One state of a {@link MachineConfig}. */
|
|
14
|
+
interface MachineStateNode<State extends string, Event extends string, Context> {
|
|
15
|
+
/**
|
|
16
|
+
* Transitions keyed by event: a target state name, one transition object,
|
|
17
|
+
* or a list of guarded transitions where the first passing guard wins.
|
|
18
|
+
*/
|
|
19
|
+
readonly on?: { readonly [Name in Event]?: State | MachineTransition<State, Context> | readonly MachineTransition<State, Context>[] };
|
|
20
|
+
/** Called with the context after the machine enters this state. */
|
|
21
|
+
readonly entry?: (context: Context) => void;
|
|
22
|
+
/** Called with the context before the machine leaves this state. */
|
|
23
|
+
readonly exit?: (context: Context) => void;
|
|
24
|
+
}
|
|
25
|
+
/** Definition consumed by {@link useMachine}. */
|
|
26
|
+
interface MachineConfig<State extends string, Event extends string, Context> {
|
|
27
|
+
/** State the machine starts (and resets) in. */
|
|
28
|
+
readonly initial: NoInfer<State>;
|
|
29
|
+
/** Initial extended state. */
|
|
30
|
+
readonly context: Context;
|
|
31
|
+
/** Every state, keyed by name. */
|
|
32
|
+
readonly states: { readonly [Name in State]: MachineStateNode<NoInfer<State>, Event, Context> };
|
|
33
|
+
}
|
|
34
|
+
/** Reactive machine returned by {@link useMachine}. */
|
|
35
|
+
interface Machine<State extends string, Event extends string, Context> {
|
|
36
|
+
/** Current state name. */
|
|
37
|
+
readonly state: Readonly<ShallowRef<State>>;
|
|
38
|
+
/** Current extended state. */
|
|
39
|
+
readonly context: Readonly<ShallowRef<Context>>;
|
|
40
|
+
/** Events that would cause a transition from the current state right now. */
|
|
41
|
+
readonly nextEvents: ComputedRef<Event[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Deliver an event.
|
|
44
|
+
*
|
|
45
|
+
* @returns Whether a transition was taken.
|
|
46
|
+
*/
|
|
47
|
+
readonly send: (event: Event) => boolean;
|
|
48
|
+
/** Whether `event` would cause a transition right now (guards included). */
|
|
49
|
+
readonly can: (event: Event) => boolean;
|
|
50
|
+
/** Whether the current state is one of `states`. */
|
|
51
|
+
readonly matches: (...states: readonly State[]) => boolean;
|
|
52
|
+
/** Return to the initial state and context without running hooks. */
|
|
53
|
+
readonly reset: () => void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Finite state machine with typed states, events, and targets.
|
|
57
|
+
*
|
|
58
|
+
* State names are inferred from the keys of `states`, event names from the
|
|
59
|
+
* keys of every `on` map, and every `target` (and `initial`) must name a
|
|
60
|
+
* declared state, so typos fail to compile. Transitions may carry guards
|
|
61
|
+
* (first passing guard wins) and actions that return the next context;
|
|
62
|
+
* `exit` runs on the old state before `entry` runs on the new one, and a
|
|
63
|
+
* self-transition runs both. Synchronous and free of globals: identical on
|
|
64
|
+
* server and client, nothing to dispose.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const fetcher = useMachine({
|
|
69
|
+
* initial: "idle",
|
|
70
|
+
* context: { retries: 0 },
|
|
71
|
+
* states: {
|
|
72
|
+
* idle: { on: { FETCH: "loading" } },
|
|
73
|
+
* loading: { on: { RESOLVE: "success", REJECT: "failure" } },
|
|
74
|
+
* failure: {
|
|
75
|
+
* on: {
|
|
76
|
+
* RETRY: { target: "loading", guard: (c) => c.retries < 3, action: (c) => ({ retries: c.retries + 1 }) },
|
|
77
|
+
* },
|
|
78
|
+
* },
|
|
79
|
+
* success: {},
|
|
80
|
+
* },
|
|
81
|
+
* });
|
|
82
|
+
* fetcher.send("FETCH");
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @param config States, events, context, and hooks.
|
|
86
|
+
* @returns The reactive machine.
|
|
87
|
+
*/
|
|
88
|
+
declare function useMachine<State extends string, Event extends string = never, Context = undefined>(config: MachineConfig<State, Event, Context>): Machine<State, Event, Context>;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { Machine, MachineConfig, MachineStateNode, MachineTransition, useMachine };
|