@vizejs/composable 0.810.0 → 0.812.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
@@ -48,12 +48,6 @@ const codecs = {
48
48
  function isEntry(candidate) {
49
49
  return Array.isArray(candidate) && candidate.length === 2;
50
50
  }
51
- /**
52
- * Typed built-in serializers, usable directly as the `serializer` option.
53
- *
54
- * `object` round-trips JSON-compatible values; `map` and `set` store their
55
- * entries as JSON arrays; `date` stores an ISO-8601 string.
56
- */
57
51
  const storageSerializers = {
58
52
  bigint: {
59
53
  read: (raw) => BigInt(raw),
@@ -94,16 +88,6 @@ const storageSerializers = {
94
88
  write: (value) => value
95
89
  }
96
90
  };
97
- /**
98
- * Select the built-in serializer kind for a default value.
99
- *
100
- * `null`, arrays, and plain objects use JSON (`"object"`); `Map`, `Set`, and
101
- * `Date` use their dedicated kinds; primitives use their `typeof`.
102
- * Functions and symbols cannot be stored and fall back to `"string"`.
103
- *
104
- * @param value Default value supplied to {@link useStorage}.
105
- * @returns The inferred serializer kind.
106
- */
107
91
  function inferStorageSerializerKind(value) {
108
92
  if (value instanceof Map) return "map";
109
93
  if (value instanceof Set) return "set";
@@ -151,38 +135,6 @@ function defaultStorage(area) {
151
135
  function isSameDocumentDetail(detail) {
152
136
  return isPlainObject(detail) && typeof detail.key === "string" && "storage" in detail;
153
137
  }
154
- /**
155
- * Synchronize a typed reactive value with a Web Storage compatible backend.
156
- *
157
- * The serializer is inferred from `defaultValue` (numbers stay numbers,
158
- * `Map`/`Set`/`Date` round-trip), and every decoded value passes the
159
- * `validate` hook before it is accepted, so corrupted or foreign data falls
160
- * back to the default instead of leaking the wrong type. Writes follow the
161
- * reactive value; changes from other tabs (`storage` events) and from other
162
- * instances in the same document using the same key are applied live.
163
- *
164
- * Server rendering: without a browser `window` no storage is touched and
165
- * `state` holds the default. Node's global `localStorage` is intentionally
166
- * ignored because it would be shared between requests. Inside a component
167
- * `initialRead` defaults to `"post-flush"`, so hydrating markup that rendered
168
- * the default matches before switching to the stored value.
169
- *
170
- * Failures (quota, disabled storage, malformed data) never throw; they are
171
- * exposed through `error` and `onError`.
172
- *
173
- * @example
174
- * ```ts
175
- * const { state: theme } = useStorage("theme", "light" as "light" | "dark");
176
- * theme.value = "dark"; // persisted
177
- * ```
178
- *
179
- * @typeParam Value Stored value type, inferred from `defaultValue`.
180
- * @param key Reactive storage key; changing it re-reads the new key.
181
- * @param defaultValue Value used when the key is absent or unreadable.
182
- * @param options Backend, serialization, validation, and timing options.
183
- * @default options {}
184
- * @returns The synchronized value and its controls.
185
- */
186
138
  function useStorage(key, defaultValue, options = {}) {
187
139
  const initial = toValue(defaultValue);
188
140
  const state = ref(initial);
@@ -382,29 +334,9 @@ function useStorage(key, defaultValue, options = {}) {
382
334
  remove
383
335
  };
384
336
  }
385
- /**
386
- * {@link useStorage} bound to `window.localStorage` by default.
387
- *
388
- * @typeParam Value Stored value type, inferred from `defaultValue`.
389
- * @param key Reactive storage key.
390
- * @param defaultValue Value used when the key is absent or unreadable.
391
- * @param options Serialization, validation, and timing options.
392
- * @default options {}
393
- * @returns The synchronized value and its controls.
394
- */
395
337
  function useLocalStorage(key, defaultValue, options = {}) {
396
338
  return useStorage(key, defaultValue, options);
397
339
  }
398
- /**
399
- * {@link useStorage} bound to `window.sessionStorage` by default.
400
- *
401
- * @typeParam Value Stored value type, inferred from `defaultValue`.
402
- * @param key Reactive storage key.
403
- * @param defaultValue Value used when the key is absent or unreadable.
404
- * @param options Serialization, validation, and timing options.
405
- * @default options {}
406
- * @returns The synchronized value and its controls.
407
- */
408
340
  function useSessionStorage(key, defaultValue, options = {}) {
409
341
  return useStorage(key, defaultValue, {
410
342
  ...options,
@@ -18,28 +18,6 @@ function browserStyleHost() {
18
18
  }
19
19
  };
20
20
  }
21
- /**
22
- * Inject a reactive `<style>` element.
23
- *
24
- * The element's text follows `css`. An existing `<style>` with the same
25
- * id — for example one emitted in server-rendered HTML — is adopted instead
26
- * of duplicated, which keeps hydration free of flashes. The element is
27
- * removed when the owning reactive scope stops or `unload` is called.
28
- *
29
- * Server rendering: nothing is injected and `loaded` is false. Emit the
30
- * server-side `<style id>` through the application's head manager using the
31
- * same id to make the client adopt it.
32
- *
33
- * @example
34
- * ```ts
35
- * const { css } = useStyleTag(() => `:root { --accent: ${accent.value} }`, { id: "theme" });
36
- * ```
37
- *
38
- * @param css Reactive style sheet text.
39
- * @param options Id, attributes, timing, and capability.
40
- * @default options {}
41
- * @returns Style state and actions.
42
- */
43
21
  function useStyleTag(css, options = {}) {
44
22
  const id = options.id ?? "vize-style";
45
23
  const state = isRef(css) ? css : ref(toValue(css));
@@ -1,23 +1,6 @@
1
1
  import { useMounted } from "./use-mounted.mjs";
2
2
  import { computed, hasInjectionContext, shallowRef } from "vue";
3
3
  //#region src/use-supported.ts
4
- /**
5
- * Hydration-stable feature detection.
6
- *
7
- * Inside a component the result is `false` until the component mounts and
8
- * then reflects `check()`, so server and hydrating client render the same
9
- * fallback first. Outside a component it is evaluated right away when a
10
- * browser `window` exists and stays `false` otherwise. `check` may read
11
- * reactive state; the result recomputes when it changes.
12
- *
13
- * @example
14
- * ```ts
15
- * const isSupported = useSupported(() => "share" in navigator);
16
- * ```
17
- *
18
- * @param check Returns a truthy value when the feature is available.
19
- * @returns Computed support flag.
20
- */
21
4
  function useSupported(check) {
22
5
  const ready = hasInjectionContext() ? useMounted() : shallowRef(typeof window !== "undefined");
23
6
  return computed(() => ready.value && Boolean(check()));
@@ -7,52 +7,6 @@ const defaultScheduler = {
7
7
  globalThis.clearTimeout(handle);
8
8
  }
9
9
  };
10
- /**
11
- * Create a readonly throttled view of a reactive source.
12
- *
13
- * Changes are observed with `flush: "sync"`, so every synchronous write
14
- * counts. Outside a cooldown window, a change applies immediately when
15
- * {@link UseThrottledOptions.leading} is enabled (otherwise it waits as a
16
- * trailing update) and opens a window of `waitMs` milliseconds. Changes
17
- * inside a window are collected as the trailing candidate; when the window
18
- * ends with a candidate waiting, the source value current at that moment is
19
- * applied and the next window opens back to back, keeping applications
20
- * spaced by `waitMs`. A window that ends without a candidate closes silently.
21
- * `waitMs` is reactive and is read each time a window opens; changing it
22
- * never disturbs an already-open window. A wait of `0` still defers trailing
23
- * updates to the next scheduler tick.
24
- *
25
- * Server rendering is explicit: without a browser `window` (and with
26
- * {@link UseThrottledOptions.runOnServer} disabled) no timer ever starts and
27
- * the view mirrors the source synchronously, so server-rendered output shows
28
- * current values and nothing leaks. `pending` stays `false` and the controls
29
- * report `false` in that mode.
30
- *
31
- * Cleanup rule: the watcher and any open window timer are released when the
32
- * owning reactive scope stops; call inside an active scope. Outside one, the
33
- * watcher lives as long as the source and `cancel()` only clears the window.
34
- *
35
- * @example
36
- * ```ts
37
- * const scrollY = shallowRef(0);
38
- * const { throttled } = useThrottled(scrollY, 100);
39
- * scrollY.value = 40; // applied immediately (leading edge)
40
- * scrollY.value = 80; // applied when the 100ms window ends
41
- * ```
42
- *
43
- * @param source Reactive source to throttle.
44
- * @param waitMs Reactive cooldown in milliseconds; must be finite and at
45
- * least zero. Fractions are truncated.
46
- * @param options Edge policy and runtime scheduling overrides.
47
- * @default options {}
48
- * @throws `RangeError` tagged `VIZE_COMPOSE_THROTTLE_INVALID_WAIT` when the
49
- * resolved wait is not finite or is negative, both synchronously at creation
50
- * (even in mirror mode) and again each time a window opens.
51
- * @throws `TypeError` tagged `VIZE_COMPOSE_THROTTLE_INVALID_EDGES` when both
52
- * `leading` and `trailing` are disabled, because updates could then never
53
- * propagate.
54
- * @returns Readonly throttled view, pending flag, and cancel/flush controls.
55
- */
56
10
  function useThrottled(source, waitMs, options = {}) {
57
11
  const leading = options.leading ?? true;
58
12
  const trailing = options.trailing ?? true;
@@ -24,28 +24,6 @@ function toEpochMs(input) {
24
24
  if (Number.isNaN(value)) throw new RangeError(`[VIZE_COMPOSE_TIME_AGO_INVALID_DATE] expected a valid date; received ${String(input)}`);
25
25
  return value;
26
26
  }
27
- /**
28
- * Format the distance between two instants as a localized relative phrase.
29
- *
30
- * Pure and deterministic: the output depends only on the arguments (the
31
- * locale defaults to `"en"`, never the host default), which makes it safe
32
- * for server rendering and hydration.
33
- *
34
- * @example
35
- * ```ts
36
- * formatTimeAgo(Date.UTC(2026, 0, 1), Date.UTC(2026, 0, 2)); // "yesterday"
37
- * formatTimeAgo(0, 90_000, { numeric: "always" }); // "2 minutes ago"
38
- * ```
39
- *
40
- * @param time Instant being described.
41
- * @param now Reference instant.
42
- * @param options Locale, wording, unit, and threshold policy.
43
- * @default options {}
44
- * @throws `RangeError` tagged `VIZE_COMPOSE_TIME_AGO_INVALID_DATE` when
45
- * either input is not a valid date, and `RangeError` from `Intl` for invalid
46
- * locales.
47
- * @returns The localized phrase.
48
- */
49
27
  function formatTimeAgo(time, now, options = {}) {
50
28
  const target = toEpochMs(time);
51
29
  const diff = target - toEpochMs(now);
@@ -1,24 +1,5 @@
1
1
  import { shallowRef } from "vue";
2
2
  //#region src/use-toggle.ts
3
- /**
4
- * Create owned boolean state with an inverting control.
5
- *
6
- * Purely synchronous state: safe during server rendering (no browser
7
- * globals, no timers) and nothing to dispose, so it works inside and
8
- * outside reactive scopes alike.
9
- *
10
- * @example
11
- * ```ts
12
- * const { state: open, toggle } = useToggle();
13
- * toggle(); // true
14
- * toggle(false); // false
15
- * open.value; // false
16
- * ```
17
- *
18
- * @param initial State before the first toggle.
19
- * @default initial false
20
- * @returns The writable state and its toggle control.
21
- */
22
3
  function useToggle(initial = false) {
23
4
  const state = shallowRef(initial);
24
5
  const toggle = (force) => {
@@ -15,34 +15,6 @@ function decodeFragment(hash) {
15
15
  function encodeFragment(raw) {
16
16
  return encodeURI(raw).replaceAll("#", "%23");
17
17
  }
18
- /**
19
- * Synchronize a typed value with the URL fragment (`location.hash`).
20
- *
21
- * Reading follows `hashchange` and `popstate`. Writing `state` updates the
22
- * fragment through `history.replaceState` (or `pushState` with
23
- * `mode: "push"`), which neither scrolls to an anchor nor fires
24
- * `hashchange`; an empty serialized value removes the fragment. Values are
25
- * percent-decoded on read and minimally encoded on write.
26
- *
27
- * Server rendering: browsers never send the fragment, so without a host the
28
- * value is `ssrHash` (when given) or the default, and no global is read.
29
- * Inside a component the browser hash is first read after mounting
30
- * (`initialRead` defaults to `"post-flush"` there), so hydration never
31
- * mismatches. Listeners are removed with the owning reactive scope.
32
- *
33
- * @example
34
- * ```ts
35
- * const { state: tab } = useUrlHash({
36
- * parse: (raw) => (raw === "settings" ? "settings" : "profile"),
37
- * serialize: (value) => value,
38
- * default: "profile" as "profile" | "settings",
39
- * });
40
- * ```
41
- *
42
- * @param options Codec, host, history mode, and server fallback.
43
- * @default options {}
44
- * @returns The synchronized value and its controls.
45
- */
46
18
  function useUrlHash(options = {}) {
47
19
  if ("parse" in options) return createUrlHash({
48
20
  parse: options.parse,
@@ -31,15 +31,7 @@ function arrayCodec(item) {
31
31
  serialize: (value) => value.flatMap((entry) => item.serialize(entry))
32
32
  };
33
33
  }
34
- /** Built-in typed codecs for {@link useUrlSearchParams} schemas. */
35
34
  const searchParam = {
36
- /**
37
- * Raw string value.
38
- *
39
- * @param fallback Value for an absent key.
40
- * @default fallback ""
41
- * @returns A string codec.
42
- */
43
35
  string(fallback = "") {
44
36
  return single({
45
37
  parse: (raw) => raw,
@@ -47,13 +39,6 @@ const searchParam = {
47
39
  default: fallback
48
40
  });
49
41
  },
50
- /**
51
- * Finite number; non-numeric input selects the default.
52
- *
53
- * @param fallback Value for an absent or invalid key.
54
- * @default fallback 0
55
- * @returns A number codec.
56
- */
57
42
  number(fallback = 0) {
58
43
  return single({
59
44
  parse: (raw) => {
@@ -64,13 +49,6 @@ const searchParam = {
64
49
  default: fallback
65
50
  });
66
51
  },
67
- /**
68
- * Boolean: `true`/`1`/empty read as `true`, `false`/`0` as `false`.
69
- *
70
- * @param fallback Value for an absent or unrecognized key.
71
- * @default fallback false
72
- * @returns A boolean codec.
73
- */
74
52
  boolean(fallback = false) {
75
53
  return single({
76
54
  parse: (raw) => {
@@ -82,13 +60,6 @@ const searchParam = {
82
60
  default: fallback
83
61
  });
84
62
  },
85
- /**
86
- * One of a closed set of string literals.
87
- *
88
- * @param values Allowed values.
89
- * @param fallback Value for an absent or unknown key.
90
- * @returns A literal-union codec.
91
- */
92
63
  enum(values, fallback) {
93
64
  const allowed = new Set(values);
94
65
  const isAllowed = (raw) => allowed.has(raw);
@@ -98,22 +69,7 @@ const searchParam = {
98
69
  default: fallback
99
70
  });
100
71
  },
101
- /**
102
- * Repeated key (`?tag=a&tag=b`) decoded item by item.
103
- *
104
- * @param item Single-value codec applied to every value.
105
- * @default item searchParam.string()
106
- * @returns An array codec whose default is `[]`.
107
- */
108
72
  array: arrayCodec,
109
- /**
110
- * JSON value checked by `validate`, or by kind against the default.
111
- *
112
- * @param fallback Value for an absent or invalid key.
113
- * @param validate Type guard applied to the decoded JSON.
114
- * @default validate the decoded value has the default's kind
115
- * @returns A JSON codec.
116
- */
117
73
  json(fallback, validate) {
118
74
  const accept = validate ?? ((candidate) => sameJsonKind(fallback, candidate));
119
75
  return single({
@@ -125,12 +81,6 @@ const searchParam = {
125
81
  default: fallback
126
82
  });
127
83
  },
128
- /**
129
- * Single-value codec from explicit parse/serialize functions.
130
- *
131
- * @param definition Parse, serialize, and default.
132
- * @returns The codec.
133
- */
134
84
  custom(definition) {
135
85
  return single(definition);
136
86
  }
@@ -149,14 +99,6 @@ function toSearch(source) {
149
99
  const query = withoutHash.indexOf("?");
150
100
  return new URLSearchParams(query === -1 ? "" : withoutHash.slice(query + 1));
151
101
  }
152
- /**
153
- * Decode search parameters with a schema. Pure and SSR-safe.
154
- *
155
- * @typeParam Schema Parameter codecs.
156
- * @param schema Parameter codecs.
157
- * @param search URL, URL string, query string, or parsed parameters.
158
- * @returns One typed value per schema key.
159
- */
160
102
  function parseSearchParams(schema, search) {
161
103
  const params = toSearch(search);
162
104
  const entries = Object.keys(schema).map((key) => {
@@ -168,16 +110,6 @@ function parseSearchParams(schema, search) {
168
110
  function sameValues(left, right) {
169
111
  return left.length === right.length && left.every((value, index) => value === right[index]);
170
112
  }
171
- /**
172
- * Encode typed values with a schema. Pure and SSR-safe.
173
- *
174
- * @typeParam Schema Parameter codecs.
175
- * @param schema Parameter codecs.
176
- * @param values Values to encode; keys absent from `values` keep the base.
177
- * @param options Base parameters and default removal.
178
- * @default options {}
179
- * @returns The encoded parameters.
180
- */
181
113
  function serializeSearchParams(schema, values, options = {}) {
182
114
  const params = options.base === void 0 ? new URLSearchParams() : toSearch(options.base);
183
115
  const removeDefaults = options.removeDefaults ?? true;
@@ -198,37 +130,6 @@ function serializeSearchParams(schema, values, options = {}) {
198
130
  function browserHost() {
199
131
  return typeof window !== "undefined" ? window : void 0;
200
132
  }
201
- /**
202
- * Two-way bind typed URL search parameters described by a codec schema.
203
- *
204
- * Every property type is inferred from its codec. Assigning a property
205
- * rewrites the query through `history.replaceState` (or `pushState` with
206
- * `mode: "push"`), keeping parameters outside the schema and the fragment,
207
- * and dropping values equal to their default. Back/forward navigation
208
- * (`popstate`) re-reads the URL.
209
- *
210
- * Server rendering: no global is read. Pass `ssrUrl` (the request URL) so
211
- * the server renders the same values the client reads during hydration.
212
- * Inside a component the browser URL is first read after mounting, so the
213
- * hydrating client renders the `ssrUrl` state before switching to it.
214
- * Listeners are removed with the owning reactive scope or `stop()`.
215
- *
216
- * @example
217
- * ```ts
218
- * const { params } = useUrlSearchParams({
219
- * page: searchParam.number(1),
220
- * sort: searchParam.enum(["new", "top"], "new"),
221
- * tags: searchParam.array(),
222
- * });
223
- * params.page += 1; // ?page=2
224
- * ```
225
- *
226
- * @typeParam Schema Parameter codecs.
227
- * @param schema Parameter codecs.
228
- * @param options Host, history mode, default removal, and server URL.
229
- * @default options {}
230
- * @returns Typed reactive parameters and controls.
231
- */
232
133
  function useUrlSearchParams(schema, options = {}) {
233
134
  const resolveHost = () => options.host === void 0 ? browserHost() : toValue(options.host) ?? void 0;
234
135
  const removeDefaults = options.removeDefaults ?? true;
package/dist/use-usb.mjs CHANGED
@@ -20,29 +20,6 @@ function describe(device) {
20
20
  opened: device.opened
21
21
  };
22
22
  }
23
- /**
24
- * Talk to USB devices with the WebUSB API.
25
- *
26
- * `devices` lists granted devices as plain snapshots and follows the host's
27
- * `connect` / `disconnect` events. The device actions are thin wrappers over
28
- * `USBDevice` that resolve to a boolean or the transfer result and record
29
- * failures in `error` instead of rejecting. Host listeners are removed and
30
- * sessions opened through `open()` are closed when the owning reactive scope
31
- * stops; outside a scope call `close()` per device.
32
- *
33
- * Server rendering: `supported` is false and `devices` is empty.
34
- *
35
- * @example
36
- * ```ts
37
- * const usb = useUSB();
38
- * const device = await usb.requestDevice([{ vendorId: 0x2341 }]);
39
- * if (device && (await usb.open(device))) await usb.claimInterface(device, 0);
40
- * ```
41
- *
42
- * @param options Capability host.
43
- * @default options {}
44
- * @returns USB state and actions.
45
- */
46
23
  function useUSB(options = {}) {
47
24
  const devices = shallowRef([]);
48
25
  const error = shallowRef(void 0);
@@ -25,28 +25,6 @@ function browserScheduler() {
25
25
  }
26
26
  };
27
27
  }
28
- /**
29
- * Track sticky and transient user activation with the User Activation API.
30
- *
31
- * The state is refreshed on activation-triggering events of `target`
32
- * (immediately and again after a microtask) and polled while `isActive` is
33
- * true so its expiry is observed. Listeners and the timer are removed when
34
- * the owning reactive scope stops; outside a scope call `stop()`.
35
- *
36
- * Server rendering: no listeners or timers, `supported`, `hasBeenActive`,
37
- * and `isActive` are false.
38
- *
39
- * @example
40
- * ```ts
41
- * const { isActive } = useUserActivation();
42
- * const canOpenPopup = computed(() => isActive.value);
43
- * ```
44
- *
45
- * @param options Capability host, event target, and polling policy.
46
- * @default options {}
47
- * @throws `RangeError` tagged `VIZE_COMPOSE_USER_ACTIVATION_INVALID_INTERVAL` when `interval` is negative or not finite.
48
- * @returns Activation state.
49
- */
50
28
  function useUserActivation(options = {}) {
51
29
  const interval = options.interval ?? 1e3;
52
30
  if (!Number.isFinite(interval) || interval < 0) throw new RangeError(`[VIZE_COMPOSE_USER_ACTIVATION_INVALID_INTERVAL] interval must be a finite, non-negative number; received ${String(interval)}`);
@@ -19,33 +19,6 @@ function classify(error) {
19
19
  function stopTracks(stream) {
20
20
  for (const track of stream.getTracks()) track.stop();
21
21
  }
22
- /**
23
- * Manage the lifecycle of a media stream from any asynchronous source.
24
- *
25
- * This is the engine behind {@link useUserMedia} and `useDisplayMedia`, and
26
- * can wrap any other stream producer (canvas capture, WebRTC). Acquisition
27
- * failures are classified into {@link MediaStreamErrorCode}s; the stream
28
- * returns to `"idle"` once all of its tracks ended (device unplugged, the
29
- * user stopped screen sharing). Latest-wins: a stream that resolves after a
30
- * newer request or a `stop` is stopped immediately. All tracks are stopped
31
- * when the owning reactive scope stops.
32
- *
33
- * Server rendering: without a browser window a missing source keeps the
34
- * status `"idle"` (no error), so server markup matches the first client
35
- * render.
36
- *
37
- * @example
38
- * ```ts
39
- * const canvasStream = useMediaStream({
40
- * source: { request: async (fps: number) => canvas.captureStream(fps) },
41
- * constraints: 30,
42
- * });
43
- * ```
44
- *
45
- * @typeParam Constraints Constraint type accepted by the source.
46
- * @param options Source, constraints, and activation.
47
- * @returns Stream state and actions.
48
- */
49
22
  function useMediaStream(options) {
50
23
  const stream = shallowRef(void 0);
51
24
  const status = ref("idle");
@@ -139,29 +112,6 @@ function browserUserMediaHost() {
139
112
  if (typeof window === "undefined") return void 0;
140
113
  return window.navigator.mediaDevices ?? void 0;
141
114
  }
142
- /**
143
- * Access the camera and microphone with `getUserMedia`.
144
- *
145
- * Built on {@link useMediaStream}: reactive constraints (restarting an
146
- * active stream when they change), `enabled` activation, classified
147
- * failures such as `"permission-denied"`, and latest-wins requests. With
148
- * `listDevices`, `devices` follows `devicechange`. Tracks and listeners are
149
- * released when the owning reactive scope stops.
150
- *
151
- * Server rendering: no device is touched; `status` is `"idle"`, `stream` is
152
- * undefined, and `supported` is false.
153
- *
154
- * @example
155
- * ```ts
156
- * const camera = useUserMedia({ constraints: { video: true, audio: false } });
157
- * await camera.start();
158
- * video.srcObject = camera.stream.value;
159
- * ```
160
- *
161
- * @param options Constraints, activation, device listing, and capability.
162
- * @default options {}
163
- * @returns Stream state, device list, and actions.
164
- */
165
115
  function useUserMedia(options = {}) {
166
116
  const resolveHost = () => options.host === void 0 ? browserUserMediaHost() : toValue(options.host) ?? void 0;
167
117
  const devices = shallowRef([]);
@@ -17,27 +17,6 @@ function validatePattern(pattern) {
17
17
  for (const duration of durations) if (!Number.isSafeInteger(duration) || duration < 0) throw new RangeError(`[VIZE_COMPOSE_VIBRATE_INVALID_PATTERN] vibration durations must be non-negative integers; received ${String(duration)}`);
18
18
  return durations;
19
19
  }
20
- /**
21
- * Drive the Vibration API with validated, optionally repeating patterns.
22
- *
23
- * Patterns alternate vibration and pause durations. With `interval > 0`
24
- * the pattern repeats until `stop` is called or the owning reactive scope
25
- * stops, which also cancels an ongoing vibration.
26
- *
27
- * Server rendering: nothing vibrates and no timer starts; `supported` is false.
28
- *
29
- * @example
30
- * ```ts
31
- * const { vibrate, stop } = useVibrate({ pattern: [200, 100, 200] });
32
- * vibrate();
33
- * ```
34
- *
35
- * @param options Default pattern, repetition, and capability.
36
- * @default options {}
37
- * @returns Vibration state and actions.
38
- * @throws {RangeError} `[VIZE_COMPOSE_VIBRATE_INVALID_INTERVAL]` for a negative
39
- * or non-finite interval.
40
- */
41
20
  function useVibrate(options = {}) {
42
21
  const interval = options.interval ?? 0;
43
22
  if (!Number.isFinite(interval) || interval < 0) throw new RangeError(`[VIZE_COMPOSE_VIBRATE_INVALID_INTERVAL] interval must be a non-negative finite number; received ${String(interval)}`);
@@ -6,28 +6,6 @@ function browserDocument() {
6
6
  return typeof window !== "undefined" && typeof window.document.startViewTransition === "function" ? window.document : void 0;
7
7
  }
8
8
  function ignore() {}
9
- /**
10
- * Animate DOM updates with the View Transition API.
11
- *
12
- * Starting a new transition skips the running one (browser behavior). The
13
- * running transition is skipped when the owning reactive scope stops.
14
- *
15
- * Server rendering: `start` runs the update directly; `supported` and
16
- * `isTransitioning` are false.
17
- *
18
- * @example
19
- * ```ts
20
- * const { start } = useViewTransition();
21
- * await start(async () => {
22
- * page.value = next;
23
- * await nextTick();
24
- * }, { types: ["forward"] });
25
- * ```
26
- *
27
- * @param options Document host and reduced-motion policy.
28
- * @default options {}
29
- * @returns Transition state and actions.
30
- */
31
9
  function useViewTransition(options = {}) {
32
10
  const transition = shallowRef(null);
33
11
  const isTransitioning = shallowRef(false);
@@ -1,31 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { computed, hasInjectionContext, readonly, ref, shallowRef, toValue, watch, watchPostEffect } from "vue";
3
3
  //#region src/use-visual-viewport.ts
4
- /**
5
- * Track the visual viewport and on-screen keyboard.
6
- *
7
- * On mobile browsers the visual viewport shrinks (or scrolls) when a virtual
8
- * keyboard opens while the layout viewport stays put; `keyboardHeight` is the
9
- * occluded bottom area (`innerHeight - height - offsetTop`), or the
10
- * VirtualKeyboard API rectangle when `overlaysContent` is enabled. Pin
11
- * toolbars above the keyboard with `bottom: calc(var(--kb, 0px))` bound to it.
12
- *
13
- * Server rendering reports zeros (scale 1) and attaches nothing; inside a
14
- * component the host attaches after mount, so hydration renders the same
15
- * zeros first. Listeners
16
- * (`resize`, `scroll`, `geometrychange`) are passive and removed with the
17
- * owning reactive scope.
18
- *
19
- * @example
20
- * ```ts
21
- * const { keyboardHeight, keyboardOpen } = useVisualViewport();
22
- * const toolbarStyle = computed(() => ({ bottom: `${keyboardHeight.value}px` }));
23
- * ```
24
- *
25
- * @param options Keyboard threshold, VirtualKeyboard opt-in, and capability.
26
- * @default options {}
27
- * @returns Reactive viewport geometry and keyboard state.
28
- */
29
4
  function useVisualViewport(options = {}) {
30
5
  const threshold = typeof options.keyboardThreshold === "number" && Number.isFinite(options.keyboardThreshold) ? Math.max(options.keyboardThreshold, 0) : 120;
31
6
  const width = ref(0);