@fitzzero/quickdraw-core 5.1.1 → 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.
Files changed (152) hide show
  1. package/README.md +1308 -219
  2. package/dist/{admin-DKwkIh5i.d.ts → admin-CS7JB_UH.d.ts} +2 -2
  3. package/dist/{adminSchemas-2DUA_hZ8.d.ts → adminSchemas-29cGgrg5.d.ts} +6 -4
  4. package/dist/{auth-BhWqdyb-.d.ts → auth-DtdYjrZ9.d.ts} +51 -21
  5. package/dist/{caller-CXTFswBO.d.ts → caller-BTwGl7vm.d.ts} +296 -33
  6. package/dist/chunk-2FDSKLBO.js +82 -0
  7. package/dist/chunk-2FDSKLBO.js.map +1 -0
  8. package/dist/{chunk-RT6OILOI.js → chunk-4D2DOGAW.js} +2 -14
  9. package/dist/chunk-4D2DOGAW.js.map +1 -0
  10. package/dist/{chunk-OECZPRPW.js → chunk-64I6MYBC.js} +162 -775
  11. package/dist/chunk-64I6MYBC.js.map +1 -0
  12. package/dist/chunk-7473HK24.js +17 -0
  13. package/dist/chunk-7473HK24.js.map +1 -0
  14. package/dist/chunk-7Y5ROPXL.js +33 -0
  15. package/dist/chunk-7Y5ROPXL.js.map +1 -0
  16. package/dist/chunk-A2RBQD66.js +7 -0
  17. package/dist/chunk-A2RBQD66.js.map +1 -0
  18. package/dist/chunk-AK23XSWD.js +16 -0
  19. package/dist/chunk-AK23XSWD.js.map +1 -0
  20. package/dist/chunk-ASAMUGHG.js +651 -0
  21. package/dist/chunk-ASAMUGHG.js.map +1 -0
  22. package/dist/{chunk-B2P7AZ25.js → chunk-CYE4UBOB.js} +6 -4
  23. package/dist/chunk-CYE4UBOB.js.map +1 -0
  24. package/dist/chunk-DKE6QO26.js +136 -0
  25. package/dist/chunk-DKE6QO26.js.map +1 -0
  26. package/dist/chunk-DNP65TD5.js +832 -0
  27. package/dist/chunk-DNP65TD5.js.map +1 -0
  28. package/dist/{chunk-H23KEFBA.js → chunk-DUBU3BB3.js} +30 -1
  29. package/dist/chunk-DUBU3BB3.js.map +1 -0
  30. package/dist/chunk-GYLWEJHW.js +19 -0
  31. package/dist/chunk-GYLWEJHW.js.map +1 -0
  32. package/dist/{chunk-SHEGLZEP.js → chunk-I3JCFS7H.js} +34 -13
  33. package/dist/chunk-I3JCFS7H.js.map +1 -0
  34. package/dist/{chunk-X5CWPX7H.js → chunk-IIQ3WMJK.js} +13 -2
  35. package/dist/chunk-IIQ3WMJK.js.map +1 -0
  36. package/dist/{chunk-RZTP4IEW.js → chunk-JVTONQFI.js} +6339 -4226
  37. package/dist/chunk-JVTONQFI.js.map +1 -0
  38. package/dist/{chunk-QEKVYG5F.js → chunk-KKQANRLG.js} +2 -2
  39. package/dist/chunk-KKQANRLG.js.map +1 -0
  40. package/dist/{chunk-CDKG4TFA.js → chunk-MPQAT55F.js} +38 -205
  41. package/dist/chunk-MPQAT55F.js.map +1 -0
  42. package/dist/chunk-NO4M6PO5.js +101 -0
  43. package/dist/chunk-NO4M6PO5.js.map +1 -0
  44. package/dist/{chunk-TBMKJ26R.js → chunk-NW6U45HX.js} +3 -1
  45. package/dist/chunk-NW6U45HX.js.map +1 -0
  46. package/dist/chunk-NX2V6SIL.js +202 -0
  47. package/dist/chunk-NX2V6SIL.js.map +1 -0
  48. package/dist/{chunk-ZIVPHYRG.js → chunk-NZHA4TZD.js} +72 -175
  49. package/dist/chunk-NZHA4TZD.js.map +1 -0
  50. package/dist/{chunk-2PWMUVC7.js → chunk-OCZJ4EYV.js} +518 -27
  51. package/dist/chunk-OCZJ4EYV.js.map +1 -0
  52. package/dist/{chunk-REX5YPHX.js → chunk-PHCURHC7.js} +76 -21
  53. package/dist/chunk-PHCURHC7.js.map +1 -0
  54. package/dist/{chunk-4YO5H5ON.js → chunk-Q4OGQM5I.js} +4 -10
  55. package/dist/chunk-Q4OGQM5I.js.map +1 -0
  56. package/dist/chunk-QSU47XEX.js +13 -0
  57. package/dist/chunk-QSU47XEX.js.map +1 -0
  58. package/dist/{chunk-DD4SKCNO.js → chunk-RZXJTDH5.js} +13 -2
  59. package/dist/chunk-RZXJTDH5.js.map +1 -0
  60. package/dist/{chunk-Z2LZ7IZ7.js → chunk-SN3OZVEQ.js} +5 -31
  61. package/dist/chunk-SN3OZVEQ.js.map +1 -0
  62. package/dist/{chunk-4DIQHASK.js → chunk-SQ5VUG77.js} +28 -8
  63. package/dist/chunk-SQ5VUG77.js.map +1 -0
  64. package/dist/chunk-STH5DLQP.js +1192 -0
  65. package/dist/chunk-STH5DLQP.js.map +1 -0
  66. package/dist/{chunk-QCHKWIRS.js → chunk-VZFJTKIW.js} +13 -13
  67. package/dist/{chunk-QCHKWIRS.js.map → chunk-VZFJTKIW.js.map} +1 -1
  68. package/dist/{chunk-VSQBHPWH.js → chunk-X4ZU4QH5.js} +54 -22
  69. package/dist/chunk-X4ZU4QH5.js.map +1 -0
  70. package/dist/chunk-XD7SRDUY.js +188 -0
  71. package/dist/chunk-XD7SRDUY.js.map +1 -0
  72. package/dist/chunk-XH2IZVLT.js +62 -0
  73. package/dist/chunk-XH2IZVLT.js.map +1 -0
  74. package/dist/chunk-Z7I6SONO.js +825 -0
  75. package/dist/chunk-Z7I6SONO.js.map +1 -0
  76. package/dist/cli/quickdraw-docs.js +132 -112
  77. package/dist/cli/quickdraw-docs.js.map +1 -1
  78. package/dist/client/core.d.ts +387 -0
  79. package/dist/client/core.js +109 -0
  80. package/dist/client/index.d.ts +52 -203
  81. package/dist/client/index.js +59 -218
  82. package/dist/client/index.js.map +1 -1
  83. package/dist/{clientTypes-Bc-G8n-U.d.ts → clientTypes-CUUNJwWs.d.ts} +3 -3
  84. package/dist/{connection-Cr1BU07W.d.ts → connection-2EeQ_Et0.d.ts} +22 -11
  85. package/dist/{createServer-CP9eDHZZ.d.ts → createServer-Bx5HOcYK.d.ts} +67 -17
  86. package/dist/{createTestApp-UKVGEmOf.d.ts → createTestApp-DAMANT79.d.ts} +46 -13
  87. package/dist/{envelope-Cp3YcVxC.d.ts → envelope-BMBaxppV.d.ts} +216 -10
  88. package/dist/{http-Djj2Inuu.d.ts → http-YzLAar3w.d.ts} +76 -60
  89. package/dist/index.d.ts +8 -7
  90. package/dist/index.js +82 -25
  91. package/dist/index.js.map +1 -1
  92. package/dist/{infer-Teo1xpsd.d.ts → infer-Br62cnyW.d.ts} +82 -11
  93. package/dist/logger-Yz93KzdV.d.ts +30 -0
  94. package/dist/{metrics-BdBu5o8G.d.ts → metrics-CTVpw0gu.d.ts} +2 -2
  95. package/dist/origins-kvpxnVcW.d.ts +8 -0
  96. package/dist/parser.js +2 -1
  97. package/dist/prisma/index.d.ts +14 -7
  98. package/dist/prisma/index.js +279 -70
  99. package/dist/prisma/index.js.map +1 -1
  100. package/dist/{rateLimit-ZMIZJUZF.js → rateLimit-5RKBFLUR.js} +2 -2
  101. package/dist/rateLimit-5RKBFLUR.js.map +1 -0
  102. package/dist/remote-N7OUAGOW.js +15 -0
  103. package/dist/remote-N7OUAGOW.js.map +1 -0
  104. package/dist/server/auth/index.d.ts +82 -33
  105. package/dist/server/auth/index.js +277 -270
  106. package/dist/server/auth/index.js.map +1 -1
  107. package/dist/server/express/index.d.ts +9 -2
  108. package/dist/server/express/index.js +1 -1
  109. package/dist/server/index.d.ts +268 -84
  110. package/dist/server/index.js +664 -418
  111. package/dist/server/index.js.map +1 -1
  112. package/dist/server/mcp/index.d.ts +89 -27
  113. package/dist/server/mcp/index.js +281 -62
  114. package/dist/server/mcp/index.js.map +1 -1
  115. package/dist/server/otel.d.ts +3 -3
  116. package/dist/{sharing-DVa8W-yR.d.ts → sharing-BrsmlDv_.d.ts} +3 -3
  117. package/dist/testing/client.d.ts +14 -14
  118. package/dist/testing/client.js +19 -10
  119. package/dist/testing/client.js.map +1 -1
  120. package/dist/testing/index.d.ts +50 -13
  121. package/dist/testing/index.js +113 -21
  122. package/dist/testing/index.js.map +1 -1
  123. package/dist/testing/mock.d.ts +5 -5
  124. package/dist/testing/mock.js +17 -9
  125. package/dist/tracked-BR5b2O-U.d.ts +43 -0
  126. package/dist/{types-Cu0vmx7c.d.ts → types-CLRCQGnO.d.ts} +4 -3
  127. package/dist/types-tMagHbjy.d.ts +151 -0
  128. package/dist/utils/index.d.ts +16 -4
  129. package/dist/utils/index.js +6 -3
  130. package/package.json +5 -1
  131. package/dist/chunk-2PWMUVC7.js.map +0 -1
  132. package/dist/chunk-4DIQHASK.js.map +0 -1
  133. package/dist/chunk-4YO5H5ON.js.map +0 -1
  134. package/dist/chunk-B2P7AZ25.js.map +0 -1
  135. package/dist/chunk-CDKG4TFA.js.map +0 -1
  136. package/dist/chunk-DD4SKCNO.js.map +0 -1
  137. package/dist/chunk-H23KEFBA.js.map +0 -1
  138. package/dist/chunk-OECZPRPW.js.map +0 -1
  139. package/dist/chunk-QEKVYG5F.js.map +0 -1
  140. package/dist/chunk-REX5YPHX.js.map +0 -1
  141. package/dist/chunk-RT6OILOI.js.map +0 -1
  142. package/dist/chunk-RZTP4IEW.js.map +0 -1
  143. package/dist/chunk-SHEGLZEP.js.map +0 -1
  144. package/dist/chunk-TBMKJ26R.js.map +0 -1
  145. package/dist/chunk-VSQBHPWH.js.map +0 -1
  146. package/dist/chunk-X5CWPX7H.js.map +0 -1
  147. package/dist/chunk-YSWH776Y.js +0 -13
  148. package/dist/chunk-YSWH776Y.js.map +0 -1
  149. package/dist/chunk-Z2LZ7IZ7.js.map +0 -1
  150. package/dist/chunk-ZIVPHYRG.js.map +0 -1
  151. package/dist/logger-BY28acW-.d.ts +0 -16
  152. /package/dist/{rateLimit-ZMIZJUZF.js.map → client/core.js.map} +0 -0
