@liveblocks/core 3.12.1-enums1 → 3.13.0-ack1
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 +57 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -22
- package/dist/index.d.ts +15 -22
- package/dist/index.js +56 -40
- 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.
|
|
9
|
+
var PKG_VERSION = "3.13.0-ack1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3092,6 +3092,7 @@ var ServerMsgCode = Object.freeze({
|
|
|
3092
3092
|
// For Storage
|
|
3093
3093
|
INITIAL_STORAGE_STATE: 200,
|
|
3094
3094
|
UPDATE_STORAGE: 201,
|
|
3095
|
+
STORAGE_ACK: 202,
|
|
3095
3096
|
// For Yjs Docs
|
|
3096
3097
|
UPDATE_YDOC: 300,
|
|
3097
3098
|
// For Comments
|
|
@@ -5922,19 +5923,10 @@ var OpCode = Object.freeze({
|
|
|
5922
5923
|
DELETE_CRDT: 5,
|
|
5923
5924
|
DELETE_OBJECT_KEY: 6,
|
|
5924
5925
|
CREATE_MAP: 7,
|
|
5925
|
-
CREATE_REGISTER: 8
|
|
5926
|
+
CREATE_REGISTER: 8,
|
|
5927
|
+
ACK: 9
|
|
5928
|
+
// Will only appear in v8+
|
|
5926
5929
|
});
|
|
5927
|
-
function ackOp(opId) {
|
|
5928
|
-
return {
|
|
5929
|
-
type: OpCode.DELETE_CRDT,
|
|
5930
|
-
id: "ACK",
|
|
5931
|
-
// (H)ACK
|
|
5932
|
-
opId
|
|
5933
|
-
};
|
|
5934
|
-
}
|
|
5935
|
-
function isAckOp(op) {
|
|
5936
|
-
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5937
|
-
}
|
|
5938
5930
|
|
|
5939
5931
|
// src/crdts/AbstractCrdt.ts
|
|
5940
5932
|
function createManagedPool(roomId, options) {
|
|
@@ -6389,7 +6381,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6389
6381
|
};
|
|
6390
6382
|
}
|
|
6391
6383
|
}
|
|
6392
|
-
#
|
|
6384
|
+
#applySetFixop(op) {
|
|
6393
6385
|
if (this._pool === void 0) {
|
|
6394
6386
|
throw new Error("Can't attach child if managed pool is not present");
|
|
6395
6387
|
}
|
|
@@ -6499,7 +6491,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6499
6491
|
reverse: []
|
|
6500
6492
|
};
|
|
6501
6493
|
}
|
|
6502
|
-
#
|
|
6494
|
+
#applyInsertFixop(op) {
|
|
6503
6495
|
const existingItem = this.#items.find((item) => item._id === op.id);
|
|
6504
6496
|
const key = asPos(op.parentKey);
|
|
6505
6497
|
const itemIndexAtPosition = this._indexOfPosition(key);
|
|
@@ -6621,16 +6613,16 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6621
6613
|
if (op.intent === "set") {
|
|
6622
6614
|
if (source === 1 /* REMOTE */) {
|
|
6623
6615
|
result = this.#applySetRemote(op);
|
|
6624
|
-
} else if (source === 2 /*
|
|
6625
|
-
result = this.#
|
|
6616
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6617
|
+
result = this.#applySetFixop(op);
|
|
6626
6618
|
} else {
|
|
6627
6619
|
result = this.#applySetUndoRedo(op);
|
|
6628
6620
|
}
|
|
6629
6621
|
} else {
|
|
6630
6622
|
if (source === 1 /* REMOTE */) {
|
|
6631
6623
|
result = this.#applyRemoteInsert(op);
|
|
6632
|
-
} else if (source === 2 /*
|
|
6633
|
-
result = this.#
|
|
6624
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6625
|
+
result = this.#applyInsertFixop(op);
|
|
6634
6626
|
} else {
|
|
6635
6627
|
result = this.#applyInsertUndoRedo(op);
|
|
6636
6628
|
}
|
|
@@ -6713,7 +6705,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6713
6705
|
};
|
|
6714
6706
|
}
|
|
6715
6707
|
}
|
|
6716
|
-
#
|
|
6708
|
+
#applySetChildKeyFixop(newKey, child) {
|
|
6717
6709
|
const previousKey = nn(child._parentKey);
|
|
6718
6710
|
if (this.#implicitlyDeletedItems.has(child)) {
|
|
6719
6711
|
const existingItemIndex = this._indexOfPosition(newKey);
|
|
@@ -6794,8 +6786,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6794
6786
|
_setChildKey(newKey, child, source) {
|
|
6795
6787
|
if (source === 1 /* REMOTE */) {
|
|
6796
6788
|
return this.#applySetChildKeyRemote(newKey, child);
|
|
6797
|
-
} else if (source === 2 /*
|
|
6798
|
-
return this.#
|
|
6789
|
+
} else if (source === 2 /* FIXOP */) {
|
|
6790
|
+
return this.#applySetChildKeyFixop(newKey, child);
|
|
6799
6791
|
} else {
|
|
6800
6792
|
return this.#applySetChildKeyUndoRedo(newKey, child);
|
|
6801
6793
|
}
|
|
@@ -7308,7 +7300,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7308
7300
|
if (this._pool.getNode(id) !== void 0) {
|
|
7309
7301
|
return { modified: false };
|
|
7310
7302
|
}
|
|
7311
|
-
if (source === 2 /*
|
|
7303
|
+
if (source === 2 /* FIXOP */) {
|
|
7312
7304
|
const lastUpdateOpId = this.#unacknowledgedSet.get(key);
|
|
7313
7305
|
if (lastUpdateOpId === opId) {
|
|
7314
7306
|
this.#unacknowledgedSet.delete(key);
|
|
@@ -7709,7 +7701,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7709
7701
|
}
|
|
7710
7702
|
return { modified: false };
|
|
7711
7703
|
}
|
|
7712
|
-
if (source === 0 /*
|
|
7704
|
+
if (source === 0 /* LOCAL */) {
|
|
7713
7705
|
this.#propToLastUpdate.set(key, nn(opId));
|
|
7714
7706
|
} else if (this.#propToLastUpdate.get(key) === void 0) {
|
|
7715
7707
|
} else if (this.#propToLastUpdate.get(key) === opId) {
|
|
@@ -9115,7 +9107,11 @@ function createRoom(options, config) {
|
|
|
9115
9107
|
currentItems.set(id, node._serialize());
|
|
9116
9108
|
}
|
|
9117
9109
|
const ops = getTreesDiffOperations(currentItems, new Map(items));
|
|
9118
|
-
const result = applyOps(
|
|
9110
|
+
const result = applyOps(
|
|
9111
|
+
ops,
|
|
9112
|
+
/* isLocal */
|
|
9113
|
+
false
|
|
9114
|
+
);
|
|
9119
9115
|
notify(result.updates);
|
|
9120
9116
|
}
|
|
9121
9117
|
function _addToRealUndoStack(historyOps) {
|
|
@@ -9196,11 +9192,12 @@ function createRoom(options, config) {
|
|
|
9196
9192
|
} else {
|
|
9197
9193
|
let source;
|
|
9198
9194
|
if (isLocal) {
|
|
9199
|
-
source = 0 /*
|
|
9195
|
+
source = 0 /* LOCAL */;
|
|
9196
|
+
} else if (op.opId) {
|
|
9197
|
+
context.unacknowledgedOps.delete(op.opId);
|
|
9198
|
+
source = 2 /* FIXOP */;
|
|
9200
9199
|
} else {
|
|
9201
|
-
|
|
9202
|
-
const deleted = context.unacknowledgedOps.delete(opId);
|
|
9203
|
-
source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
|
|
9200
|
+
source = 1 /* REMOTE */;
|
|
9204
9201
|
}
|
|
9205
9202
|
const applyOpResult = applyOp(op, source);
|
|
9206
9203
|
if (applyOpResult.modified) {
|
|
@@ -9231,9 +9228,6 @@ function createRoom(options, config) {
|
|
|
9231
9228
|
};
|
|
9232
9229
|
}
|
|
9233
9230
|
function applyOp(op, source) {
|
|
9234
|
-
if (isAckOp(op)) {
|
|
9235
|
-
return { modified: false };
|
|
9236
|
-
}
|
|
9237
9231
|
switch (op.type) {
|
|
9238
9232
|
case OpCode.DELETE_OBJECT_KEY:
|
|
9239
9233
|
case OpCode.UPDATE_OBJECT:
|
|
@@ -9242,7 +9236,7 @@ function createRoom(options, config) {
|
|
|
9242
9236
|
if (node === void 0) {
|
|
9243
9237
|
return { modified: false };
|
|
9244
9238
|
}
|
|
9245
|
-
return node._apply(op, source === 0 /*
|
|
9239
|
+
return node._apply(op, source === 0 /* LOCAL */);
|
|
9246
9240
|
}
|
|
9247
9241
|
case OpCode.SET_PARENT_KEY: {
|
|
9248
9242
|
const node = context.pool.nodes.get(op.id);
|
|
@@ -9413,7 +9407,11 @@ function createRoom(options, config) {
|
|
|
9413
9407
|
}
|
|
9414
9408
|
const messages = [];
|
|
9415
9409
|
const inOps = Array.from(offlineOps.values());
|
|
9416
|
-
const result = applyOps(
|
|
9410
|
+
const result = applyOps(
|
|
9411
|
+
inOps,
|
|
9412
|
+
/* isLocal */
|
|
9413
|
+
true
|
|
9414
|
+
);
|
|
9417
9415
|
messages.push({
|
|
9418
9416
|
type: ClientMsgCode.UPDATE_STORAGE,
|
|
9419
9417
|
ops: result.ops
|
|
@@ -9477,9 +9475,12 @@ function createRoom(options, config) {
|
|
|
9477
9475
|
processInitialStorage(message);
|
|
9478
9476
|
break;
|
|
9479
9477
|
}
|
|
9480
|
-
// Write event
|
|
9481
9478
|
case ServerMsgCode.UPDATE_STORAGE: {
|
|
9482
|
-
const applyResult = applyOps(
|
|
9479
|
+
const applyResult = applyOps(
|
|
9480
|
+
message.ops,
|
|
9481
|
+
/* isLocal */
|
|
9482
|
+
false
|
|
9483
|
+
);
|
|
9483
9484
|
for (const [key, value] of applyResult.updates.storageUpdates) {
|
|
9484
9485
|
updates.storageUpdates.set(
|
|
9485
9486
|
key,
|
|
@@ -9488,6 +9489,14 @@ function createRoom(options, config) {
|
|
|
9488
9489
|
}
|
|
9489
9490
|
break;
|
|
9490
9491
|
}
|
|
9492
|
+
// Since V8. On V7, acks were sent disguised as an Ops in UPDATE_STORAGE messages.
|
|
9493
|
+
case ServerMsgCode.STORAGE_ACK: {
|
|
9494
|
+
for (const opId of message.opIds) {
|
|
9495
|
+
context.unacknowledgedOps.delete(opId);
|
|
9496
|
+
}
|
|
9497
|
+
notifyStorageStatus();
|
|
9498
|
+
break;
|
|
9499
|
+
}
|
|
9491
9500
|
// Receiving a RejectedOps message in the client means that the server is no
|
|
9492
9501
|
// longer in sync with the client. Trying to synchronize the client again by
|
|
9493
9502
|
// rolling back particular Ops may be hard/impossible. It's fine to not try and
|
|
@@ -9693,7 +9702,11 @@ function createRoom(options, config) {
|
|
|
9693
9702
|
return;
|
|
9694
9703
|
}
|
|
9695
9704
|
context.pausedHistory = null;
|
|
9696
|
-
const result = applyOps(
|
|
9705
|
+
const result = applyOps(
|
|
9706
|
+
historyOps,
|
|
9707
|
+
/* isLocal */
|
|
9708
|
+
true
|
|
9709
|
+
);
|
|
9697
9710
|
notify(result.updates);
|
|
9698
9711
|
context.redoStack.push(result.reverse);
|
|
9699
9712
|
onHistoryChange();
|
|
@@ -9713,7 +9726,11 @@ function createRoom(options, config) {
|
|
|
9713
9726
|
return;
|
|
9714
9727
|
}
|
|
9715
9728
|
context.pausedHistory = null;
|
|
9716
|
-
const result = applyOps(
|
|
9729
|
+
const result = applyOps(
|
|
9730
|
+
historyOps,
|
|
9731
|
+
/* isLocal */
|
|
9732
|
+
true
|
|
9733
|
+
);
|
|
9717
9734
|
notify(result.updates);
|
|
9718
9735
|
context.undoStack.push(result.reverse);
|
|
9719
9736
|
onHistoryChange();
|
|
@@ -10217,7 +10234,7 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
10217
10234
|
}
|
|
10218
10235
|
const url2 = new URL(baseUrl);
|
|
10219
10236
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
10220
|
-
url2.pathname = "/
|
|
10237
|
+
url2.pathname = "/v8";
|
|
10221
10238
|
url2.searchParams.set("roomId", roomId);
|
|
10222
10239
|
if (authValue.type === "secret") {
|
|
10223
10240
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
@@ -11531,6 +11548,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
11531
11548
|
|
|
11532
11549
|
|
|
11533
11550
|
|
|
11534
|
-
|
|
11535
|
-
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.ackOp = ackOp; 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.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;
|
|
11551
|
+
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.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;
|
|
11536
11552
|
//# sourceMappingURL=index.cjs.map
|