@liveblocks/core 2.21.0-emails3 → 2.22.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 +159 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +116 -41
- package/dist/index.d.ts +116 -41
- package/dist/index.js +88 -62
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 = "2.
|
|
9
|
+
var PKG_VERSION = "2.22.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3821,6 +3821,35 @@ function isAckOp(op) {
|
|
|
3821
3821
|
}
|
|
3822
3822
|
|
|
3823
3823
|
// src/crdts/AbstractCrdt.ts
|
|
3824
|
+
function createManagedPool(roomId, options) {
|
|
3825
|
+
const {
|
|
3826
|
+
getCurrentConnectionId,
|
|
3827
|
+
onDispatch,
|
|
3828
|
+
isStorageWritable = () => true
|
|
3829
|
+
} = options;
|
|
3830
|
+
let clock = 0;
|
|
3831
|
+
let opClock = 0;
|
|
3832
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
3833
|
+
return {
|
|
3834
|
+
roomId,
|
|
3835
|
+
nodes,
|
|
3836
|
+
getNode: (id) => nodes.get(id),
|
|
3837
|
+
addNode: (id, node) => void nodes.set(id, node),
|
|
3838
|
+
deleteNode: (id) => void nodes.delete(id),
|
|
3839
|
+
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
3840
|
+
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
3841
|
+
dispatch(ops, reverse, storageUpdates) {
|
|
3842
|
+
_optionalChain([onDispatch, 'optionalCall', _65 => _65(ops, reverse, storageUpdates)]);
|
|
3843
|
+
},
|
|
3844
|
+
assertStorageIsWritable: () => {
|
|
3845
|
+
if (!isStorageWritable()) {
|
|
3846
|
+
throw new Error(
|
|
3847
|
+
"Cannot write to storage with a read only user, please ensure the user has write permissions"
|
|
3848
|
+
);
|
|
3849
|
+
}
|
|
3850
|
+
}
|
|
3851
|
+
};
|
|
3852
|
+
}
|
|
3824
3853
|
function crdtAsLiveNode(value) {
|
|
3825
3854
|
return value;
|
|
3826
3855
|
}
|
|
@@ -4037,7 +4066,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
4037
4066
|
return [
|
|
4038
4067
|
{
|
|
4039
4068
|
type: 8 /* CREATE_REGISTER */,
|
|
4040
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
4069
|
+
opId: _optionalChain([pool, 'optionalAccess', _66 => _66.generateOpId, 'call', _67 => _67()]),
|
|
4041
4070
|
id: this._id,
|
|
4042
4071
|
parentId,
|
|
4043
4072
|
parentKey,
|
|
@@ -4143,7 +4172,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4143
4172
|
const ops = [];
|
|
4144
4173
|
const op = {
|
|
4145
4174
|
id: this._id,
|
|
4146
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
4175
|
+
opId: _optionalChain([pool, 'optionalAccess', _68 => _68.generateOpId, 'call', _69 => _69()]),
|
|
4147
4176
|
type: 2 /* CREATE_LIST */,
|
|
4148
4177
|
parentId,
|
|
4149
4178
|
parentKey
|
|
@@ -4414,7 +4443,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4414
4443
|
#applyInsertUndoRedo(op) {
|
|
4415
4444
|
const { id, parentKey: key } = op;
|
|
4416
4445
|
const child = creationOpToLiveNode(op);
|
|
4417
|
-
if (_optionalChain([this, 'access',
|
|
4446
|
+
if (_optionalChain([this, 'access', _70 => _70._pool, 'optionalAccess', _71 => _71.getNode, 'call', _72 => _72(id)]) !== void 0) {
|
|
4418
4447
|
return { modified: false };
|
|
4419
4448
|
}
|
|
4420
4449
|
child._attach(id, nn(this._pool));
|
|
@@ -4422,8 +4451,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4422
4451
|
const existingItemIndex = this._indexOfPosition(key);
|
|
4423
4452
|
let newKey = key;
|
|
4424
4453
|
if (existingItemIndex !== -1) {
|
|
4425
|
-
const before2 = _optionalChain([this, 'access',
|
|
4426
|
-
const after2 = _optionalChain([this, 'access',
|
|
4454
|
+
const before2 = _optionalChain([this, 'access', _73 => _73.#items, 'access', _74 => _74[existingItemIndex], 'optionalAccess', _75 => _75._parentPos]);
|
|
4455
|
+
const after2 = _optionalChain([this, 'access', _76 => _76.#items, 'access', _77 => _77[existingItemIndex + 1], 'optionalAccess', _78 => _78._parentPos]);
|
|
4427
4456
|
newKey = makePosition(before2, after2);
|
|
4428
4457
|
child._setParentLink(this, newKey);
|
|
4429
4458
|
}
|
|
@@ -4437,7 +4466,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4437
4466
|
#applySetUndoRedo(op) {
|
|
4438
4467
|
const { id, parentKey: key } = op;
|
|
4439
4468
|
const child = creationOpToLiveNode(op);
|
|
4440
|
-
if (_optionalChain([this, 'access',
|
|
4469
|
+
if (_optionalChain([this, 'access', _79 => _79._pool, 'optionalAccess', _80 => _80.getNode, 'call', _81 => _81(id)]) !== void 0) {
|
|
4441
4470
|
return { modified: false };
|
|
4442
4471
|
}
|
|
4443
4472
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -4558,7 +4587,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4558
4587
|
} else {
|
|
4559
4588
|
this.#items[existingItemIndex]._setParentLink(
|
|
4560
4589
|
this,
|
|
4561
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4590
|
+
makePosition(newKey, _optionalChain([this, 'access', _82 => _82.#items, 'access', _83 => _83[existingItemIndex + 1], 'optionalAccess', _84 => _84._parentPos]))
|
|
4562
4591
|
);
|
|
4563
4592
|
const previousIndex = this.#items.indexOf(child);
|
|
4564
4593
|
child._setParentLink(this, newKey);
|
|
@@ -4583,7 +4612,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4583
4612
|
if (existingItemIndex !== -1) {
|
|
4584
4613
|
this.#items[existingItemIndex]._setParentLink(
|
|
4585
4614
|
this,
|
|
4586
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4615
|
+
makePosition(newKey, _optionalChain([this, 'access', _85 => _85.#items, 'access', _86 => _86[existingItemIndex + 1], 'optionalAccess', _87 => _87._parentPos]))
|
|
4587
4616
|
);
|
|
4588
4617
|
}
|
|
4589
4618
|
child._setParentLink(this, newKey);
|
|
@@ -4602,7 +4631,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4602
4631
|
if (existingItemIndex !== -1) {
|
|
4603
4632
|
this.#items[existingItemIndex]._setParentLink(
|
|
4604
4633
|
this,
|
|
4605
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4634
|
+
makePosition(newKey, _optionalChain([this, 'access', _88 => _88.#items, 'access', _89 => _89[existingItemIndex + 1], 'optionalAccess', _90 => _90._parentPos]))
|
|
4606
4635
|
);
|
|
4607
4636
|
}
|
|
4608
4637
|
child._setParentLink(this, newKey);
|
|
@@ -4629,7 +4658,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4629
4658
|
if (existingItemIndex !== -1) {
|
|
4630
4659
|
this.#items[existingItemIndex]._setParentLink(
|
|
4631
4660
|
this,
|
|
4632
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
4661
|
+
makePosition(newKey, _optionalChain([this, 'access', _91 => _91.#items, 'access', _92 => _92[existingItemIndex + 1], 'optionalAccess', _93 => _93._parentPos]))
|
|
4633
4662
|
);
|
|
4634
4663
|
}
|
|
4635
4664
|
child._setParentLink(this, newKey);
|
|
@@ -4687,7 +4716,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4687
4716
|
* @param element The element to add to the end of the LiveList.
|
|
4688
4717
|
*/
|
|
4689
4718
|
push(element) {
|
|
4690
|
-
_optionalChain([this, 'access',
|
|
4719
|
+
_optionalChain([this, 'access', _94 => _94._pool, 'optionalAccess', _95 => _95.assertStorageIsWritable, 'call', _96 => _96()]);
|
|
4691
4720
|
return this.insert(element, this.length);
|
|
4692
4721
|
}
|
|
4693
4722
|
/**
|
|
@@ -4696,7 +4725,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4696
4725
|
* @param index The index at which you want to insert the element.
|
|
4697
4726
|
*/
|
|
4698
4727
|
insert(element, index) {
|
|
4699
|
-
_optionalChain([this, 'access',
|
|
4728
|
+
_optionalChain([this, 'access', _97 => _97._pool, 'optionalAccess', _98 => _98.assertStorageIsWritable, 'call', _99 => _99()]);
|
|
4700
4729
|
if (index < 0 || index > this.#items.length) {
|
|
4701
4730
|
throw new Error(
|
|
4702
4731
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -4726,7 +4755,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4726
4755
|
* @param targetIndex The index where the element should be after moving.
|
|
4727
4756
|
*/
|
|
4728
4757
|
move(index, targetIndex) {
|
|
4729
|
-
_optionalChain([this, 'access',
|
|
4758
|
+
_optionalChain([this, 'access', _100 => _100._pool, 'optionalAccess', _101 => _101.assertStorageIsWritable, 'call', _102 => _102()]);
|
|
4730
4759
|
if (targetIndex < 0) {
|
|
4731
4760
|
throw new Error("targetIndex cannot be less than 0");
|
|
4732
4761
|
}
|
|
@@ -4784,7 +4813,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4784
4813
|
* @param index The index of the element to delete
|
|
4785
4814
|
*/
|
|
4786
4815
|
delete(index) {
|
|
4787
|
-
_optionalChain([this, 'access',
|
|
4816
|
+
_optionalChain([this, 'access', _103 => _103._pool, 'optionalAccess', _104 => _104.assertStorageIsWritable, 'call', _105 => _105()]);
|
|
4788
4817
|
if (index < 0 || index >= this.#items.length) {
|
|
4789
4818
|
throw new Error(
|
|
4790
4819
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -4817,7 +4846,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4817
4846
|
}
|
|
4818
4847
|
}
|
|
4819
4848
|
clear() {
|
|
4820
|
-
_optionalChain([this, 'access',
|
|
4849
|
+
_optionalChain([this, 'access', _106 => _106._pool, 'optionalAccess', _107 => _107.assertStorageIsWritable, 'call', _108 => _108()]);
|
|
4821
4850
|
if (this._pool) {
|
|
4822
4851
|
const ops = [];
|
|
4823
4852
|
const reverseOps = [];
|
|
@@ -4851,7 +4880,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4851
4880
|
}
|
|
4852
4881
|
}
|
|
4853
4882
|
set(index, item) {
|
|
4854
|
-
_optionalChain([this, 'access',
|
|
4883
|
+
_optionalChain([this, 'access', _109 => _109._pool, 'optionalAccess', _110 => _110.assertStorageIsWritable, 'call', _111 => _111()]);
|
|
4855
4884
|
if (index < 0 || index >= this.#items.length) {
|
|
4856
4885
|
throw new Error(
|
|
4857
4886
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -4997,7 +5026,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
4997
5026
|
#shiftItemPosition(index, key) {
|
|
4998
5027
|
const shiftedPosition = makePosition(
|
|
4999
5028
|
key,
|
|
5000
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
5029
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _112 => _112.#items, 'access', _113 => _113[index + 1], 'optionalAccess', _114 => _114._parentPos]) : void 0
|
|
5001
5030
|
);
|
|
5002
5031
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
5003
5032
|
}
|
|
@@ -5122,7 +5151,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5122
5151
|
const ops = [];
|
|
5123
5152
|
const op = {
|
|
5124
5153
|
id: this._id,
|
|
5125
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5154
|
+
opId: _optionalChain([pool, 'optionalAccess', _115 => _115.generateOpId, 'call', _116 => _116()]),
|
|
5126
5155
|
type: 7 /* CREATE_MAP */,
|
|
5127
5156
|
parentId,
|
|
5128
5157
|
parentKey
|
|
@@ -5257,7 +5286,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5257
5286
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
5258
5287
|
*/
|
|
5259
5288
|
set(key, value) {
|
|
5260
|
-
_optionalChain([this, 'access',
|
|
5289
|
+
_optionalChain([this, 'access', _117 => _117._pool, 'optionalAccess', _118 => _118.assertStorageIsWritable, 'call', _119 => _119()]);
|
|
5261
5290
|
const oldValue = this.#map.get(key);
|
|
5262
5291
|
if (oldValue) {
|
|
5263
5292
|
oldValue._detach();
|
|
@@ -5303,7 +5332,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
5303
5332
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
5304
5333
|
*/
|
|
5305
5334
|
delete(key) {
|
|
5306
|
-
_optionalChain([this, 'access',
|
|
5335
|
+
_optionalChain([this, 'access', _120 => _120._pool, 'optionalAccess', _121 => _121.assertStorageIsWritable, 'call', _122 => _122()]);
|
|
5307
5336
|
const item = this.#map.get(key);
|
|
5308
5337
|
if (item === void 0) {
|
|
5309
5338
|
return false;
|
|
@@ -5456,7 +5485,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5456
5485
|
}
|
|
5457
5486
|
return [root, parentToChildren];
|
|
5458
5487
|
}
|
|
5459
|
-
/** @
|
|
5488
|
+
/** @private Do not use this API directly */
|
|
5460
5489
|
static _fromItems(items, pool) {
|
|
5461
5490
|
const [root, parentToChildren] = _LiveObject.#buildRootAndParentToChildren(items);
|
|
5462
5491
|
return _LiveObject._deserialize(
|
|
@@ -5482,7 +5511,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5482
5511
|
if (this._id === void 0) {
|
|
5483
5512
|
throw new Error("Cannot serialize item is not attached");
|
|
5484
5513
|
}
|
|
5485
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
5514
|
+
const opId = _optionalChain([pool, 'optionalAccess', _123 => _123.generateOpId, 'call', _124 => _124()]);
|
|
5486
5515
|
const ops = [];
|
|
5487
5516
|
const op = {
|
|
5488
5517
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -5754,7 +5783,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5754
5783
|
* @param value The value of the property to add
|
|
5755
5784
|
*/
|
|
5756
5785
|
set(key, value) {
|
|
5757
|
-
_optionalChain([this, 'access',
|
|
5786
|
+
_optionalChain([this, 'access', _125 => _125._pool, 'optionalAccess', _126 => _126.assertStorageIsWritable, 'call', _127 => _127()]);
|
|
5758
5787
|
this.update({ [key]: value });
|
|
5759
5788
|
}
|
|
5760
5789
|
/**
|
|
@@ -5769,7 +5798,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5769
5798
|
* @param key The key of the property to delete
|
|
5770
5799
|
*/
|
|
5771
5800
|
delete(key) {
|
|
5772
|
-
_optionalChain([this, 'access',
|
|
5801
|
+
_optionalChain([this, 'access', _128 => _128._pool, 'optionalAccess', _129 => _129.assertStorageIsWritable, 'call', _130 => _130()]);
|
|
5773
5802
|
const keyAsString = key;
|
|
5774
5803
|
const oldValue = this.#map.get(keyAsString);
|
|
5775
5804
|
if (oldValue === void 0) {
|
|
@@ -5822,7 +5851,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
5822
5851
|
* @param patch The object used to overrides properties
|
|
5823
5852
|
*/
|
|
5824
5853
|
update(patch) {
|
|
5825
|
-
_optionalChain([this, 'access',
|
|
5854
|
+
_optionalChain([this, 'access', _131 => _131._pool, 'optionalAccess', _132 => _132.assertStorageIsWritable, 'call', _133 => _133()]);
|
|
5826
5855
|
if (this._pool === void 0 || this._id === void 0) {
|
|
5827
5856
|
for (const key in patch) {
|
|
5828
5857
|
const newValue = patch[key];
|
|
@@ -6531,19 +6560,20 @@ function installBackgroundTabSpy() {
|
|
|
6531
6560
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
6532
6561
|
const inBackgroundSince = { current: null };
|
|
6533
6562
|
function onVisibilityChange() {
|
|
6534
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
6563
|
+
if (_optionalChain([doc, 'optionalAccess', _134 => _134.visibilityState]) === "hidden") {
|
|
6535
6564
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
6536
6565
|
} else {
|
|
6537
6566
|
inBackgroundSince.current = null;
|
|
6538
6567
|
}
|
|
6539
6568
|
}
|
|
6540
|
-
_optionalChain([doc, 'optionalAccess',
|
|
6569
|
+
_optionalChain([doc, 'optionalAccess', _135 => _135.addEventListener, 'call', _136 => _136("visibilitychange", onVisibilityChange)]);
|
|
6541
6570
|
const unsub = () => {
|
|
6542
|
-
_optionalChain([doc, 'optionalAccess',
|
|
6571
|
+
_optionalChain([doc, 'optionalAccess', _137 => _137.removeEventListener, 'call', _138 => _138("visibilitychange", onVisibilityChange)]);
|
|
6543
6572
|
};
|
|
6544
6573
|
return [inBackgroundSince, unsub];
|
|
6545
6574
|
}
|
|
6546
6575
|
function createRoom(options, config) {
|
|
6576
|
+
const roomId = config.roomId;
|
|
6547
6577
|
const initialPresence = options.initialPresence;
|
|
6548
6578
|
const initialStorage = options.initialStorage;
|
|
6549
6579
|
const httpClient = config.roomHttpClient;
|
|
@@ -6590,9 +6620,11 @@ function createRoom(options, config) {
|
|
|
6590
6620
|
yjsProvider: void 0,
|
|
6591
6621
|
yjsProviderDidChange: makeEventSource(),
|
|
6592
6622
|
// Storage
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6623
|
+
pool: createManagedPool(roomId, {
|
|
6624
|
+
getCurrentConnectionId,
|
|
6625
|
+
onDispatch,
|
|
6626
|
+
isStorageWritable
|
|
6627
|
+
}),
|
|
6596
6628
|
root: void 0,
|
|
6597
6629
|
undoStack: [],
|
|
6598
6630
|
redoStack: [],
|
|
@@ -6683,59 +6715,42 @@ function createRoom(options, config) {
|
|
|
6683
6715
|
}
|
|
6684
6716
|
}
|
|
6685
6717
|
});
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
dispatch(ops, reverse, storageUpdates) {
|
|
6694
|
-
const activeBatch = context.activeBatch;
|
|
6695
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6696
|
-
const stackTrace = captureStackTrace("Storage mutation", this.dispatch);
|
|
6697
|
-
if (stackTrace) {
|
|
6698
|
-
for (const op of ops) {
|
|
6699
|
-
if (op.opId) {
|
|
6700
|
-
nn(context.opStackTraces).set(op.opId, stackTrace);
|
|
6701
|
-
}
|
|
6718
|
+
function onDispatch(ops, reverse, storageUpdates) {
|
|
6719
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6720
|
+
const stackTrace = captureStackTrace("Storage mutation", onDispatch);
|
|
6721
|
+
if (stackTrace) {
|
|
6722
|
+
for (const op of ops) {
|
|
6723
|
+
if (op.opId) {
|
|
6724
|
+
nn(context.opStackTraces).set(op.opId, stackTrace);
|
|
6702
6725
|
}
|
|
6703
6726
|
}
|
|
6704
6727
|
}
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
for (const [key, value] of storageUpdates) {
|
|
6710
|
-
activeBatch.updates.storageUpdates.set(
|
|
6711
|
-
key,
|
|
6712
|
-
mergeStorageUpdates(
|
|
6713
|
-
activeBatch.updates.storageUpdates.get(key),
|
|
6714
|
-
value
|
|
6715
|
-
)
|
|
6716
|
-
);
|
|
6717
|
-
}
|
|
6718
|
-
activeBatch.reverseOps.pushLeft(reverse);
|
|
6719
|
-
} else {
|
|
6720
|
-
addToUndoStack(reverse);
|
|
6721
|
-
context.redoStack.length = 0;
|
|
6722
|
-
dispatchOps(ops);
|
|
6723
|
-
notify({ storageUpdates });
|
|
6724
|
-
}
|
|
6725
|
-
},
|
|
6726
|
-
assertStorageIsWritable: () => {
|
|
6727
|
-
const scopes = _optionalChain([context, 'access', _138 => _138.dynamicSessionInfoSig, 'access', _139 => _139.get, 'call', _140 => _140(), 'optionalAccess', _141 => _141.scopes]);
|
|
6728
|
-
if (scopes === void 0) {
|
|
6729
|
-
return;
|
|
6728
|
+
}
|
|
6729
|
+
if (context.activeBatch) {
|
|
6730
|
+
for (const op of ops) {
|
|
6731
|
+
context.activeBatch.ops.push(op);
|
|
6730
6732
|
}
|
|
6731
|
-
const
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6733
|
+
for (const [key, value] of storageUpdates) {
|
|
6734
|
+
context.activeBatch.updates.storageUpdates.set(
|
|
6735
|
+
key,
|
|
6736
|
+
mergeStorageUpdates(
|
|
6737
|
+
context.activeBatch.updates.storageUpdates.get(key),
|
|
6738
|
+
value
|
|
6739
|
+
)
|
|
6735
6740
|
);
|
|
6736
6741
|
}
|
|
6742
|
+
context.activeBatch.reverseOps.pushLeft(reverse);
|
|
6743
|
+
} else {
|
|
6744
|
+
addToUndoStack(reverse);
|
|
6745
|
+
context.redoStack.length = 0;
|
|
6746
|
+
dispatchOps(ops);
|
|
6747
|
+
notify({ storageUpdates });
|
|
6737
6748
|
}
|
|
6738
|
-
}
|
|
6749
|
+
}
|
|
6750
|
+
function isStorageWritable() {
|
|
6751
|
+
const scopes = _optionalChain([context, 'access', _139 => _139.dynamicSessionInfoSig, 'access', _140 => _140.get, 'call', _141 => _141(), 'optionalAccess', _142 => _142.scopes]);
|
|
6752
|
+
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
6753
|
+
}
|
|
6739
6754
|
const eventHub = {
|
|
6740
6755
|
status: makeEventSource(),
|
|
6741
6756
|
// New/recommended API
|
|
@@ -6752,7 +6767,6 @@ function createRoom(options, config) {
|
|
|
6752
6767
|
comments: makeEventSource(),
|
|
6753
6768
|
roomWillDestroy: makeEventSource()
|
|
6754
6769
|
};
|
|
6755
|
-
const roomId = config.roomId;
|
|
6756
6770
|
async function createTextMention(userId, mentionId) {
|
|
6757
6771
|
return httpClient.createTextMention({ roomId, userId, mentionId });
|
|
6758
6772
|
}
|
|
@@ -6851,7 +6865,7 @@ function createRoom(options, config) {
|
|
|
6851
6865
|
}
|
|
6852
6866
|
case "experimental-fallback-to-http": {
|
|
6853
6867
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
6854
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
6868
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _143 => _143.dynamicSessionInfoSig, 'access', _144 => _144.get, 'call', _145 => _145(), 'optionalAccess', _146 => _146.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
6855
6869
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
6856
6870
|
if (!resp.ok && resp.status === 403) {
|
|
6857
6871
|
managedSocket.reconnect();
|
|
@@ -6900,9 +6914,9 @@ function createRoom(options, config) {
|
|
|
6900
6914
|
if (context.root !== void 0) {
|
|
6901
6915
|
updateRoot(message.items);
|
|
6902
6916
|
} else {
|
|
6903
|
-
context.root = LiveObject._fromItems(message.items, pool);
|
|
6917
|
+
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
6904
6918
|
}
|
|
6905
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
6919
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _147 => _147.get, 'call', _148 => _148(), 'optionalAccess', _149 => _149.canWrite]), () => ( true));
|
|
6906
6920
|
const stackSizeBefore = context.undoStack.length;
|
|
6907
6921
|
for (const key in context.initialStorage) {
|
|
6908
6922
|
if (context.root.get(key) === void 0) {
|
|
@@ -6922,7 +6936,7 @@ function createRoom(options, config) {
|
|
|
6922
6936
|
return;
|
|
6923
6937
|
}
|
|
6924
6938
|
const currentItems = /* @__PURE__ */ new Map();
|
|
6925
|
-
for (const [id, node] of context.nodes) {
|
|
6939
|
+
for (const [id, node] of context.pool.nodes) {
|
|
6926
6940
|
currentItems.set(id, node._serialize());
|
|
6927
6941
|
}
|
|
6928
6942
|
const ops = getTreesDiffOperations(currentItems, new Map(items));
|
|
@@ -6962,7 +6976,7 @@ function createRoom(options, config) {
|
|
|
6962
6976
|
}
|
|
6963
6977
|
notifyStorageStatus();
|
|
6964
6978
|
}
|
|
6965
|
-
function
|
|
6979
|
+
function getCurrentConnectionId() {
|
|
6966
6980
|
const info = context.dynamicSessionInfoSig.get();
|
|
6967
6981
|
if (info) {
|
|
6968
6982
|
return info.actor;
|
|
@@ -6980,7 +6994,7 @@ function createRoom(options, config) {
|
|
|
6980
6994
|
const createdNodeIds = /* @__PURE__ */ new Set();
|
|
6981
6995
|
const ops = rawOps.map((op) => {
|
|
6982
6996
|
if (op.type !== "presence" && !op.opId) {
|
|
6983
|
-
return { ...op, opId: pool.generateOpId() };
|
|
6997
|
+
return { ...op, opId: context.pool.generateOpId() };
|
|
6984
6998
|
} else {
|
|
6985
6999
|
return op;
|
|
6986
7000
|
}
|
|
@@ -7052,14 +7066,14 @@ function createRoom(options, config) {
|
|
|
7052
7066
|
case 6 /* DELETE_OBJECT_KEY */:
|
|
7053
7067
|
case 3 /* UPDATE_OBJECT */:
|
|
7054
7068
|
case 5 /* DELETE_CRDT */: {
|
|
7055
|
-
const node = context.nodes.get(op.id);
|
|
7069
|
+
const node = context.pool.nodes.get(op.id);
|
|
7056
7070
|
if (node === void 0) {
|
|
7057
7071
|
return { modified: false };
|
|
7058
7072
|
}
|
|
7059
7073
|
return node._apply(op, source === 0 /* UNDOREDO_RECONNECT */);
|
|
7060
7074
|
}
|
|
7061
7075
|
case 1 /* SET_PARENT_KEY */: {
|
|
7062
|
-
const node = context.nodes.get(op.id);
|
|
7076
|
+
const node = context.pool.nodes.get(op.id);
|
|
7063
7077
|
if (node === void 0) {
|
|
7064
7078
|
return { modified: false };
|
|
7065
7079
|
}
|
|
@@ -7079,7 +7093,7 @@ function createRoom(options, config) {
|
|
|
7079
7093
|
if (op.parentId === void 0) {
|
|
7080
7094
|
return { modified: false };
|
|
7081
7095
|
}
|
|
7082
|
-
const parentNode = context.nodes.get(op.parentId);
|
|
7096
|
+
const parentNode = context.pool.nodes.get(op.parentId);
|
|
7083
7097
|
if (parentNode === void 0) {
|
|
7084
7098
|
return { modified: false };
|
|
7085
7099
|
}
|
|
@@ -7105,7 +7119,7 @@ function createRoom(options, config) {
|
|
|
7105
7119
|
}
|
|
7106
7120
|
context.myPresence.patch(patch);
|
|
7107
7121
|
if (context.activeBatch) {
|
|
7108
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
7122
|
+
if (_optionalChain([options2, 'optionalAccess', _150 => _150.addToHistory])) {
|
|
7109
7123
|
context.activeBatch.reverseOps.pushLeft({
|
|
7110
7124
|
type: "presence",
|
|
7111
7125
|
data: oldValues
|
|
@@ -7114,7 +7128,7 @@ function createRoom(options, config) {
|
|
|
7114
7128
|
context.activeBatch.updates.presence = true;
|
|
7115
7129
|
} else {
|
|
7116
7130
|
flushNowOrSoon();
|
|
7117
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
7131
|
+
if (_optionalChain([options2, 'optionalAccess', _151 => _151.addToHistory])) {
|
|
7118
7132
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
7119
7133
|
}
|
|
7120
7134
|
notify({ presence: true });
|
|
@@ -7311,7 +7325,7 @@ function createRoom(options, config) {
|
|
|
7311
7325
|
if (process.env.NODE_ENV !== "production") {
|
|
7312
7326
|
const traces = /* @__PURE__ */ new Set();
|
|
7313
7327
|
for (const opId of message.opIds) {
|
|
7314
|
-
const trace = _optionalChain([context, 'access',
|
|
7328
|
+
const trace = _optionalChain([context, 'access', _152 => _152.opStackTraces, 'optionalAccess', _153 => _153.get, 'call', _154 => _154(opId)]);
|
|
7315
7329
|
if (trace) {
|
|
7316
7330
|
traces.add(trace);
|
|
7317
7331
|
}
|
|
@@ -7445,7 +7459,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7445
7459
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
7446
7460
|
createOrUpdateRootFromMessage(message);
|
|
7447
7461
|
applyAndSendOps(unacknowledgedOps);
|
|
7448
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
7462
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _155 => _155()]);
|
|
7449
7463
|
notifyStorageStatus();
|
|
7450
7464
|
eventHub.storageDidLoad.notify();
|
|
7451
7465
|
}
|
|
@@ -7668,8 +7682,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7668
7682
|
async function getThreads(options2) {
|
|
7669
7683
|
return httpClient.getThreads({
|
|
7670
7684
|
roomId,
|
|
7671
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
7672
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
7685
|
+
query: _optionalChain([options2, 'optionalAccess', _156 => _156.query]),
|
|
7686
|
+
cursor: _optionalChain([options2, 'optionalAccess', _157 => _157.cursor])
|
|
7673
7687
|
});
|
|
7674
7688
|
}
|
|
7675
7689
|
async function getThread(threadId) {
|
|
@@ -7770,7 +7784,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7770
7784
|
function getNotificationSettings(options2) {
|
|
7771
7785
|
return httpClient.getNotificationSettings({
|
|
7772
7786
|
roomId,
|
|
7773
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
7787
|
+
signal: _optionalChain([options2, 'optionalAccess', _158 => _158.signal])
|
|
7774
7788
|
});
|
|
7775
7789
|
}
|
|
7776
7790
|
function updateNotificationSettings(settings) {
|
|
@@ -7792,7 +7806,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7792
7806
|
{
|
|
7793
7807
|
[kInternal]: {
|
|
7794
7808
|
get presenceBuffer() {
|
|
7795
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
7809
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _159 => _159.buffer, 'access', _160 => _160.presenceUpdates, 'optionalAccess', _161 => _161.data]), () => ( null)));
|
|
7796
7810
|
},
|
|
7797
7811
|
// prettier-ignore
|
|
7798
7812
|
get undoStack() {
|
|
@@ -7800,16 +7814,16 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7800
7814
|
},
|
|
7801
7815
|
// prettier-ignore
|
|
7802
7816
|
get nodeCount() {
|
|
7803
|
-
return context.nodes.size;
|
|
7817
|
+
return context.pool.nodes.size;
|
|
7804
7818
|
},
|
|
7805
7819
|
// prettier-ignore
|
|
7806
7820
|
getYjsProvider() {
|
|
7807
7821
|
return context.yjsProvider;
|
|
7808
7822
|
},
|
|
7809
7823
|
setYjsProvider(newProvider) {
|
|
7810
|
-
_optionalChain([context, 'access',
|
|
7824
|
+
_optionalChain([context, 'access', _162 => _162.yjsProvider, 'optionalAccess', _163 => _163.off, 'call', _164 => _164("status", yjsStatusDidChange)]);
|
|
7811
7825
|
context.yjsProvider = newProvider;
|
|
7812
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
7826
|
+
_optionalChain([newProvider, 'optionalAccess', _165 => _165.on, 'call', _166 => _166("status", yjsStatusDidChange)]);
|
|
7813
7827
|
context.yjsProviderDidChange.notify();
|
|
7814
7828
|
},
|
|
7815
7829
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -7840,9 +7854,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7840
7854
|
},
|
|
7841
7855
|
attachmentUrlsStore: httpClient.getOrCreateAttachmentUrlsStore(roomId)
|
|
7842
7856
|
},
|
|
7843
|
-
id:
|
|
7857
|
+
id: roomId,
|
|
7844
7858
|
subscribe: makeClassicSubscribeFn(
|
|
7845
|
-
|
|
7859
|
+
roomId,
|
|
7846
7860
|
events,
|
|
7847
7861
|
config.errorEventSource
|
|
7848
7862
|
),
|
|
@@ -7855,7 +7869,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7855
7869
|
source[Symbol.dispose]();
|
|
7856
7870
|
}
|
|
7857
7871
|
eventHub.roomWillDestroy.notify();
|
|
7858
|
-
_optionalChain([context, 'access',
|
|
7872
|
+
_optionalChain([context, 'access', _167 => _167.yjsProvider, 'optionalAccess', _168 => _168.off, 'call', _169 => _169("status", yjsStatusDidChange)]);
|
|
7859
7873
|
syncSourceForStorage.destroy();
|
|
7860
7874
|
syncSourceForYjs.destroy();
|
|
7861
7875
|
uninstallBgTabSpy();
|
|
@@ -8001,7 +8015,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
8001
8015
|
}
|
|
8002
8016
|
if (isLiveNode(first)) {
|
|
8003
8017
|
const node = first;
|
|
8004
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
8018
|
+
if (_optionalChain([options, 'optionalAccess', _170 => _170.isDeep])) {
|
|
8005
8019
|
const storageCallback = second;
|
|
8006
8020
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
8007
8021
|
} else {
|
|
@@ -8080,8 +8094,8 @@ function createClient(options) {
|
|
|
8080
8094
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
8081
8095
|
currentUserId.set(() => userId);
|
|
8082
8096
|
});
|
|
8083
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
8084
|
-
_optionalChain([globalThis, 'access',
|
|
8097
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _171 => _171.polyfills, 'optionalAccess', _172 => _172.fetch]) || /* istanbul ignore next */
|
|
8098
|
+
_optionalChain([globalThis, 'access', _173 => _173.fetch, 'optionalAccess', _174 => _174.bind, 'call', _175 => _175(globalThis)]);
|
|
8085
8099
|
const httpClient = createApiClient({
|
|
8086
8100
|
baseUrl,
|
|
8087
8101
|
fetchPolyfill,
|
|
@@ -8132,7 +8146,7 @@ function createClient(options) {
|
|
|
8132
8146
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
8133
8147
|
roomId,
|
|
8134
8148
|
baseUrl,
|
|
8135
|
-
_optionalChain([clientOptions, 'access',
|
|
8149
|
+
_optionalChain([clientOptions, 'access', _176 => _176.polyfills, 'optionalAccess', _177 => _177.WebSocket])
|
|
8136
8150
|
),
|
|
8137
8151
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
8138
8152
|
})),
|
|
@@ -8155,7 +8169,7 @@ function createClient(options) {
|
|
|
8155
8169
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
8156
8170
|
if (shouldConnect) {
|
|
8157
8171
|
if (typeof atob === "undefined") {
|
|
8158
|
-
if (_optionalChain([clientOptions, 'access',
|
|
8172
|
+
if (_optionalChain([clientOptions, 'access', _178 => _178.polyfills, 'optionalAccess', _179 => _179.atob]) === void 0) {
|
|
8159
8173
|
throw new Error(
|
|
8160
8174
|
"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"
|
|
8161
8175
|
);
|
|
@@ -8167,7 +8181,7 @@ function createClient(options) {
|
|
|
8167
8181
|
return leaseRoom(newRoomDetails);
|
|
8168
8182
|
}
|
|
8169
8183
|
function getRoom(roomId) {
|
|
8170
|
-
const room = _optionalChain([roomsById, 'access',
|
|
8184
|
+
const room = _optionalChain([roomsById, 'access', _180 => _180.get, 'call', _181 => _181(roomId), 'optionalAccess', _182 => _182.room]);
|
|
8171
8185
|
return room ? room : null;
|
|
8172
8186
|
}
|
|
8173
8187
|
function logout() {
|
|
@@ -8187,7 +8201,7 @@ function createClient(options) {
|
|
|
8187
8201
|
const batchedResolveUsers = new Batch(
|
|
8188
8202
|
async (batchedUserIds) => {
|
|
8189
8203
|
const userIds = batchedUserIds.flat();
|
|
8190
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
8204
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _183 => _183({ userIds })]);
|
|
8191
8205
|
warnIfNoResolveUsers();
|
|
8192
8206
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
8193
8207
|
},
|
|
@@ -8205,7 +8219,7 @@ function createClient(options) {
|
|
|
8205
8219
|
const batchedResolveRoomsInfo = new Batch(
|
|
8206
8220
|
async (batchedRoomIds) => {
|
|
8207
8221
|
const roomIds = batchedRoomIds.flat();
|
|
8208
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
8222
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _184 => _184({ roomIds })]);
|
|
8209
8223
|
warnIfNoResolveRoomsInfo();
|
|
8210
8224
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
8211
8225
|
},
|
|
@@ -8258,7 +8272,7 @@ function createClient(options) {
|
|
|
8258
8272
|
}
|
|
8259
8273
|
};
|
|
8260
8274
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
8261
|
-
_optionalChain([win, 'optionalAccess',
|
|
8275
|
+
_optionalChain([win, 'optionalAccess', _185 => _185.addEventListener, 'call', _186 => _186("beforeunload", maybePreventClose)]);
|
|
8262
8276
|
}
|
|
8263
8277
|
async function getNotificationSettings(options2) {
|
|
8264
8278
|
const plainSettings = await httpClient.getUserNotificationSettings(options2);
|
|
@@ -8396,7 +8410,7 @@ var commentBodyElementsTypes = {
|
|
|
8396
8410
|
mention: "inline"
|
|
8397
8411
|
};
|
|
8398
8412
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
8399
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
8413
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _187 => _187.content])) {
|
|
8400
8414
|
return;
|
|
8401
8415
|
}
|
|
8402
8416
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -8406,13 +8420,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
8406
8420
|
for (const block of body.content) {
|
|
8407
8421
|
if (type === "all" || type === "block") {
|
|
8408
8422
|
if (guard(block)) {
|
|
8409
|
-
_optionalChain([visitor, 'optionalCall',
|
|
8423
|
+
_optionalChain([visitor, 'optionalCall', _188 => _188(block)]);
|
|
8410
8424
|
}
|
|
8411
8425
|
}
|
|
8412
8426
|
if (type === "all" || type === "inline") {
|
|
8413
8427
|
for (const inline of block.children) {
|
|
8414
8428
|
if (guard(inline)) {
|
|
8415
|
-
_optionalChain([visitor, 'optionalCall',
|
|
8429
|
+
_optionalChain([visitor, 'optionalCall', _189 => _189(inline)]);
|
|
8416
8430
|
}
|
|
8417
8431
|
}
|
|
8418
8432
|
}
|
|
@@ -8437,7 +8451,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
8437
8451
|
userIds
|
|
8438
8452
|
});
|
|
8439
8453
|
for (const [index, userId] of userIds.entries()) {
|
|
8440
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
8454
|
+
const user = _optionalChain([users, 'optionalAccess', _190 => _190[index]]);
|
|
8441
8455
|
if (user) {
|
|
8442
8456
|
resolvedUsers.set(userId, user);
|
|
8443
8457
|
}
|
|
@@ -8564,7 +8578,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
8564
8578
|
text: ({ element }) => element.text,
|
|
8565
8579
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
8566
8580
|
mention: ({ element, user }) => {
|
|
8567
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8581
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _191 => _191.name]), () => ( element.id))}`;
|
|
8568
8582
|
}
|
|
8569
8583
|
};
|
|
8570
8584
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -8594,7 +8608,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8594
8608
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
8595
8609
|
},
|
|
8596
8610
|
mention: ({ element, user }) => {
|
|
8597
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
8611
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _192 => _192.name]) ? html`${_optionalChain([user, 'optionalAccess', _193 => _193.name])}` : element.id}</span>`;
|
|
8598
8612
|
}
|
|
8599
8613
|
};
|
|
8600
8614
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -8624,19 +8638,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
8624
8638
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
8625
8639
|
},
|
|
8626
8640
|
mention: ({ element, user }) => {
|
|
8627
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8641
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _194 => _194.name]), () => ( element.id))}`;
|
|
8628
8642
|
}
|
|
8629
8643
|
};
|
|
8630
8644
|
async function stringifyCommentBody(body, options) {
|
|
8631
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8632
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8645
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _195 => _195.format]), () => ( "plain"));
|
|
8646
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _196 => _196.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
8633
8647
|
const elements = {
|
|
8634
8648
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
8635
|
-
..._optionalChain([options, 'optionalAccess',
|
|
8649
|
+
..._optionalChain([options, 'optionalAccess', _197 => _197.elements])
|
|
8636
8650
|
};
|
|
8637
8651
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
8638
8652
|
body,
|
|
8639
|
-
_optionalChain([options, 'optionalAccess',
|
|
8653
|
+
_optionalChain([options, 'optionalAccess', _198 => _198.resolveUsers])
|
|
8640
8654
|
);
|
|
8641
8655
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
8642
8656
|
switch (block.type) {
|
|
@@ -8927,12 +8941,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8927
8941
|
}
|
|
8928
8942
|
const newState = Object.assign({}, state);
|
|
8929
8943
|
for (const key in update.updates) {
|
|
8930
|
-
if (_optionalChain([update, 'access',
|
|
8944
|
+
if (_optionalChain([update, 'access', _199 => _199.updates, 'access', _200 => _200[key], 'optionalAccess', _201 => _201.type]) === "update") {
|
|
8931
8945
|
const val = update.node.get(key);
|
|
8932
8946
|
if (val !== void 0) {
|
|
8933
8947
|
newState[key] = lsonToJson(val);
|
|
8934
8948
|
}
|
|
8935
|
-
} else if (_optionalChain([update, 'access',
|
|
8949
|
+
} else if (_optionalChain([update, 'access', _202 => _202.updates, 'access', _203 => _203[key], 'optionalAccess', _204 => _204.type]) === "delete") {
|
|
8936
8950
|
delete newState[key];
|
|
8937
8951
|
}
|
|
8938
8952
|
}
|
|
@@ -8993,12 +9007,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8993
9007
|
}
|
|
8994
9008
|
const newState = Object.assign({}, state);
|
|
8995
9009
|
for (const key in update.updates) {
|
|
8996
|
-
if (_optionalChain([update, 'access',
|
|
9010
|
+
if (_optionalChain([update, 'access', _205 => _205.updates, 'access', _206 => _206[key], 'optionalAccess', _207 => _207.type]) === "update") {
|
|
8997
9011
|
const value = update.node.get(key);
|
|
8998
9012
|
if (value !== void 0) {
|
|
8999
9013
|
newState[key] = lsonToJson(value);
|
|
9000
9014
|
}
|
|
9001
|
-
} else if (_optionalChain([update, 'access',
|
|
9015
|
+
} else if (_optionalChain([update, 'access', _208 => _208.updates, 'access', _209 => _209[key], 'optionalAccess', _210 => _210.type]) === "delete") {
|
|
9002
9016
|
delete newState[key];
|
|
9003
9017
|
}
|
|
9004
9018
|
}
|
|
@@ -9030,6 +9044,15 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
9030
9044
|
}
|
|
9031
9045
|
}
|
|
9032
9046
|
|
|
9047
|
+
// src/lib/abortController.ts
|
|
9048
|
+
function makeAbortController(externalSignal) {
|
|
9049
|
+
const ctl = new AbortController();
|
|
9050
|
+
return {
|
|
9051
|
+
signal: externalSignal ? AbortSignal.any([ctl.signal, externalSignal]) : ctl.signal,
|
|
9052
|
+
abort: ctl.abort.bind(ctl)
|
|
9053
|
+
};
|
|
9054
|
+
}
|
|
9055
|
+
|
|
9033
9056
|
// src/lib/deprecation.ts
|
|
9034
9057
|
var _emittedDeprecationWarnings = /* @__PURE__ */ new Set();
|
|
9035
9058
|
function deprecate(message, key = message) {
|
|
@@ -9069,9 +9092,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
9069
9092
|
const startTime = performance.now();
|
|
9070
9093
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
9071
9094
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
9072
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9095
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _211 => _211.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
9073
9096
|
const context = {
|
|
9074
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
9097
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _212 => _212.visibilityState]) !== "hidden",
|
|
9075
9098
|
lastSuccessfulPollAt: startTime,
|
|
9076
9099
|
count: 0,
|
|
9077
9100
|
backoff: 0
|
|
@@ -9149,11 +9172,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
9149
9172
|
pollNowIfStale();
|
|
9150
9173
|
}
|
|
9151
9174
|
function onVisibilityChange() {
|
|
9152
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
9175
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _213 => _213.visibilityState]) !== "hidden");
|
|
9153
9176
|
}
|
|
9154
|
-
_optionalChain([doc, 'optionalAccess',
|
|
9155
|
-
_optionalChain([win, 'optionalAccess',
|
|
9156
|
-
_optionalChain([win, 'optionalAccess',
|
|
9177
|
+
_optionalChain([doc, 'optionalAccess', _214 => _214.addEventListener, 'call', _215 => _215("visibilitychange", onVisibilityChange)]);
|
|
9178
|
+
_optionalChain([win, 'optionalAccess', _216 => _216.addEventListener, 'call', _217 => _217("online", onVisibilityChange)]);
|
|
9179
|
+
_optionalChain([win, 'optionalAccess', _218 => _218.addEventListener, 'call', _219 => _219("focus", pollNowIfStale)]);
|
|
9157
9180
|
fsm.start();
|
|
9158
9181
|
return {
|
|
9159
9182
|
inc,
|
|
@@ -9377,5 +9400,8 @@ var NotificationsApiError = HttpError;
|
|
|
9377
9400
|
|
|
9378
9401
|
|
|
9379
9402
|
|
|
9380
|
-
|
|
9403
|
+
|
|
9404
|
+
|
|
9405
|
+
|
|
9406
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MutableSignal = MutableSignal; exports.NotificationsApiError = NotificationsApiError; 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.ackOp = ackOp; 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.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createThreadId = createThreadId; exports.createUserNotificationSettings = createUserNotificationSettings; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; 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.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchUserNotificationSettings = patchUserNotificationSettings; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
9381
9407
|
//# sourceMappingURL=index.cjs.map
|