@liveblocks/core 2.7.0-beta2 → 2.7.0-versions2
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 +42 -102
- package/dist/index.d.ts +42 -102
- package/dist/index.js +87 -206
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -176
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "2.7.0-
|
|
9
|
+
var PKG_VERSION = "2.7.0-versions2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1859,7 +1859,8 @@ var Batch = class {
|
|
|
1859
1859
|
this.clearDelayTimeout();
|
|
1860
1860
|
}
|
|
1861
1861
|
};
|
|
1862
|
-
function createBatchStore(
|
|
1862
|
+
function createBatchStore(callback, options) {
|
|
1863
|
+
const batch = new Batch(callback, options);
|
|
1863
1864
|
const cache = /* @__PURE__ */ new Map();
|
|
1864
1865
|
const eventSource2 = makeEventSource();
|
|
1865
1866
|
function getCacheKey(args) {
|
|
@@ -4748,19 +4749,9 @@ function findNonSerializableValue(value, path = "") {
|
|
|
4748
4749
|
return false;
|
|
4749
4750
|
}
|
|
4750
4751
|
|
|
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
|
-
|
|
4760
4752
|
// src/lib/createIds.ts
|
|
4761
4753
|
var THREAD_ID_PREFIX = "th";
|
|
4762
4754
|
var COMMENT_ID_PREFIX = "cm";
|
|
4763
|
-
var COMMENT_ATTACHMENT_ID_PREFIX = "at";
|
|
4764
4755
|
var INBOX_NOTIFICATION_ID_PREFIX = "in";
|
|
4765
4756
|
function createOptimisticId(prefix) {
|
|
4766
4757
|
return `${prefix}_${nanoid()}`;
|
|
@@ -4771,9 +4762,6 @@ function createThreadId() {
|
|
|
4771
4762
|
function createCommentId() {
|
|
4772
4763
|
return createOptimisticId(COMMENT_ID_PREFIX);
|
|
4773
4764
|
}
|
|
4774
|
-
function createCommentAttachmentId() {
|
|
4775
|
-
return createOptimisticId(COMMENT_ATTACHMENT_ID_PREFIX);
|
|
4776
|
-
}
|
|
4777
4765
|
function createInboxNotificationId() {
|
|
4778
4766
|
return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
|
|
4779
4767
|
}
|
|
@@ -5176,22 +5164,6 @@ function installBackgroundTabSpy() {
|
|
|
5176
5164
|
};
|
|
5177
5165
|
return [inBackgroundSince, unsub];
|
|
5178
5166
|
}
|
|
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
|
-
}
|
|
5195
5167
|
var CommentsApiError = class extends Error {
|
|
5196
5168
|
constructor(message, status, details) {
|
|
5197
5169
|
super(message);
|
|
@@ -5501,6 +5473,29 @@ function createRoom(options, config) {
|
|
|
5501
5473
|
})
|
|
5502
5474
|
});
|
|
5503
5475
|
}
|
|
5476
|
+
async function listTextVersions() {
|
|
5477
|
+
const authValue = await delegates.authenticate();
|
|
5478
|
+
return fetchClientApi(config.roomId, "/versions/", authValue, {
|
|
5479
|
+
method: "GET"
|
|
5480
|
+
});
|
|
5481
|
+
}
|
|
5482
|
+
async function getTextVersion(versionId) {
|
|
5483
|
+
const authValue = await delegates.authenticate();
|
|
5484
|
+
return fetchClientApi(
|
|
5485
|
+
config.roomId,
|
|
5486
|
+
`/y-version/${encodeURIComponent(versionId)}`,
|
|
5487
|
+
authValue,
|
|
5488
|
+
{
|
|
5489
|
+
method: "GET"
|
|
5490
|
+
}
|
|
5491
|
+
);
|
|
5492
|
+
}
|
|
5493
|
+
async function createTextVersion() {
|
|
5494
|
+
const authValue = await delegates.authenticate();
|
|
5495
|
+
return fetchClientApi(config.roomId, "/version", authValue, {
|
|
5496
|
+
method: "POST"
|
|
5497
|
+
});
|
|
5498
|
+
}
|
|
5504
5499
|
function sendMessages(messages) {
|
|
5505
5500
|
const serializedPayload = JSON.stringify(messages);
|
|
5506
5501
|
const nonce = _optionalChain([context, 'access', _125 => _125.dynamicSessionInfo, 'access', _126 => _126.current, 'optionalAccess', _127 => _127.nonce]);
|
|
@@ -6462,8 +6457,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6462
6457
|
metadata,
|
|
6463
6458
|
body,
|
|
6464
6459
|
commentId = createCommentId(),
|
|
6465
|
-
threadId = createThreadId()
|
|
6466
|
-
attachmentIds
|
|
6460
|
+
threadId = createThreadId()
|
|
6467
6461
|
}) {
|
|
6468
6462
|
const thread = await fetchCommentsJson("/threads", {
|
|
6469
6463
|
method: "POST",
|
|
@@ -6474,8 +6468,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6474
6468
|
id: threadId,
|
|
6475
6469
|
comment: {
|
|
6476
6470
|
id: commentId,
|
|
6477
|
-
body
|
|
6478
|
-
attachmentIds
|
|
6471
|
+
body
|
|
6479
6472
|
},
|
|
6480
6473
|
metadata
|
|
6481
6474
|
})
|
|
@@ -6521,8 +6514,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6521
6514
|
async function createComment({
|
|
6522
6515
|
threadId,
|
|
6523
6516
|
commentId = createCommentId(),
|
|
6524
|
-
body
|
|
6525
|
-
attachmentIds
|
|
6517
|
+
body
|
|
6526
6518
|
}) {
|
|
6527
6519
|
const comment = await fetchCommentsJson(
|
|
6528
6520
|
`/threads/${encodeURIComponent(threadId)}/comments`,
|
|
@@ -6533,8 +6525,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6533
6525
|
},
|
|
6534
6526
|
body: JSON.stringify({
|
|
6535
6527
|
id: commentId,
|
|
6536
|
-
body
|
|
6537
|
-
attachmentIds
|
|
6528
|
+
body
|
|
6538
6529
|
})
|
|
6539
6530
|
}
|
|
6540
6531
|
);
|
|
@@ -6543,8 +6534,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6543
6534
|
async function editComment({
|
|
6544
6535
|
threadId,
|
|
6545
6536
|
commentId,
|
|
6546
|
-
body
|
|
6547
|
-
attachmentIds
|
|
6537
|
+
body
|
|
6548
6538
|
}) {
|
|
6549
6539
|
const comment = await fetchCommentsJson(
|
|
6550
6540
|
`/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
|
|
@@ -6556,8 +6546,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6556
6546
|
"Content-Type": "application/json"
|
|
6557
6547
|
},
|
|
6558
6548
|
body: JSON.stringify({
|
|
6559
|
-
body
|
|
6560
|
-
attachmentIds
|
|
6549
|
+
body
|
|
6561
6550
|
})
|
|
6562
6551
|
}
|
|
6563
6552
|
);
|
|
@@ -6609,126 +6598,6 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6609
6598
|
}
|
|
6610
6599
|
);
|
|
6611
6600
|
}
|
|
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
|
-
}
|
|
6732
6601
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6733
6602
|
const authValue = await delegates.authenticate();
|
|
6734
6603
|
const response = await fetchClientApi(
|
|
@@ -6805,7 +6674,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6805
6674
|
{
|
|
6806
6675
|
[kInternal]: {
|
|
6807
6676
|
get presenceBuffer() {
|
|
6808
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6677
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _140 => _140.buffer, 'access', _141 => _141.presenceUpdates, 'optionalAccess', _142 => _142.data]), () => ( null)));
|
|
6809
6678
|
},
|
|
6810
6679
|
// prettier-ignore
|
|
6811
6680
|
get undoStack() {
|
|
@@ -6830,6 +6699,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6830
6699
|
createTextMention,
|
|
6831
6700
|
// delete a text mention when using a text editor
|
|
6832
6701
|
deleteTextMention,
|
|
6702
|
+
// list versions of the document
|
|
6703
|
+
listTextVersions,
|
|
6704
|
+
// get a specific version
|
|
6705
|
+
getTextVersion,
|
|
6706
|
+
// create a version
|
|
6707
|
+
createTextVersion,
|
|
6833
6708
|
// Support for the Liveblocks browser extension
|
|
6834
6709
|
getSelf_forDevTools: () => selfAsTreeNode.current,
|
|
6835
6710
|
getOthers_forDevTools: () => others_forDevTools.current,
|
|
@@ -6838,8 +6713,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6838
6713
|
// These exist only for our E2E testing app
|
|
6839
6714
|
explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
|
|
6840
6715
|
rawSend: (data) => managedSocket.send(data)
|
|
6841
|
-
}
|
|
6842
|
-
attachmentUrlsStore
|
|
6716
|
+
}
|
|
6843
6717
|
},
|
|
6844
6718
|
id: config.roomId,
|
|
6845
6719
|
subscribe: makeClassicSubscribeFn(events),
|
|
@@ -6894,9 +6768,6 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6894
6768
|
deleteComment: deleteComment2,
|
|
6895
6769
|
addReaction: addReaction2,
|
|
6896
6770
|
removeReaction: removeReaction2,
|
|
6897
|
-
prepareAttachment,
|
|
6898
|
-
uploadAttachment,
|
|
6899
|
-
getAttachmentUrl,
|
|
6900
6771
|
// Notifications
|
|
6901
6772
|
getNotificationSettings,
|
|
6902
6773
|
updateNotificationSettings,
|
|
@@ -6983,7 +6854,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
6983
6854
|
}
|
|
6984
6855
|
if (isLiveNode(first)) {
|
|
6985
6856
|
const node = first;
|
|
6986
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6857
|
+
if (_optionalChain([options, 'optionalAccess', _143 => _143.isDeep])) {
|
|
6987
6858
|
const storageCallback = second;
|
|
6988
6859
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
6989
6860
|
} else {
|
|
@@ -7036,7 +6907,8 @@ function createClientStore() {
|
|
|
7036
6907
|
queries: {},
|
|
7037
6908
|
optimisticUpdates: [],
|
|
7038
6909
|
inboxNotifications: {},
|
|
7039
|
-
notificationSettings: {}
|
|
6910
|
+
notificationSettings: {},
|
|
6911
|
+
versions: {}
|
|
7040
6912
|
});
|
|
7041
6913
|
const optimisticUpdatesEventSource = makeEventSource();
|
|
7042
6914
|
return {
|
|
@@ -7067,6 +6939,19 @@ function createClientStore() {
|
|
|
7067
6939
|
};
|
|
7068
6940
|
});
|
|
7069
6941
|
},
|
|
6942
|
+
updateRoomVersions(roomId, versions, queryKey) {
|
|
6943
|
+
store.set((state) => ({
|
|
6944
|
+
...state,
|
|
6945
|
+
versions: {
|
|
6946
|
+
...state.versions,
|
|
6947
|
+
[roomId]: versions
|
|
6948
|
+
},
|
|
6949
|
+
queries: queryKey !== void 0 ? {
|
|
6950
|
+
...state.queries,
|
|
6951
|
+
[queryKey]: { isLoading: false, data: void 0 }
|
|
6952
|
+
} : state.queries
|
|
6953
|
+
}));
|
|
6954
|
+
},
|
|
7070
6955
|
updateThreadsAndNotifications(threads, inboxNotifications, deletedThreads, deletedInboxNotifications, queryKey) {
|
|
7071
6956
|
store.set((state) => ({
|
|
7072
6957
|
...state,
|
|
@@ -7393,7 +7278,7 @@ function upsertComment(thread, comment) {
|
|
|
7393
7278
|
);
|
|
7394
7279
|
if (existingComment === void 0) {
|
|
7395
7280
|
const updatedAt = new Date(
|
|
7396
|
-
Math.max(_optionalChain([thread, 'access',
|
|
7281
|
+
Math.max(_optionalChain([thread, 'access', _144 => _144.updatedAt, 'optionalAccess', _145 => _145.getTime, 'call', _146 => _146()]) || 0, comment.createdAt.getTime())
|
|
7397
7282
|
);
|
|
7398
7283
|
const updatedThread = {
|
|
7399
7284
|
...thread,
|
|
@@ -7413,8 +7298,8 @@ function upsertComment(thread, comment) {
|
|
|
7413
7298
|
...thread,
|
|
7414
7299
|
updatedAt: new Date(
|
|
7415
7300
|
Math.max(
|
|
7416
|
-
_optionalChain([thread, 'access',
|
|
7417
|
-
_optionalChain([comment, 'access',
|
|
7301
|
+
_optionalChain([thread, 'access', _147 => _147.updatedAt, 'optionalAccess', _148 => _148.getTime, 'call', _149 => _149()]) || 0,
|
|
7302
|
+
_optionalChain([comment, 'access', _150 => _150.editedAt, 'optionalAccess', _151 => _151.getTime, 'call', _152 => _152()]) || comment.createdAt.getTime()
|
|
7418
7303
|
)
|
|
7419
7304
|
),
|
|
7420
7305
|
comments: updatedComments
|
|
@@ -7440,8 +7325,7 @@ function deleteComment(thread, commentId, deletedAt) {
|
|
|
7440
7325
|
(comment) => comment.id === commentId ? {
|
|
7441
7326
|
...comment,
|
|
7442
7327
|
deletedAt,
|
|
7443
|
-
body: void 0
|
|
7444
|
-
attachments: []
|
|
7328
|
+
body: void 0
|
|
7445
7329
|
} : comment
|
|
7446
7330
|
);
|
|
7447
7331
|
if (!updatedComments.some((comment) => comment.deletedAt === void 0)) {
|
|
@@ -7480,7 +7364,7 @@ function addReaction(thread, commentId, reaction) {
|
|
|
7480
7364
|
return {
|
|
7481
7365
|
...thread,
|
|
7482
7366
|
updatedAt: new Date(
|
|
7483
|
-
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access',
|
|
7367
|
+
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _153 => _153.updatedAt, 'optionalAccess', _154 => _154.getTime, 'call', _155 => _155()]) || 0)
|
|
7484
7368
|
),
|
|
7485
7369
|
comments: updatedComments
|
|
7486
7370
|
};
|
|
@@ -7513,7 +7397,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
|
|
|
7513
7397
|
return {
|
|
7514
7398
|
...thread,
|
|
7515
7399
|
updatedAt: new Date(
|
|
7516
|
-
Math.max(removedAt.getTime(), _optionalChain([thread, 'access',
|
|
7400
|
+
Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _156 => _156.updatedAt, 'optionalAccess', _157 => _157.getTime, 'call', _158 => _158()]) || 0)
|
|
7517
7401
|
),
|
|
7518
7402
|
comments: updatedComments
|
|
7519
7403
|
};
|
|
@@ -7624,12 +7508,12 @@ function createClient(options) {
|
|
|
7624
7508
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7625
7509
|
roomId,
|
|
7626
7510
|
baseUrl,
|
|
7627
|
-
_optionalChain([clientOptions, 'access',
|
|
7511
|
+
_optionalChain([clientOptions, 'access', _159 => _159.polyfills, 'optionalAccess', _160 => _160.WebSocket])
|
|
7628
7512
|
),
|
|
7629
7513
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7630
7514
|
})),
|
|
7631
7515
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7632
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7516
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _161 => _161.unstable_batchedUpdates]),
|
|
7633
7517
|
baseUrl,
|
|
7634
7518
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7635
7519
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7645,7 +7529,7 @@ function createClient(options) {
|
|
|
7645
7529
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7646
7530
|
if (shouldConnect) {
|
|
7647
7531
|
if (typeof atob === "undefined") {
|
|
7648
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7532
|
+
if (_optionalChain([clientOptions, 'access', _162 => _162.polyfills, 'optionalAccess', _163 => _163.atob]) === void 0) {
|
|
7649
7533
|
throw new Error(
|
|
7650
7534
|
"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"
|
|
7651
7535
|
);
|
|
@@ -7657,7 +7541,7 @@ function createClient(options) {
|
|
|
7657
7541
|
return leaseRoom(newRoomDetails);
|
|
7658
7542
|
}
|
|
7659
7543
|
function getRoom(roomId) {
|
|
7660
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7544
|
+
const room = _optionalChain([roomsById, 'access', _164 => _164.get, 'call', _165 => _165(roomId), 'optionalAccess', _166 => _166.room]);
|
|
7661
7545
|
return room ? room : null;
|
|
7662
7546
|
}
|
|
7663
7547
|
function logout() {
|
|
@@ -7681,7 +7565,7 @@ function createClient(options) {
|
|
|
7681
7565
|
getThreadsSince
|
|
7682
7566
|
} = createNotificationsApi({
|
|
7683
7567
|
baseUrl,
|
|
7684
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7568
|
+
fetcher: _optionalChain([clientOptions, 'access', _167 => _167.polyfills, 'optionalAccess', _168 => _168.fetch]) || /* istanbul ignore next */
|
|
7685
7569
|
fetch,
|
|
7686
7570
|
authManager,
|
|
7687
7571
|
currentUserIdStore
|
|
@@ -7692,31 +7576,29 @@ function createClient(options) {
|
|
|
7692
7576
|
() => !resolveUsers,
|
|
7693
7577
|
"Set the resolveUsers option in createClient to specify user info."
|
|
7694
7578
|
);
|
|
7695
|
-
const
|
|
7579
|
+
const usersStore = createBatchStore(
|
|
7696
7580
|
async (batchedUserIds) => {
|
|
7697
7581
|
const userIds = batchedUserIds.flat();
|
|
7698
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7582
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _169 => _169({ userIds })]);
|
|
7699
7583
|
warnIfNoResolveUsers();
|
|
7700
7584
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7701
7585
|
},
|
|
7702
7586
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
7703
7587
|
);
|
|
7704
|
-
const usersStore = createBatchStore(batchedResolveUsers);
|
|
7705
7588
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
7706
7589
|
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
7707
7590
|
() => !resolveRoomsInfo,
|
|
7708
7591
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
7709
7592
|
);
|
|
7710
|
-
const
|
|
7593
|
+
const roomsInfoStore = createBatchStore(
|
|
7711
7594
|
async (batchedRoomIds) => {
|
|
7712
7595
|
const roomIds = batchedRoomIds.flat();
|
|
7713
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7596
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _170 => _170({ roomIds })]);
|
|
7714
7597
|
warnIfNoResolveRoomsInfo();
|
|
7715
7598
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7716
7599
|
},
|
|
7717
7600
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
7718
7601
|
);
|
|
7719
|
-
const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
|
|
7720
7602
|
return Object.defineProperty(
|
|
7721
7603
|
{
|
|
7722
7604
|
enterRoom,
|
|
@@ -7827,7 +7709,7 @@ var commentBodyElementsTypes = {
|
|
|
7827
7709
|
mention: "inline"
|
|
7828
7710
|
};
|
|
7829
7711
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7830
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7712
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _171 => _171.content])) {
|
|
7831
7713
|
return;
|
|
7832
7714
|
}
|
|
7833
7715
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7837,13 +7719,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7837
7719
|
for (const block of body.content) {
|
|
7838
7720
|
if (type === "all" || type === "block") {
|
|
7839
7721
|
if (guard(block)) {
|
|
7840
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7722
|
+
_optionalChain([visitor, 'optionalCall', _172 => _172(block)]);
|
|
7841
7723
|
}
|
|
7842
7724
|
}
|
|
7843
7725
|
if (type === "all" || type === "inline") {
|
|
7844
7726
|
for (const inline of block.children) {
|
|
7845
7727
|
if (guard(inline)) {
|
|
7846
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7728
|
+
_optionalChain([visitor, 'optionalCall', _173 => _173(inline)]);
|
|
7847
7729
|
}
|
|
7848
7730
|
}
|
|
7849
7731
|
}
|
|
@@ -7868,7 +7750,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7868
7750
|
userIds
|
|
7869
7751
|
});
|
|
7870
7752
|
for (const [index, userId] of userIds.entries()) {
|
|
7871
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7753
|
+
const user = _optionalChain([users, 'optionalAccess', _174 => _174[index]]);
|
|
7872
7754
|
if (user) {
|
|
7873
7755
|
resolvedUsers.set(userId, user);
|
|
7874
7756
|
}
|
|
@@ -7991,7 +7873,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7991
7873
|
text: ({ element }) => element.text,
|
|
7992
7874
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7993
7875
|
mention: ({ element, user }) => {
|
|
7994
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7876
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _175 => _175.name]), () => ( element.id))}`;
|
|
7995
7877
|
}
|
|
7996
7878
|
};
|
|
7997
7879
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -8021,7 +7903,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8021
7903
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
8022
7904
|
},
|
|
8023
7905
|
mention: ({ element, user }) => {
|
|
8024
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7906
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _176 => _176.name]), () => ( element.id))}</span>`;
|
|
8025
7907
|
}
|
|
8026
7908
|
};
|
|
8027
7909
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -8051,19 +7933,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
8051
7933
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
8052
7934
|
},
|
|
8053
7935
|
mention: ({ element, user }) => {
|
|
8054
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7936
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _177 => _177.name]), () => ( element.id))}`;
|
|
8055
7937
|
}
|
|
8056
7938
|
};
|
|
8057
7939
|
async function stringifyCommentBody(body, options) {
|
|
8058
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
8059
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7940
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.format]), () => ( "plain"));
|
|
7941
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _179 => _179.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
8060
7942
|
const elements = {
|
|
8061
7943
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
8062
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7944
|
+
..._optionalChain([options, 'optionalAccess', _180 => _180.elements])
|
|
8063
7945
|
};
|
|
8064
7946
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
8065
7947
|
body,
|
|
8066
|
-
_optionalChain([options, 'optionalAccess',
|
|
7948
|
+
_optionalChain([options, 'optionalAccess', _181 => _181.resolveUsers])
|
|
8067
7949
|
);
|
|
8068
7950
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
8069
7951
|
switch (block.type) {
|
|
@@ -8338,12 +8220,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8338
8220
|
}
|
|
8339
8221
|
const newState = Object.assign({}, state);
|
|
8340
8222
|
for (const key in update.updates) {
|
|
8341
|
-
if (_optionalChain([update, 'access',
|
|
8223
|
+
if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
|
|
8342
8224
|
const val = update.node.get(key);
|
|
8343
8225
|
if (val !== void 0) {
|
|
8344
8226
|
newState[key] = lsonToJson(val);
|
|
8345
8227
|
}
|
|
8346
|
-
} else if (_optionalChain([update, 'access',
|
|
8228
|
+
} else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
|
|
8347
8229
|
delete newState[key];
|
|
8348
8230
|
}
|
|
8349
8231
|
}
|
|
@@ -8404,12 +8286,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8404
8286
|
}
|
|
8405
8287
|
const newState = Object.assign({}, state);
|
|
8406
8288
|
for (const key in update.updates) {
|
|
8407
|
-
if (_optionalChain([update, 'access',
|
|
8289
|
+
if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
|
|
8408
8290
|
const value = update.node.get(key);
|
|
8409
8291
|
if (value !== void 0) {
|
|
8410
8292
|
newState[key] = lsonToJson(value);
|
|
8411
8293
|
}
|
|
8412
|
-
} else if (_optionalChain([update, 'access',
|
|
8294
|
+
} else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
|
|
8413
8295
|
delete newState[key];
|
|
8414
8296
|
}
|
|
8415
8297
|
}
|
|
@@ -8668,6 +8550,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8668
8550
|
|
|
8669
8551
|
|
|
8670
8552
|
|
|
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;
|
|
8553
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createThreadId = createThreadId; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
8673
8554
|
//# sourceMappingURL=index.js.map
|