@liveblocks/core 2.8.0-beta2 → 2.8.0-beta4
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 +26 -7
- package/dist/index.d.ts +26 -7
- package/dist/index.js +218 -221
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -179
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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.0-
|
|
9
|
+
var PKG_VERSION = "2.8.0-beta4";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2055,11 +2055,16 @@ function toURLSearchParams(params) {
|
|
|
2055
2055
|
return result;
|
|
2056
2056
|
}
|
|
2057
2057
|
function urljoin(baseUrl, path, params) {
|
|
2058
|
-
const
|
|
2058
|
+
const url2 = new URL(path, baseUrl);
|
|
2059
2059
|
if (params !== void 0) {
|
|
2060
|
-
|
|
2060
|
+
url2.search = (params instanceof URLSearchParams ? params : toURLSearchParams(params)).toString();
|
|
2061
2061
|
}
|
|
2062
|
-
return
|
|
2062
|
+
return url2.toString();
|
|
2063
|
+
}
|
|
2064
|
+
function url(strings, ...values) {
|
|
2065
|
+
return strings.reduce(
|
|
2066
|
+
(result, str, i) => result + encodeURIComponent(values[i - 1] ?? "") + str
|
|
2067
|
+
);
|
|
2063
2068
|
}
|
|
2064
2069
|
|
|
2065
2070
|
// src/notifications.ts
|
|
@@ -2071,6 +2076,9 @@ function createNotificationsApi({
|
|
|
2071
2076
|
fetcher
|
|
2072
2077
|
}) {
|
|
2073
2078
|
async function fetchJson(endpoint, options, params) {
|
|
2079
|
+
if (!endpoint.startsWith("/v2/c/")) {
|
|
2080
|
+
raise("Expected a /v2/c/* endpoint");
|
|
2081
|
+
}
|
|
2074
2082
|
const authValue = await authManager.getAuthValue({
|
|
2075
2083
|
requestedScope: "comments:read"
|
|
2076
2084
|
});
|
|
@@ -2078,8 +2086,8 @@ function createNotificationsApi({
|
|
|
2078
2086
|
const userId = authValue.token.parsed.uid;
|
|
2079
2087
|
currentUserIdStore.set(() => userId);
|
|
2080
2088
|
}
|
|
2081
|
-
const
|
|
2082
|
-
const response = await fetcher(
|
|
2089
|
+
const url2 = urljoin(baseUrl, endpoint, params);
|
|
2090
|
+
const response = await fetcher(url2.toString(), {
|
|
2083
2091
|
...options,
|
|
2084
2092
|
headers: {
|
|
2085
2093
|
...options?.headers,
|
|
@@ -2114,7 +2122,7 @@ function createNotificationsApi({
|
|
|
2114
2122
|
return body;
|
|
2115
2123
|
}
|
|
2116
2124
|
async function getInboxNotifications() {
|
|
2117
|
-
const json = await fetchJson(
|
|
2125
|
+
const json = await fetchJson(url`/v2/c/inbox-notifications`, void 0, {});
|
|
2118
2126
|
return {
|
|
2119
2127
|
threads: json.threads.map(convertToThreadData),
|
|
2120
2128
|
inboxNotifications: json.inboxNotifications.map(
|
|
@@ -2124,7 +2132,7 @@ function createNotificationsApi({
|
|
|
2124
2132
|
};
|
|
2125
2133
|
}
|
|
2126
2134
|
async function getInboxNotificationsSince(options) {
|
|
2127
|
-
const json = await fetchJson(
|
|
2135
|
+
const json = await fetchJson(url`/v2/c/inbox-notifications`, void 0, {
|
|
2128
2136
|
since: options.since.toISOString()
|
|
2129
2137
|
});
|
|
2130
2138
|
return {
|
|
@@ -2142,11 +2150,11 @@ function createNotificationsApi({
|
|
|
2142
2150
|
};
|
|
2143
2151
|
}
|
|
2144
2152
|
async function getUnreadInboxNotificationsCount() {
|
|
2145
|
-
const { count } = await fetchJson(
|
|
2153
|
+
const { count } = await fetchJson(url`/v2/c/inbox-notifications/count`);
|
|
2146
2154
|
return count;
|
|
2147
2155
|
}
|
|
2148
2156
|
async function markAllInboxNotificationsAsRead() {
|
|
2149
|
-
await fetchJson(
|
|
2157
|
+
await fetchJson(url`/v2/c/inbox-notifications/read`, {
|
|
2150
2158
|
method: "POST",
|
|
2151
2159
|
headers: {
|
|
2152
2160
|
"Content-Type": "application/json"
|
|
@@ -2155,7 +2163,7 @@ function createNotificationsApi({
|
|
|
2155
2163
|
});
|
|
2156
2164
|
}
|
|
2157
2165
|
async function markInboxNotificationsAsRead(inboxNotificationIds) {
|
|
2158
|
-
await fetchJson(
|
|
2166
|
+
await fetchJson(url`/v2/c/inbox-notifications/read`, {
|
|
2159
2167
|
method: "POST",
|
|
2160
2168
|
headers: {
|
|
2161
2169
|
"Content-Type": "application/json"
|
|
@@ -2175,24 +2183,21 @@ function createNotificationsApi({
|
|
|
2175
2183
|
await batchedMarkInboxNotificationsAsRead.get(inboxNotificationId);
|
|
2176
2184
|
}
|
|
2177
2185
|
async function deleteAllInboxNotifications() {
|
|
2178
|
-
await fetchJson(
|
|
2186
|
+
await fetchJson(url`/v2/c/inbox-notifications`, {
|
|
2179
2187
|
method: "DELETE"
|
|
2180
2188
|
});
|
|
2181
2189
|
}
|
|
2182
2190
|
async function deleteInboxNotification(inboxNotificationId) {
|
|
2183
|
-
await fetchJson(
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
method: "DELETE"
|
|
2187
|
-
}
|
|
2188
|
-
);
|
|
2191
|
+
await fetchJson(url`/v2/c/inbox-notifications/${inboxNotificationId}`, {
|
|
2192
|
+
method: "DELETE"
|
|
2193
|
+
});
|
|
2189
2194
|
}
|
|
2190
2195
|
async function getThreads(options) {
|
|
2191
2196
|
let query;
|
|
2192
2197
|
if (options?.query) {
|
|
2193
2198
|
query = objectToQuery(options.query);
|
|
2194
2199
|
}
|
|
2195
|
-
const json = await fetchJson(
|
|
2200
|
+
const json = await fetchJson(url`/v2/c/threads`, void 0, {
|
|
2196
2201
|
query
|
|
2197
2202
|
});
|
|
2198
2203
|
return {
|
|
@@ -2208,7 +2213,7 @@ function createNotificationsApi({
|
|
|
2208
2213
|
if (options?.query) {
|
|
2209
2214
|
query = objectToQuery(options.query);
|
|
2210
2215
|
}
|
|
2211
|
-
const json = await fetchJson(
|
|
2216
|
+
const json = await fetchJson(url`/v2/c/threads`, void 0, {
|
|
2212
2217
|
since: options.since.toISOString(),
|
|
2213
2218
|
query
|
|
2214
2219
|
});
|
|
@@ -4796,7 +4801,7 @@ function findNonSerializableValue(value, path = "") {
|
|
|
4796
4801
|
}
|
|
4797
4802
|
|
|
4798
4803
|
// src/lib/autoRetry.ts
|
|
4799
|
-
async function autoRetry(promiseFn, maxTries, backoff,
|
|
4804
|
+
async function autoRetry(promiseFn, maxTries, backoff, throwError) {
|
|
4800
4805
|
const fallbackBackoff = backoff.length > 0 ? backoff[backoff.length - 1] : 0;
|
|
4801
4806
|
let attempt = 0;
|
|
4802
4807
|
while (true) {
|
|
@@ -4805,7 +4810,7 @@ async function autoRetry(promiseFn, maxTries, backoff, exitCondition) {
|
|
|
4805
4810
|
try {
|
|
4806
4811
|
return await promise;
|
|
4807
4812
|
} catch (err) {
|
|
4808
|
-
if (
|
|
4813
|
+
if (throwError?.(err)) {
|
|
4809
4814
|
throw err;
|
|
4810
4815
|
}
|
|
4811
4816
|
if (attempt >= maxTries) {
|
|
@@ -5248,6 +5253,19 @@ function installBackgroundTabSpy() {
|
|
|
5248
5253
|
var GET_ATTACHMENT_URLS_BATCH_DELAY = 50;
|
|
5249
5254
|
var ATTACHMENT_PART_SIZE = 5 * 1024 * 1024;
|
|
5250
5255
|
var ATTACHMENT_PART_BATCH_SIZE = 5;
|
|
5256
|
+
var RETRY_ATTEMPTS = 10;
|
|
5257
|
+
var RETRY_DELAYS = [
|
|
5258
|
+
2e3,
|
|
5259
|
+
2e3,
|
|
5260
|
+
2e3,
|
|
5261
|
+
2e3,
|
|
5262
|
+
2e3,
|
|
5263
|
+
2e3,
|
|
5264
|
+
2e3,
|
|
5265
|
+
2e3,
|
|
5266
|
+
2e3,
|
|
5267
|
+
2e3
|
|
5268
|
+
];
|
|
5251
5269
|
function splitFileIntoParts(file) {
|
|
5252
5270
|
const parts = [];
|
|
5253
5271
|
let start = 0;
|
|
@@ -5488,15 +5506,14 @@ function createRoom(options, config) {
|
|
|
5488
5506
|
ydoc: makeEventSource(),
|
|
5489
5507
|
comments: makeEventSource()
|
|
5490
5508
|
};
|
|
5491
|
-
async function fetchClientApi(
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
);
|
|
5509
|
+
async function fetchClientApi(endpoint, authValue, options2, params) {
|
|
5510
|
+
if (!endpoint.startsWith("/v2/c/rooms/")) {
|
|
5511
|
+
raise("Expected a /v2/c/rooms/* endpoint");
|
|
5512
|
+
}
|
|
5513
|
+
const url2 = urljoin(config.baseUrl, endpoint, params);
|
|
5497
5514
|
const fetcher = config.polyfills?.fetch || /* istanbul ignore next */
|
|
5498
5515
|
fetch;
|
|
5499
|
-
return await fetcher(
|
|
5516
|
+
return await fetcher(url2, {
|
|
5500
5517
|
...options2,
|
|
5501
5518
|
headers: {
|
|
5502
5519
|
...options2?.headers,
|
|
@@ -5505,7 +5522,7 @@ function createRoom(options, config) {
|
|
|
5505
5522
|
});
|
|
5506
5523
|
}
|
|
5507
5524
|
async function streamFetch(authValue, roomId) {
|
|
5508
|
-
return fetchClientApi(roomId
|
|
5525
|
+
return fetchClientApi(url`/v2/c/rooms/${roomId}/storage`, authValue, {
|
|
5509
5526
|
method: "GET",
|
|
5510
5527
|
headers: {
|
|
5511
5528
|
"Content-Type": "application/json"
|
|
@@ -5516,21 +5533,24 @@ function createRoom(options, config) {
|
|
|
5516
5533
|
if (!managedSocket.authValue) {
|
|
5517
5534
|
throw new Error("Not authorized");
|
|
5518
5535
|
}
|
|
5519
|
-
return fetchClientApi(
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5536
|
+
return fetchClientApi(
|
|
5537
|
+
endpoint === "/send-message" ? url`/v2/c/rooms/${config.roomId}/send-message` : url`/v2/c/rooms/${config.roomId}/text-metadata`,
|
|
5538
|
+
managedSocket.authValue,
|
|
5539
|
+
{
|
|
5540
|
+
method: "POST",
|
|
5541
|
+
headers: {
|
|
5542
|
+
"Content-Type": "application/json"
|
|
5543
|
+
},
|
|
5544
|
+
body: JSON.stringify(body)
|
|
5545
|
+
}
|
|
5546
|
+
);
|
|
5526
5547
|
}
|
|
5527
5548
|
async function createTextMention(userId, mentionId) {
|
|
5528
5549
|
if (!managedSocket.authValue) {
|
|
5529
5550
|
throw new Error("Not authorized");
|
|
5530
5551
|
}
|
|
5531
5552
|
return fetchClientApi(
|
|
5532
|
-
config.roomId
|
|
5533
|
-
"/text-mentions",
|
|
5553
|
+
url`/v2/c/rooms/${config.roomId}/text-mentions`,
|
|
5534
5554
|
managedSocket.authValue,
|
|
5535
5555
|
{
|
|
5536
5556
|
method: "POST",
|
|
@@ -5549,8 +5569,7 @@ function createRoom(options, config) {
|
|
|
5549
5569
|
throw new Error("Not authorized");
|
|
5550
5570
|
}
|
|
5551
5571
|
return fetchClientApi(
|
|
5552
|
-
config.roomId
|
|
5553
|
-
`/text-mentions/${mentionId}`,
|
|
5572
|
+
url`/v2/c/rooms/${config.roomId}/text-mentions/${mentionId}`,
|
|
5554
5573
|
managedSocket.authValue,
|
|
5555
5574
|
{
|
|
5556
5575
|
method: "DELETE"
|
|
@@ -5559,39 +5578,41 @@ function createRoom(options, config) {
|
|
|
5559
5578
|
}
|
|
5560
5579
|
async function reportTextEditor(type, rootKey) {
|
|
5561
5580
|
const authValue = await delegates.authenticate();
|
|
5562
|
-
return fetchClientApi(
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
type,
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
});
|
|
5581
|
+
return fetchClientApi(
|
|
5582
|
+
url`/v2/c/rooms/${config.roomId}/text-metadata`,
|
|
5583
|
+
authValue,
|
|
5584
|
+
{
|
|
5585
|
+
method: "POST",
|
|
5586
|
+
headers: { "Content-Type": "application/json" },
|
|
5587
|
+
body: JSON.stringify({ type, rootKey })
|
|
5588
|
+
}
|
|
5589
|
+
);
|
|
5572
5590
|
}
|
|
5573
5591
|
async function listTextVersions() {
|
|
5574
|
-
const authValue = await delegates.authenticate();
|
|
5575
|
-
return fetchClientApi(config.roomId, "/versions/", authValue, {
|
|
5576
|
-
method: "GET"
|
|
5577
|
-
});
|
|
5578
|
-
}
|
|
5579
|
-
async function getTextVersion(versionId) {
|
|
5580
5592
|
const authValue = await delegates.authenticate();
|
|
5581
5593
|
return fetchClientApi(
|
|
5582
|
-
config.roomId
|
|
5583
|
-
`/y-version/${encodeURIComponent(versionId)}`,
|
|
5594
|
+
url`/v2/c/rooms/${config.roomId}/versions`,
|
|
5584
5595
|
authValue,
|
|
5585
5596
|
{
|
|
5586
5597
|
method: "GET"
|
|
5587
5598
|
}
|
|
5588
5599
|
);
|
|
5589
5600
|
}
|
|
5601
|
+
async function getTextVersion(versionId) {
|
|
5602
|
+
const authValue = await delegates.authenticate();
|
|
5603
|
+
return fetchClientApi(
|
|
5604
|
+
url`/v2/c/rooms/${config.roomId}/y-version/${versionId}`,
|
|
5605
|
+
authValue,
|
|
5606
|
+
{ method: "GET" }
|
|
5607
|
+
);
|
|
5608
|
+
}
|
|
5590
5609
|
async function createTextVersion() {
|
|
5591
5610
|
const authValue = await delegates.authenticate();
|
|
5592
|
-
return fetchClientApi(
|
|
5593
|
-
|
|
5594
|
-
|
|
5611
|
+
return fetchClientApi(
|
|
5612
|
+
url`/v2/c/rooms/${config.roomId}/version`,
|
|
5613
|
+
authValue,
|
|
5614
|
+
{ method: "POST" }
|
|
5615
|
+
);
|
|
5595
5616
|
}
|
|
5596
5617
|
function sendMessages(messages) {
|
|
5597
5618
|
const serializedPayload = JSON.stringify(messages);
|
|
@@ -6423,7 +6444,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6423
6444
|
};
|
|
6424
6445
|
async function fetchCommentsApi(endpoint, params, options2) {
|
|
6425
6446
|
const authValue = await delegates.authenticate();
|
|
6426
|
-
return fetchClientApi(
|
|
6447
|
+
return fetchClientApi(endpoint, authValue, options2, params);
|
|
6427
6448
|
}
|
|
6428
6449
|
async function fetchCommentsJson(endpoint, options2, params) {
|
|
6429
6450
|
const response = await fetchCommentsApi(endpoint, params, options2);
|
|
@@ -6453,7 +6474,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6453
6474
|
}
|
|
6454
6475
|
async function getThreadsSince(options2) {
|
|
6455
6476
|
const response = await fetchCommentsApi(
|
|
6456
|
-
|
|
6477
|
+
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6457
6478
|
{
|
|
6458
6479
|
since: options2?.since?.toISOString()
|
|
6459
6480
|
},
|
|
@@ -6500,15 +6521,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6500
6521
|
query = objectToQuery(options2.query);
|
|
6501
6522
|
}
|
|
6502
6523
|
const response = await fetchCommentsApi(
|
|
6503
|
-
|
|
6504
|
-
{
|
|
6505
|
-
|
|
6506
|
-
},
|
|
6507
|
-
{
|
|
6508
|
-
headers: {
|
|
6509
|
-
"Content-Type": "application/json"
|
|
6510
|
-
}
|
|
6511
|
-
}
|
|
6524
|
+
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6525
|
+
{ query },
|
|
6526
|
+
{ headers: { "Content-Type": "application/json" } }
|
|
6512
6527
|
);
|
|
6513
6528
|
if (response.ok) {
|
|
6514
6529
|
const json = await response.json();
|
|
@@ -6533,7 +6548,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6533
6548
|
}
|
|
6534
6549
|
async function getThread(threadId) {
|
|
6535
6550
|
const response = await fetchCommentsApi(
|
|
6536
|
-
`/thread-with-notification/${threadId}`
|
|
6551
|
+
url`/v2/c/rooms/${config.roomId}/thread-with-notification/${threadId}`
|
|
6537
6552
|
);
|
|
6538
6553
|
if (response.ok) {
|
|
6539
6554
|
const json = await response.json();
|
|
@@ -6557,34 +6572,38 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6557
6572
|
threadId = createThreadId(),
|
|
6558
6573
|
attachmentIds
|
|
6559
6574
|
}) {
|
|
6560
|
-
const thread = await fetchCommentsJson(
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
id: threadId,
|
|
6567
|
-
comment: {
|
|
6568
|
-
id: commentId,
|
|
6569
|
-
body,
|
|
6570
|
-
attachmentIds
|
|
6575
|
+
const thread = await fetchCommentsJson(
|
|
6576
|
+
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6577
|
+
{
|
|
6578
|
+
method: "POST",
|
|
6579
|
+
headers: {
|
|
6580
|
+
"Content-Type": "application/json"
|
|
6571
6581
|
},
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6582
|
+
body: JSON.stringify({
|
|
6583
|
+
id: threadId,
|
|
6584
|
+
comment: {
|
|
6585
|
+
id: commentId,
|
|
6586
|
+
body,
|
|
6587
|
+
attachmentIds
|
|
6588
|
+
},
|
|
6589
|
+
metadata
|
|
6590
|
+
})
|
|
6591
|
+
}
|
|
6592
|
+
);
|
|
6575
6593
|
return convertToThreadData(thread);
|
|
6576
6594
|
}
|
|
6577
6595
|
async function deleteThread(threadId) {
|
|
6578
|
-
await fetchCommentsJson(
|
|
6579
|
-
|
|
6580
|
-
|
|
6596
|
+
await fetchCommentsJson(
|
|
6597
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}`,
|
|
6598
|
+
{ method: "DELETE" }
|
|
6599
|
+
);
|
|
6581
6600
|
}
|
|
6582
6601
|
async function editThreadMetadata({
|
|
6583
6602
|
metadata,
|
|
6584
6603
|
threadId
|
|
6585
6604
|
}) {
|
|
6586
6605
|
return await fetchCommentsJson(
|
|
6587
|
-
`/threads/${
|
|
6606
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/metadata`,
|
|
6588
6607
|
{
|
|
6589
6608
|
method: "POST",
|
|
6590
6609
|
headers: {
|
|
@@ -6596,18 +6615,14 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6596
6615
|
}
|
|
6597
6616
|
async function markThreadAsResolved(threadId) {
|
|
6598
6617
|
await fetchCommentsJson(
|
|
6599
|
-
`/threads/${
|
|
6600
|
-
{
|
|
6601
|
-
method: "POST"
|
|
6602
|
-
}
|
|
6618
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-resolved`,
|
|
6619
|
+
{ method: "POST" }
|
|
6603
6620
|
);
|
|
6604
6621
|
}
|
|
6605
6622
|
async function markThreadAsUnresolved(threadId) {
|
|
6606
6623
|
await fetchCommentsJson(
|
|
6607
|
-
`/threads/${
|
|
6608
|
-
{
|
|
6609
|
-
method: "POST"
|
|
6610
|
-
}
|
|
6624
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-unresolved`,
|
|
6625
|
+
{ method: "POST" }
|
|
6611
6626
|
);
|
|
6612
6627
|
}
|
|
6613
6628
|
async function createComment({
|
|
@@ -6617,7 +6632,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6617
6632
|
attachmentIds
|
|
6618
6633
|
}) {
|
|
6619
6634
|
const comment = await fetchCommentsJson(
|
|
6620
|
-
`/threads/${
|
|
6635
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments`,
|
|
6621
6636
|
{
|
|
6622
6637
|
method: "POST",
|
|
6623
6638
|
headers: {
|
|
@@ -6639,9 +6654,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6639
6654
|
attachmentIds
|
|
6640
6655
|
}) {
|
|
6641
6656
|
const comment = await fetchCommentsJson(
|
|
6642
|
-
`/threads/${
|
|
6643
|
-
commentId
|
|
6644
|
-
)}`,
|
|
6657
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`,
|
|
6645
6658
|
{
|
|
6646
6659
|
method: "POST",
|
|
6647
6660
|
headers: {
|
|
@@ -6660,12 +6673,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6660
6673
|
commentId
|
|
6661
6674
|
}) {
|
|
6662
6675
|
await fetchCommentsJson(
|
|
6663
|
-
`/threads/${
|
|
6664
|
-
|
|
6665
|
-
)}`,
|
|
6666
|
-
{
|
|
6667
|
-
method: "DELETE"
|
|
6668
|
-
}
|
|
6676
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`,
|
|
6677
|
+
{ method: "DELETE" }
|
|
6669
6678
|
);
|
|
6670
6679
|
}
|
|
6671
6680
|
async function addReaction({
|
|
@@ -6674,9 +6683,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6674
6683
|
emoji
|
|
6675
6684
|
}) {
|
|
6676
6685
|
const reaction = await fetchCommentsJson(
|
|
6677
|
-
`/threads/${
|
|
6678
|
-
commentId
|
|
6679
|
-
)}/reactions`,
|
|
6686
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions`,
|
|
6680
6687
|
{
|
|
6681
6688
|
method: "POST",
|
|
6682
6689
|
headers: {
|
|
@@ -6693,12 +6700,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6693
6700
|
emoji
|
|
6694
6701
|
}) {
|
|
6695
6702
|
await fetchCommentsJson(
|
|
6696
|
-
`/threads/${
|
|
6697
|
-
|
|
6698
|
-
)}/reactions/${encodeURIComponent(emoji)}`,
|
|
6699
|
-
{
|
|
6700
|
-
method: "DELETE"
|
|
6701
|
-
}
|
|
6703
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions/${emoji}`,
|
|
6704
|
+
{ method: "DELETE" }
|
|
6702
6705
|
);
|
|
6703
6706
|
}
|
|
6704
6707
|
function prepareAttachment(file) {
|
|
@@ -6721,10 +6724,19 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6721
6724
|
if (abortSignal?.aborted) {
|
|
6722
6725
|
throw abortError;
|
|
6723
6726
|
}
|
|
6727
|
+
const handleRetryError = (err) => {
|
|
6728
|
+
if (abortSignal?.aborted) {
|
|
6729
|
+
throw abortError;
|
|
6730
|
+
}
|
|
6731
|
+
if (err instanceof CommentsApiError && err.status === 413) {
|
|
6732
|
+
throw err;
|
|
6733
|
+
}
|
|
6734
|
+
return false;
|
|
6735
|
+
};
|
|
6724
6736
|
if (attachment.size <= ATTACHMENT_PART_SIZE) {
|
|
6725
6737
|
return autoRetry(
|
|
6726
6738
|
() => fetchCommentsJson(
|
|
6727
|
-
`/attachments/${
|
|
6739
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/upload/${encodeURIComponent(attachment.name)}`,
|
|
6728
6740
|
{
|
|
6729
6741
|
method: "PUT",
|
|
6730
6742
|
body: attachment.file,
|
|
@@ -6734,21 +6746,16 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6734
6746
|
fileSize: attachment.size
|
|
6735
6747
|
}
|
|
6736
6748
|
),
|
|
6737
|
-
|
|
6738
|
-
|
|
6739
|
-
|
|
6740
|
-
if (abortSignal?.aborted) {
|
|
6741
|
-
throw abortError;
|
|
6742
|
-
}
|
|
6743
|
-
return false;
|
|
6744
|
-
}
|
|
6749
|
+
RETRY_ATTEMPTS,
|
|
6750
|
+
RETRY_DELAYS,
|
|
6751
|
+
handleRetryError
|
|
6745
6752
|
);
|
|
6746
6753
|
} else {
|
|
6747
6754
|
let uploadId;
|
|
6748
6755
|
const uploadedParts = [];
|
|
6749
6756
|
const createMultiPartUpload = await autoRetry(
|
|
6750
6757
|
() => fetchCommentsJson(
|
|
6751
|
-
`/attachments/${
|
|
6758
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
6752
6759
|
{
|
|
6753
6760
|
method: "POST",
|
|
6754
6761
|
signal: abortSignal
|
|
@@ -6757,14 +6764,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6757
6764
|
fileSize: attachment.size
|
|
6758
6765
|
}
|
|
6759
6766
|
),
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
if (abortSignal?.aborted) {
|
|
6764
|
-
throw abortError;
|
|
6765
|
-
}
|
|
6766
|
-
return false;
|
|
6767
|
-
}
|
|
6767
|
+
RETRY_ATTEMPTS,
|
|
6768
|
+
RETRY_DELAYS,
|
|
6769
|
+
handleRetryError
|
|
6768
6770
|
);
|
|
6769
6771
|
try {
|
|
6770
6772
|
uploadId = createMultiPartUpload.uploadId;
|
|
@@ -6779,21 +6781,16 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6779
6781
|
uploadedPartsPromises.push(
|
|
6780
6782
|
autoRetry(
|
|
6781
6783
|
() => fetchCommentsJson(
|
|
6782
|
-
`/attachments/${
|
|
6784
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${createMultiPartUpload.uploadId}/${String(partNumber)}`,
|
|
6783
6785
|
{
|
|
6784
6786
|
method: "PUT",
|
|
6785
6787
|
body: part,
|
|
6786
6788
|
signal: abortSignal
|
|
6787
6789
|
}
|
|
6788
6790
|
),
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
if (abortSignal?.aborted) {
|
|
6793
|
-
throw abortError;
|
|
6794
|
-
}
|
|
6795
|
-
return false;
|
|
6796
|
-
}
|
|
6791
|
+
RETRY_ATTEMPTS,
|
|
6792
|
+
RETRY_DELAYS,
|
|
6793
|
+
handleRetryError
|
|
6797
6794
|
)
|
|
6798
6795
|
);
|
|
6799
6796
|
}
|
|
@@ -6806,7 +6803,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6806
6803
|
(a, b) => a.partNumber - b.partNumber
|
|
6807
6804
|
);
|
|
6808
6805
|
return fetchCommentsJson(
|
|
6809
|
-
`/attachments/${
|
|
6806
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
|
|
6810
6807
|
{
|
|
6811
6808
|
method: "POST",
|
|
6812
6809
|
headers: {
|
|
@@ -6820,7 +6817,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6820
6817
|
if (uploadId && error3?.name && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
6821
6818
|
try {
|
|
6822
6819
|
await fetchCommentsApi(
|
|
6823
|
-
`/attachments/${
|
|
6820
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
6824
6821
|
void 0,
|
|
6825
6822
|
{
|
|
6826
6823
|
method: "DELETE"
|
|
@@ -6835,7 +6832,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6835
6832
|
}
|
|
6836
6833
|
async function getAttachmentUrls(attachmentIds) {
|
|
6837
6834
|
const { urls } = await fetchCommentsJson(
|
|
6838
|
-
|
|
6835
|
+
url`/v2/c/rooms/${config.roomId}/attachments/presigned-urls`,
|
|
6839
6836
|
{
|
|
6840
6837
|
method: "POST",
|
|
6841
6838
|
headers: {
|
|
@@ -6851,7 +6848,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6851
6848
|
const attachmentIds = batchedAttachmentIds.flat();
|
|
6852
6849
|
const attachmentUrls = await getAttachmentUrls(attachmentIds);
|
|
6853
6850
|
return attachmentUrls.map(
|
|
6854
|
-
(
|
|
6851
|
+
(url2) => url2 ?? new Error("There was an error while getting this attachment's URL")
|
|
6855
6852
|
);
|
|
6856
6853
|
},
|
|
6857
6854
|
{ delay: GET_ATTACHMENT_URLS_BATCH_DELAY }
|
|
@@ -6862,12 +6859,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6862
6859
|
}
|
|
6863
6860
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6864
6861
|
const authValue = await delegates.authenticate();
|
|
6865
|
-
const response = await fetchClientApi(
|
|
6866
|
-
config.roomId,
|
|
6867
|
-
endpoint,
|
|
6868
|
-
authValue,
|
|
6869
|
-
options2
|
|
6870
|
-
);
|
|
6862
|
+
const response = await fetchClientApi(endpoint, authValue, options2);
|
|
6871
6863
|
if (!response.ok) {
|
|
6872
6864
|
if (response.status >= 400 && response.status < 600) {
|
|
6873
6865
|
let error3;
|
|
@@ -6897,12 +6889,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6897
6889
|
}
|
|
6898
6890
|
function getNotificationSettings() {
|
|
6899
6891
|
return fetchNotificationsJson(
|
|
6900
|
-
|
|
6892
|
+
url`/v2/c/rooms/${config.roomId}/notification-settings`
|
|
6901
6893
|
);
|
|
6902
6894
|
}
|
|
6903
6895
|
function updateNotificationSettings(settings) {
|
|
6904
6896
|
return fetchNotificationsJson(
|
|
6905
|
-
|
|
6897
|
+
url`/v2/c/rooms/${config.roomId}/notification-settings`,
|
|
6906
6898
|
{
|
|
6907
6899
|
method: "POST",
|
|
6908
6900
|
body: JSON.stringify(settings),
|
|
@@ -6913,13 +6905,16 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6913
6905
|
);
|
|
6914
6906
|
}
|
|
6915
6907
|
async function markInboxNotificationsAsRead(inboxNotificationIds) {
|
|
6916
|
-
await fetchNotificationsJson(
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6908
|
+
await fetchNotificationsJson(
|
|
6909
|
+
url`/v2/c/rooms/${config.roomId}/inbox-notifications/read`,
|
|
6910
|
+
{
|
|
6911
|
+
method: "POST",
|
|
6912
|
+
headers: {
|
|
6913
|
+
"Content-Type": "application/json"
|
|
6914
|
+
},
|
|
6915
|
+
body: JSON.stringify({ inboxNotificationIds })
|
|
6916
|
+
}
|
|
6917
|
+
);
|
|
6923
6918
|
}
|
|
6924
6919
|
const batchedMarkInboxNotificationsAsRead = new Batch(
|
|
6925
6920
|
async (batchedInboxNotificationIds) => {
|
|
@@ -7150,19 +7145,19 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
7150
7145
|
"To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill."
|
|
7151
7146
|
);
|
|
7152
7147
|
}
|
|
7153
|
-
const
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7148
|
+
const url2 = new URL(baseUrl);
|
|
7149
|
+
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
7150
|
+
url2.pathname = "/v7";
|
|
7151
|
+
url2.searchParams.set("roomId", roomId);
|
|
7157
7152
|
if (authValue.type === "secret") {
|
|
7158
|
-
|
|
7153
|
+
url2.searchParams.set("tok", authValue.token.raw);
|
|
7159
7154
|
} else if (authValue.type === "public") {
|
|
7160
|
-
|
|
7155
|
+
url2.searchParams.set("pubkey", authValue.publicApiKey);
|
|
7161
7156
|
} else {
|
|
7162
7157
|
return assertNever(authValue, "Unhandled case");
|
|
7163
7158
|
}
|
|
7164
|
-
|
|
7165
|
-
return new ws(
|
|
7159
|
+
url2.searchParams.set("version", PKG_VERSION || "dev");
|
|
7160
|
+
return new ws(url2.toString());
|
|
7166
7161
|
};
|
|
7167
7162
|
}
|
|
7168
7163
|
|
|
@@ -7424,7 +7419,7 @@ function createDevelopmentWarning(condition, ...args) {
|
|
|
7424
7419
|
|
|
7425
7420
|
// src/comments/comment-body.ts
|
|
7426
7421
|
function isCommentBodyParagraph(element) {
|
|
7427
|
-
return "type" in element && element.type === "
|
|
7422
|
+
return "type" in element && element.type === "paragraph";
|
|
7428
7423
|
}
|
|
7429
7424
|
function isCommentBodyText(element) {
|
|
7430
7425
|
return !("type" in element) && "text" in element && typeof element.text === "string";
|
|
@@ -7599,11 +7594,11 @@ var MarkdownSafeString = class {
|
|
|
7599
7594
|
function markdown(strings, ...values) {
|
|
7600
7595
|
return new MarkdownSafeString(strings, values);
|
|
7601
7596
|
}
|
|
7602
|
-
function toAbsoluteUrl(
|
|
7603
|
-
if (
|
|
7604
|
-
return
|
|
7605
|
-
} else if (
|
|
7606
|
-
return "https://" +
|
|
7597
|
+
function toAbsoluteUrl(url2) {
|
|
7598
|
+
if (url2.startsWith("http://") || url2.startsWith("https://")) {
|
|
7599
|
+
return url2;
|
|
7600
|
+
} else if (url2.startsWith("www.")) {
|
|
7601
|
+
return "https://" + url2;
|
|
7607
7602
|
}
|
|
7608
7603
|
return;
|
|
7609
7604
|
}
|
|
@@ -8287,6 +8282,8 @@ export {
|
|
|
8287
8282
|
throwUsageError,
|
|
8288
8283
|
toPlainLson,
|
|
8289
8284
|
tryParseJson,
|
|
8285
|
+
url,
|
|
8286
|
+
urljoin,
|
|
8290
8287
|
wait,
|
|
8291
8288
|
withTimeout
|
|
8292
8289
|
};
|