@vizejs/composable 0.810.0 → 0.811.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.
Files changed (166) hide show
  1. package/dist/abort-signal.mjs +0 -62
  2. package/dist/active-element.mjs +0 -11
  3. package/dist/animate.mjs +0 -19
  4. package/dist/async-resource.mjs +0 -17
  5. package/dist/battery.mjs +0 -13
  6. package/dist/breakpoints.mjs +0 -24
  7. package/dist/capability.mjs +0 -12
  8. package/dist/{catalog-BRX-Wg8B.mjs → catalog-CcpCnLjb.mjs} +0 -14
  9. package/dist/catalog.mjs +1 -1
  10. package/dist/color-mode.mjs +0 -23
  11. package/dist/computed-with-control.mjs +0 -22
  12. package/dist/create-event-hook.mjs +0 -27
  13. package/dist/create-global-state.mjs +0 -23
  14. package/dist/create-shared-composable.mjs +0 -23
  15. package/dist/device-motion.mjs +0 -11
  16. package/dist/device-orientation.mjs +0 -23
  17. package/dist/device-pixel-ratio.mjs +0 -11
  18. package/dist/disposal-scope.mjs +0 -25
  19. package/dist/document-visibility.mjs +0 -14
  20. package/dist/draggable.mjs +0 -14
  21. package/dist/element-bounding.mjs +0 -14
  22. package/dist/element-by-point.mjs +0 -10
  23. package/dist/element-hover.mjs +0 -13
  24. package/dist/element-target.mjs +0 -30
  25. package/dist/focus.mjs +0 -23
  26. package/dist/fps.mjs +0 -12
  27. package/dist/geolocation.mjs +0 -14
  28. package/dist/i18n.mjs +0 -86
  29. package/dist/icu-message.mjs +0 -58
  30. package/dist/idle.mjs +0 -16
  31. package/dist/index.mjs +2 -2
  32. package/dist/infinite-scroll.mjs +0 -16
  33. package/dist/intersection-observer.mjs +0 -27
  34. package/dist/locale.mjs +0 -20
  35. package/dist/magic-keys.mjs +0 -35
  36. package/dist/math.mjs +0 -37
  37. package/dist/media-query.mjs +0 -29
  38. package/dist/mouse-in-element.mjs +0 -12
  39. package/dist/mouse.mjs +0 -12
  40. package/dist/mutation-observer.mjs +0 -15
  41. package/dist/network.mjs +0 -24
  42. package/dist/on-click-outside.mjs +0 -16
  43. package/dist/on-key-stroke.mjs +0 -33
  44. package/dist/on-long-press.mjs +0 -14
  45. package/dist/on-start-typing.mjs +0 -23
  46. package/dist/page-leave.mjs +0 -11
  47. package/dist/parent-element.mjs +0 -9
  48. package/dist/pinch.mjs +0 -14
  49. package/dist/pointer-lock.mjs +0 -23
  50. package/dist/pointer.mjs +0 -18
  51. package/dist/preferences.mjs +0 -31
  52. package/dist/preferred-languages.mjs +0 -13
  53. package/dist/ref-auto-reset.mjs +0 -24
  54. package/dist/ref-debounced.mjs +0 -22
  55. package/dist/ref-default.mjs +0 -21
  56. package/dist/resize-observer.mjs +0 -31
  57. package/dist/resolver.mjs +1 -58
  58. package/dist/retry-async.mjs +0 -25
  59. package/dist/retry-delay.mjs +0 -23
  60. package/dist/scope.mjs +0 -14
  61. package/dist/screen-orientation.mjs +0 -15
  62. package/dist/scroll-lock.mjs +0 -14
  63. package/dist/scroll.mjs +0 -27
  64. package/dist/standard-schema.mjs +0 -31
  65. package/dist/swipe.mjs +0 -36
  66. package/dist/temporal.mjs +0 -30
  67. package/dist/text-selection.mjs +0 -15
  68. package/dist/textarea-autosize.mjs +0 -13
  69. package/dist/to-reactive.mjs +0 -20
  70. package/dist/transition.mjs +0 -7
  71. package/dist/until.mjs +0 -25
  72. package/dist/use-array.mjs +0 -52
  73. package/dist/use-barcode-detector.mjs +0 -25
  74. package/dist/use-bluetooth.mjs +0 -27
  75. package/dist/use-broadcast-channel.mjs +0 -30
  76. package/dist/use-builtin-ai.mjs +0 -68
  77. package/dist/use-clipboard.mjs +0 -27
  78. package/dist/use-compression-stream.mjs +0 -78
  79. package/dist/use-contact-picker.mjs +0 -22
  80. package/dist/use-cookie.mjs +0 -63
  81. package/dist/use-countdown.mjs +0 -22
  82. package/dist/use-counter.mjs +0 -29
  83. package/dist/use-css-var.mjs +0 -28
  84. package/dist/use-date-format.mjs +0 -48
  85. package/dist/use-date-time-format.mjs +0 -22
  86. package/dist/use-debounced.mjs +0 -39
  87. package/dist/use-display-media.mjs +0 -22
  88. package/dist/use-display-names.mjs +0 -19
  89. package/dist/use-document-title.mjs +0 -25
  90. package/dist/use-drop-zone.mjs +0 -36
  91. package/dist/use-event-source.mjs +0 -25
  92. package/dist/use-eye-dropper.mjs +0 -19
  93. package/dist/use-favicon.mjs +0 -23
  94. package/dist/use-fetch.mjs +0 -27
  95. package/dist/use-field.mjs +0 -27
  96. package/dist/use-file-dialog.mjs +0 -21
  97. package/dist/{use-form-A4j_h14D.mjs → use-form-BZqwMs6k.mjs} +0 -68
  98. package/dist/use-form-field-props.mjs +0 -57
  99. package/dist/use-form.mjs +1 -1
  100. package/dist/use-fullscreen.mjs +0 -23
  101. package/dist/use-gamepad.mjs +0 -50
  102. package/dist/use-hid.mjs +0 -25
  103. package/dist/use-history.mjs +0 -43
  104. package/dist/use-id-generator.mjs +0 -21
  105. package/dist/use-image.mjs +0 -22
  106. package/dist/use-indexed-db.mjs +0 -39
  107. package/dist/use-interval.mjs +0 -28
  108. package/dist/use-list-format.mjs +0 -18
  109. package/dist/use-machine.mjs +0 -34
  110. package/dist/use-map.mjs +0 -28
  111. package/dist/use-media-controls.mjs +0 -28
  112. package/dist/use-mounted.mjs +0 -18
  113. package/dist/use-navigation-api.mjs +0 -27
  114. package/dist/use-notification.mjs +0 -24
  115. package/dist/use-number-format.mjs +0 -23
  116. package/dist/use-object-url.mjs +0 -22
  117. package/dist/use-offset-pagination.mjs +0 -18
  118. package/dist/use-payment-request.mjs +0 -25
  119. package/dist/use-performance-observer.mjs +0 -27
  120. package/dist/use-permission.mjs +0 -26
  121. package/dist/use-plural-rules.mjs +0 -21
  122. package/dist/use-push-subscription.mjs +0 -28
  123. package/dist/use-queue.mjs +0 -29
  124. package/dist/use-raf-fn.mjs +0 -23
  125. package/dist/use-relative-time-format.mjs +0 -35
  126. package/dist/use-request-idle-callback.mjs +0 -42
  127. package/dist/use-route-query.mjs +0 -17
  128. package/dist/use-scheduler-post-task.mjs +0 -27
  129. package/dist/use-screen-details.mjs +0 -42
  130. package/dist/use-script-tag.mjs +0 -28
  131. package/dist/use-segmenter.mjs +0 -20
  132. package/dist/use-serial.mjs +0 -24
  133. package/dist/use-service-worker.mjs +0 -27
  134. package/dist/use-set.mjs +0 -23
  135. package/dist/use-share.mjs +0 -23
  136. package/dist/use-sorted-locale.mjs +0 -20
  137. package/dist/use-speech-recognition.mjs +0 -24
  138. package/dist/use-speech-synthesis.mjs +0 -26
  139. package/dist/use-stack.mjs +0 -27
  140. package/dist/use-storage-estimate.mjs +0 -41
  141. package/dist/use-storage.mjs +0 -68
  142. package/dist/use-style-tag.mjs +0 -22
  143. package/dist/use-supported.mjs +0 -17
  144. package/dist/use-throttled.mjs +0 -46
  145. package/dist/use-time-ago.mjs +0 -22
  146. package/dist/use-toggle.mjs +0 -19
  147. package/dist/use-url-hash.mjs +0 -28
  148. package/dist/use-url-search-params.mjs +0 -99
  149. package/dist/use-usb.mjs +0 -23
  150. package/dist/use-user-activation.mjs +0 -22
  151. package/dist/use-user-media.mjs +0 -50
  152. package/dist/use-vibrate.mjs +0 -21
  153. package/dist/use-view-transition.mjs +0 -22
  154. package/dist/use-visual-viewport.mjs +0 -25
  155. package/dist/use-wake-lock.mjs +0 -21
  156. package/dist/use-web-authn.mjs +0 -61
  157. package/dist/use-web-locks.mjs +0 -25
  158. package/dist/use-web-midi.mjs +0 -22
  159. package/dist/use-web-vitals.mjs +0 -41
  160. package/dist/use-websocket.mjs +0 -27
  161. package/dist/use-worker-fn.mjs +0 -37
  162. package/dist/virtual-list.mjs +0 -14
  163. package/dist/whenever.mjs +0 -21
  164. package/dist/window-size.mjs +0 -12
  165. package/package.json +2 -2
  166. package/registry/registry.json +1 -1
