@liveblocks/core 0.19.7 → 0.19.9-beta1

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
@@ -33,7 +33,7 @@ declare enum OpCode {
33
33
  * These operations are the payload for {@link UpdateStorageServerMsg} messages
34
34
  * only.
35
35
  */
36
- declare type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
36
+ declare type Op = AckOp | CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | DeleteObjectKeyOp;
37
37
  declare type CreateOp = CreateRootObjectOp | CreateChildOp;
38
38
  declare type CreateChildOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
39
39
  declare type UpdateObjectOp = {
@@ -93,6 +93,11 @@ declare type DeleteCrdtOp = {
93
93
  readonly id: string;
94
94
  readonly type: OpCode.DELETE_CRDT;
95
95
  };
96
+ declare type AckOp = {
97
+ readonly type: OpCode.DELETE_CRDT;
98
+ readonly id: "ACK";
99
+ readonly opId: string;
100
+ };
96
101
  declare type SetParentKeyOp = {
97
102
  readonly opId?: string;
98
103
  readonly id: string;
@@ -1287,12 +1292,13 @@ declare enum ServerMsgCode {
1287
1292
  BROADCASTED_EVENT = 103,
1288
1293
  ROOM_STATE = 104,
1289
1294
  INITIAL_STORAGE_STATE = 200,
1290
- UPDATE_STORAGE = 201
1295
+ UPDATE_STORAGE = 201,
1296
+ REJECT_STORAGE_OP = 299
1291
1297
  }
1292
1298
  /**
1293
1299
  * Messages that can be sent from the server to the client.
1294
1300
  */
1295
- declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg;
1301
+ declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserMeta, TRoomEvent extends Json> = UpdatePresenceServerMsg<TPresence> | UserJoinServerMsg<TUserMeta> | UserLeftServerMsg | BroadcastedEventServerMsg<TRoomEvent> | RoomStateServerMsg<TUserMeta> | InitialDocumentStateServerMsg | UpdateStorageServerMsg | RejectedStorageOpServerMsg;
1296
1302
  /**
1297
1303
  * Sent by the WebSocket server and broadcasted to all clients to announce that
1298
1304
  * a User updated their presence. For example, when a user moves their cursor.
@@ -1424,6 +1430,16 @@ declare type UpdateStorageServerMsg = {
1424
1430
  readonly type: ServerMsgCode.UPDATE_STORAGE;
1425
1431
  readonly ops: Op[];
1426
1432
  };
1433
+ /**
1434
+ * Sent by the WebSocket server to the client to indicate that certain opIds
1435
+ * have been received but were rejected because they caused mutations that are
1436
+ * incompatible with the Room's schema.
1437
+ */
1438
+ declare type RejectedStorageOpServerMsg = {
1439
+ readonly type: ServerMsgCode.REJECT_STORAGE_OP;
1440
+ readonly opIds: string[];
1441
+ readonly reason: string;
1442
+ };
1427
1443
 
1428
1444
  /**
1429
1445
  * Lookup table for nodes (= SerializedCrdt values) by their IDs.
@@ -1582,4 +1598,4 @@ declare type EnsureJson<T> = [
1582
1598
  [K in keyof T]: EnsureJson<T[K]>;
1583
1599
  };
1584
1600
 
1585
- export { AppOnlyAuthToken, AuthToken, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, ConnectionState, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, FetchStorageClientMsg, History, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonObject, LiveList, LiveMap, LiveNode, LiveObject, LiveStructure, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, Resolve, Room, RoomAuthToken, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, StorageStatus, StorageUpdate, ToImmutable, ToJson, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, asArrayWithLegacyMethods, assertNever, b64decode, comparePosition, createClient, deprecate, deprecateIf, errorIf, freeze, isAppOnlyAuthToken, isAuthToken, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isPlainObject, isRoomAuthToken, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, tryParseJson };
1601
+ export { AckOp, AppOnlyAuthToken, AuthToken, BaseUserMeta, BroadcastEventClientMsg, BroadcastOptions, BroadcastedEventServerMsg, Client, ClientMsg, ClientMsgCode, ConnectionState, CrdtType, CreateChildOp, CreateListOp, CreateMapOp, CreateObjectOp, CreateOp, CreateRegisterOp, CreateRootObjectOp, DeleteCrdtOp, DeleteObjectKeyOp, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, EnsureJson, FetchStorageClientMsg, History, IdTuple, Immutable, InitialDocumentStateServerMsg, Json, JsonArray, JsonObject, JsonScalar, LiveList, LiveMap, LiveNode, LiveObject, LiveStructure, Lson, LsonObject, NodeMap, Op, OpCode, Others, ParentToChildNodeMap, Resolve, Room, RoomAuthToken, RoomInitializers, RoomStateServerMsg, SerializedChild, SerializedCrdt, SerializedList, SerializedMap, SerializedObject, SerializedRegister, SerializedRootObject, ServerMsg, ServerMsgCode, SetParentKeyOp, StorageStatus, StorageUpdate, ToImmutable, ToJson, UpdateObjectOp, UpdatePresenceClientMsg, UpdatePresenceServerMsg, UpdateStorageClientMsg, UpdateStorageServerMsg, User, UserJoinServerMsg, UserLeftServerMsg, WebsocketCloseCodes, asArrayWithLegacyMethods, assertNever, b64decode, comparePosition, createClient, deprecate, deprecateIf, errorIf, freeze, isAppOnlyAuthToken, isAuthToken, isChildCrdt, isJsonArray, isJsonObject, isJsonScalar, isPlainObject, isRoomAuthToken, isRootCrdt, legacy_patchImmutableObject, lsonToJson, makePosition, nn, patchLiveObjectKey, shallow, throwUsageError, tryParseJson };
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
113
113
  var onMessageFromPanel = eventSource.observable;
114
114
 
115
115
  // src/devtools/index.ts
116
- var VERSION = true ? "0.19.7" : "dev";
116
+ var VERSION = true ? "0.19.9-beta1" : "dev";
117
117
  var _devtoolsSetupHasRun = false;
118
118
  function setupDevTools(getAllRooms) {
119
119
  if (process.env.NODE_ENV === "production" || typeof window === "undefined") {
@@ -340,6 +340,9 @@ var OpCode = /* @__PURE__ */ ((OpCode2) => {
340
340
  OpCode2[OpCode2["CREATE_REGISTER"] = 8] = "CREATE_REGISTER";
341
341
  return OpCode2;
342
342
  })(OpCode || {});
343
+ function isAckOp(op) {
344
+ return op.type === 5 /* DELETE_CRDT */ && op.id === "ACK";
345
+ }
343
346
 
344
347
  // src/crdts/AbstractCrdt.ts
345
348
  function crdtAsLiveNode(value) {
@@ -2079,7 +2082,7 @@ var LiveObject = class extends AbstractCrdt {
2079
2082
  if (op.type === 3 /* UPDATE_OBJECT */) {
2080
2083
  return this._applyUpdate(op, isLocal);
2081
2084
  } else if (op.type === 6 /* DELETE_OBJECT_KEY */) {
2082
- return this._applyDeleteObjectKey(op);
2085
+ return this._applyDeleteObjectKey(op, isLocal);
2083
2086
  }
2084
2087
  return super._apply(op, isLocal);
2085
2088
  }
@@ -2162,12 +2165,12 @@ var LiveObject = class extends AbstractCrdt {
2162
2165
  reverse
2163
2166
  } : { modified: false };
2164
2167
  }
2165
- _applyDeleteObjectKey(op) {
2168
+ _applyDeleteObjectKey(op, isLocal) {
2166
2169
  const key = op.key;
2167
2170
  if (this._map.has(key) === false) {
2168
2171
  return { modified: false };
2169
2172
  }
2170
- if (this._propToLastUpdate.get(key) !== void 0) {
2173
+ if (!isLocal && this._propToLastUpdate.get(key) !== void 0) {
2171
2174
  return { modified: false };
2172
2175
  }
2173
2176
  const oldValue = this._map.get(key);
@@ -2692,6 +2695,7 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
2692
2695
  ServerMsgCode2[ServerMsgCode2["ROOM_STATE"] = 104] = "ROOM_STATE";
2693
2696
  ServerMsgCode2[ServerMsgCode2["INITIAL_STORAGE_STATE"] = 200] = "INITIAL_STORAGE_STATE";
2694
2697
  ServerMsgCode2[ServerMsgCode2["UPDATE_STORAGE"] = 201] = "UPDATE_STORAGE";
2698
+ ServerMsgCode2[ServerMsgCode2["REJECT_STORAGE_OP"] = 299] = "REJECT_STORAGE_OP";
2695
2699
  return ServerMsgCode2;
2696
2700
  })(ServerMsgCode || {});
2697
2701
 
@@ -2945,7 +2949,7 @@ function makeStateMachine(state, config, mockedEffects) {
2945
2949
  )
2946
2950
  );
2947
2951
  });
2948
- activeBatch.reverseOps.push(...reverse);
2952
+ activeBatch.reverseOps.unshift(...reverse);
2949
2953
  } else {
2950
2954
  batchUpdates(() => {
2951
2955
  addToUndoStack(reverse, doNotBatchUpdates);
@@ -3203,6 +3207,9 @@ function makeStateMachine(state, config, mockedEffects) {
3203
3207
  };
3204
3208
  }
3205
3209
  function applyOp(op, source) {
3210
+ if (isAckOp(op)) {
3211
+ return { modified: false };
3212
+ }
3206
3213
  switch (op.type) {
3207
3214
  case 6 /* DELETE_OBJECT_KEY */:
3208
3215
  case 3 /* UPDATE_OBJECT */:
@@ -3354,7 +3361,7 @@ function makeStateMachine(state, config, mockedEffects) {
3354
3361
  state.me.patch(patch);
3355
3362
  if (state.activeBatch) {
3356
3363
  if (options == null ? void 0 : options.addToHistory) {
3357
- state.activeBatch.reverseOps.push({
3364
+ state.activeBatch.reverseOps.unshift({
3358
3365
  type: "presence",
3359
3366
  data: oldValues
3360
3367
  });
@@ -4111,7 +4118,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
4111
4118
  const ws = WebSocketPolyfill || WebSocket;
4112
4119
  return (token) => {
4113
4120
  return new ws(
4114
- `${liveblocksServer}/?token=${token}&version=${true ? "0.19.7" : "dev"}`
4121
+ `${liveblocksServer}/?token=${token}&version=${true ? "0.19.9-beta1" : "dev"}`
4115
4122
  );
4116
4123
  };
4117
4124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/core",
3
- "version": "0.19.7",
3
+ "version": "0.19.9-beta1",
4
4
  "description": "Shared code and foundational internals for Liveblocks",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",