@liveblocks/client 0.16.8 → 0.16.9

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.js CHANGED
@@ -170,7 +170,7 @@ function makeStateMachine(state, context, mockedEffects) {
170
170
  var _applyOpResult$modifi, _result$reverse, parentId = null == (_applyOpResult$modifi = applyOpResult.modified.node._parent) ? void 0 : _applyOpResult$modifi._id;
171
171
  if (!createdNodeIds.has(parentId)) result.updates.storageUpdates.set(applyOpResult.modified.node._id, LiveObject.mergeStorageUpdates(result.updates.storageUpdates.get(applyOpResult.modified.node._id), applyOpResult.modified)),
172
172
  (_result$reverse = result.reverse).unshift.apply(_result$reverse, applyOpResult.reverse);
173
- op.type !== LiveObject.OpType.CreateList && op.type !== LiveObject.OpType.CreateMap && op.type !== LiveObject.OpType.CreateObject || createdNodeIds.add(applyOpResult.modified.node._id);
173
+ op.type !== LiveObject.OpCode.CREATE_LIST && op.type !== LiveObject.OpCode.CREATE_MAP && op.type !== LiveObject.OpCode.CREATE_OBJECT || createdNodeIds.add(applyOpResult.modified.node._id);
174
174
  }
175
175
  }
176
176
  }
@@ -178,15 +178,15 @@ function makeStateMachine(state, context, mockedEffects) {
178
178
  }
