@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,162 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { readonly, shallowRef, toValue } from "vue";
|
|
3
|
+
//#region src/use-worker-fn.ts
|
|
4
|
+
function browserHost() {
|
|
5
|
+
if (typeof window === "undefined" || typeof window.Worker !== "function") return void 0;
|
|
6
|
+
const { URL: url } = window;
|
|
7
|
+
return {
|
|
8
|
+
Worker: window.Worker,
|
|
9
|
+
createObjectURL: (script) => url.createObjectURL(script),
|
|
10
|
+
revokeObjectURL: (target) => url.revokeObjectURL(target)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function defaultScheduler() {
|
|
14
|
+
return {
|
|
15
|
+
setTimeout: (callback, delayMs) => {
|
|
16
|
+
const handle = globalThis.setTimeout(callback, delayMs);
|
|
17
|
+
return () => globalThis.clearTimeout(handle);
|
|
18
|
+
},
|
|
19
|
+
clearTimeout: (cancel) => {
|
|
20
|
+
if (typeof cancel === "function") cancel();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function workerError(code, message, cause) {
|
|
25
|
+
return cause === void 0 ? /* @__PURE__ */ new Error(`[${code}] ${message}`) : new Error(`[${code}] ${message}`, { cause });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build the worker script for `fn`. Exposed for inspection and testing.
|
|
29
|
+
*
|
|
30
|
+
* The function source is embedded with `Function.prototype.toString`, so it
|
|
31
|
+
* must be self-contained: no closures over module variables, only its
|
|
32
|
+
* arguments, `localDependencies`, `dependencies`, and worker globals.
|
|
33
|
+
*
|
|
34
|
+
* @param fn Function to embed.
|
|
35
|
+
* @param options Imported scripts and inlined helper functions.
|
|
36
|
+
* @default options {}
|
|
37
|
+
* @returns JavaScript source for a dedicated worker.
|
|
38
|
+
*/
|
|
39
|
+
function createWorkerFnScript(fn, options = {}) {
|
|
40
|
+
const imports = (options.dependencies ?? []).map((url) => JSON.stringify(url)).join(", ");
|
|
41
|
+
const helpers = (options.localDependencies ?? []).map((helper) => {
|
|
42
|
+
if (helper.name === "") throw new TypeError("[VIZE_COMPOSE_WORKER_FN_ANONYMOUS_DEPENDENCY] localDependencies must be named functions");
|
|
43
|
+
return `const ${helper.name} = ${helper.toString()};`;
|
|
44
|
+
}).join("\n");
|
|
45
|
+
return [
|
|
46
|
+
imports === "" ? "" : `importScripts(${imports});`,
|
|
47
|
+
helpers,
|
|
48
|
+
`const __vizeWorkerFn = (${fn.toString()});`,
|
|
49
|
+
"self.onmessage = async (event) => {",
|
|
50
|
+
" try {",
|
|
51
|
+
" self.postMessage([\"success\", await __vizeWorkerFn(...event.data)]);",
|
|
52
|
+
" } catch (error) {",
|
|
53
|
+
" self.postMessage([\"error\", error instanceof Error ? error.message : String(error)]);",
|
|
54
|
+
" }",
|
|
55
|
+
"};"
|
|
56
|
+
].filter((line) => line !== "").join("\n");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Run a CPU-heavy function in a dedicated Blob-URL worker, off the main thread.
|
|
60
|
+
*
|
|
61
|
+
* Each `run` spawns a fresh worker, posts the arguments, and resolves with the
|
|
62
|
+
* function's (awaited) result; the worker is terminated and its URL revoked
|
|
63
|
+
* once the run settles, times out, or is terminated. Concurrent runs reject
|
|
64
|
+
* with `VIZE_COMPOSE_WORKER_FN_BUSY`. The running worker is terminated when
|
|
65
|
+
* the owning reactive scope stops. Server rendering never spawns workers:
|
|
66
|
+
* `supported` is `false` and `run` rejects with
|
|
67
|
+
* `VIZE_COMPOSE_WORKER_FN_UNSUPPORTED`.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const { run, status } = useWorkerFn((values: number[]) =>
|
|
72
|
+
* [...values].sort((a, b) => a - b),
|
|
73
|
+
* );
|
|
74
|
+
* const sorted = await run(bigArray);
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param fn Self-contained function; see {@link createWorkerFnScript}.
|
|
78
|
+
* @param options Timeout, dependencies, host, and scheduler.
|
|
79
|
+
* @default options {}
|
|
80
|
+
* @throws {RangeError} `[VIZE_COMPOSE_WORKER_FN_INVALID_TIMEOUT]` for an invalid timeout.
|
|
81
|
+
* @returns Reactive status and run controls.
|
|
82
|
+
*/
|
|
83
|
+
function useWorkerFn(fn, options = {}) {
|
|
84
|
+
const { timeoutMs } = options;
|
|
85
|
+
if (timeoutMs !== void 0 && (!Number.isFinite(timeoutMs) || timeoutMs < 0)) throw new RangeError(`[VIZE_COMPOSE_WORKER_FN_INVALID_TIMEOUT] timeoutMs must be a finite non-negative number; received ${String(timeoutMs)}`);
|
|
86
|
+
const status = shallowRef("idle");
|
|
87
|
+
const resolveHost = () => options.host === void 0 ? browserHost() : toValue(options.host) ?? void 0;
|
|
88
|
+
const supported = shallowRef(resolveHost() !== void 0);
|
|
89
|
+
const scheduler = options.scheduler ?? defaultScheduler();
|
|
90
|
+
let cancelActive;
|
|
91
|
+
const run = (...arguments_) => {
|
|
92
|
+
const host = resolveHost();
|
|
93
|
+
supported.value = host !== void 0;
|
|
94
|
+
if (host === void 0) return Promise.reject(workerError("VIZE_COMPOSE_WORKER_FN_UNSUPPORTED", "workers are not available"));
|
|
95
|
+
if (cancelActive !== void 0) return Promise.reject(workerError("VIZE_COMPOSE_WORKER_FN_BUSY", "a run is already in progress"));
|
|
96
|
+
const script = createWorkerFnScript(fn, options);
|
|
97
|
+
const url = host.createObjectURL(new Blob([script], { type: "text/javascript" }));
|
|
98
|
+
let worker;
|
|
99
|
+
try {
|
|
100
|
+
worker = new host.Worker(url);
|
|
101
|
+
} catch (cause) {
|
|
102
|
+
host.revokeObjectURL(url);
|
|
103
|
+
status.value = "error";
|
|
104
|
+
return Promise.reject(workerError("VIZE_COMPOSE_WORKER_FN_FAILED", "the worker could not start", cause));
|
|
105
|
+
}
|
|
106
|
+
status.value = "running";
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
let timer;
|
|
109
|
+
const cleanup = () => {
|
|
110
|
+
cancelActive = void 0;
|
|
111
|
+
if (timer !== void 0) scheduler.clearTimeout(timer);
|
|
112
|
+
worker.removeEventListener("message", onMessage);
|
|
113
|
+
worker.removeEventListener("messageerror", onFailure);
|
|
114
|
+
worker.removeEventListener("error", onFailure);
|
|
115
|
+
worker.terminate();
|
|
116
|
+
host.revokeObjectURL(url);
|
|
117
|
+
};
|
|
118
|
+
const settleError = (error, next) => {
|
|
119
|
+
cleanup();
|
|
120
|
+
status.value = next;
|
|
121
|
+
reject(error);
|
|
122
|
+
};
|
|
123
|
+
const onMessage = (event) => {
|
|
124
|
+
const payload = "data" in event ? event.data : void 0;
|
|
125
|
+
if (!Array.isArray(payload) || payload.length !== 2) return;
|
|
126
|
+
const [kind, value] = payload;
|
|
127
|
+
if (kind === "success") {
|
|
128
|
+
cleanup();
|
|
129
|
+
status.value = "success";
|
|
130
|
+
resolve(workerResult(value));
|
|
131
|
+
} else settleError(workerError("VIZE_COMPOSE_WORKER_FN_FAILED", String(value)), "error");
|
|
132
|
+
};
|
|
133
|
+
const onFailure = (event) => {
|
|
134
|
+
settleError(workerError("VIZE_COMPOSE_WORKER_FN_FAILED", "message" in event && typeof event.message === "string" ? event.message : event.type, event), "error");
|
|
135
|
+
};
|
|
136
|
+
cancelActive = settleError;
|
|
137
|
+
worker.addEventListener("message", onMessage);
|
|
138
|
+
worker.addEventListener("messageerror", onFailure);
|
|
139
|
+
worker.addEventListener("error", onFailure);
|
|
140
|
+
if (timeoutMs !== void 0) timer = scheduler.setTimeout(() => {
|
|
141
|
+
timer = void 0;
|
|
142
|
+
settleError(workerError("VIZE_COMPOSE_WORKER_FN_TIMEOUT", `the run exceeded ${String(timeoutMs)} ms`), "timeout");
|
|
143
|
+
}, timeoutMs);
|
|
144
|
+
worker.postMessage(arguments_);
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
const terminate = () => {
|
|
148
|
+
cancelActive?.(workerError("VIZE_COMPOSE_WORKER_FN_TERMINATED", "the worker was terminated"), "idle");
|
|
149
|
+
};
|
|
150
|
+
tryOnScopeDispose(terminate);
|
|
151
|
+
return {
|
|
152
|
+
status: readonly(status),
|
|
153
|
+
supported: readonly(supported),
|
|
154
|
+
run,
|
|
155
|
+
terminate
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function workerResult(value) {
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
export { createWorkerFnScript, useWorkerFn };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ResizeObserverHost } from "./resize-observer.mjs";
|
|
2
|
+
import { ElementRefSetter } from "./element-ref.mjs";
|
|
3
|
+
import { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
4
|
+
|
|
5
|
+
//#region src/virtual-list.d.ts
|
|
6
|
+
/** Item size: a fixed size in CSS pixels or a per-item function. */
|
|
7
|
+
type VirtualItemSize<Item> = number | ((index: number, item: Item) => number);
|
|
8
|
+
/** Scroll axis of {@link useVirtualList}. */
|
|
9
|
+
type VirtualListOrientation = "vertical" | "horizontal";
|
|
10
|
+
/** Options for {@link useVirtualList}. */
|
|
11
|
+
interface UseVirtualListOptions<Item> {
|
|
12
|
+
/** Item size along the scroll axis. */
|
|
13
|
+
readonly itemSize: VirtualItemSize<Item>;
|
|
14
|
+
/**
|
|
15
|
+
* Extra items rendered before and after the visible range.
|
|
16
|
+
*
|
|
17
|
+
* @default 5
|
|
18
|
+
*/
|
|
19
|
+
readonly overscan?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Scroll axis.
|
|
22
|
+
*
|
|
23
|
+
* @default "vertical"
|
|
24
|
+
*/
|
|
25
|
+
readonly orientation?: VirtualListOrientation;
|
|
26
|
+
/**
|
|
27
|
+
* Items rendered before the container is measured (every server render).
|
|
28
|
+
* Keeps SSR output deterministic and non-empty for crawlers.
|
|
29
|
+
*
|
|
30
|
+
* @default 10
|
|
31
|
+
*/
|
|
32
|
+
readonly initialItemCount?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Resize-observer capability used to measure the container.
|
|
35
|
+
*
|
|
36
|
+
* @default globalThis when it provides `ResizeObserver`
|
|
37
|
+
*/
|
|
38
|
+
readonly host?: MaybeRefOrGetter<ResizeObserverHost | null | undefined>;
|
|
39
|
+
}
|
|
40
|
+
/** One rendered row/column of {@link useVirtualList}. */
|
|
41
|
+
interface VirtualListItem<Item> {
|
|
42
|
+
/** Source item. */
|
|
43
|
+
readonly data: Item;
|
|
44
|
+
/** Index in the source list. */
|
|
45
|
+
readonly index: number;
|
|
46
|
+
/** Start offset along the scroll axis. */
|
|
47
|
+
readonly offset: number;
|
|
48
|
+
/** Size along the scroll axis. */
|
|
49
|
+
readonly size: number;
|
|
50
|
+
}
|
|
51
|
+
/** Inline style for the scroll container. */
|
|
52
|
+
interface VirtualContainerStyle {
|
|
53
|
+
/** Vertical overflow. */
|
|
54
|
+
readonly overflowY: "auto" | "hidden";
|
|
55
|
+
/** Horizontal overflow. */
|
|
56
|
+
readonly overflowX: "auto" | "hidden";
|
|
57
|
+
}
|
|
58
|
+
/** Inline style for the inner wrapper that holds the rendered items. */
|
|
59
|
+
interface VirtualWrapperStyle {
|
|
60
|
+
/** Wrapper width. */
|
|
61
|
+
readonly width: string;
|
|
62
|
+
/** Wrapper height. */
|
|
63
|
+
readonly height: string;
|
|
64
|
+
/** Leading offset (`margin-top` or `margin-left`). */
|
|
65
|
+
readonly marginTop: string;
|
|
66
|
+
/** Leading offset for horizontal lists. */
|
|
67
|
+
readonly marginLeft: string;
|
|
68
|
+
/** Horizontal lists lay items out in a row. */
|
|
69
|
+
readonly display: "block" | "flex";
|
|
70
|
+
}
|
|
71
|
+
/** State and bindings returned by {@link useVirtualList}. */
|
|
72
|
+
interface VirtualListControls<Item> {
|
|
73
|
+
/** Items to render. */
|
|
74
|
+
readonly list: ComputedRef<readonly VirtualListItem<Item>[]>;
|
|
75
|
+
/** Total content size along the scroll axis. */
|
|
76
|
+
readonly totalSize: ComputedRef<number>;
|
|
77
|
+
/** Bind on the scroll container: `v-bind="containerProps"`. */
|
|
78
|
+
readonly containerProps: {
|
|
79
|
+
readonly ref: ElementRefSetter;
|
|
80
|
+
readonly onScroll: () => void;
|
|
81
|
+
readonly style: VirtualContainerStyle;
|
|
82
|
+
};
|
|
83
|
+
/** Bind on the inner wrapper: `v-bind="wrapperProps"`. */
|
|
84
|
+
readonly wrapperProps: ComputedRef<{
|
|
85
|
+
readonly style: VirtualWrapperStyle;
|
|
86
|
+
}>;
|
|
87
|
+
/** Scroll so that the item at `index` starts at the container edge. */
|
|
88
|
+
readonly scrollTo: (index: number) => void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Render only the visible slice of a long list (fixed or variable item sizes).
|
|
92
|
+
*
|
|
93
|
+
* Offsets are prefix sums recomputed when the items change; the visible range
|
|
94
|
+
* is found by binary search, so scrolling is O(log n). Until the container is
|
|
95
|
+
* measured (always on the server) the first `initialItemCount` items render,
|
|
96
|
+
* so server and first client render match. The container is measured on
|
|
97
|
+
* scroll and via `ResizeObserver`, released with the owning reactive scope.
|
|
98
|
+
*
|
|
99
|
+
* @param items Reactive source list.
|
|
100
|
+
* @param options Item size, overscan, axis, initial count, and capability.
|
|
101
|
+
* @returns Items to render plus container/wrapper bindings.
|
|
102
|
+
*/
|
|
103
|
+
declare function useVirtualList<Item>(items: MaybeRefOrGetter<readonly Item[]>, options: UseVirtualListOptions<Item>): VirtualListControls<Item>;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { UseVirtualListOptions, VirtualContainerStyle, VirtualItemSize, VirtualListControls, VirtualListItem, VirtualListOrientation, VirtualWrapperStyle, useVirtualList };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useResizeObserver } from "./resize-observer.mjs";
|
|
2
|
+
import { useElementRef } from "./element-ref.mjs";
|
|
3
|
+
import { computed, shallowRef, toValue } from "vue";
|
|
4
|
+
//#region src/virtual-list.ts
|
|
5
|
+
/**
|
|
6
|
+
* Render only the visible slice of a long list (fixed or variable item sizes).
|
|
7
|
+
*
|
|
8
|
+
* Offsets are prefix sums recomputed when the items change; the visible range
|
|
9
|
+
* is found by binary search, so scrolling is O(log n). Until the container is
|
|
10
|
+
* measured (always on the server) the first `initialItemCount` items render,
|
|
11
|
+
* so server and first client render match. The container is measured on
|
|
12
|
+
* scroll and via `ResizeObserver`, released with the owning reactive scope.
|
|
13
|
+
*
|
|
14
|
+
* @param items Reactive source list.
|
|
15
|
+
* @param options Item size, overscan, axis, initial count, and capability.
|
|
16
|
+
* @returns Items to render plus container/wrapper bindings.
|
|
17
|
+
*/
|
|
18
|
+
function useVirtualList(items, options) {
|
|
19
|
+
const overscan = Math.max(0, Math.floor(options.overscan ?? 5));
|
|
20
|
+
const vertical = (options.orientation ?? "vertical") === "vertical";
|
|
21
|
+
const initialCount = Math.max(0, Math.floor(options.initialItemCount ?? 10));
|
|
22
|
+
const { element: container, setRef } = useElementRef();
|
|
23
|
+
const viewport = shallowRef(null);
|
|
24
|
+
const scrollOffset = shallowRef(0);
|
|
25
|
+
const layout = computed(() => {
|
|
26
|
+
const source = toValue(items);
|
|
27
|
+
const offsets = new Float64Array(source.length + 1);
|
|
28
|
+
const size = options.itemSize;
|
|
29
|
+
for (const [index, item] of source.entries()) {
|
|
30
|
+
const next = typeof size === "number" ? size : size(index, item);
|
|
31
|
+
offsets[index + 1] = (offsets[index] ?? 0) + Math.max(0, next);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
source,
|
|
35
|
+
offsets
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
const totalSize = computed(() => layout.value.offsets[layout.value.source.length] ?? 0);
|
|
39
|
+
const measure = () => {
|
|
40
|
+
const element = container.value;
|
|
41
|
+
if (!element || !isScrollable(element)) return;
|
|
42
|
+
viewport.value = vertical ? element.clientHeight : element.clientWidth;
|
|
43
|
+
scrollOffset.value = vertical ? element.scrollTop : element.scrollLeft;
|
|
44
|
+
};
|
|
45
|
+
useResizeObserver(container, measure, options.host === void 0 ? { flush: "sync" } : {
|
|
46
|
+
host: options.host,
|
|
47
|
+
flush: "sync"
|
|
48
|
+
});
|
|
49
|
+
const range = computed(() => {
|
|
50
|
+
const { source, offsets } = layout.value;
|
|
51
|
+
if (viewport.value === null) return {
|
|
52
|
+
start: 0,
|
|
53
|
+
end: Math.min(source.length, initialCount)
|
|
54
|
+
};
|
|
55
|
+
const first = findIndex(offsets, source.length, scrollOffset.value);
|
|
56
|
+
const last = findIndex(offsets, source.length, scrollOffset.value + viewport.value);
|
|
57
|
+
return {
|
|
58
|
+
start: Math.max(0, first - overscan),
|
|
59
|
+
end: Math.min(source.length, last + 1 + overscan)
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const list = computed(() => {
|
|
63
|
+
const { source, offsets } = layout.value;
|
|
64
|
+
const { start, end } = range.value;
|
|
65
|
+
return source.slice(start, end).map((data, position) => {
|
|
66
|
+
const index = start + position;
|
|
67
|
+
const offset = offsets[index] ?? 0;
|
|
68
|
+
return {
|
|
69
|
+
data,
|
|
70
|
+
index,
|
|
71
|
+
offset,
|
|
72
|
+
size: (offsets[index + 1] ?? offset) - offset
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
const wrapperProps = computed(() => {
|
|
77
|
+
const leading = layout.value.offsets[range.value.start] ?? 0;
|
|
78
|
+
const remaining = `${totalSize.value - leading}px`;
|
|
79
|
+
return { style: {
|
|
80
|
+
width: vertical ? "100%" : remaining,
|
|
81
|
+
height: vertical ? remaining : "100%",
|
|
82
|
+
marginTop: vertical ? `${leading}px` : "0px",
|
|
83
|
+
marginLeft: vertical ? "0px" : `${leading}px`,
|
|
84
|
+
display: vertical ? "block" : "flex"
|
|
85
|
+
} };
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
list,
|
|
89
|
+
totalSize,
|
|
90
|
+
containerProps: {
|
|
91
|
+
ref: setRef,
|
|
92
|
+
onScroll: measure,
|
|
93
|
+
style: vertical ? {
|
|
94
|
+
overflowY: "auto",
|
|
95
|
+
overflowX: "hidden"
|
|
96
|
+
} : {
|
|
97
|
+
overflowY: "hidden",
|
|
98
|
+
overflowX: "auto"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
wrapperProps,
|
|
102
|
+
scrollTo: (index) => {
|
|
103
|
+
const element = container.value;
|
|
104
|
+
if (!element || !isScrollable(element)) return;
|
|
105
|
+
const { offsets, source } = layout.value;
|
|
106
|
+
const offset = offsets[Math.min(Math.max(0, Math.floor(index)), source.length)] ?? 0;
|
|
107
|
+
if (vertical) element.scrollTop = offset;
|
|
108
|
+
else element.scrollLeft = offset;
|
|
109
|
+
measure();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Largest index whose start offset is ≤ `position`. */
|
|
114
|
+
function findIndex(offsets, count, position) {
|
|
115
|
+
let low = 0;
|
|
116
|
+
let high = Math.max(0, count - 1);
|
|
117
|
+
while (low < high) {
|
|
118
|
+
const middle = low + high + 1 >> 1;
|
|
119
|
+
if ((offsets[middle] ?? 0) <= position) low = middle;
|
|
120
|
+
else high = middle - 1;
|
|
121
|
+
}
|
|
122
|
+
return low;
|
|
123
|
+
}
|
|
124
|
+
function isScrollable(element) {
|
|
125
|
+
return "scrollTop" in element && "clientHeight" in element;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { useVirtualList };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { t as TimeoutScheduler } from "./timeout-scheduler-CI8RVLZs.mjs";
|
|
2
|
+
import { WatchHelperCallback, WatchSources } from "./watch-source.mjs";
|
|
3
|
+
import { MaybeRefOrGetter, WatchOptions } from "vue";
|
|
4
|
+
|
|
5
|
+
//#region src/watch-debounced.d.ts
|
|
6
|
+
/** Options for {@link watchDebounced}. */
|
|
7
|
+
interface WatchDebouncedOptions<Immediate extends boolean = false> extends WatchOptions<Immediate> {
|
|
8
|
+
/**
|
|
9
|
+
* Quiet period in milliseconds after the last change before the callback
|
|
10
|
+
* runs. Reactive; read whenever a call is scheduled.
|
|
11
|
+
*
|
|
12
|
+
* @default 0
|
|
13
|
+
*/
|
|
14
|
+
readonly debounce?: MaybeRefOrGetter<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Longest time a call may be postponed by continuous changes. When it
|
|
17
|
+
* elapses, the newest pending call runs even if changes keep coming.
|
|
18
|
+
*
|
|
19
|
+
* @default undefined (no ceiling)
|
|
20
|
+
*/
|
|
21
|
+
readonly maxWait?: MaybeRefOrGetter<number | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Applies the timing policy when no browser `window` is available. When
|
|
24
|
+
* disabled, the callback runs synchronously on the server.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
readonly runOnServer?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Owns the single-shot timers.
|
|
31
|
+
*
|
|
32
|
+
* @default globalThis timer functions
|
|
33
|
+
*/
|
|
34
|
+
readonly scheduler?: TimeoutScheduler;
|
|
35
|
+
}
|
|
36
|
+
/** Stop handle plus timing controls returned by the debounced/throttled watchers. */
|
|
37
|
+
interface TimedWatchHandle {
|
|
38
|
+
/** Stop watching and discard any pending call. */
|
|
39
|
+
readonly stop: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Run the pending call now instead of waiting.
|
|
42
|
+
*
|
|
43
|
+
* @returns Whether a pending call was run.
|
|
44
|
+
*/
|
|
45
|
+
readonly flush: () => boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Discard the pending call; later changes schedule again.
|
|
48
|
+
*
|
|
49
|
+
* @returns Whether a pending call was discarded.
|
|
50
|
+
*/
|
|
51
|
+
readonly cancel: () => boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Watch sources like Vue's `watch`, but run the callback only after the
|
|
55
|
+
* sources stayed quiet for `debounce` milliseconds.
|
|
56
|
+
*
|
|
57
|
+
* The callback receives the newest value together with the old value from
|
|
58
|
+
* before the first change of the burst, so it always describes the whole
|
|
59
|
+
* settled transition. `onCleanup` registered by a callback runs before the
|
|
60
|
+
* next call, as with `watch`. `maxWait` bounds starvation under continuous
|
|
61
|
+
* changes. Source typing mirrors `watch`, including tuples and the
|
|
62
|
+
* `immediate` flag (an immediate first call is debounced too).
|
|
63
|
+
*
|
|
64
|
+
* Without a browser `window` (and without `runOnServer`) the callback runs
|
|
65
|
+
* synchronously, so server-side effects are not silently dropped. Timers are
|
|
66
|
+
* cleared when the watcher stops or the owning scope is disposed.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* watchDebounced(query, (value) => search(value), { debounce: 300, maxWait: 1_000 });
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param source Ref, getter, reactive object, or tuple of those.
|
|
74
|
+
* @param callback Debounced watch callback.
|
|
75
|
+
* @param options Watch options plus the debounce policy.
|
|
76
|
+
* @default options {}
|
|
77
|
+
* @throws `RangeError` tagged `VIZE_COMPOSE_WATCH_DEBOUNCED_INVALID_DELAY`
|
|
78
|
+
* when `debounce` or `maxWait` resolve to a negative or non-finite value,
|
|
79
|
+
* synchronously at creation and whenever a call is scheduled.
|
|
80
|
+
* @returns Stop, flush, and cancel controls.
|
|
81
|
+
*/
|
|
82
|
+
declare function watchDebounced<const Sources extends WatchSources, Immediate extends Readonly<boolean> = false>(source: Sources, callback: WatchHelperCallback<Sources, Immediate>, options?: WatchDebouncedOptions<Immediate>): TimedWatchHandle;
|
|
83
|
+
//#endregion
|
|
84
|
+
export { TimedWatchHandle, WatchDebouncedOptions, watchDebounced };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { toValue, watch } from "vue";
|
|
3
|
+
//#region src/watch-debounced.ts
|
|
4
|
+
const defaultScheduler = {
|
|
5
|
+
setTimeout: (callback, delayMs) => globalThis.setTimeout(callback, delayMs),
|
|
6
|
+
clearTimeout: (handle) => {
|
|
7
|
+
globalThis.clearTimeout(handle);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function resolveMs(value, name) {
|
|
11
|
+
if (!Number.isFinite(value) || value < 0) throw new RangeError(`[VIZE_COMPOSE_WATCH_DEBOUNCED_INVALID_DELAY] ${name} must be finite and at least zero; received ${String(value)}`);
|
|
12
|
+
return Math.trunc(value);
|
|
13
|
+
}
|
|
14
|
+
function watchDebounced(source, callback, options = {}) {
|
|
15
|
+
const { debounce = 0, maxWait, runOnServer = false, scheduler = defaultScheduler, ...watchOptions } = options;
|
|
16
|
+
resolveMs(toValue(debounce), "debounce");
|
|
17
|
+
const initialMaxWait = toValue(maxWait);
|
|
18
|
+
if (initialMaxWait !== void 0) resolveMs(initialMaxWait, "maxWait");
|
|
19
|
+
let timer;
|
|
20
|
+
let maxTimer;
|
|
21
|
+
let pending;
|
|
22
|
+
let burstOld;
|
|
23
|
+
let cleanup;
|
|
24
|
+
const clearTimers = () => {
|
|
25
|
+
if (timer !== void 0) scheduler.clearTimeout(timer);
|
|
26
|
+
if (maxTimer !== void 0) scheduler.clearTimeout(maxTimer);
|
|
27
|
+
timer = void 0;
|
|
28
|
+
maxTimer = void 0;
|
|
29
|
+
};
|
|
30
|
+
const invoke = (value, oldValue) => {
|
|
31
|
+
const runCleanup = cleanup;
|
|
32
|
+
cleanup = void 0;
|
|
33
|
+
runCleanup?.();
|
|
34
|
+
const onCleanup = (fn) => {
|
|
35
|
+
cleanup = fn;
|
|
36
|
+
};
|
|
37
|
+
callback(value, oldValue, onCleanup);
|
|
38
|
+
};
|
|
39
|
+
const flush = () => {
|
|
40
|
+
const run = pending;
|
|
41
|
+
if (run === void 0) return false;
|
|
42
|
+
clearTimers();
|
|
43
|
+
pending = void 0;
|
|
44
|
+
run();
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
const cancel = () => {
|
|
48
|
+
if (pending === void 0) return false;
|
|
49
|
+
clearTimers();
|
|
50
|
+
pending = void 0;
|
|
51
|
+
return true;
|
|
52
|
+
};
|
|
53
|
+
const handle = watch(source, (value, oldValue) => {
|
|
54
|
+
if (typeof window === "undefined" && !runOnServer) {
|
|
55
|
+
invoke(value, oldValue);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (pending === void 0) burstOld = oldValue;
|
|
59
|
+
const settledOld = burstOld;
|
|
60
|
+
pending = () => {
|
|
61
|
+
invoke(value, settledOld);
|
|
62
|
+
};
|
|
63
|
+
const delay = resolveMs(toValue(debounce), "debounce");
|
|
64
|
+
if (timer !== void 0) scheduler.clearTimeout(timer);
|
|
65
|
+
timer = scheduler.setTimeout(flush, delay);
|
|
66
|
+
const ceiling = toValue(maxWait);
|
|
67
|
+
if (ceiling !== void 0 && maxTimer === void 0) maxTimer = scheduler.setTimeout(flush, resolveMs(ceiling, "maxWait"));
|
|
68
|
+
}, watchOptions);
|
|
69
|
+
const stop = () => {
|
|
70
|
+
handle.stop();
|
|
71
|
+
cancel();
|
|
72
|
+
const runCleanup = cleanup;
|
|
73
|
+
cleanup = void 0;
|
|
74
|
+
runCleanup?.();
|
|
75
|
+
};
|
|
76
|
+
tryOnScopeDispose(stop);
|
|
77
|
+
return {
|
|
78
|
+
stop,
|
|
79
|
+
flush,
|
|
80
|
+
cancel
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { watchDebounced };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { WatchHelperCallback, WatchSources } from "./watch-source.mjs";
|
|
2
|
+
import { WatchOptions } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/watch-ignorable.d.ts
|
|
5
|
+
/** Controls returned by {@link watchIgnorable}. */
|
|
6
|
+
interface IgnorableWatchHandle {
|
|
7
|
+
/**
|
|
8
|
+
* Run `updater` so that the source changes it makes synchronously do not
|
|
9
|
+
* trigger the callback.
|
|
10
|
+
*/
|
|
11
|
+
readonly ignoreUpdates: (updater: () => void) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Swallow the changes already queued for the next (non-sync) flush. A
|
|
14
|
+
* no-op for `flush: "sync"` watchers, which have nothing queued.
|
|
15
|
+
*/
|
|
16
|
+
readonly ignorePrevAsyncUpdates: () => void;
|
|
17
|
+
/** Stop watching permanently. */
|
|
18
|
+
readonly stop: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Watch sources like Vue's `watch`, with a way to make changes the callback
|
|
22
|
+
* should not see.
|
|
23
|
+
*
|
|
24
|
+
* Typical use is two-way syncing: writes performed inside `ignoreUpdates`
|
|
25
|
+
* (for example applying a server echo) do not bounce back. Works with every
|
|
26
|
+
* `flush` mode: for `"pre"`/`"post"`, a synchronous side watcher counts
|
|
27
|
+
* changes so that a batch made only of ignored writes is skipped, while a
|
|
28
|
+
* batch that mixes ignored and regular writes is still delivered. Stops
|
|
29
|
+
* with the owning reactive scope; safe during server rendering.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const { ignoreUpdates } = watchIgnorable(draft, (value) => save(value));
|
|
34
|
+
* ignoreUpdates(() => {
|
|
35
|
+
* draft.value = fromServer; // not saved again
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param source Ref, getter, reactive object, or tuple of those.
|
|
40
|
+
* @param callback Watch callback for non-ignored changes.
|
|
41
|
+
* @param options Vue watch options.
|
|
42
|
+
* @default options {}
|
|
43
|
+
* @returns Ignore helpers and the stop handle.
|
|
44
|
+
*/
|
|
45
|
+
declare function watchIgnorable<const Sources extends WatchSources, Immediate extends Readonly<boolean> = false>(source: Sources, callback: WatchHelperCallback<Sources, Immediate>, options?: WatchOptions<Immediate>): IgnorableWatchHandle;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { IgnorableWatchHandle, watchIgnorable };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
//#region src/watch-ignorable.ts
|
|
3
|
+
function watchIgnorable(source, callback, options = {}) {
|
|
4
|
+
if (options.flush === "sync") {
|
|
5
|
+
let ignoring = false;
|
|
6
|
+
const handle = watch(source, (value, oldValue, onCleanup) => {
|
|
7
|
+
if (!ignoring) callback(value, oldValue, onCleanup);
|
|
8
|
+
}, options);
|
|
9
|
+
return {
|
|
10
|
+
ignoreUpdates: (updater) => {
|
|
11
|
+
const previous = ignoring;
|
|
12
|
+
ignoring = true;
|
|
13
|
+
try {
|
|
14
|
+
updater();
|
|
15
|
+
} finally {
|
|
16
|
+
ignoring = previous;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
ignorePrevAsyncUpdates: () => void 0,
|
|
20
|
+
stop: () => {
|
|
21
|
+
handle.stop();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let ignoredCount = 0;
|
|
26
|
+
let changeCount = 0;
|
|
27
|
+
const counter = watch(source, () => {
|
|
28
|
+
changeCount += 1;
|
|
29
|
+
}, {
|
|
30
|
+
...options,
|
|
31
|
+
flush: "sync",
|
|
32
|
+
immediate: false,
|
|
33
|
+
once: false
|
|
34
|
+
});
|
|
35
|
+
const handle = watch(source, (value, oldValue, onCleanup) => {
|
|
36
|
+
const ignore = ignoredCount > 0 && ignoredCount === changeCount;
|
|
37
|
+
ignoredCount = 0;
|
|
38
|
+
changeCount = 0;
|
|
39
|
+
if (options.once === true) counter.stop();
|
|
40
|
+
if (!ignore) callback(value, oldValue, onCleanup);
|
|
41
|
+
}, options);
|
|
42
|
+
return {
|
|
43
|
+
ignoreUpdates: (updater) => {
|
|
44
|
+
const before = changeCount;
|
|
45
|
+
try {
|
|
46
|
+
updater();
|
|
47
|
+
} finally {
|
|
48
|
+
ignoredCount += changeCount - before;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
ignorePrevAsyncUpdates: () => {
|
|
52
|
+
ignoredCount = changeCount;
|
|
53
|
+
},
|
|
54
|
+
stop: () => {
|
|
55
|
+
counter.stop();
|
|
56
|
+
handle.stop();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { watchIgnorable };
|