@liveblocks/core 3.24.4 → 3.25.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/index.d.ts CHANGED
@@ -7,6 +7,219 @@ import { JSONSchema7 } from 'json-schema';
7
7
  declare function detectDupes(pkgName: string, pkgVersion: string | false, // false if not built yet
8
8
  pkgFormat: string | false): void;
9
9
 
10
+ type Callback<T> = (event: T) => void;
11
+ type UnsubscribeCallback = () => void;
12
+ type Observable<T> = {
13
+ /**
14
+ * Register a callback function to be called whenever the event source emits
15
+ * an event.
16
+ */
17
+ subscribe(callback: Callback<T>): UnsubscribeCallback;
18
+ /**
19
+ * Register a one-time callback function to be called whenever the event
20
+ * source emits an event. After the event fires, the callback is
21
+ * auto-unsubscribed.
22
+ */
23
+ subscribeOnce(callback: Callback<T>): UnsubscribeCallback;
24
+ /**
25
+ * Returns a promise that will resolve when an event is emitted by this
26
+ * event source. Optionally, specify a predicate that has to match. The first
27
+ * event matching that predicate will then resolve the promise.
28
+ */
29
+ waitUntil(predicate?: (event: T) => boolean): Promise<T>;
30
+ };
31
+ type EventSource<T> = Observable<T> & {
32
+ /**
33
+ * Notify all subscribers about the event. Will return `false` if there
34
+ * weren't any subscribers at the time the .notify() was called, or `true` if
35
+ * there was at least one subscriber.
36
+ */
37
+ notify(event: T): boolean;
38
+ /**
39
+ * Returns the number of active subscribers.
40
+ */
41
+ count(): number;
42
+ /**
43
+ * Observable instance, which can be used to subscribe to this event source
44
+ * in a readonly fashion. Safe to publicly expose.
45
+ */
46
+ observable: Observable<T>;
47
+ /**
48
+ * Disposes of this event source.
49
+ *
50
+ * Will clears all registered event listeners. None of the registered
51
+ * functions will ever get called again.
52
+ *
53
+ * WARNING!
54
+ * Be careful when using this API, because the subscribers may not have any
55
+ * idea they won't be notified anymore.
56
+ */
57
+ dispose(): void;
58
+ };
59
+ /**
60
+ * makeEventSource allows you to generate a subscribe/notify pair of functions
61
+ * to make subscribing easy and to get notified about events.
62
+ *
63
+ * The events are anonymous, so you can use it to define events, like so:
64
+ *
65
+ * const event1 = makeEventSource();
66
+ * const event2 = makeEventSource();
67
+ *
68
+ * event1.subscribe(foo);
69
+ * event1.subscribe(bar);
70
+ * event2.subscribe(qux);
71
+ *
72
+ * // Unsubscription is pretty standard
73
+ * const unsub = event2.subscribe(foo);
74
+ * unsub();
75
+ *
76
+ * event1.notify(); // Now foo and bar will get called
77
+ * event2.notify(); // Now qux will get called (but foo will not, since it's unsubscribed)
78
+ *
79
+ */
80
+ declare function makeEventSource<T>(): EventSource<T>;
81
+
82
+ /**
83
+ * Represents an indefinitely deep arbitrary JSON data structure. There are
84
+ * four types that make up the Json family:
85
+ *
86
+ * - Json any legal JSON value
87
+ * - JsonScalar any legal JSON leaf value (no lists or objects)
88
+ * - JsonArray a JSON value whose outer type is an array
89
+ * - JsonObject a JSON value whose outer type is an object
90
+ *
91
+ */
92
+ type Json = JsonScalar | JsonArray | JsonObject;
93
+ type JsonScalar = string | number | boolean | null;
94
+ type JsonArray = Json[];
95
+ /**
96
+ * Any valid JSON object.
97
+ */
98
+ type JsonObject = {
99
+ [key: string]: Json | undefined;
100
+ };
101
+ /**
102
+ * Like Json, but with readonly arrays and objects.
103
+ */
104
+ type ReadonlyJson = JsonScalar | readonly ReadonlyJson[] | ReadonlyJsonObject;
105
+ /**
106
+ * Like JsonObject, but readonly.
107
+ */
108
+ type ReadonlyJsonObject = {
109
+ readonly [key: string]: ReadonlyJson | undefined;
110
+ };
111
+ declare function isJsonScalar(data: Json): data is JsonScalar;
112
+ declare function isJsonArray(data: Json): data is JsonArray;
113
+ declare function isJsonObject(data: Json): data is JsonObject;
114
+
115
+ interface IWebSocketEvent {
116
+ type: string;
117
+ }
118
+ interface IWebSocketCloseEvent extends IWebSocketEvent {
119
+ readonly code: WebsocketCloseCodes;
120
+ readonly wasClean: boolean;
121
+ readonly reason: string;
122
+ }
123
+ interface IWebSocketMessageEvent extends IWebSocketEvent {
124
+ readonly data: string | Buffer | ArrayBuffer | readonly Buffer[];
125
+ }
126
+ interface IWebSocketInstance {
127
+ readonly CONNECTING: number;
128
+ readonly OPEN: number;
129
+ readonly CLOSING: number;
130
+ readonly CLOSED: number;
131
+ readonly readyState: number;
132
+ addEventListener(type: "close", listener: (this: IWebSocketInstance, ev: IWebSocketCloseEvent) => unknown): void;
133
+ addEventListener(type: "message", listener: (this: IWebSocketInstance, ev: IWebSocketMessageEvent) => unknown): void;
134
+ addEventListener(type: "open" | "error", listener: (this: IWebSocketInstance, ev: IWebSocketEvent) => unknown): void;
135
+ removeEventListener(type: "close", listener: (this: IWebSocketInstance, ev: IWebSocketCloseEvent) => unknown): void;
136
+ removeEventListener(type: "message", listener: (this: IWebSocketInstance, ev: IWebSocketMessageEvent) => unknown): void;
137
+ removeEventListener(type: "open" | "error", listener: (this: IWebSocketInstance, ev: IWebSocketEvent) => unknown): void;
138
+ close(): void;
139
+ send(data: string): void;
140
+ }
141
+ /**
142
+ * Either the browser-based WebSocket API or Node.js' WebSocket API (from the
143
+ * 'ws' package).
144
+ *
145
+ * This type defines the minimal WebSocket API that Liveblocks needs from
146
+ * a WebSocket implementation, and is a minimal subset of the browser-based
147
+ * WebSocket APIs and Node.js' WebSocket API so that both implementations are
148
+ * assignable to this type.
149
+ */
150
+ interface IWebSocket {
151
+ new (address: string): IWebSocketInstance;
152
+ }
153
+ /**
154
+ * The following ranges will be respected by the client:
155
+ *
156
+ * 10xx: client will reauthorize (just like 41xx)
157
+ * 40xx: client will disconnect
158
+ * 41xx: client will reauthorize
159
+ * 42xx: client will retry without reauthorizing (currently not used)
160
+ *
161
+ */
162
+ declare enum WebsocketCloseCodes {
163
+ /** Normal close of connection, the connection fulfilled its purpose. */
164
+ CLOSE_NORMAL = 1000,
165
+ /** Unexpected error happened with the network/infra level. In spirit akin to HTTP 503 */
166
+ CLOSE_ABNORMAL = 1006,
167
+ /** Unexpected error happened. In spirit akin to HTTP 500 */
168
+ UNEXPECTED_CONDITION = 1011,
169
+ /** Please back off for now, but try again in a few moments */
170
+ TRY_AGAIN_LATER = 1013,
171
+ /** Message wasn't understood, disconnect */
172
+ INVALID_MESSAGE_FORMAT = 4000,
173
+ /** Server refused to allow connection. Re-authorizing won't help. Disconnect. In spirit akin to HTTP 403 */
174
+ NOT_ALLOWED = 4001,
175
+ /** Unused */
176
+ MAX_NUMBER_OF_MESSAGES_PER_SECONDS = 4002,
177
+ /** Unused */
178
+ MAX_NUMBER_OF_CONCURRENT_CONNECTIONS = 4003,
179
+ /** Unused */
180
+ MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
181
+ /** Room is full, disconnect */
182
+ MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
183
+ /** The room's ID was updated, disconnect */
184
+ ROOM_ID_UPDATED = 4006,
185
+ /** The server kicked the connection from the room. */
186
+ KICKED = 4100,
187
+ /** The auth token is expired, reauthorize to get a fresh one. In spirit akin to HTTP 401 */
188
+ TOKEN_EXPIRED = 4109,
189
+ /** Disconnect immediately */
190
+ CLOSE_WITHOUT_RETRY = 4999
191
+ }
192
+
193
+ /**
194
+ * Returns a human-readable status indicating the current connection status of
195
+ * a Room, as returned by `room.getStatus()`. Can be used to implement
196
+ * a connection status badge.
197
+ */
198
+ type Status = "initial" | "connecting" | "connected" | "reconnecting" | "disconnected";
199
+ /**
200
+ * Used to report about app-level reconnection issues.
201
+ *
202
+ * Normal (quick) reconnects won't be reported as a "lost connection". Instead,
203
+ * the application will only get an event if the reconnection attempts by the
204
+ * client are taking (much) longer than usual. Definitely a situation you want
205
+ * to inform your users about, for example, by throwing a toast message on
206
+ * screen, or show a "trying to reconnect" banner.
207
+ */
208
+ type LostConnectionEvent = "lost" | "restored" | "failed";
209
+ /**
210
+ * Arbitrary record that will be used as the authentication "authValue". It's the
211
+ * value that is returned by calling the authentication delegate, and will get
212
+ * passed to the connection factory delegate. This value will be remembered by
213
+ * the connection manager, but its value will not be interpreted, so it can be
214
+ * any value (except null).
215
+ */
216
+ type BaseAuthResult = NonNullable<Json>;
217
+ type Delegates<T extends BaseAuthResult> = {
218
+ authenticate: () => Promise<T>;
219
+ createSocket: (authValue: T) => IWebSocketInstance;
220
+ canZombie: () => boolean;
221
+ };
222
+
10
223
  /**
11
224
  * This helper type is effectively a no-op, but will force TypeScript to
12
225
  * "evaluate" any named helper types in its definition. This can sometimes make
@@ -159,39 +372,6 @@ type CustomAuthenticationResult = Relax<{
159
372
  reason: string;
160
373
  }>;
161
374
 
162
- /**
163
- * Represents an indefinitely deep arbitrary JSON data structure. There are
164
- * four types that make up the Json family:
165
- *
166
- * - Json any legal JSON value
167
- * - JsonScalar any legal JSON leaf value (no lists or objects)
168
- * - JsonArray a JSON value whose outer type is an array
169
- * - JsonObject a JSON value whose outer type is an object
170
- *
171
- */
172
- type Json = JsonScalar | JsonArray | JsonObject;
173
- type JsonScalar = string | number | boolean | null;
174
- type JsonArray = Json[];
175
- /**
176
- * Any valid JSON object.
177
- */
178
- type JsonObject = {
179
- [key: string]: Json | undefined;
180
- };
181
- /**
182
- * Like Json, but with readonly arrays and objects.
183
- */
184
- type ReadonlyJson = JsonScalar | readonly ReadonlyJson[] | ReadonlyJsonObject;
185
- /**
186
- * Like JsonObject, but readonly.
187
- */
188
- type ReadonlyJsonObject = {
189
- readonly [key: string]: ReadonlyJson | undefined;
190
- };
191
- declare function isJsonScalar(data: Json): data is JsonScalar;
192
- declare function isJsonArray(data: Json): data is JsonArray;
193
- declare function isJsonObject(data: Json): data is JsonObject;
194
-
195
375
  /**
196
376
  * Represents some constraints for user info. Basically read this as: "any JSON
197
377
  * object is fine, but _if_ it has a name field, it _must_ be a string."
@@ -1300,7 +1480,11 @@ type JsonOfLsonObject<L extends LsonObject> = string extends keyof L ? L extends
1300
1480
  */
