@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
@@ -3,18 +3,6 @@ import { computed, toValue } from "vue";
3
3
  function useArrayFilter(list, predicate) {
4
4
  return computed(() => toValue(list).filter(predicate));
5
5
  }
6
- /**
7
- * Reactive `Array.prototype.map`.
8
- *
9
- * @example
10
- * ```ts
11
- * const names = useArrayMap(users, (user) => user.name);
12
- * ```
13
- *
14
- * @param list Reactive array.
15
- * @param mapper Produces the mapped item.
16
- * @returns Computed mapped copy.
17
- */
18
6
  function useArrayMap(list, mapper) {
19
7
  return computed(() => toValue(list).map(mapper));
20
8
  }
@@ -31,52 +19,12 @@ function useArrayReduce(list, reducer, ...initial) {
31
19
  return accumulator;
32
20
  });
33
21
  }
34
- /**
35
- * Reactive `Array.prototype.some`.
36
- *
37
- * @example
38
- * ```ts
39
- * const hasErrors = useArraySome(fields, (field) => field.error !== null);
40
- * ```
41
- *
42
- * @param list Reactive array.
43
- * @param predicate Condition tested per item.
44
- * @returns Computed flag.
45
- */
46
22
  function useArraySome(list, predicate) {
47
23
  return computed(() => toValue(list).some(predicate));
48
24
  }
49
- /**
50
- * Reactive `Array.prototype.every`.
51
- *
52
- * @example
53
- * ```ts
54
- * const allDone = useArrayEvery(tasks, (task) => task.done);
55
- * ```
56
- *
57
- * @param list Reactive array.
58
- * @param predicate Condition tested per item.
59
- * @returns Computed flag.
60
- */
61
25
  function useArrayEvery(list, predicate) {
62
26
  return computed(() => toValue(list).every(predicate));
63
27
  }
64
- /**
65
- * Reactive de-duplication that keeps the first occurrence of each item.
66
- *
67
- * Without `isSame`, items are compared with `SameValueZero` (like `Set`) in
68
- * linear time; with it, pairwise in quadratic time.
69
- *
70
- * @example
71
- * ```ts
72
- * const tags = useArrayUnique(allTags);
73
- * const people = useArrayUnique(rows, (left, right) => left.id === right.id);
74
- * ```
75
- *
76
- * @param list Reactive array.
77
- * @param isSame Custom equality.
78
- * @returns Computed de-duplicated copy.
79
- */
80
28
  function useArrayUnique(list, isSame) {
81
29
  return computed(() => {
82
30
  const items = toValue(list);
@@ -48,31 +48,6 @@ function normalize(barcode) {
48
48
  }))
49
49
  };
50
50
  }
