@liveblocks/core 2.10.0 → 2.10.1-react19
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 +155 -50
- package/dist/index.d.ts +155 -50
- package/dist/index.js +634 -577
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +573 -516
- 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.10.
|
|
9
|
+
var PKG_VERSION = "2.10.1-react19";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -363,10 +363,39 @@ var FSM = class {
|
|
|
363
363
|
this.enterFns.set(nameOrPattern, enterFn);
|
|
364
364
|
return this;
|
|
365
365
|
}
|
|
366
|
-
|
|
366
|
+
/**
|
|
367
|
+
* Defines a promise-based state. When the state is entered, the promise is
|
|
368
|
+
* created. When the promise resolves, the machine will transition to the
|
|
369
|
+
* provided `onOK` target state. When the promise rejects, the machine will
|
|
370
|
+
* transition to the `onError` target state.
|
|
371
|
+
*
|
|
372
|
+
* Optionally, a `maxTimeout` can be set. If the timeout happens before the
|
|
373
|
+
* promise is settled, then the machine will also transition to the `onError`
|
|
374
|
+
* target state.
|
|
375
|
+
*
|
|
376
|
+
* @param stateOrPattern The state name, or state group pattern name.
|
|
377
|
+
* @param promiseFn The callback to be invoked when the state is entered.
|
|
378
|
+
* @param onOK The state to transition to when the promise resolves.
|
|
379
|
+
* @param onError The state to transition to when the promise
|
|
380
|
+
* rejects, or when the timeout happens before the
|
|
381
|
+
* promise has been settled.
|
|
382
|
+
* @param maxTimeout Optional timeout in milliseconds.
|
|
383
|
+
*
|
|
384
|
+
* When the promise callback function is invoked, it's provided with an
|
|
385
|
+
* AbortSignal (2nd argument).
|
|
386
|
+
* If a state transition happens while the promise is pending (for example,
|
|
387
|
+
* an event, or a timeout happens), then an abort signal will be used to
|
|
388
|
+
* indicate this. Implementers can use this abort signal to terminate the
|
|
389
|
+
* in-flight promise, or ignore its results, etc.
|
|
390
|
+
*/
|
|
391
|
+
onEnterAsync(nameOrPattern, promiseFn, onOK, onError, maxTimeout) {
|
|
367
392
|
return this.onEnter(nameOrPattern, () => {
|
|
368
393
|
const abortController = new AbortController();
|
|
369
394
|
const signal = abortController.signal;
|
|
395
|
+
const timeoutId = maxTimeout ? setTimeout(() => {
|
|
396
|
+
const reason = new Error("Timed out");
|
|
397
|
+
this.transition({ type: "ASYNC_ERROR", reason }, onError);
|
|
398
|
+
}, maxTimeout) : void 0;
|
|
370
399
|
let done = false;
|
|
371
400
|
void promiseFn(this.currentContext.current, signal).then(
|
|
372
401
|
// On OK
|
|
@@ -385,6 +414,7 @@ var FSM = class {
|
|
|
385
414
|
}
|
|
386
415
|
);
|
|
387
416
|
return () => {
|
|
417
|
+
clearTimeout(timeoutId);
|
|
388
418
|
if (!done) {
|
|
389
419
|
abortController.abort();
|
|
390
420
|
}
|
|
@@ -457,11 +487,11 @@ var FSM = class {
|
|
|
457
487
|
* Like `.addTransition()`, but takes an (anonymous) transition whenever the
|
|
458
488
|
* timer fires.
|
|
459
489
|
*
|
|
460
|
-
* @param stateOrPattern
|
|
461
|
-
* @param after
|
|
462
|
-
*
|
|
463
|
-
*
|
|
464
|
-
* @param target
|
|
490
|
+
* @param stateOrPattern The state name, or state group pattern name.
|
|
491
|
+
* @param after Number of milliseconds after which to take the
|
|
492
|
+
* transition. If in the mean time, another transition
|
|
493
|
+
* is taken, the timer will get cancelled.
|
|
494
|
+
* @param target The target state to go to.
|
|
465
495
|
*/
|
|
466
496
|
addTimedTransition(stateOrPattern, after2, target) {
|
|
467
497
|
return this.onEnter(stateOrPattern, () => {
|
|
@@ -1520,8 +1550,8 @@ function prepareAuthentication(authOptions) {
|
|
|
1520
1550
|
"Invalid Liveblocks client options. Please provide either a `publicApiKey` or `authEndpoint` option. They cannot both be empty. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClient"
|
|
1521
1551
|
);
|
|
1522
1552
|
}
|
|
1523
|
-
async function fetchAuthEndpoint(
|
|
1524
|
-
const res = await
|
|
1553
|
+
async function fetchAuthEndpoint(fetch, endpoint, body) {
|
|
1554
|
+
const res = await fetch(endpoint, {
|
|
1525
1555
|
method: "POST",
|
|
1526
1556
|
headers: {
|
|
1527
1557
|
"Content-Type": "application/json"
|
|
@@ -2059,12 +2089,36 @@ function convertToInboxNotificationDeleteInfo(data) {
|
|
|
2059
2089
|
};
|
|
2060
2090
|
}
|
|
2061
2091
|
|
|
2062
|
-
// src/
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2092
|
+
// src/lib/autoRetry.ts
|
|
2093
|
+
var HttpError = class extends Error {
|
|
2094
|
+
constructor(message, status, details) {
|
|
2095
|
+
super(message);
|
|
2096
|
+
this.message = message;
|
|
2097
|
+
this.status = status;
|
|
2098
|
+
this.details = details;
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
var DONT_RETRY_4XX = (x) => x instanceof HttpError && x.status >= 400 && x.status < 500;
|
|
2102
|
+
async function autoRetry(promiseFn, maxTries, backoff, shouldStopRetrying = DONT_RETRY_4XX) {
|
|
2103
|
+
const fallbackBackoff = backoff.length > 0 ? backoff[backoff.length - 1] : 0;
|
|
2104
|
+
let attempt = 0;
|
|
2105
|
+
while (true) {
|
|
2106
|
+
attempt++;
|
|
2107
|
+
try {
|
|
2108
|
+
return await promiseFn();
|
|
2109
|
+
} catch (err) {
|
|
2110
|
+
if (shouldStopRetrying(err)) {
|
|
2111
|
+
throw err;
|
|
2112
|
+
}
|
|
2113
|
+
if (attempt >= maxTries) {
|
|
2114
|
+
throw new Error(`Failed after ${maxTries} attempts: ${String(err)}`);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
|
|
2118
|
+
warn(
|
|
2119
|
+
`Attempt ${attempt} was unsuccessful. Retrying in ${delay} milliseconds.`
|
|
2120
|
+
);
|
|
2121
|
+
await wait(delay);
|
|
2068
2122
|
}
|
|
2069
2123
|
}
|
|
2070
2124
|
|
|
@@ -2091,51 +2145,79 @@ function url(strings, ...values) {
|
|
|
2091
2145
|
);
|
|
2092
2146
|
}
|
|
2093
2147
|
|
|
2094
|
-
// src/
|
|
2095
|
-
function
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2148
|
+
// src/http-client.ts
|
|
2149
|
+
function getBearerTokenFromAuthValue(authValue) {
|
|
2150
|
+
if (authValue.type === "public") {
|
|
2151
|
+
return authValue.publicApiKey;
|
|
2152
|
+
} else {
|
|
2153
|
+
return authValue.token.raw;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
var HttpClient = class {
|
|
2157
|
+
constructor(baseUrl, fetchPolyfill, authCallback) {
|
|
2158
|
+
this._baseUrl = baseUrl;
|
|
2159
|
+
this._fetchPolyfill = fetchPolyfill;
|
|
2160
|
+
this._authCallback = authCallback;
|
|
2161
|
+
}
|
|
2162
|
+
// ------------------------------------------------------------------
|
|
2163
|
+
// Public methods
|
|
2164
|
+
// ------------------------------------------------------------------
|
|
2165
|
+
/**
|
|
2166
|
+
* Constructs and makes the HTTP request, but does not handle the response.
|
|
2167
|
+
*
|
|
2168
|
+
* This is what .rawFetch() does: 👈 This method!
|
|
2169
|
+
* 1. Set Content-Type header
|
|
2170
|
+
* 2. Set Authorization header
|
|
2171
|
+
* 3. Call the callback to obtain the `authValue` to use in the Authorization header
|
|
2172
|
+
*
|
|
2173
|
+
* This is what .fetch() does ON TOP of that:
|
|
2174
|
+
* 4. Parse response body as Json
|
|
2175
|
+
* 5. ...but silently return `{}` if that parsing fails
|
|
2176
|
+
* 6. Throw HttpError if response is an error
|
|
2177
|
+
*/
|
|
2178
|
+
async rawFetch(endpoint, options, params) {
|
|
2102
2179
|
if (!endpoint.startsWith("/v2/c/")) {
|
|
2103
|
-
raise("
|
|
2180
|
+
raise("This client can only be used to make /v2/c/* requests");
|
|
2104
2181
|
}
|
|
2105
|
-
const
|
|
2106
|
-
|
|
2107
|
-
});
|
|
2108
|
-
if (authValue.type === "secret" && authValue.token.parsed.k === "acc" /* ACCESS_TOKEN */) {
|
|
2109
|
-
const userId = authValue.token.parsed.uid;
|
|
2110
|
-
currentUserIdStore.set(() => userId);
|
|
2111
|
-
}
|
|
2112
|
-
const url2 = urljoin(baseUrl, endpoint, params);
|
|
2113
|
-
const response = await fetcher(url2.toString(), {
|
|
2182
|
+
const url2 = urljoin(this._baseUrl, endpoint, params);
|
|
2183
|
+
return await this._fetchPolyfill(url2, {
|
|
2114
2184
|
...options,
|
|
2115
2185
|
headers: {
|
|
2186
|
+
// These headers are default, but can be overriden by custom headers
|
|
2187
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
2188
|
+
// Possible header overrides
|
|
2116
2189
|
..._optionalChain([options, 'optionalAccess', _45 => _45.headers]),
|
|
2117
|
-
|
|
2190
|
+
// Cannot be overriden by custom headers
|
|
2191
|
+
Authorization: `Bearer ${getBearerTokenFromAuthValue(await this._authCallback())}`,
|
|
2118
2192
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
2119
2193
|
}
|
|
2120
2194
|
});
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Constructs, makes the HTTP request, and handles the response by parsing
|
|
2198
|
+
* JSON and/or throwing an HttpError if it failed.
|
|
2199
|
+
*
|
|
2200
|
+
* This is what .rawFetch() does:
|
|
2201
|
+
* 1. Set Content-Type header
|
|
2202
|
+
* 2. Set Authorization header
|
|
2203
|
+
* 3. Call the callback to obtain the `authValue` to use in the Authorization header
|
|
2204
|
+
*
|
|
2205
|
+
* This is what .fetch() does ON TOP of that: 👈 This method!
|
|
2206
|
+
* 4. Parse response body as Json
|
|
2207
|
+
* 5. ...but silently return `{}` if that parsing fails (🤔)
|
|
2208
|
+
* 6. Throw HttpError if response is an error
|
|
2209
|
+
*/
|
|
2210
|
+
async fetch(endpoint, options, params) {
|
|
2211
|
+
const response = await this.rawFetch(endpoint, options, params);
|
|
2121
2212
|
if (!response.ok) {
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
response.status,
|
|
2129
|
-
errorBody
|
|
2130
|
-
);
|
|
2131
|
-
} catch (e3) {
|
|
2132
|
-
error3 = new NotificationsApiError(
|
|
2133
|
-
response.statusText,
|
|
2134
|
-
response.status
|
|
2135
|
-
);
|
|
2136
|
-
}
|
|
2137
|
-
throw error3;
|
|
2213
|
+
let error3;
|
|
2214
|
+
try {
|
|
2215
|
+
const errorBody = await response.json();
|
|
2216
|
+
error3 = new HttpError(errorBody.message, response.status, errorBody);
|
|
2217
|
+
} catch (e3) {
|
|
2218
|
+
error3 = new HttpError(response.statusText, response.status);
|
|
2138
2219
|
}
|
|
2220
|
+
throw error3;
|
|
2139
2221
|
}
|
|
2140
2222
|
let body;
|
|
2141
2223
|
try {
|
|
@@ -2145,9 +2227,103 @@ function createNotificationsApi({
|
|
|
2145
2227
|
}
|
|
2146
2228
|
return body;
|
|
2147
2229
|
}
|
|
2230
|
+
/**
|
|
2231
|
+
* Makes a GET request and returns the raw response.
|
|
2232
|
+
* Won't throw if the reponse is a non-2xx.
|
|
2233
|
+
* @deprecated Ideally, use .get() instead.
|
|
2234
|
+
*/
|
|
2235
|
+
async rawGet(endpoint, params, options) {
|
|
2236
|
+
return await this.rawFetch(endpoint, options, params);
|
|
2237
|
+
}
|
|
2238
|
+
/**
|
|
2239
|
+
* Makes a POST request and returns the raw response.
|
|
2240
|
+
* Won't throw if the reponse is a non-2xx.
|
|
2241
|
+
* @deprecated Ideally, use .post() instead.
|
|
2242
|
+
*/
|
|
2243
|
+
async rawPost(endpoint, body) {
|
|
2244
|
+
return await this.rawFetch(endpoint, {
|
|
2245
|
+
method: "POST",
|
|
2246
|
+
body: JSON.stringify(body)
|
|
2247
|
+
});
|
|
2248
|
+
}
|
|
2249
|
+
/**
|
|
2250
|
+
* Makes a DELETE request and returns the raw response.
|
|
2251
|
+
* Won't throw if the reponse is a non-2xx.
|
|
2252
|
+
* @deprecated Ideally, use .delete() instead.
|
|
2253
|
+
*/
|
|
2254
|
+
async rawDelete(endpoint) {
|
|
2255
|
+
return await this.rawFetch(endpoint, { method: "DELETE" });
|
|
2256
|
+
}
|
|
2257
|
+
/**
|
|
2258
|
+
* Makes a GET request, and return the JSON response.
|
|
2259
|
+
* Will throw if the reponse is a non-2xx.
|
|
2260
|
+
*/
|
|
2261
|
+
async get(endpoint, params, options) {
|
|
2262
|
+
return await this.fetch(endpoint, options, params);
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Makes a POST request, and return the JSON response.
|
|
2266
|
+
* Will throw if the reponse is a non-2xx.
|
|
2267
|
+
*/
|
|
2268
|
+
async post(endpoint, body, options, params) {
|
|
2269
|
+
return await this.fetch(
|
|
2270
|
+
endpoint,
|
|
2271
|
+
{
|
|
2272
|
+
...options,
|
|
2273
|
+
method: "POST",
|
|
2274
|
+
body: JSON.stringify(body)
|
|
2275
|
+
},
|
|
2276
|
+
params
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Makes a DELETE request, and return the JSON response.
|
|
2281
|
+
* Will throw if the reponse is a non-2xx.
|
|
2282
|
+
*/
|
|
2283
|
+
async delete(endpoint) {
|
|
2284
|
+
return await this.fetch(endpoint, { method: "DELETE" });
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2287
|
+
* Makes a PUT request for a Blob body, and return the JSON response.
|
|
2288
|
+
* Will throw if the reponse is a non-2xx.
|
|
2289
|
+
*/
|
|
2290
|
+
async putBlob(endpoint, blob, params, options) {
|
|
2291
|
+
return await this.fetch(
|
|
2292
|
+
endpoint,
|
|
2293
|
+
{
|
|
2294
|
+
...options,
|
|
2295
|
+
method: "PUT",
|
|
2296
|
+
headers: {
|
|
2297
|
+
"Content-Type": "application/octet-stream"
|
|
2298
|
+
},
|
|
2299
|
+
body: blob
|
|
2300
|
+
},
|
|
2301
|
+
params
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
|
|
2306
|
+
// src/notifications.ts
|
|
2307
|
+
function createNotificationsApi({
|
|
2308
|
+
baseUrl,
|
|
2309
|
+
authManager,
|
|
2310
|
+
currentUserIdStore,
|
|
2311
|
+
fetchPolyfill
|
|
2312
|
+
}) {
|
|
2313
|
+
async function getAuthValue() {
|
|
2314
|
+
const authValue = await authManager.getAuthValue({
|
|
2315
|
+
requestedScope: "comments:read"
|
|
2316
|
+
});
|
|
2317
|
+
if (authValue.type === "secret" && authValue.token.parsed.k === "acc" /* ACCESS_TOKEN */) {
|
|
2318
|
+
const userId = authValue.token.parsed.uid;
|
|
2319
|
+
currentUserIdStore.set(() => userId);
|
|
2320
|
+
}
|
|
2321
|
+
return authValue;
|
|
2322
|
+
}
|
|
2323
|
+
const httpClient = new HttpClient(baseUrl, fetchPolyfill, getAuthValue);
|
|
2148
2324
|
async function getInboxNotifications(options) {
|
|
2149
2325
|
const PAGE_SIZE = 50;
|
|
2150
|
-
const json = await
|
|
2326
|
+
const json = await httpClient.get(url`/v2/c/inbox-notifications`, {
|
|
2151
2327
|
cursor: _optionalChain([options, 'optionalAccess', _46 => _46.cursor]),
|
|
2152
2328
|
limit: PAGE_SIZE
|
|
2153
2329
|
});
|
|
@@ -2160,10 +2336,12 @@ function createNotificationsApi({
|
|
|
2160
2336
|
requestedAt: new Date(json.meta.requestedAt)
|
|
2161
2337
|
};
|
|
2162
2338
|
}
|
|
2163
|
-
async function getInboxNotificationsSince(
|
|
2164
|
-
const json = await
|
|
2165
|
-
|
|
2166
|
-
|
|
2339
|
+
async function getInboxNotificationsSince(options) {
|
|
2340
|
+
const json = await httpClient.get(
|
|
2341
|
+
url`/v2/c/inbox-notifications/delta`,
|
|
2342
|
+
{ since: options.since.toISOString() },
|
|
2343
|
+
{ signal: _optionalChain([options, 'optionalAccess', _47 => _47.signal]) }
|
|
2344
|
+
);
|
|
2167
2345
|
return {
|
|
2168
2346
|
inboxNotifications: {
|
|
2169
2347
|
updated: json.inboxNotifications.map(convertToInboxNotificationData),
|
|
@@ -2179,25 +2357,19 @@ function createNotificationsApi({
|
|
|
2179
2357
|
};
|
|
2180
2358
|
}
|
|
2181
2359
|
async function getUnreadInboxNotificationsCount() {
|
|
2182
|
-
const { count } = await
|
|
2360
|
+
const { count } = await httpClient.get(
|
|
2361
|
+
url`/v2/c/inbox-notifications/count`
|
|
2362
|
+
);
|
|
2183
2363
|
return count;
|
|
2184
2364
|
}
|
|
2185
2365
|
async function markAllInboxNotificationsAsRead() {
|
|
2186
|
-
await
|
|
2187
|
-
|
|
2188
|
-
headers: {
|
|
2189
|
-
"Content-Type": "application/json"
|
|
2190
|
-
},
|
|
2191
|
-
body: JSON.stringify({ inboxNotificationIds: "all" })
|
|
2366
|
+
await httpClient.post(url`/v2/c/inbox-notifications/read`, {
|
|
2367
|
+
inboxNotificationIds: "all"
|
|
2192
2368
|
});
|
|
2193
2369
|
}
|
|
2194
2370
|
async function markInboxNotificationsAsRead(inboxNotificationIds) {
|
|
2195
|
-
await
|
|
2196
|
-
|
|
2197
|
-
headers: {
|
|
2198
|
-
"Content-Type": "application/json"
|
|
2199
|
-
},
|
|
2200
|
-
body: JSON.stringify({ inboxNotificationIds })
|
|
2371
|
+
await httpClient.post(url`/v2/c/inbox-notifications/read`, {
|
|
2372
|
+
inboxNotificationIds
|
|
2201
2373
|
});
|
|
2202
2374
|
}
|
|
2203
2375
|
const batchedMarkInboxNotificationsAsRead = new Batch(
|
|
@@ -2212,22 +2384,20 @@ function createNotificationsApi({
|
|
|
2212
2384
|
await batchedMarkInboxNotificationsAsRead.get(inboxNotificationId);
|
|
2213
2385
|
}
|
|
2214
2386
|
async function deleteAllInboxNotifications() {
|
|
2215
|
-
await
|
|
2216
|
-
method: "DELETE"
|
|
2217
|
-
});
|
|
2387
|
+
await httpClient.delete(url`/v2/c/inbox-notifications`);
|
|
2218
2388
|
}
|
|
2219
2389
|
async function deleteInboxNotification(inboxNotificationId) {
|
|
2220
|
-
await
|
|
2221
|
-
|
|
2222
|
-
|
|
2390
|
+
await httpClient.delete(
|
|
2391
|
+
url`/v2/c/inbox-notifications/${inboxNotificationId}`
|
|
2392
|
+
);
|
|
2223
2393
|
}
|
|
2224
2394
|
async function getUserThreads_experimental(options) {
|
|
2225
2395
|
let query;
|
|
2226
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2396
|
+
if (_optionalChain([options, 'optionalAccess', _48 => _48.query])) {
|
|
2227
2397
|
query = objectToQuery(options.query);
|
|
2228
2398
|
}
|
|
2229
2399
|
const PAGE_SIZE = 50;
|
|
2230
|
-
const json = await
|
|
2400
|
+
const json = await httpClient.get(url`/v2/c/threads`, {
|
|
2231
2401
|
cursor: options.cursor,
|
|
2232
2402
|
query,
|
|
2233
2403
|
limit: PAGE_SIZE
|
|
@@ -2242,9 +2412,11 @@ function createNotificationsApi({
|
|
|
2242
2412
|
};
|
|
2243
2413
|
}
|
|
2244
2414
|
async function getUserThreadsSince_experimental(options) {
|
|
2245
|
-
const json = await
|
|
2246
|
-
|
|
2247
|
-
|
|
2415
|
+
const json = await httpClient.get(
|
|
2416
|
+
url`/v2/c/threads/delta`,
|
|
2417
|
+
{ since: options.since.toISOString() },
|
|
2418
|
+
{ signal: options.signal }
|
|
2419
|
+
);
|
|
2248
2420
|
return {
|
|
2249
2421
|
threads: {
|
|
2250
2422
|
updated: json.threads.map(convertToThreadData),
|
|
@@ -2641,7 +2813,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
2641
2813
|
return [
|
|
2642
2814
|
{
|
|
2643
2815
|
type: 8 /* CREATE_REGISTER */,
|
|
2644
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2816
|
+
opId: _optionalChain([pool, 'optionalAccess', _49 => _49.generateOpId, 'call', _50 => _50()]),
|
|
2645
2817
|
id: this._id,
|
|
2646
2818
|
parentId,
|
|
2647
2819
|
parentKey,
|
|
@@ -2743,7 +2915,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2743
2915
|
const ops = [];
|
|
2744
2916
|
const op = {
|
|
2745
2917
|
id: this._id,
|
|
2746
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2918
|
+
opId: _optionalChain([pool, 'optionalAccess', _51 => _51.generateOpId, 'call', _52 => _52()]),
|
|
2747
2919
|
type: 2 /* CREATE_LIST */,
|
|
2748
2920
|
parentId,
|
|
2749
2921
|
parentKey
|
|
@@ -3020,7 +3192,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3020
3192
|
_applyInsertUndoRedo(op) {
|
|
3021
3193
|
const { id, parentKey: key } = op;
|
|
3022
3194
|
const child = creationOpToLiveNode(op);
|
|
3023
|
-
if (_optionalChain([this, 'access',
|
|
3195
|
+
if (_optionalChain([this, 'access', _53 => _53._pool, 'optionalAccess', _54 => _54.getNode, 'call', _55 => _55(id)]) !== void 0) {
|
|
3024
3196
|
return { modified: false };
|
|
3025
3197
|
}
|
|
3026
3198
|
child._attach(id, nn(this._pool));
|
|
@@ -3028,8 +3200,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3028
3200
|
const existingItemIndex = this._indexOfPosition(key);
|
|
3029
3201
|
let newKey = key;
|
|
3030
3202
|
if (existingItemIndex !== -1) {
|
|
3031
|
-
const before2 = _optionalChain([this, 'access',
|
|
3032
|
-
const after2 = _optionalChain([this, 'access',
|
|
3203
|
+
const before2 = _optionalChain([this, 'access', _56 => _56._items, 'access', _57 => _57[existingItemIndex], 'optionalAccess', _58 => _58._parentPos]);
|
|
3204
|
+
const after2 = _optionalChain([this, 'access', _59 => _59._items, 'access', _60 => _60[existingItemIndex + 1], 'optionalAccess', _61 => _61._parentPos]);
|
|
3033
3205
|
newKey = makePosition(before2, after2);
|
|
3034
3206
|
child._setParentLink(this, newKey);
|
|
3035
3207
|
}
|
|
@@ -3044,7 +3216,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3044
3216
|
_applySetUndoRedo(op) {
|
|
3045
3217
|
const { id, parentKey: key } = op;
|
|
3046
3218
|
const child = creationOpToLiveNode(op);
|
|
3047
|
-
if (_optionalChain([this, 'access',
|
|
3219
|
+
if (_optionalChain([this, 'access', _62 => _62._pool, 'optionalAccess', _63 => _63.getNode, 'call', _64 => _64(id)]) !== void 0) {
|
|
3048
3220
|
return { modified: false };
|
|
3049
3221
|
}
|
|
3050
3222
|
this._unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -3166,7 +3338,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3166
3338
|
} else {
|
|
3167
3339
|
this._items[existingItemIndex]._setParentLink(
|
|
3168
3340
|
this,
|
|
3169
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3341
|
+
makePosition(newKey, _optionalChain([this, 'access', _65 => _65._items, 'access', _66 => _66[existingItemIndex + 1], 'optionalAccess', _67 => _67._parentPos]))
|
|
3170
3342
|
);
|
|
3171
3343
|
const previousIndex = this._items.indexOf(child);
|
|
3172
3344
|
child._setParentLink(this, newKey);
|
|
@@ -3192,7 +3364,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3192
3364
|
if (existingItemIndex !== -1) {
|
|
3193
3365
|
this._items[existingItemIndex]._setParentLink(
|
|
3194
3366
|
this,
|
|
3195
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3367
|
+
makePosition(newKey, _optionalChain([this, 'access', _68 => _68._items, 'access', _69 => _69[existingItemIndex + 1], 'optionalAccess', _70 => _70._parentPos]))
|
|
3196
3368
|
);
|
|
3197
3369
|
}
|
|
3198
3370
|
child._setParentLink(this, newKey);
|
|
@@ -3211,7 +3383,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3211
3383
|
if (existingItemIndex !== -1) {
|
|
3212
3384
|
this._items[existingItemIndex]._setParentLink(
|
|
3213
3385
|
this,
|
|
3214
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3386
|
+
makePosition(newKey, _optionalChain([this, 'access', _71 => _71._items, 'access', _72 => _72[existingItemIndex + 1], 'optionalAccess', _73 => _73._parentPos]))
|
|
3215
3387
|
);
|
|
3216
3388
|
}
|
|
3217
3389
|
child._setParentLink(this, newKey);
|
|
@@ -3239,7 +3411,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3239
3411
|
if (existingItemIndex !== -1) {
|
|
3240
3412
|
this._items[existingItemIndex]._setParentLink(
|
|
3241
3413
|
this,
|
|
3242
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3414
|
+
makePosition(newKey, _optionalChain([this, 'access', _74 => _74._items, 'access', _75 => _75[existingItemIndex + 1], 'optionalAccess', _76 => _76._parentPos]))
|
|
3243
3415
|
);
|
|
3244
3416
|
}
|
|
3245
3417
|
child._setParentLink(this, newKey);
|
|
@@ -3297,7 +3469,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3297
3469
|
* @param element The element to add to the end of the LiveList.
|
|
3298
3470
|
*/
|
|
3299
3471
|
push(element) {
|
|
3300
|
-
_optionalChain([this, 'access',
|
|
3472
|
+
_optionalChain([this, 'access', _77 => _77._pool, 'optionalAccess', _78 => _78.assertStorageIsWritable, 'call', _79 => _79()]);
|
|
3301
3473
|
return this.insert(element, this.length);
|
|
3302
3474
|
}
|
|
3303
3475
|
/**
|
|
@@ -3306,7 +3478,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3306
3478
|
* @param index The index at which you want to insert the element.
|
|
3307
3479
|
*/
|
|
3308
3480
|
insert(element, index) {
|
|
3309
|
-
_optionalChain([this, 'access',
|
|
3481
|
+
_optionalChain([this, 'access', _80 => _80._pool, 'optionalAccess', _81 => _81.assertStorageIsWritable, 'call', _82 => _82()]);
|
|
3310
3482
|
if (index < 0 || index > this._items.length) {
|
|
3311
3483
|
throw new Error(
|
|
3312
3484
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
|
|
@@ -3336,7 +3508,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3336
3508
|
* @param targetIndex The index where the element should be after moving.
|
|
3337
3509
|
*/
|
|
3338
3510
|
move(index, targetIndex) {
|
|
3339
|
-
_optionalChain([this, 'access',
|
|
3511
|
+
_optionalChain([this, 'access', _83 => _83._pool, 'optionalAccess', _84 => _84.assertStorageIsWritable, 'call', _85 => _85()]);
|
|
3340
3512
|
if (targetIndex < 0) {
|
|
3341
3513
|
throw new Error("targetIndex cannot be less than 0");
|
|
3342
3514
|
}
|
|
@@ -3394,7 +3566,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3394
3566
|
* @param index The index of the element to delete
|
|
3395
3567
|
*/
|
|
3396
3568
|
delete(index) {
|
|
3397
|
-
_optionalChain([this, 'access',
|
|
3569
|
+
_optionalChain([this, 'access', _86 => _86._pool, 'optionalAccess', _87 => _87.assertStorageIsWritable, 'call', _88 => _88()]);
|
|
3398
3570
|
if (index < 0 || index >= this._items.length) {
|
|
3399
3571
|
throw new Error(
|
|
3400
3572
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
@@ -3427,7 +3599,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3427
3599
|
}
|
|
3428
3600
|
}
|
|
3429
3601
|
clear() {
|
|
3430
|
-
_optionalChain([this, 'access',
|
|
3602
|
+
_optionalChain([this, 'access', _89 => _89._pool, 'optionalAccess', _90 => _90.assertStorageIsWritable, 'call', _91 => _91()]);
|
|
3431
3603
|
if (this._pool) {
|
|
3432
3604
|
const ops = [];
|
|
3433
3605
|
const reverseOps = [];
|
|
@@ -3461,7 +3633,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3461
3633
|
}
|
|
3462
3634
|
}
|
|
3463
3635
|
set(index, item) {
|
|
3464
|
-
_optionalChain([this, 'access',
|
|
3636
|
+
_optionalChain([this, 'access', _92 => _92._pool, 'optionalAccess', _93 => _93.assertStorageIsWritable, 'call', _94 => _94()]);
|
|
3465
3637
|
if (index < 0 || index >= this._items.length) {
|
|
3466
3638
|
throw new Error(
|
|
3467
3639
|
`Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
@@ -3609,7 +3781,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3609
3781
|
_shiftItemPosition(index, key) {
|
|
3610
3782
|
const shiftedPosition = makePosition(
|
|
3611
3783
|
key,
|
|
3612
|
-
this._items.length > index + 1 ? _optionalChain([this, 'access',
|
|
3784
|
+
this._items.length > index + 1 ? _optionalChain([this, 'access', _95 => _95._items, 'access', _96 => _96[index + 1], 'optionalAccess', _97 => _97._parentPos]) : void 0
|
|
3613
3785
|
);
|
|
3614
3786
|
this._items[index]._setParentLink(this, shiftedPosition);
|
|
3615
3787
|
}
|
|
@@ -3739,7 +3911,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3739
3911
|
const ops = [];
|
|
3740
3912
|
const op = {
|
|
3741
3913
|
id: this._id,
|
|
3742
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
3914
|
+
opId: _optionalChain([pool, 'optionalAccess', _98 => _98.generateOpId, 'call', _99 => _99()]),
|
|
3743
3915
|
type: 7 /* CREATE_MAP */,
|
|
3744
3916
|
parentId,
|
|
3745
3917
|
parentKey
|
|
@@ -3886,7 +4058,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3886
4058
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
3887
4059
|
*/
|
|
3888
4060
|
set(key, value) {
|
|
3889
|
-
_optionalChain([this, 'access',
|
|
4061
|
+
_optionalChain([this, 'access', _100 => _100._pool, 'optionalAccess', _101 => _101.assertStorageIsWritable, 'call', _102 => _102()]);
|
|
3890
4062
|
const oldValue = this._map.get(key);
|
|
3891
4063
|
if (oldValue) {
|
|
3892
4064
|
oldValue._detach();
|
|
@@ -3932,7 +4104,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3932
4104
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
3933
4105
|
*/
|
|
3934
4106
|
delete(key) {
|
|
3935
|
-
_optionalChain([this, 'access',
|
|
4107
|
+
_optionalChain([this, 'access', _103 => _103._pool, 'optionalAccess', _104 => _104.assertStorageIsWritable, 'call', _105 => _105()]);
|
|
3936
4108
|
const item = this._map.get(key);
|
|
3937
4109
|
if (item === void 0) {
|
|
3938
4110
|
return false;
|
|
@@ -4110,7 +4282,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4110
4282
|
if (this._id === void 0) {
|
|
4111
4283
|
throw new Error("Cannot serialize item is not attached");
|
|
4112
4284
|
}
|
|
4113
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
4285
|
+
const opId = _optionalChain([pool, 'optionalAccess', _106 => _106.generateOpId, 'call', _107 => _107()]);
|
|
4114
4286
|
const ops = [];
|
|
4115
4287
|
const op = {
|
|
4116
4288
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -4388,7 +4560,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4388
4560
|
* @param value The value of the property to add
|
|
4389
4561
|
*/
|
|
4390
4562
|
set(key, value) {
|
|
4391
|
-
_optionalChain([this, 'access',
|
|
4563
|
+
_optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
|
|
4392
4564
|
this.update({ [key]: value });
|
|
4393
4565
|
}
|
|
4394
4566
|
/**
|
|
@@ -4403,7 +4575,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4403
4575
|
* @param key The key of the property to delete
|
|
4404
4576
|
*/
|
|
4405
4577
|
delete(key) {
|
|
4406
|
-
_optionalChain([this, 'access',
|
|
4578
|
+
_optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.assertStorageIsWritable, 'call', _113 => _113()]);
|
|
4407
4579
|
const keyAsString = key;
|
|
4408
4580
|
const oldValue = this._map.get(keyAsString);
|
|
4409
4581
|
if (oldValue === void 0) {
|
|
@@ -4456,7 +4628,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4456
4628
|
* @param patch The object used to overrides properties
|
|
4457
4629
|
*/
|
|
4458
4630
|
update(patch) {
|
|
4459
|
-
_optionalChain([this, 'access',
|
|
4631
|
+
_optionalChain([this, 'access', _114 => _114._pool, 'optionalAccess', _115 => _115.assertStorageIsWritable, 'call', _116 => _116()]);
|
|
4460
4632
|
if (this._pool === void 0 || this._id === void 0) {
|
|
4461
4633
|
for (const key in patch) {
|
|
4462
4634
|
const newValue = patch[key];
|
|
@@ -4829,36 +5001,6 @@ function findNonSerializableValue(value, path = "") {
|
|
|
4829
5001
|
return false;
|
|
4830
5002
|
}
|
|
4831
5003
|
|
|
4832
|
-
// src/lib/autoRetry.ts
|
|
4833
|
-
async function autoRetry(promiseFn, maxTries, backoff, throwError) {
|
|
4834
|
-
const fallbackBackoff = backoff.length > 0 ? backoff[backoff.length - 1] : 0;
|
|
4835
|
-
let attempt = 0;
|
|
4836
|
-
while (true) {
|
|
4837
|
-
attempt++;
|
|
4838
|
-
const promise = promiseFn();
|
|
4839
|
-
try {
|
|
4840
|
-
return await promise;
|
|
4841
|
-
} catch (err) {
|
|
4842
|
-
if (_optionalChain([throwError, 'optionalCall', _116 => _116(err)]) || err instanceof StopRetrying2) {
|
|
4843
|
-
throw err;
|
|
4844
|
-
}
|
|
4845
|
-
if (attempt >= maxTries) {
|
|
4846
|
-
throw new Error(`Failed after ${maxTries} attempts: ${String(err)}`);
|
|
4847
|
-
}
|
|
4848
|
-
}
|
|
4849
|
-
const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
|
|
4850
|
-
warn(
|
|
4851
|
-
`Attempt ${attempt} was unsuccessful. Retrying in ${delay} milliseconds.`
|
|
4852
|
-
);
|
|
4853
|
-
await wait(delay);
|
|
4854
|
-
}
|
|
4855
|
-
}
|
|
4856
|
-
var StopRetrying2 = class extends Error {
|
|
4857
|
-
constructor(reason) {
|
|
4858
|
-
super(reason);
|
|
4859
|
-
}
|
|
4860
|
-
};
|
|
4861
|
-
|
|
4862
5004
|
// src/lib/chunk.ts
|
|
4863
5005
|
function chunk(array, size) {
|
|
4864
5006
|
const chunks = [];
|
|
@@ -5316,14 +5458,6 @@ function splitFileIntoParts(file) {
|
|
|
5316
5458
|
}
|
|
5317
5459
|
return parts;
|
|
5318
5460
|
}
|
|
5319
|
-
var CommentsApiError = class extends Error {
|
|
5320
|
-
constructor(message, status, details) {
|
|
5321
|
-
super(message);
|
|
5322
|
-
this.message = message;
|
|
5323
|
-
this.status = status;
|
|
5324
|
-
this.details = details;
|
|
5325
|
-
}
|
|
5326
|
-
};
|
|
5327
5461
|
function createRoom(options, config) {
|
|
5328
5462
|
const initialPresence = options.initialPresence;
|
|
5329
5463
|
const initialStorage = options.initialStorage;
|
|
@@ -5542,128 +5676,88 @@ function createRoom(options, config) {
|
|
|
5542
5676
|
ydoc: makeEventSource(),
|
|
5543
5677
|
comments: makeEventSource()
|
|
5544
5678
|
};
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
}
|
|
5561
|
-
async function streamFetch(authValue, roomId) {
|
|
5562
|
-
return fetchClientApi(url`/v2/c/rooms/${roomId}/storage`, authValue, {
|
|
5563
|
-
method: "GET",
|
|
5564
|
-
headers: {
|
|
5565
|
-
"Content-Type": "application/json"
|
|
5566
|
-
}
|
|
5567
|
-
});
|
|
5568
|
-
}
|
|
5569
|
-
async function httpPostToRoom(endpoint, body) {
|
|
5570
|
-
if (!managedSocket.authValue) {
|
|
5571
|
-
throw new Error("Not authorized");
|
|
5572
|
-
}
|
|
5573
|
-
return fetchClientApi(
|
|
5574
|
-
endpoint === "/send-message" ? url`/v2/c/rooms/${config.roomId}/send-message` : url`/v2/c/rooms/${config.roomId}/text-metadata`,
|
|
5575
|
-
managedSocket.authValue,
|
|
5576
|
-
{
|
|
5577
|
-
method: "POST",
|
|
5578
|
-
headers: {
|
|
5579
|
-
"Content-Type": "application/json"
|
|
5580
|
-
},
|
|
5581
|
-
body: JSON.stringify(body)
|
|
5582
|
-
}
|
|
5583
|
-
);
|
|
5584
|
-
}
|
|
5679
|
+
const fetchPolyfill = _optionalChain([config, 'access', _125 => _125.polyfills, 'optionalAccess', _126 => _126.fetch]) || /* istanbul ignore next */
|
|
5680
|
+
_optionalChain([globalThis, 'access', _127 => _127.fetch, 'optionalAccess', _128 => _128.bind, 'call', _129 => _129(globalThis)]);
|
|
5681
|
+
const httpClient1 = new HttpClient(
|
|
5682
|
+
config.baseUrl,
|
|
5683
|
+
fetchPolyfill,
|
|
5684
|
+
() => Promise.resolve(_nullishCoalesce(managedSocket.authValue, () => ( raise("Not authorized"))))
|
|
5685
|
+
);
|
|
5686
|
+
const httpClient2 = new HttpClient(
|
|
5687
|
+
config.baseUrl,
|
|
5688
|
+
fetchPolyfill,
|
|
5689
|
+
() => (
|
|
5690
|
+
// TODO: Use the right scope
|
|
5691
|
+
delegates.authenticate()
|
|
5692
|
+
)
|
|
5693
|
+
);
|
|
5585
5694
|
async function createTextMention(userId, mentionId) {
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
url`/v2/c/rooms/${config.roomId}/text-mentions`,
|
|
5591
|
-
managedSocket.authValue,
|
|
5592
|
-
{
|
|
5593
|
-
method: "POST",
|
|
5594
|
-
headers: {
|
|
5595
|
-
"Content-Type": "application/json"
|
|
5596
|
-
},
|
|
5597
|
-
body: JSON.stringify({
|
|
5598
|
-
userId,
|
|
5599
|
-
mentionId
|
|
5600
|
-
})
|
|
5601
|
-
}
|
|
5602
|
-
);
|
|
5695
|
+
await httpClient1.rawPost(url`/v2/c/rooms/${config.roomId}/text-mentions`, {
|
|
5696
|
+
userId,
|
|
5697
|
+
mentionId
|
|
5698
|
+
});
|
|
5603
5699
|
}
|
|
5604
5700
|
async function deleteTextMention(mentionId) {
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
}
|
|
5608
|
-
return fetchClientApi(
|
|
5609
|
-
url`/v2/c/rooms/${config.roomId}/text-mentions/${mentionId}`,
|
|
5610
|
-
managedSocket.authValue,
|
|
5611
|
-
{
|
|
5612
|
-
method: "DELETE"
|
|
5613
|
-
}
|
|
5701
|
+
await httpClient1.rawDelete(
|
|
5702
|
+
url`/v2/c/rooms/${config.roomId}/text-mentions/${mentionId}`
|
|
5614
5703
|
);
|
|
5615
5704
|
}
|
|
5616
5705
|
async function reportTextEditor(type, rootKey) {
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
{
|
|
5622
|
-
method: "POST",
|
|
5623
|
-
headers: { "Content-Type": "application/json" },
|
|
5624
|
-
body: JSON.stringify({ type, rootKey })
|
|
5625
|
-
}
|
|
5626
|
-
);
|
|
5706
|
+
await httpClient2.rawPost(url`/v2/c/rooms/${config.roomId}/text-metadata`, {
|
|
5707
|
+
type,
|
|
5708
|
+
rootKey
|
|
5709
|
+
});
|
|
5627
5710
|
}
|
|
5628
5711
|
async function listTextVersions() {
|
|
5629
|
-
const
|
|
5630
|
-
return
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5712
|
+
const result = await httpClient2.get(url`/v2/c/rooms/${config.roomId}/versions`);
|
|
5713
|
+
return {
|
|
5714
|
+
versions: result.versions.map(({ createdAt, ...version }) => {
|
|
5715
|
+
return {
|
|
5716
|
+
createdAt: new Date(createdAt),
|
|
5717
|
+
...version
|
|
5718
|
+
};
|
|
5719
|
+
}),
|
|
5720
|
+
requestedAt: new Date(result.meta.requestedAt)
|
|
5721
|
+
};
|
|
5722
|
+
}
|
|
5723
|
+
async function listTextVersionsSince(options2) {
|
|
5724
|
+
const result = await httpClient2.get(
|
|
5725
|
+
url`/v2/c/rooms/${config.roomId}/versions/delta`,
|
|
5726
|
+
{ since: options2.since.toISOString() },
|
|
5727
|
+
{ signal: options2.signal }
|
|
5636
5728
|
);
|
|
5729
|
+
return {
|
|
5730
|
+
versions: result.versions.map(({ createdAt, ...version }) => {
|
|
5731
|
+
return {
|
|
5732
|
+
createdAt: new Date(createdAt),
|
|
5733
|
+
...version
|
|
5734
|
+
};
|
|
5735
|
+
}),
|
|
5736
|
+
requestedAt: new Date(result.meta.requestedAt)
|
|
5737
|
+
};
|
|
5637
5738
|
}
|
|
5638
5739
|
async function getTextVersion(versionId) {
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
url`/v2/c/rooms/${config.roomId}/y-version/${versionId}`,
|
|
5642
|
-
authValue,
|
|
5643
|
-
{ method: "GET" }
|
|
5740
|
+
return httpClient2.rawGet(
|
|
5741
|
+
url`/v2/c/rooms/${config.roomId}/y-version/${versionId}`
|
|
5644
5742
|
);
|
|
5645
5743
|
}
|
|
5646
5744
|
async function createTextVersion() {
|
|
5647
|
-
|
|
5648
|
-
return fetchClientApi(
|
|
5649
|
-
url`/v2/c/rooms/${config.roomId}/version`,
|
|
5650
|
-
authValue,
|
|
5651
|
-
{ method: "POST" }
|
|
5652
|
-
);
|
|
5745
|
+
await httpClient2.rawPost(url`/v2/c/rooms/${config.roomId}/version`);
|
|
5653
5746
|
}
|
|
5654
5747
|
function sendMessages(messages) {
|
|
5655
5748
|
const serializedPayload = JSON.stringify(messages);
|
|
5656
|
-
const nonce = _optionalChain([context, 'access',
|
|
5749
|
+
const nonce = _optionalChain([context, 'access', _130 => _130.dynamicSessionInfo, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.nonce]);
|
|
5657
5750
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5658
5751
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5659
5752
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
5660
|
-
void
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5753
|
+
void httpClient1.rawPost(url`/v2/c/rooms/${config.roomId}/send-message`, {
|
|
5754
|
+
nonce,
|
|
5755
|
+
messages
|
|
5756
|
+
}).then((resp) => {
|
|
5757
|
+
if (!resp.ok && resp.status === 403) {
|
|
5758
|
+
managedSocket.reconnect();
|
|
5665
5759
|
}
|
|
5666
|
-
);
|
|
5760
|
+
});
|
|
5667
5761
|
warn(
|
|
5668
5762
|
"Message was too large for websockets and sent over HTTP instead"
|
|
5669
5763
|
);
|
|
@@ -5715,7 +5809,7 @@ function createRoom(options, config) {
|
|
|
5715
5809
|
} else {
|
|
5716
5810
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
5717
5811
|
}
|
|
5718
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
5812
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.canWrite]), () => ( true));
|
|
5719
5813
|
const stackSizeBefore = context.undoStack.length;
|
|
5720
5814
|
for (const key in context.initialStorage) {
|
|
5721
5815
|
if (context.root.get(key) === void 0) {
|
|
@@ -5920,7 +6014,7 @@ function createRoom(options, config) {
|
|
|
5920
6014
|
}
|
|
5921
6015
|
context.myPresence.patch(patch);
|
|
5922
6016
|
if (context.activeBatch) {
|
|
5923
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6017
|
+
if (_optionalChain([options2, 'optionalAccess', _135 => _135.addToHistory])) {
|
|
5924
6018
|
context.activeBatch.reverseOps.unshift({
|
|
5925
6019
|
type: "presence",
|
|
5926
6020
|
data: oldValues
|
|
@@ -5930,7 +6024,7 @@ function createRoom(options, config) {
|
|
|
5930
6024
|
} else {
|
|
5931
6025
|
flushNowOrSoon();
|
|
5932
6026
|
batchUpdates(() => {
|
|
5933
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6027
|
+
if (_optionalChain([options2, 'optionalAccess', _136 => _136.addToHistory])) {
|
|
5934
6028
|
addToUndoStack(
|
|
5935
6029
|
[{ type: "presence", data: oldValues }],
|
|
5936
6030
|
doNotBatchUpdates
|
|
@@ -6128,7 +6222,7 @@ function createRoom(options, config) {
|
|
|
6128
6222
|
if (process.env.NODE_ENV !== "production") {
|
|
6129
6223
|
const traces = /* @__PURE__ */ new Set();
|
|
6130
6224
|
for (const opId of message.opIds) {
|
|
6131
|
-
const trace = _optionalChain([context, 'access',
|
|
6225
|
+
const trace = _optionalChain([context, 'access', _137 => _137.opStackTraces, 'optionalAccess', _138 => _138.get, 'call', _139 => _139(opId)]);
|
|
6132
6226
|
if (trace) {
|
|
6133
6227
|
traces.add(trace);
|
|
6134
6228
|
}
|
|
@@ -6262,15 +6356,15 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6262
6356
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
6263
6357
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
6264
6358
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
6265
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
6359
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _140 => _140()]);
|
|
6266
6360
|
notifyStorageStatus();
|
|
6267
6361
|
eventHub.storageDidLoad.notify();
|
|
6268
6362
|
}
|
|
6269
6363
|
async function streamStorage() {
|
|
6270
|
-
if (!managedSocket.authValue)
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6364
|
+
if (!managedSocket.authValue) return;
|
|
6365
|
+
const result = await httpClient1.rawGet(
|
|
6366
|
+
url`/v2/c/rooms/${config.roomId}/storage`
|
|
6367
|
+
);
|
|
6274
6368
|
const items = await result.json();
|
|
6275
6369
|
processInitialStorage({ type: 200 /* INITIAL_STORAGE_STATE */, items });
|
|
6276
6370
|
}
|
|
@@ -6479,117 +6573,48 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6479
6573
|
ydoc: eventHub.ydoc.observable,
|
|
6480
6574
|
comments: eventHub.comments.observable
|
|
6481
6575
|
};
|
|
6482
|
-
async function fetchCommentsApi(endpoint, params, options2) {
|
|
6483
|
-
const authValue = await delegates.authenticate();
|
|
6484
|
-
return fetchClientApi(endpoint, authValue, options2, params);
|
|
6485
|
-
}
|
|
6486
|
-
async function fetchCommentsJson(endpoint, options2, params) {
|
|
6487
|
-
const response = await fetchCommentsApi(endpoint, params, options2);
|
|
6488
|
-
if (!response.ok) {
|
|
6489
|
-
if (response.status >= 400 && response.status < 600) {
|
|
6490
|
-
let error3;
|
|
6491
|
-
try {
|
|
6492
|
-
const errorBody = await response.json();
|
|
6493
|
-
error3 = new CommentsApiError(
|
|
6494
|
-
errorBody.message,
|
|
6495
|
-
response.status,
|
|
6496
|
-
errorBody
|
|
6497
|
-
);
|
|
6498
|
-
} catch (e5) {
|
|
6499
|
-
error3 = new CommentsApiError(response.statusText, response.status);
|
|
6500
|
-
}
|
|
6501
|
-
throw error3;
|
|
6502
|
-
}
|
|
6503
|
-
}
|
|
6504
|
-
let body;
|
|
6505
|
-
try {
|
|
6506
|
-
body = await response.json();
|
|
6507
|
-
} catch (e6) {
|
|
6508
|
-
body = {};
|
|
6509
|
-
}
|
|
6510
|
-
return body;
|
|
6511
|
-
}
|
|
6512
6576
|
async function getThreadsSince(options2) {
|
|
6513
|
-
const
|
|
6577
|
+
const result = await httpClient2.get(
|
|
6514
6578
|
url`/v2/c/rooms/${config.roomId}/threads/delta`,
|
|
6515
|
-
{ since: _optionalChain([options2, 'optionalAccess',
|
|
6516
|
-
{
|
|
6517
|
-
headers: {
|
|
6518
|
-
"Content-Type": "application/json"
|
|
6519
|
-
}
|
|
6520
|
-
}
|
|
6579
|
+
{ since: _optionalChain([options2, 'optionalAccess', _141 => _141.since, 'optionalAccess', _142 => _142.toISOString, 'call', _143 => _143()]) },
|
|
6580
|
+
{ signal: options2.signal }
|
|
6521
6581
|
);
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
requestedAt: new Date(json.meta.requestedAt)
|
|
6536
|
-
};
|
|
6537
|
-
} else if (response.status === 404) {
|
|
6538
|
-
return {
|
|
6539
|
-
threads: {
|
|
6540
|
-
updated: [],
|
|
6541
|
-
deleted: []
|
|
6542
|
-
},
|
|
6543
|
-
inboxNotifications: {
|
|
6544
|
-
updated: [],
|
|
6545
|
-
deleted: []
|
|
6546
|
-
},
|
|
6547
|
-
requestedAt: /* @__PURE__ */ new Date()
|
|
6548
|
-
};
|
|
6549
|
-
} else {
|
|
6550
|
-
throw new Error("There was an error while getting threads.");
|
|
6551
|
-
}
|
|
6582
|
+
return {
|
|
6583
|
+
threads: {
|
|
6584
|
+
updated: result.data.map(convertToThreadData),
|
|
6585
|
+
deleted: result.deletedThreads.map(convertToThreadDeleteInfo)
|
|
6586
|
+
},
|
|
6587
|
+
inboxNotifications: {
|
|
6588
|
+
updated: result.inboxNotifications.map(convertToInboxNotificationData),
|
|
6589
|
+
deleted: result.deletedInboxNotifications.map(
|
|
6590
|
+
convertToInboxNotificationDeleteInfo
|
|
6591
|
+
)
|
|
6592
|
+
},
|
|
6593
|
+
requestedAt: new Date(result.meta.requestedAt)
|
|
6594
|
+
};
|
|
6552
6595
|
}
|
|
6553
6596
|
async function getThreads(options2) {
|
|
6554
6597
|
let query;
|
|
6555
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6598
|
+
if (_optionalChain([options2, 'optionalAccess', _144 => _144.query])) {
|
|
6556
6599
|
query = objectToQuery(options2.query);
|
|
6557
6600
|
}
|
|
6558
6601
|
const PAGE_SIZE = 50;
|
|
6559
|
-
const
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
|
|
6572
|
-
inboxNotifications: json.inboxNotifications.map(
|
|
6573
|
-
convertToInboxNotificationData
|
|
6574
|
-
),
|
|
6575
|
-
nextCursor: json.meta.nextCursor,
|
|
6576
|
-
requestedAt: new Date(json.meta.requestedAt)
|
|
6577
|
-
};
|
|
6578
|
-
} else if (response.status === 404) {
|
|
6579
|
-
return {
|
|
6580
|
-
threads: [],
|
|
6581
|
-
inboxNotifications: [],
|
|
6582
|
-
deletedThreads: [],
|
|
6583
|
-
deletedInboxNotifications: [],
|
|
6584
|
-
nextCursor: null,
|
|
6585
|
-
requestedAt: /* @__PURE__ */ new Date()
|
|
6586
|
-
};
|
|
6587
|
-
} else {
|
|
6588
|
-
throw new Error("There was an error while getting threads.");
|
|
6589
|
-
}
|
|
6602
|
+
const result = await httpClient2.get(url`/v2/c/rooms/${config.roomId}/threads`, {
|
|
6603
|
+
cursor: _optionalChain([options2, 'optionalAccess', _145 => _145.cursor]),
|
|
6604
|
+
query,
|
|
6605
|
+
limit: PAGE_SIZE
|
|
6606
|
+
});
|
|
6607
|
+
return {
|
|
6608
|
+
threads: result.data.map(convertToThreadData),
|
|
6609
|
+
inboxNotifications: result.inboxNotifications.map(
|
|
6610
|
+
convertToInboxNotificationData
|
|
6611
|
+
),
|
|
6612
|
+
nextCursor: result.meta.nextCursor,
|
|
6613
|
+
requestedAt: new Date(result.meta.requestedAt)
|
|
6614
|
+
};
|
|
6590
6615
|
}
|
|
6591
6616
|
async function getThread(threadId) {
|
|
6592
|
-
const response = await
|
|
6617
|
+
const response = await httpClient2.rawGet(
|
|
6593
6618
|
url`/v2/c/rooms/${config.roomId}/thread-with-notification/${threadId}`
|
|
6594
6619
|
);
|
|
6595
6620
|
if (response.ok) {
|
|
@@ -6614,57 +6639,42 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6614
6639
|
threadId = createThreadId(),
|
|
6615
6640
|
attachmentIds
|
|
6616
6641
|
}) {
|
|
6617
|
-
const thread = await
|
|
6642
|
+
const thread = await httpClient2.post(
|
|
6618
6643
|
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6619
6644
|
{
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6645
|
+
id: threadId,
|
|
6646
|
+
comment: {
|
|
6647
|
+
id: commentId,
|
|
6648
|
+
body,
|
|
6649
|
+
attachmentIds
|
|
6623
6650
|
},
|
|
6624
|
-
|
|
6625
|
-
id: threadId,
|
|
6626
|
-
comment: {
|
|
6627
|
-
id: commentId,
|
|
6628
|
-
body,
|
|
6629
|
-
attachmentIds
|
|
6630
|
-
},
|
|
6631
|
-
metadata
|
|
6632
|
-
})
|
|
6651
|
+
metadata
|
|
6633
6652
|
}
|
|
6634
6653
|
);
|
|
6635
6654
|
return convertToThreadData(thread);
|
|
6636
6655
|
}
|
|
6637
6656
|
async function deleteThread(threadId) {
|
|
6638
|
-
await
|
|
6639
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}
|
|
6640
|
-
{ method: "DELETE" }
|
|
6657
|
+
await httpClient2.delete(
|
|
6658
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}`
|
|
6641
6659
|
);
|
|
6642
6660
|
}
|
|
6643
6661
|
async function editThreadMetadata({
|
|
6644
6662
|
metadata,
|
|
6645
6663
|
threadId
|
|
6646
6664
|
}) {
|
|
6647
|
-
return await
|
|
6665
|
+
return await httpClient2.post(
|
|
6648
6666
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/metadata`,
|
|
6649
|
-
|
|
6650
|
-
method: "POST",
|
|
6651
|
-
headers: {
|
|
6652
|
-
"Content-Type": "application/json"
|
|
6653
|
-
},
|
|
6654
|
-
body: JSON.stringify(metadata)
|
|
6655
|
-
}
|
|
6667
|
+
metadata
|
|
6656
6668
|
);
|
|
6657
6669
|
}
|
|
6658
6670
|
async function markThreadAsResolved(threadId) {
|
|
6659
|
-
await
|
|
6660
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-resolved
|
|
6661
|
-
{ method: "POST" }
|
|
6671
|
+
await httpClient2.post(
|
|
6672
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-resolved`
|
|
6662
6673
|
);
|
|
6663
6674
|
}
|
|
6664
6675
|
async function markThreadAsUnresolved(threadId) {
|
|
6665
|
-
await
|
|
6666
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-unresolved
|
|
6667
|
-
{ method: "POST" }
|
|
6676
|
+
await httpClient2.post(
|
|
6677
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-unresolved`
|
|
6668
6678
|
);
|
|
6669
6679
|
}
|
|
6670
6680
|
async function createComment({
|
|
@@ -6673,18 +6683,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6673
6683
|
body,
|
|
6674
6684
|
attachmentIds
|
|
6675
6685
|
}) {
|
|
6676
|
-
const comment = await
|
|
6686
|
+
const comment = await httpClient2.post(
|
|
6677
6687
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments`,
|
|
6678
6688
|
{
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
},
|
|
6683
|
-
body: JSON.stringify({
|
|
6684
|
-
id: commentId,
|
|
6685
|
-
body,
|
|
6686
|
-
attachmentIds
|
|
6687
|
-
})
|
|
6689
|
+
id: commentId,
|
|
6690
|
+
body,
|
|
6691
|
+
attachmentIds
|
|
6688
6692
|
}
|
|
6689
6693
|
);
|
|
6690
6694
|
return convertToCommentData(comment);
|
|
@@ -6695,17 +6699,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6695
6699
|
body,
|
|
6696
6700
|
attachmentIds
|
|
6697
6701
|
}) {
|
|
6698
|
-
const comment = await
|
|
6702
|
+
const comment = await httpClient2.post(
|
|
6699
6703
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`,
|
|
6700
6704
|
{
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
"Content-Type": "application/json"
|
|
6704
|
-
},
|
|
6705
|
-
body: JSON.stringify({
|
|
6706
|
-
body,
|
|
6707
|
-
attachmentIds
|
|
6708
|
-
})
|
|
6705
|
+
body,
|
|
6706
|
+
attachmentIds
|
|
6709
6707
|
}
|
|
6710
6708
|
);
|
|
6711
6709
|
return convertToCommentData(comment);
|
|
@@ -6714,9 +6712,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6714
6712
|
threadId,
|
|
6715
6713
|
commentId
|
|
6716
6714
|
}) {
|
|
6717
|
-
await
|
|
6718
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}
|
|
6719
|
-
{ method: "DELETE" }
|
|
6715
|
+
await httpClient2.delete(
|
|
6716
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`
|
|
6720
6717
|
);
|
|
6721
6718
|
}
|
|
6722
6719
|
async function addReaction({
|
|
@@ -6724,15 +6721,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6724
6721
|
commentId,
|
|
6725
6722
|
emoji
|
|
6726
6723
|
}) {
|
|
6727
|
-
const reaction = await
|
|
6724
|
+
const reaction = await httpClient2.post(
|
|
6728
6725
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions`,
|
|
6729
|
-
{
|
|
6730
|
-
method: "POST",
|
|
6731
|
-
headers: {
|
|
6732
|
-
"Content-Type": "application/json"
|
|
6733
|
-
},
|
|
6734
|
-
body: JSON.stringify({ emoji })
|
|
6735
|
-
}
|
|
6726
|
+
{ emoji }
|
|
6736
6727
|
);
|
|
6737
6728
|
return convertToCommentUserReaction(reaction);
|
|
6738
6729
|
}
|
|
@@ -6741,9 +6732,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6741
6732
|
commentId,
|
|
6742
6733
|
emoji
|
|
6743
6734
|
}) {
|
|
6744
|
-
await
|
|
6745
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions/${emoji}
|
|
6746
|
-
{ method: "DELETE" }
|
|
6735
|
+
await httpClient2.delete(
|
|
6736
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions/${emoji}`
|
|
6747
6737
|
);
|
|
6748
6738
|
}
|
|
6749
6739
|
function prepareAttachment(file) {
|
|
@@ -6763,30 +6753,25 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6763
6753
|
`Upload of attachment ${attachment.id} was aborted.`,
|
|
6764
6754
|
"AbortError"
|
|
6765
6755
|
) : void 0;
|
|
6766
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6756
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _146 => _146.aborted])) {
|
|
6767
6757
|
throw abortError;
|
|
6768
6758
|
}
|
|
6769
6759
|
const handleRetryError = (err) => {
|
|
6770
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6760
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _147 => _147.aborted])) {
|
|
6771
6761
|
throw abortError;
|
|
6772
6762
|
}
|
|
6773
|
-
if (err instanceof
|
|
6763
|
+
if (err instanceof HttpError && err.status === 413) {
|
|
6774
6764
|
throw err;
|
|
6775
6765
|
}
|
|
6776
6766
|
return false;
|
|
6777
6767
|
};
|
|
6778
6768
|
if (attachment.size <= ATTACHMENT_PART_SIZE) {
|
|
6779
6769
|
return autoRetry(
|
|
6780
|
-
() =>
|
|
6770
|
+
() => httpClient2.putBlob(
|
|
6781
6771
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/upload/${encodeURIComponent(attachment.name)}`,
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
signal: abortSignal
|
|
6786
|
-
},
|
|
6787
|
-
{
|
|
6788
|
-
fileSize: attachment.size
|
|
6789
|
-
}
|
|
6772
|
+
attachment.file,
|
|
6773
|
+
{ fileSize: attachment.size },
|
|
6774
|
+
{ signal: abortSignal }
|
|
6790
6775
|
),
|
|
6791
6776
|
RETRY_ATTEMPTS,
|
|
6792
6777
|
RETRY_DELAYS,
|
|
@@ -6796,15 +6781,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6796
6781
|
let uploadId;
|
|
6797
6782
|
const uploadedParts = [];
|
|
6798
6783
|
const createMultiPartUpload = await autoRetry(
|
|
6799
|
-
() =>
|
|
6784
|
+
() => httpClient2.post(
|
|
6800
6785
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
},
|
|
6805
|
-
{
|
|
6806
|
-
fileSize: attachment.size
|
|
6807
|
-
}
|
|
6786
|
+
void 0,
|
|
6787
|
+
{ signal: abortSignal },
|
|
6788
|
+
{ fileSize: attachment.size }
|
|
6808
6789
|
),
|
|
6809
6790
|
RETRY_ATTEMPTS,
|
|
6810
6791
|
RETRY_DELAYS,
|
|
@@ -6813,7 +6794,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6813
6794
|
try {
|
|
6814
6795
|
uploadId = createMultiPartUpload.uploadId;
|
|
6815
6796
|
const parts = splitFileIntoParts(attachment.file);
|
|
6816
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6797
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _148 => _148.aborted])) {
|
|
6817
6798
|
throw abortError;
|
|
6818
6799
|
}
|
|
6819
6800
|
const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
|
|
@@ -6822,13 +6803,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6822
6803
|
for (const { part, partNumber } of parts2) {
|
|
6823
6804
|
uploadedPartsPromises.push(
|
|
6824
6805
|
autoRetry(
|
|
6825
|
-
() =>
|
|
6806
|
+
() => httpClient2.putBlob(
|
|
6826
6807
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${createMultiPartUpload.uploadId}/${String(partNumber)}`,
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
signal: abortSignal
|
|
6831
|
-
}
|
|
6808
|
+
part,
|
|
6809
|
+
void 0,
|
|
6810
|
+
{ signal: abortSignal }
|
|
6832
6811
|
),
|
|
6833
6812
|
RETRY_ATTEMPTS,
|
|
6834
6813
|
RETRY_DELAYS,
|
|
@@ -6838,32 +6817,22 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6838
6817
|
}
|
|
6839
6818
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
6840
6819
|
}
|
|
6841
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6820
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _149 => _149.aborted])) {
|
|
6842
6821
|
throw abortError;
|
|
6843
6822
|
}
|
|
6844
6823
|
const sortedUploadedParts = uploadedParts.sort(
|
|
6845
6824
|
(a, b) => a.partNumber - b.partNumber
|
|
6846
6825
|
);
|
|
6847
|
-
return
|
|
6826
|
+
return httpClient2.post(
|
|
6848
6827
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
|
|
6849
|
-
{
|
|
6850
|
-
|
|
6851
|
-
headers: {
|
|
6852
|
-
"Content-Type": "application/json"
|
|
6853
|
-
},
|
|
6854
|
-
body: JSON.stringify({ parts: sortedUploadedParts }),
|
|
6855
|
-
signal: abortSignal
|
|
6856
|
-
}
|
|
6828
|
+
{ parts: sortedUploadedParts },
|
|
6829
|
+
{ signal: abortSignal }
|
|
6857
6830
|
);
|
|
6858
6831
|
} catch (error3) {
|
|
6859
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
6832
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _150 => _150.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
6860
6833
|
try {
|
|
6861
|
-
await
|
|
6862
|
-
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}
|
|
6863
|
-
void 0,
|
|
6864
|
-
{
|
|
6865
|
-
method: "DELETE"
|
|
6866
|
-
}
|
|
6834
|
+
await httpClient2.rawDelete(
|
|
6835
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}`
|
|
6867
6836
|
);
|
|
6868
6837
|
} catch (error4) {
|
|
6869
6838
|
}
|
|
@@ -6873,16 +6842,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6873
6842
|
}
|
|
6874
6843
|
}
|
|
6875
6844
|
async function getAttachmentUrls(attachmentIds) {
|
|
6876
|
-
const { urls } = await
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
method: "POST",
|
|
6880
|
-
headers: {
|
|
6881
|
-
"Content-Type": "application/json"
|
|
6882
|
-
},
|
|
6883
|
-
body: JSON.stringify({ attachmentIds })
|
|
6884
|
-
}
|
|
6885
|
-
);
|
|
6845
|
+
const { urls } = await httpClient2.post(url`/v2/c/rooms/${config.roomId}/attachments/presigned-urls`, {
|
|
6846
|
+
attachmentIds
|
|
6847
|
+
});
|
|
6886
6848
|
return urls;
|
|
6887
6849
|
}
|
|
6888
6850
|
const batchedGetAttachmentUrls = new Batch(
|
|
@@ -6900,38 +6862,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6900
6862
|
return batchedGetAttachmentUrls.get(attachmentId);
|
|
6901
6863
|
}
|
|
6902
6864
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6903
|
-
|
|
6904
|
-
const response = await fetchClientApi(endpoint, authValue, options2);
|
|
6905
|
-
if (!response.ok) {
|
|
6906
|
-
if (response.status >= 400 && response.status < 600) {
|
|
6907
|
-
let error3;
|
|
6908
|
-
try {
|
|
6909
|
-
const errorBody = await response.json();
|
|
6910
|
-
error3 = new NotificationsApiError(
|
|
6911
|
-
errorBody.message,
|
|
6912
|
-
response.status,
|
|
6913
|
-
errorBody
|
|
6914
|
-
);
|
|
6915
|
-
} catch (e7) {
|
|
6916
|
-
error3 = new NotificationsApiError(
|
|
6917
|
-
response.statusText,
|
|
6918
|
-
response.status
|
|
6919
|
-
);
|
|
6920
|
-
}
|
|
6921
|
-
throw error3;
|
|
6922
|
-
}
|
|
6923
|
-
}
|
|
6924
|
-
let body;
|
|
6925
|
-
try {
|
|
6926
|
-
body = await response.json();
|
|
6927
|
-
} catch (e8) {
|
|
6928
|
-
body = {};
|
|
6929
|
-
}
|
|
6930
|
-
return body;
|
|
6865
|
+
return await httpClient2.get(endpoint, void 0, options2);
|
|
6931
6866
|
}
|
|
6932
|
-
function getNotificationSettings() {
|
|
6867
|
+
function getNotificationSettings(options2) {
|
|
6933
6868
|
return fetchNotificationsJson(
|
|
6934
|
-
url`/v2/c/rooms/${config.roomId}/notification-settings
|
|
6869
|
+
url`/v2/c/rooms/${config.roomId}/notification-settings`,
|
|
6870
|
+
{ signal: _optionalChain([options2, 'optionalAccess', _151 => _151.signal]) }
|
|
6935
6871
|
);
|
|
6936
6872
|
}
|
|
6937
6873
|
function updateNotificationSettings(settings) {
|
|
@@ -6939,10 +6875,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6939
6875
|
url`/v2/c/rooms/${config.roomId}/notification-settings`,
|
|
6940
6876
|
{
|
|
6941
6877
|
method: "POST",
|
|
6942
|
-
body: JSON.stringify(settings)
|
|
6943
|
-
headers: {
|
|
6944
|
-
"Content-Type": "application/json"
|
|
6945
|
-
}
|
|
6878
|
+
body: JSON.stringify(settings)
|
|
6946
6879
|
}
|
|
6947
6880
|
);
|
|
6948
6881
|
}
|
|
@@ -6951,9 +6884,6 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6951
6884
|
url`/v2/c/rooms/${config.roomId}/inbox-notifications/read`,
|
|
6952
6885
|
{
|
|
6953
6886
|
method: "POST",
|
|
6954
|
-
headers: {
|
|
6955
|
-
"Content-Type": "application/json"
|
|
6956
|
-
},
|
|
6957
6887
|
body: JSON.stringify({ inboxNotificationIds })
|
|
6958
6888
|
}
|
|
6959
6889
|
);
|
|
@@ -6973,7 +6903,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6973
6903
|
{
|
|
6974
6904
|
[kInternal]: {
|
|
6975
6905
|
get presenceBuffer() {
|
|
6976
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6906
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _152 => _152.buffer, 'access', _153 => _153.presenceUpdates, 'optionalAccess', _154 => _154.data]), () => ( null)));
|
|
6977
6907
|
},
|
|
6978
6908
|
// prettier-ignore
|
|
6979
6909
|
get undoStack() {
|
|
@@ -7000,6 +6930,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7000
6930
|
deleteTextMention,
|
|
7001
6931
|
// list versions of the document
|
|
7002
6932
|
listTextVersions,
|
|
6933
|
+
// List versions of the document since the specified date
|
|
6934
|
+
listTextVersionsSince,
|
|
7003
6935
|
// get a specific version
|
|
7004
6936
|
getTextVersion,
|
|
7005
6937
|
// create a version
|
|
@@ -7157,7 +7089,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
7157
7089
|
}
|
|
7158
7090
|
if (isLiveNode(first)) {
|
|
7159
7091
|
const node = first;
|
|
7160
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7092
|
+
if (_optionalChain([options, 'optionalAccess', _155 => _155.isDeep])) {
|
|
7161
7093
|
const storageCallback = second;
|
|
7162
7094
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7163
7095
|
} else {
|
|
@@ -7277,12 +7209,12 @@ function createClient(options) {
|
|
|
7277
7209
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7278
7210
|
roomId,
|
|
7279
7211
|
baseUrl,
|
|
7280
|
-
_optionalChain([clientOptions, 'access',
|
|
7212
|
+
_optionalChain([clientOptions, 'access', _156 => _156.polyfills, 'optionalAccess', _157 => _157.WebSocket])
|
|
7281
7213
|
),
|
|
7282
7214
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7283
7215
|
})),
|
|
7284
7216
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7285
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7217
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _158 => _158.unstable_batchedUpdates]),
|
|
7286
7218
|
baseUrl,
|
|
7287
7219
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7288
7220
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7298,7 +7230,7 @@ function createClient(options) {
|
|
|
7298
7230
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7299
7231
|
if (shouldConnect) {
|
|
7300
7232
|
if (typeof atob === "undefined") {
|
|
7301
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7233
|
+
if (_optionalChain([clientOptions, 'access', _159 => _159.polyfills, 'optionalAccess', _160 => _160.atob]) === void 0) {
|
|
7302
7234
|
throw new Error(
|
|
7303
7235
|
"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"
|
|
7304
7236
|
);
|
|
@@ -7310,7 +7242,7 @@ function createClient(options) {
|
|
|
7310
7242
|
return leaseRoom(newRoomDetails);
|
|
7311
7243
|
}
|
|
7312
7244
|
function getRoom(roomId) {
|
|
7313
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7245
|
+
const room = _optionalChain([roomsById, 'access', _161 => _161.get, 'call', _162 => _162(roomId), 'optionalAccess', _163 => _163.room]);
|
|
7314
7246
|
return room ? room : null;
|
|
7315
7247
|
}
|
|
7316
7248
|
function logout() {
|
|
@@ -7322,11 +7254,11 @@ function createClient(options) {
|
|
|
7322
7254
|
}
|
|
7323
7255
|
}
|
|
7324
7256
|
const currentUserIdStore = createStore(null);
|
|
7325
|
-
const
|
|
7326
|
-
fetch;
|
|
7327
|
-
const
|
|
7257
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _164 => _164.polyfills, 'optionalAccess', _165 => _165.fetch]) || /* istanbul ignore next */
|
|
7258
|
+
_optionalChain([globalThis, 'access', _166 => _166.fetch, 'optionalAccess', _167 => _167.bind, 'call', _168 => _168(globalThis)]);
|
|
7259
|
+
const notificationsAPI = createNotificationsApi({
|
|
7328
7260
|
baseUrl,
|
|
7329
|
-
|
|
7261
|
+
fetchPolyfill,
|
|
7330
7262
|
authManager,
|
|
7331
7263
|
currentUserIdStore
|
|
7332
7264
|
});
|
|
@@ -7338,7 +7270,7 @@ function createClient(options) {
|
|
|
7338
7270
|
const batchedResolveUsers = new Batch(
|
|
7339
7271
|
async (batchedUserIds) => {
|
|
7340
7272
|
const userIds = batchedUserIds.flat();
|
|
7341
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7273
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _169 => _169({ userIds })]);
|
|
7342
7274
|
warnIfNoResolveUsers();
|
|
7343
7275
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7344
7276
|
},
|
|
@@ -7356,7 +7288,7 @@ function createClient(options) {
|
|
|
7356
7288
|
const batchedResolveRoomsInfo = new Batch(
|
|
7357
7289
|
async (batchedRoomIds) => {
|
|
7358
7290
|
const roomIds = batchedRoomIds.flat();
|
|
7359
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7291
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _170 => _170({ roomIds })]);
|
|
7360
7292
|
warnIfNoResolveRoomsInfo();
|
|
7361
7293
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7362
7294
|
},
|
|
@@ -7370,12 +7302,12 @@ function createClient(options) {
|
|
|
7370
7302
|
function invalidateResolvedMentionSuggestions() {
|
|
7371
7303
|
mentionSuggestionsCache.clear();
|
|
7372
7304
|
}
|
|
7373
|
-
|
|
7305
|
+
const client = Object.defineProperty(
|
|
7374
7306
|
{
|
|
7375
7307
|
enterRoom,
|
|
7376
7308
|
getRoom,
|
|
7377
7309
|
logout,
|
|
7378
|
-
...
|
|
7310
|
+
...notificationsAPI,
|
|
7379
7311
|
// Advanced resolvers APIs
|
|
7380
7312
|
resolvers: {
|
|
7381
7313
|
invalidateUsers: invalidateResolvedUsers,
|
|
@@ -7393,8 +7325,10 @@ function createClient(options) {
|
|
|
7393
7325
|
return Array.from(roomsById.keys());
|
|
7394
7326
|
},
|
|
7395
7327
|
// "All" threads (= "user" threads)
|
|
7396
|
-
getUserThreads_experimental:
|
|
7397
|
-
getUserThreadsSince_experimental:
|
|
7328
|
+
getUserThreads_experimental: notificationsAPI.getUserThreads_experimental,
|
|
7329
|
+
getUserThreadsSince_experimental: notificationsAPI.getUserThreadsSince_experimental,
|
|
7330
|
+
// Type-level helper only, it's effectively only an identity-function at runtime
|
|
7331
|
+
as: () => client
|
|
7398
7332
|
}
|
|
7399
7333
|
},
|
|
7400
7334
|
kInternal,
|
|
@@ -7402,15 +7336,8 @@ function createClient(options) {
|
|
|
7402
7336
|
enumerable: false
|
|
7403
7337
|
}
|
|
7404
7338
|
);
|
|
7339
|
+
return client;
|
|
7405
7340
|
}
|
|
7406
|
-
var NotificationsApiError = class extends Error {
|
|
7407
|
-
constructor(message, status, details) {
|
|
7408
|
-
super(message);
|
|
7409
|
-
this.message = message;
|
|
7410
|
-
this.status = status;
|
|
7411
|
-
this.details = details;
|
|
7412
|
-
}
|
|
7413
|
-
};
|
|
7414
7341
|
function checkBounds(option, value, min, max, recommendedMin) {
|
|
7415
7342
|
if (typeof value !== "number" || value < min || max !== void 0 && value > max) {
|
|
7416
7343
|
throw new Error(
|
|
@@ -7480,7 +7407,7 @@ var commentBodyElementsTypes = {
|
|
|
7480
7407
|
mention: "inline"
|
|
7481
7408
|
};
|
|
7482
7409
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7483
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7410
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _171 => _171.content])) {
|
|
7484
7411
|
return;
|
|
7485
7412
|
}
|
|
7486
7413
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7490,13 +7417,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7490
7417
|
for (const block of body.content) {
|
|
7491
7418
|
if (type === "all" || type === "block") {
|
|
7492
7419
|
if (guard(block)) {
|
|
7493
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7420
|
+
_optionalChain([visitor, 'optionalCall', _172 => _172(block)]);
|
|
7494
7421
|
}
|
|
7495
7422
|
}
|
|
7496
7423
|
if (type === "all" || type === "inline") {
|
|
7497
7424
|
for (const inline of block.children) {
|
|
7498
7425
|
if (guard(inline)) {
|
|
7499
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7426
|
+
_optionalChain([visitor, 'optionalCall', _173 => _173(inline)]);
|
|
7500
7427
|
}
|
|
7501
7428
|
}
|
|
7502
7429
|
}
|
|
@@ -7521,7 +7448,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7521
7448
|
userIds
|
|
7522
7449
|
});
|
|
7523
7450
|
for (const [index, userId] of userIds.entries()) {
|
|
7524
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7451
|
+
const user = _optionalChain([users, 'optionalAccess', _174 => _174[index]]);
|
|
7525
7452
|
if (user) {
|
|
7526
7453
|
resolvedUsers.set(userId, user);
|
|
7527
7454
|
}
|
|
@@ -7644,7 +7571,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7644
7571
|
text: ({ element }) => element.text,
|
|
7645
7572
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7646
7573
|
mention: ({ element, user }) => {
|
|
7647
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7574
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _175 => _175.name]), () => ( element.id))}`;
|
|
7648
7575
|
}
|
|
7649
7576
|
};
|
|
7650
7577
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7674,7 +7601,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7674
7601
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7675
7602
|
},
|
|
7676
7603
|
mention: ({ element, user }) => {
|
|
7677
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7604
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _176 => _176.name]), () => ( element.id))}</span>`;
|
|
7678
7605
|
}
|
|
7679
7606
|
};
|
|
7680
7607
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7704,19 +7631,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7704
7631
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7705
7632
|
},
|
|
7706
7633
|
mention: ({ element, user }) => {
|
|
7707
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7634
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _177 => _177.name]), () => ( element.id))}`;
|
|
7708
7635
|
}
|
|
7709
7636
|
};
|
|
7710
7637
|
async function stringifyCommentBody(body, options) {
|
|
7711
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7712
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7638
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _178 => _178.format]), () => ( "plain"));
|
|
7639
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _179 => _179.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7713
7640
|
const elements = {
|
|
7714
7641
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7715
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7642
|
+
..._optionalChain([options, 'optionalAccess', _180 => _180.elements])
|
|
7716
7643
|
};
|
|
7717
7644
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7718
7645
|
body,
|
|
7719
|
-
_optionalChain([options, 'optionalAccess',
|
|
7646
|
+
_optionalChain([options, 'optionalAccess', _181 => _181.resolveUsers])
|
|
7720
7647
|
);
|
|
7721
7648
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7722
7649
|
switch (block.type) {
|
|
@@ -7991,12 +7918,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7991
7918
|
}
|
|
7992
7919
|
const newState = Object.assign({}, state);
|
|
7993
7920
|
for (const key in update.updates) {
|
|
7994
|
-
if (_optionalChain([update, 'access',
|
|
7921
|
+
if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
|
|
7995
7922
|
const val = update.node.get(key);
|
|
7996
7923
|
if (val !== void 0) {
|
|
7997
7924
|
newState[key] = lsonToJson(val);
|
|
7998
7925
|
}
|
|
7999
|
-
} else if (_optionalChain([update, 'access',
|
|
7926
|
+
} else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
|
|
8000
7927
|
delete newState[key];
|
|
8001
7928
|
}
|
|
8002
7929
|
}
|
|
@@ -8057,12 +7984,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8057
7984
|
}
|
|
8058
7985
|
const newState = Object.assign({}, state);
|
|
8059
7986
|
for (const key in update.updates) {
|
|
8060
|
-
if (_optionalChain([update, 'access',
|
|
7987
|
+
if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
|
|
8061
7988
|
const value = update.node.get(key);
|
|
8062
7989
|
if (value !== void 0) {
|
|
8063
7990
|
newState[key] = lsonToJson(value);
|
|
8064
7991
|
}
|
|
8065
|
-
} else if (_optionalChain([update, 'access',
|
|
7992
|
+
} else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
|
|
8066
7993
|
delete newState[key];
|
|
8067
7994
|
}
|
|
8068
7995
|
}
|
|
@@ -8128,45 +8055,102 @@ function errorIf(condition, message) {
|
|
|
8128
8055
|
}
|
|
8129
8056
|
|
|
8130
8057
|
// src/lib/Poller.ts
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
}
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8058
|
+
var BACKOFF_DELAYS2 = [1e3, 2e3, 4e3, 8e3, 1e4];
|
|
8059
|
+
function makePoller(callback, intervalMs, options) {
|
|
8060
|
+
const startTime = performance.now();
|
|
8061
|
+
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8062
|
+
const win = typeof window !== "undefined" ? window : void 0;
|
|
8063
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _194 => _194.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
8064
|
+
const context = {
|
|
8065
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _195 => _195.visibilityState]) !== "hidden",
|
|
8066
|
+
lastSuccessfulPollAt: startTime,
|
|
8067
|
+
count: 0,
|
|
8068
|
+
backoff: 0
|
|
8069
|
+
};
|
|
8070
|
+
function mayPoll() {
|
|
8071
|
+
return context.count > 0 && context.inForeground;
|
|
8072
|
+
}
|
|
8073
|
+
const fsm = new FSM({}).addState("@idle").addState("@enabled").addState("@polling");
|
|
8074
|
+
fsm.addTransitions("@idle", { START: "@enabled" });
|
|
8075
|
+
fsm.addTransitions("@enabled", { STOP: "@idle", POLL: "@polling" });
|
|
8076
|
+
fsm.addTimedTransition(
|
|
8077
|
+
"@enabled",
|
|
8078
|
+
() => {
|
|
8079
|
+
const lastPoll = context.lastSuccessfulPollAt;
|
|
8080
|
+
const nextPoll = lastPoll + intervalMs;
|
|
8081
|
+
return Math.max(0, nextPoll - performance.now()) + context.backoff;
|
|
8082
|
+
},
|
|
8083
|
+
"@polling"
|
|
8084
|
+
);
|
|
8085
|
+
fsm.onEnterAsync(
|
|
8086
|
+
"@polling",
|
|
8087
|
+
async (_ctx, signal) => {
|
|
8088
|
+
await callback(signal);
|
|
8089
|
+
if (!signal.aborted) {
|
|
8090
|
+
context.lastSuccessfulPollAt = performance.now();
|
|
8091
|
+
}
|
|
8092
|
+
},
|
|
8093
|
+
// When OK
|
|
8094
|
+
() => {
|
|
8095
|
+
return {
|
|
8096
|
+
target: mayPoll() ? "@enabled" : "@idle",
|
|
8097
|
+
effect: () => {
|
|
8098
|
+
context.backoff = 0;
|
|
8099
|
+
}
|
|
8100
|
+
};
|
|
8101
|
+
},
|
|
8102
|
+
// When error
|
|
8103
|
+
() => {
|
|
8104
|
+
return {
|
|
8105
|
+
target: mayPoll() ? "@enabled" : "@idle",
|
|
8106
|
+
effect: () => {
|
|
8107
|
+
context.backoff = _nullishCoalesce(BACKOFF_DELAYS2.find((delay) => delay > context.backoff), () => ( BACKOFF_DELAYS2[BACKOFF_DELAYS2.length - 1]));
|
|
8108
|
+
}
|
|
8109
|
+
};
|
|
8110
|
+
},
|
|
8111
|
+
3e4
|
|
8112
|
+
// Abort the poll if the callback takes more than 30 seconds to complete
|
|
8113
|
+
);
|
|
8114
|
+
function startOrStop() {
|
|
8115
|
+
if (mayPoll()) {
|
|
8116
|
+
fsm.send({ type: "START" });
|
|
8117
|
+
} else {
|
|
8118
|
+
fsm.send({ type: "STOP" });
|
|
8149
8119
|
}
|
|
8150
|
-
schedule();
|
|
8151
8120
|
}
|
|
8152
|
-
function
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8121
|
+
function inc() {
|
|
8122
|
+
context.count++;
|
|
8123
|
+
startOrStop();
|
|
8124
|
+
}
|
|
8125
|
+
function dec() {
|
|
8126
|
+
context.count--;
|
|
8127
|
+
if (context.count < 0) {
|
|
8128
|
+
context.count = 0;
|
|
8158
8129
|
}
|
|
8159
|
-
|
|
8130
|
+
startOrStop();
|
|
8160
8131
|
}
|
|
8161
|
-
function
|
|
8162
|
-
if (
|
|
8163
|
-
|
|
8164
|
-
} else {
|
|
8165
|
-
stop();
|
|
8132
|
+
function pollNowIfStale() {
|
|
8133
|
+
if (performance.now() - context.lastSuccessfulPollAt > maxStaleTimeMs) {
|
|
8134
|
+
fsm.send({ type: "POLL" });
|
|
8166
8135
|
}
|
|
8167
8136
|
}
|
|
8137
|
+
function setInForeground(inForeground) {
|
|
8138
|
+
context.inForeground = inForeground;
|
|
8139
|
+
startOrStop();
|
|
8140
|
+
pollNowIfStale();
|
|
8141
|
+
}
|
|
8142
|
+
function onVisibilityChange() {
|
|
8143
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _196 => _196.visibilityState]) !== "hidden");
|
|
8144
|
+
}
|
|
8145
|
+
_optionalChain([doc, 'optionalAccess', _197 => _197.addEventListener, 'call', _198 => _198("visibilitychange", onVisibilityChange)]);
|
|
8146
|
+
_optionalChain([win, 'optionalAccess', _199 => _199.addEventListener, 'call', _200 => _200("online", onVisibilityChange)]);
|
|
8147
|
+
fsm.start();
|
|
8168
8148
|
return {
|
|
8169
|
-
|
|
8149
|
+
inc,
|
|
8150
|
+
dec,
|
|
8151
|
+
pollNowIfStale,
|
|
8152
|
+
// Internal API, used by unit tests only to simulate visibility events
|
|
8153
|
+
setInForeground
|
|
8170
8154
|
};
|
|
8171
8155
|
}
|
|
8172
8156
|
|
|
@@ -8209,8 +8193,81 @@ function shallow(a, b) {
|
|
|
8209
8193
|
return shallowObj(a, b);
|
|
8210
8194
|
}
|
|
8211
8195
|
|
|
8196
|
+
// src/lib/SortedList.ts
|
|
8197
|
+
function bisectRight(arr, x, lt) {
|
|
8198
|
+
let lo = 0;
|
|
8199
|
+
let hi = arr.length;
|
|
8200
|
+
while (lo < hi) {
|
|
8201
|
+
const mid = lo + (hi - lo >> 1);
|
|
8202
|
+
if (lt(x, arr[mid])) {
|
|
8203
|
+
hi = mid;
|
|
8204
|
+
} else {
|
|
8205
|
+
lo = mid + 1;
|
|
8206
|
+
}
|
|
8207
|
+
}
|
|
8208
|
+
return lo;
|
|
8209
|
+
}
|
|
8210
|
+
var SortedList = class _SortedList {
|
|
8211
|
+
constructor(alreadySortedList, lt) {
|
|
8212
|
+
this._lt = lt;
|
|
8213
|
+
this._data = alreadySortedList;
|
|
8214
|
+
}
|
|
8215
|
+
static from(arr, lt) {
|
|
8216
|
+
const sorted = new _SortedList([], lt);
|
|
8217
|
+
for (const item of arr) {
|
|
8218
|
+
sorted.add(item);
|
|
8219
|
+
}
|
|
8220
|
+
return sorted;
|
|
8221
|
+
}
|
|
8222
|
+
static fromAlreadySorted(alreadySorted, lt) {
|
|
8223
|
+
return new _SortedList(alreadySorted, lt);
|
|
8224
|
+
}
|
|
8225
|
+
/**
|
|
8226
|
+
* Clones the sorted list to a new instance.
|
|
8227
|
+
*/
|
|
8228
|
+
clone() {
|
|
8229
|
+
return new _SortedList(this._data.slice(), this._lt);
|
|
8230
|
+
}
|
|
8231
|
+
/**
|
|
8232
|
+
* Adds a new item to the sorted list, such that it remains sorted.
|
|
8233
|
+
*/
|
|
8234
|
+
add(value) {
|
|
8235
|
+
const idx = bisectRight(this._data, value, this._lt);
|
|
8236
|
+
this._data.splice(idx, 0, value);
|
|
8237
|
+
}
|
|
8238
|
+
/**
|
|
8239
|
+
* Removes the given value from the sorted list, if it exists. The given
|
|
8240
|
+
* value must be `===` to one of the list items. Only the first entry will be
|
|
8241
|
+
* removed if the element exists in the sorted list multiple times.
|
|
8242
|
+
*/
|
|
8243
|
+
remove(value) {
|
|
8244
|
+
const idx = this._data.indexOf(value);
|
|
8245
|
+
if (idx >= 0) {
|
|
8246
|
+
this._data.splice(idx, 1);
|
|
8247
|
+
return true;
|
|
8248
|
+
}
|
|
8249
|
+
return false;
|
|
8250
|
+
}
|
|
8251
|
+
get length() {
|
|
8252
|
+
return this._data.length;
|
|
8253
|
+
}
|
|
8254
|
+
*filter(predicate) {
|
|
8255
|
+
for (const item of this._data) {
|
|
8256
|
+
if (predicate(item)) {
|
|
8257
|
+
yield item;
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
}
|
|
8261
|
+
[Symbol.iterator]() {
|
|
8262
|
+
return this._data[Symbol.iterator]();
|
|
8263
|
+
}
|
|
8264
|
+
};
|
|
8265
|
+
|
|
8212
8266
|
// src/index.ts
|
|
8213
8267
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
8268
|
+
var CommentsApiError = HttpError;
|
|
8269
|
+
var NotificationsApiError = HttpError;
|
|
8270
|
+
|
|
8214
8271
|
|
|
8215
8272
|
|
|
8216
8273
|
|
|
@@ -8278,5 +8335,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8278
8335
|
|
|
8279
8336
|
|
|
8280
8337
|
|
|
8281
|
-
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.
|
|
8338
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.SortedList = SortedList; 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;
|
|
8282
8339
|
//# sourceMappingURL=index.js.map
|