1301
1481
  type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? JsonOfLsonObject<O> : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
1302
1482
  readonly [K in KS]: ToJson<V>;
1303
- } : L extends LiveText ? LiveTextData : L extends LiveFile ? LiveFileData : L extends LsonObject ? JsonOfLsonObject<L> : L extends Json ? L : never;
1483
+ } : L extends LiveText ? LiveTextData : L extends LiveFile ? LiveFileData : L extends LsonObject ? JsonOfLsonObject<L> : L extends readonly (infer I extends Json)[] ? [
1484
+ Json
1485
+ ] extends [I] ? readonly ReadonlyJson[] : {
1486
+ readonly [K in keyof L]: ToJson<Extract<L[K], Json>>;
1487
+ } : L extends Json ? L : never;
1304
1488
 
1305
1489
  /**
1306
1490
  * Read-only query surface over {@link UnacknowledgedOps}, handed to CRDTs so
@@ -1471,78 +1655,6 @@ type AsyncError<F extends string = "data"> = RenameDataField<{
1471
1655
  }, F>;
1472
1656
  type AsyncResult<T, F extends string = "data"> = AsyncLoading<F> | AsyncSuccess<T, F> | AsyncError<F>;
1473
1657
 
1474
- type Callback<T> = (event: T) => void;
1475
- type UnsubscribeCallback = () => void;
1476
- type Observable<T> = {
1477
- /**
1478
- * Register a callback function to be called whenever the event source emits
1479
- * an event.
1480
- */
1481
- subscribe(callback: Callback<T>): UnsubscribeCallback;
1482
- /**
1483
- * Register a one-time callback function to be called whenever the event
1484
- * source emits an event. After the event fires, the callback is
1485
- * auto-unsubscribed.
1486
- */
1487
- subscribeOnce(callback: Callback<T>): UnsubscribeCallback;
1488
- /**
1489
- * Returns a promise that will resolve when an event is emitted by this
1490
- * event source. Optionally, specify a predicate that has to match. The first
1491
- * event matching that predicate will then resolve the promise.
1492
- */
1493
- waitUntil(predicate?: (event: T) => boolean): Promise<T>;
1494
- };
1495
- type EventSource<T> = Observable<T> & {
1496
- /**
1497
- * Notify all subscribers about the event. Will return `false` if there
1498
- * weren't any subscribers at the time the .notify() was called, or `true` if
1499
- * there was at least one subscriber.
1500
- */
1501
- notify(event: T): boolean;
1502
- /**
1503
- * Returns the number of active subscribers.
1504
- */
1505
- count(): number;
1506
- /**
1507
- * Observable instance, which can be used to subscribe to this event source
1508
- * in a readonly fashion. Safe to publicly expose.
1509
- */
1510
- observable: Observable<T>;
1511
- /**
1512
- * Disposes of this event source.
1513
- *
1514
- * Will clears all registered event listeners. None of the registered
1515
- * functions will ever get called again.
1516
- *
1517
- * WARNING!
1518
- * Be careful when using this API, because the subscribers may not have any
1519
- * idea they won't be notified anymore.
1520
- */
1521
- dispose(): void;
1522
- };
1523
- /**
1524
- * makeEventSource allows you to generate a subscribe/notify pair of functions
1525
- * to make subscribing easy and to get notified about events.
1526
- *
1527
- * The events are anonymous, so you can use it to define events, like so:
1528
- *
1529
- * const event1 = makeEventSource();
1530
- * const event2 = makeEventSource();
1531
- *
1532
- * event1.subscribe(foo);
1533
- * event1.subscribe(bar);
1534
- * event2.subscribe(qux);
1535
- *
1536
- * // Unsubscription is pretty standard
1537
- * const unsub = event2.subscribe(foo);
1538
- * unsub();
1539
- *
1540
- * event1.notify(); // Now foo and bar will get called
1541
- * event2.notify(); // Now qux will get called (but foo will not, since it's unsubscribed)
1542
- *
1543
- */
1544
- declare function makeEventSource<T>(): EventSource<T>;
1545
-
1546
1658
  type BatchStore<O, I> = {
1547
1659
  subscribe: (callback: Callback<void>) => UnsubscribeCallback;
1548
1660
  enqueue: (input: I) => Promise<void>;
@@ -2101,10 +2213,16 @@ type FileUrlData = {
2101
2213
  readonly url: string;
2102
2214
  readonly expiresAt: number;
2103
2215
  };
2216
+ type RoomAccess = {
2217
+ roomId: string;
2218
+ /** Inbox-only access covers personal notifications and their threads. */
2219
+ access: "room" | "inbox" | "none";
2220
+ };
2104
2221
  interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
2105
2222
  getThreads(options: {
2106
2223
  roomId: string;
2107
2224
  cursor?: string;
2225
+ signal?: AbortSignal;
2108
2226
  query?: {
2109
2227
  resolved?: boolean;
2110
2228
  visibility?: ThreadVisibility;
@@ -2117,6 +2235,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
2117
2235
  subscriptions: SubscriptionData[];
2118
2236
  requestedAt: Date;
2119
2237
  nextCursor: string | null;
2238
+ refreshCursor?: string;
2120
2239
  permissionHints: Record<string, RoomPermissions>;
2121
2240
  }>;
2122
2241
  getThreadsSince(options: {
@@ -2337,6 +2456,7 @@ interface RoomHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
2337
2456
  interface NotificationHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> {
2338
2457
  getInboxNotifications(options?: {
2339
2458
  cursor?: string;
2459
+ signal?: AbortSignal;
2340
2460
  query?: {
2341
2461
  roomId?: string;
2342
2462
  kind?: string;
@@ -2346,6 +2466,7 @@ interface NotificationHttpApi<TM extends BaseMetadata, CM extends BaseMetadata>
2346
2466
  threads: ThreadData<TM, CM>[];
2347
2467
  subscriptions: SubscriptionData[];
2348
2468
  nextCursor: string | null;
2469
+ refreshCursor?: string;
2349
2470
  requestedAt: Date;
2350
2471
  }>;
2351
2472
  getInboxNotificationsSince(options: {
@@ -2388,8 +2509,15 @@ interface NotificationHttpApi<TM extends BaseMetadata, CM extends BaseMetadata>
2388
2509
  }
2389
2510
  interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> extends RoomHttpApi<TM, CM>, NotificationHttpApi<TM, CM> {
2390
2511
  getUrlMetadata(url: string): Promise<UrlMetadata>;
2512
+ /** Reports confirmed accesses and returns whether all room checks succeeded. */
2513
+ checkRoomAccesses(options: {
2514
+ roomIds: string[];
2515
+ signal?: AbortSignal;
2516
+ onAccesses: (accesses: RoomAccess[]) => void;
2517
+ }): Promise<boolean>;
2391
2518
  getUserThreads_experimental(options?: {
2392
2519
  cursor?: string;
2520
+ signal?: AbortSignal;
2393
2521
  query?: {
2394
2522
  resolved?: boolean;
2395
2523
  visibility?: ThreadVisibility;
@@ -2400,6 +2528,7 @@ interface LiveblocksHttpApi<TM extends BaseMetadata, CM extends BaseMetadata> ex
2400
2528
  inboxNotifications: InboxNotificationData[];
2401
2529
  subscriptions: SubscriptionData[];
2402
2530
  nextCursor: string | null;
2531
+ refreshCursor?: string;
2403
2532
  requestedAt: Date;
2404
2533
  permissionHints: Record<string, RoomPermissions>;
2405
2534
  }>;
@@ -3023,114 +3152,6 @@ declare function createClient<U extends BaseUserMeta = DU>(options: ClientOption
3023
3152
  */
3024
3153
  declare function checkBounds(option: string, value: unknown, min: number, max?: number, recommendedMin?: number): number;
3025
3154
 
3026
- interface IWebSocketEvent {
3027
- type: string;
3028
- }
3029
- interface IWebSocketCloseEvent extends IWebSocketEvent {
3030
- readonly code: WebsocketCloseCodes;
3031
- readonly wasClean: boolean;
3032
- readonly reason: string;
3033
- }
3034
- interface IWebSocketMessageEvent extends IWebSocketEvent {
3035
- readonly data: string | Buffer | ArrayBuffer | readonly Buffer[];
3036
- }
3037
- interface IWebSocketInstance {
3038
- readonly CONNECTING: number;
3039
- readonly OPEN: number;
3040
- readonly CLOSING: number;
3041
- readonly CLOSED: number;
3042
- readonly readyState: number;
3043
- addEventListener(type: "close", listener: (this: IWebSocketInstance, ev: IWebSocketCloseEvent) => unknown): void;
3044
- addEventListener(type: "message", listener: (this: IWebSocketInstance, ev: IWebSocketMessageEvent) => unknown): void;
3045
- addEventListener(type: "open" | "error", listener: (this: IWebSocketInstance, ev: IWebSocketEvent) => unknown): void;
3046
- removeEventListener(type: "close", listener: (this: IWebSocketInstance, ev: IWebSocketCloseEvent) => unknown): void;
3047
- removeEventListener(type: "message", listener: (this: IWebSocketInstance, ev: IWebSocketMessageEvent) => unknown): void;
3048
- removeEventListener(type: "open" | "error", listener: (this: IWebSocketInstance, ev: IWebSocketEvent) => unknown): void;
3049
- close(): void;
3050
- send(data: string): void;
3051
- }
3052
- /**
3053
- * Either the browser-based WebSocket API or Node.js' WebSocket API (from the
3054
- * 'ws' package).
3055
- *
3056
- * This type defines the minimal WebSocket API that Liveblocks needs from
3057
- * a WebSocket implementation, and is a minimal subset of the browser-based
3058
- * WebSocket APIs and Node.js' WebSocket API so that both implementations are
3059
- * assignable to this type.
3060
- */
3061
- interface IWebSocket {
3062
- new (address: string): IWebSocketInstance;
3063
- }
3064
- /**
3065
- * The following ranges will be respected by the client:
3066
- *
3067
- * 10xx: client will reauthorize (just like 41xx)
3068
- * 40xx: client will disconnect
3069
- * 41xx: client will reauthorize
3070
- * 42xx: client will retry without reauthorizing (currently not used)
3071
- *
3072
- */
3073
- declare enum WebsocketCloseCodes {
3074
- /** Normal close of connection, the connection fulfilled its purpose. */
3075
- CLOSE_NORMAL = 1000,
3076
- /** Unexpected error happened with the network/infra level. In spirit akin to HTTP 503 */
3077
- CLOSE_ABNORMAL = 1006,
3078
- /** Unexpected error happened. In spirit akin to HTTP 500 */
3079
- UNEXPECTED_CONDITION = 1011,
3080
- /** Please back off for now, but try again in a few moments */
3081
- TRY_AGAIN_LATER = 1013,
3082
- /** Message wasn't understood, disconnect */
3083
- INVALID_MESSAGE_FORMAT = 4000,
3084
- /** Server refused to allow connection. Re-authorizing won't help. Disconnect. In spirit akin to HTTP 403 */
3085
- NOT_ALLOWED = 4001,
3086
- /** Unused */
3087
- MAX_NUMBER_OF_MESSAGES_PER_SECONDS = 4002,
3088
- /** Unused */
3089
- MAX_NUMBER_OF_CONCURRENT_CONNECTIONS = 4003,
3090
- /** Unused */
3091
- MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
3092
- /** Room is full, disconnect */
3093
- MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
3094
- /** The room's ID was updated, disconnect */
3095
- ROOM_ID_UPDATED = 4006,
3096
- /** The server kicked the connection from the room. */
3097
- KICKED = 4100,
3098
- /** The auth token is expired, reauthorize to get a fresh one. In spirit akin to HTTP 401 */
3099
- TOKEN_EXPIRED = 4109,
3100
- /** Disconnect immediately */
3101
- CLOSE_WITHOUT_RETRY = 4999
3102
- }
3103
-
3104
- /**
3105
- * Returns a human-readable status indicating the current connection status of
3106
- * a Room, as returned by `room.getStatus()`. Can be used to implement
3107
- * a connection status badge.
3108
- */
3109
- type Status = "initial" | "connecting" | "connected" | "reconnecting" | "disconnected";
3110
- /**
3111
- * Used to report about app-level reconnection issues.
3112
- *
3113
- * Normal (quick) reconnects won't be reported as a "lost connection". Instead,
3114
- * the application will only get an event if the reconnection attempts by the
3115
- * client are taking (much) longer than usual. Definitely a situation you want
3116
- * to inform your users about, for example, by throwing a toast message on
3117
- * screen, or show a "trying to reconnect" banner.
3118
- */
3119
- type LostConnectionEvent = "lost" | "restored" | "failed";
3120
- /**
3121
- * Arbitrary record that will be used as the authentication "authValue". It's the
3122
- * value that is returned by calling the authentication delegate, and will get
3123
- * passed to the connection factory delegate. This value will be remembered by
3124
- * the connection manager, but its value will not be interpreted, so it can be
3125
- * any value (except null).
3126
- */
3127
- type BaseAuthResult = NonNullable<Json>;
3128
- type Delegates<T extends BaseAuthResult> = {
3129
- authenticate: () => Promise<T>;
3130
- createSocket: (authValue: T) => IWebSocketInstance;
3131
- canZombie: () => boolean;
3132
- };
3133
-
3134
3155
  type ClientMsgCode = (typeof ClientMsgCode)[keyof typeof ClientMsgCode];
3135
3156
  declare const ClientMsgCode: Readonly<{
3136
3157
  UPDATE_PRESENCE: 100;
@@ -6121,6 +6142,9 @@ declare function warnOnce(message: string, key?: string): void;
6121
6142
  */
6122
6143
  declare function warnOnceIf(condition: boolean | (() => boolean), message: string, key?: string): void;
6123
6144
 
6145
+ /** Abort this wait without cancelling work that other callers may still need. */
6146
+ declare function withAbortSignal<T>(promise$: Promise<T>, signal?: AbortSignal): Promise<T>;
6147
+
6124
6148
  /**
6125
6149
  * Represents an indefinitely deep arbitrary immutable data
6126
6150
  * structure.
@@ -6265,4 +6289,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
6265
6289
  [K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
6266
6290
  };
6267
6291
 
6268
- export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type CompactTextNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CreateTextOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type FileUrlData, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, type LiveFileReference, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveText, type LiveTextAttributes, type LiveTextAttributesPatch, type LiveTextChange, type LiveTextData, type TextOperation as LiveTextOperation, type LiveTextSegment, type LiveTextUpdate, type LiveTextUpdates, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PlainLsonText, type Poller, type PrivateClientApi, type PrivateLiveNodeApi, type PrivateLiveTextApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type SerializedText, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, type TextAttributes, TextEditorType, type TextOperation, type TextStorageNode, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateSource, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateTextOp, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, applyLiveTextOperations, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getLiveFileId, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isTextStorageNode, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeLiveTextOperations, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, transformTextOperations, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withTimeout };
6292
+ export { type AccessLevel, type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type ChildStorageNode, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type CompactChildNode, type CompactFileNode, type CompactListNode, type CompactMapNode, type CompactNode, type CompactObjectNode, type CompactRegisterNode, type CompactRootNode, type CompactTextNode, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateFileOp, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type CreateTextOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DFM, type DFMD, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type Feed, type FeedCreateMetadata, type FeedDeletedServerMsg, type FeedFetchMetadataFilter, type FeedMessage, type FeedMessagesAddedServerMsg, type FeedMessagesDeletedServerMsg, type FeedMessagesListServerMsg, type FeedMessagesUpdatedServerMsg, type FeedRequestError, FeedRequestErrorCode, type FeedRequestFailedServerMsg, type FeedUpdateMetadata, type FeedsAddedServerMsg, type FeedsEventServerMsg, type FeedsListServerMsg, type FeedsUpdatedServerMsg, type FetchStorageClientMsg, type FetchYDocClientMsg, type FileStorageNode, type FileUrlData, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LayerKey, type ListStorageNode, LiveFile, type LiveFileData, type LiveFileReference, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveText, type LiveTextAttributes, type LiveTextAttributesPatch, type LiveTextChange, type LiveTextData, type TextOperation as LiveTextOperation, type LiveTextSegment, type LiveTextUpdate, type LiveTextUpdates, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MapStorageNode, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NodeStream, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type ObjectStorageNode, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PermissionMatrix, type PermissionResources, type PlainLson, type PlainLsonFields, type PlainLsonFile, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type PlainLsonText, type Poller, type PrivateClientApi, type PrivateLiveNodeApi, type PrivateLiveTextApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type ReadonlyJson, type ReadonlyJsonObject, type RegisterStorageNode, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type RequiredAccessLevel, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomAccess, type RoomAccesses, type RoomEventMessage, type RoomPermissions, type RoomStateServerMsg, type RoomSubscriptionSettings, type RootStorageNode, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedFile, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type SerializedText, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageChunkServerMsg, type StorageNode, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncConfig, type SyncMode, type SyncSource, type SyncStatus, type TextAttributes, TextEditorType, type TextOperation, type TextStorageNode, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ThreadVisibility, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateRoomAccesses, type UpdateSource, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateTextOp, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UploadFileOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, applyLiveTextOperations, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactNodesToNodeStream, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createStorageFileId, createThreadId, deepLiveify, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getLiveFileId, getMentionsFromCommentBody, getSubscriptionKey, hasPermissionAccess, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isFileStorageNode, isJsonArray, isJsonObject, isJsonScalar, isListStorageNode, isLiveNode, isMapStorageNode, isNotificationChannelEnabled, isNumberOperator, isObjectStorageNode, isPlainObject, isRegisterStorageNode, isRootStorageNode, isStartsWithOperator, isTextStorageNode, isUrl, kInternal, keys, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, mergeRoomPermissionScopes, nanoid, nn, nodeStreamToCompactNodes, normalizeLiveTextOperations, normalizeRoomAccesses, normalizeRoomPermissions, normalizeUpdateRoomAccesses, objectToQuery, patchNotificationSettings, permissionMatrixFromScopes, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, transformTextOperations, tryParseJson, url, urljoin, validatePermissionsSet, wait, warnOnce, warnOnceIf, withAbortSignal, withTimeout };