@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
@@ -6,9 +6,7 @@ const MINUTE = 6e4;
6
6
  const HOUR = 36e5;
7
7
  const DAY = 864e5;
8
8
  const WEEK = 6048e5;
9
- /** Gregorian average month: 30.436875 days. */
10
9
  const MONTH = 2629746e3;
11
- /** Gregorian average year: 365.2425 days. */
12
10
  const YEAR = 31556952e3;
13
11
  const thresholds = [
14
12
  [
@@ -42,17 +40,6 @@ const thresholds = [
42
40
  "month"
43
41
  ]
44
42
  ];
45
- /**
46
- * Pick the largest unit that expresses a millisecond difference as a
47
- * non-zero rounded amount: seconds below a minute, minutes below an hour,
48
- * hours below a day, days below a week, weeks below a month, months below
49
- * a year, and years otherwise (Gregorian average month/year lengths).
50
- *
51
- * @param diffMs Signed difference; negative is in the past.
52
- * @returns The rounded amount and its unit.
53
- * @throws {RangeError} `[VIZE_COMPOSE_RELATIVE_TIME_INVALID_DIFF]` for a
54
- * non-finite difference.
55
- */
56
43
  function selectRelativeTimeUnit(diffMs) {
57
44
  if (!Number.isFinite(diffMs)) throw new RangeError(`[VIZE_COMPOSE_RELATIVE_TIME_INVALID_DIFF] the difference must be finite; received ${String(diffMs)}`);
58
45
  const magnitude = Math.abs(diffMs);
@@ -68,28 +55,6 @@ function selectRelativeTimeUnit(diffMs) {
68
55
  function browserLanguage() {
69
56
  return typeof window === "undefined" ? void 0 : window.navigator.language;
70
57
  }
71
- /**
72
- * Format relative times ("in 3 days", "yesterday") with `Intl.RelativeTimeFormat`.
73
- *
74
- * A pure formatting wrapper: it owns no clock or timer, so it never
75
- * re-renders on its own and stays deterministic during server rendering
76
- * (pair it with a clock composable for live "time ago" labels). The
77
- * formatter follows the reactive options and is cached per locale and
78
- * option set through {@link useLocale}; invalid options surface as the
79
- * platform's `RangeError`.
80
- *
81
- * @example
82
- * ```ts
83
- * const { formatted } = useRelativeTimeFormat(-1, "day", { locale: "en", numeric: "auto" });
84
- * formatted.value; // "yesterday"
85
- * ```
86
- *
87
- * @param value Reactive signed amount; `null`/`undefined` format as `""`.
88
- * @param unit Reactive unit.
89
- * @param options Reactive locale and `Intl.RelativeTimeFormat` options.
90
- * @default options {}
91
- * @returns Reactive formatted output and formatting helpers.
92
- */
93
58
  function useRelativeTimeFormat(value, unit, options = {}) {
94
59
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
95
60
  const formatter = computed(() => {
@@ -1,7 +1,6 @@
1
1
  import { tryOnScopeDispose } from "./scope.mjs";
2
2
  import { computed, hasInjectionContext, readonly, shallowRef, toValue, watch, watchPostEffect } from "vue";
3
3
  //#region src/use-request-idle-callback.ts
4
- /** Idle period length fabricated by the fallback, in milliseconds (the spec maximum). */
5
4
  const FALLBACK_IDLE_PERIOD = 50;
6
5
  function browserIdleHost() {
7
6
  return typeof window !== "undefined" && typeof window.requestIdleCallback === "function" ? window : void 0;
@@ -19,7 +18,6 @@ function browserTimers() {
19
18
  function validateTimeout(timeout) {
20
19
  if (timeout !== void 0 && (!Number.isFinite(timeout) || timeout < 0)) throw new RangeError(`[VIZE_COMPOSE_IDLE_CALLBACK_INVALID_TIMEOUT] timeout must be a finite, non-negative number, received ${String(timeout)}`);
21
20
  }
22
- /** Schedule once; returns a canceller, or undefined when nothing could be scheduled. */
23
21
  function scheduleIdle(options, callback) {
24
22
  const host = options.host === void 0 ? browserIdleHost() : toValue(options.host);
25
23
  if (host) {
@@ -38,30 +36,6 @@ function scheduleIdle(options, callback) {
38
36
  }, 1);
39
37
  return () => timers.clearTimeout(handle);
40
38
  }
41
- /**
42
- * Run a callback in the next idle period with `requestIdleCallback`.
43
- *
44
- * When the API is missing, a `setTimeout` fallback fabricates a deadline
45
- * with a 50 ms budget and `didTimeout: false`. The pending callback is
46
- * cancelled when the owning reactive scope stops; outside a scope the
47
- * caller owns `cancel()`.
48
- *
49
- * Server rendering: nothing is scheduled, `isPending` and `supported` are
50
- * false. Inside a component the first callback is scheduled after mounting,
51
- * so hydration renders the server state first.
52
- *
53
- * @example
54
- * ```ts
55
- * const { start } = useRequestIdleCallback((deadline) => {
56
- * while (deadline.timeRemaining() > 1 && queue.length) queue.shift()?.();
57
- * }, { timeout: 2000, immediate: false });
58
- * ```
59
- *
60
- * @param callback Receives the idle deadline.
61
- * @param options Hosts, timeout and start policy.
62
- * @default options {}
63
- * @returns Scheduling state and actions.
64
- */
65
39
  function useRequestIdleCallback(callback, options = {}) {
66
40
  validateTimeout(options.timeout);
67
41
  const isPending = shallowRef(false);
@@ -101,22 +75,6 @@ function useRequestIdleCallback(callback, options = {}) {
101
75
  cancel
102
76
  };
103
77
  }
104
- /**
105
- * Resolve in the next idle period (or after `timeout`).
106
- *
107
- * Uses the same hosts and fallback as {@link useRequestIdleCallback}. When
108
- * neither an idle host nor timers resolve (server rendering) it resolves on
109
- * the next microtask with an exhausted deadline instead of hanging.
110
- *
111
- * @example
112
- * ```ts
113
- * await idle({ timeout: 1000 });
114
- * ```
115
- *
116
- * @param options Hosts, timeout and abort signal.
117
- * @default options {}
118
- * @returns The idle deadline; rejects with `signal.reason` when aborted.
119
- */
120
78
  function idle(options = {}) {
121
79
  validateTimeout(options.timeout);
122
80
  const { signal } = options;
@@ -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(() => {