@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
@@ -50,33 +50,6 @@ const unsupported = {
50
50
  status: "unsupported",
51
51
  error: void 0
52
52
  };
53
- /**
54
- * Permission-aware clipboard access with a legacy copy fallback.
55
- *
56
- * Text and rich items go through the async Clipboard API. When it is
57
- * missing (insecure contexts, older engines) or refuses a write, `copy`
58
- * falls back to `document.execCommand("copy")` unless `legacy` is false.
59
- * Every action resolves to a discriminated {@link ClipboardResult}
60
- * (`"success"`, `"permission-denied"`, `"unsupported"`, `"failed"`) instead
61
- * of rejecting, and the read/write permission states are exposed reactively.
62
- *
63
- * Server rendering: nothing is read and no permission is queried; `text` is
64
- * empty and `supported` is false. The `copied` reset timer and the optional
65
- * `copy`/`cut` listeners are released when the owning scope stops.
66
- *
67
- * Inside a component the host is read after mounting, so hydration renders
68
- * the server fallback first and never mismatches.
69
- *
70
- * @example
71
- * ```ts
72
- * const { copy, copied } = useClipboard();
73
- * await copy("npm i @vizejs/composable");
74
- * ```
75
- *
76
- * @param options Capabilities, fallback policy, and feedback timing.
77
- * @default options {}
78
- * @returns Reactive clipboard state and actions.
79
- */
80
53
  function useClipboard(options = {}) {
81
54
  const copiedDuringMs = options.copiedDuringMs ?? 1500;
82
55
  if (!Number.isFinite(copiedDuringMs) || copiedDuringMs < 0) throw new RangeError(`[VIZE_COMPOSE_CLIPBOARD_INVALID_DURATION] copiedDuringMs must be a non-negative finite number; received ${String(copiedDuringMs)}`);
@@ -42,93 +42,15 @@ async function transform(data, format, Stream, name) {
42
42
  }
43
43
  return output;
44
44
  }
45
- /**
46
- * Compress data with the Compression Streams API.
47
- *
48
- * Strings are UTF-8 encoded first. Rejects with a tagged `TypeError` for an
49
- * unknown format or when no `CompressionStream` is available (always on the
50
- * server unless one is injected).
51
- *
52
- * @example
53
- * ```ts
54
- * const gzipped = await compress(JSON.stringify(state), "gzip");
55
- * ```
56
- *
57
- * @param data Input data.
58
- * @param format Compression format.
59
- * @param options Constructor override.
60
- * @default format "gzip"
61
- * @default options {}
62
- * @returns Compressed bytes.
63
- */
64
45
  function compress(data, format = "gzip", options = {}) {
65
46
  return transform(data, format, options.CompressionStream === void 0 ? browserConstructor("CompressionStream") : options.CompressionStream, "CompressionStream");
66
47
  }
67
- /**
68
- * Decompress data with the Compression Streams API.
69
- *
70
- * Rejects with a tagged `TypeError` for an unknown format or when no
71
- * `DecompressionStream` is available, and with the stream's error for
72
- * corrupt input.
73
- *
74
- * @example
75
- * ```ts
76
- * const bytes = await decompress(await response.blob(), "gzip");
77
- * ```
78
- *
79
- * @param data Compressed data.
80
- * @param format Compression format.
81
- * @param options Constructor override.
82
- * @default format "gzip"
83
- * @default options {}
84
- * @returns Decompressed bytes.
85
- */
86
48
  function decompress(data, format = "gzip", options = {}) {
87
49
  return transform(data, format, options.DecompressionStream === void 0 ? browserConstructor("DecompressionStream") : options.DecompressionStream, "DecompressionStream");
88
50
  }
