@liveblocks/core 2.5.2 → 2.7.0-beta1
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 +203 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -12
- 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-beta1";
|
|
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
|
|
@@ -7321,7 +7479,7 @@ function addReaction(thread, commentId, reaction) {
|
|
|
7321
7479
|
return {
|
|
7322
7480
|
...thread,
|
|
7323
7481
|
updatedAt: new Date(
|
|
7324
|
-
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access',
|
|
7482
|
+
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _157 => _157.updatedAt, 'optionalAccess', _158 => _158.getTime, 'call', _159 => _159()]) || 0)
|
|
7325
7483
|
),
|
|
7326
7484
|
comments: updatedComments
|
|
7327
7485
|
};
|
|
@@ -7354,7 +7512,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
|
|
|
7354
7512
|
return {
|
|
7355
7513
|
...thread,
|
|
7356
7514
|
updatedAt: new Date(
|
|
7357
|
-
Math.max(removedAt.getTime(), _optionalChain([thread, 'access',
|
|
7515
|
+
Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _160 => _160.updatedAt, 'optionalAccess', _161 => _161.getTime, 'call', _162 => _162()]) || 0)
|
|
7358
7516
|
),
|
|
7359
7517
|
comments: updatedComments
|
|
7360
7518
|
};
|
|
@@ -7465,12 +7623,12 @@ function createClient(options) {
|
|
|
7465
7623
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7466
7624
|
roomId,
|
|
7467
7625
|
baseUrl,
|
|
7468
|
-
_optionalChain([clientOptions, 'access',
|
|
7626
|
+
_optionalChain([clientOptions, 'access', _163 => _163.polyfills, 'optionalAccess', _164 => _164.WebSocket])
|
|
7469
7627
|
),
|
|
7470
7628
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7471
7629
|
})),
|
|
7472
7630
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7473
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7631
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _165 => _165.unstable_batchedUpdates]),
|
|
7474
7632
|
baseUrl,
|
|
7475
7633
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7476
7634
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7486,7 +7644,7 @@ function createClient(options) {
|
|
|
7486
7644
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7487
7645
|
if (shouldConnect) {
|
|
7488
7646
|
if (typeof atob === "undefined") {
|
|
7489
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7647
|
+
if (_optionalChain([clientOptions, 'access', _166 => _166.polyfills, 'optionalAccess', _167 => _167.atob]) === void 0) {
|
|
7490
7648
|
throw new Error(
|
|
7491
7649
|
"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
7650
|
);
|
|
@@ -7498,7 +7656,7 @@ function createClient(options) {
|
|
|
7498
7656
|
return leaseRoom(newRoomDetails);
|
|
7499
7657
|
}
|
|
7500
7658
|
function getRoom(roomId) {
|
|
7501
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7659
|
+
const room = _optionalChain([roomsById, 'access', _168 => _168.get, 'call', _169 => _169(roomId), 'optionalAccess', _170 => _170.room]);
|
|
7502
7660
|
return room ? room : null;
|
|
7503
7661
|
}
|
|
7504
7662
|
function logout() {
|
|
@@ -7522,7 +7680,7 @@ function createClient(options) {
|
|
|
7522
7680
|
getThreadsSince
|
|
7523
7681
|
} = createNotificationsApi({
|
|
7524
7682
|
baseUrl,
|
|
7525
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7683
|
+
fetcher: _optionalChain([clientOptions, 'access', _171 => _171.polyfills, 'optionalAccess', _172 => _172.fetch]) || /* istanbul ignore next */
|
|
7526
7684
|
fetch,
|
|
7527
7685
|
authManager,
|
|
7528
7686
|
currentUserIdStore
|
|
@@ -7533,29 +7691,31 @@ function createClient(options) {
|
|
|
7533
7691
|
() => !resolveUsers,
|
|
7534
7692
|
"Set the resolveUsers option in createClient to specify user info."
|
|
7535
7693
|
);
|
|
7536
|
-
const
|
|
7694
|
+
const batchedResolveUsers = new Batch(
|
|
7537
7695
|
async (batchedUserIds) => {
|
|
7538
7696
|
const userIds = batchedUserIds.flat();
|
|
7539
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7697
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _173 => _173({ userIds })]);
|
|
7540
7698
|
warnIfNoResolveUsers();
|
|
7541
7699
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7542
7700
|
},
|
|
7543
7701
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
7544
7702
|
);
|
|
7703
|
+
const usersStore = createBatchStore(batchedResolveUsers);
|
|
7545
7704
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
7546
7705
|
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
7547
7706
|
() => !resolveRoomsInfo,
|
|
7548
7707
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
7549
7708
|
);
|
|
7550
|
-
const
|
|
7709
|
+
const batchedResolveRoomsInfo = new Batch(
|
|
7551
7710
|
async (batchedRoomIds) => {
|
|
7552
7711
|
const roomIds = batchedRoomIds.flat();
|
|
7553
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7712
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _174 => _174({ roomIds })]);
|
|
7554
7713
|
warnIfNoResolveRoomsInfo();
|
|
7555
7714
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7556
7715
|
},
|
|
7557
7716
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
7558
7717
|
);
|
|
7718
|
+
const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
|
|
7559
7719
|
return Object.defineProperty(
|
|
7560
7720
|
{
|
|
7561
7721
|
enterRoom,
|
|
@@ -7666,7 +7826,7 @@ var commentBodyElementsTypes = {
|
|
|
7666
7826
|
mention: "inline"
|
|
7667
7827
|
};
|
|
7668
7828
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7669
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7829
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _175 => _175.content])) {
|
|
7670
7830
|
return;
|
|
7671
7831
|
}
|
|
7672
7832
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7676,13 +7836,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7676
7836
|
for (const block of body.content) {
|
|
7677
7837
|
if (type === "all" || type === "block") {
|
|
7678
7838
|
if (guard(block)) {
|
|
7679
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7839
|
+
_optionalChain([visitor, 'optionalCall', _176 => _176(block)]);
|
|
7680
7840
|
}
|
|
7681
7841
|
}
|
|
7682
7842
|
if (type === "all" || type === "inline") {
|
|
7683
7843
|
for (const inline of block.children) {
|
|
7684
7844
|
if (guard(inline)) {
|
|
7685
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7845
|
+
_optionalChain([visitor, 'optionalCall', _177 => _177(inline)]);
|
|
7686
7846
|
}
|
|
7687
7847
|
}
|
|
7688
7848
|
}
|
|
@@ -7707,7 +7867,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7707
7867
|
userIds
|
|
7708
7868
|
});
|
|
7709
7869
|
for (const [index, userId] of userIds.entries()) {
|
|
7710
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7870
|
+
const user = _optionalChain([users, 'optionalAccess', _178 => _178[index]]);
|
|
7711
7871
|
if (user) {
|
|
7712
7872
|
resolvedUsers.set(userId, user);
|
|
7713
7873
|
}
|
|
@@ -7830,7 +7990,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7830
7990
|
text: ({ element }) => element.text,
|
|
7831
7991
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7832
7992
|
mention: ({ element, user }) => {
|
|
7833
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7993
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _179 => _179.name]), () => ( element.id))}`;
|
|
7834
7994
|
}
|
|
7835
7995
|
};
|
|
7836
7996
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7860,7 +8020,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7860
8020
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7861
8021
|
},
|
|
7862
8022
|
mention: ({ element, user }) => {
|
|
7863
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8023
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _180 => _180.name]), () => ( element.id))}</span>`;
|
|
7864
8024
|
}
|
|
7865
8025
|
};
|
|
7866
8026
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7890,19 +8050,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7890
8050
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7891
8051
|
},
|
|
7892
8052
|
mention: ({ element, user }) => {
|
|
7893
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
8053
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _181 => _181.name]), () => ( element.id))}`;
|
|
7894
8054
|
}
|
|
7895
8055
|
};
|
|
7896
8056
|
async function stringifyCommentBody(body, options) {
|
|
7897
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7898
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8057
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _182 => _182.format]), () => ( "plain"));
|
|
8058
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _183 => _183.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7899
8059
|
const elements = {
|
|
7900
8060
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7901
|
-
..._optionalChain([options, 'optionalAccess',
|
|
8061
|
+
..._optionalChain([options, 'optionalAccess', _184 => _184.elements])
|
|
7902
8062
|
};
|
|
7903
8063
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7904
8064
|
body,
|
|
7905
|
-
_optionalChain([options, 'optionalAccess',
|
|
8065
|
+
_optionalChain([options, 'optionalAccess', _185 => _185.resolveUsers])
|
|
7906
8066
|
);
|
|
7907
8067
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7908
8068
|
switch (block.type) {
|
|
@@ -8177,12 +8337,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8177
8337
|
}
|
|
8178
8338
|
const newState = Object.assign({}, state);
|
|
8179
8339
|
for (const key in update.updates) {
|
|
8180
|
-
if (_optionalChain([update, 'access',
|
|
8340
|
+
if (_optionalChain([update, 'access', _186 => _186.updates, 'access', _187 => _187[key], 'optionalAccess', _188 => _188.type]) === "update") {
|
|
8181
8341
|
const val = update.node.get(key);
|
|
8182
8342
|
if (val !== void 0) {
|
|
8183
8343
|
newState[key] = lsonToJson(val);
|
|
8184
8344
|
}
|
|
8185
|
-
} else if (_optionalChain([update, 'access',
|
|
8345
|
+
} else if (_optionalChain([update, 'access', _189 => _189.updates, 'access', _190 => _190[key], 'optionalAccess', _191 => _191.type]) === "delete") {
|
|
8186
8346
|
delete newState[key];
|
|
8187
8347
|
}
|
|
8188
8348
|
}
|
|
@@ -8243,12 +8403,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8243
8403
|
}
|
|
8244
8404
|
const newState = Object.assign({}, state);
|
|
8245
8405
|
for (const key in update.updates) {
|
|
8246
|
-
if (_optionalChain([update, 'access',
|
|
8406
|
+
if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "update") {
|
|
8247
8407
|
const value = update.node.get(key);
|
|
8248
8408
|
if (value !== void 0) {
|
|
8249
8409
|
newState[key] = lsonToJson(value);
|
|
8250
8410
|
}
|
|
8251
|
-
} else if (_optionalChain([update, 'access',
|
|
8411
|
+
} else if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "delete") {
|
|
8252
8412
|
delete newState[key];
|
|
8253
8413
|
}
|
|
8254
8414
|
}
|
|
@@ -8507,5 +8667,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8507
8667
|
|
|
8508
8668
|
|
|
8509
8669
|
|
|
8510
|
-
|
|
8670
|
+
|
|
8671
|
+
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
8672
|
//# sourceMappingURL=index.js.map
|