@liveblocks/core 2.8.0-beta3 → 2.8.0
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 +189 -199
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -155
- 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";
|
|
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,15 +5238,15 @@ 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
|
}
|
|
@@ -5473,7 +5478,7 @@ function createRoom(options, config) {
|
|
|
5473
5478
|
}
|
|
5474
5479
|
},
|
|
5475
5480
|
assertStorageIsWritable: () => {
|
|
5476
|
-
const scopes = _optionalChain([context, 'access',
|
|
5481
|
+
const scopes = _optionalChain([context, 'access', _122 => _122.dynamicSessionInfo, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.scopes]);
|
|
5477
5482
|
if (scopes === void 0) {
|
|
5478
5483
|
return;
|
|
5479
5484
|
}
|
|
@@ -5501,24 +5506,23 @@ function createRoom(options, config) {
|
|
|
5501
5506
|
ydoc: makeEventSource(),
|
|
5502
5507
|
comments: makeEventSource()
|
|
5503
5508
|
};
|
|
5504
|
-
async function fetchClientApi(
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
)
|
|
5510
|
-
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 */
|
|
5511
5515
|
fetch;
|
|
5512
|
-
return await fetcher(
|
|
5516
|
+
return await fetcher(url2, {
|
|
5513
5517
|
...options2,
|
|
5514
5518
|
headers: {
|
|
5515
|
-
..._optionalChain([options2, 'optionalAccess',
|
|
5519
|
+
..._optionalChain([options2, 'optionalAccess', _127 => _127.headers]),
|
|
5516
5520
|
Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
|
|
5517
5521
|
}
|
|
5518
5522
|
});
|
|
5519
5523
|
}
|
|
5520
5524
|
async function streamFetch(authValue, roomId) {
|
|
5521
|
-
return fetchClientApi(roomId
|
|
5525
|
+
return fetchClientApi(url`/v2/c/rooms/${roomId}/storage`, authValue, {
|
|
5522
5526
|
method: "GET",
|
|
5523
5527
|
headers: {
|
|
5524
5528
|
"Content-Type": "application/json"
|
|
@@ -5529,21 +5533,24 @@ function createRoom(options, config) {
|
|
|
5529
5533
|
if (!managedSocket.authValue) {
|
|
5530
5534
|
throw new Error("Not authorized");
|
|
5531
5535
|
}
|
|
5532
|
-
return fetchClientApi(
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
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
|
+
);
|
|
5539
5547
|
}
|
|
5540
5548
|
async function createTextMention(userId, mentionId) {
|
|
5541
5549
|
if (!managedSocket.authValue) {
|
|
5542
5550
|
throw new Error("Not authorized");
|
|
5543
5551
|
}
|
|
5544
5552
|
return fetchClientApi(
|
|
5545
|
-
config.roomId
|
|
5546
|
-
"/text-mentions",
|
|
5553
|
+
url`/v2/c/rooms/${config.roomId}/text-mentions`,
|
|
5547
5554
|
managedSocket.authValue,
|
|
5548
5555
|
{
|
|
5549
5556
|
method: "POST",
|
|
@@ -5562,8 +5569,7 @@ function createRoom(options, config) {
|
|
|
5562
5569
|
throw new Error("Not authorized");
|
|
5563
5570
|
}
|
|
5564
5571
|
return fetchClientApi(
|
|
5565
|
-
config.roomId
|
|
5566
|
-
`/text-mentions/${mentionId}`,
|
|
5572
|
+
url`/v2/c/rooms/${config.roomId}/text-mentions/${mentionId}`,
|
|
5567
5573
|
managedSocket.authValue,
|
|
5568
5574
|
{
|
|
5569
5575
|
method: "DELETE"
|
|
@@ -5572,43 +5578,45 @@ function createRoom(options, config) {
|
|
|
5572
5578
|
}
|
|
5573
5579
|
async function reportTextEditor(type, rootKey) {
|
|
5574
5580
|
const authValue = await delegates.authenticate();
|
|
5575
|
-
return fetchClientApi(
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
type,
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
});
|
|
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
|
+
);
|
|
5585
5590
|
}
|
|
5586
5591
|
async function listTextVersions() {
|
|
5587
|
-
const authValue = await delegates.authenticate();
|
|
5588
|
-
return fetchClientApi(config.roomId, "/versions/", authValue, {
|
|
5589
|
-
method: "GET"
|
|
5590
|
-
});
|
|
5591
|
-
}
|
|
5592
|
-
async function getTextVersion(versionId) {
|
|
5593
5592
|
const authValue = await delegates.authenticate();
|
|
5594
5593
|
return fetchClientApi(
|
|
5595
|
-
config.roomId
|
|
5596
|
-
`/y-version/${encodeURIComponent(versionId)}`,
|
|
5594
|
+
url`/v2/c/rooms/${config.roomId}/versions`,
|
|
5597
5595
|
authValue,
|
|
5598
5596
|
{
|
|
5599
5597
|
method: "GET"
|
|
5600
5598
|
}
|
|
5601
5599
|
);
|
|
5602
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
|
+
}
|
|
5603
5609
|
async function createTextVersion() {
|
|
5604
5610
|
const authValue = await delegates.authenticate();
|
|
5605
|
-
return fetchClientApi(
|
|
5606
|
-
|
|
5607
|
-
|
|
5611
|
+
return fetchClientApi(
|
|
5612
|
+
url`/v2/c/rooms/${config.roomId}/version`,
|
|
5613
|
+
authValue,
|
|
5614
|
+
{ method: "POST" }
|
|
5615
|
+
);
|
|
5608
5616
|
}
|
|
5609
5617
|
function sendMessages(messages) {
|
|
5610
5618
|
const serializedPayload = JSON.stringify(messages);
|
|
5611
|
-
const nonce = _optionalChain([context, 'access',
|
|
5619
|
+
const nonce = _optionalChain([context, 'access', _128 => _128.dynamicSessionInfo, 'access', _129 => _129.current, 'optionalAccess', _130 => _130.nonce]);
|
|
5612
5620
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5613
5621
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5614
5622
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
@@ -5670,7 +5678,7 @@ function createRoom(options, config) {
|
|
|
5670
5678
|
} else {
|
|
5671
5679
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
5672
5680
|
}
|
|
5673
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
5681
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.canWrite]), () => ( true));
|
|
5674
5682
|
const stackSizeBefore = context.undoStack.length;
|
|
5675
5683
|
for (const key in context.initialStorage) {
|
|
5676
5684
|
if (context.root.get(key) === void 0) {
|
|
@@ -5875,7 +5883,7 @@ function createRoom(options, config) {
|
|
|
5875
5883
|
}
|
|
5876
5884
|
context.myPresence.patch(patch);
|
|
5877
5885
|
if (context.activeBatch) {
|
|
5878
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5886
|
+
if (_optionalChain([options2, 'optionalAccess', _133 => _133.addToHistory])) {
|
|
5879
5887
|
context.activeBatch.reverseOps.unshift({
|
|
5880
5888
|
type: "presence",
|
|
5881
5889
|
data: oldValues
|
|
@@ -5885,7 +5893,7 @@ function createRoom(options, config) {
|
|
|
5885
5893
|
} else {
|
|
5886
5894
|
flushNowOrSoon();
|
|
5887
5895
|
batchUpdates(() => {
|
|
5888
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5896
|
+
if (_optionalChain([options2, 'optionalAccess', _134 => _134.addToHistory])) {
|
|
5889
5897
|
addToUndoStack(
|
|
5890
5898
|
[{ type: "presence", data: oldValues }],
|
|
5891
5899
|
doNotBatchUpdates
|
|
@@ -6083,7 +6091,7 @@ function createRoom(options, config) {
|
|
|
6083
6091
|
if (process.env.NODE_ENV !== "production") {
|
|
6084
6092
|
const traces = /* @__PURE__ */ new Set();
|
|
6085
6093
|
for (const opId of message.opIds) {
|
|
6086
|
-
const trace = _optionalChain([context, 'access',
|
|
6094
|
+
const trace = _optionalChain([context, 'access', _135 => _135.opStackTraces, 'optionalAccess', _136 => _136.get, 'call', _137 => _137(opId)]);
|
|
6087
6095
|
if (trace) {
|
|
6088
6096
|
traces.add(trace);
|
|
6089
6097
|
}
|
|
@@ -6217,7 +6225,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6217
6225
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
6218
6226
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
6219
6227
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
6220
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
6228
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _138 => _138()]);
|
|
6221
6229
|
notifyStorageStatus();
|
|
6222
6230
|
eventHub.storageDidLoad.notify();
|
|
6223
6231
|
}
|
|
@@ -6436,7 +6444,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6436
6444
|
};
|
|
6437
6445
|
async function fetchCommentsApi(endpoint, params, options2) {
|
|
6438
6446
|
const authValue = await delegates.authenticate();
|
|
6439
|
-
return fetchClientApi(
|
|
6447
|
+
return fetchClientApi(endpoint, authValue, options2, params);
|
|
6440
6448
|
}
|
|
6441
6449
|
async function fetchCommentsJson(endpoint, options2, params) {
|
|
6442
6450
|
const response = await fetchCommentsApi(endpoint, params, options2);
|
|
@@ -6466,9 +6474,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6466
6474
|
}
|
|
6467
6475
|
async function getThreadsSince(options2) {
|
|
6468
6476
|
const response = await fetchCommentsApi(
|
|
6469
|
-
|
|
6477
|
+
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6470
6478
|
{
|
|
6471
|
-
since: _optionalChain([options2, 'optionalAccess',
|
|
6479
|
+
since: _optionalChain([options2, 'optionalAccess', _139 => _139.since, 'optionalAccess', _140 => _140.toISOString, 'call', _141 => _141()])
|
|
6472
6480
|
},
|
|
6473
6481
|
{
|
|
6474
6482
|
headers: {
|
|
@@ -6509,19 +6517,13 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6509
6517
|
}
|
|
6510
6518
|
async function getThreads(options2) {
|
|
6511
6519
|
let query;
|
|
6512
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6520
|
+
if (_optionalChain([options2, 'optionalAccess', _142 => _142.query])) {
|
|
6513
6521
|
query = objectToQuery(options2.query);
|
|
6514
6522
|
}
|
|
6515
6523
|
const response = await fetchCommentsApi(
|
|
6516
|
-
|
|
6517
|
-
{
|
|
6518
|
-
|
|
6519
|
-
},
|
|
6520
|
-
{
|
|
6521
|
-
headers: {
|
|
6522
|
-
"Content-Type": "application/json"
|
|
6523
|
-
}
|
|
6524
|
-
}
|
|
6524
|
+
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6525
|
+
{ query },
|
|
6526
|
+
{ headers: { "Content-Type": "application/json" } }
|
|
6525
6527
|
);
|
|
6526
6528
|
if (response.ok) {
|
|
6527
6529
|
const json = await response.json();
|
|
@@ -6546,7 +6548,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6546
6548
|
}
|
|
6547
6549
|
async function getThread(threadId) {
|
|
6548
6550
|
const response = await fetchCommentsApi(
|
|
6549
|
-
`/thread-with-notification/${threadId}`
|
|
6551
|
+
url`/v2/c/rooms/${config.roomId}/thread-with-notification/${threadId}`
|
|
6550
6552
|
);
|
|
6551
6553
|
if (response.ok) {
|
|
6552
6554
|
const json = await response.json();
|
|
@@ -6570,34 +6572,38 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6570
6572
|
threadId = createThreadId(),
|
|
6571
6573
|
attachmentIds
|
|
6572
6574
|
}) {
|
|
6573
|
-
const thread = await fetchCommentsJson(
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
id: threadId,
|
|
6580
|
-
comment: {
|
|
6581
|
-
id: commentId,
|
|
6582
|
-
body,
|
|
6583
|
-
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"
|
|
6584
6581
|
},
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6582
|
+
body: JSON.stringify({
|
|
6583
|
+
id: threadId,
|
|
6584
|
+
comment: {
|
|
6585
|
+
id: commentId,
|
|
6586
|
+
body,
|
|
6587
|
+
attachmentIds
|
|
6588
|
+
},
|
|
6589
|
+
metadata
|
|
6590
|
+
})
|
|
6591
|
+
}
|
|
6592
|
+
);
|
|
6588
6593
|
return convertToThreadData(thread);
|
|
6589
6594
|
}
|
|
6590
6595
|
async function deleteThread(threadId) {
|
|
6591
|
-
await fetchCommentsJson(
|
|
6592
|
-
|
|
6593
|
-
|
|
6596
|
+
await fetchCommentsJson(
|
|
6597
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}`,
|
|
6598
|
+
{ method: "DELETE" }
|
|
6599
|
+
);
|
|
6594
6600
|
}
|
|
6595
6601
|
async function editThreadMetadata({
|
|
6596
6602
|
metadata,
|
|
6597
6603
|
threadId
|
|
6598
6604
|
}) {
|
|
6599
6605
|
return await fetchCommentsJson(
|
|
6600
|
-
`/threads/${
|
|
6606
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/metadata`,
|
|
6601
6607
|
{
|
|
6602
6608
|
method: "POST",
|
|
6603
6609
|
headers: {
|
|
@@ -6609,18 +6615,14 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6609
6615
|
}
|
|
6610
6616
|
async function markThreadAsResolved(threadId) {
|
|
6611
6617
|
await fetchCommentsJson(
|
|
6612
|
-
`/threads/${
|
|
6613
|
-
{
|
|
6614
|
-
method: "POST"
|
|
6615
|
-
}
|
|
6618
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-resolved`,
|
|
6619
|
+
{ method: "POST" }
|
|
6616
6620
|
);
|
|
6617
6621
|
}
|
|
6618
6622
|
async function markThreadAsUnresolved(threadId) {
|
|
6619
6623
|
await fetchCommentsJson(
|
|
6620
|
-
`/threads/${
|
|
6621
|
-
{
|
|
6622
|
-
method: "POST"
|
|
6623
|
-
}
|
|
6624
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-unresolved`,
|
|
6625
|
+
{ method: "POST" }
|
|
6624
6626
|
);
|
|
6625
6627
|
}
|
|
6626
6628
|
async function createComment({
|
|
@@ -6630,7 +6632,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6630
6632
|
attachmentIds
|
|
6631
6633
|
}) {
|
|
6632
6634
|
const comment = await fetchCommentsJson(
|
|
6633
|
-
`/threads/${
|
|
6635
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments`,
|
|
6634
6636
|
{
|
|
6635
6637
|
method: "POST",
|
|
6636
6638
|
headers: {
|
|
@@ -6652,9 +6654,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6652
6654
|
attachmentIds
|
|
6653
6655
|
}) {
|
|
6654
6656
|
const comment = await fetchCommentsJson(
|
|
6655
|
-
`/threads/${
|
|
6656
|
-
commentId
|
|
6657
|
-
)}`,
|
|
6657
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`,
|
|
6658
6658
|
{
|
|
6659
6659
|
method: "POST",
|
|
6660
6660
|
headers: {
|
|
@@ -6673,12 +6673,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6673
6673
|
commentId
|
|
6674
6674
|
}) {
|
|
6675
6675
|
await fetchCommentsJson(
|
|
6676
|
-
`/threads/${
|
|
6677
|
-
|
|
6678
|
-
)}`,
|
|
6679
|
-
{
|
|
6680
|
-
method: "DELETE"
|
|
6681
|
-
}
|
|
6676
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`,
|
|
6677
|
+
{ method: "DELETE" }
|
|
6682
6678
|
);
|
|
6683
6679
|
}
|
|
6684
6680
|
async function addReaction({
|
|
@@ -6687,9 +6683,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6687
6683
|
emoji
|
|
6688
6684
|
}) {
|
|
6689
6685
|
const reaction = await fetchCommentsJson(
|
|
6690
|
-
`/threads/${
|
|
6691
|
-
commentId
|
|
6692
|
-
)}/reactions`,
|
|
6686
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions`,
|
|
6693
6687
|
{
|
|
6694
6688
|
method: "POST",
|
|
6695
6689
|
headers: {
|
|
@@ -6706,12 +6700,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6706
6700
|
emoji
|
|
6707
6701
|
}) {
|
|
6708
6702
|
await fetchCommentsJson(
|
|
6709
|
-
`/threads/${
|
|
6710
|
-
|
|
6711
|
-
)}/reactions/${encodeURIComponent(emoji)}`,
|
|
6712
|
-
{
|
|
6713
|
-
method: "DELETE"
|
|
6714
|
-
}
|
|
6703
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions/${emoji}`,
|
|
6704
|
+
{ method: "DELETE" }
|
|
6715
6705
|
);
|
|
6716
6706
|
}
|
|
6717
6707
|
function prepareAttachment(file) {
|
|
@@ -6731,11 +6721,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6731
6721
|
`Upload of attachment ${attachment.id} was aborted.`,
|
|
6732
6722
|
"AbortError"
|
|
6733
6723
|
) : void 0;
|
|
6734
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6724
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _143 => _143.aborted])) {
|
|
6735
6725
|
throw abortError;
|
|
6736
6726
|
}
|
|
6737
6727
|
const handleRetryError = (err) => {
|
|
6738
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6728
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _144 => _144.aborted])) {
|
|
6739
6729
|
throw abortError;
|
|
6740
6730
|
}
|
|
6741
6731
|
if (err instanceof CommentsApiError && err.status === 413) {
|
|
@@ -6746,7 +6736,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6746
6736
|
if (attachment.size <= ATTACHMENT_PART_SIZE) {
|
|
6747
6737
|
return autoRetry(
|
|
6748
6738
|
() => fetchCommentsJson(
|
|
6749
|
-
`/attachments/${
|
|
6739
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/upload/${encodeURIComponent(attachment.name)}`,
|
|
6750
6740
|
{
|
|
6751
6741
|
method: "PUT",
|
|
6752
6742
|
body: attachment.file,
|
|
@@ -6765,7 +6755,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6765
6755
|
const uploadedParts = [];
|
|
6766
6756
|
const createMultiPartUpload = await autoRetry(
|
|
6767
6757
|
() => fetchCommentsJson(
|
|
6768
|
-
`/attachments/${
|
|
6758
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
6769
6759
|
{
|
|
6770
6760
|
method: "POST",
|
|
6771
6761
|
signal: abortSignal
|
|
@@ -6781,7 +6771,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6781
6771
|
try {
|
|
6782
6772
|
uploadId = createMultiPartUpload.uploadId;
|
|
6783
6773
|
const parts = splitFileIntoParts(attachment.file);
|
|
6784
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6774
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _145 => _145.aborted])) {
|
|
6785
6775
|
throw abortError;
|
|
6786
6776
|
}
|
|
6787
6777
|
const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
|
|
@@ -6791,7 +6781,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6791
6781
|
uploadedPartsPromises.push(
|
|
6792
6782
|
autoRetry(
|
|
6793
6783
|
() => fetchCommentsJson(
|
|
6794
|
-
`/attachments/${
|
|
6784
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${createMultiPartUpload.uploadId}/${String(partNumber)}`,
|
|
6795
6785
|
{
|
|
6796
6786
|
method: "PUT",
|
|
6797
6787
|
body: part,
|
|
@@ -6806,14 +6796,14 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6806
6796
|
}
|
|
6807
6797
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
6808
6798
|
}
|
|
6809
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6799
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _146 => _146.aborted])) {
|
|
6810
6800
|
throw abortError;
|
|
6811
6801
|
}
|
|
6812
6802
|
const sortedUploadedParts = uploadedParts.sort(
|
|
6813
6803
|
(a, b) => a.partNumber - b.partNumber
|
|
6814
6804
|
);
|
|
6815
6805
|
return fetchCommentsJson(
|
|
6816
|
-
`/attachments/${
|
|
6806
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
|
|
6817
6807
|
{
|
|
6818
6808
|
method: "POST",
|
|
6819
6809
|
headers: {
|
|
@@ -6824,10 +6814,10 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6824
6814
|
}
|
|
6825
6815
|
);
|
|
6826
6816
|
} catch (error3) {
|
|
6827
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
6817
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _147 => _147.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
6828
6818
|
try {
|
|
6829
6819
|
await fetchCommentsApi(
|
|
6830
|
-
`/attachments/${
|
|
6820
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
6831
6821
|
void 0,
|
|
6832
6822
|
{
|
|
6833
6823
|
method: "DELETE"
|
|
@@ -6842,7 +6832,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6842
6832
|
}
|
|
6843
6833
|
async function getAttachmentUrls(attachmentIds) {
|
|
6844
6834
|
const { urls } = await fetchCommentsJson(
|
|
6845
|
-
|
|
6835
|
+
url`/v2/c/rooms/${config.roomId}/attachments/presigned-urls`,
|
|
6846
6836
|
{
|
|
6847
6837
|
method: "POST",
|
|
6848
6838
|
headers: {
|
|
@@ -6858,7 +6848,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6858
6848
|
const attachmentIds = batchedAttachmentIds.flat();
|
|
6859
6849
|
const attachmentUrls = await getAttachmentUrls(attachmentIds);
|
|
6860
6850
|
return attachmentUrls.map(
|
|
6861
|
-
(
|
|
6851
|
+
(url2) => _nullishCoalesce(url2, () => ( new Error("There was an error while getting this attachment's URL")))
|
|
6862
6852
|
);
|
|
6863
6853
|
},
|
|
6864
6854
|
{ delay: GET_ATTACHMENT_URLS_BATCH_DELAY }
|
|
@@ -6869,12 +6859,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6869
6859
|
}
|
|
6870
6860
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6871
6861
|
const authValue = await delegates.authenticate();
|
|
6872
|
-
const response = await fetchClientApi(
|
|
6873
|
-
config.roomId,
|
|
6874
|
-
endpoint,
|
|
6875
|
-
authValue,
|
|
6876
|
-
options2
|
|
6877
|
-
);
|
|
6862
|
+
const response = await fetchClientApi(endpoint, authValue, options2);
|
|
6878
6863
|
if (!response.ok) {
|
|
6879
6864
|
if (response.status >= 400 && response.status < 600) {
|
|
6880
6865
|
let error3;
|
|
@@ -6904,12 +6889,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6904
6889
|
}
|
|
6905
6890
|
function getNotificationSettings() {
|
|
6906
6891
|
return fetchNotificationsJson(
|
|
6907
|
-
|
|
6892
|
+
url`/v2/c/rooms/${config.roomId}/notification-settings`
|
|
6908
6893
|
);
|
|
6909
6894
|
}
|
|
6910
6895
|
function updateNotificationSettings(settings) {
|
|
6911
6896
|
return fetchNotificationsJson(
|
|
6912
|
-
|
|
6897
|
+
url`/v2/c/rooms/${config.roomId}/notification-settings`,
|
|
6913
6898
|
{
|
|
6914
6899
|
method: "POST",
|
|
6915
6900
|
body: JSON.stringify(settings),
|
|
@@ -6920,13 +6905,16 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6920
6905
|
);
|
|
6921
6906
|
}
|
|
6922
6907
|
async function markInboxNotificationsAsRead(inboxNotificationIds) {
|
|
6923
|
-
await fetchNotificationsJson(
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
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
|
+
);
|
|
6930
6918
|
}
|
|
6931
6919
|
const batchedMarkInboxNotificationsAsRead = new Batch(
|
|
6932
6920
|
async (batchedInboxNotificationIds) => {
|
|
@@ -6943,7 +6931,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6943
6931
|
{
|
|
6944
6932
|
[kInternal]: {
|
|
6945
6933
|
get presenceBuffer() {
|
|
6946
|
-
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)));
|
|
6947
6935
|
},
|
|
6948
6936
|
// prettier-ignore
|
|
6949
6937
|
get undoStack() {
|
|
@@ -7127,7 +7115,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
7127
7115
|
}
|
|
7128
7116
|
if (isLiveNode(first)) {
|
|
7129
7117
|
const node = first;
|
|
7130
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7118
|
+
if (_optionalChain([options, 'optionalAccess', _151 => _151.isDeep])) {
|
|
7131
7119
|
const storageCallback = second;
|
|
7132
7120
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7133
7121
|
} else {
|
|
@@ -7157,19 +7145,19 @@ function makeCreateSocketDelegateForRoom(roomId, baseUrl, WebSocketPolyfill) {
|
|
|
7157
7145
|
"To use Liveblocks client in a non-DOM environment, you need to provide a WebSocket polyfill."
|
|
7158
7146
|
);
|
|
7159
7147
|
}
|
|
7160
|
-
const
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7148
|
+
const url2 = new URL(baseUrl);
|
|
7149
|
+
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
7150
|
+
url2.pathname = "/v7";
|
|
7151
|
+
url2.searchParams.set("roomId", roomId);
|
|
7164
7152
|
if (authValue.type === "secret") {
|
|
7165
|
-
|
|
7153
|
+
url2.searchParams.set("tok", authValue.token.raw);
|
|
7166
7154
|
} else if (authValue.type === "public") {
|
|
7167
|
-
|
|
7155
|
+
url2.searchParams.set("pubkey", authValue.publicApiKey);
|
|
7168
7156
|
} else {
|
|
7169
7157
|
return assertNever(authValue, "Unhandled case");
|
|
7170
7158
|
}
|
|
7171
|
-
|
|
7172
|
-
return new ws(
|
|
7159
|
+
url2.searchParams.set("version", PKG_VERSION || "dev");
|
|
7160
|
+
return new ws(url2.toString());
|
|
7173
7161
|
};
|
|
7174
7162
|
}
|
|
7175
7163
|
|
|
@@ -7254,12 +7242,12 @@ function createClient(options) {
|
|
|
7254
7242
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7255
7243
|
roomId,
|
|
7256
7244
|
baseUrl,
|
|
7257
|
-
_optionalChain([clientOptions, 'access',
|
|
7245
|
+
_optionalChain([clientOptions, 'access', _152 => _152.polyfills, 'optionalAccess', _153 => _153.WebSocket])
|
|
7258
7246
|
),
|
|
7259
7247
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7260
7248
|
})),
|
|
7261
7249
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7262
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7250
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _154 => _154.unstable_batchedUpdates]),
|
|
7263
7251
|
baseUrl,
|
|
7264
7252
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7265
7253
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7275,7 +7263,7 @@ function createClient(options) {
|
|
|
7275
7263
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7276
7264
|
if (shouldConnect) {
|
|
7277
7265
|
if (typeof atob === "undefined") {
|
|
7278
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7266
|
+
if (_optionalChain([clientOptions, 'access', _155 => _155.polyfills, 'optionalAccess', _156 => _156.atob]) === void 0) {
|
|
7279
7267
|
throw new Error(
|
|
7280
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"
|
|
7281
7269
|
);
|
|
@@ -7287,7 +7275,7 @@ function createClient(options) {
|
|
|
7287
7275
|
return leaseRoom(newRoomDetails);
|
|
7288
7276
|
}
|
|
7289
7277
|
function getRoom(roomId) {
|
|
7290
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7278
|
+
const room = _optionalChain([roomsById, 'access', _157 => _157.get, 'call', _158 => _158(roomId), 'optionalAccess', _159 => _159.room]);
|
|
7291
7279
|
return room ? room : null;
|
|
7292
7280
|
}
|
|
7293
7281
|
function logout() {
|
|
@@ -7311,7 +7299,7 @@ function createClient(options) {
|
|
|
7311
7299
|
getThreadsSince
|
|
7312
7300
|
} = createNotificationsApi({
|
|
7313
7301
|
baseUrl,
|
|
7314
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7302
|
+
fetcher: _optionalChain([clientOptions, 'access', _160 => _160.polyfills, 'optionalAccess', _161 => _161.fetch]) || /* istanbul ignore next */
|
|
7315
7303
|
fetch,
|
|
7316
7304
|
authManager,
|
|
7317
7305
|
currentUserIdStore
|
|
@@ -7324,7 +7312,7 @@ function createClient(options) {
|
|
|
7324
7312
|
const batchedResolveUsers = new Batch(
|
|
7325
7313
|
async (batchedUserIds) => {
|
|
7326
7314
|
const userIds = batchedUserIds.flat();
|
|
7327
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7315
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _162 => _162({ userIds })]);
|
|
7328
7316
|
warnIfNoResolveUsers();
|
|
7329
7317
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7330
7318
|
},
|
|
@@ -7339,7 +7327,7 @@ function createClient(options) {
|
|
|
7339
7327
|
const batchedResolveRoomsInfo = new Batch(
|
|
7340
7328
|
async (batchedRoomIds) => {
|
|
7341
7329
|
const roomIds = batchedRoomIds.flat();
|
|
7342
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7330
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _163 => _163({ roomIds })]);
|
|
7343
7331
|
warnIfNoResolveRoomsInfo();
|
|
7344
7332
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7345
7333
|
},
|
|
@@ -7431,7 +7419,7 @@ function createDevelopmentWarning(condition, ...args) {
|
|
|
7431
7419
|
|
|
7432
7420
|
// src/comments/comment-body.ts
|
|
7433
7421
|
function isCommentBodyParagraph(element) {
|
|
7434
|
-
return "type" in element && element.type === "
|
|
7422
|
+
return "type" in element && element.type === "paragraph";
|
|
7435
7423
|
}
|
|
7436
7424
|
function isCommentBodyText(element) {
|
|
7437
7425
|
return !("type" in element) && "text" in element && typeof element.text === "string";
|
|
@@ -7455,7 +7443,7 @@ var commentBodyElementsTypes = {
|
|
|
7455
7443
|
mention: "inline"
|
|
7456
7444
|
};
|
|
7457
7445
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7458
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7446
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _164 => _164.content])) {
|
|
7459
7447
|
return;
|
|
7460
7448
|
}
|
|
7461
7449
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7465,13 +7453,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7465
7453
|
for (const block of body.content) {
|
|
7466
7454
|
if (type === "all" || type === "block") {
|
|
7467
7455
|
if (guard(block)) {
|
|
7468
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7456
|
+
_optionalChain([visitor, 'optionalCall', _165 => _165(block)]);
|
|
7469
7457
|
}
|
|
7470
7458
|
}
|
|
7471
7459
|
if (type === "all" || type === "inline") {
|
|
7472
7460
|
for (const inline of block.children) {
|
|
7473
7461
|
if (guard(inline)) {
|
|
7474
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7462
|
+
_optionalChain([visitor, 'optionalCall', _166 => _166(inline)]);
|
|
7475
7463
|
}
|
|
7476
7464
|
}
|
|
7477
7465
|
}
|
|
@@ -7496,7 +7484,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7496
7484
|
userIds
|
|
7497
7485
|
});
|
|
7498
7486
|
for (const [index, userId] of userIds.entries()) {
|
|
7499
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7487
|
+
const user = _optionalChain([users, 'optionalAccess', _167 => _167[index]]);
|
|
7500
7488
|
if (user) {
|
|
7501
7489
|
resolvedUsers.set(userId, user);
|
|
7502
7490
|
}
|
|
@@ -7606,11 +7594,11 @@ var MarkdownSafeString = class {
|
|
|
7606
7594
|
function markdown(strings, ...values) {
|
|
7607
7595
|
return new MarkdownSafeString(strings, values);
|
|
7608
7596
|
}
|
|
7609
|
-
function toAbsoluteUrl(
|
|
7610
|
-
if (
|
|
7611
|
-
return
|
|
7612
|
-
} else if (
|
|
7613
|
-
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;
|
|
7614
7602
|
}
|
|
7615
7603
|
return;
|
|
7616
7604
|
}
|
|
@@ -7619,7 +7607,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7619
7607
|
text: ({ element }) => element.text,
|
|
7620
7608
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7621
7609
|
mention: ({ element, user }) => {
|
|
7622
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7610
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _168 => _168.name]), () => ( element.id))}`;
|
|
7623
7611
|
}
|
|
7624
7612
|
};
|
|
7625
7613
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7649,7 +7637,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7649
7637
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7650
7638
|
},
|
|
7651
7639
|
mention: ({ element, user }) => {
|
|
7652
|
-
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>`;
|
|
7653
7641
|
}
|
|
7654
7642
|
};
|
|
7655
7643
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7679,19 +7667,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7679
7667
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7680
7668
|
},
|
|
7681
7669
|
mention: ({ element, user }) => {
|
|
7682
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7670
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _170 => _170.name]), () => ( element.id))}`;
|
|
7683
7671
|
}
|
|
7684
7672
|
};
|
|
7685
7673
|
async function stringifyCommentBody(body, options) {
|
|
7686
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7687
|
-
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")));
|
|
7688
7676
|
const elements = {
|
|
7689
7677
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7690
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7678
|
+
..._optionalChain([options, 'optionalAccess', _173 => _173.elements])
|
|
7691
7679
|
};
|
|
7692
7680
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7693
7681
|
body,
|
|
7694
|
-
_optionalChain([options, 'optionalAccess',
|
|
7682
|
+
_optionalChain([options, 'optionalAccess', _174 => _174.resolveUsers])
|
|
7695
7683
|
);
|
|
7696
7684
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7697
7685
|
switch (block.type) {
|
|
@@ -7966,12 +7954,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7966
7954
|
}
|
|
7967
7955
|
const newState = Object.assign({}, state);
|
|
7968
7956
|
for (const key in update.updates) {
|
|
7969
|
-
if (_optionalChain([update, 'access',
|
|
7957
|
+
if (_optionalChain([update, 'access', _175 => _175.updates, 'access', _176 => _176[key], 'optionalAccess', _177 => _177.type]) === "update") {
|
|
7970
7958
|
const val = update.node.get(key);
|
|
7971
7959
|
if (val !== void 0) {
|
|
7972
7960
|
newState[key] = lsonToJson(val);
|
|
7973
7961
|
}
|
|
7974
|
-
} else if (_optionalChain([update, 'access',
|
|
7962
|
+
} else if (_optionalChain([update, 'access', _178 => _178.updates, 'access', _179 => _179[key], 'optionalAccess', _180 => _180.type]) === "delete") {
|
|
7975
7963
|
delete newState[key];
|
|
7976
7964
|
}
|
|
7977
7965
|
}
|
|
@@ -8032,12 +8020,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8032
8020
|
}
|
|
8033
8021
|
const newState = Object.assign({}, state);
|
|
8034
8022
|
for (const key in update.updates) {
|
|
8035
|
-
if (_optionalChain([update, 'access',
|
|
8023
|
+
if (_optionalChain([update, 'access', _181 => _181.updates, 'access', _182 => _182[key], 'optionalAccess', _183 => _183.type]) === "update") {
|
|
8036
8024
|
const value = update.node.get(key);
|
|
8037
8025
|
if (value !== void 0) {
|
|
8038
8026
|
newState[key] = lsonToJson(value);
|
|
8039
8027
|
}
|
|
8040
|
-
} else if (_optionalChain([update, 'access',
|
|
8028
|
+
} else if (_optionalChain([update, 'access', _184 => _184.updates, 'access', _185 => _185[key], 'optionalAccess', _186 => _186.type]) === "delete") {
|
|
8041
8029
|
delete newState[key];
|
|
8042
8030
|
}
|
|
8043
8031
|
}
|
|
@@ -8296,5 +8284,7 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8296
8284
|
|
|
8297
8285
|
|
|
8298
8286
|
|
|
8299
|
-
|
|
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;
|
|
8300
8290
|
//# sourceMappingURL=index.js.map
|