@liveblocks/core 2.14.0-v2encoding → 2.15.0-debug1
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/README.md +1 -1
- package/dist/index.d.mts +86 -29
- package/dist/index.d.ts +86 -29
- package/dist/index.js +239 -301
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +214 -276
- 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.15.0-debug1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2668,7 +2668,7 @@ var ManagedSocket = class {
|
|
|
2668
2668
|
#machine;
|
|
2669
2669
|
#cleanups;
|
|
2670
2670
|
|
|
2671
|
-
constructor(delegates, enableDebugLogging =
|
|
2671
|
+
constructor(delegates, enableDebugLogging = true, waitForActorId = true) {
|
|
2672
2672
|
const { machine, events, cleanups } = createConnectionStateMachine(
|
|
2673
2673
|
delegates,
|
|
2674
2674
|
{ waitForActorId, enableDebugLogging }
|
|
@@ -3214,68 +3214,13 @@ function unlinkDevTools(roomId) {
|
|
|
3214
3214
|
});
|
|
3215
3215
|
}
|
|
3216
3216
|
|
|
3217
|
-
// src/lib/create-store.ts
|
|
3218
|
-
function createStore(initialState) {
|
|
3219
|
-
let notifyImmediately = true;
|
|
3220
|
-
let dirty = false;
|
|
3221
|
-
let state = initialState;
|
|
3222
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
3223
|
-
function get() {
|
|
3224
|
-
return state;
|
|
3225
|
-
}
|
|
3226
|
-
function set(callback) {
|
|
3227
|
-
const oldState = state;
|
|
3228
|
-
const newState = callback(oldState);
|
|
3229
|
-
if (newState !== oldState) {
|
|
3230
|
-
state = newState;
|
|
3231
|
-
dirty = true;
|
|
3232
|
-
}
|
|
3233
|
-
if (notifyImmediately) {
|
|
3234
|
-
notify();
|
|
3235
|
-
}
|
|
3236
|
-
}
|
|
3237
|
-
function notify() {
|
|
3238
|
-
if (!dirty) {
|
|
3239
|
-
return;
|
|
3240
|
-
}
|
|
3241
|
-
dirty = false;
|
|
3242
|
-
for (const subscriber of subscribers) {
|
|
3243
|
-
subscriber(state);
|
|
3244
|
-
}
|
|
3245
|
-
}
|
|
3246
|
-
function batch2(cb) {
|
|
3247
|
-
if (notifyImmediately === false) {
|
|
3248
|
-
return cb();
|
|
3249
|
-
}
|
|
3250
|
-
notifyImmediately = false;
|
|
3251
|
-
try {
|
|
3252
|
-
cb();
|
|
3253
|
-
} finally {
|
|
3254
|
-
notifyImmediately = true;
|
|
3255
|
-
notify();
|
|
3256
|
-
}
|
|
3257
|
-
}
|
|
3258
|
-
function subscribe(callback) {
|
|
3259
|
-
subscribers.add(callback);
|
|
3260
|
-
return () => {
|
|
3261
|
-
subscribers.delete(callback);
|
|
3262
|
-
};
|
|
3263
|
-
}
|
|
3264
|
-
return {
|
|
3265
|
-
get,
|
|
3266
|
-
set,
|
|
3267
|
-
batch: batch2,
|
|
3268
|
-
subscribe
|
|
3269
|
-
};
|
|
3270
|
-
}
|
|
3271
|
-
|
|
3272
3217
|
// src/lib/freeze.ts
|
|
3273
3218
|
var freeze = process.env.NODE_ENV === "production" ? (
|
|
3274
3219
|
/* istanbul ignore next */
|
|
3275
3220
|
(x) => x
|
|
3276
3221
|
) : Object.freeze;
|
|
3277
3222
|
|
|
3278
|
-
// src/lib/
|
|
3223
|
+
// src/lib/signals.ts
|
|
3279
3224
|
var kSinks = Symbol("kSinks");
|
|
3280
3225
|
var kTrigger = Symbol("kTrigger");
|
|
3281
3226
|
var signalsToTrigger = null;
|
|
@@ -3515,7 +3460,7 @@ var MutableSignal = class extends AbstractSignal {
|
|
|
3515
3460
|
*/
|
|
3516
3461
|
mutate(callback) {
|
|
3517
3462
|
batch(() => {
|
|
3518
|
-
const result = callback(this.#state);
|
|
3463
|
+
const result = callback ? callback(this.#state) : true;
|
|
3519
3464
|
if (result !== null && typeof result === "object" && "then" in result) {
|
|
3520
3465
|
raise("MutableSignal.mutate() does not support async callbacks");
|
|
3521
3466
|
}
|
|
@@ -6324,8 +6269,25 @@ function createRoom(options, config) {
|
|
|
6324
6269
|
// Debug
|
|
6325
6270
|
opStackTraces: process.env.NODE_ENV !== "production" ? /* @__PURE__ */ new Map() : void 0
|
|
6326
6271
|
};
|
|
6327
|
-
|
|
6328
|
-
|
|
6272
|
+
function printPending(cs) {
|
|
6273
|
+
if (cs) globalThis.console.log(`[debug] at ${cs}`);
|
|
6274
|
+
if (context.unacknowledgedOps.size === 0) {
|
|
6275
|
+
globalThis.console.log("[debug] no pending ops");
|
|
6276
|
+
} else {
|
|
6277
|
+
globalThis.console.log(
|
|
6278
|
+
`[debug] pending ops (${context.unacknowledgedOps.size}):`
|
|
6279
|
+
);
|
|
6280
|
+
for (const [opId, op] of context.unacknowledgedOps) {
|
|
6281
|
+
globalThis.console.log(
|
|
6282
|
+
"[debug] opid=",
|
|
6283
|
+
opId,
|
|
6284
|
+
"op=",
|
|
6285
|
+
JSON.stringify(op)
|
|
6286
|
+
);
|
|
6287
|
+
}
|
|
6288
|
+
}
|
|
6289
|
+
globalThis.console.log("[debug] storage status", getStorageStatus());
|
|
6290
|
+
}
|
|
6329
6291
|
let lastTokenKey;
|
|
6330
6292
|
function onStatusDidChange(newStatus) {
|
|
6331
6293
|
const authValue = managedSocket.authValue;
|
|
@@ -6347,34 +6309,26 @@ function createRoom(options, config) {
|
|
|
6347
6309
|
}
|
|
6348
6310
|
}
|
|
6349
6311
|
}
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
notifySelfChanged(doNotBatchUpdates);
|
|
6353
|
-
});
|
|
6312
|
+
eventHub.status.notify(newStatus);
|
|
6313
|
+
notifySelfChanged();
|
|
6354
6314
|
}
|
|
6355
6315
|
let _connectionLossTimerId;
|
|
6356
6316
|
let _hasLostConnection = false;
|
|
6357
6317
|
function handleConnectionLossEvent(newStatus) {
|
|
6358
6318
|
if (newStatus === "reconnecting") {
|
|
6359
6319
|
_connectionLossTimerId = setTimeout(() => {
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
notify({ others: [{ type: "reset" }] }, doNotBatchUpdates);
|
|
6365
|
-
});
|
|
6320
|
+
eventHub.lostConnection.notify("lost");
|
|
6321
|
+
_hasLostConnection = true;
|
|
6322
|
+
context.others.clearOthers();
|
|
6323
|
+
notify({ others: [{ type: "reset" }] });
|
|
6366
6324
|
}, config.lostConnectionTimeout);
|
|
6367
6325
|
} else {
|
|
6368
6326
|
clearTimeout(_connectionLossTimerId);
|
|
6369
6327
|
if (_hasLostConnection) {
|
|
6370
6328
|
if (newStatus === "disconnected") {
|
|
6371
|
-
|
|
6372
|
-
eventHub.lostConnection.notify("failed");
|
|
6373
|
-
});
|
|
6329
|
+
eventHub.lostConnection.notify("failed");
|
|
6374
6330
|
} else {
|
|
6375
|
-
|
|
6376
|
-
eventHub.lostConnection.notify("restored");
|
|
6377
|
-
});
|
|
6331
|
+
eventHub.lostConnection.notify("restored");
|
|
6378
6332
|
}
|
|
6379
6333
|
_hasLostConnection = false;
|
|
6380
6334
|
}
|
|
@@ -6404,14 +6358,12 @@ function createRoom(options, config) {
|
|
|
6404
6358
|
managedSocket.events.didConnect.subscribe(onDidConnect);
|
|
6405
6359
|
managedSocket.events.didDisconnect.subscribe(onDidDisconnect);
|
|
6406
6360
|
managedSocket.events.onLiveblocksError.subscribe((err) => {
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
eventHub.error.notify(err);
|
|
6414
|
-
});
|
|
6361
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6362
|
+
error2(
|
|
6363
|
+
`Connection to websocket server closed. Reason: ${err.message} (code: ${err.code}).`
|
|
6364
|
+
);
|
|
6365
|
+
}
|
|
6366
|
+
eventHub.error.notify(err);
|
|
6415
6367
|
});
|
|
6416
6368
|
const pool = {
|
|
6417
6369
|
roomId: config.roomId,
|
|
@@ -6447,12 +6399,10 @@ function createRoom(options, config) {
|
|
|
6447
6399
|
}
|
|
6448
6400
|
activeBatch.reverseOps.unshift(...reverse);
|
|
6449
6401
|
} else {
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
notify({ storageUpdates }, doNotBatchUpdates);
|
|
6455
|
-
});
|
|
6402
|
+
addToUndoStack(reverse);
|
|
6403
|
+
context.redoStack.length = 0;
|
|
6404
|
+
dispatchOps(ops);
|
|
6405
|
+
notify({ storageUpdates });
|
|
6456
6406
|
}
|
|
6457
6407
|
},
|
|
6458
6408
|
assertStorageIsWritable: () => {
|
|
@@ -6550,12 +6500,10 @@ function createRoom(options, config) {
|
|
|
6550
6500
|
}
|
|
6551
6501
|
);
|
|
6552
6502
|
let _lastSelf;
|
|
6553
|
-
function notifySelfChanged(
|
|
6503
|
+
function notifySelfChanged() {
|
|
6554
6504
|
const currSelf = self.get();
|
|
6555
6505
|
if (currSelf !== null && currSelf !== _lastSelf) {
|
|
6556
|
-
|
|
6557
|
-
eventHub.self.notify(currSelf);
|
|
6558
|
-
});
|
|
6506
|
+
eventHub.self.notify(currSelf);
|
|
6559
6507
|
_lastSelf = currSelf;
|
|
6560
6508
|
}
|
|
6561
6509
|
}
|
|
@@ -6563,12 +6511,12 @@ function createRoom(options, config) {
|
|
|
6563
6511
|
self,
|
|
6564
6512
|
(me) => me !== null ? userToTreeNode("Me", me) : null
|
|
6565
6513
|
);
|
|
6566
|
-
function createOrUpdateRootFromMessage(message
|
|
6514
|
+
function createOrUpdateRootFromMessage(message) {
|
|
6567
6515
|
if (message.items.length === 0) {
|
|
6568
6516
|
throw new Error("Internal error: cannot load storage without items");
|
|
6569
6517
|
}
|
|
6570
6518
|
if (context.root !== void 0) {
|
|
6571
|
-
updateRoot(message.items
|
|
6519
|
+
updateRoot(message.items);
|
|
6572
6520
|
} else {
|
|
6573
6521
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
6574
6522
|
}
|
|
@@ -6587,7 +6535,7 @@ function createRoom(options, config) {
|
|
|
6587
6535
|
}
|
|
6588
6536
|
context.undoStack.length = stackSizeBefore;
|
|
6589
6537
|
}
|
|
6590
|
-
function updateRoot(items
|
|
6538
|
+
function updateRoot(items) {
|
|
6591
6539
|
if (context.root === void 0) {
|
|
6592
6540
|
return;
|
|
6593
6541
|
}
|
|
@@ -6597,42 +6545,40 @@ function createRoom(options, config) {
|
|
|
6597
6545
|
}
|
|
6598
6546
|
const ops = getTreesDiffOperations(currentItems, new Map(items));
|
|
6599
6547
|
const result = applyOps(ops, false);
|
|
6600
|
-
notify(result.updates
|
|
6548
|
+
notify(result.updates);
|
|
6601
6549
|
}
|
|
6602
|
-
function _addToRealUndoStack(historyOps
|
|
6550
|
+
function _addToRealUndoStack(historyOps) {
|
|
6603
6551
|
if (context.undoStack.length >= 50) {
|
|
6604
6552
|
context.undoStack.shift();
|
|
6605
6553
|
}
|
|
6606
6554
|
context.undoStack.push(historyOps);
|
|
6607
|
-
onHistoryChange(
|
|
6555
|
+
onHistoryChange();
|
|
6608
6556
|
}
|
|
6609
|
-
function addToUndoStack(historyOps
|
|
6557
|
+
function addToUndoStack(historyOps) {
|
|
6610
6558
|
if (context.pausedHistory !== null) {
|
|
6611
6559
|
context.pausedHistory.unshift(...historyOps);
|
|
6612
6560
|
} else {
|
|
6613
|
-
_addToRealUndoStack(historyOps
|
|
6561
|
+
_addToRealUndoStack(historyOps);
|
|
6614
6562
|
}
|
|
6615
6563
|
}
|
|
6616
|
-
function notify(updates
|
|
6564
|
+
function notify(updates) {
|
|
6617
6565
|
const storageUpdates = updates.storageUpdates;
|
|
6618
6566
|
const othersUpdates = updates.others;
|
|
6619
|
-
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
eventHub.others.notify({ ...event, others });
|
|
6624
|
-
}
|
|
6625
|
-
}
|
|
6626
|
-
if (_nullishCoalesce(updates.presence, () => ( false))) {
|
|
6627
|
-
notifySelfChanged(doNotBatchUpdates);
|
|
6628
|
-
eventHub.myPresence.notify(context.myPresence.get());
|
|
6629
|
-
}
|
|
6630
|
-
if (storageUpdates !== void 0 && storageUpdates.size > 0) {
|
|
6631
|
-
const updates2 = Array.from(storageUpdates.values());
|
|
6632
|
-
eventHub.storageBatch.notify(updates2);
|
|
6567
|
+
if (othersUpdates !== void 0 && othersUpdates.length > 0) {
|
|
6568
|
+
const others = context.others.get();
|
|
6569
|
+
for (const event of othersUpdates) {
|
|
6570
|
+
eventHub.others.notify({ ...event, others });
|
|
6633
6571
|
}
|
|
6634
|
-
|
|
6635
|
-
|
|
6572
|
+
}
|
|
6573
|
+
if (_nullishCoalesce(updates.presence, () => ( false))) {
|
|
6574
|
+
notifySelfChanged();
|
|
6575
|
+
eventHub.myPresence.notify(context.myPresence.get());
|
|
6576
|
+
}
|
|
6577
|
+
if (storageUpdates !== void 0 && storageUpdates.size > 0) {
|
|
6578
|
+
const updates2 = Array.from(storageUpdates.values());
|
|
6579
|
+
eventHub.storageBatch.notify(updates2);
|
|
6580
|
+
}
|
|
6581
|
+
notifyStorageStatus();
|
|
6636
6582
|
}
|
|
6637
6583
|
function getConnectionId() {
|
|
6638
6584
|
const info = context.dynamicSessionInfoSig.get();
|
|
@@ -6644,6 +6590,7 @@ function createRoom(options, config) {
|
|
|
6644
6590
|
);
|
|
6645
6591
|
}
|
|
6646
6592
|
function applyOps(rawOps, isLocal) {
|
|
6593
|
+
printPending("start of applyOps");
|
|
6647
6594
|
const output = {
|
|
6648
6595
|
reverse: [],
|
|
6649
6596
|
storageUpdates: /* @__PURE__ */ new Map(),
|
|
@@ -6686,6 +6633,9 @@ function createRoom(options, config) {
|
|
|
6686
6633
|
nn(context.opStackTraces).delete(opId);
|
|
6687
6634
|
}
|
|
6688
6635
|
const deleted = context.unacknowledgedOps.delete(opId);
|
|
6636
|
+
if (deleted) {
|
|
6637
|
+
globalThis.console.log("[debug] acked", opId);
|
|
6638
|
+
}
|
|
6689
6639
|
source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
|
|
6690
6640
|
}
|
|
6691
6641
|
const applyOpResult = applyOp(op, source);
|
|
@@ -6707,6 +6657,7 @@ function createRoom(options, config) {
|
|
|
6707
6657
|
}
|
|
6708
6658
|
}
|
|
6709
6659
|
}
|
|
6660
|
+
printPending("end of applyOps");
|
|
6710
6661
|
return {
|
|
6711
6662
|
ops,
|
|
6712
6663
|
reverse: output.reverse,
|
|
@@ -6786,15 +6737,10 @@ function createRoom(options, config) {
|
|
|
6786
6737
|
context.activeBatch.updates.presence = true;
|
|
6787
6738
|
} else {
|
|
6788
6739
|
flushNowOrSoon();
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
doNotBatchUpdates
|
|
6794
|
-
);
|
|
6795
|
-
}
|
|
6796
|
-
notify({ presence: true }, doNotBatchUpdates);
|
|
6797
|
-
});
|
|
6740
|
+
if (_optionalChain([options2, 'optionalAccess', _141 => _141.addToHistory])) {
|
|
6741
|
+
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
6742
|
+
}
|
|
6743
|
+
notify({ presence: true });
|
|
6798
6744
|
}
|
|
6799
6745
|
}
|
|
6800
6746
|
function onUpdatePresenceMessage(message) {
|
|
@@ -6827,14 +6773,14 @@ function createRoom(options, config) {
|
|
|
6827
6773
|
}
|
|
6828
6774
|
return null;
|
|
6829
6775
|
}
|
|
6830
|
-
function onRoomStateMessage(message
|
|
6776
|
+
function onRoomStateMessage(message) {
|
|
6831
6777
|
context.dynamicSessionInfoSig.set({
|
|
6832
6778
|
actor: message.actor,
|
|
6833
6779
|
nonce: message.nonce,
|
|
6834
6780
|
scopes: message.scopes
|
|
6835
6781
|
});
|
|
6836
6782
|
context.idFactory = makeIdFactory(message.actor);
|
|
6837
|
-
notifySelfChanged(
|
|
6783
|
+
notifySelfChanged();
|
|
6838
6784
|
for (const connectionId of context.others.connectionIds()) {
|
|
6839
6785
|
const user = message.users[connectionId];
|
|
6840
6786
|
if (user === void 0) {
|
|
@@ -6859,10 +6805,8 @@ function createRoom(options, config) {
|
|
|
6859
6805
|
function canRedo() {
|
|
6860
6806
|
return context.redoStack.length > 0;
|
|
6861
6807
|
}
|
|
6862
|
-
function onHistoryChange(
|
|
6863
|
-
|
|
6864
|
-
eventHub.history.notify({ canUndo: canUndo(), canRedo: canRedo() });
|
|
6865
|
-
});
|
|
6808
|
+
function onHistoryChange() {
|
|
6809
|
+
eventHub.history.notify({ canUndo: canUndo(), canRedo: canRedo() });
|
|
6866
6810
|
}
|
|
6867
6811
|
function onUserJoinedMessage(message) {
|
|
6868
6812
|
context.others.setConnection(
|
|
@@ -6896,7 +6840,7 @@ function createRoom(options, config) {
|
|
|
6896
6840
|
return compact([parseServerMessage(data)]);
|
|
6897
6841
|
}
|
|
6898
6842
|
}
|
|
6899
|
-
function applyAndSendOps(offlineOps
|
|
6843
|
+
function applyAndSendOps(offlineOps) {
|
|
6900
6844
|
if (offlineOps.size === 0) {
|
|
6901
6845
|
return;
|
|
6902
6846
|
}
|
|
@@ -6907,7 +6851,7 @@ function createRoom(options, config) {
|
|
|
6907
6851
|
type: 201 /* UPDATE_STORAGE */,
|
|
6908
6852
|
ops: result.ops
|
|
6909
6853
|
});
|
|
6910
|
-
notify(result.updates
|
|
6854
|
+
notify(result.updates);
|
|
6911
6855
|
sendMessages(messages);
|
|
6912
6856
|
}
|
|
6913
6857
|
function handleServerMessage(event) {
|
|
@@ -6922,104 +6866,102 @@ function createRoom(options, config) {
|
|
|
6922
6866
|
storageUpdates: /* @__PURE__ */ new Map(),
|
|
6923
6867
|
others: []
|
|
6924
6868
|
};
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
updates.others.push(userJoinedUpdate);
|
|
6932
|
-
}
|
|
6933
|
-
break;
|
|
6934
|
-
}
|
|
6935
|
-
case 100 /* UPDATE_PRESENCE */: {
|
|
6936
|
-
const othersPresenceUpdate = onUpdatePresenceMessage(message);
|
|
6937
|
-
if (othersPresenceUpdate) {
|
|
6938
|
-
updates.others.push(othersPresenceUpdate);
|
|
6939
|
-
}
|
|
6940
|
-
break;
|
|
6869
|
+
for (const message of messages) {
|
|
6870
|
+
switch (message.type) {
|
|
6871
|
+
case 101 /* USER_JOINED */: {
|
|
6872
|
+
const userJoinedUpdate = onUserJoinedMessage(message);
|
|
6873
|
+
if (userJoinedUpdate) {
|
|
6874
|
+
updates.others.push(userJoinedUpdate);
|
|
6941
6875
|
}
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
});
|
|
6949
|
-
break;
|
|
6950
|
-
}
|
|
6951
|
-
case 102 /* USER_LEFT */: {
|
|
6952
|
-
const event2 = onUserLeftMessage(message);
|
|
6953
|
-
if (event2) {
|
|
6954
|
-
updates.others.push(event2);
|
|
6955
|
-
}
|
|
6956
|
-
break;
|
|
6957
|
-
}
|
|
6958
|
-
case 300 /* UPDATE_YDOC */: {
|
|
6959
|
-
eventHub.ydoc.notify(message);
|
|
6960
|
-
break;
|
|
6961
|
-
}
|
|
6962
|
-
case 104 /* ROOM_STATE */: {
|
|
6963
|
-
updates.others.push(onRoomStateMessage(message, doNotBatchUpdates));
|
|
6964
|
-
break;
|
|
6965
|
-
}
|
|
6966
|
-
case 200 /* INITIAL_STORAGE_STATE */: {
|
|
6967
|
-
processInitialStorage(message);
|
|
6968
|
-
break;
|
|
6876
|
+
break;
|
|
6877
|
+
}
|
|
6878
|
+
case 100 /* UPDATE_PRESENCE */: {
|
|
6879
|
+
const othersPresenceUpdate = onUpdatePresenceMessage(message);
|
|
6880
|
+
if (othersPresenceUpdate) {
|
|
6881
|
+
updates.others.push(othersPresenceUpdate);
|
|
6969
6882
|
}
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6883
|
+
break;
|
|
6884
|
+
}
|
|
6885
|
+
case 103 /* BROADCASTED_EVENT */: {
|
|
6886
|
+
const others = context.others.get();
|
|
6887
|
+
eventHub.customEvent.notify({
|
|
6888
|
+
connectionId: message.actor,
|
|
6889
|
+
user: message.actor < 0 ? null : _nullishCoalesce(others.find((u) => u.connectionId === message.actor), () => ( null)),
|
|
6890
|
+
event: message.event
|
|
6891
|
+
});
|
|
6892
|
+
break;
|
|
6893
|
+
}
|
|
6894
|
+
case 102 /* USER_LEFT */: {
|
|
6895
|
+
const event2 = onUserLeftMessage(message);
|
|
6896
|
+
if (event2) {
|
|
6897
|
+
updates.others.push(event2);
|
|
6979
6898
|
}
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6899
|
+
break;
|
|
6900
|
+
}
|
|
6901
|
+
case 300 /* UPDATE_YDOC */: {
|
|
6902
|
+
eventHub.ydoc.notify(message);
|
|
6903
|
+
break;
|
|
6904
|
+
}
|
|
6905
|
+
case 104 /* ROOM_STATE */: {
|
|
6906
|
+
updates.others.push(onRoomStateMessage(message));
|
|
6907
|
+
break;
|
|
6908
|
+
}
|
|
6909
|
+
case 200 /* INITIAL_STORAGE_STATE */: {
|
|
6910
|
+
processInitialStorage(message);
|
|
6911
|
+
break;
|
|
6912
|
+
}
|
|
6913
|
+
case 201 /* UPDATE_STORAGE */: {
|
|
6914
|
+
const applyResult = applyOps(message.ops, false);
|
|
6915
|
+
for (const [key, value] of applyResult.updates.storageUpdates) {
|
|
6916
|
+
updates.storageUpdates.set(
|
|
6917
|
+
key,
|
|
6918
|
+
mergeStorageUpdates(updates.storageUpdates.get(key), value)
|
|
6984
6919
|
);
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6920
|
+
}
|
|
6921
|
+
break;
|
|
6922
|
+
}
|
|
6923
|
+
case 299 /* REJECT_STORAGE_OP */: {
|
|
6924
|
+
errorWithTitle(
|
|
6925
|
+
"Storage mutation rejection error",
|
|
6926
|
+
message.reason
|
|
6927
|
+
);
|
|
6928
|
+
if (process.env.NODE_ENV !== "production") {
|
|
6929
|
+
const traces = /* @__PURE__ */ new Set();
|
|
6930
|
+
for (const opId of message.opIds) {
|
|
6931
|
+
const trace = _optionalChain([context, 'access', _142 => _142.opStackTraces, 'optionalAccess', _143 => _143.get, 'call', _144 => _144(opId)]);
|
|
6932
|
+
if (trace) {
|
|
6933
|
+
traces.add(trace);
|
|
6992
6934
|
}
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6935
|
+
}
|
|
6936
|
+
if (traces.size > 0) {
|
|
6937
|
+
warnWithTitle(
|
|
6938
|
+
"The following function calls caused the rejected storage mutations:",
|
|
6939
|
+
`
|
|
6997
6940
|
|
|
6998
6941
|
${Array.from(traces).join("\n\n")}`
|
|
6999
|
-
);
|
|
7000
|
-
}
|
|
7001
|
-
throw new Error(
|
|
7002
|
-
`Storage mutations rejected by server: ${message.reason}`
|
|
7003
6942
|
);
|
|
7004
6943
|
}
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
case 407 /* THREAD_DELETED */:
|
|
7009
|
-
case 401 /* THREAD_METADATA_UPDATED */:
|
|
7010
|
-
case 408 /* THREAD_UPDATED */:
|
|
7011
|
-
case 405 /* COMMENT_REACTION_ADDED */:
|
|
7012
|
-
case 406 /* COMMENT_REACTION_REMOVED */:
|
|
7013
|
-
case 402 /* COMMENT_CREATED */:
|
|
7014
|
-
case 403 /* COMMENT_EDITED */:
|
|
7015
|
-
case 404 /* COMMENT_DELETED */: {
|
|
7016
|
-
eventHub.comments.notify(message);
|
|
7017
|
-
break;
|
|
6944
|
+
throw new Error(
|
|
6945
|
+
`Storage mutations rejected by server: ${message.reason}`
|
|
6946
|
+
);
|
|
7018
6947
|
}
|
|
6948
|
+
break;
|
|
6949
|
+
}
|
|
6950
|
+
case 400 /* THREAD_CREATED */:
|
|
6951
|
+
case 407 /* THREAD_DELETED */:
|
|
6952
|
+
case 401 /* THREAD_METADATA_UPDATED */:
|
|
6953
|
+
case 408 /* THREAD_UPDATED */:
|
|
6954
|
+
case 405 /* COMMENT_REACTION_ADDED */:
|
|
6955
|
+
case 406 /* COMMENT_REACTION_REMOVED */:
|
|
6956
|
+
case 402 /* COMMENT_CREATED */:
|
|
6957
|
+
case 403 /* COMMENT_EDITED */:
|
|
6958
|
+
case 404 /* COMMENT_DELETED */: {
|
|
6959
|
+
eventHub.comments.notify(message);
|
|
6960
|
+
break;
|
|
7019
6961
|
}
|
|
7020
6962
|
}
|
|
7021
|
-
|
|
7022
|
-
|
|
6963
|
+
}
|
|
6964
|
+
notify(updates);
|
|
7023
6965
|
}
|
|
7024
6966
|
function flushNowOrSoon() {
|
|
7025
6967
|
const storageOps = context.buffer.storageOperations;
|
|
@@ -7027,6 +6969,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7027
6969
|
for (const op of storageOps) {
|
|
7028
6970
|
context.unacknowledgedOps.set(nn(op.opId), op);
|
|
7029
6971
|
}
|
|
6972
|
+
printPending("flushNowOrSoon");
|
|
7030
6973
|
notifyStorageStatus();
|
|
7031
6974
|
}
|
|
7032
6975
|
if (managedSocket.getStatus() !== "connected") {
|
|
@@ -7084,12 +7027,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7084
7027
|
}
|
|
7085
7028
|
return messages;
|
|
7086
7029
|
}
|
|
7087
|
-
function updateYDoc(update, guid
|
|
7030
|
+
function updateYDoc(update, guid) {
|
|
7088
7031
|
const clientMsg = {
|
|
7089
7032
|
type: 301 /* UPDATE_YDOC */,
|
|
7090
7033
|
update,
|
|
7091
|
-
guid
|
|
7092
|
-
v2: isV2
|
|
7034
|
+
guid
|
|
7093
7035
|
};
|
|
7094
7036
|
context.buffer.messages.push(clientMsg);
|
|
7095
7037
|
eventHub.ydoc.notify(clientMsg);
|
|
@@ -7117,9 +7059,10 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7117
7059
|
let _getStorage$ = null;
|
|
7118
7060
|
let _resolveStoragePromise = null;
|
|
7119
7061
|
function processInitialStorage(message) {
|
|
7062
|
+
printPending("initial local ops");
|
|
7120
7063
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
7121
|
-
createOrUpdateRootFromMessage(message
|
|
7122
|
-
applyAndSendOps(unacknowledgedOps
|
|
7064
|
+
createOrUpdateRootFromMessage(message);
|
|
7065
|
+
applyAndSendOps(unacknowledgedOps);
|
|
7123
7066
|
_optionalChain([_resolveStoragePromise, 'optionalCall', _145 => _145()]);
|
|
7124
7067
|
notifyStorageStatus();
|
|
7125
7068
|
eventHub.storageDidLoad.notify();
|
|
@@ -7170,15 +7113,14 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7170
7113
|
root: nn(context.root)
|
|
7171
7114
|
};
|
|
7172
7115
|
}
|
|
7173
|
-
function fetchYDoc(vector, guid
|
|
7116
|
+
function fetchYDoc(vector, guid) {
|
|
7174
7117
|
if (!context.buffer.messages.find((m) => {
|
|
7175
|
-
return m.type === 300 /* FETCH_YDOC */ && m.vector === vector && m.guid === guid
|
|
7118
|
+
return m.type === 300 /* FETCH_YDOC */ && m.vector === vector && m.guid === guid;
|
|
7176
7119
|
})) {
|
|
7177
7120
|
context.buffer.messages.push({
|
|
7178
7121
|
type: 300 /* FETCH_YDOC */,
|
|
7179
7122
|
vector,
|
|
7180
|
-
guid
|
|
7181
|
-
v2: isV2
|
|
7123
|
+
guid
|
|
7182
7124
|
});
|
|
7183
7125
|
}
|
|
7184
7126
|
flushNowOrSoon();
|
|
@@ -7193,11 +7135,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7193
7135
|
}
|
|
7194
7136
|
context.pausedHistory = null;
|
|
7195
7137
|
const result = applyOps(historyOps, true);
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
onHistoryChange(doNotBatchUpdates);
|
|
7200
|
-
});
|
|
7138
|
+
notify(result.updates);
|
|
7139
|
+
context.redoStack.push(result.reverse);
|
|
7140
|
+
onHistoryChange();
|
|
7201
7141
|
for (const op of result.ops) {
|
|
7202
7142
|
if (op.type !== "presence") {
|
|
7203
7143
|
context.buffer.storageOperations.push(op);
|
|
@@ -7215,11 +7155,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7215
7155
|
}
|
|
7216
7156
|
context.pausedHistory = null;
|
|
7217
7157
|
const result = applyOps(historyOps, true);
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
onHistoryChange(doNotBatchUpdates);
|
|
7222
|
-
});
|
|
7158
|
+
notify(result.updates);
|
|
7159
|
+
context.undoStack.push(result.reverse);
|
|
7160
|
+
onHistoryChange();
|
|
7223
7161
|
for (const op of result.ops) {
|
|
7224
7162
|
if (op.type !== "presence") {
|
|
7225
7163
|
context.buffer.storageOperations.push(op);
|
|
@@ -7236,34 +7174,32 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7236
7174
|
return callback();
|
|
7237
7175
|
}
|
|
7238
7176
|
let returnValue = void 0;
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7255
|
-
addToUndoStack(currentBatch.reverseOps, doNotBatchUpdates);
|
|
7256
|
-
}
|
|
7257
|
-
if (currentBatch.ops.length > 0) {
|
|
7258
|
-
context.redoStack.length = 0;
|
|
7259
|
-
}
|
|
7260
|
-
if (currentBatch.ops.length > 0) {
|
|
7261
|
-
dispatchOps(currentBatch.ops);
|
|
7262
|
-
}
|
|
7263
|
-
notify(currentBatch.updates, doNotBatchUpdates);
|
|
7264
|
-
flushNowOrSoon();
|
|
7177
|
+
context.activeBatch = {
|
|
7178
|
+
ops: [],
|
|
7179
|
+
updates: {
|
|
7180
|
+
storageUpdates: /* @__PURE__ */ new Map(),
|
|
7181
|
+
presence: false,
|
|
7182
|
+
others: []
|
|
7183
|
+
},
|
|
7184
|
+
reverseOps: []
|
|
7185
|
+
};
|
|
7186
|
+
try {
|
|
7187
|
+
returnValue = callback();
|
|
7188
|
+
} finally {
|
|
7189
|
+
const currentBatch = context.activeBatch;
|
|
7190
|
+
context.activeBatch = null;
|
|
7191
|
+
if (currentBatch.reverseOps.length > 0) {
|
|
7192
|
+
addToUndoStack(currentBatch.reverseOps);
|
|
7265
7193
|
}
|
|
7266
|
-
|
|
7194
|
+
if (currentBatch.ops.length > 0) {
|
|
7195
|
+
context.redoStack.length = 0;
|
|
7196
|
+
}
|
|
7197
|
+
if (currentBatch.ops.length > 0) {
|
|
7198
|
+
dispatchOps(currentBatch.ops);
|
|
7199
|
+
}
|
|
7200
|
+
notify(currentBatch.updates);
|
|
7201
|
+
flushNowOrSoon();
|
|
7202
|
+
}
|
|
7267
7203
|
return returnValue;
|
|
7268
7204
|
}
|
|
7269
7205
|
function pauseHistory() {
|
|
@@ -7275,7 +7211,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7275
7211
|
const historyOps = context.pausedHistory;
|
|
7276
7212
|
context.pausedHistory = null;
|
|
7277
7213
|
if (historyOps !== null && historyOps.length > 0) {
|
|
7278
|
-
_addToRealUndoStack(historyOps
|
|
7214
|
+
_addToRealUndoStack(historyOps);
|
|
7279
7215
|
}
|
|
7280
7216
|
}
|
|
7281
7217
|
const syncSourceForStorage = config.createSyncSource();
|
|
@@ -7738,10 +7674,10 @@ function createClient(options) {
|
|
|
7738
7674
|
clientOptions.backgroundKeepAliveTimeout
|
|
7739
7675
|
);
|
|
7740
7676
|
const baseUrl = getBaseUrl(clientOptions.baseUrl);
|
|
7741
|
-
const
|
|
7677
|
+
const currentUserId = new Signal(void 0);
|
|
7742
7678
|
const authManager = createAuthManager(options, (token) => {
|
|
7743
7679
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
7744
|
-
|
|
7680
|
+
currentUserId.set(() => userId);
|
|
7745
7681
|
});
|
|
7746
7682
|
const fetchPolyfill = _optionalChain([clientOptions, 'access', _161 => _161.polyfills, 'optionalAccess', _162 => _162.fetch]) || /* istanbul ignore next */
|
|
7747
7683
|
_optionalChain([globalThis, 'access', _163 => _163.fetch, 'optionalAccess', _164 => _164.bind, 'call', _165 => _165(globalThis)]);
|
|
@@ -7800,7 +7736,6 @@ function createClient(options) {
|
|
|
7800
7736
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7801
7737
|
})),
|
|
7802
7738
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7803
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _168 => _168.unstable_batchedUpdates]),
|
|
7804
7739
|
baseUrl,
|
|
7805
7740
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7806
7741
|
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
@@ -7818,7 +7753,7 @@ function createClient(options) {
|
|
|
7818
7753
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7819
7754
|
if (shouldConnect) {
|
|
7820
7755
|
if (typeof atob === "undefined") {
|
|
7821
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7756
|
+
if (_optionalChain([clientOptions, 'access', _168 => _168.polyfills, 'optionalAccess', _169 => _169.atob]) === void 0) {
|
|
7822
7757
|
throw new Error(
|
|
7823
7758
|
"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"
|
|
7824
7759
|
);
|
|
@@ -7830,12 +7765,12 @@ function createClient(options) {
|
|
|
7830
7765
|
return leaseRoom(newRoomDetails);
|
|
7831
7766
|
}
|
|
7832
7767
|
function getRoom(roomId) {
|
|
7833
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7768
|
+
const room = _optionalChain([roomsById, 'access', _170 => _170.get, 'call', _171 => _171(roomId), 'optionalAccess', _172 => _172.room]);
|
|
7834
7769
|
return room ? room : null;
|
|
7835
7770
|
}
|
|
7836
7771
|
function logout() {
|
|
7837
7772
|
authManager.reset();
|
|
7838
|
-
|
|
7773
|
+
currentUserId.set(() => void 0);
|
|
7839
7774
|
for (const { room } of roomsById.values()) {
|
|
7840
7775
|
if (!isIdle(room.getStatus())) {
|
|
7841
7776
|
room.reconnect();
|
|
@@ -7850,7 +7785,7 @@ function createClient(options) {
|
|
|
7850
7785
|
const batchedResolveUsers = new Batch(
|
|
7851
7786
|
async (batchedUserIds) => {
|
|
7852
7787
|
const userIds = batchedUserIds.flat();
|
|
7853
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7788
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _173 => _173({ userIds })]);
|
|
7854
7789
|
warnIfNoResolveUsers();
|
|
7855
7790
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7856
7791
|
},
|
|
@@ -7868,7 +7803,7 @@ function createClient(options) {
|
|
|
7868
7803
|
const batchedResolveRoomsInfo = new Batch(
|
|
7869
7804
|
async (batchedRoomIds) => {
|
|
7870
7805
|
const roomIds = batchedRoomIds.flat();
|
|
7871
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7806
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _174 => _174({ roomIds })]);
|
|
7872
7807
|
warnIfNoResolveRoomsInfo();
|
|
7873
7808
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7874
7809
|
},
|
|
@@ -7920,7 +7855,7 @@ function createClient(options) {
|
|
|
7920
7855
|
}
|
|
7921
7856
|
};
|
|
7922
7857
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
7923
|
-
_optionalChain([win, 'optionalAccess',
|
|
7858
|
+
_optionalChain([win, 'optionalAccess', _175 => _175.addEventListener, 'call', _176 => _176("beforeunload", maybePreventClose)]);
|
|
7924
7859
|
}
|
|
7925
7860
|
const client = Object.defineProperty(
|
|
7926
7861
|
{
|
|
@@ -7947,7 +7882,7 @@ function createClient(options) {
|
|
|
7947
7882
|
},
|
|
7948
7883
|
// Internal
|
|
7949
7884
|
[kInternal]: {
|
|
7950
|
-
|
|
7885
|
+
currentUserId,
|
|
7951
7886
|
mentionSuggestionsCache,
|
|
7952
7887
|
resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
|
|
7953
7888
|
usersStore,
|
|
@@ -8037,7 +7972,7 @@ var commentBodyElementsTypes = {
|
|
|
8037
7972
|
mention: "inline"
|
|
8038
7973
|
};
|
|
8039
7974
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
8040
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7975
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _177 => _177.content])) {
|
|
8041
7976
|
return;
|
|
8042
7977
|
}
|
|
8043
7978
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -8047,13 +7982,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
8047
7982
|
for (const block of body.content) {
|
|
8048
7983
|
if (type === "all" || type === "block") {
|
|
8049
7984
|
if (guard(block)) {
|
|
8050
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7985
|
+
_optionalChain([visitor, 'optionalCall', _178 => _178(block)]);
|
|
8051
7986
|
}
|
|
8052
7987
|
}
|
|
8053
7988
|
if (type === "all" || type === "inline") {
|
|
8054
7989
|
for (const inline of block.children) {
|
|
8055
7990
|
if (guard(inline)) {
|
|
8056
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7991
|
+
_optionalChain([visitor, 'optionalCall', _179 => _179(inline)]);
|
|
8057
7992
|
}
|
|
8058
7993
|
}
|
|
8059
7994
|
}
|
|
@@ -8078,7 +8013,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
8078
8013
|
userIds
|
|
8079
8014
|
});
|
|
8080
8015
|
for (const [index, userId] of userIds.entries()) {
|
|
8081
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
8016
|
+
const user = _optionalChain([users, 'optionalAccess', _180 => _180[index]]);
|
|
8082
8017
|
if (user) {
|
|
8083
8018
|
resolvedUsers.set(userId, user);
|
|
8084
8019
|
}
|
|
@@ -8205,7 +8140,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
8205
8140
|
text: ({ element }) => element.text,
|
|
8206
8141
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
8207
8142
|
mention: ({ element, user }) => {
|
|
8208
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8143
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _181 => _181.name]), () => ( element.id))}`;
|
|
8209
8144
|
}
|
|
8210
8145
|
};
|
|
8211
8146
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -8235,7 +8170,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8235
8170
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
8236
8171
|
},
|
|
8237
8172
|
mention: ({ element, user }) => {
|
|
8238
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8173
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _182 => _182.name]), () => ( element.id))}</span>`;
|
|
8239
8174
|
}
|
|
8240
8175
|
};
|
|
8241
8176
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -8265,19 +8200,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
8265
8200
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
8266
8201
|
},
|
|
8267
8202
|
mention: ({ element, user }) => {
|
|
8268
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8203
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _183 => _183.name]), () => ( element.id))}`;
|
|
8269
8204
|
}
|
|
8270
8205
|
};
|
|
8271
8206
|
async function stringifyCommentBody(body, options) {
|
|
8272
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8273
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8207
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _184 => _184.format]), () => ( "plain"));
|
|
8208
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _185 => _185.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
8274
8209
|
const elements = {
|
|
8275
8210
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
8276
|
-
..._optionalChain([options, 'optionalAccess',
|
|
8211
|
+
..._optionalChain([options, 'optionalAccess', _186 => _186.elements])
|
|
8277
8212
|
};
|
|
8278
8213
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
8279
8214
|
body,
|
|
8280
|
-
_optionalChain([options, 'optionalAccess',
|
|
8215
|
+
_optionalChain([options, 'optionalAccess', _187 => _187.resolveUsers])
|
|
8281
8216
|
);
|
|
8282
8217
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
8283
8218
|
switch (block.type) {
|
|
@@ -8568,12 +8503,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8568
8503
|
}
|
|
8569
8504
|
const newState = Object.assign({}, state);
|
|
8570
8505
|
for (const key in update.updates) {
|
|
8571
|
-
if (_optionalChain([update, 'access',
|
|
8506
|
+
if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
|
|
8572
8507
|
const val = update.node.get(key);
|
|
8573
8508
|
if (val !== void 0) {
|
|
8574
8509
|
newState[key] = lsonToJson(val);
|
|
8575
8510
|
}
|
|
8576
|
-
} else if (_optionalChain([update, 'access',
|
|
8511
|
+
} else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
|
|
8577
8512
|
delete newState[key];
|
|
8578
8513
|
}
|
|
8579
8514
|
}
|
|
@@ -8634,12 +8569,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8634
8569
|
}
|
|
8635
8570
|
const newState = Object.assign({}, state);
|
|
8636
8571
|
for (const key in update.updates) {
|
|
8637
|
-
if (_optionalChain([update, 'access',
|
|
8572
|
+
if (_optionalChain([update, 'access', _194 => _194.updates, 'access', _195 => _195[key], 'optionalAccess', _196 => _196.type]) === "update") {
|
|
8638
8573
|
const value = update.node.get(key);
|
|
8639
8574
|
if (value !== void 0) {
|
|
8640
8575
|
newState[key] = lsonToJson(value);
|
|
8641
8576
|
}
|
|
8642
|
-
} else if (_optionalChain([update, 'access',
|
|
8577
|
+
} else if (_optionalChain([update, 'access', _197 => _197.updates, 'access', _198 => _198[key], 'optionalAccess', _199 => _199.type]) === "delete") {
|
|
8643
8578
|
delete newState[key];
|
|
8644
8579
|
}
|
|
8645
8580
|
}
|
|
@@ -8710,9 +8645,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
8710
8645
|
const startTime = performance.now();
|
|
8711
8646
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8712
8647
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
8713
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8648
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _200 => _200.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
8714
8649
|
const context = {
|
|
8715
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
8650
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _201 => _201.visibilityState]) !== "hidden",
|
|
8716
8651
|
lastSuccessfulPollAt: startTime,
|
|
8717
8652
|
count: 0,
|
|
8718
8653
|
backoff: 0
|
|
@@ -8790,10 +8725,10 @@ function makePoller(callback, intervalMs, options) {
|
|
|
8790
8725
|
pollNowIfStale();
|
|
8791
8726
|
}
|
|
8792
8727
|
function onVisibilityChange() {
|
|
8793
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
8728
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _202 => _202.visibilityState]) !== "hidden");
|
|
8794
8729
|
}
|
|
8795
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8796
|
-
_optionalChain([win, 'optionalAccess',
|
|
8730
|
+
_optionalChain([doc, 'optionalAccess', _203 => _203.addEventListener, 'call', _204 => _204("visibilitychange", onVisibilityChange)]);
|
|
8731
|
+
_optionalChain([win, 'optionalAccess', _205 => _205.addEventListener, 'call', _206 => _206("online", onVisibilityChange)]);
|
|
8797
8732
|
fsm.start();
|
|
8798
8733
|
return {
|
|
8799
8734
|
inc,
|
|
@@ -9006,5 +8941,8 @@ var NotificationsApiError = HttpError;
|
|
|
9006
8941
|
|
|
9007
8942
|
|
|
9008
8943
|
|
|
9009
|
-
|
|
8944
|
+
|
|
8945
|
+
|
|
8946
|
+
|
|
8947
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; 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.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.createThreadId = createThreadId; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; 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.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.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.stringify = stringify; 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;
|
|
9010
8948
|
//# sourceMappingURL=index.js.map
|