@vizejs/composable 0.809.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 (173) 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.d.mts +2 -2
  32. package/dist/index.mjs +2 -2
  33. package/dist/infinite-scroll.mjs +0 -16
  34. package/dist/intersection-observer.mjs +0 -27
  35. package/dist/locale.mjs +0 -20
  36. package/dist/magic-keys.mjs +0 -35
  37. package/dist/math.mjs +0 -37
  38. package/dist/media-query.mjs +0 -29
  39. package/dist/mouse-in-element.mjs +0 -12
  40. package/dist/mouse.mjs +0 -12
  41. package/dist/mutation-observer.mjs +0 -15
  42. package/dist/network.mjs +0 -24
  43. package/dist/on-click-outside.mjs +0 -16
  44. package/dist/on-key-stroke.mjs +0 -33
  45. package/dist/on-long-press.mjs +0 -14
  46. package/dist/on-start-typing.mjs +0 -23
  47. package/dist/page-leave.mjs +0 -11
  48. package/dist/parent-element.mjs +0 -9
  49. package/dist/pinch.mjs +0 -14
  50. package/dist/pointer-lock.mjs +0 -23
  51. package/dist/pointer.mjs +0 -18
  52. package/dist/preferences.mjs +0 -31
  53. package/dist/preferred-languages.mjs +0 -13
  54. package/dist/ref-auto-reset.mjs +0 -24
  55. package/dist/ref-debounced.mjs +0 -22
  56. package/dist/ref-default.mjs +0 -21
  57. package/dist/resize-observer.mjs +0 -31
  58. package/dist/resolver.mjs +1 -58
  59. package/dist/retry-async.mjs +0 -25
  60. package/dist/retry-delay.mjs +0 -23
  61. package/dist/scope.mjs +0 -14
  62. package/dist/screen-orientation.mjs +0 -15
  63. package/dist/scroll-lock.mjs +0 -14
  64. package/dist/scroll.mjs +0 -27
  65. package/dist/standard-schema.mjs +0 -31
  66. package/dist/swipe.mjs +0 -36
  67. package/dist/temporal.mjs +0 -30
  68. package/dist/text-selection.mjs +0 -15
  69. package/dist/textarea-autosize.mjs +0 -13
  70. package/dist/to-reactive.mjs +0 -20
  71. package/dist/transition.mjs +0 -7
  72. package/dist/until.mjs +0 -25
  73. package/dist/use-array.mjs +0 -52
  74. package/dist/use-barcode-detector.mjs +0 -25
  75. package/dist/use-bluetooth.mjs +0 -27
  76. package/dist/use-broadcast-channel.mjs +0 -30
  77. package/dist/use-builtin-ai.mjs +0 -68
  78. package/dist/use-clipboard.mjs +0 -27
  79. package/dist/use-compression-stream.mjs +0 -78
  80. package/dist/use-contact-picker.mjs +0 -22
  81. package/dist/use-cookie.mjs +0 -63
  82. package/dist/use-countdown.mjs +0 -22
  83. package/dist/use-counter.mjs +0 -29
  84. package/dist/use-css-var.mjs +0 -28
  85. package/dist/use-date-format.mjs +0 -48
  86. package/dist/use-date-time-format.mjs +0 -22
  87. package/dist/use-debounced.mjs +0 -39
  88. package/dist/use-display-media.mjs +0 -22
  89. package/dist/use-display-names.mjs +0 -19
  90. package/dist/use-document-title.mjs +0 -25
  91. package/dist/use-drop-zone.mjs +0 -36
  92. package/dist/use-event-source.mjs +0 -25
  93. package/dist/use-eye-dropper.mjs +0 -19
  94. package/dist/use-favicon.mjs +0 -23
  95. package/dist/use-fetch.mjs +0 -27
  96. package/dist/use-field.mjs +0 -27
  97. package/dist/use-file-dialog.mjs +0 -21
  98. package/dist/{use-form-C2JXZ0i7.mjs → use-form-BZqwMs6k.mjs} +143 -70
  99. package/dist/use-form-field-props.mjs +0 -57
  100. package/dist/use-form.d.mts +123 -18
  101. package/dist/use-form.mjs +1 -1
  102. package/dist/use-fullscreen.mjs +0 -23
  103. package/dist/use-gamepad.mjs +0 -50
  104. package/dist/use-hid.mjs +0 -25
  105. package/dist/use-history.mjs +0 -43
  106. package/dist/use-id-generator.mjs +0 -21
  107. package/dist/use-image.mjs +0 -22
  108. package/dist/use-indexed-db.mjs +0 -39
  109. package/dist/use-interval.mjs +0 -28
  110. package/dist/use-list-format.mjs +0 -18
  111. package/dist/use-machine.mjs +0 -34
  112. package/dist/use-map.mjs +0 -28
  113. package/dist/use-media-controls.mjs +0 -28
  114. package/dist/use-mounted.mjs +0 -18
  115. package/dist/use-navigation-api.mjs +0 -27
  116. package/dist/use-notification.mjs +0 -24
  117. package/dist/use-number-format.mjs +0 -23
  118. package/dist/use-object-url.mjs +0 -22
  119. package/dist/use-offset-pagination.mjs +0 -18
  120. package/dist/use-payment-request.mjs +0 -25
  121. package/dist/use-performance-observer.mjs +0 -27
  122. package/dist/use-permission.mjs +0 -26
  123. package/dist/use-plural-rules.mjs +0 -21
  124. package/dist/use-push-subscription.mjs +0 -28
  125. package/dist/use-queue.mjs +0 -29
  126. package/dist/use-raf-fn.mjs +0 -23
  127. package/dist/use-relative-time-format.mjs +0 -35
  128. package/dist/use-request-idle-callback.mjs +0 -42
  129. package/dist/use-route-query.mjs +0 -17
  130. package/dist/use-scheduler-post-task.mjs +0 -27
  131. package/dist/use-screen-details.mjs +0 -42
  132. package/dist/use-script-tag.mjs +0 -28
  133. package/dist/use-segmenter.mjs +0 -20
  134. package/dist/use-serial.mjs +0 -24
  135. package/dist/use-service-worker.mjs +0 -27
  136. package/dist/use-set.mjs +0 -23
  137. package/dist/use-share.mjs +0 -23
  138. package/dist/use-sorted-locale.mjs +0 -20
  139. package/dist/use-speech-recognition.mjs +0 -24
  140. package/dist/use-speech-synthesis.mjs +0 -26
  141. package/dist/use-stack.mjs +0 -27
  142. package/dist/use-storage-estimate.mjs +0 -41
  143. package/dist/use-storage.mjs +0 -68
  144. package/dist/use-style-tag.mjs +0 -22
  145. package/dist/use-supported.mjs +0 -17
  146. package/dist/use-throttled.mjs +0 -46
  147. package/dist/use-time-ago.mjs +0 -22
  148. package/dist/use-toggle.mjs +0 -19
  149. package/dist/use-url-hash.mjs +0 -28
  150. package/dist/use-url-search-params.mjs +0 -99
  151. package/dist/use-usb.mjs +0 -23
  152. package/dist/use-user-activation.mjs +0 -22
  153. package/dist/use-user-media.mjs +0 -50
  154. package/dist/use-vibrate.mjs +0 -21
  155. package/dist/use-view-transition.mjs +0 -22
  156. package/dist/use-visual-viewport.mjs +0 -25
  157. package/dist/use-wake-lock.mjs +0 -21
  158. package/dist/use-web-authn.mjs +0 -61
  159. package/dist/use-web-locks.mjs +0 -25
  160. package/dist/use-web-midi.mjs +0 -22
  161. package/dist/use-web-vitals.mjs +0 -41
  162. package/dist/use-websocket.mjs +0 -27
  163. package/dist/use-worker-fn.mjs +0 -37
  164. package/dist/virtual-list.mjs +0 -14
  165. package/dist/whenever.mjs +0 -21
  166. package/dist/window-size.mjs +0 -12
  167. package/package.json +2 -2
  168. package/registry/files/form-control-types.ts +260 -0
  169. package/registry/files/form-dirty.ts +131 -0
  170. package/registry/files/form-options.ts +156 -0
  171. package/registry/files/form-path-types.ts +135 -0
  172. package/registry/files/use-form.ts +102 -449
  173. package/registry/registry.json +28 -4
