@liveblocks/core 2.8.2 → 2.8.3-tiptap2
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 +491 -457
- package/dist/index.d.ts +491 -457
- package/dist/index.js +124 -159
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -129
- 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.8.
|
|
9
|
+
var PKG_VERSION = "2.8.3-tiptap2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1990,8 +1990,8 @@ function convertToCommentData(data) {
|
|
|
1990
1990
|
}
|
|
1991
1991
|
}
|
|
1992
1992
|
function convertToThreadData(data) {
|
|
1993
|
-
const updatedAt = data.updatedAt ? new Date(data.updatedAt) : void 0;
|
|
1994
1993
|
const createdAt = new Date(data.createdAt);
|
|
1994
|
+
const updatedAt = new Date(data.updatedAt);
|
|
1995
1995
|
const comments = data.comments.map(
|
|
1996
1996
|
(comment) => convertToCommentData(comment)
|
|
1997
1997
|
);
|
|
@@ -2044,6 +2044,15 @@ function convertToInboxNotificationDeleteInfo(data) {
|
|
|
2044
2044
|
};
|
|
2045
2045
|
}
|
|
2046
2046
|
|
|
2047
|
+
// src/http-client.ts
|
|
2048
|
+
function getBearerTokenFromAuthValue(authValue) {
|
|
2049
|
+
if (authValue.type === "public") {
|
|
2050
|
+
return authValue.publicApiKey;
|
|
2051
|
+
} else {
|
|
2052
|
+
return authValue.token.raw;
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2047
2056
|
// src/lib/url.ts
|
|
2048
2057
|
function toURLSearchParams(params) {
|
|
2049
2058
|
const result = new URLSearchParams();
|
|
@@ -2068,7 +2077,6 @@ function url(strings, ...values) {
|
|
|
2068
2077
|
}
|
|
2069
2078
|
|
|
2070
2079
|
// src/notifications.ts
|
|
2071
|
-
var MARK_INBOX_NOTIFICATIONS_AS_READ_BATCH_DELAY = 50;
|
|
2072
2080
|
function createNotificationsApi({
|
|
2073
2081
|
baseUrl,
|
|
2074
2082
|
authManager,
|
|
@@ -2091,7 +2099,7 @@ function createNotificationsApi({
|
|
|
2091
2099
|
...options,
|
|
2092
2100
|
headers: {
|
|
2093
2101
|
..._optionalChain([options, 'optionalAccess', _45 => _45.headers]),
|
|
2094
|
-
Authorization: `Bearer ${
|
|
2102
|
+
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
2095
2103
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
2096
2104
|
}
|
|
2097
2105
|
});
|
|
@@ -2122,31 +2130,36 @@ function createNotificationsApi({
|
|
|
2122
2130
|
}
|
|
2123
2131
|
return body;
|
|
2124
2132
|
}
|
|
2125
|
-
async function getInboxNotifications() {
|
|
2126
|
-
const
|
|
2133
|
+
async function getInboxNotifications(options) {
|
|
2134
|
+
const PAGE_SIZE = 50;
|
|
2135
|
+
const json = await fetchJson(url`/v2/c/inbox-notifications`, void 0, {
|
|
2136
|
+
cursor: _optionalChain([options, 'optionalAccess', _46 => _46.cursor]),
|
|
2137
|
+
limit: PAGE_SIZE
|
|
2138
|
+
});
|
|
2127
2139
|
return {
|
|
2128
|
-
threads: json.threads.map(convertToThreadData),
|
|
2129
2140
|
inboxNotifications: json.inboxNotifications.map(
|
|
2130
2141
|
convertToInboxNotificationData
|
|
2131
2142
|
),
|
|
2143
|
+
threads: json.threads.map(convertToThreadData),
|
|
2144
|
+
nextCursor: json.meta.nextCursor,
|
|
2132
2145
|
requestedAt: new Date(json.meta.requestedAt)
|
|
2133
2146
|
};
|
|
2134
2147
|
}
|
|
2135
|
-
async function getInboxNotificationsSince(
|
|
2136
|
-
const json = await fetchJson(url`/v2/c/inbox-notifications`, void 0, {
|
|
2137
|
-
since:
|
|
2148
|
+
async function getInboxNotificationsSince(since) {
|
|
2149
|
+
const json = await fetchJson(url`/v2/c/inbox-notifications/delta`, void 0, {
|
|
2150
|
+
since: since.toISOString()
|
|
2138
2151
|
});
|
|
2139
2152
|
return {
|
|
2140
|
-
threads: {
|
|
2141
|
-
updated: json.threads.map(convertToThreadData),
|
|
2142
|
-
deleted: json.deletedThreads.map(convertToThreadDeleteInfo)
|
|
2143
|
-
},
|
|
2144
2153
|
inboxNotifications: {
|
|
2145
2154
|
updated: json.inboxNotifications.map(convertToInboxNotificationData),
|
|
2146
2155
|
deleted: json.deletedInboxNotifications.map(
|
|
2147
2156
|
convertToInboxNotificationDeleteInfo
|
|
2148
2157
|
)
|
|
2149
2158
|
},
|
|
2159
|
+
threads: {
|
|
2160
|
+
updated: json.threads.map(convertToThreadData),
|
|
2161
|
+
deleted: json.deletedThreads.map(convertToThreadDeleteInfo)
|
|
2162
|
+
},
|
|
2150
2163
|
requestedAt: new Date(json.meta.requestedAt)
|
|
2151
2164
|
};
|
|
2152
2165
|
}
|
|
@@ -2178,7 +2191,7 @@ function createNotificationsApi({
|
|
|
2178
2191
|
await markInboxNotificationsAsRead(inboxNotificationIds);
|
|
2179
2192
|
return inboxNotificationIds;
|
|
2180
2193
|
},
|
|
2181
|
-
{ delay:
|
|
2194
|
+
{ delay: 50 }
|
|
2182
2195
|
);
|
|
2183
2196
|
async function markInboxNotificationAsRead(inboxNotificationId) {
|
|
2184
2197
|
await batchedMarkInboxNotificationsAsRead.get(inboxNotificationId);
|
|
@@ -2193,30 +2206,29 @@ function createNotificationsApi({
|
|
|
2193
2206
|
method: "DELETE"
|
|
2194
2207
|
});
|
|
2195
2208
|
}
|
|
2196
|
-
async function
|
|
2209
|
+
async function getUserThreads_experimental(options) {
|
|
2197
2210
|
let query;
|
|
2198
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2211
|
+
if (_optionalChain([options, 'optionalAccess', _47 => _47.query])) {
|
|
2199
2212
|
query = objectToQuery(options.query);
|
|
2200
2213
|
}
|
|
2214
|
+
const PAGE_SIZE = 50;
|
|
2201
2215
|
const json = await fetchJson(url`/v2/c/threads`, void 0, {
|
|
2202
|
-
|
|
2216
|
+
cursor: options.cursor,
|
|
2217
|
+
query,
|
|
2218
|
+
limit: PAGE_SIZE
|
|
2203
2219
|
});
|
|
2204
2220
|
return {
|
|
2205
2221
|
threads: json.threads.map(convertToThreadData),
|
|
2206
2222
|
inboxNotifications: json.inboxNotifications.map(
|
|
2207
2223
|
convertToInboxNotificationData
|
|
2208
2224
|
),
|
|
2225
|
+
nextCursor: json.meta.nextCursor,
|
|
2209
2226
|
requestedAt: new Date(json.meta.requestedAt)
|
|
2210
2227
|
};
|
|
2211
2228
|
}
|
|
2212
|
-
async function
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
query = objectToQuery(options.query);
|
|
2216
|
-
}
|
|
2217
|
-
const json = await fetchJson(url`/v2/c/threads`, void 0, {
|
|
2218
|
-
since: options.since.toISOString(),
|
|
2219
|
-
query
|
|
2229
|
+
async function getUserThreadsSince_experimental(options) {
|
|
2230
|
+
const json = await fetchJson(url`/v2/c/threads/delta`, void 0, {
|
|
2231
|
+
since: options.since.toISOString()
|
|
2220
2232
|
});
|
|
2221
2233
|
return {
|
|
2222
2234
|
threads: {
|
|
@@ -2240,8 +2252,8 @@ function createNotificationsApi({
|
|
|
2240
2252
|
markInboxNotificationAsRead,
|
|
2241
2253
|
deleteAllInboxNotifications,
|
|
2242
2254
|
deleteInboxNotification,
|
|
2243
|
-
|
|
2244
|
-
|
|
2255
|
+
getUserThreads_experimental,
|
|
2256
|
+
getUserThreadsSince_experimental
|
|
2245
2257
|
};
|
|
2246
2258
|
}
|
|
2247
2259
|
|
|
@@ -4811,7 +4823,7 @@ async function autoRetry(promiseFn, maxTries, backoff, throwError) {
|
|
|
4811
4823
|
try {
|
|
4812
4824
|
return await promise;
|
|
4813
4825
|
} catch (err) {
|
|
4814
|
-
if (_optionalChain([throwError, 'optionalCall', _116 => _116(err)])) {
|
|
4826
|
+
if (_optionalChain([throwError, 'optionalCall', _116 => _116(err)]) || err instanceof StopRetrying2) {
|
|
4815
4827
|
throw err;
|
|
4816
4828
|
}
|
|
4817
4829
|
if (attempt >= maxTries) {
|
|
@@ -4819,9 +4831,17 @@ async function autoRetry(promiseFn, maxTries, backoff, throwError) {
|
|
|
4819
4831
|
}
|
|
4820
4832
|
}
|
|
4821
4833
|
const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
|
|
4834
|
+
warn(
|
|
4835
|
+
`Attempt ${attempt} was unsuccessful. Retrying in ${delay} milliseconds.`
|
|
4836
|
+
);
|
|
4822
4837
|
await wait(delay);
|
|
4823
4838
|
}
|
|
4824
4839
|
}
|
|
4840
|
+
var StopRetrying2 = class extends Error {
|
|
4841
|
+
constructor(reason) {
|
|
4842
|
+
super(reason);
|
|
4843
|
+
}
|
|
4844
|
+
};
|
|
4825
4845
|
|
|
4826
4846
|
// src/lib/chunk.ts
|
|
4827
4847
|
function chunk(array, size) {
|
|
@@ -5288,7 +5308,6 @@ var CommentsApiError = class extends Error {
|
|
|
5288
5308
|
this.details = details;
|
|
5289
5309
|
}
|
|
5290
5310
|
};
|
|
5291
|
-
var MARK_INBOX_NOTIFICATIONS_AS_READ_BATCH_DELAY2 = 50;
|
|
5292
5311
|
function createRoom(options, config) {
|
|
5293
5312
|
const initialPresence = options.initialPresence;
|
|
5294
5313
|
const initialStorage = options.initialStorage;
|
|
@@ -5353,7 +5372,7 @@ function createRoom(options, config) {
|
|
|
5353
5372
|
function onStatusDidChange(newStatus) {
|
|
5354
5373
|
const authValue = managedSocket.authValue;
|
|
5355
5374
|
if (authValue !== null) {
|
|
5356
|
-
const tokenKey =
|
|
5375
|
+
const tokenKey = getBearerTokenFromAuthValue(authValue);
|
|
5357
5376
|
if (tokenKey !== lastTokenKey) {
|
|
5358
5377
|
lastTokenKey = tokenKey;
|
|
5359
5378
|
if (authValue.type === "secret") {
|
|
@@ -5518,7 +5537,7 @@ function createRoom(options, config) {
|
|
|
5518
5537
|
...options2,
|
|
5519
5538
|
headers: {
|
|
5520
5539
|
..._optionalChain([options2, 'optionalAccess', _127 => _127.headers]),
|
|
5521
|
-
Authorization: `Bearer ${
|
|
5540
|
+
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
5522
5541
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
5523
5542
|
}
|
|
5524
5543
|
});
|
|
@@ -6476,10 +6495,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6476
6495
|
}
|
|
6477
6496
|
async function getThreadsSince(options2) {
|
|
6478
6497
|
const response = await fetchCommentsApi(
|
|
6479
|
-
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6480
|
-
{
|
|
6481
|
-
since: _optionalChain([options2, 'optionalAccess', _139 => _139.since, 'optionalAccess', _140 => _140.toISOString, 'call', _141 => _141()])
|
|
6482
|
-
},
|
|
6498
|
+
url`/v2/c/rooms/${config.roomId}/threads/delta`,
|
|
6499
|
+
{ since: _optionalChain([options2, 'optionalAccess', _139 => _139.since, 'optionalAccess', _140 => _140.toISOString, 'call', _141 => _141()]) },
|
|
6483
6500
|
{
|
|
6484
6501
|
headers: {
|
|
6485
6502
|
"Content-Type": "application/json"
|
|
@@ -6522,9 +6539,14 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6522
6539
|
if (_optionalChain([options2, 'optionalAccess', _142 => _142.query])) {
|
|
6523
6540
|
query = objectToQuery(options2.query);
|
|
6524
6541
|
}
|
|
6542
|
+
const PAGE_SIZE = 50;
|
|
6525
6543
|
const response = await fetchCommentsApi(
|
|
6526
6544
|
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6527
|
-
{
|
|
6545
|
+
{
|
|
6546
|
+
cursor: _optionalChain([options2, 'optionalAccess', _143 => _143.cursor]),
|
|
6547
|
+
query,
|
|
6548
|
+
limit: PAGE_SIZE
|
|
6549
|
+
},
|
|
6528
6550
|
{ headers: { "Content-Type": "application/json" } }
|
|
6529
6551
|
);
|
|
6530
6552
|
if (response.ok) {
|
|
@@ -6534,6 +6556,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6534
6556
|
inboxNotifications: json.inboxNotifications.map(
|
|
6535
6557
|
convertToInboxNotificationData
|
|
6536
6558
|
),
|
|
6559
|
+
nextCursor: json.meta.nextCursor,
|
|
6537
6560
|
requestedAt: new Date(json.meta.requestedAt)
|
|
6538
6561
|
};
|
|
6539
6562
|
} else if (response.status === 404) {
|
|
@@ -6542,6 +6565,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6542
6565
|
inboxNotifications: [],
|
|
6543
6566
|
deletedThreads: [],
|
|
6544
6567
|
deletedInboxNotifications: [],
|
|
6568
|
+
nextCursor: null,
|
|
6545
6569
|
requestedAt: /* @__PURE__ */ new Date()
|
|
6546
6570
|
};
|
|
6547
6571
|
} else {
|
|
@@ -6723,11 +6747,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6723
6747
|
`Upload of attachment ${attachment.id} was aborted.`,
|
|
6724
6748
|
"AbortError"
|
|
6725
6749
|
) : void 0;
|
|
6726
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6750
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.aborted])) {
|
|
6727
6751
|
throw abortError;
|
|
6728
6752
|
}
|
|
6729
6753
|
const handleRetryError = (err) => {
|
|
6730
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6754
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _145 => _145.aborted])) {
|
|
6731
6755
|
throw abortError;
|
|
6732
6756
|
}
|
|
6733
6757
|
if (err instanceof CommentsApiError && err.status === 413) {
|
|
@@ -6773,7 +6797,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6773
6797
|
try {
|
|
6774
6798
|
uploadId = createMultiPartUpload.uploadId;
|
|
6775
6799
|
const parts = splitFileIntoParts(attachment.file);
|
|
6776
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6800
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _146 => _146.aborted])) {
|
|
6777
6801
|
throw abortError;
|
|
6778
6802
|
}
|
|
6779
6803
|
const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
|
|
@@ -6798,7 +6822,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6798
6822
|
}
|
|
6799
6823
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
6800
6824
|
}
|
|
6801
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6825
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _147 => _147.aborted])) {
|
|
6802
6826
|
throw abortError;
|
|
6803
6827
|
}
|
|
6804
6828
|
const sortedUploadedParts = uploadedParts.sort(
|
|
@@ -6816,7 +6840,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6816
6840
|
}
|
|
6817
6841
|
);
|
|
6818
6842
|
} catch (error3) {
|
|
6819
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
6843
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _148 => _148.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
6820
6844
|
try {
|
|
6821
6845
|
await fetchCommentsApi(
|
|
6822
6846
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
@@ -6924,7 +6948,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6924
6948
|
await markInboxNotificationsAsRead(inboxNotificationIds);
|
|
6925
6949
|
return inboxNotificationIds;
|
|
6926
6950
|
},
|
|
6927
|
-
{ delay:
|
|
6951
|
+
{ delay: 50 }
|
|
6928
6952
|
);
|
|
6929
6953
|
async function markInboxNotificationAsRead(inboxNotificationId) {
|
|
6930
6954
|
await batchedMarkInboxNotificationsAsRead.get(inboxNotificationId);
|
|
@@ -6933,7 +6957,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6933
6957
|
{
|
|
6934
6958
|
[kInternal]: {
|
|
6935
6959
|
get presenceBuffer() {
|
|
6936
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6960
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _149 => _149.buffer, 'access', _150 => _150.presenceUpdates, 'optionalAccess', _151 => _151.data]), () => ( null)));
|
|
6937
6961
|
},
|
|
6938
6962
|
// prettier-ignore
|
|
6939
6963
|
get undoStack() {
|
|
@@ -7117,7 +7141,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
7117
7141
|
}
|
|
7118
7142
|
if (isLiveNode(first)) {
|
|
7119
7143
|
const node = first;
|
|
7120
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7144
|
+
if (_optionalChain([options, 'optionalAccess', _152 => _152.isDeep])) {
|
|
7121
7145
|
const storageCallback = second;
|
|
7122
7146
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7123
7147
|
} else {
|
|
@@ -7181,13 +7205,6 @@ function getBaseUrl(baseUrl) {
|
|
|
7181
7205
|
return DEFAULT_BASE_URL;
|
|
7182
7206
|
}
|
|
7183
7207
|
}
|
|
7184
|
-
function getAuthBearerHeaderFromAuthValue(authValue) {
|
|
7185
|
-
if (authValue.type === "public") {
|
|
7186
|
-
return authValue.publicApiKey;
|
|
7187
|
-
} else {
|
|
7188
|
-
return authValue.token.raw;
|
|
7189
|
-
}
|
|
7190
|
-
}
|
|
7191
7208
|
function createClient(options) {
|
|
7192
7209
|
const clientOptions = options;
|
|
7193
7210
|
const throttleDelay = getThrottle(_nullishCoalesce(clientOptions.throttle, () => ( DEFAULT_THROTTLE)));
|
|
@@ -7244,12 +7261,12 @@ function createClient(options) {
|
|
|
7244
7261
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7245
7262
|
roomId,
|
|
7246
7263
|
baseUrl,
|
|
7247
|
-
_optionalChain([clientOptions, 'access',
|
|
7264
|
+
_optionalChain([clientOptions, 'access', _153 => _153.polyfills, 'optionalAccess', _154 => _154.WebSocket])
|
|
7248
7265
|
),
|
|
7249
7266
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7250
7267
|
})),
|
|
7251
7268
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7252
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7269
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _155 => _155.unstable_batchedUpdates]),
|
|
7253
7270
|
baseUrl,
|
|
7254
7271
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7255
7272
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7265,7 +7282,7 @@ function createClient(options) {
|
|
|
7265
7282
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7266
7283
|
if (shouldConnect) {
|
|
7267
7284
|
if (typeof atob === "undefined") {
|
|
7268
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7285
|
+
if (_optionalChain([clientOptions, 'access', _156 => _156.polyfills, 'optionalAccess', _157 => _157.atob]) === void 0) {
|
|
7269
7286
|
throw new Error(
|
|
7270
7287
|
"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"
|
|
7271
7288
|
);
|
|
@@ -7277,7 +7294,7 @@ function createClient(options) {
|
|
|
7277
7294
|
return leaseRoom(newRoomDetails);
|
|
7278
7295
|
}
|
|
7279
7296
|
function getRoom(roomId) {
|
|
7280
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7297
|
+
const room = _optionalChain([roomsById, 'access', _158 => _158.get, 'call', _159 => _159(roomId), 'optionalAccess', _160 => _160.room]);
|
|
7281
7298
|
return room ? room : null;
|
|
7282
7299
|
}
|
|
7283
7300
|
function logout() {
|
|
@@ -7289,20 +7306,11 @@ function createClient(options) {
|
|
|
7289
7306
|
}
|
|
7290
7307
|
}
|
|
7291
7308
|
const currentUserIdStore = createStore(null);
|
|
7292
|
-
const
|
|
7293
|
-
|
|
7294
|
-
|
|
7295
|
-
getUnreadInboxNotificationsCount,
|
|
7296
|
-
markAllInboxNotificationsAsRead,
|
|
7297
|
-
markInboxNotificationAsRead,
|
|
7298
|
-
deleteAllInboxNotifications,
|
|
7299
|
-
deleteInboxNotification,
|
|
7300
|
-
getThreads,
|
|
7301
|
-
getThreadsSince
|
|
7302
|
-
} = createNotificationsApi({
|
|
7309
|
+
const fetcher = _optionalChain([clientOptions, 'access', _161 => _161.polyfills, 'optionalAccess', _162 => _162.fetch]) || /* istanbul ignore next */
|
|
7310
|
+
fetch;
|
|
7311
|
+
const httpClientLike = createNotificationsApi({
|
|
7303
7312
|
baseUrl,
|
|
7304
|
-
fetcher
|
|
7305
|
-
fetch,
|
|
7313
|
+
fetcher,
|
|
7306
7314
|
authManager,
|
|
7307
7315
|
currentUserIdStore
|
|
7308
7316
|
});
|
|
@@ -7314,7 +7322,7 @@ function createClient(options) {
|
|
|
7314
7322
|
const batchedResolveUsers = new Batch(
|
|
7315
7323
|
async (batchedUserIds) => {
|
|
7316
7324
|
const userIds = batchedUserIds.flat();
|
|
7317
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7325
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _163 => _163({ userIds })]);
|
|
7318
7326
|
warnIfNoResolveUsers();
|
|
7319
7327
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7320
7328
|
},
|
|
@@ -7329,7 +7337,7 @@ function createClient(options) {
|
|
|
7329
7337
|
const batchedResolveRoomsInfo = new Batch(
|
|
7330
7338
|
async (batchedRoomIds) => {
|
|
7331
7339
|
const roomIds = batchedRoomIds.flat();
|
|
7332
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7340
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _164 => _164({ roomIds })]);
|
|
7333
7341
|
warnIfNoResolveRoomsInfo();
|
|
7334
7342
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7335
7343
|
},
|
|
@@ -7341,14 +7349,7 @@ function createClient(options) {
|
|
|
7341
7349
|
enterRoom,
|
|
7342
7350
|
getRoom,
|
|
7343
7351
|
logout,
|
|
7344
|
-
|
|
7345
|
-
getInboxNotificationsSince,
|
|
7346
|
-
getUnreadInboxNotificationsCount,
|
|
7347
|
-
markAllInboxNotificationsAsRead,
|
|
7348
|
-
markInboxNotificationAsRead,
|
|
7349
|
-
deleteAllInboxNotifications,
|
|
7350
|
-
deleteInboxNotification,
|
|
7351
|
-
getThreads,
|
|
7352
|
+
...httpClientLike,
|
|
7352
7353
|
// Internal
|
|
7353
7354
|
[kInternal]: {
|
|
7354
7355
|
currentUserIdStore,
|
|
@@ -7358,8 +7359,9 @@ function createClient(options) {
|
|
|
7358
7359
|
getRoomIds() {
|
|
7359
7360
|
return Array.from(roomsById.keys());
|
|
7360
7361
|
},
|
|
7361
|
-
|
|
7362
|
-
|
|
7362
|
+
// "All" threads (= "user" threads)
|
|
7363
|
+
getUserThreads_experimental: httpClientLike.getUserThreads_experimental,
|
|
7364
|
+
getUserThreadsSince_experimental: httpClientLike.getUserThreadsSince_experimental
|
|
7363
7365
|
}
|
|
7364
7366
|
},
|
|
7365
7367
|
kInternal,
|
|
@@ -7445,7 +7447,7 @@ var commentBodyElementsTypes = {
|
|
|
7445
7447
|
mention: "inline"
|
|
7446
7448
|
};
|
|
7447
7449
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7448
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7450
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _165 => _165.content])) {
|
|
7449
7451
|
return;
|
|
7450
7452
|
}
|
|
7451
7453
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7455,13 +7457,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7455
7457
|
for (const block of body.content) {
|
|
7456
7458
|
if (type === "all" || type === "block") {
|
|
7457
7459
|
if (guard(block)) {
|
|
7458
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7460
|
+
_optionalChain([visitor, 'optionalCall', _166 => _166(block)]);
|
|
7459
7461
|
}
|
|
7460
7462
|
}
|
|
7461
7463
|
if (type === "all" || type === "inline") {
|
|
7462
7464
|
for (const inline of block.children) {
|
|
7463
7465
|
if (guard(inline)) {
|
|
7464
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7466
|
+
_optionalChain([visitor, 'optionalCall', _167 => _167(inline)]);
|
|
7465
7467
|
}
|
|
7466
7468
|
}
|
|
7467
7469
|
}
|
|
@@ -7486,7 +7488,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7486
7488
|
userIds
|
|
7487
7489
|
});
|
|
7488
7490
|
for (const [index, userId] of userIds.entries()) {
|
|
7489
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7491
|
+
const user = _optionalChain([users, 'optionalAccess', _168 => _168[index]]);
|
|
7490
7492
|
if (user) {
|
|
7491
7493
|
resolvedUsers.set(userId, user);
|
|
7492
7494
|
}
|
|
@@ -7609,7 +7611,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7609
7611
|
text: ({ element }) => element.text,
|
|
7610
7612
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7611
7613
|
mention: ({ element, user }) => {
|
|
7612
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7614
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _169 => _169.name]), () => ( element.id))}`;
|
|
7613
7615
|
}
|
|
7614
7616
|
};
|
|
7615
7617
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7639,7 +7641,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7639
7641
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7640
7642
|
},
|
|
7641
7643
|
mention: ({ element, user }) => {
|
|
7642
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7644
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _170 => _170.name]), () => ( element.id))}</span>`;
|
|
7643
7645
|
}
|
|
7644
7646
|
};
|
|
7645
7647
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7669,19 +7671,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7669
7671
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7670
7672
|
},
|
|
7671
7673
|
mention: ({ element, user }) => {
|
|
7672
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7674
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _171 => _171.name]), () => ( element.id))}`;
|
|
7673
7675
|
}
|
|
7674
7676
|
};
|
|
7675
7677
|
async function stringifyCommentBody(body, options) {
|
|
7676
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7677
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7678
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.format]), () => ( "plain"));
|
|
7679
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _173 => _173.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7678
7680
|
const elements = {
|
|
7679
7681
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7680
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7682
|
+
..._optionalChain([options, 'optionalAccess', _174 => _174.elements])
|
|
7681
7683
|
};
|
|
7682
7684
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7683
7685
|
body,
|
|
7684
|
-
_optionalChain([options, 'optionalAccess',
|
|
7686
|
+
_optionalChain([options, 'optionalAccess', _175 => _175.resolveUsers])
|
|
7685
7687
|
);
|
|
7686
7688
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7687
7689
|
switch (block.type) {
|
|
@@ -7956,12 +7958,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7956
7958
|
}
|
|
7957
7959
|
const newState = Object.assign({}, state);
|
|
7958
7960
|
for (const key in update.updates) {
|
|
7959
|
-
if (_optionalChain([update, 'access',
|
|
7961
|
+
if (_optionalChain([update, 'access', _176 => _176.updates, 'access', _177 => _177[key], 'optionalAccess', _178 => _178.type]) === "update") {
|
|
7960
7962
|
const val = update.node.get(key);
|
|
7961
7963
|
if (val !== void 0) {
|
|
7962
7964
|
newState[key] = lsonToJson(val);
|
|
7963
7965
|
}
|
|
7964
|
-
} else if (_optionalChain([update, 'access',
|
|
7966
|
+
} else if (_optionalChain([update, 'access', _179 => _179.updates, 'access', _180 => _180[key], 'optionalAccess', _181 => _181.type]) === "delete") {
|
|
7965
7967
|
delete newState[key];
|
|
7966
7968
|
}
|
|
7967
7969
|
}
|
|
@@ -8022,12 +8024,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8022
8024
|
}
|
|
8023
8025
|
const newState = Object.assign({}, state);
|
|
8024
8026
|
for (const key in update.updates) {
|
|
8025
|
-
if (_optionalChain([update, 'access',
|
|
8027
|
+
if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
|
|
8026
8028
|
const value = update.node.get(key);
|
|
8027
8029
|
if (value !== void 0) {
|
|
8028
8030
|
newState[key] = lsonToJson(value);
|
|
8029
8031
|
}
|
|
8030
|
-
} else if (_optionalChain([update, 'access',
|
|
8032
|
+
} else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
|
|
8031
8033
|
delete newState[key];
|
|
8032
8034
|
}
|
|
8033
8035
|
}
|
|
@@ -8093,69 +8095,26 @@ function errorIf(condition, message) {
|
|
|
8093
8095
|
}
|
|
8094
8096
|
|
|
8095
8097
|
// src/lib/Poller.ts
|
|
8096
|
-
function makePoller(callback) {
|
|
8097
|
-
let context = {
|
|
8098
|
-
state: "stopped",
|
|
8099
|
-
timeoutHandle: null,
|
|
8100
|
-
interval: null,
|
|
8101
|
-
lastScheduledAt: null,
|
|
8102
|
-
remainingInterval: null
|
|
8103
|
-
};
|
|
8098
|
+
function makePoller(callback, interval) {
|
|
8099
|
+
let context = { state: "stopped" };
|
|
8104
8100
|
function poll() {
|
|
8105
8101
|
if (context.state === "running") {
|
|
8106
|
-
schedule(
|
|
8102
|
+
schedule();
|
|
8107
8103
|
}
|
|
8108
8104
|
void callback();
|
|
8109
8105
|
}
|
|
8110
|
-
function schedule(
|
|
8106
|
+
function schedule() {
|
|
8111
8107
|
context = {
|
|
8112
8108
|
state: "running",
|
|
8113
|
-
interval: context.state !== "stopped" ? context.interval : interval,
|
|
8114
8109
|
lastScheduledAt: performance.now(),
|
|
8115
|
-
timeoutHandle: setTimeout(poll, interval)
|
|
8116
|
-
remainingInterval: null
|
|
8117
|
-
};
|
|
8118
|
-
}
|
|
8119
|
-
function scheduleRemaining(remaining) {
|
|
8120
|
-
if (context.state !== "paused") {
|
|
8121
|
-
return;
|
|
8122
|
-
}
|
|
8123
|
-
context = {
|
|
8124
|
-
state: "running",
|
|
8125
|
-
interval: context.interval,
|
|
8126
|
-
lastScheduledAt: context.lastScheduledAt,
|
|
8127
|
-
timeoutHandle: setTimeout(poll, remaining),
|
|
8128
|
-
remainingInterval: null
|
|
8110
|
+
timeoutHandle: setTimeout(poll, interval)
|
|
8129
8111
|
};
|
|
8130
8112
|
}
|
|
8131
|
-
function start(
|
|
8113
|
+
function start() {
|
|
8132
8114
|
if (context.state === "running") {
|
|
8133
8115
|
return;
|
|
8134
8116
|
}
|
|
8135
|
-
schedule(
|
|
8136
|
-
}
|
|
8137
|
-
function restart(interval) {
|
|
8138
|
-
stop();
|
|
8139
|
-
start(interval);
|
|
8140
|
-
}
|
|
8141
|
-
function pause() {
|
|
8142
|
-
if (context.state !== "running") {
|
|
8143
|
-
return;
|
|
8144
|
-
}
|
|
8145
|
-
clearTimeout(context.timeoutHandle);
|
|
8146
|
-
context = {
|
|
8147
|
-
state: "paused",
|
|
8148
|
-
interval: context.interval,
|
|
8149
|
-
lastScheduledAt: context.lastScheduledAt,
|
|
8150
|
-
timeoutHandle: null,
|
|
8151
|
-
remainingInterval: context.interval - (performance.now() - context.lastScheduledAt)
|
|
8152
|
-
};
|
|
8153
|
-
}
|
|
8154
|
-
function resume() {
|
|
8155
|
-
if (context.state !== "paused") {
|
|
8156
|
-
return;
|
|
8157
|
-
}
|
|
8158
|
-
scheduleRemaining(context.remainingInterval);
|
|
8117
|
+
schedule();
|
|
8159
8118
|
}
|
|
8160
8119
|
function stop() {
|
|
8161
8120
|
if (context.state === "stopped") {
|
|
@@ -8164,20 +8123,17 @@ function makePoller(callback) {
|
|
|
8164
8123
|
if (context.timeoutHandle) {
|
|
8165
8124
|
clearTimeout(context.timeoutHandle);
|
|
8166
8125
|
}
|
|
8167
|
-
context = {
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8126
|
+
context = { state: "stopped" };
|
|
8127
|
+
}
|
|
8128
|
+
function enable(condition) {
|
|
8129
|
+
if (condition) {
|
|
8130
|
+
start();
|
|
8131
|
+
} else {
|
|
8132
|
+
stop();
|
|
8133
|
+
}
|
|
8174
8134
|
}
|
|
8175
8135
|
return {
|
|
8176
|
-
|
|
8177
|
-
restart,
|
|
8178
|
-
pause,
|
|
8179
|
-
resume,
|
|
8180
|
-
stop
|
|
8136
|
+
enable
|
|
8181
8137
|
};
|
|
8182
8138
|
}
|
|
8183
8139
|
|
|
@@ -8220,6 +8176,13 @@ function shallow(a, b) {
|
|
|
8220
8176
|
return shallowObj(a, b);
|
|
8221
8177
|
}
|
|
8222
8178
|
|
|
8179
|
+
// src/types/Others.ts
|
|
8180
|
+
var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
|
|
8181
|
+
TextEditorType2["Lexical"] = "lexical";
|
|
8182
|
+
TextEditorType2["TipTap"] = "tiptap";
|
|
8183
|
+
return TextEditorType2;
|
|
8184
|
+
})(TextEditorType || {});
|
|
8185
|
+
|
|
8223
8186
|
// src/index.ts
|
|
8224
8187
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
8225
8188
|
|
|
@@ -8288,5 +8251,7 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8288
8251
|
|
|
8289
8252
|
|
|
8290
8253
|
|
|
8291
|
-
|
|
8254
|
+
|
|
8255
|
+
|
|
8256
|
+
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.StopRetrying = StopRetrying2; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; 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.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
8292
8257
|
//# sourceMappingURL=index.js.map
|