@liveblocks/core 3.16.0-flow3 → 3.16.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 +1073 -892
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +258 -121
- package/dist/index.d.ts +258 -121
- package/dist/index.js +986 -805
- 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.16.0
|
|
9
|
+
var PKG_VERSION = "3.16.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3219,10 +3219,26 @@ var ServerMsgCode = Object.freeze({
|
|
|
3219
3219
|
COMMENT_REACTION_ADDED: 405,
|
|
3220
3220
|
COMMENT_REACTION_REMOVED: 406,
|
|
3221
3221
|
COMMENT_METADATA_UPDATED: 409,
|
|
3222
|
+
// For Feeds
|
|
3223
|
+
FEEDS_LIST: 500,
|
|
3224
|
+
FEEDS_ADDED: 501,
|
|
3225
|
+
FEEDS_UPDATED: 502,
|
|
3226
|
+
FEED_DELETED: 503,
|
|
3227
|
+
FEED_MESSAGES_LIST: 504,
|
|
3228
|
+
FEED_MESSAGES_ADDED: 505,
|
|
3229
|
+
FEED_MESSAGES_UPDATED: 506,
|
|
3230
|
+
FEED_MESSAGES_DELETED: 507,
|
|
3231
|
+
FEED_REQUEST_FAILED: 508,
|
|
3222
3232
|
// Error codes
|
|
3223
3233
|
REJECT_STORAGE_OP: 299
|
|
3224
3234
|
// Sent if a mutation was not allowed on the server (i.e. due to permissions, limit exceeded, etc)
|
|
3225
3235
|
});
|
|
3236
|
+
var FeedRequestErrorCode = {
|
|
3237
|
+
INTERNAL: "INTERNAL",
|
|
3238
|
+
FEED_ALREADY_EXISTS: "FEED_ALREADY_EXISTS",
|
|
3239
|
+
FEED_NOT_FOUND: "FEED_NOT_FOUND",
|
|
3240
|
+
FEED_MESSAGE_NOT_FOUND: "FEED_MESSAGE_NOT_FOUND"
|
|
3241
|
+
};
|
|
3226
3242
|
|
|
3227
3243
|
// src/types/IWebSocket.ts
|
|
3228
3244
|
var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
@@ -5186,6 +5202,7 @@ var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
|
5186
5202
|
Permission2["PresenceWrite"] = "room:presence:write";
|
|
5187
5203
|
Permission2["CommentsWrite"] = "comments:write";
|
|
5188
5204
|
Permission2["CommentsRead"] = "comments:read";
|
|
5205
|
+
Permission2["FeedsWrite"] = "feeds:write";
|
|
5189
5206
|
return Permission2;
|
|
5190
5207
|
})(Permission || {});
|
|
5191
5208
|
function canWriteStorage(scopes) {
|
|
@@ -6302,6 +6319,7 @@ var AbstractCrdt = class {
|
|
|
6302
6319
|
}
|
|
6303
6320
|
/**
|
|
6304
6321
|
* @internal
|
|
6322
|
+
*
|
|
6305
6323
|
* Return an snapshot of this Live tree for use in DevTools.
|
|
6306
6324
|
*/
|
|
6307
6325
|
toTreeNode(key) {
|
|
@@ -6311,14 +6329,6 @@ var AbstractCrdt = class {
|
|
|
6311
6329
|
}
|
|
6312
6330
|
return this.#cachedTreeNode;
|
|
6313
6331
|
}
|
|
6314
|
-
/**
|
|
6315
|
-
* @private
|
|
6316
|
-
* Returns true if the cached immutable snapshot exists and is
|
|
6317
|
-
* reference-equal to the given value. Does not trigger a recompute.
|
|
6318
|
-
*/
|
|
6319
|
-
immutableIs(value) {
|
|
6320
|
-
return this.#cachedImmutable !== void 0 && this.#cachedImmutable === value;
|
|
6321
|
-
}
|
|
6322
6332
|
/**
|
|
6323
6333
|
* Return an immutable snapshot of this Live node and its children.
|
|
6324
6334
|
*/
|
|
@@ -7866,557 +7876,157 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7866
7876
|
}
|
|
7867
7877
|
};
|
|
7868
7878
|
|
|
7869
|
-
// src/
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
}
|
|
7904
|
-
function liveListToJson(value) {
|
|
7905
|
-
return lsonListToJson(value.toArray());
|
|
7906
|
-
}
|
|
7907
|
-
function lsonToJson(value) {
|
|
7908
|
-
if (value instanceof LiveObject) {
|
|
7909
|
-
return liveObjectToJson(value);
|
|
7910
|
-
} else if (value instanceof LiveList) {
|
|
7911
|
-
return liveListToJson(value);
|
|
7912
|
-
} else if (value instanceof LiveMap) {
|
|
7913
|
-
return liveMapToJson(value);
|
|
7914
|
-
} else if (value instanceof LiveRegister) {
|
|
7915
|
-
return value.data;
|
|
7916
|
-
}
|
|
7917
|
-
if (Array.isArray(value)) {
|
|
7918
|
-
return lsonListToJson(value);
|
|
7919
|
-
} else if (isPlainObject(value)) {
|
|
7920
|
-
return lsonObjectToJson(value);
|
|
7921
|
-
}
|
|
7922
|
-
return value;
|
|
7923
|
-
}
|
|
7924
|
-
function deepLiveify(value, config) {
|
|
7925
|
-
if (Array.isArray(value)) {
|
|
7926
|
-
return new LiveList(value.map((v) => deepLiveify(v, config)));
|
|
7927
|
-
} else if (isPlainObject(value)) {
|
|
7928
|
-
const init = {};
|
|
7929
|
-
const locals = {};
|
|
7930
|
-
for (const key in value) {
|
|
7931
|
-
const val = value[key];
|
|
7932
|
-
if (val === void 0) {
|
|
7933
|
-
continue;
|
|
7934
|
-
}
|
|
7935
|
-
const subConfig = isPlainObject(config) ? config[key] : config;
|
|
7936
|
-
if (subConfig === false) {
|
|
7937
|
-
locals[key] = val;
|
|
7938
|
-
} else if (subConfig === "atomic") {
|
|
7939
|
-
init[key] = val;
|
|
7879
|
+
// src/crdts/LiveObject.ts
|
|
7880
|
+
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
7881
|
+
var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
7882
|
+
#map;
|
|
7883
|
+
/**
|
|
7884
|
+
* Tracks unacknowledged local changes per property to preserve optimistic
|
|
7885
|
+
* updates. Maps property keys to their pending operation IDs.
|
|
7886
|
+
*
|
|
7887
|
+
* INVARIANT: Only locally-generated opIds are ever stored here. Remote opIds
|
|
7888
|
+
* are only compared against (to detect ACKs), never stored.
|
|
7889
|
+
*
|
|
7890
|
+
* When a local change is made, the opId is stored here. When a remote op
|
|
7891
|
+
* arrives for the same key:
|
|
7892
|
+
* - If no entry exists → apply remote op
|
|
7893
|
+
* - If opId matches → it's an ACK, clear the entry
|
|
7894
|
+
* - If opId differs → ignore remote op to preserve optimistic update
|
|
7895
|
+
*/
|
|
7896
|
+
#unackedOpsByKey;
|
|
7897
|
+
/**
|
|
7898
|
+
* Enable or disable detection of too large LiveObjects.
|
|
7899
|
+
* When enabled, throws an error if LiveObject static data exceeds 128KB, which
|
|
7900
|
+
* is the maximum value the server will be able to accept.
|
|
7901
|
+
* By default, this behavior is disabled to avoid the runtime performance
|
|
7902
|
+
* overhead on every LiveObject.set() or LiveObject.update() call.
|
|
7903
|
+
*
|
|
7904
|
+
* @experimental
|
|
7905
|
+
*/
|
|
7906
|
+
static __initStatic() {this.detectLargeObjects = false}
|
|
7907
|
+
static #buildRootAndParentToChildren(nodes) {
|
|
7908
|
+
const parentToChildren = /* @__PURE__ */ new Map();
|
|
7909
|
+
let root = null;
|
|
7910
|
+
for (const node of nodes) {
|
|
7911
|
+
if (isRootStorageNode(node)) {
|
|
7912
|
+
root = node[1];
|
|
7940
7913
|
} else {
|
|
7941
|
-
|
|
7914
|
+
const crdt = node[1];
|
|
7915
|
+
const children = parentToChildren.get(crdt.parentId);
|
|
7916
|
+
if (children !== void 0) {
|
|
7917
|
+
children.push(node);
|
|
7918
|
+
} else {
|
|
7919
|
+
parentToChildren.set(crdt.parentId, [node]);
|
|
7920
|
+
}
|
|
7942
7921
|
}
|
|
7943
7922
|
}
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
lo.setLocal(key, locals[key]);
|
|
7923
|
+
if (root === null) {
|
|
7924
|
+
throw new Error("Root can't be null");
|
|
7947
7925
|
}
|
|
7948
|
-
return
|
|
7949
|
-
} else {
|
|
7950
|
-
return value;
|
|
7926
|
+
return [root, parentToChildren];
|
|
7951
7927
|
}
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
return
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
} else {
|
|
7961
|
-
return deepLiveify(json, config);
|
|
7928
|
+
/** @private Do not use this API directly */
|
|
7929
|
+
static _fromItems(nodes, pool) {
|
|
7930
|
+
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(nodes);
|
|
7931
|
+
return _LiveObject._deserialize(
|
|
7932
|
+
["root", root],
|
|
7933
|
+
parentToChildren,
|
|
7934
|
+
pool
|
|
7935
|
+
);
|
|
7962
7936
|
}
|
|
7963
|
-
}
|
|
7964
|
-
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
const newVal = jsonObj[key];
|
|
7972
|
-
if (newVal === void 0) {
|
|
7973
|
-
liveObj.delete(key);
|
|
7974
|
-
continue;
|
|
7975
|
-
}
|
|
7976
|
-
const subConfig = isPlainObject(config) ? config[key] : config;
|
|
7977
|
-
if (subConfig === false) {
|
|
7978
|
-
liveObj.setLocal(key, newVal);
|
|
7979
|
-
} else if (subConfig === "atomic") {
|
|
7980
|
-
const curVal = liveObj.get(key);
|
|
7981
|
-
if (curVal !== newVal) {
|
|
7982
|
-
liveObj.set(key, newVal);
|
|
7983
|
-
}
|
|
7984
|
-
} else {
|
|
7985
|
-
const curVal = liveObj.get(key);
|
|
7986
|
-
if (curVal === void 0) {
|
|
7987
|
-
liveObj.set(key, deepLiveify(newVal, subConfig));
|
|
7988
|
-
} else if (isLiveStructure(curVal)) {
|
|
7989
|
-
const next = reconcile(curVal, newVal, subConfig);
|
|
7990
|
-
if (next !== curVal) {
|
|
7991
|
-
liveObj.set(key, next);
|
|
7992
|
-
}
|
|
7993
|
-
} else if (curVal !== newVal) {
|
|
7994
|
-
liveObj.set(key, deepLiveify(newVal, subConfig));
|
|
7937
|
+
constructor(obj = {}) {
|
|
7938
|
+
super();
|
|
7939
|
+
this.#unackedOpsByKey = /* @__PURE__ */ new Map();
|
|
7940
|
+
const o = compactObject(obj);
|
|
7941
|
+
for (const key of Object.keys(o)) {
|
|
7942
|
+
const value = o[key];
|
|
7943
|
+
if (isLiveNode(value)) {
|
|
7944
|
+
value._setParentLink(this, key);
|
|
7995
7945
|
}
|
|
7996
7946
|
}
|
|
7947
|
+
this.#map = new Map(Object.entries(o));
|
|
7997
7948
|
}
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
}
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
7949
|
+
/** @internal */
|
|
7950
|
+
_toOps(parentId, parentKey) {
|
|
7951
|
+
if (this._id === void 0) {
|
|
7952
|
+
throw new Error("Cannot serialize item is not attached");
|
|
7953
|
+
}
|
|
7954
|
+
const ops = [];
|
|
7955
|
+
const op = {
|
|
7956
|
+
type: OpCode.CREATE_OBJECT,
|
|
7957
|
+
id: this._id,
|
|
7958
|
+
parentId,
|
|
7959
|
+
parentKey,
|
|
7960
|
+
data: {}
|
|
7961
|
+
};
|
|
7962
|
+
ops.push(op);
|
|
7963
|
+
for (const [key, value] of this.#map) {
|
|
7964
|
+
if (isLiveNode(value)) {
|
|
7965
|
+
for (const childOp of value._toOps(this._id, key)) {
|
|
7966
|
+
ops.push(childOp);
|
|
7967
|
+
}
|
|
7968
|
+
} else {
|
|
7969
|
+
op.data[key] = value;
|
|
8013
7970
|
}
|
|
8014
|
-
} else if (curVal !== newVal) {
|
|
8015
|
-
liveList.set(i, deepLiveify(newVal, config));
|
|
8016
7971
|
}
|
|
7972
|
+
return ops;
|
|
8017
7973
|
}
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
7974
|
+
/** @internal */
|
|
7975
|
+
static _deserialize([id, item], parentToChildren, pool) {
|
|
7976
|
+
const liveObj = new _LiveObject(item.data);
|
|
7977
|
+
liveObj._attach(id, pool);
|
|
7978
|
+
return this._deserializeChildren(liveObj, parentToChildren, pool);
|
|
8023
7979
|
}
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
let nextEnd = next.length - 1;
|
|
8030
|
-
let prevNode = prev[0];
|
|
8031
|
-
let nextNode = next[0];
|
|
8032
|
-
outer: {
|
|
8033
|
-
while (prevNode === nextNode) {
|
|
8034
|
-
++i;
|
|
8035
|
-
if (i > prevEnd || i > nextEnd) {
|
|
8036
|
-
break outer;
|
|
8037
|
-
}
|
|
8038
|
-
prevNode = prev[i];
|
|
8039
|
-
nextNode = next[i];
|
|
7980
|
+
/** @internal */
|
|
7981
|
+
static _deserializeChildren(liveObj, parentToChildren, pool) {
|
|
7982
|
+
const children = parentToChildren.get(nn(liveObj._id));
|
|
7983
|
+
if (children === void 0) {
|
|
7984
|
+
return liveObj;
|
|
8040
7985
|
}
|
|
8041
|
-
|
|
8042
|
-
|
|
8043
|
-
|
|
8044
|
-
|
|
8045
|
-
|
|
8046
|
-
if (i > prevEnd || i > nextEnd) {
|
|
8047
|
-
break outer;
|
|
7986
|
+
for (const node of children) {
|
|
7987
|
+
const child = deserializeToLson(node, parentToChildren, pool);
|
|
7988
|
+
const crdt = node[1];
|
|
7989
|
+
if (isLiveStructure(child)) {
|
|
7990
|
+
child._setParentLink(liveObj, crdt.parentKey);
|
|
8048
7991
|
}
|
|
8049
|
-
|
|
8050
|
-
|
|
7992
|
+
liveObj.#map.set(crdt.parentKey, child);
|
|
7993
|
+
liveObj.invalidate();
|
|
8051
7994
|
}
|
|
7995
|
+
return liveObj;
|
|
8052
7996
|
}
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
7997
|
+
/** @internal */
|
|
7998
|
+
_attach(id, pool) {
|
|
7999
|
+
super._attach(id, pool);
|
|
8000
|
+
for (const [_key, value] of this.#map) {
|
|
8001
|
+
if (isLiveNode(value)) {
|
|
8002
|
+
value._attach(pool.generateId(), pool);
|
|
8058
8003
|
}
|
|
8059
8004
|
}
|
|
8060
|
-
}
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8005
|
+
}
|
|
8006
|
+
/** @internal */
|
|
8007
|
+
_attachChild(op, source) {
|
|
8008
|
+
if (this._pool === void 0) {
|
|
8009
|
+
throw new Error("Can't attach child if managed pool is not present");
|
|
8065
8010
|
}
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
if (isLiveObject(liveListNode) && isPlainObject(prevNode) && isPlainObject(nextNode)) {
|
|
8072
|
-
legacy_patchLiveObject(liveListNode, prevNode, nextNode);
|
|
8073
|
-
} else {
|
|
8074
|
-
liveList.set(i, deepLiveify(nextNode));
|
|
8011
|
+
const { id, opId, parentKey: key } = op;
|
|
8012
|
+
const child = creationOpToLson(op);
|
|
8013
|
+
if (this._pool.getNode(id) !== void 0) {
|
|
8014
|
+
if (this.#unackedOpsByKey.get(key) === opId) {
|
|
8015
|
+
this.#unackedOpsByKey.delete(key);
|
|
8075
8016
|
}
|
|
8076
|
-
|
|
8077
|
-
}
|
|
8078
|
-
while (i <= nextEnd) {
|
|
8079
|
-
liveList.insert(deepLiveify(next[i]), i);
|
|
8080
|
-
i++;
|
|
8017
|
+
return { modified: false };
|
|
8081
8018
|
}
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
}
|
|
8089
|
-
|
|
8090
|
-
if (process.env.NODE_ENV !== "production") {
|
|
8091
|
-
const nonSerializableValue = findNonSerializableValue(next);
|
|
8092
|
-
if (nonSerializableValue) {
|
|
8093
|
-
error2(
|
|
8094
|
-
`New state path: '${nonSerializableValue.path}' value: '${String(
|
|
8095
|
-
nonSerializableValue.value
|
|
8096
|
-
)}' is not serializable.
|
|
8097
|
-
Only serializable value can be synced with Liveblocks.`
|
|
8098
|
-
);
|
|
8099
|
-
return;
|
|
8100
|
-
}
|
|
8101
|
-
}
|
|
8102
|
-
const value = liveObject.get(key);
|
|
8103
|
-
if (next === void 0) {
|
|
8104
|
-
liveObject.delete(key);
|
|
8105
|
-
} else if (value === void 0) {
|
|
8106
|
-
liveObject.set(key, deepLiveify(next));
|
|
8107
|
-
} else if (prev === next) {
|
|
8108
|
-
return;
|
|
8109
|
-
} else if (isLiveList(value) && Array.isArray(prev) && Array.isArray(next)) {
|
|
8110
|
-
legacy_patchLiveList(value, prev, next);
|
|
8111
|
-
} else if (isLiveObject(value) && isPlainObject(prev) && isPlainObject(next)) {
|
|
8112
|
-
legacy_patchLiveObject(value, prev, next);
|
|
8113
|
-
} else {
|
|
8114
|
-
liveObject.set(key, deepLiveify(next));
|
|
8115
|
-
}
|
|
8116
|
-
}
|
|
8117
|
-
function legacy_patchLiveObject(root, prev, next) {
|
|
8118
|
-
const updates = {};
|
|
8119
|
-
for (const key in next) {
|
|
8120
|
-
legacy_patchLiveObjectKey(root, key, prev[key], next[key]);
|
|
8121
|
-
}
|
|
8122
|
-
for (const key in prev) {
|
|
8123
|
-
if (next[key] === void 0) {
|
|
8124
|
-
root.delete(key);
|
|
8125
|
-
}
|
|
8126
|
-
}
|
|
8127
|
-
if (Object.keys(updates).length > 0) {
|
|
8128
|
-
root.update(updates);
|
|
8129
|
-
}
|
|
8130
|
-
}
|
|
8131
|
-
function getParentsPath(node) {
|
|
8132
|
-
const path = [];
|
|
8133
|
-
while (node.parent.type === "HasParent") {
|
|
8134
|
-
if (isLiveList(node.parent.node)) {
|
|
8135
|
-
path.push(node.parent.node._indexOfPosition(node.parent.key));
|
|
8136
|
-
} else {
|
|
8137
|
-
path.push(node.parent.key);
|
|
8138
|
-
}
|
|
8139
|
-
node = node.parent.node;
|
|
8140
|
-
}
|
|
8141
|
-
return path;
|
|
8142
|
-
}
|
|
8143
|
-
function legacy_patchImmutableObject(state, updates) {
|
|
8144
|
-
return updates.reduce(
|
|
8145
|
-
(state2, update) => legacy_patchImmutableObjectWithUpdate(state2, update),
|
|
8146
|
-
state
|
|
8147
|
-
);
|
|
8148
|
-
}
|
|
8149
|
-
function legacy_patchImmutableObjectWithUpdate(state, update) {
|
|
8150
|
-
const path = getParentsPath(update.node);
|
|
8151
|
-
return legacy_patchImmutableNode(state, path, update);
|
|
8152
|
-
}
|
|
8153
|
-
function legacy_patchImmutableNode(state, path, update) {
|
|
8154
|
-
const pathItem = path.pop();
|
|
8155
|
-
if (pathItem === void 0) {
|
|
8156
|
-
switch (update.type) {
|
|
8157
|
-
case "LiveObject": {
|
|
8158
|
-
if (!isJsonObject(state)) {
|
|
8159
|
-
throw new Error(
|
|
8160
|
-
"Internal: received update on LiveObject but state was not an object"
|
|
8161
|
-
);
|
|
8162
|
-
}
|
|
8163
|
-
const newState = Object.assign({}, state);
|
|
8164
|
-
for (const key in update.updates) {
|
|
8165
|
-
if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "update") {
|
|
8166
|
-
const val = update.node.get(key);
|
|
8167
|
-
if (val !== void 0) {
|
|
8168
|
-
newState[key] = lsonToJson(val);
|
|
8169
|
-
}
|
|
8170
|
-
} else if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "delete") {
|
|
8171
|
-
delete newState[key];
|
|
8172
|
-
}
|
|
8173
|
-
}
|
|
8174
|
-
return newState;
|
|
8175
|
-
}
|
|
8176
|
-
case "LiveList": {
|
|
8177
|
-
if (!Array.isArray(state)) {
|
|
8178
|
-
throw new Error(
|
|
8179
|
-
"Internal: received update on LiveList but state was not an array"
|
|
8180
|
-
);
|
|
8181
|
-
}
|
|
8182
|
-
let newState = state.map((x) => x);
|
|
8183
|
-
for (const listUpdate of update.updates) {
|
|
8184
|
-
if (listUpdate.type === "set") {
|
|
8185
|
-
newState = newState.map(
|
|
8186
|
-
(item, index) => index === listUpdate.index ? lsonToJson(listUpdate.item) : item
|
|
8187
|
-
);
|
|
8188
|
-
} else if (listUpdate.type === "insert") {
|
|
8189
|
-
if (listUpdate.index === newState.length) {
|
|
8190
|
-
newState.push(lsonToJson(listUpdate.item));
|
|
8191
|
-
} else {
|
|
8192
|
-
newState = [
|
|
8193
|
-
...newState.slice(0, listUpdate.index),
|
|
8194
|
-
lsonToJson(listUpdate.item),
|
|
8195
|
-
...newState.slice(listUpdate.index)
|
|
8196
|
-
];
|
|
8197
|
-
}
|
|
8198
|
-
} else if (listUpdate.type === "delete") {
|
|
8199
|
-
newState.splice(listUpdate.index, 1);
|
|
8200
|
-
} else if (listUpdate.type === "move") {
|
|
8201
|
-
if (listUpdate.previousIndex > listUpdate.index) {
|
|
8202
|
-
newState = [
|
|
8203
|
-
...newState.slice(0, listUpdate.index),
|
|
8204
|
-
lsonToJson(listUpdate.item),
|
|
8205
|
-
...newState.slice(listUpdate.index, listUpdate.previousIndex),
|
|
8206
|
-
...newState.slice(listUpdate.previousIndex + 1)
|
|
8207
|
-
];
|
|
8208
|
-
} else {
|
|
8209
|
-
newState = [
|
|
8210
|
-
...newState.slice(0, listUpdate.previousIndex),
|
|
8211
|
-
...newState.slice(
|
|
8212
|
-
listUpdate.previousIndex + 1,
|
|
8213
|
-
listUpdate.index + 1
|
|
8214
|
-
),
|
|
8215
|
-
lsonToJson(listUpdate.item),
|
|
8216
|
-
...newState.slice(listUpdate.index + 1)
|
|
8217
|
-
];
|
|
8218
|
-
}
|
|
8219
|
-
}
|
|
8220
|
-
}
|
|
8221
|
-
return newState;
|
|
8222
|
-
}
|
|
8223
|
-
case "LiveMap": {
|
|
8224
|
-
if (!isJsonObject(state)) {
|
|
8225
|
-
throw new Error(
|
|
8226
|
-
"Internal: received update on LiveMap but state was not an object"
|
|
8227
|
-
);
|
|
8228
|
-
}
|
|
8229
|
-
const newState = Object.assign({}, state);
|
|
8230
|
-
for (const key in update.updates) {
|
|
8231
|
-
if (_optionalChain([update, 'access', _198 => _198.updates, 'access', _199 => _199[key], 'optionalAccess', _200 => _200.type]) === "update") {
|
|
8232
|
-
const value = update.node.get(key);
|
|
8233
|
-
if (value !== void 0) {
|
|
8234
|
-
newState[key] = lsonToJson(value);
|
|
8235
|
-
}
|
|
8236
|
-
} else if (_optionalChain([update, 'access', _201 => _201.updates, 'access', _202 => _202[key], 'optionalAccess', _203 => _203.type]) === "delete") {
|
|
8237
|
-
delete newState[key];
|
|
8238
|
-
}
|
|
8239
|
-
}
|
|
8240
|
-
return newState;
|
|
8241
|
-
}
|
|
8242
|
-
}
|
|
8243
|
-
}
|
|
8244
|
-
if (Array.isArray(state)) {
|
|
8245
|
-
const newArray = [...state];
|
|
8246
|
-
newArray[pathItem] = legacy_patchImmutableNode(
|
|
8247
|
-
state[pathItem],
|
|
8248
|
-
path,
|
|
8249
|
-
update
|
|
8250
|
-
);
|
|
8251
|
-
return newArray;
|
|
8252
|
-
} else if (isJsonObject(state)) {
|
|
8253
|
-
const node = state[pathItem];
|
|
8254
|
-
if (node === void 0) {
|
|
8255
|
-
return state;
|
|
8256
|
-
} else {
|
|
8257
|
-
const stateAsObj = state;
|
|
8258
|
-
return {
|
|
8259
|
-
...stateAsObj,
|
|
8260
|
-
[pathItem]: legacy_patchImmutableNode(node, path, update)
|
|
8261
|
-
};
|
|
8262
|
-
}
|
|
8263
|
-
} else {
|
|
8264
|
-
return state;
|
|
8265
|
-
}
|
|
8266
|
-
}
|
|
8267
|
-
|
|
8268
|
-
// src/crdts/LiveObject.ts
|
|
8269
|
-
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
8270
|
-
var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
8271
|
-
#synced;
|
|
8272
|
-
#local = /* @__PURE__ */ new Map();
|
|
8273
|
-
/**
|
|
8274
|
-
* Tracks unacknowledged local changes per property to preserve optimistic
|
|
8275
|
-
* updates. Maps property keys to their pending operation IDs.
|
|
8276
|
-
*
|
|
8277
|
-
* INVARIANT: Only locally-generated opIds are ever stored here. Remote opIds
|
|
8278
|
-
* are only compared against (to detect ACKs), never stored.
|
|
8279
|
-
*
|
|
8280
|
-
* When a local change is made, the opId is stored here. When a remote op
|
|
8281
|
-
* arrives for the same key:
|
|
8282
|
-
* - If no entry exists → apply remote op
|
|
8283
|
-
* - If opId matches → it's an ACK, clear the entry
|
|
8284
|
-
* - If opId differs → ignore remote op to preserve optimistic update
|
|
8285
|
-
*/
|
|
8286
|
-
#unackedOpsByKey;
|
|
8287
|
-
/**
|
|
8288
|
-
* Enable or disable detection of too large LiveObjects.
|
|
8289
|
-
* When enabled, throws an error if LiveObject static data exceeds 128KB, which
|
|
8290
|
-
* is the maximum value the server will be able to accept.
|
|
8291
|
-
* By default, this behavior is disabled to avoid the runtime performance
|
|
8292
|
-
* overhead on every LiveObject.set() or LiveObject.update() call.
|
|
8293
|
-
*
|
|
8294
|
-
* @experimental
|
|
8295
|
-
*/
|
|
8296
|
-
static __initStatic() {this.detectLargeObjects = false}
|
|
8297
|
-
static #buildRootAndParentToChildren(nodes) {
|
|
8298
|
-
const parentToChildren = /* @__PURE__ */ new Map();
|
|
8299
|
-
let root = null;
|
|
8300
|
-
for (const node of nodes) {
|
|
8301
|
-
if (isRootStorageNode(node)) {
|
|
8302
|
-
root = node[1];
|
|
8303
|
-
} else {
|
|
8304
|
-
const crdt = node[1];
|
|
8305
|
-
const children = parentToChildren.get(crdt.parentId);
|
|
8306
|
-
if (children !== void 0) {
|
|
8307
|
-
children.push(node);
|
|
8308
|
-
} else {
|
|
8309
|
-
parentToChildren.set(crdt.parentId, [node]);
|
|
8310
|
-
}
|
|
8311
|
-
}
|
|
8312
|
-
}
|
|
8313
|
-
if (root === null) {
|
|
8314
|
-
throw new Error("Root can't be null");
|
|
8315
|
-
}
|
|
8316
|
-
return [root, parentToChildren];
|
|
8317
|
-
}
|
|
8318
|
-
/** @private Do not use this API directly */
|
|
8319
|
-
static _fromItems(nodes, pool) {
|
|
8320
|
-
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(nodes);
|
|
8321
|
-
return _LiveObject._deserialize(
|
|
8322
|
-
["root", root],
|
|
8323
|
-
parentToChildren,
|
|
8324
|
-
pool
|
|
8325
|
-
);
|
|
8326
|
-
}
|
|
8327
|
-
constructor(obj = {}) {
|
|
8328
|
-
super();
|
|
8329
|
-
this.#unackedOpsByKey = /* @__PURE__ */ new Map();
|
|
8330
|
-
const o = compactObject(obj);
|
|
8331
|
-
for (const key of Object.keys(o)) {
|
|
8332
|
-
const value = o[key];
|
|
8333
|
-
if (isLiveNode(value)) {
|
|
8334
|
-
value._setParentLink(this, key);
|
|
8335
|
-
}
|
|
8336
|
-
}
|
|
8337
|
-
this.#synced = new Map(Object.entries(o));
|
|
8338
|
-
}
|
|
8339
|
-
/** @internal */
|
|
8340
|
-
_toOps(parentId, parentKey) {
|
|
8341
|
-
if (this._id === void 0) {
|
|
8342
|
-
throw new Error("Cannot serialize item is not attached");
|
|
8343
|
-
}
|
|
8344
|
-
const ops = [];
|
|
8345
|
-
const op = {
|
|
8346
|
-
type: OpCode.CREATE_OBJECT,
|
|
8347
|
-
id: this._id,
|
|
8348
|
-
parentId,
|
|
8349
|
-
parentKey,
|
|
8350
|
-
data: {}
|
|
8351
|
-
};
|
|
8352
|
-
ops.push(op);
|
|
8353
|
-
for (const [key, value] of this.#synced) {
|
|
8354
|
-
if (isLiveNode(value)) {
|
|
8355
|
-
for (const childOp of value._toOps(this._id, key)) {
|
|
8356
|
-
ops.push(childOp);
|
|
8357
|
-
}
|
|
8358
|
-
} else {
|
|
8359
|
-
op.data[key] = value;
|
|
8360
|
-
}
|
|
8361
|
-
}
|
|
8362
|
-
return ops;
|
|
8363
|
-
}
|
|
8364
|
-
/** @internal */
|
|
8365
|
-
static _deserialize([id, item], parentToChildren, pool) {
|
|
8366
|
-
const liveObj = new _LiveObject(item.data);
|
|
8367
|
-
liveObj._attach(id, pool);
|
|
8368
|
-
return this._deserializeChildren(liveObj, parentToChildren, pool);
|
|
8369
|
-
}
|
|
8370
|
-
/** @internal */
|
|
8371
|
-
static _deserializeChildren(liveObj, parentToChildren, pool) {
|
|
8372
|
-
const children = parentToChildren.get(nn(liveObj._id));
|
|
8373
|
-
if (children === void 0) {
|
|
8374
|
-
return liveObj;
|
|
8375
|
-
}
|
|
8376
|
-
for (const node of children) {
|
|
8377
|
-
const child = deserializeToLson(node, parentToChildren, pool);
|
|
8378
|
-
const crdt = node[1];
|
|
8379
|
-
if (isLiveStructure(child)) {
|
|
8380
|
-
child._setParentLink(liveObj, crdt.parentKey);
|
|
8381
|
-
}
|
|
8382
|
-
liveObj.#synced.set(crdt.parentKey, child);
|
|
8383
|
-
liveObj.invalidate();
|
|
8384
|
-
}
|
|
8385
|
-
return liveObj;
|
|
8386
|
-
}
|
|
8387
|
-
/** @internal */
|
|
8388
|
-
_attach(id, pool) {
|
|
8389
|
-
super._attach(id, pool);
|
|
8390
|
-
for (const [_key, value] of this.#synced) {
|
|
8391
|
-
if (isLiveNode(value)) {
|
|
8392
|
-
value._attach(pool.generateId(), pool);
|
|
8393
|
-
}
|
|
8394
|
-
}
|
|
8395
|
-
}
|
|
8396
|
-
/** @internal */
|
|
8397
|
-
_attachChild(op, source) {
|
|
8398
|
-
if (this._pool === void 0) {
|
|
8399
|
-
throw new Error("Can't attach child if managed pool is not present");
|
|
8400
|
-
}
|
|
8401
|
-
const { id, opId, parentKey: key } = op;
|
|
8402
|
-
const child = creationOpToLson(op);
|
|
8403
|
-
if (this._pool.getNode(id) !== void 0) {
|
|
8404
|
-
if (this.#unackedOpsByKey.get(key) === opId) {
|
|
8405
|
-
this.#unackedOpsByKey.delete(key);
|
|
8406
|
-
}
|
|
8407
|
-
return { modified: false };
|
|
8408
|
-
}
|
|
8409
|
-
if (source === 0 /* LOCAL */) {
|
|
8410
|
-
this.#unackedOpsByKey.set(key, nn(opId));
|
|
8411
|
-
} else if (this.#unackedOpsByKey.get(key) === void 0) {
|
|
8412
|
-
} else if (this.#unackedOpsByKey.get(key) === opId) {
|
|
8413
|
-
this.#unackedOpsByKey.delete(key);
|
|
8414
|
-
return { modified: false };
|
|
8415
|
-
} else {
|
|
8416
|
-
return { modified: false };
|
|
8019
|
+
if (source === 0 /* LOCAL */) {
|
|
8020
|
+
this.#unackedOpsByKey.set(key, nn(opId));
|
|
8021
|
+
} else if (this.#unackedOpsByKey.get(key) === void 0) {
|
|
8022
|
+
} else if (this.#unackedOpsByKey.get(key) === opId) {
|
|
8023
|
+
this.#unackedOpsByKey.delete(key);
|
|
8024
|
+
return { modified: false };
|
|
8025
|
+
} else {
|
|
8026
|
+
return { modified: false };
|
|
8417
8027
|
}
|
|
8418
8028
|
const thisId = nn(this._id);
|
|
8419
|
-
const previousValue = this.#
|
|
8029
|
+
const previousValue = this.#map.get(key);
|
|
8420
8030
|
let reverse;
|
|
8421
8031
|
if (isLiveNode(previousValue)) {
|
|
8422
8032
|
reverse = previousValue._toOps(thisId, key);
|
|
@@ -8432,8 +8042,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8432
8042
|
}
|
|
8433
8043
|
];
|
|
8434
8044
|
}
|
|
8435
|
-
this.#
|
|
8436
|
-
this.#synced.set(key, child);
|
|
8045
|
+
this.#map.set(key, child);
|
|
8437
8046
|
this.invalidate();
|
|
8438
8047
|
if (isLiveStructure(child)) {
|
|
8439
8048
|
child._setParentLink(this, key);
|
|
@@ -8454,9 +8063,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8454
8063
|
const id = nn(this._id);
|
|
8455
8064
|
const parentKey = nn(child._parentKey);
|
|
8456
8065
|
const reverse = child._toOps(id, parentKey);
|
|
8457
|
-
for (const [key, value] of this.#
|
|
8066
|
+
for (const [key, value] of this.#map) {
|
|
8458
8067
|
if (value === child) {
|
|
8459
|
-
this.#
|
|
8068
|
+
this.#map.delete(key);
|
|
8460
8069
|
this.invalidate();
|
|
8461
8070
|
}
|
|
8462
8071
|
}
|
|
@@ -8475,7 +8084,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8475
8084
|
/** @internal */
|
|
8476
8085
|
_detach() {
|
|
8477
8086
|
super._detach();
|
|
8478
|
-
for (const value of this.#
|
|
8087
|
+
for (const value of this.#map.values()) {
|
|
8479
8088
|
if (isLiveNode(value)) {
|
|
8480
8089
|
value._detach();
|
|
8481
8090
|
}
|
|
@@ -8493,7 +8102,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8493
8102
|
/** @internal */
|
|
8494
8103
|
_serialize() {
|
|
8495
8104
|
const data = {};
|
|
8496
|
-
for (const [key, value] of this.#
|
|
8105
|
+
for (const [key, value] of this.#map) {
|
|
8497
8106
|
if (!isLiveNode(value)) {
|
|
8498
8107
|
data[key] = value;
|
|
8499
8108
|
}
|
|
@@ -8522,7 +8131,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8522
8131
|
data: {}
|
|
8523
8132
|
};
|
|
8524
8133
|
for (const key in op.data) {
|
|
8525
|
-
const oldValue = this.#
|
|
8134
|
+
const oldValue = this.#map.get(key);
|
|
8526
8135
|
if (isLiveNode(oldValue)) {
|
|
8527
8136
|
for (const childOp of oldValue._toOps(id, key)) {
|
|
8528
8137
|
reverse.push(childOp);
|
|
@@ -8550,14 +8159,13 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8550
8159
|
} else {
|
|
8551
8160
|
continue;
|
|
8552
8161
|
}
|
|
8553
|
-
const oldValue = this.#
|
|
8162
|
+
const oldValue = this.#map.get(key);
|
|
8554
8163
|
if (isLiveNode(oldValue)) {
|
|
8555
8164
|
oldValue._detach();
|
|
8556
8165
|
}
|
|
8557
8166
|
isModified = true;
|
|
8558
8167
|
updateDelta[key] = { type: "update" };
|
|
8559
|
-
this.#
|
|
8560
|
-
this.#synced.set(key, value);
|
|
8168
|
+
this.#map.set(key, value);
|
|
8561
8169
|
this.invalidate();
|
|
8562
8170
|
}
|
|
8563
8171
|
if (Object.keys(reverseUpdate.data).length !== 0) {
|
|
@@ -8574,7 +8182,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8574
8182
|
}
|
|
8575
8183
|
#applyDeleteObjectKey(op, isLocal) {
|
|
8576
8184
|
const key = op.key;
|
|
8577
|
-
const oldValue = this.#
|
|
8185
|
+
const oldValue = this.#map.get(key);
|
|
8578
8186
|
if (oldValue === void 0) {
|
|
8579
8187
|
return { modified: false };
|
|
8580
8188
|
}
|
|
@@ -8595,8 +8203,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8595
8203
|
}
|
|
8596
8204
|
];
|
|
8597
8205
|
}
|
|
8598
|
-
this.#
|
|
8599
|
-
this.#synced.delete(key);
|
|
8206
|
+
this.#map.delete(key);
|
|
8600
8207
|
this.invalidate();
|
|
8601
8208
|
return {
|
|
8602
8209
|
modified: {
|
|
@@ -8609,23 +8216,11 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8609
8216
|
reverse
|
|
8610
8217
|
};
|
|
8611
8218
|
}
|
|
8612
|
-
/** @private */
|
|
8613
|
-
keys() {
|
|
8614
|
-
const result = new Set(this.#synced.keys());
|
|
8615
|
-
for (const key of this.#local.keys()) {
|
|
8616
|
-
result.add(key);
|
|
8617
|
-
}
|
|
8618
|
-
return result;
|
|
8619
|
-
}
|
|
8620
8219
|
/**
|
|
8621
8220
|
* Transform the LiveObject into a javascript object
|
|
8622
8221
|
*/
|
|
8623
8222
|
toObject() {
|
|
8624
|
-
|
|
8625
|
-
for (const [key, value] of this.#local) {
|
|
8626
|
-
result[key] = value;
|
|
8627
|
-
}
|
|
8628
|
-
return result;
|
|
8223
|
+
return Object.fromEntries(this.#map);
|
|
8629
8224
|
}
|
|
8630
8225
|
/**
|
|
8631
8226
|
* Adds or updates a property with a specified key and a value.
|
|
@@ -8633,109 +8228,49 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8633
8228
|
* @param value The value of the property to add
|
|
8634
8229
|
*/
|
|
8635
8230
|
set(key, value) {
|
|
8231
|
+
_optionalChain([this, 'access', _192 => _192._pool, 'optionalAccess', _193 => _193.assertStorageIsWritable, 'call', _194 => _194()]);
|
|
8636
8232
|
this.update({ [key]: value });
|
|
8637
8233
|
}
|
|
8638
|
-
/**
|
|
8639
|
-
* @experimental
|
|
8640
|
-
*
|
|
8641
|
-
* Sets a local-only property that is not synchronized over the wire.
|
|
8642
|
-
* The value will be visible via get(), toObject(), and toImmutable() on
|
|
8643
|
-
* this client only. Other clients and the server will see `undefined`
|
|
8644
|
-
* for this key.
|
|
8645
|
-
*
|
|
8646
|
-
* Caveat: this method will not add changes to the undo/redo stack.
|
|
8647
|
-
*/
|
|
8648
|
-
setLocal(key, value) {
|
|
8649
|
-
_optionalChain([this, 'access', _204 => _204._pool, 'optionalAccess', _205 => _205.assertStorageIsWritable, 'call', _206 => _206()]);
|
|
8650
|
-
const deleteResult = this.#prepareDelete(key);
|
|
8651
|
-
this.#local.set(key, value);
|
|
8652
|
-
this.invalidate();
|
|
8653
|
-
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8654
|
-
const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _207 => _207[0]]), () => ( []));
|
|
8655
|
-
const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _208 => _208[1]]), () => ( []));
|
|
8656
|
-
const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _209 => _209[2]]), () => ( /* @__PURE__ */ new Map()));
|
|
8657
|
-
const existing = storageUpdates.get(this._id);
|
|
8658
|
-
storageUpdates.set(this._id, {
|
|
8659
|
-
node: this,
|
|
8660
|
-
type: "LiveObject",
|
|
8661
|
-
updates: {
|
|
8662
|
-
..._optionalChain([existing, 'optionalAccess', _210 => _210.updates]),
|
|
8663
|
-
[key]: { type: "update" }
|
|
8664
|
-
}
|
|
8665
|
-
});
|
|
8666
|
-
this._pool.dispatch(ops, reverse, storageUpdates);
|
|
8667
|
-
}
|
|
8668
|
-
}
|
|
8669
8234
|
/**
|
|
8670
8235
|
* Returns a specified property from the LiveObject.
|
|
8671
8236
|
* @param key The key of the property to get
|
|
8672
8237
|
*/
|
|
8673
8238
|
get(key) {
|
|
8674
|
-
return this.#
|
|
8239
|
+
return this.#map.get(key);
|
|
8675
8240
|
}
|
|
8676
8241
|
/**
|
|
8677
|
-
*
|
|
8678
|
-
*
|
|
8679
|
-
* #synced or pool/id are unavailable. Does NOT dispatch.
|
|
8242
|
+
* Deletes a key from the LiveObject
|
|
8243
|
+
* @param key The key of the property to delete
|
|
8680
8244
|
*/
|
|
8681
|
-
|
|
8682
|
-
_optionalChain([this, 'access',
|
|
8683
|
-
const
|
|
8684
|
-
|
|
8685
|
-
const oldValue2 = this.#local.get(k);
|
|
8686
|
-
this.#local.delete(k);
|
|
8687
|
-
this.invalidate();
|
|
8688
|
-
if (this._pool !== void 0 && this._id !== void 0) {
|
|
8689
|
-
const storageUpdates2 = /* @__PURE__ */ new Map();
|
|
8690
|
-
storageUpdates2.set(this._id, {
|
|
8691
|
-
node: this,
|
|
8692
|
-
type: "LiveObject",
|
|
8693
|
-
updates: {
|
|
8694
|
-
[k]: {
|
|
8695
|
-
type: "delete",
|
|
8696
|
-
deletedItem: oldValue2
|
|
8697
|
-
}
|
|
8698
|
-
}
|
|
8699
|
-
});
|
|
8700
|
-
return [[], [], storageUpdates2];
|
|
8701
|
-
}
|
|
8702
|
-
return null;
|
|
8703
|
-
}
|
|
8704
|
-
this.#local.delete(k);
|
|
8705
|
-
const oldValue = this.#synced.get(k);
|
|
8245
|
+
delete(key) {
|
|
8246
|
+
_optionalChain([this, 'access', _195 => _195._pool, 'optionalAccess', _196 => _196.assertStorageIsWritable, 'call', _197 => _197()]);
|
|
8247
|
+
const keyAsString = key;
|
|
8248
|
+
const oldValue = this.#map.get(keyAsString);
|
|
8706
8249
|
if (oldValue === void 0) {
|
|
8707
|
-
return
|
|
8250
|
+
return;
|
|
8708
8251
|
}
|
|
8709
8252
|
if (this._pool === void 0 || this._id === void 0) {
|
|
8710
8253
|
if (isLiveNode(oldValue)) {
|
|
8711
8254
|
oldValue._detach();
|
|
8712
8255
|
}
|
|
8713
|
-
this.#
|
|
8256
|
+
this.#map.delete(keyAsString);
|
|
8714
8257
|
this.invalidate();
|
|
8715
|
-
return
|
|
8258
|
+
return;
|
|
8716
8259
|
}
|
|
8717
|
-
const ops = [
|
|
8718
|
-
{
|
|
8719
|
-
type: OpCode.DELETE_OBJECT_KEY,
|
|
8720
|
-
key: k,
|
|
8721
|
-
id: this._id,
|
|
8722
|
-
opId: this._pool.generateOpId()
|
|
8723
|
-
}
|
|
8724
|
-
];
|
|
8725
8260
|
let reverse;
|
|
8726
8261
|
if (isLiveNode(oldValue)) {
|
|
8727
8262
|
oldValue._detach();
|
|
8728
|
-
reverse = oldValue._toOps(this._id,
|
|
8263
|
+
reverse = oldValue._toOps(this._id, keyAsString);
|
|
8729
8264
|
} else {
|
|
8730
8265
|
reverse = [
|
|
8731
8266
|
{
|
|
8732
8267
|
type: OpCode.UPDATE_OBJECT,
|
|
8733
|
-
data: { [
|
|
8268
|
+
data: { [keyAsString]: oldValue },
|
|
8734
8269
|
id: this._id
|
|
8735
8270
|
}
|
|
8736
8271
|
];
|
|
8737
8272
|
}
|
|
8738
|
-
this.#
|
|
8273
|
+
this.#map.delete(keyAsString);
|
|
8739
8274
|
this.invalidate();
|
|
8740
8275
|
const storageUpdates = /* @__PURE__ */ new Map();
|
|
8741
8276
|
storageUpdates.set(this._id, {
|
|
@@ -8745,28 +8280,28 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8745
8280
|
[key]: { type: "delete", deletedItem: oldValue }
|
|
8746
8281
|
}
|
|
8747
8282
|
});
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8283
|
+
this._pool.dispatch(
|
|
8284
|
+
[
|
|
8285
|
+
{
|
|
8286
|
+
type: OpCode.DELETE_OBJECT_KEY,
|
|
8287
|
+
key: keyAsString,
|
|
8288
|
+
id: this._id,
|
|
8289
|
+
opId: this._pool.generateOpId()
|
|
8290
|
+
}
|
|
8291
|
+
],
|
|
8292
|
+
reverse,
|
|
8293
|
+
storageUpdates
|
|
8294
|
+
);
|
|
8760
8295
|
}
|
|
8761
8296
|
/**
|
|
8762
8297
|
* Adds or updates multiple properties at once with an object.
|
|
8763
8298
|
* @param patch The object used to overrides properties
|
|
8764
8299
|
*/
|
|
8765
8300
|
update(patch) {
|
|
8766
|
-
_optionalChain([this, 'access',
|
|
8301
|
+
_optionalChain([this, 'access', _198 => _198._pool, 'optionalAccess', _199 => _199.assertStorageIsWritable, 'call', _200 => _200()]);
|
|
8767
8302
|
if (_LiveObject.detectLargeObjects) {
|
|
8768
8303
|
const data = {};
|
|
8769
|
-
for (const [key, value] of this.#
|
|
8304
|
+
for (const [key, value] of this.#map) {
|
|
8770
8305
|
if (!isLiveNode(value)) {
|
|
8771
8306
|
data[key] = value;
|
|
8772
8307
|
}
|
|
@@ -8795,15 +8330,14 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8795
8330
|
if (newValue === void 0) {
|
|
8796
8331
|
continue;
|
|
8797
8332
|
}
|
|
8798
|
-
const oldValue = this.#
|
|
8333
|
+
const oldValue = this.#map.get(key);
|
|
8799
8334
|
if (isLiveNode(oldValue)) {
|
|
8800
8335
|
oldValue._detach();
|
|
8801
8336
|
}
|
|
8802
8337
|
if (isLiveNode(newValue)) {
|
|
8803
8338
|
newValue._setParentLink(this, key);
|
|
8804
8339
|
}
|
|
8805
|
-
this.#
|
|
8806
|
-
this.#synced.set(key, newValue);
|
|
8340
|
+
this.#map.set(key, newValue);
|
|
8807
8341
|
this.invalidate();
|
|
8808
8342
|
}
|
|
8809
8343
|
return;
|
|
@@ -8823,7 +8357,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8823
8357
|
if (newValue === void 0) {
|
|
8824
8358
|
continue;
|
|
8825
8359
|
}
|
|
8826
|
-
const oldValue = this.#
|
|
8360
|
+
const oldValue = this.#map.get(key);
|
|
8827
8361
|
if (isLiveNode(oldValue)) {
|
|
8828
8362
|
for (const childOp of oldValue._toOps(this._id, key)) {
|
|
8829
8363
|
reverseOps.push(childOp);
|
|
@@ -8855,8 +8389,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8855
8389
|
updatedProps[key] = newValue;
|
|
8856
8390
|
this.#unackedOpsByKey.set(key, opId);
|
|
8857
8391
|
}
|
|
8858
|
-
this.#
|
|
8859
|
-
this.#synced.set(key, newValue);
|
|
8392
|
+
this.#map.set(key, newValue);
|
|
8860
8393
|
this.invalidate();
|
|
8861
8394
|
updateDelta[key] = { type: "update" };
|
|
8862
8395
|
}
|
|
@@ -8879,34 +8412,6 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8879
8412
|
});
|
|
8880
8413
|
this._pool.dispatch(ops, reverseOps, storageUpdates);
|
|
8881
8414
|
}
|
|
8882
|
-
/**
|
|
8883
|
-
* Creates a new LiveObject from a plain JSON object, recursively converting
|
|
8884
|
-
* nested objects to LiveObjects and arrays to LiveLists. An optional
|
|
8885
|
-
* SyncConfig controls per-key behavior (local-only, atomic, or deep).
|
|
8886
|
-
*
|
|
8887
|
-
* @private
|
|
8888
|
-
*/
|
|
8889
|
-
static from(obj, config) {
|
|
8890
|
-
if (!isPlainObject(obj)) throw new Error("Expected a JSON object");
|
|
8891
|
-
const liveObj = new _LiveObject({});
|
|
8892
|
-
liveObj.reconcile(obj, config);
|
|
8893
|
-
return liveObj;
|
|
8894
|
-
}
|
|
8895
|
-
/**
|
|
8896
|
-
* Reconciles a LiveObject tree to match the given JSON object and sync
|
|
8897
|
-
* config. Only mutates keys that actually changed. Recursively reconciles
|
|
8898
|
-
* the entire Live tree below it.
|
|
8899
|
-
*
|
|
8900
|
-
* @private
|
|
8901
|
-
*/
|
|
8902
|
-
reconcile(jsonObj, config) {
|
|
8903
|
-
if (this.immutableIs(jsonObj)) return;
|
|
8904
|
-
if (!isPlainObject(jsonObj))
|
|
8905
|
-
throw new Error(
|
|
8906
|
-
"Reconciling the document root expects a plain object value"
|
|
8907
|
-
);
|
|
8908
|
-
reconcileLiveObject(this, jsonObj, config);
|
|
8909
|
-
}
|
|
8910
8415
|
toImmutable() {
|
|
8911
8416
|
return super.toImmutable();
|
|
8912
8417
|
}
|
|
@@ -8921,7 +8426,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8921
8426
|
type: "LiveObject",
|
|
8922
8427
|
id: nodeId,
|
|
8923
8428
|
key,
|
|
8924
|
-
payload: Array.from(this.#
|
|
8429
|
+
payload: Array.from(this.#map.entries()).map(
|
|
8925
8430
|
([key2, value]) => isLiveNode(value) ? value.toTreeNode(key2) : { type: "Json", id: `${nodeId}:${key2}`, key: key2, payload: value }
|
|
8926
8431
|
)
|
|
8927
8432
|
};
|
|
@@ -8929,27 +8434,20 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
8929
8434
|
/** @internal */
|
|
8930
8435
|
_toImmutable() {
|
|
8931
8436
|
const result = {};
|
|
8932
|
-
for (const [key, val] of this.#
|
|
8437
|
+
for (const [key, val] of this.#map) {
|
|
8933
8438
|
result[key] = isLiveStructure(val) ? val.toImmutable() : val;
|
|
8934
8439
|
}
|
|
8935
|
-
for (const [key, val] of this.#local) {
|
|
8936
|
-
result[key] = val;
|
|
8937
|
-
}
|
|
8938
8440
|
return process.env.NODE_ENV === "production" ? result : Object.freeze(result);
|
|
8939
8441
|
}
|
|
8940
8442
|
clone() {
|
|
8941
|
-
|
|
8443
|
+
return new _LiveObject(
|
|
8942
8444
|
Object.fromEntries(
|
|
8943
|
-
Array.from(this.#
|
|
8445
|
+
Array.from(this.#map).map(([key, value]) => [
|
|
8944
8446
|
key,
|
|
8945
8447
|
isLiveStructure(value) ? value.clone() : deepClone(value)
|
|
8946
8448
|
])
|
|
8947
8449
|
)
|
|
8948
8450
|
);
|
|
8949
|
-
for (const [key, value] of this.#local) {
|
|
8950
|
-
cloned.#local.set(key, deepClone(value));
|
|
8951
|
-
}
|
|
8952
|
-
return cloned;
|
|
8953
8451
|
}
|
|
8954
8452
|
}, _class2.__initStatic(), _class2);
|
|
8955
8453
|
|
|
@@ -9249,6 +8747,17 @@ var Deque = class {
|
|
|
9249
8747
|
}
|
|
9250
8748
|
};
|
|
9251
8749
|
|
|
8750
|
+
// src/lib/Json.ts
|
|
8751
|
+
function isJsonScalar(data) {
|
|
8752
|
+
return data === null || typeof data === "string" || typeof data === "number" || typeof data === "boolean";
|
|
8753
|
+
}
|
|
8754
|
+
function isJsonArray(data) {
|
|
8755
|
+
return Array.isArray(data);
|
|
8756
|
+
}
|
|
8757
|
+
function isJsonObject(data) {
|
|
8758
|
+
return !isJsonScalar(data) && !isJsonArray(data);
|
|
8759
|
+
}
|
|
8760
|
+
|
|
9252
8761
|
// src/lib/stopwatch.ts
|
|
9253
8762
|
function makeStopWatch() {
|
|
9254
8763
|
let startTime = 0;
|
|
@@ -9282,7 +8791,16 @@ var ClientMsgCode = Object.freeze({
|
|
|
9282
8791
|
UPDATE_STORAGE: 201,
|
|
9283
8792
|
// For Yjs support
|
|
9284
8793
|
FETCH_YDOC: 300,
|
|
9285
|
-
UPDATE_YDOC: 301
|
|
8794
|
+
UPDATE_YDOC: 301,
|
|
8795
|
+
// For Feeds
|
|
8796
|
+
FETCH_FEEDS: 510,
|
|
8797
|
+
FETCH_FEED_MESSAGES: 511,
|
|
8798
|
+
ADD_FEED: 512,
|
|
8799
|
+
UPDATE_FEED: 513,
|
|
8800
|
+
DELETE_FEED: 514,
|
|
8801
|
+
ADD_FEED_MESSAGE: 515,
|
|
8802
|
+
UPDATE_FEED_MESSAGE: 516,
|
|
8803
|
+
DELETE_FEED_MESSAGE: 517
|
|
9286
8804
|
});
|
|
9287
8805
|
|
|
9288
8806
|
// src/refs/ManagedOthers.ts
|
|
@@ -9518,12 +9036,15 @@ function defaultMessageFromContext(context) {
|
|
|
9518
9036
|
return "Could not update notification settings";
|
|
9519
9037
|
case "LARGE_MESSAGE_ERROR":
|
|
9520
9038
|
return "Could not send large message";
|
|
9039
|
+
case "FEED_REQUEST_ERROR":
|
|
9040
|
+
return _nullishCoalesce(context.reason, () => ( "Feed request failed"));
|
|
9521
9041
|
default:
|
|
9522
9042
|
return assertNever(context, "Unhandled case");
|
|
9523
9043
|
}
|
|
9524
9044
|
}
|
|
9525
9045
|
|
|
9526
9046
|
// src/room.ts
|
|
9047
|
+
var FEEDS_TIMEOUT = 5e3;
|
|
9527
9048
|
function makeIdFactory(connectionId) {
|
|
9528
9049
|
let count = 0;
|
|
9529
9050
|
return () => `${connectionId}:${count++}`;
|
|
@@ -9546,15 +9067,15 @@ function installBackgroundTabSpy() {
|
|
|
9546
9067
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
9547
9068
|
const inBackgroundSince = { current: null };
|
|
9548
9069
|
function onVisibilityChange() {
|
|
9549
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
9070
|
+
if (_optionalChain([doc, 'optionalAccess', _201 => _201.visibilityState]) === "hidden") {
|
|
9550
9071
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
9551
9072
|
} else {
|
|
9552
9073
|
inBackgroundSince.current = null;
|
|
9553
9074
|
}
|
|
9554
9075
|
}
|
|
9555
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9076
|
+
_optionalChain([doc, 'optionalAccess', _202 => _202.addEventListener, 'call', _203 => _203("visibilitychange", onVisibilityChange)]);
|
|
9556
9077
|
const unsub = () => {
|
|
9557
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9078
|
+
_optionalChain([doc, 'optionalAccess', _204 => _204.removeEventListener, 'call', _205 => _205("visibilitychange", onVisibilityChange)]);
|
|
9558
9079
|
};
|
|
9559
9080
|
return [inBackgroundSince, unsub];
|
|
9560
9081
|
}
|
|
@@ -9734,18 +9255,14 @@ function createRoom(options, config) {
|
|
|
9734
9255
|
}
|
|
9735
9256
|
context.activeBatch.reverseOps.pushLeft(reverse);
|
|
9736
9257
|
} else {
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
if (ops.length > 0) {
|
|
9741
|
-
context.redoStack.length = 0;
|
|
9742
|
-
dispatchOps(ops);
|
|
9743
|
-
}
|
|
9258
|
+
addToUndoStack(reverse);
|
|
9259
|
+
context.redoStack.length = 0;
|
|
9260
|
+
dispatchOps(ops);
|
|
9744
9261
|
notify({ storageUpdates });
|
|
9745
9262
|
}
|
|
9746
9263
|
}
|
|
9747
9264
|
function isStorageWritable() {
|
|
9748
|
-
const scopes = _optionalChain([context, 'access',
|
|
9265
|
+
const scopes = _optionalChain([context, 'access', _206 => _206.dynamicSessionInfoSig, 'access', _207 => _207.get, 'call', _208 => _208(), 'optionalAccess', _209 => _209.scopes]);
|
|
9749
9266
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
9750
9267
|
}
|
|
9751
9268
|
const eventHub = {
|
|
@@ -9762,6 +9279,7 @@ function createRoom(options, config) {
|
|
|
9762
9279
|
storageStatus: makeEventSource(),
|
|
9763
9280
|
ydoc: makeEventSource(),
|
|
9764
9281
|
comments: makeEventSource(),
|
|
9282
|
+
feeds: makeEventSource(),
|
|
9765
9283
|
roomWillDestroy: makeEventSource()
|
|
9766
9284
|
};
|
|
9767
9285
|
async function createTextMention(mentionId, mention) {
|
|
@@ -9848,21 +9366,20 @@ function createRoom(options, config) {
|
|
|
9848
9366
|
context.pool
|
|
9849
9367
|
);
|
|
9850
9368
|
}
|
|
9851
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
9852
|
-
const
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
if (
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
);
|
|
9862
|
-
}
|
|
9369
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _210 => _210.get, 'call', _211 => _211(), 'optionalAccess', _212 => _212.canWrite]), () => ( true));
|
|
9370
|
+
const stackSizeBefore = context.undoStack.length;
|
|
9371
|
+
for (const key in context.initialStorage) {
|
|
9372
|
+
if (context.root.get(key) === void 0) {
|
|
9373
|
+
if (canWrite) {
|
|
9374
|
+
context.root.set(key, cloneLson(context.initialStorage[key]));
|
|
9375
|
+
} else {
|
|
9376
|
+
warn(
|
|
9377
|
+
`Attempted to populate missing storage key '${key}', but current user has no write access`
|
|
9378
|
+
);
|
|
9863
9379
|
}
|
|
9864
9380
|
}
|
|
9865
|
-
}
|
|
9381
|
+
}
|
|
9382
|
+
context.undoStack.length = stackSizeBefore;
|
|
9866
9383
|
}
|
|
9867
9384
|
function _addToRealUndoStack(frames) {
|
|
9868
9385
|
if (context.undoStack.length >= 50) {
|
|
@@ -10053,7 +9570,7 @@ function createRoom(options, config) {
|
|
|
10053
9570
|
}
|
|
10054
9571
|
context.myPresence.patch(patch);
|
|
10055
9572
|
if (context.activeBatch) {
|
|
10056
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9573
|
+
if (_optionalChain([options2, 'optionalAccess', _213 => _213.addToHistory])) {
|
|
10057
9574
|
context.activeBatch.reverseOps.pushLeft({
|
|
10058
9575
|
type: "presence",
|
|
10059
9576
|
data: oldValues
|
|
@@ -10062,7 +9579,7 @@ function createRoom(options, config) {
|
|
|
10062
9579
|
context.activeBatch.updates.presence = true;
|
|
10063
9580
|
} else {
|
|
10064
9581
|
flushNowOrSoon();
|
|
10065
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9582
|
+
if (_optionalChain([options2, 'optionalAccess', _214 => _214.addToHistory])) {
|
|
10066
9583
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
10067
9584
|
}
|
|
10068
9585
|
notify({ presence: true });
|
|
@@ -10183,6 +9700,9 @@ function createRoom(options, config) {
|
|
|
10183
9700
|
notify(result.updates);
|
|
10184
9701
|
sendMessages(messages);
|
|
10185
9702
|
}
|
|
9703
|
+
function isFeedRequestFailedMsg(msg) {
|
|
9704
|
+
return msg.type === ServerMsgCode.FEED_REQUEST_FAILED;
|
|
9705
|
+
}
|
|
10186
9706
|
function handleServerMessage(event) {
|
|
10187
9707
|
if (typeof event.data !== "string") {
|
|
10188
9708
|
return;
|
|
@@ -10236,11 +9756,11 @@ function createRoom(options, config) {
|
|
|
10236
9756
|
break;
|
|
10237
9757
|
}
|
|
10238
9758
|
case ServerMsgCode.STORAGE_CHUNK:
|
|
10239
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
9759
|
+
_optionalChain([stopwatch, 'optionalAccess', _215 => _215.lap, 'call', _216 => _216()]);
|
|
10240
9760
|
nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
|
|
10241
9761
|
break;
|
|
10242
9762
|
case ServerMsgCode.STORAGE_STREAM_END: {
|
|
10243
|
-
const timing = _optionalChain([stopwatch, 'optionalAccess',
|
|
9763
|
+
const timing = _optionalChain([stopwatch, 'optionalAccess', _217 => _217.stop, 'call', _218 => _218()]);
|
|
10244
9764
|
if (timing) {
|
|
10245
9765
|
const ms = (v) => `${v.toFixed(1)}ms`;
|
|
10246
9766
|
const rest = timing.laps.slice(1);
|
|
@@ -10296,6 +9816,94 @@ function createRoom(options, config) {
|
|
|
10296
9816
|
eventHub.comments.notify(message);
|
|
10297
9817
|
break;
|
|
10298
9818
|
}
|
|
9819
|
+
case ServerMsgCode.FEEDS_LIST: {
|
|
9820
|
+
const feedsListMsg = message;
|
|
9821
|
+
const pending = pendingFeedsRequests.get(feedsListMsg.requestId);
|
|
9822
|
+
if (pending) {
|
|
9823
|
+
pending.resolve({
|
|
9824
|
+
feeds: feedsListMsg.feeds,
|
|
9825
|
+
nextCursor: feedsListMsg.nextCursor
|
|
9826
|
+
});
|
|
9827
|
+
pendingFeedsRequests.delete(feedsListMsg.requestId);
|
|
9828
|
+
}
|
|
9829
|
+
eventHub.feeds.notify(feedsListMsg);
|
|
9830
|
+
break;
|
|
9831
|
+
}
|
|
9832
|
+
case ServerMsgCode.FEEDS_ADDED: {
|
|
9833
|
+
const feedsAddedMsg = message;
|
|
9834
|
+
eventHub.feeds.notify(feedsAddedMsg);
|
|
9835
|
+
tryResolvePendingFeedMutationsFromFeedsEvent(feedsAddedMsg);
|
|
9836
|
+
break;
|
|
9837
|
+
}
|
|
9838
|
+
case ServerMsgCode.FEEDS_UPDATED: {
|
|
9839
|
+
const feedsUpdatedMsg = message;
|
|
9840
|
+
eventHub.feeds.notify(feedsUpdatedMsg);
|
|
9841
|
+
tryResolvePendingFeedMutationsFromFeedsEvent(feedsUpdatedMsg);
|
|
9842
|
+
break;
|
|
9843
|
+
}
|
|
9844
|
+
case ServerMsgCode.FEED_DELETED: {
|
|
9845
|
+
eventHub.feeds.notify(message);
|
|
9846
|
+
tryResolvePendingFeedMutationsFromFeedsEvent(message);
|
|
9847
|
+
break;
|
|
9848
|
+
}
|
|
9849
|
+
case ServerMsgCode.FEED_MESSAGES_LIST: {
|
|
9850
|
+
const feedMsgsListMsg = message;
|
|
9851
|
+
const pending = pendingFeedMessagesRequests.get(
|
|
9852
|
+
feedMsgsListMsg.requestId
|
|
9853
|
+
);
|
|
9854
|
+
if (pending) {
|
|
9855
|
+
pending.resolve({
|
|
9856
|
+
messages: feedMsgsListMsg.messages,
|
|
9857
|
+
nextCursor: feedMsgsListMsg.nextCursor
|
|
9858
|
+
});
|
|
9859
|
+
pendingFeedMessagesRequests.delete(feedMsgsListMsg.requestId);
|
|
9860
|
+
}
|
|
9861
|
+
eventHub.feeds.notify(feedMsgsListMsg);
|
|
9862
|
+
break;
|
|
9863
|
+
}
|
|
9864
|
+
case ServerMsgCode.FEED_MESSAGES_ADDED: {
|
|
9865
|
+
const feedMsgsAddedMsg = message;
|
|
9866
|
+
eventHub.feeds.notify(feedMsgsAddedMsg);
|
|
9867
|
+
tryResolvePendingFeedMutationsFromFeedsEvent(feedMsgsAddedMsg);
|
|
9868
|
+
break;
|
|
9869
|
+
}
|
|
9870
|
+
case ServerMsgCode.FEED_MESSAGES_UPDATED: {
|
|
9871
|
+
const feedMsgsUpdatedMsg = message;
|
|
9872
|
+
eventHub.feeds.notify(feedMsgsUpdatedMsg);
|
|
9873
|
+
tryResolvePendingFeedMutationsFromFeedsEvent(feedMsgsUpdatedMsg);
|
|
9874
|
+
break;
|
|
9875
|
+
}
|
|
9876
|
+
case ServerMsgCode.FEED_MESSAGES_DELETED: {
|
|
9877
|
+
eventHub.feeds.notify(message);
|
|
9878
|
+
tryResolvePendingFeedMutationsFromFeedsEvent(message);
|
|
9879
|
+
break;
|
|
9880
|
+
}
|
|
9881
|
+
case ServerMsgCode.FEED_REQUEST_FAILED: {
|
|
9882
|
+
if (!isFeedRequestFailedMsg(message)) {
|
|
9883
|
+
break;
|
|
9884
|
+
}
|
|
9885
|
+
const { requestId, code, reason } = message;
|
|
9886
|
+
const err = new LiveblocksError(_nullishCoalesce(reason, () => ( "Feed request failed")), {
|
|
9887
|
+
type: "FEED_REQUEST_ERROR",
|
|
9888
|
+
roomId,
|
|
9889
|
+
requestId,
|
|
9890
|
+
code,
|
|
9891
|
+
reason
|
|
9892
|
+
});
|
|
9893
|
+
if (pendingFeedMutations.has(requestId)) {
|
|
9894
|
+
settleFeedMutation(requestId, "error", err);
|
|
9895
|
+
} else if (pendingFeedsRequests.has(requestId)) {
|
|
9896
|
+
const pending = pendingFeedsRequests.get(requestId);
|
|
9897
|
+
pendingFeedsRequests.delete(requestId);
|
|
9898
|
+
_optionalChain([pending, 'optionalAccess', _219 => _219.reject, 'call', _220 => _220(err)]);
|
|
9899
|
+
} else if (pendingFeedMessagesRequests.has(requestId)) {
|
|
9900
|
+
const pending = pendingFeedMessagesRequests.get(requestId);
|
|
9901
|
+
pendingFeedMessagesRequests.delete(requestId);
|
|
9902
|
+
_optionalChain([pending, 'optionalAccess', _221 => _221.reject, 'call', _222 => _222(err)]);
|
|
9903
|
+
}
|
|
9904
|
+
eventHub.feeds.notify(message);
|
|
9905
|
+
break;
|
|
9906
|
+
}
|
|
10299
9907
|
case ServerMsgCode.STORAGE_STATE_V7:
|
|
10300
9908
|
// No longer used in V8
|
|
10301
9909
|
default:
|
|
@@ -10399,11 +10007,146 @@ function createRoom(options, config) {
|
|
|
10399
10007
|
}
|
|
10400
10008
|
let _getStorage$ = null;
|
|
10401
10009
|
let _resolveStoragePromise = null;
|
|
10010
|
+
const pendingFeedsRequests = /* @__PURE__ */ new Map();
|
|
10011
|
+
const pendingFeedMessagesRequests = /* @__PURE__ */ new Map();
|
|
10012
|
+
const pendingFeedMutations = /* @__PURE__ */ new Map();
|
|
10013
|
+
const pendingAddMessageFifoByFeed = /* @__PURE__ */ new Map();
|
|
10014
|
+
function settleFeedMutation(requestId, outcome, error3) {
|
|
10015
|
+
const pending = pendingFeedMutations.get(requestId);
|
|
10016
|
+
if (pending === void 0) {
|
|
10017
|
+
return;
|
|
10018
|
+
}
|
|
10019
|
+
clearTimeout(pending.timeoutId);
|
|
10020
|
+
pendingFeedMutations.delete(requestId);
|
|
10021
|
+
if (pending.kind === "add-message" && !pending.expectedClientMessageId) {
|
|
10022
|
+
const q = pendingAddMessageFifoByFeed.get(pending.feedId);
|
|
10023
|
+
if (q !== void 0) {
|
|
10024
|
+
const idx = q.indexOf(requestId);
|
|
10025
|
+
if (idx >= 0) {
|
|
10026
|
+
q.splice(idx, 1);
|
|
10027
|
+
}
|
|
10028
|
+
if (q.length === 0) {
|
|
10029
|
+
pendingAddMessageFifoByFeed.delete(pending.feedId);
|
|
10030
|
+
}
|
|
10031
|
+
}
|
|
10032
|
+
}
|
|
10033
|
+
if (outcome === "ok") {
|
|
10034
|
+
pending.resolve();
|
|
10035
|
+
} else {
|
|
10036
|
+
pending.reject(_nullishCoalesce(error3, () => ( new Error("Feed mutation failed"))));
|
|
10037
|
+
}
|
|
10038
|
+
}
|
|
10039
|
+
function registerFeedMutation(requestId, kind, feedId, options2) {
|
|
10040
|
+
const { promise, resolve, reject } = Promise_withResolvers();
|
|
10041
|
+
const timeoutId = setTimeout(() => {
|
|
10042
|
+
if (pendingFeedMutations.has(requestId)) {
|
|
10043
|
+
settleFeedMutation(
|
|
10044
|
+
requestId,
|
|
10045
|
+
"error",
|
|
10046
|
+
new Error("Feed mutation timeout")
|
|
10047
|
+
);
|
|
10048
|
+
}
|
|
10049
|
+
}, FEEDS_TIMEOUT);
|
|
10050
|
+
pendingFeedMutations.set(requestId, {
|
|
10051
|
+
resolve,
|
|
10052
|
+
reject,
|
|
10053
|
+
timeoutId,
|
|
10054
|
+
kind,
|
|
10055
|
+
feedId,
|
|
10056
|
+
messageId: _optionalChain([options2, 'optionalAccess', _223 => _223.messageId]),
|
|
10057
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _224 => _224.expectedClientMessageId])
|
|
10058
|
+
});
|
|
10059
|
+
if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _225 => _225.expectedClientMessageId]) === void 0) {
|
|
10060
|
+
const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
|
|
10061
|
+
q.push(requestId);
|
|
10062
|
+
pendingAddMessageFifoByFeed.set(feedId, q);
|
|
10063
|
+
}
|
|
10064
|
+
return promise;
|
|
10065
|
+
}
|
|
10066
|
+
function tryResolvePendingFeedMutationsFromFeedsEvent(message) {
|
|
10067
|
+
switch (message.type) {
|
|
10068
|
+
case ServerMsgCode.FEEDS_ADDED: {
|
|
10069
|
+
for (const feed of message.feeds) {
|
|
10070
|
+
for (const [requestId, pending] of [...pendingFeedMutations]) {
|
|
10071
|
+
if (pending.kind === "add-feed" && pending.feedId === feed.feedId) {
|
|
10072
|
+
settleFeedMutation(requestId, "ok");
|
|
10073
|
+
break;
|
|
10074
|
+
}
|
|
10075
|
+
}
|
|
10076
|
+
}
|
|
10077
|
+
break;
|
|
10078
|
+
}
|
|
10079
|
+
case ServerMsgCode.FEEDS_UPDATED: {
|
|
10080
|
+
for (const feed of message.feeds) {
|
|
10081
|
+
for (const [requestId, pending] of [...pendingFeedMutations]) {
|
|
10082
|
+
if (pending.kind === "update-feed" && pending.feedId === feed.feedId) {
|
|
10083
|
+
settleFeedMutation(requestId, "ok");
|
|
10084
|
+
}
|
|
10085
|
+
}
|
|
10086
|
+
}
|
|
10087
|
+
break;
|
|
10088
|
+
}
|
|
10089
|
+
case ServerMsgCode.FEED_DELETED: {
|
|
10090
|
+
for (const [requestId, pending] of [...pendingFeedMutations]) {
|
|
10091
|
+
if (pending.kind === "delete-feed" && pending.feedId === message.feedId) {
|
|
10092
|
+
settleFeedMutation(requestId, "ok");
|
|
10093
|
+
break;
|
|
10094
|
+
}
|
|
10095
|
+
}
|
|
10096
|
+
break;
|
|
10097
|
+
}
|
|
10098
|
+
case ServerMsgCode.FEED_MESSAGES_ADDED: {
|
|
10099
|
+
for (const m of message.messages) {
|
|
10100
|
+
let matched = false;
|
|
10101
|
+
for (const [requestId, pending] of [...pendingFeedMutations]) {
|
|
10102
|
+
if (pending.kind === "add-message" && pending.feedId === message.feedId && pending.expectedClientMessageId === m.id) {
|
|
10103
|
+
settleFeedMutation(requestId, "ok");
|
|
10104
|
+
matched = true;
|
|
10105
|
+
break;
|
|
10106
|
+
}
|
|
10107
|
+
}
|
|
10108
|
+
if (!matched) {
|
|
10109
|
+
const q = pendingAddMessageFifoByFeed.get(message.feedId);
|
|
10110
|
+
const headId = _optionalChain([q, 'optionalAccess', _226 => _226[0]]);
|
|
10111
|
+
if (headId !== void 0) {
|
|
10112
|
+
const pending = pendingFeedMutations.get(headId);
|
|
10113
|
+
if (_optionalChain([pending, 'optionalAccess', _227 => _227.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
|
|
10114
|
+
settleFeedMutation(headId, "ok");
|
|
10115
|
+
}
|
|
10116
|
+
}
|
|
10117
|
+
}
|
|
10118
|
+
}
|
|
10119
|
+
break;
|
|
10120
|
+
}
|
|
10121
|
+
case ServerMsgCode.FEED_MESSAGES_UPDATED: {
|
|
10122
|
+
for (const m of message.messages) {
|
|
10123
|
+
for (const [requestId, pending] of [...pendingFeedMutations]) {
|
|
10124
|
+
if (pending.kind === "update-message" && pending.feedId === message.feedId && pending.messageId === m.id) {
|
|
10125
|
+
settleFeedMutation(requestId, "ok");
|
|
10126
|
+
}
|
|
10127
|
+
}
|
|
10128
|
+
}
|
|
10129
|
+
break;
|
|
10130
|
+
}
|
|
10131
|
+
case ServerMsgCode.FEED_MESSAGES_DELETED: {
|
|
10132
|
+
for (const mid of message.messageIds) {
|
|
10133
|
+
for (const [requestId, pending] of [...pendingFeedMutations]) {
|
|
10134
|
+
if (pending.kind === "delete-message" && pending.feedId === message.feedId && pending.messageId === mid) {
|
|
10135
|
+
settleFeedMutation(requestId, "ok");
|
|
10136
|
+
}
|
|
10137
|
+
}
|
|
10138
|
+
}
|
|
10139
|
+
break;
|
|
10140
|
+
}
|
|
10141
|
+
default:
|
|
10142
|
+
break;
|
|
10143
|
+
}
|
|
10144
|
+
}
|
|
10402
10145
|
function processInitialStorage(nodes) {
|
|
10403
10146
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
10404
10147
|
createOrUpdateRootFromMessage(nodes);
|
|
10405
10148
|
applyAndSendOfflineOps(unacknowledgedOps);
|
|
10406
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
10149
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _228 => _228()]);
|
|
10407
10150
|
notifyStorageStatus();
|
|
10408
10151
|
eventHub.storageDidLoad.notify();
|
|
10409
10152
|
}
|
|
@@ -10421,7 +10164,7 @@ function createRoom(options, config) {
|
|
|
10421
10164
|
} else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
|
|
10422
10165
|
messages.push({ type: ClientMsgCode.FETCH_STORAGE });
|
|
10423
10166
|
nodeMapBuffer.take();
|
|
10424
|
-
_optionalChain([stopwatch, 'optionalAccess',
|
|
10167
|
+
_optionalChain([stopwatch, 'optionalAccess', _229 => _229.start, 'call', _230 => _230()]);
|
|
10425
10168
|
}
|
|
10426
10169
|
if (options2.flush) {
|
|
10427
10170
|
flushNowOrSoon();
|
|
@@ -10446,29 +10189,161 @@ function createRoom(options, config) {
|
|
|
10446
10189
|
return null;
|
|
10447
10190
|
}
|
|
10448
10191
|
}
|
|
10449
|
-
async function getStorage() {
|
|
10450
|
-
if (context.root !== void 0) {
|
|
10451
|
-
return Promise.resolve({
|
|
10452
|
-
root: context.root
|
|
10453
|
-
});
|
|
10454
|
-
}
|
|
10455
|
-
await startLoadingStorage();
|
|
10456
|
-
return {
|
|
10457
|
-
root: nn(context.root)
|
|
10192
|
+
async function getStorage() {
|
|
10193
|
+
if (context.root !== void 0) {
|
|
10194
|
+
return Promise.resolve({
|
|
10195
|
+
root: context.root
|
|
10196
|
+
});
|
|
10197
|
+
}
|
|
10198
|
+
await startLoadingStorage();
|
|
10199
|
+
return {
|
|
10200
|
+
root: nn(context.root)
|
|
10201
|
+
};
|
|
10202
|
+
}
|
|
10203
|
+
function fetchYDoc(vector, guid, isV2) {
|
|
10204
|
+
if (!context.buffer.messages.find((m) => {
|
|
10205
|
+
return m.type === ClientMsgCode.FETCH_YDOC && m.vector === vector && m.guid === guid && m.v2 === isV2;
|
|
10206
|
+
})) {
|
|
10207
|
+
context.buffer.messages.push({
|
|
10208
|
+
type: ClientMsgCode.FETCH_YDOC,
|
|
10209
|
+
vector,
|
|
10210
|
+
guid,
|
|
10211
|
+
v2: isV2
|
|
10212
|
+
});
|
|
10213
|
+
}
|
|
10214
|
+
flushNowOrSoon();
|
|
10215
|
+
}
|
|
10216
|
+
async function fetchFeeds(options2) {
|
|
10217
|
+
const requestId = nanoid();
|
|
10218
|
+
const { promise, resolve, reject } = Promise_withResolvers();
|
|
10219
|
+
pendingFeedsRequests.set(requestId, { resolve, reject });
|
|
10220
|
+
const message = {
|
|
10221
|
+
type: ClientMsgCode.FETCH_FEEDS,
|
|
10222
|
+
requestId,
|
|
10223
|
+
cursor: _optionalChain([options2, 'optionalAccess', _231 => _231.cursor]),
|
|
10224
|
+
since: _optionalChain([options2, 'optionalAccess', _232 => _232.since]),
|
|
10225
|
+
limit: _optionalChain([options2, 'optionalAccess', _233 => _233.limit]),
|
|
10226
|
+
metadata: _optionalChain([options2, 'optionalAccess', _234 => _234.metadata])
|
|
10227
|
+
};
|
|
10228
|
+
context.buffer.messages.push(message);
|
|
10229
|
+
flushNowOrSoon();
|
|
10230
|
+
setTimeout(() => {
|
|
10231
|
+
if (pendingFeedsRequests.has(requestId)) {
|
|
10232
|
+
pendingFeedsRequests.delete(requestId);
|
|
10233
|
+
reject(new Error("Feeds fetch timeout"));
|
|
10234
|
+
}
|
|
10235
|
+
}, FEEDS_TIMEOUT);
|
|
10236
|
+
return promise;
|
|
10237
|
+
}
|
|
10238
|
+
async function fetchFeedMessages(feedId, options2) {
|
|
10239
|
+
const requestId = nanoid();
|
|
10240
|
+
const { promise, resolve, reject } = Promise_withResolvers();
|
|
10241
|
+
pendingFeedMessagesRequests.set(requestId, { resolve, reject });
|
|
10242
|
+
const message = {
|
|
10243
|
+
type: ClientMsgCode.FETCH_FEED_MESSAGES,
|
|
10244
|
+
requestId,
|
|
10245
|
+
feedId,
|
|
10246
|
+
cursor: _optionalChain([options2, 'optionalAccess', _235 => _235.cursor]),
|
|
10247
|
+
since: _optionalChain([options2, 'optionalAccess', _236 => _236.since]),
|
|
10248
|
+
limit: _optionalChain([options2, 'optionalAccess', _237 => _237.limit])
|
|
10249
|
+
};
|
|
10250
|
+
context.buffer.messages.push(message);
|
|
10251
|
+
flushNowOrSoon();
|
|
10252
|
+
setTimeout(() => {
|
|
10253
|
+
if (pendingFeedMessagesRequests.has(requestId)) {
|
|
10254
|
+
pendingFeedMessagesRequests.delete(requestId);
|
|
10255
|
+
reject(new Error("Feed messages fetch timeout"));
|
|
10256
|
+
}
|
|
10257
|
+
}, FEEDS_TIMEOUT);
|
|
10258
|
+
return promise;
|
|
10259
|
+
}
|
|
10260
|
+
function addFeed(feedId, options2) {
|
|
10261
|
+
const requestId = nanoid();
|
|
10262
|
+
const promise = registerFeedMutation(requestId, "add-feed", feedId);
|
|
10263
|
+
const message = {
|
|
10264
|
+
type: ClientMsgCode.ADD_FEED,
|
|
10265
|
+
requestId,
|
|
10266
|
+
feedId,
|
|
10267
|
+
metadata: _optionalChain([options2, 'optionalAccess', _238 => _238.metadata]),
|
|
10268
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _239 => _239.createdAt])
|
|
10269
|
+
};
|
|
10270
|
+
context.buffer.messages.push(message);
|
|
10271
|
+
flushNowOrSoon();
|
|
10272
|
+
return promise;
|
|
10273
|
+
}
|
|
10274
|
+
function updateFeed(feedId, metadata) {
|
|
10275
|
+
const requestId = nanoid();
|
|
10276
|
+
const promise = registerFeedMutation(requestId, "update-feed", feedId);
|
|
10277
|
+
const message = {
|
|
10278
|
+
type: ClientMsgCode.UPDATE_FEED,
|
|
10279
|
+
requestId,
|
|
10280
|
+
feedId,
|
|
10281
|
+
metadata
|
|
10282
|
+
};
|
|
10283
|
+
context.buffer.messages.push(message);
|
|
10284
|
+
flushNowOrSoon();
|
|
10285
|
+
return promise;
|
|
10286
|
+
}
|
|
10287
|
+
function deleteFeed(feedId) {
|
|
10288
|
+
const requestId = nanoid();
|
|
10289
|
+
const promise = registerFeedMutation(requestId, "delete-feed", feedId);
|
|
10290
|
+
const message = {
|
|
10291
|
+
type: ClientMsgCode.DELETE_FEED,
|
|
10292
|
+
requestId,
|
|
10293
|
+
feedId
|
|
10294
|
+
};
|
|
10295
|
+
context.buffer.messages.push(message);
|
|
10296
|
+
flushNowOrSoon();
|
|
10297
|
+
return promise;
|
|
10298
|
+
}
|
|
10299
|
+
function addFeedMessage(feedId, data, options2) {
|
|
10300
|
+
const requestId = nanoid();
|
|
10301
|
+
const promise = registerFeedMutation(requestId, "add-message", feedId, {
|
|
10302
|
+
expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _240 => _240.id])
|
|
10303
|
+
});
|
|
10304
|
+
const message = {
|
|
10305
|
+
type: ClientMsgCode.ADD_FEED_MESSAGE,
|
|
10306
|
+
requestId,
|
|
10307
|
+
feedId,
|
|
10308
|
+
data,
|
|
10309
|
+
id: _optionalChain([options2, 'optionalAccess', _241 => _241.id]),
|
|
10310
|
+
createdAt: _optionalChain([options2, 'optionalAccess', _242 => _242.createdAt])
|
|
10311
|
+
};
|
|
10312
|
+
context.buffer.messages.push(message);
|
|
10313
|
+
flushNowOrSoon();
|
|
10314
|
+
return promise;
|
|
10315
|
+
}
|
|
10316
|
+
function updateFeedMessage(feedId, messageId, data, options2) {
|
|
10317
|
+
const requestId = nanoid();
|
|
10318
|
+
const promise = registerFeedMutation(requestId, "update-message", feedId, {
|
|
10319
|
+
messageId
|
|
10320
|
+
});
|
|
10321
|
+
const message = {
|
|
10322
|
+
type: ClientMsgCode.UPDATE_FEED_MESSAGE,
|
|
10323
|
+
requestId,
|
|
10324
|
+
feedId,
|
|
10325
|
+
messageId,
|
|
10326
|
+
data,
|
|
10327
|
+
updatedAt: _optionalChain([options2, 'optionalAccess', _243 => _243.updatedAt])
|
|
10458
10328
|
};
|
|
10329
|
+
context.buffer.messages.push(message);
|
|
10330
|
+
flushNowOrSoon();
|
|
10331
|
+
return promise;
|
|
10459
10332
|
}
|
|
10460
|
-
function
|
|
10461
|
-
|
|
10462
|
-
|
|
10463
|
-
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
}
|
|
10333
|
+
function deleteFeedMessage(feedId, messageId) {
|
|
10334
|
+
const requestId = nanoid();
|
|
10335
|
+
const promise = registerFeedMutation(requestId, "delete-message", feedId, {
|
|
10336
|
+
messageId
|
|
10337
|
+
});
|
|
10338
|
+
const message = {
|
|
10339
|
+
type: ClientMsgCode.DELETE_FEED_MESSAGE,
|
|
10340
|
+
requestId,
|
|
10341
|
+
feedId,
|
|
10342
|
+
messageId
|
|
10343
|
+
};
|
|
10344
|
+
context.buffer.messages.push(message);
|
|
10471
10345
|
flushNowOrSoon();
|
|
10346
|
+
return promise;
|
|
10472
10347
|
}
|
|
10473
10348
|
function undo() {
|
|
10474
10349
|
if (context.activeBatch) {
|
|
@@ -10555,16 +10430,6 @@ function createRoom(options, config) {
|
|
|
10555
10430
|
_addToRealUndoStack(Array.from(frames));
|
|
10556
10431
|
}
|
|
10557
10432
|
}
|
|
10558
|
-
function withoutHistory(fn) {
|
|
10559
|
-
const undoBefore = context.undoStack.length;
|
|
10560
|
-
const redoBefore = context.redoStack.length;
|
|
10561
|
-
try {
|
|
10562
|
-
return fn();
|
|
10563
|
-
} finally {
|
|
10564
|
-
context.undoStack.length = undoBefore;
|
|
10565
|
-
context.redoStack.length = redoBefore;
|
|
10566
|
-
}
|
|
10567
|
-
}
|
|
10568
10433
|
const syncSourceForStorage = config.createSyncSource();
|
|
10569
10434
|
function getStorageStatus() {
|
|
10570
10435
|
if (context.root === void 0) {
|
|
@@ -10622,6 +10487,7 @@ function createRoom(options, config) {
|
|
|
10622
10487
|
storageStatus: eventHub.storageStatus.observable,
|
|
10623
10488
|
ydoc: eventHub.ydoc.observable,
|
|
10624
10489
|
comments: eventHub.comments.observable,
|
|
10490
|
+
feeds: eventHub.feeds.observable,
|
|
10625
10491
|
roomWillDestroy: eventHub.roomWillDestroy.observable
|
|
10626
10492
|
};
|
|
10627
10493
|
async function getThreadsSince(options2) {
|
|
@@ -10634,8 +10500,8 @@ function createRoom(options, config) {
|
|
|
10634
10500
|
async function getThreads(options2) {
|
|
10635
10501
|
return httpClient.getThreads({
|
|
10636
10502
|
roomId,
|
|
10637
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
10638
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
10503
|
+
query: _optionalChain([options2, 'optionalAccess', _244 => _244.query]),
|
|
10504
|
+
cursor: _optionalChain([options2, 'optionalAccess', _245 => _245.cursor])
|
|
10639
10505
|
});
|
|
10640
10506
|
}
|
|
10641
10507
|
async function getThread(threadId) {
|
|
@@ -10757,7 +10623,7 @@ function createRoom(options, config) {
|
|
|
10757
10623
|
function getSubscriptionSettings(options2) {
|
|
10758
10624
|
return httpClient.getSubscriptionSettings({
|
|
10759
10625
|
roomId,
|
|
10760
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
10626
|
+
signal: _optionalChain([options2, 'optionalAccess', _246 => _246.signal])
|
|
10761
10627
|
});
|
|
10762
10628
|
}
|
|
10763
10629
|
function updateSubscriptionSettings(settings) {
|
|
@@ -10779,7 +10645,7 @@ function createRoom(options, config) {
|
|
|
10779
10645
|
{
|
|
10780
10646
|
[kInternal]: {
|
|
10781
10647
|
get presenceBuffer() {
|
|
10782
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
10648
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _247 => _247.buffer, 'access', _248 => _248.presenceUpdates, 'optionalAccess', _249 => _249.data]), () => ( null)));
|
|
10783
10649
|
},
|
|
10784
10650
|
// prettier-ignore
|
|
10785
10651
|
get undoStack() {
|
|
@@ -10794,9 +10660,9 @@ function createRoom(options, config) {
|
|
|
10794
10660
|
return context.yjsProvider;
|
|
10795
10661
|
},
|
|
10796
10662
|
setYjsProvider(newProvider) {
|
|
10797
|
-
_optionalChain([context, 'access',
|
|
10663
|
+
_optionalChain([context, 'access', _250 => _250.yjsProvider, 'optionalAccess', _251 => _251.off, 'call', _252 => _252("status", yjsStatusDidChange)]);
|
|
10798
10664
|
context.yjsProvider = newProvider;
|
|
10799
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
10665
|
+
_optionalChain([newProvider, 'optionalAccess', _253 => _253.on, 'call', _254 => _254("status", yjsStatusDidChange)]);
|
|
10800
10666
|
context.yjsProviderDidChange.notify();
|
|
10801
10667
|
},
|
|
10802
10668
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -10831,19 +10697,25 @@ function createRoom(options, config) {
|
|
|
10831
10697
|
id: roomId,
|
|
10832
10698
|
subscribe: makeClassicSubscribeFn(
|
|
10833
10699
|
roomId,
|
|
10834
|
-
|
|
10700
|
+
eventHub,
|
|
10835
10701
|
config.errorEventSource
|
|
10836
10702
|
),
|
|
10837
10703
|
connect: () => managedSocket.connect(),
|
|
10838
10704
|
reconnect: () => managedSocket.reconnect(),
|
|
10839
10705
|
disconnect: () => managedSocket.disconnect(),
|
|
10840
10706
|
destroy: () => {
|
|
10707
|
+
pendingFeedsRequests.forEach(
|
|
10708
|
+
(request) => request.reject(new Error("Room destroyed"))
|
|
10709
|
+
);
|
|
10710
|
+
pendingFeedMessagesRequests.forEach(
|
|
10711
|
+
(request) => request.reject(new Error("Room destroyed"))
|
|
10712
|
+
);
|
|
10841
10713
|
const { roomWillDestroy, ...eventsExceptDestroy } = eventHub;
|
|
10842
10714
|
for (const source of Object.values(eventsExceptDestroy)) {
|
|
10843
10715
|
source.dispose();
|
|
10844
10716
|
}
|
|
10845
10717
|
eventHub.roomWillDestroy.notify();
|
|
10846
|
-
_optionalChain([context, 'access',
|
|
10718
|
+
_optionalChain([context, 'access', _255 => _255.yjsProvider, 'optionalAccess', _256 => _256.off, 'call', _257 => _257("status", yjsStatusDidChange)]);
|
|
10847
10719
|
syncSourceForStorage.destroy();
|
|
10848
10720
|
syncSourceForYjs.destroy();
|
|
10849
10721
|
uninstallBgTabSpy();
|
|
@@ -10863,12 +10735,17 @@ function createRoom(options, config) {
|
|
|
10863
10735
|
canRedo,
|
|
10864
10736
|
clear,
|
|
10865
10737
|
pause: pauseHistory,
|
|
10866
|
-
resume: resumeHistory
|
|
10867
|
-
[kInternal]: {
|
|
10868
|
-
withoutHistory
|
|
10869
|
-
}
|
|
10738
|
+
resume: resumeHistory
|
|
10870
10739
|
},
|
|
10871
10740
|
fetchYDoc,
|
|
10741
|
+
fetchFeeds,
|
|
10742
|
+
fetchFeedMessages,
|
|
10743
|
+
addFeed,
|
|
10744
|
+
updateFeed,
|
|
10745
|
+
deleteFeed,
|
|
10746
|
+
addFeedMessage,
|
|
10747
|
+
updateFeedMessage,
|
|
10748
|
+
deleteFeedMessage,
|
|
10872
10749
|
getStorage,
|
|
10873
10750
|
getStorageSnapshot,
|
|
10874
10751
|
getStorageStatus,
|
|
@@ -10997,7 +10874,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
10997
10874
|
}
|
|
10998
10875
|
if (isLiveNode(first)) {
|
|
10999
10876
|
const node = first;
|
|
11000
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
10877
|
+
if (_optionalChain([options, 'optionalAccess', _258 => _258.isDeep])) {
|
|
11001
10878
|
const storageCallback = second;
|
|
11002
10879
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
11003
10880
|
} else {
|
|
@@ -11083,8 +10960,8 @@ function createClient(options) {
|
|
|
11083
10960
|
const authManager = createAuthManager(options, (token) => {
|
|
11084
10961
|
currentUserId.set(() => token.uid);
|
|
11085
10962
|
});
|
|
11086
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
11087
|
-
_optionalChain([globalThis, 'access',
|
|
10963
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _259 => _259.polyfills, 'optionalAccess', _260 => _260.fetch]) || /* istanbul ignore next */
|
|
10964
|
+
_optionalChain([globalThis, 'access', _261 => _261.fetch, 'optionalAccess', _262 => _262.bind, 'call', _263 => _263(globalThis)]);
|
|
11088
10965
|
const httpClient = createApiClient({
|
|
11089
10966
|
baseUrl,
|
|
11090
10967
|
fetchPolyfill,
|
|
@@ -11102,7 +10979,7 @@ function createClient(options) {
|
|
|
11102
10979
|
delegates: {
|
|
11103
10980
|
createSocket: makeCreateSocketDelegateForAi(
|
|
11104
10981
|
baseUrl,
|
|
11105
|
-
_optionalChain([clientOptions, 'access',
|
|
10982
|
+
_optionalChain([clientOptions, 'access', _264 => _264.polyfills, 'optionalAccess', _265 => _265.WebSocket])
|
|
11106
10983
|
),
|
|
11107
10984
|
authenticate: async () => {
|
|
11108
10985
|
const resp = await authManager.getAuthValue({
|
|
@@ -11162,7 +11039,7 @@ function createClient(options) {
|
|
|
11162
11039
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
11163
11040
|
roomId,
|
|
11164
11041
|
baseUrl,
|
|
11165
|
-
_optionalChain([clientOptions, 'access',
|
|
11042
|
+
_optionalChain([clientOptions, 'access', _266 => _266.polyfills, 'optionalAccess', _267 => _267.WebSocket])
|
|
11166
11043
|
),
|
|
11167
11044
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
11168
11045
|
})),
|
|
@@ -11185,7 +11062,7 @@ function createClient(options) {
|
|
|
11185
11062
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
11186
11063
|
if (shouldConnect) {
|
|
11187
11064
|
if (typeof atob === "undefined") {
|
|
11188
|
-
if (_optionalChain([clientOptions, 'access',
|
|
11065
|
+
if (_optionalChain([clientOptions, 'access', _268 => _268.polyfills, 'optionalAccess', _269 => _269.atob]) === void 0) {
|
|
11189
11066
|
throw new Error(
|
|
11190
11067
|
"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"
|
|
11191
11068
|
);
|
|
@@ -11197,7 +11074,7 @@ function createClient(options) {
|
|
|
11197
11074
|
return leaseRoom(newRoomDetails);
|
|
11198
11075
|
}
|
|
11199
11076
|
function getRoom(roomId) {
|
|
11200
|
-
const room = _optionalChain([roomsById, 'access',
|
|
11077
|
+
const room = _optionalChain([roomsById, 'access', _270 => _270.get, 'call', _271 => _271(roomId), 'optionalAccess', _272 => _272.room]);
|
|
11201
11078
|
return room ? room : null;
|
|
11202
11079
|
}
|
|
11203
11080
|
function logout() {
|
|
@@ -11213,7 +11090,7 @@ function createClient(options) {
|
|
|
11213
11090
|
const batchedResolveUsers = new Batch(
|
|
11214
11091
|
async (batchedUserIds) => {
|
|
11215
11092
|
const userIds = batchedUserIds.flat();
|
|
11216
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
11093
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _273 => _273({ userIds })]);
|
|
11217
11094
|
warnOnceIf(
|
|
11218
11095
|
!resolveUsers,
|
|
11219
11096
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -11230,7 +11107,7 @@ function createClient(options) {
|
|
|
11230
11107
|
const batchedResolveRoomsInfo = new Batch(
|
|
11231
11108
|
async (batchedRoomIds) => {
|
|
11232
11109
|
const roomIds = batchedRoomIds.flat();
|
|
11233
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
11110
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _274 => _274({ roomIds })]);
|
|
11234
11111
|
warnOnceIf(
|
|
11235
11112
|
!resolveRoomsInfo,
|
|
11236
11113
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -11247,7 +11124,7 @@ function createClient(options) {
|
|
|
11247
11124
|
const batchedResolveGroupsInfo = new Batch(
|
|
11248
11125
|
async (batchedGroupIds) => {
|
|
11249
11126
|
const groupIds = batchedGroupIds.flat();
|
|
11250
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
11127
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _275 => _275({ groupIds })]);
|
|
11251
11128
|
warnOnceIf(
|
|
11252
11129
|
!resolveGroupsInfo,
|
|
11253
11130
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -11303,7 +11180,7 @@ function createClient(options) {
|
|
|
11303
11180
|
}
|
|
11304
11181
|
};
|
|
11305
11182
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
11306
|
-
_optionalChain([win, 'optionalAccess',
|
|
11183
|
+
_optionalChain([win, 'optionalAccess', _276 => _276.addEventListener, 'call', _277 => _277("beforeunload", maybePreventClose)]);
|
|
11307
11184
|
}
|
|
11308
11185
|
async function getNotificationSettings(options2) {
|
|
11309
11186
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -11430,7 +11307,7 @@ var commentBodyElementsTypes = {
|
|
|
11430
11307
|
mention: "inline"
|
|
11431
11308
|
};
|
|
11432
11309
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
11433
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
11310
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _278 => _278.content])) {
|
|
11434
11311
|
return;
|
|
11435
11312
|
}
|
|
11436
11313
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -11440,13 +11317,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
11440
11317
|
for (const block of body.content) {
|
|
11441
11318
|
if (type === "all" || type === "block") {
|
|
11442
11319
|
if (guard(block)) {
|
|
11443
|
-
_optionalChain([visitor, 'optionalCall',
|
|
11320
|
+
_optionalChain([visitor, 'optionalCall', _279 => _279(block)]);
|
|
11444
11321
|
}
|
|
11445
11322
|
}
|
|
11446
11323
|
if (type === "all" || type === "inline") {
|
|
11447
11324
|
for (const inline of block.children) {
|
|
11448
11325
|
if (guard(inline)) {
|
|
11449
|
-
_optionalChain([visitor, 'optionalCall',
|
|
11326
|
+
_optionalChain([visitor, 'optionalCall', _280 => _280(inline)]);
|
|
11450
11327
|
}
|
|
11451
11328
|
}
|
|
11452
11329
|
}
|
|
@@ -11616,7 +11493,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
11616
11493
|
text: ({ element }) => element.text,
|
|
11617
11494
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
11618
11495
|
mention: ({ element, user, group }) => {
|
|
11619
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
11496
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _281 => _281.name]), () => ( _optionalChain([group, 'optionalAccess', _282 => _282.name]))), () => ( element.id))}`;
|
|
11620
11497
|
}
|
|
11621
11498
|
};
|
|
11622
11499
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -11646,7 +11523,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
11646
11523
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
11647
11524
|
},
|
|
11648
11525
|
mention: ({ element, user, group }) => {
|
|
11649
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
11526
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _283 => _283.name]) ? html`${_optionalChain([user, 'optionalAccess', _284 => _284.name])}` : _optionalChain([group, 'optionalAccess', _285 => _285.name]) ? html`${_optionalChain([group, 'optionalAccess', _286 => _286.name])}` : element.id}</span>`;
|
|
11650
11527
|
}
|
|
11651
11528
|
};
|
|
11652
11529
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -11658,121 +11535,424 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
11658
11535
|
if (!children) {
|
|
11659
11536
|
return children;
|
|
11660
11537
|
}
|
|
11661
|
-
if (element.bold) {
|
|
11662
|
-
children = markdown`**${children}**`;
|
|
11538
|
+
if (element.bold) {
|
|
11539
|
+
children = markdown`**${children}**`;
|
|
11540
|
+
}
|
|
11541
|
+
if (element.italic) {
|
|
11542
|
+
children = markdown`_${children}_`;
|
|
11543
|
+
}
|
|
11544
|
+
if (element.strikethrough) {
|
|
11545
|
+
children = markdown`~~${children}~~`;
|
|
11546
|
+
}
|
|
11547
|
+
if (element.code) {
|
|
11548
|
+
children = markdown`\`${children}\``;
|
|
11549
|
+
}
|
|
11550
|
+
return children;
|
|
11551
|
+
},
|
|
11552
|
+
link: ({ element, href }) => {
|
|
11553
|
+
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
11554
|
+
},
|
|
11555
|
+
mention: ({ element, user, group }) => {
|
|
11556
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _287 => _287.name]), () => ( _optionalChain([group, 'optionalAccess', _288 => _288.name]))), () => ( element.id))}`;
|
|
11557
|
+
}
|
|
11558
|
+
};
|
|
11559
|
+
async function stringifyCommentBody(body, options) {
|
|
11560
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _289 => _289.format]), () => ( "plain"));
|
|
11561
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _290 => _290.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
11562
|
+
const elements = {
|
|
11563
|
+
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
11564
|
+
..._optionalChain([options, 'optionalAccess', _291 => _291.elements])
|
|
11565
|
+
};
|
|
11566
|
+
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
11567
|
+
body,
|
|
11568
|
+
_optionalChain([options, 'optionalAccess', _292 => _292.resolveUsers]),
|
|
11569
|
+
_optionalChain([options, 'optionalAccess', _293 => _293.resolveGroupsInfo])
|
|
11570
|
+
);
|
|
11571
|
+
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
11572
|
+
switch (block.type) {
|
|
11573
|
+
case "paragraph": {
|
|
11574
|
+
const inlines = block.children.flatMap((inline, inlineIndex) => {
|
|
11575
|
+
if (isCommentBodyMention(inline)) {
|
|
11576
|
+
return inline.id ? [
|
|
11577
|
+
elements.mention(
|
|
11578
|
+
{
|
|
11579
|
+
element: inline,
|
|
11580
|
+
user: inline.kind === "user" ? resolvedUsers.get(inline.id) : void 0,
|
|
11581
|
+
group: inline.kind === "group" ? resolvedGroupsInfo.get(inline.id) : void 0
|
|
11582
|
+
},
|
|
11583
|
+
inlineIndex
|
|
11584
|
+
)
|
|
11585
|
+
] : [];
|
|
11586
|
+
}
|
|
11587
|
+
if (isCommentBodyLink(inline)) {
|
|
11588
|
+
const href = sanitizeUrl(inline.url);
|
|
11589
|
+
if (href === null) {
|
|
11590
|
+
return [
|
|
11591
|
+
elements.text(
|
|
11592
|
+
{
|
|
11593
|
+
element: { text: _nullishCoalesce(inline.text, () => ( inline.url)) }
|
|
11594
|
+
},
|
|
11595
|
+
inlineIndex
|
|
11596
|
+
)
|
|
11597
|
+
];
|
|
11598
|
+
}
|
|
11599
|
+
return [
|
|
11600
|
+
elements.link(
|
|
11601
|
+
{
|
|
11602
|
+
element: inline,
|
|
11603
|
+
href
|
|
11604
|
+
},
|
|
11605
|
+
inlineIndex
|
|
11606
|
+
)
|
|
11607
|
+
];
|
|
11608
|
+
}
|
|
11609
|
+
if (isCommentBodyText(inline)) {
|
|
11610
|
+
return [elements.text({ element: inline }, inlineIndex)];
|
|
11611
|
+
}
|
|
11612
|
+
return [];
|
|
11613
|
+
});
|
|
11614
|
+
return [
|
|
11615
|
+
elements.paragraph(
|
|
11616
|
+
{ element: block, children: inlines.join("") },
|
|
11617
|
+
blockIndex
|
|
11618
|
+
)
|
|
11619
|
+
];
|
|
11620
|
+
}
|
|
11621
|
+
default:
|
|
11622
|
+
return [];
|
|
11623
|
+
}
|
|
11624
|
+
});
|
|
11625
|
+
return blocks.join(separator);
|
|
11626
|
+
}
|
|
11627
|
+
|
|
11628
|
+
// src/crdts/utils.ts
|
|
11629
|
+
function toPlainLson(lson) {
|
|
11630
|
+
if (lson instanceof LiveObject) {
|
|
11631
|
+
return {
|
|
11632
|
+
liveblocksType: "LiveObject",
|
|
11633
|
+
data: Object.fromEntries(
|
|
11634
|
+
Object.entries(lson.toObject()).flatMap(
|
|
11635
|
+
([key, value]) => value !== void 0 ? [[key, toPlainLson(value)]] : []
|
|
11636
|
+
)
|
|
11637
|
+
)
|
|
11638
|
+
};
|
|
11639
|
+
} else if (lson instanceof LiveMap) {
|
|
11640
|
+
return {
|
|
11641
|
+
liveblocksType: "LiveMap",
|
|
11642
|
+
data: Object.fromEntries(
|
|
11643
|
+
[...lson].map(([key, value]) => [key, toPlainLson(value)])
|
|
11644
|
+
)
|
|
11645
|
+
};
|
|
11646
|
+
} else if (lson instanceof LiveList) {
|
|
11647
|
+
return {
|
|
11648
|
+
liveblocksType: "LiveList",
|
|
11649
|
+
data: [...lson].map((item) => toPlainLson(item))
|
|
11650
|
+
};
|
|
11651
|
+
} else {
|
|
11652
|
+
return lson;
|
|
11653
|
+
}
|
|
11654
|
+
}
|
|
11655
|
+
|
|
11656
|
+
// src/immutable.ts
|
|
11657
|
+
function lsonObjectToJson(obj) {
|
|
11658
|
+
const result = {};
|
|
11659
|
+
for (const key in obj) {
|
|
11660
|
+
const val = obj[key];
|
|
11661
|
+
if (val !== void 0) {
|
|
11662
|
+
result[key] = lsonToJson(val);
|
|
11663
|
+
}
|
|
11664
|
+
}
|
|
11665
|
+
return result;
|
|
11666
|
+
}
|
|
11667
|
+
function liveObjectToJson(liveObject) {
|
|
11668
|
+
return lsonObjectToJson(liveObject.toObject());
|
|
11669
|
+
}
|
|
11670
|
+
function liveMapToJson(map) {
|
|
11671
|
+
const result = {};
|
|
11672
|
+
for (const [key, value] of map.entries()) {
|
|
11673
|
+
result[key] = lsonToJson(value);
|
|
11674
|
+
}
|
|
11675
|
+
return result;
|
|
11676
|
+
}
|
|
11677
|
+
function lsonListToJson(value) {
|
|
11678
|
+
return value.map(lsonToJson);
|
|
11679
|
+
}
|
|
11680
|
+
function liveListToJson(value) {
|
|
11681
|
+
return lsonListToJson(value.toArray());
|
|
11682
|
+
}
|
|
11683
|
+
function lsonToJson(value) {
|
|
11684
|
+
if (value instanceof LiveObject) {
|
|
11685
|
+
return liveObjectToJson(value);
|
|
11686
|
+
} else if (value instanceof LiveList) {
|
|
11687
|
+
return liveListToJson(value);
|
|
11688
|
+
} else if (value instanceof LiveMap) {
|
|
11689
|
+
return liveMapToJson(value);
|
|
11690
|
+
} else if (value instanceof LiveRegister) {
|
|
11691
|
+
return value.data;
|
|
11692
|
+
}
|
|
11693
|
+
if (Array.isArray(value)) {
|
|
11694
|
+
return lsonListToJson(value);
|
|
11695
|
+
} else if (isPlainObject(value)) {
|
|
11696
|
+
return lsonObjectToJson(value);
|
|
11697
|
+
}
|
|
11698
|
+
return value;
|
|
11699
|
+
}
|
|
11700
|
+
function deepLiveify(value) {
|
|
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) {
|
|
11718
|
+
let i = 0;
|
|
11719
|
+
let prevEnd = prev.length - 1;
|
|
11720
|
+
let nextEnd = next.length - 1;
|
|
11721
|
+
let prevNode = prev[0];
|
|
11722
|
+
let nextNode = next[0];
|
|
11723
|
+
outer: {
|
|
11724
|
+
while (prevNode === nextNode) {
|
|
11725
|
+
++i;
|
|
11726
|
+
if (i > prevEnd || i > nextEnd) {
|
|
11727
|
+
break outer;
|
|
11728
|
+
}
|
|
11729
|
+
prevNode = prev[i];
|
|
11730
|
+
nextNode = next[i];
|
|
11731
|
+
}
|
|
11732
|
+
prevNode = prev[prevEnd];
|
|
11733
|
+
nextNode = next[nextEnd];
|
|
11734
|
+
while (prevNode === nextNode) {
|
|
11735
|
+
prevEnd--;
|
|
11736
|
+
nextEnd--;
|
|
11737
|
+
if (i > prevEnd || i > nextEnd) {
|
|
11738
|
+
break outer;
|
|
11739
|
+
}
|
|
11740
|
+
prevNode = prev[prevEnd];
|
|
11741
|
+
nextNode = next[nextEnd];
|
|
11742
|
+
}
|
|
11743
|
+
}
|
|
11744
|
+
if (i > prevEnd) {
|
|
11745
|
+
if (i <= nextEnd) {
|
|
11746
|
+
while (i <= nextEnd) {
|
|
11747
|
+
liveList.insert(deepLiveify(next[i]), i);
|
|
11748
|
+
i++;
|
|
11749
|
+
}
|
|
11750
|
+
}
|
|
11751
|
+
} else if (i > nextEnd) {
|
|
11752
|
+
let localI = i;
|
|
11753
|
+
while (localI <= prevEnd) {
|
|
11754
|
+
liveList.delete(i);
|
|
11755
|
+
localI++;
|
|
11756
|
+
}
|
|
11757
|
+
} else {
|
|
11758
|
+
while (i <= prevEnd && i <= nextEnd) {
|
|
11759
|
+
prevNode = prev[i];
|
|
11760
|
+
nextNode = next[i];
|
|
11761
|
+
const liveListNode = liveList.get(i);
|
|
11762
|
+
if (isLiveObject(liveListNode) && isPlainObject(prevNode) && isPlainObject(nextNode)) {
|
|
11763
|
+
patchLiveObject(liveListNode, prevNode, nextNode);
|
|
11764
|
+
} else {
|
|
11765
|
+
liveList.set(i, deepLiveify(nextNode));
|
|
11766
|
+
}
|
|
11767
|
+
i++;
|
|
11768
|
+
}
|
|
11769
|
+
while (i <= nextEnd) {
|
|
11770
|
+
liveList.insert(deepLiveify(next[i]), i);
|
|
11771
|
+
i++;
|
|
11772
|
+
}
|
|
11773
|
+
let localI = i;
|
|
11774
|
+
while (localI <= prevEnd) {
|
|
11775
|
+
liveList.delete(i);
|
|
11776
|
+
localI++;
|
|
11663
11777
|
}
|
|
11664
|
-
|
|
11665
|
-
|
|
11778
|
+
}
|
|
11779
|
+
}
|
|
11780
|
+
function patchLiveObjectKey(liveObject, key, prev, next) {
|
|
11781
|
+
if (process.env.NODE_ENV !== "production") {
|
|
11782
|
+
const nonSerializableValue = findNonSerializableValue(next);
|
|
11783
|
+
if (nonSerializableValue) {
|
|
11784
|
+
error2(
|
|
11785
|
+
`New state path: '${nonSerializableValue.path}' value: '${String(
|
|
11786
|
+
nonSerializableValue.value
|
|
11787
|
+
)}' is not serializable.
|
|
11788
|
+
Only serializable value can be synced with Liveblocks.`
|
|
11789
|
+
);
|
|
11790
|
+
return;
|
|
11666
11791
|
}
|
|
11667
|
-
|
|
11668
|
-
|
|
11792
|
+
}
|
|
11793
|
+
const value = liveObject.get(key);
|
|
11794
|
+
if (next === void 0) {
|
|
11795
|
+
liveObject.delete(key);
|
|
11796
|
+
} else if (value === void 0) {
|
|
11797
|
+
liveObject.set(key, deepLiveify(next));
|
|
11798
|
+
} else if (prev === next) {
|
|
11799
|
+
return;
|
|
11800
|
+
} else if (isLiveList(value) && Array.isArray(prev) && Array.isArray(next)) {
|
|
11801
|
+
patchLiveList(value, prev, next);
|
|
11802
|
+
} else if (isLiveObject(value) && isPlainObject(prev) && isPlainObject(next)) {
|
|
11803
|
+
patchLiveObject(value, prev, next);
|
|
11804
|
+
} else {
|
|
11805
|
+
liveObject.set(key, deepLiveify(next));
|
|
11806
|
+
}
|
|
11807
|
+
}
|
|
11808
|
+
function patchLiveObject(root, prev, next) {
|
|
11809
|
+
const updates = {};
|
|
11810
|
+
for (const key in next) {
|
|
11811
|
+
patchLiveObjectKey(root, key, prev[key], next[key]);
|
|
11812
|
+
}
|
|
11813
|
+
for (const key in prev) {
|
|
11814
|
+
if (next[key] === void 0) {
|
|
11815
|
+
root.delete(key);
|
|
11669
11816
|
}
|
|
11670
|
-
|
|
11671
|
-
|
|
11817
|
+
}
|
|
11818
|
+
if (Object.keys(updates).length > 0) {
|
|
11819
|
+
root.update(updates);
|
|
11820
|
+
}
|
|
11821
|
+
}
|
|
11822
|
+
function getParentsPath(node) {
|
|
11823
|
+
const path = [];
|
|
11824
|
+
while (node.parent.type === "HasParent") {
|
|
11825
|
+
if (isLiveList(node.parent.node)) {
|
|
11826
|
+
path.push(node.parent.node._indexOfPosition(node.parent.key));
|
|
11827
|
+
} else {
|
|
11828
|
+
path.push(node.parent.key);
|
|
11672
11829
|
}
|
|
11673
|
-
|
|
11674
|
-
},
|
|
11675
|
-
link: ({ element, href }) => {
|
|
11676
|
-
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
11677
|
-
},
|
|
11678
|
-
mention: ({ element, user, group }) => {
|
|
11679
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _284 => _284.name]), () => ( _optionalChain([group, 'optionalAccess', _285 => _285.name]))), () => ( element.id))}`;
|
|
11830
|
+
node = node.parent.node;
|
|
11680
11831
|
}
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
..._optionalChain([options, 'optionalAccess', _288 => _288.elements])
|
|
11688
|
-
};
|
|
11689
|
-
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
11690
|
-
body,
|
|
11691
|
-
_optionalChain([options, 'optionalAccess', _289 => _289.resolveUsers]),
|
|
11692
|
-
_optionalChain([options, 'optionalAccess', _290 => _290.resolveGroupsInfo])
|
|
11832
|
+
return path;
|
|
11833
|
+
}
|
|
11834
|
+
function legacy_patchImmutableObject(state, updates) {
|
|
11835
|
+
return updates.reduce(
|
|
11836
|
+
(state2, update) => legacy_patchImmutableObjectWithUpdate(state2, update),
|
|
11837
|
+
state
|
|
11693
11838
|
);
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11839
|
+
}
|
|
11840
|
+
function legacy_patchImmutableObjectWithUpdate(state, update) {
|
|
11841
|
+
const path = getParentsPath(update.node);
|
|
11842
|
+
return legacy_patchImmutableNode(state, path, update);
|
|
11843
|
+
}
|
|
11844
|
+
function legacy_patchImmutableNode(state, path, update) {
|
|
11845
|
+
const pathItem = path.pop();
|
|
11846
|
+
if (pathItem === void 0) {
|
|
11847
|
+
switch (update.type) {
|
|
11848
|
+
case "LiveObject": {
|
|
11849
|
+
if (!isJsonObject(state)) {
|
|
11850
|
+
throw new Error(
|
|
11851
|
+
"Internal: received update on LiveObject but state was not an object"
|
|
11852
|
+
);
|
|
11853
|
+
}
|
|
11854
|
+
const newState = Object.assign({}, state);
|
|
11855
|
+
for (const key in update.updates) {
|
|
11856
|
+
if (_optionalChain([update, 'access', _294 => _294.updates, 'access', _295 => _295[key], 'optionalAccess', _296 => _296.type]) === "update") {
|
|
11857
|
+
const val = update.node.get(key);
|
|
11858
|
+
if (val !== void 0) {
|
|
11859
|
+
newState[key] = lsonToJson(val);
|
|
11860
|
+
}
|
|
11861
|
+
} else if (_optionalChain([update, 'access', _297 => _297.updates, 'access', _298 => _298[key], 'optionalAccess', _299 => _299.type]) === "delete") {
|
|
11862
|
+
delete newState[key];
|
|
11709
11863
|
}
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
|
|
11719
|
-
|
|
11864
|
+
}
|
|
11865
|
+
return newState;
|
|
11866
|
+
}
|
|
11867
|
+
case "LiveList": {
|
|
11868
|
+
if (!Array.isArray(state)) {
|
|
11869
|
+
throw new Error(
|
|
11870
|
+
"Internal: received update on LiveList but state was not an array"
|
|
11871
|
+
);
|
|
11872
|
+
}
|
|
11873
|
+
let newState = state.map((x) => x);
|
|
11874
|
+
for (const listUpdate of update.updates) {
|
|
11875
|
+
if (listUpdate.type === "set") {
|
|
11876
|
+
newState = newState.map(
|
|
11877
|
+
(item, index) => index === listUpdate.index ? lsonToJson(listUpdate.item) : item
|
|
11878
|
+
);
|
|
11879
|
+
} else if (listUpdate.type === "insert") {
|
|
11880
|
+
if (listUpdate.index === newState.length) {
|
|
11881
|
+
newState.push(lsonToJson(listUpdate.item));
|
|
11882
|
+
} else {
|
|
11883
|
+
newState = [
|
|
11884
|
+
...newState.slice(0, listUpdate.index),
|
|
11885
|
+
lsonToJson(listUpdate.item),
|
|
11886
|
+
...newState.slice(listUpdate.index)
|
|
11887
|
+
];
|
|
11888
|
+
}
|
|
11889
|
+
} else if (listUpdate.type === "delete") {
|
|
11890
|
+
newState.splice(listUpdate.index, 1);
|
|
11891
|
+
} else if (listUpdate.type === "move") {
|
|
11892
|
+
if (listUpdate.previousIndex > listUpdate.index) {
|
|
11893
|
+
newState = [
|
|
11894
|
+
...newState.slice(0, listUpdate.index),
|
|
11895
|
+
lsonToJson(listUpdate.item),
|
|
11896
|
+
...newState.slice(listUpdate.index, listUpdate.previousIndex),
|
|
11897
|
+
...newState.slice(listUpdate.previousIndex + 1)
|
|
11898
|
+
];
|
|
11899
|
+
} else {
|
|
11900
|
+
newState = [
|
|
11901
|
+
...newState.slice(0, listUpdate.previousIndex),
|
|
11902
|
+
...newState.slice(
|
|
11903
|
+
listUpdate.previousIndex + 1,
|
|
11904
|
+
listUpdate.index + 1
|
|
11905
|
+
),
|
|
11906
|
+
lsonToJson(listUpdate.item),
|
|
11907
|
+
...newState.slice(listUpdate.index + 1)
|
|
11720
11908
|
];
|
|
11721
11909
|
}
|
|
11722
|
-
return [
|
|
11723
|
-
elements.link(
|
|
11724
|
-
{
|
|
11725
|
-
element: inline,
|
|
11726
|
-
href
|
|
11727
|
-
},
|
|
11728
|
-
inlineIndex
|
|
11729
|
-
)
|
|
11730
|
-
];
|
|
11731
11910
|
}
|
|
11732
|
-
|
|
11733
|
-
|
|
11911
|
+
}
|
|
11912
|
+
return newState;
|
|
11913
|
+
}
|
|
11914
|
+
case "LiveMap": {
|
|
11915
|
+
if (!isJsonObject(state)) {
|
|
11916
|
+
throw new Error(
|
|
11917
|
+
"Internal: received update on LiveMap but state was not an object"
|
|
11918
|
+
);
|
|
11919
|
+
}
|
|
11920
|
+
const newState = Object.assign({}, state);
|
|
11921
|
+
for (const key in update.updates) {
|
|
11922
|
+
if (_optionalChain([update, 'access', _300 => _300.updates, 'access', _301 => _301[key], 'optionalAccess', _302 => _302.type]) === "update") {
|
|
11923
|
+
const value = update.node.get(key);
|
|
11924
|
+
if (value !== void 0) {
|
|
11925
|
+
newState[key] = lsonToJson(value);
|
|
11926
|
+
}
|
|
11927
|
+
} else if (_optionalChain([update, 'access', _303 => _303.updates, 'access', _304 => _304[key], 'optionalAccess', _305 => _305.type]) === "delete") {
|
|
11928
|
+
delete newState[key];
|
|
11734
11929
|
}
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
return [
|
|
11738
|
-
elements.paragraph(
|
|
11739
|
-
{ element: block, children: inlines.join("") },
|
|
11740
|
-
blockIndex
|
|
11741
|
-
)
|
|
11742
|
-
];
|
|
11930
|
+
}
|
|
11931
|
+
return newState;
|
|
11743
11932
|
}
|
|
11744
|
-
default:
|
|
11745
|
-
return [];
|
|
11746
11933
|
}
|
|
11747
|
-
}
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11756
|
-
|
|
11757
|
-
|
|
11758
|
-
|
|
11759
|
-
|
|
11760
|
-
|
|
11761
|
-
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
)
|
|
11768
|
-
};
|
|
11769
|
-
} else if (lson instanceof LiveList) {
|
|
11770
|
-
return {
|
|
11771
|
-
liveblocksType: "LiveList",
|
|
11772
|
-
data: [...lson].map((item) => toPlainLson(item))
|
|
11773
|
-
};
|
|
11934
|
+
}
|
|
11935
|
+
if (Array.isArray(state)) {
|
|
11936
|
+
const newArray = [...state];
|
|
11937
|
+
newArray[pathItem] = legacy_patchImmutableNode(
|
|
11938
|
+
state[pathItem],
|
|
11939
|
+
path,
|
|
11940
|
+
update
|
|
11941
|
+
);
|
|
11942
|
+
return newArray;
|
|
11943
|
+
} else if (isJsonObject(state)) {
|
|
11944
|
+
const node = state[pathItem];
|
|
11945
|
+
if (node === void 0) {
|
|
11946
|
+
return state;
|
|
11947
|
+
} else {
|
|
11948
|
+
const stateAsObj = state;
|
|
11949
|
+
return {
|
|
11950
|
+
...stateAsObj,
|
|
11951
|
+
[pathItem]: legacy_patchImmutableNode(node, path, update)
|
|
11952
|
+
};
|
|
11953
|
+
}
|
|
11774
11954
|
} else {
|
|
11775
|
-
return
|
|
11955
|
+
return state;
|
|
11776
11956
|
}
|
|
11777
11957
|
}
|
|
11778
11958
|
|
|
@@ -11824,9 +12004,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11824
12004
|
const startTime = performance.now();
|
|
11825
12005
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
11826
12006
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
11827
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
12007
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _306 => _306.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
11828
12008
|
const context = {
|
|
11829
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
12009
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _307 => _307.visibilityState]) !== "hidden",
|
|
11830
12010
|
lastSuccessfulPollAt: startTime,
|
|
11831
12011
|
count: 0,
|
|
11832
12012
|
backoff: 0
|
|
@@ -11907,11 +12087,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11907
12087
|
pollNowIfStale();
|
|
11908
12088
|
}
|
|
11909
12089
|
function onVisibilityChange() {
|
|
11910
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
12090
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _308 => _308.visibilityState]) !== "hidden");
|
|
11911
12091
|
}
|
|
11912
|
-
_optionalChain([doc, 'optionalAccess',
|
|
11913
|
-
_optionalChain([win, 'optionalAccess',
|
|
11914
|
-
_optionalChain([win, 'optionalAccess',
|
|
12092
|
+
_optionalChain([doc, 'optionalAccess', _309 => _309.addEventListener, 'call', _310 => _310("visibilitychange", onVisibilityChange)]);
|
|
12093
|
+
_optionalChain([win, 'optionalAccess', _311 => _311.addEventListener, 'call', _312 => _312("online", onVisibilityChange)]);
|
|
12094
|
+
_optionalChain([win, 'optionalAccess', _313 => _313.addEventListener, 'call', _314 => _314("focus", pollNowIfStale)]);
|
|
11915
12095
|
fsm.start();
|
|
11916
12096
|
return {
|
|
11917
12097
|
inc,
|
|
@@ -12050,5 +12230,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
12050
12230
|
|
|
12051
12231
|
|
|
12052
12232
|
|
|
12053
|
-
|
|
12233
|
+
|
|
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.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;
|
|
12054
12235
|
//# sourceMappingURL=index.cjs.map
|