@liveblocks/core 3.16.0 → 3.17.0
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 +413 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +105 -4
- package/dist/index.d.ts +105 -4
- package/dist/index.js +341 -96
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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.17.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -6319,7 +6319,6 @@ var AbstractCrdt = class {
|
|
|
6319
6319
|
}
|
|
6320
6320
|
/**
|
|
6321
6321
|
* @internal
|
|
6322
|
-
*
|
|
6323
6322
|
* Return an snapshot of this Live tree for use in DevTools.
|
|
6324
6323
|
*/
|
|
6325
6324
|
toTreeNode(key) {
|
|
@@ -6329,6 +6328,14 @@ var AbstractCrdt = class {
|
|
|
6329
6328
|
}
|
|
6330
6329
|
return this.#cachedTreeNode;
|
|
6331
6330
|
}
|
|
6331
|
+
/**
|
|
6332
|
+
* @private
|
|
6333
|
+
* Returns true if the cached immutable snapshot exists and is
|
|
6334
|
+
* reference-equal to the given value. Does not trigger a recompute.
|
|
6335
|
+
*/
|
|
6336
|
+
immutableIs(value) {
|
|
6337
|
+
return this.#cachedImmutable !== void 0 && this.#cachedImmutable === value;
|
|
6338
|
+
}
|
|
6332
6339
|
/**
|
|
6333
6340
|
* Return an immutable snapshot of this Live node and its children.
|
|
6334
6341
|
*/
|
|
@@ -6728,7 +6735,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6728
6735
|
};
|
|
6729
6736
|
} else {
|
|
6730
6737
|
if (indexOfItemWithSamePosition !== -1) {
|
|
6731
|
-
nn(
|
|
6738
|
+
const displaced = nn(
|
|
6739
|
+
this.#items.removeAt(indexOfItemWithSamePosition)
|
|
6740
|
+
);
|
|
6741
|
+
this.#implicitlyDeletedItems.add(displaced);
|
|
6732
6742
|
}
|
|
6733
6743
|
const { newItem, newIndex } = this.#createAttachItemAndSort(
|
|
6734
6744
|
op,
|
|
@@ -7876,10 +7886,115 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7876
7886
|
}
|
|
7877
7887
|
};
|
|
7878
7888
|
|
|
7889
|
+
// src/crdts/reconcile.ts
|
|
7890
|
+
function deepLiveify(value, config) {
|
|
7891
|
+
if (Array.isArray(value)) {
|
|
7892
|
+
return new LiveList(value.map((v) => deepLiveify(v, config)));
|
|
7893
|
+
} else if (isPlainObject(value)) {
|
|
7894
|
+
const init = {};
|
|
7895
|
+
const locals = {};
|
|
7896
|
+
for (const key in value) {
|
|
7897
|
+
const val = value[key];
|
|
7898
|
+
if (val === void 0) {
|
|
7899
|
+
continue;
|
|
7900
|
+
}
|
|
7901
|
+
const subConfig = isPlainObject(config) ? config[key] : config;
|
|
7902
|
+
if (subConfig === false) {
|
|
7903
|
+
locals[key] = val;
|
|
7904
|
+
} else if (subConfig === "atomic") {
|
|
7905
|
+
init[key] = val;
|
|
7906
|
+
} else {
|
|
7907
|
+
init[key] = deepLiveify(val, subConfig);
|
|
7908
|
+
}
|
|
7909
|
+
}
|
|
7910
|
+
const lo = new LiveObject(init);
|
|
7911
|
+
for (const key in locals) {
|
|
7912
|
+
lo.setLocal(key, locals[key]);
|
|
7913
|
+
}
|
|
7914
|
+
return lo;
|
|
7915
|
+
} else {
|
|
7916
|
+
return value;
|
|
7917
|
+
}
|
|
7918
|
+
}
|
|
7919
|
+
function reconcile(live, json, config) {
|
|
7920
|
+
if (isLiveObject(live) && isPlainObject(json)) {
|
|
7921
|
+
return reconcileLiveObject(live, json, config);
|
|
7922
|
+
} else if (isLiveList(live) && Array.isArray(json)) {
|
|
7923
|
+
return reconcileLiveList(live, json, config);
|
|
7924
|
+
} else if (isLiveMap(live) && isPlainObject(json)) {
|
|
7925
|
+
return reconcileLiveMap(live, config);
|
|
7926
|
+
} else {
|
|
7927
|
+
return deepLiveify(json, config);
|
|
7928
|
+
}
|
|
7929
|
+
}
|
|
7930
|
+
function reconcileLiveMap(_liveMap, _config) {
|
|
7931
|
+
throw new Error("Reconciling a LiveMap is not supported yet");
|
|
7932
|
+
}
|
|
7933
|
+
function reconcileLiveObject(liveObj, jsonObj, config) {
|
|
7934
|
+
const currentKeys = liveObj.keys();
|
|
7935
|
+
for (const key in jsonObj) {
|
|
7936
|
+
currentKeys.delete(key);
|
|
7937
|
+
const newVal = jsonObj[key];
|
|
7938
|
+
if (newVal === void 0) {
|
|
7939
|
+
liveObj.delete(key);
|
|
7940
|
+
continue;
|
|
7941
|
+
}
|
|
7942
|
+
const subConfig = isPlainObject(config) ? config[key] : config;
|
|
7943
|
+
if (subConfig === false) {
|
|
7944
|
+
liveObj.setLocal(key, newVal);
|
|
7945
|
+
} else if (subConfig === "atomic") {
|
|
7946
|
+
const curVal = liveObj.get(key);
|
|
7947
|
+
if (curVal !== newVal) {
|
|
7948
|
+
liveObj.set(key, newVal);
|
|
7949
|
+
}
|
|
7950
|
+
} else {
|
|
7951
|
+
const curVal = liveObj.get(key);
|
|
7952
|
+
if (curVal === void 0) {
|
|
7953
|
+
liveObj.set(key, deepLiveify(newVal, subConfig));
|
|
7954
|
+
} else if (isLiveStructure(curVal)) {
|
|
7955
|
+
const next = reconcile(curVal, newVal, subConfig);
|
|
7956
|
+
if (next !== curVal) {
|
|
7957
|
+
liveObj.set(key, next);
|
|
7958
|
+
}
|
|
7959
|
+
} else if (curVal !== newVal) {
|
|
7960
|
+
liveObj.set(key, deepLiveify(newVal, subConfig));
|
|
7961
|
+
}
|
|
7962
|
+
}
|
|
7963
|
+
}
|
|
7964
|
+
for (const key of currentKeys) {
|
|
7965
|
+
liveObj.delete(key);
|
|
7966
|
+
}
|
|
7967
|
+
return liveObj;
|
|
7968
|
+
}
|
|
7969
|
+
function reconcileLiveList(liveList, jsonArr, config) {
|
|
7970
|
+
const curLen = liveList.length;
|
|
7971
|
+
const newLen = jsonArr.length;
|
|
7972
|
+
for (let i = 0; i < Math.min(curLen, newLen); i++) {
|
|
7973
|
+
const curVal = liveList.get(i);
|
|
7974
|
+
const newVal = jsonArr[i];
|
|
7975
|
+
if (isLiveStructure(curVal)) {
|
|
7976
|
+
const next = reconcile(curVal, newVal, config);
|
|
7977
|
+
if (next !== curVal) {
|
|
7978
|
+
liveList.set(i, next);
|
|
7979
|
+
}
|
|
7980
|
+
} else if (curVal !== newVal) {
|
|
7981
|
+
liveList.set(i, deepLiveify(newVal, config));
|
|
7982
|
+
}
|
|
7983
|
+
}
|
|
7984
|
+
for (let i = curLen; i < newLen; i++) {
|
|
7985
|
+
liveList.push(deepLiveify(jsonArr[i], config));
|
|
7986
|
+
}
|
|
7987
|
+
for (let i = curLen - 1; i >= newLen; i--) {
|
|
7988
|
+
liveList.delete(i);
|
|
7989
|
+
}
|
|
7990
|
+
return liveList;
|
|
7991
|
+
}
|
|
7992
|
+
|
|
7879
7993
|
// src/crdts/LiveObject.ts
|
|
7880
7994
|
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7881
7995
|
var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
7882
|
-
#
|
|
7996
|
+
#synced;
|
|
7997
|
+
#local = /* @__PURE__ */ new Map();
|
|
7883
7998
|
/**
|
|
7884
7999
|
* Tracks unacknowledged local changes per property to preserve optimistic
|
|
7885
8000
|
* updates. Maps property keys to their pending operation IDs.
|
|
@@ -7944,7 +8059,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7944
8059
|
value._setParentLink(this, key);
|
|
7945
8060
|
}
|
|
7946
8061
|
}
|
|
7947
|
-
this.#
|
|
8062
|
+
this.#synced = new Map(Object.entries(o));
|
|
7948
8063
|
}
|
|
7949
8064
|
/** @internal */
|
|
7950
8065
|
_toOps(parentId, parentKey) {
|
|
@@ -7960,7 +8075,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7960
8075
|
data: {}
|
|
7961
8076
|
};
|
|
7962
8077
|
ops.push(op);
|
|
7963
|
-
for (const [key, value] of this.#
|
|
8078
|
+
for (const [key, value] of this.#synced) {
|
|
7964
8079
|
if (isLiveNode(value)) {
|
|
7965
8080
|
for (const childOp of value._toOps(this._id, key)) {
|
|
7966
8081
|
ops.push(childOp);
|
|
@@ -7989,7 +8104,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7989
8104
|
if (isLiveStructure(child)) {
|
|
7990
8105
|
child._setParentLink(liveObj, crdt.parentKey);
|
|
7991
8106
|
}
|
|
7992
|
-
liveObj.#
|
|
8107
|
+
liveObj.#synced.set(crdt.parentKey, child);
|
|
7993
8108
|
liveObj.invalidate();
|
|
7994
8109
|
}
|
|
7995
8110
|
return liveObj;
|
|
@@ -7997,7 +8112,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7997
8112
|
/** @internal */
|
|
7998
8113
|
_attach(id, pool) {
|
|
7999
8114
|
super._attach(id, pool);
|
|
8000
|
-
for (const [_key, value] of this.#
|
|
8115
|
+
for (const [_key, value] of this.#synced) {
|
|
8001
8116
|
if (isLiveNode(value)) {
|
|
8002
8117
|
value._attach(pool.generateId(), pool);
|
|
8003
8118
|
}
|
|
@@ -8026,7 +8141,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8026
8141
|
return { modified: false };
|
|
8027
8142
|
}
|
|
8028
8143
|
const thisId = nn(this._id);
|
|
8029
|
-
const previousValue = this.#
|
|
8144
|
+
const previousValue = this.#synced.get(key);
|
|
8030
8145
|
let reverse;
|
|
8031
8146
|
if (isLiveNode(previousValue)) {
|
|
8032
8147
|
reverse = previousValue._toOps(thisId, key);
|
|
@@ -8042,7 +8157,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8042
8157
|
}
|
|
8043
8158
|
];
|
|
8044
8159
|
}
|
|
8045
|
-
this.#
|
|
8160
|
+
this.#local.delete(key);
|
|
8161
|
+
this.#synced.set(key, child);
|
|
8046
8162
|
this.invalidate();
|
|
8047
8163
|
if (isLiveStructure(child)) {
|
|
8048
8164
|
child._setParentLink(this, key);
|
|
@@ -8063,9 +8179,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8063
8179
|
const id = nn(this._id);
|
|
8064
8180
|
const parentKey = nn(child._parentKey);
|
|
8065
8181
|
const reverse = child._toOps(id, parentKey);
|
|
8066
|
-
for (const [key, value] of this.#
|
|
8182
|
+
for (const [key, value] of this.#synced) {
|
|
8067
8183
|
if (value === child) {
|
|
8068
|
-
this.#
|
|
8184
|
+
this.#synced.delete(key);
|
|
8069
8185
|
this.invalidate();
|
|
8070
8186
|
}
|
|
8071
8187
|
}
|
|
@@ -8084,7 +8200,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8084
8200
|
/** @internal */
|
|
8085
8201
|
_detach() {
|
|
8086
8202
|
super._detach();
|
|
8087
|
-
for (const value of this.#
|
|
8203
|
+
for (const value of this.#synced.values()) {
|
|
8088
8204
|
if (isLiveNode(value)) {
|
|
8089
8205
|
value._detach();
|
|
8090
8206
|
}
|
|
@@ -8102,7 +8218,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8102
8218
|
/** @internal */
|
|
8103
8219
|
_serialize() {
|
|
8104
8220
|
const data = {};
|
|
8105
|
-
for (const [key, value] of this.#
|
|
8221
|
+
for (const [key, value] of this.#synced) {
|
|
8106
8222
|
if (!isLiveNode(value)) {
|
|
8107
8223
|
data[key] = value;
|
|
8108
8224
|
}
|
|
@@ -8131,7 +8247,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8131
8247
|
data: {}
|
|
8132
8248
|
};
|
|
8133
8249
|
for (const key in op.data) {
|
|
8134
|
-
const oldValue = this.#
|
|
8250
|
+
const oldValue = this.#synced.get(key);
|
|
8135
8251
|
if (isLiveNode(oldValue)) {
|
|
8136
8252
|
for (const childOp of oldValue._toOps(id, key)) {
|
|
8137
8253
|
reverse.push(childOp);
|
|
@@ -8159,13 +8275,14 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8159
8275
|
} else {
|
|
8160
8276
|
continue;
|
|
8161
8277
|
}
|
|
8162
|
-
const oldValue = this.#
|
|
8278
|
+
const oldValue = this.#synced.get(key);
|
|
8163
8279
|
if (isLiveNode(oldValue)) {
|
|
8164
8280
|
oldValue._detach();
|
|
8165
8281
|
}
|
|
8166
8282
|
isModified = true;
|
|
8167
8283
|
updateDelta[key] = { type: "update" };
|
|
8168
|
-
this.#
|
|
8284
|
+
this.#local.delete(key);
|
|
8285
|
+
this.#synced.set(key, value);
|
|
8169
8286
|
this.invalidate();
|
|
8170
8287
|
}
|
|
8171
8288
|
if (Object.keys(reverseUpdate.data).length !== 0) {
|
|
@@ -8182,7 +8299,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8182
8299
|
}
|
|
8183
8300
|
#applyDeleteObjectKey(op, isLocal) {
|
|
8184
8301
|
const key = op.key;
|
|
8185
|
-
const oldValue = this.#
|
|
8302
|
+
const oldValue = this.#synced.get(key);
|
|
8186
8303
|
if (oldValue === void 0) {
|
|
8187
8304
|
return { modified: false };
|
|
8188
8305
|
}
|
|
@@ -8203,7 +8320,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8203
8320
|
}
|
|
8204
8321
|
];
|
|
8205
8322
|
}
|
|
8206
|
-
this.#
|
|
8323
|
+
this.#local.delete(key);
|
|
8324
|
+
this.#synced.delete(key);
|
|
8207
8325
|
this.invalidate();
|
|
8208
8326
|
return {
|
|
8209
8327
|
modified: {
|
|
@@ -8216,11 +8334,23 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8216
8334
|
reverse
|
|
8217
8335
|
};
|
|
8218
8336
|
}
|
|
8337
|
+
/** @private */
|
|
8338
|
+
keys() {
|
|
8339
|
+
const result = new Set(this.#synced.keys());
|
|
8340
|
+
for (const key of this.#local.keys()) {
|
|
8341
|
+
result.add(key);
|
|
8342
|
+
}
|
|
8343
|
+
return result;
|
|
8344
|
+
}
|
|
8219
8345
|
/**
|
|
8220
8346
|
* Transform the LiveObject into a javascript object
|
|
8221
8347
|
*/
|
|
8222
8348
|
toObject() {
|
|
8223
|
-
|
|
8349
|
+
const result = Object.fromEntries(this.#synced);
|
|
8350
|
+
for (const [key, value] of this.#local) {
|
|
8351
|
+
result[key] = value;
|
|
8352
|
+
}
|
|
8353
|
+
return result;
|
|
8224
8354
|
}
|
|
8225
8355
|
/**
|
|
8226
8356
|
* Adds or updates a property with a specified key and a value.
|
|
@@ -8228,49 +8358,109 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8228
8358
|
* @param value The value of the property to add
|
|
8229
8359
|
*/
|
|
8230
8360
|
set(key, value) {
|
|
8231
|
-
_optionalChain([this, 'access', _192 => _192._pool, 'optionalAccess', _193 => _193.assertStorageIsWritable, 'call', _194 => _194()]);
|
|
8232
8361
|
this.update({ [key]: value });
|
|
8233
8362
|
}
|
|
8363
|
+
/**
|
|
8364
|
+
* @experimental
|
|
8365
|
+
*
|
|
8366
|
+
* Sets a local-only property that is not synchronized over the wire.
|
|
8367
|
+
* The value will be visible via get(), toObject(), and toImmutable() on
|
|
8368
|
+
* this client only. Other clients and the server will see `undefined`
|
|
8369
|
+
* for this key.
|
|
8370
|
+
*
|
|
8371
|
+
* Caveat: this method will not add changes to the undo/redo stack.
|
|
8372
|
+
*/
|
|
8373
|
+
setLocal(key, value) {
|
|
8374
|
+
_optionalChain([this, 'access', _192 => _192._pool, 'optionalAccess', _193 => _193.assertStorageIsWritable, 'call', _194 => _194()]);
|
|
8375
|
+
const deleteResult = this.#prepareDelete(key);
|
|
8376
|
+
this.#local.set(key, value);
|
|
8377
|
+
this.invalidate();
|
|
8378
|
+
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8379
|
+
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _195 => _195[0]]), () => ( []));
|
|
8380
|
+
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _196 => _196[1]]), () => ( []));
|
|
8381
|
+
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _197 => _197[2]]), () => ( /* @__PURE__ */ new Map()));
|
|
8382
|
+
const existing = storageUpdates.get(this._id);
|
|
8383
|
+
storageUpdates.set(this._id, {
|
|
8384
|
+
node: this,
|
|
8385
|
+
type: "LiveObject",
|
|
8386
|
+
updates: {
|
|
8387
|
+
..._optionalChain([existing, 'optionalAccess', _198 => _198.updates]),
|
|
8388
|
+
[key]: { type: "update" }
|
|
8389
|
+
}
|
|
8390
|
+
});
|
|
8391
|
+
this._pool.dispatch(ops, reverse, storageUpdates);
|
|
8392
|
+
}
|
|
8393
|
+
}
|
|
8234
8394
|
/**
|
|
8235
8395
|
* Returns a specified property from the LiveObject.
|
|
8236
8396
|
* @param key The key of the property to get
|
|
8237
8397
|
*/
|
|
8238
8398
|
get(key) {
|
|
8239
|
-
return this.#
|
|
8399
|
+
return this.#local.has(key) ? this.#local.get(key) : this.#synced.get(key);
|
|
8240
8400
|
}
|
|
8241
8401
|
/**
|
|
8242
|
-
*
|
|
8243
|
-
*
|
|
8402
|
+
* Removes a synced key, returning the ops, reverse ops, and storage updates
|
|
8403
|
+
* needed to notify the pool. Returns null if the key doesn't exist in
|
|
8404
|
+
* #synced or pool/id are unavailable. Does NOT dispatch.
|
|
8244
8405
|
*/
|
|
8245
|
-
|
|
8246
|
-
_optionalChain([this, 'access',
|
|
8247
|
-
const
|
|
8248
|
-
|
|
8406
|
+
#prepareDelete(key) {
|
|
8407
|
+
_optionalChain([this, 'access', _199 => _199._pool, 'optionalAccess', _200 => _200.assertStorageIsWritable, 'call', _201 => _201()]);
|
|
8408
|
+
const k = key;
|
|
8409
|
+
if (this.#local.has(k) && !this.#synced.has(k)) {
|
|
8410
|
+
const oldValue2 = this.#local.get(k);
|
|
8411
|
+
this.#local.delete(k);
|
|
8412
|
+
this.invalidate();
|
|
8413
|
+
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8414
|
+
const storageUpdates2 = /* @__PURE__ */ new Map();
|
|
8415
|
+
storageUpdates2.set(this._id, {
|
|
8416
|
+
node: this,
|
|
8417
|
+
type: "LiveObject",
|
|
8418
|
+
updates: {
|
|
8419
|
+
[k]: {
|
|
8420
|
+
type: "delete",
|
|
8421
|
+
deletedItem: oldValue2
|
|
8422
|
+
}
|
|
8423
|
+
}
|
|
8424
|
+
});
|
|
8425
|
+
return [[], [], storageUpdates2];
|
|
8426
|
+
}
|
|
8427
|
+
return null;
|
|
8428
|
+
}
|
|
8429
|
+
this.#local.delete(k);
|
|
8430
|
+
const oldValue = this.#synced.get(k);
|
|
8249
8431
|
if (oldValue === void 0) {
|
|
8250
|
-
return;
|
|
8432
|
+
return null;
|
|
8251
8433
|
}
|
|
8252
8434
|
if (this._pool === void 0 || this._id === void 0) {
|
|
8253
8435
|
if (isLiveNode(oldValue)) {
|
|
8254
8436
|
oldValue._detach();
|
|
8255
8437
|
}
|
|
8256
|
-
this.#
|
|
8438
|
+
this.#synced.delete(k);
|
|
8257
8439
|
this.invalidate();
|
|
8258
|
-
return;
|
|
8440
|
+
return null;
|
|
8259
8441
|
}
|
|
8442
|
+
const ops = [
|
|
8443
|
+
{
|
|
8444
|
+
type: OpCode.DELETE_OBJECT_KEY,
|
|
8445
|
+
key: k,
|
|
8446
|
+
id: this._id,
|
|
8447
|
+
opId: this._pool.generateOpId()
|
|
8448
|
+
}
|
|
8449
|
+
];
|
|
8260
8450
|
let reverse;
|
|
8261
8451
|
if (isLiveNode(oldValue)) {
|
|
8262
8452
|
oldValue._detach();
|
|
8263
|
-
reverse = oldValue._toOps(this._id,
|
|
8453
|
+
reverse = oldValue._toOps(this._id, k);
|
|
8264
8454
|
} else {
|
|
8265
8455
|
reverse = [
|
|
8266
8456
|
{
|
|
8267
8457
|
type: OpCode.UPDATE_OBJECT,
|
|
8268
|
-
data: { [
|
|
8458
|
+
data: { [k]: oldValue },
|
|
8269
8459
|
id: this._id
|
|
8270
8460
|
}
|
|
8271
8461
|
];
|
|
8272
8462
|
}
|
|
8273
|
-
this.#
|
|
8463
|
+
this.#synced.delete(k);
|
|
8274
8464
|
this.invalidate();
|
|
8275
8465
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
8276
8466
|
storageUpdates.set(this._id, {
|
|
@@ -8280,28 +8470,28 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8280
8470
|
[key]: { type: "delete", deletedItem: oldValue }
|
|
8281
8471
|
}
|
|
8282
8472
|
});
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
reverse,
|
|
8293
|
-
storageUpdates
|
|
8294
|
-
|
|
8473
|
+
return [ops, reverse, storageUpdates];
|
|
8474
|
+
}
|
|
8475
|
+
/**
|
|
8476
|
+
* Deletes a key from the LiveObject
|
|
8477
|
+
* @param key The key of the property to delete
|
|
8478
|
+
*/
|
|
8479
|
+
delete(key) {
|
|
8480
|
+
const result = this.#prepareDelete(key);
|
|
8481
|
+
if (result) {
|
|
8482
|
+
const [ops, reverse, storageUpdates] = result;
|
|
8483
|
+
_optionalChain([this, 'access', _202 => _202._pool, 'optionalAccess', _203 => _203.dispatch, 'call', _204 => _204(ops, reverse, storageUpdates)]);
|
|
8484
|
+
}
|
|
8295
8485
|
}
|
|
8296
8486
|
/**
|
|
8297
8487
|
* Adds or updates multiple properties at once with an object.
|
|
8298
8488
|
* @param patch The object used to overrides properties
|
|
8299
8489
|
*/
|
|
8300
8490
|
update(patch) {
|
|
8301
|
-
_optionalChain([this, 'access',
|
|
8491
|
+
_optionalChain([this, 'access', _205 => _205._pool, 'optionalAccess', _206 => _206.assertStorageIsWritable, 'call', _207 => _207()]);
|
|
8302
8492
|
if (_LiveObject.detectLargeObjects) {
|
|
8303
8493
|
const data = {};
|
|
8304
|
-
for (const [key, value] of this.#
|
|
8494
|
+
for (const [key, value] of this.#synced) {
|
|
8305
8495
|
if (!isLiveNode(value)) {
|
|
8306
8496
|
data[key] = value;
|
|
8307
8497
|
}
|
|
@@ -8330,14 +8520,15 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8330
8520
|
if (newValue === void 0) {
|
|
8331
8521
|
continue;
|
|
8332
8522
|
}
|
|
8333
|
-
const oldValue = this.#
|
|
8523
|
+
const oldValue = this.#synced.get(key);
|
|
8334
8524
|
if (isLiveNode(oldValue)) {
|
|
8335
8525
|
oldValue._detach();
|
|
8336
8526
|
}
|
|
8337
8527
|
if (isLiveNode(newValue)) {
|
|
8338
8528
|
newValue._setParentLink(this, key);
|
|
8339
8529
|
}
|
|
8340
|
-
this.#
|
|
8530
|
+
this.#local.delete(key);
|
|
8531
|
+
this.#synced.set(key, newValue);
|
|
8341
8532
|
this.invalidate();
|
|
8342
8533
|
}
|
|
8343
8534
|
return;
|
|
@@ -8357,7 +8548,10 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8357
8548
|
if (newValue === void 0) {
|
|
8358
8549
|
continue;
|
|
8359
8550
|
}
|
|
8360
|
-
const oldValue = this.#
|
|
8551
|
+
const oldValue = this.#synced.get(key);
|
|
8552
|
+
if (oldValue === newValue) {
|
|
8553
|
+
continue;
|
|
8554
|
+
}
|
|
8361
8555
|
if (isLiveNode(oldValue)) {
|
|
8362
8556
|
for (const childOp of oldValue._toOps(this._id, key)) {
|
|
8363
8557
|
reverseOps.push(childOp);
|
|
@@ -8389,7 +8583,8 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8389
8583
|
updatedProps[key] = newValue;
|
|
8390
8584
|
this.#unackedOpsByKey.set(key, opId);
|
|
8391
8585
|
}
|
|
8392
|
-
this.#
|
|
8586
|
+
this.#local.delete(key);
|
|
8587
|
+
this.#synced.set(key, newValue);
|
|
8393
8588
|
this.invalidate();
|
|
8394
8589
|
updateDelta[key] = { type: "update" };
|
|
8395
8590
|
}
|
|
@@ -8404,6 +8599,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8404
8599
|
data: updatedProps
|
|
8405
8600
|
});
|
|
8406
8601
|
}
|
|
8602
|
+
if (ops.length === 0 && reverseOps.length === 0 && Object.keys(updateDelta).length === 0) {
|
|
8603
|
+
return;
|
|
8604
|
+
}
|
|
8407
8605
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
8408
8606
|
storageUpdates.set(this._id, {
|
|
8409
8607
|
node: this,
|
|
@@ -8412,6 +8610,34 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8412
8610
|
});
|
|
8413
8611
|
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
8414
8612
|
}
|
|
8613
|
+
/**
|
|
8614
|
+
* Creates a new LiveObject from a plain JSON object, recursively converting
|
|
8615
|
+
* nested objects to LiveObjects and arrays to LiveLists. An optional
|
|
8616
|
+
* SyncConfig controls per-key behavior (local-only, atomic, or deep).
|
|
8617
|
+
*
|
|
8618
|
+
* @private
|
|
8619
|
+
*/
|
|
8620
|
+
static from(obj, config) {
|
|
8621
|
+
if (!isPlainObject(obj)) throw new Error("Expected a JSON object");
|
|
8622
|
+
const liveObj = new _LiveObject({});
|
|
8623
|
+
liveObj.reconcile(obj, config);
|
|
8624
|
+
return liveObj;
|
|
8625
|
+
}
|
|
8626
|
+
/**
|
|
8627
|
+
* Reconciles a LiveObject tree to match the given JSON object and sync
|
|
8628
|
+
* config. Only mutates keys that actually changed. Recursively reconciles
|
|
8629
|
+
* the entire Live tree below it.
|
|
8630
|
+
*
|
|
8631
|
+
* @private
|
|
8632
|
+
*/
|
|
8633
|
+
reconcile(jsonObj, config) {
|
|
8634
|
+
if (this.immutableIs(jsonObj)) return;
|
|
8635
|
+
if (!isPlainObject(jsonObj))
|
|
8636
|
+
throw new Error(
|
|
8637
|
+
"Reconciling the document root expects a plain object value"
|
|
8638
|
+
);
|
|
8639
|
+
reconcileLiveObject(this, jsonObj, config);
|
|
8640
|
+
}
|
|
8415
8641
|
toImmutable() {
|
|
8416
8642
|
return super.toImmutable();
|
|
8417
8643
|
}
|
|
@@ -8426,7 +8652,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8426
8652
|
type: "LiveObject",
|
|
8427
8653
|
id: nodeId,
|
|
8428
8654
|
key,
|
|
8429
|
-
payload: Array.from(this.#
|
|
8655
|
+
payload: Array.from(this.#synced.entries()).map(
|
|
8430
8656
|
([key2, value]) => isLiveNode(value) ? value.toTreeNode(key2) : { type: "Json", id: `${nodeId}:${key2}`, key: key2, payload: value }
|
|
8431
8657
|
)
|
|
8432
8658
|
};
|
|
@@ -8434,20 +8660,27 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8434
8660
|
/** @internal */
|
|
8435
8661
|
_toImmutable() {
|
|
8436
8662
|
const result = {};
|
|
8437
|
-
for (const [key, val] of this.#
|
|
8663
|
+
for (const [key, val] of this.#synced) {
|
|
8438
8664
|
result[key] = isLiveStructure(val) ? val.toImmutable() : val;
|
|
8439
8665
|
}
|
|
8666
|
+
for (const [key, val] of this.#local) {
|
|
8667
|
+
result[key] = val;
|
|
8668
|
+
}
|
|
8440
8669
|
return process.env.NODE_ENV === "production" ? result : Object.freeze(result);
|
|
8441
8670
|
}
|
|
8442
8671
|
clone() {
|
|
8443
|
-
|
|
8672
|
+
const cloned = new _LiveObject(
|
|
8444
8673
|
Object.fromEntries(
|
|
8445
|
-
Array.from(this.#
|
|
8674
|
+
Array.from(this.#synced).map(([key, value]) => [
|
|
8446
8675
|
key,
|
|
8447
8676
|
isLiveStructure(value) ? value.clone() : deepClone(value)
|
|
8448
8677
|
])
|
|
8449
8678
|
)
|
|
8450
8679
|
);
|
|
8680
|
+
for (const [key, value] of this.#local) {
|
|
8681
|
+
cloned.#local.set(key, deepClone(value));
|
|
8682
|
+
}
|
|
8683
|
+
return cloned;
|
|
8451
8684
|
}
|
|
8452
8685
|
}, _class2.__initStatic(), _class2);
|
|
8453
8686
|
|
|
@@ -9067,15 +9300,15 @@ function installBackgroundTabSpy() {
|
|
|
9067
9300
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
9068
9301
|
const inBackgroundSince = { current: null };
|
|
9069
9302
|
function onVisibilityChange() {
|
|
9070
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
9303
|
+
if (_optionalChain([doc, 'optionalAccess', _208 => _208.visibilityState]) === "hidden") {
|
|
9071
9304
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
9072
9305
|
} else {
|
|
9073
9306
|
inBackgroundSince.current = null;
|
|
9074
9307
|
}
|
|
9075
9308
|
}
|
|
9076
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9309
|
+
_optionalChain([doc, 'optionalAccess', _209 => _209.addEventListener, 'call', _210 => _210("visibilitychange", onVisibilityChange)]);
|
|
9077
9310
|
const unsub = () => {
|
|
9078
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9311
|
+
_optionalChain([doc, 'optionalAccess', _211 => _211.removeEventListener, 'call', _212 => _212("visibilitychange", onVisibilityChange)]);
|
|
9079
9312
|
};
|
|
9080
9313
|
return [inBackgroundSince, unsub];
|
|
9081
9314
|
}
|
|
@@ -9255,14 +9488,18 @@ function createRoom(options, config) {
|
|
|
9255
9488
|
}
|
|
9256
9489
|
context.activeBatch.reverseOps.pushLeft(reverse);
|
|
9257
9490
|
} else {
|
|
9258
|
-
|
|
9259
|
-
|
|
9260
|
-
|
|
9491
|
+
if (reverse.length > 0) {
|
|
9492
|
+
addToUndoStack(reverse);
|
|
9493
|
+
}
|
|
9494
|
+
if (ops.length > 0) {
|
|
9495
|
+
context.redoStack.length = 0;
|
|
9496
|
+
dispatchOps(ops);
|
|
9497
|
+
}
|
|
9261
9498
|
notify({ storageUpdates });
|
|
9262
9499
|
}
|
|
9263
9500
|
}
|
|
9264
9501
|
function isStorageWritable() {
|
|
9265
|
-
const scopes = _optionalChain([context, 'access',
|
|
9502
|
+
const scopes = _optionalChain([context, 'access', _213 => _213.dynamicSessionInfoSig, 'access', _214 => _214.get, 'call', _215 => _215(), 'optionalAccess', _216 => _216.scopes]);
|
|
9266
9503
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
9267
9504
|
}
|
|
9268
9505
|
const eventHub = {
|
|
@@ -9366,20 +9603,21 @@ function createRoom(options, config) {
|
|
|
9366
9603
|
context.pool
|
|
9367
9604
|
);
|
|
9368
9605
|
}
|
|
9369
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
9370
|
-
const
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
if (
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9606
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _217 => _217.get, 'call', _218 => _218(), 'optionalAccess', _219 => _219.canWrite]), () => ( true));
|
|
9607
|
+
const root = context.root;
|
|
9608
|
+
withoutHistory(() => {
|
|
9609
|
+
for (const key in context.initialStorage) {
|
|
9610
|
+
if (root.get(key) === void 0) {
|
|
9611
|
+
if (canWrite) {
|
|
9612
|
+
root.set(key, cloneLson(context.initialStorage[key]));
|
|
9613
|
+
} else {
|
|
9614
|
+
warn(
|
|
9615
|
+
`Attempted to populate missing storage key '${key}', but current user has no write access`
|
|
9616
|
+
);
|
|
9617
|
+
}
|
|
9379
9618
|
}
|
|
9380
9619
|
}
|
|
9381
|
-
}
|
|
9382
|
-
context.undoStack.length = stackSizeBefore;
|
|
9620
|
+
});
|
|
9383
9621
|
}
|
|
9384
9622
|
function _addToRealUndoStack(frames) {
|
|
9385
9623
|
if (context.undoStack.length >= 50) {
|
|
@@ -9570,7 +9808,7 @@ function createRoom(options, config) {
|
|
|
9570
9808
|
}
|
|
9571
9809
|
context.myPresence.patch(patch);
|
|
9572
9810
|
if (context.activeBatch) {
|
|
9573
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9811
|
+
if (_optionalChain([options2, 'optionalAccess', _220 => _220.addToHistory])) {
|
|
9574
9812
|
context.activeBatch.reverseOps.pushLeft({
|
|
9575
9813
|
type: "presence",
|
|
9576
9814
|
data: oldValues
|
|
@@ -9579,7 +9817,7 @@ function createRoom(options, config) {
|
|
|
9579
9817
|
context.activeBatch.updates.presence = true;
|
|
9580
9818
|
} else {
|
|
9581
9819
|
flushNowOrSoon();
|
|
9582
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9820
|
+
if (_optionalChain([options2, 'optionalAccess', _221 => _221.addToHistory])) {
|
|
9583
9821
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
9584
9822
|
}
|
|
9585
9823
|
notify({ presence: true });
|
|
@@ -9756,11 +9994,11 @@ function createRoom(options, config) {
|
|
|
9756
9994
|
break;
|
|
9757
9995
|
}
|
|
9758
9996
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
9759
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
9997
|
+
_optionalChain([stopwatch, 'optionalAccess', _222 => _222.lap, 'call', _223 => _223()]);
|
|
9760
9998
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
9761
9999
|
break;
|
|
9762
10000
|
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
9763
|
-
const timing = _optionalChain([stopwatch, 'optionalAccess',
|
|
10001
|
+
const timing = _optionalChain([stopwatch, 'optionalAccess', _224 => _224.stop, 'call', _225 => _225()]);
|
|
9764
10002
|
if (timing) {
|
|
9765
10003
|
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
9766
10004
|
const rest = timing.laps.slice(1);
|
|
@@ -9895,11 +10133,11 @@ function createRoom(options, config) {
|
|
|
9895
10133
|
} else if (pendingFeedsRequests.has(requestId)) {
|
|
9896
10134
|
const pending = pendingFeedsRequests.get(requestId);
|
|
9897
10135
|
pendingFeedsRequests.delete(requestId);
|
|
9898
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10136
|
+
_optionalChain([pending, 'optionalAccess', _226 => _226.reject, 'call', _227 => _227(err)]);
|
|
9899
10137
|
} else if (pendingFeedMessagesRequests.has(requestId)) {
|
|
9900
10138
|
const pending = pendingFeedMessagesRequests.get(requestId);
|
|
9901
10139
|
pendingFeedMessagesRequests.delete(requestId);
|
|
9902
|
-
_optionalChain([pending, 'optionalAccess',
|
|
10140
|
+
_optionalChain([pending, 'optionalAccess', _228 => _228.reject, 'call', _229 => _229(err)]);
|
|
9903
10141
|
}
|
|
9904
10142
|
eventHub.feeds.notify(message);
|
|
9905
10143
|
break;
|
|
@@ -10053,10 +10291,10 @@ function createRoom(options, config) {
|
|
|
10053
10291
|
timeoutId,
|
|
10054
10292
|
kind,
|
|
10055
10293
|
feedId,
|
|
10056
|
-
messageId: _optionalChain([options2, 'optionalAccess',
|
|
10057
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
10294
|
+
messageId: _optionalChain([options2, 'optionalAccess', _230 => _230.messageId]),
|
|
10295
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _231 => _231.expectedClientMessageId])
|
|
10058
10296
|
});
|
|
10059
|
-
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess',
|
|
10297
|
+
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _232 => _232.expectedClientMessageId]) === void 0) {
|
|
10060
10298
|
const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
|
|
10061
10299
|
q.push(requestId);
|
|
10062
10300
|
pendingAddMessageFifoByFeed.set(feedId, q);
|
|
@@ -10107,10 +10345,10 @@ function createRoom(options, config) {
|
|
|
10107
10345
|
}
|
|
10108
10346
|
if (!matched) {
|
|
10109
10347
|
const q = pendingAddMessageFifoByFeed.get(message.feedId);
|
|
10110
|
-
const headId = _optionalChain([q, 'optionalAccess',
|
|
10348
|
+
const headId = _optionalChain([q, 'optionalAccess', _233 => _233[0]]);
|
|
10111
10349
|
if (headId !== void 0) {
|
|
10112
10350
|
const pending = pendingFeedMutations.get(headId);
|
|
10113
|
-
if (_optionalChain([pending, 'optionalAccess',
|
|
10351
|
+
if (_optionalChain([pending, 'optionalAccess', _234 => _234.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
|
|
10114
10352
|
settleFeedMutation(headId, "ok");
|
|
10115
10353
|
}
|
|
10116
10354
|
}
|
|
@@ -10146,7 +10384,7 @@ function createRoom(options, config) {
|
|
|
10146
10384
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
10147
10385
|
createOrUpdateRootFromMessage(nodes);
|
|
10148
10386
|
applyAndSendOfflineOps(unacknowledgedOps);
|
|
10149
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
10387
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _235 => _235()]);
|
|
10150
10388
|
notifyStorageStatus();
|
|
10151
10389
|
eventHub.storageDidLoad.notify();
|
|
10152
10390
|
}
|
|
@@ -10164,7 +10402,7 @@ function createRoom(options, config) {
|
|
|
10164
10402
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
10165
10403
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
10166
10404
|
nodeMapBuffer.take();
|
|
10167
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
10405
|
+
_optionalChain([stopwatch, 'optionalAccess', _236 => _236.start, 'call', _237 => _237()]);
|
|
10168
10406
|
}
|
|
10169
10407
|
if (options2.flush) {
|
|
10170
10408
|
flushNowOrSoon();
|
|
@@ -10220,10 +10458,10 @@ function createRoom(options, config) {
|
|
|
10220
10458
|
const message = {
|
|
10221
10459
|
type: ClientMsgCode.FETCH_FEEDS,
|
|
10222
10460
|
requestId,
|
|
10223
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
10224
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
10225
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
10226
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
10461
|
+
cursor: _optionalChain([options2, 'optionalAccess', _238 => _238.cursor]),
|
|
10462
|
+
since: _optionalChain([options2, 'optionalAccess', _239 => _239.since]),
|
|
10463
|
+
limit: _optionalChain([options2, 'optionalAccess', _240 => _240.limit]),
|
|
10464
|
+
metadata: _optionalChain([options2, 'optionalAccess', _241 => _241.metadata])
|
|
10227
10465
|
};
|
|
10228
10466
|
context.buffer.messages.push(message);
|
|
10229
10467
|
flushNowOrSoon();
|
|
@@ -10243,9 +10481,9 @@ function createRoom(options, config) {
|
|
|
10243
10481
|
type: ClientMsgCode.FETCH_FEED_MESSAGES,
|
|
10244
10482
|
requestId,
|
|
10245
10483
|
feedId,
|
|
10246
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
10247
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
10248
|
-
limit: _optionalChain([options2, 'optionalAccess',
|
|
10484
|
+
cursor: _optionalChain([options2, 'optionalAccess', _242 => _242.cursor]),
|
|
10485
|
+
since: _optionalChain([options2, 'optionalAccess', _243 => _243.since]),
|
|
10486
|
+
limit: _optionalChain([options2, 'optionalAccess', _244 => _244.limit])
|
|
10249
10487
|
};
|
|
10250
10488
|
context.buffer.messages.push(message);
|
|
10251
10489
|
flushNowOrSoon();
|
|
@@ -10264,8 +10502,8 @@ function createRoom(options, config) {
|
|
|
10264
10502
|
type: ClientMsgCode.ADD_FEED,
|
|
10265
10503
|
requestId,
|
|
10266
10504
|
feedId,
|
|
10267
|
-
metadata: _optionalChain([options2, 'optionalAccess',
|
|
10268
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
10505
|
+
metadata: _optionalChain([options2, 'optionalAccess', _245 => _245.metadata]),
|
|
10506
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _246 => _246.createdAt])
|
|
10269
10507
|
};
|
|
10270
10508
|
context.buffer.messages.push(message);
|
|
10271
10509
|
flushNowOrSoon();
|
|
@@ -10299,15 +10537,15 @@ function createRoom(options, config) {
|
|
|
10299
10537
|
function addFeedMessage(feedId, data, options2) {
|
|
10300
10538
|
const requestId = nanoid();
|
|
10301
10539
|
const promise = registerFeedMutation(requestId, "add-message", feedId, {
|
|
10302
|
-
expectedClientMessageId: _optionalChain([options2, 'optionalAccess',
|
|
10540
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _247 => _247.id])
|
|
10303
10541
|
});
|
|
10304
10542
|
const message = {
|
|
10305
10543
|
type: ClientMsgCode.ADD_FEED_MESSAGE,
|
|
10306
10544
|
requestId,
|
|
10307
10545
|
feedId,
|
|
10308
10546
|
data,
|
|
10309
|
-
id: _optionalChain([options2, 'optionalAccess',
|
|
10310
|
-
createdAt: _optionalChain([options2, 'optionalAccess',
|
|
10547
|
+
id: _optionalChain([options2, 'optionalAccess', _248 => _248.id]),
|
|
10548
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _249 => _249.createdAt])
|
|
10311
10549
|
};
|
|
10312
10550
|
context.buffer.messages.push(message);
|
|
10313
10551
|
flushNowOrSoon();
|
|
@@ -10324,7 +10562,7 @@ function createRoom(options, config) {
|
|
|
10324
10562
|
feedId,
|
|
10325
10563
|
messageId,
|
|
10326
10564
|
data,
|
|
10327
|
-
updatedAt: _optionalChain([options2, 'optionalAccess',
|
|
10565
|
+
updatedAt: _optionalChain([options2, 'optionalAccess', _250 => _250.updatedAt])
|
|
10328
10566
|
};
|
|
10329
10567
|
context.buffer.messages.push(message);
|
|
10330
10568
|
flushNowOrSoon();
|
|
@@ -10397,7 +10635,8 @@ function createRoom(options, config) {
|
|
|
10397
10635
|
presence: false,
|
|
10398
10636
|
others: []
|
|
10399
10637
|
},
|
|
10400
|
-
reverseOps: new Deque()
|
|
10638
|
+
reverseOps: new Deque(),
|
|
10639
|
+
scheduleHistoryResume: false
|
|
10401
10640
|
};
|
|
10402
10641
|
try {
|
|
10403
10642
|
returnValue = callback();
|
|
@@ -10407,6 +10646,9 @@ function createRoom(options, config) {
|
|
|
10407
10646
|
if (currentBatch.reverseOps.length > 0) {
|
|
10408
10647
|
addToUndoStack(Array.from(currentBatch.reverseOps));
|
|
10409
10648
|
}
|
|
10649
|
+
if (currentBatch.scheduleHistoryResume) {
|
|
10650
|
+
commitPausedHistoryToUndoStack();
|
|
10651
|
+
}
|
|
10410
10652
|
if (currentBatch.ops.length > 0) {
|
|
10411
10653
|
context.redoStack.length = 0;
|
|
10412
10654
|
}
|
|
@@ -10423,13 +10665,30 @@ function createRoom(options, config) {
|
|
|
10423
10665
|
context.pausedHistory = new Deque();
|
|
10424
10666
|
}
|
|
10425
10667
|
}
|
|
10426
|
-
function
|
|
10668
|
+
function commitPausedHistoryToUndoStack() {
|
|
10427
10669
|
const frames = context.pausedHistory;
|
|
10428
10670
|
context.pausedHistory = null;
|
|
10429
10671
|
if (frames !== null && frames.length > 0) {
|
|
10430
10672
|
_addToRealUndoStack(Array.from(frames));
|
|
10431
10673
|
}
|
|
10432
10674
|
}
|
|
10675
|
+
function resumeHistory() {
|
|
10676
|
+
if (context.activeBatch !== null) {
|
|
10677
|
+
context.activeBatch.scheduleHistoryResume = true;
|
|
10678
|
+
return;
|
|
10679
|
+
}
|
|
10680
|
+
commitPausedHistoryToUndoStack();
|
|
10681
|
+
}
|
|
10682
|
+
function withoutHistory(fn) {
|
|
10683
|
+
const undoBefore = context.undoStack.length;
|
|
10684
|
+
const redoBefore = context.redoStack.length;
|
|
10685
|
+
try {
|
|
10686
|
+
return fn();
|
|
10687
|
+
} finally {
|
|
10688
|
+
context.undoStack.length = undoBefore;
|
|
10689
|
+
context.redoStack.length = redoBefore;
|
|
10690
|
+
}
|
|
10691
|
+
}
|
|
10433
10692
|
const syncSourceForStorage = config.createSyncSource();
|
|
10434
10693
|
function getStorageStatus() {
|
|
10435
10694
|
if (context.root === void 0) {
|
|
@@ -10500,8 +10759,8 @@ function createRoom(options, config) {
|
|
|
10500
10759
|
async function getThreads(options2) {
|
|
10501
10760
|
return httpClient.getThreads({
|
|
10502
10761
|
roomId,
|
|
10503
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
10504
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
10762
|
+
query: _optionalChain([options2, 'optionalAccess', _251 => _251.query]),
|
|
10763
|
+
cursor: _optionalChain([options2, 'optionalAccess', _252 => _252.cursor])
|
|
10505
10764
|
});
|
|
10506
10765
|
}
|
|
10507
10766
|
async function getThread(threadId) {
|
|
@@ -10623,7 +10882,7 @@ function createRoom(options, config) {
|
|
|
10623
10882
|
function getSubscriptionSettings(options2) {
|
|
10624
10883
|
return httpClient.getSubscriptionSettings({
|
|
10625
10884
|
roomId,
|
|
10626
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
10885
|
+
signal: _optionalChain([options2, 'optionalAccess', _253 => _253.signal])
|
|
10627
10886
|
});
|
|
10628
10887
|
}
|
|
10629
10888
|
function updateSubscriptionSettings(settings) {
|
|
@@ -10645,7 +10904,7 @@ function createRoom(options, config) {
|
|
|
10645
10904
|
{
|
|
10646
10905
|
[kInternal]: {
|
|
10647
10906
|
get presenceBuffer() {
|
|
10648
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
10907
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _254 => _254.buffer, 'access', _255 => _255.presenceUpdates, 'optionalAccess', _256 => _256.data]), () => ( null)));
|
|
10649
10908
|
},
|
|
10650
10909
|
// prettier-ignore
|
|
10651
10910
|
get undoStack() {
|
|
@@ -10660,9 +10919,9 @@ function createRoom(options, config) {
|
|
|
10660
10919
|
return context.yjsProvider;
|
|
10661
10920
|
},
|
|
10662
10921
|
setYjsProvider(newProvider) {
|
|
10663
|
-
_optionalChain([context, 'access',
|
|
10922
|
+
_optionalChain([context, 'access', _257 => _257.yjsProvider, 'optionalAccess', _258 => _258.off, 'call', _259 => _259("status", yjsStatusDidChange)]);
|
|
10664
10923
|
context.yjsProvider = newProvider;
|
|
10665
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
10924
|
+
_optionalChain([newProvider, 'optionalAccess', _260 => _260.on, 'call', _261 => _261("status", yjsStatusDidChange)]);
|
|
10666
10925
|
context.yjsProviderDidChange.notify();
|
|
10667
10926
|
},
|
|
10668
10927
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -10715,7 +10974,7 @@ function createRoom(options, config) {
|
|
|
10715
10974
|
source.dispose();
|
|
10716
10975
|
}
|
|
10717
10976
|
eventHub.roomWillDestroy.notify();
|
|
10718
|
-
_optionalChain([context, 'access',
|
|
10977
|
+
_optionalChain([context, 'access', _262 => _262.yjsProvider, 'optionalAccess', _263 => _263.off, 'call', _264 => _264("status", yjsStatusDidChange)]);
|
|
10719
10978
|
syncSourceForStorage.destroy();
|
|
10720
10979
|
syncSourceForYjs.destroy();
|
|
10721
10980
|
uninstallBgTabSpy();
|
|
@@ -10735,7 +10994,10 @@ function createRoom(options, config) {
|
|
|
10735
10994
|
canRedo,
|
|
10736
10995
|
clear,
|
|
10737
10996
|
pause: pauseHistory,
|
|
10738
|
-
resume: resumeHistory
|
|
10997
|
+
resume: resumeHistory,
|
|
10998
|
+
[kInternal]: {
|
|
10999
|
+
withoutHistory
|
|
11000
|
+
}
|
|
10739
11001
|
},
|
|
10740
11002
|
fetchYDoc,
|
|
10741
11003
|
fetchFeeds,
|
|
@@ -10874,7 +11136,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
10874
11136
|
}
|
|
10875
11137
|
if (isLiveNode(first)) {
|
|
10876
11138
|
const node = first;
|
|
10877
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
11139
|
+
if (_optionalChain([options, 'optionalAccess', _265 => _265.isDeep])) {
|
|
10878
11140
|
const storageCallback = second;
|
|
10879
11141
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
10880
11142
|
} else {
|
|
@@ -10960,8 +11222,8 @@ function createClient(options) {
|
|
|
10960
11222
|
const authManager = createAuthManager(options, (token) => {
|
|
10961
11223
|
currentUserId.set(() => token.uid);
|
|
10962
11224
|
});
|
|
10963
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
10964
|
-
_optionalChain([globalThis, 'access',
|
|
11225
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _266 => _266.polyfills, 'optionalAccess', _267 => _267.fetch]) || /* istanbul ignore next */
|
|
11226
|
+
_optionalChain([globalThis, 'access', _268 => _268.fetch, 'optionalAccess', _269 => _269.bind, 'call', _270 => _270(globalThis)]);
|
|
10965
11227
|
const httpClient = createApiClient({
|
|
10966
11228
|
baseUrl,
|
|
10967
11229
|
fetchPolyfill,
|
|
@@ -10979,7 +11241,7 @@ function createClient(options) {
|
|
|
10979
11241
|
delegates: {
|
|
10980
11242
|
createSocket: makeCreateSocketDelegateForAi(
|
|
10981
11243
|
baseUrl,
|
|
10982
|
-
_optionalChain([clientOptions, 'access',
|
|
11244
|
+
_optionalChain([clientOptions, 'access', _271 => _271.polyfills, 'optionalAccess', _272 => _272.WebSocket])
|
|
10983
11245
|
),
|
|
10984
11246
|
authenticate: async () => {
|
|
10985
11247
|
const resp = await authManager.getAuthValue({
|
|
@@ -11039,7 +11301,7 @@ function createClient(options) {
|
|
|
11039
11301
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
11040
11302
|
roomId,
|
|
11041
11303
|
baseUrl,
|
|
11042
|
-
_optionalChain([clientOptions, 'access',
|
|
11304
|
+
_optionalChain([clientOptions, 'access', _273 => _273.polyfills, 'optionalAccess', _274 => _274.WebSocket])
|
|
11043
11305
|
),
|
|
11044
11306
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
11045
11307
|
})),
|
|
@@ -11062,7 +11324,7 @@ function createClient(options) {
|
|
|
11062
11324
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
11063
11325
|
if (shouldConnect) {
|
|
11064
11326
|
if (typeof atob === "undefined") {
|
|
11065
|
-
if (_optionalChain([clientOptions, 'access',
|
|
11327
|
+
if (_optionalChain([clientOptions, 'access', _275 => _275.polyfills, 'optionalAccess', _276 => _276.atob]) === void 0) {
|
|
11066
11328
|
throw new Error(
|
|
11067
11329
|
"You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
|
|
11068
11330
|
);
|
|
@@ -11074,7 +11336,7 @@ function createClient(options) {
|
|
|
11074
11336
|
return leaseRoom(newRoomDetails);
|
|
11075
11337
|
}
|
|
11076
11338
|
function getRoom(roomId) {
|
|
11077
|
-
const room = _optionalChain([roomsById, 'access',
|
|
11339
|
+
const room = _optionalChain([roomsById, 'access', _277 => _277.get, 'call', _278 => _278(roomId), 'optionalAccess', _279 => _279.room]);
|
|
11078
11340
|
return room ? room : null;
|
|
11079
11341
|
}
|
|
11080
11342
|
function logout() {
|
|
@@ -11090,7 +11352,7 @@ function createClient(options) {
|
|
|
11090
11352
|
const batchedResolveUsers = new Batch(
|
|
11091
11353
|
async (batchedUserIds) => {
|
|
11092
11354
|
const userIds = batchedUserIds.flat();
|
|
11093
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
11355
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _280 => _280({ userIds })]);
|
|
11094
11356
|
warnOnceIf(
|
|
11095
11357
|
!resolveUsers,
|
|
11096
11358
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -11107,7 +11369,7 @@ function createClient(options) {
|
|
|
11107
11369
|
const batchedResolveRoomsInfo = new Batch(
|
|
11108
11370
|
async (batchedRoomIds) => {
|
|
11109
11371
|
const roomIds = batchedRoomIds.flat();
|
|
11110
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
11372
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _281 => _281({ roomIds })]);
|
|
11111
11373
|
warnOnceIf(
|
|
11112
11374
|
!resolveRoomsInfo,
|
|
11113
11375
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -11124,7 +11386,7 @@ function createClient(options) {
|
|
|
11124
11386
|
const batchedResolveGroupsInfo = new Batch(
|
|
11125
11387
|
async (batchedGroupIds) => {
|
|
11126
11388
|
const groupIds = batchedGroupIds.flat();
|
|
11127
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
11389
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _282 => _282({ groupIds })]);
|
|
11128
11390
|
warnOnceIf(
|
|
11129
11391
|
!resolveGroupsInfo,
|
|
11130
11392
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -11180,7 +11442,7 @@ function createClient(options) {
|
|
|
11180
11442
|
}
|
|
11181
11443
|
};
|
|
11182
11444
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
11183
|
-
_optionalChain([win, 'optionalAccess',
|
|
11445
|
+
_optionalChain([win, 'optionalAccess', _283 => _283.addEventListener, 'call', _284 => _284("beforeunload", maybePreventClose)]);
|
|
11184
11446
|
}
|
|
11185
11447
|
async function getNotificationSettings(options2) {
|
|
11186
11448
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -11307,7 +11569,7 @@ var commentBodyElementsTypes = {
|
|
|
11307
11569
|
mention: "inline"
|
|
11308
11570
|
};
|
|
11309
11571
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
11310
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
11572
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _285 => _285.content])) {
|
|
11311
11573
|
return;
|
|
11312
11574
|
}
|
|
11313
11575
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -11317,13 +11579,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
11317
11579
|
for (const block of body.content) {
|
|
11318
11580
|
if (type === "all" || type === "block") {
|
|
11319
11581
|
if (guard(block)) {
|
|
11320
|
-
_optionalChain([visitor, 'optionalCall',
|
|
11582
|
+
_optionalChain([visitor, 'optionalCall', _286 => _286(block)]);
|
|
11321
11583
|
}
|
|
11322
11584
|
}
|
|
11323
11585
|
if (type === "all" || type === "inline") {
|
|
11324
11586
|
for (const inline of block.children) {
|
|
11325
11587
|
if (guard(inline)) {
|
|
11326
|
-
_optionalChain([visitor, 'optionalCall',
|
|
11588
|
+
_optionalChain([visitor, 'optionalCall', _287 => _287(inline)]);
|
|
11327
11589
|
}
|
|
11328
11590
|
}
|
|
11329
11591
|
}
|
|
@@ -11493,7 +11755,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
11493
11755
|
text: ({ element }) => element.text,
|
|
11494
11756
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
11495
11757
|
mention: ({ element, user, group }) => {
|
|
11496
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
11758
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _288 => _288.name]), () => ( _optionalChain([group, 'optionalAccess', _289 => _289.name]))), () => ( element.id))}`;
|
|
11497
11759
|
}
|
|
11498
11760
|
};
|
|
11499
11761
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -11523,7 +11785,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
11523
11785
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
11524
11786
|
},
|
|
11525
11787
|
mention: ({ element, user, group }) => {
|
|
11526
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
11788
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _290 => _290.name]) ? html`${_optionalChain([user, 'optionalAccess', _291 => _291.name])}` : _optionalChain([group, 'optionalAccess', _292 => _292.name]) ? html`${_optionalChain([group, 'optionalAccess', _293 => _293.name])}` : element.id}</span>`;
|
|
11527
11789
|
}
|
|
11528
11790
|
};
|
|
11529
11791
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -11553,20 +11815,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
11553
11815
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
11554
11816
|
},
|
|
11555
11817
|
mention: ({ element, user, group }) => {
|
|
11556
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
11818
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _294 => _294.name]), () => ( _optionalChain([group, 'optionalAccess', _295 => _295.name]))), () => ( element.id))}`;
|
|
11557
11819
|
}
|
|
11558
11820
|
};
|
|
11559
11821
|
async function stringifyCommentBody(body, options) {
|
|
11560
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11561
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11822
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _296 => _296.format]), () => ( "plain"));
|
|
11823
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _297 => _297.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
11562
11824
|
const elements = {
|
|
11563
11825
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
11564
|
-
..._optionalChain([options, 'optionalAccess',
|
|
11826
|
+
..._optionalChain([options, 'optionalAccess', _298 => _298.elements])
|
|
11565
11827
|
};
|
|
11566
11828
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
11567
11829
|
body,
|
|
11568
|
-
_optionalChain([options, 'optionalAccess',
|
|
11569
|
-
_optionalChain([options, 'optionalAccess',
|
|
11830
|
+
_optionalChain([options, 'optionalAccess', _299 => _299.resolveUsers]),
|
|
11831
|
+
_optionalChain([options, 'optionalAccess', _300 => _300.resolveGroupsInfo])
|
|
11570
11832
|
);
|
|
11571
11833
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
11572
11834
|
switch (block.type) {
|
|
@@ -11697,24 +11959,7 @@ function lsonToJson(value) {
|
|
|
11697
11959
|
}
|
|
11698
11960
|
return value;
|
|
11699
11961
|
}
|
|
11700
|
-
function
|
|
11701
|
-
if (Array.isArray(value)) {
|
|
11702
|
-
return new LiveList(value.map(deepLiveify));
|
|
11703
|
-
} else if (isPlainObject(value)) {
|
|
11704
|
-
const init = {};
|
|
11705
|
-
for (const key in value) {
|
|
11706
|
-
const val = value[key];
|
|
11707
|
-
if (val === void 0) {
|
|
11708
|
-
continue;
|
|
11709
|
-
}
|
|
11710
|
-
init[key] = deepLiveify(val);
|
|
11711
|
-
}
|
|
11712
|
-
return new LiveObject(init);
|
|
11713
|
-
} else {
|
|
11714
|
-
return value;
|
|
11715
|
-
}
|
|
11716
|
-
}
|
|
11717
|
-
function patchLiveList(liveList, prev, next) {
|
|
11962
|
+
function legacy_patchLiveList(liveList, prev, next) {
|
|
11718
11963
|
let i = 0;
|
|
11719
11964
|
let prevEnd = prev.length - 1;
|
|
11720
11965
|
let nextEnd = next.length - 1;
|
|
@@ -11760,7 +12005,7 @@ function patchLiveList(liveList, prev, next) {
|
|
|
11760
12005
|
nextNode = next[i];
|
|
11761
12006
|
const liveListNode = liveList.get(i);
|
|
11762
12007
|
if (isLiveObject(liveListNode) && isPlainObject(prevNode) && isPlainObject(nextNode)) {
|
|
11763
|
-
|
|
12008
|
+
legacy_patchLiveObject(liveListNode, prevNode, nextNode);
|
|
11764
12009
|
} else {
|
|
11765
12010
|
liveList.set(i, deepLiveify(nextNode));
|
|
11766
12011
|
}
|
|
@@ -11777,7 +12022,7 @@ function patchLiveList(liveList, prev, next) {
|
|
|
11777
12022
|
}
|
|
11778
12023
|
}
|
|
11779
12024
|
}
|
|
11780
|
-
function
|
|
12025
|
+
function legacy_patchLiveObjectKey(liveObject, key, prev, next) {
|
|
11781
12026
|
if (process.env.NODE_ENV !== "production") {
|
|
11782
12027
|
const nonSerializableValue = findNonSerializableValue(next);
|
|
11783
12028
|
if (nonSerializableValue) {
|
|
@@ -11798,17 +12043,17 @@ Only serializable value can be synced with Liveblocks.`
|
|
|
11798
12043
|
} else if (prev === next) {
|
|
11799
12044
|
return;
|
|
11800
12045
|
} else if (isLiveList(value) && Array.isArray(prev) && Array.isArray(next)) {
|
|
11801
|
-
|
|
12046
|
+
legacy_patchLiveList(value, prev, next);
|
|
11802
12047
|
} else if (isLiveObject(value) && isPlainObject(prev) && isPlainObject(next)) {
|
|
11803
|
-
|
|
12048
|
+
legacy_patchLiveObject(value, prev, next);
|
|
11804
12049
|
} else {
|
|
11805
12050
|
liveObject.set(key, deepLiveify(next));
|
|
11806
12051
|
}
|
|
11807
12052
|
}
|
|
11808
|
-
function
|
|
12053
|
+
function legacy_patchLiveObject(root, prev, next) {
|
|
11809
12054
|
const updates = {};
|
|
11810
12055
|
for (const key in next) {
|
|
11811
|
-
|
|
12056
|
+
legacy_patchLiveObjectKey(root, key, prev[key], next[key]);
|
|
11812
12057
|
}
|
|
11813
12058
|
for (const key in prev) {
|
|
11814
12059
|
if (next[key] === void 0) {
|
|
@@ -11853,12 +12098,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
11853
12098
|
}
|
|
11854
12099
|
const newState = Object.assign({}, state);
|
|
11855
12100
|
for (const key in update.updates) {
|
|
11856
|
-
if (_optionalChain([update, 'access',
|
|
12101
|
+
if (_optionalChain([update, 'access', _301 => _301.updates, 'access', _302 => _302[key], 'optionalAccess', _303 => _303.type]) === "update") {
|
|
11857
12102
|
const val = update.node.get(key);
|
|
11858
12103
|
if (val !== void 0) {
|
|
11859
12104
|
newState[key] = lsonToJson(val);
|
|
11860
12105
|
}
|
|
11861
|
-
} else if (_optionalChain([update, 'access',
|
|
12106
|
+
} else if (_optionalChain([update, 'access', _304 => _304.updates, 'access', _305 => _305[key], 'optionalAccess', _306 => _306.type]) === "delete") {
|
|
11862
12107
|
delete newState[key];
|
|
11863
12108
|
}
|
|
11864
12109
|
}
|
|
@@ -11919,12 +12164,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
11919
12164
|
}
|
|
11920
12165
|
const newState = Object.assign({}, state);
|
|
11921
12166
|
for (const key in update.updates) {
|
|
11922
|
-
if (_optionalChain([update, 'access',
|
|
12167
|
+
if (_optionalChain([update, 'access', _307 => _307.updates, 'access', _308 => _308[key], 'optionalAccess', _309 => _309.type]) === "update") {
|
|
11923
12168
|
const value = update.node.get(key);
|
|
11924
12169
|
if (value !== void 0) {
|
|
11925
12170
|
newState[key] = lsonToJson(value);
|
|
11926
12171
|
}
|
|
11927
|
-
} else if (_optionalChain([update, 'access',
|
|
12172
|
+
} else if (_optionalChain([update, 'access', _310 => _310.updates, 'access', _311 => _311[key], 'optionalAccess', _312 => _312.type]) === "delete") {
|
|
11928
12173
|
delete newState[key];
|
|
11929
12174
|
}
|
|
11930
12175
|
}
|
|
@@ -12004,9 +12249,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
12004
12249
|
const startTime = performance.now();
|
|
12005
12250
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
12006
12251
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
12007
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12252
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _313 => _313.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
12008
12253
|
const context = {
|
|
12009
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
12254
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _314 => _314.visibilityState]) !== "hidden",
|
|
12010
12255
|
lastSuccessfulPollAt: startTime,
|
|
12011
12256
|
count: 0,
|
|
12012
12257
|
backoff: 0
|
|
@@ -12087,11 +12332,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
12087
12332
|
pollNowIfStale();
|
|
12088
12333
|
}
|
|
12089
12334
|
function onVisibilityChange() {
|
|
12090
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
12335
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _315 => _315.visibilityState]) !== "hidden");
|
|
12091
12336
|
}
|
|
12092
|
-
_optionalChain([doc, 'optionalAccess',
|
|
12093
|
-
_optionalChain([win, 'optionalAccess',
|
|
12094
|
-
_optionalChain([win, 'optionalAccess',
|
|
12337
|
+
_optionalChain([doc, 'optionalAccess', _316 => _316.addEventListener, 'call', _317 => _317("visibilitychange", onVisibilityChange)]);
|
|
12338
|
+
_optionalChain([win, 'optionalAccess', _318 => _318.addEventListener, 'call', _319 => _319("online", onVisibilityChange)]);
|
|
12339
|
+
_optionalChain([win, 'optionalAccess', _320 => _320.addEventListener, 'call', _321 => _321("focus", pollNowIfStale)]);
|
|
12095
12340
|
fsm.start();
|
|
12096
12341
|
return {
|
|
12097
12342
|
inc,
|
|
@@ -12231,5 +12476,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
12231
12476
|
|
|
12232
12477
|
|
|
12233
12478
|
|
|
12234
|
-
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; 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.
|
|
12479
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; 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.legacy_patchLiveObjectKey = legacy_patchLiveObjectKey; 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.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;
|
|
12235
12480
|
//# sourceMappingURL=index.cjs.map
|