@liveblocks/core 0.19.1-test2 → 0.19.2-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/dist/index.d.ts +103 -103
- package/dist/index.js +57 -39
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -37,73 +37,73 @@ declare type Op = CreateOp | UpdateObjectOp | DeleteCrdtOp | SetParentKeyOp | De
|
|
|
37
37
|
declare type CreateOp = CreateRootObjectOp | CreateChildOp;
|
|
38
38
|
declare type CreateChildOp = CreateObjectOp | CreateRegisterOp | CreateMapOp | CreateListOp;
|
|
39
39
|
declare type UpdateObjectOp = {
|
|
40
|
-
opId?: string;
|
|
41
|
-
id: string;
|
|
42
|
-
type: OpCode.UPDATE_OBJECT;
|
|
43
|
-
data: Partial<JsonObject>;
|
|
40
|
+
readonly opId?: string;
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly type: OpCode.UPDATE_OBJECT;
|
|
43
|
+
readonly data: Partial<JsonObject>;
|
|
44
44
|
};
|
|
45
45
|
declare type CreateObjectOp = {
|
|
46
|
-
opId?: string;
|
|
47
|
-
id: string;
|
|
48
|
-
intent?: "set";
|
|
49
|
-
deletedId?: string;
|
|
50
|
-
type: OpCode.CREATE_OBJECT;
|
|
51
|
-
parentId: string;
|
|
52
|
-
parentKey: string;
|
|
53
|
-
data: JsonObject;
|
|
46
|
+
readonly opId?: string;
|
|
47
|
+
readonly id: string;
|
|
48
|
+
readonly intent?: "set";
|
|
49
|
+
readonly deletedId?: string;
|
|
50
|
+
readonly type: OpCode.CREATE_OBJECT;
|
|
51
|
+
readonly parentId: string;
|
|
52
|
+
readonly parentKey: string;
|
|
53
|
+
readonly data: JsonObject;
|
|
54
54
|
};
|
|
55
55
|
declare type CreateRootObjectOp = {
|
|
56
|
-
opId?: string;
|
|
57
|
-
id: string;
|
|
58
|
-
type: OpCode.CREATE_OBJECT;
|
|
59
|
-
data: JsonObject;
|
|
60
|
-
parentId?: never;
|
|
61
|
-
parentKey?: never;
|
|
56
|
+
readonly opId?: string;
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly type: OpCode.CREATE_OBJECT;
|
|
59
|
+
readonly data: JsonObject;
|
|
60
|
+
readonly parentId?: never;
|
|
61
|
+
readonly parentKey?: never;
|
|
62
62
|
};
|
|
63
63
|
declare type CreateListOp = {
|
|
64
|
-
opId?: string;
|
|
65
|
-
id: string;
|
|
66
|
-
intent?: "set";
|
|
67
|
-
deletedId?: string;
|
|
68
|
-
type: OpCode.CREATE_LIST;
|
|
69
|
-
parentId: string;
|
|
70
|
-
parentKey: string;
|
|
64
|
+
readonly opId?: string;
|
|
65
|
+
readonly id: string;
|
|
66
|
+
readonly intent?: "set";
|
|
67
|
+
readonly deletedId?: string;
|
|
68
|
+
readonly type: OpCode.CREATE_LIST;
|
|
69
|
+
readonly parentId: string;
|
|
70
|
+
readonly parentKey: string;
|
|
71
71
|
};
|
|
72
72
|
declare type CreateMapOp = {
|
|
73
|
-
opId?: string;
|
|
74
|
-
id: string;
|
|
75
|
-
intent?: "set";
|
|
76
|
-
deletedId?: string;
|
|
77
|
-
type: OpCode.CREATE_MAP;
|
|
78
|
-
parentId: string;
|
|
79
|
-
parentKey: string;
|
|
73
|
+
readonly opId?: string;
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly intent?: "set";
|
|
76
|
+
readonly deletedId?: string;
|
|
77
|
+
readonly type: OpCode.CREATE_MAP;
|
|
78
|
+
readonly parentId: string;
|
|
79
|
+
readonly parentKey: string;
|
|
80
80
|
};
|
|
81
81
|
declare type CreateRegisterOp = {
|
|
82
|
-
opId?: string;
|
|
83
|
-
id: string;
|
|
84
|
-
intent?: "set";
|
|
85
|
-
deletedId?: string;
|
|
86
|
-
type: OpCode.CREATE_REGISTER;
|
|
87
|
-
parentId: string;
|
|
88
|
-
parentKey: string;
|
|
89
|
-
data: Json;
|
|
82
|
+
readonly opId?: string;
|
|
83
|
+
readonly id: string;
|
|
84
|
+
readonly intent?: "set";
|
|
85
|
+
readonly deletedId?: string;
|
|
86
|
+
readonly type: OpCode.CREATE_REGISTER;
|
|
87
|
+
readonly parentId: string;
|
|
88
|
+
readonly parentKey: string;
|
|
89
|
+
readonly data: Json;
|
|
90
90
|
};
|
|
91
91
|
declare type DeleteCrdtOp = {
|
|
92
|
-
opId?: string;
|
|
93
|
-
id: string;
|
|
94
|
-
type: OpCode.DELETE_CRDT;
|
|
92
|
+
readonly opId?: string;
|
|
93
|
+
readonly id: string;
|
|
94
|
+
readonly type: OpCode.DELETE_CRDT;
|
|
95
95
|
};
|
|
96
96
|
declare type SetParentKeyOp = {
|
|
97
|
-
opId?: string;
|
|
98
|
-
id: string;
|
|
99
|
-
type: OpCode.SET_PARENT_KEY;
|
|
100
|
-
parentKey: string;
|
|
97
|
+
readonly opId?: string;
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly type: OpCode.SET_PARENT_KEY;
|
|
100
|
+
readonly parentKey: string;
|
|
101
101
|
};
|
|
102
102
|
declare type DeleteObjectKeyOp = {
|
|
103
|
-
opId?: string;
|
|
104
|
-
id: string;
|
|
105
|
-
type: OpCode.DELETE_OBJECT_KEY;
|
|
106
|
-
key: string;
|
|
103
|
+
readonly opId?: string;
|
|
104
|
+
readonly id: string;
|
|
105
|
+
readonly type: OpCode.DELETE_OBJECT_KEY;
|
|
106
|
+
readonly key: string;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -537,7 +537,7 @@ declare type BroadcastEventClientMsg<TRoomEvent extends Json> = {
|
|
|
537
537
|
event: TRoomEvent;
|
|
538
538
|
};
|
|
539
539
|
declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
|
|
540
|
-
type: ClientMsgCode.UPDATE_PRESENCE;
|
|
540
|
+
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
541
541
|
/**
|
|
542
542
|
* Set this to any number to signify that this is a Full Presence™
|
|
543
543
|
* update, not a patch.
|
|
@@ -551,23 +551,23 @@ declare type UpdatePresenceClientMsg<TPresence extends JsonObject> = {
|
|
|
551
551
|
* is a backward-compatible way of expressing that the `data` contains
|
|
552
552
|
* all presence fields, and isn't a partial "patch".
|
|
553
553
|
*/
|
|
554
|
-
targetActor: number;
|
|
555
|
-
data: TPresence;
|
|
554
|
+
readonly targetActor: number;
|
|
555
|
+
readonly data: TPresence;
|
|
556
556
|
} | {
|
|
557
|
-
type: ClientMsgCode.UPDATE_PRESENCE;
|
|
557
|
+
readonly type: ClientMsgCode.UPDATE_PRESENCE;
|
|
558
558
|
/**
|
|
559
559
|
* Absence of the `targetActor` field signifies that this is a Partial
|
|
560
560
|
* Presence™ "patch".
|
|
561
561
|
*/
|
|
562
|
-
targetActor?: undefined;
|
|
563
|
-
data: Partial<TPresence>;
|
|
562
|
+
readonly targetActor?: undefined;
|
|
563
|
+
readonly data: Partial<TPresence>;
|
|
564
564
|
};
|
|
565
565
|
declare type UpdateStorageClientMsg = {
|
|
566
|
-
type: ClientMsgCode.UPDATE_STORAGE;
|
|
567
|
-
ops: Op[];
|
|
566
|
+
readonly type: ClientMsgCode.UPDATE_STORAGE;
|
|
567
|
+
readonly ops: Op[];
|
|
568
568
|
};
|
|
569
569
|
declare type FetchStorageClientMsg = {
|
|
570
|
-
type: ClientMsgCode.FETCH_STORAGE;
|
|
570
|
+
readonly type: ClientMsgCode.FETCH_STORAGE;
|
|
571
571
|
};
|
|
572
572
|
|
|
573
573
|
declare type ReadonlyArrayWithLegacyMethods<T> = readonly T[] & {
|
|
@@ -1167,32 +1167,32 @@ declare enum CrdtType {
|
|
|
1167
1167
|
declare type SerializedCrdt = SerializedRootObject | SerializedChild;
|
|
1168
1168
|
declare type SerializedChild = SerializedObject | SerializedList | SerializedMap | SerializedRegister;
|
|
1169
1169
|
declare type SerializedRootObject = {
|
|
1170
|
-
type: CrdtType.OBJECT;
|
|
1171
|
-
data: JsonObject;
|
|
1172
|
-
parentId?: never;
|
|
1173
|
-
parentKey?: never;
|
|
1170
|
+
readonly type: CrdtType.OBJECT;
|
|
1171
|
+
readonly data: JsonObject;
|
|
1172
|
+
readonly parentId?: never;
|
|
1173
|
+
readonly parentKey?: never;
|
|
1174
1174
|
};
|
|
1175
1175
|
declare type SerializedObject = {
|
|
1176
|
-
type: CrdtType.OBJECT;
|
|
1177
|
-
parentId: string;
|
|
1178
|
-
parentKey: string;
|
|
1179
|
-
data: JsonObject;
|
|
1176
|
+
readonly type: CrdtType.OBJECT;
|
|
1177
|
+
readonly parentId: string;
|
|
1178
|
+
readonly parentKey: string;
|
|
1179
|
+
readonly data: JsonObject;
|
|
1180
1180
|
};
|
|
1181
1181
|
declare type SerializedList = {
|
|
1182
|
-
type: CrdtType.LIST;
|
|
1183
|
-
parentId: string;
|
|
1184
|
-
parentKey: string;
|
|
1182
|
+
readonly type: CrdtType.LIST;
|
|
1183
|
+
readonly parentId: string;
|
|
1184
|
+
readonly parentKey: string;
|
|
1185
1185
|
};
|
|
1186
1186
|
declare type SerializedMap = {
|
|
1187
|
-
type: CrdtType.MAP;
|
|
1188
|
-
parentId: string;
|
|
1189
|
-
parentKey: string;
|
|
1187
|
+
readonly type: CrdtType.MAP;
|
|
1188
|
+
readonly parentId: string;
|
|
1189
|
+
readonly parentKey: string;
|
|
1190
1190
|
};
|
|
1191
1191
|
declare type SerializedRegister = {
|
|
1192
|
-
type: CrdtType.REGISTER;
|
|
1193
|
-
parentId: string;
|
|
1194
|
-
parentKey: string;
|
|
1195
|
-
data: Json;
|
|
1192
|
+
readonly type: CrdtType.REGISTER;
|
|
1193
|
+
readonly parentId: string;
|
|
1194
|
+
readonly parentKey: string;
|
|
1195
|
+
readonly data: Json;
|
|
1196
1196
|
};
|
|
1197
1197
|
declare function isRootCrdt(crdt: SerializedCrdt): crdt is SerializedRootObject;
|
|
1198
1198
|
declare function isChildCrdt(crdt: SerializedCrdt): crdt is SerializedChild;
|
|
@@ -1222,11 +1222,11 @@ declare type ServerMsg<TPresence extends JsonObject, TUserMeta extends BaseUserM
|
|
|
1222
1222
|
* so all other existing clients can ignore this broadcasted message.
|
|
1223
1223
|
*/
|
|
1224
1224
|
declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
|
|
1225
|
-
type: ServerMsgCode.UPDATE_PRESENCE;
|
|
1225
|
+
readonly type: ServerMsgCode.UPDATE_PRESENCE;
|
|
1226
1226
|
/**
|
|
1227
1227
|
* The User whose Presence has changed.
|
|
1228
1228
|
*/
|
|
1229
|
-
actor: number;
|
|
1229
|
+
readonly actor: number;
|
|
1230
1230
|
/**
|
|
1231
1231
|
* When set, signifies that this is a Full Presence™ update, not a patch.
|
|
1232
1232
|
*
|
|
@@ -1239,74 +1239,74 @@ declare type UpdatePresenceServerMsg<TPresence extends JsonObject> = {
|
|
|
1239
1239
|
* is a backward-compatible way of expressing that the `data` contains
|
|
1240
1240
|
* all presence fields, and isn't a partial "patch".
|
|
1241
1241
|
*/
|
|
1242
|
-
targetActor: number;
|
|
1242
|
+
readonly targetActor: number;
|
|
1243
1243
|
/**
|
|
1244
1244
|
* The partial or full Presence of a User. If the `targetActor` field is set,
|
|
1245
1245
|
* this will be the full Presence, otherwise it only contain the fields that
|
|
1246
1246
|
* have changed since the last broadcast.
|
|
1247
1247
|
*/
|
|
1248
|
-
data: TPresence;
|
|
1248
|
+
readonly data: TPresence;
|
|
1249
1249
|
} | {
|
|
1250
|
-
type: ServerMsgCode.UPDATE_PRESENCE;
|
|
1250
|
+
readonly type: ServerMsgCode.UPDATE_PRESENCE;
|
|
1251
1251
|
/**
|
|
1252
1252
|
* The User whose Presence has changed.
|
|
1253
1253
|
*/
|
|
1254
|
-
actor: number;
|
|
1254
|
+
readonly actor: number;
|
|
1255
1255
|
/**
|
|
1256
1256
|
* Not set for partial presence updates.
|
|
1257
1257
|
*/
|
|
1258
|
-
targetActor?: undefined;
|
|
1258
|
+
readonly targetActor?: undefined;
|
|
1259
1259
|
/**
|
|
1260
1260
|
* A partial Presence patch to apply to the User. It will only contain the
|
|
1261
1261
|
* fields that have changed since the last broadcast.
|
|
1262
1262
|
*/
|
|
1263
|
-
data: Partial<TPresence>;
|
|
1263
|
+
readonly data: Partial<TPresence>;
|
|
1264
1264
|
};
|
|
1265
1265
|
/**
|
|
1266
1266
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1267
1267
|
* a new User has joined the Room.
|
|
1268
1268
|
*/
|
|
1269
1269
|
declare type UserJoinServerMsg<TUserMeta extends BaseUserMeta> = {
|
|
1270
|
-
type: ServerMsgCode.USER_JOINED;
|
|
1271
|
-
actor: number;
|
|
1270
|
+
readonly type: ServerMsgCode.USER_JOINED;
|
|
1271
|
+
readonly actor: number;
|
|
1272
1272
|
/**
|
|
1273
1273
|
* The id of the User that has been set in the authentication endpoint.
|
|
1274
1274
|
* Useful to get additional information about the connected user.
|
|
1275
1275
|
*/
|
|
1276
|
-
id: TUserMeta["id"];
|
|
1276
|
+
readonly id: TUserMeta["id"];
|
|
1277
1277
|
/**
|
|
1278
1278
|
* Additional user information that has been set in the authentication
|
|
1279
1279
|
* endpoint.
|
|
1280
1280
|
*/
|
|
1281
|
-
info: TUserMeta["info"];
|
|
1281
|
+
readonly info: TUserMeta["info"];
|
|
1282
1282
|
/**
|
|
1283
1283
|
* Permissions that the user has in the Room.
|
|
1284
1284
|
*/
|
|
1285
|
-
scopes: string[];
|
|
1285
|
+
readonly scopes: string[];
|
|
1286
1286
|
};
|
|
1287
1287
|
/**
|
|
1288
1288
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1289
1289
|
* a new User has left the Room.
|
|
1290
1290
|
*/
|
|
1291
1291
|
declare type UserLeftServerMsg = {
|
|
1292
|
-
type: ServerMsgCode.USER_LEFT;
|
|
1293
|
-
actor: number;
|
|
1292
|
+
readonly type: ServerMsgCode.USER_LEFT;
|
|
1293
|
+
readonly actor: number;
|
|
1294
1294
|
};
|
|
1295
1295
|
/**
|
|
1296
1296
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
1297
1297
|
* a User broadcasted an Event to everyone in the Room.
|
|
1298
1298
|
*/
|
|
1299
1299
|
declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
|
|
1300
|
-
type: ServerMsgCode.BROADCASTED_EVENT;
|
|
1300
|
+
readonly type: ServerMsgCode.BROADCASTED_EVENT;
|
|
1301
1301
|
/**
|
|
1302
1302
|
* The User who broadcasted the Event.
|
|
1303
1303
|
*/
|
|
1304
|
-
actor: number;
|
|
1304
|
+
readonly actor: number;
|
|
1305
1305
|
/**
|
|
1306
1306
|
* The arbitrary payload of the Event. This can be any JSON value. Clients
|
|
1307
1307
|
* will have to manually verify/decode this event.
|
|
1308
1308
|
*/
|
|
1309
|
-
event: TRoomEvent;
|
|
1309
|
+
readonly event: TRoomEvent;
|
|
1310
1310
|
};
|
|
1311
1311
|
/**
|
|
1312
1312
|
* Sent by the WebSocket server to a single client in response to the client
|
|
@@ -1314,9 +1314,9 @@ declare type BroadcastedEventServerMsg<TRoomEvent extends Json> = {
|
|
|
1314
1314
|
* includes a list of all other Users that already are in the Room.
|
|
1315
1315
|
*/
|
|
1316
1316
|
declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
|
|
1317
|
-
type: ServerMsgCode.ROOM_STATE;
|
|
1318
|
-
users: {
|
|
1319
|
-
[actor: number]: TUserMeta & {
|
|
1317
|
+
readonly type: ServerMsgCode.ROOM_STATE;
|
|
1318
|
+
readonly users: {
|
|
1319
|
+
readonly [actor: number]: TUserMeta & {
|
|
1320
1320
|
scopes: string[];
|
|
1321
1321
|
};
|
|
1322
1322
|
};
|
|
@@ -1327,8 +1327,8 @@ declare type RoomStateServerMsg<TUserMeta extends BaseUserMeta> = {
|
|
|
1327
1327
|
* payload includes the entire Storage document.
|
|
1328
1328
|
*/
|
|
1329
1329
|
declare type InitialDocumentStateServerMsg = {
|
|
1330
|
-
type: ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
1331
|
-
items: IdTuple<SerializedCrdt>[];
|
|
1330
|
+
readonly type: ServerMsgCode.INITIAL_STORAGE_STATE;
|
|
1331
|
+
readonly items: IdTuple<SerializedCrdt>[];
|
|
1332
1332
|
};
|
|
1333
1333
|
/**
|
|
1334
1334
|
* Sent by the WebSocket server and broadcasted to all clients to announce that
|
|
@@ -1338,8 +1338,8 @@ declare type InitialDocumentStateServerMsg = {
|
|
|
1338
1338
|
* mutations to make to the initially loaded document).
|
|
1339
1339
|
*/
|
|
1340
1340
|
declare type UpdateStorageServerMsg = {
|
|
1341
|
-
type: ServerMsgCode.UPDATE_STORAGE;
|
|
1342
|
-
ops: Op[];
|
|
1341
|
+
readonly type: ServerMsgCode.UPDATE_STORAGE;
|
|
1342
|
+
readonly ops: Op[];
|
|
1343
1343
|
};
|
|
1344
1344
|
|
|
1345
1345
|
/**
|
package/dist/index.js
CHANGED
|
@@ -825,8 +825,10 @@ var LiveList = class extends AbstractCrdt {
|
|
|
825
825
|
const existingItem = this._items[indexOfItemWithSameKey];
|
|
826
826
|
existingItem._detach();
|
|
827
827
|
this._items[indexOfItemWithSameKey] = child;
|
|
828
|
-
const reverse =
|
|
829
|
-
|
|
828
|
+
const reverse = HACK_addIntentAndDeletedIdToOperation(
|
|
829
|
+
existingItem._toOps(nn(this._id), key, this._pool),
|
|
830
|
+
op.id
|
|
831
|
+
);
|
|
830
832
|
const delta = [setDelta(indexOfItemWithSameKey, child)];
|
|
831
833
|
const deletedDelta = this._detachItemAssociatedToSetOperation(
|
|
832
834
|
op.deletedId
|
|
@@ -1239,11 +1241,15 @@ var LiveList = class extends AbstractCrdt {
|
|
|
1239
1241
|
value._attach(id, this._pool);
|
|
1240
1242
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
1241
1243
|
storageUpdates.set(this._id, makeUpdate(this, [setDelta(index, value)]));
|
|
1242
|
-
const ops =
|
|
1243
|
-
|
|
1244
|
+
const ops = HACK_addIntentAndDeletedIdToOperation(
|
|
1245
|
+
value._toOps(this._id, position, this._pool),
|
|
1246
|
+
existingId
|
|
1247
|
+
);
|
|
1244
1248
|
this._unacknowledgedSets.set(position, nn(ops[0].opId));
|
|
1245
|
-
const reverseOps =
|
|
1246
|
-
|
|
1249
|
+
const reverseOps = HACK_addIntentAndDeletedIdToOperation(
|
|
1250
|
+
existingItem._toOps(this._id, position, void 0),
|
|
1251
|
+
id
|
|
1252
|
+
);
|
|
1247
1253
|
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
1248
1254
|
}
|
|
1249
1255
|
}
|
|
@@ -1371,15 +1377,18 @@ function moveDelta(previousIndex, index, item) {
|
|
|
1371
1377
|
item: item instanceof LiveRegister ? item.data : item
|
|
1372
1378
|
};
|
|
1373
1379
|
}
|
|
1374
|
-
function
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1380
|
+
function HACK_addIntentAndDeletedIdToOperation(ops, deletedId) {
|
|
1381
|
+
return ops.map((op, index) => {
|
|
1382
|
+
if (index === 0) {
|
|
1383
|
+
const firstOp = op;
|
|
1384
|
+
return __spreadProps(__spreadValues({}, firstOp), {
|
|
1385
|
+
intent: "set",
|
|
1386
|
+
deletedId
|
|
1387
|
+
});
|
|
1388
|
+
} else {
|
|
1389
|
+
return op;
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1383
1392
|
}
|
|
1384
1393
|
|
|
1385
1394
|
// src/lib/freeze.ts
|
|
@@ -2817,7 +2826,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2817
2826
|
currentItems.set(id, node._serialize());
|
|
2818
2827
|
});
|
|
2819
2828
|
const ops = getTreesDiffOperations(currentItems, new Map(items));
|
|
2820
|
-
const result =
|
|
2829
|
+
const result = applyOps(ops, false);
|
|
2821
2830
|
notify(result.updates, batchedUpdatesWrapper);
|
|
2822
2831
|
}
|
|
2823
2832
|
function load(items) {
|
|
@@ -2870,15 +2879,20 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2870
2879
|
"Internal. Tried to get connection id but connection was never open"
|
|
2871
2880
|
);
|
|
2872
2881
|
}
|
|
2873
|
-
function
|
|
2874
|
-
const
|
|
2882
|
+
function applyOps(rawOps, isLocal) {
|
|
2883
|
+
const output = {
|
|
2875
2884
|
reverse: [],
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
presence: false
|
|
2879
|
-
}
|
|
2885
|
+
storageUpdates: /* @__PURE__ */ new Map(),
|
|
2886
|
+
presence: false
|
|
2880
2887
|
};
|
|
2881
2888
|
const createdNodeIds = /* @__PURE__ */ new Set();
|
|
2889
|
+
const ops = rawOps.map((op) => {
|
|
2890
|
+
if (op.type !== "presence" && !op.opId) {
|
|
2891
|
+
return __spreadProps(__spreadValues({}, op), { opId: pool.generateOpId() });
|
|
2892
|
+
} else {
|
|
2893
|
+
return op;
|
|
2894
|
+
}
|
|
2895
|
+
});
|
|
2882
2896
|
for (const op of ops) {
|
|
2883
2897
|
if (op.type === "presence") {
|
|
2884
2898
|
const reverse = {
|
|
@@ -2896,13 +2910,10 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2896
2910
|
state.buffer.me.data[key] = op.data[key];
|
|
2897
2911
|
}
|
|
2898
2912
|
}
|
|
2899
|
-
|
|
2900
|
-
|
|
2913
|
+
output.reverse.unshift(reverse);
|
|
2914
|
+
output.presence = true;
|
|
2901
2915
|
} else {
|
|
2902
2916
|
let source;
|
|
2903
|
-
if (!op.opId) {
|
|
2904
|
-
op.opId = pool.generateOpId();
|
|
2905
|
-
}
|
|
2906
2917
|
if (isLocal) {
|
|
2907
2918
|
source = 0 /* UNDOREDO_RECONNECT */;
|
|
2908
2919
|
} else {
|
|
@@ -2916,16 +2927,16 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2916
2927
|
"Expected parent node to have an ID"
|
|
2917
2928
|
) : void 0;
|
|
2918
2929
|
if (!parentId || !createdNodeIds.has(parentId)) {
|
|
2919
|
-
|
|
2930
|
+
output.storageUpdates.set(
|
|
2920
2931
|
nn(applyOpResult.modified.node._id),
|
|
2921
2932
|
mergeStorageUpdates(
|
|
2922
|
-
|
|
2933
|
+
output.storageUpdates.get(
|
|
2923
2934
|
nn(applyOpResult.modified.node._id)
|
|
2924
2935
|
),
|
|
2925
2936
|
applyOpResult.modified
|
|
2926
2937
|
)
|
|
2927
2938
|
);
|
|
2928
|
-
|
|
2939
|
+
output.reverse.unshift(...applyOpResult.reverse);
|
|
2929
2940
|
}
|
|
2930
2941
|
if (op.type === 2 /* CREATE_LIST */ || op.type === 7 /* CREATE_MAP */ || op.type === 4 /* CREATE_OBJECT */) {
|
|
2931
2942
|
createdNodeIds.add(nn(applyOpResult.modified.node._id));
|
|
@@ -2933,7 +2944,14 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
2933
2944
|
}
|
|
2934
2945
|
}
|
|
2935
2946
|
}
|
|
2936
|
-
return
|
|
2947
|
+
return {
|
|
2948
|
+
ops,
|
|
2949
|
+
reverse: output.reverse,
|
|
2950
|
+
updates: {
|
|
2951
|
+
storageUpdates: output.storageUpdates,
|
|
2952
|
+
presence: output.presence
|
|
2953
|
+
}
|
|
2954
|
+
};
|
|
2937
2955
|
}
|
|
2938
2956
|
function applyOp(op, source) {
|
|
2939
2957
|
switch (op.type) {
|
|
@@ -3283,7 +3301,7 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3283
3301
|
break;
|
|
3284
3302
|
}
|
|
3285
3303
|
case 201 /* UPDATE_STORAGE */: {
|
|
3286
|
-
const applyResult =
|
|
3304
|
+
const applyResult = applyOps(message.ops, false);
|
|
3287
3305
|
applyResult.updates.storageUpdates.forEach((value, key) => {
|
|
3288
3306
|
updates.storageUpdates.set(
|
|
3289
3307
|
key,
|
|
@@ -3415,10 +3433,10 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3415
3433
|
}
|
|
3416
3434
|
const messages = [];
|
|
3417
3435
|
const ops = Array.from(offlineOps.values());
|
|
3418
|
-
const result =
|
|
3436
|
+
const result = applyOps(ops, true);
|
|
3419
3437
|
messages.push({
|
|
3420
3438
|
type: 201 /* UPDATE_STORAGE */,
|
|
3421
|
-
ops
|
|
3439
|
+
ops: result.ops
|
|
3422
3440
|
});
|
|
3423
3441
|
notify(result.updates, batchedUpdatesWrapper);
|
|
3424
3442
|
effects.send(messages);
|
|
@@ -3569,13 +3587,13 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3569
3587
|
return;
|
|
3570
3588
|
}
|
|
3571
3589
|
state.pausedHistory = null;
|
|
3572
|
-
const result =
|
|
3590
|
+
const result = applyOps(historyOps, true);
|
|
3573
3591
|
batchUpdates(() => {
|
|
3574
3592
|
notify(result.updates, doNotBatchUpdates);
|
|
3575
3593
|
state.redoStack.push(result.reverse);
|
|
3576
3594
|
onHistoryChange(doNotBatchUpdates);
|
|
3577
3595
|
});
|
|
3578
|
-
for (const op of
|
|
3596
|
+
for (const op of result.ops) {
|
|
3579
3597
|
if (op.type !== "presence") {
|
|
3580
3598
|
state.buffer.storageOperations.push(op);
|
|
3581
3599
|
}
|
|
@@ -3594,13 +3612,13 @@ function makeStateMachine(state, config, mockedEffects) {
|
|
|
3594
3612
|
return;
|
|
3595
3613
|
}
|
|
3596
3614
|
state.pausedHistory = null;
|
|
3597
|
-
const result =
|
|
3615
|
+
const result = applyOps(historyOps, true);
|
|
3598
3616
|
batchUpdates(() => {
|
|
3599
3617
|
notify(result.updates, doNotBatchUpdates);
|
|
3600
3618
|
state.undoStack.push(result.reverse);
|
|
3601
3619
|
onHistoryChange(doNotBatchUpdates);
|
|
3602
3620
|
});
|
|
3603
|
-
for (const op of
|
|
3621
|
+
for (const op of result.ops) {
|
|
3604
3622
|
if (op.type !== "presence") {
|
|
3605
3623
|
state.buffer.storageOperations.push(op);
|
|
3606
3624
|
}
|
|
@@ -3806,7 +3824,7 @@ function prepareCreateWebSocket(liveblocksServer, WebSocketPolyfill) {
|
|
|
3806
3824
|
const ws = WebSocketPolyfill || WebSocket;
|
|
3807
3825
|
return (token) => {
|
|
3808
3826
|
return new ws(
|
|
3809
|
-
`${liveblocksServer}/?token=${token}&version=${true ? "0.19.
|
|
3827
|
+
`${liveblocksServer}/?token=${token}&version=${true ? "0.19.2-test1" : "dev"}`
|
|
3810
3828
|
);
|
|
3811
3829
|
};
|
|
3812
3830
|
}
|