@liveblocks/core 3.3.4 → 3.4.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 +251 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +156 -6
- 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.4.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -243,6 +243,14 @@ function memoizeOnSuccess(factoryFn) {
|
|
|
243
243
|
return cached;
|
|
244
244
|
};
|
|
245
245
|
}
|
|
246
|
+
function findLastIndex(arr, predicate) {
|
|
247
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
248
|
+
if (predicate(arr[i], i, arr)) {
|
|
249
|
+
return i;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return -1;
|
|
253
|
+
}
|
|
246
254
|
|
|
247
255
|
// src/lib/signals.ts
|
|
248
256
|
var kSinks = Symbol("kSinks");
|
|
@@ -1332,6 +1340,9 @@ function sanitizeUrl(url2) {
|
|
|
1332
1340
|
if (url2.startsWith("www.")) {
|
|
1333
1341
|
url2 = "https://" + url2;
|
|
1334
1342
|
}
|
|
1343
|
+
if (url2 === "#") {
|
|
1344
|
+
return url2;
|
|
1345
|
+
}
|
|
1335
1346
|
try {
|
|
1336
1347
|
const isAbsolute = ABSOLUTE_URL_REGEX.test(url2);
|
|
1337
1348
|
const urlObject = new URL(
|
|
@@ -1375,6 +1386,14 @@ function generateUrl(url2, params, hash) {
|
|
|
1375
1386
|
}
|
|
1376
1387
|
return isAbsolute ? urlObject.href : urlObject.href.replace(PLACEHOLDER_BASE_URL, "");
|
|
1377
1388
|
}
|
|
1389
|
+
function isUrl(string) {
|
|
1390
|
+
try {
|
|
1391
|
+
new URL(string);
|
|
1392
|
+
return true;
|
|
1393
|
+
} catch (_) {
|
|
1394
|
+
return false;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1378
1397
|
|
|
1379
1398
|
// src/api-client.ts
|
|
1380
1399
|
function createApiClient({
|
|
@@ -3798,8 +3817,102 @@ function parseAuthToken(rawTokenString) {
|
|
|
3798
3817
|
};
|
|
3799
3818
|
}
|
|
3800
3819
|
|
|
3820
|
+
// src/lib/parsePartialJsonObject.ts
|
|
3821
|
+
function parsePartialJsonObject(partial) {
|
|
3822
|
+
partial = partial.trimStart();
|
|
3823
|
+
if (partial.charAt(0) !== "{") {
|
|
3824
|
+
return {};
|
|
3825
|
+
}
|
|
3826
|
+
if (partial.trimEnd().endsWith("}")) {
|
|
3827
|
+
const quickCheck = tryParseJson(partial);
|
|
3828
|
+
if (quickCheck) {
|
|
3829
|
+
return quickCheck;
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
let result = partial;
|
|
3833
|
+
let quoteCount = 0;
|
|
3834
|
+
let escaped = false;
|
|
3835
|
+
for (let i = 0; i < result.length; i++) {
|
|
3836
|
+
const char = result[i];
|
|
3837
|
+
if (escaped) {
|
|
3838
|
+
escaped = false;
|
|
3839
|
+
} else if (char === "\\") {
|
|
3840
|
+
escaped = true;
|
|
3841
|
+
} else if (char === '"') {
|
|
3842
|
+
quoteCount++;
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
if (quoteCount % 2 === 1) {
|
|
3846
|
+
result += '"';
|
|
3847
|
+
}
|
|
3848
|
+
result = result.trimEnd();
|
|
3849
|
+
if (result.endsWith(",")) {
|
|
3850
|
+
result = result.slice(0, -1);
|
|
3851
|
+
}
|
|
3852
|
+
if (result.endsWith(".")) {
|
|
3853
|
+
result = result.slice(0, -1);
|
|
3854
|
+
}
|
|
3855
|
+
const stack = [];
|
|
3856
|
+
let inString = false;
|
|
3857
|
+
escaped = false;
|
|
3858
|
+
for (let i = 0; i < result.length; i++) {
|
|
3859
|
+
const char = result[i];
|
|
3860
|
+
if (inString) {
|
|
3861
|
+
if (escaped) {
|
|
3862
|
+
escaped = false;
|
|
3863
|
+
} else if (char === "\\") {
|
|
3864
|
+
escaped = true;
|
|
3865
|
+
} else if (char === '"') {
|
|
3866
|
+
inString = false;
|
|
3867
|
+
}
|
|
3868
|
+
} else {
|
|
3869
|
+
if (char === '"') {
|
|
3870
|
+
inString = true;
|
|
3871
|
+
} else if (char === "{") {
|
|
3872
|
+
stack.push("}");
|
|
3873
|
+
} else if (char === "[") {
|
|
3874
|
+
stack.push("]");
|
|
3875
|
+
} else if (char === "}" && stack.length > 0 && stack[stack.length - 1] === "}") {
|
|
3876
|
+
stack.pop();
|
|
3877
|
+
} else if (char === "]" && stack.length > 0 && stack[stack.length - 1] === "]") {
|
|
3878
|
+
stack.pop();
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
}
|
|
3882
|
+
const suffix = stack.reverse().join("");
|
|
3883
|
+
{
|
|
3884
|
+
const attempt = tryParseJson(result + suffix);
|
|
3885
|
+
if (attempt) {
|
|
3886
|
+
return attempt;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
if (result.endsWith(":")) {
|
|
3890
|
+
result = result.slice(0, -1);
|
|
3891
|
+
}
|
|
3892
|
+
if (result.endsWith('"')) {
|
|
3893
|
+
let pos = result.length - 2;
|
|
3894
|
+
escaped = false;
|
|
3895
|
+
while (pos >= 0) {
|
|
3896
|
+
if (escaped) {
|
|
3897
|
+
escaped = false;
|
|
3898
|
+
} else if (result[pos] === "\\") {
|
|
3899
|
+
escaped = true;
|
|
3900
|
+
} else if (result[pos] === '"') {
|
|
3901
|
+
result = result.slice(0, pos);
|
|
3902
|
+
break;
|
|
3903
|
+
}
|
|
3904
|
+
pos--;
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
if (result.endsWith(",")) {
|
|
3908
|
+
result = result.slice(0, -1);
|
|
3909
|
+
}
|
|
3910
|
+
result += suffix;
|
|
3911
|
+
return _nullishCoalesce(tryParseJson(result), () => ( {}));
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3801
3914
|
// src/types/ai.ts
|
|
3802
|
-
function
|
|
3915
|
+
function patchContentWithDelta(content, delta) {
|
|
3803
3916
|
const lastPart = content[content.length - 1];
|
|
3804
3917
|
switch (delta.type) {
|
|
3805
3918
|
case "text-delta":
|
|
@@ -3819,9 +3932,44 @@ function appendDelta(content, delta) {
|
|
|
3819
3932
|
});
|
|
3820
3933
|
}
|
|
3821
3934
|
break;
|
|
3822
|
-
case "tool-
|
|
3823
|
-
|
|
3935
|
+
case "tool-stream": {
|
|
3936
|
+
let _cacheKey = "";
|
|
3937
|
+
let _cachedArgs = {};
|
|
3938
|
+
const toolInvocation = {
|
|
3939
|
+
type: "tool-invocation",
|
|
3940
|
+
stage: "receiving",
|
|
3941
|
+
invocationId: delta.invocationId,
|
|
3942
|
+
name: delta.name,
|
|
3943
|
+
partialArgsText: "",
|
|
3944
|
+
get partialArgs() {
|
|
3945
|
+
if (this.partialArgsText !== _cacheKey) {
|
|
3946
|
+
_cachedArgs = parsePartialJsonObject(this.partialArgsText);
|
|
3947
|
+
_cacheKey = this.partialArgsText;
|
|
3948
|
+
}
|
|
3949
|
+
return _cachedArgs;
|
|
3950
|
+
}
|
|
3951
|
+
};
|
|
3952
|
+
content.push(toolInvocation);
|
|
3953
|
+
break;
|
|
3954
|
+
}
|
|
3955
|
+
case "tool-delta": {
|
|
3956
|
+
if (_optionalChain([lastPart, 'optionalAccess', _57 => _57.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
3957
|
+
lastPart.partialArgsText += delta.delta;
|
|
3958
|
+
}
|
|
3824
3959
|
break;
|
|
3960
|
+
}
|
|
3961
|
+
case "tool-invocation": {
|
|
3962
|
+
const existingIndex = findLastIndex(
|
|
3963
|
+
content,
|
|
3964
|
+
(part) => part.type === "tool-invocation" && part.invocationId === delta.invocationId
|
|
3965
|
+
);
|
|
3966
|
+
if (existingIndex > -1) {
|
|
3967
|
+
content[existingIndex] = delta;
|
|
3968
|
+
} else {
|
|
3969
|
+
content.push(delta);
|
|
3970
|
+
}
|
|
3971
|
+
break;
|
|
3972
|
+
}
|
|
3825
3973
|
default:
|
|
3826
3974
|
return assertNever(delta, "Unhandled case");
|
|
3827
3975
|
}
|
|
@@ -3908,7 +4056,7 @@ function createStore_forTools() {
|
|
|
3908
4056
|
return DerivedSignal.from(() => {
|
|
3909
4057
|
return (
|
|
3910
4058
|
// A tool that's registered and scoped to a specific chat ID...
|
|
3911
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4059
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _58 => _58.get, 'call', _59 => _59()]), () => ( // ...or a globally registered tool
|
|
3912
4060
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
3913
4061
|
);
|
|
3914
4062
|
});
|
|
@@ -3938,8 +4086,8 @@ function createStore_forTools() {
|
|
|
3938
4086
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
3939
4087
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
3940
4088
|
return Array.from([
|
|
3941
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
3942
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4089
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _60 => _60.entries, 'call', _61 => _61()]), () => ( [])),
|
|
4090
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _62 => _62.entries, 'call', _63 => _63()]), () => ( []))
|
|
3943
4091
|
]).flatMap(([name, tool\u03A3]) => {
|
|
3944
4092
|
const tool = tool\u03A3.get();
|
|
3945
4093
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4040,7 +4188,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4040
4188
|
} else {
|
|
4041
4189
|
continue;
|
|
4042
4190
|
}
|
|
4043
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4191
|
+
const executeFn = _optionalChain([toolsStore, 'access', _64 => _64.getTool\u03A3, 'call', _65 => _65(toolInvocation.name, message.chatId), 'access', _66 => _66.get, 'call', _67 => _67(), 'optionalAccess', _68 => _68.execute]);
|
|
4044
4192
|
if (executeFn) {
|
|
4045
4193
|
(async () => {
|
|
4046
4194
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4074,7 +4222,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4074
4222
|
generatingMessages\u03A3.mutate((lut) => {
|
|
4075
4223
|
const message = lut.get(messageId);
|
|
4076
4224
|
if (message === void 0) return false;
|
|
4077
|
-
|
|
4225
|
+
patchContentWithDelta(message.contentSoFar, delta);
|
|
4078
4226
|
lut.set(messageId, message);
|
|
4079
4227
|
return true;
|
|
4080
4228
|
});
|
|
@@ -4138,8 +4286,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4138
4286
|
const spine = [];
|
|
4139
4287
|
let lastVisitedMessage = null;
|
|
4140
4288
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4141
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4142
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4289
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _69 => _69(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _70 => _70.id]), () => ( null));
|
|
4290
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _71 => _71(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _72 => _72.id]), () => ( null));
|
|
4143
4291
|
if (!message2.deletedAt || prev || next) {
|
|
4144
4292
|
const node = {
|
|
4145
4293
|
...message2,
|
|
@@ -4322,7 +4470,7 @@ function createAi(config) {
|
|
|
4322
4470
|
if ("event" in msg) {
|
|
4323
4471
|
switch (msg.event) {
|
|
4324
4472
|
case "cmd-failed":
|
|
4325
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4473
|
+
_optionalChain([pendingCmd, 'optionalAccess', _73 => _73.reject, 'call', _74 => _74(new Error(msg.error))]);
|
|
4326
4474
|
break;
|
|
4327
4475
|
case "delta": {
|
|
4328
4476
|
const { id, delta } = msg;
|
|
@@ -4404,7 +4552,7 @@ function createAi(config) {
|
|
|
4404
4552
|
return assertNever(msg, "Unhandled case");
|
|
4405
4553
|
}
|
|
4406
4554
|
}
|
|
4407
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4555
|
+
_optionalChain([pendingCmd, 'optionalAccess', _75 => _75.resolve, 'call', _76 => _76(msg)]);
|
|
4408
4556
|
}
|
|
4409
4557
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4410
4558
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4489,9 +4637,9 @@ function createAi(config) {
|
|
|
4489
4637
|
invocationId,
|
|
4490
4638
|
result,
|
|
4491
4639
|
generationOptions: {
|
|
4492
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4493
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4494
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4640
|
+
copilotId: _optionalChain([options, 'optionalAccess', _77 => _77.copilotId]),
|
|
4641
|
+
stream: _optionalChain([options, 'optionalAccess', _78 => _78.stream]),
|
|
4642
|
+
timeout: _optionalChain([options, 'optionalAccess', _79 => _79.timeout]),
|
|
4495
4643
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4496
4644
|
// from the global context
|
|
4497
4645
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -4520,7 +4668,7 @@ function createAi(config) {
|
|
|
4520
4668
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4521
4669
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4522
4670
|
const globalKnowledge = context.knowledge.get();
|
|
4523
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
4671
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _80 => _80.knowledge]) || [];
|
|
4524
4672
|
const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
|
|
4525
4673
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4526
4674
|
messagesStore.markMine(targetMessageId);
|
|
@@ -4530,9 +4678,9 @@ function createAi(config) {
|
|
|
4530
4678
|
sourceMessage: userMessage,
|
|
4531
4679
|
targetMessageId,
|
|
4532
4680
|
generationOptions: {
|
|
4533
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4534
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4535
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4681
|
+
copilotId: _optionalChain([options, 'optionalAccess', _81 => _81.copilotId]),
|
|
4682
|
+
stream: _optionalChain([options, 'optionalAccess', _82 => _82.stream]),
|
|
4683
|
+
timeout: _optionalChain([options, 'optionalAccess', _83 => _83.timeout]),
|
|
4536
4684
|
// Combine global knowledge with request-specific knowledge
|
|
4537
4685
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
4538
4686
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -4568,7 +4716,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
|
|
|
4568
4716
|
}
|
|
4569
4717
|
const url2 = new URL(baseUrl);
|
|
4570
4718
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
4571
|
-
url2.pathname = "/ai/
|
|
4719
|
+
url2.pathname = "/ai/v5";
|
|
4572
4720
|
if (authValue.type === "secret") {
|
|
4573
4721
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
4574
4722
|
} else if (authValue.type === "public") {
|
|
@@ -4632,7 +4780,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4632
4780
|
return void 0;
|
|
4633
4781
|
}
|
|
4634
4782
|
async function makeAuthRequest(options) {
|
|
4635
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
4783
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _84 => _84.polyfills, 'optionalAccess', _85 => _85.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
4636
4784
|
if (authentication.type === "private") {
|
|
4637
4785
|
if (fetcher === void 0) {
|
|
4638
4786
|
throw new StopRetrying(
|
|
@@ -4648,7 +4796,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4648
4796
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
4649
4797
|
);
|
|
4650
4798
|
}
|
|
4651
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4799
|
+
_optionalChain([onAuthenticate, 'optionalCall', _86 => _86(parsed.parsed)]);
|
|
4652
4800
|
return parsed;
|
|
4653
4801
|
}
|
|
4654
4802
|
if (authentication.type === "custom") {
|
|
@@ -4656,7 +4804,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4656
4804
|
if (response && typeof response === "object") {
|
|
4657
4805
|
if (typeof response.token === "string") {
|
|
4658
4806
|
const parsed = parseAuthToken(response.token);
|
|
4659
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4807
|
+
_optionalChain([onAuthenticate, 'optionalCall', _87 => _87(parsed.parsed)]);
|
|
4660
4808
|
return parsed;
|
|
4661
4809
|
} else if (typeof response.error === "string") {
|
|
4662
4810
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -4814,7 +4962,7 @@ function sendToPanel(message, options) {
|
|
|
4814
4962
|
...message,
|
|
4815
4963
|
source: "liveblocks-devtools-client"
|
|
4816
4964
|
};
|
|
4817
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
4965
|
+
if (!(_optionalChain([options, 'optionalAccess', _88 => _88.force]) || _bridgeActive)) {
|
|
4818
4966
|
return;
|
|
4819
4967
|
}
|
|
4820
4968
|
window.postMessage(fullMsg, "*");
|
|
@@ -4822,7 +4970,7 @@ function sendToPanel(message, options) {
|
|
|
4822
4970
|
var eventSource = makeEventSource();
|
|
4823
4971
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
4824
4972
|
window.addEventListener("message", (event) => {
|
|
4825
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
4973
|
+
if (event.source === window && _optionalChain([event, 'access', _89 => _89.data, 'optionalAccess', _90 => _90.source]) === "liveblocks-devtools-panel") {
|
|
4826
4974
|
eventSource.notify(event.data);
|
|
4827
4975
|
} else {
|
|
4828
4976
|
}
|
|
@@ -4964,7 +5112,7 @@ function fullSync(room) {
|
|
|
4964
5112
|
msg: "room::sync::full",
|
|
4965
5113
|
roomId: room.id,
|
|
4966
5114
|
status: room.getStatus(),
|
|
4967
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
5115
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _91 => _91.toTreeNode, 'call', _92 => _92("root"), 'access', _93 => _93.payload]), () => ( null)),
|
|
4968
5116
|
me,
|
|
4969
5117
|
others
|
|
4970
5118
|
});
|
|
@@ -5255,7 +5403,7 @@ function createManagedPool(roomId, options) {
|
|
|
5255
5403
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
5256
5404
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
5257
5405
|
dispatch(ops, reverse, storageUpdates) {
|
|
5258
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
5406
|
+
_optionalChain([onDispatch, 'optionalCall', _94 => _94(ops, reverse, storageUpdates)]);
|
|
5259
5407
|
},
|
|
5260
5408
|
assertStorageIsWritable: () => {
|
|
5261
5409
|
if (!isStorageWritable()) {
|
|
@@ -5482,7 +5630,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
5482
5630
|
return [
|
|
5483
5631
|
{
|
|
5484
5632
|
type: 8 /* CREATE_REGISTER */,
|
|
5485
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5633
|
+
opId: _optionalChain([pool, 'optionalAccess', _95 => _95.generateOpId, 'call', _96 => _96()]),
|
|
5486
5634
|
id: this._id,
|
|
5487
5635
|
parentId,
|
|
5488
5636
|
parentKey,
|
|
@@ -5588,7 +5736,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5588
5736
|
const ops = [];
|
|
5589
5737
|
const op = {
|
|
5590
5738
|
id: this._id,
|
|
5591
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5739
|
+
opId: _optionalChain([pool, 'optionalAccess', _97 => _97.generateOpId, 'call', _98 => _98()]),
|
|
5592
5740
|
type: 2 /* CREATE_LIST */,
|
|
5593
5741
|
parentId,
|
|
5594
5742
|
parentKey
|
|
@@ -5859,7 +6007,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5859
6007
|
#applyInsertUndoRedo(op) {
|
|
5860
6008
|
const { id, parentKey: key } = op;
|
|
5861
6009
|
const child = creationOpToLiveNode(op);
|
|
5862
|
-
if (_optionalChain([this, 'access',
|
|
6010
|
+
if (_optionalChain([this, 'access', _99 => _99._pool, 'optionalAccess', _100 => _100.getNode, 'call', _101 => _101(id)]) !== void 0) {
|
|
5863
6011
|
return { modified: false };
|
|
5864
6012
|
}
|
|
5865
6013
|
child._attach(id, nn(this._pool));
|
|
@@ -5867,8 +6015,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5867
6015
|
const existingItemIndex = this._indexOfPosition(key);
|
|
5868
6016
|
let newKey = key;
|
|
5869
6017
|
if (existingItemIndex !== -1) {
|
|
5870
|
-
const before2 = _optionalChain([this, 'access',
|
|
5871
|
-
const after2 = _optionalChain([this, 'access',
|
|
6018
|
+
const before2 = _optionalChain([this, 'access', _102 => _102.#items, 'access', _103 => _103[existingItemIndex], 'optionalAccess', _104 => _104._parentPos]);
|
|
6019
|
+
const after2 = _optionalChain([this, 'access', _105 => _105.#items, 'access', _106 => _106[existingItemIndex + 1], 'optionalAccess', _107 => _107._parentPos]);
|
|
5872
6020
|
newKey = makePosition(before2, after2);
|
|
5873
6021
|
child._setParentLink(this, newKey);
|
|
5874
6022
|
}
|
|
@@ -5882,7 +6030,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5882
6030
|
#applySetUndoRedo(op) {
|
|
5883
6031
|
const { id, parentKey: key } = op;
|
|
5884
6032
|
const child = creationOpToLiveNode(op);
|
|
5885
|
-
if (_optionalChain([this, 'access',
|
|
6033
|
+
if (_optionalChain([this, 'access', _108 => _108._pool, 'optionalAccess', _109 => _109.getNode, 'call', _110 => _110(id)]) !== void 0) {
|
|
5886
6034
|
return { modified: false };
|
|
5887
6035
|
}
|
|
5888
6036
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -6003,7 +6151,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6003
6151
|
} else {
|
|
6004
6152
|
this.#items[existingItemIndex]._setParentLink(
|
|
6005
6153
|
this,
|
|
6006
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6154
|
+
makePosition(newKey, _optionalChain([this, 'access', _111 => _111.#items, 'access', _112 => _112[existingItemIndex + 1], 'optionalAccess', _113 => _113._parentPos]))
|
|
6007
6155
|
);
|
|
6008
6156
|
const previousIndex = this.#items.indexOf(child);
|
|
6009
6157
|
child._setParentLink(this, newKey);
|
|
@@ -6028,7 +6176,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6028
6176
|
if (existingItemIndex !== -1) {
|
|
6029
6177
|
this.#items[existingItemIndex]._setParentLink(
|
|
6030
6178
|
this,
|
|
6031
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6179
|
+
makePosition(newKey, _optionalChain([this, 'access', _114 => _114.#items, 'access', _115 => _115[existingItemIndex + 1], 'optionalAccess', _116 => _116._parentPos]))
|
|
6032
6180
|
);
|
|
6033
6181
|
}
|
|
6034
6182
|
child._setParentLink(this, newKey);
|
|
@@ -6047,7 +6195,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6047
6195
|
if (existingItemIndex !== -1) {
|
|
6048
6196
|
this.#items[existingItemIndex]._setParentLink(
|
|
6049
6197
|
this,
|
|
6050
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6198
|
+
makePosition(newKey, _optionalChain([this, 'access', _117 => _117.#items, 'access', _118 => _118[existingItemIndex + 1], 'optionalAccess', _119 => _119._parentPos]))
|
|
6051
6199
|
);
|
|
6052
6200
|
}
|
|
6053
6201
|
child._setParentLink(this, newKey);
|
|
@@ -6074,7 +6222,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6074
6222
|
if (existingItemIndex !== -1) {
|
|
6075
6223
|
this.#items[existingItemIndex]._setParentLink(
|
|
6076
6224
|
this,
|
|
6077
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6225
|
+
makePosition(newKey, _optionalChain([this, 'access', _120 => _120.#items, 'access', _121 => _121[existingItemIndex + 1], 'optionalAccess', _122 => _122._parentPos]))
|
|
6078
6226
|
);
|
|
6079
6227
|
}
|
|
6080
6228
|
child._setParentLink(this, newKey);
|
|
@@ -6132,7 +6280,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6132
6280
|
* @param element The element to add to the end of the LiveList.
|
|
6133
6281
|
*/
|
|
6134
6282
|
push(element) {
|
|
6135
|
-
_optionalChain([this, 'access',
|
|
6283
|
+
_optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.assertStorageIsWritable, 'call', _125 => _125()]);
|
|
6136
6284
|
return this.insert(element, this.length);
|
|
6137
6285
|
}
|
|
6138
6286
|
/**
|
|
@@ -6141,7 +6289,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6141
6289
|
* @param index The index at which you want to insert the element.
|
|
6142
6290
|
*/
|
|
6143
6291
|
insert(element, index) {
|
|
6144
|
-
_optionalChain([this, 'access',
|
|
6292
|
+
_optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
|
|
6145
6293
|
if (index < 0 || index > this.#items.length) {
|
|
6146
6294
|
throw new Error(
|
|
6147
6295
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -6171,7 +6319,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6171
6319
|
* @param targetIndex The index where the element should be after moving.
|
|
6172
6320
|
*/
|
|
6173
6321
|
move(index, targetIndex) {
|
|
6174
|
-
_optionalChain([this, 'access',
|
|
6322
|
+
_optionalChain([this, 'access', _129 => _129._pool, 'optionalAccess', _130 => _130.assertStorageIsWritable, 'call', _131 => _131()]);
|
|
6175
6323
|
if (targetIndex < 0) {
|
|
6176
6324
|
throw new Error("targetIndex cannot be less than 0");
|
|
6177
6325
|
}
|
|
@@ -6229,7 +6377,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6229
6377
|
* @param index The index of the element to delete
|
|
6230
6378
|
*/
|
|
6231
6379
|
delete(index) {
|
|
6232
|
-
_optionalChain([this, 'access',
|
|
6380
|
+
_optionalChain([this, 'access', _132 => _132._pool, 'optionalAccess', _133 => _133.assertStorageIsWritable, 'call', _134 => _134()]);
|
|
6233
6381
|
if (index < 0 || index >= this.#items.length) {
|
|
6234
6382
|
throw new Error(
|
|
6235
6383
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6262,7 +6410,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6262
6410
|
}
|
|
6263
6411
|
}
|
|
6264
6412
|
clear() {
|
|
6265
|
-
_optionalChain([this, 'access',
|
|
6413
|
+
_optionalChain([this, 'access', _135 => _135._pool, 'optionalAccess', _136 => _136.assertStorageIsWritable, 'call', _137 => _137()]);
|
|
6266
6414
|
if (this._pool) {
|
|
6267
6415
|
const ops = [];
|
|
6268
6416
|
const reverseOps = [];
|
|
@@ -6296,7 +6444,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6296
6444
|
}
|
|
6297
6445
|
}
|
|
6298
6446
|
set(index, item) {
|
|
6299
|
-
_optionalChain([this, 'access',
|
|
6447
|
+
_optionalChain([this, 'access', _138 => _138._pool, 'optionalAccess', _139 => _139.assertStorageIsWritable, 'call', _140 => _140()]);
|
|
6300
6448
|
if (index < 0 || index >= this.#items.length) {
|
|
6301
6449
|
throw new Error(
|
|
6302
6450
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6442,7 +6590,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6442
6590
|
#shiftItemPosition(index, key) {
|
|
6443
6591
|
const shiftedPosition = makePosition(
|
|
6444
6592
|
key,
|
|
6445
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
6593
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _141 => _141.#items, 'access', _142 => _142[index + 1], 'optionalAccess', _143 => _143._parentPos]) : void 0
|
|
6446
6594
|
);
|
|
6447
6595
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
6448
6596
|
}
|
|
@@ -6567,7 +6715,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6567
6715
|
const ops = [];
|
|
6568
6716
|
const op = {
|
|
6569
6717
|
id: this._id,
|
|
6570
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6718
|
+
opId: _optionalChain([pool, 'optionalAccess', _144 => _144.generateOpId, 'call', _145 => _145()]),
|
|
6571
6719
|
type: 7 /* CREATE_MAP */,
|
|
6572
6720
|
parentId,
|
|
6573
6721
|
parentKey
|
|
@@ -6702,7 +6850,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6702
6850
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
6703
6851
|
*/
|
|
6704
6852
|
set(key, value) {
|
|
6705
|
-
_optionalChain([this, 'access',
|
|
6853
|
+
_optionalChain([this, 'access', _146 => _146._pool, 'optionalAccess', _147 => _147.assertStorageIsWritable, 'call', _148 => _148()]);
|
|
6706
6854
|
const oldValue = this.#map.get(key);
|
|
6707
6855
|
if (oldValue) {
|
|
6708
6856
|
oldValue._detach();
|
|
@@ -6748,7 +6896,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6748
6896
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
6749
6897
|
*/
|
|
6750
6898
|
delete(key) {
|
|
6751
|
-
_optionalChain([this, 'access',
|
|
6899
|
+
_optionalChain([this, 'access', _149 => _149._pool, 'optionalAccess', _150 => _150.assertStorageIsWritable, 'call', _151 => _151()]);
|
|
6752
6900
|
const item = this.#map.get(key);
|
|
6753
6901
|
if (item === void 0) {
|
|
6754
6902
|
return false;
|
|
@@ -6938,7 +7086,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
6938
7086
|
if (this._id === void 0) {
|
|
6939
7087
|
throw new Error("Cannot serialize item is not attached");
|
|
6940
7088
|
}
|
|
6941
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
7089
|
+
const opId = _optionalChain([pool, 'optionalAccess', _152 => _152.generateOpId, 'call', _153 => _153()]);
|
|
6942
7090
|
const ops = [];
|
|
6943
7091
|
const op = {
|
|
6944
7092
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -7210,7 +7358,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7210
7358
|
* @param value The value of the property to add
|
|
7211
7359
|
*/
|
|
7212
7360
|
set(key, value) {
|
|
7213
|
-
_optionalChain([this, 'access',
|
|
7361
|
+
_optionalChain([this, 'access', _154 => _154._pool, 'optionalAccess', _155 => _155.assertStorageIsWritable, 'call', _156 => _156()]);
|
|
7214
7362
|
this.update({ [key]: value });
|
|
7215
7363
|
}
|
|
7216
7364
|
/**
|
|
@@ -7225,7 +7373,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7225
7373
|
* @param key The key of the property to delete
|
|
7226
7374
|
*/
|
|
7227
7375
|
delete(key) {
|
|
7228
|
-
_optionalChain([this, 'access',
|
|
7376
|
+
_optionalChain([this, 'access', _157 => _157._pool, 'optionalAccess', _158 => _158.assertStorageIsWritable, 'call', _159 => _159()]);
|
|
7229
7377
|
const keyAsString = key;
|
|
7230
7378
|
const oldValue = this.#map.get(keyAsString);
|
|
7231
7379
|
if (oldValue === void 0) {
|
|
@@ -7278,7 +7426,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7278
7426
|
* @param patch The object used to overrides properties
|
|
7279
7427
|
*/
|
|
7280
7428
|
update(patch) {
|
|
7281
|
-
_optionalChain([this, 'access',
|
|
7429
|
+
_optionalChain([this, 'access', _160 => _160._pool, 'optionalAccess', _161 => _161.assertStorageIsWritable, 'call', _162 => _162()]);
|
|
7282
7430
|
if (_LiveObject.detectLargeObjects) {
|
|
7283
7431
|
const data = {};
|
|
7284
7432
|
for (const [key, value] of this.#map) {
|
|
@@ -8026,15 +8174,15 @@ function installBackgroundTabSpy() {
|
|
|
8026
8174
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8027
8175
|
const inBackgroundSince = { current: null };
|
|
8028
8176
|
function onVisibilityChange() {
|
|
8029
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
8177
|
+
if (_optionalChain([doc, 'optionalAccess', _163 => _163.visibilityState]) === "hidden") {
|
|
8030
8178
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
8031
8179
|
} else {
|
|
8032
8180
|
inBackgroundSince.current = null;
|
|
8033
8181
|
}
|
|
8034
8182
|
}
|
|
8035
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8183
|
+
_optionalChain([doc, 'optionalAccess', _164 => _164.addEventListener, 'call', _165 => _165("visibilitychange", onVisibilityChange)]);
|
|
8036
8184
|
const unsub = () => {
|
|
8037
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8185
|
+
_optionalChain([doc, 'optionalAccess', _166 => _166.removeEventListener, 'call', _167 => _167("visibilitychange", onVisibilityChange)]);
|
|
8038
8186
|
};
|
|
8039
8187
|
return [inBackgroundSince, unsub];
|
|
8040
8188
|
}
|
|
@@ -8214,7 +8362,7 @@ function createRoom(options, config) {
|
|
|
8214
8362
|
}
|
|
8215
8363
|
}
|
|
8216
8364
|
function isStorageWritable() {
|
|
8217
|
-
const scopes = _optionalChain([context, 'access',
|
|
8365
|
+
const scopes = _optionalChain([context, 'access', _168 => _168.dynamicSessionInfoSig, 'access', _169 => _169.get, 'call', _170 => _170(), 'optionalAccess', _171 => _171.scopes]);
|
|
8218
8366
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
8219
8367
|
}
|
|
8220
8368
|
const eventHub = {
|
|
@@ -8340,7 +8488,7 @@ function createRoom(options, config) {
|
|
|
8340
8488
|
}
|
|
8341
8489
|
case "experimental-fallback-to-http": {
|
|
8342
8490
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8343
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
8491
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _172 => _172.dynamicSessionInfoSig, 'access', _173 => _173.get, 'call', _174 => _174(), 'optionalAccess', _175 => _175.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
8344
8492
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
8345
8493
|
if (!resp.ok && resp.status === 403) {
|
|
8346
8494
|
managedSocket.reconnect();
|
|
@@ -8391,7 +8539,7 @@ function createRoom(options, config) {
|
|
|
8391
8539
|
} else {
|
|
8392
8540
|
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
8393
8541
|
}
|
|
8394
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
8542
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _176 => _176.get, 'call', _177 => _177(), 'optionalAccess', _178 => _178.canWrite]), () => ( true));
|
|
8395
8543
|
const stackSizeBefore = context.undoStack.length;
|
|
8396
8544
|
for (const key in context.initialStorage) {
|
|
8397
8545
|
if (context.root.get(key) === void 0) {
|
|
@@ -8594,7 +8742,7 @@ function createRoom(options, config) {
|
|
|
8594
8742
|
}
|
|
8595
8743
|
context.myPresence.patch(patch);
|
|
8596
8744
|
if (context.activeBatch) {
|
|
8597
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8745
|
+
if (_optionalChain([options2, 'optionalAccess', _179 => _179.addToHistory])) {
|
|
8598
8746
|
context.activeBatch.reverseOps.pushLeft({
|
|
8599
8747
|
type: "presence",
|
|
8600
8748
|
data: oldValues
|
|
@@ -8603,7 +8751,7 @@ function createRoom(options, config) {
|
|
|
8603
8751
|
context.activeBatch.updates.presence = true;
|
|
8604
8752
|
} else {
|
|
8605
8753
|
flushNowOrSoon();
|
|
8606
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8754
|
+
if (_optionalChain([options2, 'optionalAccess', _180 => _180.addToHistory])) {
|
|
8607
8755
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
8608
8756
|
}
|
|
8609
8757
|
notify({ presence: true });
|
|
@@ -8800,7 +8948,7 @@ function createRoom(options, config) {
|
|
|
8800
8948
|
if (process.env.NODE_ENV !== "production") {
|
|
8801
8949
|
const traces = /* @__PURE__ */ new Set();
|
|
8802
8950
|
for (const opId of message.opIds) {
|
|
8803
|
-
const trace = _optionalChain([context, 'access',
|
|
8951
|
+
const trace = _optionalChain([context, 'access', _181 => _181.opStackTraces, 'optionalAccess', _182 => _182.get, 'call', _183 => _183(opId)]);
|
|
8804
8952
|
if (trace) {
|
|
8805
8953
|
traces.add(trace);
|
|
8806
8954
|
}
|
|
@@ -8934,7 +9082,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
8934
9082
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
8935
9083
|
createOrUpdateRootFromMessage(message);
|
|
8936
9084
|
applyAndSendOps(unacknowledgedOps);
|
|
8937
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
9085
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _184 => _184()]);
|
|
8938
9086
|
notifyStorageStatus();
|
|
8939
9087
|
eventHub.storageDidLoad.notify();
|
|
8940
9088
|
}
|
|
@@ -9155,8 +9303,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9155
9303
|
async function getThreads(options2) {
|
|
9156
9304
|
return httpClient.getThreads({
|
|
9157
9305
|
roomId,
|
|
9158
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
9159
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9306
|
+
query: _optionalChain([options2, 'optionalAccess', _185 => _185.query]),
|
|
9307
|
+
cursor: _optionalChain([options2, 'optionalAccess', _186 => _186.cursor])
|
|
9160
9308
|
});
|
|
9161
9309
|
}
|
|
9162
9310
|
async function getThread(threadId) {
|
|
@@ -9263,7 +9411,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9263
9411
|
function getSubscriptionSettings(options2) {
|
|
9264
9412
|
return httpClient.getSubscriptionSettings({
|
|
9265
9413
|
roomId,
|
|
9266
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9414
|
+
signal: _optionalChain([options2, 'optionalAccess', _187 => _187.signal])
|
|
9267
9415
|
});
|
|
9268
9416
|
}
|
|
9269
9417
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9285,7 +9433,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9285
9433
|
{
|
|
9286
9434
|
[kInternal]: {
|
|
9287
9435
|
get presenceBuffer() {
|
|
9288
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9436
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _188 => _188.buffer, 'access', _189 => _189.presenceUpdates, 'optionalAccess', _190 => _190.data]), () => ( null)));
|
|
9289
9437
|
},
|
|
9290
9438
|
// prettier-ignore
|
|
9291
9439
|
get undoStack() {
|
|
@@ -9300,9 +9448,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9300
9448
|
return context.yjsProvider;
|
|
9301
9449
|
},
|
|
9302
9450
|
setYjsProvider(newProvider) {
|
|
9303
|
-
_optionalChain([context, 'access',
|
|
9451
|
+
_optionalChain([context, 'access', _191 => _191.yjsProvider, 'optionalAccess', _192 => _192.off, 'call', _193 => _193("status", yjsStatusDidChange)]);
|
|
9304
9452
|
context.yjsProvider = newProvider;
|
|
9305
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9453
|
+
_optionalChain([newProvider, 'optionalAccess', _194 => _194.on, 'call', _195 => _195("status", yjsStatusDidChange)]);
|
|
9306
9454
|
context.yjsProviderDidChange.notify();
|
|
9307
9455
|
},
|
|
9308
9456
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9348,7 +9496,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9348
9496
|
source.dispose();
|
|
9349
9497
|
}
|
|
9350
9498
|
eventHub.roomWillDestroy.notify();
|
|
9351
|
-
_optionalChain([context, 'access',
|
|
9499
|
+
_optionalChain([context, 'access', _196 => _196.yjsProvider, 'optionalAccess', _197 => _197.off, 'call', _198 => _198("status", yjsStatusDidChange)]);
|
|
9352
9500
|
syncSourceForStorage.destroy();
|
|
9353
9501
|
syncSourceForYjs.destroy();
|
|
9354
9502
|
uninstallBgTabSpy();
|
|
@@ -9498,7 +9646,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9498
9646
|
}
|
|
9499
9647
|
if (isLiveNode(first)) {
|
|
9500
9648
|
const node = first;
|
|
9501
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9649
|
+
if (_optionalChain([options, 'optionalAccess', _199 => _199.isDeep])) {
|
|
9502
9650
|
const storageCallback = second;
|
|
9503
9651
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9504
9652
|
} else {
|
|
@@ -9577,8 +9725,8 @@ function createClient(options) {
|
|
|
9577
9725
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
9578
9726
|
currentUserId.set(() => userId);
|
|
9579
9727
|
});
|
|
9580
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
9581
|
-
_optionalChain([globalThis, 'access',
|
|
9728
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _200 => _200.polyfills, 'optionalAccess', _201 => _201.fetch]) || /* istanbul ignore next */
|
|
9729
|
+
_optionalChain([globalThis, 'access', _202 => _202.fetch, 'optionalAccess', _203 => _203.bind, 'call', _204 => _204(globalThis)]);
|
|
9582
9730
|
const httpClient = createApiClient({
|
|
9583
9731
|
baseUrl,
|
|
9584
9732
|
fetchPolyfill,
|
|
@@ -9596,7 +9744,7 @@ function createClient(options) {
|
|
|
9596
9744
|
delegates: {
|
|
9597
9745
|
createSocket: makeCreateSocketDelegateForAi(
|
|
9598
9746
|
baseUrl,
|
|
9599
|
-
_optionalChain([clientOptions, 'access',
|
|
9747
|
+
_optionalChain([clientOptions, 'access', _205 => _205.polyfills, 'optionalAccess', _206 => _206.WebSocket])
|
|
9600
9748
|
),
|
|
9601
9749
|
authenticate: async () => {
|
|
9602
9750
|
const resp = await authManager.getAuthValue({
|
|
@@ -9664,7 +9812,7 @@ function createClient(options) {
|
|
|
9664
9812
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
9665
9813
|
roomId,
|
|
9666
9814
|
baseUrl,
|
|
9667
|
-
_optionalChain([clientOptions, 'access',
|
|
9815
|
+
_optionalChain([clientOptions, 'access', _207 => _207.polyfills, 'optionalAccess', _208 => _208.WebSocket])
|
|
9668
9816
|
),
|
|
9669
9817
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
9670
9818
|
})),
|
|
@@ -9687,7 +9835,7 @@ function createClient(options) {
|
|
|
9687
9835
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
9688
9836
|
if (shouldConnect) {
|
|
9689
9837
|
if (typeof atob === "undefined") {
|
|
9690
|
-
if (_optionalChain([clientOptions, 'access',
|
|
9838
|
+
if (_optionalChain([clientOptions, 'access', _209 => _209.polyfills, 'optionalAccess', _210 => _210.atob]) === void 0) {
|
|
9691
9839
|
throw new Error(
|
|
9692
9840
|
"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"
|
|
9693
9841
|
);
|
|
@@ -9699,7 +9847,7 @@ function createClient(options) {
|
|
|
9699
9847
|
return leaseRoom(newRoomDetails);
|
|
9700
9848
|
}
|
|
9701
9849
|
function getRoom(roomId) {
|
|
9702
|
-
const room = _optionalChain([roomsById, 'access',
|
|
9850
|
+
const room = _optionalChain([roomsById, 'access', _211 => _211.get, 'call', _212 => _212(roomId), 'optionalAccess', _213 => _213.room]);
|
|
9703
9851
|
return room ? room : null;
|
|
9704
9852
|
}
|
|
9705
9853
|
function logout() {
|
|
@@ -9719,7 +9867,7 @@ function createClient(options) {
|
|
|
9719
9867
|
const batchedResolveUsers = new Batch(
|
|
9720
9868
|
async (batchedUserIds) => {
|
|
9721
9869
|
const userIds = batchedUserIds.flat();
|
|
9722
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
9870
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _214 => _214({ userIds })]);
|
|
9723
9871
|
warnIfNoResolveUsers();
|
|
9724
9872
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
9725
9873
|
},
|
|
@@ -9737,7 +9885,7 @@ function createClient(options) {
|
|
|
9737
9885
|
const batchedResolveRoomsInfo = new Batch(
|
|
9738
9886
|
async (batchedRoomIds) => {
|
|
9739
9887
|
const roomIds = batchedRoomIds.flat();
|
|
9740
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
9888
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _215 => _215({ roomIds })]);
|
|
9741
9889
|
warnIfNoResolveRoomsInfo();
|
|
9742
9890
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
9743
9891
|
},
|
|
@@ -9790,7 +9938,7 @@ function createClient(options) {
|
|
|
9790
9938
|
}
|
|
9791
9939
|
};
|
|
9792
9940
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
9793
|
-
_optionalChain([win, 'optionalAccess',
|
|
9941
|
+
_optionalChain([win, 'optionalAccess', _216 => _216.addEventListener, 'call', _217 => _217("beforeunload", maybePreventClose)]);
|
|
9794
9942
|
}
|
|
9795
9943
|
async function getNotificationSettings(options2) {
|
|
9796
9944
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -9929,7 +10077,7 @@ var commentBodyElementsTypes = {
|
|
|
9929
10077
|
mention: "inline"
|
|
9930
10078
|
};
|
|
9931
10079
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
9932
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
10080
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _218 => _218.content])) {
|
|
9933
10081
|
return;
|
|
9934
10082
|
}
|
|
9935
10083
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -9939,13 +10087,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
9939
10087
|
for (const block of body.content) {
|
|
9940
10088
|
if (type === "all" || type === "block") {
|
|
9941
10089
|
if (guard(block)) {
|
|
9942
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10090
|
+
_optionalChain([visitor, 'optionalCall', _219 => _219(block)]);
|
|
9943
10091
|
}
|
|
9944
10092
|
}
|
|
9945
10093
|
if (type === "all" || type === "inline") {
|
|
9946
10094
|
for (const inline of block.children) {
|
|
9947
10095
|
if (guard(inline)) {
|
|
9948
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10096
|
+
_optionalChain([visitor, 'optionalCall', _220 => _220(inline)]);
|
|
9949
10097
|
}
|
|
9950
10098
|
}
|
|
9951
10099
|
}
|
|
@@ -9979,7 +10127,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
9979
10127
|
userIds
|
|
9980
10128
|
});
|
|
9981
10129
|
for (const [index, userId] of userIds.entries()) {
|
|
9982
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
10130
|
+
const user = _optionalChain([users, 'optionalAccess', _221 => _221[index]]);
|
|
9983
10131
|
if (user) {
|
|
9984
10132
|
resolvedUsers.set(userId, user);
|
|
9985
10133
|
}
|
|
@@ -10098,7 +10246,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
10098
10246
|
text: ({ element }) => element.text,
|
|
10099
10247
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
10100
10248
|
mention: ({ element, user }) => {
|
|
10101
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10249
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _222 => _222.name]), () => ( element.id))}`;
|
|
10102
10250
|
}
|
|
10103
10251
|
};
|
|
10104
10252
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -10128,7 +10276,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
10128
10276
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
10129
10277
|
},
|
|
10130
10278
|
mention: ({ element, user }) => {
|
|
10131
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
10279
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _223 => _223.name]) ? html`${_optionalChain([user, 'optionalAccess', _224 => _224.name])}` : element.id}</span>`;
|
|
10132
10280
|
}
|
|
10133
10281
|
};
|
|
10134
10282
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -10158,19 +10306,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
10158
10306
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
10159
10307
|
},
|
|
10160
10308
|
mention: ({ element, user }) => {
|
|
10161
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10309
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _225 => _225.name]), () => ( element.id))}`;
|
|
10162
10310
|
}
|
|
10163
10311
|
};
|
|
10164
10312
|
async function stringifyCommentBody(body, options) {
|
|
10165
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10166
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10313
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _226 => _226.format]), () => ( "plain"));
|
|
10314
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _227 => _227.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
10167
10315
|
const elements = {
|
|
10168
10316
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
10169
|
-
..._optionalChain([options, 'optionalAccess',
|
|
10317
|
+
..._optionalChain([options, 'optionalAccess', _228 => _228.elements])
|
|
10170
10318
|
};
|
|
10171
10319
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
10172
10320
|
body,
|
|
10173
|
-
_optionalChain([options, 'optionalAccess',
|
|
10321
|
+
_optionalChain([options, 'optionalAccess', _229 => _229.resolveUsers])
|
|
10174
10322
|
);
|
|
10175
10323
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
10176
10324
|
switch (block.type) {
|
|
@@ -10456,12 +10604,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10456
10604
|
}
|
|
10457
10605
|
const newState = Object.assign({}, state);
|
|
10458
10606
|
for (const key in update.updates) {
|
|
10459
|
-
if (_optionalChain([update, 'access',
|
|
10607
|
+
if (_optionalChain([update, 'access', _230 => _230.updates, 'access', _231 => _231[key], 'optionalAccess', _232 => _232.type]) === "update") {
|
|
10460
10608
|
const val = update.node.get(key);
|
|
10461
10609
|
if (val !== void 0) {
|
|
10462
10610
|
newState[key] = lsonToJson(val);
|
|
10463
10611
|
}
|
|
10464
|
-
} else if (_optionalChain([update, 'access',
|
|
10612
|
+
} else if (_optionalChain([update, 'access', _233 => _233.updates, 'access', _234 => _234[key], 'optionalAccess', _235 => _235.type]) === "delete") {
|
|
10465
10613
|
delete newState[key];
|
|
10466
10614
|
}
|
|
10467
10615
|
}
|
|
@@ -10522,12 +10670,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10522
10670
|
}
|
|
10523
10671
|
const newState = Object.assign({}, state);
|
|
10524
10672
|
for (const key in update.updates) {
|
|
10525
|
-
if (_optionalChain([update, 'access',
|
|
10673
|
+
if (_optionalChain([update, 'access', _236 => _236.updates, 'access', _237 => _237[key], 'optionalAccess', _238 => _238.type]) === "update") {
|
|
10526
10674
|
const value = update.node.get(key);
|
|
10527
10675
|
if (value !== void 0) {
|
|
10528
10676
|
newState[key] = lsonToJson(value);
|
|
10529
10677
|
}
|
|
10530
|
-
} else if (_optionalChain([update, 'access',
|
|
10678
|
+
} else if (_optionalChain([update, 'access', _239 => _239.updates, 'access', _240 => _240[key], 'optionalAccess', _241 => _241.type]) === "delete") {
|
|
10531
10679
|
delete newState[key];
|
|
10532
10680
|
}
|
|
10533
10681
|
}
|
|
@@ -10607,9 +10755,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10607
10755
|
const startTime = performance.now();
|
|
10608
10756
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10609
10757
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10610
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10758
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _242 => _242.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
10611
10759
|
const context = {
|
|
10612
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
10760
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _243 => _243.visibilityState]) !== "hidden",
|
|
10613
10761
|
lastSuccessfulPollAt: startTime,
|
|
10614
10762
|
count: 0,
|
|
10615
10763
|
backoff: 0
|
|
@@ -10690,11 +10838,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10690
10838
|
pollNowIfStale();
|
|
10691
10839
|
}
|
|
10692
10840
|
function onVisibilityChange() {
|
|
10693
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
10841
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _244 => _244.visibilityState]) !== "hidden");
|
|
10694
10842
|
}
|
|
10695
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10696
|
-
_optionalChain([win, 'optionalAccess',
|
|
10697
|
-
_optionalChain([win, 'optionalAccess',
|
|
10843
|
+
_optionalChain([doc, 'optionalAccess', _245 => _245.addEventListener, 'call', _246 => _246("visibilitychange", onVisibilityChange)]);
|
|
10844
|
+
_optionalChain([win, 'optionalAccess', _247 => _247.addEventListener, 'call', _248 => _248("online", onVisibilityChange)]);
|
|
10845
|
+
_optionalChain([win, 'optionalAccess', _249 => _249.addEventListener, 'call', _250 => _250("focus", pollNowIfStale)]);
|
|
10698
10846
|
fsm.start();
|
|
10699
10847
|
return {
|
|
10700
10848
|
inc,
|
|
@@ -10822,5 +10970,7 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
10822
10970
|
|
|
10823
10971
|
|
|
10824
10972
|
|
|
10825
|
-
|
|
10973
|
+
|
|
10974
|
+
|
|
10975
|
+
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.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.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.resolveUsersInCommentBody = resolveUsersInCommentBody; 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.withTimeout = withTimeout;
|
|
10826
10976
|
//# sourceMappingURL=index.cjs.map
|