@liveblocks/client 0.17.7 → 0.17.10-debug
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/.built-by-link-script +1 -0
- package/chunk-QLMVHHAZ.js +3592 -0
- package/index-0007883d.d.ts +793 -0
- package/index.d.ts +7 -27
- package/index.js +2007 -1269
- package/index.mjs +1 -1114
- package/internal.d.ts +198 -307
- package/internal.js +526 -309
- package/internal.mjs +29 -281
- package/package.json +1 -1
- package/shared.d.ts +0 -855
- package/shared.js +0 -2655
- package/shared.mjs +0 -2069
package/internal.d.ts
CHANGED
|
@@ -1,190 +1,178 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
J as Json,
|
|
4
|
-
B as BaseUserMeta,
|
|
5
|
-
g as Lson,
|
|
6
|
-
h as LsonObject,
|
|
7
|
-
c as LiveObject,
|
|
8
|
-
S as StorageUpdate,
|
|
9
|
-
} from "./shared.js";
|
|
10
|
-
export {
|
|
11
|
-
i as LiveNode,
|
|
12
|
-
j as Resolve,
|
|
13
|
-
k as RoomInitializers,
|
|
14
|
-
W as WebsocketCloseCodes,
|
|
15
|
-
l as isJsonArray,
|
|
16
|
-
m as isJsonObject,
|
|
17
|
-
n as isJsonScalar,
|
|
18
|
-
} from "./shared.js";
|
|
1
|
+
import { e as JsonObject, J as Json, B as BaseUserMeta, g as Lson, h as LsonObject, c as LiveObject, S as StorageUpdate } from './index-0007883d.js';
|
|
2
|
+
export { i as LiveNode, j as Resolve, k as RoomInitializers, W as WebsocketCloseCodes, l as isJsonArray, m as isJsonObject, n as isJsonScalar } from './index-0007883d.js';
|
|
19
3
|
|
|
20
4
|
declare enum OpCode {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
INIT = 0,
|
|
6
|
+
SET_PARENT_KEY = 1,
|
|
7
|
+
CREATE_LIST = 2,
|
|
8
|
+
UPDATE_OBJECT = 3,
|
|
9
|
+
CREATE_OBJECT = 4,
|
|
10
|
+
DELETE_CRDT = 5,
|
|
11
|
+
DELETE_OBJECT_KEY = 6,
|
|
12
|
+
CREATE_MAP = 7,
|
|
13
|
+
CREATE_REGISTER = 8
|
|
30
14
|
}
|
|
31
15
|
/**
|
|
32
16
|
* These operations are the payload for {@link UpdateStorageServerMsg} messages
|
|
33
17
|
* only.
|
|
34
18
|
*/
|
|
35
|
-
declare type Op =
|
|
36
|
-
| CreateOp
|
|
37
|
-
| UpdateObjectOp
|
|
38
|
-
| DeleteCrdtOp
|
|
39
|
-
| SetParentKeyOp
|
|
40
|
-
| DeleteObjectKeyOp;
|
|
19
|
+
declare type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
|
|
41
20
|
declare type CreateOp = CreateRootObjectOp | CreateChildOp;
|
|
42
|
-
declare type CreateChildOp =
|
|
43
|
-
| CreateObjectOp
|
|
44
|
-
| CreateRegisterOp
|
|
45
|
-
| CreateMapOp
|
|
46
|
-
| CreateListOp;
|
|
21
|
+
declare type CreateChildOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
47
22
|
declare type UpdateObjectOp = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
23
|
+
opId?: string;
|
|
24
|
+
id: string;
|
|
25
|
+
type: OpCode.UPDATE_OBJECT;
|
|
26
|
+
data: Partial<JsonObject>;
|
|
52
27
|
};
|
|
53
28
|
declare type CreateObjectOp = {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
29
|
+
opId?: string;
|
|
30
|
+
id: string;
|
|
31
|
+
intent?: "set";
|
|
32
|
+
deletedId?: string;
|
|
33
|
+
type: OpCode.CREATE_OBJECT;
|
|
34
|
+
parentId: string;
|
|
35
|
+
parentKey: string;
|
|
36
|
+
data: JsonObject;
|
|
62
37
|
};
|
|
63
38
|
declare type CreateRootObjectOp = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
39
|
+
opId?: string;
|
|
40
|
+
id: string;
|
|
41
|
+
type: OpCode.CREATE_OBJECT;
|
|
42
|
+
data: JsonObject;
|
|
43
|
+
parentId?: never;
|
|
44
|
+
parentKey?: never;
|
|
70
45
|
};
|
|
71
46
|
declare type CreateListOp = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
47
|
+
opId?: string;
|
|
48
|
+
id: string;
|
|
49
|
+
intent?: "set";
|
|
50
|
+
deletedId?: string;
|
|
51
|
+
type: OpCode.CREATE_LIST;
|
|
52
|
+
parentId: string;
|
|
53
|
+
parentKey: string;
|
|
79
54
|
};
|
|
80
55
|
declare type CreateMapOp = {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
opId?: string;
|
|
57
|
+
id: string;
|
|
58
|
+
intent?: "set";
|
|
59
|
+
deletedId?: string;
|
|
60
|
+
type: OpCode.CREATE_MAP;
|
|
61
|
+
parentId: string;
|
|
62
|
+
parentKey: string;
|
|
88
63
|
};
|
|
89
64
|
declare type CreateRegisterOp = {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
65
|
+
opId?: string;
|
|
66
|
+
id: string;
|
|
67
|
+
intent?: "set";
|
|
68
|
+
deletedId?: string;
|
|
69
|
+
type: OpCode.CREATE_REGISTER;
|
|
70
|
+
parentId: string;
|
|
71
|
+
parentKey: string;
|
|
72
|
+
data: Json;
|
|
98
73
|
};
|
|
99
74
|
declare type DeleteCrdtOp = {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
75
|
+
opId?: string;
|
|
76
|
+
id: string;
|
|
77
|
+
type: OpCode.DELETE_CRDT;
|
|
103
78
|
};
|
|
104
79
|
declare type SetParentKeyOp = {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
80
|
+
opId?: string;
|
|
81
|
+
id: string;
|
|
82
|
+
type: OpCode.SET_PARENT_KEY;
|
|
83
|
+
parentKey: string;
|
|
109
84
|
};
|
|
110
85
|
declare type DeleteObjectKeyOp = {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
86
|
+
opId?: string;
|
|
87
|
+
id: string;
|
|
88
|
+
type: OpCode.DELETE_OBJECT_KEY;
|
|
89
|
+
key: string;
|
|
115
90
|
};
|
|
116
91
|
|
|
117
92
|
declare enum ClientMsgCode {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
93
|
+
UPDATE_PRESENCE = 100,
|
|
94
|
+
BROADCAST_EVENT = 103,
|
|
95
|
+
FETCH_STORAGE = 200,
|
|
96
|
+
UPDATE_STORAGE = 201
|
|
122
97
|
}
|
|
123
98
|
/**
|
|
124
99
|
* Messages that can be sent from the client to the server.
|
|
125
100
|
*/
|
|
126
|
-
declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> =
|
|
127
|
-
| BroadcastEventClientMsg<TRoomEvent>
|
|
128
|
-
| UpdatePresenceClientMsg<TPresence>
|
|
129
|
-
| UpdateStorageClientMsg
|
|
130
|
-
| FetchStorageClientMsg;
|
|
101
|
+
declare type ClientMsg<TPresence extends JsonObject, TRoomEvent extends Json> = BroadcastEventClientMsg<TRoomEvent> | UpdatePresenceClientMsg<TPresence> | UpdateStorageClientMsg | FetchStorageClientMsg;
|
|
131
102
|
declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
|
|
132
|
-
|
|
133
|
-
|
|
103
|
+
type: ClientMsgCode.BROADCAST_EVENT;
|
|
104
|
+
event: TRoomEvent;
|
|
134
105
|
};
|
|
135
106
|
declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
107
|
+
type: ClientMsgCode.UPDATE_PRESENCE;
|
|
108
|
+
/**
|
|
109
|
+
* Set this to any number to signify that this is a Full Presence™
|
|
110
|
+
* update, not a patch.
|
|
111
|
+
*
|
|
112
|
+
* The numeric value itself no longer has specific meaning. Historically,
|
|
113
|
+
* this field was intended so that clients could ignore these broadcasted
|
|
114
|
+
* full presence messages, but it turned out that getting a full presence
|
|
115
|
+
* "keyframe" from time to time was useful.
|
|
116
|
+
*
|
|
117
|
+
* So nowadays, the presence (pun intended) of this `targetActor` field
|
|
118
|
+
* is a backward-compatible way of expressing that the `data` contains
|
|
119
|
+
* all presence fields, and isn't a partial "patch".
|
|
120
|
+
*/
|
|
121
|
+
targetActor: number;
|
|
122
|
+
data: TPresence;
|
|
123
|
+
} | {
|
|
124
|
+
type: ClientMsgCode.UPDATE_PRESENCE;
|
|
125
|
+
/**
|
|
126
|
+
* Absence of the `targetActor` field signifies that this is a Partial
|
|
127
|
+
* Presence™ "patch".
|
|
128
|
+
*/
|
|
129
|
+
targetActor?: undefined;
|
|
130
|
+
data: Partial<TPresence>;
|
|
139
131
|
};
|
|
140
132
|
declare type UpdateStorageClientMsg = {
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
type: ClientMsgCode.UPDATE_STORAGE;
|
|
134
|
+
ops: Op[];
|
|
143
135
|
};
|
|
144
136
|
declare type FetchStorageClientMsg = {
|
|
145
|
-
|
|
137
|
+
type: ClientMsgCode.FETCH_STORAGE;
|
|
146
138
|
};
|
|
147
139
|
|
|
148
140
|
declare type IdTuple<T> = [id: string, value: T];
|
|
149
141
|
declare enum CrdtType {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
142
|
+
OBJECT = 0,
|
|
143
|
+
LIST = 1,
|
|
144
|
+
MAP = 2,
|
|
145
|
+
REGISTER = 3
|
|
154
146
|
}
|
|
155
147
|
declare type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
156
|
-
declare type SerializedChild =
|
|
157
|
-
| SerializedObject
|
|
158
|
-
| SerializedList
|
|
159
|
-
| SerializedMap
|
|
160
|
-
| SerializedRegister;
|
|
148
|
+
declare type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
161
149
|
declare type SerializedRootObject = {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
150
|
+
type: CrdtType.OBJECT;
|
|
151
|
+
data: JsonObject;
|
|
152
|
+
parentId?: never;
|
|
153
|
+
parentKey?: never;
|
|
166
154
|
};
|
|
167
155
|
declare type SerializedObject = {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
156
|
+
type: CrdtType.OBJECT;
|
|
157
|
+
parentId: string;
|
|
158
|
+
parentKey: string;
|
|
159
|
+
data: JsonObject;
|
|
172
160
|
};
|
|
173
161
|
declare type SerializedList = {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
162
|
+
type: CrdtType.LIST;
|
|
163
|
+
parentId: string;
|
|
164
|
+
parentKey: string;
|
|
177
165
|
};
|
|
178
166
|
declare type SerializedMap = {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
167
|
+
type: CrdtType.MAP;
|
|
168
|
+
parentId: string;
|
|
169
|
+
parentKey: string;
|
|
182
170
|
};
|
|
183
171
|
declare type SerializedRegister = {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
172
|
+
type: CrdtType.REGISTER;
|
|
173
|
+
parentId: string;
|
|
174
|
+
parentKey: string;
|
|
175
|
+
data: Json;
|
|
188
176
|
};
|
|
189
177
|
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
190
178
|
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
@@ -192,43 +180,28 @@ declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
|
192
180
|
/**
|
|
193
181
|
* Lookup table for nodes (= SerializedCrdt values) by their IDs.
|
|
194
182
|
*/
|
|
195
|
-
declare type NodeMap = Map<
|
|
196
|
-
|
|
197
|
-
SerializedCrdt
|
|
198
|
-
>;
|
|
183
|
+
declare type NodeMap = Map<string, // Node ID
|
|
184
|
+
SerializedCrdt>;
|
|
199
185
|
/**
|
|
200
186
|
* Reverse lookup table for all child nodes (= list of SerializedCrdt values)
|
|
201
187
|
* by their parent node's IDs.
|
|
202
188
|
*/
|
|
203
|
-
declare type ParentToChildNodeMap = Map<
|
|
204
|
-
|
|
205
|
-
IdTuple<SerializedChild>[]
|
|
206
|
-
>;
|
|
189
|
+
declare type ParentToChildNodeMap = Map<string, // Parent's node ID
|
|
190
|
+
IdTuple<SerializedChild>[]>;
|
|
207
191
|
|
|
208
192
|
declare enum ServerMsgCode {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
193
|
+
UPDATE_PRESENCE = 100,
|
|
194
|
+
USER_JOINED = 101,
|
|
195
|
+
USER_LEFT = 102,
|
|
196
|
+
BROADCASTED_EVENT = 103,
|
|
197
|
+
ROOM_STATE = 104,
|
|
198
|
+
INITIAL_STORAGE_STATE = 200,
|
|
199
|
+
UPDATE_STORAGE = 201
|
|
216
200
|
}
|
|
217
201
|
/**
|
|
218
202
|
* Messages that can be sent from the server to the client.
|
|
219
203
|
*/
|
|
220
|
-
declare type ServerMsg<
|
|
221
|
-
TPresence extends JsonObject,
|
|
222
|
-
TUserMeta extends BaseUserMeta,
|
|
223
|
-
TRoomEvent extends Json
|
|
224
|
-
> =
|
|
225
|
-
| UpdatePresenceServerMsg<TPresence>
|
|
226
|
-
| UserJoinServerMsg<TUserMeta>
|
|
227
|
-
| UserLeftServerMsg
|
|
228
|
-
| BroadcastedEventServerMsg<TRoomEvent>
|
|
229
|
-
| RoomStateServerMsg<TUserMeta>
|
|
230
|
-
| InitialDocumentStateServerMsg
|
|
231
|
-
| UpdateStorageServerMsg;
|
|
204
|
+
declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg;
|
|
232
205
|
/**
|
|
233
206
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
234
207
|
* a User updated their presence. For example, when a user moves their cursor.
|
|
@@ -241,65 +214,65 @@ declare type ServerMsg<
|
|
|
241
214
|
* so all other existing clients can ignore this broadcasted message.
|
|
242
215
|
*/
|
|
243
216
|
declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
217
|
+
type: ServerMsgCode.UPDATE_PRESENCE;
|
|
218
|
+
/**
|
|
219
|
+
* The User whose Presence has changed.
|
|
220
|
+
*/
|
|
221
|
+
actor: number;
|
|
222
|
+
/**
|
|
223
|
+
* The partial or full Presence of a User. If the `targetActor` field is set,
|
|
224
|
+
* this will be the full Presence, otherwise it only contain the fields that
|
|
225
|
+
* have changed since the last broadcast.
|
|
226
|
+
*/
|
|
227
|
+
data: TPresence;
|
|
228
|
+
/**
|
|
229
|
+
* If this message was sent in response to a newly joined user, this field
|
|
230
|
+
* indicates which client this message is for. Other existing clients may
|
|
231
|
+
* ignore this message if this message isn't targeted for them.
|
|
232
|
+
*/
|
|
233
|
+
targetActor?: number;
|
|
261
234
|
};
|
|
262
235
|
/**
|
|
263
236
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
264
237
|
* a new User has joined the Room.
|
|
265
238
|
*/
|
|
266
239
|
declare type UserJoinServerMsg<TUserMeta extends BaseUserMeta> = {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
240
|
+
type: ServerMsgCode.USER_JOINED;
|
|
241
|
+
actor: number;
|
|
242
|
+
/**
|
|
243
|
+
* The id of the User that has been set in the authentication endpoint.
|
|
244
|
+
* Useful to get additional information about the connected user.
|
|
245
|
+
*/
|
|
246
|
+
id: TUserMeta["id"];
|
|
247
|
+
/**
|
|
248
|
+
* Additional user information that has been set in the authentication
|
|
249
|
+
* endpoint.
|
|
250
|
+
*/
|
|
251
|
+
info: TUserMeta["info"];
|
|
279
252
|
};
|
|
280
253
|
/**
|
|
281
254
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
282
255
|
* a new User has left the Room.
|
|
283
256
|
*/
|
|
284
257
|
declare type UserLeftServerMsg = {
|
|
285
|
-
|
|
286
|
-
|
|
258
|
+
type: ServerMsgCode.USER_LEFT;
|
|
259
|
+
actor: number;
|
|
287
260
|
};
|
|
288
261
|
/**
|
|
289
262
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
290
263
|
* a User broadcasted an Event to everyone in the Room.
|
|
291
264
|
*/
|
|
292
265
|
declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
266
|
+
type: ServerMsgCode.BROADCASTED_EVENT;
|
|
267
|
+
/**
|
|
268
|
+
* The User who broadcasted the Event.
|
|
269
|
+
*/
|
|
270
|
+
actor: number;
|
|
271
|
+
/**
|
|
272
|
+
* The arbitrary payload of the Event. This can be any JSON value. Clients
|
|
273
|
+
* will have to manually verify/decode this event.
|
|
274
|
+
*/
|
|
275
|
+
event: TRoomEvent;
|
|
303
276
|
};
|
|
304
277
|
/**
|
|
305
278
|
* Sent by the WebSocket server to a single client in response to the client
|
|
@@ -307,10 +280,10 @@ declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
|
|
|
307
280
|
* includes a list of all other Users that already are in the Room.
|
|
308
281
|
*/
|
|
309
282
|
declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
283
|
+
type: ServerMsgCode.ROOM_STATE;
|
|
284
|
+
users: {
|
|
285
|
+
[actor: number]: TUserMeta;
|
|
286
|
+
};
|
|
314
287
|
};
|
|
315
288
|
/**
|
|
316
289
|
* Sent by the WebSocket server to a single client in response to the client
|
|
@@ -318,8 +291,8 @@ declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
|
|
|
318
291
|
* payload includes the entire Storage document.
|
|
319
292
|
*/
|
|
320
293
|
declare type InitialDocumentStateServerMsg = {
|
|
321
|
-
|
|
322
|
-
|
|
294
|
+
type: ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
295
|
+
items: IdTuple<SerializedCrdt>[];
|
|
323
296
|
};
|
|
324
297
|
/**
|
|
325
298
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
@@ -329,8 +302,8 @@ declare type InitialDocumentStateServerMsg = {
|
|
|
329
302
|
* mutations to make to the initially loaded document).
|
|
330
303
|
*/
|
|
331
304
|
declare type UpdateStorageServerMsg = {
|
|
332
|
-
|
|
333
|
-
|
|
305
|
+
type: ServerMsgCode.UPDATE_STORAGE;
|
|
306
|
+
ops: Op[];
|
|
334
307
|
};
|
|
335
308
|
|
|
336
309
|
/**
|
|
@@ -369,28 +342,21 @@ declare function assertNever(_value: never, errmsg: string): never;
|
|
|
369
342
|
*/
|
|
370
343
|
declare function nn<T>(value: T, errmsg?: string): NonNullable<T>;
|
|
371
344
|
|
|
372
|
-
declare const SCOPES: readonly [
|
|
373
|
-
"websocket:presence",
|
|
374
|
-
"websocket:storage",
|
|
375
|
-
"room:read",
|
|
376
|
-
"room:write",
|
|
377
|
-
"rooms:read",
|
|
378
|
-
"rooms:write"
|
|
379
|
-
];
|
|
345
|
+
declare const SCOPES: readonly ["websocket:presence", "websocket:storage", "room:read", "room:write", "rooms:read", "rooms:write"];
|
|
380
346
|
declare type Scope = typeof SCOPES[number];
|
|
381
347
|
declare type AppOnlyAuthToken = {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
348
|
+
appId: string;
|
|
349
|
+
roomId?: never;
|
|
350
|
+
scopes: string[];
|
|
385
351
|
};
|
|
386
352
|
declare type RoomAuthToken = {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
353
|
+
appId: string;
|
|
354
|
+
roomId: string;
|
|
355
|
+
scopes: string[];
|
|
356
|
+
actor: number;
|
|
357
|
+
maxConnectionsPerRoom?: number;
|
|
358
|
+
id?: string;
|
|
359
|
+
info?: Json;
|
|
394
360
|
};
|
|
395
361
|
declare type AuthToken = AppOnlyAuthToken | RoomAuthToken;
|
|
396
362
|
declare function isScope(value: unknown): value is Scope;
|
|
@@ -413,11 +379,7 @@ declare function deprecate(message: string, key?: string): void;
|
|
|
413
379
|
* console if the first argument is truthy. Only in dev mode, and
|
|
414
380
|
* only once per message/key. In production, this is a no-op.
|
|
415
381
|
*/
|
|
416
|
-
declare function deprecateIf(
|
|
417
|
-
condition: unknown,
|
|
418
|
-
message: string,
|
|
419
|
-
key?: string
|
|
420
|
-
): void;
|
|
382
|
+
declare function deprecateIf(condition: unknown, message: string, key?: string): void;
|
|
421
383
|
/**
|
|
422
384
|
* Throws a deprecation error in the dev console.
|
|
423
385
|
*
|
|
@@ -434,21 +396,14 @@ declare function throwUsageError(message: string): void;
|
|
|
434
396
|
declare function errorIf(condition: unknown, message: string): void;
|
|
435
397
|
|
|
436
398
|
declare function lsonToJson(value: Lson): Json;
|
|
437
|
-
declare function patchLiveObjectKey<
|
|
438
|
-
|
|
439
|
-
K extends keyof O,
|
|
440
|
-
V extends Lson
|
|
441
|
-
>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
442
|
-
declare function patchImmutableObject<S extends JsonObject>(
|
|
443
|
-
state: S,
|
|
444
|
-
updates: StorageUpdate[]
|
|
445
|
-
): S;
|
|
399
|
+
declare function patchLiveObjectKey<O extends LsonObject, K extends keyof O, V extends Lson>(liveObject: LiveObject<O>, key: K, prev?: V, next?: V): void;
|
|
400
|
+
declare function patchImmutableObject<S extends JsonObject>(state: S, updates: StorageUpdate[]): S;
|
|
446
401
|
|
|
447
402
|
declare function makePosition(before?: string, after?: string): string;
|
|
448
403
|
declare function comparePosition(posA: string, posB: string): number;
|
|
449
404
|
|
|
450
405
|
declare function isPlainObject(blob: unknown): blob is {
|
|
451
|
-
|
|
406
|
+
[key: string]: unknown;
|
|
452
407
|
};
|
|
453
408
|
/**
|
|
454
409
|
* Alternative to JSON.parse() that will not throw in production. If the passed
|
|
@@ -460,68 +415,4 @@ declare function tryParseJson(rawMessage: string): Json | undefined;
|
|
|
460
415
|
*/
|
|
461
416
|
declare function b64decode(b64value: string): string;
|
|
462
417
|
|
|
463
|
-
export {
|
|
464
|
-
AppOnlyAuthToken,
|
|
465
|
-
AuthToken,
|
|
466
|
-
BroadcastEventClientMsg,
|
|
467
|
-
BroadcastedEventServerMsg,
|
|
468
|
-
ClientMsg,
|
|
469
|
-
ClientMsgCode,
|
|
470
|
-
CrdtType,
|
|
471
|
-
CreateChildOp,
|
|
472
|
-
CreateListOp,
|
|
473
|
-
CreateMapOp,
|
|
474
|
-
CreateObjectOp,
|
|
475
|
-
CreateOp,
|
|
476
|
-
CreateRegisterOp,
|
|
477
|
-
CreateRootObjectOp,
|
|
478
|
-
DeleteCrdtOp,
|
|
479
|
-
DeleteObjectKeyOp,
|
|
480
|
-
FetchStorageClientMsg,
|
|
481
|
-
IdTuple,
|
|
482
|
-
InitialDocumentStateServerMsg,
|
|
483
|
-
NodeMap,
|
|
484
|
-
Op,
|
|
485
|
-
OpCode,
|
|
486
|
-
ParentToChildNodeMap,
|
|
487
|
-
RoomAuthToken,
|
|
488
|
-
RoomStateServerMsg,
|
|
489
|
-
Scope,
|
|
490
|
-
SerializedChild,
|
|
491
|
-
SerializedCrdt,
|
|
492
|
-
SerializedList,
|
|
493
|
-
SerializedMap,
|
|
494
|
-
SerializedObject,
|
|
495
|
-
SerializedRegister,
|
|
496
|
-
SerializedRootObject,
|
|
497
|
-
ServerMsg,
|
|
498
|
-
ServerMsgCode,
|
|
499
|
-
SetParentKeyOp,
|
|
500
|
-
UpdateObjectOp,
|
|
501
|
-
UpdatePresenceClientMsg,
|
|
502
|
-
UpdatePresenceServerMsg,
|
|
503
|
-
UpdateStorageClientMsg,
|
|
504
|
-
UpdateStorageServerMsg,
|
|
505
|
-
UserJoinServerMsg,
|
|
506
|
-
UserLeftServerMsg,
|
|
507
|
-
assertNever,
|
|
508
|
-
b64decode,
|
|
509
|
-
comparePosition,
|
|
510
|
-
deprecate,
|
|
511
|
-
deprecateIf,
|
|
512
|
-
errorIf,
|
|
513
|
-
isAppOnlyAuthToken,
|
|
514
|
-
isAuthToken,
|
|
515
|
-
isChildCrdt,
|
|
516
|
-
isPlainObject,
|
|
517
|
-
isRoomAuthToken,
|
|
518
|
-
isRootCrdt,
|
|
519
|
-
isScope,
|
|
520
|
-
lsonToJson,
|
|
521
|
-
makePosition,
|
|
522
|
-
nn,
|
|
523
|
-
patchImmutableObject,
|
|
524
|
-
patchLiveObjectKey,
|
|
525
|
-
throwUsageError,
|
|
526
|
-
tryParseJson,
|
|
527
|
-
};
|
|
418
|
+
export { AppOnlyAuthToken, AuthToken, BroadcastEventClientMsg, BroadcastedEventServerMsg, ClientMsg, ClientMsgCode, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, DeleteCrdtOp, DeleteObjectKeyOp, FetchStorageClientMsg, IdTuple, InitialDocumentStateServerMsg, NodeMap, Op, OpCode, ParentToChildNodeMap, RoomAuthToken, RoomStateServerMsg, Scope, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, UserJoinServerMsg, UserLeftServerMsg, assertNever, b64decode, comparePosition, deprecate, deprecateIf, errorIf, isAppOnlyAuthToken, isAuthToken, isChildCrdt, isPlainObject, isRoomAuthToken, isRootCrdt, isScope, lsonToJson, makePosition, nn, patchImmutableObject, patchLiveObjectKey, throwUsageError, tryParseJson };
|