@@ -1,42 +1,25 @@
1
1
  import { computed, toValue } from "vue";
2
2
  //#region src/use-route-query.ts
3
- /** Built-in {@link QueryParser}s. */
4
3
  const queryParsers = {
5
- /** First value as a string. */
6
4
  string: (raw) => typeof raw === "string" ? raw : raw?.[0],
7
- /** First value as a finite number. */
8
5
  number: (raw) => {
9
6
  const text = typeof raw === "string" ? raw : raw?.[0];
10
7
  if (text === void 0 || text.trim() === "") return void 0;
11
8
  const value = Number(text);
12
9
  return Number.isFinite(value) ? value : void 0;
13
10
  },
14
- /** First value as a safe integer. */
15
11
  integer: (raw) => {
16
12
  const text = typeof raw === "string" ? raw : raw?.[0];
17
13
  return text !== void 0 && /^-?\d+$/.test(text) && Number.isSafeInteger(Number(text)) ? Number(text) : void 0;
18
14
  },
19
- /** `"true"`/`"1"`/`""` (present flag) → `true`, `"false"`/`"0"` → `false`. */
20
15
  boolean: (raw) => {
21
16
  const text = typeof raw === "string" ? raw : raw?.[0];
22
17
  if (text === void 0) return void 0;
23
18
  if (text === "true" || text === "1" || text === "") return true;
24
19
  if (text === "false" || text === "0") return false;
25
20
  },
26
- /** Every value as a string array. */
27
21
  array: (raw) => raw === void 0 ? void 0 : typeof raw === "string" ? [raw] : [...raw]
28
22
  };