51
- /**
52
- * Detect barcodes and QR codes with the Barcode Detection API.
53
- *
54
- * `detect(source)` scans once; with a `source` (typically a camera video),
55
- * detection also runs on animation frames through {@link useRafFn}, throttled
56
- * by `fpsLimit` and never overlapping. Results are normalized into plain
57
- * {@link DetectedBarcode} objects. The frame loop stops with the owning
58
- * reactive scope; outside a scope call `stop()`.
59
- *
60
- * Server rendering: nothing is constructed or scheduled, `supported` is
61
- * false and `barcodes` is empty.
62
- * Inside a component `supported` turns true only after mounting, so
63
- * hydration renders this server state first.
64
- *
65
- * @example
66
- * ```ts
67
- * const video = useTemplateRef<HTMLVideoElement>("video");
68
- * const { barcodes } = useBarcodeDetector({ source: video, formats: ["qr_code"] });
69
- * ```
70
- *
71
- * @param options Constructor host, formats, and continuous-scan policy.
72
- * @default options {}
73
- * @throws `RangeError` tagged `VIZE_COMPOSE_RAF_INVALID_FPS_LIMIT` for an invalid `fpsLimit`.
74
- * @returns Detector state and actions.
75
- */
76
51
  function useBarcodeDetector(options = {}) {
77
52
  const barcodes = shallowRef([]);
78
53
  const error = shallowRef(void 0);
@@ -13,33 +13,6 @@ function isBluetoothHost(value) {
13
13
  function availabilityOf(event) {
14
14
  return "value" in event && typeof event.value === "boolean" ? event.value : void 0;
15
15
  }
16
- /**
17
- * Connect to Bluetooth Low Energy devices with the Web Bluetooth API.
18
- *
19
- * `requestDevice()` prompts for a device, `connect()` connects its GATT
20
- * server, and `read` / `write` / `notify` address characteristics by service
21
- * and characteristic UUID. `connected` follows `gattserverdisconnected` and
22
- * `available` follows `availabilitychanged`. Failures land in `error`.
23
- * Notifications are stopped and the server disconnected when the owning
24
- * reactive scope stops; outside a scope call `disconnect()`.
25
- *
26
- * Server rendering: `supported`, `available` and `connected` are false and
27
- * nothing is queried.
28
- * Inside a component the host is resolved after mounting, so hydration
29
- * renders this server state first.
30
- *
31
- * @example
32
- * ```ts
33
- * const ble = useBluetooth({ requestOptions: { filters: [{ services: ["heart_rate"] }] } });
34
- * await ble.requestDevice();
35
- * await ble.connect();
36
- * await ble.notify("heart_rate", "heart_rate_measurement", (value) => show(value.getUint8(1)));
37
- * ```
38
- *
39
- * @param options Host and default request options.
40
- * @default options {}
41
- * @returns Bluetooth state and actions.
42
- */
43
16
  function useBluetooth(options = {}) {
44
17
  const available = ref(false);
45
18
  const device = shallowRef(void 0);
@@ -4,36 +4,6 @@ import { hasInjectionContext, readonly, ref, shallowRef, toValue, watch, watchPo
4
4
  function browserBroadcastChannelHost() {
5
5
  return typeof window !== "undefined" && typeof window.BroadcastChannel === "function" ? window : void 0;
6
6
  }
7
- /**
8
- * Exchange typed messages with other tabs, windows, and workers of the same
9
- * origin through the Broadcast Channel API.
10
- *
11
- * The channel follows the reactive `name`: changing it closes the old channel
12
- * and opens a new one. The channel closes when the owning reactive scope
13
- * stops or when `close()` is called; outside a scope the caller owns
14
- * `close()`. Incoming payloads pass the `validate` type guard before they
15
- * reach `data`, so foreign messages cannot widen the declared type.
16
- *
17
- * Server rendering: without a browser `window` no channel is opened (Node's
18
- * global `BroadcastChannel` is ignored), `supported` is `false`, and `post`
19
- * returns `false`.
20
- *
21
- * Inside a component the host is read after mounting, so hydration renders
22
- * the server fallback first and never mismatches.
23
- *
24
- * @example
25
- * ```ts
26
- * type Sync = { readonly type: "logout" };
27
- * const { data, post } = useBroadcastChannel<Sync>("auth");
28
- * post({ type: "logout" });
29
- * ```
30
- *
31
- * @typeParam Message Payload type exchanged over the channel.
32
- * @param name Reactive channel name.
33
- * @param options Host, validation, and observation hooks.
34
- * @default options {}
35
- * @returns Reactive channel state and controls.
36
- */
37
7
  function useBroadcastChannel(name, options = {}) {
38
8
  const data = shallowRef(void 0);
39
9
  const error = shallowRef(void 0);
@@ -149,30 +149,6 @@ function useAiSession(name, host, createOptions) {
149
149
  stream
150
150
  };
151
151
  }
152
- /**
153
- * Translate text on-device with Chrome's built-in `Translator` API.
154
- *
155
- * The session is created lazily by the first `translate` (or explicitly by
156
- * `create()`, which browsers require inside a user gesture when the model
157
- * must be downloaded); `downloadProgress` follows the download. Changing a
158
- * language destroys the session. The session is destroyed and a pending
159
- * creation aborted when the owning reactive scope stops; outside a scope
160
- * call `destroy()`.
161
- *
162
- * Server rendering: nothing is created, `supported` is false and `status`
163
- * is `"unsupported"`.
164
- * Inside a component `supported` turns true only after mounting, so
165
- * hydration renders this server state first.
166
- *
167
- * @example
168
- * ```ts
169
- * const translator = useTranslator({ sourceLanguage: "en", targetLanguage: "ja" });
170
- * const japanese = await translator.translate("Hello");
171
- * ```
172
- *
173
- * @param options Language pair and class override.
174
- * @returns Translator state and actions.
175
- */
176
152
  function useTranslator(options) {
177
153
  const session = useAiSession("Translator", options.host, () => ({
178
154
  sourceLanguage: toValue(options.sourceLanguage),
@@ -184,28 +160,6 @@ function useTranslator(options) {
184
160
  translateStreaming: (text) => session.stream((translator) => translator.translateStreaming(text))
185
161
  };
186
162
  }
187
- /**
188
- * Detect the language of text on-device with Chrome's built-in
189
- * `LanguageDetector` API.
190
- *
191
- * Shares the lifecycle of {@link useTranslator}: lazy creation, download
192
- * progress, destruction with the owning reactive scope.
193
- *
194
- * Server rendering: nothing is created, `supported` is false and `status`
195
- * is `"unsupported"`.
196
- * Inside a component `supported` turns true only after mounting, so
197
- * hydration renders this server state first.
198
- *
199
- * @example
200
- * ```ts
201
- * const detector = useLanguageDetector();
202
- * const [best] = await detector.detect(input.value);
203
- * ```
204
- *
205
- * @param options Expected languages and class override.
206
- * @default options {}
207
- * @returns Detector state and actions.
208
- */
209
163
  function useLanguageDetector(options = {}) {
210
164
  const session = useAiSession("LanguageDetector", options.host, () => {
211
165
  const expectedInputLanguages = toValue(options.expectedInputLanguages);
@@ -216,28 +170,6 @@ function useLanguageDetector(options = {}) {
216
170
  detect: (text) => session.run((detector) => detector.detect(text))
217
171
  };
218
172
  }
219
- /**
220
- * Summarize text on-device with Chrome's built-in `Summarizer` API.
221
- *
222
- * Shares the lifecycle of {@link useTranslator}: lazy creation, download
223
- * progress, destruction with the owning reactive scope; changing `type`,
224
- * `format`, `length` or `sharedContext` destroys the session.
225
- *
226
- * Server rendering: nothing is created, `supported` is false and `status`
227
- * is `"unsupported"`.
228
- * Inside a component `supported` turns true only after mounting, so
229
- * hydration renders this server state first.
230
- *
231
- * @example
232
- * ```ts
233
- * const summarizer = useSummarizer({ type: "tldr", length: "medium" });
234
- * for await (const chunk of summarizer.summarizeStreaming(article.value)) output.value += chunk;
235
- * ```
236
- *
237
- * @param options Summary shape and class override.
238
- * @default options {}
239
- * @returns Summarizer state and actions.
240
- */
241
173
  function useSummarizer(options = {}) {
242
174
  const session = useAiSession("Summarizer", options.host, () => {
243
175
  const base = {
@@ -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",