@liveblocks/core 3.16.0-flow3 → 3.17.0-rc1

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 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-flow3";
9
+ var PKG_VERSION = "3.17.0-rc1";
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) {
@@ -6718,7 +6735,10 @@ var LiveList = class _LiveList extends AbstractCrdt {
6718
6735
  };
6719
6736
  } else {
6720
6737
  if (indexOfItemWithSamePosition !== -1) {
6721
- nn(this.#items.removeAt(indexOfItemWithSamePosition));
6738
+ const displaced = nn(
6739
+ this.#items.removeAt(indexOfItemWithSamePosition)
6740
+ );
6741
+ this.#implicitlyDeletedItems.add(displaced);
6722
6742
  }
6723
6743
  const { newItem, newIndex } = this.#createAttachItemAndSort(
6724
6744
  op,
@@ -7866,61 +7886,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7866
7886
  }
7867
7887
  };
7868
7888
 
7869
- // src/lib/Json.ts
7870
- function isJsonScalar(data) {
7871
- return data === null || typeof data === "string" || typeof data === "number" || typeof data === "boolean";
7872
- }
7873
- function isJsonArray(data) {
7874
- return Array.isArray(data);
7875
- }
7876
- function isJsonObject(data) {
7877
- return !isJsonScalar(data) && !isJsonArray(data);
7878
- }
7879
-
7880
- // src/immutable.ts
7881
- function lsonObjectToJson(obj) {
7882
- const result = {};
7883
- for (const key in obj) {
7884
- const val = obj[key];
7885
- if (val !== void 0) {
7886
- result[key] = lsonToJson(val);
7887
- }
7888
- }
7889
- return result;
7890
- }
7891
- function liveObjectToJson(liveObject) {
7892
- return lsonObjectToJson(liveObject.toObject());
7893
- }
7894
- function liveMapToJson(map) {
7895
- const result = {};
7896
- for (const [key, value] of map.entries()) {
7897
- result[key] = lsonToJson(value);
7898
- }
7899
- return result;
7900
- }
7901
- function lsonListToJson(value) {
7902
- return value.map(lsonToJson);
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
- }
7889
+ // src/crdts/reconcile.ts
7924
7890
  function deepLiveify(value, config) {
7925
7891
  if (Array.isArray(value)) {
7926
7892
  return new LiveList(value.map((v) => deepLiveify(v, config)));
@@ -8023,374 +7989,133 @@ function reconcileLiveList(liveList, jsonArr, config) {
8023
7989
  }
8024
7990
  return liveList;
8025
7991
  }
8026
- function legacy_patchLiveList(liveList, prev, next) {
8027
- let i = 0;
8028
- let prevEnd = prev.length - 1;
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;
7992
+
7993
+ // src/crdts/LiveObject.ts
7994
+ var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
7995
+ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7996
+ #synced;
7997
+ #local = /* @__PURE__ */ new Map();
7998
+ /**
7999
+ * Tracks unacknowledged local changes per property to preserve optimistic
8000
+ * updates. Maps property keys to their pending operation IDs.
8001
+ *
8002
+ * INVARIANT: Only locally-generated opIds are ever stored here. Remote opIds
8003
+ * are only compared against (to detect ACKs), never stored.
8004
+ *
8005
+ * When a local change is made, the opId is stored here. When a remote op
8006
+ * arrives for the same key:
8007
+ * - If no entry exists → apply remote op
8008
+ * - If opId matches → it's an ACK, clear the entry
8009
+ * - If opId differs → ignore remote op to preserve optimistic update
8010
+ */
8011
+ #unackedOpsByKey;
8012
+ /**
8013
+ * Enable or disable detection of too large LiveObjects.
8014
+ * When enabled, throws an error if LiveObject static data exceeds 128KB, which
8015
+ * is the maximum value the server will be able to accept.
8016
+ * By default, this behavior is disabled to avoid the runtime performance
8017
+ * overhead on every LiveObject.set() or LiveObject.update() call.
8018
+ *
8019
+ * @experimental
8020
+ */
8021
+ static __initStatic() {this.detectLargeObjects = false}
8022
+ static #buildRootAndParentToChildren(nodes) {
8023
+ const parentToChildren = /* @__PURE__ */ new Map();
8024
+ let root = null;
8025
+ for (const node of nodes) {
8026
+ if (isRootStorageNode(node)) {
8027
+ root = node[1];
8028
+ } else {
8029
+ const crdt = node[1];
8030
+ const children = parentToChildren.get(crdt.parentId);
8031
+ if (children !== void 0) {
8032
+ children.push(node);
8033
+ } else {
8034
+ parentToChildren.set(crdt.parentId, [node]);
8035
+ }
8037
8036
  }
8038
- prevNode = prev[i];
8039
- nextNode = next[i];
8040
8037
  }
8041
- prevNode = prev[prevEnd];
8042
- nextNode = next[nextEnd];
8043
- while (prevNode === nextNode) {
8044
- prevEnd--;
8045
- nextEnd--;
8046
- if (i > prevEnd || i > nextEnd) {
8047
- break outer;
8048
- }
8049
- prevNode = prev[prevEnd];
8050
- nextNode = next[nextEnd];
8038
+ if (root === null) {
8039
+ throw new Error("Root can't be null");
8051
8040
  }
8041
+ return [root, parentToChildren];
8052
8042
  }
8053
- if (i > prevEnd) {
8054
- if (i <= nextEnd) {
8055
- while (i <= nextEnd) {
8056
- liveList.insert(deepLiveify(next[i]), i);
8057
- i++;
8043
+ /** @private Do not use this API directly */
8044
+ static _fromItems(nodes, pool) {
8045
+ const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(nodes);
8046
+ return _LiveObject._deserialize(
8047
+ ["root", root],
8048
+ parentToChildren,
8049
+ pool
8050
+ );
8051
+ }
8052
+ constructor(obj = {}) {
8053
+ super();
8054
+ this.#unackedOpsByKey = /* @__PURE__ */ new Map();
8055
+ const o = compactObject(obj);
8056
+ for (const key of Object.keys(o)) {
8057
+ const value = o[key];
8058
+ if (isLiveNode(value)) {
8059
+ value._setParentLink(this, key);
8058
8060
  }
8059
8061
  }
8060
- } else if (i > nextEnd) {
8061
- let localI = i;
8062
- while (localI <= prevEnd) {
8063
- liveList.delete(i);
8064
- localI++;
8062
+ this.#synced = new Map(Object.entries(o));
8063
+ }
8064
+ /** @internal */
8065
+ _toOps(parentId, parentKey) {
8066
+ if (this._id === void 0) {
8067
+ throw new Error("Cannot serialize item is not attached");
8065
8068
  }
8066
- } else {
8067
- while (i <= prevEnd && i <= nextEnd) {
8068
- prevNode = prev[i];
8069
- nextNode = next[i];
8070
- const liveListNode = liveList.get(i);
8071
- if (isLiveObject(liveListNode) && isPlainObject(prevNode) && isPlainObject(nextNode)) {
8072
- legacy_patchLiveObject(liveListNode, prevNode, nextNode);
8069
+ const ops = [];
8070
+ const op = {
8071
+ type: OpCode.CREATE_OBJECT,
8072
+ id: this._id,
8073
+ parentId,
8074
+ parentKey,
8075
+ data: {}
8076
+ };
8077
+ ops.push(op);
8078
+ for (const [key, value] of this.#synced) {
8079
+ if (isLiveNode(value)) {
8080
+ for (const childOp of value._toOps(this._id, key)) {
8081
+ ops.push(childOp);
8082
+ }
8073
8083
  } else {
8074
- liveList.set(i, deepLiveify(nextNode));
8084
+ op.data[key] = value;
8075
8085
  }
8076
- i++;
8077
8086
  }
8078
- while (i <= nextEnd) {
8079
- liveList.insert(deepLiveify(next[i]), i);
8080
- i++;
8087
+ return ops;
8088
+ }
8089
+ /** @internal */
8090
+ static _deserialize([id, item], parentToChildren, pool) {
8091
+ const liveObj = new _LiveObject(item.data);
8092
+ liveObj._attach(id, pool);
8093
+ return this._deserializeChildren(liveObj, parentToChildren, pool);
8094
+ }
8095
+ /** @internal */
8096
+ static _deserializeChildren(liveObj, parentToChildren, pool) {
8097
+ const children = parentToChildren.get(nn(liveObj._id));
8098
+ if (children === void 0) {
8099
+ return liveObj;
8081
8100
  }
8082
- let localI = i;
8083
- while (localI <= prevEnd) {
8084
- liveList.delete(i);
8085
- localI++;
8101
+ for (const node of children) {
8102
+ const child = deserializeToLson(node, parentToChildren, pool);
8103
+ const crdt = node[1];
8104
+ if (isLiveStructure(child)) {
8105
+ child._setParentLink(liveObj, crdt.parentKey);
8106
+ }
8107
+ liveObj.#synced.set(crdt.parentKey, child);
8108
+ liveObj.invalidate();
8086
8109
  }
8110
+ return liveObj;
8087
8111
  }
8088
- }
8089
- function legacy_patchLiveObjectKey(liveObject, key, prev, next) {
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
- }
8112
+ /** @internal */
8113
+ _attach(id, pool) {
8114
+ super._attach(id, pool);
8115
+ for (const [_key, value] of this.#synced) {
8116
+ if (isLiveNode(value)) {
8117
+ value._attach(pool.generateId(), pool);
8118
+ }
8394
8119
  }
8395
8120
  }
8396
8121
  /** @internal */
@@ -8646,20 +8371,20 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
8646
8371
  * Caveat: this method will not add changes to the undo/redo stack.
8647
8372
  */
8648
8373
  setLocal(key, value) {
8649
- _optionalChain([this, 'access', _204 => _204._pool, 'optionalAccess', _205 => _205.assertStorageIsWritable, 'call', _206 => _206()]);
8374
+ _optionalChain([this, 'access', _192 => _192._pool, 'optionalAccess', _193 => _193.assertStorageIsWritable, 'call', _194 => _194()]);
8650
8375
  const deleteResult = this.#prepareDelete(key);
8651
8376
  this.#local.set(key, value);
8652
8377
  this.invalidate();
8653
8378
  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()));
8379
+ const ops = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _195 => _195[0]]), () => ( []));
8380
+ const reverse = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _196 => _196[1]]), () => ( []));
8381
+ const storageUpdates = _nullishCoalesce(_optionalChain([deleteResult, 'optionalAccess', _197 => _197[2]]), () => ( /* @__PURE__ */ new Map()));
8657
8382
  const existing = storageUpdates.get(this._id);
8658
8383
  storageUpdates.set(this._id, {
8659
8384
  node: this,
8660
8385
  type: "LiveObject",
8661
8386
  updates: {
8662
- ..._optionalChain([existing, 'optionalAccess', _210 => _210.updates]),
8387
+ ..._optionalChain([existing, 'optionalAccess', _198 => _198.updates]),
8663
8388
  [key]: { type: "update" }
8664
8389
  }
8665
8390
  });
@@ -8679,7 +8404,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
8679
8404
  * #synced or pool/id are unavailable. Does NOT dispatch.
8680
8405
  */
8681
8406
  #prepareDelete(key) {
8682
- _optionalChain([this, 'access', _211 => _211._pool, 'optionalAccess', _212 => _212.assertStorageIsWritable, 'call', _213 => _213()]);
8407
+ _optionalChain([this, 'access', _199 => _199._pool, 'optionalAccess', _200 => _200.assertStorageIsWritable, 'call', _201 => _201()]);
8683
8408
  const k = key;
8684
8409
  if (this.#local.has(k) && !this.#synced.has(k)) {
8685
8410
  const oldValue2 = this.#local.get(k);
@@ -8755,7 +8480,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
8755
8480
  const result = this.#prepareDelete(key);
8756
8481
  if (result) {
8757
8482
  const [ops, reverse, storageUpdates] = result;
8758
- _optionalChain([this, 'access', _214 => _214._pool, 'optionalAccess', _215 => _215.dispatch, 'call', _216 => _216(ops, reverse, storageUpdates)]);
8483
+ _optionalChain([this, 'access', _202 => _202._pool, 'optionalAccess', _203 => _203.dispatch, 'call', _204 => _204(ops, reverse, storageUpdates)]);
8759
8484
  }
8760
8485
  }
8761
8486
  /**
@@ -8763,7 +8488,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
8763
8488
  * @param patch The object used to overrides properties
8764
8489
  */
8765
8490
  update(patch) {
8766
- _optionalChain([this, 'access', _217 => _217._pool, 'optionalAccess', _218 => _218.assertStorageIsWritable, 'call', _219 => _219()]);
8491
+ _optionalChain([this, 'access', _205 => _205._pool, 'optionalAccess', _206 => _206.assertStorageIsWritable, 'call', _207 => _207()]);
8767
8492
  if (_LiveObject.detectLargeObjects) {
8768
8493
  const data = {};
8769
8494
  for (const [key, value] of this.#synced) {
@@ -8824,6 +8549,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
8824
8549
  continue;
8825
8550
  }
8826
8551
  const oldValue = this.#synced.get(key);
8552
+ if (oldValue === newValue) {
8553
+ continue;
8554
+ }
8827
8555
  if (isLiveNode(oldValue)) {
8828
8556
  for (const childOp of oldValue._toOps(this._id, key)) {
8829
8557
  reverseOps.push(childOp);
@@ -8871,6 +8599,9 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
8871
8599
  data: updatedProps
8872
8600
  });
8873
8601
  }
8602
+ if (ops.length === 0 && reverseOps.length === 0 && Object.keys(updateDelta).length === 0) {
8603
+ return;
8604
+ }
8874
8605
  const storageUpdates = /* @__PURE__ */ new Map();
8875
8606
  storageUpdates.set(this._id, {
8876
8607
  node: this,
@@ -9249,6 +8980,17 @@ var Deque = class {
9249
8980
  }
9250
8981
  };
9251
8982
 
8983
+ // src/lib/Json.ts
8984
+ function isJsonScalar(data) {
8985
+ return data === null || typeof data === "string" || typeof data === "number" || typeof data === "boolean";
8986
+ }
8987
+ function isJsonArray(data) {
8988
+ return Array.isArray(data);
8989
+ }
8990
+ function isJsonObject(data) {
8991
+ return !isJsonScalar(data) && !isJsonArray(data);
8992
+ }
8993
+
9252
8994
  // src/lib/stopwatch.ts
9253
8995
  function makeStopWatch() {
9254
8996
  let startTime = 0;
@@ -9282,7 +9024,16 @@ var ClientMsgCode = Object.freeze({
9282
9024
  UPDATE_STORAGE: 201,
9283
9025
  // For Yjs support
9284
9026
  FETCH_YDOC: 300,
9285
- UPDATE_YDOC: 301
9027
+ UPDATE_YDOC: 301,
9028
+ // For Feeds
9029
+ FETCH_FEEDS: 510,
9030
+ FETCH_FEED_MESSAGES: 511,
9031
+ ADD_FEED: 512,
9032
+ UPDATE_FEED: 513,
9033
+ DELETE_FEED: 514,
9034
+ ADD_FEED_MESSAGE: 515,
9035
+ UPDATE_FEED_MESSAGE: 516,
9036
+ DELETE_FEED_MESSAGE: 517
9286
9037
  });
9287
9038
 
9288
9039
  // src/refs/ManagedOthers.ts
@@ -9518,12 +9269,15 @@ function defaultMessageFromContext(context) {
9518
9269
  return "Could not update notification settings";
9519
9270
  case "LARGE_MESSAGE_ERROR":
9520
9271
  return "Could not send large message";
9272
+ case "FEED_REQUEST_ERROR":
9273
+ return _nullishCoalesce(context.reason, () => ( "Feed request failed"));
9521
9274
  default:
9522
9275
  return assertNever(context, "Unhandled case");
9523
9276
  }
9524
9277
  }
9525
9278
 
9526
9279
  // src/room.ts
9280
+ var FEEDS_TIMEOUT = 5e3;
9527
9281
  function makeIdFactory(connectionId) {
9528
9282
  let count = 0;
9529
9283
  return () => `${connectionId}:${count++}`;
@@ -9546,15 +9300,15 @@ function installBackgroundTabSpy() {
9546
9300
  const doc = typeof document !== "undefined" ? document : void 0;
9547
9301
  const inBackgroundSince = { current: null };
9548
9302
  function onVisibilityChange() {
9549
- if (_optionalChain([doc, 'optionalAccess', _220 => _220.visibilityState]) === "hidden") {
9303
+ if (_optionalChain([doc, 'optionalAccess', _208 => _208.visibilityState]) === "hidden") {
9550
9304
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
9551
9305
  } else {
9552
9306
  inBackgroundSince.current = null;
9553
9307
  }
9554
9308
  }
9555
- _optionalChain([doc, 'optionalAccess', _221 => _221.addEventListener, 'call', _222 => _222("visibilitychange", onVisibilityChange)]);
9309
+ _optionalChain([doc, 'optionalAccess', _209 => _209.addEventListener, 'call', _210 => _210("visibilitychange", onVisibilityChange)]);
9556
9310
  const unsub = () => {
9557
- _optionalChain([doc, 'optionalAccess', _223 => _223.removeEventListener, 'call', _224 => _224("visibilitychange", onVisibilityChange)]);
9311
+ _optionalChain([doc, 'optionalAccess', _211 => _211.removeEventListener, 'call', _212 => _212("visibilitychange", onVisibilityChange)]);
9558
9312
  };
9559
9313
  return [inBackgroundSince, unsub];
9560
9314
  }
@@ -9745,7 +9499,7 @@ function createRoom(options, config) {
9745
9499
  }
9746
9500
  }
9747
9501
  function isStorageWritable() {
9748
- const scopes = _optionalChain([context, 'access', _225 => _225.dynamicSessionInfoSig, 'access', _226 => _226.get, 'call', _227 => _227(), 'optionalAccess', _228 => _228.scopes]);
9502
+ const scopes = _optionalChain([context, 'access', _213 => _213.dynamicSessionInfoSig, 'access', _214 => _214.get, 'call', _215 => _215(), 'optionalAccess', _216 => _216.scopes]);
9749
9503
  return scopes !== void 0 ? canWriteStorage(scopes) : true;
9750
9504
  }
9751
9505
  const eventHub = {
@@ -9762,6 +9516,7 @@ function createRoom(options, config) {
9762
9516
  storageStatus: makeEventSource(),
9763
9517
  ydoc: makeEventSource(),
9764
9518
  comments: makeEventSource(),
9519
+ feeds: makeEventSource(),
9765
9520
  roomWillDestroy: makeEventSource()
9766
9521
  };
9767
9522
  async function createTextMention(mentionId, mention) {
@@ -9848,7 +9603,7 @@ function createRoom(options, config) {
9848
9603
  context.pool
9849
9604
  );
9850
9605
  }
9851
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _229 => _229.get, 'call', _230 => _230(), 'optionalAccess', _231 => _231.canWrite]), () => ( true));
9606
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _217 => _217.get, 'call', _218 => _218(), 'optionalAccess', _219 => _219.canWrite]), () => ( true));
9852
9607
  const root = context.root;
