@liveblocks/client 0.16.15 → 0.17.0-test1
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/index.d.ts +26 -7
- package/index.js +1230 -830
- package/index.mjs +1030 -782
- package/internal.d.ts +271 -251
- package/internal.js +314 -168
- package/internal.mjs +265 -130
- package/package.json +15 -10
- package/shared.d.ts +973 -628
- package/shared.js +2568 -1331
- package/shared.mjs +1989 -1210
package/internal.d.ts
CHANGED
|
@@ -1,45 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
d as JsonObject,
|
|
3
|
+
J as Json,
|
|
4
|
+
h as Op,
|
|
5
|
+
I as IdTuple,
|
|
6
|
+
i as SerializedCrdt,
|
|
7
|
+
f as Lson,
|
|
8
|
+
g as LsonObject,
|
|
9
|
+
c as LiveObject,
|
|
10
|
+
S as StorageUpdate,
|
|
11
|
+
} from "./shared.js";
|
|
12
|
+
export {
|
|
13
|
+
G as CrdtType,
|
|
14
|
+
j as CreateChildOp,
|
|
15
|
+
k as CreateListOp,
|
|
16
|
+
l as CreateMapOp,
|
|
17
|
+
m as CreateObjectOp,
|
|
18
|
+
n as CreateOp,
|
|
19
|
+
o as CreateRegisterOp,
|
|
20
|
+
p as CreateRootObjectOp,
|
|
21
|
+
D as DeleteCrdtOp,
|
|
22
|
+
q as DeleteObjectKeyOp,
|
|
23
|
+
I as IdTuple,
|
|
24
|
+
r as LiveNode,
|
|
25
|
+
N as NodeMap,
|
|
26
|
+
h as Op,
|
|
27
|
+
K as OpCode,
|
|
28
|
+
s as ParentToChildNodeMap,
|
|
29
|
+
t as Resolve,
|
|
30
|
+
u as RoomInitializers,
|
|
31
|
+
v as SerializedChild,
|
|
32
|
+
i as SerializedCrdt,
|
|
33
|
+
w as SerializedList,
|
|
34
|
+
x as SerializedMap,
|
|
35
|
+
y as SerializedObject,
|
|
36
|
+
z as SerializedRegister,
|
|
37
|
+
A as SerializedRootObject,
|
|
38
|
+
E as SetParentKeyOp,
|
|
39
|
+
F as UpdateObjectOp,
|
|
40
|
+
W as WebsocketCloseCodes,
|
|
41
|
+
V as isChildCrdt,
|
|
42
|
+
M as isJsonArray,
|
|
43
|
+
Q as isJsonObject,
|
|
44
|
+
T as isJsonScalar,
|
|
45
|
+
X as isRootCrdt,
|
|
46
|
+
} from "./shared.js";
|
|
3
47
|
|
|
4
|
-
declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Reverse lookup table for all child nodes (= list of SerializedCrdt values)
|
|
12
|
-
* by their parent node's IDs.
|
|
13
|
-
*/
|
|
14
|
-
declare type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
15
|
-
IdTuple<SerializedChild>[]>;
|
|
48
|
+
declare enum ClientMsgCode {
|
|
49
|
+
UPDATE_PRESENCE = 100,
|
|
50
|
+
BROADCAST_EVENT = 103,
|
|
51
|
+
FETCH_STORAGE = 200,
|
|
52
|
+
UPDATE_STORAGE = 201,
|
|
53
|
+
}
|
|
16
54
|
/**
|
|
17
|
-
* Messages that can be sent from the
|
|
55
|
+
* Messages that can be sent from the client to the server.
|
|
18
56
|
*/
|
|
19
|
-
declare type
|
|
57
|
+
declare type ClientMsg<TPresence extends JsonObject> =
|
|
58
|
+
| BroadcastEventClientMsg
|
|
59
|
+
| UpdatePresenceClientMsg<TPresence>
|
|
60
|
+
| UpdateStorageClientMsg
|
|
61
|
+
| FetchStorageClientMsg;
|
|
62
|
+
declare type BroadcastEventClientMsg = {
|
|
63
|
+
type: ClientMsgCode.BROADCAST_EVENT;
|
|
64
|
+
event: Json;
|
|
65
|
+
};
|
|
66
|
+
declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
|
|
67
|
+
type: ClientMsgCode.UPDATE_PRESENCE;
|
|
68
|
+
data: TPresence;
|
|
69
|
+
targetActor?: number;
|
|
70
|
+
};
|
|
71
|
+
declare type UpdateStorageClientMsg = {
|
|
72
|
+
type: ClientMsgCode.UPDATE_STORAGE;
|
|
73
|
+
ops: Op[];
|
|
74
|
+
};
|
|
75
|
+
declare type FetchStorageClientMsg = {
|
|
76
|
+
type: ClientMsgCode.FETCH_STORAGE;
|
|
77
|
+
};
|
|
78
|
+
|
|
20
79
|
declare enum ServerMsgCode {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
80
|
+
UPDATE_PRESENCE = 100,
|
|
81
|
+
USER_JOINED = 101,
|
|
82
|
+
USER_LEFT = 102,
|
|
83
|
+
BROADCASTED_EVENT = 103,
|
|
84
|
+
ROOM_STATE = 104,
|
|
85
|
+
INITIAL_STORAGE_STATE = 200,
|
|
86
|
+
UPDATE_STORAGE = 201,
|
|
28
87
|
}
|
|
29
88
|
/**
|
|
30
|
-
*
|
|
31
|
-
* joining the Room, to provide the initial state of the Room. The payload
|
|
32
|
-
* includes a list of all other Users that already are in the Room.
|
|
89
|
+
* Messages that can be sent from the server to the client.
|
|
33
90
|
*/
|
|
34
|
-
declare type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
};
|
|
91
|
+
declare type ServerMsg<TPresence extends JsonObject> =
|
|
92
|
+
| UpdatePresenceServerMsg<TPresence>
|
|
93
|
+
| UserJoinServerMsg
|
|
94
|
+
| UserLeftServerMsg
|
|
95
|
+
| BroadcastedEventServerMsg
|
|
96
|
+
| RoomStateServerMsg
|
|
97
|
+
| InitialDocumentStateServerMsg
|
|
98
|
+
| UpdateStorageServerMsg;
|
|
43
99
|
/**
|
|
44
100
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
45
101
|
* a User updated their presence. For example, when a user moves their cursor.
|
|
@@ -52,65 +108,79 @@ declare type RoomStateServerMsg = {
|
|
|
52
108
|
* so all other existing clients can ignore this broadcasted message.
|
|
53
109
|
*/
|
|
54
110
|
declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
111
|
+
type: ServerMsgCode.UPDATE_PRESENCE;
|
|
112
|
+
/**
|
|
113
|
+
* The User whose Presence has changed.
|
|
114
|
+
*/
|
|
115
|
+
actor: number;
|
|
116
|
+
/**
|
|
117
|
+
* The partial or full Presence of a User. If the `targetActor` field is set,
|
|
118
|
+
* this will be the full Presence, otherwise it only contain the fields that
|
|
119
|
+
* have changed since the last broadcast.
|
|
120
|
+
*/
|
|
121
|
+
data: TPresence;
|
|
122
|
+
/**
|
|
123
|
+
* If this message was sent in response to a newly joined user, this field
|
|
124
|
+
* indicates which client this message is for. Other existing clients may
|
|
125
|
+
* ignore this message if this message isn't targeted for them.
|
|
126
|
+
*/
|
|
127
|
+
targetActor?: number;
|
|
72
128
|
};
|
|
73
129
|
/**
|
|
74
130
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
75
131
|
* a new User has joined the Room.
|
|
76
132
|
*/
|
|
77
133
|
declare type UserJoinServerMsg = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
134
|
+
type: ServerMsgCode.USER_JOINED;
|
|
135
|
+
actor: number;
|
|
136
|
+
/**
|
|
137
|
+
* The id of the User that has been set in the authentication endpoint.
|
|
138
|
+
* Useful to get additional information about the connected user.
|
|
139
|
+
*/
|
|
140
|
+
id?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Additional user information that has been set in the authentication
|
|
143
|
+
* endpoint.
|
|
144
|
+
*/
|
|
145
|
+
info?: Json;
|
|
90
146
|
};
|
|
91
147
|
/**
|
|
92
148
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
93
149
|
* a new User has left the Room.
|
|
94
150
|
*/
|
|
95
151
|
declare type UserLeftServerMsg = {
|
|
96
|
-
|
|
97
|
-
|
|
152
|
+
type: ServerMsgCode.USER_LEFT;
|
|
153
|
+
actor: number;
|
|
98
154
|
};
|
|
99
155
|
/**
|
|
100
156
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
101
157
|
* a User broadcasted an Event to everyone in the Room.
|
|
102
158
|
*/
|
|
103
159
|
declare type BroadcastedEventServerMsg = {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
160
|
+
type: ServerMsgCode.BROADCASTED_EVENT;
|
|
161
|
+
/**
|
|
162
|
+
* The User who broadcasted the Event.
|
|
163
|
+
*/
|
|
164
|
+
actor: number;
|
|
165
|
+
/**
|
|
166
|
+
* The arbitrary payload of the Event. This can be any JSON value. Clients
|
|
167
|
+
* will have to manually verify/decode this event.
|
|
168
|
+
*/
|
|
169
|
+
event: Json;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Sent by the WebSocket server to a single client in response to the client
|
|
173
|
+
* joining the Room, to provide the initial state of the Room. The payload
|
|
174
|
+
* includes a list of all other Users that already are in the Room.
|
|
175
|
+
*/
|
|
176
|
+
declare type RoomStateServerMsg = {
|
|
177
|
+
type: ServerMsgCode.ROOM_STATE;
|
|
178
|
+
users: {
|
|
179
|
+
[actor: number]: {
|
|
180
|
+
id?: string;
|
|
181
|
+
info?: Json;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
114
184
|
};
|
|
115
185
|
/**
|
|
116
186
|
* Sent by the WebSocket server to a single client in response to the client
|
|
@@ -118,8 +188,8 @@ declare type BroadcastedEventServerMsg = {
|
|
|
118
188
|
* payload includes the entire Storage document.
|
|
119
189
|
*/
|
|
120
190
|
declare type InitialDocumentStateServerMsg = {
|
|
121
|
-
|
|
122
|
-
|
|
191
|
+
type: ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
192
|
+
items: IdTuple<SerializedCrdt>[];
|
|
123
193
|
};
|
|
124
194
|
/**
|
|
125
195
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
@@ -129,162 +199,79 @@ declare type InitialDocumentStateServerMsg = {
|
|
|
129
199
|
* mutations to make to the initially loaded document).
|
|
130
200
|
*/
|
|
131
201
|
declare type UpdateStorageServerMsg = {
|
|
132
|
-
|
|
133
|
-
|
|
202
|
+
type: ServerMsgCode.UPDATE_STORAGE;
|
|
203
|
+
ops: Op[];
|
|
134
204
|
};
|
|
205
|
+
|
|
135
206
|
/**
|
|
136
|
-
*
|
|
207
|
+
* Helper function that can be used to implement exhaustive switch statements
|
|
208
|
+
* with TypeScript. Example usage:
|
|
209
|
+
*
|
|
210
|
+
* type Fruit = "🍎" | "🍌";
|
|
211
|
+
*
|
|
212
|
+
* switch (fruit) {
|
|
213
|
+
* case "🍎":
|
|
214
|
+
* case "🍌":
|
|
215
|
+
* return doSomething();
|
|
216
|
+
*
|
|
217
|
+
* default:
|
|
218
|
+
* return assertNever(fruit, "Unknown fruit");
|
|
219
|
+
* }
|
|
220
|
+
*
|
|
221
|
+
* If now the Fruit union is extended (i.e. add "🍒"), TypeScript will catch
|
|
222
|
+
* this *statically*, rather than at runtime, and force you to handle the
|
|
223
|
+
* 🍒 case.
|
|
137
224
|
*/
|
|
138
|
-
declare
|
|
139
|
-
declare enum ClientMsgCode {
|
|
140
|
-
UPDATE_PRESENCE = 100,
|
|
141
|
-
BROADCAST_EVENT = 103,
|
|
142
|
-
FETCH_STORAGE = 200,
|
|
143
|
-
UPDATE_STORAGE = 201
|
|
144
|
-
}
|
|
145
|
-
declare type BroadcastEventClientMsg = {
|
|
146
|
-
type: ClientMsgCode.BROADCAST_EVENT;
|
|
147
|
-
event: Json;
|
|
148
|
-
};
|
|
149
|
-
declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
|
|
150
|
-
type: ClientMsgCode.UPDATE_PRESENCE;
|
|
151
|
-
data: TPresence;
|
|
152
|
-
targetActor?: number;
|
|
153
|
-
};
|
|
154
|
-
declare type UpdateStorageClientMsg = {
|
|
155
|
-
type: ClientMsgCode.UPDATE_STORAGE;
|
|
156
|
-
ops: Op[];
|
|
157
|
-
};
|
|
158
|
-
declare type FetchStorageClientMsg = {
|
|
159
|
-
type: ClientMsgCode.FETCH_STORAGE;
|
|
160
|
-
};
|
|
161
|
-
declare enum CrdtType {
|
|
162
|
-
OBJECT = 0,
|
|
163
|
-
LIST = 1,
|
|
164
|
-
MAP = 2,
|
|
165
|
-
REGISTER = 3
|
|
166
|
-
}
|
|
167
|
-
declare type SerializedRootObject = {
|
|
168
|
-
type: CrdtType.OBJECT;
|
|
169
|
-
data: JsonObject;
|
|
170
|
-
parentId?: never;
|
|
171
|
-
parentKey?: never;
|
|
172
|
-
};
|
|
173
|
-
declare type SerializedObject = {
|
|
174
|
-
type: CrdtType.OBJECT;
|
|
175
|
-
parentId: string;
|
|
176
|
-
parentKey: string;
|
|
177
|
-
data: JsonObject;
|
|
178
|
-
};
|
|
179
|
-
declare type SerializedList = {
|
|
180
|
-
type: CrdtType.LIST;
|
|
181
|
-
parentId: string;
|
|
182
|
-
parentKey: string;
|
|
183
|
-
};
|
|
184
|
-
declare type SerializedMap = {
|
|
185
|
-
type: CrdtType.MAP;
|
|
186
|
-
parentId: string;
|
|
187
|
-
parentKey: string;
|
|
188
|
-
};
|
|
189
|
-
declare type SerializedRegister = {
|
|
190
|
-
type: CrdtType.REGISTER;
|
|
191
|
-
parentId: string;
|
|
192
|
-
parentKey: string;
|
|
193
|
-
data: Json;
|
|
194
|
-
};
|
|
195
|
-
declare type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
196
|
-
declare type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
197
|
-
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
198
|
-
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
199
|
-
declare enum OpCode {
|
|
200
|
-
INIT = 0,
|
|
201
|
-
SET_PARENT_KEY = 1,
|
|
202
|
-
CREATE_LIST = 2,
|
|
203
|
-
UPDATE_OBJECT = 3,
|
|
204
|
-
CREATE_OBJECT = 4,
|
|
205
|
-
DELETE_CRDT = 5,
|
|
206
|
-
DELETE_OBJECT_KEY = 6,
|
|
207
|
-
CREATE_MAP = 7,
|
|
208
|
-
CREATE_REGISTER = 8
|
|
209
|
-
}
|
|
225
|
+
declare function assertNever(_value: never, errmsg: string): never;
|
|
210
226
|
/**
|
|
211
|
-
*
|
|
212
|
-
* only
|
|
227
|
+
* Asserts that a given value is non-nullable. This is similar to TypeScript's
|
|
228
|
+
* `!` operator, but will throw an error at runtime (dev-mode only) indicating
|
|
229
|
+
* an incorrect assumption.
|
|
230
|
+
*
|
|
231
|
+
* Instead of:
|
|
232
|
+
*
|
|
233
|
+
* foo!.bar
|
|
234
|
+
*
|
|
235
|
+
* Use:
|
|
236
|
+
*
|
|
237
|
+
* nn(foo).bar
|
|
238
|
+
*
|
|
213
239
|
*/
|
|
214
|
-
declare
|
|
215
|
-
|
|
216
|
-
declare
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
parentKey: string;
|
|
230
|
-
data: JsonObject;
|
|
231
|
-
};
|
|
232
|
-
declare type CreateRootObjectOp = Resolve<Omit<CreateObjectOp, "parentId" | "parentKey"> & {
|
|
233
|
-
parentId?: never;
|
|
234
|
-
parentKey?: never;
|
|
235
|
-
}>;
|
|
236
|
-
declare type CreateListOp = {
|
|
237
|
-
opId?: string;
|
|
238
|
-
id: string;
|
|
239
|
-
intent?: "set";
|
|
240
|
-
type: OpCode.CREATE_LIST;
|
|
241
|
-
parentId: string;
|
|
242
|
-
parentKey: string;
|
|
243
|
-
};
|
|
244
|
-
declare type CreateMapOp = {
|
|
245
|
-
opId?: string;
|
|
246
|
-
id: string;
|
|
247
|
-
intent?: "set";
|
|
248
|
-
type: OpCode.CREATE_MAP;
|
|
249
|
-
parentId: string;
|
|
250
|
-
parentKey: string;
|
|
251
|
-
};
|
|
252
|
-
declare type CreateRegisterOp = {
|
|
253
|
-
opId?: string;
|
|
254
|
-
id: string;
|
|
255
|
-
intent?: "set";
|
|
256
|
-
type: OpCode.CREATE_REGISTER;
|
|
257
|
-
parentId: string;
|
|
258
|
-
parentKey: string;
|
|
259
|
-
data: Json;
|
|
260
|
-
};
|
|
261
|
-
declare type DeleteCrdtOp = {
|
|
262
|
-
opId?: string;
|
|
263
|
-
id: string;
|
|
264
|
-
type: OpCode.DELETE_CRDT;
|
|
265
|
-
};
|
|
266
|
-
declare type SetParentKeyOp = {
|
|
267
|
-
opId?: string;
|
|
268
|
-
id: string;
|
|
269
|
-
type: OpCode.SET_PARENT_KEY;
|
|
270
|
-
parentKey: string;
|
|
240
|
+
declare function nn<T>(value: T, errmsg?: string): NonNullable<T>;
|
|
241
|
+
|
|
242
|
+
declare const SCOPES: readonly [
|
|
243
|
+
"websocket:presence",
|
|
244
|
+
"websocket:storage",
|
|
245
|
+
"room:read",
|
|
246
|
+
"room:write",
|
|
247
|
+
"rooms:read",
|
|
248
|
+
"rooms:write"
|
|
249
|
+
];
|
|
250
|
+
declare type Scope = typeof SCOPES[number];
|
|
251
|
+
declare type AppOnlyAuthToken = {
|
|
252
|
+
appId: string;
|
|
253
|
+
roomId?: never;
|
|
254
|
+
scopes: string[];
|
|
271
255
|
};
|
|
272
|
-
declare type
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
256
|
+
declare type RoomAuthToken = {
|
|
257
|
+
appId: string;
|
|
258
|
+
roomId: string;
|
|
259
|
+
scopes: string[];
|
|
260
|
+
actor: number;
|
|
261
|
+
maxConnectionsPerRoom?: number;
|
|
262
|
+
id?: string;
|
|
263
|
+
info?: Json;
|
|
277
264
|
};
|
|
278
|
-
declare
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
MAX_NUMBER_OF_MESSAGES_PER_SECONDS = 4002,
|
|
283
|
-
MAX_NUMBER_OF_CONCURRENT_CONNECTIONS = 4003,
|
|
284
|
-
MAX_NUMBER_OF_MESSAGES_PER_DAY_PER_APP = 4004,
|
|
285
|
-
MAX_NUMBER_OF_CONCURRENT_CONNECTIONS_PER_ROOM = 4005,
|
|
286
|
-
CLOSE_WITHOUT_RETRY = 4999
|
|
265
|
+
declare type AuthToken = AppOnlyAuthToken | RoomAuthToken;
|
|
266
|
+
interface JwtMetadata extends JsonObject {
|
|
267
|
+
iat: number;
|
|
268
|
+
exp: number;
|
|
287
269
|
}
|
|
270
|
+
declare function isScope(value: unknown): value is Scope;
|
|
271
|
+
declare function isAppOnlyAuthToken(data: JsonObject): data is AppOnlyAuthToken;
|
|
272
|
+
declare function isRoomAuthToken(data: JsonObject): data is RoomAuthToken;
|
|
273
|
+
declare function isAuthToken(data: JsonObject): data is AuthToken;
|
|
274
|
+
declare function parseAuthToken(token: string): AuthToken & JwtMetadata;
|
|
288
275
|
|
|
289
276
|
/**
|
|
290
277
|
* Tools to help with the controlled deprecation of public APIs.
|
|
@@ -301,7 +288,11 @@ declare function deprecate(message: string, key?: string): void;
|
|
|
301
288
|
* console if the first argument is truthy. Only in dev mode, and
|
|
302
289
|
* only once per message/key. In production, this is a no-op.
|
|
303
290
|
*/
|
|
304
|
-
declare function deprecateIf(
|
|
291
|
+
declare function deprecateIf(
|
|
292
|
+
condition: unknown,
|
|
293
|
+
message: string,
|
|
294
|
+
key?: string
|
|
295
|
+
): void;
|
|
305
296
|
/**
|
|
306
297
|
* Throws a deprecation error in the dev console.
|
|
307
298
|
*
|
|
@@ -317,33 +308,23 @@ declare function throwUsageError(message: string): void;
|
|
|
317
308
|
*/
|
|
318
309
|
declare function errorIf(condition: unknown, message: string): void;
|
|
319
310
|
|
|
320
|
-
declare function lsonToJson(value: Lson
|
|
321
|
-
declare function patchLiveObjectKey<
|
|
322
|
-
|
|
311
|
+
declare function lsonToJson(value: Lson): Json;
|
|
312
|
+
declare function patchLiveObjectKey<
|
|
313
|
+
O extends LsonObject,
|
|
314
|
+
K extends keyof O,
|
|
315
|
+
V extends Lson
|
|
316
|
+
>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
317
|
+
declare function patchImmutableObject<S extends JsonObject>(
|
|
318
|
+
state: S,
|
|
319
|
+
updates: StorageUpdate[]
|
|
320
|
+
): S;
|
|
323
321
|
|
|
324
322
|
declare function makePosition(before?: string, after?: string): string;
|
|
325
323
|
declare function comparePosition(posA: string, posB: string): number;
|
|
326
324
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
*
|
|
331
|
-
* type Fruit = "🍎" | "🍌";
|
|
332
|
-
*
|
|
333
|
-
* switch (fruit) {
|
|
334
|
-
* case "🍎":
|
|
335
|
-
* case "🍌":
|
|
336
|
-
* return doSomething();
|
|
337
|
-
*
|
|
338
|
-
* default:
|
|
339
|
-
* return assertNever(fruit, "Unknown fruit");
|
|
340
|
-
* }
|
|
341
|
-
*
|
|
342
|
-
* If now the Fruit union is extended (i.e. add "🍒"), TypeScript will catch
|
|
343
|
-
* this *statically*, rather than at runtime, and force you to handle the
|
|
344
|
-
* 🍒 case.
|
|
345
|
-
*/
|
|
346
|
-
declare function assertNever(_value: never, errmsg: string): never;
|
|
325
|
+
declare function isPlainObject(blob: unknown): blob is {
|
|
326
|
+
[key: string]: unknown;
|
|
327
|
+
};
|
|
347
328
|
/**
|
|
348
329
|
* Alternative to JSON.parse() that will not throw in production. If the passed
|
|
349
330
|
* string cannot be parsed, this will return `undefined`.
|
|
@@ -354,4 +335,43 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
|
|
|
354
335
|
*/
|
|
355
336
|
declare function b64decode(b64value: string): string;
|
|
356
337
|
|
|
357
|
-
export {
|
|
338
|
+
export {
|
|
339
|
+
AppOnlyAuthToken,
|
|
340
|
+
AuthToken,
|
|
341
|
+
BroadcastEventClientMsg,
|
|
342
|
+
BroadcastedEventServerMsg,
|
|
343
|
+
ClientMsg,
|
|
344
|
+
ClientMsgCode,
|
|
345
|
+
FetchStorageClientMsg,
|
|
346
|
+
InitialDocumentStateServerMsg,
|
|
347
|
+
RoomAuthToken,
|
|
348
|
+
RoomStateServerMsg,
|
|
349
|
+
Scope,
|
|
350
|
+
ServerMsg,
|
|
351
|
+
ServerMsgCode,
|
|
352
|
+
UpdatePresenceClientMsg,
|
|
353
|
+
UpdatePresenceServerMsg,
|
|
354
|
+
UpdateStorageClientMsg,
|
|
355
|
+
UpdateStorageServerMsg,
|
|
356
|
+
UserJoinServerMsg,
|
|
357
|
+
UserLeftServerMsg,
|
|
358
|
+
assertNever,
|
|
359
|
+
b64decode,
|
|
360
|
+
comparePosition,
|
|
361
|
+
deprecate,
|
|
362
|
+
deprecateIf,
|
|
363
|
+
errorIf,
|
|
364
|
+
isAppOnlyAuthToken,
|
|
365
|
+
isAuthToken,
|
|
366
|
+
isPlainObject,
|
|
367
|
+
isRoomAuthToken,
|
|
368
|
+
isScope,
|
|
369
|
+
lsonToJson,
|
|
370
|
+
makePosition,
|
|
371
|
+
nn,
|
|
372
|
+
parseAuthToken,
|
|
373
|
+
patchImmutableObject,
|
|
374
|
+
patchLiveObjectKey,
|
|
375
|
+
throwUsageError,
|
|
376
|
+
tryParseJson,
|
|
377
|
+
};
|