@liveblocks/core 2.11.0 → 2.12.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +79 -14
- package/dist/index.d.ts +79 -14
- package/dist/index.js +189 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -89
- 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.
|
|
9
|
+
var PKG_VERSION = "2.12.0-rc1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2444,6 +2444,84 @@ function createNotificationsApi({
|
|
|
2444
2444
|
};
|
|
2445
2445
|
}
|
|
2446
2446
|
|
|
2447
|
+
// src/lib/freeze.ts
|
|
2448
|
+
var freeze = process.env.NODE_ENV === "production" ? (
|
|
2449
|
+
/* istanbul ignore next */
|
|
2450
|
+
(x) => x
|
|
2451
|
+
) : Object.freeze;
|
|
2452
|
+
|
|
2453
|
+
// src/refs/ImmutableRef.ts
|
|
2454
|
+
function merge(target, patch) {
|
|
2455
|
+
let updated = false;
|
|
2456
|
+
const newValue = { ...target };
|
|
2457
|
+
Object.keys(patch).forEach((k) => {
|
|
2458
|
+
const key = k;
|
|
2459
|
+
const val = patch[key];
|
|
2460
|
+
if (newValue[key] !== val) {
|
|
2461
|
+
if (val === void 0) {
|
|
2462
|
+
delete newValue[key];
|
|
2463
|
+
} else {
|
|
2464
|
+
newValue[key] = val;
|
|
2465
|
+
}
|
|
2466
|
+
updated = true;
|
|
2467
|
+
}
|
|
2468
|
+
});
|
|
2469
|
+
return updated ? newValue : target;
|
|
2470
|
+
}
|
|
2471
|
+
var ImmutableRef = class {
|
|
2472
|
+
constructor() {
|
|
2473
|
+
this._ev = makeEventSource();
|
|
2474
|
+
}
|
|
2475
|
+
get didInvalidate() {
|
|
2476
|
+
return this._ev.observable;
|
|
2477
|
+
}
|
|
2478
|
+
invalidate() {
|
|
2479
|
+
if (this._cache !== null) {
|
|
2480
|
+
this._cache = null;
|
|
2481
|
+
this._ev.notify();
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
get current() {
|
|
2485
|
+
return _nullishCoalesce(this._cache, () => ( (this._cache = this._toImmutable())));
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
|
|
2489
|
+
// src/refs/ValueRef.ts
|
|
2490
|
+
var ValueRef = class extends ImmutableRef {
|
|
2491
|
+
constructor(initialValue) {
|
|
2492
|
+
super();
|
|
2493
|
+
this._value = freeze(initialValue);
|
|
2494
|
+
}
|
|
2495
|
+
/** @internal */
|
|
2496
|
+
_toImmutable() {
|
|
2497
|
+
return this._value;
|
|
2498
|
+
}
|
|
2499
|
+
set(newValue) {
|
|
2500
|
+
if (this._value !== newValue) {
|
|
2501
|
+
this._value = freeze(newValue);
|
|
2502
|
+
this.invalidate();
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
};
|
|
2506
|
+
var DerivedRef = class extends ImmutableRef {
|
|
2507
|
+
constructor(...args) {
|
|
2508
|
+
super();
|
|
2509
|
+
const transformFn = args.pop();
|
|
2510
|
+
const otherRefs = args;
|
|
2511
|
+
this._refs = otherRefs;
|
|
2512
|
+
this._refs.forEach((ref) => {
|
|
2513
|
+
ref.didInvalidate.subscribe(() => this.invalidate());
|
|
2514
|
+
});
|
|
2515
|
+
this._transform = transformFn;
|
|
2516
|
+
}
|
|
2517
|
+
/** @internal */
|
|
2518
|
+
_toImmutable() {
|
|
2519
|
+
return this._transform(
|
|
2520
|
+
...this._refs.map((ref) => ref.current)
|
|
2521
|
+
);
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
|
|
2447
2525
|
// src/lib/position.ts
|
|
2448
2526
|
var MIN_CODE = 32;
|
|
2449
2527
|
var MAX_CODE = 126;
|
|
@@ -3878,12 +3956,6 @@ function HACK_addIntentAndDeletedIdToOperation(ops, deletedId) {
|
|
|
3878
3956
|
});
|
|
3879
3957
|
}
|
|
3880
3958
|
|
|
3881
|
-
// src/lib/freeze.ts
|
|
3882
|
-
var freeze = process.env.NODE_ENV === "production" ? (
|
|
3883
|
-
/* istanbul ignore next */
|
|
3884
|
-
(x) => x
|
|
3885
|
-
) : Object.freeze;
|
|
3886
|
-
|
|
3887
3959
|
// src/crdts/LiveMap.ts
|
|
3888
3960
|
var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
3889
3961
|
constructor(entries2) {
|
|
@@ -5172,42 +5244,6 @@ var ClientMsgCode = /* @__PURE__ */ ((ClientMsgCode2) => {
|
|
|
5172
5244
|
return ClientMsgCode2;
|
|
5173
5245
|
})(ClientMsgCode || {});
|
|
5174
5246
|
|
|
5175
|
-
// src/refs/ImmutableRef.ts
|
|
5176
|
-
function merge(target, patch) {
|
|
5177
|
-
let updated = false;
|
|
5178
|
-
const newValue = { ...target };
|
|
5179
|
-
Object.keys(patch).forEach((k) => {
|
|
5180
|
-
const key = k;
|
|
5181
|
-
const val = patch[key];
|
|
5182
|
-
if (newValue[key] !== val) {
|
|
5183
|
-
if (val === void 0) {
|
|
5184
|
-
delete newValue[key];
|
|
5185
|
-
} else {
|
|
5186
|
-
newValue[key] = val;
|
|
5187
|
-
}
|
|
5188
|
-
updated = true;
|
|
5189
|
-
}
|
|
5190
|
-
});
|
|
5191
|
-
return updated ? newValue : target;
|
|
5192
|
-
}
|
|
5193
|
-
var ImmutableRef = class {
|
|
5194
|
-
constructor() {
|
|
5195
|
-
this._ev = makeEventSource();
|
|
5196
|
-
}
|
|
5197
|
-
get didInvalidate() {
|
|
5198
|
-
return this._ev.observable;
|
|
5199
|
-
}
|
|
5200
|
-
invalidate() {
|
|
5201
|
-
if (this._cache !== void 0) {
|
|
5202
|
-
this._cache = void 0;
|
|
5203
|
-
this._ev.notify();
|
|
5204
|
-
}
|
|
5205
|
-
}
|
|
5206
|
-
get current() {
|
|
5207
|
-
return _nullishCoalesce(this._cache, () => ( (this._cache = this._toImmutable())));
|
|
5208
|
-
}
|
|
5209
|
-
};
|
|
5210
|
-
|
|
5211
5247
|
// src/refs/OthersRef.ts
|
|
5212
5248
|
function makeUser(conn, presence) {
|
|
5213
5249
|
const { connectionId, id, info } = conn;
|
|
@@ -5359,40 +5395,6 @@ var PatchableRef = class extends ImmutableRef {
|
|
|
5359
5395
|
}
|
|
5360
5396
|
};
|
|
5361
5397
|
|
|
5362
|
-
// src/refs/ValueRef.ts
|
|
5363
|
-
var ValueRef = class extends ImmutableRef {
|
|
5364
|
-
constructor(initialValue) {
|
|
5365
|
-
super();
|
|
5366
|
-
this._value = freeze(initialValue);
|
|
5367
|
-
}
|
|
5368
|
-
/** @internal */
|
|
5369
|
-
_toImmutable() {
|
|
5370
|
-
return this._value;
|
|
5371
|
-
}
|
|
5372
|
-
set(newValue) {
|
|
5373
|
-
this._value = freeze(newValue);
|
|
5374
|
-
this.invalidate();
|
|
5375
|
-
}
|
|
5376
|
-
};
|
|
5377
|
-
var DerivedRef = class extends ImmutableRef {
|
|
5378
|
-
constructor(...args) {
|
|
5379
|
-
super();
|
|
5380
|
-
const transformFn = args.pop();
|
|
5381
|
-
const otherRefs = args;
|
|
5382
|
-
this._refs = otherRefs;
|
|
5383
|
-
this._refs.forEach((ref) => {
|
|
5384
|
-
ref.didInvalidate.subscribe(() => this.invalidate());
|
|
5385
|
-
});
|
|
5386
|
-
this._transform = transformFn;
|
|
5387
|
-
}
|
|
5388
|
-
/** @internal */
|
|
5389
|
-
_toImmutable() {
|
|
5390
|
-
return this._transform(
|
|
5391
|
-
...this._refs.map((ref) => ref.current)
|
|
5392
|
-
);
|
|
5393
|
-
}
|
|
5394
|
-
};
|
|
5395
|
-
|
|
5396
5398
|
// src/room.ts
|
|
5397
5399
|
var MAX_SOCKET_MESSAGE_SIZE = 1024 * 1024 - 1024;
|
|
5398
5400
|
function makeIdFactory(connectionId) {
|
|
@@ -5500,9 +5502,9 @@ function createRoom(options, config) {
|
|
|
5500
5502
|
others: new OthersRef(),
|
|
5501
5503
|
initialStorage,
|
|
5502
5504
|
idFactory: null,
|
|
5503
|
-
//
|
|
5504
|
-
|
|
5505
|
-
|
|
5505
|
+
// The Yjs provider associated to this room
|
|
5506
|
+
yjsProvider: void 0,
|
|
5507
|
+
yjsProviderDidChange: makeEventSource(),
|
|
5506
5508
|
// Storage
|
|
5507
5509
|
clock: 0,
|
|
5508
5510
|
opClock: 0,
|
|
@@ -6516,6 +6518,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6516
6518
|
_addToRealUndoStack(historyOps, batchUpdates);
|
|
6517
6519
|
}
|
|
6518
6520
|
}
|
|
6521
|
+
const syncSourceForStorage = config.createSyncSource();
|
|
6519
6522
|
function getStorageStatus() {
|
|
6520
6523
|
if (context.root === void 0) {
|
|
6521
6524
|
return _getStorage$ === null ? "not-loaded" : "loading";
|
|
@@ -6530,6 +6533,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6530
6533
|
_lastStorageStatus = storageStatus;
|
|
6531
6534
|
eventHub.storageStatus.notify(storageStatus);
|
|
6532
6535
|
}
|
|
6536
|
+
syncSourceForStorage.setSyncStatus(
|
|
6537
|
+
storageStatus === "synchronizing" ? "synchronizing" : "synchronized"
|
|
6538
|
+
);
|
|
6533
6539
|
}
|
|
6534
6540
|
function isPresenceReady() {
|
|
6535
6541
|
return self.current !== null;
|
|
@@ -6619,7 +6625,15 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6619
6625
|
threads: [],
|
|
6620
6626
|
inboxNotifications: [],
|
|
6621
6627
|
nextCursor: null,
|
|
6622
|
-
|
|
6628
|
+
//
|
|
6629
|
+
// HACK
|
|
6630
|
+
// requestedAt needs to be a *server* timestamp here. However, on
|
|
6631
|
+
// this 404 error response, there is no such timestamp. So out of
|
|
6632
|
+
// pure necessity we'll fall back to a local timestamp instead (and
|
|
6633
|
+
// allow for a possible 6 hour clock difference between client and
|
|
6634
|
+
// server).
|
|
6635
|
+
//
|
|
6636
|
+
requestedAt: new Date(Date.now() - 6 * 60 * 60 * 1e3)
|
|
6623
6637
|
};
|
|
6624
6638
|
}
|
|
6625
6639
|
throw err;
|
|
@@ -6911,6 +6925,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6911
6925
|
async function markInboxNotificationAsRead(inboxNotificationId) {
|
|
6912
6926
|
await batchedMarkInboxNotificationsAsRead.get(inboxNotificationId);
|
|
6913
6927
|
}
|
|
6928
|
+
const syncSourceForYjs = config.createSyncSource();
|
|
6929
|
+
function yjsStatusDidChange(status) {
|
|
6930
|
+
return syncSourceForYjs.setSyncStatus(
|
|
6931
|
+
status === "synchronizing" ? "synchronizing" : "synchronized"
|
|
6932
|
+
);
|
|
6933
|
+
}
|
|
6914
6934
|
return Object.defineProperty(
|
|
6915
6935
|
{
|
|
6916
6936
|
[kInternal]: {
|
|
@@ -6926,14 +6946,16 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6926
6946
|
return context.nodes.size;
|
|
6927
6947
|
},
|
|
6928
6948
|
// prettier-ignore
|
|
6929
|
-
|
|
6930
|
-
return context.
|
|
6949
|
+
getYjsProvider() {
|
|
6950
|
+
return context.yjsProvider;
|
|
6931
6951
|
},
|
|
6932
|
-
|
|
6933
|
-
context.
|
|
6934
|
-
context.
|
|
6952
|
+
setYjsProvider(newProvider) {
|
|
6953
|
+
_optionalChain([context, 'access', _155 => _155.yjsProvider, 'optionalAccess', _156 => _156.off, 'call', _157 => _157("status", yjsStatusDidChange)]);
|
|
6954
|
+
context.yjsProvider = newProvider;
|
|
6955
|
+
_optionalChain([newProvider, 'optionalAccess', _158 => _158.on, 'call', _159 => _159("status", yjsStatusDidChange)]);
|
|
6956
|
+
context.yjsProviderDidChange.notify();
|
|
6935
6957
|
},
|
|
6936
|
-
|
|
6958
|
+
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
6937
6959
|
// send metadata when using a text editor
|
|
6938
6960
|
reportTextEditor,
|
|
6939
6961
|
// create a text mention when using a text editor
|
|
@@ -6965,6 +6987,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6965
6987
|
reconnect: () => managedSocket.reconnect(),
|
|
6966
6988
|
disconnect: () => managedSocket.disconnect(),
|
|
6967
6989
|
destroy: () => {
|
|
6990
|
+
syncSourceForStorage.destroy();
|
|
6991
|
+
_optionalChain([context, 'access', _160 => _160.yjsProvider, 'optionalAccess', _161 => _161.off, 'call', _162 => _162("status", yjsStatusDidChange)]);
|
|
6992
|
+
syncSourceForYjs.destroy();
|
|
6968
6993
|
uninstallBgTabSpy();
|
|
6969
6994
|
managedSocket.destroy();
|
|
6970
6995
|
},
|
|
@@ -7101,7 +7126,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
7101
7126
|
}
|
|
7102
7127
|
if (isLiveNode(first)) {
|
|
7103
7128
|
const node = first;
|
|
7104
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7129
|
+
if (_optionalChain([options, 'optionalAccess', _163 => _163.isDeep])) {
|
|
7105
7130
|
const storageCallback = second;
|
|
7106
7131
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7107
7132
|
} else {
|
|
@@ -7221,15 +7246,16 @@ function createClient(options) {
|
|
|
7221
7246
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7222
7247
|
roomId,
|
|
7223
7248
|
baseUrl,
|
|
7224
|
-
_optionalChain([clientOptions, 'access',
|
|
7249
|
+
_optionalChain([clientOptions, 'access', _164 => _164.polyfills, 'optionalAccess', _165 => _165.WebSocket])
|
|
7225
7250
|
),
|
|
7226
7251
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7227
7252
|
})),
|
|
7228
7253
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7229
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7254
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _166 => _166.unstable_batchedUpdates]),
|
|
7230
7255
|
baseUrl,
|
|
7231
7256
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7232
|
-
unstable_streamData: !!clientOptions.unstable_streamData
|
|
7257
|
+
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
7258
|
+
createSyncSource
|
|
7233
7259
|
}
|
|
7234
7260
|
);
|
|
7235
7261
|
const newRoomDetails = {
|
|
@@ -7242,7 +7268,7 @@ function createClient(options) {
|
|
|
7242
7268
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7243
7269
|
if (shouldConnect) {
|
|
7244
7270
|
if (typeof atob === "undefined") {
|
|
7245
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7271
|
+
if (_optionalChain([clientOptions, 'access', _167 => _167.polyfills, 'optionalAccess', _168 => _168.atob]) === void 0) {
|
|
7246
7272
|
throw new Error(
|
|
7247
7273
|
"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"
|
|
7248
7274
|
);
|
|
@@ -7254,7 +7280,7 @@ function createClient(options) {
|
|
|
7254
7280
|
return leaseRoom(newRoomDetails);
|
|
7255
7281
|
}
|
|
7256
7282
|
function getRoom(roomId) {
|
|
7257
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7283
|
+
const room = _optionalChain([roomsById, 'access', _169 => _169.get, 'call', _170 => _170(roomId), 'optionalAccess', _171 => _171.room]);
|
|
7258
7284
|
return room ? room : null;
|
|
7259
7285
|
}
|
|
7260
7286
|
function logout() {
|
|
@@ -7266,8 +7292,8 @@ function createClient(options) {
|
|
|
7266
7292
|
}
|
|
7267
7293
|
}
|
|
7268
7294
|
const currentUserIdStore = createStore(null);
|
|
7269
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
7270
|
-
_optionalChain([globalThis, 'access',
|
|
7295
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _172 => _172.polyfills, 'optionalAccess', _173 => _173.fetch]) || /* istanbul ignore next */
|
|
7296
|
+
_optionalChain([globalThis, 'access', _174 => _174.fetch, 'optionalAccess', _175 => _175.bind, 'call', _176 => _176(globalThis)]);
|
|
7271
7297
|
const notificationsAPI = createNotificationsApi({
|
|
7272
7298
|
baseUrl,
|
|
7273
7299
|
fetchPolyfill,
|
|
@@ -7282,7 +7308,7 @@ function createClient(options) {
|
|
|
7282
7308
|
const batchedResolveUsers = new Batch(
|
|
7283
7309
|
async (batchedUserIds) => {
|
|
7284
7310
|
const userIds = batchedUserIds.flat();
|
|
7285
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7311
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _177 => _177({ userIds })]);
|
|
7286
7312
|
warnIfNoResolveUsers();
|
|
7287
7313
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7288
7314
|
},
|
|
@@ -7300,7 +7326,7 @@ function createClient(options) {
|
|
|
7300
7326
|
const batchedResolveRoomsInfo = new Batch(
|
|
7301
7327
|
async (batchedRoomIds) => {
|
|
7302
7328
|
const roomIds = batchedRoomIds.flat();
|
|
7303
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7329
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _178 => _178({ roomIds })]);
|
|
7304
7330
|
warnIfNoResolveRoomsInfo();
|
|
7305
7331
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7306
7332
|
},
|
|
@@ -7314,6 +7340,46 @@ function createClient(options) {
|
|
|
7314
7340
|
function invalidateResolvedMentionSuggestions() {
|
|
7315
7341
|
mentionSuggestionsCache.clear();
|
|
7316
7342
|
}
|
|
7343
|
+
const syncStatusSources = [];
|
|
7344
|
+
const syncStatusRef = new ValueRef("synchronized");
|
|
7345
|
+
function getSyncStatus() {
|
|
7346
|
+
const status = syncStatusRef.current;
|
|
7347
|
+
return status === "synchronizing" ? status : "synchronized";
|
|
7348
|
+
}
|
|
7349
|
+
function recompute() {
|
|
7350
|
+
syncStatusRef.set(
|
|
7351
|
+
syncStatusSources.some((src) => src.current === "synchronizing") ? "synchronizing" : syncStatusSources.some((src) => src.current === "has-local-changes") ? "has-local-changes" : "synchronized"
|
|
7352
|
+
);
|
|
7353
|
+
}
|
|
7354
|
+
function createSyncSource() {
|
|
7355
|
+
const source = new ValueRef("synchronized");
|
|
7356
|
+
syncStatusSources.push(source);
|
|
7357
|
+
const unsub = source.didInvalidate.subscribe(() => recompute());
|
|
7358
|
+
function setSyncStatus(status) {
|
|
7359
|
+
source.set(status);
|
|
7360
|
+
}
|
|
7361
|
+
function destroy() {
|
|
7362
|
+
unsub();
|
|
7363
|
+
const index = syncStatusSources.findIndex((item) => item === source);
|
|
7364
|
+
if (index > -1) {
|
|
7365
|
+
const [ref] = syncStatusSources.splice(index, 1);
|
|
7366
|
+
const wasStillPending = ref.current !== "synchronized";
|
|
7367
|
+
if (wasStillPending) {
|
|
7368
|
+
recompute();
|
|
7369
|
+
}
|
|
7370
|
+
}
|
|
7371
|
+
}
|
|
7372
|
+
return { setSyncStatus, destroy };
|
|
7373
|
+
}
|
|
7374
|
+
{
|
|
7375
|
+
const maybePreventClose = (e) => {
|
|
7376
|
+
if (clientOptions.preventUnsavedChanges && syncStatusRef.current !== "synchronized") {
|
|
7377
|
+
e.preventDefault();
|
|
7378
|
+
}
|
|
7379
|
+
};
|
|
7380
|
+
const win = typeof window !== "undefined" ? window : void 0;
|
|
7381
|
+
_optionalChain([win, 'optionalAccess', _179 => _179.addEventListener, 'call', _180 => _180("beforeunload", maybePreventClose)]);
|
|
7382
|
+
}
|
|
7317
7383
|
const client = Object.defineProperty(
|
|
7318
7384
|
{
|
|
7319
7385
|
enterRoom,
|
|
@@ -7326,6 +7392,10 @@ function createClient(options) {
|
|
|
7326
7392
|
invalidateRoomsInfo: invalidateResolvedRoomsInfo,
|
|
7327
7393
|
invalidateMentionSuggestions: invalidateResolvedMentionSuggestions
|
|
7328
7394
|
},
|
|
7395
|
+
getSyncStatus,
|
|
7396
|
+
events: {
|
|
7397
|
+
syncStatus: syncStatusRef.didInvalidate
|
|
7398
|
+
},
|
|
7329
7399
|
// Internal
|
|
7330
7400
|
[kInternal]: {
|
|
7331
7401
|
currentUserIdStore,
|
|
@@ -7340,7 +7410,8 @@ function createClient(options) {
|
|
|
7340
7410
|
getUserThreads_experimental: notificationsAPI.getUserThreads_experimental,
|
|
7341
7411
|
getUserThreadsSince_experimental: notificationsAPI.getUserThreadsSince_experimental,
|
|
7342
7412
|
// Type-level helper only, it's effectively only an identity-function at runtime
|
|
7343
|
-
as: () => client
|
|
7413
|
+
as: () => client,
|
|
7414
|
+
createSyncSource
|
|
7344
7415
|
}
|
|
7345
7416
|
},
|
|
7346
7417
|
kInternal,
|
|
@@ -7419,7 +7490,7 @@ var commentBodyElementsTypes = {
|
|
|
7419
7490
|
mention: "inline"
|
|
7420
7491
|
};
|
|
7421
7492
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7422
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7493
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _181 => _181.content])) {
|
|
7423
7494
|
return;
|
|
7424
7495
|
}
|
|
7425
7496
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7429,13 +7500,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7429
7500
|
for (const block of body.content) {
|
|
7430
7501
|
if (type === "all" || type === "block") {
|
|
7431
7502
|
if (guard(block)) {
|
|
7432
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7503
|
+
_optionalChain([visitor, 'optionalCall', _182 => _182(block)]);
|
|
7433
7504
|
}
|
|
7434
7505
|
}
|
|
7435
7506
|
if (type === "all" || type === "inline") {
|
|
7436
7507
|
for (const inline of block.children) {
|
|
7437
7508
|
if (guard(inline)) {
|
|
7438
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7509
|
+
_optionalChain([visitor, 'optionalCall', _183 => _183(inline)]);
|
|
7439
7510
|
}
|
|
7440
7511
|
}
|
|
7441
7512
|
}
|
|
@@ -7460,7 +7531,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7460
7531
|
userIds
|
|
7461
7532
|
});
|
|
7462
7533
|
for (const [index, userId] of userIds.entries()) {
|
|
7463
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7534
|
+
const user = _optionalChain([users, 'optionalAccess', _184 => _184[index]]);
|
|
7464
7535
|
if (user) {
|
|
7465
7536
|
resolvedUsers.set(userId, user);
|
|
7466
7537
|
}
|
|
@@ -7583,7 +7654,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7583
7654
|
text: ({ element }) => element.text,
|
|
7584
7655
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7585
7656
|
mention: ({ element, user }) => {
|
|
7586
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7657
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _185 => _185.name]), () => ( element.id))}`;
|
|
7587
7658
|
}
|
|
7588
7659
|
};
|
|
7589
7660
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7613,7 +7684,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7613
7684
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7614
7685
|
},
|
|
7615
7686
|
mention: ({ element, user }) => {
|
|
7616
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7687
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _186 => _186.name]), () => ( element.id))}</span>`;
|
|
7617
7688
|
}
|
|
7618
7689
|
};
|
|
7619
7690
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7643,19 +7714,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7643
7714
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7644
7715
|
},
|
|
7645
7716
|
mention: ({ element, user }) => {
|
|
7646
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7717
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _187 => _187.name]), () => ( element.id))}`;
|
|
7647
7718
|
}
|
|
7648
7719
|
};
|
|
7649
7720
|
async function stringifyCommentBody(body, options) {
|
|
7650
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7651
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7721
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _188 => _188.format]), () => ( "plain"));
|
|
7722
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _189 => _189.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7652
7723
|
const elements = {
|
|
7653
7724
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7654
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7725
|
+
..._optionalChain([options, 'optionalAccess', _190 => _190.elements])
|
|
7655
7726
|
};
|
|
7656
7727
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7657
7728
|
body,
|
|
7658
|
-
_optionalChain([options, 'optionalAccess',
|
|
7729
|
+
_optionalChain([options, 'optionalAccess', _191 => _191.resolveUsers])
|
|
7659
7730
|
);
|
|
7660
7731
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7661
7732
|
switch (block.type) {
|
|
@@ -7946,12 +8017,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7946
8017
|
}
|
|
7947
8018
|
const newState = Object.assign({}, state);
|
|
7948
8019
|
for (const key in update.updates) {
|
|
7949
|
-
if (_optionalChain([update, 'access',
|
|
8020
|
+
if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "update") {
|
|
7950
8021
|
const val = update.node.get(key);
|
|
7951
8022
|
if (val !== void 0) {
|
|
7952
8023
|
newState[key] = lsonToJson(val);
|
|
7953
8024
|
}
|
|
7954
|
-
} else if (_optionalChain([update, 'access',
|
|
8025
|
+
} else if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "delete") {
|
|
7955
8026
|
delete newState[key];
|
|
7956
8027
|
}
|
|
7957
8028
|
}
|
|
@@ -8012,12 +8083,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8012
8083
|
}
|
|
8013
8084
|
const newState = Object.assign({}, state);
|
|
8014
8085
|
for (const key in update.updates) {
|
|
8015
|
-
if (_optionalChain([update, 'access',
|
|
8086
|
+
if (_optionalChain([update, 'access', _198 => _198.updates, 'access', _199 => _199[key], 'optionalAccess', _200 => _200.type]) === "update") {
|
|
8016
8087
|
const value = update.node.get(key);
|
|
8017
8088
|
if (value !== void 0) {
|
|
8018
8089
|
newState[key] = lsonToJson(value);
|
|
8019
8090
|
}
|
|
8020
|
-
} else if (_optionalChain([update, 'access',
|
|
8091
|
+
} else if (_optionalChain([update, 'access', _201 => _201.updates, 'access', _202 => _202[key], 'optionalAccess', _203 => _203.type]) === "delete") {
|
|
8021
8092
|
delete newState[key];
|
|
8022
8093
|
}
|
|
8023
8094
|
}
|
|
@@ -8088,9 +8159,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
8088
8159
|
const startTime = performance.now();
|
|
8089
8160
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8090
8161
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
8091
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8162
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _204 => _204.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
8092
8163
|
const context = {
|
|
8093
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
8164
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _205 => _205.visibilityState]) !== "hidden",
|
|
8094
8165
|
lastSuccessfulPollAt: startTime,
|
|
8095
8166
|
count: 0,
|
|
8096
8167
|
backoff: 0
|
|
@@ -8168,10 +8239,10 @@ function makePoller(callback, intervalMs, options) {
|
|
|
8168
8239
|
pollNowIfStale();
|
|
8169
8240
|
}
|
|
8170
8241
|
function onVisibilityChange() {
|
|
8171
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
8242
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _206 => _206.visibilityState]) !== "hidden");
|
|
8172
8243
|
}
|
|
8173
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8174
|
-
_optionalChain([win, 'optionalAccess',
|
|
8244
|
+
_optionalChain([doc, 'optionalAccess', _207 => _207.addEventListener, 'call', _208 => _208("visibilitychange", onVisibilityChange)]);
|
|
8245
|
+
_optionalChain([win, 'optionalAccess', _209 => _209.addEventListener, 'call', _210 => _210("online", onVisibilityChange)]);
|
|
8175
8246
|
fsm.start();
|
|
8176
8247
|
return {
|
|
8177
8248
|
inc,
|