@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.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.0-
|
|
9
|
+
var PKG_VERSION = "2.8.0-beta4";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
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(_nullishCoalesce(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
|
..._optionalChain([options, 'optionalAccess', _45 => _45.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 (_optionalChain([options, 'optionalAccess', _46 => _46.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 (_optionalChain([options, 'optionalAccess', _47 => _47.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 (_optionalChain([throwError, 'optionalCall', _116 => _116(err)])) {
|
|
4809
4814
|
throw err;
|
|
4810
4815
|
}
|
|
4811
4816
|
if (attempt >= maxTries) {
|
|
@@ -5233,21 +5238,34 @@ function installBackgroundTabSpy() {
|
|
|
5233
5238
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
5234
5239
|
const inBackgroundSince = { current: null };
|
|
5235
5240
|
function onVisibilityChange() {
|
|
5236
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
5241
|
+
if (_optionalChain([doc, 'optionalAccess', _117 => _117.visibilityState]) === "hidden") {
|
|
5237
5242
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
5238
5243
|
} else {
|
|
5239
5244
|
inBackgroundSince.current = null;
|
|
5240
5245
|
}
|
|
5241
5246
|
}
|
|
5242
|
-
_optionalChain([doc, 'optionalAccess',
|
|
5247
|
+
_optionalChain([doc, 'optionalAccess', _118 => _118.addEventListener, 'call', _119 => _119("visibilitychange", onVisibilityChange)]);
|
|
5243
5248
|
const unsub = () => {
|
|
5244
|
-
_optionalChain([doc, 'optionalAccess',
|
|
5249
|
+
_optionalChain([doc, 'optionalAccess', _120 => _120.removeEventListener, 'call', _121 => _121("visibilitychange", onVisibilityChange)]);
|
|
5245
5250
|
};
|
|
5246
5251
|
return [inBackgroundSince, unsub];
|
|
5247
5252
|
}
|
|
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;
|
|
@@ -5460,7 +5478,7 @@ function createRoom(options, config) {
|
|
|
5460
5478
|
}
|
|
5461
5479
|
},
|
|
5462
5480
|
assertStorageIsWritable: () => {
|
|
5463
|
-
const scopes = _optionalChain([context, 'access',
|
|
5481
|
+
const scopes = _optionalChain([context, 'access', _122 => _122.dynamicSessionInfo, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.scopes]);
|
|
5464
5482
|
if (scopes === void 0) {
|
|
5465
5483
|
return;
|
|
5466
5484
|
}
|
|
@@ -5488,24 +5506,23 @@ function createRoom(options, config) {
|
|
|
5488
5506
|
ydoc: makeEventSource(),
|
|
5489
5507
|
comments: makeEventSource()
|
|
5490
5508
|
};
|
|
5491
|
-
async function fetchClientApi(
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5496
|
-
)
|
|
5497
|
-
const fetcher = _optionalChain([config, 'access', _124 => _124.polyfills, 'optionalAccess', _125 => _125.fetch]) || /* istanbul ignore next */
|
|
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);
|
|
5514
|
+
const fetcher = _optionalChain([config, 'access', _125 => _125.polyfills, 'optionalAccess', _126 => _126.fetch]) || /* istanbul ignore next */
|
|
5498
5515
|
fetch;
|
|
5499
|
-
return await fetcher(
|
|
5516
|
+
return await fetcher(url2, {
|
|
5500
5517
|
...options2,
|
|
5501
5518
|
headers: {
|
|
5502
|
-
..._optionalChain([options2, 'optionalAccess',
|
|
5519
|
+
..._optionalChain([options2, 'optionalAccess', _127 => _127.headers]),
|
|
5503
5520
|
Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
|
|
5504
5521
|
}
|
|
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,43 +5578,45 @@ 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);
|
|
5598
|
-
const nonce = _optionalChain([context, 'access',
|
|
5619
|
+
const nonce = _optionalChain([context, 'access', _128 => _128.dynamicSessionInfo, 'access', _129 => _129.current, 'optionalAccess', _130 => _130.nonce]);
|
|
5599
5620
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5600
5621
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5601
5622
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
@@ -5657,7 +5678,7 @@ function createRoom(options, config) {
|
|
|
5657
5678
|
} else {
|
|
5658
5679
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
5659
5680
|
}
|
|
5660
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
5681
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.canWrite]), () => ( true));
|
|
5661
5682
|
const stackSizeBefore = context.undoStack.length;
|
|
5662
5683
|
for (const key in context.initialStorage) {
|
|
5663
5684
|
if (context.root.get(key) === void 0) {
|
|
@@ -5862,7 +5883,7 @@ function createRoom(options, config) {
|
|
|
5862
5883
|
}
|
|
5863
5884
|
context.myPresence.patch(patch);
|
|
5864
5885
|
if (context.activeBatch) {
|
|
5865
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5886
|
+
if (_optionalChain([options2, 'optionalAccess', _133 => _133.addToHistory])) {
|
|
5866
5887
|
context.activeBatch.reverseOps.unshift({
|
|
5867
5888
|
type: "presence",
|
|
5868
5889
|
data: oldValues
|
|
@@ -5872,7 +5893,7 @@ function createRoom(options, config) {
|
|
|
5872
5893
|
} else {
|
|
5873
5894
|
flushNowOrSoon();
|
|
5874
5895
|
batchUpdates(() => {
|
|
5875
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5896
|
+
if (_optionalChain([options2, 'optionalAccess', _134 => _134.addToHistory])) {
|
|
5876
5897
|
addToUndoStack(
|
|
5877
5898
|
[{ type: "presence", data: oldValues }],
|
|
5878
5899
|
doNotBatchUpdates
|
|
@@ -6070,7 +6091,7 @@ function createRoom(options, config) {
|
|
|
6070
6091
|
if (process.env.NODE_ENV !== "production") {
|
|
6071
6092
|
const traces = /* @__PURE__ */ new Set();
|
|
6072
6093
|
for (const opId of message.opIds) {
|
|
6073
|
-
const trace = _optionalChain([context, 'access',
|
|
6094
|
+
const trace = _optionalChain([context, 'access', _135 => _135.opStackTraces, 'optionalAccess', _136 => _136.get, 'call', _137 => _137(opId)]);
|
|
6074
6095
|
if (trace) {
|
|
6075
6096
|
traces.add(trace);
|
|
6076
6097
|
}
|
|
@@ -6204,7 +6225,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6204
6225
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
6205
6226
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
6206
6227
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
6207
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
6228
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _138 => _138()]);
|
|
6208
6229
|
notifyStorageStatus();
|
|
6209
6230
|
eventHub.storageDidLoad.notify();
|
|
6210
6231
|
}
|
|
@@ -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,9 +6474,9 @@ ${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
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
6479
|
+
since: _optionalChain([options2, 'optionalAccess', _139 => _139.since, 'optionalAccess', _140 => _140.toISOString, 'call', _141 => _141()])
|
|
6459
6480
|
},
|
|
6460
6481
|
{
|
|
6461
6482
|
headers: {
|
|
@@ -6496,19 +6517,13 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6496
6517
|
}
|
|
6497
6518
|
async function getThreads(options2) {
|
|
6498
6519
|
let query;
|
|
6499
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6520
|
+
if (_optionalChain([options2, 'optionalAccess', _142 => _142.query])) {
|
|
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) {
|
|
@@ -6718,13 +6721,22 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6718
6721
|
`Upload of attachment ${attachment.id} was aborted.`,
|
|
6719
6722
|
"AbortError"
|
|
6720
6723
|
) : void 0;
|
|
6721
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6724
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _143 => _143.aborted])) {
|
|
6722
6725
|
throw abortError;
|
|
6723
6726
|
}
|
|
6727
|
+
const handleRetryError = (err) => {
|
|
6728
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.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 (_optionalChain([abortSignal, 'optionalAccess', _143 => _143.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 (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.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,34 +6781,29 @@ ${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 (_optionalChain([abortSignal, 'optionalAccess', _146 => _146.aborted])) {
|
|
6793
|
-
throw abortError;
|
|
6794
|
-
}
|
|
6795
|
-
return false;
|
|
6796
|
-
}
|
|
6791
|
+
RETRY_ATTEMPTS,
|
|
6792
|
+
RETRY_DELAYS,
|
|
6793
|
+
handleRetryError
|
|
6797
6794
|
)
|
|
6798
6795
|
);
|
|
6799
6796
|
}
|
|
6800
6797
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
6801
6798
|
}
|
|
6802
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6799
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _146 => _146.aborted])) {
|
|
6803
6800
|
throw abortError;
|
|
6804
6801
|
}
|
|
6805
6802
|
const sortedUploadedParts = uploadedParts.sort(
|
|
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: {
|
|
@@ -6817,10 +6814,10 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6817
6814
|
}
|
|
6818
6815
|
);
|
|
6819
6816
|
} catch (error3) {
|
|
6820
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
6817
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _147 => _147.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) => _nullishCoalesce(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) => {
|
|
@@ -6936,7 +6931,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6936
6931
|
{
|
|
6937
6932
|
[kInternal]: {
|
|
6938
6933
|
get presenceBuffer() {
|
|
6939
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6934
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _148 => _148.buffer, 'access', _149 => _149.presenceUpdates, 'optionalAccess', _150 => _150.data]), () => ( null)));
|
|
6940
6935
|
},
|
|
6941
6936
|
// prettier-ignore
|
|
6942
6937
|
get undoStack() {
|
|
@@ -7120,7 +7115,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
7120
7115
|
}
|
|
7121
7116
|
if (isLiveNode(first)) {
|
|
7122
7117
|
const node = first;
|
|
7123
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7118
|
+
if (_optionalChain([options, 'optionalAccess', _151 => _151.isDeep])) {
|
|
7124
7119
|
const storageCallback = second;
|
|
7125
7120
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7126
7121
|
} else {
|
|
@@ -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
|
|
|
@@ -7247,12 +7242,12 @@ function createClient(options) {
|
|
|
7247
7242
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7248
7243
|
roomId,
|
|
7249
7244
|
baseUrl,
|
|
7250
|
-
_optionalChain([clientOptions, 'access',
|
|
7245
|
+
_optionalChain([clientOptions, 'access', _152 => _152.polyfills, 'optionalAccess', _153 => _153.WebSocket])
|
|
7251
7246
|
),
|
|
7252
7247
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7253
7248
|
})),
|
|
7254
7249
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7255
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7250
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _154 => _154.unstable_batchedUpdates]),
|
|
7256
7251
|
baseUrl,
|
|
7257
7252
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7258
7253
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7268,7 +7263,7 @@ function createClient(options) {
|
|
|
7268
7263
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7269
7264
|
if (shouldConnect) {
|
|
7270
7265
|
if (typeof atob === "undefined") {
|
|
7271
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7266
|
+
if (_optionalChain([clientOptions, 'access', _155 => _155.polyfills, 'optionalAccess', _156 => _156.atob]) === void 0) {
|
|
7272
7267
|
throw new Error(
|
|
7273
7268
|
"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"
|
|
7274
7269
|
);
|
|
@@ -7280,7 +7275,7 @@ function createClient(options) {
|
|
|
7280
7275
|
return leaseRoom(newRoomDetails);
|
|
7281
7276
|
}
|
|
7282
7277
|
function getRoom(roomId) {
|
|
7283
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7278
|
+
const room = _optionalChain([roomsById, 'access', _157 => _157.get, 'call', _158 => _158(roomId), 'optionalAccess', _159 => _159.room]);
|
|
7284
7279
|
return room ? room : null;
|
|
7285
7280
|
}
|
|
7286
7281
|
function logout() {
|
|
@@ -7304,7 +7299,7 @@ function createClient(options) {
|
|
|
7304
7299
|
getThreadsSince
|
|
7305
7300
|
} = createNotificationsApi({
|
|
7306
7301
|
baseUrl,
|
|
7307
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7302
|
+
fetcher: _optionalChain([clientOptions, 'access', _160 => _160.polyfills, 'optionalAccess', _161 => _161.fetch]) || /* istanbul ignore next */
|
|
7308
7303
|
fetch,
|
|
7309
7304
|
authManager,
|
|
7310
7305
|
currentUserIdStore
|
|
@@ -7317,7 +7312,7 @@ function createClient(options) {
|
|
|
7317
7312
|
const batchedResolveUsers = new Batch(
|
|
7318
7313
|
async (batchedUserIds) => {
|
|
7319
7314
|
const userIds = batchedUserIds.flat();
|
|
7320
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7315
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _162 => _162({ userIds })]);
|
|
7321
7316
|
warnIfNoResolveUsers();
|
|
7322
7317
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7323
7318
|
},
|
|
@@ -7332,7 +7327,7 @@ function createClient(options) {
|
|
|
7332
7327
|
const batchedResolveRoomsInfo = new Batch(
|
|
7333
7328
|
async (batchedRoomIds) => {
|
|
7334
7329
|
const roomIds = batchedRoomIds.flat();
|
|
7335
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7330
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _163 => _163({ roomIds })]);
|
|
7336
7331
|
warnIfNoResolveRoomsInfo();
|
|
7337
7332
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7338
7333
|
},
|
|
@@ -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";
|
|
@@ -7448,7 +7443,7 @@ var commentBodyElementsTypes = {
|
|
|
7448
7443
|
mention: "inline"
|
|
7449
7444
|
};
|
|
7450
7445
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7451
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7446
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _164 => _164.content])) {
|
|
7452
7447
|
return;
|
|
7453
7448
|
}
|
|
7454
7449
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7458,13 +7453,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7458
7453
|
for (const block of body.content) {
|
|
7459
7454
|
if (type === "all" || type === "block") {
|
|
7460
7455
|
if (guard(block)) {
|
|
7461
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7456
|
+
_optionalChain([visitor, 'optionalCall', _165 => _165(block)]);
|
|
7462
7457
|
}
|
|
7463
7458
|
}
|
|
7464
7459
|
if (type === "all" || type === "inline") {
|
|
7465
7460
|
for (const inline of block.children) {
|
|
7466
7461
|
if (guard(inline)) {
|
|
7467
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7462
|
+
_optionalChain([visitor, 'optionalCall', _166 => _166(inline)]);
|
|
7468
7463
|
}
|
|
7469
7464
|
}
|
|
7470
7465
|
}
|
|
@@ -7489,7 +7484,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7489
7484
|
userIds
|
|
7490
7485
|
});
|
|
7491
7486
|
for (const [index, userId] of userIds.entries()) {
|
|
7492
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7487
|
+
const user = _optionalChain([users, 'optionalAccess', _167 => _167[index]]);
|
|
7493
7488
|
if (user) {
|
|
7494
7489
|
resolvedUsers.set(userId, user);
|
|
7495
7490
|
}
|
|
@@ -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
|
}
|
|
@@ -7612,7 +7607,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7612
7607
|
text: ({ element }) => element.text,
|
|
7613
7608
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7614
7609
|
mention: ({ element, user }) => {
|
|
7615
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7610
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _168 => _168.name]), () => ( element.id))}`;
|
|
7616
7611
|
}
|
|
7617
7612
|
};
|
|
7618
7613
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7642,7 +7637,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7642
7637
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7643
7638
|
},
|
|
7644
7639
|
mention: ({ element, user }) => {
|
|
7645
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7640
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _169 => _169.name]), () => ( element.id))}</span>`;
|
|
7646
7641
|
}
|
|
7647
7642
|
};
|
|
7648
7643
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7672,19 +7667,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7672
7667
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7673
7668
|
},
|
|
7674
7669
|
mention: ({ element, user }) => {
|
|
7675
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7670
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _170 => _170.name]), () => ( element.id))}`;
|
|
7676
7671
|
}
|
|
7677
7672
|
};
|
|
7678
7673
|
async function stringifyCommentBody(body, options) {
|
|
7679
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7680
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7674
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _171 => _171.format]), () => ( "plain"));
|
|
7675
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _172 => _172.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7681
7676
|
const elements = {
|
|
7682
7677
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7683
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7678
|
+
..._optionalChain([options, 'optionalAccess', _173 => _173.elements])
|
|
7684
7679
|
};
|
|
7685
7680
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7686
7681
|
body,
|
|
7687
|
-
_optionalChain([options, 'optionalAccess',
|
|
7682
|
+
_optionalChain([options, 'optionalAccess', _174 => _174.resolveUsers])
|
|
7688
7683
|
);
|
|
7689
7684
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7690
7685
|
switch (block.type) {
|
|
@@ -7959,12 +7954,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7959
7954
|
}
|
|
7960
7955
|
const newState = Object.assign({}, state);
|
|
7961
7956
|
for (const key in update.updates) {
|
|
7962
|
-
if (_optionalChain([update, 'access',
|
|
7957
|
+
if (_optionalChain([update, 'access', _175 => _175.updates, 'access', _176 => _176[key], 'optionalAccess', _177 => _177.type]) === "update") {
|
|
7963
7958
|
const val = update.node.get(key);
|
|
7964
7959
|
if (val !== void 0) {
|
|
7965
7960
|
newState[key] = lsonToJson(val);
|
|
7966
7961
|
}
|
|
7967
|
-
} else if (_optionalChain([update, 'access',
|
|
7962
|
+
} else if (_optionalChain([update, 'access', _178 => _178.updates, 'access', _179 => _179[key], 'optionalAccess', _180 => _180.type]) === "delete") {
|
|
7968
7963
|
delete newState[key];
|
|
7969
7964
|
}
|
|
7970
7965
|
}
|
|
@@ -8025,12 +8020,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8025
8020
|
}
|
|
8026
8021
|
const newState = Object.assign({}, state);
|
|
8027
8022
|
for (const key in update.updates) {
|
|
8028
|
-
if (_optionalChain([update, 'access',
|
|
8023
|
+
if (_optionalChain([update, 'access', _181 => _181.updates, 'access', _182 => _182[key], 'optionalAccess', _183 => _183.type]) === "update") {
|
|
8029
8024
|
const value = update.node.get(key);
|
|
8030
8025
|
if (value !== void 0) {
|
|
8031
8026
|
newState[key] = lsonToJson(value);
|
|
8032
8027
|
}
|
|
8033
|
-
} else if (_optionalChain([update, 'access',
|
|
8028
|
+
} else if (_optionalChain([update, 'access', _184 => _184.updates, 'access', _185 => _185[key], 'optionalAccess', _186 => _186.type]) === "delete") {
|
|
8034
8029
|
delete newState[key];
|
|
8035
8030
|
}
|
|
8036
8031
|
}
|
|
@@ -8289,5 +8284,7 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8289
8284
|
|
|
8290
8285
|
|
|
8291
8286
|
|
|
8292
|
-
|
|
8287
|
+
|
|
8288
|
+
|
|
8289
|
+
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.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;
|
|
8293
8290
|
//# sourceMappingURL=index.js.map
|