@liveblocks/core 2.7.1 → 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 +102 -24
- package/dist/index.d.ts +102 -24
- package/dist/index.js +198 -37
- 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.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) {
|
|
@@ -4796,9 +4795,19 @@ function findNonSerializableValue(value, path = "") {
|
|
|
4796
4795
|
return false;
|
|
4797
4796
|
}
|
|
4798
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
|
+
|
|
4799
4807
|
// src/lib/createIds.ts
|
|
4800
4808
|
var THREAD_ID_PREFIX = "th";
|
|
4801
4809
|
var COMMENT_ID_PREFIX = "cm";
|
|
4810
|
+
var COMMENT_ATTACHMENT_ID_PREFIX = "at";
|
|
4802
4811
|
var INBOX_NOTIFICATION_ID_PREFIX = "in";
|
|
4803
4812
|
function createOptimisticId(prefix) {
|
|
4804
4813
|
return `${prefix}_${nanoid()}`;
|
|
@@ -4809,6 +4818,9 @@ function createThreadId() {
|
|
|
4809
4818
|
function createCommentId() {
|
|
4810
4819
|
return createOptimisticId(COMMENT_ID_PREFIX);
|
|
4811
4820
|
}
|
|
4821
|
+
function createCommentAttachmentId() {
|
|
4822
|
+
return createOptimisticId(COMMENT_ATTACHMENT_ID_PREFIX);
|
|
4823
|
+
}
|
|
4812
4824
|
function createInboxNotificationId() {
|
|
4813
4825
|
return createOptimisticId(INBOX_NOTIFICATION_ID_PREFIX);
|
|
4814
4826
|
}
|
|
@@ -5211,6 +5223,22 @@ function installBackgroundTabSpy() {
|
|
|
5211
5223
|
};
|
|
5212
5224
|
return [inBackgroundSince, unsub];
|
|
5213
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
|
+
}
|
|
5214
5242
|
var CommentsApiError = class extends Error {
|
|
5215
5243
|
constructor(message, status, details) {
|
|
5216
5244
|
super(message);
|
|
@@ -6504,7 +6532,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6504
6532
|
metadata,
|
|
6505
6533
|
body,
|
|
6506
6534
|
commentId = createCommentId(),
|
|
6507
|
-
threadId = createThreadId()
|
|
6535
|
+
threadId = createThreadId(),
|
|
6536
|
+
attachmentIds
|
|
6508
6537
|
}) {
|
|
6509
6538
|
const thread = await fetchCommentsJson("/threads", {
|
|
6510
6539
|
method: "POST",
|
|
@@ -6515,7 +6544,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6515
6544
|
id: threadId,
|
|
6516
6545
|
comment: {
|
|
6517
6546
|
id: commentId,
|
|
6518
|
-
body
|
|
6547
|
+
body,
|
|
6548
|
+
attachmentIds
|
|
6519
6549
|
},
|
|
6520
6550
|
metadata
|
|
6521
6551
|
})
|
|
@@ -6561,7 +6591,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6561
6591
|
async function createComment({
|
|
6562
6592
|
threadId,
|
|
6563
6593
|
commentId = createCommentId(),
|
|
6564
|
-
body
|
|
6594
|
+
body,
|
|
6595
|
+
attachmentIds
|
|
6565
6596
|
}) {
|
|
6566
6597
|
const comment = await fetchCommentsJson(
|
|
6567
6598
|
`/threads/${encodeURIComponent(threadId)}/comments`,
|
|
@@ -6572,7 +6603,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6572
6603
|
},
|
|
6573
6604
|
body: JSON.stringify({
|
|
6574
6605
|
id: commentId,
|
|
6575
|
-
body
|
|
6606
|
+
body,
|
|
6607
|
+
attachmentIds
|
|
6576
6608
|
})
|
|
6577
6609
|
}
|
|
6578
6610
|
);
|
|
@@ -6581,7 +6613,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6581
6613
|
async function editComment({
|
|
6582
6614
|
threadId,
|
|
6583
6615
|
commentId,
|
|
6584
|
-
body
|
|
6616
|
+
body,
|
|
6617
|
+
attachmentIds
|
|
6585
6618
|
}) {
|
|
6586
6619
|
const comment = await fetchCommentsJson(
|
|
6587
6620
|
`/threads/${encodeURIComponent(threadId)}/comments/${encodeURIComponent(
|
|
@@ -6593,7 +6626,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6593
6626
|
"Content-Type": "application/json"
|
|
6594
6627
|
},
|
|
6595
6628
|
body: JSON.stringify({
|
|
6596
|
-
body
|
|
6629
|
+
body,
|
|
6630
|
+
attachmentIds
|
|
6597
6631
|
})
|
|
6598
6632
|
}
|
|
6599
6633
|
);
|
|
@@ -6645,6 +6679,126 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6645
6679
|
}
|
|
6646
6680
|
);
|
|
6647
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
|
+
}
|
|
6648
6802
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6649
6803
|
const authValue = await delegates.authenticate();
|
|
6650
6804
|
const response = await fetchClientApi(
|
|
@@ -6721,7 +6875,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6721
6875
|
{
|
|
6722
6876
|
[kInternal]: {
|
|
6723
6877
|
get presenceBuffer() {
|
|
6724
|
-
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)));
|
|
6725
6879
|
},
|
|
6726
6880
|
// prettier-ignore
|
|
6727
6881
|
get undoStack() {
|
|
@@ -6760,7 +6914,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6760
6914
|
// These exist only for our E2E testing app
|
|
6761
6915
|
explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
|
|
6762
6916
|
rawSend: (data) => managedSocket.send(data)
|
|
6763
|
-
}
|
|
6917
|
+
},
|
|
6918
|
+
attachmentUrlsStore
|
|
6764
6919
|
},
|
|
6765
6920
|
id: config.roomId,
|
|
6766
6921
|
subscribe: makeClassicSubscribeFn(events),
|
|
@@ -6815,6 +6970,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6815
6970
|
deleteComment,
|
|
6816
6971
|
addReaction,
|
|
6817
6972
|
removeReaction,
|
|
6973
|
+
prepareAttachment,
|
|
6974
|
+
uploadAttachment,
|
|
6975
|
+
getAttachmentUrl,
|
|
6818
6976
|
// Notifications
|
|
6819
6977
|
getNotificationSettings,
|
|
6820
6978
|
updateNotificationSettings,
|
|
@@ -6901,7 +7059,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
6901
7059
|
}
|
|
6902
7060
|
if (isLiveNode(first)) {
|
|
6903
7061
|
const node = first;
|
|
6904
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7062
|
+
if (_optionalChain([options, 'optionalAccess', _149 => _149.isDeep])) {
|
|
6905
7063
|
const storageCallback = second;
|
|
6906
7064
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
6907
7065
|
} else {
|
|
@@ -7028,12 +7186,12 @@ function createClient(options) {
|
|
|
7028
7186
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7029
7187
|
roomId,
|
|
7030
7188
|
baseUrl,
|
|
7031
|
-
_optionalChain([clientOptions, 'access',
|
|
7189
|
+
_optionalChain([clientOptions, 'access', _150 => _150.polyfills, 'optionalAccess', _151 => _151.WebSocket])
|
|
7032
7190
|
),
|
|
7033
7191
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7034
7192
|
})),
|
|
7035
7193
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7036
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7194
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _152 => _152.unstable_batchedUpdates]),
|
|
7037
7195
|
baseUrl,
|
|
7038
7196
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7039
7197
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7049,7 +7207,7 @@ function createClient(options) {
|
|
|
7049
7207
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7050
7208
|
if (shouldConnect) {
|
|
7051
7209
|
if (typeof atob === "undefined") {
|
|
7052
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7210
|
+
if (_optionalChain([clientOptions, 'access', _153 => _153.polyfills, 'optionalAccess', _154 => _154.atob]) === void 0) {
|
|
7053
7211
|
throw new Error(
|
|
7054
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"
|
|
7055
7213
|
);
|
|
@@ -7061,7 +7219,7 @@ function createClient(options) {
|
|
|
7061
7219
|
return leaseRoom(newRoomDetails);
|
|
7062
7220
|
}
|
|
7063
7221
|
function getRoom(roomId) {
|
|
7064
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7222
|
+
const room = _optionalChain([roomsById, 'access', _155 => _155.get, 'call', _156 => _156(roomId), 'optionalAccess', _157 => _157.room]);
|
|
7065
7223
|
return room ? room : null;
|
|
7066
7224
|
}
|
|
7067
7225
|
function logout() {
|
|
@@ -7085,7 +7243,7 @@ function createClient(options) {
|
|
|
7085
7243
|
getThreadsSince
|
|
7086
7244
|
} = createNotificationsApi({
|
|
7087
7245
|
baseUrl,
|
|
7088
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7246
|
+
fetcher: _optionalChain([clientOptions, 'access', _158 => _158.polyfills, 'optionalAccess', _159 => _159.fetch]) || /* istanbul ignore next */
|
|
7089
7247
|
fetch,
|
|
7090
7248
|
authManager,
|
|
7091
7249
|
currentUserIdStore
|
|
@@ -7095,29 +7253,31 @@ function createClient(options) {
|
|
|
7095
7253
|
() => !resolveUsers,
|
|
7096
7254
|
"Set the resolveUsers option in createClient to specify user info."
|
|
7097
7255
|
);
|
|
7098
|
-
const
|
|
7256
|
+
const batchedResolveUsers = new Batch(
|
|
7099
7257
|
async (batchedUserIds) => {
|
|
7100
7258
|
const userIds = batchedUserIds.flat();
|
|
7101
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7259
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _160 => _160({ userIds })]);
|
|
7102
7260
|
warnIfNoResolveUsers();
|
|
7103
7261
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7104
7262
|
},
|
|
7105
7263
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
7106
7264
|
);
|
|
7265
|
+
const usersStore = createBatchStore(batchedResolveUsers);
|
|
7107
7266
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
7108
7267
|
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
7109
7268
|
() => !resolveRoomsInfo,
|
|
7110
7269
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
7111
7270
|
);
|
|
7112
|
-
const
|
|
7271
|
+
const batchedResolveRoomsInfo = new Batch(
|
|
7113
7272
|
async (batchedRoomIds) => {
|
|
7114
7273
|
const roomIds = batchedRoomIds.flat();
|
|
7115
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7274
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _161 => _161({ roomIds })]);
|
|
7116
7275
|
warnIfNoResolveRoomsInfo();
|
|
7117
7276
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7118
7277
|
},
|
|
7119
7278
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
7120
7279
|
);
|
|
7280
|
+
const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
|
|
7121
7281
|
return Object.defineProperty(
|
|
7122
7282
|
{
|
|
7123
7283
|
enterRoom,
|
|
@@ -7227,7 +7387,7 @@ var commentBodyElementsTypes = {
|
|
|
7227
7387
|
mention: "inline"
|
|
7228
7388
|
};
|
|
7229
7389
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7230
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7390
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _162 => _162.content])) {
|
|
7231
7391
|
return;
|
|
7232
7392
|
}
|
|
7233
7393
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7237,13 +7397,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7237
7397
|
for (const block of body.content) {
|
|
7238
7398
|
if (type === "all" || type === "block") {
|
|
7239
7399
|
if (guard(block)) {
|
|
7240
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7400
|
+
_optionalChain([visitor, 'optionalCall', _163 => _163(block)]);
|
|
7241
7401
|
}
|
|
7242
7402
|
}
|
|
7243
7403
|
if (type === "all" || type === "inline") {
|
|
7244
7404
|
for (const inline of block.children) {
|
|
7245
7405
|
if (guard(inline)) {
|
|
7246
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7406
|
+
_optionalChain([visitor, 'optionalCall', _164 => _164(inline)]);
|
|
7247
7407
|
}
|
|
7248
7408
|
}
|
|
7249
7409
|
}
|
|
@@ -7268,7 +7428,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7268
7428
|
userIds
|
|
7269
7429
|
});
|
|
7270
7430
|
for (const [index, userId] of userIds.entries()) {
|
|
7271
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7431
|
+
const user = _optionalChain([users, 'optionalAccess', _165 => _165[index]]);
|
|
7272
7432
|
if (user) {
|
|
7273
7433
|
resolvedUsers.set(userId, user);
|
|
7274
7434
|
}
|
|
@@ -7391,7 +7551,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7391
7551
|
text: ({ element }) => element.text,
|
|
7392
7552
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7393
7553
|
mention: ({ element, user }) => {
|
|
7394
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7554
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _166 => _166.name]), () => ( element.id))}`;
|
|
7395
7555
|
}
|
|
7396
7556
|
};
|
|
7397
7557
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7421,7 +7581,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7421
7581
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7422
7582
|
},
|
|
7423
7583
|
mention: ({ element, user }) => {
|
|
7424
|
-
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>`;
|
|
7425
7585
|
}
|
|
7426
7586
|
};
|
|
7427
7587
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7451,19 +7611,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7451
7611
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7452
7612
|
},
|
|
7453
7613
|
mention: ({ element, user }) => {
|
|
7454
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7614
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _168 => _168.name]), () => ( element.id))}`;
|
|
7455
7615
|
}
|
|
7456
7616
|
};
|
|
7457
7617
|
async function stringifyCommentBody(body, options) {
|
|
7458
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7459
|
-
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")));
|
|
7460
7620
|
const elements = {
|
|
7461
7621
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7462
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7622
|
+
..._optionalChain([options, 'optionalAccess', _171 => _171.elements])
|
|
7463
7623
|
};
|
|
7464
7624
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7465
7625
|
body,
|
|
7466
|
-
_optionalChain([options, 'optionalAccess',
|
|
7626
|
+
_optionalChain([options, 'optionalAccess', _172 => _172.resolveUsers])
|
|
7467
7627
|
);
|
|
7468
7628
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7469
7629
|
switch (block.type) {
|
|
@@ -7738,12 +7898,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7738
7898
|
}
|
|
7739
7899
|
const newState = Object.assign({}, state);
|
|
7740
7900
|
for (const key in update.updates) {
|
|
7741
|
-
if (_optionalChain([update, 'access',
|
|
7901
|
+
if (_optionalChain([update, 'access', _173 => _173.updates, 'access', _174 => _174[key], 'optionalAccess', _175 => _175.type]) === "update") {
|
|
7742
7902
|
const val = update.node.get(key);
|
|
7743
7903
|
if (val !== void 0) {
|
|
7744
7904
|
newState[key] = lsonToJson(val);
|
|
7745
7905
|
}
|
|
7746
|
-
} else if (_optionalChain([update, 'access',
|
|
7906
|
+
} else if (_optionalChain([update, 'access', _176 => _176.updates, 'access', _177 => _177[key], 'optionalAccess', _178 => _178.type]) === "delete") {
|
|
7747
7907
|
delete newState[key];
|
|
7748
7908
|
}
|
|
7749
7909
|
}
|
|
@@ -7804,12 +7964,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7804
7964
|
}
|
|
7805
7965
|
const newState = Object.assign({}, state);
|
|
7806
7966
|
for (const key in update.updates) {
|
|
7807
|
-
if (_optionalChain([update, 'access',
|
|
7967
|
+
if (_optionalChain([update, 'access', _179 => _179.updates, 'access', _180 => _180[key], 'optionalAccess', _181 => _181.type]) === "update") {
|
|
7808
7968
|
const value = update.node.get(key);
|
|
7809
7969
|
if (value !== void 0) {
|
|
7810
7970
|
newState[key] = lsonToJson(value);
|
|
7811
7971
|
}
|
|
7812
|
-
} else if (_optionalChain([update, 'access',
|
|
7972
|
+
} else if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "delete") {
|
|
7813
7973
|
delete newState[key];
|
|
7814
7974
|
}
|
|
7815
7975
|
}
|
|
@@ -8066,5 +8226,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8066
8226
|
|
|
8067
8227
|
|
|
8068
8228
|
|
|
8069
|
-
|
|
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
|