@liveblocks/core 0.19.6 → 0.19.8

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;
@@ -1582,4 +1587,4 @@ declare type EnsureJson<T> = [
1582
1587
  [K in keyof T]: EnsureJson<T[K]>;
1583
1588
  };
1584
1589
 
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 };
1590
+ 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.6" : "dev";
116
+ var VERSION = true ? "0.19.8" : "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);
@@ -2945,7 +2948,7 @@ function makeStateMachine(state, config, mockedEffects) {
2945
2948
  )
2946
2949
  );
2947
2950
  });
2948
- activeBatch.reverseOps.push(...reverse);
2951
+ activeBatch.reverseOps.unshift(...reverse);
2949
2952
  } else {
2950
2953
  batchUpdates(() => {
2951
2954
  addToUndoStack(reverse, doNotBatchUpdates);
@@ -3173,11 +3176,8 @@ function makeStateMachine(state, config, mockedEffects) {
3173
3176
  }
3174
3177
  const applyOpResult = applyOp(op, source);
3175
3178
  if (applyOpResult.modified) {
3176
- const parentId = applyOpResult.modified.node.parent.type === "HasParent" ? nn(
3177
- applyOpResult.modified.node.parent.node._id,
3178
- "Expected parent node to have an ID"
3179
- ) : void 0;
3180
- if (!parentId || !createdNodeIds.has(parentId)) {
3179
+ const nodeId = applyOpResult.modified.node._id;
3180
+ if (!(nodeId && createdNodeIds.has(nodeId))) {
3181
3181
  output.storageUpdates.set(
3182
3182
  nn(applyOpResult.modified.node._id),
3183
3183
  mergeStorageUpdates(
@@ -3190,7 +3190,7 @@ function makeStateMachine(state, config, mockedEffects) {
3190
3190
  output.reverse.unshift(...applyOpResult.reverse);
3191
3191
  }
3192
3192
  if (op.type === 2 /* CREATE_LIST */ || op.type === 7 /* CREATE_MAP */ || op.type === 4 /* CREATE_OBJECT */) {
3193
- createdNodeIds.add(nn(applyOpResult.modified.node._id));
3193
+ createdNodeIds.add(nn(op.id));
3194
3194
  }
3195
3195
  }
3196
3196
  }
@@ -3206,6 +3206,9 @@ function makeStateMachine(state, config, mockedEffects) {
3206
3206
  };
3207
3207
  }
3208
3208
  function applyOp(op, source) {
3209
+ if (isAckOp(op)) {
3210
+ return { modified: false };
3211
+ }
3209
3212
  switch (op.type) {
3210
3213
  case 6 /* DELETE_OBJECT_KEY */:
3211
3214
  case 3 /* UPDATE_OBJECT */:
@@ -3357,7 +3360,7 @@ function makeStateMachine(state, config, mockedEffects) {
3357
3360
  state.me.patch(patch);
3358
3361
  if (state.activeBatch) {
3359
3362
  if (options == null ? void 0 : options.addToHistory) {
3360
- state.activeBatch.reverseOps.push({
3363
+ state.activeBatch.reverseOps.unshift({
3361
3364
  type: "presence",
3362
3365
  data: oldValues
3363
3366
  });
@@ -4114,7 +4117,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
4114
4117
  const ws = WebSocketPolyfill || WebSocket;
4115
4118
  return (token) => {
4116
4119
  return new ws(
4117
- `${liveblocksServer}/?token=${token}&version=${true ? "0.19.6" : "dev"}`
4120
+ `${liveblocksServer}/?token=${token}&version=${true ? "0.19.8" : "dev"}`
4118
4121
  );
4119
4122
  };
4120
4123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/core",
3
- "version": "0.19.6",
3
+ "version": "0.19.8",
4
4
  "description": "Shared code and foundational internals for Liveblocks",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",