@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.
- package/dist/abort-signal.mjs +0 -62
- package/dist/active-element.mjs +0 -11
- package/dist/animate.mjs +0 -19
- package/dist/async-resource.mjs +0 -17
- package/dist/battery.mjs +0 -13
- package/dist/breakpoints.mjs +0 -24
- package/dist/capability.mjs +0 -12
- package/dist/{catalog-BRX-Wg8B.mjs → catalog-CcpCnLjb.mjs} +0 -14
- package/dist/catalog.mjs +1 -1
- package/dist/color-mode.mjs +0 -23
- package/dist/computed-with-control.mjs +0 -22
- package/dist/create-event-hook.mjs +0 -27
- package/dist/create-global-state.mjs +0 -23
- package/dist/create-shared-composable.mjs +0 -23
- package/dist/device-motion.mjs +0 -11
- package/dist/device-orientation.mjs +0 -23
- package/dist/device-pixel-ratio.mjs +0 -11
- package/dist/disposal-scope.mjs +0 -25
- package/dist/document-visibility.mjs +0 -14
- package/dist/draggable.mjs +0 -14
- package/dist/element-bounding.mjs +0 -14
- package/dist/element-by-point.mjs +0 -10
- package/dist/element-hover.mjs +0 -13
- package/dist/element-target.mjs +0 -30
- package/dist/focus.mjs +0 -23
- package/dist/fps.mjs +0 -12
- package/dist/geolocation.mjs +0 -14
- package/dist/i18n.mjs +0 -86
- package/dist/icu-message.mjs +0 -58
- package/dist/idle.mjs +0 -16
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/infinite-scroll.mjs +0 -16
- package/dist/intersection-observer.mjs +0 -27
- package/dist/locale.mjs +0 -20
- package/dist/magic-keys.mjs +0 -35
- package/dist/math.mjs +0 -37
- package/dist/media-query.mjs +0 -29
- package/dist/mouse-in-element.mjs +0 -12
- package/dist/mouse.mjs +0 -12
- package/dist/mutation-observer.mjs +0 -15
- package/dist/network.mjs +0 -24
- package/dist/on-click-outside.mjs +0 -16
- package/dist/on-key-stroke.mjs +0 -33
- package/dist/on-long-press.mjs +0 -14
- package/dist/on-start-typing.mjs +0 -23
- package/dist/page-leave.mjs +0 -11
- package/dist/parent-element.mjs +0 -9
- package/dist/pinch.mjs +0 -14
- package/dist/pointer-lock.mjs +0 -23
- package/dist/pointer.mjs +0 -18
- package/dist/preferences.mjs +0 -31
- package/dist/preferred-languages.mjs +0 -13
- package/dist/ref-auto-reset.mjs +0 -24
- package/dist/ref-debounced.mjs +0 -22
- package/dist/ref-default.mjs +0 -21
- package/dist/resize-observer.mjs +0 -31
- package/dist/resolver.mjs +1 -58
- package/dist/retry-async.mjs +0 -25
- package/dist/retry-delay.mjs +0 -23
- package/dist/scope.mjs +0 -14
- package/dist/screen-orientation.mjs +0 -15
- package/dist/scroll-lock.mjs +0 -14
- package/dist/scroll.mjs +0 -27
- package/dist/standard-schema.mjs +0 -31
- package/dist/swipe.mjs +0 -36
- package/dist/temporal.mjs +0 -30
- package/dist/text-selection.mjs +0 -15
- package/dist/textarea-autosize.mjs +0 -13
- package/dist/to-reactive.mjs +0 -20
- package/dist/transition.mjs +0 -7
- package/dist/until.mjs +0 -25
- package/dist/use-array.mjs +0 -52
- package/dist/use-barcode-detector.mjs +0 -25
- package/dist/use-bluetooth.mjs +0 -27
- package/dist/use-broadcast-channel.mjs +0 -30
- package/dist/use-builtin-ai.mjs +0 -68
- package/dist/use-clipboard.mjs +0 -27
- package/dist/use-compression-stream.mjs +0 -78
- package/dist/use-contact-picker.mjs +0 -22
- package/dist/use-cookie.mjs +0 -63
- package/dist/use-countdown.mjs +0 -22
- package/dist/use-counter.mjs +0 -29
- package/dist/use-css-var.mjs +0 -28
- package/dist/use-date-format.mjs +0 -48
- package/dist/use-date-time-format.mjs +0 -22
- package/dist/use-debounced.mjs +0 -39
- package/dist/use-display-media.mjs +0 -22
- package/dist/use-display-names.mjs +0 -19
- package/dist/use-document-title.mjs +0 -25
- package/dist/use-drop-zone.mjs +0 -36
- package/dist/use-event-source.mjs +0 -25
- package/dist/use-eye-dropper.mjs +0 -19
- package/dist/use-favicon.mjs +0 -23
- package/dist/use-fetch.mjs +0 -27
- package/dist/use-field.mjs +0 -27
- package/dist/use-file-dialog.mjs +0 -21
- package/dist/{use-form-C2JXZ0i7.mjs → use-form-BZqwMs6k.mjs} +143 -70
- package/dist/use-form-field-props.mjs +0 -57
- package/dist/use-form.d.mts +123 -18
- package/dist/use-form.mjs +1 -1
- package/dist/use-fullscreen.mjs +0 -23
- package/dist/use-gamepad.mjs +0 -50
- package/dist/use-hid.mjs +0 -25
- package/dist/use-history.mjs +0 -43
- package/dist/use-id-generator.mjs +0 -21
- package/dist/use-image.mjs +0 -22
- package/dist/use-indexed-db.mjs +0 -39
- package/dist/use-interval.mjs +0 -28
- package/dist/use-list-format.mjs +0 -18
- package/dist/use-machine.mjs +0 -34
- package/dist/use-map.mjs +0 -28
- package/dist/use-media-controls.mjs +0 -28
- package/dist/use-mounted.mjs +0 -18
- package/dist/use-navigation-api.mjs +0 -27
- package/dist/use-notification.mjs +0 -24
- package/dist/use-number-format.mjs +0 -23
- package/dist/use-object-url.mjs +0 -22
- package/dist/use-offset-pagination.mjs +0 -18
- package/dist/use-payment-request.mjs +0 -25
- package/dist/use-performance-observer.mjs +0 -27
- package/dist/use-permission.mjs +0 -26
- package/dist/use-plural-rules.mjs +0 -21
- package/dist/use-push-subscription.mjs +0 -28
- package/dist/use-queue.mjs +0 -29
- package/dist/use-raf-fn.mjs +0 -23
- package/dist/use-relative-time-format.mjs +0 -35
- package/dist/use-request-idle-callback.mjs +0 -42
- package/dist/use-route-query.mjs +0 -17
- package/dist/use-scheduler-post-task.mjs +0 -27
- package/dist/use-screen-details.mjs +0 -42
- package/dist/use-script-tag.mjs +0 -28
- package/dist/use-segmenter.mjs +0 -20
- package/dist/use-serial.mjs +0 -24
- package/dist/use-service-worker.mjs +0 -27
- package/dist/use-set.mjs +0 -23
- package/dist/use-share.mjs +0 -23
- package/dist/use-sorted-locale.mjs +0 -20
- package/dist/use-speech-recognition.mjs +0 -24
- package/dist/use-speech-synthesis.mjs +0 -26
- package/dist/use-stack.mjs +0 -27
- package/dist/use-storage-estimate.mjs +0 -41
- package/dist/use-storage.mjs +0 -68
- package/dist/use-style-tag.mjs +0 -22
- package/dist/use-supported.mjs +0 -17
- package/dist/use-throttled.mjs +0 -46
- package/dist/use-time-ago.mjs +0 -22
- package/dist/use-toggle.mjs +0 -19
- package/dist/use-url-hash.mjs +0 -28
- package/dist/use-url-search-params.mjs +0 -99
- package/dist/use-usb.mjs +0 -23
- package/dist/use-user-activation.mjs +0 -22
- package/dist/use-user-media.mjs +0 -50
- package/dist/use-vibrate.mjs +0 -21
- package/dist/use-view-transition.mjs +0 -22
- package/dist/use-visual-viewport.mjs +0 -25
- package/dist/use-wake-lock.mjs +0 -21
- package/dist/use-web-authn.mjs +0 -61
- package/dist/use-web-locks.mjs +0 -25
- package/dist/use-web-midi.mjs +0 -22
- package/dist/use-web-vitals.mjs +0 -41
- package/dist/use-websocket.mjs +0 -27
- package/dist/use-worker-fn.mjs +0 -37
- package/dist/virtual-list.mjs +0 -14
- package/dist/whenever.mjs +0 -21
- package/dist/window-size.mjs +0 -12
- package/package.json +2 -2
- package/registry/files/form-control-types.ts +260 -0
- package/registry/files/form-dirty.ts +131 -0
- package/registry/files/form-options.ts +156 -0
- package/registry/files/form-path-types.ts +135 -0
- package/registry/files/use-form.ts +102 -449
- package/registry/registry.json +28 -4
package/dist/use-throttled.mjs
CHANGED
|
@@ -7,52 +7,6 @@ const defaultScheduler = {
|
|
|
7
7
|
globalThis.clearTimeout(handle);
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Create a readonly throttled view of a reactive source.
|
|
12
|
-
*
|
|
13
|
-
* Changes are observed with `flush: "sync"`, so every synchronous write
|
|
14
|
-
* counts. Outside a cooldown window, a change applies immediately when
|
|
15
|
-
* {@link UseThrottledOptions.leading} is enabled (otherwise it waits as a
|
|
16
|
-
* trailing update) and opens a window of `waitMs` milliseconds. Changes
|
|
17
|
-
* inside a window are collected as the trailing candidate; when the window
|
|
18
|
-
* ends with a candidate waiting, the source value current at that moment is
|
|
19
|
-
* applied and the next window opens back to back, keeping applications
|
|
20
|
-
* spaced by `waitMs`. A window that ends without a candidate closes silently.
|
|
21
|
-
* `waitMs` is reactive and is read each time a window opens; changing it
|
|
22
|
-
* never disturbs an already-open window. A wait of `0` still defers trailing
|
|
23
|
-
* updates to the next scheduler tick.
|
|
24
|
-
*
|
|
25
|
-
* Server rendering is explicit: without a browser `window` (and with
|
|
26
|
-
* {@link UseThrottledOptions.runOnServer} disabled) no timer ever starts and
|
|
27
|
-
* the view mirrors the source synchronously, so server-rendered output shows
|
|
28
|
-
* current values and nothing leaks. `pending` stays `false` and the controls
|
|
29
|
-
* report `false` in that mode.
|
|
30
|
-
*
|
|
31
|
-
* Cleanup rule: the watcher and any open window timer are released when the
|
|
32
|
-
* owning reactive scope stops; call inside an active scope. Outside one, the
|
|
33
|
-
* watcher lives as long as the source and `cancel()` only clears the window.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* const scrollY = shallowRef(0);
|
|
38
|
-
* const { throttled } = useThrottled(scrollY, 100);
|
|
39
|
-
* scrollY.value = 40; // applied immediately (leading edge)
|
|
40
|
-
* scrollY.value = 80; // applied when the 100ms window ends
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* @param source Reactive source to throttle.
|
|
44
|
-
* @param waitMs Reactive cooldown in milliseconds; must be finite and at
|
|
45
|
-
* least zero. Fractions are truncated.
|
|
46
|
-
* @param options Edge policy and runtime scheduling overrides.
|
|
47
|
-
* @default options {}
|
|
48
|
-
* @throws `RangeError` tagged `VIZE_COMPOSE_THROTTLE_INVALID_WAIT` when the
|
|
49
|
-
* resolved wait is not finite or is negative, both synchronously at creation
|
|
50
|
-
* (even in mirror mode) and again each time a window opens.
|
|
51
|
-
* @throws `TypeError` tagged `VIZE_COMPOSE_THROTTLE_INVALID_EDGES` when both
|
|
52
|
-
* `leading` and `trailing` are disabled, because updates could then never
|
|
53
|
-
* propagate.
|
|
54
|
-
* @returns Readonly throttled view, pending flag, and cancel/flush controls.
|
|
55
|
-
*/
|
|
56
10
|
function useThrottled(source, waitMs, options = {}) {
|
|
57
11
|
const leading = options.leading ?? true;
|
|
58
12
|
const trailing = options.trailing ?? true;
|
package/dist/use-time-ago.mjs
CHANGED
|
@@ -24,28 +24,6 @@ function toEpochMs(input) {
|
|
|
24
24
|
if (Number.isNaN(value)) throw new RangeError(`[VIZE_COMPOSE_TIME_AGO_INVALID_DATE] expected a valid date; received ${String(input)}`);
|
|
25
25
|
return value;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Format the distance between two instants as a localized relative phrase.
|
|
29
|
-
*
|
|
30
|
-
* Pure and deterministic: the output depends only on the arguments (the
|
|
31
|
-
* locale defaults to `"en"`, never the host default), which makes it safe
|
|
32
|
-
* for server rendering and hydration.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* formatTimeAgo(Date.UTC(2026, 0, 1), Date.UTC(2026, 0, 2)); // "yesterday"
|
|
37
|
-
* formatTimeAgo(0, 90_000, { numeric: "always" }); // "2 minutes ago"
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @param time Instant being described.
|
|
41
|
-
* @param now Reference instant.
|
|
42
|
-
* @param options Locale, wording, unit, and threshold policy.
|
|
43
|
-
* @default options {}
|
|
44
|
-
* @throws `RangeError` tagged `VIZE_COMPOSE_TIME_AGO_INVALID_DATE` when
|
|
45
|
-
* either input is not a valid date, and `RangeError` from `Intl` for invalid
|
|
46
|
-
* locales.
|
|
47
|
-
* @returns The localized phrase.
|
|
48
|
-
*/
|
|
49
27
|
function formatTimeAgo(time, now, options = {}) {
|
|
50
28
|
const target = toEpochMs(time);
|
|
51
29
|
const diff = target - toEpochMs(now);
|
package/dist/use-toggle.mjs
CHANGED
|
@@ -1,24 +1,5 @@
|
|
|
1
1
|
import { shallowRef } from "vue";
|
|
2
2
|
//#region src/use-toggle.ts
|
|
3
|
-
/**
|
|
4
|
-
* Create owned boolean state with an inverting control.
|
|
5
|
-
*
|
|
6
|
-
* Purely synchronous state: safe during server rendering (no browser
|
|
7
|
-
* globals, no timers) and nothing to dispose, so it works inside and
|
|
8
|
-
* outside reactive scopes alike.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* const { state: open, toggle } = useToggle();
|
|
13
|
-
* toggle(); // true
|
|
14
|
-
* toggle(false); // false
|
|
15
|
-
* open.value; // false
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @param initial State before the first toggle.
|
|
19
|
-
* @default initial false
|
|
20
|
-
* @returns The writable state and its toggle control.
|
|
21
|
-
*/
|
|
22
3
|
function useToggle(initial = false) {
|
|
23
4
|
const state = shallowRef(initial);
|
|
24
5
|
const toggle = (force) => {
|
package/dist/use-url-hash.mjs
CHANGED
|
@@ -15,34 +15,6 @@ function decodeFragment(hash) {
|
|
|
15
15
|
function encodeFragment(raw) {
|
|
16
16
|
return encodeURI(raw).replaceAll("#", "%23");
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Synchronize a typed value with the URL fragment (`location.hash`).
|
|
20
|
-
*
|
|
21
|
-
* Reading follows `hashchange` and `popstate`. Writing `state` updates the
|
|
22
|
-
* fragment through `history.replaceState` (or `pushState` with
|
|
23
|
-
* `mode: "push"`), which neither scrolls to an anchor nor fires
|
|
24
|
-
* `hashchange`; an empty serialized value removes the fragment. Values are
|
|
25
|
-
* percent-decoded on read and minimally encoded on write.
|
|
26
|
-
*
|
|
27
|
-
* Server rendering: browsers never send the fragment, so without a host the
|
|
28
|
-
* value is `ssrHash` (when given) or the default, and no global is read.
|
|
29
|
-
* Inside a component the browser hash is first read after mounting
|
|
30
|
-
* (`initialRead` defaults to `"post-flush"` there), so hydration never
|
|
31
|
-
* mismatches. Listeners are removed with the owning reactive scope.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* const { state: tab } = useUrlHash({
|
|
36
|
-
* parse: (raw) => (raw === "settings" ? "settings" : "profile"),
|
|
37
|
-
* serialize: (value) => value,
|
|
38
|
-
* default: "profile" as "profile" | "settings",
|
|
39
|
-
* });
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @param options Codec, host, history mode, and server fallback.
|
|
43
|
-
* @default options {}
|
|
44
|
-
* @returns The synchronized value and its controls.
|
|
45
|
-
*/
|
|
46
18
|
function useUrlHash(options = {}) {
|
|
47
19
|
if ("parse" in options) return createUrlHash({
|
|
48
20
|
parse: options.parse,
|
|
@@ -31,15 +31,7 @@ function arrayCodec(item) {
|
|
|
31
31
|
serialize: (value) => value.flatMap((entry) => item.serialize(entry))
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
/** Built-in typed codecs for {@link useUrlSearchParams} schemas. */
|
|
35
34
|
const searchParam = {
|
|
36
|
-
/**
|
|
37
|
-
* Raw string value.
|
|
38
|
-
*
|
|
39
|
-
* @param fallback Value for an absent key.
|
|
40
|
-
* @default fallback ""
|
|
41
|
-
* @returns A string codec.
|
|
42
|
-
*/
|
|
43
35
|
string(fallback = "") {
|
|
44
36
|
return single({
|
|
45
37
|
parse: (raw) => raw,
|
|
@@ -47,13 +39,6 @@ const searchParam = {
|
|
|
47
39
|
default: fallback
|
|
48
40
|
});
|
|
49
41
|
},
|
|
50
|
-
/**
|
|
51
|
-
* Finite number; non-numeric input selects the default.
|
|
52
|
-
*
|
|
53
|
-
* @param fallback Value for an absent or invalid key.
|
|
54
|
-
* @default fallback 0
|
|
55
|
-
* @returns A number codec.
|
|
56
|
-
*/
|
|
57
42
|
number(fallback = 0) {
|
|
58
43
|
return single({
|
|
59
44
|
parse: (raw) => {
|
|
@@ -64,13 +49,6 @@ const searchParam = {
|
|
|
64
49
|
default: fallback
|
|
65
50
|
});
|
|
66
51
|
},
|
|
67
|
-
/**
|
|
68
|
-
* Boolean: `true`/`1`/empty read as `true`, `false`/`0` as `false`.
|
|
69
|
-
*
|
|
70
|
-
* @param fallback Value for an absent or unrecognized key.
|
|
71
|
-
* @default fallback false
|
|
72
|
-
* @returns A boolean codec.
|
|
73
|
-
*/
|
|
74
52
|
boolean(fallback = false) {
|
|
75
53
|
return single({
|
|
76
54
|
parse: (raw) => {
|
|
@@ -82,13 +60,6 @@ const searchParam = {
|
|
|
82
60
|
default: fallback
|
|
83
61
|
});
|
|
84
62
|
},
|
|
85
|
-
/**
|
|
86
|
-
* One of a closed set of string literals.
|
|
87
|
-
*
|
|
88
|
-
* @param values Allowed values.
|
|
89
|
-
* @param fallback Value for an absent or unknown key.
|
|
90
|
-
* @returns A literal-union codec.
|
|
91
|
-
*/
|
|
92
63
|
enum(values, fallback) {
|
|
93
64
|
const allowed = new Set(values);
|
|
94
65
|
const isAllowed = (raw) => allowed.has(raw);
|
|
@@ -98,22 +69,7 @@ const searchParam = {
|
|
|
98
69
|
default: fallback
|
|
99
70
|
});
|
|
100
71
|
},
|
|
101
|
-
/**
|
|
102
|
-
* Repeated key (`?tag=a&tag=b`) decoded item by item.
|
|
103
|
-
*
|
|
104
|
-
* @param item Single-value codec applied to every value.
|
|
105
|
-
* @default item searchParam.string()
|
|
106
|
-
* @returns An array codec whose default is `[]`.
|
|
107
|
-
*/
|
|
108
72
|
array: arrayCodec,
|
|
109
|
-
/**
|
|
110
|
-
* JSON value checked by `validate`, or by kind against the default.
|
|
111
|
-
*
|
|
112
|
-
* @param fallback Value for an absent or invalid key.
|
|
113
|
-
* @param validate Type guard applied to the decoded JSON.
|
|
114
|
-
* @default validate the decoded value has the default's kind
|
|
115
|
-
* @returns A JSON codec.
|
|
116
|
-
*/
|
|
117
73
|
json(fallback, validate) {
|
|
118
74
|
const accept = validate ?? ((candidate) => sameJsonKind(fallback, candidate));
|
|
119
75
|
return single({
|
|
@@ -125,12 +81,6 @@ const searchParam = {
|
|
|
125
81
|
default: fallback
|
|
126
82
|
});
|
|
127
83
|
},
|
|
128
|
-
/**
|
|
129
|
-
* Single-value codec from explicit parse/serialize functions.
|
|
130
|
-
*
|
|
131
|
-
* @param definition Parse, serialize, and default.
|
|
132
|
-
* @returns The codec.
|
|
133
|
-
*/
|
|
134
84
|
custom(definition) {
|
|
135
85
|
return single(definition);
|
|
136
86
|
}
|
|
@@ -149,14 +99,6 @@ function toSearch(source) {
|
|
|
149
99
|
const query = withoutHash.indexOf("?");
|
|
150
100
|
return new URLSearchParams(query === -1 ? "" : withoutHash.slice(query + 1));
|
|
151
101
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Decode search parameters with a schema. Pure and SSR-safe.
|
|
154
|
-
*
|
|
155
|
-
* @typeParam Schema Parameter codecs.
|
|
156
|
-
* @param schema Parameter codecs.
|
|
157
|
-
* @param search URL, URL string, query string, or parsed parameters.
|
|
158
|
-
* @returns One typed value per schema key.
|
|
159
|
-
*/
|
|
160
102
|
function parseSearchParams(schema, search) {
|
|
161
103
|
const params = toSearch(search);
|
|
162
104
|
const entries = Object.keys(schema).map((key) => {
|
|
@@ -168,16 +110,6 @@ function parseSearchParams(schema, search) {
|
|
|
168
110
|
function sameValues(left, right) {
|
|
169
111
|
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
170
112
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Encode typed values with a schema. Pure and SSR-safe.
|
|
173
|
-
*
|
|
174
|
-
* @typeParam Schema Parameter codecs.
|
|
175
|
-
* @param schema Parameter codecs.
|
|
176
|
-
* @param values Values to encode; keys absent from `values` keep the base.
|
|
177
|
-
* @param options Base parameters and default removal.
|
|
178
|
-
* @default options {}
|
|
179
|
-
* @returns The encoded parameters.
|
|
180
|
-
*/
|
|
181
113
|
function serializeSearchParams(schema, values, options = {}) {
|
|
182
114
|
const params = options.base === void 0 ? new URLSearchParams() : toSearch(options.base);
|
|
183
115
|
const removeDefaults = options.removeDefaults ?? true;
|
|
@@ -198,37 +130,6 @@ function serializeSearchParams(schema, values, options = {}) {
|
|
|
198
130
|
function browserHost() {
|
|
199
131
|
return typeof window !== "undefined" ? window : void 0;
|
|
200
132
|
}
|
|
201
|
-
/**
|
|
202
|
-
* Two-way bind typed URL search parameters described by a codec schema.
|
|
203
|
-
*
|
|
204
|
-
* Every property type is inferred from its codec. Assigning a property
|
|
205
|
-
* rewrites the query through `history.replaceState` (or `pushState` with
|
|
206
|
-
* `mode: "push"`), keeping parameters outside the schema and the fragment,
|
|
207
|
-
* and dropping values equal to their default. Back/forward navigation
|
|
208
|
-
* (`popstate`) re-reads the URL.
|
|
209
|
-
*
|
|
210
|
-
* Server rendering: no global is read. Pass `ssrUrl` (the request URL) so
|
|
211
|
-
* the server renders the same values the client reads during hydration.
|
|
212
|
-
* Inside a component the browser URL is first read after mounting, so the
|
|
213
|
-
* hydrating client renders the `ssrUrl` state before switching to it.
|
|
214
|
-
* Listeners are removed with the owning reactive scope or `stop()`.
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```ts
|
|
218
|
-
* const { params } = useUrlSearchParams({
|
|
219
|
-
* page: searchParam.number(1),
|
|
220
|
-
* sort: searchParam.enum(["new", "top"], "new"),
|
|
221
|
-
* tags: searchParam.array(),
|
|
222
|
-
* });
|
|
223
|
-
* params.page += 1; // ?page=2
|
|
224
|
-
* ```
|
|
225
|
-
*
|
|
226
|
-
* @typeParam Schema Parameter codecs.
|
|
227
|
-
* @param schema Parameter codecs.
|
|
228
|
-
* @param options Host, history mode, default removal, and server URL.
|
|
229
|
-
* @default options {}
|
|
230
|
-
* @returns Typed reactive parameters and controls.
|
|
231
|
-
*/
|
|
232
133
|
function useUrlSearchParams(schema, options = {}) {
|
|
233
134
|
const resolveHost = () => options.host === void 0 ? browserHost() : toValue(options.host) ?? void 0;
|
|
234
135
|
const removeDefaults = options.removeDefaults ?? true;
|
package/dist/use-usb.mjs
CHANGED
|
@@ -20,29 +20,6 @@ function describe(device) {
|
|
|
20
20
|
opened: device.opened
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Talk to USB devices with the WebUSB API.
|
|
25
|
-
*
|
|
26
|
-
* `devices` lists granted devices as plain snapshots and follows the host's
|
|
27
|
-
* `connect` / `disconnect` events. The device actions are thin wrappers over
|
|
28
|
-
* `USBDevice` that resolve to a boolean or the transfer result and record
|
|
29
|
-
* failures in `error` instead of rejecting. Host listeners are removed and
|
|
30
|
-
* sessions opened through `open()` are closed when the owning reactive scope
|
|
31
|
-
* stops; outside a scope call `close()` per device.
|
|
32
|
-
*
|
|
33
|
-
* Server rendering: `supported` is false and `devices` is empty.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* const usb = useUSB();
|
|
38
|
-
* const device = await usb.requestDevice([{ vendorId: 0x2341 }]);
|
|
39
|
-
* if (device && (await usb.open(device))) await usb.claimInterface(device, 0);
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @param options Capability host.
|
|
43
|
-
* @default options {}
|
|
44
|
-
* @returns USB state and actions.
|
|
45
|
-
*/
|
|
46
23
|
function useUSB(options = {}) {
|
|
47
24
|
const devices = shallowRef([]);
|
|
48
25
|
const error = shallowRef(void 0);
|
|
@@ -25,28 +25,6 @@ function browserScheduler() {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Track sticky and transient user activation with the User Activation API.
|
|
30
|
-
*
|
|
31
|
-
* The state is refreshed on activation-triggering events of `target`
|
|
32
|
-
* (immediately and again after a microtask) and polled while `isActive` is
|
|
33
|
-
* true so its expiry is observed. Listeners and the timer are removed when
|
|
34
|
-
* the owning reactive scope stops; outside a scope call `stop()`.
|
|
35
|
-
*
|
|
36
|
-
* Server rendering: no listeners or timers, `supported`, `hasBeenActive`,
|
|
37
|
-
* and `isActive` are false.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* const { isActive } = useUserActivation();
|
|
42
|
-
* const canOpenPopup = computed(() => isActive.value);
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @param options Capability host, event target, and polling policy.
|
|
46
|
-
* @default options {}
|
|
47
|
-
* @throws `RangeError` tagged `VIZE_COMPOSE_USER_ACTIVATION_INVALID_INTERVAL` when `interval` is negative or not finite.
|
|
48
|
-
* @returns Activation state.
|
|
49
|
-
*/
|
|
50
28
|
function useUserActivation(options = {}) {
|
|
51
29
|
const interval = options.interval ?? 1e3;
|
|
52
30
|
if (!Number.isFinite(interval) || interval < 0) throw new RangeError(`[VIZE_COMPOSE_USER_ACTIVATION_INVALID_INTERVAL] interval must be a finite, non-negative number; received ${String(interval)}`);
|
package/dist/use-user-media.mjs
CHANGED
|
@@ -19,33 +19,6 @@ function classify(error) {
|
|
|
19
19
|
function stopTracks(stream) {
|
|
20
20
|
for (const track of stream.getTracks()) track.stop();
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Manage the lifecycle of a media stream from any asynchronous source.
|
|
24
|
-
*
|
|
25
|
-
* This is the engine behind {@link useUserMedia} and `useDisplayMedia`, and
|
|
26
|
-
* can wrap any other stream producer (canvas capture, WebRTC). Acquisition
|
|
27
|
-
* failures are classified into {@link MediaStreamErrorCode}s; the stream
|
|
28
|
-
* returns to `"idle"` once all of its tracks ended (device unplugged, the
|
|
29
|
-
* user stopped screen sharing). Latest-wins: a stream that resolves after a
|
|
30
|
-
* newer request or a `stop` is stopped immediately. All tracks are stopped
|
|
31
|
-
* when the owning reactive scope stops.
|
|
32
|
-
*
|
|
33
|
-
* Server rendering: without a browser window a missing source keeps the
|
|
34
|
-
* status `"idle"` (no error), so server markup matches the first client
|
|
35
|
-
* render.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* const canvasStream = useMediaStream({
|
|
40
|
-
* source: { request: async (fps: number) => canvas.captureStream(fps) },
|
|
41
|
-
* constraints: 30,
|
|
42
|
-
* });
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @typeParam Constraints Constraint type accepted by the source.
|
|
46
|
-
* @param options Source, constraints, and activation.
|
|
47
|
-
* @returns Stream state and actions.
|
|
48
|
-
*/
|
|
49
22
|
function useMediaStream(options) {
|
|
50
23
|
const stream = shallowRef(void 0);
|
|
51
24
|
const status = ref("idle");
|
|
@@ -139,29 +112,6 @@ function browserUserMediaHost() {
|
|
|
139
112
|
if (typeof window === "undefined") return void 0;
|
|
140
113
|
return window.navigator.mediaDevices ?? void 0;
|
|
141
114
|
}
|
|
142
|
-
/**
|
|
143
|
-
* Access the camera and microphone with `getUserMedia`.
|
|
144
|
-
*
|
|
145
|
-
* Built on {@link useMediaStream}: reactive constraints (restarting an
|
|
146
|
-
* active stream when they change), `enabled` activation, classified
|
|
147
|
-
* failures such as `"permission-denied"`, and latest-wins requests. With
|
|
148
|
-
* `listDevices`, `devices` follows `devicechange`. Tracks and listeners are
|
|
149
|
-
* released when the owning reactive scope stops.
|
|
150
|
-
*
|
|
151
|
-
* Server rendering: no device is touched; `status` is `"idle"`, `stream` is
|
|
152
|
-
* undefined, and `supported` is false.
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* ```ts
|
|
156
|
-
* const camera = useUserMedia({ constraints: { video: true, audio: false } });
|
|
157
|
-
* await camera.start();
|
|
158
|
-
* video.srcObject = camera.stream.value;
|
|
159
|
-
* ```
|
|
160
|
-
*
|
|
161
|
-
* @param options Constraints, activation, device listing, and capability.
|
|
162
|
-
* @default options {}
|
|
163
|
-
* @returns Stream state, device list, and actions.
|
|
164
|
-
*/
|
|
165
115
|
function useUserMedia(options = {}) {
|
|
166
116
|
const resolveHost = () => options.host === void 0 ? browserUserMediaHost() : toValue(options.host) ?? void 0;
|
|
167
117
|
const devices = shallowRef([]);
|
package/dist/use-vibrate.mjs
CHANGED
|
@@ -17,27 +17,6 @@ function validatePattern(pattern) {
|
|
|
17
17
|
for (const duration of durations) if (!Number.isSafeInteger(duration) || duration < 0) throw new RangeError(`[VIZE_COMPOSE_VIBRATE_INVALID_PATTERN] vibration durations must be non-negative integers; received ${String(duration)}`);
|
|
18
18
|
return durations;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Drive the Vibration API with validated, optionally repeating patterns.
|
|
22
|
-
*
|
|
23
|
-
* Patterns alternate vibration and pause durations. With `interval > 0`
|
|
24
|
-
* the pattern repeats until `stop` is called or the owning reactive scope
|
|
25
|
-
* stops, which also cancels an ongoing vibration.
|
|
26
|
-
*
|
|
27
|
-
* Server rendering: nothing vibrates and no timer starts; `supported` is false.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* const { vibrate, stop } = useVibrate({ pattern: [200, 100, 200] });
|
|
32
|
-
* vibrate();
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @param options Default pattern, repetition, and capability.
|
|
36
|
-
* @default options {}
|
|
37
|
-
* @returns Vibration state and actions.
|
|
38
|
-
* @throws {RangeError} `[VIZE_COMPOSE_VIBRATE_INVALID_INTERVAL]` for a negative
|
|
39
|
-
* or non-finite interval.
|
|
40
|
-
*/
|
|
41
20
|
function useVibrate(options = {}) {
|
|
42
21
|
const interval = options.interval ?? 0;
|
|
43
22
|
if (!Number.isFinite(interval) || interval < 0) throw new RangeError(`[VIZE_COMPOSE_VIBRATE_INVALID_INTERVAL] interval must be a non-negative finite number; received ${String(interval)}`);
|
|
@@ -6,28 +6,6 @@ function browserDocument() {
|
|
|
6
6
|
return typeof window !== "undefined" && typeof window.document.startViewTransition === "function" ? window.document : void 0;
|
|
7
7
|
}
|
|
8
8
|
function ignore() {}
|
|
9
|
-
/**
|
|
10
|
-
* Animate DOM updates with the View Transition API.
|
|
11
|
-
*
|
|
12
|
-
* Starting a new transition skips the running one (browser behavior). The
|
|
13
|
-
* running transition is skipped when the owning reactive scope stops.
|
|
14
|
-
*
|
|
15
|
-
* Server rendering: `start` runs the update directly; `supported` and
|
|
16
|
-
* `isTransitioning` are false.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const { start } = useViewTransition();
|
|
21
|
-
* await start(async () => {
|
|
22
|
-
* page.value = next;
|
|
23
|
-
* await nextTick();
|
|
24
|
-
* }, { types: ["forward"] });
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param options Document host and reduced-motion policy.
|
|
28
|
-
* @default options {}
|
|
29
|
-
* @returns Transition state and actions.
|
|
30
|
-
*/
|
|
31
9
|
function useViewTransition(options = {}) {
|
|
32
10
|
const transition = shallowRef(null);
|
|
33
11
|
const isTransitioning = shallowRef(false);
|
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
2
|
import { computed, hasInjectionContext, readonly, ref, shallowRef, toValue, watch, watchPostEffect } from "vue";
|
|
3
3
|
//#region src/use-visual-viewport.ts
|
|
4
|
-
/**
|
|
5
|
-
* Track the visual viewport and on-screen keyboard.
|
|
6
|
-
*
|
|
7
|
-
* On mobile browsers the visual viewport shrinks (or scrolls) when a virtual
|
|
8
|
-
* keyboard opens while the layout viewport stays put; `keyboardHeight` is the
|
|
9
|
-
* occluded bottom area (`innerHeight - height - offsetTop`), or the
|
|
10
|
-
* VirtualKeyboard API rectangle when `overlaysContent` is enabled. Pin
|
|
11
|
-
* toolbars above the keyboard with `bottom: calc(var(--kb, 0px))` bound to it.
|
|
12
|
-
*
|
|
13
|
-
* Server rendering reports zeros (scale 1) and attaches nothing; inside a
|
|
14
|
-
* component the host attaches after mount, so hydration renders the same
|
|
15
|
-
* zeros first. Listeners
|
|
16
|
-
* (`resize`, `scroll`, `geometrychange`) are passive and removed with the
|
|
17
|
-
* owning reactive scope.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* const { keyboardHeight, keyboardOpen } = useVisualViewport();
|
|
22
|
-
* const toolbarStyle = computed(() => ({ bottom: `${keyboardHeight.value}px` }));
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @param options Keyboard threshold, VirtualKeyboard opt-in, and capability.
|
|
26
|
-
* @default options {}
|
|
27
|
-
* @returns Reactive viewport geometry and keyboard state.
|
|
28
|
-
*/
|
|
29
4
|
function useVisualViewport(options = {}) {
|
|
30
5
|
const threshold = typeof options.keyboardThreshold === "number" && Number.isFinite(options.keyboardThreshold) ? Math.max(options.keyboardThreshold, 0) : 120;
|
|
31
6
|
const width = ref(0);
|
package/dist/use-wake-lock.mjs
CHANGED
|
@@ -9,27 +9,6 @@ function browserWakeLockHost() {
|
|
|
9
9
|
document
|
|
10
10
|
} : void 0;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Keep the screen awake with the Screen Wake Lock API.
|
|
14
|
-
*
|
|
15
|
-
* Browsers release screen locks when the page is hidden; while a lock is
|
|
16
|
-
* `requested`, it is re-acquired on the next `visibilitychange` to visible.
|
|
17
|
-
* Request failures (missing user activation, battery saver) are exposed
|
|
18
|
-
* through `error` rather than thrown. The lock and the visibility listener
|
|
19
|
-
* are released when the owning reactive scope stops.
|
|
20
|
-
*
|
|
21
|
-
* Server rendering: nothing is requested, `supported` and `active` are false.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const wakeLock = useWakeLock();
|
|
26
|
-
* const startPresentation = () => wakeLock.request();
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @param options Capability host and re-acquisition policy.
|
|
30
|
-
* @default options {}
|
|
31
|
-
* @returns Wake lock state and actions.
|
|
32
|
-
*/
|
|
33
12
|
function useWakeLock(options = {}) {
|
|
34
13
|
const active = ref(false);
|
|
35
14
|
const requested = ref(false);
|
package/dist/use-web-authn.mjs
CHANGED
|
@@ -14,25 +14,12 @@ function isTransport(value) {
|
|
|
14
14
|
function isAttachment(value) {
|
|
15
15
|
return value === "platform" || value === "cross-platform";
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Encode bytes as unpadded base64url.
|
|
19
|
-
*
|
|
20
|
-
* @param bytes Buffer or view to encode.
|
|
21
|
-
* @returns Base64url text without `=` padding.
|
|
22
|
-
*/
|
|
23
17
|
function encodeBase64Url(bytes) {
|
|
24
18
|
const view = bytes instanceof ArrayBuffer ? new Uint8Array(bytes) : new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
25
19
|
let binary = "";
|
|
26
20
|
for (const byte of view) binary += String.fromCharCode(byte);
|
|
27
21
|
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
28
22
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Decode base64url (padded or unpadded) into bytes.
|
|
31
|
-
*
|
|
32
|
-
* @param text Base64url text.
|
|
33
|
-
* @throws `TypeError` tagged `VIZE_COMPOSE_WEBAUTHN_INVALID_BASE64URL` for malformed input.
|
|
34
|
-
* @returns Decoded bytes.
|
|
35
|
-
*/
|
|
36
23
|
function decodeBase64Url(text) {
|
|
37
24
|
const body = text.replace(/=+$/u, "");
|
|
38
25
|
if (!/^[\w-]*$/u.test(body) || body.length % 4 === 1) throw new TypeError(`[VIZE_COMPOSE_WEBAUTHN_INVALID_BASE64URL] invalid base64url input`);
|
|
@@ -81,13 +68,6 @@ function serializeExtensionValue(value) {
|
|
|
81
68
|
function serializeExtensions(results) {
|
|
82
69
|
return serializeExtensionValue(results);
|
|
83
70
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Convert server creation-options JSON into binary options for `create`.
|
|
86
|
-
*
|
|
87
|
-
* @param json Options with base64url `challenge`, `user.id`, and credential ids.
|
|
88
|
-
* @throws `TypeError` tagged `VIZE_COMPOSE_WEBAUTHN_INVALID_BASE64URL` for malformed fields.
|
|
89
|
-
* @returns Binary creation options.
|
|
90
|
-
*/
|
|
91
71
|
function parseCreationOptionsFromJSON(json) {
|
|
92
72
|
const { excludeCredentials, authenticatorSelection, hints, extensions, ...rest } = json;
|
|
93
73
|
return {
|
|
@@ -105,13 +85,6 @@ function parseCreationOptionsFromJSON(json) {
|
|
|
105
85
|
...extensions ? { extensions: parseExtensions(extensions) } : {}
|
|
106
86
|
};
|
|
107
87
|
}
|
|
108
|
-
/**
|
|
109
|
-
* Convert server request-options JSON into binary options for `get`.
|
|
110
|
-
*
|
|
111
|
-
* @param json Options with base64url `challenge` and credential ids.
|
|
112
|
-
* @throws `TypeError` tagged `VIZE_COMPOSE_WEBAUTHN_INVALID_BASE64URL` for malformed fields.
|
|
113
|
-
* @returns Binary request options.
|
|
114
|
-
*/
|
|
115
88
|
function parseRequestOptionsFromJSON(json) {
|
|
116
89
|
const { allowCredentials, hints, extensions, ...rest } = json;
|
|
117
90
|
return {
|
|
@@ -122,12 +95,6 @@ function parseRequestOptionsFromJSON(json) {
|
|
|
122
95
|
...extensions ? { extensions: parseExtensions(extensions) } : {}
|
|
123
96
|
};
|
|
124
97
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Serialize a registration credential into JSON-safe base64url fields.
|
|
127
|
-
*
|
|
128
|
-
* @param credential Credential resolved by `create`.
|
|
129
|
-
* @returns Server-ready registration response.
|
|
130
|
-
*/
|
|
131
98
|
function serializeRegistrationCredential(credential) {
|
|
132
99
|
const { response } = credential;
|
|
133
100
|
const publicKey = response.getPublicKey?.() ?? null;
|
|
@@ -150,12 +117,6 @@ function serializeRegistrationCredential(credential) {
|
|
|
150
117
|
}
|
|
151
118
|
};
|
|
152
119
|
}
|
|
153
|
-
/**
|
|
154
|
-
* Serialize an authentication credential into JSON-safe base64url fields.
|
|
155
|
-
*
|
|
156
|
-
* @param credential Credential resolved by `get`.
|
|
157
|
-
* @returns Server-ready authentication response.
|
|
158
|
-
*/
|
|
159
120
|
function serializeAuthenticationCredential(credential) {
|
|
160
121
|
const { response } = credential;
|
|
161
122
|
return {
|
|
@@ -206,28 +167,6 @@ function isJSONOptions(input) {
|
|
|
206
167
|
function errorName(error) {
|
|
207
168
|
return typeof error === "object" && error !== null && "name" in error ? error.name : void 0;
|
|
208
169
|
}
|
|
209
|
-
/**
|
|
210
|
-
* Register and authenticate passkeys with the Web Authentication API.
|
|
211
|
-
*
|
|
212
|
-
* `create` and `get` accept binary options or server JSON, run one ceremony
|
|
213
|
-
* at a time (starting one aborts the previous), and resolve to a
|
|
214
|
-
* discriminated {@link WebAuthnResult}. Use the exported pure helpers to
|
|
215
|
-
* serialize results for the server. A pending ceremony is aborted when the
|
|
216
|
-
* owning reactive scope stops; outside a scope call `abort()`.
|
|
217
|
-
*
|
|
218
|
-
* Server rendering: nothing is requested, `supported` and `pending` are false.
|
|
219
|
-
*
|
|
220
|
-
* @example
|
|
221
|
-
* ```ts
|
|
222
|
-
* const webAuthn = useWebAuthn();
|
|
223
|
-
* const result = await webAuthn.get(await fetchJSON("/login/options"));
|
|
224
|
-
* if (result.status === "success") await post(serializeAuthenticationCredential(result.credential));
|
|
225
|
-
* ```
|
|
226
|
-
*
|
|
227
|
-
* @param options Capability hosts.
|
|
228
|
-
* @default options {}
|
|
229
|
-
* @returns Ceremony state and actions.
|
|
230
|
-
*/
|
|
231
170
|
function useWebAuthn(options = {}) {
|
|
232
171
|
const pending = ref(false);
|
|
233
172
|
const error = shallowRef(void 0);
|
package/dist/use-web-locks.mjs
CHANGED
|
@@ -10,31 +10,6 @@ function without(names, name) {
|
|
|
10
10
|
const index = names.indexOf(name);
|
|
11
11
|
return index === -1 ? names : [...names.slice(0, index), ...names.slice(index + 1)];
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Coordinate work across tabs and workers with the Web Locks API.
|
|
15
|
-
*
|
|
16
|
-
* `request` runs the callback while the named lock is held and resolves with
|
|
17
|
-
* its result; with `ifAvailable` it resolves with a discriminated
|
|
18
|
-
* `{ acquired }` outcome instead of waiting. `held` and `pending` track the
|
|
19
|
-
* lock names requested through this composable. Requests still waiting when
|
|
20
|
-
* the owning reactive scope stops are aborted; locks already held are
|
|
21
|
-
* released when their callbacks settle. Outside a scope, pass a `signal` to
|
|
22
|
-
* own cancellation.
|
|
23
|
-
*
|
|
24
|
-
* Server rendering: nothing is requested, `supported` is false and the name
|
|
25
|
-
* lists are empty.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* const locks = useWebLocks();
|
|
30
|
-
* await locks.request("sync", async () => syncOutbox());
|
|
31
|
-
* const attempt = await locks.request("leader", runLeader, { ifAvailable: true });
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @param options Lock manager override.
|
|
35
|
-
* @default options {}
|
|
36
|
-
* @returns Lock state and actions.
|
|
37
|
-
*/
|
|
38
13
|
function useWebLocks(options = {}) {
|
|
39
14
|
const held = ref([]);
|
|
40
15
|
const pending = ref([]);
|