@liveblocks/core 3.13.0-rc2 → 3.13.0-vincent2
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 +101 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +65 -27
- package/dist/index.d.ts +65 -27
- package/dist/index.js +100 -28
- 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.13.0-
|
|
9
|
+
var PKG_VERSION = "3.13.0-vincent2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3090,7 +3090,10 @@ var ServerMsgCode = Object.freeze({
|
|
|
3090
3090
|
BROADCASTED_EVENT: 103,
|
|
3091
3091
|
ROOM_STATE: 104,
|
|
3092
3092
|
// For Storage
|
|
3093
|
-
|
|
3093
|
+
STORAGE_STATE_V7: 200,
|
|
3094
|
+
// Only sent in V7
|
|
3095
|
+
STORAGE_CHUNK: 210,
|
|
3096
|
+
// Used in V8+
|
|
3094
3097
|
UPDATE_STORAGE: 201,
|
|
3095
3098
|
// For Yjs Docs
|
|
3096
3099
|
UPDATE_YDOC: 300,
|
|
@@ -5922,9 +5925,7 @@ var OpCode = Object.freeze({
|
|
|
5922
5925
|
DELETE_CRDT: 5,
|
|
5923
5926
|
DELETE_OBJECT_KEY: 6,
|
|
5924
5927
|
CREATE_MAP: 7,
|
|
5925
|
-
CREATE_REGISTER: 8
|
|
5926
|
-
ACK: 9
|
|
5927
|
-
// Will only appear in v8+
|
|
5928
|
+
CREATE_REGISTER: 8
|
|
5928
5929
|
});
|
|
5929
5930
|
function isAckOp(op) {
|
|
5930
5931
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
@@ -6142,6 +6143,57 @@ var CrdtType = Object.freeze({
|
|
|
6142
6143
|
MAP: 2,
|
|
6143
6144
|
REGISTER: 3
|
|
6144
6145
|
});
|
|
6146
|
+
function isRootNode(node) {
|
|
6147
|
+
return node[0] === "root";
|
|
6148
|
+
}
|
|
6149
|
+
function isRootCrdt(id, _) {
|
|
6150
|
+
return id === "root";
|
|
6151
|
+
}
|
|
6152
|
+
function* compactNodesToNodeStream(nodes) {
|
|
6153
|
+
for (const node of nodes) {
|
|
6154
|
+
const id = node[0];
|
|
6155
|
+
if (isRootNode(node)) {
|
|
6156
|
+
yield [id, { type: CrdtType.OBJECT, data: node[1] }];
|
|
6157
|
+
continue;
|
|
6158
|
+
}
|
|
6159
|
+
switch (node[1]) {
|
|
6160
|
+
case CrdtType.OBJECT:
|
|
6161
|
+
yield [id, { type: CrdtType.OBJECT, parentId: node[2], parentKey: node[3], data: node[4] }];
|
|
6162
|
+
break;
|
|
6163
|
+
case CrdtType.LIST:
|
|
6164
|
+
yield [id, { type: CrdtType.LIST, parentId: node[2], parentKey: node[3] }];
|
|
6165
|
+
break;
|
|
6166
|
+
case CrdtType.MAP:
|
|
6167
|
+
yield [id, { type: CrdtType.MAP, parentId: node[2], parentKey: node[3] }];
|
|
6168
|
+
break;
|
|
6169
|
+
case CrdtType.REGISTER:
|
|
6170
|
+
yield [id, { type: CrdtType.REGISTER, parentId: node[2], parentKey: node[3], data: node[4] }];
|
|
6171
|
+
break;
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
function* nodeStreamToCompactNodes(nodes) {
|
|
6176
|
+
for (const [id, node] of nodes) {
|
|
6177
|
+
switch (node.type) {
|
|
6178
|
+
case CrdtType.OBJECT:
|
|
6179
|
+
if (isRootCrdt(id, node)) {
|
|
6180
|
+
yield [id, node.data];
|
|
6181
|
+
} else {
|
|
6182
|
+
yield [id, CrdtType.OBJECT, node.parentId, node.parentKey, node.data];
|
|
6183
|
+
}
|
|
6184
|
+
break;
|
|
6185
|
+
case CrdtType.LIST:
|
|
6186
|
+
yield [id, CrdtType.LIST, node.parentId, node.parentKey];
|
|
6187
|
+
break;
|
|
6188
|
+
case CrdtType.MAP:
|
|
6189
|
+
yield [id, CrdtType.MAP, node.parentId, node.parentKey];
|
|
6190
|
+
break;
|
|
6191
|
+
case CrdtType.REGISTER:
|
|
6192
|
+
yield [id, CrdtType.REGISTER, node.parentId, node.parentKey, node.data];
|
|
6193
|
+
break;
|
|
6194
|
+
}
|
|
6195
|
+
}
|
|
6196
|
+
}
|
|
6145
6197
|
|
|
6146
6198
|
// src/crdts/LiveRegister.ts
|
|
6147
6199
|
var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
@@ -7576,7 +7628,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7576
7628
|
|
|
7577
7629
|
// src/crdts/LiveObject.ts
|
|
7578
7630
|
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7579
|
-
function
|
|
7631
|
+
function isRootCrdt2(id, _) {
|
|
7580
7632
|
return id === "root";
|
|
7581
7633
|
}
|
|
7582
7634
|
var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
@@ -7596,7 +7648,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7596
7648
|
const parentToChildren = /* @__PURE__ */ new Map();
|
|
7597
7649
|
let root = null;
|
|
7598
7650
|
for (const [id, crdt] of items) {
|
|
7599
|
-
if (
|
|
7651
|
+
if (isRootCrdt2(id, crdt)) {
|
|
7600
7652
|
root = crdt;
|
|
7601
7653
|
} else {
|
|
7602
7654
|
const tuple = [id, crdt];
|
|
@@ -7614,8 +7666,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7614
7666
|
return [root, parentToChildren];
|
|
7615
7667
|
}
|
|
7616
7668
|
/** @private Do not use this API directly */
|
|
7617
|
-
static _fromItems(
|
|
7618
|
-
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(
|
|
7669
|
+
static _fromItems(nodes, pool) {
|
|
7670
|
+
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(nodes);
|
|
7619
7671
|
return _LiveObject._deserialize(
|
|
7620
7672
|
["root", root],
|
|
7621
7673
|
parentToChildren,
|
|
@@ -8234,10 +8286,7 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
8234
8286
|
const ops = [];
|
|
8235
8287
|
currentItems.forEach((_, id) => {
|
|
8236
8288
|
if (!newItems.get(id)) {
|
|
8237
|
-
ops.push({
|
|
8238
|
-
type: OpCode.DELETE_CRDT,
|
|
8239
|
-
id
|
|
8240
|
-
});
|
|
8289
|
+
ops.push({ type: OpCode.DELETE_CRDT, id });
|
|
8241
8290
|
}
|
|
8242
8291
|
});
|
|
8243
8292
|
newItems.forEach((crdt, id) => {
|
|
@@ -8735,6 +8784,21 @@ function installBackgroundTabSpy() {
|
|
|
8735
8784
|
};
|
|
8736
8785
|
return [inBackgroundSince, unsub];
|
|
8737
8786
|
}
|
|
8787
|
+
function makePartialNodeMap() {
|
|
8788
|
+
let map = /* @__PURE__ */ new Map();
|
|
8789
|
+
return {
|
|
8790
|
+
append(chunk2) {
|
|
8791
|
+
for (const [id, node] of chunk2) {
|
|
8792
|
+
map.set(id, node);
|
|
8793
|
+
}
|
|
8794
|
+
},
|
|
8795
|
+
clear() {
|
|
8796
|
+
const result = map;
|
|
8797
|
+
map = /* @__PURE__ */ new Map();
|
|
8798
|
+
return result;
|
|
8799
|
+
}
|
|
8800
|
+
};
|
|
8801
|
+
}
|
|
8738
8802
|
function createRoom(options, config) {
|
|
8739
8803
|
const roomId = config.roomId;
|
|
8740
8804
|
const initialPresence = options.initialPresence;
|
|
@@ -8795,6 +8859,7 @@ function createRoom(options, config) {
|
|
|
8795
8859
|
activeBatch: null,
|
|
8796
8860
|
unacknowledgedOps: /* @__PURE__ */ new Map()
|
|
8797
8861
|
};
|
|
8862
|
+
const partialNodes = makePartialNodeMap();
|
|
8798
8863
|
let lastTokenKey;
|
|
8799
8864
|
function onStatusDidChange(newStatus) {
|
|
8800
8865
|
const authValue = managedSocket.authValue;
|
|
@@ -9076,14 +9141,11 @@ function createRoom(options, config) {
|
|
|
9076
9141
|
self,
|
|
9077
9142
|
(me) => me !== null ? userToTreeNode("Me", me) : null
|
|
9078
9143
|
);
|
|
9079
|
-
function createOrUpdateRootFromMessage(
|
|
9080
|
-
if (message.items.length === 0) {
|
|
9081
|
-
throw new Error("Internal error: cannot load storage without items");
|
|
9082
|
-
}
|
|
9144
|
+
function createOrUpdateRootFromMessage(nodes) {
|
|
9083
9145
|
if (context.root !== void 0) {
|
|
9084
|
-
updateRoot(
|
|
9146
|
+
updateRoot(new Map(nodes));
|
|
9085
9147
|
} else {
|
|
9086
|
-
context.root = LiveObject._fromItems(
|
|
9148
|
+
context.root = LiveObject._fromItems(nodes, context.pool);
|
|
9087
9149
|
}
|
|
9088
9150
|
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _196 => _196.get, 'call', _197 => _197(), 'optionalAccess', _198 => _198.canWrite]), () => ( true));
|
|
9089
9151
|
const stackSizeBefore = context.undoStack.length;
|
|
@@ -9100,7 +9162,10 @@ function createRoom(options, config) {
|
|
|
9100
9162
|
}
|
|
9101
9163
|
context.undoStack.length = stackSizeBefore;
|
|
9102
9164
|
}
|
|
9103
|
-
function updateRoot(
|
|
9165
|
+
function updateRoot(nodes) {
|
|
9166
|
+
if (nodes.size === 0) {
|
|
9167
|
+
throw new Error("Internal error: cannot load storage without items");
|
|
9168
|
+
}
|
|
9104
9169
|
if (context.root === void 0) {
|
|
9105
9170
|
return;
|
|
9106
9171
|
}
|
|
@@ -9108,7 +9173,7 @@ function createRoom(options, config) {
|
|
|
9108
9173
|
for (const [id, node] of context.pool.nodes) {
|
|
9109
9174
|
currentItems.set(id, node._serialize());
|
|
9110
9175
|
}
|
|
9111
|
-
const ops = getTreesDiffOperations(currentItems,
|
|
9176
|
+
const ops = getTreesDiffOperations(currentItems, nodes);
|
|
9112
9177
|
const result = applyOps(
|
|
9113
9178
|
ops,
|
|
9114
9179
|
/* isLocal */
|
|
@@ -9475,8 +9540,11 @@ function createRoom(options, config) {
|
|
|
9475
9540
|
updates.others.push(onRoomStateMessage(message));
|
|
9476
9541
|
break;
|
|
9477
9542
|
}
|
|
9478
|
-
case ServerMsgCode.
|
|
9479
|
-
|
|
9543
|
+
case ServerMsgCode.STORAGE_CHUNK: {
|
|
9544
|
+
partialNodes.append(compactNodesToNodeStream(message.nodes));
|
|
9545
|
+
if (message.done) {
|
|
9546
|
+
processInitialStorage(partialNodes.clear());
|
|
9547
|
+
}
|
|
9480
9548
|
break;
|
|
9481
9549
|
}
|
|
9482
9550
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
@@ -9521,6 +9589,8 @@ function createRoom(options, config) {
|
|
|
9521
9589
|
eventHub.comments.notify(message);
|
|
9522
9590
|
break;
|
|
9523
9591
|
}
|
|
9592
|
+
case ServerMsgCode.STORAGE_STATE_V7:
|
|
9593
|
+
// No longer used in V8
|
|
9524
9594
|
default:
|
|
9525
9595
|
break;
|
|
9526
9596
|
}
|
|
@@ -9622,9 +9692,9 @@ function createRoom(options, config) {
|
|
|
9622
9692
|
}
|
|
9623
9693
|
let _getStorage$ = null;
|
|
9624
9694
|
let _resolveStoragePromise = null;
|
|
9625
|
-
function processInitialStorage(
|
|
9695
|
+
function processInitialStorage(nodes) {
|
|
9626
9696
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9627
|
-
createOrUpdateRootFromMessage(
|
|
9697
|
+
createOrUpdateRootFromMessage(nodes);
|
|
9628
9698
|
applyAndSendOps(unacknowledgedOps);
|
|
9629
9699
|
_optionalChain([_resolveStoragePromise, 'optionalCall', _201 => _201()]);
|
|
9630
9700
|
notifyStorageStatus();
|
|
@@ -9632,8 +9702,8 @@ function createRoom(options, config) {
|
|
|
9632
9702
|
}
|
|
9633
9703
|
async function streamStorage() {
|
|
9634
9704
|
if (!managedSocket.authValue) return;
|
|
9635
|
-
const
|
|
9636
|
-
processInitialStorage(
|
|
9705
|
+
const nodes = new Map(await httpClient.streamStorage({ roomId }));
|
|
9706
|
+
processInitialStorage(nodes);
|
|
9637
9707
|
}
|
|
9638
9708
|
function refreshStorage(options2) {
|
|
9639
9709
|
const messages = context.buffer.messages;
|
|
@@ -9641,6 +9711,7 @@ function createRoom(options, config) {
|
|
|
9641
9711
|
void streamStorage();
|
|
9642
9712
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
9643
9713
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
9714
|
+
partialNodes.clear();
|
|
9644
9715
|
}
|
|
9645
9716
|
if (options2.flush) {
|
|
9646
9717
|
flushNowOrSoon();
|
|
@@ -10230,7 +10301,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill, eng
|
|
|
10230
10301
|
}
|
|
10231
10302
|
const url2 = new URL(baseUrl);
|
|
10232
10303
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10233
|
-
url2.pathname = "/
|
|
10304
|
+
url2.pathname = "/v8";
|
|
10234
10305
|
url2.searchParams.set("roomId", roomId);
|
|
10235
10306
|
if (authValue.type === "secret") {
|
|
10236
10307
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
@@ -11548,5 +11619,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
11548
11619
|
|
|
11549
11620
|
|
|
11550
11621
|
|
|
11551
|
-
|
|
11622
|
+
|
|
11623
|
+
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.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.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isPlainObject = isPlainObject; 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;
|
|
11552
11624
|
//# sourceMappingURL=index.cjs.map
|