@liveblocks/core 2.7.0-versions → 2.7.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.d.mts +32 -156
- package/dist/index.d.ts +32 -156
- package/dist/index.js +124 -608
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -547
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "2.7.0
|
|
9
|
+
var PKG_VERSION = "2.7.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -590,6 +590,18 @@ function isPlainObject(blob) {
|
|
|
590
590
|
function entries(obj) {
|
|
591
591
|
return Object.entries(obj);
|
|
592
592
|
}
|
|
593
|
+
function mapValues(obj, mapFn) {
|
|
594
|
+
const result = {};
|
|
595
|
+
for (const pair of Object.entries(obj)) {
|
|
596
|
+
const key = pair[0];
|
|
597
|
+
if (key === "__proto__") {
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
const value = pair[1];
|
|
601
|
+
result[key] = mapFn(value, key);
|
|
602
|
+
}
|
|
603
|
+
return result;
|
|
604
|
+
}
|
|
593
605
|
function tryParseJson(rawMessage) {
|
|
594
606
|
try {
|
|
595
607
|
return JSON.parse(rawMessage);
|
|
@@ -1899,21 +1911,45 @@ function createBatchStore(callback, options) {
|
|
|
1899
1911
|
|
|
1900
1912
|
// src/lib/create-store.ts
|
|
1901
1913
|
function createStore(initialState) {
|
|
1914
|
+
let notifyImmediately = true;
|
|
1915
|
+
let dirty = false;
|
|
1902
1916
|
let state = initialState;
|
|
1903
1917
|
const subscribers = /* @__PURE__ */ new Set();
|
|
1904
1918
|
function get() {
|
|
1905
1919
|
return state;
|
|
1906
1920
|
}
|
|
1907
1921
|
function set(callback) {
|
|
1908
|
-
const
|
|
1909
|
-
|
|
1922
|
+
const oldState = state;
|
|
1923
|
+
const newState = callback(oldState);
|
|
1924
|
+
if (newState !== oldState) {
|
|
1925
|
+
state = newState;
|
|
1926
|
+
dirty = true;
|
|
1927
|
+
}
|
|
1928
|
+
if (notifyImmediately) {
|
|
1929
|
+
notify();
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
function notify() {
|
|
1933
|
+
if (!dirty) {
|
|
1910
1934
|
return;
|
|
1911
1935
|
}
|
|
1912
|
-
|
|
1936
|
+
dirty = false;
|
|
1913
1937
|
for (const subscriber of subscribers) {
|
|
1914
1938
|
subscriber(state);
|
|
1915
1939
|
}
|
|
1916
1940
|
}
|
|
1941
|
+
function batch(cb) {
|
|
1942
|
+
if (notifyImmediately === false) {
|
|
1943
|
+
return cb();
|
|
1944
|
+
}
|
|
1945
|
+
notifyImmediately = false;
|
|
1946
|
+
try {
|
|
1947
|
+
cb();
|
|
1948
|
+
} finally {
|
|
1949
|
+
notifyImmediately = true;
|
|
1950
|
+
notify();
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1917
1953
|
function subscribe(callback) {
|
|
1918
1954
|
subscribers.add(callback);
|
|
1919
1955
|
callback(state);
|
|
@@ -1924,6 +1960,7 @@ function createStore(initialState) {
|
|
|
1924
1960
|
return {
|
|
1925
1961
|
get,
|
|
1926
1962
|
set,
|
|
1963
|
+
batch,
|
|
1927
1964
|
subscribe
|
|
1928
1965
|
};
|
|
1929
1966
|
}
|
|
@@ -2152,8 +2189,14 @@ function createNotificationsApi({
|
|
|
2152
2189
|
}
|
|
2153
2190
|
);
|
|
2154
2191
|
}
|
|
2155
|
-
async function getThreads() {
|
|
2156
|
-
|
|
2192
|
+
async function getThreads(options) {
|
|
2193
|
+
let query;
|
|
2194
|
+
if (_optionalChain([options, 'optionalAccess', _46 => _46.query])) {
|
|
2195
|
+
query = objectToQuery(options.query);
|
|
2196
|
+
}
|
|
2197
|
+
const json = await fetchJson("/threads", void 0, {
|
|
2198
|
+
query
|
|
2199
|
+
});
|
|
2157
2200
|
return {
|
|
2158
2201
|
threads: json.threads.map(convertToThreadData),
|
|
2159
2202
|
inboxNotifications: json.inboxNotifications.map(
|
|
@@ -2163,8 +2206,13 @@ function createNotificationsApi({
|
|
|
2163
2206
|
};
|
|
2164
2207
|
}
|
|
2165
2208
|
async function getThreadsSince(options) {
|
|
2209
|
+
let query;
|
|
2210
|
+
if (_optionalChain([options, 'optionalAccess', _47 => _47.query])) {
|
|
2211
|
+
query = objectToQuery(options.query);
|
|
2212
|
+
}
|
|
2166
2213
|
const json = await fetchJson("/threads", void 0, {
|
|
2167
|
-
since: options.since.toISOString()
|
|
2214
|
+
since: options.since.toISOString(),
|
|
2215
|
+
query
|
|
2168
2216
|
});
|
|
2169
2217
|
return {
|
|
2170
2218
|
threads: {
|
|
@@ -2562,7 +2610,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
2562
2610
|
return [
|
|
2563
2611
|
{
|
|
2564
2612
|
type: 8 /* CREATE_REGISTER */,
|
|
2565
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2613
|
+
opId: _optionalChain([pool, 'optionalAccess', _48 => _48.generateOpId, 'call', _49 => _49()]),
|
|
2566
2614
|
id: this._id,
|
|
2567
2615
|
parentId,
|
|
2568
2616
|
parentKey,
|
|
@@ -2664,7 +2712,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2664
2712
|
const ops = [];
|
|
2665
2713
|
const op = {
|
|
2666
2714
|
id: this._id,
|
|
2667
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2715
|
+
opId: _optionalChain([pool, 'optionalAccess', _50 => _50.generateOpId, 'call', _51 => _51()]),
|
|
2668
2716
|
type: 2 /* CREATE_LIST */,
|
|
2669
2717
|
parentId,
|
|
2670
2718
|
parentKey
|
|
@@ -2941,7 +2989,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2941
2989
|
_applyInsertUndoRedo(op) {
|
|
2942
2990
|
const { id, parentKey: key } = op;
|
|
2943
2991
|
const child = creationOpToLiveNode(op);
|
|
2944
|
-
if (_optionalChain([this, 'access',
|
|
2992
|
+
if (_optionalChain([this, 'access', _52 => _52._pool, 'optionalAccess', _53 => _53.getNode, 'call', _54 => _54(id)]) !== void 0) {
|
|
2945
2993
|
return { modified: false };
|
|
2946
2994
|
}
|
|
2947
2995
|
child._attach(id, nn(this._pool));
|
|
@@ -2949,8 +2997,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2949
2997
|
const existingItemIndex = this._indexOfPosition(key);
|
|
2950
2998
|
let newKey = key;
|
|
2951
2999
|
if (existingItemIndex !== -1) {
|
|
2952
|
-
const before2 = _optionalChain([this, 'access',
|
|
2953
|
-
const after2 = _optionalChain([this, 'access',
|
|
3000
|
+
const before2 = _optionalChain([this, 'access', _55 => _55._items, 'access', _56 => _56[existingItemIndex], 'optionalAccess', _57 => _57._parentPos]);
|
|
3001
|
+
const after2 = _optionalChain([this, 'access', _58 => _58._items, 'access', _59 => _59[existingItemIndex + 1], 'optionalAccess', _60 => _60._parentPos]);
|
|
2954
3002
|
newKey = makePosition(before2, after2);
|
|
2955
3003
|
child._setParentLink(this, newKey);
|
|
2956
3004
|
}
|
|
@@ -2965,7 +3013,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2965
3013
|
_applySetUndoRedo(op) {
|
|
2966
3014
|
const { id, parentKey: key } = op;
|
|
2967
3015
|
const child = creationOpToLiveNode(op);
|
|
2968
|
-
if (_optionalChain([this, 'access',
|
|
3016
|
+
if (_optionalChain([this, 'access', _61 => _61._pool, 'optionalAccess', _62 => _62.getNode, 'call', _63 => _63(id)]) !== void 0) {
|
|
2969
3017
|
return { modified: false };
|
|
2970
3018
|
}
|
|
2971
3019
|
this._unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -3087,7 +3135,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3087
3135
|
} else {
|
|
3088
3136
|
this._items[existingItemIndex]._setParentLink(
|
|
3089
3137
|
this,
|
|
3090
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3138
|
+
makePosition(newKey, _optionalChain([this, 'access', _64 => _64._items, 'access', _65 => _65[existingItemIndex + 1], 'optionalAccess', _66 => _66._parentPos]))
|
|
3091
3139
|
);
|
|
3092
3140
|
const previousIndex = this._items.indexOf(child);
|
|
3093
3141
|
child._setParentLink(this, newKey);
|
|
@@ -3113,7 +3161,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3113
3161
|
if (existingItemIndex !== -1) {
|
|
3114
3162
|
this._items[existingItemIndex]._setParentLink(
|
|
3115
3163
|
this,
|
|
3116
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3164
|
+
makePosition(newKey, _optionalChain([this, 'access', _67 => _67._items, 'access', _68 => _68[existingItemIndex + 1], 'optionalAccess', _69 => _69._parentPos]))
|
|
3117
3165
|
);
|
|
3118
3166
|
}
|
|
3119
3167
|
child._setParentLink(this, newKey);
|
|
@@ -3132,7 +3180,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3132
3180
|
if (existingItemIndex !== -1) {
|
|
3133
3181
|
this._items[existingItemIndex]._setParentLink(
|
|
3134
3182
|
this,
|
|
3135
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3183
|
+
makePosition(newKey, _optionalChain([this, 'access', _70 => _70._items, 'access', _71 => _71[existingItemIndex + 1], 'optionalAccess', _72 => _72._parentPos]))
|
|
3136
3184
|
);
|
|
3137
3185
|
}
|
|
3138
3186
|
child._setParentLink(this, newKey);
|
|
@@ -3160,7 +3208,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3160
3208
|
if (existingItemIndex !== -1) {
|
|
3161
3209
|
this._items[existingItemIndex]._setParentLink(
|
|
3162
3210
|
this,
|
|
3163
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3211
|
+
makePosition(newKey, _optionalChain([this, 'access', _73 => _73._items, 'access', _74 => _74[existingItemIndex + 1], 'optionalAccess', _75 => _75._parentPos]))
|
|
3164
3212
|
);
|
|
3165
3213
|
}
|
|
3166
3214
|
child._setParentLink(this, newKey);
|
|
@@ -3218,7 +3266,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3218
3266
|
* @param element The element to add to the end of the LiveList.
|
|
3219
3267
|
*/
|
|
3220
3268
|
push(element) {
|
|
3221
|
-
_optionalChain([this, 'access',
|
|
3269
|
+
_optionalChain([this, 'access', _76 => _76._pool, 'optionalAccess', _77 => _77.assertStorageIsWritable, 'call', _78 => _78()]);
|
|
3222
3270
|
return this.insert(element, this.length);
|
|
3223
3271
|
}
|
|
3224
3272
|
/**
|
|
@@ -3227,7 +3275,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3227
3275
|
* @param index The index at which you want to insert the element.
|
|
3228
3276
|
*/
|
|
3229
3277
|
insert(element, index) {
|
|
3230
|
-
_optionalChain([this, 'access',
|
|
3278
|
+
_optionalChain([this, 'access', _79 => _79._pool, 'optionalAccess', _80 => _80.assertStorageIsWritable, 'call', _81 => _81()]);
|
|
3231
3279
|
if (index < 0 || index > this._items.length) {
|
|
3232
3280
|
throw new Error(
|
|
3233
3281
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
|
|
@@ -3257,7 +3305,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3257
3305
|
* @param targetIndex The index where the element should be after moving.
|
|
3258
3306
|
*/
|
|
3259
3307
|
move(index, targetIndex) {
|
|
3260
|
-
_optionalChain([this, 'access',
|
|
3308
|
+
_optionalChain([this, 'access', _82 => _82._pool, 'optionalAccess', _83 => _83.assertStorageIsWritable, 'call', _84 => _84()]);
|
|
3261
3309
|
if (targetIndex < 0) {
|
|
3262
3310
|
throw new Error("targetIndex cannot be less than 0");
|
|
3263
3311
|
}
|
|
@@ -3315,7 +3363,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3315
3363
|
* @param index The index of the element to delete
|
|
3316
3364
|
*/
|
|
3317
3365
|
delete(index) {
|
|
3318
|
-
_optionalChain([this, 'access',
|
|
3366
|
+
_optionalChain([this, 'access', _85 => _85._pool, 'optionalAccess', _86 => _86.assertStorageIsWritable, 'call', _87 => _87()]);
|
|
3319
3367
|
if (index < 0 || index >= this._items.length) {
|
|
3320
3368
|
throw new Error(
|
|
3321
3369
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
@@ -3348,7 +3396,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3348
3396
|
}
|
|
3349
3397
|
}
|
|
3350
3398
|
clear() {
|
|
3351
|
-
_optionalChain([this, 'access',
|
|
3399
|
+
_optionalChain([this, 'access', _88 => _88._pool, 'optionalAccess', _89 => _89.assertStorageIsWritable, 'call', _90 => _90()]);
|
|
3352
3400
|
if (this._pool) {
|
|
3353
3401
|
const ops = [];
|
|
3354
3402
|
const reverseOps = [];
|
|
@@ -3382,7 +3430,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3382
3430
|
}
|
|
3383
3431
|
}
|
|
3384
3432
|
set(index, item) {
|
|
3385
|
-
_optionalChain([this, 'access',
|
|
3433
|
+
_optionalChain([this, 'access', _91 => _91._pool, 'optionalAccess', _92 => _92.assertStorageIsWritable, 'call', _93 => _93()]);
|
|
3386
3434
|
if (index < 0 || index >= this._items.length) {
|
|
3387
3435
|
throw new Error(
|
|
3388
3436
|
`Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
@@ -3530,7 +3578,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3530
3578
|
_shiftItemPosition(index, key) {
|
|
3531
3579
|
const shiftedPosition = makePosition(
|
|
3532
3580
|
key,
|
|
3533
|
-
this._items.length > index + 1 ? _optionalChain([this, 'access',
|
|
3581
|
+
this._items.length > index + 1 ? _optionalChain([this, 'access', _94 => _94._items, 'access', _95 => _95[index + 1], 'optionalAccess', _96 => _96._parentPos]) : void 0
|
|
3534
3582
|
);
|
|
3535
3583
|
this._items[index]._setParentLink(this, shiftedPosition);
|
|
3536
3584
|
}
|
|
@@ -3659,7 +3707,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3659
3707
|
const ops = [];
|
|
3660
3708
|
const op = {
|
|
3661
3709
|
id: this._id,
|
|
3662
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
3710
|
+
opId: _optionalChain([pool, 'optionalAccess', _97 => _97.generateOpId, 'call', _98 => _98()]),
|
|
3663
3711
|
type: 7 /* CREATE_MAP */,
|
|
3664
3712
|
parentId,
|
|
3665
3713
|
parentKey
|
|
@@ -3806,7 +3854,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3806
3854
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
3807
3855
|
*/
|
|
3808
3856
|
set(key, value) {
|
|
3809
|
-
_optionalChain([this, 'access',
|
|
3857
|
+
_optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.assertStorageIsWritable, 'call', _101 => _101()]);
|
|
3810
3858
|
const oldValue = this._map.get(key);
|
|
3811
3859
|
if (oldValue) {
|
|
3812
3860
|
oldValue._detach();
|
|
@@ -3852,7 +3900,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3852
3900
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
3853
3901
|
*/
|
|
3854
3902
|
delete(key) {
|
|
3855
|
-
_optionalChain([this, 'access',
|
|
3903
|
+
_optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.assertStorageIsWritable, 'call', _104 => _104()]);
|
|
3856
3904
|
const item = this._map.get(key);
|
|
3857
3905
|
if (item === void 0) {
|
|
3858
3906
|
return false;
|
|
@@ -4030,7 +4078,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4030
4078
|
if (this._id === void 0) {
|
|
4031
4079
|
throw new Error("Cannot serialize item is not attached");
|
|
4032
4080
|
}
|
|
4033
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
4081
|
+
const opId = _optionalChain([pool, 'optionalAccess', _105 => _105.generateOpId, 'call', _106 => _106()]);
|
|
4034
4082
|
const ops = [];
|
|
4035
4083
|
const op = {
|
|
4036
4084
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -4308,7 +4356,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4308
4356
|
* @param value The value of the property to add
|
|
4309
4357
|
*/
|
|
4310
4358
|
set(key, value) {
|
|
4311
|
-
_optionalChain([this, 'access',
|
|
4359
|
+
_optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.assertStorageIsWritable, 'call', _109 => _109()]);
|
|
4312
4360
|
this.update({ [key]: value });
|
|
4313
4361
|
}
|
|
4314
4362
|
/**
|
|
@@ -4323,7 +4371,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4323
4371
|
* @param key The key of the property to delete
|
|
4324
4372
|
*/
|
|
4325
4373
|
delete(key) {
|
|
4326
|
-
_optionalChain([this, 'access',
|
|
4374
|
+
_optionalChain([this, 'access', _110 => _110._pool, 'optionalAccess', _111 => _111.assertStorageIsWritable, 'call', _112 => _112()]);
|
|
4327
4375
|
const keyAsString = key;
|
|
4328
4376
|
const oldValue = this._map.get(keyAsString);
|
|
4329
4377
|
if (oldValue === void 0) {
|
|
@@ -4376,7 +4424,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4376
4424
|
* @param patch The object used to overrides properties
|
|
4377
4425
|
*/
|
|
4378
4426
|
update(patch) {
|
|
4379
|
-
_optionalChain([this, 'access',
|
|
4427
|
+
_optionalChain([this, 'access', _113 => _113._pool, 'optionalAccess', _114 => _114.assertStorageIsWritable, 'call', _115 => _115()]);
|
|
4380
4428
|
if (this._pool === void 0 || this._id === void 0) {
|
|
4381
4429
|
for (const key in patch) {
|
|
4382
4430
|
const newValue = patch[key];
|
|
@@ -5152,15 +5200,15 @@ function installBackgroundTabSpy() {
|
|
|
5152
5200
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
5153
5201
|
const inBackgroundSince = { current: null };
|
|
5154
5202
|
function onVisibilityChange() {
|
|
5155
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
5203
|
+
if (_optionalChain([doc, 'optionalAccess', _116 => _116.visibilityState]) === "hidden") {
|
|
5156
5204
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
5157
5205
|
} else {
|
|
5158
5206
|
inBackgroundSince.current = null;
|
|
5159
5207
|
}
|
|
5160
5208
|
}
|
|
5161
|
-
_optionalChain([doc, 'optionalAccess',
|
|
5209
|
+
_optionalChain([doc, 'optionalAccess', _117 => _117.addEventListener, 'call', _118 => _118("visibilitychange", onVisibilityChange)]);
|
|
5162
5210
|
const unsub = () => {
|
|
5163
|
-
_optionalChain([doc, 'optionalAccess',
|
|
5211
|
+
_optionalChain([doc, 'optionalAccess', _119 => _119.removeEventListener, 'call', _120 => _120("visibilitychange", onVisibilityChange)]);
|
|
5164
5212
|
};
|
|
5165
5213
|
return [inBackgroundSince, unsub];
|
|
5166
5214
|
}
|
|
@@ -5363,7 +5411,7 @@ function createRoom(options, config) {
|
|
|
5363
5411
|
}
|
|
5364
5412
|
},
|
|
5365
5413
|
assertStorageIsWritable: () => {
|
|
5366
|
-
const scopes = _optionalChain([context, 'access',
|
|
5414
|
+
const scopes = _optionalChain([context, 'access', _121 => _121.dynamicSessionInfo, 'access', _122 => _122.current, 'optionalAccess', _123 => _123.scopes]);
|
|
5367
5415
|
if (scopes === void 0) {
|
|
5368
5416
|
return;
|
|
5369
5417
|
}
|
|
@@ -5397,12 +5445,12 @@ function createRoom(options, config) {
|
|
|
5397
5445
|
`/v2/c/rooms/${encodeURIComponent(roomId)}${endpoint}`,
|
|
5398
5446
|
params
|
|
5399
5447
|
);
|
|
5400
|
-
const fetcher = _optionalChain([config, 'access',
|
|
5448
|
+
const fetcher = _optionalChain([config, 'access', _124 => _124.polyfills, 'optionalAccess', _125 => _125.fetch]) || /* istanbul ignore next */
|
|
5401
5449
|
fetch;
|
|
5402
5450
|
return await fetcher(url, {
|
|
5403
5451
|
...options2,
|
|
5404
5452
|
headers: {
|
|
5405
|
-
..._optionalChain([options2, 'optionalAccess',
|
|
5453
|
+
..._optionalChain([options2, 'optionalAccess', _126 => _126.headers]),
|
|
5406
5454
|
Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
|
|
5407
5455
|
}
|
|
5408
5456
|
});
|
|
@@ -5498,7 +5546,7 @@ function createRoom(options, config) {
|
|
|
5498
5546
|
}
|
|
5499
5547
|
function sendMessages(messages) {
|
|
5500
5548
|
const serializedPayload = JSON.stringify(messages);
|
|
5501
|
-
const nonce = _optionalChain([context, 'access',
|
|
5549
|
+
const nonce = _optionalChain([context, 'access', _127 => _127.dynamicSessionInfo, 'access', _128 => _128.current, 'optionalAccess', _129 => _129.nonce]);
|
|
5502
5550
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5503
5551
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5504
5552
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
@@ -5560,7 +5608,7 @@ function createRoom(options, config) {
|
|
|
5560
5608
|
} else {
|
|
5561
5609
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
5562
5610
|
}
|
|
5563
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
5611
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.canWrite]), () => ( true));
|
|
5564
5612
|
const stackSizeBefore = context.undoStack.length;
|
|
5565
5613
|
for (const key in context.initialStorage) {
|
|
5566
5614
|
if (context.root.get(key) === void 0) {
|
|
@@ -5765,7 +5813,7 @@ function createRoom(options, config) {
|
|
|
5765
5813
|
}
|
|
5766
5814
|
context.myPresence.patch(patch);
|
|
5767
5815
|
if (context.activeBatch) {
|
|
5768
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5816
|
+
if (_optionalChain([options2, 'optionalAccess', _132 => _132.addToHistory])) {
|
|
5769
5817
|
context.activeBatch.reverseOps.unshift({
|
|
5770
5818
|
type: "presence",
|
|
5771
5819
|
data: oldValues
|
|
@@ -5775,7 +5823,7 @@ function createRoom(options, config) {
|
|
|
5775
5823
|
} else {
|
|
5776
5824
|
flushNowOrSoon();
|
|
5777
5825
|
batchUpdates(() => {
|
|
5778
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5826
|
+
if (_optionalChain([options2, 'optionalAccess', _133 => _133.addToHistory])) {
|
|
5779
5827
|
addToUndoStack(
|
|
5780
5828
|
[{ type: "presence", data: oldValues }],
|
|
5781
5829
|
doNotBatchUpdates
|
|
@@ -5973,7 +6021,7 @@ function createRoom(options, config) {
|
|
|
5973
6021
|
if (process.env.NODE_ENV !== "production") {
|
|
5974
6022
|
const traces = /* @__PURE__ */ new Set();
|
|
5975
6023
|
for (const opId of message.opIds) {
|
|
5976
|
-
const trace = _optionalChain([context, 'access',
|
|
6024
|
+
const trace = _optionalChain([context, 'access', _134 => _134.opStackTraces, 'optionalAccess', _135 => _135.get, 'call', _136 => _136(opId)]);
|
|
5977
6025
|
if (trace) {
|
|
5978
6026
|
traces.add(trace);
|
|
5979
6027
|
}
|
|
@@ -6107,7 +6155,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6107
6155
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
6108
6156
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
6109
6157
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
6110
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
6158
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _137 => _137()]);
|
|
6111
6159
|
notifyStorageStatus();
|
|
6112
6160
|
eventHub.storageDidLoad.notify();
|
|
6113
6161
|
}
|
|
@@ -6358,7 +6406,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6358
6406
|
const response = await fetchCommentsApi(
|
|
6359
6407
|
"/threads",
|
|
6360
6408
|
{
|
|
6361
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
6409
|
+
since: _optionalChain([options2, 'optionalAccess', _138 => _138.since, 'optionalAccess', _139 => _139.toISOString, 'call', _140 => _140()])
|
|
6362
6410
|
},
|
|
6363
6411
|
{
|
|
6364
6412
|
headers: {
|
|
@@ -6399,7 +6447,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6399
6447
|
}
|
|
6400
6448
|
async function getThreads(options2) {
|
|
6401
6449
|
let query;
|
|
6402
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6450
|
+
if (_optionalChain([options2, 'optionalAccess', _141 => _141.query])) {
|
|
6403
6451
|
query = objectToQuery(options2.query);
|
|
6404
6452
|
}
|
|
6405
6453
|
const response = await fetchCommentsApi(
|
|
@@ -6552,7 +6600,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6552
6600
|
);
|
|
6553
6601
|
return convertToCommentData(comment);
|
|
6554
6602
|
}
|
|
6555
|
-
async function
|
|
6603
|
+
async function deleteComment({
|
|
6556
6604
|
threadId,
|
|
6557
6605
|
commentId
|
|
6558
6606
|
}) {
|
|
@@ -6565,7 +6613,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6565
6613
|
}
|
|
6566
6614
|
);
|
|
6567
6615
|
}
|
|
6568
|
-
async function
|
|
6616
|
+
async function addReaction({
|
|
6569
6617
|
threadId,
|
|
6570
6618
|
commentId,
|
|
6571
6619
|
emoji
|
|
@@ -6584,7 +6632,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6584
6632
|
);
|
|
6585
6633
|
return convertToCommentUserReaction(reaction);
|
|
6586
6634
|
}
|
|
6587
|
-
async function
|
|
6635
|
+
async function removeReaction({
|
|
6588
6636
|
threadId,
|
|
6589
6637
|
commentId,
|
|
6590
6638
|
emoji
|
|
@@ -6674,7 +6722,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6674
6722
|
{
|
|
6675
6723
|
[kInternal]: {
|
|
6676
6724
|
get presenceBuffer() {
|
|
6677
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6725
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _142 => _142.buffer, 'access', _143 => _143.presenceUpdates, 'optionalAccess', _144 => _144.data]), () => ( null)));
|
|
6678
6726
|
},
|
|
6679
6727
|
// prettier-ignore
|
|
6680
6728
|
get undoStack() {
|
|
@@ -6765,9 +6813,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6765
6813
|
markThreadAsUnresolved,
|
|
6766
6814
|
createComment,
|
|
6767
6815
|
editComment,
|
|
6768
|
-
deleteComment
|
|
6769
|
-
addReaction
|
|
6770
|
-
removeReaction
|
|
6816
|
+
deleteComment,
|
|
6817
|
+
addReaction,
|
|
6818
|
+
removeReaction,
|
|
6771
6819
|
// Notifications
|
|
6772
6820
|
getNotificationSettings,
|
|
6773
6821
|
updateNotificationSettings,
|
|
@@ -6854,7 +6902,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
6854
6902
|
}
|
|
6855
6903
|
if (isLiveNode(first)) {
|
|
6856
6904
|
const node = first;
|
|
6857
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6905
|
+
if (_optionalChain([options, 'optionalAccess', _145 => _145.isDeep])) {
|
|
6858
6906
|
const storageCallback = second;
|
|
6859
6907
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
6860
6908
|
} else {
|
|
@@ -6900,533 +6948,6 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
6900
6948
|
};
|
|
6901
6949
|
}
|
|
6902
6950
|
|
|
6903
|
-
// src/store.ts
|
|
6904
|
-
function createClientStore() {
|
|
6905
|
-
const store = createStore({
|
|
6906
|
-
threads: {},
|
|
6907
|
-
queries: {},
|
|
6908
|
-
optimisticUpdates: [],
|
|
6909
|
-
inboxNotifications: {},
|
|
6910
|
-
notificationSettings: {},
|
|
6911
|
-
versions: {}
|
|
6912
|
-
});
|
|
6913
|
-
const optimisticUpdatesEventSource = makeEventSource();
|
|
6914
|
-
return {
|
|
6915
|
-
...store,
|
|
6916
|
-
deleteThread(threadId) {
|
|
6917
|
-
store.set((state) => {
|
|
6918
|
-
return {
|
|
6919
|
-
...state,
|
|
6920
|
-
threads: deleteKeyImmutable(state.threads, threadId),
|
|
6921
|
-
inboxNotifications: Object.fromEntries(
|
|
6922
|
-
Object.entries(state.inboxNotifications).filter(
|
|
6923
|
-
([_id, notification]) => notification.kind === "thread" && notification.threadId === threadId
|
|
6924
|
-
)
|
|
6925
|
-
)
|
|
6926
|
-
};
|
|
6927
|
-
});
|
|
6928
|
-
},
|
|
6929
|
-
updateThreadAndNotification(thread, inboxNotification) {
|
|
6930
|
-
store.set((state) => {
|
|
6931
|
-
const existingThread = state.threads[thread.id];
|
|
6932
|
-
return {
|
|
6933
|
-
...state,
|
|
6934
|
-
threads: existingThread === void 0 || compareThreads(thread, existingThread) === 1 ? { ...state.threads, [thread.id]: thread } : state.threads,
|
|
6935
|
-
inboxNotifications: inboxNotification === void 0 ? state.inboxNotifications : {
|
|
6936
|
-
...state.inboxNotifications,
|
|
6937
|
-
[inboxNotification.id]: inboxNotification
|
|
6938
|
-
}
|
|
6939
|
-
};
|
|
6940
|
-
});
|
|
6941
|
-
},
|
|
6942
|
-
updateRoomVersions(roomId, versions, queryKey) {
|
|
6943
|
-
store.set((state) => ({
|
|
6944
|
-
...state,
|
|
6945
|
-
versions: {
|
|
6946
|
-
...state.versions,
|
|
6947
|
-
[roomId]: versions
|
|
6948
|
-
},
|
|
6949
|
-
queries: queryKey !== void 0 ? {
|
|
6950
|
-
...state.queries,
|
|
6951
|
-
[queryKey]: { isLoading: false, data: void 0 }
|
|
6952
|
-
} : state.queries
|
|
6953
|
-
}));
|
|
6954
|
-
},
|
|
6955
|
-
updateThreadsAndNotifications(threads, inboxNotifications, deletedThreads, deletedInboxNotifications, queryKey) {
|
|
6956
|
-
store.set((state) => ({
|
|
6957
|
-
...state,
|
|
6958
|
-
threads: applyThreadUpdates(state.threads, {
|
|
6959
|
-
newThreads: threads,
|
|
6960
|
-
deletedThreads
|
|
6961
|
-
}),
|
|
6962
|
-
inboxNotifications: applyNotificationsUpdates(
|
|
6963
|
-
state.inboxNotifications,
|
|
6964
|
-
{
|
|
6965
|
-
newInboxNotifications: inboxNotifications,
|
|
6966
|
-
deletedNotifications: deletedInboxNotifications
|
|
6967
|
-
}
|
|
6968
|
-
),
|
|
6969
|
-
queries: queryKey !== void 0 ? {
|
|
6970
|
-
...state.queries,
|
|
6971
|
-
[queryKey]: { isLoading: false, data: void 0 }
|
|
6972
|
-
} : state.queries
|
|
6973
|
-
}));
|
|
6974
|
-
},
|
|
6975
|
-
updateRoomInboxNotificationSettings(roomId, settings, queryKey) {
|
|
6976
|
-
store.set((state) => ({
|
|
6977
|
-
...state,
|
|
6978
|
-
notificationSettings: {
|
|
6979
|
-
...state.notificationSettings,
|
|
6980
|
-
[roomId]: settings
|
|
6981
|
-
},
|
|
6982
|
-
queries: {
|
|
6983
|
-
...state.queries,
|
|
6984
|
-
[queryKey]: { isLoading: false, data: void 0 }
|
|
6985
|
-
}
|
|
6986
|
-
}));
|
|
6987
|
-
},
|
|
6988
|
-
pushOptimisticUpdate(optimisticUpdate) {
|
|
6989
|
-
optimisticUpdatesEventSource.notify(optimisticUpdate);
|
|
6990
|
-
store.set((state) => ({
|
|
6991
|
-
...state,
|
|
6992
|
-
optimisticUpdates: [...state.optimisticUpdates, optimisticUpdate]
|
|
6993
|
-
}));
|
|
6994
|
-
},
|
|
6995
|
-
setQueryState(queryKey, queryState) {
|
|
6996
|
-
store.set((state) => ({
|
|
6997
|
-
...state,
|
|
6998
|
-
queries: {
|
|
6999
|
-
...state.queries,
|
|
7000
|
-
[queryKey]: queryState
|
|
7001
|
-
}
|
|
7002
|
-
}));
|
|
7003
|
-
},
|
|
7004
|
-
optimisticUpdatesEventSource
|
|
7005
|
-
};
|
|
7006
|
-
}
|
|
7007
|
-
function deleteKeyImmutable(record, key) {
|
|
7008
|
-
if (Object.prototype.hasOwnProperty.call(record, key)) {
|
|
7009
|
-
const { [key]: _toDelete, ...rest } = record;
|
|
7010
|
-
return rest;
|
|
7011
|
-
}
|
|
7012
|
-
return record;
|
|
7013
|
-
}
|
|
7014
|
-
function compareThreads(thread1, thread2) {
|
|
7015
|
-
if (thread1.updatedAt && thread2.updatedAt) {
|
|
7016
|
-
return thread1.updatedAt > thread2.updatedAt ? 1 : thread1.updatedAt < thread2.updatedAt ? -1 : 0;
|
|
7017
|
-
} else if (thread1.updatedAt || thread2.updatedAt) {
|
|
7018
|
-
return thread1.updatedAt ? 1 : -1;
|
|
7019
|
-
}
|
|
7020
|
-
if (thread1.createdAt > thread2.createdAt) {
|
|
7021
|
-
return 1;
|
|
7022
|
-
} else if (thread1.createdAt < thread2.createdAt) {
|
|
7023
|
-
return -1;
|
|
7024
|
-
}
|
|
7025
|
-
return 0;
|
|
7026
|
-
}
|
|
7027
|
-
function applyOptimisticUpdates(state) {
|
|
7028
|
-
const result = {
|
|
7029
|
-
threads: {
|
|
7030
|
-
...state.threads
|
|
7031
|
-
},
|
|
7032
|
-
inboxNotifications: {
|
|
7033
|
-
...state.inboxNotifications
|
|
7034
|
-
},
|
|
7035
|
-
notificationSettings: {
|
|
7036
|
-
...state.notificationSettings
|
|
7037
|
-
}
|
|
7038
|
-
};
|
|
7039
|
-
for (const optimisticUpdate of state.optimisticUpdates) {
|
|
7040
|
-
switch (optimisticUpdate.type) {
|
|
7041
|
-
case "create-thread": {
|
|
7042
|
-
result.threads[optimisticUpdate.thread.id] = optimisticUpdate.thread;
|
|
7043
|
-
break;
|
|
7044
|
-
}
|
|
7045
|
-
case "edit-thread-metadata": {
|
|
7046
|
-
const thread = result.threads[optimisticUpdate.threadId];
|
|
7047
|
-
if (thread === void 0) {
|
|
7048
|
-
break;
|
|
7049
|
-
}
|
|
7050
|
-
if (thread.deletedAt !== void 0) {
|
|
7051
|
-
break;
|
|
7052
|
-
}
|
|
7053
|
-
if (thread.updatedAt !== void 0 && thread.updatedAt > optimisticUpdate.updatedAt) {
|
|
7054
|
-
break;
|
|
7055
|
-
}
|
|
7056
|
-
result.threads[thread.id] = {
|
|
7057
|
-
...thread,
|
|
7058
|
-
updatedAt: optimisticUpdate.updatedAt,
|
|
7059
|
-
metadata: {
|
|
7060
|
-
...thread.metadata,
|
|
7061
|
-
...optimisticUpdate.metadata
|
|
7062
|
-
}
|
|
7063
|
-
};
|
|
7064
|
-
break;
|
|
7065
|
-
}
|
|
7066
|
-
case "mark-thread-as-resolved": {
|
|
7067
|
-
const thread = result.threads[optimisticUpdate.threadId];
|
|
7068
|
-
if (thread === void 0) {
|
|
7069
|
-
break;
|
|
7070
|
-
}
|
|
7071
|
-
if (thread.deletedAt !== void 0) {
|
|
7072
|
-
break;
|
|
7073
|
-
}
|
|
7074
|
-
result.threads[thread.id] = {
|
|
7075
|
-
...thread,
|
|
7076
|
-
resolved: true
|
|
7077
|
-
};
|
|
7078
|
-
break;
|
|
7079
|
-
}
|
|
7080
|
-
case "mark-thread-as-unresolved": {
|
|
7081
|
-
const thread = result.threads[optimisticUpdate.threadId];
|
|
7082
|
-
if (thread === void 0) {
|
|
7083
|
-
break;
|
|
7084
|
-
}
|
|
7085
|
-
if (thread.deletedAt !== void 0) {
|
|
7086
|
-
break;
|
|
7087
|
-
}
|
|
7088
|
-
result.threads[thread.id] = {
|
|
7089
|
-
...thread,
|
|
7090
|
-
resolved: false
|
|
7091
|
-
};
|
|
7092
|
-
break;
|
|
7093
|
-
}
|
|
7094
|
-
case "create-comment": {
|
|
7095
|
-
const thread = result.threads[optimisticUpdate.comment.threadId];
|
|
7096
|
-
if (thread === void 0) {
|
|
7097
|
-
break;
|
|
7098
|
-
}
|
|
7099
|
-
result.threads[thread.id] = upsertComment(
|
|
7100
|
-
thread,
|
|
7101
|
-
optimisticUpdate.comment
|
|
7102
|
-
);
|
|
7103
|
-
const inboxNotification = Object.values(result.inboxNotifications).find(
|
|
7104
|
-
(notification) => notification.kind === "thread" && notification.threadId === thread.id
|
|
7105
|
-
);
|
|
7106
|
-
if (inboxNotification === void 0) {
|
|
7107
|
-
break;
|
|
7108
|
-
}
|
|
7109
|
-
result.inboxNotifications[inboxNotification.id] = {
|
|
7110
|
-
...inboxNotification,
|
|
7111
|
-
notifiedAt: optimisticUpdate.comment.createdAt,
|
|
7112
|
-
readAt: optimisticUpdate.comment.createdAt
|
|
7113
|
-
};
|
|
7114
|
-
break;
|
|
7115
|
-
}
|
|
7116
|
-
case "edit-comment": {
|
|
7117
|
-
const thread = result.threads[optimisticUpdate.comment.threadId];
|
|
7118
|
-
if (thread === void 0) {
|
|
7119
|
-
break;
|
|
7120
|
-
}
|
|
7121
|
-
result.threads[thread.id] = upsertComment(
|
|
7122
|
-
thread,
|
|
7123
|
-
optimisticUpdate.comment
|
|
7124
|
-
);
|
|
7125
|
-
break;
|
|
7126
|
-
}
|
|
7127
|
-
case "delete-comment": {
|
|
7128
|
-
const thread = result.threads[optimisticUpdate.threadId];
|
|
7129
|
-
if (thread === void 0) {
|
|
7130
|
-
break;
|
|
7131
|
-
}
|
|
7132
|
-
result.threads[thread.id] = deleteComment(
|
|
7133
|
-
thread,
|
|
7134
|
-
optimisticUpdate.commentId,
|
|
7135
|
-
optimisticUpdate.deletedAt
|
|
7136
|
-
);
|
|
7137
|
-
break;
|
|
7138
|
-
}
|
|
7139
|
-
case "delete-thread": {
|
|
7140
|
-
const thread = result.threads[optimisticUpdate.threadId];
|
|
7141
|
-
if (thread === void 0) {
|
|
7142
|
-
break;
|
|
7143
|
-
}
|
|
7144
|
-
result.threads[optimisticUpdate.threadId] = {
|
|
7145
|
-
...result.threads[optimisticUpdate.threadId],
|
|
7146
|
-
deletedAt: optimisticUpdate.deletedAt,
|
|
7147
|
-
updatedAt: optimisticUpdate.deletedAt,
|
|
7148
|
-
comments: []
|
|
7149
|
-
};
|
|
7150
|
-
break;
|
|
7151
|
-
}
|
|
7152
|
-
case "add-reaction": {
|
|
7153
|
-
const thread = result.threads[optimisticUpdate.threadId];
|
|
7154
|
-
if (thread === void 0) {
|
|
7155
|
-
break;
|
|
7156
|
-
}
|
|
7157
|
-
result.threads[thread.id] = addReaction(
|
|
7158
|
-
thread,
|
|
7159
|
-
optimisticUpdate.commentId,
|
|
7160
|
-
optimisticUpdate.reaction
|
|
7161
|
-
);
|
|
7162
|
-
break;
|
|
7163
|
-
}
|
|
7164
|
-
case "remove-reaction": {
|
|
7165
|
-
const thread = result.threads[optimisticUpdate.threadId];
|
|
7166
|
-
if (thread === void 0) {
|
|
7167
|
-
break;
|
|
7168
|
-
}
|
|
7169
|
-
result.threads[thread.id] = removeReaction(
|
|
7170
|
-
thread,
|
|
7171
|
-
optimisticUpdate.commentId,
|
|
7172
|
-
optimisticUpdate.emoji,
|
|
7173
|
-
optimisticUpdate.userId,
|
|
7174
|
-
optimisticUpdate.removedAt
|
|
7175
|
-
);
|
|
7176
|
-
break;
|
|
7177
|
-
}
|
|
7178
|
-
case "mark-inbox-notification-as-read": {
|
|
7179
|
-
result.inboxNotifications[optimisticUpdate.inboxNotificationId] = {
|
|
7180
|
-
...state.inboxNotifications[optimisticUpdate.inboxNotificationId],
|
|
7181
|
-
readAt: optimisticUpdate.readAt
|
|
7182
|
-
};
|
|
7183
|
-
break;
|
|
7184
|
-
}
|
|
7185
|
-
case "mark-all-inbox-notifications-as-read": {
|
|
7186
|
-
for (const id in result.inboxNotifications) {
|
|
7187
|
-
result.inboxNotifications[id] = {
|
|
7188
|
-
...result.inboxNotifications[id],
|
|
7189
|
-
readAt: optimisticUpdate.readAt
|
|
7190
|
-
};
|
|
7191
|
-
}
|
|
7192
|
-
break;
|
|
7193
|
-
}
|
|
7194
|
-
case "delete-inbox-notification": {
|
|
7195
|
-
const {
|
|
7196
|
-
[optimisticUpdate.inboxNotificationId]: _,
|
|
7197
|
-
...inboxNotifications
|
|
7198
|
-
} = result.inboxNotifications;
|
|
7199
|
-
result.inboxNotifications = inboxNotifications;
|
|
7200
|
-
break;
|
|
7201
|
-
}
|
|
7202
|
-
case "delete-all-inbox-notifications": {
|
|
7203
|
-
result.inboxNotifications = {};
|
|
7204
|
-
break;
|
|
7205
|
-
}
|
|
7206
|
-
case "update-notification-settings": {
|
|
7207
|
-
result.notificationSettings[optimisticUpdate.roomId] = {
|
|
7208
|
-
...result.notificationSettings[optimisticUpdate.roomId],
|
|
7209
|
-
...optimisticUpdate.settings
|
|
7210
|
-
};
|
|
7211
|
-
}
|
|
7212
|
-
}
|
|
7213
|
-
}
|
|
7214
|
-
return result;
|
|
7215
|
-
}
|
|
7216
|
-
function applyThreadUpdates(existingThreads, updates) {
|
|
7217
|
-
const updatedThreads = { ...existingThreads };
|
|
7218
|
-
updates.newThreads.forEach((thread) => {
|
|
7219
|
-
const existingThread = updatedThreads[thread.id];
|
|
7220
|
-
if (existingThread) {
|
|
7221
|
-
const result = compareThreads(existingThread, thread);
|
|
7222
|
-
if (result === 1) return;
|
|
7223
|
-
}
|
|
7224
|
-
updatedThreads[thread.id] = thread;
|
|
7225
|
-
});
|
|
7226
|
-
updates.deletedThreads.forEach(({ id, deletedAt }) => {
|
|
7227
|
-
const existingThread = updatedThreads[id];
|
|
7228
|
-
if (existingThread === void 0) return;
|
|
7229
|
-
existingThread.deletedAt = deletedAt;
|
|
7230
|
-
existingThread.updatedAt = deletedAt;
|
|
7231
|
-
existingThread.comments = [];
|
|
7232
|
-
});
|
|
7233
|
-
return updatedThreads;
|
|
7234
|
-
}
|
|
7235
|
-
function applyNotificationsUpdates(existingInboxNotifications, updates) {
|
|
7236
|
-
const updatedInboxNotifications = { ...existingInboxNotifications };
|
|
7237
|
-
updates.newInboxNotifications.forEach((notification) => {
|
|
7238
|
-
const existingNotification = updatedInboxNotifications[notification.id];
|
|
7239
|
-
if (existingNotification) {
|
|
7240
|
-
const result = compareInboxNotifications(
|
|
7241
|
-
existingNotification,
|
|
7242
|
-
notification
|
|
7243
|
-
);
|
|
7244
|
-
if (result === 1) return;
|
|
7245
|
-
}
|
|
7246
|
-
updatedInboxNotifications[notification.id] = notification;
|
|
7247
|
-
});
|
|
7248
|
-
updates.deletedNotifications.forEach(
|
|
7249
|
-
({ id }) => delete updatedInboxNotifications[id]
|
|
7250
|
-
);
|
|
7251
|
-
return updatedInboxNotifications;
|
|
7252
|
-
}
|
|
7253
|
-
function compareInboxNotifications(inboxNotificationA, inboxNotificationB) {
|
|
7254
|
-
if (inboxNotificationA.notifiedAt > inboxNotificationB.notifiedAt) {
|
|
7255
|
-
return 1;
|
|
7256
|
-
} else if (inboxNotificationA.notifiedAt < inboxNotificationB.notifiedAt) {
|
|
7257
|
-
return -1;
|
|
7258
|
-
}
|
|
7259
|
-
if (inboxNotificationA.readAt && inboxNotificationB.readAt) {
|
|
7260
|
-
return inboxNotificationA.readAt > inboxNotificationB.readAt ? 1 : inboxNotificationA.readAt < inboxNotificationB.readAt ? -1 : 0;
|
|
7261
|
-
} else if (inboxNotificationA.readAt || inboxNotificationB.readAt) {
|
|
7262
|
-
return inboxNotificationA.readAt ? 1 : -1;
|
|
7263
|
-
}
|
|
7264
|
-
return 0;
|
|
7265
|
-
}
|
|
7266
|
-
function upsertComment(thread, comment) {
|
|
7267
|
-
if (thread.deletedAt !== void 0) {
|
|
7268
|
-
return thread;
|
|
7269
|
-
}
|
|
7270
|
-
if (comment.threadId !== thread.id) {
|
|
7271
|
-
warn(
|
|
7272
|
-
`Comment ${comment.id} does not belong to thread ${thread.id}`
|
|
7273
|
-
);
|
|
7274
|
-
return thread;
|
|
7275
|
-
}
|
|
7276
|
-
const existingComment = thread.comments.find(
|
|
7277
|
-
(existingComment2) => existingComment2.id === comment.id
|
|
7278
|
-
);
|
|
7279
|
-
if (existingComment === void 0) {
|
|
7280
|
-
const updatedAt = new Date(
|
|
7281
|
-
Math.max(_optionalChain([thread, 'access', _144 => _144.updatedAt, 'optionalAccess', _145 => _145.getTime, 'call', _146 => _146()]) || 0, comment.createdAt.getTime())
|
|
7282
|
-
);
|
|
7283
|
-
const updatedThread = {
|
|
7284
|
-
...thread,
|
|
7285
|
-
updatedAt,
|
|
7286
|
-
comments: [...thread.comments, comment]
|
|
7287
|
-
};
|
|
7288
|
-
return updatedThread;
|
|
7289
|
-
}
|
|
7290
|
-
if (existingComment.deletedAt !== void 0) {
|
|
7291
|
-
return thread;
|
|
7292
|
-
}
|
|
7293
|
-
if (existingComment.editedAt === void 0 || comment.editedAt === void 0 || existingComment.editedAt <= comment.editedAt) {
|
|
7294
|
-
const updatedComments = thread.comments.map(
|
|
7295
|
-
(existingComment2) => existingComment2.id === comment.id ? comment : existingComment2
|
|
7296
|
-
);
|
|
7297
|
-
const updatedThread = {
|
|
7298
|
-
...thread,
|
|
7299
|
-
updatedAt: new Date(
|
|
7300
|
-
Math.max(
|
|
7301
|
-
_optionalChain([thread, 'access', _147 => _147.updatedAt, 'optionalAccess', _148 => _148.getTime, 'call', _149 => _149()]) || 0,
|
|
7302
|
-
_optionalChain([comment, 'access', _150 => _150.editedAt, 'optionalAccess', _151 => _151.getTime, 'call', _152 => _152()]) || comment.createdAt.getTime()
|
|
7303
|
-
)
|
|
7304
|
-
),
|
|
7305
|
-
comments: updatedComments
|
|
7306
|
-
};
|
|
7307
|
-
return updatedThread;
|
|
7308
|
-
}
|
|
7309
|
-
return thread;
|
|
7310
|
-
}
|
|
7311
|
-
function deleteComment(thread, commentId, deletedAt) {
|
|
7312
|
-
if (thread.deletedAt !== void 0) {
|
|
7313
|
-
return thread;
|
|
7314
|
-
}
|
|
7315
|
-
const existingComment = thread.comments.find(
|
|
7316
|
-
(comment) => comment.id === commentId
|
|
7317
|
-
);
|
|
7318
|
-
if (existingComment === void 0) {
|
|
7319
|
-
return thread;
|
|
7320
|
-
}
|
|
7321
|
-
if (existingComment.deletedAt !== void 0) {
|
|
7322
|
-
return thread;
|
|
7323
|
-
}
|
|
7324
|
-
const updatedComments = thread.comments.map(
|
|
7325
|
-
(comment) => comment.id === commentId ? {
|
|
7326
|
-
...comment,
|
|
7327
|
-
deletedAt,
|
|
7328
|
-
body: void 0
|
|
7329
|
-
} : comment
|
|
7330
|
-
);
|
|
7331
|
-
if (!updatedComments.some((comment) => comment.deletedAt === void 0)) {
|
|
7332
|
-
return {
|
|
7333
|
-
...thread,
|
|
7334
|
-
deletedAt,
|
|
7335
|
-
updatedAt: deletedAt,
|
|
7336
|
-
comments: []
|
|
7337
|
-
};
|
|
7338
|
-
}
|
|
7339
|
-
return {
|
|
7340
|
-
...thread,
|
|
7341
|
-
updatedAt: deletedAt,
|
|
7342
|
-
comments: updatedComments
|
|
7343
|
-
};
|
|
7344
|
-
}
|
|
7345
|
-
function addReaction(thread, commentId, reaction) {
|
|
7346
|
-
if (thread.deletedAt !== void 0) {
|
|
7347
|
-
return thread;
|
|
7348
|
-
}
|
|
7349
|
-
const existingComment = thread.comments.find(
|
|
7350
|
-
(comment) => comment.id === commentId
|
|
7351
|
-
);
|
|
7352
|
-
if (existingComment === void 0) {
|
|
7353
|
-
return thread;
|
|
7354
|
-
}
|
|
7355
|
-
if (existingComment.deletedAt !== void 0) {
|
|
7356
|
-
return thread;
|
|
7357
|
-
}
|
|
7358
|
-
const updatedComments = thread.comments.map(
|
|
7359
|
-
(comment) => comment.id === commentId ? {
|
|
7360
|
-
...comment,
|
|
7361
|
-
reactions: upsertReaction(comment.reactions, reaction)
|
|
7362
|
-
} : comment
|
|
7363
|
-
);
|
|
7364
|
-
return {
|
|
7365
|
-
...thread,
|
|
7366
|
-
updatedAt: new Date(
|
|
7367
|
-
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _153 => _153.updatedAt, 'optionalAccess', _154 => _154.getTime, 'call', _155 => _155()]) || 0)
|
|
7368
|
-
),
|
|
7369
|
-
comments: updatedComments
|
|
7370
|
-
};
|
|
7371
|
-
}
|
|
7372
|
-
function removeReaction(thread, commentId, emoji, userId, removedAt) {
|
|
7373
|
-
if (thread.deletedAt !== void 0) {
|
|
7374
|
-
return thread;
|
|
7375
|
-
}
|
|
7376
|
-
const existingComment = thread.comments.find(
|
|
7377
|
-
(comment) => comment.id === commentId
|
|
7378
|
-
);
|
|
7379
|
-
if (existingComment === void 0) {
|
|
7380
|
-
return thread;
|
|
7381
|
-
}
|
|
7382
|
-
if (existingComment.deletedAt !== void 0) {
|
|
7383
|
-
return thread;
|
|
7384
|
-
}
|
|
7385
|
-
const updatedComments = thread.comments.map(
|
|
7386
|
-
(comment) => comment.id === commentId ? {
|
|
7387
|
-
...comment,
|
|
7388
|
-
reactions: comment.reactions.map(
|
|
7389
|
-
(reaction) => reaction.emoji === emoji ? {
|
|
7390
|
-
...reaction,
|
|
7391
|
-
users: reaction.users.filter((user) => user.id !== userId)
|
|
7392
|
-
} : reaction
|
|
7393
|
-
).filter((reaction) => reaction.users.length > 0)
|
|
7394
|
-
// Remove reactions with no users left
|
|
7395
|
-
} : comment
|
|
7396
|
-
);
|
|
7397
|
-
return {
|
|
7398
|
-
...thread,
|
|
7399
|
-
updatedAt: new Date(
|
|
7400
|
-
Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _156 => _156.updatedAt, 'optionalAccess', _157 => _157.getTime, 'call', _158 => _158()]) || 0)
|
|
7401
|
-
),
|
|
7402
|
-
comments: updatedComments
|
|
7403
|
-
};
|
|
7404
|
-
}
|
|
7405
|
-
function upsertReaction(reactions, reaction) {
|
|
7406
|
-
const existingReaction = reactions.find(
|
|
7407
|
-
(existingReaction2) => existingReaction2.emoji === reaction.emoji
|
|
7408
|
-
);
|
|
7409
|
-
if (existingReaction === void 0) {
|
|
7410
|
-
return [
|
|
7411
|
-
...reactions,
|
|
7412
|
-
{
|
|
7413
|
-
emoji: reaction.emoji,
|
|
7414
|
-
createdAt: reaction.createdAt,
|
|
7415
|
-
users: [{ id: reaction.userId }]
|
|
7416
|
-
}
|
|
7417
|
-
];
|
|
7418
|
-
}
|
|
7419
|
-
if (existingReaction.users.some((user) => user.id === reaction.userId) === false) {
|
|
7420
|
-
return reactions.map(
|
|
7421
|
-
(existingReaction2) => existingReaction2.emoji === reaction.emoji ? {
|
|
7422
|
-
...existingReaction2,
|
|
7423
|
-
users: [...existingReaction2.users, { id: reaction.userId }]
|
|
7424
|
-
} : existingReaction2
|
|
7425
|
-
);
|
|
7426
|
-
}
|
|
7427
|
-
return reactions;
|
|
7428
|
-
}
|
|
7429
|
-
|
|
7430
6951
|
// src/client.ts
|
|
7431
6952
|
var MIN_THROTTLE = 16;
|
|
7432
6953
|
var MAX_THROTTLE = 1e3;
|
|
@@ -7508,12 +7029,12 @@ function createClient(options) {
|
|
|
7508
7029
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7509
7030
|
roomId,
|
|
7510
7031
|
baseUrl,
|
|
7511
|
-
_optionalChain([clientOptions, 'access',
|
|
7032
|
+
_optionalChain([clientOptions, 'access', _146 => _146.polyfills, 'optionalAccess', _147 => _147.WebSocket])
|
|
7512
7033
|
),
|
|
7513
7034
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7514
7035
|
})),
|
|
7515
7036
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7516
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7037
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _148 => _148.unstable_batchedUpdates]),
|
|
7517
7038
|
baseUrl,
|
|
7518
7039
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7519
7040
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7529,7 +7050,7 @@ function createClient(options) {
|
|
|
7529
7050
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7530
7051
|
if (shouldConnect) {
|
|
7531
7052
|
if (typeof atob === "undefined") {
|
|
7532
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7053
|
+
if (_optionalChain([clientOptions, 'access', _149 => _149.polyfills, 'optionalAccess', _150 => _150.atob]) === void 0) {
|
|
7533
7054
|
throw new Error(
|
|
7534
7055
|
"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"
|
|
7535
7056
|
);
|
|
@@ -7541,7 +7062,7 @@ function createClient(options) {
|
|
|
7541
7062
|
return leaseRoom(newRoomDetails);
|
|
7542
7063
|
}
|
|
7543
7064
|
function getRoom(roomId) {
|
|
7544
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7065
|
+
const room = _optionalChain([roomsById, 'access', _151 => _151.get, 'call', _152 => _152(roomId), 'optionalAccess', _153 => _153.room]);
|
|
7545
7066
|
return room ? room : null;
|
|
7546
7067
|
}
|
|
7547
7068
|
function logout() {
|
|
@@ -7565,12 +7086,11 @@ function createClient(options) {
|
|
|
7565
7086
|
getThreadsSince
|
|
7566
7087
|
} = createNotificationsApi({
|
|
7567
7088
|
baseUrl,
|
|
7568
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7089
|
+
fetcher: _optionalChain([clientOptions, 'access', _154 => _154.polyfills, 'optionalAccess', _155 => _155.fetch]) || /* istanbul ignore next */
|
|
7569
7090
|
fetch,
|
|
7570
7091
|
authManager,
|
|
7571
7092
|
currentUserIdStore
|
|
7572
7093
|
});
|
|
7573
|
-
const cacheStore = createClientStore();
|
|
7574
7094
|
const resolveUsers = clientOptions.resolveUsers;
|
|
7575
7095
|
const warnIfNoResolveUsers = createDevelopmentWarning(
|
|
7576
7096
|
() => !resolveUsers,
|
|
@@ -7579,7 +7099,7 @@ function createClient(options) {
|
|
|
7579
7099
|
const usersStore = createBatchStore(
|
|
7580
7100
|
async (batchedUserIds) => {
|
|
7581
7101
|
const userIds = batchedUserIds.flat();
|
|
7582
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7102
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _156 => _156({ userIds })]);
|
|
7583
7103
|
warnIfNoResolveUsers();
|
|
7584
7104
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7585
7105
|
},
|
|
@@ -7593,7 +7113,7 @@ function createClient(options) {
|
|
|
7593
7113
|
const roomsInfoStore = createBatchStore(
|
|
7594
7114
|
async (batchedRoomIds) => {
|
|
7595
7115
|
const roomIds = batchedRoomIds.flat();
|
|
7596
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7116
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _157 => _157({ roomIds })]);
|
|
7597
7117
|
warnIfNoResolveRoomsInfo();
|
|
7598
7118
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7599
7119
|
},
|
|
@@ -7616,7 +7136,6 @@ function createClient(options) {
|
|
|
7616
7136
|
[kInternal]: {
|
|
7617
7137
|
currentUserIdStore,
|
|
7618
7138
|
resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
|
|
7619
|
-
cacheStore,
|
|
7620
7139
|
usersStore,
|
|
7621
7140
|
roomsInfoStore,
|
|
7622
7141
|
getRoomIds() {
|
|
@@ -7709,7 +7228,7 @@ var commentBodyElementsTypes = {
|
|
|
7709
7228
|
mention: "inline"
|
|
7710
7229
|
};
|
|
7711
7230
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7712
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7231
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _158 => _158.content])) {
|
|
7713
7232
|
return;
|
|
7714
7233
|
}
|
|
7715
7234
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7719,13 +7238,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7719
7238
|
for (const block of body.content) {
|
|
7720
7239
|
if (type === "all" || type === "block") {
|
|
7721
7240
|
if (guard(block)) {
|
|
7722
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7241
|
+
_optionalChain([visitor, 'optionalCall', _159 => _159(block)]);
|
|
7723
7242
|
}
|
|
7724
7243
|
}
|
|
7725
7244
|
if (type === "all" || type === "inline") {
|
|
7726
7245
|
for (const inline of block.children) {
|
|
7727
7246
|
if (guard(inline)) {
|
|
7728
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7247
|
+
_optionalChain([visitor, 'optionalCall', _160 => _160(inline)]);
|
|
7729
7248
|
}
|
|
7730
7249
|
}
|
|
7731
7250
|
}
|
|
@@ -7750,7 +7269,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7750
7269
|
userIds
|
|
7751
7270
|
});
|
|
7752
7271
|
for (const [index, userId] of userIds.entries()) {
|
|
7753
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7272
|
+
const user = _optionalChain([users, 'optionalAccess', _161 => _161[index]]);
|
|
7754
7273
|
if (user) {
|
|
7755
7274
|
resolvedUsers.set(userId, user);
|
|
7756
7275
|
}
|
|
@@ -7873,7 +7392,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7873
7392
|
text: ({ element }) => element.text,
|
|
7874
7393
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7875
7394
|
mention: ({ element, user }) => {
|
|
7876
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7395
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _162 => _162.name]), () => ( element.id))}`;
|
|
7877
7396
|
}
|
|
7878
7397
|
};
|
|
7879
7398
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7903,7 +7422,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7903
7422
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7904
7423
|
},
|
|
7905
7424
|
mention: ({ element, user }) => {
|
|
7906
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7425
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _163 => _163.name]), () => ( element.id))}</span>`;
|
|
7907
7426
|
}
|
|
7908
7427
|
};
|
|
7909
7428
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7933,19 +7452,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7933
7452
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7934
7453
|
},
|
|
7935
7454
|
mention: ({ element, user }) => {
|
|
7936
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7455
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _164 => _164.name]), () => ( element.id))}`;
|
|
7937
7456
|
}
|
|
7938
7457
|
};
|
|
7939
7458
|
async function stringifyCommentBody(body, options) {
|
|
7940
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7941
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7459
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _165 => _165.format]), () => ( "plain"));
|
|
7460
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _166 => _166.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7942
7461
|
const elements = {
|
|
7943
7462
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7944
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7463
|
+
..._optionalChain([options, 'optionalAccess', _167 => _167.elements])
|
|
7945
7464
|
};
|
|
7946
7465
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7947
7466
|
body,
|
|
7948
|
-
_optionalChain([options, 'optionalAccess',
|
|
7467
|
+
_optionalChain([options, 'optionalAccess', _168 => _168.resolveUsers])
|
|
7949
7468
|
);
|
|
7950
7469
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7951
7470
|
switch (block.type) {
|
|
@@ -8220,12 +7739,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8220
7739
|
}
|
|
8221
7740
|
const newState = Object.assign({}, state);
|
|
8222
7741
|
for (const key in update.updates) {
|
|
8223
|
-
if (_optionalChain([update, 'access',
|
|
7742
|
+
if (_optionalChain([update, 'access', _169 => _169.updates, 'access', _170 => _170[key], 'optionalAccess', _171 => _171.type]) === "update") {
|
|
8224
7743
|
const val = update.node.get(key);
|
|
8225
7744
|
if (val !== void 0) {
|
|
8226
7745
|
newState[key] = lsonToJson(val);
|
|
8227
7746
|
}
|
|
8228
|
-
} else if (_optionalChain([update, 'access',
|
|
7747
|
+
} else if (_optionalChain([update, 'access', _172 => _172.updates, 'access', _173 => _173[key], 'optionalAccess', _174 => _174.type]) === "delete") {
|
|
8229
7748
|
delete newState[key];
|
|
8230
7749
|
}
|
|
8231
7750
|
}
|
|
@@ -8286,12 +7805,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8286
7805
|
}
|
|
8287
7806
|
const newState = Object.assign({}, state);
|
|
8288
7807
|
for (const key in update.updates) {
|
|
8289
|
-
if (_optionalChain([update, 'access',
|
|
7808
|
+
if (_optionalChain([update, 'access', _175 => _175.updates, 'access', _176 => _176[key], 'optionalAccess', _177 => _177.type]) === "update") {
|
|
8290
7809
|
const value = update.node.get(key);
|
|
8291
7810
|
if (value !== void 0) {
|
|
8292
7811
|
newState[key] = lsonToJson(value);
|
|
8293
7812
|
}
|
|
8294
|
-
} else if (_optionalChain([update, 'access',
|
|
7813
|
+
} else if (_optionalChain([update, 'access', _178 => _178.updates, 'access', _179 => _179[key], 'optionalAccess', _180 => _180.type]) === "delete") {
|
|
8295
7814
|
delete newState[key];
|
|
8296
7815
|
}
|
|
8297
7816
|
}
|
|
@@ -8547,8 +8066,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8547
8066
|
|
|
8548
8067
|
|
|
8549
8068
|
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
8069
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createStore = createStore; exports.createThreadId = createThreadId; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; 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.raise = raise; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
8554
8070
|
//# sourceMappingURL=index.js.map
|