@liveblocks/core 2.7.0 → 2.8.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 +111 -25
- package/dist/index.d.ts +111 -25
- package/dist/index.js +200 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -14
- 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.8.0-beta1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1871,8 +1871,7 @@ var Batch = class {
|
|
|
1871
1871
|
this.clearDelayTimeout();
|
|
1872
1872
|
}
|
|
1873
1873
|
};
|
|
1874
|
-
function createBatchStore(
|
|
1875
|
-
const batch = new Batch(callback, options);
|
|
1874
|
+
function createBatchStore(batch) {
|
|
1876
1875
|
const cache = /* @__PURE__ */ new Map();
|
|
1877
1876
|
const eventSource2 = makeEventSource();
|
|
1878
1877
|
function getCacheKey(args) {
|
|
@@ -1952,7 +1951,6 @@ function createStore(initialState) {
|
|
|
1952
1951
|
}
|
|
1953
1952
|
function subscribe(callback) {
|
|
1954
1953
|
subscribers.add(callback);
|
|
1955
|
-
callback(state);
|
|
1956
1954
|
return () => {
|
|
1957
1955
|
subscribers.delete(callback);
|
|
1958
1956
|
};
|
|
@@ -4797,9 +4795,19 @@ function findNonSerializableValue(value, path = "") {
|
|
|
4797
4795
|
return false;
|
|
4798
4796
|
}
|
|
4799
4797
|
|
|
4798
|
+
// src/lib/chunk.ts
|
|
4799
|
+
function chunk(array, size) {
|
|
4800
|
+
const chunks = [];
|
|
4801
|
+
for (let i = 0, j = array.length; i < j; i += size) {
|
|
4802
|
+
chunks.push(array.slice(i, i + size));
|
|
4803
|
+
}
|
|
4804
|
+
return chunks;
|
|
4805
|
+
}
|
|
4806
|
+
|
|
4800
4807
|
// src/lib/createIds.ts
|
|
4801
4808
|
var THREAD_ID_PREFIX = "th";
|
|
4802
4809
|
var COMMENT_ID_PREFIX = "cm";
|
|
4810
|
+
var COMMENT_ATTACHMENT_ID_PREFIX = "at";
|
|
4803
4811
|
var INBOX_NOTIFICATION_ID_PREFIX = "in";
|
|
4804
4812
|
function createOptimisticId(prefix) {
|
|
4805
4813
|
return `${prefix}_${nanoid()}`;
|
|
@@ -4810,6 +4818,9 @@ function createThreadId() {
|
|
|
4810
4818
|
function createCommentId() {
|
|
4811
4819
|
return createOptimisticId(COMMENT_ID_PREFIX);
|
|
4812
4820
|
}
|
|
4821
|
+
function createCommentAttachmentId() {
|
|
4822
|
+
return createOptimisticId(COMMENT_ATTACHMENT_ID_PREFIX);
|
|
4823
|
+
}
|
|
4813
4824
|
function createInboxNotificationId() {
|
|
4814
4825
|
return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
|
|
4815
4826
|
}
|
|
@@ -5212,6 +5223,22 @@ function installBackgroundTabSpy() {
|
|
|
5212
5223
|
};
|
|
5213
5224
|
return [inBackgroundSince, unsub];
|
|
5214
5225
|
}
|
|
5226
|
+
var GET_ATTACHMENT_URLS_BATCH_DELAY = 50;
|
|
5227
|
+
var ATTACHMENT_PART_SIZE = 5 * 1024 * 1024;
|
|
5228
|
+
var ATTACHMENT_PART_BATCH_SIZE = 5;
|
|
5229
|
+
function splitFileIntoParts(file) {
|
|
5230
|
+
const parts = [];
|
|
5231
|
+
let start = 0;
|
|
5232
|
+
while (start < file.size) {
|
|
5233
|
+
const end = Math.min(start + ATTACHMENT_PART_SIZE, file.size);
|
|
5234
|
+
parts.push({
|
|
5235
|
+
partNumber: parts.length + 1,
|
|
5236
|
+
part: file.slice(start, end)
|
|
5237
|
+
});
|
|
5238
|
+
start = end;
|
|
5239
|
+
}
|
|
5240
|
+
return parts;
|
|
5241
|
+
}
|
|
5215
5242
|
var CommentsApiError = class extends Error {
|
|
5216
5243
|
constructor(message, status, details) {
|
|
5217
5244
|
super(message);
|
|
@@ -6505,7 +6532,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6505
6532
|
metadata,
|
|
6506
6533
|
body,
|
|
6507
6534
|
commentId = createCommentId(),
|
|
6508
|
-
threadId = createThreadId()
|
|
6535
|
+
threadId = createThreadId(),
|
|
6536
|
+
attachmentIds
|
|
6509
6537
|
}) {
|
|
6510
6538
|
const thread = await fetchCommentsJson("/threads", {
|
|
6511
6539
|
method: "POST",
|
|
@@ -6516,7 +6544,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6516
6544
|
id: threadId,
|
|
6517
6545
|
comment: {
|
|
6518
6546
|
id: commentId,
|
|
6519
|
-
body
|
|
6547
|
+
body,
|
|
6548
|
+
attachmentIds
|
|
6520
6549
|
},
|
|
6521
6550
|
metadata
|
|
6522
6551
|
})
|
|
@@ -6562,7 +6591,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6562
6591
|
async function createComment({
|
|
6563
6592
|
threadId,
|
|
6564
6593
|
commentId = createCommentId(),
|
|
6565
|
-
body
|
|
6594
|
+
body,
|
|
6595
|
+
attachmentIds
|
|
6566
6596
|
}) {
|
|
6567
6597
|
const comment = await fetchCommentsJson(
|
|
6568
6598
|
`/threads/${encodeURIComponent(threadId)}/comments`,
|
|
@@ -6573,7 +6603,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6573
6603
|
},
|
|
6574
6604
|
body: JSON.stringify({
|
|
6575
6605
|
id: commentId,
|
|
6576
|
-
body
|
|
6606
|
+
body,
|
|
6607
|
+
attachmentIds
|
|
6577
6608
|
})
|
|
6578
6609
|
}
|
|
6579
6610
|
);
|
|
@@ -6582,7 +6613,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6582
6613
|
async function editComment({
|
|
6583
6614
|
threadId,
|
|
6584
6615
|
commentId,
|
|
6585
|
-
body
|
|
6616
|
+
body,
|
|
6617
|
+
attachmentIds
|
|
6586
6618
|
}) {
|
|
6587
6619
|
const comment = await fetchCommentsJson(
|
|
6588
6620
|
`/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
|
|
@@ -6594,7 +6626,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6594
6626
|
"Content-Type": "application/json"
|
|
6595
6627
|
},
|
|
6596
6628
|
body: JSON.stringify({
|
|
6597
|
-
body
|
|
6629
|
+
body,
|
|
6630
|
+
attachmentIds
|
|
6598
6631
|
})
|
|
6599
6632
|
}
|
|
6600
6633
|
);
|
|
@@ -6646,6 +6679,126 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6646
6679
|
}
|
|
6647
6680
|
);
|
|
6648
6681
|
}
|
|
6682
|
+
function prepareAttachment(file) {
|
|
6683
|
+
return {
|
|
6684
|
+
type: "localAttachment",
|
|
6685
|
+
status: "idle",
|
|
6686
|
+
id: createCommentAttachmentId(),
|
|
6687
|
+
name: file.name,
|
|
6688
|
+
size: file.size,
|
|
6689
|
+
mimeType: file.type,
|
|
6690
|
+
file
|
|
6691
|
+
};
|
|
6692
|
+
}
|
|
6693
|
+
async function uploadAttachment(attachment, options2 = {}) {
|
|
6694
|
+
const abortSignal = options2.signal;
|
|
6695
|
+
const abortError = abortSignal ? new DOMException(
|
|
6696
|
+
`Upload of attachment ${attachment.id} was aborted.`,
|
|
6697
|
+
"AbortError"
|
|
6698
|
+
) : void 0;
|
|
6699
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _142 => _142.aborted])) {
|
|
6700
|
+
throw abortError;
|
|
6701
|
+
}
|
|
6702
|
+
if (attachment.size <= ATTACHMENT_PART_SIZE) {
|
|
6703
|
+
return fetchCommentsJson(
|
|
6704
|
+
`/attachments/${encodeURIComponent(attachment.id)}/upload/${encodeURIComponent(attachment.name)}`,
|
|
6705
|
+
{
|
|
6706
|
+
method: "PUT",
|
|
6707
|
+
body: attachment.file,
|
|
6708
|
+
signal: abortSignal
|
|
6709
|
+
}
|
|
6710
|
+
);
|
|
6711
|
+
} else {
|
|
6712
|
+
let uploadId;
|
|
6713
|
+
const uploadedParts = [];
|
|
6714
|
+
try {
|
|
6715
|
+
const createMultiPartUpload = await fetchCommentsJson(
|
|
6716
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
6717
|
+
{
|
|
6718
|
+
method: "POST",
|
|
6719
|
+
signal: abortSignal
|
|
6720
|
+
}
|
|
6721
|
+
);
|
|
6722
|
+
uploadId = createMultiPartUpload.uploadId;
|
|
6723
|
+
const parts = splitFileIntoParts(attachment.file);
|
|
6724
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _143 => _143.aborted])) {
|
|
6725
|
+
throw abortError;
|
|
6726
|
+
}
|
|
6727
|
+
const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
|
|
6728
|
+
for (const parts2 of batches) {
|
|
6729
|
+
const uploadedPartsPromises = [];
|
|
6730
|
+
for (const { part, partNumber } of parts2) {
|
|
6731
|
+
uploadedPartsPromises.push(
|
|
6732
|
+
fetchCommentsJson(
|
|
6733
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}/${encodeURIComponent(partNumber)}`,
|
|
6734
|
+
{
|
|
6735
|
+
method: "PUT",
|
|
6736
|
+
body: part,
|
|
6737
|
+
signal: abortSignal
|
|
6738
|
+
}
|
|
6739
|
+
)
|
|
6740
|
+
);
|
|
6741
|
+
}
|
|
6742
|
+
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
6743
|
+
}
|
|
6744
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.aborted])) {
|
|
6745
|
+
throw abortError;
|
|
6746
|
+
}
|
|
6747
|
+
const sortedUploadedParts = uploadedParts.sort(
|
|
6748
|
+
(a, b) => a.partNumber - b.partNumber
|
|
6749
|
+
);
|
|
6750
|
+
return fetchCommentsJson(
|
|
6751
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}/complete`,
|
|
6752
|
+
{
|
|
6753
|
+
method: "POST",
|
|
6754
|
+
headers: {
|
|
6755
|
+
"Content-Type": "application/json"
|
|
6756
|
+
},
|
|
6757
|
+
body: JSON.stringify({ parts: sortedUploadedParts }),
|
|
6758
|
+
signal: abortSignal
|
|
6759
|
+
}
|
|
6760
|
+
);
|
|
6761
|
+
} catch (error3) {
|
|
6762
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _145 => _145.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
6763
|
+
await fetchCommentsApi(
|
|
6764
|
+
`/attachments/${encodeURIComponent(attachment.id)}/multipart/${encodeURIComponent(uploadId)}`,
|
|
6765
|
+
void 0,
|
|
6766
|
+
{
|
|
6767
|
+
method: "DELETE"
|
|
6768
|
+
}
|
|
6769
|
+
);
|
|
6770
|
+
}
|
|
6771
|
+
throw error3;
|
|
6772
|
+
}
|
|
6773
|
+
}
|
|
6774
|
+
}
|
|
6775
|
+
async function getAttachmentUrls(attachmentIds) {
|
|
6776
|
+
const { urls } = await fetchCommentsJson(
|
|
6777
|
+
"/attachments/presigned-urls",
|
|
6778
|
+
{
|
|
6779
|
+
method: "POST",
|
|
6780
|
+
headers: {
|
|
6781
|
+
"Content-Type": "application/json"
|
|
6782
|
+
},
|
|
6783
|
+
body: JSON.stringify({ attachmentIds })
|
|
6784
|
+
}
|
|
6785
|
+
);
|
|
6786
|
+
return urls;
|
|
6787
|
+
}
|
|
6788
|
+
const batchedGetAttachmentUrls = new Batch(
|
|
6789
|
+
async (batchedAttachmentIds) => {
|
|
6790
|
+
const attachmentIds = batchedAttachmentIds.flat();
|
|
6791
|
+
const attachmentUrls = await getAttachmentUrls(attachmentIds);
|
|
6792
|
+
return attachmentUrls.map(
|
|
6793
|
+
(url) => _nullishCoalesce(url, () => ( new Error("There was an error while getting this attachment's URL")))
|
|
6794
|
+
);
|
|
6795
|
+
},
|
|
6796
|
+
{ delay: GET_ATTACHMENT_URLS_BATCH_DELAY }
|
|
6797
|
+
);
|
|
6798
|
+
const attachmentUrlsStore = createBatchStore(batchedGetAttachmentUrls);
|
|
6799
|
+
function getAttachmentUrl(attachmentId) {
|
|
6800
|
+
return batchedGetAttachmentUrls.get(attachmentId);
|
|
6801
|
+
}
|
|
6649
6802
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6650
6803
|
const authValue = await delegates.authenticate();
|
|
6651
6804
|
const response = await fetchClientApi(
|
|
@@ -6722,7 +6875,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6722
6875
|
{
|
|
6723
6876
|
[kInternal]: {
|
|
6724
6877
|
get presenceBuffer() {
|
|
6725
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6878
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _146 => _146.buffer, 'access', _147 => _147.presenceUpdates, 'optionalAccess', _148 => _148.data]), () => ( null)));
|
|
6726
6879
|
},
|
|
6727
6880
|
// prettier-ignore
|
|
6728
6881
|
get undoStack() {
|
|
@@ -6761,7 +6914,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6761
6914
|
// These exist only for our E2E testing app
|
|
6762
6915
|
explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
|
|
6763
6916
|
rawSend: (data) => managedSocket.send(data)
|
|
6764
|
-
}
|
|
6917
|
+
},
|
|
6918
|
+
attachmentUrlsStore
|
|
6765
6919
|
},
|
|
6766
6920
|
id: config.roomId,
|
|
6767
6921
|
subscribe: makeClassicSubscribeFn(events),
|
|
@@ -6816,6 +6970,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6816
6970
|
deleteComment,
|
|
6817
6971
|
addReaction,
|
|
6818
6972
|
removeReaction,
|
|
6973
|
+
prepareAttachment,
|
|
6974
|
+
uploadAttachment,
|
|
6975
|
+
getAttachmentUrl,
|
|
6819
6976
|
// Notifications
|
|
6820
6977
|
getNotificationSettings,
|
|
6821
6978
|
updateNotificationSettings,
|
|
@@ -6902,7 +7059,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
6902
7059
|
}
|
|
6903
7060
|
if (isLiveNode(first)) {
|
|
6904
7061
|
const node = first;
|
|
6905
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7062
|
+
if (_optionalChain([options, 'optionalAccess', _149 => _149.isDeep])) {
|
|
6906
7063
|
const storageCallback = second;
|
|
6907
7064
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
6908
7065
|
} else {
|
|
@@ -7029,12 +7186,12 @@ function createClient(options) {
|
|
|
7029
7186
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7030
7187
|
roomId,
|
|
7031
7188
|
baseUrl,
|
|
7032
|
-
_optionalChain([clientOptions, 'access',
|
|
7189
|
+
_optionalChain([clientOptions, 'access', _150 => _150.polyfills, 'optionalAccess', _151 => _151.WebSocket])
|
|
7033
7190
|
),
|
|
7034
7191
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7035
7192
|
})),
|
|
7036
7193
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7037
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7194
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _152 => _152.unstable_batchedUpdates]),
|
|
7038
7195
|
baseUrl,
|
|
7039
7196
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7040
7197
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7050,7 +7207,7 @@ function createClient(options) {
|
|
|
7050
7207
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7051
7208
|
if (shouldConnect) {
|
|
7052
7209
|
if (typeof atob === "undefined") {
|
|
7053
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7210
|
+
if (_optionalChain([clientOptions, 'access', _153 => _153.polyfills, 'optionalAccess', _154 => _154.atob]) === void 0) {
|
|
7054
7211
|
throw new Error(
|
|
7055
7212
|
"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"
|
|
7056
7213
|
);
|
|
@@ -7062,7 +7219,7 @@ function createClient(options) {
|
|
|
7062
7219
|
return leaseRoom(newRoomDetails);
|
|
7063
7220
|
}
|
|
7064
7221
|
function getRoom(roomId) {
|
|
7065
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7222
|
+
const room = _optionalChain([roomsById, 'access', _155 => _155.get, 'call', _156 => _156(roomId), 'optionalAccess', _157 => _157.room]);
|
|
7066
7223
|
return room ? room : null;
|
|
7067
7224
|
}
|
|
7068
7225
|
function logout() {
|
|
@@ -7086,7 +7243,7 @@ function createClient(options) {
|
|
|
7086
7243
|
getThreadsSince
|
|
7087
7244
|
} = createNotificationsApi({
|
|
7088
7245
|
baseUrl,
|
|
7089
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7246
|
+
fetcher: _optionalChain([clientOptions, 'access', _158 => _158.polyfills, 'optionalAccess', _159 => _159.fetch]) || /* istanbul ignore next */
|
|
7090
7247
|
fetch,
|
|
7091
7248
|
authManager,
|
|
7092
7249
|
currentUserIdStore
|
|
@@ -7096,29 +7253,31 @@ function createClient(options) {
|
|
|
7096
7253
|
() => !resolveUsers,
|
|
7097
7254
|
"Set the resolveUsers option in createClient to specify user info."
|
|
7098
7255
|
);
|
|
7099
|
-
const
|
|
7256
|
+
const batchedResolveUsers = new Batch(
|
|
7100
7257
|
async (batchedUserIds) => {
|
|
7101
7258
|
const userIds = batchedUserIds.flat();
|
|
7102
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7259
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _160 => _160({ userIds })]);
|
|
7103
7260
|
warnIfNoResolveUsers();
|
|
7104
7261
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7105
7262
|
},
|
|
7106
7263
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
7107
7264
|
);
|
|
7265
|
+
const usersStore = createBatchStore(batchedResolveUsers);
|
|
7108
7266
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
7109
7267
|
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
7110
7268
|
() => !resolveRoomsInfo,
|
|
7111
7269
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
7112
7270
|
);
|
|
7113
|
-
const
|
|
7271
|
+
const batchedResolveRoomsInfo = new Batch(
|
|
7114
7272
|
async (batchedRoomIds) => {
|
|
7115
7273
|
const roomIds = batchedRoomIds.flat();
|
|
7116
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7274
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _161 => _161({ roomIds })]);
|
|
7117
7275
|
warnIfNoResolveRoomsInfo();
|
|
7118
7276
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7119
7277
|
},
|
|
7120
7278
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
7121
7279
|
);
|
|
7280
|
+
const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
|
|
7122
7281
|
return Object.defineProperty(
|
|
7123
7282
|
{
|
|
7124
7283
|
enterRoom,
|
|
@@ -7228,7 +7387,7 @@ var commentBodyElementsTypes = {
|
|
|
7228
7387
|
mention: "inline"
|
|
7229
7388
|
};
|
|
7230
7389
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7231
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7390
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _162 => _162.content])) {
|
|
7232
7391
|
return;
|
|
7233
7392
|
}
|
|
7234
7393
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7238,13 +7397,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7238
7397
|
for (const block of body.content) {
|
|
7239
7398
|
if (type === "all" || type === "block") {
|
|
7240
7399
|
if (guard(block)) {
|
|
7241
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7400
|
+
_optionalChain([visitor, 'optionalCall', _163 => _163(block)]);
|
|
7242
7401
|
}
|
|
7243
7402
|
}
|
|
7244
7403
|
if (type === "all" || type === "inline") {
|
|
7245
7404
|
for (const inline of block.children) {
|
|
7246
7405
|
if (guard(inline)) {
|
|
7247
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7406
|
+
_optionalChain([visitor, 'optionalCall', _164 => _164(inline)]);
|
|
7248
7407
|
}
|
|
7249
7408
|
}
|
|
7250
7409
|
}
|
|
@@ -7269,7 +7428,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7269
7428
|
userIds
|
|
7270
7429
|
});
|
|
7271
7430
|
for (const [index, userId] of userIds.entries()) {
|
|
7272
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7431
|
+
const user = _optionalChain([users, 'optionalAccess', _165 => _165[index]]);
|
|
7273
7432
|
if (user) {
|
|
7274
7433
|
resolvedUsers.set(userId, user);
|
|
7275
7434
|
}
|
|
@@ -7392,7 +7551,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7392
7551
|
text: ({ element }) => element.text,
|
|
7393
7552
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7394
7553
|
mention: ({ element, user }) => {
|
|
7395
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7554
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _166 => _166.name]), () => ( element.id))}`;
|
|
7396
7555
|
}
|
|
7397
7556
|
};
|
|
7398
7557
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7422,7 +7581,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7422
7581
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7423
7582
|
},
|
|
7424
7583
|
mention: ({ element, user }) => {
|
|
7425
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7584
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _167 => _167.name]), () => ( element.id))}</span>`;
|
|
7426
7585
|
}
|
|
7427
7586
|
};
|
|
7428
7587
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7452,19 +7611,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7452
7611
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7453
7612
|
},
|
|
7454
7613
|
mention: ({ element, user }) => {
|
|
7455
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7614
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _168 => _168.name]), () => ( element.id))}`;
|
|
7456
7615
|
}
|
|
7457
7616
|
};
|
|
7458
7617
|
async function stringifyCommentBody(body, options) {
|
|
7459
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7460
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7618
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _169 => _169.format]), () => ( "plain"));
|
|
7619
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _170 => _170.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7461
7620
|
const elements = {
|
|
7462
7621
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7463
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7622
|
+
..._optionalChain([options, 'optionalAccess', _171 => _171.elements])
|
|
7464
7623
|
};
|
|
7465
7624
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7466
7625
|
body,
|
|
7467
|
-
_optionalChain([options, 'optionalAccess',
|
|
7626
|
+
_optionalChain([options, 'optionalAccess', _172 => _172.resolveUsers])
|
|
7468
7627
|
);
|
|
7469
7628
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7470
7629
|
switch (block.type) {
|
|
@@ -7739,12 +7898,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7739
7898
|
}
|
|
7740
7899
|
const newState = Object.assign({}, state);
|
|
7741
7900
|
for (const key in update.updates) {
|
|
7742
|
-
if (_optionalChain([update, 'access',
|
|
7901
|
+
if (_optionalChain([update, 'access', _173 => _173.updates, 'access', _174 => _174[key], 'optionalAccess', _175 => _175.type]) === "update") {
|
|
7743
7902
|
const val = update.node.get(key);
|
|
7744
7903
|
if (val !== void 0) {
|
|
7745
7904
|
newState[key] = lsonToJson(val);
|
|
7746
7905
|
}
|
|
7747
|
-
} else if (_optionalChain([update, 'access',
|
|
7906
|
+
} else if (_optionalChain([update, 'access', _176 => _176.updates, 'access', _177 => _177[key], 'optionalAccess', _178 => _178.type]) === "delete") {
|
|
7748
7907
|
delete newState[key];
|
|
7749
7908
|
}
|
|
7750
7909
|
}
|
|
@@ -7805,12 +7964,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7805
7964
|
}
|
|
7806
7965
|
const newState = Object.assign({}, state);
|
|
7807
7966
|
for (const key in update.updates) {
|
|
7808
|
-
if (_optionalChain([update, 'access',
|
|
7967
|
+
if (_optionalChain([update, 'access', _179 => _179.updates, 'access', _180 => _180[key], 'optionalAccess', _181 => _181.type]) === "update") {
|
|
7809
7968
|
const value = update.node.get(key);
|
|
7810
7969
|
if (value !== void 0) {
|
|
7811
7970
|
newState[key] = lsonToJson(value);
|
|
7812
7971
|
}
|
|
7813
|
-
} else if (_optionalChain([update, 'access',
|
|
7972
|
+
} else if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "delete") {
|
|
7814
7973
|
delete newState[key];
|
|
7815
7974
|
}
|
|
7816
7975
|
}
|
|
@@ -7977,7 +8136,7 @@ function shallowArray(xs, ys) {
|
|
|
7977
8136
|
return true;
|
|
7978
8137
|
}
|
|
7979
8138
|
function shallowObj(objA, objB) {
|
|
7980
|
-
if (
|
|
8139
|
+
if (!isPlainObject(objA) || !isPlainObject(objB)) {
|
|
7981
8140
|
return false;
|
|
7982
8141
|
}
|
|
7983
8142
|
const keysA = Object.keys(objA);
|
|
@@ -8066,5 +8225,7 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8066
8225
|
|
|
8067
8226
|
|
|
8068
8227
|
|
|
8069
|
-
|
|
8228
|
+
|
|
8229
|
+
|
|
8230
|
+
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.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; 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.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createStore = createStore; exports.createThreadId = createThreadId; 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.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
8070
8231
|
//# sourceMappingURL=index.js.map
|