@vizejs/composable 0.426.3 → 0.428.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,178 @@
|
|
|
1
|
+
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
|
+
import { computed, hasInjectionContext, readonly, ref, shallowReadonly, shallowRef, toValue, watch, watchPostEffect } from "vue";
|
|
3
|
+
//#region src/use-service-worker.ts
|
|
4
|
+
const emptyStates = {
|
|
5
|
+
installing: null,
|
|
6
|
+
waiting: null,
|
|
7
|
+
active: null
|
|
8
|
+
};
|
|
9
|
+
function browserContainer() {
|
|
10
|
+
if (typeof window === "undefined") return void 0;
|
|
11
|
+
const { navigator } = window;
|
|
12
|
+
return "serviceWorker" in navigator && navigator.serviceWorker ? navigator.serviceWorker : void 0;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Register a service worker and follow its update lifecycle.
|
|
16
|
+
*
|
|
17
|
+
* Tracks `updatefound` and each worker's `statechange` so `state` mirrors
|
|
18
|
+
* the installing, waiting and active workers. `updateAvailable` turns true
|
|
19
|
+
* once an installed worker waits while another one controls the page;
|
|
20
|
+
* `skipWaiting()` then posts the configured message to it, and
|
|
21
|
+
* `onControllerChange` runs once it takes control. Listeners are removed
|
|
22
|
+
* when the owning reactive scope stops; outside a scope they live as long as
|
|
23
|
+
* the registration.
|
|
24
|
+
*
|
|
25
|
+
* Server rendering: nothing is registered, `supported` is false and every
|
|
26
|
+
* state is `null`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const sw = useServiceWorker("/sw.js", {
|
|
31
|
+
* onControllerChange: () => window.location.reload(),
|
|
32
|
+
* });
|
|
33
|
+
* const applyUpdate = () => sw.skipWaiting();
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param scriptUrl Service worker script URL.
|
|
37
|
+
* @param options Container override, registration options and update hooks.
|
|
38
|
+
* @default options {}
|
|
39
|
+
* @returns Registration state and actions.
|
|
40
|
+
*/
|
|
41
|
+
function useServiceWorker(scriptUrl, options = {}) {
|
|
42
|
+
const registration = shallowRef(null);
|
|
43
|
+
const state = ref(emptyStates);
|
|
44
|
+
const controller = shallowRef(null);
|
|
45
|
+
const error = shallowRef(void 0);
|
|
46
|
+
const watched = /* @__PURE__ */ new Set();
|
|
47
|
+
let active = true;
|
|
48
|
+
const hydrated = shallowRef(!hasInjectionContext());
|
|
49
|
+
if (!hydrated.value) watchPostEffect(() => {
|
|
50
|
+
hydrated.value = true;
|
|
51
|
+
});
|
|
52
|
+
const resolveContainer = () => !hydrated.value ? void 0 : options.container === void 0 ? browserContainer() : toValue(options.container) ?? void 0;
|
|
53
|
+
const sync = () => {
|
|
54
|
+
const current = registration.value;
|
|
55
|
+
if (!current) {
|
|
56
|
+
state.value = emptyStates;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
for (const worker of [
|
|
60
|
+
current.installing,
|
|
61
|
+
current.waiting,
|
|
62
|
+
current.active
|
|
63
|
+
]) if (worker && !watched.has(worker)) {
|
|
64
|
+
watched.add(worker);
|
|
65
|
+
worker.addEventListener("statechange", sync);
|
|
66
|
+
}
|
|
67
|
+
state.value = {
|
|
68
|
+
installing: current.installing?.state ?? null,
|
|
69
|
+
waiting: current.waiting?.state ?? null,
|
|
70
|
+
active: current.active?.state ?? null
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const unwatchWorkers = () => {
|
|
74
|
+
for (const worker of watched) worker.removeEventListener("statechange", sync);
|
|
75
|
+
watched.clear();
|
|
76
|
+
};
|
|
77
|
+
watch(registration, (current, _previous, onCleanup) => {
|
|
78
|
+
sync();
|
|
79
|
+
if (!current) return;
|
|
80
|
+
current.addEventListener("updatefound", sync);
|
|
81
|
+
onCleanup(() => {
|
|
82
|
+
current.removeEventListener("updatefound", sync);
|
|
83
|
+
unwatchWorkers();
|
|
84
|
+
});
|
|
85
|
+
}, { flush: "sync" });
|
|
86
|
+
watch(resolveContainer, (container, _previous, onCleanup) => {
|
|
87
|
+
controller.value = container?.controller ?? null;
|
|
88
|
+
if (!container) return;
|
|
89
|
+
const onChange = () => {
|
|
90
|
+
controller.value = container.controller;
|
|
91
|
+
sync();
|
|
92
|
+
options.onControllerChange?.(container.controller);
|
|
93
|
+
};
|
|
94
|
+
container.addEventListener("controllerchange", onChange);
|
|
95
|
+
onCleanup(() => container.removeEventListener("controllerchange", onChange));
|
|
96
|
+
}, {
|
|
97
|
+
immediate: true,
|
|
98
|
+
flush: "sync"
|
|
99
|
+
});
|
|
100
|
+
const register = async () => {
|
|
101
|
+
const container = resolveContainer();
|
|
102
|
+
if (!container) return null;
|
|
103
|
+
const registerOptions = {};
|
|
104
|
+
if (options.scope !== void 0) registerOptions.scope = options.scope;
|
|
105
|
+
if (options.type !== void 0) registerOptions.type = options.type;
|
|
106
|
+
if (options.updateViaCache !== void 0) registerOptions.updateViaCache = options.updateViaCache;
|
|
107
|
+
try {
|
|
108
|
+
const next = await container.register(toValue(scriptUrl), registerOptions);
|
|
109
|
+
if (!active) return next;
|
|
110
|
+
registration.value = next;
|
|
111
|
+
error.value = void 0;
|
|
112
|
+
return next;
|
|
113
|
+
} catch (cause) {
|
|
114
|
+
if (active) error.value = cause;
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const update = async () => {
|
|
119
|
+
const current = registration.value;
|
|
120
|
+
if (!current) return false;
|
|
121
|
+
try {
|
|
122
|
+
await current.update();
|
|
123
|
+
error.value = void 0;
|
|
124
|
+
sync();
|
|
125
|
+
return true;
|
|
126
|
+
} catch (cause) {
|
|
127
|
+
error.value = cause;
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const skipWaiting = () => {
|
|
132
|
+
const waiting = registration.value?.waiting;
|
|
133
|
+
if (!waiting) return false;
|
|
134
|
+
waiting.postMessage("skipWaitingMessage" in options ? options.skipWaitingMessage : { type: "SKIP_WAITING" });
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
const unregister = async () => {
|
|
138
|
+
const current = registration.value;
|
|
139
|
+
if (!current) return false;
|
|
140
|
+
try {
|
|
141
|
+
const removed = await current.unregister();
|
|
142
|
+
if (removed) registration.value = null;
|
|
143
|
+
error.value = void 0;
|
|
144
|
+
return removed;
|
|
145
|
+
} catch (cause) {
|
|
146
|
+
error.value = cause;
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
if (options.immediate ?? true) {
|
|
151
|
+
let registered = false;
|
|
152
|
+
watch(() => resolveContainer() !== void 0, (ready) => {
|
|
153
|
+
if (!ready || registered) return;
|
|
154
|
+
registered = true;
|
|
155
|
+
register();
|
|
156
|
+
}, {
|
|
157
|
+
immediate: true,
|
|
158
|
+
flush: "sync"
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
tryOnScopeDispose(() => {
|
|
162
|
+
active = false;
|
|
163
|
+
registration.value = null;
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
supported: computed(() => resolveContainer() !== void 0),
|
|
167
|
+
registration: shallowReadonly(registration),
|
|
168
|
+
state: readonly(state),
|
|
169
|
+
updateAvailable: computed(() => state.value.waiting !== null && controller.value !== null),
|
|
170
|
+
error: readonly(error),
|
|
171
|
+
register,
|
|
172
|
+
update,
|
|
173
|
+
skipWaiting,
|
|
174
|
+
unregister
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
//#endregion
|
|
178
|
+
export { useServiceWorker };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ComputedRef } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-set.d.ts
|
|
4
|
+
/** Reactive set wrapper returned by {@link useSet}. */
|
|
5
|
+
interface SetControls<Item> {
|
|
6
|
+
/**
|
|
7
|
+
* Read-only reactive view of the set. `has`, iteration, and `size` on this
|
|
8
|
+
* view are tracked. Members are stored shallowly.
|
|
9
|
+
*/
|
|
10
|
+
readonly set: ReadonlySet<Item>;
|
|
11
|
+
/** Number of members. */
|
|
12
|
+
readonly size: ComputedRef<number>;
|
|
13
|
+
/** Snapshot of the members in insertion order. */
|
|
14
|
+
readonly values: ComputedRef<readonly Item[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether `item` is a member. Reactive when read inside an effect.
|
|
17
|
+
*
|
|
18
|
+
* @param item Candidate member.
|
|
19
|
+
* @returns Whether it is present.
|
|
20
|
+
*/
|
|
21
|
+
readonly has: (item: Item) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Add `item`.
|
|
24
|
+
*
|
|
25
|
+
* @param item Member to add.
|
|
26
|
+
* @returns Whether it was newly added.
|
|
27
|
+
*/
|
|
28
|
+
readonly add: (item: Item) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Remove `item`.
|
|
31
|
+
*
|
|
32
|
+
* @param item Member to remove.
|
|
33
|
+
* @returns Whether it was removed.
|
|
34
|
+
*/
|
|
35
|
+
readonly delete: (item: Item) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Add `item` when absent and remove it when present, or force membership.
|
|
38
|
+
* Passing an explicit `undefined` behaves like passing no argument.
|
|
39
|
+
*
|
|
40
|
+
* @param item Member to toggle.
|
|
41
|
+
* @param force Membership to force instead of inverting.
|
|
42
|
+
* @returns Whether `item` is a member afterwards.
|
|
43
|
+
*/
|
|
44
|
+
readonly toggle: (item: Item, force?: boolean) => boolean;
|
|
45
|
+
/** Remove every member. */
|
|
46
|
+
readonly clear: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Members of this set or `other`.
|
|
49
|
+
*
|
|
50
|
+
* @param other Items to combine with.
|
|
51
|
+
* @returns A new, non-reactive set.
|
|
52
|
+
*/
|
|
53
|
+
readonly union: (other: Iterable<Item>) => Set<Item>;
|
|
54
|
+
/**
|
|
55
|
+
* Members of this set that are also in `other`.
|
|
56
|
+
*
|
|
57
|
+
* @param other Items to intersect with.
|
|
58
|
+
* @returns A new, non-reactive set.
|
|
59
|
+
*/
|
|
60
|
+
readonly intersection: (other: Iterable<Item>) => Set<Item>;
|
|
61
|
+
/**
|
|
62
|
+
* Members of this set that are not in `other`.
|
|
63
|
+
*
|
|
64
|
+
* @param other Items to subtract.
|
|
65
|
+
* @returns A new, non-reactive set.
|
|
66
|
+
*/
|
|
67
|
+
readonly difference: (other: Iterable<Item>) => Set<Item>;
|
|
68
|
+
/** Restore the creation-time members. */
|
|
69
|
+
readonly reset: () => void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a reactive `Set` with typed helpers.
|
|
73
|
+
*
|
|
74
|
+
* The member type is inferred from the initial items (`useSet(["a"])` is a
|
|
75
|
+
* `Set<string>`); pass a type argument for an initially empty set.
|
|
76
|
+
* Membership checks are tracked per item. The set-algebra helpers return
|
|
77
|
+
* new plain sets and do not require ES2025 `Set` methods.
|
|
78
|
+
*
|
|
79
|
+
* Purely synchronous state: safe during server rendering (no host globals,
|
|
80
|
+
* no timers) and nothing to dispose.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const selected = useSet<number>();
|
|
85
|
+
* selected.toggle(3); // true
|
|
86
|
+
* selected.has(3); // true
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @typeParam Item Member type, inferred from `initial`.
|
|
90
|
+
* @param initial Members added at creation and restored by `reset`.
|
|
91
|
+
* @default initial []
|
|
92
|
+
* @returns The reactive set and its helpers.
|
|
93
|
+
*/
|
|
94
|
+
declare function useSet<Item = unknown>(initial?: Iterable<Item>): SetControls<Item>;
|
|
95
|
+
//#endregion
|
|
96
|
+
export { SetControls, useSet };
|
package/dist/use-set.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { computed, shallowReactive, shallowReadonly } from "vue";
|
|
2
|
+
//#region src/use-set.ts
|
|
3
|
+
/**
|
|
4
|
+
* Create a reactive `Set` with typed helpers.
|
|
5
|
+
*
|
|
6
|
+
* The member type is inferred from the initial items (`useSet(["a"])` is a
|
|
7
|
+
* `Set<string>`); pass a type argument for an initially empty set.
|
|
8
|
+
* Membership checks are tracked per item. The set-algebra helpers return
|
|
9
|
+
* new plain sets and do not require ES2025 `Set` methods.
|
|
10
|
+
*
|
|
11
|
+
* Purely synchronous state: safe during server rendering (no host globals,
|
|
12
|
+
* no timers) and nothing to dispose.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const selected = useSet<number>();
|
|
17
|
+
* selected.toggle(3); // true
|
|
18
|
+
* selected.has(3); // true
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @typeParam Item Member type, inferred from `initial`.
|
|
22
|
+
* @param initial Members added at creation and restored by `reset`.
|
|
23
|
+
* @default initial []
|
|
24
|
+
* @returns The reactive set and its helpers.
|
|
25
|
+
*/
|
|
26
|
+
function useSet(initial = []) {
|
|
27
|
+
const baseline = [...initial];
|
|
28
|
+
const set = shallowReactive(new Set(baseline));
|
|
29
|
+
const add = (item) => {
|
|
30
|
+
if (set.has(item)) return false;
|
|
31
|
+
set.add(item);
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
set: shallowReadonly(set),
|
|
36
|
+
size: computed(() => set.size),
|
|
37
|
+
values: computed(() => [...set.values()]),
|
|
38
|
+
has: (item) => set.has(item),
|
|
39
|
+
add,
|
|
40
|
+
delete: (item) => set.delete(item),
|
|
41
|
+
toggle: (item, force) => {
|
|
42
|
+
const next = force ?? !set.has(item);
|
|
43
|
+
if (next) add(item);
|
|
44
|
+
else set.delete(item);
|
|
45
|
+
return next;
|
|
46
|
+
},
|
|
47
|
+
clear: () => {
|
|
48
|
+
set.clear();
|
|
49
|
+
},
|
|
50
|
+
union: (other) => {
|
|
51
|
+
const result = new Set(set);
|
|
52
|
+
for (const item of other) result.add(item);
|
|
53
|
+
return result;
|
|
54
|
+
},
|
|
55
|
+
intersection: (other) => {
|
|
56
|
+
const lookup = new Set(other);
|
|
57
|
+
const result = /* @__PURE__ */ new Set();
|
|
58
|
+
for (const item of set) if (lookup.has(item)) result.add(item);
|
|
59
|
+
return result;
|
|
60
|
+
},
|
|
61
|
+
difference: (other) => {
|
|
62
|
+
const lookup = new Set(other);
|
|
63
|
+
const result = /* @__PURE__ */ new Set();
|
|
64
|
+
for (const item of set) if (!lookup.has(item)) result.add(item);
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
reset: () => {
|
|
68
|
+
set.clear();
|
|
69
|
+
for (const item of baseline) set.add(item);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { useSet };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter, Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-share.d.ts
|
|
4
|
+
/** Data shared through the Web Share API. */
|
|
5
|
+
interface ShareDataLike {
|
|
6
|
+
/** Title of the shared content. */
|
|
7
|
+
readonly title?: string;
|
|
8
|
+
/** Body text of the shared content. */
|
|
9
|
+
readonly text?: string;
|
|
10
|
+
/** URL of the shared content. */
|
|
11
|
+
readonly url?: string;
|
|
12
|
+
/** Files to share (Level 2 of the Web Share API). */
|
|
13
|
+
readonly files?: File[];
|
|
14
|
+
}
|
|
15
|
+
/** Minimal Web Share capability (`navigator`). */
|
|
16
|
+
interface ShareHost {
|
|
17
|
+
/** Open the platform share sheet. */
|
|
18
|
+
share(data: ShareDataLike): Promise<void>;
|
|
19
|
+
/** Whether the platform can share `data`. Absent in older engines. */
|
|
20
|
+
canShare?(data?: ShareDataLike): boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Discriminated outcome of {@link ShareControls.share}. */
|
|
23
|
+
type ShareResult = {
|
|
24
|
+
/** The share sheet completed. */readonly status: "shared"; /** Data that was shared. */
|
|
25
|
+
readonly data: ShareDataLike;
|
|
26
|
+
} | {
|
|
27
|
+
/**
|
|
28
|
+
* `"cancelled"`: the user dismissed the sheet (AbortError).
|
|
29
|
+
* `"unsupported"`: no Web Share capability.
|
|
30
|
+
* `"invalid"`: the platform cannot share this data (canShare / TypeError).
|
|
31
|
+
* `"not-allowed"`: no transient user activation or blocked by policy.
|
|
32
|
+
* `"failed"`: any other failure.
|
|
33
|
+
*/
|
|
34
|
+
readonly status: "cancelled" | "unsupported" | "invalid" | "not-allowed" | "failed"; /** Exact error thrown by the host, when one was thrown. */
|
|
35
|
+
readonly error: unknown;
|
|
36
|
+
};
|
|
37
|
+
/** Options for {@link useShare}. */
|
|
38
|
+
interface UseShareOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Web Share capability for alternate runtimes and tests.
|
|
41
|
+
*
|
|
42
|
+
* @default window.navigator when it implements `share`
|
|
43
|
+
*/
|
|
44
|
+
readonly host?: MaybeRefOrGetter<ShareHost | null | undefined>;
|
|
45
|
+
}
|
|
46
|
+
/** Reactive state and actions returned by {@link useShare}. */
|
|
47
|
+
interface ShareControls {
|
|
48
|
+
/** Whether the Web Share API is available. */
|
|
49
|
+
readonly supported: ComputedRef<boolean>;
|
|
50
|
+
/** Whether a share sheet opened by this composable is currently open. */
|
|
51
|
+
readonly sharing: Readonly<Ref<boolean>>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the platform can share the given (or default) data.
|
|
54
|
+
*
|
|
55
|
+
* @param data Data merged over the defaults.
|
|
56
|
+
* @returns `false` when unsupported.
|
|
57
|
+
*/
|
|
58
|
+
readonly canShare: (data?: ShareDataLike) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Open the share sheet. Must run inside a user gesture in browsers.
|
|
61
|
+
*
|
|
62
|
+
* @param overrides Data merged over the defaults.
|
|
63
|
+
* @returns The discriminated outcome; never rejects.
|
|
64
|
+
*/
|
|
65
|
+
readonly share: (overrides?: ShareDataLike) => Promise<ShareResult>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Share text, links, and files through the platform share sheet.
|
|
69
|
+
*
|
|
70
|
+
* Reactive defaults are merged with per-call overrides. Outcomes are
|
|
71
|
+
* reported as a discriminated {@link ShareResult}, so a user dismissing the
|
|
72
|
+
* sheet (`"cancelled"`) is distinguishable from missing support or invalid
|
|
73
|
+
* data without try/catch.
|
|
74
|
+
*
|
|
75
|
+
* Server rendering: no capability is resolved, `supported` is false, and
|
|
76
|
+
* nothing is shared. No resources are retained, so nothing needs cleanup.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const { share, supported } = useShare(() => ({ title: document.title, url: location.href }));
|
|
81
|
+
* const onClick = () => share();
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param defaults Reactive default share data.
|
|
85
|
+
* @param options Web Share capability.
|
|
86
|
+
* @default defaults {}
|
|
87
|
+
* @default options {}
|
|
88
|
+
* @returns Share state and actions.
|
|
89
|
+
*/
|
|
90
|
+
declare function useShare(defaults?: MaybeRefOrGetter<ShareDataLike>, options?: UseShareOptions): ShareControls;
|
|
91
|
+
//#endregion
|
|
92
|
+
export { ShareControls, ShareDataLike, ShareHost, ShareResult, UseShareOptions, useShare };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { computed, readonly, ref, toValue } from "vue";
|
|
2
|
+
//#region src/use-share.ts
|
|
3
|
+
function browserShareHost() {
|
|
4
|
+
if (typeof window === "undefined") return void 0;
|
|
5
|
+
const { navigator } = window;
|
|
6
|
+
return typeof navigator.share === "function" ? navigator : void 0;
|
|
7
|
+
}
|
|
8
|
+
function errorName(error) {
|
|
9
|
+
return typeof error === "object" && error !== null && "name" in error ? String(error.name) : void 0;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Share text, links, and files through the platform share sheet.
|
|
13
|
+
*
|
|
14
|
+
* Reactive defaults are merged with per-call overrides. Outcomes are
|
|
15
|
+
* reported as a discriminated {@link ShareResult}, so a user dismissing the
|
|
16
|
+
* sheet (`"cancelled"`) is distinguishable from missing support or invalid
|
|
17
|
+
* data without try/catch.
|
|
18
|
+
*
|
|
19
|
+
* Server rendering: no capability is resolved, `supported` is false, and
|
|
20
|
+
* nothing is shared. No resources are retained, so nothing needs cleanup.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const { share, supported } = useShare(() => ({ title: document.title, url: location.href }));
|
|
25
|
+
* const onClick = () => share();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param defaults Reactive default share data.
|
|
29
|
+
* @param options Web Share capability.
|
|
30
|
+
* @default defaults {}
|
|
31
|
+
* @default options {}
|
|
32
|
+
* @returns Share state and actions.
|
|
33
|
+
*/
|
|
34
|
+
function useShare(defaults = {}, options = {}) {
|
|
35
|
+
const sharing = ref(false);
|
|
36
|
+
const resolveHost = () => options.host === void 0 ? browserShareHost() : toValue(options.host) ?? void 0;
|
|
37
|
+
const merge = (data) => ({
|
|
38
|
+
...toValue(defaults),
|
|
39
|
+
...data
|
|
40
|
+
});
|
|
41
|
+
const canShare = (data) => {
|
|
42
|
+
const host = resolveHost();
|
|
43
|
+
if (!host) return false;
|
|
44
|
+
if (!host.canShare) return true;
|
|
45
|
+
try {
|
|
46
|
+
return host.canShare(merge(data));
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const share = async (overrides) => {
|
|
52
|
+
const host = resolveHost();
|
|
53
|
+
if (!host) return {
|
|
54
|
+
status: "unsupported",
|
|
55
|
+
error: void 0
|
|
56
|
+
};
|
|
57
|
+
const data = merge(overrides);
|
|
58
|
+
if (host.canShare && !canShare(overrides)) return {
|
|
59
|
+
status: "invalid",
|
|
60
|
+
error: void 0
|
|
61
|
+
};
|
|
62
|
+
sharing.value = true;
|
|
63
|
+
try {
|
|
64
|
+
await host.share(data);
|
|
65
|
+
return {
|
|
66
|
+
status: "shared",
|
|
67
|
+
data
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
const name = errorName(error);
|
|
71
|
+
if (name === "AbortError") return {
|
|
72
|
+
status: "cancelled",
|
|
73
|
+
error
|
|
74
|
+
};
|
|
75
|
+
if (name === "NotAllowedError") return {
|
|
76
|
+
status: "not-allowed",
|
|
77
|
+
error
|
|
78
|
+
};
|
|
79
|
+
if (name === "TypeError" || name === "DataError") return {
|
|
80
|
+
status: "invalid",
|
|
81
|
+
error
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
status: "failed",
|
|
85
|
+
error
|
|
86
|
+
};
|
|
87
|
+
} finally {
|
|
88
|
+
sharing.value = false;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
supported: computed(() => resolveHost() !== void 0),
|
|
93
|
+
sharing: readonly(sharing),
|
|
94
|
+
canShare,
|
|
95
|
+
share
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { useShare };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-sorted-locale.d.ts
|
|
4
|
+
/** Options for {@link useSortedLocale}. */
|
|
5
|
+
interface UseSortedLocaleOptions<Item> extends Intl.CollatorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Locale whose collation order is used. Pass it explicitly for
|
|
8
|
+
* hydration-stable server rendering.
|
|
9
|
+
*
|
|
10
|
+
* @default the browser language, otherwise "en"
|
|
11
|
+
*/
|
|
12
|
+
readonly locale?: string | Intl.Locale;
|
|
13
|
+
/**
|
|
14
|
+
* Sort from Z to A.
|
|
15
|
+
*
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
readonly descending?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Text to compare for each item. Required for non-string items.
|
|
21
|
+
*
|
|
22
|
+
* @default String(item)
|
|
23
|
+
*/
|
|
24
|
+
readonly key?: (item: Item) => string;
|
|
25
|
+
}
|
|
26
|
+
/** Reactive locale-aware sorting returned by {@link useSortedLocale}. */
|
|
27
|
+
interface SortedLocaleControls<Item> {
|
|
28
|
+
/** Canonical locale in use. */
|
|
29
|
+
readonly locale: ComputedRef<string>;
|
|
30
|
+
/** Collator for the current locale and options. */
|
|
31
|
+
readonly collator: ComputedRef<Intl.Collator>;
|
|
32
|
+
/** New array sorted by locale collation; the source is never mutated. */
|
|
33
|
+
readonly sorted: ComputedRef<readonly Item[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Compare two strings with the current collator (ignores `descending`).
|
|
36
|
+
*
|
|
37
|
+
* @param left First string.
|
|
38
|
+
* @param right Second string.
|
|
39
|
+
* @returns Negative, zero, or positive.
|
|
40
|
+
*/
|
|
41
|
+
readonly compare: (left: string, right: string) => number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Sort strings locale-aware with `Intl.Collator`.
|
|
45
|
+
*
|
|
46
|
+
* @param items Reactive strings.
|
|
47
|
+
* @param options Reactive locale, collation, and direction options.
|
|
48
|
+
* @returns Reactive sorted copy and collation helpers.
|
|
49
|
+
*/
|
|
50
|
+
declare function useSortedLocale(items: MaybeRefOrGetter<readonly string[]>, options?: MaybeRefOrGetter<UseSortedLocaleOptions<string>>): SortedLocaleControls<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Sort any items locale-aware by a string key with `Intl.Collator`.
|
|
53
|
+
*
|
|
54
|
+
* @param items Reactive items.
|
|
55
|
+
* @param options Reactive locale, collation, direction, and required key.
|
|
56
|
+
* @returns Reactive sorted copy and collation helpers.
|
|
57
|
+
*/
|
|
58
|
+
declare function useSortedLocale<Item>(items: MaybeRefOrGetter<readonly Item[]>, options: MaybeRefOrGetter<UseSortedLocaleOptions<Item> & {
|
|
59
|
+
readonly key: (item: Item) => string;
|
|
60
|
+
}>): SortedLocaleControls<Item>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { SortedLocaleControls, UseSortedLocaleOptions, useSortedLocale };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useLocale } from "./locale.mjs";
|
|
2
|
+
import { computed, toValue } from "vue";
|
|
3
|
+
//#region src/use-sorted-locale.ts
|
|
4
|
+
function browserLanguage() {
|
|
5
|
+
return typeof window === "undefined" ? void 0 : window.navigator.language;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Sort items with locale-aware collation (`Intl.Collator`): `"ä"` sorts
|
|
9
|
+
* next to `"a"` in German but after `"z"` in Swedish, and `numeric: true`
|
|
10
|
+
* orders `"item 10"` after `"item 9"`.
|
|
11
|
+
*
|
|
12
|
+
* The result is a new, stable-sorted array recomputed when the items,
|
|
13
|
+
* options, or locale change; the source array is never mutated. Invalid
|
|
14
|
+
* options surface as the platform `RangeError`. Derived state only: safe
|
|
15
|
+
* and deterministic on the server when the locale is explicit.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const { sorted } = useSortedLocale(users, { key: (user) => user.name, locale: "de", sensitivity: "base" });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param items Reactive items.
|
|
23
|
+
* @param options Reactive locale, collation, direction, and key.
|
|
24
|
+
* @default options {}
|
|
25
|
+
* @returns Reactive sorted copy and collation helpers.
|
|
26
|
+
*/
|
|
27
|
+
function useSortedLocale(items, options = {}) {
|
|
28
|
+
const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
|
|
29
|
+
const collator = computed(() => {
|
|
30
|
+
const { locale: _locale, descending: _descending, key: _key, ...collatorOptions } = toValue(options);
|
|
31
|
+
return new Intl.Collator(localeControls.locale.value, collatorOptions);
|
|
32
|
+
});
|
|
33
|
+
const sorted = computed(() => {
|
|
34
|
+
const { key = String, descending = false } = toValue(options);
|
|
35
|
+
const active = collator.value;
|
|
36
|
+
const direction = descending ? -1 : 1;
|
|
37
|
+
const keyed = toValue(items).map((item) => ({
|
|
38
|
+
item,
|
|
39
|
+
text: key(item)
|
|
40
|
+
}));
|
|
41
|
+
keyed.sort((left, right) => direction * active.compare(left.text, right.text));
|
|
42
|
+
return keyed.map(({ item }) => item);
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
locale: localeControls.locale,
|
|
46
|
+
collator,
|
|
47
|
+
sorted,
|
|
48
|
+
compare: (left, right) => collator.value.compare(left, right)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { useSortedLocale };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ComputedRef, MaybeRefOrGetter } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/use-sorted.d.ts
|
|
4
|
+
/** Comparator with `Array.prototype.sort` semantics. */
|
|
5
|
+
type SortComparator<Item> = (left: Item, right: Item) => number;
|
|
6
|
+
/** Values with a natural order used by the default comparator. */
|
|
7
|
+
type NaturallyOrdered = number | bigint | string | Date;
|
|
8
|
+
/**
|
|
9
|
+
* Sorted copy of a reactive array; the source is never mutated.
|
|
10
|
+
*
|
|
11
|
+
* Numbers, bigints, strings, and dates sort in natural ascending order by
|
|
12
|
+
* default (numerically, unlike `Array.prototype.sort`); any other item type
|
|
13
|
+
* requires a comparator. The sort is stable. Pure derived state: SSR-safe
|
|
14
|
+
* and nothing to dispose.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const ranked = useSorted(players, (a, b) => b.score - a.score);
|
|
19
|
+
* const ascending = useSorted([10, 9, 100]); // [9, 10, 100]
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param source Reactive array.
|
|
23
|
+
* @param compare Comparator; optional for naturally ordered items.
|
|
24
|
+
* @returns Computed sorted copy.
|
|
25
|
+
*/
|
|
26
|
+
declare function useSorted<Item extends NaturallyOrdered>(source: MaybeRefOrGetter<readonly Item[]>, compare?: SortComparator<Item>): ComputedRef<Item[]>;
|
|
27
|
+
declare function useSorted<Item>(source: MaybeRefOrGetter<readonly Item[]>, compare: SortComparator<Item>): ComputedRef<Item[]>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { NaturallyOrdered, SortComparator, useSorted };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
//#region src/use-sorted.ts
|
|
3
|
+
function naturalOrder(left, right) {
|
|
4
|
+
const a = left instanceof Date ? left.getTime() : left;
|
|
5
|
+
const b = right instanceof Date ? right.getTime() : right;
|
|
6
|
+
if (a < b) return -1;
|
|
7
|
+
if (a > b) return 1;
|
|
8
|
+
return 0;
|
|
9
|
+
}
|
|
10
|
+
function useSorted(source, compare = naturalOrder) {
|
|
11
|
+
return computed(() => [...toValue(source)].sort(compare));
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useSorted };
|