@liveblocks/core 2.18.0 → 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.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +83 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -2090,6 +2090,12 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
2090
2090
|
readonly storageStatus: Observable<StorageStatus>;
|
|
2091
2091
|
readonly ydoc: Observable<YDocUpdateServerMsg | UpdateYDocClientMsg>;
|
|
2092
2092
|
readonly comments: Observable<CommentsEventServerMsg>;
|
|
2093
|
+
/**
|
|
2094
|
+
* Called right before the room is destroyed. The event cannot be used to
|
|
2095
|
+
* prevent the room from being destroyed, only to be informed that this is
|
|
2096
|
+
* imminent.
|
|
2097
|
+
*/
|
|
2098
|
+
readonly roomWillDestroy: Observable<void>;
|
|
2093
2099
|
};
|
|
2094
2100
|
/**
|
|
2095
2101
|
* Batches modifications made during the given function.
|
package/dist/index.d.ts
CHANGED
|
@@ -2090,6 +2090,12 @@ type Room<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUs
|
|
|
2090
2090
|
readonly storageStatus: Observable<StorageStatus>;
|
|
2091
2091
|
readonly ydoc: Observable<YDocUpdateServerMsg | UpdateYDocClientMsg>;
|
|
2092
2092
|
readonly comments: Observable<CommentsEventServerMsg>;
|
|
2093
|
+
/**
|
|
2094
|
+
* Called right before the room is destroyed. The event cannot be used to
|
|
2095
|
+
* prevent the room from being destroyed, only to be informed that this is
|
|
2096
|
+
* imminent.
|
|
2097
|
+
*/
|
|
2098
|
+
readonly roomWillDestroy: Observable<void>;
|
|
2093
2099
|
};
|
|
2094
2100
|
/**
|
|
2095
2101
|
* Batches modifications made during the given function.
|
package/dist/index.js
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 = "cjs";
|
|
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;
|
|
@@ -6611,7 +6669,8 @@ function createRoom(options, config) {
|
|
|
6611
6669
|
storageDidLoad: makeEventSource(),
|
|
6612
6670
|
storageStatus: makeEventSource(),
|
|
6613
6671
|
ydoc: makeEventSource(),
|
|
6614
|
-
comments: makeEventSource()
|
|
6672
|
+
comments: makeEventSource(),
|
|
6673
|
+
roomWillDestroy: makeEventSource()
|
|
6615
6674
|
};
|
|
6616
6675
|
const roomId = config.roomId;
|
|
6617
6676
|
async function createTextMention(userId, mentionId) {
|
|
@@ -6799,7 +6858,7 @@ function createRoom(options, config) {
|
|
|
6799
6858
|
}
|
|
6800
6859
|
function addToUndoStack(historyOps) {
|
|
6801
6860
|
if (context.pausedHistory !== null) {
|
|
6802
|
-
context.pausedHistory.
|
|
6861
|
+
context.pausedHistory.pushLeft(historyOps);
|
|
6803
6862
|
} else {
|
|
6804
6863
|
_addToRealUndoStack(historyOps);
|
|
6805
6864
|
}
|
|
@@ -6834,7 +6893,7 @@ function createRoom(options, config) {
|
|
|
6834
6893
|
}
|
|
6835
6894
|
function applyOps(rawOps, isLocal) {
|
|
6836
6895
|
const output = {
|
|
6837
|
-
reverse:
|
|
6896
|
+
reverse: new Deque(),
|
|
6838
6897
|
storageUpdates: /* @__PURE__ */ new Map(),
|
|
6839
6898
|
presence: false
|
|
6840
6899
|
};
|
|
@@ -6863,7 +6922,7 @@ function createRoom(options, config) {
|
|
|
6863
6922
|
context.buffer.presenceUpdates.data[key] = op.data[key];
|
|
6864
6923
|
}
|
|
6865
6924
|
}
|
|
6866
|
-
output.reverse.
|
|
6925
|
+
output.reverse.pushLeft(reverse);
|
|
6867
6926
|
output.presence = true;
|
|
6868
6927
|
} else {
|
|
6869
6928
|
let source;
|
|
@@ -6888,7 +6947,7 @@ function createRoom(options, config) {
|
|
|
6888
6947
|
applyOpResult.modified
|
|
6889
6948
|
)
|
|
6890
6949
|
);
|
|
6891
|
-
output.reverse.
|
|
6950
|
+
output.reverse.pushLeft(applyOpResult.reverse);
|
|
6892
6951
|
}
|
|
6893
6952
|
if (op.type === 2 /* CREATE_LIST */ || op.type === 7 /* CREATE_MAP */ || op.type === 4 /* CREATE_OBJECT */) {
|
|
6894
6953
|
createdNodeIds.add(nn(op.id));
|
|
@@ -6898,7 +6957,7 @@ function createRoom(options, config) {
|
|
|
6898
6957
|
}
|
|
6899
6958
|
return {
|
|
6900
6959
|
ops,
|
|
6901
|
-
reverse: output.reverse,
|
|
6960
|
+
reverse: Array.from(output.reverse),
|
|
6902
6961
|
updates: {
|
|
6903
6962
|
storageUpdates: output.storageUpdates,
|
|
6904
6963
|
presence: output.presence
|
|
@@ -6967,7 +7026,7 @@ function createRoom(options, config) {
|
|
|
6967
7026
|
context.myPresence.patch(patch);
|
|
6968
7027
|
if (context.activeBatch) {
|
|
6969
7028
|
if (_optionalChain([options2, 'optionalAccess', _149 => _149.addToHistory])) {
|
|
6970
|
-
context.activeBatch.reverseOps.
|
|
7029
|
+
context.activeBatch.reverseOps.pushLeft({
|
|
6971
7030
|
type: "presence",
|
|
6972
7031
|
data: oldValues
|
|
6973
7032
|
});
|
|
@@ -7083,8 +7142,8 @@ function createRoom(options, config) {
|
|
|
7083
7142
|
return;
|
|
7084
7143
|
}
|
|
7085
7144
|
const messages = [];
|
|
7086
|
-
const
|
|
7087
|
-
const result = applyOps(
|
|
7145
|
+
const inOps = Array.from(offlineOps.values());
|
|
7146
|
+
const result = applyOps(inOps, true);
|
|
7088
7147
|
messages.push({
|
|
7089
7148
|
type: 201 /* UPDATE_STORAGE */,
|
|
7090
7149
|
ops: result.ops
|
|
@@ -7425,7 +7484,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7425
7484
|
presence: false,
|
|
7426
7485
|
others: []
|
|
7427
7486
|
},
|
|
7428
|
-
reverseOps:
|
|
7487
|
+
reverseOps: new Deque()
|
|
7429
7488
|
};
|
|
7430
7489
|
try {
|
|
7431
7490
|
returnValue = callback();
|
|
@@ -7433,7 +7492,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7433
7492
|
const currentBatch = context.activeBatch;
|
|
7434
7493
|
context.activeBatch = null;
|
|
7435
7494
|
if (currentBatch.reverseOps.length > 0) {
|
|
7436
|
-
addToUndoStack(currentBatch.reverseOps);
|
|
7495
|
+
addToUndoStack(Array.from(currentBatch.reverseOps));
|
|
7437
7496
|
}
|
|
7438
7497
|
if (currentBatch.ops.length > 0) {
|
|
7439
7498
|
context.redoStack.length = 0;
|
|
@@ -7448,14 +7507,14 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7448
7507
|
}
|
|
7449
7508
|
function pauseHistory() {
|
|
7450
7509
|
if (context.pausedHistory === null) {
|
|
7451
|
-
context.pausedHistory =
|
|
7510
|
+
context.pausedHistory = new Deque();
|
|
7452
7511
|
}
|
|
7453
7512
|
}
|
|
7454
7513
|
function resumeHistory() {
|
|
7455
7514
|
const historyOps = context.pausedHistory;
|
|
7456
7515
|
context.pausedHistory = null;
|
|
7457
7516
|
if (historyOps !== null && historyOps.length > 0) {
|
|
7458
|
-
_addToRealUndoStack(historyOps);
|
|
7517
|
+
_addToRealUndoStack(Array.from(historyOps));
|
|
7459
7518
|
}
|
|
7460
7519
|
}
|
|
7461
7520
|
const syncSourceForStorage = config.createSyncSource();
|
|
@@ -7516,7 +7575,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7516
7575
|
storageDidLoad: eventHub.storageDidLoad.observable,
|
|
7517
7576
|
storageStatus: eventHub.storageStatus.observable,
|
|
7518
7577
|
ydoc: eventHub.ydoc.observable,
|
|
7519
|
-
comments: eventHub.comments.observable
|
|
7578
|
+
comments: eventHub.comments.observable,
|
|
7579
|
+
roomWillDestroy: eventHub.roomWillDestroy.observable
|
|
7520
7580
|
};
|
|
7521
7581
|
async function getThreadsSince(options2) {
|
|
7522
7582
|
return httpClient.getThreadsSince({
|
|
@@ -7710,11 +7770,17 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7710
7770
|
reconnect: () => managedSocket.reconnect(),
|
|
7711
7771
|
disconnect: () => managedSocket.disconnect(),
|
|
7712
7772
|
destroy: () => {
|
|
7713
|
-
|
|
7773
|
+
const { roomWillDestroy, ...eventsExceptDestroy } = eventHub;
|
|
7774
|
+
for (const source of Object.values(eventsExceptDestroy)) {
|
|
7775
|
+
source[Symbol.dispose]();
|
|
7776
|
+
}
|
|
7777
|
+
eventHub.roomWillDestroy.notify();
|
|
7714
7778
|
_optionalChain([context, 'access', _166 => _166.yjsProvider, 'optionalAccess', _167 => _167.off, 'call', _168 => _168("status", yjsStatusDidChange)]);
|
|
7779
|
+
syncSourceForStorage.destroy();
|
|
7715
7780
|
syncSourceForYjs.destroy();
|
|
7716
7781
|
uninstallBgTabSpy();
|
|
7717
7782
|
managedSocket.destroy();
|
|
7783
|
+
roomWillDestroy[Symbol.dispose]();
|
|
7718
7784
|
},
|
|
7719
7785
|
// Presence
|
|
7720
7786
|
updatePresence,
|