@@ -34,17 +34,6 @@ function openDatabase(factory, name, store, version) {
34
34
  return openDatabase(factory, name, store, next);
35
35
  });
36
36
  }
37
- /**
38
- * Create a small promise-based key-value store on one IndexedDB object
39
- * store. The connection opens lazily on the first operation, the store is
40
- * created on demand, and writes resolve once their transaction commits.
41
- * Without IndexedDB (server rendering, privacy modes) every operation
42
- * rejects with a tagged `[VIZE_COMPOSE_INDEXED_DB_UNAVAILABLE]` error.
43
- *
44
- * @param options Database, store, and implementation.
45
- * @default options {}
46
- * @returns Key-value operations.
47
- */
48
37
  function createIndexedDBKeyval(options = {}) {
49
38
  const name = options.database ?? "vize-keyval";
50
39
  const store = options.store ?? "keyval";
@@ -91,34 +80,6 @@ function sameKind(defaults, candidate) {
91
80
  if (typeof defaults === "object") return typeof candidate === "object" && candidate !== null && !Array.isArray(candidate);
92
81
  return typeof candidate === typeof defaults;
93
82
  }
94
- /**
95
- * Synchronize a reactive value with one IndexedDB key.
96
- *
97
- * Values are stored by structured clone, so objects, arrays, `Map`, `Set`,
98
- * `Date`, typed arrays, and `Blob`s round-trip without a serializer. The
99
- * value is loaded asynchronously: `state` holds the default until `ready`
100
- * becomes `true`. Loaded values pass `validate` before they are accepted.
101
- * Assignments and nested mutations are written back; changing the reactive
102
- * `key` loads the new key (stale loads are discarded).
103
- *
104
- * Server rendering: without a browser `window` nothing is opened, `state`
105
- * is the default, and `ready` stays `false`, so server and client first
106
- * render identically. The connection closes and watchers stop with the
107
- * owning reactive scope. Failures never reject; they are exposed through
108
- * `error` and `onError`.
109
- *
110
- * @example
111
- * ```ts
112
- * const { state: draft, ready } = useIndexedDB("draft", { title: "", body: "" });
113
- * ```
114
- *
115
- * @typeParam Value Stored value type, inferred from `defaultValue`.
116
- * @param key Reactive IndexedDB key.
117
- * @param defaultValue Value used until loaded, and when absent or invalid.
118
- * @param options Database, store, implementation, and validation.
119
- * @default options {}
120
- * @returns The synchronized value and its controls.
121
- */
122
83
  function useIndexedDB(key, defaultValue, options = {}) {
123
84
  const state = ref(defaultValue);
124
85
  const supported = ref(false);
@@ -11,34 +11,6 @@ function resolveIntervalMs(value) {
11
11
  if (!Number.isFinite(value) || value <= 0) throw new RangeError(`[VIZE_COMPOSE_INTERVAL_INVALID_DELAY] intervalMs must be finite and greater than zero; received ${String(value)}`);
12
12
  return Math.max(1, Math.trunc(value));
13
13
  }
14
- /**
15
- * Call a function on a fixed, pausable interval.
16
- *
17
- * `intervalMs` is reactive: while active, a change replaces the running timer
18
- * with one using the new period. The timer is cleared when the owning
19
- * reactive scope stops; call inside an active scope, or call `pause()`
20
- * yourself.
21
- *
22
- * Server rendering is hydration-stable: without a browser `window` (and
23
- * with {@link UseIntervalFnOptions.runOnServer} disabled) `isActive` reports
24
- * the requested state but no host timer is created, so nothing leaks and
25
- * the server snapshot matches the client's initial render.
26
- *
27
- * @example
28
- * ```ts
29
- * const { pause, resume, isActive } = useIntervalFn(() => poll(), 5_000);
30
- * ```
31
- *
32
- * @param callback Invoked on every tick.
33
- * @param intervalMs Reactive period in milliseconds; must be finite and
34
- * greater than zero. Fractions are truncated.
35
- * @param options Start, server, and scheduler policy.
36
- * @default options {}
37
- * @throws `RangeError` tagged `VIZE_COMPOSE_INTERVAL_INVALID_DELAY` when the
38
- * resolved period is invalid, synchronously at creation and whenever a timer
39
- * would start.
40
- * @returns Pause/resume controls.
41
- */
42
14
  function useIntervalFn(callback, intervalMs, options = {}) {
43
15
  const scheduler = options.scheduler ?? defaultScheduler;
44
16
  const isActive = shallowRef(false);
@@ -4,24 +4,6 @@ import { computed, toValue } from "vue";
4
4
  function browserLanguage() {
5
5
  return typeof window === "undefined" ? void 0 : window.navigator.language;
6
6
  }
7
- /**
8
- * Join strings into a locale-aware list with `Intl.ListFormat`
9
- * (`"a, b, and c"`, `"a、b、c"`, `"a, b or c"`).
10
- *
11
- * Follows reactive items and options; formatters are cached per locale and
12
- * option set through {@link useLocale}. Invalid options surface as the
13
- * platform's `RangeError`. No listeners or timers are created.
14
- *
15
- * @example
16
- * ```ts
17
- * const { formatted } = useListFormat(names, { locale: "en", type: "disjunction" });
18
- * ```
19
- *
20
- * @param items Reactive list of strings.
21
- * @param options Reactive locale and `Intl.ListFormat` options.
22
- * @default options {}
23
- * @returns Reactive formatted output and formatting helpers.
24
- */
25
7
  function useListFormat(items, options = {}) {
26
8
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
27
9
  const formatter = computed(() => {
@@ -1,42 +1,8 @@
1
1
  import { computed, shallowRef } from "vue";
2
2
  //#region src/use-machine.ts
3
- /** Shallow ref typed through an unconstrained parameter, so literal unions stay intact. */
4
3
  function ownedRef(value) {
5
4
  return shallowRef(value);
6
5
  }
7
- /**
8
- * Finite state machine with typed states, events, and targets.
9
- *
10
- * State names are inferred from the keys of `states`, event names from the
11
- * keys of every `on` map, and every `target` (and `initial`) must name a
12
- * declared state, so typos fail to compile. Transitions may carry guards
13
- * (first passing guard wins) and actions that return the next context;
14
- * `exit` runs on the old state before `entry` runs on the new one, and a
15
- * self-transition runs both. Synchronous and free of globals: identical on
16
- * server and client, nothing to dispose.
17
- *
18
- * @example
19
- * ```ts
20
- * const fetcher = useMachine({
21
- * initial: "idle",
22
- * context: { retries: 0 },
23
- * states: {
24
- * idle: { on: { FETCH: "loading" } },
25
- * loading: { on: { RESOLVE: "success", REJECT: "failure" } },
26
- * failure: {
27
- * on: {
28
- * RETRY: { target: "loading", guard: (c) => c.retries < 3, action: (c) => ({ retries: c.retries + 1 }) },
29
- * },
30
- * },
31
- * success: {},
32
- * },
33
- * });
34
- * fetcher.send("FETCH");
35
- * ```
36
- *
37
- * @param config States, events, context, and hooks.
38
- * @returns The reactive machine.
39
- */
40
6
  function useMachine(config) {
41
7
  const state = ownedRef(config.initial);
42
8
  const context = ownedRef(config.context);
package/dist/use-map.mjs CHANGED
@@ -1,36 +1,8 @@
1
1
  import { computed, shallowReactive, shallowReadonly } from "vue";
2
2
  //#region src/use-map.ts
3
- /**
4
- * Narrow a `get` result using the matching `has` answer: when the key is
5
- * present the result is a stored `Value`, even if that value is `undefined`.
6
- */
7
3
  function isStored(value, present) {
8
4
  return present;
9
5
  }
10
- /**
11
- * Create a reactive `Map` with typed helpers.
12
- *
13
- * Key and value types are inferred from the initial entries
14
- * (`useMap([["a", 1]])` is a `Map<string, number>`); pass type arguments
15
- * for an initially empty map. Reads through `get`, `has`, and `map` are
16
- * tracked per key, so an effect reading one key does not re-run when an
17
- * unrelated key changes. Values are stored as-is (not deeply reactive).
18
- *
19
- * Purely synchronous state: safe during server rendering (no host globals,
20
- * no timers) and nothing to dispose.
21
- *
22
- * @example
23
- * ```ts
24
- * const counts = useMap<string, number>();
25
- * counts.update("clicks", (previous = 0) => previous + 1);
26
- * ```
27
- *
28
- * @typeParam Key Key type, inferred from `initial`.
29
- * @typeParam Value Value type, inferred from `initial`.
30
- * @param initial Entries inserted at creation and restored by `reset`.
31
- * @default initial []
32
- * @returns The reactive map and its helpers.
33
- */
34
6
  function useMap(initial = []) {
35
7
  const baseline = [...initial];
36
8
  const map = shallowReactive(new Map(baseline));
@@ -15,34 +15,6 @@ function chooseSource(element, source) {
15
15
  if (element.canPlayType(candidate.type) !== "") return candidate.src;
16
16
  }
17
17
  }
18
- /**
19
- * Two-way reactive controls for a `<video>` or `<audio>` element.
20
- *
21
- * `playing`, `currentTime`, `volume`, `muted`, and `rate` mirror the
22
- * element and are writable: assigning them drives the element, while
23
- * element events update them without echoing the change back. The element
24
- * is the source of truth whenever a new target attaches. Read-only state
25
- * covers duration, buffering, seeking, waiting, stalls, text tracks, and
26
- * picture-in-picture. A rejected `play()` (blocked autoplay) resets
27
- * `playing` and is exposed through `error`. Listeners are removed when the
28
- * target changes and when the owning reactive scope stops.
29
- *
30
- * Server rendering: the template ref is empty, so every value keeps its
31
- * neutral default (paused, time 0, volume 1) and nothing is touched.
32
- *
33
- * @example
34
- * ```ts
35
- * const video = useTemplateRef<HTMLVideoElement>("video");
36
- * const { playing, currentTime, duration } = useMediaControls(video, {
37
- * src: [{ src: "/clip.webm", type: "video/webm" }, { src: "/clip.mp4", type: "video/mp4" }],
38
- * });
39
- * ```
40
- *
41
- * @param target Reactive media element.
42
- * @param options Source selection and picture-in-picture document.
43
- * @default options {}
44
- * @returns Reactive media state and actions.
45
- */
46
18
  function useMediaControls(target, options = {}) {
47
19
  const playing = ref(false);
48
20
  const currentTime = ref(0);
@@ -1,23 +1,5 @@
1
1
  import { hasInjectionContext, onMounted, shallowRef } from "vue";
2
2
  //#region src/use-mounted.ts
3
- /**
4
- * Whether the calling component has mounted.
5
- *
6
- * `false` during server rendering and during hydration, `true` from the
7
- * component's `onMounted` on: gate client-only rendering behind it to keep
8
- * hydration stable. Outside a component (no instance to mount) it stays
9
- * `false`. Component detection uses `hasInjectionContext()` rather than
10
- * `getCurrentInstance()`, which returns `null` inside Vapor components, so
11
- * the flag also flips in Vapor.
12
- *
13
- * @example
14
- * ```ts
15
- * const mounted = useMounted();
16
- * // <ClientOnlyChart v-if="mounted" />
17
- * ```
18
- *
19
- * @returns Readonly mounted flag.
20
- */
21
3
  function useMounted() {
22
4
  const mounted = shallowRef(false);
23
5
  if (hasInjectionContext()) onMounted(() => {
@@ -25,33 +25,6 @@ function snapshot(entry) {
25
25
  };
26
26
  }
27
27
  function ignore() {}
28
- /**
29
- * Reactive access to the Navigation API (`window.navigation`).
30
- *
31
- * Entry snapshots refresh on `currententrychange`, `navigatesuccess` and
32
- * `navigateerror`. Actions resolve to a {@link NavigationOutcome} and never
33
- * reject; failures also land in `error`. Listeners (including interceptors)
34
- * are removed when the owning reactive scope stops; outside a scope the
35
- * caller removes them with the returned functions.
36
- *
37
- * Server rendering: nothing is read or subscribed; `supported` is false,
38
- * `currentEntry` null, `entries` empty, and actions resolve to
39
- * `{ status: "unsupported" }`.
40
- * Inside a component the host is resolved after mounting, so hydration
41
- * renders this server state first.
42
- *
43
- * @example
44
- * ```ts
45
- * const nav = useNavigationApi<{ tab: string }>();
46
- * nav.intercept((url) => url.pathname.startsWith("/app/"), {
47
- * handler: async () => renderRoute(location.pathname),
48
- * });
49
- * ```
50
- *
51
- * @param options Navigation host and state parser.
52
- * @default options {}
53
- * @returns Navigation state, hooks and actions.
54
- */
55
28
  function useNavigationApi(options = {}) {
56
29
  const currentEntry = shallowRef(null);
57
30
  const entries = shallowRef([]);
@@ -14,30 +14,6 @@ const notificationEvents = [
14
14
  "error",
15
15
  "close"
16
16
  ];
17
- /**
18
- * Show typed Web Notifications with permission handling.
19
- *
20
- * `show` merges reactive defaults with per-call options, asks for
21
- * permission first when it is still undecided (configurable), and resolves
22
- * to a discriminated {@link WebNotificationResult}. Handlers registered with
23
- * `on` apply to every notification this composable shows. The current
24
- * notification is closed when the owning reactive scope stops.
25
- *
26
- * Server rendering: the API is never touched; `permission` is
27
- * `"unsupported"` and `supported` is false.
28
- *
29
- * @example
30
- * ```ts
31
- * const notify = useWebNotification<{ id: string }>({ defaults: { icon: "/icon.png" } });
32
- * notify.on("click", () => window.focus());
33
- * await notify.show("Build finished", { data: { id: "42" } });
34
- * ```
35
- *
36
- * @typeParam Data Application data attached to notifications.
37
- * @param options Capability, defaults, and permission policy.
38
- * @default options {}
39
- * @returns Notification state and actions.
40
- */
41
17
  function useWebNotification(options = {}) {
42
18
  const resolveHost = () => options.host === void 0 ? browserNotificationHost() : unref(options.host) ?? void 0;
43
19
  const readPermission = () => {
@@ -12,29 +12,6 @@ function formatRangeWith(formatter, start, end) {
12
12
  function browserLanguage() {
13
13
  return typeof window === "undefined" ? void 0 : window.navigator.language;
14
14
  }
15
- /**
16
- * Format numbers reactively with `Intl.NumberFormat`.
17
- *
18
- * The formatter follows the reactive options (including `locale`) and is
19
- * cached per locale and option set through {@link useLocale}. Without an
20
- * explicit locale the browser language is used, falling back to `"en"`
21
- * (always the case on the server). Invalid options surface as the
22
- * platform's `RangeError`/`TypeError` on first read. No listeners or timers
23
- * are created, so nothing needs cleanup.
24
- *
25
- * @example
26
- * ```ts
27
- * const price = ref(1234.5);
28
- * const { formatted } = useNumberFormat(price, { locale: "de-DE", style: "currency", currency: "EUR" });
29
- * formatted.value; // "1.234,50 €"
30
- * ```
31
- *
32
- * @param value Reactive number; `null`/`undefined` format as `""`.
33
- * @param options Reactive locale and `Intl.NumberFormat` options.
34
- * @default value undefined
35
- * @default options {}
36
- * @returns Reactive formatted output and formatter helpers.
37
- */
38
15
  function useNumberFormat(value, options = {}) {
39
16
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
40
17
  const formatter = computed(() => {
@@ -6,28 +6,6 @@ function browserObjectUrlHost() {
6
6
  const { URL } = window;
7
7
  return typeof URL.createObjectURL === "function" ? URL : void 0;
8
8
  }
9
- /**
10
- * Create a reactive object URL for a `Blob`, `File`, or `MediaSource`.
11
- *
12
- * A new URL is created whenever the reactive object changes and the
13
- * previous one is revoked immediately, so memory held by the old object is
14
- * released. The last URL is revoked when the owning reactive scope stops.
15
- * Outside a scope, the caller owns the last URL (it lives until unload).
16
- *
17
- * Server rendering: no URL is created and the ref stays `undefined`.
18
- *
19
- * @example
20
- * ```ts
21
- * const file = shallowRef<File>();
22
- * const preview = useObjectUrl(file);
23
- * // <img :src="preview">
24
- * ```
25
- *
26
- * @param object Reactive object to reference; `null`/`undefined` clears the URL.
27
- * @param options Object-URL capability.
28
- * @default options {}
29
- * @returns Readonly ref holding the current object URL.
30
- */
31
9
  function useObjectUrl(object, options = {}) {
32
10
  const url = ref(void 0);
33
11
  const resolveHost = () => options.host === void 0 ? browserObjectUrlHost() : unref(options.host) ?? void 0;
@@ -3,24 +3,6 @@ import { computed, isRef, shallowRef, toValue, watch } from "vue";
3
3
  function toWritable(value, fallback) {
4
4
  return isRef(value) ? value : shallowRef(value ?? fallback);
5
5
  }
6
- /**
7
- * Offset-based pagination state.
8
- *
9
- * The page is clamped into `[1, pageCount]` on every read and write, so
10
- * shrinking `total` or growing `pageSize` never leaves the cursor past the
11
- * end. Writable `page`/`pageSize` refs are updated in place for two-way
12
- * binding. Callbacks fire after the corresponding value settles.
13
- * Synchronous state: SSR-safe; watchers follow the owning scope.
14
- *
15
- * @example
16
- * ```ts
17
- * const { currentPage, pageCount, next, offset } = useOffsetPagination({ total, pageSize: 20 });
18
- * ```
19
- *
20
- * @param options Total, page, page size, and change callbacks.
21
- * @default options {}
22
- * @returns Pagination state and controls.
23
- */
24
6
  function useOffsetPagination(options = {}) {
25
7
  const page = toWritable(options.page, 1);
26
8
  const size = toWritable(options.pageSize, 10);
@@ -15,31 +15,6 @@ function hasUpdateWith(event) {
15
15
  function errorName(error) {
16
16
  return typeof error === "object" && error !== null && "name" in error ? error.name : void 0;
17
17
  }
18
- /**
19
- * Collect payments with a typed Payment Request API wrapper.
20
- *
21
- * Every `show()` constructs a fresh request from the reactive `methods`,
22
- * `details`, and `paymentOptions`, wires the shipping hooks (which call
23
- * `updateWith` synchronously when they return an update), and resolves to a
24
- * discriminated {@link PaymentShowResult}. Call `complete()` after
25
- * processing a `"completed"` result. A showing sheet is aborted when the
26
- * owning reactive scope stops; outside a scope call `abort()`.
27
- *
28
- * Server rendering: nothing is constructed, `supported` is false and
29
- * `state` is `"idle"`.
30
- * Inside a component `supported` turns true only after mounting, so
31
- * hydration renders this server state first.
32
- *
33
- * @example
34
- * ```ts
35
- * const payment = usePaymentRequest({ methods, details: { total } });
36
- * const result = await payment.show();
37
- * if (result.status === "completed") await payment.complete(await charge(result.response));
38
- * ```
39
- *
40
- * @param options Methods, details, hooks, and the constructor host.
41
- * @returns Payment state and actions.
42
- */
43
18
  function usePaymentRequest(options) {
44
19
  const state = shallowRef("idle");
45
20
  const response = shallowRef(void 0);
@@ -12,33 +12,6 @@ function browserPerformanceObserver() {
12
12
  function isEntryOf(entry, types) {
13
13
  return types.some((type) => type === entry.entryType);
14
14
  }
15
- /**
16
- * Observe performance entries with callbacks typed by entry type.
17
- *
18
- * Each supported type is observed with its own `observe({ type })` call so
19
- * `buffered` and `durationThreshold` apply. Types missing from
20
- * `PerformanceObserver.supportedEntryTypes` are skipped; `supported` is false
21
- * when none remain. The observer follows reactive `entryTypes` and is
22
- * disconnected when the owning reactive scope stops; outside a scope the
23
- * caller owns `stop()`.
24
- *
25
- * Server rendering: no observer is created and `supported` is false. Inside
26
- * a component the observer connects after mounting, so hydration renders the
27
- * server state first.
28
- *
29
- * @example
30
- * ```ts
31
- * usePerformanceObserver("largest-contentful-paint", (entries) => {
32
- * console.log(entries.at(-1)?.renderTime);
33
- * }, { buffered: true });
34
- * ```
35
- *
36
- * @param entryTypes One entry type or a list of them.
37
- * @param callback Receives batches of typed entries.
38
- * @param options Constructor host and observation options.
39
- * @default options {}
40
- * @returns Observer state and actions.
41
- */
42
15
  function usePerformanceObserver(entryTypes, callback, options = {}) {
43
16
  const { durationThreshold } = options;
44
17
  if (durationThreshold !== void 0 && (!Number.isFinite(durationThreshold) || durationThreshold < 0)) throw new RangeError(`[VIZE_COMPOSE_PERF_OBSERVER_INVALID_DURATION_THRESHOLD] durationThreshold must be a finite, non-negative number, received ${String(durationThreshold)}`);
@@ -11,32 +11,6 @@ function browserPermissions() {
11
11
  function toDescriptor(name) {
12
12
  return typeof name === "string" ? { name } : name;
13
13
  }
14
- /**
15
- * Observe a browser permission reactively.
16
- *
17
- * The permission is queried when the composable is created and whenever
18
- * the reactive name/descriptor or host changes; the `change` event of the
19
- * returned `PermissionStatus` keeps `state` current (for example after the
20
- * user revokes camera access in the site settings). The subscription is
21
- * removed when the name changes and when the owning reactive scope stops.
22
- *
23
- * Server rendering: no browser window exists, so nothing is queried and
24
- * `state` stays at `initialState` (`"unknown"`) with `supported` false.
25
- * Unknown names (the browser rejects the query) report `"unsupported"`.
26
- * Inside a component the first query runs after mounting, so hydration
27
- * renders `initialState` exactly like the server did.
28
- *
29
- * @example
30
- * ```ts
31
- * const { state } = usePermission("camera");
32
- * const canUseCamera = computed(() => state.value === "granted");
33
- * ```
34
- *
35
- * @param name Reactive permission name or full descriptor.
36
- * @param options Capability host and initial state.
37
- * @default options {}
38
- * @returns The reactive permission state and a re-query control.
39
- */
40
14
  function usePermission(name, options = {}) {
41
15
  const initialState = options.initialState ?? "unknown";
42
16
  const state = ref(initialState);
@@ -7,27 +7,6 @@ function browserLanguage() {
7
7
  function renderMessage(message, count, formatted) {
8
8
  return typeof message === "function" ? message(count, formatted) : message.replaceAll("{count}", formatted).replaceAll("#", formatted);
9
9
  }
10
- /**
11
- * Choose and render a message by CLDR plural category (`Intl.PluralRules`).
12
- *
13
- * Messages are typed per category with a mandatory `other`, plus optional
14
- * exact overrides (`"=0": "No items"`). Cardinal (`1 item`) and ordinal
15
- * (`1st`, `2nd`) rules are supported via `type`. The count is formatted
16
- * with the same locale for interpolation. Everything is derived state:
17
- * no listeners or timers, deterministic during server rendering when the
18
- * locale is explicit. Invalid options surface as the platform `RangeError`.
19
- *
20
- * @example
21
- * ```ts
22
- * const { message } = usePluralRules(count, { "=0": "No files", one: "# file", other: "# files" }, { locale: "en" });
23
- * ```
24
- *
25
- * @param count Reactive count.
26
- * @param messages Reactive messages per category.
27
- * @param options Reactive locale and `Intl.PluralRules` options.
28
- * @default options {}
29
- * @returns Reactive category, message, and selection helpers.
30
- */
31
10
  function usePluralRules(count, messages, options = {}) {
32
11
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
33
12
  const rules = computed(() => {
@@ -28,34 +28,6 @@ function browserContainer() {
28
28
  const { navigator } = window;
29
29
  return "serviceWorker" in navigator && navigator.serviceWorker ? navigator.serviceWorker : void 0;
30
30
  }
31
- /**
32
- * Manage a Web Push subscription.
33
- *
34
- * Uses the push manager of `options.registration`, or of
35
- * `navigator.serviceWorker.ready` by default. The existing subscription is
36
- * loaded when the registration becomes known; `subscribe` accepts the VAPID
37
- * key as a base64url string. `json` is the snapshot to send to a push server.
38
- * Nothing needs cleanup; pending results are ignored after the owning
39
- * reactive scope stops.
40
- *
41
- * Server rendering: nothing is read, `supported` is false and the
42
- * subscription is `null`.
43
- * Inside a component the host is resolved after mounting, so hydration
44
- * renders this server state first.
45
- *
46
- * @example
47
- * ```ts
48
- * const push = usePushSubscription();
49
- * const enable = async () => {
50
- * await push.subscribe({ applicationServerKey: VAPID_PUBLIC_KEY });
51
- * await fetch("/api/push", { method: "POST", body: JSON.stringify(push.json.value) });
52
- * };
53
- * ```
54
- *
55
- * @param options Registration override and initial read policy.
56
- * @default options {}
57
- * @returns Subscription state and actions.
58
- */
59
31
  function usePushSubscription(options = {}) {
60
32
  const subscription = shallowRef(null);
61
33
  const error = shallowRef(void 0);
@@ -1,40 +1,11 @@
1
1
  import { computed, shallowRef } from "vue";
2
2
  //#region src/use-queue.ts
3
- /** Compact the backing buffer once this many dequeued slots accumulate. */
4
3
  const COMPACT_THRESHOLD = 32;
5
4
  function validateCapacity(capacity) {
6
5
  if (capacity === Number.POSITIVE_INFINITY) return capacity;
7
6
  if (!Number.isSafeInteger(capacity) || capacity < 1) throw new RangeError(`[VIZE_COMPOSE_QUEUE_INVALID_CAPACITY] capacity must be a positive integer or Infinity; received ${String(capacity)}`);
8
7
  return capacity;
9
8
  }
10
- /**
11
- * Create a typed reactive FIFO queue.
12
- *
13
- * Dequeueing is amortized O(1): the head advances through a backing buffer
14
- * that is compacted only after enough slots have been consumed, so large
15
- * queues never pay for `Array.prototype.shift`. Reactivity is driven by a
16
- * single version counter; `items`, `size`, `isEmpty`, and `peek` all
17
- * re-evaluate after each mutation.
18
- *
19
- * Purely synchronous state: safe during server rendering (no host globals,
20
- * no timers) and nothing to dispose.
21
- *
22
- * @example
23
- * ```ts
24
- * const jobs = useQueue<string>([], { capacity: 100, overflow: "reject" });
25
- * jobs.enqueue("a", "b");
26
- * jobs.dequeue(); // "a"
27
- * ```
28
- *
29
- * @typeParam Item Queued item type, inferred from `initial` when given.
30
- * @param initial Items enqueued at creation, head first (overflow applies).
31
- * @param options Capacity and overflow policy.
32
- * @default initial []
33
- * @default options {}
34
- * @throws {RangeError} `[VIZE_COMPOSE_QUEUE_INVALID_CAPACITY]` when `capacity`
35
- * is not a positive integer or `Infinity`.
36
- * @returns The reactive queue and its controls.
37
- */
38
9
  function useQueue(initial = [], options = {}) {
39
10
  const capacity = validateCapacity(options.capacity ?? Number.POSITIVE_INFINITY);
40
11
  const overflow = options.overflow ?? "drop-oldest";
@@ -11,29 +11,6 @@ function resolveHost(scheduler) {
11
11
  }
12
12
  };
13
13
  }
14
- /**
15
- * Run a callback on every animation frame, with pause/resume controls and an
16
- * optional frame-rate cap.
17
- *
18
- * The host is resolved lazily on `resume()`, so importing and calling this
19
- * during server rendering is safe: without a browser `window` (and without
20
- * {@link UseRafFnOptions.runOnServer}), or without any frame host,
21
- * `isActive` reports the requested state and no callbacks run, matching the
22
- * client's initial render. The pending frame is cancelled when the owning reactive scope
23
- * stops.
24
- *
25
- * @example
26
- * ```ts
27
- * const { pause } = useRafFn(({ delta }) => step(delta), { fpsLimit: 30 });
28
- * ```
29
- *
30
- * @param callback Invoked with frame timing for every delivered frame.
31
- * @param options Start, rate-limit, and host policy.
32
- * @default options {}
33
- * @throws `RangeError` tagged `VIZE_COMPOSE_RAF_INVALID_FPS_LIMIT` when a
34
- * resolved `fpsLimit` is not finite and greater than zero.
35
- * @returns Pause/resume controls.
36
- */
37
14
  function useRafFn(callback, options = {}) {
38
15
  const isActive = shallowRef(false);
39
16
  let host;