179
179
  function applyOp(op, isLocal) {
180
180
  switch (op.opId && state.offlineOperations.delete(op.opId), op.type) {
181
- case LiveObject.OpType.DeleteObjectKey:
182
- case LiveObject.OpType.UpdateObject:
183
- case LiveObject.OpType.DeleteCrdt:
181
+ case LiveObject.OpCode.DELETE_OBJECT_KEY:
182
+ case LiveObject.OpCode.UPDATE_OBJECT:
183
+ case LiveObject.OpCode.DELETE_CRDT:
184
184
  var item = state.items.get(op.id);
185
185
  return null == item ? {
186
186
  modified: !1
187
187
  } : item._apply(op, isLocal);
188
188
 
189
- case LiveObject.OpType.SetParentKey:
189
+ case LiveObject.OpCode.SET_PARENT_KEY:
190
190
  var _item = state.items.get(op.id);
191
191
  if (null == _item) return {
192
192
  modified: !1
@@ -201,10 +201,10 @@ function makeStateMachine(state, context, mockedEffects) {
201
201
  modified: !1
202
202
  };
203
203
 
204
- case LiveObject.OpType.CreateObject:
205
- case LiveObject.OpType.CreateList:
206
- case LiveObject.OpType.CreateMap:
207
- case LiveObject.OpType.CreateRegister:
204
+ case LiveObject.OpCode.CREATE_OBJECT:
205
+ case LiveObject.OpCode.CREATE_LIST:
206
+ case LiveObject.OpCode.CREATE_MAP:
207
+ case LiveObject.OpCode.CREATE_REGISTER:
208
208
  var parent = state.items.get(op.parentId);
209
209
  return null == parent ? {
210
210
  modified: !1
@@ -311,7 +311,7 @@ function makeStateMachine(state, context, mockedEffects) {
311
311
  id: message.id,
312
312
  _hasReceivedInitialPresence: !0
313
313
  }, state.me && (state.buffer.messages.push({
314
- type: LiveObject.ClientMessageType.UpdatePresence,
314
+ type: LiveObject.ClientMsgCode.UPDATE_PRESENCE,
315
315
  data: state.me,
316
316
  targetActor: message.actor
317
317
  }), tryFlushing()), {
@@ -334,34 +334,34 @@ function makeStateMachine(state, context, mockedEffects) {
334
334
  }, _iterator9 = LiveObject._createForOfIteratorHelperLoose(messages); !(_step9 = _iterator9()).done; ) {
335
335
  var message = _step9.value;
336
336
  switch (message.type) {
337
- case LiveObject.ServerMessageType.UserJoined:
337
+ case LiveObject.ServerMsgCode.USER_JOINED:
338
338
  updates.others.push(onUserJoinedMessage(message));
339
339
  break;
340
340
 
341
- case LiveObject.ServerMessageType.UpdatePresence:
341
+ case LiveObject.ServerMsgCode.UPDATE_PRESENCE:
342
342
  var othersPresenceUpdate = onUpdatePresenceMessage(message);
343
343
  othersPresenceUpdate && updates.others.push(othersPresenceUpdate);
344
344
  break;
345
345
 
346
- case LiveObject.ServerMessageType.Event:
346
+ case LiveObject.ServerMsgCode.BROADCASTED_EVENT:
347
347
  onEvent(message);
348
348
  break;
349
349
 
350
- case LiveObject.ServerMessageType.UserLeft:
350
+ case LiveObject.ServerMsgCode.USER_LEFT:
351
351
  var _event2 = onUserLeftMessage(message);
352
352
  _event2 && updates.others.push(_event2);
353
353
  break;
354
354
 
355
- case LiveObject.ServerMessageType.RoomState:
355
+ case LiveObject.ServerMsgCode.ROOM_STATE:
356
356
  updates.others.push(onRoomStateMessage(message));
357
357
  break;
358
358
 
359
- case LiveObject.ServerMessageType.InitialStorageState:
359
+ case LiveObject.ServerMsgCode.INITIAL_STORAGE_STATE:
360
360
  var offlineOps = new Map(state.offlineOperations);
361
361
  createOrUpdateRootFromMessage(message), applyAndSendOfflineOps(offlineOps), null == _getInitialStateResolver || _getInitialStateResolver();
362
362
  break;
363
363
 
364
- case LiveObject.ServerMessageType.UpdateStorage:
364
+ case LiveObject.ServerMsgCode.UPDATE_STORAGE:
365
365
  apply(message.ops, !1).updates.storageUpdates.forEach((function(value, key) {
366
366
  updates.storageUpdates.set(key, LiveObject.mergeStorageUpdates(updates.storageUpdates.get(key), value));
367
367
  }));
@@ -416,7 +416,7 @@ function makeStateMachine(state, context, mockedEffects) {
416
416
  state: "open"
417
417
  })), state.numberOfRetry = 0, void 0 !== state.lastConnectionId && (state.buffer.presence = state.me,
418
418
  tryFlushing()), state.lastConnectionId = state.connection.id, state.root && state.buffer.messages.push({
419
- type: LiveObject.ClientMessageType.FetchStorage
419
+ type: LiveObject.ClientMsgCode.FETCH_STORAGE
420
420
  }), tryFlushing());
421
421
  }
422
422
  function heartbeat() {
@@ -439,7 +439,7 @@ function makeStateMachine(state, context, mockedEffects) {
439
439
  if (0 !== offlineOps.size) {
440
440
  var messages = [], ops = Array.from(offlineOps.values()), result = apply(ops, !0);
441
441
  messages.push({
442
- type: LiveObject.ClientMessageType.UpdateStorage,
442
+ type: LiveObject.ClientMsgCode.UPDATE_STORAGE,
443
443
  ops: ops
444
444
  }), notify(result.updates), effects.send(messages);
445
445
  }
@@ -454,7 +454,7 @@ function makeStateMachine(state, context, mockedEffects) {
454
454
  var _messages = function(state) {
455
455
  var messages = [];
456
456
  state.buffer.presence && messages.push({
457
- type: LiveObject.ClientMessageType.UpdatePresence,
457
+ type: LiveObject.ClientMsgCode.UPDATE_PRESENCE,
458
458
  data: state.buffer.presence
459
459
  });
460
460
  for (var _step12, _iterator12 = LiveObject._createForOfIteratorHelperLoose(state.buffer.messages); !(_step12 = _iterator12()).done; ) {
@@ -462,7 +462,7 @@ function makeStateMachine(state, context, mockedEffects) {
462
462
  messages.push(_event3);
463
463
  }
464
464
  state.buffer.storageOperations.length > 0 && messages.push({
465
- type: LiveObject.ClientMessageType.UpdateStorage,
465
+ type: LiveObject.ClientMsgCode.UPDATE_STORAGE,
466
466
  ops: state.buffer.storageOperations
467
467
  });
468
468
  return messages;
@@ -566,7 +566,7 @@ function makeStateMachine(state, context, mockedEffects) {
566
566
  void 0 === options && (options = {
567
567
  shouldQueueEventIfNotReady: !1
568
568
  }), null == state.socket && 0 == options.shouldQueueEventIfNotReady || (state.buffer.messages.push({
569
- type: LiveObject.ClientMessageType.ClientEvent,
569
+ type: LiveObject.ClientMsgCode.BROADCAST_EVENT,
570
570
  event: event
571
571
  }), tryFlushing());
572
572
  },
@@ -630,7 +630,7 @@ function makeStateMachine(state, context, mockedEffects) {
630
630
  root: state.root
631
631
  });
632
632
  })) : (null == _getInitialStatePromise && (state.buffer.messages.push({
633
- type: LiveObject.ClientMessageType.FetchStorage
633
+ type: LiveObject.ClientMsgCode.FETCH_STORAGE
634
634
  }), tryFlushing(), _getInitialStatePromise = new Promise((function(resolve) {
635
635
  return _getInitialStateResolver = resolve;
636
636
  }))), _getInitialStatePromise.then((function() {
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AbstractCrdt, r as remove, S as ServerMessageType, m as mergeStorageUpdates, W as WebsocketCloseCodes, C as ClientMessageType, i as isTokenValid, a as isSameNodeOrChildOf, L as LiveObject, g as getTreesDiffOperations, O as OpType, b as LiveList, p as parseJson, c as isJsonArray, d as compact, e as isJsonObject, f as deprecateIf } from "./shared.mjs";
1
+ import { A as AbstractCrdt, r as remove, S as ServerMsgCode, m as mergeStorageUpdates, W as WebsocketCloseCodes, C as ClientMsgCode, i as isTokenValid, a as isSameNodeOrChildOf, L as LiveObject, g as getTreesDiffOperations, O as OpCode, b as LiveList, p as parseJson, c as isJsonArray, d as compact, e as isJsonObject, f as deprecateIf } from "./shared.mjs";
2
2
 
3
3
  export { b as LiveList, h as LiveMap, L as LiveObject } from "./shared.mjs";
4
4
 
@@ -153,16 +153,16 @@ function makeStateMachine(state, context, mockedEffects) {
153
153
  if (applyOpResult.modified) {
154
154
  const parentId = null === (_a = applyOpResult.modified.node._parent) || void 0 === _a ? void 0 : _a._id;
155
155
  createdNodeIds.has(parentId) || (result.updates.storageUpdates.set(applyOpResult.modified.node._id, mergeStorageUpdates(result.updates.storageUpdates.get(applyOpResult.modified.node._id), applyOpResult.modified)),
156
- result.reverse.unshift(...applyOpResult.reverse)), op.type !== OpType.CreateList && op.type !== OpType.CreateMap && op.type !== OpType.CreateObject || createdNodeIds.add(applyOpResult.modified.node._id);
156
+ result.reverse.unshift(...applyOpResult.reverse)), op.type !== OpCode.CREATE_LIST && op.type !== OpCode.CREATE_MAP && op.type !== OpCode.CREATE_OBJECT || createdNodeIds.add(applyOpResult.modified.node._id);
157
157
  }
158
158
  }
159
159
  return result;
160
160
  }
161
161
  function applyOp(op, isLocal) {
162
162
  switch (op.opId && state.offlineOperations.delete(op.opId), op.type) {
163
- case OpType.DeleteObjectKey:
164
- case OpType.UpdateObject:
165
- case OpType.DeleteCrdt:
163
+ case OpCode.DELETE_OBJECT_KEY:
164
+ case OpCode.UPDATE_OBJECT:
165
+ case OpCode.DELETE_CRDT:
166
166
  {
167
167
  const item = state.items.get(op.id);
168
168
  return null == item ? {
@@ -170,7 +170,7 @@ function makeStateMachine(state, context, mockedEffects) {
170
170
  } : item._apply(op, isLocal);
171
171
  }
172
172
 
173
- case OpType.SetParentKey:
173
+ case OpCode.SET_PARENT_KEY:
174
174
  {
175
175
  const item = state.items.get(op.id);
176
176
  if (null == item) return {
@@ -187,10 +187,10 @@ function makeStateMachine(state, context, mockedEffects) {
187
187
  };
188
188
  }
189
189
 
190
- case OpType.CreateObject:
191
- case OpType.CreateList:
192
- case OpType.CreateMap:
193
- case OpType.CreateRegister:
190
+ case OpCode.CREATE_OBJECT:
191
+ case OpCode.CREATE_LIST:
192
+ case OpCode.CREATE_MAP:
193
+ case OpCode.CREATE_REGISTER:
194
194
  {
195
195
  const parent = state.items.get(op.parentId);
196
196
  return null == parent ? {
@@ -291,7 +291,7 @@ function makeStateMachine(state, context, mockedEffects) {
291
291
  id: message.id,
292
292
  _hasReceivedInitialPresence: !0
293
293
  }, state.me && (state.buffer.messages.push({
294
- type: ClientMessageType.UpdatePresence,
294
+ type: ClientMsgCode.UPDATE_PRESENCE,
295
295
  data: state.me,
296
296
  targetActor: message.actor
297
297
  }), tryFlushing()), {
@@ -314,40 +314,40 @@ function makeStateMachine(state, context, mockedEffects) {
314
314
  others: []
315
315
  };
316
316
  for (const message of messages) switch (message.type) {
317
- case ServerMessageType.UserJoined:
317
+ case ServerMsgCode.USER_JOINED:
318
318
  updates.others.push(onUserJoinedMessage(message));
319
319
  break;
320
320
 
321
- case ServerMessageType.UpdatePresence:
321
+ case ServerMsgCode.UPDATE_PRESENCE:
322
322
  {
323
323
  const othersPresenceUpdate = onUpdatePresenceMessage(message);
324
324
  othersPresenceUpdate && updates.others.push(othersPresenceUpdate);
325
325
  break;
326
326
  }
327
327
 
328
- case ServerMessageType.Event:
328
+ case ServerMsgCode.BROADCASTED_EVENT:
329
329
  onEvent(message);
330
330
  break;
331
331
 
332
- case ServerMessageType.UserLeft:
332
+ case ServerMsgCode.USER_LEFT:
333
333
  {
334
334
  const event = onUserLeftMessage(message);
335
335
  event && updates.others.push(event);
336
336
  break;
337
337
  }
338
338
 
339
- case ServerMessageType.RoomState:
339
+ case ServerMsgCode.ROOM_STATE:
340
340
  updates.others.push(onRoomStateMessage(message));
341
341
  break;
342
342
 
343
- case ServerMessageType.InitialStorageState:
343
+ case ServerMsgCode.INITIAL_STORAGE_STATE:
344
344
  {
345
345
  const offlineOps = new Map(state.offlineOperations);
346
346
  createOrUpdateRootFromMessage(message), applyAndSendOfflineOps(offlineOps), null == _getInitialStateResolver || _getInitialStateResolver();
347
347
  break;
348
348
  }
349
349
 
350
- case ServerMessageType.UpdateStorage:
350
+ case ServerMsgCode.UPDATE_STORAGE:
351
351
  apply(message.ops, !1).updates.storageUpdates.forEach(((value, key) => {
352
352
  updates.storageUpdates.set(key, mergeStorageUpdates(updates.storageUpdates.get(key), value));
353
353
  }));
@@ -397,7 +397,7 @@ function makeStateMachine(state, context, mockedEffects) {
397
397
  state: "open"
398
398
  })), state.numberOfRetry = 0, void 0 !== state.lastConnectionId && (state.buffer.presence = state.me,
399
399
  tryFlushing()), state.lastConnectionId = state.connection.id, state.root && state.buffer.messages.push({
400
- type: ClientMessageType.FetchStorage
400
+ type: ClientMsgCode.FETCH_STORAGE
401
401
  }), tryFlushing());
402
402
  }
403
403
  function heartbeat() {
@@ -420,7 +420,7 @@ function makeStateMachine(state, context, mockedEffects) {
420
420
  if (0 === offlineOps.size) return;
421
421
  const messages = [], ops = Array.from(offlineOps.values()), result = apply(ops, !0);
422
422
  messages.push({
423
- type: ClientMessageType.UpdateStorage,
423
+ type: ClientMsgCode.UPDATE_STORAGE,
424
424
  ops: ops
425
425
  }), notify(result.updates), effects.send(messages);
426
426
  }
@@ -434,12 +434,12 @@ function makeStateMachine(state, context, mockedEffects) {
434
434
  const messages = function(state) {
435
435
  const messages = [];
436
436
  state.buffer.presence && messages.push({
437
- type: ClientMessageType.UpdatePresence,
437
+ type: ClientMsgCode.UPDATE_PRESENCE,
438
438
  data: state.buffer.presence
439
439
  });
440
440
  for (const event of state.buffer.messages) messages.push(event);
441
441
  state.buffer.storageOperations.length > 0 && messages.push({
442
- type: ClientMessageType.UpdateStorage,
442
+ type: ClientMsgCode.UPDATE_STORAGE,
443
443
  ops: state.buffer.storageOperations
444
444
  });
445
445
  return messages;
@@ -534,7 +534,7 @@ function makeStateMachine(state, context, mockedEffects) {
534
534
  shouldQueueEventIfNotReady: !1
535
535
  }) {
536
536
  null == state.socket && 0 == options.shouldQueueEventIfNotReady || (state.buffer.messages.push({
537
- type: ClientMessageType.ClientEvent,
537
+ type: ClientMsgCode.BROADCAST_EVENT,
538
538
  event: event
539
539
  }), tryFlushing());
540
540
  },
@@ -588,7 +588,7 @@ function makeStateMachine(state, context, mockedEffects) {
588
588
  return state.root ? new Promise((resolve => resolve({
589
589
  root: state.root
590
590
  }))) : (null == _getInitialStatePromise && (state.buffer.messages.push({
591
- type: ClientMessageType.FetchStorage
591
+ type: ClientMsgCode.FETCH_STORAGE
592
592
  }), tryFlushing(), _getInitialStatePromise = new Promise((resolve => _getInitialStateResolver = resolve))),
593
593
  _getInitialStatePromise.then((() => ({
594
594
  root: state.root
package/internal.d.ts CHANGED
@@ -4,23 +4,23 @@ export { g as Resolve, h as RoomInitializers } from './shared';
4
4
  /**
5
5
  * Messages that can be sent from the server to the client.
6
6
  */
7
- declare type ServerMessage<TPresence extends JsonObject> = UpdatePresenceMessage<TPresence> | UserJoinMessage | UserLeftMessage | EventMessage | RoomStateMessage | InitialDocumentStateMessage | UpdateStorageMessage;
8
- declare enum ServerMessageType {
9
- UpdatePresence = 100,
10
- UserJoined = 101,
11
- UserLeft = 102,
12
- Event = 103,
13
- RoomState = 104,
14
- InitialStorageState = 200,
15
- UpdateStorage = 201
7
+ declare type ServerMsg<TPresence extends JsonObject> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg | UserLeftServerMsg | BroadcastedEventServerMsg | RoomStateServerMsg | InitialDocumentStateServerMsg | UpdateStorageServerMsg;
8
+ declare enum ServerMsgCode {
9
+ UPDATE_PRESENCE = 100,
10
+ USER_JOINED = 101,
11
+ USER_LEFT = 102,
12
+ BROADCASTED_EVENT = 103,
13
+ ROOM_STATE = 104,
14
+ INITIAL_STORAGE_STATE = 200,
15
+ UPDATE_STORAGE = 201
16
16
  }
17
17
  /**
18
18
  * Sent by the WebSocket server to a single client in response to the client
19
19
  * joining the Room, to provide the initial state of the Room. The payload
20
20
  * includes a list of all other Users that already are in the Room.
21
21
  */
22
- declare type RoomStateMessage = {
23
- type: ServerMessageType.RoomState;
22
+ declare type RoomStateServerMsg = {
23
+ type: ServerMsgCode.ROOM_STATE;
24
24
  users: {
25
25
  [actor: number]: {
26
26
  id?: string;
@@ -39,8 +39,8 @@ declare type RoomStateMessage = {
39
39
  * those cases, the `targetActor` field indicates the newly connected client,
40
40
  * so all other existing clients can ignore this broadcasted message.
41
41
  */
42
- declare type UpdatePresenceMessage<TPresence extends JsonObject> = {
43
- type: ServerMessageType.UpdatePresence;
42
+ declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
43
+ type: ServerMsgCode.UPDATE_PRESENCE;
44
44
  /**
45
45
  * The User whose Presence has changed.
46
46
  */
@@ -62,8 +62,8 @@ declare type UpdatePresenceMessage<TPresence extends JsonObject> = {
62
62
  * Sent by the WebSocket server and broadcasted to all clients to announce that
63
63
  * a new User has joined the Room.
64
64
  */
65
- declare type UserJoinMessage = {
66
- type: ServerMessageType.UserJoined;
65
+ declare type UserJoinServerMsg = {
66
+ type: ServerMsgCode.USER_JOINED;
67
67
  actor: number;
68
68
  /**
69
69
  * The id of the User that has been set in the authentication endpoint.
@@ -80,16 +80,16 @@ declare type UserJoinMessage = {
80
80
  * Sent by the WebSocket server and broadcasted to all clients to announce that
81
81
  * a new User has left the Room.
82
82
  */
83
- declare type UserLeftMessage = {
84
- type: ServerMessageType.UserLeft;
83
+ declare type UserLeftServerMsg = {
84
+ type: ServerMsgCode.USER_LEFT;
85
85
  actor: number;
86
86
  };
87
87
  /**
88
88
  * Sent by the WebSocket server and broadcasted to all clients to announce that
89
89
  * a User broadcasted an Event to everyone in the Room.
90
90
  */
91
- declare type EventMessage = {
92
- type: ServerMessageType.Event;
91
+ declare type BroadcastedEventServerMsg = {
92
+ type: ServerMsgCode.BROADCASTED_EVENT;
93
93
  /**
94
94
  * The User who broadcasted the Event.
95
95
  */
@@ -106,8 +106,8 @@ declare type SerializedCrdtWithId = [id: string, crdt: SerializedCrdt];
106
106
  * joining the Room, to provide the initial Storage state of the Room. The
107
107
  * payload includes the entire Storage document.
108
108
  */
109
- declare type InitialDocumentStateMessage = {
110
- type: ServerMessageType.InitialStorageState;
109
+ declare type InitialDocumentStateServerMsg = {
110
+ type: ServerMsgCode.INITIAL_STORAGE_STATE;
111
111
  items: SerializedCrdtWithId[];
112
112
  };
113
113
  /**
@@ -117,72 +117,72 @@ declare type InitialDocumentStateMessage = {
117
117
  * The payload of this message contains a list of Ops (aka incremental
118
118
  * mutations to make to the initially loaded document).
119
119
  */
120
- declare type UpdateStorageMessage = {
121
- type: ServerMessageType.UpdateStorage;
120
+ declare type UpdateStorageServerMsg = {
121
+ type: ServerMsgCode.UPDATE_STORAGE;
122
122
  ops: Op[];
123
123
  };
124
- declare enum ClientMessageType {
125
- UpdatePresence = 100,
126
- ClientEvent = 103,
127
- FetchStorage = 200,
128
- UpdateStorage = 201
124
+ declare enum ClientMsgCode {
125
+ UPDATE_PRESENCE = 100,
126
+ BROADCAST_EVENT = 103,
127
+ FETCH_STORAGE = 200,
128
+ UPDATE_STORAGE = 201
129
129
  }
130
130
  declare enum CrdtType {
131
- Object = 0,
132
- List = 1,
133
- Map = 2,
134
- Register = 3
131
+ OBJECT = 0,
132
+ LIST = 1,
133
+ MAP = 2,
134
+ REGISTER = 3
135
135
  }
136
136
  declare type SerializedObject = {
137
- type: CrdtType.Object;
137
+ type: CrdtType.OBJECT;
138
138
  parentId?: string;
139
139
  parentKey?: string;
140
140
  data: JsonObject;
141
141
  };
142
142
  declare type SerializedList = {
143
- type: CrdtType.List;
143
+ type: CrdtType.LIST;
144
144
  parentId: string;
145
145
  parentKey: string;
146
146
  };
147
147
  declare type SerializedMap = {
148
- type: CrdtType.Map;
148
+ type: CrdtType.MAP;
149
149
  parentId: string;
150
150
  parentKey: string;
151
151
  };
152
152
  declare type SerializedRegister = {
153
- type: CrdtType.Register;
153
+ type: CrdtType.REGISTER;
154
154
  parentId: string;
155
155
  parentKey: string;
156
156
  data: Json;
157
157
  };
158
158
  declare type SerializedCrdt = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
159
- declare enum OpType {
160
- Init = 0,
161
- SetParentKey = 1,
162
- CreateList = 2,
163
- UpdateObject = 3,
164
- CreateObject = 4,
165
- DeleteCrdt = 5,
166
- DeleteObjectKey = 6,
167
- CreateMap = 7,
168
- CreateRegister = 8
159
+ declare enum OpCode {
160
+ INIT = 0,
161
+ SET_PARENT_KEY = 1,
162
+ CREATE_LIST = 2,
163
+ UPDATE_OBJECT = 3,
164
+ CREATE_OBJECT = 4,
165
+ DELETE_CRDT = 5,
166
+ DELETE_OBJECT_KEY = 6,
167
+ CREATE_MAP = 7,
168
+ CREATE_REGISTER = 8
169
169
  }
170
170
  /**
171
- * These operations are the payload for {@link UpdateStorageMessage} messages
171
+ * These operations are the payload for {@link UpdateStorageServerMsg} messages
172
172
  * only.
173
173
  */
174
174
  declare type Op = CreateObjectOp | UpdateObjectOp | DeleteCrdtOp | CreateListOp | SetParentKeyOp | DeleteObjectKeyOp | CreateMapOp | CreateRegisterOp;
175
175
  declare type UpdateObjectOp = {
176
176
  opId?: string;
177
177
  id: string;
178
- type: OpType.UpdateObject;
178
+ type: OpCode.UPDATE_OBJECT;
179
179
  data: Partial<JsonObject>;
180
180
  };
181
181
  declare type CreateObjectOp = {
182
182
  opId?: string;
183
183
  id: string;
184
184
  intent?: "set";
185
- type: OpType.CreateObject;
185
+ type: OpCode.CREATE_OBJECT;
186
186
  parentId?: string;
187
187
  parentKey?: string;
188
188
  data: JsonObject;
@@ -191,7 +191,7 @@ declare type CreateListOp = {
191
191
  opId?: string;
192
192
  id: string;
193
193
  intent?: "set";
194
- type: OpType.CreateList;
194
+ type: OpCode.CREATE_LIST;
195
195
  parentId: string;
196
196
  parentKey: string;
197
197
  };
@@ -199,7 +199,7 @@ declare type CreateMapOp = {
199
199
  opId?: string;
200
200
  id: string;
201
201
  intent?: "set";
202
- type: OpType.CreateMap;
202
+ type: OpCode.CREATE_MAP;
203
203
  parentId: string;
204
204
  parentKey: string;
205
205
  };
@@ -207,7 +207,7 @@ declare type CreateRegisterOp = {
207
207
  opId?: string;
208
208
  id: string;
209
209
  intent?: "set";
210
- type: OpType.CreateRegister;
210
+ type: OpCode.CREATE_REGISTER;
211
211
  parentId: string;
212
212
  parentKey: string;
213
213
  data: Json;
@@ -215,18 +215,18 @@ declare type CreateRegisterOp = {
215
215
  declare type DeleteCrdtOp = {
216
216
  opId?: string;
217
217
  id: string;
218
- type: OpType.DeleteCrdt;
218
+ type: OpCode.DELETE_CRDT;
219
219
  };
220
220
  declare type SetParentKeyOp = {
221
221
  opId?: string;
222
222
  id: string;
223
- type: OpType.SetParentKey;
223
+ type: OpCode.SET_PARENT_KEY;
224
224
  parentKey: string;
225
225
  };
226
226
  declare type DeleteObjectKeyOp = {
227
227
  opId?: string;
228
228
  id: string;
229
- type: OpType.DeleteObjectKey;
229
+ type: OpCode.DELETE_OBJECT_KEY;
230
230
  key: string;
231
231
  };
232
232
  declare enum WebsocketCloseCodes {
@@ -278,4 +278,4 @@ declare function patchImmutableObject<T>(state: T, updates: StorageUpdate[]): T;
278
278
  declare function makePosition(before?: string, after?: string): string;
279
279
  declare function comparePosition(posA: string, posB: string): number;
280
280
 
281
- export { ClientMessageType, CrdtType, CreateListOp, CreateMapOp, CreateObjectOp, CreateRegisterOp, DeleteCrdtOp, DeleteObjectKeyOp, Op, OpType, RoomStateMessage, SerializedCrdt, SerializedCrdtWithId, SerializedList, SerializedMap, SerializedObject, SerializedRegister, ServerMessage, ServerMessageType, SetParentKeyOp, UpdateObjectOp, UserJoinMessage, WebsocketCloseCodes, comparePosition, deprecate, deprecateIf, errorIf, lsonToJson, makePosition, patchImmutableObject, patchLiveObjectKey, throwUsageError };
281
+ export { ClientMsgCode, CrdtType, CreateListOp, CreateMapOp, CreateObjectOp, CreateRegisterOp, DeleteCrdtOp, DeleteObjectKeyOp, Op, OpCode, RoomStateServerMsg, SerializedCrdt, SerializedCrdtWithId, SerializedList, SerializedMap, SerializedObject, SerializedRegister, ServerMsg, ServerMsgCode, SetParentKeyOp, UpdateObjectOp, UserJoinServerMsg, WebsocketCloseCodes, comparePosition, deprecate, deprecateIf, errorIf, lsonToJson, makePosition, patchImmutableObject, patchLiveObjectKey, throwUsageError };
package/internal.js CHANGED
@@ -140,25 +140,25 @@ function patchImmutableNode(state, path, update) {
140
140
  _extends2));
141
141
  }
142
142
 
143
- Object.defineProperty(exports, "ClientMessageType", {
143
+ Object.defineProperty(exports, "ClientMsgCode", {
144
144
  enumerable: !0,
145
145
  get: function() {
146
- return LiveObject.ClientMessageType;
146
+ return LiveObject.ClientMsgCode;
147
147
  }
148
148
  }), Object.defineProperty(exports, "CrdtType", {
149
149
  enumerable: !0,
150
150
  get: function() {
151
151
  return LiveObject.CrdtType;
152
152
  }
153
- }), Object.defineProperty(exports, "OpType", {
153
+ }), Object.defineProperty(exports, "OpCode", {
154
154
  enumerable: !0,
155
155
  get: function() {
156
- return LiveObject.OpType;
156
+ return LiveObject.OpCode;
157
157
  }
158
- }), Object.defineProperty(exports, "ServerMessageType", {
158
+ }), Object.defineProperty(exports, "ServerMsgCode", {
159
159
  enumerable: !0,
160
160
  get: function() {
161
- return LiveObject.ServerMessageType;
161
+ return LiveObject.ServerMsgCode;
162
162
  }
163
163
  }), Object.defineProperty(exports, "WebsocketCloseCodes", {
164
164
  enumerable: !0,
package/internal.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { L as LiveObject, b as LiveList, h as LiveMap, j as LiveRegister, A as AbstractCrdt, k as findNonSerializableValue } from "./shared.mjs";
2
2
 
3
- export { C as ClientMessageType, o as CrdtType, O as OpType, S as ServerMessageType, W as WebsocketCloseCodes, q as comparePosition, l as deprecate, f as deprecateIf, n as errorIf, s as makePosition, t as throwUsageError } from "./shared.mjs";
3
+ export { C as ClientMsgCode, o as CrdtType, O as OpCode, S as ServerMsgCode, W as WebsocketCloseCodes, q as comparePosition, l as deprecate, f as deprecateIf, n as errorIf, s as makePosition, t as throwUsageError } from "./shared.mjs";
4
4
 
5
5
  function lsonObjectToJson(obj) {
6
6
  const result = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/client",
3
- "version": "0.16.8",
3
+ "version": "0.16.9",
4
4
  "description": "A client that lets you interact with Liveblocks servers.",
5
5
  "main": "./index.js",
6
6
  "module": "./index.mjs",