89
- /**
90
- * Decompress data and decode the result as UTF-8 text.
91
- *
92
- * Rejects exactly like {@link decompress}.
93
- *
94
- * @example
95
- * ```ts
96
- * const json = JSON.parse(await decompressText(bytes, "deflate"));
97
- * ```
98
- *
99
- * @param data Compressed data.
100
- * @param format Compression format.
101
- * @param options Constructor override.
102
- * @default format "gzip"
103
- * @default options {}
104
- * @returns Decompressed text.
105
- */
106
51
  async function decompressText(data, format = "gzip", options = {}) {
107
52
  return new TextDecoder().decode(await decompress(data, format, options));
108
53
  }
109
- /**
110
- * Reactive wrapper around {@link compress}, {@link decompress} and
111
- * {@link decompressText}.
112
- *
113
- * Tracks whether an action is in flight and records the last failure in
114
- * `error`; actions still reject so callers can handle failures inline.
115
- * Nothing needs cleanup.
116
- *
117
- * Server rendering: `supported` is false and actions reject with the tagged
118
- * unsupported error unless constructors are injected.
119
- * Inside a component `supported` turns true only after mounting, so
120
- * hydration renders this server state first.
121
- *
122
- * @example
123
- * ```ts
124
- * const { compress, decompressText, pending } = useCompressionStream({ format: "deflate" });
125
- * const packed = await compress(draft.value);
126
- * ```
127
- *
128
- * @param options Constructor overrides and default format.
129
- * @default options {}
130
- * @returns Compression state and bound actions.
131
- */
132
54
  function useCompressionStream(options = {}) {
133
55
  const defaultFormat = options.format ?? "gzip";
134
56
  const inFlight = ref(0);
@@ -30,28 +30,6 @@ function pickContact(contact, properties) {
30
30
  for (const property of properties) picked[property] = full[property];
31
31
  return picked;
32
32
  }
33
- /**
34
- * Let the user share contacts with the Contact Picker API.
35
- *
36
- * `select(["name", "email"])` resolves to contacts typed with exactly those
37
- * keys (missing values become empty arrays). Dismissing the picker resolves
38
- * with an empty list. The composable holds no resources, so nothing needs
39
- * cleanup.
40
- *
41
- * Server rendering: nothing is requested, `supported` and `pending` are false.
42
- * Inside a component `supported` turns true only after mounting, so
43
- * hydration renders this server state first.
44
- *
45
- * @example
46
- * ```ts
47
- * const picker = useContactPicker();
48
- * const result = await picker.select(["name", "tel"], { multiple: true });
49
- * ```
50
- *
51
- * @param options Capability host.
52
- * @default options {}
53
- * @returns Picker state and actions.
54
- */
55
33
  function useContactPicker(options = {}) {
56
34
  const pending = ref(false);
57
35
  const error = shallowRef(void 0);
@@ -12,15 +12,6 @@ function decode(value) {
12
12
  return value;
13
13
  }
14
14
  }
15
- /**
16
- * Parse a `Cookie` request header (or `document.cookie`) into name/value
17
- * pairs. Values are percent-decoded; the first occurrence of a name wins,
18
- * matching how browsers order more specific cookies first. Pure and
19
- * SSR-safe.
20
- *
21
- * @param header Raw header value.
22
- * @returns Cookie values by name.
23
- */
24
15
  function parseCookieHeader(header) {
25
16
  const cookies = /* @__PURE__ */ new Map();
26
17
  for (const part of header.split(";")) {
@@ -34,21 +25,6 @@ function parseCookieHeader(header) {
34
25
  }
35
26
  return Object.fromEntries(cookies);
36
27
  }
37
- /**
38
- * Serialize one cookie as a `Set-Cookie` header value (also accepted by
39
- * `document.cookie`). The value is percent-encoded so any string is safe.
40
- *
41
- * @param name Cookie name; must be an RFC 6265 token.
42
- * @param value Unencoded cookie value.
43
- * @param attributes Cookie attributes.
44
- * @default attributes {}
45
- * @throws {TypeError} `[VIZE_COMPOSE_COOKIE_INVALID_NAME]`,
46
- * `[VIZE_COMPOSE_COOKIE_INVALID_DOMAIN]`, `[VIZE_COMPOSE_COOKIE_INVALID_PATH]`,
47
- * or `[VIZE_COMPOSE_COOKIE_REQUIRES_SECURE]` for malformed attributes.
48
- * @throws {RangeError} `[VIZE_COMPOSE_COOKIE_INVALID_MAX_AGE]` or
49
- * `[VIZE_COMPOSE_COOKIE_INVALID_EXPIRES]` for invalid lifetimes.
50
- * @returns The serialized cookie.
51
- */
52
28
  function serializeCookie(name, value, attributes = {}) {
53
29
  if (!TOKEN.test(name)) throw new TypeError(`[VIZE_COMPOSE_COOKIE_INVALID_NAME] cookie names must be RFC 6265 tokens; received ${JSON.stringify(name)}`);
54
30
  let cookie = `${name}=${encodeURIComponent(value)}`;
@@ -79,15 +55,7 @@ function serializeCookie(name, value, attributes = {}) {
79
55
  if (attributes.partitioned === true) cookie += "; Partitioned";
80
56
  return cookie;
81
57
  }
82
- /** Injection key for an app- or subtree-wide {@link CookieAdapter}. */
83
58
  const COOKIE_ADAPTER_KEY = Symbol("vize:cookie-adapter");
84
- /**
85
- * Provide a {@link CookieAdapter} to descendant components (for example the
86
- * request/response pair of a server render). Must be called during setup;
87
- * use `app.provide(COOKIE_ADAPTER_KEY, adapter)` for a whole app.
88
- *
89
- * @param adapter Adapter used by descendants' {@link useCookie} calls.
90
- */
91
59
  function provideCookieAdapter(adapter) {
92
60
  provide(COOKIE_ADAPTER_KEY, adapter);
93
61
  }
@@ -115,37 +83,6 @@ const jsonCodec = {
115
83
  read: (raw) => JSON.parse(raw),
116
84
  write: (value) => JSON.stringify(value)
117
85
  };
118
- /**
119
- * Synchronize a typed reactive value with one cookie, on the server and in
120
- * the browser.
121
- *
122
- * The adapter is resolved from `options.adapter`, then from
123
- * {@link COOKIE_ADAPTER_KEY} (see {@link provideCookieAdapter}), then from
124
- * `document.cookie` in browsers. During a server render with an adapter the
125
- * value comes from the request `Cookie` header and assignments emit
126
- * `Set-Cookie` headers through `adapter.write`, so server and client render
127
- * the same value and hydrate without a mismatch. Without any adapter (plain
128
- * SSR) the default is used and nothing is written.
129
- *
130
- * String defaults are stored raw; other defaults as JSON checked by
131
- * `validate` (by default: same kind as the default). Assigning `undefined`
132
- * (or calling `remove`) expires the cookie. Cookies are written with
133
- * `Path=/` unless `path` is given. Failures never throw; they are exposed
134
- * through `error` and `onError`. The write watcher stops with the owning
135
- * reactive scope.
136
- *
137
- * @example
138
- * ```ts
139
- * // server entry: app.provide(COOKIE_ADAPTER_KEY, { read: () => req.headers.cookie ?? "",
140
- * // write: (value) => res.appendHeader("Set-Cookie", value) });
141
- * const { state: locale } = useCookie("locale", { default: "en", maxAge: 31_536_000 });
142
- * ```
143
- *
144
- * @param name Cookie name (an RFC 6265 token).
145
- * @param options Default, serializer, validation, attributes, and adapter.
146
- * @default options {}
147
- * @returns The synchronized value and its controls.
148
- */
149
86
  function useCookie(name, options = {}) {
150
87
  const injected = hasInjectionContext() ? inject(COOKIE_ADAPTER_KEY, void 0) : void 0;
151
88
  const adapter = options.adapter === void 0 ? injected ?? browserAdapter() : options.adapter ?? void 0;
@@ -5,28 +5,6 @@ function resolveCount(value) {
5
5
  if (!Number.isFinite(value) || value < 0) throw new RangeError(`[VIZE_COMPOSE_COUNTDOWN_INVALID_COUNT] count must be finite and at least zero; received ${String(value)}`);
6
6
  return Math.trunc(value);
7
7
  }
8
- /**
9
- * Count down from a number of ticks to zero.
10
- *
11
- * Builds on {@link useIntervalFn}: pause/resume keep the remaining count,
12
- * `start` and `reset` restore it, and the timer pauses itself at zero after
13
- * calling `onComplete`. The initial count is reactive only for later
14
- * `start()`/`reset()` calls without an argument. Server rendering is
15
- * hydration-stable (no timer, remaining stays at the initial count).
16
- *
17
- * @example
18
- * ```ts
19
- * const { remaining, start } = useCountdown(60, { onComplete: resendAvailable });
20
- * start();
21
- * ```
22
- *
23
- * @param initialCount Reactive starting count in ticks.
24
- * @param options Cadence, callbacks, and scheduler policy.
25
- * @default options {}
26
- * @throws `RangeError` tagged `VIZE_COMPOSE_COUNTDOWN_INVALID_COUNT` when a
27
- * count is negative or not finite.
28
- * @returns Remaining count, completion flag, and controls.
29
- */
30
8
  function useCountdown(initialCount, options = {}) {
31
9
  const remaining = shallowRef(resolveCount(toValue(initialCount)));
32
10
  const isComplete = computed(() => remaining.value === 0);
@@ -1,34 +1,5 @@
1
1
  import { computed, shallowRef } from "vue";
2
2
  //#region src/use-counter.ts
3
- /**
4
- * Create a clamped counter whose every transition stays inside `[min, max]`.
5
- *
6
- * All operations clamp instead of failing, including the initial value, so
7
- * the count is inside the bounds at every observable moment. Only `NaN` is
8
- * rejected — silently corrupting the count is never an option. Purely
9
- * synchronous state: safe during server rendering (no browser globals, no
10
- * timers) and nothing to dispose, so it works inside and outside reactive
11
- * scopes alike. Bounds are fixed at creation and not reactive.
12
- *
13
- * @example
14
- * ```ts
15
- * const { count, increment, atMax } = useCounter(9, { min: 0, max: 10 });
16
- * increment(); // 10
17
- * increment(); // 10 (clamped)
18
- * atMax.value; // true
19
- * ```
20
- *
21
- * @param initial Count before any operation, clamped into the bounds.
22
- * @default initial 0
23
- * @param options Inclusive bounds for every value the counter takes.
24
- * @default options {}
25
- * @throws `RangeError` tagged `VIZE_COMPOSE_COUNTER_INVALID_RANGE` when a
26
- * bound is `NaN` or `min` exceeds `max`.
27
- * @throws `RangeError` tagged `VIZE_COMPOSE_COUNTER_INVALID_VALUE` when an
28
- * initial value, operand, or arithmetic result is `NaN` (for example
29
- * incrementing `-Infinity` by `Infinity`); the count is left unchanged.
30
- * @returns Reactive count, bound flags, and mutation controls.
31
- */
32
3
  function useCounter(initial = 0, options = {}) {
33
4
  const min = requireBound(options.min ?? Number.NEGATIVE_INFINITY, "min");
34
5
  const max = requireBound(options.max ?? Number.POSITIVE_INFINITY, "max");
@@ -20,34 +20,6 @@ function browserCssVarHost() {
20
20
  function assertVariableName(name) {
21
21
  if (!name.startsWith("--")) throw new TypeError(`[VIZE_COMPOSE_CSS_VAR_INVALID_NAME] custom property names must start with "--"; received ${JSON.stringify(name)}`);
22
22
  }
23
- /**
24
- * Read and write a CSS custom property reactively.
25
- *
26
- * The value is read from the target's computed style whenever the
27
- * reactive name, target, or host changes (and, with `observe`, when its
28
- * `style`/`class` attribute changes). Assigning `value` writes an inline
29
- * `style.setProperty`; assigning `""` removes the inline declaration. Values
30
- * read from the element are never written back, so a stylesheet-provided
31
- * variable is not frozen into inline style.
32
- *
33
- * Server rendering: nothing is read or written; `value` holds
34
- * `initialValue`. Keep server markup and the first client render identical
35
- * by rendering from `initialValue` until mounted. The observer and
36
- * watchers are released with the owning reactive scope.
37
- *
38
- * @example
39
- * ```ts
40
- * const accent = useCssVar("--accent", rootRef, { initialValue: "#0af" });
41
- * accent.value.value = "#f60";
42
- * ```
43
- *
44
- * @param name Reactive custom property name, starting with `--`.
45
- * @param target Reactive element; defaults to the document root element.
46
- * @param options Initial value, observation, and capability.
47
- * @default options {}
48
- * @returns The writable variable value.
49
- * @throws {TypeError} `[VIZE_COMPOSE_CSS_VAR_INVALID_NAME]` when the name does not start with `--`.
50
- */
51
23
  function useCssVar(name, target, options = {}) {
52
24
  const initialValue = options.initialValue ?? "";
53
25
  assertVariableName(toValue(name));
@@ -21,30 +21,6 @@ function pad(value, length) {
21
21
  function partsOf(formatter, date) {
22
22
  return new Map(formatter.formatToParts(date).map((part) => [part.type, part.value]));
23
23
  }
24
- /**
25
- * Format a date with a token pattern or `Intl.DateTimeFormat` options.
26
- *
27
- * Pure and deterministic: locale and time zone default to fixed values
28
- * (`"en"`, `"UTC"`) rather than host settings, so the same input renders
29
- * identically on server and client. Calendar fields are computed in the
30
- * requested time zone through `Intl`, so no host-zone arithmetic leaks in.
31
- *
32
- * @example
33
- * ```ts
34
- * formatDate(0, "YYYY-MM-DD HH:mm:ss"); // "1970-01-01 00:00:00"
35
- * formatDate(0, "dddd, MMMM D [at] h:mm A", { locale: "en", timeZone: "Asia/Tokyo" });
36
- * formatDate(0, { dateStyle: "long" }, { locale: "ja" }); // "1970年1月1日"
37
- * ```
38
- *
39
- * @param input Date to format.
40
- * @param format Token pattern (see {@link DateFormatToken}) or `Intl` options.
41
- * @param options Locale and time zone.
42
- * @default format "HH:mm:ss"
43
- * @default options {}
44
- * @throws `RangeError` tagged `VIZE_COMPOSE_DATE_FORMAT_INVALID_DATE` for
45
- * invalid dates, and `RangeError` from `Intl` for invalid locales or zones.
46
- * @returns The formatted string.
47
- */
48
24
  function formatDate(input, format = "HH:mm:ss", options = {}) {
49
25
  const date = toDate(input);
50
26
  const locales = typeof options.locale === "string" ? options.locale : [...options.locale ?? ["en"]];
@@ -113,30 +89,6 @@ function formatDate(input, format = "HH:mm:ss", options = {}) {
113
89
  };
114
90
  return format.replaceAll(tokenPattern, (match, literal) => literal ?? render(match));
115
91
  }
116
- /**
117
- * Reactive formatted date.
118
- *
119
- * Wraps {@link formatDate} in a computed ref; the date, the format, the
120
- * locale, and the time zone are all reactive. Deterministic defaults (`"en"`,
121
- * `"UTC"`) keep server and client output identical. No timers, no globals,
122
- * nothing to dispose.
123
- *
124
- * @example
125
- * ```ts
126
- * const label = useDateFormat(() => event.value.startsAt, "ddd, MMM D HH:mm", {
127
- * locale: () => locale.value,
128
- * timeZone: "Europe/Paris",
129
- * });
130
- * ```
131
- *
132
- * @param input Reactive date.
133
- * @param format Reactive token pattern or `Intl` options.
134
- * @param options Reactive locale and time zone.
135
- * @default format "HH:mm:ss"
136
- * @default options {}
137
- * @throws `RangeError` on read for invalid dates, locales, or zones.
138
- * @returns Computed formatted string.
139
- */
140
92
  function useDateFormat(input, format = "HH:mm:ss", options = {}) {
141
93
  return computed(() => formatDate(toValue(input), toValue(format), {
142
94
  locale: toValue(options.locale) ?? "en",
@@ -7,28 +7,6 @@ function browserLanguage() {
7
7
  function isValidDate(value) {
8
8
  return !Number.isNaN(value instanceof Date ? value.getTime() : value);
9
9
  }
10
- /**
11
- * Format dates and times reactively with `Intl.DateTimeFormat`.
12
- *
13
- * The formatter follows the reactive options (including `locale`) and is
14
- * cached per locale and option set through {@link useLocale}. For
15
- * hydration-stable output pass both `locale` and `timeZone`: otherwise the
16
- * server uses `"en"` and its own zone. Invalid options surface as the
17
- * platform's `RangeError` on first read; invalid dates render as `""`.
18
- * No listeners or timers are created — combine with a clock composable for
19
- * live-updating output.
20
- *
21
- * @example
22
- * ```ts
23
- * const { formatted } = useDateTimeFormat(date, { locale: "en-GB", dateStyle: "long", timeZone: "UTC" });
24
- * ```
25
- *
26
- * @param value Reactive date; `null`/`undefined` format as `""`.
27
- * @param options Reactive locale and `Intl.DateTimeFormat` options.
28
- * @default value undefined
29
- * @default options {}
30
- * @returns Reactive formatted output and formatter helpers.
31
- */
32
10
  function useDateTimeFormat(value, options = {}) {
33
11
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
34
12
  const formatter = computed(() => {
@@ -7,45 +7,6 @@ const defaultScheduler = {
7
7
  globalThis.clearTimeout(handle);
8
8
  }
9
9
  };
10
- /**
11
- * Create a readonly debounced view of a reactive source.
12
- *
13
- * The view starts at the current source value. Each source change (observed
14
- * with `flush: "sync"`, so every synchronous write counts) restarts a
15
- * single-shot timer of `waitMs` milliseconds; when it fires, the view takes
16
- * the source value current at that moment. `waitMs` is reactive and is read
17
- * when a timer is scheduled; changing it does not restart an already-pending
18
- * timer. A wait of `0` still defers to the next scheduler tick.
19
- *
20
- * Server rendering is explicit: without a browser `window` (and with
21
- * {@link UseDebouncedOptions.runOnServer} disabled) no timer ever starts and
22
- * the view mirrors the source synchronously, so server-rendered output shows
23
- * current values and nothing leaks. `pending` stays `false` and the controls
24
- * report `false` in that mode.
25
- *
26
- * Cleanup rule: the watcher and any pending timer are released when the
27
- * owning reactive scope stops; call inside an active scope. Outside one, the
28
- * watcher lives as long as the source and `cancel()` only clears the pending
29
- * timer.
30
- *
31
- * @example
32
- * ```ts
33
- * const query = shallowRef("");
34
- * const { debounced, flush } = useDebounced(query, 300);
35
- * query.value = "vize"; // debounced.value still "" for 300ms
36
- * flush(); // debounced.value === "vize" immediately
37
- * ```
38
- *
39
- * @param source Reactive source to debounce.
40
- * @param waitMs Reactive delay in milliseconds; must be finite and at least
41
- * zero. Fractions are truncated.
42
- * @param options Runtime scheduling overrides.
43
- * @default options {}
44
- * @throws `RangeError` tagged `VIZE_COMPOSE_DEBOUNCE_INVALID_WAIT` when the
45
- * resolved wait is not finite or is negative, both synchronously at creation
46
- * (even in mirror mode) and again for every scheduled delay.
47
- * @returns Readonly debounced view, pending flag, and cancel/flush controls.
48
- */
49
10
  function useDebounced(source, waitMs, options = {}) {
50
11
  const scheduler = options.scheduler ?? defaultScheduler;
51
12
  const debounced = shallowRef(toValue(source));
@@ -6,28 +6,6 @@ function browserDisplayMediaHost() {
6
6
  const devices = window.navigator.mediaDevices;
7
7
  return devices && typeof devices.getDisplayMedia === "function" ? devices : void 0;
8
8
  }
9
- /**
10
- * Capture a screen, window, or tab with `getDisplayMedia`.
11
- *
12
- * Shares the stream lifecycle of `useMediaStream` (from `use-user-media`):
13
- * classified failures (`"permission-denied"` when the user dismisses the
14
- * picker), latest-wins requests, and automatic return to `"idle"` when the
15
- * user ends sharing from the browser UI (every track `ended`). Tracks are
16
- * stopped when the owning reactive scope stops.
17
- *
18
- * Server rendering: nothing is captured; `status` is `"idle"` and
19
- * `supported` is false.
20
- *
21
- * @example
22
- * ```ts
23
- * const screen = useDisplayMedia({ audio: true });
24
- * const share = () => screen.start();
25
- * ```
26
- *
27
- * @param options Capture constraints, activation, and capability.
28
- * @default options {}
29
- * @returns Stream state and actions.
30
- */
31
9
  function useDisplayMedia(options = {}) {
32
10
  const resolveHost = () => options.host === void 0 ? browserDisplayMediaHost() : toValue(options.host) ?? void 0;
33
11
  return useMediaStream({
@@ -4,25 +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
- * Localized names of languages, regions, scripts, currencies, calendars, and
9
- * date-time fields (`Intl.DisplayNames`): `"JP"` → "Japan", `"ja"` → "日本語"
10
- * in Japanese, `"EUR"` → "Euro".
11
- *
12
- * Malformed codes yield `undefined` rather than the platform `RangeError`,
13
- * so user-entered codes never crash rendering; invalid *options* still
14
- * throw on first read. Derived state only: no listeners or timers, and
15
- * deterministic during server rendering when the locale is explicit.
16
- *
17
- * @example
18
- * ```ts
19
- * const { name } = useDisplayNames(regionCode, { type: "region", locale: "en" });
20
- * ```
21
- *
22
- * @param code Reactive code to name.
23
- * @param options Reactive kind, locale, and display options.
24
- * @returns Reactive name and a naming helper.
25
- */
26
7
  function useDisplayNames(code, options) {
27
8
  const localeControls = useLocale(() => toValue(options).locale, { detect: browserLanguage });
28
9
  const displayNames = computed(() => {
@@ -27,31 +27,6 @@ function browserTitleHost() {
27
27
  function formatTitle(template, title) {
28
28
  return typeof template === "function" ? template(title) : template.replaceAll("%s", title);
29
29
  }
30
- /**
31
- * Bind the document title to reactive state.
32
- *
33
- * Accepts a writable ref (used as-is), a getter (followed), a plain
34
- * string, or nothing (an owned ref seeded from the current title). Every
35
- * non-nullish title is passed through `template` before it is written.
36
- * With `observe`, external title changes flow back into `title`.
37
- *
38
- * Server rendering: the document is never touched and `title` keeps the
39
- * value it was given (or `undefined`). Head management for server-rendered
40
- * markup (`<title>` in the HTML) is the job of the application's head
41
- * manager; this composable only updates the live document on the client.
42
- * Watchers and the observer are released with the owning reactive scope,
43
- * which also applies `restoreOnDispose`.
44
- *
45
- * @example
46
- * ```ts
47
- * const { title } = useDocumentTitle(() => route.meta.title, { template: "%s | Vize" });
48
- * ```
49
- *
50
- * @param title Reactive title source.
51
- * @param options Template, restore policy, observation, and capability.
52
- * @default options {}
53
- * @returns The title ref and support flag.
54
- */
55
30
  function useDocumentTitle(title, options = {}) {
56
31
  const template = options.template ?? "%s";
57
32
  const resolveHost = () => options.host === void 0 ? browserTitleHost() : toValue(options.host) ?? void 0;
@@ -9,18 +9,6 @@ function matchesPattern(pattern, file) {
9
9
  if (normalized.endsWith("/*")) return type.startsWith(normalized.slice(0, -1));
10
10
  return type === normalized;
11
11
  }
12
- /**
13
- * Test a file against `accept`-attribute style patterns.
14
- *
15
- * Supports exact MIME types, wildcard subtypes (`"image/*"`), extensions
16
- * (`".png"`, case-insensitive), and `"*"`. An empty pattern list accepts
17
- * everything. An empty `name` (the file is still being dragged) makes
18
- * extension patterns match provisionally.
19
- *
20
- * @param accept Patterns to test.
21
- * @param file File name and MIME type.
22
- * @returns Whether any pattern matches.
23
- */
24
12
  function matchesAccept(accept, file) {
25
13
  return accept.length === 0 || accept.some((pattern) => matchesPattern(pattern, file));
26
14
  }
@@ -43,30 +31,6 @@ function draggedTypes(transfer) {
43
31
  }
44
32
  return types;
45
33
  }
46
- /**
47
- * Headless drop-zone logic for any element.
48
- *
49
- * Tracks whether a drag is over the target (a nesting counter keeps
50
- * `dragleave` from child elements from flickering the state), decides
51
- * acceptance from the dragged MIME types while dragging, and filters the
52
- * dropped files by `accept` (including extension patterns) and `multiple`.
53
- * Rejected drags show the `"none"` drop effect. Rendering is entirely up to
54
- * the caller. Listeners follow the reactive target and are removed when the
55
- * owning reactive scope stops.
56
- *
57
- * Server rendering: no listener is attached; all state is empty/false.
58
- *
59
- * @example
60
- * ```ts
61
- * const zone = useTemplateRef<HTMLElement>("zone");
62
- * const { isOverDropZone, files } = useDropZone(zone, { accept: ["image/*"] });
63
- * ```
64
- *
65
- * @param target Reactive drop target.
66
- * @param options Acceptance rules and lifecycle callbacks.
67
- * @default options {}
68
- * @returns Drag and drop state.
69
- */
70
34
  function useDropZone(target, options = {}) {
71
35
  const isOverDropZone = ref(false);
72
36
  const accepted = ref(false);
@@ -20,31 +20,6 @@ function defaultScheduler() {
20
20
  function eventData(value) {
21
21
  return value;
22
22
  }
23
- /**
24
- * Reactive Server-Sent Events stream with typed, per-event decoding.
25
- *
26
- * Every subscribed event is decoded by its parser (raw text by default) and
27
- * exposed as a discriminated `message`, plus `data`/`event`/`lastEventId`
28
- * shortcuts and typed `on()` handlers. Transient drops use the browser's
29
- * native reconnection; `autoReconnect` additionally reopens streams the
30
- * browser closed for good. The stream and timers are released when the
31
- * owning reactive scope stops (the caller owns `close()` outside a scope).
32
- * Server rendering never connects and reports `"closed"`.
33
- *
34
- * @example
35
- * ```ts
36
- * const feed = useEventSource<{ price: number; notice: string }>("/stream", {
37
- * events: ["price", "notice"],
38
- * parse: { price: (raw) => Number(raw) },
39
- * });
40
- * feed.on("price", (price) => chart.push(price));
41
- * ```
42
- *
43
- * @param url Reactive URL; changing it reconnects.
44
- * @param options Events, decoders, host, and reconnection options.
45
- * @default options {}
46
- * @returns Reactive state and controls.
47
- */
48
23
  function useEventSource(url, ...[options]) {
49
24
  const settings = options ?? {};
50
25
  const status = shallowRef("closed");