29
- /**
30
- * Parser accepting only the given literal values.
31
- *
32
- * @example
33
- * ```ts
34
- * useRouteQuery(route, "sort", { parse: oneOf(["new", "top"]), default: "new" });
35
- * ```
36
- *
37
- * @param values Allowed values.
38
- * @returns A parser narrowing to the literal union.
39
- */
40
23
  function oneOf(values) {
41
24
  const allowed = new Set(values);
42
25
  const isAllowed = (text) => allowed.has(text);
@@ -31,33 +31,6 @@ function browserTimers() {
31
31
  function validatePriority(priority) {
32
32
  if (priority !== void 0 && !PRIORITIES.includes(priority)) throw new TypeError(`[VIZE_COMPOSE_POST_TASK_INVALID_PRIORITY] priority must be one of ${PRIORITIES.join(", ")}, received ${String(priority)}`);
33
33
  }
34
- /**
35
- * Post prioritized tasks with the Prioritized Task Scheduling API.
36
- *
37
- * Every task gets its own controller (a `TaskController` when available),
38
- * so `setPriority` re-prioritizes pending tasks and `abort` rejects them;
39
- * pending tasks are aborted when the owning reactive scope stops (their
40
- * promises reject with an AbortError; outside a scope the caller owns
41
- * `abort()`).
42
- *
43
- * Fallback without `scheduler`: tasks run from `setTimeout(delay)` in
44
- * timer (FIFO) order. Priorities are ignored, so a later "user-blocking"
45
- * task does not overtake an earlier "background" one, and tasks do not
46
- * yield to rendering or input the way native tasks do.
47
- *
48
- * Server rendering: nothing is scheduled, `supported` is false and
49
- * `postTask` rejects.
50
- *
51
- * @example
52
- * ```ts
53
- * const { postTask } = useSchedulerPostTask();
54
- * const total = await postTask(() => expensiveSum(rows), { priority: "background" });
55
- * ```
56
- *
57
- * @param options Hosts and the initial priority.
58
- * @default options {}
59
- * @returns Task state and actions.
60
- */
61
34
  function useSchedulerPostTask(options = {}) {
62
35
  validatePriority(options.priority);
63
36
  const priority = shallowRef(options.priority ?? "user-visible");
@@ -1,12 +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-screen-details.ts
4
- /**
5
- * Snapshot a `ScreenDetailed` into a plain object.
6
- *
7
- * @param screen Screen to copy.
8
- * @returns Plain snapshot.
9
- */
10
4
  function snapshotScreen(screen) {
11
5
  return {
12
6
  label: screen.label,
@@ -24,17 +18,6 @@ function snapshotScreen(screen) {
24
18
  isInternal: screen.isInternal
25
19
  };
26
20
  }
27
- /**
28
- * Compute absolute window geometry inside a screen's available area.
29
- *
30
- * Sizes are clamped to the available area; omitted offsets center the window.
31
- *
32
- * @param screen Target screen area.
33
- * @param placement Desired size and offsets.
34
- * @default placement {}
35
- * @throws `RangeError` tagged `VIZE_COMPOSE_SCREEN_DETAILS_INVALID_PLACEMENT` for negative or non-finite values.
36
- * @returns Absolute placement.
37
- */
38
21
  function placeWindow(screen, placement = {}) {
39
22
  for (const value of [
40
23
  placement.width,
@@ -59,31 +42,6 @@ function browserHost() {
59
42
  function errorName(error) {
60
43
  return typeof error === "object" && error !== null && "name" in error ? error.name : void 0;
61
44
  }
62
- /**
63
- * Enumerate and target multiple screens with the Window Management API.
64
- *
65
- * `isExtended` is live from `window.screen`. `request()` asks for the
66
- * window-management permission; once granted, `screens` and
67
- * `currentScreen` stay current through `screenschange`,
68
- * `currentscreenchange`, and per-screen `change` events. `openOnScreen`
69
- * opens a window placed with {@link placeWindow}. Listeners are removed when
70
- * the owning reactive scope stops; outside a scope call `stop()`.
71
- *
72
- * Server rendering: nothing is requested, `supported` and `isExtended` are
73
- * false and `screens` is empty.
74
- *
75
- * @example
76
- * ```ts
77
- * const { request, screens, openOnScreen } = useScreenDetails();
78
- * await request();
79
- * const external = screens.value.find((screen) => !screen.isPrimary);
80
- * if (external) openOnScreen("/slides", external, { features: "popup" });
81
- * ```
82
- *
83
- * @param options Capability host.
84
- * @default options {}
85
- * @returns Screen state and actions.
86
- */
87
45
  function useScreenDetails(options = {}) {
88
46
  const isExtended = ref(false);
89
47
  const screens = shallowRef([]);
@@ -19,34 +19,6 @@ function browserScriptHost() {
19
19
  }
20
20
  };
21
21
  }
22
- /**
23
- * Inject a `<script>` tag and track its loading state.
24
- *
25
- * An existing tag with the same `src` is reused instead of duplicated: if
26
- * it was created by another `useScriptTag` call its state is shared through
27
- * a `data-vize-script-status` attribute; a tag without that attribute (for
28
- * example emitted in server-rendered HTML) is assumed to have executed.
29
- * Changing the reactive `src` unloads the previous script and, with
30
- * `immediate`, loads the new one.
31
- *
32
- * Server rendering: no document exists, so nothing is injected, `status`
33
- * stays `"idle"`, and `load` resolves `"unsupported"`. Emit server-side
34
- * script tags through the application's head manager. Scripts created by
35
- * this composable are removed when the owning scope stops (configurable);
36
- * already-executed code cannot be unloaded.
37
- *
38
- * @example
39
- * ```ts
40
- * const { status } = useScriptTag("https://example.com/widget.js", {
41
- * onLoaded: () => window.Widget.init(),
42
- * });
43
- * ```
44
- *
45
- * @param src Reactive script URL.
46
- * @param options Attributes, lifecycle, and capability.
47
- * @default options {}
48
- * @returns Loading state and actions.
49
- */
50
22
  function useScriptTag(src, options = {}) {
51
23
  const status = ref("idle");
52
24
  const element = shallowRef(void 0);
@@ -11,26 +11,6 @@ function toSegments(segmenter, text) {
11
11
  isWordLike: data.isWordLike ?? false
12
12
  }));
13
13
  }
14
- /**
15
- * Split text into graphemes, words, or sentences with `Intl.Segmenter`.
16
- *
17
- * Counts reflect what users perceive: `"👨‍👩‍👧"` is one grapheme, and
18
- * word counts skip spaces and punctuation while handling languages without
19
- * spaces (Japanese, Thai) through the locale. `truncate` shortens text
20
- * without splitting clusters. Derived state only; deterministic during
21
- * server rendering when the locale is explicit.
22
- *
23
- * @example
24
- * ```ts
25
- * const { graphemeCount, truncate } = useSegmenter(bio, { locale: "en" });
26
- * const remaining = computed(() => 160 - graphemeCount.value);
27
- * ```
28
- *
29
- * @param text Reactive text.
30
- * @param options Reactive granularity and locale.
31
- * @default options {}
32
- * @returns Reactive segments, counts, and truncation.
33
- */
34
14
  function useSegmenter(text, options = {}) {
35
15
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
36
16
  const segmenterFor = (granularity) => computed(() => new Intl.Segmenter(localeControls.locale.value, { granularity }));
@@ -10,30 +10,6 @@ function browserSerialHost() {
10
10
  function isSerialHost(value) {
11
11
  return typeof value === "object" && value !== null && "requestPort" in value;
12
12
  }
13
- /**
14
- * Talk to serial devices with the Web Serial API.
15
- *
16
- * `requestPort()` prompts for a port, `open()` opens it and starts a read
17
- * loop that feeds `onData` with bytes or decoded text, `write()` sends text
18
- * or bytes. `ports` follows the host's `connect` / `disconnect` events and a
19
- * port's own `disconnect` closes the session. Failures land in `error`. The
20
- * read loop is cancelled and the port closed when the owning reactive scope
21
- * stops; outside a scope call `close()`.
22
- *
23
- * Server rendering: `supported` and `connected` are false, nothing is read.
24
- *
25
- * @example
26
- * ```ts
27
- * const serial = useSerial({ decode: "text", onData: (text) => log(text) });
28
- * const port = await serial.requestPort([{ usbVendorId: 0x2341 }]);
29
- * if (port) await serial.open(port, { baudRate: 115200 });
30
- * ```
31
- *
32
- * @param options Host, decoding, and data callback.
33
- * @default options {}
34
- * @throws `RangeError` tagged `VIZE_COMPOSE_SERIAL_INVALID_ENCODING` for an unknown `encoding`.
35
- * @returns Serial state and actions.
36
- */
37
13
  function useSerial(options = {}) {
38
14
  const ports = shallowRef([]);
39
15
  const port = shallowRef(void 0);
@@ -11,33 +11,6 @@ function browserContainer() {
11
11
  const { navigator } = window;
12
12
  return "serviceWorker" in navigator && navigator.serviceWorker ? navigator.serviceWorker : void 0;
13
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
14
  function useServiceWorker(scriptUrl, options = {}) {
42
15
  const registration = shallowRef(null);
43
16
  const state = ref(emptyStates);
package/dist/use-set.mjs CHANGED
@@ -1,28 +1,5 @@
1
1
  import { computed, shallowReactive, shallowReadonly } from "vue";
2
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
3
  function useSet(initial = []) {
27
4
  const baseline = [...initial];
28
5
  const set = shallowReactive(new Set(baseline));
@@ -8,29 +8,6 @@ function browserShareHost() {
8
8
  function errorName(error) {
9
9
  return typeof error === "object" && error !== null && "name" in error ? String(error.name) : void 0;
10
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
11
  function useShare(defaults = {}, options = {}) {
35
12
  const sharing = ref(false);
36
13
  const resolveHost = () => options.host === void 0 ? browserShareHost() : toValue(options.host) ?? void 0;
@@ -4,26 +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
- * 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
7
  function useSortedLocale(items, options = {}) {
28
8
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
29
9
  const collator = computed(() => {
@@ -31,30 +31,6 @@ function readString(event, key) {
31
31
  const value = key in event ? Reflect.get(event, key) : void 0;
32
32
  return typeof value === "string" ? value : "";
33
33
  }
34
- /**
35
- * Transcribe speech with the Web Speech API.
36
- *
37
- * `result` accumulates the final transcript of the current session and
38
- * `interimResult` the text still being recognized. Options are applied each
39
- * time listening starts, so a reactive `lang` takes effect on the next
40
- * `start`. Errors are normalized to a closed {@link SpeechRecognitionErrorCode}
41
- * union and exposed through `error` rather than thrown. The recognizer is
42
- * aborted and its listeners removed when the owning reactive scope stops.
43
- *
44
- * Server rendering: no recognizer is created; `supported` and `listening`
45
- * are false and the transcripts are empty.
46
- *
47
- * @example
48
- * ```ts
49
- * const speech = useSpeechRecognition({ lang: "ja-JP" });
50
- * speech.start();
51
- * watch(speech.result, (text) => console.log(text));
52
- * ```
53
- *
54
- * @param options Recognition settings and recognizer constructor.
55
- * @default options {}
56
- * @returns Recognition state and actions.
57
- */
58
34
  function useSpeechRecognition(options = {}) {
59
35
  const listening = ref(false);
60
36
  const result = ref("");
@@ -28,32 +28,6 @@ function checkedRange(name, value, minimum, maximum) {
28
28
  if (!Number.isFinite(value) || value < minimum || value > maximum) throw new RangeError(`[VIZE_COMPOSE_SPEECH_SYNTHESIS_INVALID_OPTION] ${name} must be between ${String(minimum)} and ${String(maximum)}; received ${String(value)}`);
29
29
  return value;
30
30
  }
31
- /**
32
- * Speak text with the Web Speech API.
33
- *
34
- * Each `speak` creates a fresh utterance from the current reactive text,
35
- * language, voice, pitch, rate, and volume (validated ranges), and cancels
36
- * speech previously started by this composable. `status` follows the
37
- * utterance lifecycle; interruptions caused by `cancel` return to `"idle"`
38
- * instead of reporting an error. The available voices are kept current via
39
- * `voiceschanged`. Speech started by this composable is cancelled and the
40
- * listener removed when the owning reactive scope stops.
41
- *
42
- * Server rendering: nothing is spoken; `supported` is false, `status` is
43
- * `"idle"`, and `voices` is empty.
44
- *
45
- * @example
46
- * ```ts
47
- * const text = ref("Hello, Vize");
48
- * const { speak, status } = useSpeechSynthesis(text, { rate: 1.2 });
49
- * speak();
50
- * ```
51
- *
52
- * @param text Reactive text to speak.
53
- * @param options Voice parameters and synthesis capabilities.
54
- * @default options {}
55
- * @returns Synthesis state and actions.
56
- */
57
31
  function useSpeechSynthesis(text, options = {}) {
58
32
  const status = ref("idle");
59
33
  const voices = shallowRef([]);
@@ -5,33 +5,6 @@ function validateCapacity(capacity) {
5
5
  if (!Number.isSafeInteger(capacity) || capacity < 1) throw new RangeError(`[VIZE_COMPOSE_STACK_INVALID_CAPACITY] capacity must be a positive integer or Infinity; received ${String(capacity)}`);
6
6
  return capacity;
7
7
  }
8
- /**
9
- * Create a typed reactive LIFO stack.
10
- *
11
- * `push` and `pop` are O(1). A bounded stack either drops its bottom item
12
- * or rejects new pushes when full. Reactivity is driven by a version
13
- * counter, so `items`, `size`, `isEmpty`, and `peek` re-evaluate after
14
- * every mutation.
15
- *
16
- * Purely synchronous state: safe during server rendering (no host globals,
17
- * no timers) and nothing to dispose.
18
- *
19
- * @example
20
- * ```ts
21
- * const breadcrumbs = useStack<string>(["home"]);
22
- * breadcrumbs.push("settings");
23
- * breadcrumbs.pop(); // "settings"
24
- * ```
25
- *
26
- * @typeParam Item Stacked item type, inferred from `initial` when given.
27
- * @param initial Items pushed at creation, bottom first (overflow applies).
28
- * @param options Capacity and overflow policy.
29
- * @default initial []
30
- * @default options {}
31
- * @throws {RangeError} `[VIZE_COMPOSE_STACK_INVALID_CAPACITY]` when `capacity`
32
- * is not a positive integer or `Infinity`.
33
- * @returns The reactive stack and its controls.
34
- */
35
8
  function useStack(initial = [], options = {}) {
36
9
  const capacity = validateCapacity(options.capacity ?? Number.POSITIVE_INFINITY);
37
10
  const overflow = options.overflow ?? "drop-oldest";
@@ -18,27 +18,6 @@ function browserScheduler() {
18
18
  function resolver(source) {
19
19
  return () => source === void 0 ? browserStorage() : toValue(source) ?? void 0;
20
20
  }
21
- /**
22
- * Track the origin's storage usage and quota with `navigator.storage.estimate()`.
23
- *
24
- * The estimate is read on creation (unless `immediate` is false), whenever a
25
- * reactive `storage` host changes, on `refresh()`, and every `interval`
26
- * milliseconds through the injectable `scheduler`. The polling timer stops
27
- * with the owning reactive scope; outside a scope, polling runs until the
28
- * page unloads, so leave `interval` at `0` there.
29
- *
30
- * Server rendering: nothing is read, no timer starts, `supported` is false
31
- * and every value is `null`.
32
- *
33
- * @example
34
- * ```ts
35
- * const { usage, quota, percentUsed } = useStorageEstimate({ interval: 60_000 });
36
- * ```
37
- *
38
- * @param options Storage host, polling interval and scheduler.
39
- * @default options {}
40
- * @returns Storage usage state and a refresh action.
41
- */
42
21
  function useStorageEstimate(options = {}) {
43
22
  const { immediate = true, interval = 0 } = options;
44
23
  if (!Number.isFinite(interval) || interval < 0) throw new RangeError(`[VIZE_COMPOSE_STORAGE_ESTIMATE_INVALID_INTERVAL] interval must be a non-negative finite number; received ${interval}.`);
@@ -96,26 +75,6 @@ function useStorageEstimate(options = {}) {
96
75
  refresh
97
76
  };
98
77
  }
99
- /**
100
- * Read and request persistent storage with `navigator.storage.persist()`.
101
- *
102
- * Persistent storage is not evicted under storage pressure. `persist()` may
103
- * show a prompt or be decided silently by the browser; the result is stored
104
- * in `persisted`. Nothing needs cleanup; a pending read is ignored after the
105
- * owning reactive scope stops.
106
- *
107
- * Server rendering: nothing is read, `supported` and `persisted` are false.
108
- *
109
- * @example
110
- * ```ts
111
- * const storage = usePersistentStorage();
112
- * const keepOfflineData = () => storage.persist();
113
- * ```
114
- *
115
- * @param options Storage host and initial read policy.
116
- * @default options {}
117
- * @returns Persistence state and actions.
118
- */
119
78
  function usePersistentStorage(options = {}) {
120
79
  const hydrated = shallowRef(!hasInjectionContext());
121
80
  if (!hydrated.value) watchPostEffect(() => {
@@ -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()));