@liveblocks/core 2.5.2 → 2.7.0-beta2
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 +102 -24
- package/dist/index.d.ts +102 -24
- package/dist/index.js +205 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -13
- 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.7.0-beta2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1859,8 +1859,7 @@ var Batch = class {
|
|
|
1859
1859
|
this.clearDelayTimeout();
|
|
1860
1860
|
}
|
|
1861
1861
|
};
|
|
1862
|
-
function createBatchStore(
|
|
1863
|
-
const batch = new Batch(callback, options);
|
|
1862
|
+
function createBatchStore(batch) {
|
|
1864
1863
|
const cache = /* @__PURE__ */ new Map();
|
|
1865
1864
|
const eventSource2 = makeEventSource();
|
|
1866
1865
|
function getCacheKey(args) {
|
|
@@ -4749,9 +4748,19 @@ function findNonSerializableValue(value, path = "") {
|
|
|
4749
4748
|
return false;
|
|
4750
4749
|
}
|
|
4751
4750
|
|
|
4751
|
+
// src/lib/chunk.ts
|
|
4752
|
+
function chunk(array, size) {
|
|
4753
|
+
const chunks = [];
|
|
4754
|
+
for (let i = 0, j = array.length; i < j; i += size) {
|
|
4755
|
+
chunks.push(array.slice(i, i + size));
|
|
4756
|
+
}
|
|
4757
|
+
return chunks;
|
|
4758
|
+
}
|
|
4759
|
+
|
|
4752
4760
|
// src/lib/createIds.ts
|
|
4753
4761
|
var THREAD_ID_PREFIX = "th";
|
|
4754
4762
|
var COMMENT_ID_PREFIX = "cm";
|
|
4763
|
+
var COMMENT_ATTACHMENT_ID_PREFIX = "at";
|
|
4755
4764
|
var INBOX_NOTIFICATION_ID_PREFIX = "in";
|
|
4756
4765
|
function createOptimisticId(prefix) {
|
|
4757
4766
|
return `${prefix}_${nanoid()}`;
|
|
@@ -4762,6 +4771,9 @@ function createThreadId() {
|
|
|
4762
4771
|
function createCommentId() {
|
|
4763
4772
|
return createOptimisticId(COMMENT_ID_PREFIX);
|
|
4764
4773
|
}
|
|
4774
|
+
function createCommentAttachmentId() {
|
|
4775
|
+
return createOptimisticId(COMMENT_ATTACHMENT_ID_PREFIX);
|
|
4776
|
+
}
|
|
4765
4777
|
function createInboxNotificationId() {
|
|
4766
4778
|
return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
|
|
4767
4779
|
}
|
|
@@ -5164,6 +5176,22 @@ function installBackgroundTabSpy() {
|
|
|
5164
5176
|
};
|
|
5165
5177
|
return [inBackgroundSince, unsub];
|
|
5166
5178
|
}
|
|
5179
|
+
var GET_ATTACHMENT_URLS_BATCH_DELAY = 50;
|
|
5180
|
+
var ATTACHMENT_PART_SIZE = 5 * 1024 * 1024;
|
|
5181
|
+
var ATTACHMENT_PART_BATCH_SIZE = 5;
|
|
5182
|
+
function splitFileIntoParts(file) {
|
|
5183
|
+
const parts = [];
|
|
5184
|
+
let start = 0;
|
|
5185
|
+
while (start < file.size) {
|
|
5186
|
+
const end = Math.min(start + ATTACHMENT_PART_SIZE, file.size);
|
|
5187
|
+
parts.push({
|
|
5188
|
+
partNumber: parts.length + 1,
|
|
5189
|
+
part: file.slice(start, end)
|
|
5190
|
+
});
|
|
5191
|
+
start = end;
|
|
5192
|
+
}
|
|
5193
|
+
return parts;
|
|
5194
|
+
}
|
|
5167
5195
|
var CommentsApiError = class extends Error {
|
|
5168
5196
|
constructor(message, status, details) {
|
|
5169
5197
|
super(message);
|
|
@@ -6434,7 +6462,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6434
6462
|
metadata,
|
|
6435
6463
|
body,
|
|
6436
6464
|
commentId = createCommentId(),
|
|
6437
|
-
threadId = createThreadId()
|
|
6465
|
+
threadId = createThreadId(),
|
|
6466
|
+
attachmentIds
|
|
6438
6467
|
}) {
|
|
6439
6468
|
const thread = await fetchCommentsJson("/threads", {
|
|
6440
6469
|
method: "POST",
|
|
@@ -6445,7 +6474,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6445
6474
|
id: threadId,
|
|
6446
6475
|
comment: {
|
|
6447
6476
|
id: commentId,
|
|
6448
|
-
body
|
|
6477
|
+
body,
|
|
6478
|
+
attachmentIds
|
|
6449
6479
|
},
|
|
6450
6480
|
metadata
|
|
6451
6481
|
})
|
|
@@ -6491,7 +6521,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6491
6521
|
async function createComment({
|
|
6492
6522
|
threadId,
|
|
6493
6523
|
commentId = createCommentId(),
|
|
6494
|
-
body
|
|
6524
|
+
body,
|
|
6525
|
+
attachmentIds
|
|
6495
6526
|
}) {
|
|
6496
6527
|
const comment = await fetchCommentsJson(
|
|
6497
6528
|
`/threads/${encodeURIComponent(threadId)}/comments`,
|
|
@@ -6502,7 +6533,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6502
6533
|
},
|
|
6503
6534
|
body: JSON.stringify({
|
|
6504
6535
|
id: commentId,
|
|
6505
|
-
body
|
|
6536
|
+
body,
|
|
6537
|
+
attachmentIds
|
|
6506
6538
|
})
|
|
6507
6539
|
}
|
|
6508
6540
|
);
|
|
@@ -6511,7 +6543,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6511
6543
|
async function editComment({
|
|
6512
6544
|
threadId,
|
|
6513
6545
|
commentId,
|
|
6514
|
-
body
|
|
6546
|
+
body,
|
|
6547
|
+
attachmentIds
|
|
6515
6548
|
}) {
|
|
6516
6549
|
const comment = await fetchCommentsJson(
|
|
6517
6550
|
`/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
|
|
@@ -6523,7 +6556,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6523
6556
|
"Content-Type": "application/json"
|
|
6524
6557
|
},
|
|
6525
6558
|
body: JSON.stringify({
|
|
6526
|
-
body
|
|
6559
|
+
body,
|
|
6560
|
+
attachmentIds
|
|
6527
6561
|
})
|
|
6528
6562
|
}
|
|
6529
6563
|
);
|
|
@@ -6575,6 +6609,126 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6575
6609
|
}
|
|
6576
6610
|
);
|
|
6577
6611
|
}
|
|
6612
|
+
function prepareAttachment(file) {
|
|
6613
|
+
return {
|
|
6614
|
+
type: "localAttachment",
|
|
6615
|
+
status: "idle",
|
|
6616
|
+
id: createCommentAttachmentId(),
|
|
6617
|
+
name: file.name,
|
|
6618
|
+
size: file.size,
|
|
6619
|
+
mimeType: file.type,
|
|
6620
|
+
file
|
|
6621
|
+
};
|
|
6622
|
+
}
|
|
6623
|
+
async function uploadAttachment(attachment, options2 = {}) {
|
|
6624
|
+
const abortSignal = options2.signal;
|
|
6625
|
+
const abortError = abortSignal ? new DOMException(
|
|
6626
|
+
`Upload of attachment ${attachment.id} was aborted.`,
|
|
6627
|
+
"AbortError"
|
|
6628
|
+
) : void 0;
|
|
6629
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _140 => _140.aborted])) {
|
|
6630
|
+
throw abortError;
|
|
6631
|
+
}
|
|
6632
|
+
if (attachment.size <= ATTACHMENT_PART_SIZE) {
|
|
6633
|
+
return fetchCommentsJson(
|
|
6634
|
+
`/attachments/${encodeURIComponent(attachment.id)}/upload/${encodeURIComponent(attachment.name)}`,
|
|
6635
|
+
{
|
|
6636
|
+
method: "PUT",
|
|
6637
|
+
body: attachment.file,
|
|
6638
|
+
signal: abortSignal
|
|
6639
|
+
}
|
|
6640
|
+
);
|
|
6641
|
+
} else {
|
|
6642
|
+
let uploadId;
|
|
6643
|
+
const uploadedParts = [];
|
|
6644
|
+
try {
|
|
6645
|
+
const createMultiPartUpload = await fetchCommentsJson(
|
|
6646
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
6647
|
+
{
|
|
6648
|
+
method: "POST",
|
|
6649
|
+
signal: abortSignal
|
|
6650
|
+
}
|
|
6651
|
+
);
|
|
6652
|
+
uploadId = createMultiPartUpload.uploadId;
|
|
6653
|
+
const parts = splitFileIntoParts(attachment.file);
|
|
6654
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _141 => _141.aborted])) {
|
|
6655
|
+
throw abortError;
|
|
6656
|
+
}
|
|
6657
|
+
const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
|
|
6658
|
+
for (const parts2 of batches) {
|
|
6659
|
+
const uploadedPartsPromises = [];
|
|
6660
|
+
for (const { part, partNumber } of parts2) {
|
|
6661
|
+
uploadedPartsPromises.push(
|
|
6662
|
+
fetchCommentsJson(
|
|
6663
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}/${encodeURIComponent(partNumber)}`,
|
|
6664
|
+
{
|
|
6665
|
+
method: "PUT",
|
|
6666
|
+
body: part,
|
|
6667
|
+
signal: abortSignal
|
|
6668
|
+
}
|
|
6669
|
+
)
|
|
6670
|
+
);
|
|
6671
|
+
}
|
|
6672
|
+
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
6673
|
+
}
|
|
6674
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _142 => _142.aborted])) {
|
|
6675
|
+
throw abortError;
|
|
6676
|
+
}
|
|
6677
|
+
const sortedUploadedParts = uploadedParts.sort(
|
|
6678
|
+
(a, b) => a.partNumber - b.partNumber
|
|
6679
|
+
);
|
|
6680
|
+
return fetchCommentsJson(
|
|
6681
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}/complete`,
|
|
6682
|
+
{
|
|
6683
|
+
method: "POST",
|
|
6684
|
+
headers: {
|
|
6685
|
+
"Content-Type": "application/json"
|
|
6686
|
+
},
|
|
6687
|
+
body: JSON.stringify({ parts: sortedUploadedParts }),
|
|
6688
|
+
signal: abortSignal
|
|
6689
|
+
}
|
|
6690
|
+
);
|
|
6691
|
+
} catch (error3) {
|
|
6692
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _143 => _143.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
6693
|
+
await fetchCommentsApi(
|
|
6694
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}`,
|
|
6695
|
+
void 0,
|
|
6696
|
+
{
|
|
6697
|
+
method: "DELETE"
|
|
6698
|
+
}
|
|
6699
|
+
);
|
|
6700
|
+
}
|
|
6701
|
+
throw error3;
|
|
6702
|
+
}
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
async function getAttachmentUrls(attachmentIds) {
|
|
6706
|
+
const { urls } = await fetchCommentsJson(
|
|
6707
|
+
"/attachments/presigned-urls",
|
|
6708
|
+
{
|
|
6709
|
+
method: "POST",
|
|
6710
|
+
headers: {
|
|
6711
|
+
"Content-Type": "application/json"
|
|
6712
|
+
},
|
|
6713
|
+
body: JSON.stringify({ attachmentIds })
|
|
6714
|
+
}
|
|
6715
|
+
);
|
|
6716
|
+
return urls;
|
|
6717
|
+
}
|
|
6718
|
+
const batchedGetAttachmentUrls = new Batch(
|
|
6719
|
+
async (batchedAttachmentIds) => {
|
|
6720
|
+
const attachmentIds = batchedAttachmentIds.flat();
|
|
6721
|
+
const attachmentUrls = await getAttachmentUrls(attachmentIds);
|
|
6722
|
+
return attachmentUrls.map(
|
|
6723
|
+
(url) => _nullishCoalesce(url, () => ( new Error("There was an error while getting this attachment's URL")))
|
|
6724
|
+
);
|
|
6725
|
+
},
|
|
6726
|
+
{ delay: GET_ATTACHMENT_URLS_BATCH_DELAY }
|
|
6727
|
+
);
|
|
6728
|
+
const attachmentUrlsStore = createBatchStore(batchedGetAttachmentUrls);
|
|
6729
|
+
function getAttachmentUrl(attachmentId) {
|
|
6730
|
+
return batchedGetAttachmentUrls.get(attachmentId);
|
|
6731
|
+
}
|
|
6578
6732
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6579
6733
|
const authValue = await delegates.authenticate();
|
|
6580
6734
|
const response = await fetchClientApi(
|
|
@@ -6651,7 +6805,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6651
6805
|
{
|
|
6652
6806
|
[kInternal]: {
|
|
6653
6807
|
get presenceBuffer() {
|
|
6654
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6808
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _144 => _144.buffer, 'access', _145 => _145.presenceUpdates, 'optionalAccess', _146 => _146.data]), () => ( null)));
|
|
6655
6809
|
},
|
|
6656
6810
|
// prettier-ignore
|
|
6657
6811
|
get undoStack() {
|
|
@@ -6684,7 +6838,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6684
6838
|
// These exist only for our E2E testing app
|
|
6685
6839
|
explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
|
|
6686
6840
|
rawSend: (data) => managedSocket.send(data)
|
|
6687
|
-
}
|
|
6841
|
+
},
|
|
6842
|
+
attachmentUrlsStore
|
|
6688
6843
|
},
|
|
6689
6844
|
id: config.roomId,
|
|
6690
6845
|
subscribe: makeClassicSubscribeFn(events),
|
|
@@ -6739,6 +6894,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6739
6894
|
deleteComment: deleteComment2,
|
|
6740
6895
|
addReaction: addReaction2,
|
|
6741
6896
|
removeReaction: removeReaction2,
|
|
6897
|
+
prepareAttachment,
|
|
6898
|
+
uploadAttachment,
|
|
6899
|
+
getAttachmentUrl,
|
|
6742
6900
|
// Notifications
|
|
6743
6901
|
getNotificationSettings,
|
|
6744
6902
|
updateNotificationSettings,
|
|
@@ -6825,7 +6983,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
6825
6983
|
}
|
|
6826
6984
|
if (isLiveNode(first)) {
|
|
6827
6985
|
const node = first;
|
|
6828
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6986
|
+
if (_optionalChain([options, 'optionalAccess', _147 => _147.isDeep])) {
|
|
6829
6987
|
const storageCallback = second;
|
|
6830
6988
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
6831
6989
|
} else {
|
|
@@ -7235,7 +7393,7 @@ function upsertComment(thread, comment) {
|
|
|
7235
7393
|
);
|
|
7236
7394
|
if (existingComment === void 0) {
|
|
7237
7395
|
const updatedAt = new Date(
|
|
7238
|
-
Math.max(_optionalChain([thread, 'access',
|
|
7396
|
+
Math.max(_optionalChain([thread, 'access', _148 => _148.updatedAt, 'optionalAccess', _149 => _149.getTime, 'call', _150 => _150()]) || 0, comment.createdAt.getTime())
|
|
7239
7397
|
);
|
|
7240
7398
|
const updatedThread = {
|
|
7241
7399
|
...thread,
|
|
@@ -7255,8 +7413,8 @@ function upsertComment(thread, comment) {
|
|
|
7255
7413
|
...thread,
|
|
7256
7414
|
updatedAt: new Date(
|
|
7257
7415
|
Math.max(
|
|
7258
|
-
_optionalChain([thread, 'access',
|
|
7259
|
-
_optionalChain([comment, 'access',
|
|
7416
|
+
_optionalChain([thread, 'access', _151 => _151.updatedAt, 'optionalAccess', _152 => _152.getTime, 'call', _153 => _153()]) || 0,
|
|
7417
|
+
_optionalChain([comment, 'access', _154 => _154.editedAt, 'optionalAccess', _155 => _155.getTime, 'call', _156 => _156()]) || comment.createdAt.getTime()
|
|
7260
7418
|
)
|
|
7261
7419
|
),
|
|
7262
7420
|
comments: updatedComments
|
|
@@ -7282,7 +7440,8 @@ function deleteComment(thread, commentId, deletedAt) {
|
|
|
7282
7440
|
(comment) => comment.id === commentId ? {
|
|
7283
7441
|
...comment,
|
|
7284
7442
|
deletedAt,
|
|
7285
|
-
body: void 0
|
|
7443
|
+
body: void 0,
|
|
7444
|
+
attachments: []
|
|
7286
7445
|
} : comment
|
|
7287
7446
|
);
|
|
7288
7447
|
if (!updatedComments.some((comment) => comment.deletedAt === void 0)) {
|
|
@@ -7321,7 +7480,7 @@ function addReaction(thread, commentId, reaction) {
|
|
|
7321
7480
|
return {
|
|
7322
7481
|
...thread,
|
|
7323
7482
|
updatedAt: new Date(
|
|
7324
|
-
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access',
|
|
7483
|
+
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _157 => _157.updatedAt, 'optionalAccess', _158 => _158.getTime, 'call', _159 => _159()]) || 0)
|
|
7325
7484
|
),
|
|
7326
7485
|
comments: updatedComments
|
|
7327
7486
|
};
|
|
@@ -7354,7 +7513,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
|
|
|
7354
7513
|
return {
|
|
7355
7514
|
...thread,
|
|
7356
7515
|
updatedAt: new Date(
|
|
7357
|
-
Math.max(removedAt.getTime(), _optionalChain([thread, 'access',
|
|
7516
|
+
Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _160 => _160.updatedAt, 'optionalAccess', _161 => _161.getTime, 'call', _162 => _162()]) || 0)
|
|
7358
7517
|
),
|
|
7359
7518
|
comments: updatedComments
|
|
7360
7519
|
};
|
|
@@ -7465,12 +7624,12 @@ function createClient(options) {
|
|
|
7465
7624
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7466
7625
|
roomId,
|
|
7467
7626
|
baseUrl,
|
|
7468
|
-
_optionalChain([clientOptions, 'access',
|
|
7627
|
+
_optionalChain([clientOptions, 'access', _163 => _163.polyfills, 'optionalAccess', _164 => _164.WebSocket])
|
|
7469
7628
|
),
|
|
7470
7629
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7471
7630
|
})),
|
|
7472
7631
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7473
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7632
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _165 => _165.unstable_batchedUpdates]),
|
|
7474
7633
|
baseUrl,
|
|
7475
7634
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7476
7635
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7486,7 +7645,7 @@ function createClient(options) {
|
|
|
7486
7645
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7487
7646
|
if (shouldConnect) {
|
|
7488
7647
|
if (typeof atob === "undefined") {
|
|
7489
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7648
|
+
if (_optionalChain([clientOptions, 'access', _166 => _166.polyfills, 'optionalAccess', _167 => _167.atob]) === void 0) {
|
|
7490
7649
|
throw new Error(
|
|
7491
7650
|
"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"
|
|
7492
7651
|
);
|
|
@@ -7498,7 +7657,7 @@ function createClient(options) {
|
|
|
7498
7657
|
return leaseRoom(newRoomDetails);
|
|
7499
7658
|
}
|
|
7500
7659
|
function getRoom(roomId) {
|
|
7501
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7660
|
+
const room = _optionalChain([roomsById, 'access', _168 => _168.get, 'call', _169 => _169(roomId), 'optionalAccess', _170 => _170.room]);
|
|
7502
7661
|
return room ? room : null;
|
|
7503
7662
|
}
|
|
7504
7663
|
function logout() {
|
|
@@ -7522,7 +7681,7 @@ function createClient(options) {
|
|
|
7522
7681
|
getThreadsSince
|
|
7523
7682
|
} = createNotificationsApi({
|
|
7524
7683
|
baseUrl,
|
|
7525
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7684
|
+
fetcher: _optionalChain([clientOptions, 'access', _171 => _171.polyfills, 'optionalAccess', _172 => _172.fetch]) || /* istanbul ignore next */
|
|
7526
7685
|
fetch,
|
|
7527
7686
|
authManager,
|
|
7528
7687
|
currentUserIdStore
|
|
@@ -7533,29 +7692,31 @@ function createClient(options) {
|
|
|
7533
7692
|
() => !resolveUsers,
|
|
7534
7693
|
"Set the resolveUsers option in createClient to specify user info."
|
|
7535
7694
|
);
|
|
7536
|
-
const
|
|
7695
|
+
const batchedResolveUsers = new Batch(
|
|
7537
7696
|
async (batchedUserIds) => {
|
|
7538
7697
|
const userIds = batchedUserIds.flat();
|
|
7539
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7698
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _173 => _173({ userIds })]);
|
|
7540
7699
|
warnIfNoResolveUsers();
|
|
7541
7700
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7542
7701
|
},
|
|
7543
7702
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
7544
7703
|
);
|
|
7704
|
+
const usersStore = createBatchStore(batchedResolveUsers);
|
|
7545
7705
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
7546
7706
|
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
7547
7707
|
() => !resolveRoomsInfo,
|
|
7548
7708
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
7549
7709
|
);
|
|
7550
|
-
const
|
|
7710
|
+
const batchedResolveRoomsInfo = new Batch(
|
|
7551
7711
|
async (batchedRoomIds) => {
|
|
7552
7712
|
const roomIds = batchedRoomIds.flat();
|
|
7553
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7713
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _174 => _174({ roomIds })]);
|
|
7554
7714
|
warnIfNoResolveRoomsInfo();
|
|
7555
7715
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7556
7716
|
},
|
|
7557
7717
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
7558
7718
|
);
|
|
7719
|
+
const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
|
|
7559
7720
|
return Object.defineProperty(
|
|
7560
7721
|
{
|
|
7561
7722
|
enterRoom,
|
|
@@ -7666,7 +7827,7 @@ var commentBodyElementsTypes = {
|
|
|
7666
7827
|
mention: "inline"
|
|
7667
7828
|
};
|
|
7668
7829
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7669
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7830
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _175 => _175.content])) {
|
|
7670
7831
|
return;
|
|
7671
7832
|
}
|
|
7672
7833
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7676,13 +7837,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7676
7837
|
for (const block of body.content) {
|
|
7677
7838
|
if (type === "all" || type === "block") {
|
|
7678
7839
|
if (guard(block)) {
|
|
7679
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7840
|
+
_optionalChain([visitor, 'optionalCall', _176 => _176(block)]);
|
|
7680
7841
|
}
|
|
7681
7842
|
}
|
|
7682
7843
|
if (type === "all" || type === "inline") {
|
|
7683
7844
|
for (const inline of block.children) {
|
|
7684
7845
|
if (guard(inline)) {
|
|
7685
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7846
|
+
_optionalChain([visitor, 'optionalCall', _177 => _177(inline)]);
|
|
7686
7847
|
}
|
|
7687
7848
|
}
|
|
7688
7849
|
}
|
|
@@ -7707,7 +7868,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7707
7868
|
userIds
|
|
7708
7869
|
});
|
|
7709
7870
|
for (const [index, userId] of userIds.entries()) {
|
|
7710
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7871
|
+
const user = _optionalChain([users, 'optionalAccess', _178 => _178[index]]);
|
|
7711
7872
|
if (user) {
|
|
7712
7873
|
resolvedUsers.set(userId, user);
|
|
7713
7874
|
}
|
|
@@ -7830,7 +7991,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7830
7991
|
text: ({ element }) => element.text,
|
|
7831
7992
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7832
7993
|
mention: ({ element, user }) => {
|
|
7833
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7994
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _179 => _179.name]), () => ( element.id))}`;
|
|
7834
7995
|
}
|
|
7835
7996
|
};
|
|
7836
7997
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7860,7 +8021,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7860
8021
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7861
8022
|
},
|
|
7862
8023
|
mention: ({ element, user }) => {
|
|
7863
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8024
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _180 => _180.name]), () => ( element.id))}</span>`;
|
|
7864
8025
|
}
|
|
7865
8026
|
};
|
|
7866
8027
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7890,19 +8051,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7890
8051
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7891
8052
|
},
|
|
7892
8053
|
mention: ({ element, user }) => {
|
|
7893
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8054
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _181 => _181.name]), () => ( element.id))}`;
|
|
7894
8055
|
}
|
|
7895
8056
|
};
|
|
7896
8057
|
async function stringifyCommentBody(body, options) {
|
|
7897
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7898
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8058
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.format]), () => ( "plain"));
|
|
8059
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _183 => _183.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7899
8060
|
const elements = {
|
|
7900
8061
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7901
|
-
..._optionalChain([options, 'optionalAccess',
|
|
8062
|
+
..._optionalChain([options, 'optionalAccess', _184 => _184.elements])
|
|
7902
8063
|
};
|
|
7903
8064
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7904
8065
|
body,
|
|
7905
|
-
_optionalChain([options, 'optionalAccess',
|
|
8066
|
+
_optionalChain([options, 'optionalAccess', _185 => _185.resolveUsers])
|
|
7906
8067
|
);
|
|
7907
8068
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7908
8069
|
switch (block.type) {
|
|
@@ -8177,12 +8338,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8177
8338
|
}
|
|
8178
8339
|
const newState = Object.assign({}, state);
|
|
8179
8340
|
for (const key in update.updates) {
|
|
8180
|
-
if (_optionalChain([update, 'access',
|
|
8341
|
+
if (_optionalChain([update, 'access', _186 => _186.updates, 'access', _187 => _187[key], 'optionalAccess', _188 => _188.type]) === "update") {
|
|
8181
8342
|
const val = update.node.get(key);
|
|
8182
8343
|
if (val !== void 0) {
|
|
8183
8344
|
newState[key] = lsonToJson(val);
|
|
8184
8345
|
}
|
|
8185
|
-
} else if (_optionalChain([update, 'access',
|
|
8346
|
+
} else if (_optionalChain([update, 'access', _189 => _189.updates, 'access', _190 => _190[key], 'optionalAccess', _191 => _191.type]) === "delete") {
|
|
8186
8347
|
delete newState[key];
|
|
8187
8348
|
}
|
|
8188
8349
|
}
|
|
@@ -8243,12 +8404,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8243
8404
|
}
|
|
8244
8405
|
const newState = Object.assign({}, state);
|
|
8245
8406
|
for (const key in update.updates) {
|
|
8246
|
-
if (_optionalChain([update, 'access',
|
|
8407
|
+
if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "update") {
|
|
8247
8408
|
const value = update.node.get(key);
|
|
8248
8409
|
if (value !== void 0) {
|
|
8249
8410
|
newState[key] = lsonToJson(value);
|
|
8250
8411
|
}
|
|
8251
|
-
} else if (_optionalChain([update, 'access',
|
|
8412
|
+
} else if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "delete") {
|
|
8252
8413
|
delete newState[key];
|
|
8253
8414
|
}
|
|
8254
8415
|
}
|
|
@@ -8507,5 +8668,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8507
8668
|
|
|
8508
8669
|
|
|
8509
8670
|
|
|
8510
|
-
|
|
8671
|
+
|
|
8672
|
+
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.chunk = chunk; 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;
|
|
8511
8673
|
//# sourceMappingURL=index.js.map
|