@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.
- 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.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-A4j_h14D.mjs → use-form-BZqwMs6k.mjs} +0 -68
- package/dist/use-form-field-props.mjs +0 -57
- 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/registry.json +1 -1
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([]);
|
package/dist/use-web-midi.mjs
CHANGED
|
@@ -18,28 +18,6 @@ function describe(port) {
|
|
|
18
18
|
function hasMessageData(event) {
|
|
19
19
|
return "data" in event;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Access MIDI devices with the Web MIDI API.
|
|
23
|
-
*
|
|
24
|
-
* Nothing is requested until `request()` is called. Once granted, `inputs`
|
|
25
|
-
* and `outputs` follow `statechange` events, and `onMessage` receives
|
|
26
|
-
* messages from every input. Failures land in `error`. Listeners are removed
|
|
27
|
-
* when the owning reactive scope stops; outside a scope call `stop()`.
|
|
28
|
-
*
|
|
29
|
-
* Server rendering: `supported` is false, `status` stays `"idle"` and no
|
|
30
|
-
* access is requested.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* const midi = useWebMIDI({ onMessage: ({ data }) => console.log(data) });
|
|
35
|
-
* await midi.request();
|
|
36
|
-
* midi.send(midi.outputs.value[0]!.id, [0x90, 60, 127]);
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @param options Host, access flags, and message callback.
|
|
40
|
-
* @default options {}
|
|
41
|
-
* @returns MIDI state and actions.
|
|
42
|
-
*/
|
|
43
21
|
function useWebMIDI(options = {}) {
|
|
44
22
|
const status = ref("idle");
|
|
45
23
|
const inputs = shallowRef([]);
|
package/dist/use-web-vitals.mjs
CHANGED
|
@@ -2,11 +2,6 @@ import { tryOnScopeDispose } from "./scope.mjs";
|
|
|
2
2
|
import { usePerformanceObserver } from "./use-performance-observer.mjs";
|
|
3
3
|
import { computed, hasInjectionContext, readonly, shallowRef, toValue, watch, watchPostEffect } from "vue";
|
|
4
4
|
//#region src/use-web-vitals.ts
|
|
5
|
-
/**
|
|
6
|
-
* Standard `[good, poor]` thresholds: values up to the first bound are
|
|
7
|
-
* "good", values above the second are "poor". Times are milliseconds; CLS is
|
|
8
|
-
* unitless.
|
|
9
|
-
*/
|
|
10
5
|
const WEB_VITALS_THRESHOLDS = {
|
|
11
6
|
LCP: [2500, 4e3],
|
|
12
7
|
CLS: [.1, .25],
|
|
@@ -14,13 +9,6 @@ const WEB_VITALS_THRESHOLDS = {
|
|
|
14
9
|
FCP: [1800, 3e3],
|
|
15
10
|
TTFB: [800, 1800]
|
|
16
11
|
};
|
|
17
|
-
/**
|
|
18
|
-
* Rate a metric value with {@link WEB_VITALS_THRESHOLDS}.
|
|
19
|
-
*
|
|
20
|
-
* @param name Metric name.
|
|
21
|
-
* @param value Metric value (milliseconds, or the unitless CLS score).
|
|
22
|
-
* @returns The rating bucket.
|
|
23
|
-
*/
|
|
24
12
|
function rateMetric(name, value) {
|
|
25
13
|
if (Number.isNaN(value)) throw new RangeError(`[VIZE_COMPOSE_WEB_VITALS_INVALID_VALUE] ${name} value must be a number`);
|
|
26
14
|
const [good, poor] = WEB_VITALS_THRESHOLDS[name];
|
|
@@ -31,35 +19,6 @@ const MAX_INTERACTIONS = 10;
|
|
|
31
19
|
function browserDocument() {
|
|
32
20
|
return typeof window === "undefined" ? void 0 : window.document;
|
|
33
21
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Measure LCP, CLS, INP, FCP and TTFB locally, without dependencies.
|
|
36
|
-
*
|
|
37
|
-
* - LCP: last candidate before the first input or hidden page.
|
|
38
|
-
* - CLS: largest session window (shifts < 1 s apart, window ≤ 5 s),
|
|
39
|
-
* ignoring shifts after recent input.
|
|
40
|
-
* - INP: per-interaction maximum duration; the highest after ignoring one
|
|
41
|
-
* per 50 interactions (a p98 approximation over the 10 longest). The
|
|
42
|
-
* interaction count only includes interactions above `durationThreshold`.
|
|
43
|
-
* - FCP: `first-contentful-paint` before the page was first hidden.
|
|
44
|
-
* - TTFB: navigation `responseStart - activationStart`, clamped at 0.
|
|
45
|
-
*
|
|
46
|
-
* Values are not adjusted for prerender activation except TTFB. Observers
|
|
47
|
-
* and listeners are released when the owning reactive scope stops; outside
|
|
48
|
-
* a scope the caller owns `stop()`.
|
|
49
|
-
*
|
|
50
|
-
* Server rendering: nothing is observed, `metrics` is `{}` and `supported`
|
|
51
|
-
* is false.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* const { metrics, onMetric } = useWebVitals();
|
|
56
|
-
* onMetric((metric) => navigator.sendBeacon("/vitals", JSON.stringify(metric)));
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @param options Hosts and reporting policy.
|
|
60
|
-
* @default options {}
|
|
61
|
-
* @returns Reactive metrics and a report hook.
|
|
62
|
-
*/
|
|
63
22
|
function useWebVitals(options = {}) {
|
|
64
23
|
const metrics = shallowRef({});
|
|
65
24
|
const reported = /* @__PURE__ */ new Map();
|
package/dist/use-websocket.mjs
CHANGED
|
@@ -24,33 +24,6 @@ function defaultScheduler() {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Reactive WebSocket with typed messages, auto-reconnect, and heartbeat.
|
|
29
|
-
*
|
|
30
|
-
* Unexpected closes reconnect with exponential backoff when `autoReconnect`
|
|
31
|
-
* is enabled; `close()` is always final until `open()` is called again.
|
|
32
|
-
* Messages sent while connecting are queued. The connection and all timers
|
|
33
|
-
* are released when the owning reactive scope stops; outside a scope the
|
|
34
|
-
* caller owns `close()`. Server rendering never connects: automatic
|
|
35
|
-
* connection requires a browser or an explicit `host`, and status stays
|
|
36
|
-
* `"closed"`.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* const chat = useWebSocket<ChatEvent, ChatCommand>("wss://example.test/chat", {
|
|
41
|
-
* parse: (raw) => parseChatEvent(String(raw)),
|
|
42
|
-
* serialize: (command) => JSON.stringify(command),
|
|
43
|
-
* autoReconnect: { retries: 5 },
|
|
44
|
-
* heartbeat: true,
|
|
45
|
-
* });
|
|
46
|
-
* chat.send({ type: "join", room: "general" });
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @param url Reactive URL; changing it reconnects.
|
|
50
|
-
* @param options Codecs, reconnection, heartbeat, and host options.
|
|
51
|
-
* @default options {}
|
|
52
|
-
* @returns Reactive state and controls.
|
|
53
|
-
*/
|
|
54
27
|
function useWebSocket(url, options = {}) {
|
|
55
28
|
const status = shallowRef("closed");
|
|
56
29
|
const data = shallowRef(void 0);
|
package/dist/use-worker-fn.mjs
CHANGED
|
@@ -24,18 +24,6 @@ function defaultScheduler() {
|
|
|
24
24
|
function workerError(code, message, cause) {
|
|
25
25
|
return cause === void 0 ? /* @__PURE__ */ new Error(`[${code}] ${message}`) : new Error(`[${code}] ${message}`, { cause });
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Build the worker script for `fn`. Exposed for inspection and testing.
|
|
29
|
-
*
|
|
30
|
-
* The function source is embedded with `Function.prototype.toString`, so it
|
|
31
|
-
* must be self-contained: no closures over module variables, only its
|
|
32
|
-
* arguments, `localDependencies`, `dependencies`, and worker globals.
|
|
33
|
-
*
|
|
34
|
-
* @param fn Function to embed.
|
|
35
|
-
* @param options Imported scripts and inlined helper functions.
|
|
36
|
-
* @default options {}
|
|
37
|
-
* @returns JavaScript source for a dedicated worker.
|
|
38
|
-
*/
|
|
39
27
|
function createWorkerFnScript(fn, options = {}) {
|
|
40
28
|
const imports = (options.dependencies ?? []).map((url) => JSON.stringify(url)).join(", ");
|
|
41
29
|
const helpers = (options.localDependencies ?? []).map((helper) => {
|
|
@@ -55,31 +43,6 @@ function createWorkerFnScript(fn, options = {}) {
|
|
|
55
43
|
"};"
|
|
56
44
|
].filter((line) => line !== "").join("\n");
|
|
57
45
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Run a CPU-heavy function in a dedicated Blob-URL worker, off the main thread.
|
|
60
|
-
*
|
|
61
|
-
* Each `run` spawns a fresh worker, posts the arguments, and resolves with the
|
|
62
|
-
* function's (awaited) result; the worker is terminated and its URL revoked
|
|
63
|
-
* once the run settles, times out, or is terminated. Concurrent runs reject
|
|
64
|
-
* with `VIZE_COMPOSE_WORKER_FN_BUSY`. The running worker is terminated when
|
|
65
|
-
* the owning reactive scope stops. Server rendering never spawns workers:
|
|
66
|
-
* `supported` is `false` and `run` rejects with
|
|
67
|
-
* `VIZE_COMPOSE_WORKER_FN_UNSUPPORTED`.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* const { run, status } = useWorkerFn((values: number[]) =>
|
|
72
|
-
* [...values].sort((a, b) => a - b),
|
|
73
|
-
* );
|
|
74
|
-
* const sorted = await run(bigArray);
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @param fn Self-contained function; see {@link createWorkerFnScript}.
|
|
78
|
-
* @param options Timeout, dependencies, host, and scheduler.
|
|
79
|
-
* @default options {}
|
|
80
|
-
* @throws {RangeError} `[VIZE_COMPOSE_WORKER_FN_INVALID_TIMEOUT]` for an invalid timeout.
|
|
81
|
-
* @returns Reactive status and run controls.
|
|
82
|
-
*/
|
|
83
46
|
function useWorkerFn(fn, options = {}) {
|
|
84
47
|
const { timeoutMs } = options;
|
|
85
48
|
if (timeoutMs !== void 0 && (!Number.isFinite(timeoutMs) || timeoutMs < 0)) throw new RangeError(`[VIZE_COMPOSE_WORKER_FN_INVALID_TIMEOUT] timeoutMs must be a finite non-negative number; received ${String(timeoutMs)}`);
|
package/dist/virtual-list.mjs
CHANGED
|
@@ -2,19 +2,6 @@ import { useResizeObserver } from "./resize-observer.mjs";
|
|
|
2
2
|
import { useElementRef } from "./element-ref.mjs";
|
|
3
3
|
import { computed, shallowRef, toValue } from "vue";
|
|
4
4
|
//#region src/virtual-list.ts
|
|
5
|
-
/**
|
|
6
|
-
* Render only the visible slice of a long list (fixed or variable item sizes).
|
|
7
|
-
*
|
|
8
|
-
* Offsets are prefix sums recomputed when the items change; the visible range
|
|
9
|
-
* is found by binary search, so scrolling is O(log n). Until the container is
|
|
10
|
-
* measured (always on the server) the first `initialItemCount` items render,
|
|
11
|
-
* so server and first client render match. The container is measured on
|
|
12
|
-
* scroll and via `ResizeObserver`, released with the owning reactive scope.
|
|
13
|
-
*
|
|
14
|
-
* @param items Reactive source list.
|
|
15
|
-
* @param options Item size, overscan, axis, initial count, and capability.
|
|
16
|
-
* @returns Items to render plus container/wrapper bindings.
|
|
17
|
-
*/
|
|
18
5
|
function useVirtualList(items, options) {
|
|
19
6
|
const overscan = Math.max(0, Math.floor(options.overscan ?? 5));
|
|
20
7
|
const vertical = (options.orientation ?? "vertical") === "vertical";
|
|
@@ -110,7 +97,6 @@ function useVirtualList(items, options) {
|
|
|
110
97
|
}
|
|
111
98
|
};
|
|
112
99
|
}
|
|
113
|
-
/** Largest index whose start offset is ≤ `position`. */
|
|
114
100
|
function findIndex(offsets, count, position) {
|
|
115
101
|
let low = 0;
|
|
116
102
|
let high = Math.max(0, count - 1);
|
package/dist/whenever.mjs
CHANGED
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
import { watch } from "vue";
|
|
2
2
|
//#region src/whenever.ts
|
|
3
|
-
/**
|
|
4
|
-
* Run a callback whenever a source becomes (or changes while) truthy.
|
|
5
|
-
*
|
|
6
|
-
* The callback's value is narrowed with `Exclude<Value, Falsy>`, so a
|
|
7
|
-
* `Ref<User | null>` delivers `User`. With `once`, the watcher stops after
|
|
8
|
-
* the first truthy delivery, not after the first change (unlike Vue's
|
|
9
|
-
* `once`). With `immediate`, an already-truthy source is delivered right
|
|
10
|
-
* away. Safe during server rendering and bound to the owning scope.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* whenever(currentUser, (user) => greet(user.name), { immediate: true, once: true });
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @param source Ref or getter.
|
|
18
|
-
* @param callback Receives the truthy value, the previous value, and
|
|
19
|
-
* `onCleanup`.
|
|
20
|
-
* @param options Vue watch options; `once` counts truthy deliveries only.
|
|
21
|
-
* @default options {}
|
|
22
|
-
* @returns Vue's watch handle.
|
|
23
|
-
*/
|
|
24
3
|
function whenever(source, callback, options = {}) {
|
|
25
4
|
const { once = false, ...watchOptions } = options;
|
|
26
5
|
let handle;
|
package/dist/window-size.mjs
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { tryOnScopeDispose } from "./scope.mjs";
|
|
2
2
|
import { hasInjectionContext, onMounted, readonly, ref, toValue, watch } from "vue";
|
|
3
3
|
//#region src/window-size.ts
|
|
4
|
-
/**
|
|
5
|
-
* Track the window size reactively.
|
|
6
|
-
*
|
|
7
|
-
* Server renders expose `initialWidth`/`initialHeight` (default `0`), so the
|
|
8
|
-
* first client render matches; the real size is applied as soon as a window
|
|
9
|
-
* resolves (after mounting when called inside a component). Resize (and orientation) listeners are passive and removed with
|
|
10
|
-
* the owning reactive scope.
|
|
11
|
-
*
|
|
12
|
-
* @param options Initial size, measurement kind, and capability.
|
|
13
|
-
* @default options {}
|
|
14
|
-
* @returns Reactive width/height plus a support flag.
|
|
15
|
-
*/
|
|
16
4
|
function useWindowSize(options = {}) {
|
|
17
5
|
const { initialWidth = 0, initialHeight = 0, includeScrollbar = true, type = "inner", listenOrientation = true } = options;
|
|
18
6
|
const width = ref(initialWidth);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/composable",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.811.0",
|
|
4
4
|
"description": "Lifecycle-safe composable foundations for Vize applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"composables",
|
|
@@ -978,7 +978,7 @@
|
|
|
978
978
|
},
|
|
979
979
|
"devDependencies": {
|
|
980
980
|
"@types/node": "25.9.2",
|
|
981
|
-
"@vizejs/native": "0.
|
|
981
|
+
"@vizejs/native": "0.811.0",
|
|
982
982
|
"happy-dom": "21.0.4",
|
|
983
983
|
"typescript": "6.0.3",
|
|
984
984
|
"vite-plus": "0.1.24",
|