@liveblocks/core 3.6.2 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +324 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +135 -14
- package/dist/index.d.ts +135 -14
- package/dist/index.js +201 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
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 = "3.
|
|
9
|
+
var PKG_VERSION = "3.7.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -851,6 +851,38 @@ function convertToSubscriptionDeleteInfo(data) {
|
|
|
851
851
|
deletedAt
|
|
852
852
|
};
|
|
853
853
|
}
|
|
854
|
+
function convertToGroupData(data) {
|
|
855
|
+
const createdAt = new Date(data.createdAt);
|
|
856
|
+
const updatedAt = new Date(data.updatedAt);
|
|
857
|
+
const members = data.members.map((member) => ({
|
|
858
|
+
...member,
|
|
859
|
+
addedAt: new Date(member.addedAt)
|
|
860
|
+
}));
|
|
861
|
+
return {
|
|
862
|
+
...data,
|
|
863
|
+
createdAt,
|
|
864
|
+
updatedAt,
|
|
865
|
+
members
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// src/lib/assert.ts
|
|
870
|
+
function assertNever(_value, errmsg) {
|
|
871
|
+
throw new Error(errmsg);
|
|
872
|
+
}
|
|
873
|
+
function assert(condition, errmsg) {
|
|
874
|
+
if (process.env.NODE_ENV !== "production") {
|
|
875
|
+
if (!condition) {
|
|
876
|
+
const err = new Error(errmsg);
|
|
877
|
+
err.name = "Assertion failure";
|
|
878
|
+
throw err;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function nn(value, errmsg = "Expected value to be non-nullable") {
|
|
883
|
+
assert(value !== null && value !== void 0, errmsg);
|
|
884
|
+
return value;
|
|
885
|
+
}
|
|
854
886
|
|
|
855
887
|
// src/lib/fancy-console.ts
|
|
856
888
|
var fancy_console_exports = {};
|
|
@@ -1095,9 +1127,15 @@ function createBatchStore(batch2) {
|
|
|
1095
1127
|
function getCacheKey(args) {
|
|
1096
1128
|
return stableStringify(args);
|
|
1097
1129
|
}
|
|
1098
|
-
function update(
|
|
1130
|
+
function update(entryOrEntries) {
|
|
1099
1131
|
signal.mutate((cache) => {
|
|
1100
|
-
|
|
1132
|
+
if (Array.isArray(entryOrEntries)) {
|
|
1133
|
+
for (const entry of entryOrEntries) {
|
|
1134
|
+
cache.set(entry.key, entry.state);
|
|
1135
|
+
}
|
|
1136
|
+
} else {
|
|
1137
|
+
cache.set(entryOrEntries.key, entryOrEntries.state);
|
|
1138
|
+
}
|
|
1101
1139
|
});
|
|
1102
1140
|
}
|
|
1103
1141
|
function invalidate(inputs) {
|
|
@@ -1118,21 +1156,34 @@ function createBatchStore(batch2) {
|
|
|
1118
1156
|
return;
|
|
1119
1157
|
}
|
|
1120
1158
|
try {
|
|
1121
|
-
update(cacheKey, { isLoading: true });
|
|
1159
|
+
update({ key: cacheKey, state: { isLoading: true } });
|
|
1122
1160
|
const result = await batch2.get(input);
|
|
1123
|
-
update(cacheKey, { isLoading: false, data: result });
|
|
1161
|
+
update({ key: cacheKey, state: { isLoading: false, data: result } });
|
|
1124
1162
|
} catch (error3) {
|
|
1125
|
-
update(
|
|
1126
|
-
|
|
1127
|
-
error: error3
|
|
1163
|
+
update({
|
|
1164
|
+
key: cacheKey,
|
|
1165
|
+
state: { isLoading: false, error: error3 }
|
|
1128
1166
|
});
|
|
1129
1167
|
}
|
|
1130
1168
|
}
|
|
1169
|
+
function setData(entries2) {
|
|
1170
|
+
update(
|
|
1171
|
+
entries2.map((entry) => ({
|
|
1172
|
+
key: getCacheKey(entry[0]),
|
|
1173
|
+
state: { isLoading: false, data: entry[1] }
|
|
1174
|
+
}))
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1131
1177
|
function getItemState(input) {
|
|
1132
1178
|
const cacheKey = getCacheKey(input);
|
|
1133
1179
|
const cache = signal.get();
|
|
1134
1180
|
return cache.get(cacheKey);
|
|
1135
1181
|
}
|
|
1182
|
+
function getData(input) {
|
|
1183
|
+
const cacheKey = getCacheKey(input);
|
|
1184
|
+
const cache = signal.get();
|
|
1185
|
+
return _optionalChain([cache, 'access', _12 => _12.get, 'call', _13 => _13(cacheKey), 'optionalAccess', _14 => _14.data]);
|
|
1186
|
+
}
|
|
1136
1187
|
function _cacheKeys() {
|
|
1137
1188
|
const cache = signal.get();
|
|
1138
1189
|
return [...cache.keys()];
|
|
@@ -1140,7 +1191,9 @@ function createBatchStore(batch2) {
|
|
|
1140
1191
|
return {
|
|
1141
1192
|
subscribe: signal.subscribe,
|
|
1142
1193
|
enqueue,
|
|
1194
|
+
setData,
|
|
1143
1195
|
getItemState,
|
|
1196
|
+
getData,
|
|
1144
1197
|
invalidate,
|
|
1145
1198
|
batch: batch2,
|
|
1146
1199
|
_cacheKeys
|
|
@@ -1658,11 +1711,11 @@ function createApiClient({
|
|
|
1658
1711
|
`Upload of attachment ${options.attachment.id} was aborted.`,
|
|
1659
1712
|
"AbortError"
|
|
1660
1713
|
) : void 0;
|
|
1661
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1714
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _15 => _15.aborted])) {
|
|
1662
1715
|
throw abortError;
|
|
1663
1716
|
}
|
|
1664
1717
|
const handleRetryError = (err) => {
|
|
1665
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1718
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _16 => _16.aborted])) {
|
|
1666
1719
|
throw abortError;
|
|
1667
1720
|
}
|
|
1668
1721
|
if (err instanceof HttpError && err.status === 413) {
|
|
@@ -1734,7 +1787,7 @@ function createApiClient({
|
|
|
1734
1787
|
try {
|
|
1735
1788
|
uploadId = createMultiPartUpload.uploadId;
|
|
1736
1789
|
const parts = splitFileIntoParts(attachment.file);
|
|
1737
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1790
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _17 => _17.aborted])) {
|
|
1738
1791
|
throw abortError;
|
|
1739
1792
|
}
|
|
1740
1793
|
const batches = chunk(parts, 5);
|
|
@@ -1761,7 +1814,7 @@ function createApiClient({
|
|
|
1761
1814
|
}
|
|
1762
1815
|
uploadedParts.push(...await Promise.all(uploadedPartsPromises));
|
|
1763
1816
|
}
|
|
1764
|
-
if (_optionalChain([abortSignal, 'optionalAccess',
|
|
1817
|
+
if (_optionalChain([abortSignal, 'optionalAccess', _18 => _18.aborted])) {
|
|
1765
1818
|
throw abortError;
|
|
1766
1819
|
}
|
|
1767
1820
|
const sortedUploadedParts = uploadedParts.sort(
|
|
@@ -1777,7 +1830,7 @@ function createApiClient({
|
|
|
1777
1830
|
{ signal: abortSignal }
|
|
1778
1831
|
);
|
|
1779
1832
|
} catch (error3) {
|
|
1780
|
-
if (uploadId && _optionalChain([error3, 'optionalAccess',
|
|
1833
|
+
if (uploadId && _optionalChain([error3, 'optionalAccess', _19 => _19.name]) && (error3.name === "AbortError" || error3.name === "TimeoutError")) {
|
|
1781
1834
|
try {
|
|
1782
1835
|
await httpClient.rawDelete(
|
|
1783
1836
|
url`/v2/c/rooms/${roomId}/attachments/${attachment.id}/multipart/${uploadId}`,
|
|
@@ -1962,6 +2015,9 @@ function createApiClient({
|
|
|
1962
2015
|
return batch2.get(options.inboxNotificationId);
|
|
1963
2016
|
}
|
|
1964
2017
|
async function createTextMention(options) {
|
|
2018
|
+
if (options.mention.kind !== "user" && options.mention.kind !== "group") {
|
|
2019
|
+
return assertNever(options.mention, "Unexpected mention kind");
|
|
2020
|
+
}
|
|
1965
2021
|
await httpClient.rawPost(
|
|
1966
2022
|
url`/v2/c/rooms/${options.roomId}/text-mentions`,
|
|
1967
2023
|
await authManager.getAuthValue({
|
|
@@ -1969,7 +2025,9 @@ function createApiClient({
|
|
|
1969
2025
|
roomId: options.roomId
|
|
1970
2026
|
}),
|
|
1971
2027
|
{
|
|
1972
|
-
userId: options.
|
|
2028
|
+
userId: options.mention.kind === "user" ? options.mention.id : void 0,
|
|
2029
|
+
groupId: options.mention.kind === "group" ? options.mention.id : void 0,
|
|
2030
|
+
userIds: options.mention.kind === "group" ? options.mention.userIds : void 0,
|
|
1973
2031
|
mentionId: options.mentionId
|
|
1974
2032
|
}
|
|
1975
2033
|
);
|
|
@@ -2100,14 +2158,21 @@ function createApiClient({
|
|
|
2100
2158
|
}
|
|
2101
2159
|
async function getInboxNotifications(options) {
|
|
2102
2160
|
const PAGE_SIZE = 50;
|
|
2161
|
+
let query;
|
|
2162
|
+
if (_optionalChain([options, 'optionalAccess', _20 => _20.query])) {
|
|
2163
|
+
query = objectToQuery(options.query);
|
|
2164
|
+
}
|
|
2103
2165
|
const json = await httpClient.get(
|
|
2104
2166
|
url`/v2/c/inbox-notifications`,
|
|
2105
2167
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2106
2168
|
{
|
|
2107
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2108
|
-
limit: PAGE_SIZE
|
|
2169
|
+
cursor: _optionalChain([options, 'optionalAccess', _21 => _21.cursor]),
|
|
2170
|
+
limit: PAGE_SIZE,
|
|
2171
|
+
query
|
|
2109
2172
|
}
|
|
2110
2173
|
);
|
|
2174
|
+
const groups = json.groups.map(convertToGroupData);
|
|
2175
|
+
groupsStore.setData(groups.map((group) => [group.id, group]));
|
|
2111
2176
|
return {
|
|
2112
2177
|
inboxNotifications: json.inboxNotifications.map(
|
|
2113
2178
|
convertToInboxNotificationData
|
|
@@ -2119,10 +2184,14 @@ function createApiClient({
|
|
|
2119
2184
|
};
|
|
2120
2185
|
}
|
|
2121
2186
|
async function getInboxNotificationsSince(options) {
|
|
2187
|
+
let query;
|
|
2188
|
+
if (_optionalChain([options, 'optionalAccess', _22 => _22.query])) {
|
|
2189
|
+
query = objectToQuery(options.query);
|
|
2190
|
+
}
|
|
2122
2191
|
const json = await httpClient.get(
|
|
2123
2192
|
url`/v2/c/inbox-notifications/delta`,
|
|
2124
2193
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2125
|
-
{ since: options.since.toISOString() },
|
|
2194
|
+
{ since: options.since.toISOString(), query },
|
|
2126
2195
|
{ signal: options.signal }
|
|
2127
2196
|
);
|
|
2128
2197
|
return {
|
|
@@ -2196,7 +2265,7 @@ function createApiClient({
|
|
|
2196
2265
|
url`/v2/c/notification-settings`,
|
|
2197
2266
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2198
2267
|
void 0,
|
|
2199
|
-
{ signal: _optionalChain([options, 'optionalAccess',
|
|
2268
|
+
{ signal: _optionalChain([options, 'optionalAccess', _23 => _23.signal]) }
|
|
2200
2269
|
);
|
|
2201
2270
|
}
|
|
2202
2271
|
async function updateNotificationSettings(settings) {
|
|
@@ -2208,7 +2277,7 @@ function createApiClient({
|
|
|
2208
2277
|
}
|
|
2209
2278
|
async function getUserThreads_experimental(options) {
|
|
2210
2279
|
let query;
|
|
2211
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
2280
|
+
if (_optionalChain([options, 'optionalAccess', _24 => _24.query])) {
|
|
2212
2281
|
query = objectToQuery(options.query);
|
|
2213
2282
|
}
|
|
2214
2283
|
const PAGE_SIZE = 50;
|
|
@@ -2216,7 +2285,7 @@ function createApiClient({
|
|
|
2216
2285
|
url`/v2/c/threads`,
|
|
2217
2286
|
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2218
2287
|
{
|
|
2219
|
-
cursor: _optionalChain([options, 'optionalAccess',
|
|
2288
|
+
cursor: _optionalChain([options, 'optionalAccess', _25 => _25.cursor]),
|
|
2220
2289
|
query,
|
|
2221
2290
|
limit: PAGE_SIZE
|
|
2222
2291
|
}
|
|
@@ -2258,6 +2327,28 @@ function createApiClient({
|
|
|
2258
2327
|
permissionHints: json.meta.permissionHints
|
|
2259
2328
|
};
|
|
2260
2329
|
}
|
|
2330
|
+
const batchedGetGroups = new Batch(
|
|
2331
|
+
async (batchedGroupIds) => {
|
|
2332
|
+
const groupIds = batchedGroupIds.flat();
|
|
2333
|
+
const { groups: plainGroups } = await httpClient.post(
|
|
2334
|
+
url`/v2/c/groups/find`,
|
|
2335
|
+
await authManager.getAuthValue({
|
|
2336
|
+
requestedScope: "comments:read"
|
|
2337
|
+
}),
|
|
2338
|
+
{ groupIds }
|
|
2339
|
+
);
|
|
2340
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2341
|
+
for (const group of plainGroups) {
|
|
2342
|
+
groups.set(group.id, convertToGroupData(group));
|
|
2343
|
+
}
|
|
2344
|
+
return groupIds.map((groupId) => groups.get(groupId));
|
|
2345
|
+
},
|
|
2346
|
+
{ delay: 50 }
|
|
2347
|
+
);
|
|
2348
|
+
const groupsStore = createBatchStore(batchedGetGroups);
|
|
2349
|
+
function getGroup(groupId) {
|
|
2350
|
+
return batchedGetGroups.get(groupId);
|
|
2351
|
+
}
|
|
2261
2352
|
return {
|
|
2262
2353
|
// Room threads
|
|
2263
2354
|
getThreads,
|
|
@@ -2311,6 +2402,9 @@ function createApiClient({
|
|
|
2311
2402
|
// User threads
|
|
2312
2403
|
getUserThreads_experimental,
|
|
2313
2404
|
getUserThreadsSince_experimental,
|
|
2405
|
+
// Groups
|
|
2406
|
+
groupsStore,
|
|
2407
|
+
getGroup,
|
|
2314
2408
|
// AI
|
|
2315
2409
|
executeContextualPrompt
|
|
2316
2410
|
};
|
|
@@ -2356,7 +2450,7 @@ var HttpClient = class {
|
|
|
2356
2450
|
// These headers are default, but can be overriden by custom headers
|
|
2357
2451
|
"Content-Type": "application/json; charset=utf-8",
|
|
2358
2452
|
// Possible header overrides
|
|
2359
|
-
..._optionalChain([options, 'optionalAccess',
|
|
2453
|
+
..._optionalChain([options, 'optionalAccess', _26 => _26.headers]),
|
|
2360
2454
|
// Cannot be overriden by custom headers
|
|
2361
2455
|
Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
|
|
2362
2456
|
"X-LB-Client": PKG_VERSION || "dev"
|
|
@@ -2468,24 +2562,6 @@ var HttpClient = class {
|
|
|
2468
2562
|
}
|
|
2469
2563
|
};
|
|
2470
2564
|
|
|
2471
|
-
// src/lib/assert.ts
|
|
2472
|
-
function assertNever(_value, errmsg) {
|
|
2473
|
-
throw new Error(errmsg);
|
|
2474
|
-
}
|
|
2475
|
-
function assert(condition, errmsg) {
|
|
2476
|
-
if (process.env.NODE_ENV !== "production") {
|
|
2477
|
-
if (!condition) {
|
|
2478
|
-
const err = new Error(errmsg);
|
|
2479
|
-
err.name = "Assertion failure";
|
|
2480
|
-
throw err;
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
}
|
|
2484
|
-
function nn(value, errmsg = "Expected value to be non-nullable") {
|
|
2485
|
-
assert(value !== null && value !== void 0, errmsg);
|
|
2486
|
-
return value;
|
|
2487
|
-
}
|
|
2488
|
-
|
|
2489
2565
|
// src/lib/fsm.ts
|
|
2490
2566
|
function distance(state1, state2) {
|
|
2491
2567
|
if (state1 === state2) {
|
|
@@ -2831,7 +2907,7 @@ var FSM = class {
|
|
|
2831
2907
|
});
|
|
2832
2908
|
}
|
|
2833
2909
|
#getTargetFn(eventName) {
|
|
2834
|
-
return _optionalChain([this, 'access',
|
|
2910
|
+
return _optionalChain([this, 'access', _27 => _27.#allowedTransitions, 'access', _28 => _28.get, 'call', _29 => _29(this.currentState), 'optionalAccess', _30 => _30.get, 'call', _31 => _31(eventName)]);
|
|
2835
2911
|
}
|
|
2836
2912
|
/**
|
|
2837
2913
|
* Exits the current state, and executes any necessary cleanup functions.
|
|
@@ -2848,7 +2924,7 @@ var FSM = class {
|
|
|
2848
2924
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2849
2925
|
levels = _nullishCoalesce(levels, () => ( this.#cleanupStack.length));
|
|
2850
2926
|
for (let i = 0; i < levels; i++) {
|
|
2851
|
-
_optionalChain([this, 'access',
|
|
2927
|
+
_optionalChain([this, 'access', _32 => _32.#cleanupStack, 'access', _33 => _33.pop, 'call', _34 => _34(), 'optionalCall', _35 => _35(patchableContext)]);
|
|
2852
2928
|
}
|
|
2853
2929
|
});
|
|
2854
2930
|
}
|
|
@@ -2864,7 +2940,7 @@ var FSM = class {
|
|
|
2864
2940
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
2865
2941
|
for (const pattern of enterPatterns) {
|
|
2866
2942
|
const enterFn = this.#enterFns.get(pattern);
|
|
2867
|
-
const cleanupFn = _optionalChain([enterFn, 'optionalCall',
|
|
2943
|
+
const cleanupFn = _optionalChain([enterFn, 'optionalCall', _36 => _36(patchableContext)]);
|
|
2868
2944
|
if (typeof cleanupFn === "function") {
|
|
2869
2945
|
this.#cleanupStack.push(cleanupFn);
|
|
2870
2946
|
} else {
|
|
@@ -3258,7 +3334,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3258
3334
|
}
|
|
3259
3335
|
function waitForActorId(event) {
|
|
3260
3336
|
const serverMsg = tryParseJson(event.data);
|
|
3261
|
-
if (_optionalChain([serverMsg, 'optionalAccess',
|
|
3337
|
+
if (_optionalChain([serverMsg, 'optionalAccess', _37 => _37.type]) === 104 /* ROOM_STATE */) {
|
|
3262
3338
|
didReceiveActor();
|
|
3263
3339
|
}
|
|
3264
3340
|
}
|
|
@@ -3367,12 +3443,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3367
3443
|
const sendHeartbeat = {
|
|
3368
3444
|
target: "@ok.awaiting-pong",
|
|
3369
3445
|
effect: (ctx) => {
|
|
3370
|
-
_optionalChain([ctx, 'access',
|
|
3446
|
+
_optionalChain([ctx, 'access', _38 => _38.socket, 'optionalAccess', _39 => _39.send, 'call', _40 => _40("ping")]);
|
|
3371
3447
|
}
|
|
3372
3448
|
};
|
|
3373
3449
|
const maybeHeartbeat = () => {
|
|
3374
3450
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
3375
|
-
const canZombie = _optionalChain([doc, 'optionalAccess',
|
|
3451
|
+
const canZombie = _optionalChain([doc, 'optionalAccess', _41 => _41.visibilityState]) === "hidden" && delegates.canZombie();
|
|
3376
3452
|
return canZombie ? "@idle.zombie" : sendHeartbeat;
|
|
3377
3453
|
};
|
|
3378
3454
|
machine.addTimedTransition("@ok.connected", HEARTBEAT_INTERVAL, maybeHeartbeat).addTransitions("@ok.connected", {
|
|
@@ -3411,7 +3487,7 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3411
3487
|
// socket, or not. So always check to see if the socket is still OPEN or
|
|
3412
3488
|
// not. When still OPEN, don't transition.
|
|
3413
3489
|
EXPLICIT_SOCKET_ERROR: (_, context) => {
|
|
3414
|
-
if (_optionalChain([context, 'access',
|
|
3490
|
+
if (_optionalChain([context, 'access', _42 => _42.socket, 'optionalAccess', _43 => _43.readyState]) === 1) {
|
|
3415
3491
|
return null;
|
|
3416
3492
|
}
|
|
3417
3493
|
return {
|
|
@@ -3463,17 +3539,17 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3463
3539
|
machine.send({ type: "NAVIGATOR_ONLINE" });
|
|
3464
3540
|
}
|
|
3465
3541
|
function onVisibilityChange() {
|
|
3466
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
3542
|
+
if (_optionalChain([doc, 'optionalAccess', _44 => _44.visibilityState]) === "visible") {
|
|
3467
3543
|
machine.send({ type: "WINDOW_GOT_FOCUS" });
|
|
3468
3544
|
}
|
|
3469
3545
|
}
|
|
3470
|
-
_optionalChain([win, 'optionalAccess',
|
|
3471
|
-
_optionalChain([win, 'optionalAccess',
|
|
3472
|
-
_optionalChain([root, 'optionalAccess',
|
|
3546
|
+
_optionalChain([win, 'optionalAccess', _45 => _45.addEventListener, 'call', _46 => _46("online", onNetworkBackOnline)]);
|
|
3547
|
+
_optionalChain([win, 'optionalAccess', _47 => _47.addEventListener, 'call', _48 => _48("offline", onNetworkOffline)]);
|
|
3548
|
+
_optionalChain([root, 'optionalAccess', _49 => _49.addEventListener, 'call', _50 => _50("visibilitychange", onVisibilityChange)]);
|
|
3473
3549
|
return () => {
|
|
3474
|
-
_optionalChain([root, 'optionalAccess',
|
|
3475
|
-
_optionalChain([win, 'optionalAccess',
|
|
3476
|
-
_optionalChain([win, 'optionalAccess',
|
|
3550
|
+
_optionalChain([root, 'optionalAccess', _51 => _51.removeEventListener, 'call', _52 => _52("visibilitychange", onVisibilityChange)]);
|
|
3551
|
+
_optionalChain([win, 'optionalAccess', _53 => _53.removeEventListener, 'call', _54 => _54("online", onNetworkBackOnline)]);
|
|
3552
|
+
_optionalChain([win, 'optionalAccess', _55 => _55.removeEventListener, 'call', _56 => _56("offline", onNetworkOffline)]);
|
|
3477
3553
|
teardownSocket(ctx.socket);
|
|
3478
3554
|
};
|
|
3479
3555
|
});
|
|
@@ -3562,7 +3638,7 @@ var ManagedSocket = class {
|
|
|
3562
3638
|
* message if this is somehow impossible.
|
|
3563
3639
|
*/
|
|
3564
3640
|
send(data) {
|
|
3565
|
-
const socket = _optionalChain([this, 'access',
|
|
3641
|
+
const socket = _optionalChain([this, 'access', _57 => _57.#machine, 'access', _58 => _58.context, 'optionalAccess', _59 => _59.socket]);
|
|
3566
3642
|
if (socket === null) {
|
|
3567
3643
|
warn("Cannot send: not connected yet", data);
|
|
3568
3644
|
} else if (socket.readyState !== 1) {
|
|
@@ -4000,7 +4076,7 @@ function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
|
4000
4076
|
}
|
|
4001
4077
|
}
|
|
4002
4078
|
function closePart(prevPart, endedAt) {
|
|
4003
|
-
if (_optionalChain([prevPart, 'optionalAccess',
|
|
4079
|
+
if (_optionalChain([prevPart, 'optionalAccess', _60 => _60.type]) === "reasoning") {
|
|
4004
4080
|
prevPart.endedAt ??= endedAt;
|
|
4005
4081
|
}
|
|
4006
4082
|
}
|
|
@@ -4011,7 +4087,7 @@ function patchContentWithDelta(content, delta) {
|
|
|
4011
4087
|
const lastPart = content[content.length - 1];
|
|
4012
4088
|
switch (delta.type) {
|
|
4013
4089
|
case "text-delta":
|
|
4014
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
4090
|
+
if (_optionalChain([lastPart, 'optionalAccess', _61 => _61.type]) === "text") {
|
|
4015
4091
|
lastPart.text += delta.textDelta;
|
|
4016
4092
|
} else {
|
|
4017
4093
|
closePart(lastPart, now2);
|
|
@@ -4019,13 +4095,13 @@ function patchContentWithDelta(content, delta) {
|
|
|
4019
4095
|
}
|
|
4020
4096
|
break;
|
|
4021
4097
|
case "reasoning-delta":
|
|
4022
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
4098
|
+
if (_optionalChain([lastPart, 'optionalAccess', _62 => _62.type]) === "reasoning") {
|
|
4023
4099
|
lastPart.text += delta.textDelta;
|
|
4024
4100
|
} else {
|
|
4025
4101
|
closePart(lastPart, now2);
|
|
4026
4102
|
content.push({
|
|
4027
4103
|
type: "reasoning",
|
|
4028
|
-
text:
|
|
4104
|
+
text: delta.textDelta,
|
|
4029
4105
|
startedAt: now2
|
|
4030
4106
|
});
|
|
4031
4107
|
}
|
|
@@ -4039,8 +4115,8 @@ function patchContentWithDelta(content, delta) {
|
|
|
4039
4115
|
break;
|
|
4040
4116
|
}
|
|
4041
4117
|
case "tool-delta": {
|
|
4042
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
4043
|
-
_optionalChain([lastPart, 'access',
|
|
4118
|
+
if (_optionalChain([lastPart, 'optionalAccess', _63 => _63.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
4119
|
+
_optionalChain([lastPart, 'access', _64 => _64.__appendDelta, 'optionalCall', _65 => _65(delta.delta)]);
|
|
4044
4120
|
}
|
|
4045
4121
|
break;
|
|
4046
4122
|
}
|
|
@@ -4159,7 +4235,7 @@ function createStore_forTools() {
|
|
|
4159
4235
|
return DerivedSignal.from(() => {
|
|
4160
4236
|
return (
|
|
4161
4237
|
// A tool that's registered and scoped to a specific chat ID...
|
|
4162
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4238
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _66 => _66.get, 'call', _67 => _67()]), () => ( // ...or a globally registered tool
|
|
4163
4239
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4164
4240
|
);
|
|
4165
4241
|
});
|
|
@@ -4189,8 +4265,8 @@ function createStore_forTools() {
|
|
|
4189
4265
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4190
4266
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4191
4267
|
return Array.from([
|
|
4192
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4193
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4268
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _68 => _68.entries, 'call', _69 => _69()]), () => ( [])),
|
|
4269
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _70 => _70.entries, 'call', _71 => _71()]), () => ( []))
|
|
4194
4270
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4195
4271
|
const tool = tool\u03A3.get();
|
|
4196
4272
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4293,7 +4369,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4293
4369
|
} else {
|
|
4294
4370
|
continue;
|
|
4295
4371
|
}
|
|
4296
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4372
|
+
const executeFn = _optionalChain([toolsStore, 'access', _72 => _72.getTool\u03A3, 'call', _73 => _73(toolInvocation.name, message.chatId), 'access', _74 => _74.get, 'call', _75 => _75(), 'optionalAccess', _76 => _76.execute]);
|
|
4297
4373
|
if (executeFn) {
|
|
4298
4374
|
(async () => {
|
|
4299
4375
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4392,8 +4468,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4392
4468
|
const spine = [];
|
|
4393
4469
|
let lastVisitedMessage = null;
|
|
4394
4470
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4395
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4396
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4471
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _77 => _77(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _78 => _78.id]), () => ( null));
|
|
4472
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _79 => _79(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _80 => _80.id]), () => ( null));
|
|
4397
4473
|
if (!message2.deletedAt || prev || next) {
|
|
4398
4474
|
const node = {
|
|
4399
4475
|
...message2,
|
|
@@ -4459,7 +4535,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4459
4535
|
const latest = pool.sorted.findRight(
|
|
4460
4536
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4461
4537
|
);
|
|
4462
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4538
|
+
return _optionalChain([latest, 'optionalAccess', _81 => _81.copilotId]);
|
|
4463
4539
|
}
|
|
4464
4540
|
return {
|
|
4465
4541
|
// Readers
|
|
@@ -4490,11 +4566,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4490
4566
|
*getAutoExecutingMessageIds() {
|
|
4491
4567
|
for (const messageId of myMessages) {
|
|
4492
4568
|
const message = getMessageById(messageId);
|
|
4493
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
4569
|
+
if (_optionalChain([message, 'optionalAccess', _82 => _82.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
4494
4570
|
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
4495
4571
|
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
4496
4572
|
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
4497
|
-
return typeof _optionalChain([tool, 'optionalAccess',
|
|
4573
|
+
return typeof _optionalChain([tool, 'optionalAccess', _83 => _83.execute]) === "function";
|
|
4498
4574
|
}
|
|
4499
4575
|
return false;
|
|
4500
4576
|
});
|
|
@@ -4639,7 +4715,7 @@ function createAi(config) {
|
|
|
4639
4715
|
flushPendingDeltas();
|
|
4640
4716
|
switch (msg.event) {
|
|
4641
4717
|
case "cmd-failed":
|
|
4642
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4718
|
+
_optionalChain([pendingCmd, 'optionalAccess', _84 => _84.reject, 'call', _85 => _85(new Error(msg.error))]);
|
|
4643
4719
|
break;
|
|
4644
4720
|
case "settle": {
|
|
4645
4721
|
context.messagesStore.upsert(msg.message);
|
|
@@ -4716,7 +4792,7 @@ function createAi(config) {
|
|
|
4716
4792
|
return assertNever(msg, "Unhandled case");
|
|
4717
4793
|
}
|
|
4718
4794
|
}
|
|
4719
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4795
|
+
_optionalChain([pendingCmd, 'optionalAccess', _86 => _86.resolve, 'call', _87 => _87(msg)]);
|
|
4720
4796
|
}
|
|
4721
4797
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4722
4798
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4801,9 +4877,9 @@ function createAi(config) {
|
|
|
4801
4877
|
invocationId,
|
|
4802
4878
|
result,
|
|
4803
4879
|
generationOptions: {
|
|
4804
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4805
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4806
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4880
|
+
copilotId: _optionalChain([options, 'optionalAccess', _88 => _88.copilotId]),
|
|
4881
|
+
stream: _optionalChain([options, 'optionalAccess', _89 => _89.stream]),
|
|
4882
|
+
timeout: _optionalChain([options, 'optionalAccess', _90 => _90.timeout]),
|
|
4807
4883
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4808
4884
|
// from the global context
|
|
4809
4885
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -4821,7 +4897,7 @@ function createAi(config) {
|
|
|
4821
4897
|
}
|
|
4822
4898
|
}
|
|
4823
4899
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
4824
|
-
_optionalChain([win, 'optionalAccess',
|
|
4900
|
+
_optionalChain([win, 'optionalAccess', _91 => _91.addEventListener, 'call', _92 => _92("beforeunload", handleBeforeUnload, { once: true })]);
|
|
4825
4901
|
return Object.defineProperty(
|
|
4826
4902
|
{
|
|
4827
4903
|
[kInternal]: {
|
|
@@ -4840,7 +4916,7 @@ function createAi(config) {
|
|
|
4840
4916
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4841
4917
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4842
4918
|
const globalKnowledge = context.knowledge.get();
|
|
4843
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
4919
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _93 => _93.knowledge]) || [];
|
|
4844
4920
|
const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
|
|
4845
4921
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4846
4922
|
messagesStore.markMine(targetMessageId);
|
|
@@ -4850,9 +4926,9 @@ function createAi(config) {
|
|
|
4850
4926
|
sourceMessage: userMessage,
|
|
4851
4927
|
targetMessageId,
|
|
4852
4928
|
generationOptions: {
|
|
4853
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4854
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4855
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4929
|
+
copilotId: _optionalChain([options, 'optionalAccess', _94 => _94.copilotId]),
|
|
4930
|
+
stream: _optionalChain([options, 'optionalAccess', _95 => _95.stream]),
|
|
4931
|
+
timeout: _optionalChain([options, 'optionalAccess', _96 => _96.timeout]),
|
|
4856
4932
|
// Combine global knowledge with request-specific knowledge
|
|
4857
4933
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
4858
4934
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -4953,7 +5029,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4953
5029
|
return void 0;
|
|
4954
5030
|
}
|
|
4955
5031
|
async function makeAuthRequest(options) {
|
|
4956
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
5032
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _97 => _97.polyfills, 'optionalAccess', _98 => _98.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
4957
5033
|
if (authentication.type === "private") {
|
|
4958
5034
|
if (fetcher === void 0) {
|
|
4959
5035
|
throw new StopRetrying(
|
|
@@ -4969,7 +5045,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4969
5045
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
4970
5046
|
);
|
|
4971
5047
|
}
|
|
4972
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5048
|
+
_optionalChain([onAuthenticate, 'optionalCall', _99 => _99(parsed.parsed)]);
|
|
4973
5049
|
return parsed;
|
|
4974
5050
|
}
|
|
4975
5051
|
if (authentication.type === "custom") {
|
|
@@ -4977,7 +5053,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4977
5053
|
if (response && typeof response === "object") {
|
|
4978
5054
|
if (typeof response.token === "string") {
|
|
4979
5055
|
const parsed = parseAuthToken(response.token);
|
|
4980
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
5056
|
+
_optionalChain([onAuthenticate, 'optionalCall', _100 => _100(parsed.parsed)]);
|
|
4981
5057
|
return parsed;
|
|
4982
5058
|
} else if (typeof response.error === "string") {
|
|
4983
5059
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -5121,6 +5197,7 @@ async function fetchAuthEndpoint(fetch, endpoint, body) {
|
|
|
5121
5197
|
|
|
5122
5198
|
// src/constants.ts
|
|
5123
5199
|
var DEFAULT_BASE_URL = "https://api.liveblocks.io";
|
|
5200
|
+
var MENTION_CHARACTER = "@";
|
|
5124
5201
|
|
|
5125
5202
|
// src/devtools/bridge.ts
|
|
5126
5203
|
var _bridgeActive = false;
|
|
@@ -5135,7 +5212,7 @@ function sendToPanel(message, options) {
|
|
|
5135
5212
|
...message,
|
|
5136
5213
|
source: "liveblocks-devtools-client"
|
|
5137
5214
|
};
|
|
5138
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
5215
|
+
if (!(_optionalChain([options, 'optionalAccess', _101 => _101.force]) || _bridgeActive)) {
|
|
5139
5216
|
return;
|
|
5140
5217
|
}
|
|
5141
5218
|
window.postMessage(fullMsg, "*");
|
|
@@ -5143,7 +5220,7 @@ function sendToPanel(message, options) {
|
|
|
5143
5220
|
var eventSource = makeEventSource();
|
|
5144
5221
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
5145
5222
|
window.addEventListener("message", (event) => {
|
|
5146
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
5223
|
+
if (event.source === window && _optionalChain([event, 'access', _102 => _102.data, 'optionalAccess', _103 => _103.source]) === "liveblocks-devtools-panel") {
|
|
5147
5224
|
eventSource.notify(event.data);
|
|
5148
5225
|
} else {
|
|
5149
5226
|
}
|
|
@@ -5285,7 +5362,7 @@ function fullSync(room) {
|
|
|
5285
5362
|
msg: "room::sync::full",
|
|
5286
5363
|
roomId: room.id,
|
|
5287
5364
|
status: room.getStatus(),
|
|
5288
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
5365
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _104 => _104.toTreeNode, 'call', _105 => _105("root"), 'access', _106 => _106.payload]), () => ( null)),
|
|
5289
5366
|
me,
|
|
5290
5367
|
others
|
|
5291
5368
|
});
|
|
@@ -5340,6 +5417,22 @@ function unlinkDevTools(roomId) {
|
|
|
5340
5417
|
});
|
|
5341
5418
|
}
|
|
5342
5419
|
|
|
5420
|
+
// src/lib/warnings.ts
|
|
5421
|
+
var _emittedWarnings = /* @__PURE__ */ new Set();
|
|
5422
|
+
function warnOnce(message, key = message) {
|
|
5423
|
+
if (process.env.NODE_ENV !== "production") {
|
|
5424
|
+
if (!_emittedWarnings.has(key)) {
|
|
5425
|
+
_emittedWarnings.add(key);
|
|
5426
|
+
warn(message);
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
}
|
|
5430
|
+
function warnOnceIf(condition, message, key = message) {
|
|
5431
|
+
if (typeof condition === "function" ? condition() : condition) {
|
|
5432
|
+
warnOnce(message, key);
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
|
|
5343
5436
|
// src/protocol/NotificationSettings.ts
|
|
5344
5437
|
var kPlain = Symbol("notification-settings-plain");
|
|
5345
5438
|
function createNotificationSettings(plain) {
|
|
@@ -5576,7 +5669,7 @@ function createManagedPool(roomId, options) {
|
|
|
5576
5669
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
5577
5670
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
5578
5671
|
dispatch(ops, reverse, storageUpdates) {
|
|
5579
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
5672
|
+
_optionalChain([onDispatch, 'optionalCall', _107 => _107(ops, reverse, storageUpdates)]);
|
|
5580
5673
|
},
|
|
5581
5674
|
assertStorageIsWritable: () => {
|
|
5582
5675
|
if (!isStorageWritable()) {
|
|
@@ -5803,7 +5896,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
5803
5896
|
return [
|
|
5804
5897
|
{
|
|
5805
5898
|
type: 8 /* CREATE_REGISTER */,
|
|
5806
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5899
|
+
opId: _optionalChain([pool, 'optionalAccess', _108 => _108.generateOpId, 'call', _109 => _109()]),
|
|
5807
5900
|
id: this._id,
|
|
5808
5901
|
parentId,
|
|
5809
5902
|
parentKey,
|
|
@@ -5909,7 +6002,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5909
6002
|
const ops = [];
|
|
5910
6003
|
const op = {
|
|
5911
6004
|
id: this._id,
|
|
5912
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6005
|
+
opId: _optionalChain([pool, 'optionalAccess', _110 => _110.generateOpId, 'call', _111 => _111()]),
|
|
5913
6006
|
type: 2 /* CREATE_LIST */,
|
|
5914
6007
|
parentId,
|
|
5915
6008
|
parentKey
|
|
@@ -6180,7 +6273,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6180
6273
|
#applyInsertUndoRedo(op) {
|
|
6181
6274
|
const { id, parentKey: key } = op;
|
|
6182
6275
|
const child = creationOpToLiveNode(op);
|
|
6183
|
-
if (_optionalChain([this, 'access',
|
|
6276
|
+
if (_optionalChain([this, 'access', _112 => _112._pool, 'optionalAccess', _113 => _113.getNode, 'call', _114 => _114(id)]) !== void 0) {
|
|
6184
6277
|
return { modified: false };
|
|
6185
6278
|
}
|
|
6186
6279
|
child._attach(id, nn(this._pool));
|
|
@@ -6188,8 +6281,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6188
6281
|
const existingItemIndex = this._indexOfPosition(key);
|
|
6189
6282
|
let newKey = key;
|
|
6190
6283
|
if (existingItemIndex !== -1) {
|
|
6191
|
-
const before2 = _optionalChain([this, 'access',
|
|
6192
|
-
const after2 = _optionalChain([this, 'access',
|
|
6284
|
+
const before2 = _optionalChain([this, 'access', _115 => _115.#items, 'access', _116 => _116[existingItemIndex], 'optionalAccess', _117 => _117._parentPos]);
|
|
6285
|
+
const after2 = _optionalChain([this, 'access', _118 => _118.#items, 'access', _119 => _119[existingItemIndex + 1], 'optionalAccess', _120 => _120._parentPos]);
|
|
6193
6286
|
newKey = makePosition(before2, after2);
|
|
6194
6287
|
child._setParentLink(this, newKey);
|
|
6195
6288
|
}
|
|
@@ -6203,7 +6296,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6203
6296
|
#applySetUndoRedo(op) {
|
|
6204
6297
|
const { id, parentKey: key } = op;
|
|
6205
6298
|
const child = creationOpToLiveNode(op);
|
|
6206
|
-
if (_optionalChain([this, 'access',
|
|
6299
|
+
if (_optionalChain([this, 'access', _121 => _121._pool, 'optionalAccess', _122 => _122.getNode, 'call', _123 => _123(id)]) !== void 0) {
|
|
6207
6300
|
return { modified: false };
|
|
6208
6301
|
}
|
|
6209
6302
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -6324,7 +6417,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6324
6417
|
} else {
|
|
6325
6418
|
this.#items[existingItemIndex]._setParentLink(
|
|
6326
6419
|
this,
|
|
6327
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6420
|
+
makePosition(newKey, _optionalChain([this, 'access', _124 => _124.#items, 'access', _125 => _125[existingItemIndex + 1], 'optionalAccess', _126 => _126._parentPos]))
|
|
6328
6421
|
);
|
|
6329
6422
|
const previousIndex = this.#items.indexOf(child);
|
|
6330
6423
|
child._setParentLink(this, newKey);
|
|
@@ -6349,7 +6442,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6349
6442
|
if (existingItemIndex !== -1) {
|
|
6350
6443
|
this.#items[existingItemIndex]._setParentLink(
|
|
6351
6444
|
this,
|
|
6352
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6445
|
+
makePosition(newKey, _optionalChain([this, 'access', _127 => _127.#items, 'access', _128 => _128[existingItemIndex + 1], 'optionalAccess', _129 => _129._parentPos]))
|
|
6353
6446
|
);
|
|
6354
6447
|
}
|
|
6355
6448
|
child._setParentLink(this, newKey);
|
|
@@ -6368,7 +6461,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6368
6461
|
if (existingItemIndex !== -1) {
|
|
6369
6462
|
this.#items[existingItemIndex]._setParentLink(
|
|
6370
6463
|
this,
|
|
6371
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6464
|
+
makePosition(newKey, _optionalChain([this, 'access', _130 => _130.#items, 'access', _131 => _131[existingItemIndex + 1], 'optionalAccess', _132 => _132._parentPos]))
|
|
6372
6465
|
);
|
|
6373
6466
|
}
|
|
6374
6467
|
child._setParentLink(this, newKey);
|
|
@@ -6396,7 +6489,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6396
6489
|
if (existingItemIndex !== -1) {
|
|
6397
6490
|
actualNewKey = makePosition(
|
|
6398
6491
|
newKey,
|
|
6399
|
-
_optionalChain([this, 'access',
|
|
6492
|
+
_optionalChain([this, 'access', _133 => _133.#items, 'access', _134 => _134[existingItemIndex + 1], 'optionalAccess', _135 => _135._parentPos])
|
|
6400
6493
|
);
|
|
6401
6494
|
}
|
|
6402
6495
|
child._setParentLink(this, actualNewKey);
|
|
@@ -6454,7 +6547,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6454
6547
|
* @param element The element to add to the end of the LiveList.
|
|
6455
6548
|
*/
|
|
6456
6549
|
push(element) {
|
|
6457
|
-
_optionalChain([this, 'access',
|
|
6550
|
+
_optionalChain([this, 'access', _136 => _136._pool, 'optionalAccess', _137 => _137.assertStorageIsWritable, 'call', _138 => _138()]);
|
|
6458
6551
|
return this.insert(element, this.length);
|
|
6459
6552
|
}
|
|
6460
6553
|
/**
|
|
@@ -6463,7 +6556,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6463
6556
|
* @param index The index at which you want to insert the element.
|
|
6464
6557
|
*/
|
|
6465
6558
|
insert(element, index) {
|
|
6466
|
-
_optionalChain([this, 'access',
|
|
6559
|
+
_optionalChain([this, 'access', _139 => _139._pool, 'optionalAccess', _140 => _140.assertStorageIsWritable, 'call', _141 => _141()]);
|
|
6467
6560
|
if (index < 0 || index > this.#items.length) {
|
|
6468
6561
|
throw new Error(
|
|
6469
6562
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -6493,7 +6586,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6493
6586
|
* @param targetIndex The index where the element should be after moving.
|
|
6494
6587
|
*/
|
|
6495
6588
|
move(index, targetIndex) {
|
|
6496
|
-
_optionalChain([this, 'access',
|
|
6589
|
+
_optionalChain([this, 'access', _142 => _142._pool, 'optionalAccess', _143 => _143.assertStorageIsWritable, 'call', _144 => _144()]);
|
|
6497
6590
|
if (targetIndex < 0) {
|
|
6498
6591
|
throw new Error("targetIndex cannot be less than 0");
|
|
6499
6592
|
}
|
|
@@ -6551,7 +6644,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6551
6644
|
* @param index The index of the element to delete
|
|
6552
6645
|
*/
|
|
6553
6646
|
delete(index) {
|
|
6554
|
-
_optionalChain([this, 'access',
|
|
6647
|
+
_optionalChain([this, 'access', _145 => _145._pool, 'optionalAccess', _146 => _146.assertStorageIsWritable, 'call', _147 => _147()]);
|
|
6555
6648
|
if (index < 0 || index >= this.#items.length) {
|
|
6556
6649
|
throw new Error(
|
|
6557
6650
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6584,7 +6677,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6584
6677
|
}
|
|
6585
6678
|
}
|
|
6586
6679
|
clear() {
|
|
6587
|
-
_optionalChain([this, 'access',
|
|
6680
|
+
_optionalChain([this, 'access', _148 => _148._pool, 'optionalAccess', _149 => _149.assertStorageIsWritable, 'call', _150 => _150()]);
|
|
6588
6681
|
if (this._pool) {
|
|
6589
6682
|
const ops = [];
|
|
6590
6683
|
const reverseOps = [];
|
|
@@ -6618,7 +6711,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6618
6711
|
}
|
|
6619
6712
|
}
|
|
6620
6713
|
set(index, item) {
|
|
6621
|
-
_optionalChain([this, 'access',
|
|
6714
|
+
_optionalChain([this, 'access', _151 => _151._pool, 'optionalAccess', _152 => _152.assertStorageIsWritable, 'call', _153 => _153()]);
|
|
6622
6715
|
if (index < 0 || index >= this.#items.length) {
|
|
6623
6716
|
throw new Error(
|
|
6624
6717
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6764,7 +6857,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6764
6857
|
#shiftItemPosition(index, key) {
|
|
6765
6858
|
const shiftedPosition = makePosition(
|
|
6766
6859
|
key,
|
|
6767
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
6860
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _154 => _154.#items, 'access', _155 => _155[index + 1], 'optionalAccess', _156 => _156._parentPos]) : void 0
|
|
6768
6861
|
);
|
|
6769
6862
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
6770
6863
|
}
|
|
@@ -6889,7 +6982,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6889
6982
|
const ops = [];
|
|
6890
6983
|
const op = {
|
|
6891
6984
|
id: this._id,
|
|
6892
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6985
|
+
opId: _optionalChain([pool, 'optionalAccess', _157 => _157.generateOpId, 'call', _158 => _158()]),
|
|
6893
6986
|
type: 7 /* CREATE_MAP */,
|
|
6894
6987
|
parentId,
|
|
6895
6988
|
parentKey
|
|
@@ -7024,7 +7117,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7024
7117
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
7025
7118
|
*/
|
|
7026
7119
|
set(key, value) {
|
|
7027
|
-
_optionalChain([this, 'access',
|
|
7120
|
+
_optionalChain([this, 'access', _159 => _159._pool, 'optionalAccess', _160 => _160.assertStorageIsWritable, 'call', _161 => _161()]);
|
|
7028
7121
|
const oldValue = this.#map.get(key);
|
|
7029
7122
|
if (oldValue) {
|
|
7030
7123
|
oldValue._detach();
|
|
@@ -7070,7 +7163,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7070
7163
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
7071
7164
|
*/
|
|
7072
7165
|
delete(key) {
|
|
7073
|
-
_optionalChain([this, 'access',
|
|
7166
|
+
_optionalChain([this, 'access', _162 => _162._pool, 'optionalAccess', _163 => _163.assertStorageIsWritable, 'call', _164 => _164()]);
|
|
7074
7167
|
const item = this.#map.get(key);
|
|
7075
7168
|
if (item === void 0) {
|
|
7076
7169
|
return false;
|
|
@@ -7260,7 +7353,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7260
7353
|
if (this._id === void 0) {
|
|
7261
7354
|
throw new Error("Cannot serialize item is not attached");
|
|
7262
7355
|
}
|
|
7263
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
7356
|
+
const opId = _optionalChain([pool, 'optionalAccess', _165 => _165.generateOpId, 'call', _166 => _166()]);
|
|
7264
7357
|
const ops = [];
|
|
7265
7358
|
const op = {
|
|
7266
7359
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -7532,7 +7625,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7532
7625
|
* @param value The value of the property to add
|
|
7533
7626
|
*/
|
|
7534
7627
|
set(key, value) {
|
|
7535
|
-
_optionalChain([this, 'access',
|
|
7628
|
+
_optionalChain([this, 'access', _167 => _167._pool, 'optionalAccess', _168 => _168.assertStorageIsWritable, 'call', _169 => _169()]);
|
|
7536
7629
|
this.update({ [key]: value });
|
|
7537
7630
|
}
|
|
7538
7631
|
/**
|
|
@@ -7547,7 +7640,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7547
7640
|
* @param key The key of the property to delete
|
|
7548
7641
|
*/
|
|
7549
7642
|
delete(key) {
|
|
7550
|
-
_optionalChain([this, 'access',
|
|
7643
|
+
_optionalChain([this, 'access', _170 => _170._pool, 'optionalAccess', _171 => _171.assertStorageIsWritable, 'call', _172 => _172()]);
|
|
7551
7644
|
const keyAsString = key;
|
|
7552
7645
|
const oldValue = this.#map.get(keyAsString);
|
|
7553
7646
|
if (oldValue === void 0) {
|
|
@@ -7600,7 +7693,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7600
7693
|
* @param patch The object used to overrides properties
|
|
7601
7694
|
*/
|
|
7602
7695
|
update(patch) {
|
|
7603
|
-
_optionalChain([this, 'access',
|
|
7696
|
+
_optionalChain([this, 'access', _173 => _173._pool, 'optionalAccess', _174 => _174.assertStorageIsWritable, 'call', _175 => _175()]);
|
|
7604
7697
|
if (_LiveObject.detectLargeObjects) {
|
|
7605
7698
|
const data = {};
|
|
7606
7699
|
for (const [key, value] of this.#map) {
|
|
@@ -8348,15 +8441,15 @@ function installBackgroundTabSpy() {
|
|
|
8348
8441
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8349
8442
|
const inBackgroundSince = { current: null };
|
|
8350
8443
|
function onVisibilityChange() {
|
|
8351
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
8444
|
+
if (_optionalChain([doc, 'optionalAccess', _176 => _176.visibilityState]) === "hidden") {
|
|
8352
8445
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
8353
8446
|
} else {
|
|
8354
8447
|
inBackgroundSince.current = null;
|
|
8355
8448
|
}
|
|
8356
8449
|
}
|
|
8357
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8450
|
+
_optionalChain([doc, 'optionalAccess', _177 => _177.addEventListener, 'call', _178 => _178("visibilitychange", onVisibilityChange)]);
|
|
8358
8451
|
const unsub = () => {
|
|
8359
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8452
|
+
_optionalChain([doc, 'optionalAccess', _179 => _179.removeEventListener, 'call', _180 => _180("visibilitychange", onVisibilityChange)]);
|
|
8360
8453
|
};
|
|
8361
8454
|
return [inBackgroundSince, unsub];
|
|
8362
8455
|
}
|
|
@@ -8536,7 +8629,7 @@ function createRoom(options, config) {
|
|
|
8536
8629
|
}
|
|
8537
8630
|
}
|
|
8538
8631
|
function isStorageWritable() {
|
|
8539
|
-
const scopes = _optionalChain([context, 'access',
|
|
8632
|
+
const scopes = _optionalChain([context, 'access', _181 => _181.dynamicSessionInfoSig, 'access', _182 => _182.get, 'call', _183 => _183(), 'optionalAccess', _184 => _184.scopes]);
|
|
8540
8633
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
8541
8634
|
}
|
|
8542
8635
|
const eventHub = {
|
|
@@ -8555,8 +8648,8 @@ function createRoom(options, config) {
|
|
|
8555
8648
|
comments: makeEventSource(),
|
|
8556
8649
|
roomWillDestroy: makeEventSource()
|
|
8557
8650
|
};
|
|
8558
|
-
async function createTextMention(
|
|
8559
|
-
return httpClient.createTextMention({ roomId,
|
|
8651
|
+
async function createTextMention(mentionId, mention) {
|
|
8652
|
+
return httpClient.createTextMention({ roomId, mentionId, mention });
|
|
8560
8653
|
}
|
|
8561
8654
|
async function deleteTextMention(mentionId) {
|
|
8562
8655
|
return httpClient.deleteTextMention({ roomId, mentionId });
|
|
@@ -8662,7 +8755,7 @@ function createRoom(options, config) {
|
|
|
8662
8755
|
}
|
|
8663
8756
|
case "experimental-fallback-to-http": {
|
|
8664
8757
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8665
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
8758
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _185 => _185.dynamicSessionInfoSig, 'access', _186 => _186.get, 'call', _187 => _187(), 'optionalAccess', _188 => _188.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
8666
8759
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
8667
8760
|
if (!resp.ok && resp.status === 403) {
|
|
8668
8761
|
managedSocket.reconnect();
|
|
@@ -8713,7 +8806,7 @@ function createRoom(options, config) {
|
|
|
8713
8806
|
} else {
|
|
8714
8807
|
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
8715
8808
|
}
|
|
8716
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
8809
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _189 => _189.get, 'call', _190 => _190(), 'optionalAccess', _191 => _191.canWrite]), () => ( true));
|
|
8717
8810
|
const stackSizeBefore = context.undoStack.length;
|
|
8718
8811
|
for (const key in context.initialStorage) {
|
|
8719
8812
|
if (context.root.get(key) === void 0) {
|
|
@@ -8916,7 +9009,7 @@ function createRoom(options, config) {
|
|
|
8916
9009
|
}
|
|
8917
9010
|
context.myPresence.patch(patch);
|
|
8918
9011
|
if (context.activeBatch) {
|
|
8919
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9012
|
+
if (_optionalChain([options2, 'optionalAccess', _192 => _192.addToHistory])) {
|
|
8920
9013
|
context.activeBatch.reverseOps.pushLeft({
|
|
8921
9014
|
type: "presence",
|
|
8922
9015
|
data: oldValues
|
|
@@ -8925,7 +9018,7 @@ function createRoom(options, config) {
|
|
|
8925
9018
|
context.activeBatch.updates.presence = true;
|
|
8926
9019
|
} else {
|
|
8927
9020
|
flushNowOrSoon();
|
|
8928
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
9021
|
+
if (_optionalChain([options2, 'optionalAccess', _193 => _193.addToHistory])) {
|
|
8929
9022
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
8930
9023
|
}
|
|
8931
9024
|
notify({ presence: true });
|
|
@@ -9122,7 +9215,7 @@ function createRoom(options, config) {
|
|
|
9122
9215
|
if (process.env.NODE_ENV !== "production") {
|
|
9123
9216
|
const traces = /* @__PURE__ */ new Set();
|
|
9124
9217
|
for (const opId of message.opIds) {
|
|
9125
|
-
const trace = _optionalChain([context, 'access',
|
|
9218
|
+
const trace = _optionalChain([context, 'access', _194 => _194.opStackTraces, 'optionalAccess', _195 => _195.get, 'call', _196 => _196(opId)]);
|
|
9126
9219
|
if (trace) {
|
|
9127
9220
|
traces.add(trace);
|
|
9128
9221
|
}
|
|
@@ -9256,7 +9349,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9256
9349
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9257
9350
|
createOrUpdateRootFromMessage(message);
|
|
9258
9351
|
applyAndSendOps(unacknowledgedOps);
|
|
9259
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
9352
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _197 => _197()]);
|
|
9260
9353
|
notifyStorageStatus();
|
|
9261
9354
|
eventHub.storageDidLoad.notify();
|
|
9262
9355
|
}
|
|
@@ -9477,8 +9570,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9477
9570
|
async function getThreads(options2) {
|
|
9478
9571
|
return httpClient.getThreads({
|
|
9479
9572
|
roomId,
|
|
9480
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
9481
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9573
|
+
query: _optionalChain([options2, 'optionalAccess', _198 => _198.query]),
|
|
9574
|
+
cursor: _optionalChain([options2, 'optionalAccess', _199 => _199.cursor])
|
|
9482
9575
|
});
|
|
9483
9576
|
}
|
|
9484
9577
|
async function getThread(threadId) {
|
|
@@ -9585,7 +9678,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9585
9678
|
function getSubscriptionSettings(options2) {
|
|
9586
9679
|
return httpClient.getSubscriptionSettings({
|
|
9587
9680
|
roomId,
|
|
9588
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9681
|
+
signal: _optionalChain([options2, 'optionalAccess', _200 => _200.signal])
|
|
9589
9682
|
});
|
|
9590
9683
|
}
|
|
9591
9684
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9607,7 +9700,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9607
9700
|
{
|
|
9608
9701
|
[kInternal]: {
|
|
9609
9702
|
get presenceBuffer() {
|
|
9610
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9703
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _201 => _201.buffer, 'access', _202 => _202.presenceUpdates, 'optionalAccess', _203 => _203.data]), () => ( null)));
|
|
9611
9704
|
},
|
|
9612
9705
|
// prettier-ignore
|
|
9613
9706
|
get undoStack() {
|
|
@@ -9622,9 +9715,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9622
9715
|
return context.yjsProvider;
|
|
9623
9716
|
},
|
|
9624
9717
|
setYjsProvider(newProvider) {
|
|
9625
|
-
_optionalChain([context, 'access',
|
|
9718
|
+
_optionalChain([context, 'access', _204 => _204.yjsProvider, 'optionalAccess', _205 => _205.off, 'call', _206 => _206("status", yjsStatusDidChange)]);
|
|
9626
9719
|
context.yjsProvider = newProvider;
|
|
9627
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9720
|
+
_optionalChain([newProvider, 'optionalAccess', _207 => _207.on, 'call', _208 => _208("status", yjsStatusDidChange)]);
|
|
9628
9721
|
context.yjsProviderDidChange.notify();
|
|
9629
9722
|
},
|
|
9630
9723
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9670,7 +9763,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9670
9763
|
source.dispose();
|
|
9671
9764
|
}
|
|
9672
9765
|
eventHub.roomWillDestroy.notify();
|
|
9673
|
-
_optionalChain([context, 'access',
|
|
9766
|
+
_optionalChain([context, 'access', _209 => _209.yjsProvider, 'optionalAccess', _210 => _210.off, 'call', _211 => _211("status", yjsStatusDidChange)]);
|
|
9674
9767
|
syncSourceForStorage.destroy();
|
|
9675
9768
|
syncSourceForYjs.destroy();
|
|
9676
9769
|
uninstallBgTabSpy();
|
|
@@ -9820,7 +9913,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9820
9913
|
}
|
|
9821
9914
|
if (isLiveNode(first)) {
|
|
9822
9915
|
const node = first;
|
|
9823
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9916
|
+
if (_optionalChain([options, 'optionalAccess', _212 => _212.isDeep])) {
|
|
9824
9917
|
const storageCallback = second;
|
|
9825
9918
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9826
9919
|
} else {
|
|
@@ -9877,6 +9970,7 @@ var MAX_LOST_CONNECTION_TIMEOUT = 3e4;
|
|
|
9877
9970
|
var DEFAULT_LOST_CONNECTION_TIMEOUT = 5e3;
|
|
9878
9971
|
var RESOLVE_USERS_BATCH_DELAY = 50;
|
|
9879
9972
|
var RESOLVE_ROOMS_INFO_BATCH_DELAY = 50;
|
|
9973
|
+
var RESOLVE_GROUPS_INFO_BATCH_DELAY = 50;
|
|
9880
9974
|
function getBaseUrl(baseUrl) {
|
|
9881
9975
|
if (typeof baseUrl === "string" && baseUrl.startsWith("http")) {
|
|
9882
9976
|
return baseUrl;
|
|
@@ -9899,8 +9993,8 @@ function createClient(options) {
|
|
|
9899
9993
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
9900
9994
|
currentUserId.set(() => userId);
|
|
9901
9995
|
});
|
|
9902
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
9903
|
-
_optionalChain([globalThis, 'access',
|
|
9996
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _213 => _213.polyfills, 'optionalAccess', _214 => _214.fetch]) || /* istanbul ignore next */
|
|
9997
|
+
_optionalChain([globalThis, 'access', _215 => _215.fetch, 'optionalAccess', _216 => _216.bind, 'call', _217 => _217(globalThis)]);
|
|
9904
9998
|
const httpClient = createApiClient({
|
|
9905
9999
|
baseUrl,
|
|
9906
10000
|
fetchPolyfill,
|
|
@@ -9918,7 +10012,7 @@ function createClient(options) {
|
|
|
9918
10012
|
delegates: {
|
|
9919
10013
|
createSocket: makeCreateSocketDelegateForAi(
|
|
9920
10014
|
baseUrl,
|
|
9921
|
-
_optionalChain([clientOptions, 'access',
|
|
10015
|
+
_optionalChain([clientOptions, 'access', _218 => _218.polyfills, 'optionalAccess', _219 => _219.WebSocket])
|
|
9922
10016
|
),
|
|
9923
10017
|
authenticate: async () => {
|
|
9924
10018
|
const resp = await authManager.getAuthValue({
|
|
@@ -9986,7 +10080,7 @@ function createClient(options) {
|
|
|
9986
10080
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
9987
10081
|
roomId,
|
|
9988
10082
|
baseUrl,
|
|
9989
|
-
_optionalChain([clientOptions, 'access',
|
|
10083
|
+
_optionalChain([clientOptions, 'access', _220 => _220.polyfills, 'optionalAccess', _221 => _221.WebSocket])
|
|
9990
10084
|
),
|
|
9991
10085
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
9992
10086
|
})),
|
|
@@ -10009,7 +10103,7 @@ function createClient(options) {
|
|
|
10009
10103
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
10010
10104
|
if (shouldConnect) {
|
|
10011
10105
|
if (typeof atob === "undefined") {
|
|
10012
|
-
if (_optionalChain([clientOptions, 'access',
|
|
10106
|
+
if (_optionalChain([clientOptions, 'access', _222 => _222.polyfills, 'optionalAccess', _223 => _223.atob]) === void 0) {
|
|
10013
10107
|
throw new Error(
|
|
10014
10108
|
"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"
|
|
10015
10109
|
);
|
|
@@ -10021,7 +10115,7 @@ function createClient(options) {
|
|
|
10021
10115
|
return leaseRoom(newRoomDetails);
|
|
10022
10116
|
}
|
|
10023
10117
|
function getRoom(roomId) {
|
|
10024
|
-
const room = _optionalChain([roomsById, 'access',
|
|
10118
|
+
const room = _optionalChain([roomsById, 'access', _224 => _224.get, 'call', _225 => _225(roomId), 'optionalAccess', _226 => _226.room]);
|
|
10025
10119
|
return room ? room : null;
|
|
10026
10120
|
}
|
|
10027
10121
|
function logout() {
|
|
@@ -10034,15 +10128,14 @@ function createClient(options) {
|
|
|
10034
10128
|
}
|
|
10035
10129
|
}
|
|
10036
10130
|
const resolveUsers = clientOptions.resolveUsers;
|
|
10037
|
-
const warnIfNoResolveUsers = createDevelopmentWarning(
|
|
10038
|
-
() => !resolveUsers,
|
|
10039
|
-
"Set the resolveUsers option in createClient to specify user info."
|
|
10040
|
-
);
|
|
10041
10131
|
const batchedResolveUsers = new Batch(
|
|
10042
10132
|
async (batchedUserIds) => {
|
|
10043
10133
|
const userIds = batchedUserIds.flat();
|
|
10044
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
10045
|
-
|
|
10134
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _227 => _227({ userIds })]);
|
|
10135
|
+
warnOnceIf(
|
|
10136
|
+
!resolveUsers,
|
|
10137
|
+
"Set the resolveUsers option in createClient to specify user info."
|
|
10138
|
+
);
|
|
10046
10139
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
10047
10140
|
},
|
|
10048
10141
|
{ delay: RESOLVE_USERS_BATCH_DELAY }
|
|
@@ -10052,15 +10145,14 @@ function createClient(options) {
|
|
|
10052
10145
|
usersStore.invalidate(userIds);
|
|
10053
10146
|
}
|
|
10054
10147
|
const resolveRoomsInfo = clientOptions.resolveRoomsInfo;
|
|
10055
|
-
const warnIfNoResolveRoomsInfo = createDevelopmentWarning(
|
|
10056
|
-
() => !resolveRoomsInfo,
|
|
10057
|
-
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
10058
|
-
);
|
|
10059
10148
|
const batchedResolveRoomsInfo = new Batch(
|
|
10060
10149
|
async (batchedRoomIds) => {
|
|
10061
10150
|
const roomIds = batchedRoomIds.flat();
|
|
10062
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
10063
|
-
|
|
10151
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _228 => _228({ roomIds })]);
|
|
10152
|
+
warnOnceIf(
|
|
10153
|
+
!resolveRoomsInfo,
|
|
10154
|
+
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
10155
|
+
);
|
|
10064
10156
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
10065
10157
|
},
|
|
10066
10158
|
{ delay: RESOLVE_ROOMS_INFO_BATCH_DELAY }
|
|
@@ -10069,6 +10161,23 @@ function createClient(options) {
|
|
|
10069
10161
|
function invalidateResolvedRoomsInfo(roomIds) {
|
|
10070
10162
|
roomsInfoStore.invalidate(roomIds);
|
|
10071
10163
|
}
|
|
10164
|
+
const resolveGroupsInfo = clientOptions.resolveGroupsInfo;
|
|
10165
|
+
const batchedResolveGroupsInfo = new Batch(
|
|
10166
|
+
async (batchedGroupIds) => {
|
|
10167
|
+
const groupIds = batchedGroupIds.flat();
|
|
10168
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _229 => _229({ groupIds })]);
|
|
10169
|
+
warnOnceIf(
|
|
10170
|
+
!resolveGroupsInfo,
|
|
10171
|
+
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
10172
|
+
);
|
|
10173
|
+
return _nullishCoalesce(groupsInfo, () => ( groupIds.map(() => void 0)));
|
|
10174
|
+
},
|
|
10175
|
+
{ delay: RESOLVE_GROUPS_INFO_BATCH_DELAY }
|
|
10176
|
+
);
|
|
10177
|
+
const groupsInfoStore = createBatchStore(batchedResolveGroupsInfo);
|
|
10178
|
+
function invalidateResolvedGroupsInfo(groupIds) {
|
|
10179
|
+
groupsInfoStore.invalidate(groupIds);
|
|
10180
|
+
}
|
|
10072
10181
|
const mentionSuggestionsCache = /* @__PURE__ */ new Map();
|
|
10073
10182
|
function invalidateResolvedMentionSuggestions() {
|
|
10074
10183
|
mentionSuggestionsCache.clear();
|
|
@@ -10112,7 +10221,7 @@ function createClient(options) {
|
|
|
10112
10221
|
}
|
|
10113
10222
|
};
|
|
10114
10223
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10115
|
-
_optionalChain([win, 'optionalAccess',
|
|
10224
|
+
_optionalChain([win, 'optionalAccess', _230 => _230.addEventListener, 'call', _231 => _231("beforeunload", maybePreventClose)]);
|
|
10116
10225
|
}
|
|
10117
10226
|
async function getNotificationSettings(options2) {
|
|
10118
10227
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -10144,6 +10253,7 @@ function createClient(options) {
|
|
|
10144
10253
|
resolvers: {
|
|
10145
10254
|
invalidateUsers: invalidateResolvedUsers,
|
|
10146
10255
|
invalidateRoomsInfo: invalidateResolvedRoomsInfo,
|
|
10256
|
+
invalidateGroupsInfo: invalidateResolvedGroupsInfo,
|
|
10147
10257
|
invalidateMentionSuggestions: invalidateResolvedMentionSuggestions
|
|
10148
10258
|
},
|
|
10149
10259
|
getSyncStatus,
|
|
@@ -10159,6 +10269,7 @@ function createClient(options) {
|
|
|
10159
10269
|
resolveMentionSuggestions: clientOptions.resolveMentionSuggestions,
|
|
10160
10270
|
usersStore,
|
|
10161
10271
|
roomsInfoStore,
|
|
10272
|
+
groupsInfoStore,
|
|
10162
10273
|
getRoomIds() {
|
|
10163
10274
|
return Array.from(roomsById.keys());
|
|
10164
10275
|
},
|
|
@@ -10210,20 +10321,6 @@ function getLostConnectionTimeout(value) {
|
|
|
10210
10321
|
RECOMMENDED_MIN_LOST_CONNECTION_TIMEOUT
|
|
10211
10322
|
);
|
|
10212
10323
|
}
|
|
10213
|
-
function createDevelopmentWarning(condition, ...args) {
|
|
10214
|
-
let hasWarned = false;
|
|
10215
|
-
if (process.env.NODE_ENV !== "production") {
|
|
10216
|
-
return () => {
|
|
10217
|
-
if (!hasWarned && (typeof condition === "function" ? condition() : condition)) {
|
|
10218
|
-
warn(...args);
|
|
10219
|
-
hasWarned = true;
|
|
10220
|
-
}
|
|
10221
|
-
};
|
|
10222
|
-
} else {
|
|
10223
|
-
return () => {
|
|
10224
|
-
};
|
|
10225
|
-
}
|
|
10226
|
-
}
|
|
10227
10324
|
|
|
10228
10325
|
// src/comments/comment-body.ts
|
|
10229
10326
|
function isCommentBodyParagraph(element) {
|
|
@@ -10251,7 +10348,7 @@ var commentBodyElementsTypes = {
|
|
|
10251
10348
|
mention: "inline"
|
|
10252
10349
|
};
|
|
10253
10350
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
10254
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
10351
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _232 => _232.content])) {
|
|
10255
10352
|
return;
|
|
10256
10353
|
}
|
|
10257
10354
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -10261,13 +10358,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
10261
10358
|
for (const block of body.content) {
|
|
10262
10359
|
if (type === "all" || type === "block") {
|
|
10263
10360
|
if (guard(block)) {
|
|
10264
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10361
|
+
_optionalChain([visitor, 'optionalCall', _233 => _233(block)]);
|
|
10265
10362
|
}
|
|
10266
10363
|
}
|
|
10267
10364
|
if (type === "all" || type === "inline") {
|
|
10268
10365
|
for (const inline of block.children) {
|
|
10269
10366
|
if (guard(inline)) {
|
|
10270
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10367
|
+
_optionalChain([visitor, 'optionalCall', _234 => _234(inline)]);
|
|
10271
10368
|
}
|
|
10272
10369
|
}
|
|
10273
10370
|
}
|
|
@@ -10288,25 +10385,42 @@ function getMentionsFromCommentBody(body, predicate) {
|
|
|
10288
10385
|
});
|
|
10289
10386
|
return mentions;
|
|
10290
10387
|
}
|
|
10291
|
-
async function
|
|
10388
|
+
async function resolveMentionsInCommentBody(body, resolveUsers, resolveGroupsInfo) {
|
|
10292
10389
|
const resolvedUsers = /* @__PURE__ */ new Map();
|
|
10293
|
-
|
|
10294
|
-
|
|
10390
|
+
const resolvedGroupsInfo = /* @__PURE__ */ new Map();
|
|
10391
|
+
if (!resolveUsers && !resolveGroupsInfo) {
|
|
10392
|
+
return {
|
|
10393
|
+
users: resolvedUsers,
|
|
10394
|
+
groups: resolvedGroupsInfo
|
|
10395
|
+
};
|
|
10295
10396
|
}
|
|
10296
|
-
const
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
const
|
|
10305
|
-
|
|
10306
|
-
|
|
10397
|
+
const mentions = getMentionsFromCommentBody(body);
|
|
10398
|
+
const userIds = mentions.filter((mention) => mention.kind === "user").map((mention) => mention.id);
|
|
10399
|
+
const groupIds = mentions.filter((mention) => mention.kind === "group").map((mention) => mention.id);
|
|
10400
|
+
const [users, groups] = await Promise.all([
|
|
10401
|
+
resolveUsers && userIds.length > 0 ? resolveUsers({ userIds }) : void 0,
|
|
10402
|
+
resolveGroupsInfo && groupIds.length > 0 ? resolveGroupsInfo({ groupIds }) : void 0
|
|
10403
|
+
]);
|
|
10404
|
+
if (users) {
|
|
10405
|
+
for (const [index, userId] of userIds.entries()) {
|
|
10406
|
+
const user = users[index];
|
|
10407
|
+
if (user) {
|
|
10408
|
+
resolvedUsers.set(userId, user);
|
|
10409
|
+
}
|
|
10410
|
+
}
|
|
10411
|
+
}
|
|
10412
|
+
if (groups) {
|
|
10413
|
+
for (const [index, groupId] of groupIds.entries()) {
|
|
10414
|
+
const group = groups[index];
|
|
10415
|
+
if (group) {
|
|
10416
|
+
resolvedGroupsInfo.set(groupId, group);
|
|
10417
|
+
}
|
|
10307
10418
|
}
|
|
10308
10419
|
}
|
|
10309
|
-
return
|
|
10420
|
+
return {
|
|
10421
|
+
users: resolvedUsers,
|
|
10422
|
+
groups: resolvedGroupsInfo
|
|
10423
|
+
};
|
|
10310
10424
|
}
|
|
10311
10425
|
var htmlEscapables = {
|
|
10312
10426
|
"&": "&",
|
|
@@ -10419,8 +10533,8 @@ var stringifyCommentBodyPlainElements = {
|
|
|
10419
10533
|
paragraph: ({ children }) => children,
|
|
10420
10534
|
text: ({ element }) => element.text,
|
|
10421
10535
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
10422
|
-
mention: ({ element, user }) => {
|
|
10423
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10536
|
+
mention: ({ element, user, group }) => {
|
|
10537
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _235 => _235.name]), () => ( _optionalChain([group, 'optionalAccess', _236 => _236.name]))), () => ( element.id))}`;
|
|
10424
10538
|
}
|
|
10425
10539
|
};
|
|
10426
10540
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -10449,8 +10563,8 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
10449
10563
|
link: ({ element, href }) => {
|
|
10450
10564
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
10451
10565
|
},
|
|
10452
|
-
mention: ({ element, user }) => {
|
|
10453
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
10566
|
+
mention: ({ element, user, group }) => {
|
|
10567
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _237 => _237.name]) ? html`${_optionalChain([user, 'optionalAccess', _238 => _238.name])}` : _optionalChain([group, 'optionalAccess', _239 => _239.name]) ? html`${_optionalChain([group, 'optionalAccess', _240 => _240.name])}` : element.id}</span>`;
|
|
10454
10568
|
}
|
|
10455
10569
|
};
|
|
10456
10570
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -10479,20 +10593,21 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
10479
10593
|
link: ({ element, href }) => {
|
|
10480
10594
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
10481
10595
|
},
|
|
10482
|
-
mention: ({ element, user }) => {
|
|
10483
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10596
|
+
mention: ({ element, user, group }) => {
|
|
10597
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _241 => _241.name]), () => ( _optionalChain([group, 'optionalAccess', _242 => _242.name]))), () => ( element.id))}`;
|
|
10484
10598
|
}
|
|
10485
10599
|
};
|
|
10486
10600
|
async function stringifyCommentBody(body, options) {
|
|
10487
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10488
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10601
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _243 => _243.format]), () => ( "plain"));
|
|
10602
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
10489
10603
|
const elements = {
|
|
10490
10604
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
10491
|
-
..._optionalChain([options, 'optionalAccess',
|
|
10605
|
+
..._optionalChain([options, 'optionalAccess', _245 => _245.elements])
|
|
10492
10606
|
};
|
|
10493
|
-
const resolvedUsers = await
|
|
10607
|
+
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
10494
10608
|
body,
|
|
10495
|
-
_optionalChain([options, 'optionalAccess',
|
|
10609
|
+
_optionalChain([options, 'optionalAccess', _246 => _246.resolveUsers]),
|
|
10610
|
+
_optionalChain([options, 'optionalAccess', _247 => _247.resolveGroupsInfo])
|
|
10496
10611
|
);
|
|
10497
10612
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
10498
10613
|
switch (block.type) {
|
|
@@ -10503,7 +10618,8 @@ async function stringifyCommentBody(body, options) {
|
|
|
10503
10618
|
elements.mention(
|
|
10504
10619
|
{
|
|
10505
10620
|
element: inline,
|
|
10506
|
-
user: resolvedUsers.get(inline.id)
|
|
10621
|
+
user: inline.kind === "user" ? resolvedUsers.get(inline.id) : void 0,
|
|
10622
|
+
group: inline.kind === "group" ? resolvedGroupsInfo.get(inline.id) : void 0
|
|
10507
10623
|
},
|
|
10508
10624
|
inlineIndex
|
|
10509
10625
|
)
|
|
@@ -10778,12 +10894,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10778
10894
|
}
|
|
10779
10895
|
const newState = Object.assign({}, state);
|
|
10780
10896
|
for (const key in update.updates) {
|
|
10781
|
-
if (_optionalChain([update, 'access',
|
|
10897
|
+
if (_optionalChain([update, 'access', _248 => _248.updates, 'access', _249 => _249[key], 'optionalAccess', _250 => _250.type]) === "update") {
|
|
10782
10898
|
const val = update.node.get(key);
|
|
10783
10899
|
if (val !== void 0) {
|
|
10784
10900
|
newState[key] = lsonToJson(val);
|
|
10785
10901
|
}
|
|
10786
|
-
} else if (_optionalChain([update, 'access',
|
|
10902
|
+
} else if (_optionalChain([update, 'access', _251 => _251.updates, 'access', _252 => _252[key], 'optionalAccess', _253 => _253.type]) === "delete") {
|
|
10787
10903
|
delete newState[key];
|
|
10788
10904
|
}
|
|
10789
10905
|
}
|
|
@@ -10844,12 +10960,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10844
10960
|
}
|
|
10845
10961
|
const newState = Object.assign({}, state);
|
|
10846
10962
|
for (const key in update.updates) {
|
|
10847
|
-
if (_optionalChain([update, 'access',
|
|
10963
|
+
if (_optionalChain([update, 'access', _254 => _254.updates, 'access', _255 => _255[key], 'optionalAccess', _256 => _256.type]) === "update") {
|
|
10848
10964
|
const value = update.node.get(key);
|
|
10849
10965
|
if (value !== void 0) {
|
|
10850
10966
|
newState[key] = lsonToJson(value);
|
|
10851
10967
|
}
|
|
10852
|
-
} else if (_optionalChain([update, 'access',
|
|
10968
|
+
} else if (_optionalChain([update, 'access', _257 => _257.updates, 'access', _258 => _258[key], 'optionalAccess', _259 => _259.type]) === "delete") {
|
|
10853
10969
|
delete newState[key];
|
|
10854
10970
|
}
|
|
10855
10971
|
}
|
|
@@ -10929,9 +11045,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10929
11045
|
const startTime = performance.now();
|
|
10930
11046
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10931
11047
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10932
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11048
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _260 => _260.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
10933
11049
|
const context = {
|
|
10934
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
11050
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _261 => _261.visibilityState]) !== "hidden",
|
|
10935
11051
|
lastSuccessfulPollAt: startTime,
|
|
10936
11052
|
count: 0,
|
|
10937
11053
|
backoff: 0
|
|
@@ -11012,11 +11128,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11012
11128
|
pollNowIfStale();
|
|
11013
11129
|
}
|
|
11014
11130
|
function onVisibilityChange() {
|
|
11015
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
11131
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _262 => _262.visibilityState]) !== "hidden");
|
|
11016
11132
|
}
|
|
11017
|
-
_optionalChain([doc, 'optionalAccess',
|
|
11018
|
-
_optionalChain([win, 'optionalAccess',
|
|
11019
|
-
_optionalChain([win, 'optionalAccess',
|
|
11133
|
+
_optionalChain([doc, 'optionalAccess', _263 => _263.addEventListener, 'call', _264 => _264("visibilitychange", onVisibilityChange)]);
|
|
11134
|
+
_optionalChain([win, 'optionalAccess', _265 => _265.addEventListener, 'call', _266 => _266("online", onVisibilityChange)]);
|
|
11135
|
+
_optionalChain([win, 'optionalAccess', _267 => _267.addEventListener, 'call', _268 => _268("focus", pollNowIfStale)]);
|
|
11020
11136
|
fsm.start();
|
|
11021
11137
|
return {
|
|
11022
11138
|
inc,
|
|
@@ -11146,5 +11262,9 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
11146
11262
|
|
|
11147
11263
|
|
|
11148
11264
|
|
|
11149
|
-
|
|
11265
|
+
|
|
11266
|
+
|
|
11267
|
+
|
|
11268
|
+
|
|
11269
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MENTION_CHARACTER = MENTION_CHARACTER; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToGroupData = convertToGroupData; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.findLastIndex = findLastIndex; exports.freeze = freeze; exports.generateUrl = generateUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.isUrl = isUrl; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; 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.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveMentionsInCommentBody = resolveMentionsInCommentBody; exports.sanitizeUrl = sanitizeUrl; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.warnOnce = warnOnce; exports.warnOnceIf = warnOnceIf; exports.withTimeout = withTimeout;
|
|
11150
11270
|
//# sourceMappingURL=index.cjs.map
|