@liveblocks/core 3.14.0-pre2 → 3.14.0-pre4
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.cjs +108 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -12
- package/dist/index.d.ts +19 -12
- package/dist/index.js +107 -91
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.14.0-
|
|
9
|
+
var PKG_VERSION = "3.14.0-pre4";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3227,7 +3227,7 @@ var BACKOFF_DELAYS_SLOW = [2e3, 3e4, 6e4, 3e5];
|
|
|
3227
3227
|
var HEARTBEAT_INTERVAL = 3e4;
|
|
3228
3228
|
var PONG_TIMEOUT = 2e3;
|
|
3229
3229
|
var AUTH_TIMEOUT = 1e4;
|
|
3230
|
-
var SOCKET_CONNECT_TIMEOUT =
|
|
3230
|
+
var SOCKET_CONNECT_TIMEOUT = 2e4;
|
|
3231
3231
|
var StopRetrying = class extends Error {
|
|
3232
3232
|
constructor(reason) {
|
|
3233
3233
|
super(reason);
|
|
@@ -6215,61 +6215,79 @@ var AbstractCrdt = class {
|
|
|
6215
6215
|
}
|
|
6216
6216
|
};
|
|
6217
6217
|
|
|
6218
|
-
// src/protocol/
|
|
6218
|
+
// src/protocol/StorageNode.ts
|
|
6219
6219
|
var CrdtType = Object.freeze({
|
|
6220
6220
|
OBJECT: 0,
|
|
6221
6221
|
LIST: 1,
|
|
6222
6222
|
MAP: 2,
|
|
6223
6223
|
REGISTER: 3
|
|
6224
6224
|
});
|
|
6225
|
-
function
|
|
6225
|
+
function isRootStorageNode(node) {
|
|
6226
6226
|
return node[0] === "root";
|
|
6227
6227
|
}
|
|
6228
|
-
function
|
|
6229
|
-
return
|
|
6228
|
+
function isObjectStorageNode(node) {
|
|
6229
|
+
return node[1].type === CrdtType.OBJECT;
|
|
6230
6230
|
}
|
|
6231
|
-
function
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6231
|
+
function isListStorageNode(node) {
|
|
6232
|
+
return node[1].type === CrdtType.LIST;
|
|
6233
|
+
}
|
|
6234
|
+
function isMapStorageNode(node) {
|
|
6235
|
+
return node[1].type === CrdtType.MAP;
|
|
6236
|
+
}
|
|
6237
|
+
function isRegisterStorageNode(node) {
|
|
6238
|
+
return node[1].type === CrdtType.REGISTER;
|
|
6239
|
+
}
|
|
6240
|
+
function isCompactRootNode(node) {
|
|
6241
|
+
return node[0] === "root";
|
|
6242
|
+
}
|
|
6243
|
+
function* compactNodesToNodeStream(compactNodes) {
|
|
6244
|
+
for (const cnode of compactNodes) {
|
|
6245
|
+
if (isCompactRootNode(cnode)) {
|
|
6246
|
+
yield [cnode[0], { type: CrdtType.OBJECT, data: cnode[1] }];
|
|
6236
6247
|
continue;
|
|
6237
6248
|
}
|
|
6238
|
-
switch (
|
|
6249
|
+
switch (cnode[1]) {
|
|
6239
6250
|
case CrdtType.OBJECT:
|
|
6240
|
-
yield [
|
|
6251
|
+
yield [cnode[0], { type: CrdtType.OBJECT, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
6241
6252
|
break;
|
|
6242
6253
|
case CrdtType.LIST:
|
|
6243
|
-
yield [
|
|
6254
|
+
yield [cnode[0], { type: CrdtType.LIST, parentId: cnode[2], parentKey: cnode[3] }];
|
|
6244
6255
|
break;
|
|
6245
6256
|
case CrdtType.MAP:
|
|
6246
|
-
yield [
|
|
6257
|
+
yield [cnode[0], { type: CrdtType.MAP, parentId: cnode[2], parentKey: cnode[3] }];
|
|
6247
6258
|
break;
|
|
6248
6259
|
case CrdtType.REGISTER:
|
|
6249
|
-
yield [
|
|
6260
|
+
yield [cnode[0], { type: CrdtType.REGISTER, parentId: cnode[2], parentKey: cnode[3], data: cnode[4] }];
|
|
6250
6261
|
break;
|
|
6262
|
+
default:
|
|
6251
6263
|
}
|
|
6252
6264
|
}
|
|
6253
6265
|
}
|
|
6254
6266
|
function* nodeStreamToCompactNodes(nodes) {
|
|
6255
|
-
for (const
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6267
|
+
for (const node of nodes) {
|
|
6268
|
+
if (isObjectStorageNode(node)) {
|
|
6269
|
+
if (isRootStorageNode(node)) {
|
|
6270
|
+
const id = node[0];
|
|
6271
|
+
const crdt = node[1];
|
|
6272
|
+
yield [id, crdt.data];
|
|
6273
|
+
} else {
|
|
6274
|
+
const id = node[0];
|
|
6275
|
+
const crdt = node[1];
|
|
6276
|
+
yield [id, CrdtType.OBJECT, crdt.parentId, crdt.parentKey, crdt.data];
|
|
6277
|
+
}
|
|
6278
|
+
} else if (isListStorageNode(node)) {
|
|
6279
|
+
const id = node[0];
|
|
6280
|
+
const crdt = node[1];
|
|
6281
|
+
yield [id, CrdtType.LIST, crdt.parentId, crdt.parentKey];
|
|
6282
|
+
} else if (isMapStorageNode(node)) {
|
|
6283
|
+
const id = node[0];
|
|
6284
|
+
const crdt = node[1];
|
|
6285
|
+
yield [id, CrdtType.MAP, crdt.parentId, crdt.parentKey];
|
|
6286
|
+
} else if (isRegisterStorageNode(node)) {
|
|
6287
|
+
const id = node[0];
|
|
6288
|
+
const crdt = node[1];
|
|
6289
|
+
yield [id, CrdtType.REGISTER, crdt.parentId, crdt.parentKey, crdt.data];
|
|
6290
|
+
} else {
|
|
6273
6291
|
}
|
|
6274
6292
|
}
|
|
6275
6293
|
}
|
|
@@ -6375,15 +6393,16 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6375
6393
|
}
|
|
6376
6394
|
}
|
|
6377
6395
|
/** @internal */
|
|
6378
|
-
static _deserialize([id], parentToChildren, pool) {
|
|
6396
|
+
static _deserialize([id, _], parentToChildren, pool) {
|
|
6379
6397
|
const list = new _LiveList([]);
|
|
6380
6398
|
list._attach(id, pool);
|
|
6381
6399
|
const children = parentToChildren.get(id);
|
|
6382
6400
|
if (children === void 0) {
|
|
6383
6401
|
return list;
|
|
6384
6402
|
}
|
|
6385
|
-
for (const
|
|
6386
|
-
const
|
|
6403
|
+
for (const node of children) {
|
|
6404
|
+
const crdt = node[1];
|
|
6405
|
+
const child = deserialize(node, parentToChildren, pool);
|
|
6387
6406
|
child._setParentLink(list, crdt.parentKey);
|
|
6388
6407
|
list._insertAndSort(child);
|
|
6389
6408
|
}
|
|
@@ -7400,8 +7419,9 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7400
7419
|
if (children === void 0) {
|
|
7401
7420
|
return map;
|
|
7402
7421
|
}
|
|
7403
|
-
for (const
|
|
7404
|
-
const
|
|
7422
|
+
for (const node of children) {
|
|
7423
|
+
const crdt = node[1];
|
|
7424
|
+
const child = deserialize(node, parentToChildren, pool);
|
|
7405
7425
|
child._setParentLink(map, crdt.parentKey);
|
|
7406
7426
|
map.#map.set(crdt.parentKey, child);
|
|
7407
7427
|
map.invalidate();
|
|
@@ -7702,9 +7722,6 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7702
7722
|
|
|
7703
7723
|
// src/crdts/LiveObject.ts
|
|
7704
7724
|
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7705
|
-
function isRootCrdt2(id, _) {
|
|
7706
|
-
return id === "root";
|
|
7707
|
-
}
|
|
7708
7725
|
var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
7709
7726
|
#map;
|
|
7710
7727
|
/**
|
|
@@ -7734,16 +7751,16 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7734
7751
|
static #buildRootAndParentToChildren(nodes) {
|
|
7735
7752
|
const parentToChildren = /* @__PURE__ */ new Map();
|
|
7736
7753
|
let root = null;
|
|
7737
|
-
for (const
|
|
7738
|
-
if (
|
|
7739
|
-
root =
|
|
7754
|
+
for (const node of nodes) {
|
|
7755
|
+
if (isRootStorageNode(node)) {
|
|
7756
|
+
root = node[1];
|
|
7740
7757
|
} else {
|
|
7741
|
-
const
|
|
7758
|
+
const crdt = node[1];
|
|
7742
7759
|
const children = parentToChildren.get(crdt.parentId);
|
|
7743
7760
|
if (children !== void 0) {
|
|
7744
|
-
children.push(
|
|
7761
|
+
children.push(node);
|
|
7745
7762
|
} else {
|
|
7746
|
-
parentToChildren.set(crdt.parentId, [
|
|
7763
|
+
parentToChildren.set(crdt.parentId, [node]);
|
|
7747
7764
|
}
|
|
7748
7765
|
}
|
|
7749
7766
|
}
|
|
@@ -7808,8 +7825,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7808
7825
|
if (children === void 0) {
|
|
7809
7826
|
return liveObj;
|
|
7810
7827
|
}
|
|
7811
|
-
for (const
|
|
7812
|
-
const child = deserializeToLson(
|
|
7828
|
+
for (const node of children) {
|
|
7829
|
+
const child = deserializeToLson(node, parentToChildren, pool);
|
|
7830
|
+
const crdt = node[1];
|
|
7813
7831
|
if (isLiveStructure(child)) {
|
|
7814
7832
|
child._setParentLink(liveObj, crdt.parentKey);
|
|
7815
7833
|
}
|
|
@@ -8296,42 +8314,30 @@ function isSameNodeOrChildOf(node, parent) {
|
|
|
8296
8314
|
}
|
|
8297
8315
|
return false;
|
|
8298
8316
|
}
|
|
8299
|
-
function deserialize(
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
}
|
|
8318
|
-
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
case CrdtType.LIST: {
|
|
8324
|
-
return LiveList._deserialize([id, crdt], parentToChildren, pool);
|
|
8325
|
-
}
|
|
8326
|
-
case CrdtType.MAP: {
|
|
8327
|
-
return LiveMap._deserialize([id, crdt], parentToChildren, pool);
|
|
8328
|
-
}
|
|
8329
|
-
case CrdtType.REGISTER: {
|
|
8330
|
-
return crdt.data;
|
|
8331
|
-
}
|
|
8332
|
-
default: {
|
|
8333
|
-
throw new Error("Unexpected CRDT type");
|
|
8334
|
-
}
|
|
8317
|
+
function deserialize(node, parentToChildren, pool) {
|
|
8318
|
+
if (isObjectStorageNode(node)) {
|
|
8319
|
+
return LiveObject._deserialize(node, parentToChildren, pool);
|
|
8320
|
+
} else if (isListStorageNode(node)) {
|
|
8321
|
+
return LiveList._deserialize(node, parentToChildren, pool);
|
|
8322
|
+
} else if (isMapStorageNode(node)) {
|
|
8323
|
+
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
8324
|
+
} else if (isRegisterStorageNode(node)) {
|
|
8325
|
+
return LiveRegister._deserialize(node, parentToChildren, pool);
|
|
8326
|
+
} else {
|
|
8327
|
+
throw new Error("Unexpected CRDT type");
|
|
8328
|
+
}
|
|
8329
|
+
}
|
|
8330
|
+
function deserializeToLson(node, parentToChildren, pool) {
|
|
8331
|
+
if (isObjectStorageNode(node)) {
|
|
8332
|
+
return LiveObject._deserialize(node, parentToChildren, pool);
|
|
8333
|
+
} else if (isListStorageNode(node)) {
|
|
8334
|
+
return LiveList._deserialize(node, parentToChildren, pool);
|
|
8335
|
+
} else if (isMapStorageNode(node)) {
|
|
8336
|
+
return LiveMap._deserialize(node, parentToChildren, pool);
|
|
8337
|
+
} else if (isRegisterStorageNode(node)) {
|
|
8338
|
+
return node[1].data;
|
|
8339
|
+
} else {
|
|
8340
|
+
throw new Error("Unexpected CRDT type");
|
|
8335
8341
|
}
|
|
8336
8342
|
}
|
|
8337
8343
|
function isLiveStructure(value) {
|
|
@@ -9236,9 +9242,12 @@ function createRoom(options, config) {
|
|
|
9236
9242
|
);
|
|
9237
9243
|
function createOrUpdateRootFromMessage(nodes) {
|
|
9238
9244
|
if (context.root !== void 0) {
|
|
9239
|
-
updateRoot(
|
|
9245
|
+
updateRoot(nodes);
|
|
9240
9246
|
} else {
|
|
9241
|
-
context.root = LiveObject._fromItems(
|
|
9247
|
+
context.root = LiveObject._fromItems(
|
|
9248
|
+
nodes,
|
|
9249
|
+
context.pool
|
|
9250
|
+
);
|
|
9242
9251
|
}
|
|
9243
9252
|
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _188 => _188.get, 'call', _189 => _189(), 'optionalAccess', _190 => _190.canWrite]), () => ( true));
|
|
9244
9253
|
const stackSizeBefore = context.undoStack.length;
|
|
@@ -9263,8 +9272,8 @@ function createRoom(options, config) {
|
|
|
9263
9272
|
return;
|
|
9264
9273
|
}
|
|
9265
9274
|
const currentItems = /* @__PURE__ */ new Map();
|
|
9266
|
-
for (const [id,
|
|
9267
|
-
currentItems.set(id,
|
|
9275
|
+
for (const [id, crdt] of context.pool.nodes) {
|
|
9276
|
+
currentItems.set(id, crdt._serialize());
|
|
9268
9277
|
}
|
|
9269
9278
|
const ops = getTreesDiffOperations(currentItems, nodes);
|
|
9270
9279
|
const result = applyRemoteOps(ops);
|
|
@@ -9799,7 +9808,9 @@ function createRoom(options, config) {
|
|
|
9799
9808
|
}
|
|
9800
9809
|
async function streamStorage() {
|
|
9801
9810
|
if (!managedSocket.authValue) return;
|
|
9802
|
-
const nodes = new Map(
|
|
9811
|
+
const nodes = new Map(
|
|
9812
|
+
await httpClient.streamStorage({ roomId })
|
|
9813
|
+
);
|
|
9803
9814
|
processInitialStorage(nodes);
|
|
9804
9815
|
}
|
|
9805
9816
|
function refreshStorage(options2) {
|
|
@@ -11719,5 +11730,10 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
11719
11730
|
|
|
11720
11731
|
|
|
11721
11732
|
|
|
11722
|
-
|
|
11733
|
+
|
|
11734
|
+
|
|
11735
|
+
|
|
11736
|
+
|
|
11737
|
+
|
|
11738
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactNodesToNodeStream = compactNodesToNodeStream; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isListStorageNode = isListStorageNode; exports.isLiveNode = isLiveNode; exports.isMapStorageNode = isMapStorageNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isObjectStorageNode = isObjectStorageNode; exports.isPlainObject = isPlainObject; exports.isRegisterStorageNode = isRegisterStorageNode; exports.isRootStorageNode = isRootStorageNode; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
11723
11739
|
//# sourceMappingURL=index.cjs.map
|