@@ -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
- import { Q as QuickdrawConnection, a as QuickdrawConnectionOptions, C as ConnectionAuth, b as ConnectionStatus, c as ConnectionRefusal } from '../connection-Cr1BU07W.js';
5
- 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-Cr1BU07W.js';
6
- import { k as MethodKind, O as OrderBy, C as CollectionDef, ae as ContractMap, A as AccessLevel, z as SortDirection } from '../infer-Teo1xpsd.js';
7
- import { ad as Version, y as CallSuccess, w as CallNotModified, n as ProtocolMismatch, a5 as Revision, F as CollectionDelta, G as CollectionFrame, a7 as RevokeReason, k as HelloFrame } from '../envelope-Cp3YcVxC.js';
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-Bc-G8n-U.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-Bc-G8n-U.js';
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-2DUA_hZ8.js';
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. */
@@ -270,9 +93,12 @@ interface InvalidationCoordinator {
270
93
  */
271
94
  declare function createInvalidationCoordinator(queryClient: QueryClient, options?: CoordinatorOptions): InvalidationCoordinator;
272
95
 
273
- /** What a new `qd:hello` meant for the cache. */
96
+ /** What a new `qd:hello`, or the end of the session, meant for the cache. */
274
97
  interface HelloChange {
275
- /** It names another user than the cache was loaded for: the cache was emptied. */
98
+ /**
99
+ * It names another user than the cache was loaded for, or the server ended
100
+ * the session: the cache was emptied.
101
+ */
276
102
  readonly switched: boolean;
277
103
  /** No hello was held before it: the connection's first, or the first on new credentials. */
278
104
  readonly first: boolean;
@@ -608,6 +434,8 @@ interface StreamTarget {
608
434
  readonly stream: string;
609
435
  /** True for a stream with one feed per scope value; false for a global stream. */
610
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;
611
439
  }
612
440
  /** What a feed shows: its items, oldest first, whether its seed is still to come, and why it failed. */
613
441
  interface StreamState<Item = unknown> {
@@ -829,6 +657,15 @@ interface AdminQueryMember<Input, Output> {
829
657
  call(input: Input, options?: QueryCallOptions): Promise<Output>;
830
658
  key(input: Input): MethodQueryKey<Input>;
831
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;
832
669
  }
833
670
  /** A mutation member of an admin screen: the typed client's, typed by field name. */
834
671
  interface AdminMutationMember<Input, Output> {
@@ -917,29 +754,40 @@ interface QuickdrawStatus {
917
754
  readonly isConnected: boolean;
918
755
  /**
919
756
  * True once the server's hello on the current credentials has arrived:
920
- * `userId` is then final, `null` meaning anonymous. False before it, and
921
- * again from new credentials (`auth` changed) until their hello; it stays
922
- * true while the connection reconnects with the same credentials. Gate on
923
- * it, not on `isConnected`, to tell "signed out" from "not known yet".
757
+ * `userId` is then final, `null` meaning anonymous. False before it, again
758
+ * from new credentials (`auth` changed) until their hello, and again once
759
+ * the server ended the session or refused a connect for it (`status`
760
+ * `"disconnected"`, or `"refused"` after the handshake's error code
761
+ * `UNAUTHENTICATED` or `FORBIDDEN`): the hello, the grants and everything
762
+ * quickdraw cached are gone. Another protocol (`refusal.code`
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
766
+ * reconnects with the same credentials. Gate on it, not on `isConnected`;
767
+ * while it is false, a stopped `status` tells "signed out" from "not
768
+ * known yet".
924
769
  */
925
770
  readonly isKnown: boolean;
926
771
  /**
927
772
  * True while the connection is connecting again after it was connected
928
- * with its current credentials (the network dropped, or the server asked
929
- * it to rotate). What it showed stays meanwhile, and `userId` is kept.
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.
930
776
  */
931
777
  readonly reconnecting: boolean;
932
778
  /** The server's `qd:hello` on the current credentials: its version, limits and who the socket acts for. */
933
779
  readonly hello: HelloFrame | null;
934
780
  /**
935
781
  * The user the connection acts for, from the server's hello: `null` while
936
- * anonymous, and before the hello on the current credentials arrives
937
- * (`isKnown` tells the two apart).
782
+ * anonymous, before the hello on the current credentials arrives, and
783
+ * once the server ended the session (`isKnown` and `status` tell them
784
+ * apart).
938
785
  */
939
786
  readonly userId: string | null;
940
787
  /**
941
788
  * The user's service grants: from the server's hello, then from each
942
- * `qd:access` push; `null` before the hello on the current credentials.
789
+ * `qd:access` push; `null` before the hello on the current credentials,
790
+ * and once the server ended the session.
943
791
  */
944
792
  readonly serviceAccess: Readonly<Record<string, AccessLevel>> | null;
945
793
  /** Why the server refused the connection, while `status` is `refused`. */
@@ -970,10 +818,11 @@ declare function QuickdrawProvider<Contracts extends ContractMap>(props: Quickdr
970
818
  * `RATE_LIMITED`.
971
819
  *
972
820
  * @example
973
- * const { isKnown, userId } = useQuickdraw();
974
- * if (!isKnown) return <Spinner />;
821
+ * const { status, isKnown, userId } = useQuickdraw();
822
+ * // stopped with nobody known: the server ended or refused the session
823
+ * if (!isKnown) return status === "disconnected" || status === "refused" ? <SignIn /> : <Spinner />;
975
824
  * return userId === null ? <SignIn /> : <App />;
976
825
  */
977
826
  declare function useQuickdraw(): QuickdrawStatus;
978
827
 
979
- export { type AdminKeysOf, type AdminListRequest, type AdminMutationMember, type AdminQueryMember, type AdminRow, type AdminScreen, type AdminServiceInfo, type AdminWriteData, type AuthProviderInfo, type AuthRoutesTarget, type CacheSession, type CallRequest, type CallResult, 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 SignInUrlOptions, 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, authProviders, call, callData, clearAuthToken, createInvalidationCoordinator, createQuickdrawClient, emptyCollection, feedKey, getAuthToken, isNotModified, isUnknownOutcome, liveDataOf, newId, refetchOnAccessChanges, reloadOncePerSession, sessionOf, setAuthToken, shouldRetry, signInUrl, signOut, signOutEverywhere, useAdminServices, useJoin, usePresence, useQuickdraw };
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 };
@@ -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-ZIVPHYRG.js";
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,26 +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-OECZPRPW.js";
44
- import "../chunk-CDKG4TFA.js";
45
- import "../chunk-VSQBHPWH.js";
46
- import "../chunk-RT6OILOI.js";
47
- import "../chunk-47AEXVDM.js";
48
- import "../chunk-Z2LZ7IZ7.js";
49
- import "../chunk-YSWH776Y.js";
33
+ } from "../chunk-64I6MYBC.js";
34
+ import "../chunk-XD7SRDUY.js";
35
+ import "../chunk-4D2DOGAW.js";
36
+ import "../chunk-AK23XSWD.js";
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";
50
54
  import {
51
55
  buildBreadcrumbs,
52
56
  createServerCaller,
@@ -60,7 +64,24 @@ import {
60
64
  parseJWTPayload,
61
65
  routeRequiresAuth,
62
66
  truncate
63
- } from "../chunk-B2P7AZ25.js";
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";
64
85
  import {
65
86
  KEY_ROOT,
66
87
  collectionKey,
@@ -68,206 +89,20 @@ import {
68
89
  methodKey,
69
90
  methodKeyPrefix,
70
91
  serviceKeyPrefix
71
- } from "../chunk-X5CWPX7H.js";
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";
72
102
  import {
73
- QuickdrawError,
74
- isErrorCode,
75
- isRecord
76
- } from "../chunk-4YO5H5ON.js";
77
-
78
- // src/client/auth.ts
79
- var AUTH_TOKEN_KEY = "auth_token";
80
- var DEFAULT_API_URL = "http://localhost:4000";
81
- var memoryToken = null;
82
- function onClient() {
83
- return typeof window !== "undefined";
84
- }
85
- function storedToken() {
86
- try {
87
- return globalThis.localStorage.getItem(AUTH_TOKEN_KEY);
88
- } catch {
89
- return void 0;
90
- }
91
- }
92
- function announce() {
93
- if (typeof window.dispatchEvent === "function" && typeof Event === "function") {
94
- window.dispatchEvent(new Event("auth-token-changed"));
95
- }
96
- }
97
- function apiUrlOf(apiUrl) {
98
- if (apiUrl !== void 0) {
99
- return apiUrl;
100
- }
101
- try {
102
- return process.env.NEXT_PUBLIC_API_URL ?? DEFAULT_API_URL;
103
- } catch {
104
- return DEFAULT_API_URL;
105
- }
106
- }
107
- function getAuthToken() {
108
- if (!onClient()) return null;
109
- const stored = storedToken();
110
- return stored === void 0 ? memoryToken : stored;
111
- }
112
- function setAuthToken(token) {
113
- if (!onClient()) return;
114
- memoryToken = token;
115
- try {
116
- globalThis.localStorage.setItem(AUTH_TOKEN_KEY, token);
117
- } catch {
118
- }
119
- announce();
120
- }
121
- function clearAuthToken() {
122
- if (!onClient()) return;
123
- memoryToken = null;
124
- try {
125
- globalThis.localStorage.removeItem(AUTH_TOKEN_KEY);
126
- } catch {
127
- }
128
- announce();
129
- }
130
- var PROVIDER_ID = /^[a-z0-9][a-z0-9-]*$/;
131
- function routesUrl(owner, target) {
132
- const base = apiUrlOf(target.apiUrl).replace(/\/+$/, "");
133
- const path = target.basePath ?? "/auth";
134
- if (typeof path !== "string" || !path.startsWith("/")) {
135
- throw new TypeError(`${owner}: basePath must start with "/", as createAuthRoutes takes it`);
136
- }
137
- return `${base}${path.replace(/\/+$/, "")}`;
138
- }
139
- function pageOrigin() {
140
- try {
141
- const origin = globalThis.location?.origin;
142
- return typeof origin === "string" && origin !== "null" ? origin : void 0;
143
- } catch {
144
- return void 0;
145
- }
146
- }
147
- function signInUrl(provider, options = {}) {
148
- if (typeof provider !== "string" || !PROVIDER_ID.test(provider)) {
149
- throw new TypeError(
150
- `signInUrl: a provider id is lowercase letters, digits and hyphens; got ${String(provider)}`
151
- );
152
- }
153
- const url = new URL(`${routesUrl("signInUrl", options)}/${provider}/start`);
154
- const returnTo = options.returnTo ?? pageOrigin();
155
- if (returnTo !== void 0) {
156
- url.searchParams.set("returnTo", returnTo);
157
- }
158
- return url.toString();
159
- }
160
- async function refusalOf(response) {
161
- let body;
162
- try {
163
- body = await response.json();
164
- } catch {
165
- body = void 0;
166
- }
167
- const code = isRecord(body) && isErrorCode(body.error) ? body.error : void 0;
168
- const message = isRecord(body) && typeof body.message === "string" ? body.message : `The auth route answered ${String(response.status)}`;
169
- if (code !== void 0) {
170
- return new QuickdrawError(code, message);
171
- }
172
- return new QuickdrawError(response.status === 429 ? "RATE_LIMITED" : "INTERNAL", message);
173
- }
174
- async function postRoute(owner, route, target) {
175
- const url = `${routesUrl(owner, target)}${route}`;
176
- const token = getAuthToken();
177
- let response;
178
- try {
179
- response = await fetch(url, {
180
- method: "POST",
181
- credentials: "include",
182
- headers: {
183
- "Content-Type": "application/json",
184
- ...token === null ? {} : { Authorization: `Bearer ${token}` }
185
- },
186
- body: "{}"
187
- });
188
- } catch (error) {
189
- throw new QuickdrawError("INTERNAL", `${owner}: ${url} could not be reached`, {
190
- cause: error instanceof Error ? error.message : String(error)
191
- });
192
- }
193
- if (!response.ok) {
194
- throw await refusalOf(response);
195
- }
196
- }
197
- async function signOut(options = {}) {
198
- try {
199
- await postRoute("signOut", "/logout", options);
200
- } finally {
201
- clearAuthToken();
202
- }
203
- }
204
- var PROVIDER_KINDS = /* @__PURE__ */ new Set(["oauth", "mock", "guest"]);
205
- function providerInfoOf(value) {
206
- if (!isRecord(value) || typeof value.id !== "string" || !PROVIDER_ID.test(value.id)) {
207
- return void 0;
208
- }
209
- const kind = PROVIDER_KINDS.has(value.kind) ? value.kind : void 0;
210
- return kind === void 0 ? void 0 : { id: value.id, name: typeof value.name === "string" ? value.name : value.id, kind };
211
- }
212
- async function authProviders(options = {}) {
213
- const url = `${routesUrl("authProviders", options)}/providers`;
214
- let response;
215
- try {
216
- response = await fetch(url, { headers: { Accept: "application/json" } });
217
- } catch (error) {
218
- throw new QuickdrawError("INTERNAL", `authProviders: ${url} could not be reached`, {
219
- cause: error instanceof Error ? error.message : String(error)
220
- });
221
- }
222
- if (!response.ok) {
223
- throw await refusalOf(response);
224
- }
225
- let body;
226
- try {
227
- body = await response.json();
228
- } catch {
229
- body = void 0;
230
- }
231
- if (!isRecord(body) || !Array.isArray(body.providers)) {
232
- throw new QuickdrawError("INTERNAL", `authProviders: ${url} answered no list of providers`);
233
- }
234
- return body.providers.flatMap((entry) => {
235
- const info = providerInfoOf(entry);
236
- return info === void 0 ? [] : [info];
237
- });
238
- }
239
- async function signOutEverywhere(options = {}) {
240
- try {
241
- await postRoute("signOutEverywhere", "/logout-all", options);
242
- } finally {
243
- clearAuthToken();
244
- }
245
- }
246
-
247
- // src/client/newId.ts
248
- function uuidByte(byte, index) {
249
- if (index === 6) {
250
- return 64 + byte % 16;
251
- }
252
- return index === 8 ? 128 + byte % 64 : byte;
253
- }
254
- function uuidOf(bytes) {
255
- const hex = Array.from(
256
- bytes,
257
- (byte, index) => uuidByte(byte, index).toString(16).padStart(2, "0")
258
- ).join("");
259
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
260
- }
261
- function newId() {
262
- const { crypto } = globalThis;
263
- if (typeof crypto?.randomUUID === "function") {
264
- return crypto.randomUUID();
265
- }
266
- if (typeof crypto?.getRandomValues !== "function") {
267
- throw new TypeError("newId: this runtime has no crypto.getRandomValues");
268
- }
269
- return uuidOf(crypto.getRandomValues(new Uint8Array(16)));
270
- }
103
+ QuickdrawError
104
+ } from "../chunk-Q4OGQM5I.js";
105
+ import "../chunk-QSU47XEX.js";
271
106
 
272
107
  // src/client/live/usePresence.ts
273
108
  import { useCallback, useSyncExternalStore } from "react";
@@ -413,6 +248,7 @@ function adminOf(client, key) {
413
248
  }
414
249
  export {
415
250
  DEFAULT_BACKOFF_MS,
251
+ DEFAULT_ICE_SERVERS,
416
252
  DEFAULT_INVALIDATION_WINDOW_MS,
417
253
  DEFAULT_SUBSCRIPTION_LANE,
418
254
  KEY_ROOT,
@@ -436,9 +272,11 @@ export {
436
272
  clearAuthToken,
437
273
  collectionKey,
438
274
  createInvalidationCoordinator,
275
+ createPeerLink,
439
276
  createQuickdrawClient,
440
277
  createQuickdrawConnection,
441
278
  createServerCaller,
279
+ defineHost,
442
280
  emptyCollection,
443
281
  entityKey,
444
282
  feedKey,
@@ -450,12 +288,15 @@ export {
450
288
  formatNumber,
451
289
  formatPercent,
452
290
  getAuthToken,
291
+ hostOf,
453
292
  isNotModified,
454
293
  isUnknownOutcome,
455
294
  liveDataOf,
456
295
  methodKey,
457
296
  methodKeyPrefix,
458
297
  newId,
298
+ onHostChange,
299
+ onPeerRequest,
459
300
  overlaysOf,
460
301
  parseJWTPayload,
461
302
  refetchOnAccessChanges,