@liveblocks/core 2.9.3-experimental1 → 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 +194 -50
- package/dist/index.d.ts +194 -50
- package/dist/index.js +667 -578
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +606 -517
- 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.
|
|
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"
|
|
@@ -1881,6 +1911,16 @@ function createBatchStore(batch) {
|
|
|
1881
1911
|
cache.set(cacheKey, state);
|
|
1882
1912
|
eventSource2.notify();
|
|
1883
1913
|
}
|
|
1914
|
+
function invalidate(inputs) {
|
|
1915
|
+
if (Array.isArray(inputs)) {
|
|
1916
|
+
for (const input of inputs) {
|
|
1917
|
+
cache.delete(getCacheKey(input));
|
|
1918
|
+
}
|
|
1919
|
+
} else {
|
|
1920
|
+
cache.clear();
|
|
1921
|
+
}
|
|
1922
|
+
eventSource2.notify();
|
|
1923
|
+
}
|
|
1884
1924
|
async function get(input) {
|
|
1885
1925
|
const cacheKey = getCacheKey(input);
|
|
1886
1926
|
if (cache.has(cacheKey)) {
|
|
@@ -1901,10 +1941,15 @@ function createBatchStore(batch) {
|
|
|
1901
1941
|
const cacheKey = getCacheKey(input);
|
|
1902
1942
|
return cache.get(cacheKey);
|
|
1903
1943
|
}
|
|
1944
|
+
function _cacheKeys() {
|
|
1945
|
+
return [...cache.keys()];
|
|
1946
|
+
}
|
|
1904
1947
|
return {
|
|
1905
1948
|
...eventSource2.observable,
|
|
1906
1949
|
get,
|
|
1907
|
-
getState
|
|
1950
|
+
getState,
|
|
1951
|
+
invalidate,
|
|
1952
|
+
_cacheKeys
|
|
1908
1953
|
};
|
|
1909
1954
|
}
|
|
1910
1955
|
|
|
@@ -2044,12 +2089,36 @@ function convertToInboxNotificationDeleteInfo(data) {
|
|
|
2044
2089
|
};
|
|
2045
2090
|
}
|
|
2046
2091
|
|
|
2047
|
-
// src/
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
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);
|
|
2053
2122
|
}
|
|
2054
2123
|
}
|
|
2055
2124
|
|
|
@@ -2076,51 +2145,79 @@ function url(strings, ...values) {
|
|
|
2076
2145
|
);
|
|
2077
2146
|
}
|
|
2078
2147
|
|
|
2079
|
-
// src/
|
|
2080
|
-
function
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
}
|
|
2086
|
-
|
|
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) {
|
|
2087
2179
|
if (!endpoint.startsWith("/v2/c/")) {
|
|
2088
|
-
raise("
|
|
2089
|
-
}
|
|
2090
|
-
const authValue = await authManager.getAuthValue({
|
|
2091
|
-
requestedScope: "comments:read"
|
|
2092
|
-
});
|
|
2093
|
-
if (authValue.type === "secret" && authValue.token.parsed.k === "acc" /* ACCESS_TOKEN */) {
|
|
2094
|
-
const userId = authValue.token.parsed.uid;
|
|
2095
|
-
currentUserIdStore.set(() => userId);
|
|
2180
|
+
raise("This client can only be used to make /v2/c/* requests");
|
|
2096
2181
|
}
|
|
2097
|
-
const url2 = urljoin(
|
|
2098
|
-
|
|
2182
|
+
const url2 = urljoin(this._baseUrl, endpoint, params);
|
|
2183
|
+
return await this._fetchPolyfill(url2, {
|
|
2099
2184
|
...options,
|
|
2100
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
|
|
2101
2189
|
..._optionalChain([options, 'optionalAccess', _45 => _45.headers]),
|
|
2102
|
-
|
|
2190
|
+
// Cannot be overriden by custom headers
|
|
2191
|
+
Authorization: `Bearer ${getBearerTokenFromAuthValue(await this._authCallback())}`,
|
|
2103
2192
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
2104
2193
|
}
|
|
2105
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);
|
|
2106
2212
|
if (!response.ok) {
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
response.status,
|
|
2114
|
-
errorBody
|
|
2115
|
-
);
|
|
2116
|
-
} catch (e3) {
|
|
2117
|
-
error3 = new NotificationsApiError(
|
|
2118
|
-
response.statusText,
|
|
2119
|
-
response.status
|
|
2120
|
-
);
|
|
2121
|
-
}
|
|
2122
|
-
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);
|
|
2123
2219
|
}
|
|
2220
|
+
throw error3;
|
|
2124
2221
|
}
|
|
2125
2222
|
let body;
|
|
2126
2223
|
try {
|
|
@@ -2130,9 +2227,103 @@ function createNotificationsApi({
|
|
|
2130
2227
|
}
|
|
2131
2228
|
return body;
|
|
2132
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);
|
|
2133
2324
|
async function getInboxNotifications(options) {
|
|
2134
2325
|
const PAGE_SIZE = 50;
|
|
2135
|
-
const json = await
|
|
2326
|
+
const json = await httpClient.get(url`/v2/c/inbox-notifications`, {
|
|
2136
2327
|
cursor: _optionalChain([options, 'optionalAccess', _46 => _46.cursor]),
|
|
2137
2328
|
limit: PAGE_SIZE
|
|
2138
2329
|
});
|
|
@@ -2145,10 +2336,12 @@ function createNotificationsApi({
|
|
|
2145
2336
|
requestedAt: new Date(json.meta.requestedAt)
|
|
2146
2337
|
};
|
|
2147
2338
|
}
|
|
2148
|
-
async function getInboxNotificationsSince(
|
|
2149
|
-
const json = await
|
|
2150
|
-
|
|
2151
|
-
|
|
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
|
+
);
|
|
2152
2345
|
return {
|
|
2153
2346
|
inboxNotifications: {
|
|
2154
2347
|
updated: json.inboxNotifications.map(convertToInboxNotificationData),
|
|
@@ -2164,25 +2357,19 @@ function createNotificationsApi({
|
|
|
2164
2357
|
};
|
|
2165
2358
|
}
|
|
2166
2359
|
async function getUnreadInboxNotificationsCount() {
|
|
2167
|
-
const { count } = await
|
|
2360
|
+
const { count } = await httpClient.get(
|
|
2361
|
+
url`/v2/c/inbox-notifications/count`
|
|
2362
|
+
);
|
|
2168
2363
|
return count;
|
|
2169
2364
|
}
|
|
2170
2365
|
async function markAllInboxNotificationsAsRead() {
|
|
2171
|
-
await
|
|
2172
|
-
|
|
2173
|
-
headers: {
|
|
2174
|
-
"Content-Type": "application/json"
|
|
2175
|
-
},
|
|
2176
|
-
body: JSON.stringify({ inboxNotificationIds: "all" })
|
|
2366
|
+
await httpClient.post(url`/v2/c/inbox-notifications/read`, {
|
|
2367
|
+
inboxNotificationIds: "all"
|
|
2177
2368
|
});
|
|
2178
2369
|
}
|
|
2179
2370
|
async function markInboxNotificationsAsRead(inboxNotificationIds) {
|
|
2180
|
-
await
|
|
2181
|
-
|
|
2182
|
-
headers: {
|
|
2183
|
-
"Content-Type": "application/json"
|
|
2184
|
-
},
|
|
2185
|
-
body: JSON.stringify({ inboxNotificationIds })
|
|
2371
|
+
await httpClient.post(url`/v2/c/inbox-notifications/read`, {
|
|
2372
|
+
inboxNotificationIds
|
|
2186
2373
|
});
|
|
2187
2374
|
}
|
|
2188
2375
|
const batchedMarkInboxNotificationsAsRead = new Batch(
|
|
@@ -2197,22 +2384,20 @@ function createNotificationsApi({
|
|
|
2197
2384
|
await batchedMarkInboxNotificationsAsRead.get(inboxNotificationId);
|
|
2198
2385
|
}
|
|
2199
2386
|
async function deleteAllInboxNotifications() {
|
|
2200
|
-
await
|
|
2201
|
-
method: "DELETE"
|
|
2202
|
-
});
|
|
2387
|
+
await httpClient.delete(url`/v2/c/inbox-notifications`);
|
|
2203
2388
|
}
|
|
2204
2389
|
async function deleteInboxNotification(inboxNotificationId) {
|
|
2205
|
-
await
|
|
2206
|
-
|
|
2207
|
-
|
|
2390
|
+
await httpClient.delete(
|
|
2391
|
+
url`/v2/c/inbox-notifications/${inboxNotificationId}`
|
|
2392
|
+
);
|
|
2208
2393
|
}
|
|
2209
2394
|
async function getUserThreads_experimental(options) {
|
|
2210
2395
|
let query;
|
|
2211
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2396
|
+
if (_optionalChain([options, 'optionalAccess', _48 => _48.query])) {
|
|
2212
2397
|
query = objectToQuery(options.query);
|
|
2213
2398
|
}
|
|
2214
2399
|
const PAGE_SIZE = 50;
|
|
2215
|
-
const json = await
|
|
2400
|
+
const json = await httpClient.get(url`/v2/c/threads`, {
|
|
2216
2401
|
cursor: options.cursor,
|
|
2217
2402
|
query,
|
|
2218
2403
|
limit: PAGE_SIZE
|
|
@@ -2227,9 +2412,11 @@ function createNotificationsApi({
|
|
|
2227
2412
|
};
|
|
2228
2413
|
}
|
|
2229
2414
|
async function getUserThreadsSince_experimental(options) {
|
|
2230
|
-
const json = await
|
|
2231
|
-
|
|
2232
|
-
|
|
2415
|
+
const json = await httpClient.get(
|
|
2416
|
+
url`/v2/c/threads/delta`,
|
|
2417
|
+
{ since: options.since.toISOString() },
|
|
2418
|
+
{ signal: options.signal }
|
|
2419
|
+
);
|
|
2233
2420
|
return {
|
|
2234
2421
|
threads: {
|
|
2235
2422
|
updated: json.threads.map(convertToThreadData),
|
|
@@ -2626,7 +2813,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
2626
2813
|
return [
|
|
2627
2814
|
{
|
|
2628
2815
|
type: 8 /* CREATE_REGISTER */,
|
|
2629
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2816
|
+
opId: _optionalChain([pool, 'optionalAccess', _49 => _49.generateOpId, 'call', _50 => _50()]),
|
|
2630
2817
|
id: this._id,
|
|
2631
2818
|
parentId,
|
|
2632
2819
|
parentKey,
|
|
@@ -2728,7 +2915,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
2728
2915
|
const ops = [];
|
|
2729
2916
|
const op = {
|
|
2730
2917
|
id: this._id,
|
|
2731
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
2918
|
+
opId: _optionalChain([pool, 'optionalAccess', _51 => _51.generateOpId, 'call', _52 => _52()]),
|
|
2732
2919
|
type: 2 /* CREATE_LIST */,
|
|
2733
2920
|
parentId,
|
|
2734
2921
|
parentKey
|
|
@@ -3005,7 +3192,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3005
3192
|
_applyInsertUndoRedo(op) {
|
|
3006
3193
|
const { id, parentKey: key } = op;
|
|
3007
3194
|
const child = creationOpToLiveNode(op);
|
|
3008
|
-
if (_optionalChain([this, 'access',
|
|
3195
|
+
if (_optionalChain([this, 'access', _53 => _53._pool, 'optionalAccess', _54 => _54.getNode, 'call', _55 => _55(id)]) !== void 0) {
|
|
3009
3196
|
return { modified: false };
|
|
3010
3197
|
}
|
|
3011
3198
|
child._attach(id, nn(this._pool));
|
|
@@ -3013,8 +3200,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3013
3200
|
const existingItemIndex = this._indexOfPosition(key);
|
|
3014
3201
|
let newKey = key;
|
|
3015
3202
|
if (existingItemIndex !== -1) {
|
|
3016
|
-
const before2 = _optionalChain([this, 'access',
|
|
3017
|
-
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]);
|
|
3018
3205
|
newKey = makePosition(before2, after2);
|
|
3019
3206
|
child._setParentLink(this, newKey);
|
|
3020
3207
|
}
|
|
@@ -3029,7 +3216,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3029
3216
|
_applySetUndoRedo(op) {
|
|
3030
3217
|
const { id, parentKey: key } = op;
|
|
3031
3218
|
const child = creationOpToLiveNode(op);
|
|
3032
|
-
if (_optionalChain([this, 'access',
|
|
3219
|
+
if (_optionalChain([this, 'access', _62 => _62._pool, 'optionalAccess', _63 => _63.getNode, 'call', _64 => _64(id)]) !== void 0) {
|
|
3033
3220
|
return { modified: false };
|
|
3034
3221
|
}
|
|
3035
3222
|
this._unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -3151,7 +3338,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3151
3338
|
} else {
|
|
3152
3339
|
this._items[existingItemIndex]._setParentLink(
|
|
3153
3340
|
this,
|
|
3154
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3341
|
+
makePosition(newKey, _optionalChain([this, 'access', _65 => _65._items, 'access', _66 => _66[existingItemIndex + 1], 'optionalAccess', _67 => _67._parentPos]))
|
|
3155
3342
|
);
|
|
3156
3343
|
const previousIndex = this._items.indexOf(child);
|
|
3157
3344
|
child._setParentLink(this, newKey);
|
|
@@ -3177,7 +3364,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3177
3364
|
if (existingItemIndex !== -1) {
|
|
3178
3365
|
this._items[existingItemIndex]._setParentLink(
|
|
3179
3366
|
this,
|
|
3180
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3367
|
+
makePosition(newKey, _optionalChain([this, 'access', _68 => _68._items, 'access', _69 => _69[existingItemIndex + 1], 'optionalAccess', _70 => _70._parentPos]))
|
|
3181
3368
|
);
|
|
3182
3369
|
}
|
|
3183
3370
|
child._setParentLink(this, newKey);
|
|
@@ -3196,7 +3383,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3196
3383
|
if (existingItemIndex !== -1) {
|
|
3197
3384
|
this._items[existingItemIndex]._setParentLink(
|
|
3198
3385
|
this,
|
|
3199
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3386
|
+
makePosition(newKey, _optionalChain([this, 'access', _71 => _71._items, 'access', _72 => _72[existingItemIndex + 1], 'optionalAccess', _73 => _73._parentPos]))
|
|
3200
3387
|
);
|
|
3201
3388
|
}
|
|
3202
3389
|
child._setParentLink(this, newKey);
|
|
@@ -3224,7 +3411,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3224
3411
|
if (existingItemIndex !== -1) {
|
|
3225
3412
|
this._items[existingItemIndex]._setParentLink(
|
|
3226
3413
|
this,
|
|
3227
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
3414
|
+
makePosition(newKey, _optionalChain([this, 'access', _74 => _74._items, 'access', _75 => _75[existingItemIndex + 1], 'optionalAccess', _76 => _76._parentPos]))
|
|
3228
3415
|
);
|
|
3229
3416
|
}
|
|
3230
3417
|
child._setParentLink(this, newKey);
|
|
@@ -3282,7 +3469,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3282
3469
|
* @param element The element to add to the end of the LiveList.
|
|
3283
3470
|
*/
|
|
3284
3471
|
push(element) {
|
|
3285
|
-
_optionalChain([this, 'access',
|
|
3472
|
+
_optionalChain([this, 'access', _77 => _77._pool, 'optionalAccess', _78 => _78.assertStorageIsWritable, 'call', _79 => _79()]);
|
|
3286
3473
|
return this.insert(element, this.length);
|
|
3287
3474
|
}
|
|
3288
3475
|
/**
|
|
@@ -3291,7 +3478,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3291
3478
|
* @param index The index at which you want to insert the element.
|
|
3292
3479
|
*/
|
|
3293
3480
|
insert(element, index) {
|
|
3294
|
-
_optionalChain([this, 'access',
|
|
3481
|
+
_optionalChain([this, 'access', _80 => _80._pool, 'optionalAccess', _81 => _81.assertStorageIsWritable, 'call', _82 => _82()]);
|
|
3295
3482
|
if (index < 0 || index > this._items.length) {
|
|
3296
3483
|
throw new Error(
|
|
3297
3484
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this._items.length}`
|
|
@@ -3321,7 +3508,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3321
3508
|
* @param targetIndex The index where the element should be after moving.
|
|
3322
3509
|
*/
|
|
3323
3510
|
move(index, targetIndex) {
|
|
3324
|
-
_optionalChain([this, 'access',
|
|
3511
|
+
_optionalChain([this, 'access', _83 => _83._pool, 'optionalAccess', _84 => _84.assertStorageIsWritable, 'call', _85 => _85()]);
|
|
3325
3512
|
if (targetIndex < 0) {
|
|
3326
3513
|
throw new Error("targetIndex cannot be less than 0");
|
|
3327
3514
|
}
|
|
@@ -3379,7 +3566,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3379
3566
|
* @param index The index of the element to delete
|
|
3380
3567
|
*/
|
|
3381
3568
|
delete(index) {
|
|
3382
|
-
_optionalChain([this, 'access',
|
|
3569
|
+
_optionalChain([this, 'access', _86 => _86._pool, 'optionalAccess', _87 => _87.assertStorageIsWritable, 'call', _88 => _88()]);
|
|
3383
3570
|
if (index < 0 || index >= this._items.length) {
|
|
3384
3571
|
throw new Error(
|
|
3385
3572
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
@@ -3412,7 +3599,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3412
3599
|
}
|
|
3413
3600
|
}
|
|
3414
3601
|
clear() {
|
|
3415
|
-
_optionalChain([this, 'access',
|
|
3602
|
+
_optionalChain([this, 'access', _89 => _89._pool, 'optionalAccess', _90 => _90.assertStorageIsWritable, 'call', _91 => _91()]);
|
|
3416
3603
|
if (this._pool) {
|
|
3417
3604
|
const ops = [];
|
|
3418
3605
|
const reverseOps = [];
|
|
@@ -3446,7 +3633,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3446
3633
|
}
|
|
3447
3634
|
}
|
|
3448
3635
|
set(index, item) {
|
|
3449
|
-
_optionalChain([this, 'access',
|
|
3636
|
+
_optionalChain([this, 'access', _92 => _92._pool, 'optionalAccess', _93 => _93.assertStorageIsWritable, 'call', _94 => _94()]);
|
|
3450
3637
|
if (index < 0 || index >= this._items.length) {
|
|
3451
3638
|
throw new Error(
|
|
3452
3639
|
`Cannot set list item at index "${index}". index should be between 0 and ${this._items.length - 1}`
|
|
@@ -3594,7 +3781,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
3594
3781
|
_shiftItemPosition(index, key) {
|
|
3595
3782
|
const shiftedPosition = makePosition(
|
|
3596
3783
|
key,
|
|
3597
|
-
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
|
|
3598
3785
|
);
|
|
3599
3786
|
this._items[index]._setParentLink(this, shiftedPosition);
|
|
3600
3787
|
}
|
|
@@ -3724,7 +3911,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3724
3911
|
const ops = [];
|
|
3725
3912
|
const op = {
|
|
3726
3913
|
id: this._id,
|
|
3727
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
3914
|
+
opId: _optionalChain([pool, 'optionalAccess', _98 => _98.generateOpId, 'call', _99 => _99()]),
|
|
3728
3915
|
type: 7 /* CREATE_MAP */,
|
|
3729
3916
|
parentId,
|
|
3730
3917
|
parentKey
|
|
@@ -3871,7 +4058,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3871
4058
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
3872
4059
|
*/
|
|
3873
4060
|
set(key, value) {
|
|
3874
|
-
_optionalChain([this, 'access',
|
|
4061
|
+
_optionalChain([this, 'access', _100 => _100._pool, 'optionalAccess', _101 => _101.assertStorageIsWritable, 'call', _102 => _102()]);
|
|
3875
4062
|
const oldValue = this._map.get(key);
|
|
3876
4063
|
if (oldValue) {
|
|
3877
4064
|
oldValue._detach();
|
|
@@ -3917,7 +4104,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
3917
4104
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
3918
4105
|
*/
|
|
3919
4106
|
delete(key) {
|
|
3920
|
-
_optionalChain([this, 'access',
|
|
4107
|
+
_optionalChain([this, 'access', _103 => _103._pool, 'optionalAccess', _104 => _104.assertStorageIsWritable, 'call', _105 => _105()]);
|
|
3921
4108
|
const item = this._map.get(key);
|
|
3922
4109
|
if (item === void 0) {
|
|
3923
4110
|
return false;
|
|
@@ -4095,7 +4282,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4095
4282
|
if (this._id === void 0) {
|
|
4096
4283
|
throw new Error("Cannot serialize item is not attached");
|
|
4097
4284
|
}
|
|
4098
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
4285
|
+
const opId = _optionalChain([pool, 'optionalAccess', _106 => _106.generateOpId, 'call', _107 => _107()]);
|
|
4099
4286
|
const ops = [];
|
|
4100
4287
|
const op = {
|
|
4101
4288
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -4373,7 +4560,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4373
4560
|
* @param value The value of the property to add
|
|
4374
4561
|
*/
|
|
4375
4562
|
set(key, value) {
|
|
4376
|
-
_optionalChain([this, 'access',
|
|
4563
|
+
_optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.assertStorageIsWritable, 'call', _110 => _110()]);
|
|
4377
4564
|
this.update({ [key]: value });
|
|
4378
4565
|
}
|
|
4379
4566
|
/**
|
|
@@ -4388,7 +4575,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4388
4575
|
* @param key The key of the property to delete
|
|
4389
4576
|
*/
|
|
4390
4577
|
delete(key) {
|
|
4391
|
-
_optionalChain([this, 'access',
|
|
4578
|
+
_optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.assertStorageIsWritable, 'call', _113 => _113()]);
|
|
4392
4579
|
const keyAsString = key;
|
|
4393
4580
|
const oldValue = this._map.get(keyAsString);
|
|
4394
4581
|
if (oldValue === void 0) {
|
|
@@ -4441,7 +4628,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
4441
4628
|
* @param patch The object used to overrides properties
|
|
4442
4629
|
*/
|
|
4443
4630
|
update(patch) {
|
|
4444
|
-
_optionalChain([this, 'access',
|
|
4631
|
+
_optionalChain([this, 'access', _114 => _114._pool, 'optionalAccess', _115 => _115.assertStorageIsWritable, 'call', _116 => _116()]);
|
|
4445
4632
|
if (this._pool === void 0 || this._id === void 0) {
|
|
4446
4633
|
for (const key in patch) {
|
|
4447
4634
|
const newValue = patch[key];
|
|
@@ -4814,36 +5001,6 @@ function findNonSerializableValue(value, path = "") {
|
|
|
4814
5001
|
return false;
|
|
4815
5002
|
}
|
|
4816
5003
|
|
|
4817
|
-
// src/lib/autoRetry.ts
|
|
4818
|
-
async function autoRetry(promiseFn, maxTries, backoff, throwError) {
|
|
4819
|
-
const fallbackBackoff = backoff.length > 0 ? backoff[backoff.length - 1] : 0;
|
|
4820
|
-
let attempt = 0;
|
|
4821
|
-
while (true) {
|
|
4822
|
-
attempt++;
|
|
4823
|
-
const promise = promiseFn();
|
|
4824
|
-
try {
|
|
4825
|
-
return await promise;
|
|
4826
|
-
} catch (err) {
|
|
4827
|
-
if (_optionalChain([throwError, 'optionalCall', _116 => _116(err)]) || err instanceof StopRetrying2) {
|
|
4828
|
-
throw err;
|
|
4829
|
-
}
|
|
4830
|
-
if (attempt >= maxTries) {
|
|
4831
|
-
throw new Error(`Failed after ${maxTries} attempts: ${String(err)}`);
|
|
4832
|
-
}
|
|
4833
|
-
}
|
|
4834
|
-
const delay = _nullishCoalesce(backoff[attempt - 1], () => ( fallbackBackoff));
|
|
4835
|
-
warn(
|
|
4836
|
-
`Attempt ${attempt} was unsuccessful. Retrying in ${delay} milliseconds.`
|
|
4837
|
-
);
|
|
4838
|
-
await wait(delay);
|
|
4839
|
-
}
|
|
4840
|
-
}
|
|
4841
|
-
var StopRetrying2 = class extends Error {
|
|
4842
|
-
constructor(reason) {
|
|
4843
|
-
super(reason);
|
|
4844
|
-
}
|
|
4845
|
-
};
|
|
4846
|
-
|
|
4847
5004
|
// src/lib/chunk.ts
|
|
4848
5005
|
function chunk(array, size) {
|
|
4849
5006
|
const chunks = [];
|
|
@@ -5301,14 +5458,6 @@ function splitFileIntoParts(file) {
|
|
|
5301
5458
|
}
|
|
5302
5459
|
return parts;
|
|
5303
5460
|
}
|
|
5304
|
-
var CommentsApiError = class extends Error {
|
|
5305
|
-
constructor(message, status, details) {
|
|
5306
|
-
super(message);
|
|
5307
|
-
this.message = message;
|
|
5308
|
-
this.status = status;
|
|
5309
|
-
this.details = details;
|
|
5310
|
-
}
|
|
5311
|
-
};
|
|
5312
5461
|
function createRoom(options, config) {
|
|
5313
5462
|
const initialPresence = options.initialPresence;
|
|
5314
5463
|
const initialStorage = options.initialStorage;
|
|
@@ -5527,128 +5676,88 @@ function createRoom(options, config) {
|
|
|
5527
5676
|
ydoc: makeEventSource(),
|
|
5528
5677
|
comments: makeEventSource()
|
|
5529
5678
|
};
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
}
|
|
5546
|
-
async function streamFetch(authValue, roomId) {
|
|
5547
|
-
return fetchClientApi(url`/v2/c/rooms/${roomId}/storage`, authValue, {
|
|
5548
|
-
method: "GET",
|
|
5549
|
-
headers: {
|
|
5550
|
-
"Content-Type": "application/json"
|
|
5551
|
-
}
|
|
5552
|
-
});
|
|
5553
|
-
}
|
|
5554
|
-
async function httpPostToRoom(endpoint, body) {
|
|
5555
|
-
if (!managedSocket.authValue) {
|
|
5556
|
-
throw new Error("Not authorized");
|
|
5557
|
-
}
|
|
5558
|
-
return fetchClientApi(
|
|
5559
|
-
endpoint === "/send-message" ? url`/v2/c/rooms/${config.roomId}/send-message` : url`/v2/c/rooms/${config.roomId}/text-metadata`,
|
|
5560
|
-
managedSocket.authValue,
|
|
5561
|
-
{
|
|
5562
|
-
method: "POST",
|
|
5563
|
-
headers: {
|
|
5564
|
-
"Content-Type": "application/json"
|
|
5565
|
-
},
|
|
5566
|
-
body: JSON.stringify(body)
|
|
5567
|
-
}
|
|
5568
|
-
);
|
|
5569
|
-
}
|
|
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
|
+
);
|
|
5570
5694
|
async function createTextMention(userId, mentionId) {
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
url`/v2/c/rooms/${config.roomId}/text-mentions`,
|
|
5576
|
-
managedSocket.authValue,
|
|
5577
|
-
{
|
|
5578
|
-
method: "POST",
|
|
5579
|
-
headers: {
|
|
5580
|
-
"Content-Type": "application/json"
|
|
5581
|
-
},
|
|
5582
|
-
body: JSON.stringify({
|
|
5583
|
-
userId,
|
|
5584
|
-
mentionId
|
|
5585
|
-
})
|
|
5586
|
-
}
|
|
5587
|
-
);
|
|
5695
|
+
await httpClient1.rawPost(url`/v2/c/rooms/${config.roomId}/text-mentions`, {
|
|
5696
|
+
userId,
|
|
5697
|
+
mentionId
|
|
5698
|
+
});
|
|
5588
5699
|
}
|
|
5589
5700
|
async function deleteTextMention(mentionId) {
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
}
|
|
5593
|
-
return fetchClientApi(
|
|
5594
|
-
url`/v2/c/rooms/${config.roomId}/text-mentions/${mentionId}`,
|
|
5595
|
-
managedSocket.authValue,
|
|
5596
|
-
{
|
|
5597
|
-
method: "DELETE"
|
|
5598
|
-
}
|
|
5701
|
+
await httpClient1.rawDelete(
|
|
5702
|
+
url`/v2/c/rooms/${config.roomId}/text-mentions/${mentionId}`
|
|
5599
5703
|
);
|
|
5600
5704
|
}
|
|
5601
5705
|
async function reportTextEditor(type, rootKey) {
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
{
|
|
5607
|
-
method: "POST",
|
|
5608
|
-
headers: { "Content-Type": "application/json" },
|
|
5609
|
-
body: JSON.stringify({ type, rootKey })
|
|
5610
|
-
}
|
|
5611
|
-
);
|
|
5706
|
+
await httpClient2.rawPost(url`/v2/c/rooms/${config.roomId}/text-metadata`, {
|
|
5707
|
+
type,
|
|
5708
|
+
rootKey
|
|
5709
|
+
});
|
|
5612
5710
|
}
|
|
5613
5711
|
async function listTextVersions() {
|
|
5614
|
-
const
|
|
5615
|
-
return
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
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 }
|
|
5621
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
|
+
};
|
|
5622
5738
|
}
|
|
5623
5739
|
async function getTextVersion(versionId) {
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
url`/v2/c/rooms/${config.roomId}/y-version/${versionId}`,
|
|
5627
|
-
authValue,
|
|
5628
|
-
{ method: "GET" }
|
|
5740
|
+
return httpClient2.rawGet(
|
|
5741
|
+
url`/v2/c/rooms/${config.roomId}/y-version/${versionId}`
|
|
5629
5742
|
);
|
|
5630
5743
|
}
|
|
5631
5744
|
async function createTextVersion() {
|
|
5632
|
-
|
|
5633
|
-
return fetchClientApi(
|
|
5634
|
-
url`/v2/c/rooms/${config.roomId}/version`,
|
|
5635
|
-
authValue,
|
|
5636
|
-
{ method: "POST" }
|
|
5637
|
-
);
|
|
5745
|
+
await httpClient2.rawPost(url`/v2/c/rooms/${config.roomId}/version`);
|
|
5638
5746
|
}
|
|
5639
5747
|
function sendMessages(messages) {
|
|
5640
5748
|
const serializedPayload = JSON.stringify(messages);
|
|
5641
|
-
const nonce = _optionalChain([context, 'access',
|
|
5749
|
+
const nonce = _optionalChain([context, 'access', _130 => _130.dynamicSessionInfo, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.nonce]);
|
|
5642
5750
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5643
5751
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5644
5752
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
5645
|
-
void
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
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();
|
|
5650
5759
|
}
|
|
5651
|
-
);
|
|
5760
|
+
});
|
|
5652
5761
|
warn(
|
|
5653
5762
|
"Message was too large for websockets and sent over HTTP instead"
|
|
5654
5763
|
);
|
|
@@ -5700,7 +5809,7 @@ function createRoom(options, config) {
|
|
|
5700
5809
|
} else {
|
|
5701
5810
|
context.root = LiveObject._fromItems(message.items, pool);
|
|
5702
5811
|
}
|
|
5703
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
5812
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.canWrite]), () => ( true));
|
|
5704
5813
|
const stackSizeBefore = context.undoStack.length;
|
|
5705
5814
|
for (const key in context.initialStorage) {
|
|
5706
5815
|
if (context.root.get(key) === void 0) {
|
|
@@ -5905,7 +6014,7 @@ function createRoom(options, config) {
|
|
|
5905
6014
|
}
|
|
5906
6015
|
context.myPresence.patch(patch);
|
|
5907
6016
|
if (context.activeBatch) {
|
|
5908
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6017
|
+
if (_optionalChain([options2, 'optionalAccess', _135 => _135.addToHistory])) {
|
|
5909
6018
|
context.activeBatch.reverseOps.unshift({
|
|
5910
6019
|
type: "presence",
|
|
5911
6020
|
data: oldValues
|
|
@@ -5915,7 +6024,7 @@ function createRoom(options, config) {
|
|
|
5915
6024
|
} else {
|
|
5916
6025
|
flushNowOrSoon();
|
|
5917
6026
|
batchUpdates(() => {
|
|
5918
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6027
|
+
if (_optionalChain([options2, 'optionalAccess', _136 => _136.addToHistory])) {
|
|
5919
6028
|
addToUndoStack(
|
|
5920
6029
|
[{ type: "presence", data: oldValues }],
|
|
5921
6030
|
doNotBatchUpdates
|
|
@@ -6113,7 +6222,7 @@ function createRoom(options, config) {
|
|
|
6113
6222
|
if (process.env.NODE_ENV !== "production") {
|
|
6114
6223
|
const traces = /* @__PURE__ */ new Set();
|
|
6115
6224
|
for (const opId of message.opIds) {
|
|
6116
|
-
const trace = _optionalChain([context, 'access',
|
|
6225
|
+
const trace = _optionalChain([context, 'access', _137 => _137.opStackTraces, 'optionalAccess', _138 => _138.get, 'call', _139 => _139(opId)]);
|
|
6117
6226
|
if (trace) {
|
|
6118
6227
|
traces.add(trace);
|
|
6119
6228
|
}
|
|
@@ -6247,15 +6356,15 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6247
6356
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
6248
6357
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
6249
6358
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
6250
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
6359
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _140 => _140()]);
|
|
6251
6360
|
notifyStorageStatus();
|
|
6252
6361
|
eventHub.storageDidLoad.notify();
|
|
6253
6362
|
}
|
|
6254
6363
|
async function streamStorage() {
|
|
6255
|
-
if (!managedSocket.authValue)
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6364
|
+
if (!managedSocket.authValue) return;
|
|
6365
|
+
const result = await httpClient1.rawGet(
|
|
6366
|
+
url`/v2/c/rooms/${config.roomId}/storage`
|
|
6367
|
+
);
|
|
6259
6368
|
const items = await result.json();
|
|
6260
6369
|
processInitialStorage({ type: 200 /* INITIAL_STORAGE_STATE */, items });
|
|
6261
6370
|
}
|
|
@@ -6464,117 +6573,48 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6464
6573
|
ydoc: eventHub.ydoc.observable,
|
|
6465
6574
|
comments: eventHub.comments.observable
|
|
6466
6575
|
};
|
|
6467
|
-
async function fetchCommentsApi(endpoint, params, options2) {
|
|
6468
|
-
const authValue = await delegates.authenticate();
|
|
6469
|
-
return fetchClientApi(endpoint, authValue, options2, params);
|
|
6470
|
-
}
|
|
6471
|
-
async function fetchCommentsJson(endpoint, options2, params) {
|
|
6472
|
-
const response = await fetchCommentsApi(endpoint, params, options2);
|
|
6473
|
-
if (!response.ok) {
|
|
6474
|
-
if (response.status >= 400 && response.status < 600) {
|
|
6475
|
-
let error3;
|
|
6476
|
-
try {
|
|
6477
|
-
const errorBody = await response.json();
|
|
6478
|
-
error3 = new CommentsApiError(
|
|
6479
|
-
errorBody.message,
|
|
6480
|
-
response.status,
|
|
6481
|
-
errorBody
|
|
6482
|
-
);
|
|
6483
|
-
} catch (e5) {
|
|
6484
|
-
error3 = new CommentsApiError(response.statusText, response.status);
|
|
6485
|
-
}
|
|
6486
|
-
throw error3;
|
|
6487
|
-
}
|
|
6488
|
-
}
|
|
6489
|
-
let body;
|
|
6490
|
-
try {
|
|
6491
|
-
body = await response.json();
|
|
6492
|
-
} catch (e6) {
|
|
6493
|
-
body = {};
|
|
6494
|
-
}
|
|
6495
|
-
return body;
|
|
6496
|
-
}
|
|
6497
6576
|
async function getThreadsSince(options2) {
|
|
6498
|
-
const
|
|
6577
|
+
const result = await httpClient2.get(
|
|
6499
6578
|
url`/v2/c/rooms/${config.roomId}/threads/delta`,
|
|
6500
|
-
{ since: _optionalChain([options2, 'optionalAccess',
|
|
6501
|
-
{
|
|
6502
|
-
headers: {
|
|
6503
|
-
"Content-Type": "application/json"
|
|
6504
|
-
}
|
|
6505
|
-
}
|
|
6579
|
+
{ since: _optionalChain([options2, 'optionalAccess', _141 => _141.since, 'optionalAccess', _142 => _142.toISOString, 'call', _143 => _143()]) },
|
|
6580
|
+
{ signal: options2.signal }
|
|
6506
6581
|
);
|
|
6507
|
-
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
requestedAt: new Date(json.meta.requestedAt)
|
|
6521
|
-
};
|
|
6522
|
-
} else if (response.status === 404) {
|
|
6523
|
-
return {
|
|
6524
|
-
threads: {
|
|
6525
|
-
updated: [],
|
|
6526
|
-
deleted: []
|
|
6527
|
-
},
|
|
6528
|
-
inboxNotifications: {
|
|
6529
|
-
updated: [],
|
|
6530
|
-
deleted: []
|
|
6531
|
-
},
|
|
6532
|
-
requestedAt: /* @__PURE__ */ new Date()
|
|
6533
|
-
};
|
|
6534
|
-
} else {
|
|
6535
|
-
throw new Error("There was an error while getting threads.");
|
|
6536
|
-
}
|
|
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
|
+
};
|
|
6537
6595
|
}
|
|
6538
6596
|
async function getThreads(options2) {
|
|
6539
6597
|
let query;
|
|
6540
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
6598
|
+
if (_optionalChain([options2, 'optionalAccess', _144 => _144.query])) {
|
|
6541
6599
|
query = objectToQuery(options2.query);
|
|
6542
6600
|
}
|
|
6543
6601
|
const PAGE_SIZE = 50;
|
|
6544
|
-
const
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
inboxNotifications: json.inboxNotifications.map(
|
|
6558
|
-
convertToInboxNotificationData
|
|
6559
|
-
),
|
|
6560
|
-
nextCursor: json.meta.nextCursor,
|
|
6561
|
-
requestedAt: new Date(json.meta.requestedAt)
|
|
6562
|
-
};
|
|
6563
|
-
} else if (response.status === 404) {
|
|
6564
|
-
return {
|
|
6565
|
-
threads: [],
|
|
6566
|
-
inboxNotifications: [],
|
|
6567
|
-
deletedThreads: [],
|
|
6568
|
-
deletedInboxNotifications: [],
|
|
6569
|
-
nextCursor: null,
|
|
6570
|
-
requestedAt: /* @__PURE__ */ new Date()
|
|
6571
|
-
};
|
|
6572
|
-
} else {
|
|
6573
|
-
throw new Error("There was an error while getting threads.");
|
|
6574
|
-
}
|
|
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
|
+
};
|
|
6575
6615
|
}
|
|
6576
6616
|
async function getThread(threadId) {
|
|
6577
|
-
const response = await
|
|
6617
|
+
const response = await httpClient2.rawGet(
|
|
6578
6618
|
url`/v2/c/rooms/${config.roomId}/thread-with-notification/${threadId}`
|
|
6579
6619
|
);
|
|
6580
6620
|
if (response.ok) {
|
|
@@ -6599,57 +6639,42 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6599
6639
|
threadId = createThreadId(),
|
|
6600
6640
|
attachmentIds
|
|
6601
6641
|
}) {
|
|
6602
|
-
const thread = await
|
|
6642
|
+
const thread = await httpClient2.post(
|
|
6603
6643
|
url`/v2/c/rooms/${config.roomId}/threads`,
|
|
6604
6644
|
{
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6645
|
+
id: threadId,
|
|
6646
|
+
comment: {
|
|
6647
|
+
id: commentId,
|
|
6648
|
+
body,
|
|
6649
|
+
attachmentIds
|
|
6608
6650
|
},
|
|
6609
|
-
|
|
6610
|
-
id: threadId,
|
|
6611
|
-
comment: {
|
|
6612
|
-
id: commentId,
|
|
6613
|
-
body,
|
|
6614
|
-
attachmentIds
|
|
6615
|
-
},
|
|
6616
|
-
metadata
|
|
6617
|
-
})
|
|
6651
|
+
metadata
|
|
6618
6652
|
}
|
|
6619
6653
|
);
|
|
6620
6654
|
return convertToThreadData(thread);
|
|
6621
6655
|
}
|
|
6622
6656
|
async function deleteThread(threadId) {
|
|
6623
|
-
await
|
|
6624
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}
|
|
6625
|
-
{ method: "DELETE" }
|
|
6657
|
+
await httpClient2.delete(
|
|
6658
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}`
|
|
6626
6659
|
);
|
|
6627
6660
|
}
|
|
6628
6661
|
async function editThreadMetadata({
|
|
6629
6662
|
metadata,
|
|
6630
6663
|
threadId
|
|
6631
6664
|
}) {
|
|
6632
|
-
return await
|
|
6665
|
+
return await httpClient2.post(
|
|
6633
6666
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/metadata`,
|
|
6634
|
-
|
|
6635
|
-
method: "POST",
|
|
6636
|
-
headers: {
|
|
6637
|
-
"Content-Type": "application/json"
|
|
6638
|
-
},
|
|
6639
|
-
body: JSON.stringify(metadata)
|
|
6640
|
-
}
|
|
6667
|
+
metadata
|
|
6641
6668
|
);
|
|
6642
6669
|
}
|
|
6643
6670
|
async function markThreadAsResolved(threadId) {
|
|
6644
|
-
await
|
|
6645
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-resolved
|
|
6646
|
-
{ method: "POST" }
|
|
6671
|
+
await httpClient2.post(
|
|
6672
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-resolved`
|
|
6647
6673
|
);
|
|
6648
6674
|
}
|
|
6649
6675
|
async function markThreadAsUnresolved(threadId) {
|
|
6650
|
-
await
|
|
6651
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-unresolved
|
|
6652
|
-
{ method: "POST" }
|
|
6676
|
+
await httpClient2.post(
|
|
6677
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/mark-as-unresolved`
|
|
6653
6678
|
);
|
|
6654
6679
|
}
|
|
6655
6680
|
async function createComment({
|
|
@@ -6658,18 +6683,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6658
6683
|
body,
|
|
6659
6684
|
attachmentIds
|
|
6660
6685
|
}) {
|
|
6661
|
-
const comment = await
|
|
6686
|
+
const comment = await httpClient2.post(
|
|
6662
6687
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments`,
|
|
6663
6688
|
{
|
|
6664
|
-
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
},
|
|
6668
|
-
body: JSON.stringify({
|
|
6669
|
-
id: commentId,
|
|
6670
|
-
body,
|
|
6671
|
-
attachmentIds
|
|
6672
|
-
})
|
|
6689
|
+
id: commentId,
|
|
6690
|
+
body,
|
|
6691
|
+
attachmentIds
|
|
6673
6692
|
}
|
|
6674
6693
|
);
|
|
6675
6694
|
return convertToCommentData(comment);
|
|
@@ -6680,17 +6699,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6680
6699
|
body,
|
|
6681
6700
|
attachmentIds
|
|
6682
6701
|
}) {
|
|
6683
|
-
const comment = await
|
|
6702
|
+
const comment = await httpClient2.post(
|
|
6684
6703
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`,
|
|
6685
6704
|
{
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
"Content-Type": "application/json"
|
|
6689
|
-
},
|
|
6690
|
-
body: JSON.stringify({
|
|
6691
|
-
body,
|
|
6692
|
-
attachmentIds
|
|
6693
|
-
})
|
|
6705
|
+
body,
|
|
6706
|
+
attachmentIds
|
|
6694
6707
|
}
|
|
6695
6708
|
);
|
|
6696
6709
|
return convertToCommentData(comment);
|
|
@@ -6699,9 +6712,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6699
6712
|
threadId,
|
|
6700
6713
|
commentId
|
|
6701
6714
|
}) {
|
|
6702
|
-
await
|
|
6703
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}
|
|
6704
|
-
{ method: "DELETE" }
|
|
6715
|
+
await httpClient2.delete(
|
|
6716
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}`
|
|
6705
6717
|
);
|
|
6706
6718
|
}
|
|
6707
6719
|
async function addReaction({
|
|
@@ -6709,15 +6721,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6709
6721
|
commentId,
|
|
6710
6722
|
emoji
|
|
6711
6723
|
}) {
|
|
6712
|
-
const reaction = await
|
|
6724
|
+
const reaction = await httpClient2.post(
|
|
6713
6725
|
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions`,
|
|
6714
|
-
{
|
|
6715
|
-
method: "POST",
|
|
6716
|
-
headers: {
|
|
6717
|
-
"Content-Type": "application/json"
|
|
6718
|
-
},
|
|
6719
|
-
body: JSON.stringify({ emoji })
|
|
6720
|
-
}
|
|
6726
|
+
{ emoji }
|
|
6721
6727
|
);
|
|
6722
6728
|
return convertToCommentUserReaction(reaction);
|
|
6723
6729
|
}
|
|
@@ -6726,9 +6732,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6726
6732
|
commentId,
|
|
6727
6733
|
emoji
|
|
6728
6734
|
}) {
|
|
6729
|
-
await
|
|
6730
|
-
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions/${emoji}
|
|
6731
|
-
{ method: "DELETE" }
|
|
6735
|
+
await httpClient2.delete(
|
|
6736
|
+
url`/v2/c/rooms/${config.roomId}/threads/${threadId}/comments/${commentId}/reactions/${emoji}`
|
|
6732
6737
|
);
|
|
6733
6738
|
}
|
|
6734
6739
|
function prepareAttachment(file) {
|
|
@@ -6748,30 +6753,25 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6748
6753
|
`Upload of attachment ${attachment.id} was aborted.`,
|
|
6749
6754
|
"AbortError"
|
|
6750
6755
|
) : void 0;
|
|
6751
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6756
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _146 => _146.aborted])) {
|
|
6752
6757
|
throw abortError;
|
|
6753
6758
|
}
|
|
6754
6759
|
const handleRetryError = (err) => {
|
|
6755
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6760
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _147 => _147.aborted])) {
|
|
6756
6761
|
throw abortError;
|
|
6757
6762
|
}
|
|
6758
|
-
if (err instanceof
|
|
6763
|
+
if (err instanceof HttpError && err.status === 413) {
|
|
6759
6764
|
throw err;
|
|
6760
6765
|
}
|
|
6761
6766
|
return false;
|
|
6762
6767
|
};
|
|
6763
6768
|
if (attachment.size <= ATTACHMENT_PART_SIZE) {
|
|
6764
6769
|
return autoRetry(
|
|
6765
|
-
() =>
|
|
6770
|
+
() => httpClient2.putBlob(
|
|
6766
6771
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/upload/${encodeURIComponent(attachment.name)}`,
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
signal: abortSignal
|
|
6771
|
-
},
|
|
6772
|
-
{
|
|
6773
|
-
fileSize: attachment.size
|
|
6774
|
-
}
|
|
6772
|
+
attachment.file,
|
|
6773
|
+
{ fileSize: attachment.size },
|
|
6774
|
+
{ signal: abortSignal }
|
|
6775
6775
|
),
|
|
6776
6776
|
RETRY_ATTEMPTS,
|
|
6777
6777
|
RETRY_DELAYS,
|
|
@@ -6781,15 +6781,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6781
6781
|
let uploadId;
|
|
6782
6782
|
const uploadedParts = [];
|
|
6783
6783
|
const createMultiPartUpload = await autoRetry(
|
|
6784
|
-
() =>
|
|
6784
|
+
() => httpClient2.post(
|
|
6785
6785
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${encodeURIComponent(attachment.name)}`,
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
},
|
|
6790
|
-
{
|
|
6791
|
-
fileSize: attachment.size
|
|
6792
|
-
}
|
|
6786
|
+
void 0,
|
|
6787
|
+
{ signal: abortSignal },
|
|
6788
|
+
{ fileSize: attachment.size }
|
|
6793
6789
|
),
|
|
6794
6790
|
RETRY_ATTEMPTS,
|
|
6795
6791
|
RETRY_DELAYS,
|
|
@@ -6798,7 +6794,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6798
6794
|
try {
|
|
6799
6795
|
uploadId = createMultiPartUpload.uploadId;
|
|
6800
6796
|
const parts = splitFileIntoParts(attachment.file);
|
|
6801
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6797
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _148 => _148.aborted])) {
|
|
6802
6798
|
throw abortError;
|
|
6803
6799
|
}
|
|
6804
6800
|
const batches = chunk(parts, ATTACHMENT_PART_BATCH_SIZE);
|
|
@@ -6807,13 +6803,11 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6807
6803
|
for (const { part, partNumber } of parts2) {
|
|
6808
6804
|
uploadedPartsPromises.push(
|
|
6809
6805
|
autoRetry(
|
|
6810
|
-
() =>
|
|
6806
|
+
() => httpClient2.putBlob(
|
|
6811
6807
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${createMultiPartUpload.uploadId}/${String(partNumber)}`,
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
signal: abortSignal
|
|
6816
|
-
}
|
|
6808
|
+
part,
|
|
6809
|
+
void 0,
|
|
6810
|
+
{ signal: abortSignal }
|
|
6817
6811
|
),
|
|
6818
6812
|
RETRY_ATTEMPTS,
|
|
6819
6813
|
RETRY_DELAYS,
|
|
@@ -6823,32 +6817,22 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6823
6817
|
}
|
|
6824
6818
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
6825
6819
|
}
|
|
6826
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
6820
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _149 => _149.aborted])) {
|
|
6827
6821
|
throw abortError;
|
|
6828
6822
|
}
|
|
6829
6823
|
const sortedUploadedParts = uploadedParts.sort(
|
|
6830
6824
|
(a, b) => a.partNumber - b.partNumber
|
|
6831
6825
|
);
|
|
6832
|
-
return
|
|
6826
|
+
return httpClient2.post(
|
|
6833
6827
|
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}/complete`,
|
|
6834
|
-
{
|
|
6835
|
-
|
|
6836
|
-
headers: {
|
|
6837
|
-
"Content-Type": "application/json"
|
|
6838
|
-
},
|
|
6839
|
-
body: JSON.stringify({ parts: sortedUploadedParts }),
|
|
6840
|
-
signal: abortSignal
|
|
6841
|
-
}
|
|
6828
|
+
{ parts: sortedUploadedParts },
|
|
6829
|
+
{ signal: abortSignal }
|
|
6842
6830
|
);
|
|
6843
6831
|
} catch (error3) {
|
|
6844
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
6832
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _150 => _150.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
6845
6833
|
try {
|
|
6846
|
-
await
|
|
6847
|
-
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}
|
|
6848
|
-
void 0,
|
|
6849
|
-
{
|
|
6850
|
-
method: "DELETE"
|
|
6851
|
-
}
|
|
6834
|
+
await httpClient2.rawDelete(
|
|
6835
|
+
url`/v2/c/rooms/${config.roomId}/attachments/${attachment.id}/multipart/${uploadId}`
|
|
6852
6836
|
);
|
|
6853
6837
|
} catch (error4) {
|
|
6854
6838
|
}
|
|
@@ -6858,16 +6842,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6858
6842
|
}
|
|
6859
6843
|
}
|
|
6860
6844
|
async function getAttachmentUrls(attachmentIds) {
|
|
6861
|
-
const { urls } = await
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
method: "POST",
|
|
6865
|
-
headers: {
|
|
6866
|
-
"Content-Type": "application/json"
|
|
6867
|
-
},
|
|
6868
|
-
body: JSON.stringify({ attachmentIds })
|
|
6869
|
-
}
|
|
6870
|
-
);
|
|
6845
|
+
const { urls } = await httpClient2.post(url`/v2/c/rooms/${config.roomId}/attachments/presigned-urls`, {
|
|
6846
|
+
attachmentIds
|
|
6847
|
+
});
|
|
6871
6848
|
return urls;
|
|
6872
6849
|
}
|
|
6873
6850
|
const batchedGetAttachmentUrls = new Batch(
|
|
@@ -6885,38 +6862,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6885
6862
|
return batchedGetAttachmentUrls.get(attachmentId);
|
|
6886
6863
|
}
|
|
6887
6864
|
async function fetchNotificationsJson(endpoint, options2) {
|
|
6888
|
-
|
|
6889
|
-
const response = await fetchClientApi(endpoint, authValue, options2);
|
|
6890
|
-
if (!response.ok) {
|
|
6891
|
-
if (response.status >= 400 && response.status < 600) {
|
|
6892
|
-
let error3;
|
|
6893
|
-
try {
|
|
6894
|
-
const errorBody = await response.json();
|
|
6895
|
-
error3 = new NotificationsApiError(
|
|
6896
|
-
errorBody.message,
|
|
6897
|
-
response.status,
|
|
6898
|
-
errorBody
|
|
6899
|
-
);
|
|
6900
|
-
} catch (e7) {
|
|
6901
|
-
error3 = new NotificationsApiError(
|
|
6902
|
-
response.statusText,
|
|
6903
|
-
response.status
|
|
6904
|
-
);
|
|
6905
|
-
}
|
|
6906
|
-
throw error3;
|
|
6907
|
-
}
|
|
6908
|
-
}
|
|
6909
|
-
let body;
|
|
6910
|
-
try {
|
|
6911
|
-
body = await response.json();
|
|
6912
|
-
} catch (e8) {
|
|
6913
|
-
body = {};
|
|
6914
|
-
}
|
|
6915
|
-
return body;
|
|
6865
|
+
return await httpClient2.get(endpoint, void 0, options2);
|
|
6916
6866
|
}
|
|
6917
|
-
function getNotificationSettings() {
|
|
6867
|
+
function getNotificationSettings(options2) {
|
|
6918
6868
|
return fetchNotificationsJson(
|
|
6919
|
-
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]) }
|
|
6920
6871
|
);
|
|
6921
6872
|
}
|
|
6922
6873
|
function updateNotificationSettings(settings) {
|
|
@@ -6924,10 +6875,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6924
6875
|
url`/v2/c/rooms/${config.roomId}/notification-settings`,
|
|
6925
6876
|
{
|
|
6926
6877
|
method: "POST",
|
|
6927
|
-
body: JSON.stringify(settings)
|
|
6928
|
-
headers: {
|
|
6929
|
-
"Content-Type": "application/json"
|
|
6930
|
-
}
|
|
6878
|
+
body: JSON.stringify(settings)
|
|
6931
6879
|
}
|
|
6932
6880
|
);
|
|
6933
6881
|
}
|
|
@@ -6936,9 +6884,6 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6936
6884
|
url`/v2/c/rooms/${config.roomId}/inbox-notifications/read`,
|
|
6937
6885
|
{
|
|
6938
6886
|
method: "POST",
|
|
6939
|
-
headers: {
|
|
6940
|
-
"Content-Type": "application/json"
|
|
6941
|
-
},
|
|
6942
6887
|
body: JSON.stringify({ inboxNotificationIds })
|
|
6943
6888
|
}
|
|
6944
6889
|
);
|
|
@@ -6958,7 +6903,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6958
6903
|
{
|
|
6959
6904
|
[kInternal]: {
|
|
6960
6905
|
get presenceBuffer() {
|
|
6961
|
-
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)));
|
|
6962
6907
|
},
|
|
6963
6908
|
// prettier-ignore
|
|
6964
6909
|
get undoStack() {
|
|
@@ -6985,6 +6930,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6985
6930
|
deleteTextMention,
|
|
6986
6931
|
// list versions of the document
|
|
6987
6932
|
listTextVersions,
|
|
6933
|
+
// List versions of the document since the specified date
|
|
6934
|
+
listTextVersionsSince,
|
|
6988
6935
|
// get a specific version
|
|
6989
6936
|
getTextVersion,
|
|
6990
6937
|
// create a version
|
|
@@ -7142,7 +7089,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
7142
7089
|
}
|
|
7143
7090
|
if (isLiveNode(first)) {
|
|
7144
7091
|
const node = first;
|
|
7145
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
7092
|
+
if (_optionalChain([options, 'optionalAccess', _155 => _155.isDeep])) {
|
|
7146
7093
|
const storageCallback = second;
|
|
7147
7094
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
7148
7095
|
} else {
|
|
@@ -7262,12 +7209,12 @@ function createClient(options) {
|
|
|
7262
7209
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7263
7210
|
roomId,
|
|
7264
7211
|
baseUrl,
|
|
7265
|
-
_optionalChain([clientOptions, 'access',
|
|
7212
|
+
_optionalChain([clientOptions, 'access', _156 => _156.polyfills, 'optionalAccess', _157 => _157.WebSocket])
|
|
7266
7213
|
),
|
|
7267
7214
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7268
7215
|
})),
|
|
7269
7216
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7270
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7217
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _158 => _158.unstable_batchedUpdates]),
|
|
7271
7218
|
baseUrl,
|
|
7272
7219
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7273
7220
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7283,7 +7230,7 @@ function createClient(options) {
|
|
|
7283
7230
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
7284
7231
|
if (shouldConnect) {
|
|
7285
7232
|
if (typeof atob === "undefined") {
|
|
7286
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7233
|
+
if (_optionalChain([clientOptions, 'access', _159 => _159.polyfills, 'optionalAccess', _160 => _160.atob]) === void 0) {
|
|
7287
7234
|
throw new Error(
|
|
7288
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"
|
|
7289
7236
|
);
|
|
@@ -7295,7 +7242,7 @@ function createClient(options) {
|
|
|
7295
7242
|
return leaseRoom(newRoomDetails);
|
|
7296
7243
|
}
|
|
7297
7244
|
function getRoom(roomId) {
|
|
7298
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7245
|
+
const room = _optionalChain([roomsById, 'access', _161 => _161.get, 'call', _162 => _162(roomId), 'optionalAccess', _163 => _163.room]);
|
|
7299
7246
|
return room ? room : null;
|
|
7300
7247
|
}
|
|
7301
7248
|
function logout() {
|
|
@@ -7307,11 +7254,11 @@ function createClient(options) {
|
|
|
7307
7254
|
}
|
|
7308
7255
|
}
|
|
7309
7256
|
const currentUserIdStore = createStore(null);
|
|
7310
|
-
const
|
|
7311
|
-
fetch;
|
|
7312
|
-
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({
|
|
7313
7260
|
baseUrl,
|
|
7314
|
-
|
|
7261
|
+
fetchPolyfill,
|
|
7315
7262
|
authManager,
|
|
7316
7263
|
currentUserIdStore
|
|
7317
7264
|
});
|
|
@@ -7323,13 +7270,16 @@ function createClient(options) {
|
|
|
7323
7270
|
const batchedResolveUsers = new Batch(
|
|
7324
7271
|
async (batchedUserIds) => {
|
|
7325
7272
|
const userIds = batchedUserIds.flat();
|
|
7326
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7273
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _169 => _169({ userIds })]);
|
|
7327
7274
|
warnIfNoResolveUsers();
|
|
7328
7275
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7329
7276
|
},
|
|
7330
7277
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
7331
7278
|
);
|
|
7332
7279
|
const usersStore = createBatchStore(batchedResolveUsers);
|
|
7280
|
+
function invalidateResolvedUsers(userIds) {
|
|
7281
|
+
usersStore.invalidate(userIds);
|
|
7282
|
+
}
|
|
7333
7283
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
7334
7284
|
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
7335
7285
|
() => !resolveRoomsInfo,
|
|
@@ -7338,22 +7288,36 @@ function createClient(options) {
|
|
|
7338
7288
|
const batchedResolveRoomsInfo = new Batch(
|
|
7339
7289
|
async (batchedRoomIds) => {
|
|
7340
7290
|
const roomIds = batchedRoomIds.flat();
|
|
7341
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7291
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _170 => _170({ roomIds })]);
|
|
7342
7292
|
warnIfNoResolveRoomsInfo();
|
|
7343
7293
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7344
7294
|
},
|
|
7345
7295
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
7346
7296
|
);
|
|
7347
7297
|
const roomsInfoStore = createBatchStore(batchedResolveRoomsInfo);
|
|
7348
|
-
|
|
7298
|
+
function invalidateResolvedRoomsInfo(roomIds) {
|
|
7299
|
+
roomsInfoStore.invalidate(roomIds);
|
|
7300
|
+
}
|
|
7301
|
+
const mentionSuggestionsCache = /* @__PURE__ */ new Map();
|
|
7302
|
+
function invalidateResolvedMentionSuggestions() {
|
|
7303
|
+
mentionSuggestionsCache.clear();
|
|
7304
|
+
}
|
|
7305
|
+
const client = Object.defineProperty(
|
|
7349
7306
|
{
|
|
7350
7307
|
enterRoom,
|
|
7351
7308
|
getRoom,
|
|
7352
7309
|
logout,
|
|
7353
|
-
...
|
|
7310
|
+
...notificationsAPI,
|
|
7311
|
+
// Advanced resolvers APIs
|
|
7312
|
+
resolvers: {
|
|
7313
|
+
invalidateUsers: invalidateResolvedUsers,
|
|
7314
|
+
invalidateRoomsInfo: invalidateResolvedRoomsInfo,
|
|
7315
|
+
invalidateMentionSuggestions: invalidateResolvedMentionSuggestions
|
|
7316
|
+
},
|
|
7354
7317
|
// Internal
|
|
7355
7318
|
[kInternal]: {
|
|
7356
7319
|
currentUserIdStore,
|
|
7320
|
+
mentionSuggestionsCache,
|
|
7357
7321
|
resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
|
|
7358
7322
|
usersStore,
|
|
7359
7323
|
roomsInfoStore,
|
|
@@ -7361,8 +7325,10 @@ function createClient(options) {
|
|
|
7361
7325
|
return Array.from(roomsById.keys());
|
|
7362
7326
|
},
|
|
7363
7327
|
// "All" threads (= "user" threads)
|
|
7364
|
-
getUserThreads_experimental:
|
|
7365
|
-
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
|
|
7366
7332
|
}
|
|
7367
7333
|
},
|
|
7368
7334
|
kInternal,
|
|
@@ -7370,15 +7336,8 @@ function createClient(options) {
|
|
|
7370
7336
|
enumerable: false
|
|
7371
7337
|
}
|
|
7372
7338
|
);
|
|
7339
|
+
return client;
|
|
7373
7340
|
}
|
|
7374
|
-
var NotificationsApiError = class extends Error {
|
|
7375
|
-
constructor(message, status, details) {
|
|
7376
|
-
super(message);
|
|
7377
|
-
this.message = message;
|
|
7378
|
-
this.status = status;
|
|
7379
|
-
this.details = details;
|
|
7380
|
-
}
|
|
7381
|
-
};
|
|
7382
7341
|
function checkBounds(option, value, min, max, recommendedMin) {
|
|
7383
7342
|
if (typeof value !== "number" || value < min || max !== void 0 && value > max) {
|
|
7384
7343
|
throw new Error(
|
|
@@ -7448,7 +7407,7 @@ var commentBodyElementsTypes = {
|
|
|
7448
7407
|
mention: "inline"
|
|
7449
7408
|
};
|
|
7450
7409
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7451
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7410
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _171 => _171.content])) {
|
|
7452
7411
|
return;
|
|
7453
7412
|
}
|
|
7454
7413
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7458,13 +7417,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7458
7417
|
for (const block of body.content) {
|
|
7459
7418
|
if (type === "all" || type === "block") {
|
|
7460
7419
|
if (guard(block)) {
|
|
7461
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7420
|
+
_optionalChain([visitor, 'optionalCall', _172 => _172(block)]);
|
|
7462
7421
|
}
|
|
7463
7422
|
}
|
|
7464
7423
|
if (type === "all" || type === "inline") {
|
|
7465
7424
|
for (const inline of block.children) {
|
|
7466
7425
|
if (guard(inline)) {
|
|
7467
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7426
|
+
_optionalChain([visitor, 'optionalCall', _173 => _173(inline)]);
|
|
7468
7427
|
}
|
|
7469
7428
|
}
|
|
7470
7429
|
}
|
|
@@ -7489,7 +7448,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7489
7448
|
userIds
|
|
7490
7449
|
});
|
|
7491
7450
|
for (const [index, userId] of userIds.entries()) {
|
|
7492
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7451
|
+
const user = _optionalChain([users, 'optionalAccess', _174 => _174[index]]);
|
|
7493
7452
|
if (user) {
|
|
7494
7453
|
resolvedUsers.set(userId, user);
|
|
7495
7454
|
}
|
|
@@ -7612,7 +7571,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7612
7571
|
text: ({ element }) => element.text,
|
|
7613
7572
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
7614
7573
|
mention: ({ element, user }) => {
|
|
7615
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7574
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _175 => _175.name]), () => ( element.id))}`;
|
|
7616
7575
|
}
|
|
7617
7576
|
};
|
|
7618
7577
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7642,7 +7601,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7642
7601
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${_nullishCoalesce(element.text, () => ( element.url))}</a>`;
|
|
7643
7602
|
},
|
|
7644
7603
|
mention: ({ element, user }) => {
|
|
7645
|
-
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>`;
|
|
7646
7605
|
}
|
|
7647
7606
|
};
|
|
7648
7607
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7672,19 +7631,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7672
7631
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
7673
7632
|
},
|
|
7674
7633
|
mention: ({ element, user }) => {
|
|
7675
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7634
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _177 => _177.name]), () => ( element.id))}`;
|
|
7676
7635
|
}
|
|
7677
7636
|
};
|
|
7678
7637
|
async function stringifyCommentBody(body, options) {
|
|
7679
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7680
|
-
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")));
|
|
7681
7640
|
const elements = {
|
|
7682
7641
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7683
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7642
|
+
..._optionalChain([options, 'optionalAccess', _180 => _180.elements])
|
|
7684
7643
|
};
|
|
7685
7644
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7686
7645
|
body,
|
|
7687
|
-
_optionalChain([options, 'optionalAccess',
|
|
7646
|
+
_optionalChain([options, 'optionalAccess', _181 => _181.resolveUsers])
|
|
7688
7647
|
);
|
|
7689
7648
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7690
7649
|
switch (block.type) {
|
|
@@ -7959,12 +7918,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7959
7918
|
}
|
|
7960
7919
|
const newState = Object.assign({}, state);
|
|
7961
7920
|
for (const key in update.updates) {
|
|
7962
|
-
if (_optionalChain([update, 'access',
|
|
7921
|
+
if (_optionalChain([update, 'access', _182 => _182.updates, 'access', _183 => _183[key], 'optionalAccess', _184 => _184.type]) === "update") {
|
|
7963
7922
|
const val = update.node.get(key);
|
|
7964
7923
|
if (val !== void 0) {
|
|
7965
7924
|
newState[key] = lsonToJson(val);
|
|
7966
7925
|
}
|
|
7967
|
-
} else if (_optionalChain([update, 'access',
|
|
7926
|
+
} else if (_optionalChain([update, 'access', _185 => _185.updates, 'access', _186 => _186[key], 'optionalAccess', _187 => _187.type]) === "delete") {
|
|
7968
7927
|
delete newState[key];
|
|
7969
7928
|
}
|
|
7970
7929
|
}
|
|
@@ -8025,12 +7984,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
8025
7984
|
}
|
|
8026
7985
|
const newState = Object.assign({}, state);
|
|
8027
7986
|
for (const key in update.updates) {
|
|
8028
|
-
if (_optionalChain([update, 'access',
|
|
7987
|
+
if (_optionalChain([update, 'access', _188 => _188.updates, 'access', _189 => _189[key], 'optionalAccess', _190 => _190.type]) === "update") {
|
|
8029
7988
|
const value = update.node.get(key);
|
|
8030
7989
|
if (value !== void 0) {
|
|
8031
7990
|
newState[key] = lsonToJson(value);
|
|
8032
7991
|
}
|
|
8033
|
-
} else if (_optionalChain([update, 'access',
|
|
7992
|
+
} else if (_optionalChain([update, 'access', _191 => _191.updates, 'access', _192 => _192[key], 'optionalAccess', _193 => _193.type]) === "delete") {
|
|
8034
7993
|
delete newState[key];
|
|
8035
7994
|
}
|
|
8036
7995
|
}
|
|
@@ -8096,45 +8055,102 @@ function errorIf(condition, message) {
|
|
|
8096
8055
|
}
|
|
8097
8056
|
|
|
8098
8057
|
// src/lib/Poller.ts
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
}
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
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" });
|
|
8117
8119
|
}
|
|
8118
|
-
schedule();
|
|
8119
8120
|
}
|
|
8120
|
-
function
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8121
|
+
function inc() {
|
|
8122
|
+
context.count++;
|
|
8123
|
+
startOrStop();
|
|
8124
|
+
}
|
|
8125
|
+
function dec() {
|
|
8126
|
+
context.count--;
|
|
8127
|
+
if (context.count < 0) {
|
|
8128
|
+
context.count = 0;
|
|
8126
8129
|
}
|
|
8127
|
-
|
|
8130
|
+
startOrStop();
|
|
8128
8131
|
}
|
|
8129
|
-
function
|
|
8130
|
-
if (
|
|
8131
|
-
|
|
8132
|
-
} else {
|
|
8133
|
-
stop();
|
|
8132
|
+
function pollNowIfStale() {
|
|
8133
|
+
if (performance.now() - context.lastSuccessfulPollAt > maxStaleTimeMs) {
|
|
8134
|
+
fsm.send({ type: "POLL" });
|
|
8134
8135
|
}
|
|
8135
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();
|
|
8136
8148
|
return {
|
|
8137
|
-
|
|
8149
|
+
inc,
|
|
8150
|
+
dec,
|
|
8151
|
+
pollNowIfStale,
|
|
8152
|
+
// Internal API, used by unit tests only to simulate visibility events
|
|
8153
|
+
setInForeground
|
|
8138
8154
|
};
|
|
8139
8155
|
}
|
|
8140
8156
|
|
|
@@ -8177,8 +8193,81 @@ function shallow(a, b) {
|
|
|
8177
8193
|
return shallowObj(a, b);
|
|
8178
8194
|
}
|
|
8179
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
|
+
|
|
8180
8266
|
// src/index.ts
|
|
8181
8267
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
8268
|
+
var CommentsApiError = HttpError;
|
|
8269
|
+
var NotificationsApiError = HttpError;
|
|
8270
|
+
|
|
8182
8271
|
|
|
8183
8272
|
|
|
8184
8273
|
|
|
@@ -8246,5 +8335,5 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8246
8335
|
|
|
8247
8336
|
|
|
8248
8337
|
|
|
8249
|
-
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;
|
|
8250
8339
|
//# sourceMappingURL=index.js.map
|