9853
9608
  withoutHistory(() => {
9854
9609
  for (const key in context.initialStorage) {
@@ -10053,7 +9808,7 @@ function createRoom(options, config) {
10053
9808
  }
10054
9809
  context.myPresence.patch(patch);
10055
9810
  if (context.activeBatch) {
10056
- if (_optionalChain([options2, 'optionalAccess', _232 => _232.addToHistory])) {
9811
+ if (_optionalChain([options2, 'optionalAccess', _220 => _220.addToHistory])) {
10057
9812
  context.activeBatch.reverseOps.pushLeft({
10058
9813
  type: "presence",
10059
9814
  data: oldValues
@@ -10062,7 +9817,7 @@ function createRoom(options, config) {
10062
9817
  context.activeBatch.updates.presence = true;
10063
9818
  } else {
10064
9819
  flushNowOrSoon();
10065
- if (_optionalChain([options2, 'optionalAccess', _233 => _233.addToHistory])) {
9820
+ if (_optionalChain([options2, 'optionalAccess', _221 => _221.addToHistory])) {
10066
9821
  addToUndoStack([{ type: "presence", data: oldValues }]);
10067
9822
  }
10068
9823
  notify({ presence: true });
@@ -10183,6 +9938,9 @@ function createRoom(options, config) {
10183
9938
  notify(result.updates);
10184
9939
  sendMessages(messages);
10185
9940
  }
9941
+ function isFeedRequestFailedMsg(msg) {
9942
+ return msg.type === ServerMsgCode.FEED_REQUEST_FAILED;
9943
+ }
10186
9944
  function handleServerMessage(event) {
10187
9945
  if (typeof event.data !== "string") {
10188
9946
  return;
@@ -10236,11 +9994,11 @@ function createRoom(options, config) {
10236
9994
  break;
10237
9995
  }
10238
9996
  case ServerMsgCode.STORAGE_CHUNK:
10239
- _optionalChain([stopwatch, 'optionalAccess', _234 => _234.lap, 'call', _235 => _235()]);
9997
+ _optionalChain([stopwatch, 'optionalAccess', _222 => _222.lap, 'call', _223 => _223()]);
10240
9998
  nodeMapBuffer.append(compactNodesToNodeStream(message.nodes));
10241
9999
  break;
10242
10000
  case ServerMsgCode.STORAGE_STREAM_END: {
10243
- const timing = _optionalChain([stopwatch, 'optionalAccess', _236 => _236.stop, 'call', _237 => _237()]);
10001
+ const timing = _optionalChain([stopwatch, 'optionalAccess', _224 => _224.stop, 'call', _225 => _225()]);
10244
10002
  if (timing) {
10245
10003
  const ms = (v) => `${v.toFixed(1)}ms`;
10246
10004
  const rest = timing.laps.slice(1);
@@ -10296,6 +10054,94 @@ function createRoom(options, config) {
10296
10054
  eventHub.comments.notify(message);
10297
10055
  break;
10298
10056
  }
10057
+ case ServerMsgCode.FEEDS_LIST: {
10058
+ const feedsListMsg = message;
10059
+ const pending = pendingFeedsRequests.get(feedsListMsg.requestId);
10060
+ if (pending) {
10061
+ pending.resolve({
10062
+ feeds: feedsListMsg.feeds,
10063
+ nextCursor: feedsListMsg.nextCursor
10064
+ });
10065
+ pendingFeedsRequests.delete(feedsListMsg.requestId);
10066
+ }
10067
+ eventHub.feeds.notify(feedsListMsg);
10068
+ break;
10069
+ }
10070
+ case ServerMsgCode.FEEDS_ADDED: {
10071
+ const feedsAddedMsg = message;
10072
+ eventHub.feeds.notify(feedsAddedMsg);
10073
+ tryResolvePendingFeedMutationsFromFeedsEvent(feedsAddedMsg);
10074
+ break;
10075
+ }
10076
+ case ServerMsgCode.FEEDS_UPDATED: {
10077
+ const feedsUpdatedMsg = message;
10078
+ eventHub.feeds.notify(feedsUpdatedMsg);
10079
+ tryResolvePendingFeedMutationsFromFeedsEvent(feedsUpdatedMsg);
10080
+ break;
10081
+ }
10082
+ case ServerMsgCode.FEED_DELETED: {
10083
+ eventHub.feeds.notify(message);
10084
+ tryResolvePendingFeedMutationsFromFeedsEvent(message);
10085
+ break;
10086
+ }
10087
+ case ServerMsgCode.FEED_MESSAGES_LIST: {
10088
+ const feedMsgsListMsg = message;
10089
+ const pending = pendingFeedMessagesRequests.get(
10090
+ feedMsgsListMsg.requestId
10091
+ );
10092
+ if (pending) {
10093
+ pending.resolve({
10094
+ messages: feedMsgsListMsg.messages,
10095
+ nextCursor: feedMsgsListMsg.nextCursor
10096
+ });
10097
+ pendingFeedMessagesRequests.delete(feedMsgsListMsg.requestId);
10098
+ }
10099
+ eventHub.feeds.notify(feedMsgsListMsg);
10100
+ break;
10101
+ }
10102
+ case ServerMsgCode.FEED_MESSAGES_ADDED: {
10103
+ const feedMsgsAddedMsg = message;
10104
+ eventHub.feeds.notify(feedMsgsAddedMsg);
10105
+ tryResolvePendingFeedMutationsFromFeedsEvent(feedMsgsAddedMsg);
10106
+ break;
10107
+ }
10108
+ case ServerMsgCode.FEED_MESSAGES_UPDATED: {
10109
+ const feedMsgsUpdatedMsg = message;
10110
+ eventHub.feeds.notify(feedMsgsUpdatedMsg);
10111
+ tryResolvePendingFeedMutationsFromFeedsEvent(feedMsgsUpdatedMsg);
10112
+ break;
10113
+ }
10114
+ case ServerMsgCode.FEED_MESSAGES_DELETED: {
10115
+ eventHub.feeds.notify(message);
10116
+ tryResolvePendingFeedMutationsFromFeedsEvent(message);
10117
+ break;
10118
+ }
10119
+ case ServerMsgCode.FEED_REQUEST_FAILED: {
10120
+ if (!isFeedRequestFailedMsg(message)) {
10121
+ break;
10122
+ }
10123
+ const { requestId, code, reason } = message;
10124
+ const err = new LiveblocksError(_nullishCoalesce(reason, () => ( "Feed request failed")), {
10125
+ type: "FEED_REQUEST_ERROR",
10126
+ roomId,
10127
+ requestId,
10128
+ code,
10129
+ reason
10130
+ });
10131
+ if (pendingFeedMutations.has(requestId)) {
10132
+ settleFeedMutation(requestId, "error", err);
10133
+ } else if (pendingFeedsRequests.has(requestId)) {
10134
+ const pending = pendingFeedsRequests.get(requestId);
10135
+ pendingFeedsRequests.delete(requestId);
10136
+ _optionalChain([pending, 'optionalAccess', _226 => _226.reject, 'call', _227 => _227(err)]);
10137
+ } else if (pendingFeedMessagesRequests.has(requestId)) {
10138
+ const pending = pendingFeedMessagesRequests.get(requestId);
10139
+ pendingFeedMessagesRequests.delete(requestId);
10140
+ _optionalChain([pending, 'optionalAccess', _228 => _228.reject, 'call', _229 => _229(err)]);
10141
+ }
10142
+ eventHub.feeds.notify(message);
10143
+ break;
10144
+ }
10299
10145
  case ServerMsgCode.STORAGE_STATE_V7:
10300
10146
  // No longer used in V8
10301
10147
  default:
@@ -10395,15 +10241,150 @@ function createRoom(options, config) {
10395
10241
  for (const op of ops) {
10396
10242
  storageOperations.push(op);
10397
10243
  }
10398
- flushNowOrSoon();
10244
+ flushNowOrSoon();
10245
+ }
10246
+ let _getStorage$ = null;
10247
+ let _resolveStoragePromise = null;
10248
+ const pendingFeedsRequests = /* @__PURE__ */ new Map();
10249
+ const pendingFeedMessagesRequests = /* @__PURE__ */ new Map();
10250
+ const pendingFeedMutations = /* @__PURE__ */ new Map();
10251
+ const pendingAddMessageFifoByFeed = /* @__PURE__ */ new Map();
10252
+ function settleFeedMutation(requestId, outcome, error3) {
10253
+ const pending = pendingFeedMutations.get(requestId);
10254
+ if (pending === void 0) {
10255
+ return;
10256
+ }
10257
+ clearTimeout(pending.timeoutId);
10258
+ pendingFeedMutations.delete(requestId);
10259
+ if (pending.kind === "add-message" && !pending.expectedClientMessageId) {
10260
+ const q = pendingAddMessageFifoByFeed.get(pending.feedId);
10261
+ if (q !== void 0) {
10262
+ const idx = q.indexOf(requestId);
10263
+ if (idx >= 0) {
10264
+ q.splice(idx, 1);
10265
+ }
10266
+ if (q.length === 0) {
10267
+ pendingAddMessageFifoByFeed.delete(pending.feedId);
10268
+ }
10269
+ }
10270
+ }
10271
+ if (outcome === "ok") {
10272
+ pending.resolve();
10273
+ } else {
10274
+ pending.reject(_nullishCoalesce(error3, () => ( new Error("Feed mutation failed"))));
10275
+ }
10276
+ }
10277
+ function registerFeedMutation(requestId, kind, feedId, options2) {
10278
+ const { promise, resolve, reject } = Promise_withResolvers();
10279
+ const timeoutId = setTimeout(() => {
10280
+ if (pendingFeedMutations.has(requestId)) {
10281
+ settleFeedMutation(
10282
+ requestId,
10283
+ "error",
10284
+ new Error("Feed mutation timeout")
10285
+ );
10286
+ }
10287
+ }, FEEDS_TIMEOUT);
10288
+ pendingFeedMutations.set(requestId, {
10289
+ resolve,
10290
+ reject,
10291
+ timeoutId,
10292
+ kind,
10293
+ feedId,
10294
+ messageId: _optionalChain([options2, 'optionalAccess', _230 => _230.messageId]),
10295
+ expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _231 => _231.expectedClientMessageId])
10296
+ });
10297
+ if (kind === "add-message" && _optionalChain([options2, 'optionalAccess', _232 => _232.expectedClientMessageId]) === void 0) {
10298
+ const q = _nullishCoalesce(pendingAddMessageFifoByFeed.get(feedId), () => ( []));
10299
+ q.push(requestId);
10300
+ pendingAddMessageFifoByFeed.set(feedId, q);
10301
+ }
10302
+ return promise;
10303
+ }
10304
+ function tryResolvePendingFeedMutationsFromFeedsEvent(message) {
10305
+ switch (message.type) {
10306
+ case ServerMsgCode.FEEDS_ADDED: {
10307
+ for (const feed of message.feeds) {
10308
+ for (const [requestId, pending] of [...pendingFeedMutations]) {
10309
+ if (pending.kind === "add-feed" && pending.feedId === feed.feedId) {
10310
+ settleFeedMutation(requestId, "ok");
10311
+ break;
10312
+ }
10313
+ }
10314
+ }
10315
+ break;
10316
+ }
10317
+ case ServerMsgCode.FEEDS_UPDATED: {
10318
+ for (const feed of message.feeds) {
10319
+ for (const [requestId, pending] of [...pendingFeedMutations]) {
10320
+ if (pending.kind === "update-feed" && pending.feedId === feed.feedId) {
10321
+ settleFeedMutation(requestId, "ok");
10322
+ }
10323
+ }
10324
+ }
10325
+ break;
10326
+ }
10327
+ case ServerMsgCode.FEED_DELETED: {
10328
+ for (const [requestId, pending] of [...pendingFeedMutations]) {
10329
+ if (pending.kind === "delete-feed" && pending.feedId === message.feedId) {
10330
+ settleFeedMutation(requestId, "ok");
10331
+ break;
10332
+ }
10333
+ }
10334
+ break;
10335
+ }
10336
+ case ServerMsgCode.FEED_MESSAGES_ADDED: {
10337
+ for (const m of message.messages) {
10338
+ let matched = false;
10339
+ for (const [requestId, pending] of [...pendingFeedMutations]) {
10340
+ if (pending.kind === "add-message" && pending.feedId === message.feedId && pending.expectedClientMessageId === m.id) {
10341
+ settleFeedMutation(requestId, "ok");
10342
+ matched = true;
10343
+ break;
10344
+ }
10345
+ }
10346
+ if (!matched) {
10347
+ const q = pendingAddMessageFifoByFeed.get(message.feedId);
10348
+ const headId = _optionalChain([q, 'optionalAccess', _233 => _233[0]]);
10349
+ if (headId !== void 0) {
10350
+ const pending = pendingFeedMutations.get(headId);
10351
+ if (_optionalChain([pending, 'optionalAccess', _234 => _234.kind]) === "add-message" && pending.expectedClientMessageId === void 0) {
10352
+ settleFeedMutation(headId, "ok");
10353
+ }
10354
+ }
10355
+ }
10356
+ }
10357
+ break;
10358
+ }
10359
+ case ServerMsgCode.FEED_MESSAGES_UPDATED: {
10360
+ for (const m of message.messages) {
10361
+ for (const [requestId, pending] of [...pendingFeedMutations]) {
10362
+ if (pending.kind === "update-message" && pending.feedId === message.feedId && pending.messageId === m.id) {
10363
+ settleFeedMutation(requestId, "ok");
10364
+ }
10365
+ }
10366
+ }
10367
+ break;
10368
+ }
10369
+ case ServerMsgCode.FEED_MESSAGES_DELETED: {
10370
+ for (const mid of message.messageIds) {
10371
+ for (const [requestId, pending] of [...pendingFeedMutations]) {
10372
+ if (pending.kind === "delete-message" && pending.feedId === message.feedId && pending.messageId === mid) {
10373
+ settleFeedMutation(requestId, "ok");
10374
+ }
10375
+ }
10376
+ }
10377
+ break;
10378
+ }
10379
+ default:
10380
+ break;
10381
+ }
10399
10382
  }
10400
- let _getStorage$ = null;
10401
- let _resolveStoragePromise = null;
10402
10383
  function processInitialStorage(nodes) {
10403
10384
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
10404
10385
  createOrUpdateRootFromMessage(nodes);
10405
10386
  applyAndSendOfflineOps(unacknowledgedOps);
10406
- _optionalChain([_resolveStoragePromise, 'optionalCall', _238 => _238()]);
10387
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _235 => _235()]);
10407
10388
  notifyStorageStatus();
10408
10389
  eventHub.storageDidLoad.notify();
10409
10390
  }
@@ -10421,7 +10402,7 @@ function createRoom(options, config) {
10421
10402
  } else if (!messages.some((msg) => msg.type === ClientMsgCode.FETCH_STORAGE)) {
10422
10403
  messages.push({ type: ClientMsgCode.FETCH_STORAGE });
10423
10404
  nodeMapBuffer.take();
10424
- _optionalChain([stopwatch, 'optionalAccess', _239 => _239.start, 'call', _240 => _240()]);
10405
+ _optionalChain([stopwatch, 'optionalAccess', _236 => _236.start, 'call', _237 => _237()]);
10425
10406
  }
10426
10407
  if (options2.flush) {
10427
10408
  flushNowOrSoon();
@@ -10470,6 +10451,138 @@ function createRoom(options, config) {
10470
10451
  }
10471
10452
  flushNowOrSoon();
10472
10453
  }
10454
+ async function fetchFeeds(options2) {
10455
+ const requestId = nanoid();
10456
+ const { promise, resolve, reject } = Promise_withResolvers();
10457
+ pendingFeedsRequests.set(requestId, { resolve, reject });
10458
+ const message = {
10459
+ type: ClientMsgCode.FETCH_FEEDS,
10460
+ requestId,
10461
+ cursor: _optionalChain([options2, 'optionalAccess', _238 => _238.cursor]),
10462
+ since: _optionalChain([options2, 'optionalAccess', _239 => _239.since]),
10463
+ limit: _optionalChain([options2, 'optionalAccess', _240 => _240.limit]),
10464
+ metadata: _optionalChain([options2, 'optionalAccess', _241 => _241.metadata])
10465
+ };
10466
+ context.buffer.messages.push(message);
10467
+ flushNowOrSoon();
10468
+ setTimeout(() => {
10469
+ if (pendingFeedsRequests.has(requestId)) {
10470
+ pendingFeedsRequests.delete(requestId);
10471
+ reject(new Error("Feeds fetch timeout"));
10472
+ }
10473
+ }, FEEDS_TIMEOUT);
10474
+ return promise;
10475
+ }
10476
+ async function fetchFeedMessages(feedId, options2) {
10477
+ const requestId = nanoid();
10478
+ const { promise, resolve, reject } = Promise_withResolvers();
10479
+ pendingFeedMessagesRequests.set(requestId, { resolve, reject });
10480
+ const message = {
10481
+ type: ClientMsgCode.FETCH_FEED_MESSAGES,
10482
+ requestId,
10483
+ feedId,
10484
+ cursor: _optionalChain([options2, 'optionalAccess', _242 => _242.cursor]),
10485
+ since: _optionalChain([options2, 'optionalAccess', _243 => _243.since]),
10486
+ limit: _optionalChain([options2, 'optionalAccess', _244 => _244.limit])
10487
+ };
10488
+ context.buffer.messages.push(message);
10489
+ flushNowOrSoon();
10490
+ setTimeout(() => {
10491
+ if (pendingFeedMessagesRequests.has(requestId)) {
10492
+ pendingFeedMessagesRequests.delete(requestId);
10493
+ reject(new Error("Feed messages fetch timeout"));
10494
+ }
10495
+ }, FEEDS_TIMEOUT);
10496
+ return promise;
10497
+ }
10498
+ function addFeed(feedId, options2) {
10499
+ const requestId = nanoid();
10500
+ const promise = registerFeedMutation(requestId, "add-feed", feedId);
10501
+ const message = {
10502
+ type: ClientMsgCode.ADD_FEED,
10503
+ requestId,
10504
+ feedId,
10505
+ metadata: _optionalChain([options2, 'optionalAccess', _245 => _245.metadata]),
10506
+ createdAt: _optionalChain([options2, 'optionalAccess', _246 => _246.createdAt])
10507
+ };
10508
+ context.buffer.messages.push(message);
10509
+ flushNowOrSoon();
10510
+ return promise;
10511
+ }
10512
+ function updateFeed(feedId, metadata) {
10513
+ const requestId = nanoid();
10514
+ const promise = registerFeedMutation(requestId, "update-feed", feedId);
10515
+ const message = {
10516
+ type: ClientMsgCode.UPDATE_FEED,
10517
+ requestId,
10518
+ feedId,
10519
+ metadata
10520
+ };
10521
+ context.buffer.messages.push(message);
10522
+ flushNowOrSoon();
10523
+ return promise;
10524
+ }
10525
+ function deleteFeed(feedId) {
10526
+ const requestId = nanoid();
10527
+ const promise = registerFeedMutation(requestId, "delete-feed", feedId);
10528
+ const message = {
10529
+ type: ClientMsgCode.DELETE_FEED,
10530
+ requestId,
10531
+ feedId
10532
+ };
10533
+ context.buffer.messages.push(message);
10534
+ flushNowOrSoon();
10535
+ return promise;
10536
+ }
10537
+ function addFeedMessage(feedId, data, options2) {
10538
+ const requestId = nanoid();
10539
+ const promise = registerFeedMutation(requestId, "add-message", feedId, {
10540
+ expectedClientMessageId: _optionalChain([options2, 'optionalAccess', _247 => _247.id])
10541
+ });
10542
+ const message = {
10543
+ type: ClientMsgCode.ADD_FEED_MESSAGE,
10544
+ requestId,
10545
+ feedId,
10546
+ data,
10547
+ id: _optionalChain([options2, 'optionalAccess', _248 => _248.id]),
10548
+ createdAt: _optionalChain([options2, 'optionalAccess', _249 => _249.createdAt])
10549
+ };
10550
+ context.buffer.messages.push(message);
10551
+ flushNowOrSoon();
10552
+ return promise;
10553
+ }
10554
+ function updateFeedMessage(feedId, messageId, data, options2) {
10555
+ const requestId = nanoid();
10556
+ const promise = registerFeedMutation(requestId, "update-message", feedId, {
10557
+ messageId
10558
+ });
10559
+ const message = {
10560
+ type: ClientMsgCode.UPDATE_FEED_MESSAGE,
10561
+ requestId,
10562
+ feedId,
10563
+ messageId,
10564
+ data,
10565
+ updatedAt: _optionalChain([options2, 'optionalAccess', _250 => _250.updatedAt])
10566
+ };
10567
+ context.buffer.messages.push(message);
10568
+ flushNowOrSoon();
10569
+ return promise;
10570
+ }
10571
+ function deleteFeedMessage(feedId, messageId) {
10572
+ const requestId = nanoid();
10573
+ const promise = registerFeedMutation(requestId, "delete-message", feedId, {
10574
+ messageId
10575
+ });
10576
+ const message = {
10577
+ type: ClientMsgCode.DELETE_FEED_MESSAGE,
10578
+ requestId,
10579
+ feedId,
10580
+ messageId
10581
+ };
10582
+ context.buffer.messages.push(message);
10583
+ flushNowOrSoon();
10584
+ return promise;
10585
+ }
10473
10586
  function undo() {
10474
10587
  if (context.activeBatch) {
10475
10588
  throw new Error("undo is not allowed during a batch");
@@ -10522,7 +10635,8 @@ function createRoom(options, config) {
10522
10635
  presence: false,
10523
10636
  others: []
10524
10637
  },
10525
- reverseOps: new Deque()
10638
+ reverseOps: new Deque(),
10639
+ scheduleHistoryResume: false
10526
10640
  };
10527
10641
  try {
10528
10642
  returnValue = callback();
@@ -10532,6 +10646,9 @@ function createRoom(options, config) {
10532
10646
  if (currentBatch.reverseOps.length > 0) {
10533
10647
  addToUndoStack(Array.from(currentBatch.reverseOps));
10534
10648
  }
10649
+ if (currentBatch.scheduleHistoryResume) {
10650
+ commitPausedHistoryToUndoStack();
10651
+ }
10535
10652
  if (currentBatch.ops.length > 0) {
10536
10653
  context.redoStack.length = 0;
10537
10654
  }
@@ -10548,13 +10665,20 @@ function createRoom(options, config) {
10548
10665
  context.pausedHistory = new Deque();
10549
10666
  }
10550
10667
  }
10551
- function resumeHistory() {
10668
+ function commitPausedHistoryToUndoStack() {
10552
10669
  const frames = context.pausedHistory;
10553
10670
  context.pausedHistory = null;
10554
10671
  if (frames !== null && frames.length > 0) {
10555
10672
  _addToRealUndoStack(Array.from(frames));
10556
10673
  }
10557
10674
  }
10675
+ function resumeHistory() {
10676
+ if (context.activeBatch !== null) {
10677
+ context.activeBatch.scheduleHistoryResume = true;
10678
+ return;
10679
+ }
10680
+ commitPausedHistoryToUndoStack();
10681
+ }
10558
10682
  function withoutHistory(fn) {
10559
10683
  const undoBefore = context.undoStack.length;
10560
10684
  const redoBefore = context.redoStack.length;
@@ -10622,6 +10746,7 @@ function createRoom(options, config) {
10622
10746
  storageStatus: eventHub.storageStatus.observable,
10623
10747
  ydoc: eventHub.ydoc.observable,
10624
10748
  comments: eventHub.comments.observable,
10749
+ feeds: eventHub.feeds.observable,
10625
10750
  roomWillDestroy: eventHub.roomWillDestroy.observable
10626
10751
  };
10627
10752
  async function getThreadsSince(options2) {
@@ -10634,8 +10759,8 @@ function createRoom(options, config) {
10634
10759
  async function getThreads(options2) {
10635
10760
  return httpClient.getThreads({
10636
10761
  roomId,
10637
- query: _optionalChain([options2, 'optionalAccess', _241 => _241.query]),
10638
- cursor: _optionalChain([options2, 'optionalAccess', _242 => _242.cursor])
10762
+ query: _optionalChain([options2, 'optionalAccess', _251 => _251.query]),
10763
+ cursor: _optionalChain([options2, 'optionalAccess', _252 => _252.cursor])
10639
10764
  });
10640
10765
  }
10641
10766
  async function getThread(threadId) {
@@ -10757,7 +10882,7 @@ function createRoom(options, config) {
10757
10882
  function getSubscriptionSettings(options2) {
10758
10883
  return httpClient.getSubscriptionSettings({
10759
10884
  roomId,
10760
- signal: _optionalChain([options2, 'optionalAccess', _243 => _243.signal])
10885
+ signal: _optionalChain([options2, 'optionalAccess', _253 => _253.signal])
10761
10886
  });
10762
10887
  }
10763
10888
  function updateSubscriptionSettings(settings) {
@@ -10779,7 +10904,7 @@ function createRoom(options, config) {
10779
10904
  {
10780
10905
  [kInternal]: {
10781
10906
  get presenceBuffer() {
10782
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _244 => _244.buffer, 'access', _245 => _245.presenceUpdates, 'optionalAccess', _246 => _246.data]), () => ( null)));
10907
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _254 => _254.buffer, 'access', _255 => _255.presenceUpdates, 'optionalAccess', _256 => _256.data]), () => ( null)));
10783
10908
  },
10784
10909
  // prettier-ignore
10785
10910
  get undoStack() {
@@ -10794,9 +10919,9 @@ function createRoom(options, config) {
10794
10919
  return context.yjsProvider;
10795
10920
  },
10796
10921
  setYjsProvider(newProvider) {
10797
- _optionalChain([context, 'access', _247 => _247.yjsProvider, 'optionalAccess', _248 => _248.off, 'call', _249 => _249("status", yjsStatusDidChange)]);
10922
+ _optionalChain([context, 'access', _257 => _257.yjsProvider, 'optionalAccess', _258 => _258.off, 'call', _259 => _259("status", yjsStatusDidChange)]);
10798
10923
  context.yjsProvider = newProvider;
10799
- _optionalChain([newProvider, 'optionalAccess', _250 => _250.on, 'call', _251 => _251("status", yjsStatusDidChange)]);
10924
+ _optionalChain([newProvider, 'optionalAccess', _260 => _260.on, 'call', _261 => _261("status", yjsStatusDidChange)]);
10800
10925
  context.yjsProviderDidChange.notify();
10801
10926
  },
10802
10927
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -10831,19 +10956,25 @@ function createRoom(options, config) {
10831
10956
  id: roomId,
10832
10957
  subscribe: makeClassicSubscribeFn(
10833
10958
  roomId,
10834
- events,
10959
+ eventHub,
10835
10960
  config.errorEventSource
10836
10961
  ),
10837
10962
  connect: () => managedSocket.connect(),
10838
10963
  reconnect: () => managedSocket.reconnect(),
10839
10964
  disconnect: () => managedSocket.disconnect(),
10840
10965
  destroy: () => {
10966
+ pendingFeedsRequests.forEach(
10967
+ (request) => request.reject(new Error("Room destroyed"))
10968
+ );
10969
+ pendingFeedMessagesRequests.forEach(
10970
+ (request) => request.reject(new Error("Room destroyed"))
10971
+ );
10841
10972
  const { roomWillDestroy, ...eventsExceptDestroy } = eventHub;
10842
10973
  for (const source of Object.values(eventsExceptDestroy)) {
10843
10974
  source.dispose();
10844
10975
  }
10845
10976
  eventHub.roomWillDestroy.notify();
10846
- _optionalChain([context, 'access', _252 => _252.yjsProvider, 'optionalAccess', _253 => _253.off, 'call', _254 => _254("status", yjsStatusDidChange)]);
10977
+ _optionalChain([context, 'access', _262 => _262.yjsProvider, 'optionalAccess', _263 => _263.off, 'call', _264 => _264("status", yjsStatusDidChange)]);
10847
10978
  syncSourceForStorage.destroy();
10848
10979
  syncSourceForYjs.destroy();
10849
10980
  uninstallBgTabSpy();
@@ -10869,6 +11000,14 @@ function createRoom(options, config) {
10869
11000
  }
10870
11001
  },
10871
11002
  fetchYDoc,
11003
+ fetchFeeds,
11004
+ fetchFeedMessages,
11005
+ addFeed,
11006
+ updateFeed,
11007
+ deleteFeed,
11008
+ addFeedMessage,
11009
+ updateFeedMessage,
11010
+ deleteFeedMessage,
10872
11011
  getStorage,
10873
11012
  getStorageSnapshot,
10874
11013
  getStorageStatus,
@@ -10997,7 +11136,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
10997
11136
  }
10998
11137
  if (isLiveNode(first)) {
10999
11138
  const node = first;
11000
- if (_optionalChain([options, 'optionalAccess', _255 => _255.isDeep])) {
11139
+ if (_optionalChain([options, 'optionalAccess', _265 => _265.isDeep])) {
11001
11140
  const storageCallback = second;
11002
11141
  return subscribeToLiveStructureDeeply(node, storageCallback);
11003
11142
  } else {
@@ -11083,8 +11222,8 @@ function createClient(options) {
11083
11222
  const authManager = createAuthManager(options, (token) => {
11084
11223
  currentUserId.set(() => token.uid);
11085
11224
  });
11086
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _256 => _256.polyfills, 'optionalAccess', _257 => _257.fetch]) || /* istanbul ignore next */
11087
- _optionalChain([globalThis, 'access', _258 => _258.fetch, 'optionalAccess', _259 => _259.bind, 'call', _260 => _260(globalThis)]);
11225
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _266 => _266.polyfills, 'optionalAccess', _267 => _267.fetch]) || /* istanbul ignore next */
11226
+ _optionalChain([globalThis, 'access', _268 => _268.fetch, 'optionalAccess', _269 => _269.bind, 'call', _270 => _270(globalThis)]);
11088
11227
  const httpClient = createApiClient({
11089
11228
  baseUrl,
11090
11229
  fetchPolyfill,
@@ -11102,7 +11241,7 @@ function createClient(options) {
11102
11241
  delegates: {
11103
11242
  createSocket: makeCreateSocketDelegateForAi(
11104
11243
  baseUrl,
11105
- _optionalChain([clientOptions, 'access', _261 => _261.polyfills, 'optionalAccess', _262 => _262.WebSocket])
11244
+ _optionalChain([clientOptions, 'access', _271 => _271.polyfills, 'optionalAccess', _272 => _272.WebSocket])
11106
11245
  ),
11107
11246
  authenticate: async () => {
11108
11247
  const resp = await authManager.getAuthValue({
@@ -11162,7 +11301,7 @@ function createClient(options) {
11162
11301
  createSocket: makeCreateSocketDelegateForRoom(
11163
11302
  roomId,
11164
11303
  baseUrl,
11165
- _optionalChain([clientOptions, 'access', _263 => _263.polyfills, 'optionalAccess', _264 => _264.WebSocket])
11304
+ _optionalChain([clientOptions, 'access', _273 => _273.polyfills, 'optionalAccess', _274 => _274.WebSocket])
11166
11305
  ),
11167
11306
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
11168
11307
  })),
@@ -11185,7 +11324,7 @@ function createClient(options) {
11185
11324
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
11186
11325
  if (shouldConnect) {
11187
11326
  if (typeof atob === "undefined") {
11188
- if (_optionalChain([clientOptions, 'access', _265 => _265.polyfills, 'optionalAccess', _266 => _266.atob]) === void 0) {
11327
+ if (_optionalChain([clientOptions, 'access', _275 => _275.polyfills, 'optionalAccess', _276 => _276.atob]) === void 0) {
11189
11328
  throw new Error(
11190
11329
  "You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
11191
11330
  );
@@ -11197,7 +11336,7 @@ function createClient(options) {
11197
11336
  return leaseRoom(newRoomDetails);
11198
11337
  }
11199
11338
  function getRoom(roomId) {
11200
- const room = _optionalChain([roomsById, 'access', _267 => _267.get, 'call', _268 => _268(roomId), 'optionalAccess', _269 => _269.room]);
11339
+ const room = _optionalChain([roomsById, 'access', _277 => _277.get, 'call', _278 => _278(roomId), 'optionalAccess', _279 => _279.room]);
11201
11340
  return room ? room : null;
11202
11341
  }
11203
11342
  function logout() {
@@ -11213,7 +11352,7 @@ function createClient(options) {
11213
11352
  const batchedResolveUsers = new Batch(
11214
11353
  async (batchedUserIds) => {
11215
11354
  const userIds = batchedUserIds.flat();
11216
- const users = await _optionalChain([resolveUsers, 'optionalCall', _270 => _270({ userIds })]);
11355
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _280 => _280({ userIds })]);
11217
11356
  warnOnceIf(
11218
11357
  !resolveUsers,
11219
11358
  "Set the resolveUsers option in createClient to specify user info."
@@ -11230,7 +11369,7 @@ function createClient(options) {
11230
11369
  const batchedResolveRoomsInfo = new Batch(
11231
11370
  async (batchedRoomIds) => {
11232
11371
  const roomIds = batchedRoomIds.flat();
11233
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _271 => _271({ roomIds })]);
11372
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _281 => _281({ roomIds })]);
11234
11373
  warnOnceIf(
11235
11374
  !resolveRoomsInfo,
11236
11375
  "Set the resolveRoomsInfo option in createClient to specify room info."
@@ -11247,7 +11386,7 @@ function createClient(options) {
11247
11386
  const batchedResolveGroupsInfo = new Batch(
11248
11387
  async (batchedGroupIds) => {
11249
11388
  const groupIds = batchedGroupIds.flat();
11250
- const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _272 => _272({ groupIds })]);
11389
+ const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _282 => _282({ groupIds })]);
11251
11390
  warnOnceIf(
11252
11391
  !resolveGroupsInfo,
11253
11392
  "Set the resolveGroupsInfo option in createClient to specify group info."
@@ -11303,7 +11442,7 @@ function createClient(options) {
11303
11442
  }
11304
11443
  };
11305
11444
  const win = typeof window !== "undefined" ? window : void 0;
11306
- _optionalChain([win, 'optionalAccess', _273 => _273.addEventListener, 'call', _274 => _274("beforeunload", maybePreventClose)]);
11445
+ _optionalChain([win, 'optionalAccess', _283 => _283.addEventListener, 'call', _284 => _284("beforeunload", maybePreventClose)]);
11307
11446
  }
11308
11447
  async function getNotificationSettings(options2) {
11309
11448
  const plainSettings = await httpClient.getNotificationSettings(options2);
@@ -11430,7 +11569,7 @@ var commentBodyElementsTypes = {
11430
11569
  mention: "inline"
11431
11570
  };
11432
11571
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
11433
- if (!body || !_optionalChain([body, 'optionalAccess', _275 => _275.content])) {
11572
+ if (!body || !_optionalChain([body, 'optionalAccess', _285 => _285.content])) {
11434
11573
  return;
11435
11574
  }
11436
11575
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -11440,13 +11579,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
11440
11579
  for (const block of body.content) {
11441
11580
  if (type === "all" || type === "block") {
11442
11581
  if (guard(block)) {
11443
- _optionalChain([visitor, 'optionalCall', _276 => _276(block)]);
11582
+ _optionalChain([visitor, 'optionalCall', _286 => _286(block)]);
11444
11583
  }
11445
11584
  }
11446
11585
  if (type === "all" || type === "inline") {
11447
11586
  for (const inline of block.children) {
11448
11587
  if (guard(inline)) {
11449
- _optionalChain([visitor, 'optionalCall', _277 => _277(inline)]);
11588
+ _optionalChain([visitor, 'optionalCall', _287 => _287(inline)]);
11450
11589
  }
11451
11590
  }
11452
11591
  }
@@ -11616,7 +11755,7 @@ var stringifyCommentBodyPlainElements = {
11616
11755
  text: ({ element }) => element.text,
11617
11756
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
11618
11757
  mention: ({ element, user, group }) => {
11619
- return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _278 => _278.name]), () => ( _optionalChain([group, 'optionalAccess', _279 => _279.name]))), () => ( element.id))}`;
11758
+ return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _288 => _288.name]), () => ( _optionalChain([group, 'optionalAccess', _289 => _289.name]))), () => ( element.id))}`;
11620
11759
  }
11621
11760
  };
11622
11761
  var stringifyCommentBodyHtmlElements = {
@@ -11646,7 +11785,7 @@ var stringifyCommentBodyHtmlElements = {
11646
11785
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
11647
11786
  },
11648
11787
  mention: ({ element, user, group }) => {
11649
- return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _280 => _280.name]) ? html`${_optionalChain([user, 'optionalAccess', _281 => _281.name])}` : _optionalChain([group, 'optionalAccess', _282 => _282.name]) ? html`${_optionalChain([group, 'optionalAccess', _283 => _283.name])}` : element.id}</span>`;
11788
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _290 => _290.name]) ? html`${_optionalChain([user, 'optionalAccess', _291 => _291.name])}` : _optionalChain([group, 'optionalAccess', _292 => _292.name]) ? html`${_optionalChain([group, 'optionalAccess', _293 => _293.name])}` : element.id}</span>`;
11650
11789
  }
11651
11790
  };
11652
11791
  var stringifyCommentBodyMarkdownElements = {
@@ -11661,118 +11800,404 @@ var stringifyCommentBodyMarkdownElements = {
11661
11800
  if (element.bold) {
11662
11801
  children = markdown`**${children}**`;
11663
11802
  }
11664
- if (element.italic) {
11665
- children = markdown`_${children}_`;
11803
+ if (element.italic) {
11804
+ children = markdown`_${children}_`;
11805
+ }
11806
+ if (element.strikethrough) {
11807
+ children = markdown`~~${children}~~`;
11808
+ }
11809
+ if (element.code) {
11810
+ children = markdown`\`${children}\``;
11811
+ }
11812
+ return children;
11813
+ },
11814
+ link: ({ element, href }) => {
11815
+ return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
11816
+ },
11817
+ mention: ({ element, user, group }) => {
11818
+ return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _294 => _294.name]), () => ( _optionalChain([group, 'optionalAccess', _295 => _295.name]))), () => ( element.id))}`;
11819
+ }
11820
+ };
11821
+ async function stringifyCommentBody(body, options) {
11822
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _296 => _296.format]), () => ( "plain"));
11823
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _297 => _297.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
11824
+ const elements = {
11825
+ ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
11826
+ ..._optionalChain([options, 'optionalAccess', _298 => _298.elements])
11827
+ };
11828
+ const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
11829
+ body,
11830
+ _optionalChain([options, 'optionalAccess', _299 => _299.resolveUsers]),
11831
+ _optionalChain([options, 'optionalAccess', _300 => _300.resolveGroupsInfo])
11832
+ );
11833
+ const blocks = body.content.flatMap((block, blockIndex) => {
11834
+ switch (block.type) {
11835
+ case "paragraph": {
11836
+ const inlines = block.children.flatMap((inline, inlineIndex) => {
11837
+ if (isCommentBodyMention(inline)) {
11838
+ return inline.id ? [
11839
+ elements.mention(
11840
+ {
11841
+ element: inline,
11842
+ user: inline.kind === "user" ? resolvedUsers.get(inline.id) : void 0,
11843
+ group: inline.kind === "group" ? resolvedGroupsInfo.get(inline.id) : void 0
11844
+ },
11845
+ inlineIndex
11846
+ )
11847
+ ] : [];
11848
+ }
11849
+ if (isCommentBodyLink(inline)) {
11850
+ const href = sanitizeUrl(inline.url);
11851
+ if (href === null) {
11852
+ return [
11853
+ elements.text(
11854
+ {
11855
+ element: { text: _nullishCoalesce(inline.text, () => ( inline.url)) }
11856
+ },
11857
+ inlineIndex
11858
+ )
11859
+ ];
11860
+ }
11861
+ return [
11862
+ elements.link(
11863
+ {
11864
+ element: inline,
11865
+ href
11866
+ },
11867
+ inlineIndex
11868
+ )
11869
+ ];
11870
+ }
11871
+ if (isCommentBodyText(inline)) {
11872
+ return [elements.text({ element: inline }, inlineIndex)];
11873
+ }
11874
+ return [];
11875
+ });
11876
+ return [
11877
+ elements.paragraph(
11878
+ { element: block, children: inlines.join("") },
11879
+ blockIndex
11880
+ )
11881
+ ];
11882
+ }
11883
+ default:
11884
+ return [];
11885
+ }
11886
+ });
11887
+ return blocks.join(separator);
11888
+ }
11889
+
11890
+ // src/crdts/utils.ts
11891
+ function toPlainLson(lson) {
11892
+ if (lson instanceof LiveObject) {
11893
+ return {
11894
+ liveblocksType: "LiveObject",
11895
+ data: Object.fromEntries(
11896
+ Object.entries(lson.toObject()).flatMap(
11897
+ ([key, value]) => value !== void 0 ? [[key, toPlainLson(value)]] : []
11898
+ )
11899
+ )
11900
+ };
11901
+ } else if (lson instanceof LiveMap) {
11902
+ return {
11903
+ liveblocksType: "LiveMap",
11904
+ data: Object.fromEntries(
11905
+ [...lson].map(([key, value]) => [key, toPlainLson(value)])
11906
+ )
11907
+ };
11908
+ } else if (lson instanceof LiveList) {
11909
+ return {
11910
+ liveblocksType: "LiveList",
11911
+ data: [...lson].map((item) => toPlainLson(item))
11912
+ };
11913
+ } else {
11914
+ return lson;
11915
+ }
11916
+ }
11917
+
11918
+ // src/immutable.ts
11919
+ function lsonObjectToJson(obj) {
11920
+ const result = {};
11921
+ for (const key in obj) {
11922
+ const val = obj[key];
11923
+ if (val !== void 0) {
11924
+ result[key] = lsonToJson(val);
11925
+ }
11926
+ }
11927
+ return result;
11928
+ }
11929
+ function liveObjectToJson(liveObject) {
11930
+ return lsonObjectToJson(liveObject.toObject());
11931
+ }
11932
+ function liveMapToJson(map) {
11933
+ const result = {};
11934
+ for (const [key, value] of map.entries()) {
11935
+ result[key] = lsonToJson(value);
11936
+ }
11937
+ return result;
11938
+ }
11939
+ function lsonListToJson(value) {
11940
+ return value.map(lsonToJson);
11941
+ }
11942
+ function liveListToJson(value) {
11943
+ return lsonListToJson(value.toArray());
11944
+ }
11945
+ function lsonToJson(value) {
11946
+ if (value instanceof LiveObject) {
11947
+ return liveObjectToJson(value);
11948
+ } else if (value instanceof LiveList) {
11949
+ return liveListToJson(value);
11950
+ } else if (value instanceof LiveMap) {
11951
+ return liveMapToJson(value);
11952
+ } else if (value instanceof LiveRegister) {
11953
+ return value.data;
11954
+ }
11955
+ if (Array.isArray(value)) {
11956
+ return lsonListToJson(value);
11957
+ } else if (isPlainObject(value)) {
11958
+ return lsonObjectToJson(value);
11959
+ }
11960
+ return value;
11961
+ }
11962
+ function legacy_patchLiveList(liveList, prev, next) {
11963
+ let i = 0;
11964
+ let prevEnd = prev.length - 1;
11965
+ let nextEnd = next.length - 1;
11966
+ let prevNode = prev[0];
11967
+ let nextNode = next[0];
11968
+ outer: {
11969
+ while (prevNode === nextNode) {
11970
+ ++i;
11971
+ if (i > prevEnd || i > nextEnd) {
11972
+ break outer;
11973
+ }
11974
+ prevNode = prev[i];
11975
+ nextNode = next[i];
11976
+ }
11977
+ prevNode = prev[prevEnd];
11978
+ nextNode = next[nextEnd];
11979
+ while (prevNode === nextNode) {
11980
+ prevEnd--;
11981
+ nextEnd--;
11982
+ if (i > prevEnd || i > nextEnd) {
11983
+ break outer;
11984
+ }
11985
+ prevNode = prev[prevEnd];
11986
+ nextNode = next[nextEnd];
11987
+ }
11988
+ }
11989
+ if (i > prevEnd) {
11990
+ if (i <= nextEnd) {
11991
+ while (i <= nextEnd) {
11992
+ liveList.insert(deepLiveify(next[i]), i);
11993
+ i++;
11994
+ }
11995
+ }
11996
+ } else if (i > nextEnd) {
11997
+ let localI = i;
11998
+ while (localI <= prevEnd) {
11999
+ liveList.delete(i);
12000
+ localI++;
12001
+ }
12002
+ } else {
12003
+ while (i <= prevEnd && i <= nextEnd) {
12004
+ prevNode = prev[i];
12005
+ nextNode = next[i];
12006
+ const liveListNode = liveList.get(i);
12007
+ if (isLiveObject(liveListNode) && isPlainObject(prevNode) && isPlainObject(nextNode)) {
12008
+ legacy_patchLiveObject(liveListNode, prevNode, nextNode);
12009
+ } else {
12010
+ liveList.set(i, deepLiveify(nextNode));
12011
+ }
12012
+ i++;
12013
+ }
12014
+ while (i <= nextEnd) {
12015
+ liveList.insert(deepLiveify(next[i]), i);
12016
+ i++;
12017
+ }
12018
+ let localI = i;
12019
+ while (localI <= prevEnd) {
12020
+ liveList.delete(i);
12021
+ localI++;
12022
+ }
12023
+ }
12024
+ }
12025
+ function legacy_patchLiveObjectKey(liveObject, key, prev, next) {
12026
+ if (process.env.NODE_ENV !== "production") {
12027
+ const nonSerializableValue = findNonSerializableValue(next);
12028
+ if (nonSerializableValue) {
12029
+ error2(
12030
+ `New state path: '${nonSerializableValue.path}' value: '${String(
12031
+ nonSerializableValue.value
12032
+ )}' is not serializable.
12033
+ Only serializable value can be synced with Liveblocks.`
12034
+ );
12035
+ return;
11666
12036
  }
11667
- if (element.strikethrough) {
11668
- children = markdown`~~${children}~~`;
12037
+ }
12038
+ const value = liveObject.get(key);
12039
+ if (next === void 0) {
12040
+ liveObject.delete(key);
12041
+ } else if (value === void 0) {
12042
+ liveObject.set(key, deepLiveify(next));
12043
+ } else if (prev === next) {
12044
+ return;
12045
+ } else if (isLiveList(value) && Array.isArray(prev) && Array.isArray(next)) {
12046
+ legacy_patchLiveList(value, prev, next);
12047
+ } else if (isLiveObject(value) && isPlainObject(prev) && isPlainObject(next)) {
12048
+ legacy_patchLiveObject(value, prev, next);
12049
+ } else {
12050
+ liveObject.set(key, deepLiveify(next));
12051
+ }
12052
+ }
12053
+ function legacy_patchLiveObject(root, prev, next) {
12054
+ const updates = {};
12055
+ for (const key in next) {
12056
+ legacy_patchLiveObjectKey(root, key, prev[key], next[key]);
12057
+ }
12058
+ for (const key in prev) {
12059
+ if (next[key] === void 0) {
12060
+ root.delete(key);
11669
12061
  }
11670
- if (element.code) {
11671
- children = markdown`\`${children}\``;
12062
+ }
12063
+ if (Object.keys(updates).length > 0) {
12064
+ root.update(updates);
12065
+ }
12066
+ }
12067
+ function getParentsPath(node) {
12068
+ const path = [];
12069
+ while (node.parent.type === "HasParent") {
12070
+ if (isLiveList(node.parent.node)) {
12071
+ path.push(node.parent.node._indexOfPosition(node.parent.key));
12072
+ } else {
12073
+ path.push(node.parent.key);
11672
12074
  }
11673
- return children;
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))}`;
12075
+ node = node.parent.node;
11680
12076
  }
11681
- };
11682
- async function stringifyCommentBody(body, options) {
11683
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _286 => _286.format]), () => ( "plain"));
11684
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _287 => _287.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
11685
- const elements = {
11686
- ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
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])
12077
+ return path;
12078
+ }
12079
+ function legacy_patchImmutableObject(state, updates) {
12080
+ return updates.reduce(
12081
+ (state2, update) => legacy_patchImmutableObjectWithUpdate(state2, update),
12082
+ state
11693
12083
  );
11694
- const blocks = body.content.flatMap((block, blockIndex) => {
11695
- switch (block.type) {
11696
- case "paragraph": {
11697
- const inlines = block.children.flatMap((inline, inlineIndex) => {
11698
- if (isCommentBodyMention(inline)) {
11699
- return inline.id ? [
11700
- elements.mention(
11701
- {
11702
- element: inline,
11703
- user: inline.kind === "user" ? resolvedUsers.get(inline.id) : void 0,
11704
- group: inline.kind === "group" ? resolvedGroupsInfo.get(inline.id) : void 0
11705
- },
11706
- inlineIndex
11707
- )
11708
- ] : [];
12084
+ }
12085
+ function legacy_patchImmutableObjectWithUpdate(state, update) {
12086
+ const path = getParentsPath(update.node);
12087
+ return legacy_patchImmutableNode(state, path, update);
12088
+ }
12089
+ function legacy_patchImmutableNode(state, path, update) {
12090
+ const pathItem = path.pop();
12091
+ if (pathItem === void 0) {
12092
+ switch (update.type) {
12093
+ case "LiveObject": {
12094
+ if (!isJsonObject(state)) {
12095
+ throw new Error(
12096
+ "Internal: received update on LiveObject but state was not an object"
12097
+ );
12098
+ }
12099
+ const newState = Object.assign({}, state);
12100
+ for (const key in update.updates) {
12101
+ if (_optionalChain([update, 'access', _301 => _301.updates, 'access', _302 => _302[key], 'optionalAccess', _303 => _303.type]) === "update") {
12102
+ const val = update.node.get(key);
12103
+ if (val !== void 0) {
12104
+ newState[key] = lsonToJson(val);
12105
+ }
12106
+ } else if (_optionalChain([update, 'access', _304 => _304.updates, 'access', _305 => _305[key], 'optionalAccess', _306 => _306.type]) === "delete") {
12107
+ delete newState[key];
11709
12108
  }
11710
- if (isCommentBodyLink(inline)) {
11711
- const href = sanitizeUrl(inline.url);
11712
- if (href === null) {
11713
- return [
11714
- elements.text(
11715
- {
11716
- element: { text: _nullishCoalesce(inline.text, () => ( inline.url)) }
11717
- },
11718
- inlineIndex
11719
- )
12109
+ }
12110
+ return newState;
12111
+ }
12112
+ case "LiveList": {
12113
+ if (!Array.isArray(state)) {
12114
+ throw new Error(
12115
+ "Internal: received update on LiveList but state was not an array"
12116
+ );
12117
+ }
12118
+ let newState = state.map((x) => x);
12119
+ for (const listUpdate of update.updates) {
12120
+ if (listUpdate.type === "set") {
12121
+ newState = newState.map(
12122
+ (item, index) => index === listUpdate.index ? lsonToJson(listUpdate.item) : item
12123
+ );
12124
+ } else if (listUpdate.type === "insert") {
12125
+ if (listUpdate.index === newState.length) {
12126
+ newState.push(lsonToJson(listUpdate.item));
12127
+ } else {
12128
+ newState = [
12129
+ ...newState.slice(0, listUpdate.index),
12130
+ lsonToJson(listUpdate.item),
12131
+ ...newState.slice(listUpdate.index)
12132
+ ];
12133
+ }
12134
+ } else if (listUpdate.type === "delete") {
12135
+ newState.splice(listUpdate.index, 1);
12136
+ } else if (listUpdate.type === "move") {
12137
+ if (listUpdate.previousIndex > listUpdate.index) {
12138
+ newState = [
12139
+ ...newState.slice(0, listUpdate.index),
12140
+ lsonToJson(listUpdate.item),
12141
+ ...newState.slice(listUpdate.index, listUpdate.previousIndex),
12142
+ ...newState.slice(listUpdate.previousIndex + 1)
12143
+ ];
12144
+ } else {
12145
+ newState = [
12146
+ ...newState.slice(0, listUpdate.previousIndex),
12147
+ ...newState.slice(
12148
+ listUpdate.previousIndex + 1,
12149
+ listUpdate.index + 1
12150
+ ),
12151
+ lsonToJson(listUpdate.item),
12152
+ ...newState.slice(listUpdate.index + 1)
11720
12153
  ];
11721
12154
  }
11722
- return [
11723
- elements.link(
11724
- {
11725
- element: inline,
11726
- href
11727
- },
11728
- inlineIndex
11729
- )
11730
- ];
11731
12155
  }
11732
- if (isCommentBodyText(inline)) {
11733
- return [elements.text({ element: inline }, inlineIndex)];
12156
+ }
12157
+ return newState;
12158
+ }
12159
+ case "LiveMap": {
12160
+ if (!isJsonObject(state)) {
12161
+ throw new Error(
12162
+ "Internal: received update on LiveMap but state was not an object"
12163
+ );
12164
+ }
12165
+ const newState = Object.assign({}, state);
12166
+ for (const key in update.updates) {
12167
+ if (_optionalChain([update, 'access', _307 => _307.updates, 'access', _308 => _308[key], 'optionalAccess', _309 => _309.type]) === "update") {
12168
+ const value = update.node.get(key);
12169
+ if (value !== void 0) {
12170
+ newState[key] = lsonToJson(value);
12171
+ }
12172
+ } else if (_optionalChain([update, 'access', _310 => _310.updates, 'access', _311 => _311[key], 'optionalAccess', _312 => _312.type]) === "delete") {
12173
+ delete newState[key];
11734
12174
  }
11735
- return [];
11736
- });
11737
- return [
11738
- elements.paragraph(
11739
- { element: block, children: inlines.join("") },
11740
- blockIndex
11741
- )
11742
- ];
12175
+ }
12176
+ return newState;
11743
12177
  }
11744
- default:
11745
- return [];
11746
12178
  }
11747
- });
11748
- return blocks.join(separator);
11749
- }
11750
-
11751
- // src/crdts/utils.ts
11752
- function toPlainLson(lson) {
11753
- if (lson instanceof LiveObject) {
11754
- return {
11755
- liveblocksType: "LiveObject",
11756
- data: Object.fromEntries(
11757
- Object.entries(lson.toObject()).flatMap(
11758
- ([key, value]) => value !== void 0 ? [[key, toPlainLson(value)]] : []
11759
- )
11760
- )
11761
- };
11762
- } else if (lson instanceof LiveMap) {
11763
- return {
11764
- liveblocksType: "LiveMap",
11765
- data: Object.fromEntries(
11766
- [...lson].map(([key, value]) => [key, toPlainLson(value)])
11767
- )
11768
- };
11769
- } else if (lson instanceof LiveList) {
11770
- return {
11771
- liveblocksType: "LiveList",
11772
- data: [...lson].map((item) => toPlainLson(item))
11773
- };
12179
+ }
12180
+ if (Array.isArray(state)) {
12181
+ const newArray = [...state];
12182
+ newArray[pathItem] = legacy_patchImmutableNode(
12183
+ state[pathItem],
12184
+ path,
12185
+ update
12186
+ );
12187
+ return newArray;
12188
+ } else if (isJsonObject(state)) {
12189
+ const node = state[pathItem];
12190
+ if (node === void 0) {
12191
+ return state;
12192
+ } else {
12193
+ const stateAsObj = state;
12194
+ return {
12195
+ ...stateAsObj,
12196
+ [pathItem]: legacy_patchImmutableNode(node, path, update)
12197
+ };
12198
+ }
11774
12199
  } else {
11775
- return lson;
12200
+ return state;
11776
12201
  }
11777
12202
  }
11778
12203
 
@@ -11824,9 +12249,9 @@ function makePoller(callback, intervalMs, options) {
11824
12249
  const startTime = performance.now();
11825
12250
  const doc = typeof document !== "undefined" ? document : void 0;
11826
12251
  const win = typeof window !== "undefined" ? window : void 0;
11827
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _291 => _291.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
12252
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _313 => _313.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
11828
12253
  const context = {
11829
- inForeground: _optionalChain([doc, 'optionalAccess', _292 => _292.visibilityState]) !== "hidden",
12254
+ inForeground: _optionalChain([doc, 'optionalAccess', _314 => _314.visibilityState]) !== "hidden",
11830
12255
  lastSuccessfulPollAt: startTime,
11831
12256
  count: 0,
11832
12257
  backoff: 0
@@ -11907,11 +12332,11 @@ function makePoller(callback, intervalMs, options) {
11907
12332
  pollNowIfStale();
11908
12333
  }
11909
12334
  function onVisibilityChange() {
11910
- setInForeground(_optionalChain([doc, 'optionalAccess', _293 => _293.visibilityState]) !== "hidden");
12335
+ setInForeground(_optionalChain([doc, 'optionalAccess', _315 => _315.visibilityState]) !== "hidden");
11911
12336
  }
11912
- _optionalChain([doc, 'optionalAccess', _294 => _294.addEventListener, 'call', _295 => _295("visibilitychange", onVisibilityChange)]);
11913
- _optionalChain([win, 'optionalAccess', _296 => _296.addEventListener, 'call', _297 => _297("online", onVisibilityChange)]);
11914
- _optionalChain([win, 'optionalAccess', _298 => _298.addEventListener, 'call', _299 => _299("focus", pollNowIfStale)]);
12337
+ _optionalChain([doc, 'optionalAccess', _316 => _316.addEventListener, 'call', _317 => _317("visibilitychange", onVisibilityChange)]);
12338
+ _optionalChain([win, 'optionalAccess', _318 => _318.addEventListener, 'call', _319 => _319("online", onVisibilityChange)]);
12339
+ _optionalChain([win, 'optionalAccess', _320 => _320.addEventListener, 'call', _321 => _321("focus", pollNowIfStale)]);
11915
12340
  fsm.start();
11916
12341
  return {
11917
12342
  inc,
@@ -12050,5 +12475,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
12050
12475
 
12051
12476
 
12052
12477
 
12053
- exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactNodesToNodeStream = compactNodesToNodeStream; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isListStorageNode = isListStorageNode; exports.isLiveNode = isLiveNode; exports.isMapStorageNode = isMapStorageNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isObjectStorageNode = isObjectStorageNode; exports.isPlainObject = isPlainObject; exports.isRegisterStorageNode = isRegisterStorageNode; exports.isRootStorageNode = isRootStorageNode; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.legacy_patchLiveObjectKey = legacy_patchLiveObjectKey; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.objectToQuery = objectToQuery; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
12478
+
12479
+ exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.FeedRequestErrorCode = FeedRequestErrorCode; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactNodesToNodeStream = compactNodesToNodeStream; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isListStorageNode = isListStorageNode; exports.isLiveNode = isLiveNode; exports.isMapStorageNode = isMapStorageNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isNumberOperator = isNumberOperator; exports.isObjectStorageNode = isObjectStorageNode; exports.isPlainObject = isPlainObject; exports.isRegisterStorageNode = isRegisterStorageNode; exports.isRootStorageNode = isRootStorageNode; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.legacy_patchLiveObjectKey = legacy_patchLiveObjectKey; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.nodeStreamToCompactNodes = nodeStreamToCompactNodes; exports.objectToQuery = objectToQuery; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
12054
12480
  //# sourceMappingURL=index.cjs.map