@liveblocks/core 2.18.1 → 2.18.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.js +72 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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 = "2.18.
|
|
9
|
+
var PKG_VERSION = "2.18.2-test1";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -6125,6 +6125,64 @@ function captureStackTrace(msg, traceRoot) {
|
|
|
6125
6125
|
return errorLike.stack;
|
|
6126
6126
|
}
|
|
6127
6127
|
|
|
6128
|
+
// src/lib/Deque.ts
|
|
6129
|
+
var Deque = class {
|
|
6130
|
+
#data;
|
|
6131
|
+
#front;
|
|
6132
|
+
#back;
|
|
6133
|
+
#size;
|
|
6134
|
+
constructor() {
|
|
6135
|
+
this.#data = {};
|
|
6136
|
+
this.#front = 0;
|
|
6137
|
+
this.#back = 1;
|
|
6138
|
+
this.#size = 0;
|
|
6139
|
+
}
|
|
6140
|
+
get length() {
|
|
6141
|
+
return this.#size;
|
|
6142
|
+
}
|
|
6143
|
+
*[Symbol.iterator]() {
|
|
6144
|
+
const size = this.#size;
|
|
6145
|
+
const front = this.#front;
|
|
6146
|
+
for (let i = 0; i < size; i++) {
|
|
6147
|
+
yield this.#data[front + i];
|
|
6148
|
+
}
|
|
6149
|
+
}
|
|
6150
|
+
push(value) {
|
|
6151
|
+
const values2 = Array.isArray(value) ? value : [value];
|
|
6152
|
+
if (this.#back > Number.MAX_SAFE_INTEGER - values2.length - 1)
|
|
6153
|
+
raise("Deque full");
|
|
6154
|
+
for (const value2 of values2) {
|
|
6155
|
+
this.#data[this.#back++ - 1] = value2;
|
|
6156
|
+
}
|
|
6157
|
+
this.#size += values2.length;
|
|
6158
|
+
}
|
|
6159
|
+
pop() {
|
|
6160
|
+
if (this.#size < 1) return void 0;
|
|
6161
|
+
this.#back--;
|
|
6162
|
+
const value = this.#data[this.#back - 1];
|
|
6163
|
+
delete this.#data[this.#back];
|
|
6164
|
+
this.#size--;
|
|
6165
|
+
return value;
|
|
6166
|
+
}
|
|
6167
|
+
pushLeft(value) {
|
|
6168
|
+
const values2 = Array.isArray(value) ? value : [value];
|
|
6169
|
+
if (this.#front < Number.MIN_SAFE_INTEGER + values2.length)
|
|
6170
|
+
raise("Deque full");
|
|
6171
|
+
for (let i = values2.length - 1; i >= 0; i--) {
|
|
6172
|
+
this.#data[--this.#front] = values2[i];
|
|
6173
|
+
}
|
|
6174
|
+
this.#size += values2.length;
|
|
6175
|
+
}
|
|
6176
|
+
popLeft() {
|
|
6177
|
+
if (this.#size < 1) return void 0;
|
|
6178
|
+
const value = this.#data[this.#front];
|
|
6179
|
+
delete this.#data[this.#front];
|
|
6180
|
+
this.#front++;
|
|
6181
|
+
this.#size--;
|
|
6182
|
+
return value;
|
|
6183
|
+
}
|
|
6184
|
+
};
|
|
6185
|
+
|
|
6128
6186
|
// src/lib/Json.ts
|
|
6129
6187
|
function isJsonScalar(data) {
|
|
6130
6188
|
return data === null || typeof data === "string" || typeof data === "number" || typeof data === "boolean";
|
|
@@ -6577,7 +6635,7 @@ function createRoom(options, config) {
|
|
|
6577
6635
|
)
|
|
6578
6636
|
);
|
|
6579
6637
|
}
|
|
6580
|
-
activeBatch.reverseOps.
|
|
6638
|
+
activeBatch.reverseOps.pushLeft(reverse);
|
|
6581
6639
|
} else {
|
|
6582
6640
|
addToUndoStack(reverse);
|
|
6583
6641
|
context.redoStack.length = 0;
|
|
@@ -6800,7 +6858,7 @@ function createRoom(options, config) {
|
|
|
6800
6858
|
}
|
|
6801
6859
|
function addToUndoStack(historyOps) {
|
|
6802
6860
|
if (context.pausedHistory !== null) {
|
|
6803
|
-
context.pausedHistory.
|
|
6861
|
+
context.pausedHistory.pushLeft(historyOps);
|
|
6804
6862
|
} else {
|
|
6805
6863
|
_addToRealUndoStack(historyOps);
|
|
6806
6864
|
}
|
|
@@ -6835,7 +6893,7 @@ function createRoom(options, config) {
|
|
|
6835
6893
|
}
|
|
6836
6894
|
function applyOps(rawOps, isLocal) {
|
|
6837
6895
|
const output = {
|
|
6838
|
-
reverse:
|
|
6896
|
+
reverse: new Deque(),
|
|
6839
6897
|
storageUpdates: /* @__PURE__ */ new Map(),
|
|
6840
6898
|
presence: false
|
|
6841
6899
|
};
|
|
@@ -6864,7 +6922,7 @@ function createRoom(options, config) {
|
|
|
6864
6922
|
context.buffer.presenceUpdates.data[key] = op.data[key];
|
|
6865
6923
|
}
|
|
6866
6924
|
}
|
|
6867
|
-
output.reverse.
|
|
6925
|
+
output.reverse.pushLeft(reverse);
|
|
6868
6926
|
output.presence = true;
|
|
6869
6927
|
} else {
|
|
6870
6928
|
let source;
|
|
@@ -6889,7 +6947,7 @@ function createRoom(options, config) {
|
|
|
6889
6947
|
applyOpResult.modified
|
|
6890
6948
|
)
|
|
6891
6949
|
);
|
|
6892
|
-
output.reverse.
|
|
6950
|
+
output.reverse.pushLeft(applyOpResult.reverse);
|
|
6893
6951
|
}
|
|
6894
6952
|
if (op.type === 2 /* CREATE_LIST */ || op.type === 7 /* CREATE_MAP */ || op.type === 4 /* CREATE_OBJECT */) {
|
|
6895
6953
|
createdNodeIds.add(nn(op.id));
|
|
@@ -6899,7 +6957,7 @@ function createRoom(options, config) {
|
|
|
6899
6957
|
}
|
|
6900
6958
|
return {
|
|
6901
6959
|
ops,
|
|
6902
|
-
reverse: output.reverse,
|
|
6960
|
+
reverse: Array.from(output.reverse),
|
|
6903
6961
|
updates: {
|
|
6904
6962
|
storageUpdates: output.storageUpdates,
|
|
6905
6963
|
presence: output.presence
|
|
@@ -6968,7 +7026,7 @@ function createRoom(options, config) {
|
|
|
6968
7026
|
context.myPresence.patch(patch);
|
|
6969
7027
|
if (context.activeBatch) {
|
|
6970
7028
|
if (options2?.addToHistory) {
|
|
6971
|
-
context.activeBatch.reverseOps.
|
|
7029
|
+
context.activeBatch.reverseOps.pushLeft({
|
|
6972
7030
|
type: "presence",
|
|
6973
7031
|
data: oldValues
|
|
6974
7032
|
});
|
|
@@ -7084,8 +7142,8 @@ function createRoom(options, config) {
|
|
|
7084
7142
|
return;
|
|
7085
7143
|
}
|
|
7086
7144
|
const messages = [];
|
|
7087
|
-
const
|
|
7088
|
-
const result = applyOps(
|
|
7145
|
+
const inOps = Array.from(offlineOps.values());
|
|
7146
|
+
const result = applyOps(inOps, true);
|
|
7089
7147
|
messages.push({
|
|
7090
7148
|
type: 201 /* UPDATE_STORAGE */,
|
|
7091
7149
|
ops: result.ops
|
|
@@ -7426,7 +7484,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7426
7484
|
presence: false,
|
|
7427
7485
|
others: []
|
|
7428
7486
|
},
|
|
7429
|
-
reverseOps:
|
|
7487
|
+
reverseOps: new Deque()
|
|
7430
7488
|
};
|
|
7431
7489
|
try {
|
|
7432
7490
|
returnValue = callback();
|
|
@@ -7434,7 +7492,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7434
7492
|
const currentBatch = context.activeBatch;
|
|
7435
7493
|
context.activeBatch = null;
|
|
7436
7494
|
if (currentBatch.reverseOps.length > 0) {
|
|
7437
|
-
addToUndoStack(currentBatch.reverseOps);
|
|
7495
|
+
addToUndoStack(Array.from(currentBatch.reverseOps));
|
|
7438
7496
|
}
|
|
7439
7497
|
if (currentBatch.ops.length > 0) {
|
|
7440
7498
|
context.redoStack.length = 0;
|
|
@@ -7449,14 +7507,14 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7449
7507
|
}
|
|
7450
7508
|
function pauseHistory() {
|
|
7451
7509
|
if (context.pausedHistory === null) {
|
|
7452
|
-
context.pausedHistory =
|
|
7510
|
+
context.pausedHistory = new Deque();
|
|
7453
7511
|
}
|
|
7454
7512
|
}
|
|
7455
7513
|
function resumeHistory() {
|
|
7456
7514
|
const historyOps = context.pausedHistory;
|
|
7457
7515
|
context.pausedHistory = null;
|
|
7458
7516
|
if (historyOps !== null && historyOps.length > 0) {
|
|
7459
|
-
_addToRealUndoStack(historyOps);
|
|
7517
|
+
_addToRealUndoStack(Array.from(historyOps));
|
|
7460
7518
|
}
|
|
7461
7519
|
}
|
|
7462
7520
|
const syncSourceForStorage = config.createSyncSource();
|