@fitzzero/quickdraw-core 5.1.2 → 5.1.3
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/README.md +793 -57
- package/dist/{admin-DWWrT1h6.d.ts → admin-CS7JB_UH.d.ts} +2 -2
- package/dist/{adminSchemas-D4bFKsrb.d.ts → adminSchemas-29cGgrg5.d.ts} +1 -1
- package/dist/{auth-DXiSJZaf.d.ts → auth-DtdYjrZ9.d.ts} +11 -7
- package/dist/{caller-BT-Mv4bD.d.ts → caller-BTwGl7vm.d.ts} +183 -15
- package/dist/chunk-2FDSKLBO.js +82 -0
- package/dist/chunk-2FDSKLBO.js.map +1 -0
- package/dist/{chunk-GSIPUNJL.js → chunk-64I6MYBC.js} +139 -792
- package/dist/chunk-64I6MYBC.js.map +1 -0
- package/dist/chunk-7473HK24.js +17 -0
- package/dist/chunk-7473HK24.js.map +1 -0
- package/dist/chunk-7Y5ROPXL.js +33 -0
- package/dist/chunk-7Y5ROPXL.js.map +1 -0
- package/dist/chunk-A2RBQD66.js +7 -0
- package/dist/chunk-A2RBQD66.js.map +1 -0
- package/dist/chunk-ASAMUGHG.js +651 -0
- package/dist/chunk-ASAMUGHG.js.map +1 -0
- package/dist/{chunk-B2P7AZ25.js → chunk-CYE4UBOB.js} +6 -4
- package/dist/chunk-CYE4UBOB.js.map +1 -0
- package/dist/chunk-DNP65TD5.js +832 -0
- package/dist/chunk-DNP65TD5.js.map +1 -0
- package/dist/{chunk-5CGO426C.js → chunk-GYLWEJHW.js} +5 -1
- package/dist/chunk-GYLWEJHW.js.map +1 -0
- package/dist/{chunk-AONAFOYU.js → chunk-I3JCFS7H.js} +25 -13
- package/dist/chunk-I3JCFS7H.js.map +1 -0
- package/dist/{chunk-X5CWPX7H.js → chunk-IIQ3WMJK.js} +13 -2
- package/dist/chunk-IIQ3WMJK.js.map +1 -0
- package/dist/{chunk-6K5BY47X.js → chunk-JVTONQFI.js} +1277 -277
- package/dist/chunk-JVTONQFI.js.map +1 -0
- package/dist/{chunk-RL4VKLBX.js → chunk-KKQANRLG.js} +2 -2
- package/dist/{chunk-RL4VKLBX.js.map → chunk-KKQANRLG.js.map} +1 -1
- package/dist/{chunk-GKH3LJ7N.js → chunk-MPQAT55F.js} +38 -205
- package/dist/chunk-MPQAT55F.js.map +1 -0
- package/dist/chunk-NX2V6SIL.js +202 -0
- package/dist/chunk-NX2V6SIL.js.map +1 -0
- package/dist/{chunk-7QCUX4TK.js → chunk-NZHA4TZD.js} +72 -175
- package/dist/chunk-NZHA4TZD.js.map +1 -0
- package/dist/{chunk-MBH6IDSM.js → chunk-OCZJ4EYV.js} +40 -17
- package/dist/chunk-OCZJ4EYV.js.map +1 -0
- package/dist/{chunk-RJ5I2VO3.js → chunk-PHCURHC7.js} +6 -6
- package/dist/chunk-PHCURHC7.js.map +1 -0
- package/dist/{chunk-4YO5H5ON.js → chunk-Q4OGQM5I.js} +4 -10
- package/dist/chunk-Q4OGQM5I.js.map +1 -0
- package/dist/chunk-QSU47XEX.js +13 -0
- package/dist/chunk-QSU47XEX.js.map +1 -0
- package/dist/{chunk-LCC7HNFP.js → chunk-RZXJTDH5.js} +2 -2
- package/dist/{chunk-Z2LZ7IZ7.js → chunk-SN3OZVEQ.js} +5 -31
- package/dist/chunk-SN3OZVEQ.js.map +1 -0
- package/dist/{chunk-Z5ILULF2.js → chunk-SQ5VUG77.js} +4 -3
- package/dist/{chunk-Z5ILULF2.js.map → chunk-SQ5VUG77.js.map} +1 -1
- package/dist/chunk-STH5DLQP.js +1192 -0
- package/dist/chunk-STH5DLQP.js.map +1 -0
- package/dist/{chunk-NMXYENH4.js → chunk-VZFJTKIW.js} +6 -6
- package/dist/{chunk-753VJIUP.js → chunk-X4ZU4QH5.js} +43 -9
- package/dist/chunk-X4ZU4QH5.js.map +1 -0
- package/dist/chunk-XD7SRDUY.js +188 -0
- package/dist/chunk-XD7SRDUY.js.map +1 -0
- package/dist/chunk-Z7I6SONO.js +825 -0
- package/dist/chunk-Z7I6SONO.js.map +1 -0
- package/dist/cli/quickdraw-docs.js +131 -113
- package/dist/cli/quickdraw-docs.js.map +1 -1
- package/dist/client/core.d.ts +387 -0
- package/dist/client/core.js +109 -0
- package/dist/client/core.js.map +1 -0
- package/dist/client/index.d.ts +30 -193
- package/dist/client/index.js +56 -217
- package/dist/client/index.js.map +1 -1
- package/dist/{clientTypes-hWcPUVS9.d.ts → clientTypes-CUUNJwWs.d.ts} +3 -3
- package/dist/{connection-CgijdGpT.d.ts → connection-2EeQ_Et0.d.ts} +16 -9
- package/dist/{createServer-Cp-Wk500.d.ts → createServer-Bx5HOcYK.d.ts} +37 -9
- package/dist/{createTestApp-BB_PkqQ7.d.ts → createTestApp-DAMANT79.d.ts} +36 -9
- package/dist/{envelope-DzWyIXjj.d.ts → envelope-BMBaxppV.d.ts} +200 -8
- package/dist/{http-DotQ5bj8.d.ts → http-YzLAar3w.d.ts} +15 -50
- package/dist/index.d.ts +7 -6
- package/dist/index.js +61 -28
- package/dist/index.js.map +1 -1
- package/dist/{infer-BmoZsL9a.d.ts → infer-Br62cnyW.d.ts} +39 -1
- package/dist/{metrics-DW80Exve.d.ts → metrics-CTVpw0gu.d.ts} +2 -2
- package/dist/parser.js +2 -1
- package/dist/prisma/index.d.ts +13 -6
- package/dist/prisma/index.js +155 -9
- package/dist/prisma/index.js.map +1 -1
- package/dist/remote-N7OUAGOW.js +15 -0
- package/dist/remote-N7OUAGOW.js.map +1 -0
- package/dist/server/auth/index.d.ts +3 -3
- package/dist/server/auth/index.js +5 -3
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/index.d.ts +140 -36
- package/dist/server/index.js +162 -55
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp/index.d.ts +34 -18
- package/dist/server/mcp/index.js +29 -12
- package/dist/server/mcp/index.js.map +1 -1
- package/dist/server/otel.d.ts +3 -3
- package/dist/{sharing-UDLn1049.d.ts → sharing-BrsmlDv_.d.ts} +3 -3
- package/dist/testing/client.d.ts +13 -13
- package/dist/testing/client.js +17 -10
- package/dist/testing/client.js.map +1 -1
- package/dist/testing/index.d.ts +49 -12
- package/dist/testing/index.js +102 -19
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/mock.d.ts +5 -5
- package/dist/testing/mock.js +15 -9
- package/dist/tracked-BR5b2O-U.d.ts +43 -0
- package/dist/{types-CYliTP65.d.ts → types-CLRCQGnO.d.ts} +4 -3
- package/dist/types-tMagHbjy.d.ts +151 -0
- package/dist/utils/index.d.ts +16 -4
- package/dist/utils/index.js +6 -3
- package/package.json +5 -1
- package/dist/chunk-4YO5H5ON.js.map +0 -1
- package/dist/chunk-5CGO426C.js.map +0 -1
- package/dist/chunk-6K5BY47X.js.map +0 -1
- package/dist/chunk-753VJIUP.js.map +0 -1
- package/dist/chunk-7QCUX4TK.js.map +0 -1
- package/dist/chunk-AONAFOYU.js.map +0 -1
- package/dist/chunk-B2P7AZ25.js.map +0 -1
- package/dist/chunk-GKH3LJ7N.js.map +0 -1
- package/dist/chunk-GSIPUNJL.js.map +0 -1
- package/dist/chunk-MBH6IDSM.js.map +0 -1
- package/dist/chunk-RJ5I2VO3.js.map +0 -1
- package/dist/chunk-X5CWPX7H.js.map +0 -1
- package/dist/chunk-Z2LZ7IZ7.js.map +0 -1
- /package/dist/{chunk-LCC7HNFP.js.map → chunk-RZXJTDH5.js.map} +0 -0
- /package/dist/{chunk-NMXYENH4.js.map → chunk-VZFJTKIW.js.map} +0 -0
package/dist/client/index.d.ts
CHANGED
|
@@ -1,198 +1,21 @@
|
|
|
1
|
-
export { BreadcrumbItem, JWTPayload, NavItem, ServerCallOptions, ServerCaller, ServerCallerHeaders, ServerCallerOptions, ServerMethod, ServerMutation, ServerQuery, buildBreadcrumbs, createServerCaller, findNavItemByHref, findParentNavItem, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, parseJWTPayload, routeRequiresAuth, truncate } from '../utils/index.js';
|
|
1
|
+
export { BreadcrumbItem, JWTPayload, NavItem, QueryClientLike, ServerCallOptions, ServerCaller, ServerCallerHeaders, ServerCallerOptions, ServerMethod, ServerMutation, ServerQuery, buildBreadcrumbs, createServerCaller, findNavItemByHref, findParentNavItem, formatCurrency, formatDate, formatDateTime, formatNumber, formatPercent, parseJWTPayload, routeRequiresAuth, truncate } from '../utils/index.js';
|
|
2
2
|
import { C as CollectionQueryKey, M as MethodQueryKey } from '../keys-CqKkljVN.js';
|
|
3
3
|
export { E as EntityQueryKey, K as KEY_ROOT, b as MethodKeyPrefix, S as ServiceKeyPrefix, c as collectionKey, e as entityKey, m as methodKey, a as methodKeyPrefix, s as serviceKeyPrefix } from '../keys-CqKkljVN.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { QueryClient, QueryKey, Query, UseQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
9
|
-
import { Q as QuickdrawClient, M as MethodQueryOptions, a as QueryCallOptions, b as MethodMutationOptions, c as MutationCallOptions } from '../clientTypes-
|
|
10
|
-
export { A as AddItemOptions, h as AdminMembers, u as ChannelMember, C as CollectionMember, E as EntityMembers, v as EventMember, G as GlobalStreamMember, L as LiveMembers, i as MethodMember, j as MutationMember, k as MutationVariables, O as OnRefused, d as OptimisticCache, l as OptimisticCacheOf, e as OptimisticUpdate, f as OverlayStore, g as OverlayView, m as QueryMember, n as QuickdrawInvalidate, w as RealtimeMembers, R as RefusedAddition, p as RefusedItem, x as ScopedStreamMember, H as SearchMember, I as SearchMemberOf, S as ServiceClient, y as StreamMember, z as UseChannelResult, U as UseCollectionOptions, q as UseCollectionResult, r as UseEntitiesResult, s as UseEntityOptions, t as UseEntityResult, B as UseEventOptions, J as UseSearchOptions, K as UseSearchResult, D as UseStreamOptions, F as UseStreamResult, o as overlaysOf } from '../clientTypes-
|
|
4
|
+
export { AuthProviderInfo, AuthRoutesTarget, CallRequest, CallResult, DEFAULT_ICE_SERVERS, Host, HostChannelContext, HostChannelHandler, HostDefinition, HostImplementation, HostListener, HostPeer, HostStream, HostStreamOptions, PeerConnectionConfig, PeerIceServer, PeerLinkOptions, PeerRequest, RelayMode, SignInUrlOptions, authProviders, call, callData, clearAuthToken, createPeerLink, defineHost, getAuthToken, hostOf, isNotModified, isUnknownOutcome, newId, onHostChange, onPeerRequest, reloadOncePerSession, setAuthToken, shouldRetry, signInUrl, signOut, signOutEverywhere } from './core.js';
|
|
5
|
+
import { Q as QuickdrawConnection, a as QuickdrawConnectionOptions, C as ConnectionAuth, b as ConnectionStatus, c as ConnectionRefusal } from '../connection-2EeQ_Et0.js';
|
|
6
|
+
export { B as BackoffKind, g as BackoffWindows, e as ConnectionState, D as DEFAULT_BACKOFF_MS, h as DEFAULT_SUBSCRIPTION_LANE, J as JoinWait, L as LaneCallback, f as QuickdrawSocket, S as SocketClientOptions, i as SubscriptionEvent, j as SubscriptionLane, T as TopicWatch, d as createQuickdrawConnection } from '../connection-2EeQ_Et0.js';
|
|
7
|
+
export { b as PeerClock, c as PeerCloseReason, a as PeerLink, d as PeerLinkEvents, e as PeerLinkLag, f as PeerLinkLagOptions, g as PeerLinkState, h as PeerLinkStats, P as PeerPath } from '../types-tMagHbjy.js';
|
|
8
|
+
import { QueryClient, QueryKey, Query, UseQueryResult, Updater, UseMutationResult } from '@tanstack/react-query';
|
|
9
|
+
import { Q as QuickdrawClient, M as MethodQueryOptions, a as QueryCallOptions, b as MethodMutationOptions, c as MutationCallOptions } from '../clientTypes-CUUNJwWs.js';
|
|
10
|
+
export { A as AddItemOptions, h as AdminMembers, u as ChannelMember, C as CollectionMember, E as EntityMembers, v as EventMember, G as GlobalStreamMember, L as LiveMembers, i as MethodMember, j as MutationMember, k as MutationVariables, O as OnRefused, d as OptimisticCache, l as OptimisticCacheOf, e as OptimisticUpdate, f as OverlayStore, g as OverlayView, m as QueryMember, n as QuickdrawInvalidate, w as RealtimeMembers, R as RefusedAddition, p as RefusedItem, x as ScopedStreamMember, H as SearchMember, I as SearchMemberOf, S as ServiceClient, y as StreamMember, z as UseChannelResult, U as UseCollectionOptions, q as UseCollectionResult, r as UseEntitiesResult, s as UseEntityOptions, t as UseEntityResult, B as UseEventOptions, J as UseSearchOptions, K as UseSearchResult, D as UseStreamOptions, F as UseStreamResult, o as overlaysOf } from '../clientTypes-CUUNJwWs.js';
|
|
11
|
+
import { as as Revision, J as CollectionDelta, K as CollectionFrame, au as RevokeReason, m as HelloFrame } from '../envelope-BMBaxppV.js';
|
|
12
|
+
export { ab as PeerLabel } from '../envelope-BMBaxppV.js';
|
|
13
|
+
import { O as OrderBy, C as CollectionDef, ae as ContractMap, A as AccessLevel, z as SortDirection } from '../infer-Br62cnyW.js';
|
|
11
14
|
import { Q as QuickdrawError } from '../errors-S-bxEIBC.js';
|
|
12
|
-
import { n as AdminServiceMeta, F as FilterValue, y as AdminPage, z as AdminSubscribers } from '../adminSchemas-
|
|
15
|
+
import { n as AdminServiceMeta, F as FilterValue, y as AdminPage, z as AdminSubscribers } from '../adminSchemas-29cGgrg5.js';
|
|
13
16
|
import * as React from 'react';
|
|
14
17
|
import 'socket.io-client';
|
|
15
18
|
|
|
16
|
-
/**
|
|
17
|
-
* Get the stored auth token: from `localStorage`, or from memory where it
|
|
18
|
-
* cannot be used; `null` without a `window`.
|
|
19
|
-
*/
|
|
20
|
-
declare function getAuthToken(): string | null;
|
|
21
|
-
/**
|
|
22
|
-
* Store the auth token (in `localStorage`, else in memory) and dispatch a
|
|
23
|
-
* change event. Does nothing without a `window`.
|
|
24
|
-
*/
|
|
25
|
-
declare function setAuthToken(token: string): void;
|
|
26
|
-
/**
|
|
27
|
-
* Remove the auth token and dispatch a change event. Does nothing without a
|
|
28
|
-
* `window`.
|
|
29
|
-
*/
|
|
30
|
-
declare function clearAuthToken(): void;
|
|
31
|
-
/** Where the auth routes are, for the browser helpers. */
|
|
32
|
-
interface AuthRoutesTarget {
|
|
33
|
-
/**
|
|
34
|
-
* The API's URL, where `createAuthRoutes` is mounted:
|
|
35
|
-
* `"https://api.example.com"`. Default: `NEXT_PUBLIC_API_URL` where it can
|
|
36
|
-
* be read, else `http://localhost:4000`.
|
|
37
|
-
*/
|
|
38
|
-
readonly apiUrl?: string;
|
|
39
|
-
/** The routes' `basePath`, as `createAuthRoutes` was given it. Default `/auth`. */
|
|
40
|
-
readonly basePath?: string;
|
|
41
|
-
}
|
|
42
|
-
/** Options of {@link signInUrl}. */
|
|
43
|
-
interface SignInUrlOptions extends AuthRoutesTarget {
|
|
44
|
-
/**
|
|
45
|
-
* The page to come back to: an origin or a URL on one, of which the
|
|
46
|
-
* routes keep the origin when `allowedOrigins` lists it, and land on
|
|
47
|
-
* `{origin}{successPath}`. Default: the current page's origin where there
|
|
48
|
-
* is a page; elsewhere the routes take their first allowed origin.
|
|
49
|
-
*/
|
|
50
|
-
readonly returnTo?: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* The URL that starts a sign-in with `provider`: the auth routes' `GET
|
|
54
|
-
* {basePath}/{provider}/start?returnTo=`, which redirects to the provider
|
|
55
|
-
* and, once the user consents, back to `returnTo`'s origin with the session
|
|
56
|
-
* cookie set (or to the routes' `errorPath` with `?error=`). Navigate to it:
|
|
57
|
-
* a link, or `location.assign`. Throws a `TypeError` for a provider id the
|
|
58
|
-
* routes cannot have (lowercase letters, digits and hyphens).
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* <a href={signInUrl("google", { apiUrl: API_URL })}>Sign in with Google</a>
|
|
62
|
-
*/
|
|
63
|
-
declare function signInUrl(provider: string, options?: SignInUrlOptions): string;
|
|
64
|
-
/**
|
|
65
|
-
* Signs out: `POST {basePath}/logout`, which revokes the request's session
|
|
66
|
-
* and clears its cookie, sent with the session cookie and, when one is
|
|
67
|
-
* stored, the bearer token; the stored token is forgotten either way.
|
|
68
|
-
* Rejects with a `QuickdrawError` when the server cannot be reached or
|
|
69
|
-
* refuses (`RATE_LIMITED`, say), so the app knows the session may still be
|
|
70
|
-
* live. The connection keeps the user it signed in as until it connects
|
|
71
|
-
* again: with cookie sessions, reconnect it (`connection.close()`, then
|
|
72
|
-
* `open()`), or load the next page; a provider whose `auth` was the stored
|
|
73
|
-
* token reconnects when the app clears it.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* await signOut({ apiUrl: API_URL });
|
|
77
|
-
*/
|
|
78
|
-
declare function signOut(options?: AuthRoutesTarget): Promise<void>;
|
|
79
|
-
/** A sign-in the API's auth routes serve, as `GET {basePath}/providers` lists it ({@link authProviders}). */
|
|
80
|
-
interface AuthProviderInfo {
|
|
81
|
-
/** Its id: `signInUrl(id)` starts it; a guest's is `POST {basePath}/guest`. */
|
|
82
|
-
readonly id: string;
|
|
83
|
-
/** A name for its button: `"Google"`, `"Discord"`, `"Mock"`, `"Guest"`, or an OAuth provider's own. */
|
|
84
|
-
readonly name: string;
|
|
85
|
-
/** `"oauth"` (a redirecting provider), `"mock"` (the development picker) or `"guest"`. */
|
|
86
|
-
readonly kind: "oauth" | "mock" | "guest";
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* The sign-ins the API serves, in the order its routes list them: `GET
|
|
90
|
-
* {basePath}/providers` (finding F9.1 of the owner's QA of the template), so
|
|
91
|
-
* a login page renders a button only for a provider that is there, whatever
|
|
92
|
-
* the web app was built with: a provider whose credentials the server lacks
|
|
93
|
-
* is not listed, nor the mock where it is off. Rejects with a
|
|
94
|
-
* `QuickdrawError` when the server cannot be reached or refuses.
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* const { data: providers = [] } = useQuery({
|
|
98
|
-
* queryKey: ["auth", "providers"],
|
|
99
|
-
* queryFn: () => authProviders({ apiUrl: API_URL }),
|
|
100
|
-
* });
|
|
101
|
-
*/
|
|
102
|
-
declare function authProviders(options?: AuthRoutesTarget): Promise<readonly AuthProviderInfo[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Signs the user out everywhere: `POST {basePath}/logout-all`, which
|
|
105
|
-
* revokes every session of the user (the app's `onRevoke` can disconnect
|
|
106
|
-
* their sockets) and clears this browser's cookie; the stored token is
|
|
107
|
-
* forgotten either way. Rejects with `UNAUTHENTICATED` when the request
|
|
108
|
-
* carries no live session, and with a `QuickdrawError` when the server
|
|
109
|
-
* cannot be reached or refuses.
|
|
110
|
-
*/
|
|
111
|
-
declare function signOutEverywhere(options?: AuthRoutesTarget): Promise<void>;
|
|
112
|
-
|
|
113
|
-
/** One call, as {@link call} takes it. */
|
|
114
|
-
interface CallRequest {
|
|
115
|
-
/** The service's name on the wire: the contract's `name`. */
|
|
116
|
-
readonly service: string;
|
|
117
|
-
readonly method: string;
|
|
118
|
-
/** The input; left out of the envelope when `undefined`. */
|
|
119
|
-
readonly input?: unknown;
|
|
120
|
-
/** The method's kind, which picks the backoff a `RATE_LIMITED` answer starts. Default `"query"`. */
|
|
121
|
-
readonly kind?: MethodKind;
|
|
122
|
-
/** Aborting it cancels the call. */
|
|
123
|
-
readonly signal?: AbortSignal;
|
|
124
|
-
/** How long to wait for the answer. Default: the connection's `timeoutMs`. */
|
|
125
|
-
readonly timeoutMs?: number;
|
|
126
|
-
/** The version of the result the caller holds; the server answers "not modified" while it is current. */
|
|
127
|
-
readonly v?: Version;
|
|
128
|
-
/**
|
|
129
|
-
* Called with the result the moment the reply arrives, before any frame
|
|
130
|
-
* the server sent after it is handled; the returned promise settles only
|
|
131
|
-
* after more microtasks, and a client on Node can handle several frames in
|
|
132
|
-
* between. What must follow reply order goes here: an optimistic layer
|
|
133
|
-
* ends at the first newer frame after its call's reply.
|
|
134
|
-
*/
|
|
135
|
-
readonly onReply?: (result: CallResult) => void;
|
|
136
|
-
}
|
|
137
|
-
/** What a call resolves with: the data, or "not modified" when the `v` it sent is current. */
|
|
138
|
-
type CallResult<Output = unknown> = CallSuccess<Output> | CallNotModified;
|
|
139
|
-
/** True when the server answered that the caller's version is current. */
|
|
140
|
-
declare function isNotModified(result: CallResult): result is CallNotModified;
|
|
141
|
-
/**
|
|
142
|
-
* True when `error` leaves a call's outcome unknown: a `TIMEOUT` (the
|
|
143
|
-
* server may still be running it, or ran it and the answer was lost), or the
|
|
144
|
-
* `INTERNAL` of a call whose connection dropped after it was sent. The write
|
|
145
|
-
* may have been made: before sending it again, make sure the call is
|
|
146
|
-
* idempotent (a create that carries an id the client made, which the server
|
|
147
|
-
* keeps, fails `CONFLICT` the second time instead of writing a second row).
|
|
148
|
-
* False for a refusal, and for a call that was never sent.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* onError: (error) => setStatus(isUnknownOutcome(error) ? "checking" : "failed")
|
|
152
|
-
*/
|
|
153
|
-
declare function isUnknownOutcome(error: unknown): boolean;
|
|
154
|
-
/**
|
|
155
|
-
* Calls `request.method` of `request.service` over `connection`. Resolves
|
|
156
|
-
* with `{ ok: true, d, v? }`, or `{ ok: true, nm: true, v }` when the `v` it
|
|
157
|
-
* sent is current; rejects with a `QuickdrawError` (see the top of this file
|
|
158
|
-
* for which code when).
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* const reply = await call(connection, { service: "taskService", method: "get", input: { id } });
|
|
162
|
-
* const task = isNotModified(reply) ? cached : reply.d;
|
|
163
|
-
*/
|
|
164
|
-
declare function call<Output = unknown>(connection: QuickdrawConnection, request: CallRequest): Promise<CallResult<Output>>;
|
|
165
|
-
/**
|
|
166
|
-
* Calls a method and resolves with its data. For a caller that sends no
|
|
167
|
-
* version, which is never answered "not modified".
|
|
168
|
-
*/
|
|
169
|
-
declare function callData<Output = unknown>(connection: QuickdrawConnection, request: Omit<CallRequest, "v">): Promise<Output>;
|
|
170
|
-
/**
|
|
171
|
-
* The default `retry` of query hooks: one more attempt after an `INTERNAL`
|
|
172
|
-
* error, which includes a dropped connection, or an error that is not a
|
|
173
|
-
* `QuickdrawError`; none for any other code. A `TIMEOUT` is not retried,
|
|
174
|
-
* because the server may still be running the call, and `RATE_LIMITED`
|
|
175
|
-
* waits for the backoff instead.
|
|
176
|
-
*/
|
|
177
|
-
declare function shouldRetry(failureCount: number, error: unknown): boolean;
|
|
178
|
-
|
|
179
|
-
/** The default `onProtocolMismatch`: reloads the page once per session and server protocol. */
|
|
180
|
-
declare function reloadOncePerSession(mismatch: ProtocolMismatch): void;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* A new id for a row the client creates and the server keeps: a version 4
|
|
184
|
-
* UUID, from `crypto.randomUUID()`, or from `crypto.getRandomValues()` where
|
|
185
|
-
* that is missing (a page over plain http, which browsers do not give
|
|
186
|
-
* `randomUUID`). Give it to an item an optimistic update adds and to the
|
|
187
|
-
* create's input, so the scope's next load can find the item after a lost
|
|
188
|
-
* answer and `retry()` cannot write twice. Throws a `TypeError` in a runtime
|
|
189
|
-
* without Web Crypto.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* create.mutate({ id: newId(), chatId, content });
|
|
193
|
-
*/
|
|
194
|
-
declare function newId(): string;
|
|
195
|
-
|
|
196
19
|
/** How long after a refetch further invalidations of the key are served together, by default. */
|
|
197
20
|
declare const DEFAULT_INVALIDATION_WINDOW_MS = 250;
|
|
198
21
|
/** The longest random delay of a refetch after a reconnect, by default. */
|
|
@@ -611,6 +434,8 @@ interface StreamTarget {
|
|
|
611
434
|
readonly stream: string;
|
|
612
435
|
/** True for a stream with one feed per scope value; false for a global stream. */
|
|
613
436
|
readonly scoped: boolean;
|
|
437
|
+
/** A host-served stream's room of each scope, whose host serves the feed; absent for the server's. */
|
|
438
|
+
readonly host?: (scope: string) => string | undefined;
|
|
614
439
|
}
|
|
615
440
|
/** What a feed shows: its items, oldest first, whether its seed is still to come, and why it failed. */
|
|
616
441
|
interface StreamState<Item = unknown> {
|
|
@@ -832,6 +657,15 @@ interface AdminQueryMember<Input, Output> {
|
|
|
832
657
|
call(input: Input, options?: QueryCallOptions): Promise<Output>;
|
|
833
658
|
key(input: Input): MethodQueryKey<Input>;
|
|
834
659
|
prefetch(queryClient: QueryClient, input: Input): Promise<void>;
|
|
660
|
+
/**
|
|
661
|
+
* Writes the cached result for `input`, as the typed client's `setData`
|
|
662
|
+
* does: `updater` is the new result, or a function of the cached one
|
|
663
|
+
* (`undefined` when nothing is cached; returning `undefined` writes
|
|
664
|
+
* nothing), and it returns what the cache then holds. The admin kit's
|
|
665
|
+
* reads are not live, so this is how a screen shows the row a write
|
|
666
|
+
* returned: `admin.adminGet?.setData({ id: row.id }, row)`.
|
|
667
|
+
*/
|
|
668
|
+
setData(input: Input, updater: Updater<Output | undefined, Output | undefined>): Output | undefined;
|
|
835
669
|
}
|
|
836
670
|
/** A mutation member of an admin screen: the typed client's, typed by field name. */
|
|
837
671
|
interface AdminMutationMember<Input, Output> {
|
|
@@ -926,7 +760,9 @@ interface QuickdrawStatus {
|
|
|
926
760
|
* `"disconnected"`, or `"refused"` after the handshake's error code
|
|
927
761
|
* `UNAUTHENTICATED` or `FORBIDDEN`): the hello, the grants and everything
|
|
928
762
|
* quickdraw cached are gone. Another protocol (`refusal.code`
|
|
929
|
-
* `"PROTOCOL_MISMATCH"`) keeps them
|
|
763
|
+
* `"PROTOCOL_MISMATCH"`) keeps them, and so does a server that could not
|
|
764
|
+
* check the credentials (`INTERNAL`: the connection stays `"connecting"`
|
|
765
|
+
* and connects again by itself). It stays true while the connection
|
|
930
766
|
* reconnects with the same credentials. Gate on it, not on `isConnected`;
|
|
931
767
|
* while it is false, a stopped `status` tells "signed out" from "not
|
|
932
768
|
* known yet".
|
|
@@ -934,8 +770,9 @@ interface QuickdrawStatus {
|
|
|
934
770
|
readonly isKnown: boolean;
|
|
935
771
|
/**
|
|
936
772
|
* True while the connection is connecting again after it was connected
|
|
937
|
-
* with its current credentials (the network dropped,
|
|
938
|
-
*
|
|
773
|
+
* with its current credentials (the network dropped, the server asked it
|
|
774
|
+
* to rotate, or the server could not authenticate a reconnect). What it
|
|
775
|
+
* showed stays meanwhile, and `userId` is kept.
|
|
939
776
|
*/
|
|
940
777
|
readonly reconnecting: boolean;
|
|
941
778
|
/** The server's `qd:hello` on the current credentials: its version, limits and who the socket acts for. */
|
|
@@ -988,4 +825,4 @@ declare function QuickdrawProvider<Contracts extends ContractMap>(props: Quickdr
|
|
|
988
825
|
*/
|
|
989
826
|
declare function useQuickdraw(): QuickdrawStatus;
|
|
990
827
|
|
|
991
|
-
export { type AdminKeysOf, type AdminListRequest, type AdminMutationMember, type AdminQueryMember, type AdminRow, type AdminScreen, type AdminServiceInfo, type AdminWriteData, type
|
|
828
|
+
export { type AdminKeysOf, type AdminListRequest, type AdminMutationMember, type AdminQueryMember, type AdminRow, type AdminScreen, type AdminServiceInfo, type AdminWriteData, type CacheSession, type CollectionController, type CollectionEntry, type CollectionHub, type CollectionItem, CollectionQueryKey, type CollectionShape, type CollectionState, type CollectionTarget, ConnectionAuth, ConnectionRefusal, ConnectionStatus, type CoordinatorOptions, DEFAULT_INVALIDATION_WINDOW_MS, type DeltaBatch, type DeltaOptions, type DeltaResult, type EntityEntry, type EntityStore, type EventBus, type EventHandler, type HelloChange, type IndexRow, type InvalidateOptions, type InvalidationCoordinator, type JoinMember, type JoinStatus, type KeptResult, type LiveData, MethodMutationOptions, MethodQueryKey, MethodQueryOptions, MutationCallOptions, PENDING_STREAM, type PageReply, type PresenceStore, QueryCallOptions, QuickdrawClient, QuickdrawConnection, QuickdrawConnectionOptions, QuickdrawProvider, type QuickdrawProviderProps, type QuickdrawStatus, RECONNECT_JITTER_MS, type ReconnectRefetchOptions, type ResumeReason, SEARCH_DEBOUNCE_MS, STREAM_DEFAULT_MAX, STREAM_MAX_ITEMS, type ScopeHolding, type ScopeOptions, type StreamState, type StreamStore, type StreamTarget, type UseAdminServicesOptions, type UseAdminServicesResult, type UseJoinOptions, type UseJoinResult, adminOf, applyDeltas as applyCollectionDeltas, applyFrames as applyCollectionFrames, applyItems as applyCollectionItems, applyKept as applyCollectionKept, applyPage as applyCollectionPage, applySnapshot as applyCollectionSnapshot, createInvalidationCoordinator, createQuickdrawClient, emptyCollection, feedKey, liveDataOf, refetchOnAccessChanges, sessionOf, useAdminServices, useJoin, usePresence, useQuickdraw };
|
package/dist/client/index.js
CHANGED
|
@@ -2,19 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
QuickdrawProvider,
|
|
4
4
|
SEARCH_DEBOUNCE_MS,
|
|
5
|
-
call,
|
|
6
|
-
callData,
|
|
7
5
|
createQuickdrawClient,
|
|
8
|
-
isNotModified,
|
|
9
|
-
isUnknownOutcome,
|
|
10
|
-
shouldRetry,
|
|
11
6
|
useLiveData,
|
|
12
7
|
useQuickdraw
|
|
13
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-NZHA4TZD.js";
|
|
14
9
|
import {
|
|
15
|
-
DEFAULT_BACKOFF_MS,
|
|
16
10
|
DEFAULT_INVALIDATION_WINDOW_MS,
|
|
17
|
-
DEFAULT_SUBSCRIPTION_LANE,
|
|
18
11
|
PENDING_STREAM,
|
|
19
12
|
RECONNECT_JITTER_MS,
|
|
20
13
|
STREAM_DEFAULT_MAX,
|
|
@@ -27,28 +20,37 @@ import {
|
|
|
27
20
|
applyPage,
|
|
28
21
|
applySnapshot,
|
|
29
22
|
createInvalidationCoordinator,
|
|
30
|
-
createQuickdrawConnection,
|
|
31
23
|
emptyCollection,
|
|
32
24
|
feedKey,
|
|
33
25
|
liveDataOf,
|
|
34
26
|
overlaysOf,
|
|
35
27
|
refetchOnAccessChanges,
|
|
36
|
-
reloadOncePerSession,
|
|
37
|
-
retryAfterOf,
|
|
38
28
|
serverStateOf,
|
|
39
29
|
sessionOf,
|
|
40
30
|
useAdminServices,
|
|
41
31
|
useConnectionState,
|
|
42
32
|
useQuickdrawContext
|
|
43
|
-
} from "../chunk-
|
|
44
|
-
import "../chunk-
|
|
45
|
-
import "../chunk-753VJIUP.js";
|
|
46
|
-
import "../chunk-5CGO426C.js";
|
|
33
|
+
} from "../chunk-64I6MYBC.js";
|
|
34
|
+
import "../chunk-XD7SRDUY.js";
|
|
47
35
|
import "../chunk-4D2DOGAW.js";
|
|
48
36
|
import "../chunk-AK23XSWD.js";
|
|
49
|
-
import "../chunk-47AEXVDM.js";
|
|
50
|
-
import "../chunk-Z2LZ7IZ7.js";
|
|
51
37
|
import "../chunk-DKE6QO26.js";
|
|
38
|
+
import {
|
|
39
|
+
authProviders,
|
|
40
|
+
clearAuthToken,
|
|
41
|
+
defineHost,
|
|
42
|
+
getAuthToken,
|
|
43
|
+
newId,
|
|
44
|
+
setAuthToken,
|
|
45
|
+
signInUrl,
|
|
46
|
+
signOut,
|
|
47
|
+
signOutEverywhere
|
|
48
|
+
} from "../chunk-Z7I6SONO.js";
|
|
49
|
+
import {
|
|
50
|
+
DEFAULT_ICE_SERVERS,
|
|
51
|
+
createPeerLink,
|
|
52
|
+
onPeerRequest
|
|
53
|
+
} from "../chunk-DNP65TD5.js";
|
|
52
54
|
import {
|
|
53
55
|
buildBreadcrumbs,
|
|
54
56
|
createServerCaller,
|
|
@@ -62,7 +64,24 @@ import {
|
|
|
62
64
|
parseJWTPayload,
|
|
63
65
|
routeRequiresAuth,
|
|
64
66
|
truncate
|
|
65
|
-
} from "../chunk-
|
|
67
|
+
} from "../chunk-CYE4UBOB.js";
|
|
68
|
+
import "../chunk-ASAMUGHG.js";
|
|
69
|
+
import {
|
|
70
|
+
call,
|
|
71
|
+
callData,
|
|
72
|
+
isNotModified,
|
|
73
|
+
isUnknownOutcome,
|
|
74
|
+
shouldRetry
|
|
75
|
+
} from "../chunk-NX2V6SIL.js";
|
|
76
|
+
import {
|
|
77
|
+
DEFAULT_BACKOFF_MS,
|
|
78
|
+
DEFAULT_SUBSCRIPTION_LANE,
|
|
79
|
+
createQuickdrawConnection,
|
|
80
|
+
hostOf,
|
|
81
|
+
onHostChange,
|
|
82
|
+
reloadOncePerSession,
|
|
83
|
+
retryAfterOf
|
|
84
|
+
} from "../chunk-STH5DLQP.js";
|
|
66
85
|
import {
|
|
67
86
|
KEY_ROOT,
|
|
68
87
|
collectionKey,
|
|
@@ -70,206 +89,20 @@ import {
|
|
|
70
89
|
methodKey,
|
|
71
90
|
methodKeyPrefix,
|
|
72
91
|
serviceKeyPrefix
|
|
73
|
-
} from "../chunk-
|
|
92
|
+
} from "../chunk-IIQ3WMJK.js";
|
|
93
|
+
import "../chunk-7473HK24.js";
|
|
94
|
+
import "../chunk-2FDSKLBO.js";
|
|
95
|
+
import "../chunk-MPQAT55F.js";
|
|
96
|
+
import "../chunk-A2RBQD66.js";
|
|
97
|
+
import "../chunk-X4ZU4QH5.js";
|
|
98
|
+
import "../chunk-GYLWEJHW.js";
|
|
99
|
+
import "../chunk-47AEXVDM.js";
|
|
100
|
+
import "../chunk-SN3OZVEQ.js";
|
|
101
|
+
import "../chunk-7Y5ROPXL.js";
|
|
74
102
|
import {
|
|
75
|
-
QuickdrawError
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} from "../chunk-4YO5H5ON.js";
|
|
79
|
-
|
|
80
|
-
// src/client/auth.ts
|
|
81
|
-
var AUTH_TOKEN_KEY = "auth_token";
|
|
82
|
-
var DEFAULT_API_URL = "http://localhost:4000";
|
|
83
|
-
var memoryToken = null;
|
|
84
|
-
function onClient() {
|
|
85
|
-
return typeof window !== "undefined";
|
|
86
|
-
}
|
|
87
|
-
function storedToken() {
|
|
88
|
-
try {
|
|
89
|
-
return globalThis.localStorage.getItem(AUTH_TOKEN_KEY);
|
|
90
|
-
} catch {
|
|
91
|
-
return void 0;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function announce() {
|
|
95
|
-
if (typeof window.dispatchEvent === "function" && typeof Event === "function") {
|
|
96
|
-
window.dispatchEvent(new Event("auth-token-changed"));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function apiUrlOf(apiUrl) {
|
|
100
|
-
if (apiUrl !== void 0) {
|
|
101
|
-
return apiUrl;
|
|
102
|
-
}
|
|
103
|
-
try {
|
|
104
|
-
return process.env.NEXT_PUBLIC_API_URL ?? DEFAULT_API_URL;
|
|
105
|
-
} catch {
|
|
106
|
-
return DEFAULT_API_URL;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function getAuthToken() {
|
|
110
|
-
if (!onClient()) return null;
|
|
111
|
-
const stored = storedToken();
|
|
112
|
-
return stored === void 0 ? memoryToken : stored;
|
|
113
|
-
}
|
|
114
|
-
function setAuthToken(token) {
|
|
115
|
-
if (!onClient()) return;
|
|
116
|
-
memoryToken = token;
|
|
117
|
-
try {
|
|
118
|
-
globalThis.localStorage.setItem(AUTH_TOKEN_KEY, token);
|
|
119
|
-
} catch {
|
|
120
|
-
}
|
|
121
|
-
announce();
|
|
122
|
-
}
|
|
123
|
-
function clearAuthToken() {
|
|
124
|
-
if (!onClient()) return;
|
|
125
|
-
memoryToken = null;
|
|
126
|
-
try {
|
|
127
|
-
globalThis.localStorage.removeItem(AUTH_TOKEN_KEY);
|
|
128
|
-
} catch {
|
|
129
|
-
}
|
|
130
|
-
announce();
|
|
131
|
-
}
|
|
132
|
-
var PROVIDER_ID = /^[a-z0-9][a-z0-9-]*$/;
|
|
133
|
-
function routesUrl(owner, target) {
|
|
134
|
-
const base = apiUrlOf(target.apiUrl).replace(/\/+$/, "");
|
|
135
|
-
const path = target.basePath ?? "/auth";
|
|
136
|
-
if (typeof path !== "string" || !path.startsWith("/")) {
|
|
137
|
-
throw new TypeError(`${owner}: basePath must start with "/", as createAuthRoutes takes it`);
|
|
138
|
-
}
|
|
139
|
-
return `${base}${path.replace(/\/+$/, "")}`;
|
|
140
|
-
}
|
|
141
|
-
function pageOrigin() {
|
|
142
|
-
try {
|
|
143
|
-
const origin = globalThis.location?.origin;
|
|
144
|
-
return typeof origin === "string" && origin !== "null" ? origin : void 0;
|
|
145
|
-
} catch {
|
|
146
|
-
return void 0;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function signInUrl(provider, options = {}) {
|
|
150
|
-
if (typeof provider !== "string" || !PROVIDER_ID.test(provider)) {
|
|
151
|
-
throw new TypeError(
|
|
152
|
-
`signInUrl: a provider id is lowercase letters, digits and hyphens; got ${String(provider)}`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
const url = new URL(`${routesUrl("signInUrl", options)}/${provider}/start`);
|
|
156
|
-
const returnTo = options.returnTo ?? pageOrigin();
|
|
157
|
-
if (returnTo !== void 0) {
|
|
158
|
-
url.searchParams.set("returnTo", returnTo);
|
|
159
|
-
}
|
|
160
|
-
return url.toString();
|
|
161
|
-
}
|
|
162
|
-
async function refusalOf(response) {
|
|
163
|
-
let body;
|
|
164
|
-
try {
|
|
165
|
-
body = await response.json();
|
|
166
|
-
} catch {
|
|
167
|
-
body = void 0;
|
|
168
|
-
}
|
|
169
|
-
const code = isRecord(body) && isErrorCode(body.error) ? body.error : void 0;
|
|
170
|
-
const message = isRecord(body) && typeof body.message === "string" ? body.message : `The auth route answered ${String(response.status)}`;
|
|
171
|
-
if (code !== void 0) {
|
|
172
|
-
return new QuickdrawError(code, message);
|
|
173
|
-
}
|
|
174
|
-
return new QuickdrawError(response.status === 429 ? "RATE_LIMITED" : "INTERNAL", message);
|
|
175
|
-
}
|
|
176
|
-
async function postRoute(owner, route, target) {
|
|
177
|
-
const url = `${routesUrl(owner, target)}${route}`;
|
|
178
|
-
const token = getAuthToken();
|
|
179
|
-
let response;
|
|
180
|
-
try {
|
|
181
|
-
response = await fetch(url, {
|
|
182
|
-
method: "POST",
|
|
183
|
-
credentials: "include",
|
|
184
|
-
headers: {
|
|
185
|
-
"Content-Type": "application/json",
|
|
186
|
-
...token === null ? {} : { Authorization: `Bearer ${token}` }
|
|
187
|
-
},
|
|
188
|
-
body: "{}"
|
|
189
|
-
});
|
|
190
|
-
} catch (error) {
|
|
191
|
-
throw new QuickdrawError("INTERNAL", `${owner}: ${url} could not be reached`, {
|
|
192
|
-
cause: error instanceof Error ? error.message : String(error)
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
if (!response.ok) {
|
|
196
|
-
throw await refusalOf(response);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
async function signOut(options = {}) {
|
|
200
|
-
try {
|
|
201
|
-
await postRoute("signOut", "/logout", options);
|
|
202
|
-
} finally {
|
|
203
|
-
clearAuthToken();
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
var PROVIDER_KINDS = /* @__PURE__ */ new Set(["oauth", "mock", "guest"]);
|
|
207
|
-
function providerInfoOf(value) {
|
|
208
|
-
if (!isRecord(value) || typeof value.id !== "string" || !PROVIDER_ID.test(value.id)) {
|
|
209
|
-
return void 0;
|
|
210
|
-
}
|
|
211
|
-
const kind = PROVIDER_KINDS.has(value.kind) ? value.kind : void 0;
|
|
212
|
-
return kind === void 0 ? void 0 : { id: value.id, name: typeof value.name === "string" ? value.name : value.id, kind };
|
|
213
|
-
}
|
|
214
|
-
async function authProviders(options = {}) {
|
|
215
|
-
const url = `${routesUrl("authProviders", options)}/providers`;
|
|
216
|
-
let response;
|
|
217
|
-
try {
|
|
218
|
-
response = await fetch(url, { headers: { Accept: "application/json" } });
|
|
219
|
-
} catch (error) {
|
|
220
|
-
throw new QuickdrawError("INTERNAL", `authProviders: ${url} could not be reached`, {
|
|
221
|
-
cause: error instanceof Error ? error.message : String(error)
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
if (!response.ok) {
|
|
225
|
-
throw await refusalOf(response);
|
|
226
|
-
}
|
|
227
|
-
let body;
|
|
228
|
-
try {
|
|
229
|
-
body = await response.json();
|
|
230
|
-
} catch {
|
|
231
|
-
body = void 0;
|
|
232
|
-
}
|
|
233
|
-
if (!isRecord(body) || !Array.isArray(body.providers)) {
|
|
234
|
-
throw new QuickdrawError("INTERNAL", `authProviders: ${url} answered no list of providers`);
|
|
235
|
-
}
|
|
236
|
-
return body.providers.flatMap((entry) => {
|
|
237
|
-
const info = providerInfoOf(entry);
|
|
238
|
-
return info === void 0 ? [] : [info];
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
async function signOutEverywhere(options = {}) {
|
|
242
|
-
try {
|
|
243
|
-
await postRoute("signOutEverywhere", "/logout-all", options);
|
|
244
|
-
} finally {
|
|
245
|
-
clearAuthToken();
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// src/client/newId.ts
|
|
250
|
-
function uuidByte(byte, index) {
|
|
251
|
-
if (index === 6) {
|
|
252
|
-
return 64 + byte % 16;
|
|
253
|
-
}
|
|
254
|
-
return index === 8 ? 128 + byte % 64 : byte;
|
|
255
|
-
}
|
|
256
|
-
function uuidOf(bytes) {
|
|
257
|
-
const hex = Array.from(
|
|
258
|
-
bytes,
|
|
259
|
-
(byte, index) => uuidByte(byte, index).toString(16).padStart(2, "0")
|
|
260
|
-
).join("");
|
|
261
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
262
|
-
}
|
|
263
|
-
function newId() {
|
|
264
|
-
const { crypto } = globalThis;
|
|
265
|
-
if (typeof crypto?.randomUUID === "function") {
|
|
266
|
-
return crypto.randomUUID();
|
|
267
|
-
}
|
|
268
|
-
if (typeof crypto?.getRandomValues !== "function") {
|
|
269
|
-
throw new TypeError("newId: this runtime has no crypto.getRandomValues");
|
|
270
|
-
}
|
|
271
|
-
return uuidOf(crypto.getRandomValues(new Uint8Array(16)));
|
|
272
|
-
}
|
|
103
|
+
QuickdrawError
|
|
104
|
+
} from "../chunk-Q4OGQM5I.js";
|
|
105
|
+
import "../chunk-QSU47XEX.js";
|
|
273
106
|
|
|
274
107
|
// src/client/live/usePresence.ts
|
|
275
108
|
import { useCallback, useSyncExternalStore } from "react";
|
|
@@ -415,6 +248,7 @@ function adminOf(client, key) {
|
|
|
415
248
|
}
|
|
416
249
|
export {
|
|
417
250
|
DEFAULT_BACKOFF_MS,
|
|
251
|
+
DEFAULT_ICE_SERVERS,
|
|
418
252
|
DEFAULT_INVALIDATION_WINDOW_MS,
|
|
419
253
|
DEFAULT_SUBSCRIPTION_LANE,
|
|
420
254
|
KEY_ROOT,
|
|
@@ -438,9 +272,11 @@ export {
|
|
|
438
272
|
clearAuthToken,
|
|
439
273
|
collectionKey,
|
|
440
274
|
createInvalidationCoordinator,
|
|
275
|
+
createPeerLink,
|
|
441
276
|
createQuickdrawClient,
|
|
442
277
|
createQuickdrawConnection,
|
|
443
278
|
createServerCaller,
|
|
279
|
+
defineHost,
|
|
444
280
|
emptyCollection,
|
|
445
281
|
entityKey,
|
|
446
282
|
feedKey,
|
|
@@ -452,12 +288,15 @@ export {
|
|
|
452
288
|
formatNumber,
|
|
453
289
|
formatPercent,
|
|
454
290
|
getAuthToken,
|
|
291
|
+
hostOf,
|
|
455
292
|
isNotModified,
|
|
456
293
|
isUnknownOutcome,
|
|
457
294
|
liveDataOf,
|
|
458
295
|
methodKey,
|
|
459
296
|
methodKeyPrefix,
|
|
460
297
|
newId,
|
|
298
|
+
onHostChange,
|
|
299
|
+
onPeerRequest,
|
|
461
300
|
overlaysOf,
|
|
462
301
|
parseJWTPayload,
|
|
463
302
|
refetchOnAccessChanges,
|