@liveblocks/core 3.5.4 → 3.6.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 +170 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -4
- package/dist/index.d.ts +29 -4
- package/dist/index.js +71 -15
- 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.6.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3987,23 +3987,46 @@ var IncrementalJsonParser = class {
|
|
|
3987
3987
|
};
|
|
3988
3988
|
|
|
3989
3989
|
// src/types/ai.ts
|
|
3990
|
+
function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
3991
|
+
const existingIndex = findLastIndex(
|
|
3992
|
+
content,
|
|
3993
|
+
(item) => item.type === newItem.type && keyFn(item) === keyFn(newItem)
|
|
3994
|
+
);
|
|
3995
|
+
if (existingIndex > -1) {
|
|
3996
|
+
content[existingIndex] = newItem;
|
|
3997
|
+
} else {
|
|
3998
|
+
closePart(content[content.length - 1], now2);
|
|
3999
|
+
content.push(newItem);
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
function closePart(prevPart, endedAt) {
|
|
4003
|
+
if (_optionalChain([prevPart, 'optionalAccess', _55 => _55.type]) === "reasoning") {
|
|
4004
|
+
prevPart.endedAt ??= endedAt;
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
3990
4007
|
function patchContentWithDelta(content, delta) {
|
|
4008
|
+
if (delta === null)
|
|
4009
|
+
return;
|
|
4010
|
+
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
3991
4011
|
const lastPart = content[content.length - 1];
|
|
3992
4012
|
switch (delta.type) {
|
|
3993
4013
|
case "text-delta":
|
|
3994
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
4014
|
+
if (_optionalChain([lastPart, 'optionalAccess', _56 => _56.type]) === "text") {
|
|
3995
4015
|
lastPart.text += delta.textDelta;
|
|
3996
4016
|
} else {
|
|
4017
|
+
closePart(lastPart, now2);
|
|
3997
4018
|
content.push({ type: "text", text: delta.textDelta });
|
|
3998
4019
|
}
|
|
3999
4020
|
break;
|
|
4000
4021
|
case "reasoning-delta":
|
|
4001
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
4022
|
+
if (_optionalChain([lastPart, 'optionalAccess', _57 => _57.type]) === "reasoning") {
|
|
4002
4023
|
lastPart.text += delta.textDelta;
|
|
4003
4024
|
} else {
|
|
4025
|
+
closePart(lastPart, now2);
|
|
4004
4026
|
content.push({
|
|
4005
4027
|
type: "reasoning",
|
|
4006
|
-
text: _nullishCoalesce(delta.textDelta, () => ( ""))
|
|
4028
|
+
text: _nullishCoalesce(delta.textDelta, () => ( "")),
|
|
4029
|
+
startedAt: now2
|
|
4007
4030
|
});
|
|
4008
4031
|
}
|
|
4009
4032
|
break;
|
|
@@ -4016,23 +4039,17 @@ function patchContentWithDelta(content, delta) {
|
|
|
4016
4039
|
break;
|
|
4017
4040
|
}
|
|
4018
4041
|
case "tool-delta": {
|
|
4019
|
-
if (_optionalChain([lastPart, 'optionalAccess',
|
|
4020
|
-
_optionalChain([lastPart, 'access',
|
|
4042
|
+
if (_optionalChain([lastPart, 'optionalAccess', _58 => _58.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
4043
|
+
_optionalChain([lastPart, 'access', _59 => _59.__appendDelta, 'optionalCall', _60 => _60(delta.delta)]);
|
|
4021
4044
|
}
|
|
4022
4045
|
break;
|
|
4023
4046
|
}
|
|
4024
|
-
case "tool-invocation":
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
);
|
|
4029
|
-
if (existingIndex > -1) {
|
|
4030
|
-
content[existingIndex] = delta;
|
|
4031
|
-
} else {
|
|
4032
|
-
content.push(delta);
|
|
4033
|
-
}
|
|
4047
|
+
case "tool-invocation":
|
|
4048
|
+
replaceOrAppend(content, delta, (x) => x.invocationId, now2);
|
|
4049
|
+
break;
|
|
4050
|
+
case "retrieval":
|
|
4051
|
+
replaceOrAppend(content, delta, (x) => x.id, now2);
|
|
4034
4052
|
break;
|
|
4035
|
-
}
|
|
4036
4053
|
default:
|
|
4037
4054
|
return assertNever(delta, "Unhandled case");
|
|
4038
4055
|
}
|
|
@@ -4044,16 +4061,20 @@ function createReceivingToolInvocation(invocationId, name, partialArgsText = "")
|
|
|
4044
4061
|
stage: "receiving",
|
|
4045
4062
|
invocationId,
|
|
4046
4063
|
name,
|
|
4064
|
+
// --- Alternative implementation for FRONTEND only ------------------------
|
|
4047
4065
|
get partialArgsText() {
|
|
4048
4066
|
return parser.source;
|
|
4049
4067
|
},
|
|
4068
|
+
// prettier-ignore
|
|
4050
4069
|
get partialArgs() {
|
|
4051
4070
|
return parser.json;
|
|
4052
4071
|
},
|
|
4053
|
-
//
|
|
4072
|
+
// prettier-ignore
|
|
4054
4073
|
__appendDelta(delta) {
|
|
4055
4074
|
parser.append(delta);
|
|
4056
4075
|
}
|
|
4076
|
+
// prettier-ignore
|
|
4077
|
+
// ------------------------------------------------------------------------
|
|
4057
4078
|
};
|
|
4058
4079
|
}
|
|
4059
4080
|
|
|
@@ -4138,7 +4159,7 @@ function createStore_forTools() {
|
|
|
4138
4159
|
return DerivedSignal.from(() => {
|
|
4139
4160
|
return (
|
|
4140
4161
|
// A tool that's registered and scoped to a specific chat ID...
|
|
4141
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4162
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _61 => _61.get, 'call', _62 => _62()]), () => ( // ...or a globally registered tool
|
|
4142
4163
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4143
4164
|
);
|
|
4144
4165
|
});
|
|
@@ -4168,8 +4189,8 @@ function createStore_forTools() {
|
|
|
4168
4189
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4169
4190
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4170
4191
|
return Array.from([
|
|
4171
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4172
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4192
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _63 => _63.entries, 'call', _64 => _64()]), () => ( [])),
|
|
4193
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _65 => _65.entries, 'call', _66 => _66()]), () => ( []))
|
|
4173
4194
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4174
4195
|
const tool = tool\u03A3.get();
|
|
4175
4196
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4272,7 +4293,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4272
4293
|
} else {
|
|
4273
4294
|
continue;
|
|
4274
4295
|
}
|
|
4275
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4296
|
+
const executeFn = _optionalChain([toolsStore, 'access', _67 => _67.getTool\u03A3, 'call', _68 => _68(toolInvocation.name, message.chatId), 'access', _69 => _69.get, 'call', _70 => _70(), 'optionalAccess', _71 => _71.execute]);
|
|
4276
4297
|
if (executeFn) {
|
|
4277
4298
|
(async () => {
|
|
4278
4299
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4371,8 +4392,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4371
4392
|
const spine = [];
|
|
4372
4393
|
let lastVisitedMessage = null;
|
|
4373
4394
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4374
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4375
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4395
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _72 => _72(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _73 => _73.id]), () => ( null));
|
|
4396
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _74 => _74(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _75 => _75.id]), () => ( null));
|
|
4376
4397
|
if (!message2.deletedAt || prev || next) {
|
|
4377
4398
|
const node = {
|
|
4378
4399
|
...message2,
|
|
@@ -4438,7 +4459,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4438
4459
|
const latest = pool.sorted.findRight(
|
|
4439
4460
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4440
4461
|
);
|
|
4441
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4462
|
+
return _optionalChain([latest, 'optionalAccess', _76 => _76.copilotId]);
|
|
4442
4463
|
}
|
|
4443
4464
|
return {
|
|
4444
4465
|
// Readers
|
|
@@ -4455,6 +4476,33 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4455
4476
|
failAllPending,
|
|
4456
4477
|
markMine(messageId) {
|
|
4457
4478
|
myMessages.add(messageId);
|
|
4479
|
+
},
|
|
4480
|
+
/**
|
|
4481
|
+
* Iterates over all my auto-executing messages.
|
|
4482
|
+
*
|
|
4483
|
+
* These are messages that match all these conditions:
|
|
4484
|
+
* - The message is an assistant message
|
|
4485
|
+
* - The message is owned by this client ("mine")
|
|
4486
|
+
* - The message is currently in "awaiting-tool" status
|
|
4487
|
+
* - The message has at least one tool invocation in "executing" stage
|
|
4488
|
+
* - The tool invocation has an execute() function defined
|
|
4489
|
+
*/
|
|
4490
|
+
*getAutoExecutingMessageIds() {
|
|
4491
|
+
for (const messageId of myMessages) {
|
|
4492
|
+
const message = getMessageById(messageId);
|
|
4493
|
+
if (_optionalChain([message, 'optionalAccess', _77 => _77.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
4494
|
+
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
4495
|
+
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
4496
|
+
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
4497
|
+
return typeof _optionalChain([tool, 'optionalAccess', _78 => _78.execute]) === "function";
|
|
4498
|
+
}
|
|
4499
|
+
return false;
|
|
4500
|
+
});
|
|
4501
|
+
if (isAutoExecuting) {
|
|
4502
|
+
yield message.id;
|
|
4503
|
+
}
|
|
4504
|
+
}
|
|
4505
|
+
}
|
|
4458
4506
|
}
|
|
4459
4507
|
};
|
|
4460
4508
|
}
|
|
@@ -4591,7 +4639,7 @@ function createAi(config) {
|
|
|
4591
4639
|
flushPendingDeltas();
|
|
4592
4640
|
switch (msg.event) {
|
|
4593
4641
|
case "cmd-failed":
|
|
4594
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4642
|
+
_optionalChain([pendingCmd, 'optionalAccess', _79 => _79.reject, 'call', _80 => _80(new Error(msg.error))]);
|
|
4595
4643
|
break;
|
|
4596
4644
|
case "settle": {
|
|
4597
4645
|
context.messagesStore.upsert(msg.message);
|
|
@@ -4668,7 +4716,7 @@ function createAi(config) {
|
|
|
4668
4716
|
return assertNever(msg, "Unhandled case");
|
|
4669
4717
|
}
|
|
4670
4718
|
}
|
|
4671
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4719
|
+
_optionalChain([pendingCmd, 'optionalAccess', _81 => _81.resolve, 'call', _82 => _82(msg)]);
|
|
4672
4720
|
}
|
|
4673
4721
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4674
4722
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4753,9 +4801,9 @@ function createAi(config) {
|
|
|
4753
4801
|
invocationId,
|
|
4754
4802
|
result,
|
|
4755
4803
|
generationOptions: {
|
|
4756
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4757
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4758
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4804
|
+
copilotId: _optionalChain([options, 'optionalAccess', _83 => _83.copilotId]),
|
|
4805
|
+
stream: _optionalChain([options, 'optionalAccess', _84 => _84.stream]),
|
|
4806
|
+
timeout: _optionalChain([options, 'optionalAccess', _85 => _85.timeout]),
|
|
4759
4807
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4760
4808
|
// from the global context
|
|
4761
4809
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -4766,6 +4814,14 @@ function createAi(config) {
|
|
|
4766
4814
|
messagesStore.markMine(resp.message.id);
|
|
4767
4815
|
}
|
|
4768
4816
|
}
|
|
4817
|
+
function handleBeforeUnload() {
|
|
4818
|
+
for (const messageId of context.messagesStore.getAutoExecutingMessageIds()) {
|
|
4819
|
+
sendClientMsgWithResponse({ cmd: "abort-ai", messageId }).catch(() => {
|
|
4820
|
+
});
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
const win = typeof window !== "undefined" ? window : void 0;
|
|
4824
|
+
_optionalChain([win, 'optionalAccess', _86 => _86.addEventListener, 'call', _87 => _87("beforeunload", handleBeforeUnload, { once: true })]);
|
|
4769
4825
|
return Object.defineProperty(
|
|
4770
4826
|
{
|
|
4771
4827
|
[kInternal]: {
|
|
@@ -4784,7 +4840,7 @@ function createAi(config) {
|
|
|
4784
4840
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4785
4841
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4786
4842
|
const globalKnowledge = context.knowledge.get();
|
|
4787
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
4843
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _88 => _88.knowledge]) || [];
|
|
4788
4844
|
const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
|
|
4789
4845
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4790
4846
|
messagesStore.markMine(targetMessageId);
|
|
@@ -4794,9 +4850,9 @@ function createAi(config) {
|
|
|
4794
4850
|
sourceMessage: userMessage,
|
|
4795
4851
|
targetMessageId,
|
|
4796
4852
|
generationOptions: {
|
|
4797
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4798
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4799
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4853
|
+
copilotId: _optionalChain([options, 'optionalAccess', _89 => _89.copilotId]),
|
|
4854
|
+
stream: _optionalChain([options, 'optionalAccess', _90 => _90.stream]),
|
|
4855
|
+
timeout: _optionalChain([options, 'optionalAccess', _91 => _91.timeout]),
|
|
4800
4856
|
// Combine global knowledge with request-specific knowledge
|
|
4801
4857
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
4802
4858
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -4833,7 +4889,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
|
|
|
4833
4889
|
}
|
|
4834
4890
|
const url2 = new URL(baseUrl);
|
|
4835
4891
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
4836
|
-
url2.pathname = "/ai/
|
|
4892
|
+
url2.pathname = "/ai/v6";
|
|
4837
4893
|
if (authValue.type === "secret") {
|
|
4838
4894
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
4839
4895
|
} else if (authValue.type === "public") {
|
|
@@ -4897,7 +4953,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4897
4953
|
return void 0;
|
|
4898
4954
|
}
|
|
4899
4955
|
async function makeAuthRequest(options) {
|
|
4900
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
4956
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _92 => _92.polyfills, 'optionalAccess', _93 => _93.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
4901
4957
|
if (authentication.type === "private") {
|
|
4902
4958
|
if (fetcher === void 0) {
|
|
4903
4959
|
throw new StopRetrying(
|
|
@@ -4913,7 +4969,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4913
4969
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
4914
4970
|
);
|
|
4915
4971
|
}
|
|
4916
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4972
|
+
_optionalChain([onAuthenticate, 'optionalCall', _94 => _94(parsed.parsed)]);
|
|
4917
4973
|
return parsed;
|
|
4918
4974
|
}
|
|
4919
4975
|
if (authentication.type === "custom") {
|
|
@@ -4921,7 +4977,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4921
4977
|
if (response && typeof response === "object") {
|
|
4922
4978
|
if (typeof response.token === "string") {
|
|
4923
4979
|
const parsed = parseAuthToken(response.token);
|
|
4924
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4980
|
+
_optionalChain([onAuthenticate, 'optionalCall', _95 => _95(parsed.parsed)]);
|
|
4925
4981
|
return parsed;
|
|
4926
4982
|
} else if (typeof response.error === "string") {
|
|
4927
4983
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -5079,7 +5135,7 @@ function sendToPanel(message, options) {
|
|
|
5079
5135
|
...message,
|
|
5080
5136
|
source: "liveblocks-devtools-client"
|
|
5081
5137
|
};
|
|
5082
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
5138
|
+
if (!(_optionalChain([options, 'optionalAccess', _96 => _96.force]) || _bridgeActive)) {
|
|
5083
5139
|
return;
|
|
5084
5140
|
}
|
|
5085
5141
|
window.postMessage(fullMsg, "*");
|
|
@@ -5087,7 +5143,7 @@ function sendToPanel(message, options) {
|
|
|
5087
5143
|
var eventSource = makeEventSource();
|
|
5088
5144
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
5089
5145
|
window.addEventListener("message", (event) => {
|
|
5090
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
5146
|
+
if (event.source === window && _optionalChain([event, 'access', _97 => _97.data, 'optionalAccess', _98 => _98.source]) === "liveblocks-devtools-panel") {
|
|
5091
5147
|
eventSource.notify(event.data);
|
|
5092
5148
|
} else {
|
|
5093
5149
|
}
|
|
@@ -5229,7 +5285,7 @@ function fullSync(room) {
|
|
|
5229
5285
|
msg: "room::sync::full",
|
|
5230
5286
|
roomId: room.id,
|
|
5231
5287
|
status: room.getStatus(),
|
|
5232
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
5288
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _99 => _99.toTreeNode, 'call', _100 => _100("root"), 'access', _101 => _101.payload]), () => ( null)),
|
|
5233
5289
|
me,
|
|
5234
5290
|
others
|
|
5235
5291
|
});
|
|
@@ -5520,7 +5576,7 @@ function createManagedPool(roomId, options) {
|
|
|
5520
5576
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
5521
5577
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
5522
5578
|
dispatch(ops, reverse, storageUpdates) {
|
|
5523
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
5579
|
+
_optionalChain([onDispatch, 'optionalCall', _102 => _102(ops, reverse, storageUpdates)]);
|
|
5524
5580
|
},
|
|
5525
5581
|
assertStorageIsWritable: () => {
|
|
5526
5582
|
if (!isStorageWritable()) {
|
|
@@ -5747,7 +5803,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
5747
5803
|
return [
|
|
5748
5804
|
{
|
|
5749
5805
|
type: 8 /* CREATE_REGISTER */,
|
|
5750
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5806
|
+
opId: _optionalChain([pool, 'optionalAccess', _103 => _103.generateOpId, 'call', _104 => _104()]),
|
|
5751
5807
|
id: this._id,
|
|
5752
5808
|
parentId,
|
|
5753
5809
|
parentKey,
|
|
@@ -5853,7 +5909,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5853
5909
|
const ops = [];
|
|
5854
5910
|
const op = {
|
|
5855
5911
|
id: this._id,
|
|
5856
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5912
|
+
opId: _optionalChain([pool, 'optionalAccess', _105 => _105.generateOpId, 'call', _106 => _106()]),
|
|
5857
5913
|
type: 2 /* CREATE_LIST */,
|
|
5858
5914
|
parentId,
|
|
5859
5915
|
parentKey
|
|
@@ -6124,7 +6180,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6124
6180
|
#applyInsertUndoRedo(op) {
|
|
6125
6181
|
const { id, parentKey: key } = op;
|
|
6126
6182
|
const child = creationOpToLiveNode(op);
|
|
6127
|
-
if (_optionalChain([this, 'access',
|
|
6183
|
+
if (_optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.getNode, 'call', _109 => _109(id)]) !== void 0) {
|
|
6128
6184
|
return { modified: false };
|
|
6129
6185
|
}
|
|
6130
6186
|
child._attach(id, nn(this._pool));
|
|
@@ -6132,8 +6188,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6132
6188
|
const existingItemIndex = this._indexOfPosition(key);
|
|
6133
6189
|
let newKey = key;
|
|
6134
6190
|
if (existingItemIndex !== -1) {
|
|
6135
|
-
const before2 = _optionalChain([this, 'access',
|
|
6136
|
-
const after2 = _optionalChain([this, 'access',
|
|
6191
|
+
const before2 = _optionalChain([this, 'access', _110 => _110.#items, 'access', _111 => _111[existingItemIndex], 'optionalAccess', _112 => _112._parentPos]);
|
|
6192
|
+
const after2 = _optionalChain([this, 'access', _113 => _113.#items, 'access', _114 => _114[existingItemIndex + 1], 'optionalAccess', _115 => _115._parentPos]);
|
|
6137
6193
|
newKey = makePosition(before2, after2);
|
|
6138
6194
|
child._setParentLink(this, newKey);
|
|
6139
6195
|
}
|
|
@@ -6147,7 +6203,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6147
6203
|
#applySetUndoRedo(op) {
|
|
6148
6204
|
const { id, parentKey: key } = op;
|
|
6149
6205
|
const child = creationOpToLiveNode(op);
|
|
6150
|
-
if (_optionalChain([this, 'access',
|
|
6206
|
+
if (_optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.getNode, 'call', _118 => _118(id)]) !== void 0) {
|
|
6151
6207
|
return { modified: false };
|
|
6152
6208
|
}
|
|
6153
6209
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -6268,7 +6324,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6268
6324
|
} else {
|
|
6269
6325
|
this.#items[existingItemIndex]._setParentLink(
|
|
6270
6326
|
this,
|
|
6271
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6327
|
+
makePosition(newKey, _optionalChain([this, 'access', _119 => _119.#items, 'access', _120 => _120[existingItemIndex + 1], 'optionalAccess', _121 => _121._parentPos]))
|
|
6272
6328
|
);
|
|
6273
6329
|
const previousIndex = this.#items.indexOf(child);
|
|
6274
6330
|
child._setParentLink(this, newKey);
|
|
@@ -6293,7 +6349,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6293
6349
|
if (existingItemIndex !== -1) {
|
|
6294
6350
|
this.#items[existingItemIndex]._setParentLink(
|
|
6295
6351
|
this,
|
|
6296
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6352
|
+
makePosition(newKey, _optionalChain([this, 'access', _122 => _122.#items, 'access', _123 => _123[existingItemIndex + 1], 'optionalAccess', _124 => _124._parentPos]))
|
|
6297
6353
|
);
|
|
6298
6354
|
}
|
|
6299
6355
|
child._setParentLink(this, newKey);
|
|
@@ -6312,7 +6368,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6312
6368
|
if (existingItemIndex !== -1) {
|
|
6313
6369
|
this.#items[existingItemIndex]._setParentLink(
|
|
6314
6370
|
this,
|
|
6315
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6371
|
+
makePosition(newKey, _optionalChain([this, 'access', _125 => _125.#items, 'access', _126 => _126[existingItemIndex + 1], 'optionalAccess', _127 => _127._parentPos]))
|
|
6316
6372
|
);
|
|
6317
6373
|
}
|
|
6318
6374
|
child._setParentLink(this, newKey);
|
|
@@ -6339,7 +6395,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6339
6395
|
if (existingItemIndex !== -1) {
|
|
6340
6396
|
this.#items[existingItemIndex]._setParentLink(
|
|
6341
6397
|
this,
|
|
6342
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6398
|
+
makePosition(newKey, _optionalChain([this, 'access', _128 => _128.#items, 'access', _129 => _129[existingItemIndex + 1], 'optionalAccess', _130 => _130._parentPos]))
|
|
6343
6399
|
);
|
|
6344
6400
|
}
|
|
6345
6401
|
child._setParentLink(this, newKey);
|
|
@@ -6397,7 +6453,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6397
6453
|
* @param element The element to add to the end of the LiveList.
|
|
6398
6454
|
*/
|
|
6399
6455
|
push(element) {
|
|
6400
|
-
_optionalChain([this, 'access',
|
|
6456
|
+
_optionalChain([this, 'access', _131 => _131._pool, 'optionalAccess', _132 => _132.assertStorageIsWritable, 'call', _133 => _133()]);
|
|
6401
6457
|
return this.insert(element, this.length);
|
|
6402
6458
|
}
|
|
6403
6459
|
/**
|
|
@@ -6406,7 +6462,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6406
6462
|
* @param index The index at which you want to insert the element.
|
|
6407
6463
|
*/
|
|
6408
6464
|
insert(element, index) {
|
|
6409
|
-
_optionalChain([this, 'access',
|
|
6465
|
+
_optionalChain([this, 'access', _134 => _134._pool, 'optionalAccess', _135 => _135.assertStorageIsWritable, 'call', _136 => _136()]);
|
|
6410
6466
|
if (index < 0 || index > this.#items.length) {
|
|
6411
6467
|
throw new Error(
|
|
6412
6468
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -6436,7 +6492,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6436
6492
|
* @param targetIndex The index where the element should be after moving.
|
|
6437
6493
|
*/
|
|
6438
6494
|
move(index, targetIndex) {
|
|
6439
|
-
_optionalChain([this, 'access',
|
|
6495
|
+
_optionalChain([this, 'access', _137 => _137._pool, 'optionalAccess', _138 => _138.assertStorageIsWritable, 'call', _139 => _139()]);
|
|
6440
6496
|
if (targetIndex < 0) {
|
|
6441
6497
|
throw new Error("targetIndex cannot be less than 0");
|
|
6442
6498
|
}
|
|
@@ -6494,7 +6550,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6494
6550
|
* @param index The index of the element to delete
|
|
6495
6551
|
*/
|
|
6496
6552
|
delete(index) {
|
|
6497
|
-
_optionalChain([this, 'access',
|
|
6553
|
+
_optionalChain([this, 'access', _140 => _140._pool, 'optionalAccess', _141 => _141.assertStorageIsWritable, 'call', _142 => _142()]);
|
|
6498
6554
|
if (index < 0 || index >= this.#items.length) {
|
|
6499
6555
|
throw new Error(
|
|
6500
6556
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6527,7 +6583,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6527
6583
|
}
|
|
6528
6584
|
}
|
|
6529
6585
|
clear() {
|
|
6530
|
-
_optionalChain([this, 'access',
|
|
6586
|
+
_optionalChain([this, 'access', _143 => _143._pool, 'optionalAccess', _144 => _144.assertStorageIsWritable, 'call', _145 => _145()]);
|
|
6531
6587
|
if (this._pool) {
|
|
6532
6588
|
const ops = [];
|
|
6533
6589
|
const reverseOps = [];
|
|
@@ -6561,7 +6617,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6561
6617
|
}
|
|
6562
6618
|
}
|
|
6563
6619
|
set(index, item) {
|
|
6564
|
-
_optionalChain([this, 'access',
|
|
6620
|
+
_optionalChain([this, 'access', _146 => _146._pool, 'optionalAccess', _147 => _147.assertStorageIsWritable, 'call', _148 => _148()]);
|
|
6565
6621
|
if (index < 0 || index >= this.#items.length) {
|
|
6566
6622
|
throw new Error(
|
|
6567
6623
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6707,7 +6763,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6707
6763
|
#shiftItemPosition(index, key) {
|
|
6708
6764
|
const shiftedPosition = makePosition(
|
|
6709
6765
|
key,
|
|
6710
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
6766
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _149 => _149.#items, 'access', _150 => _150[index + 1], 'optionalAccess', _151 => _151._parentPos]) : void 0
|
|
6711
6767
|
);
|
|
6712
6768
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
6713
6769
|
}
|
|
@@ -6832,7 +6888,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6832
6888
|
const ops = [];
|
|
6833
6889
|
const op = {
|
|
6834
6890
|
id: this._id,
|
|
6835
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6891
|
+
opId: _optionalChain([pool, 'optionalAccess', _152 => _152.generateOpId, 'call', _153 => _153()]),
|
|
6836
6892
|
type: 7 /* CREATE_MAP */,
|
|
6837
6893
|
parentId,
|
|
6838
6894
|
parentKey
|
|
@@ -6967,7 +7023,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6967
7023
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
6968
7024
|
*/
|
|
6969
7025
|
set(key, value) {
|
|
6970
|
-
_optionalChain([this, 'access',
|
|
7026
|
+
_optionalChain([this, 'access', _154 => _154._pool, 'optionalAccess', _155 => _155.assertStorageIsWritable, 'call', _156 => _156()]);
|
|
6971
7027
|
const oldValue = this.#map.get(key);
|
|
6972
7028
|
if (oldValue) {
|
|
6973
7029
|
oldValue._detach();
|
|
@@ -7013,7 +7069,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
7013
7069
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
7014
7070
|
*/
|
|
7015
7071
|
delete(key) {
|
|
7016
|
-
_optionalChain([this, 'access',
|
|
7072
|
+
_optionalChain([this, 'access', _157 => _157._pool, 'optionalAccess', _158 => _158.assertStorageIsWritable, 'call', _159 => _159()]);
|
|
7017
7073
|
const item = this.#map.get(key);
|
|
7018
7074
|
if (item === void 0) {
|
|
7019
7075
|
return false;
|
|
@@ -7203,7 +7259,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7203
7259
|
if (this._id === void 0) {
|
|
7204
7260
|
throw new Error("Cannot serialize item is not attached");
|
|
7205
7261
|
}
|
|
7206
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
7262
|
+
const opId = _optionalChain([pool, 'optionalAccess', _160 => _160.generateOpId, 'call', _161 => _161()]);
|
|
7207
7263
|
const ops = [];
|
|
7208
7264
|
const op = {
|
|
7209
7265
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -7475,7 +7531,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7475
7531
|
* @param value The value of the property to add
|
|
7476
7532
|
*/
|
|
7477
7533
|
set(key, value) {
|
|
7478
|
-
_optionalChain([this, 'access',
|
|
7534
|
+
_optionalChain([this, 'access', _162 => _162._pool, 'optionalAccess', _163 => _163.assertStorageIsWritable, 'call', _164 => _164()]);
|
|
7479
7535
|
this.update({ [key]: value });
|
|
7480
7536
|
}
|
|
7481
7537
|
/**
|
|
@@ -7490,7 +7546,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7490
7546
|
* @param key The key of the property to delete
|
|
7491
7547
|
*/
|
|
7492
7548
|
delete(key) {
|
|
7493
|
-
_optionalChain([this, 'access',
|
|
7549
|
+
_optionalChain([this, 'access', _165 => _165._pool, 'optionalAccess', _166 => _166.assertStorageIsWritable, 'call', _167 => _167()]);
|
|
7494
7550
|
const keyAsString = key;
|
|
7495
7551
|
const oldValue = this.#map.get(keyAsString);
|
|
7496
7552
|
if (oldValue === void 0) {
|
|
@@ -7543,7 +7599,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7543
7599
|
* @param patch The object used to overrides properties
|
|
7544
7600
|
*/
|
|
7545
7601
|
update(patch) {
|
|
7546
|
-
_optionalChain([this, 'access',
|
|
7602
|
+
_optionalChain([this, 'access', _168 => _168._pool, 'optionalAccess', _169 => _169.assertStorageIsWritable, 'call', _170 => _170()]);
|
|
7547
7603
|
if (_LiveObject.detectLargeObjects) {
|
|
7548
7604
|
const data = {};
|
|
7549
7605
|
for (const [key, value] of this.#map) {
|
|
@@ -8291,15 +8347,15 @@ function installBackgroundTabSpy() {
|
|
|
8291
8347
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8292
8348
|
const inBackgroundSince = { current: null };
|
|
8293
8349
|
function onVisibilityChange() {
|
|
8294
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
8350
|
+
if (_optionalChain([doc, 'optionalAccess', _171 => _171.visibilityState]) === "hidden") {
|
|
8295
8351
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
8296
8352
|
} else {
|
|
8297
8353
|
inBackgroundSince.current = null;
|
|
8298
8354
|
}
|
|
8299
8355
|
}
|
|
8300
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8356
|
+
_optionalChain([doc, 'optionalAccess', _172 => _172.addEventListener, 'call', _173 => _173("visibilitychange", onVisibilityChange)]);
|
|
8301
8357
|
const unsub = () => {
|
|
8302
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8358
|
+
_optionalChain([doc, 'optionalAccess', _174 => _174.removeEventListener, 'call', _175 => _175("visibilitychange", onVisibilityChange)]);
|
|
8303
8359
|
};
|
|
8304
8360
|
return [inBackgroundSince, unsub];
|
|
8305
8361
|
}
|
|
@@ -8479,7 +8535,7 @@ function createRoom(options, config) {
|
|
|
8479
8535
|
}
|
|
8480
8536
|
}
|
|
8481
8537
|
function isStorageWritable() {
|
|
8482
|
-
const scopes = _optionalChain([context, 'access',
|
|
8538
|
+
const scopes = _optionalChain([context, 'access', _176 => _176.dynamicSessionInfoSig, 'access', _177 => _177.get, 'call', _178 => _178(), 'optionalAccess', _179 => _179.scopes]);
|
|
8483
8539
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
8484
8540
|
}
|
|
8485
8541
|
const eventHub = {
|
|
@@ -8605,7 +8661,7 @@ function createRoom(options, config) {
|
|
|
8605
8661
|
}
|
|
8606
8662
|
case "experimental-fallback-to-http": {
|
|
8607
8663
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8608
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
8664
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _180 => _180.dynamicSessionInfoSig, 'access', _181 => _181.get, 'call', _182 => _182(), 'optionalAccess', _183 => _183.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
8609
8665
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
8610
8666
|
if (!resp.ok && resp.status === 403) {
|
|
8611
8667
|
managedSocket.reconnect();
|
|
@@ -8656,7 +8712,7 @@ function createRoom(options, config) {
|
|
|
8656
8712
|
} else {
|
|
8657
8713
|
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
8658
8714
|
}
|
|
8659
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
8715
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _184 => _184.get, 'call', _185 => _185(), 'optionalAccess', _186 => _186.canWrite]), () => ( true));
|
|
8660
8716
|
const stackSizeBefore = context.undoStack.length;
|
|
8661
8717
|
for (const key in context.initialStorage) {
|
|
8662
8718
|
if (context.root.get(key) === void 0) {
|
|
@@ -8859,7 +8915,7 @@ function createRoom(options, config) {
|
|
|
8859
8915
|
}
|
|
8860
8916
|
context.myPresence.patch(patch);
|
|
8861
8917
|
if (context.activeBatch) {
|
|
8862
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8918
|
+
if (_optionalChain([options2, 'optionalAccess', _187 => _187.addToHistory])) {
|
|
8863
8919
|
context.activeBatch.reverseOps.pushLeft({
|
|
8864
8920
|
type: "presence",
|
|
8865
8921
|
data: oldValues
|
|
@@ -8868,7 +8924,7 @@ function createRoom(options, config) {
|
|
|
8868
8924
|
context.activeBatch.updates.presence = true;
|
|
8869
8925
|
} else {
|
|
8870
8926
|
flushNowOrSoon();
|
|
8871
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8927
|
+
if (_optionalChain([options2, 'optionalAccess', _188 => _188.addToHistory])) {
|
|
8872
8928
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
8873
8929
|
}
|
|
8874
8930
|
notify({ presence: true });
|
|
@@ -9065,7 +9121,7 @@ function createRoom(options, config) {
|
|
|
9065
9121
|
if (process.env.NODE_ENV !== "production") {
|
|
9066
9122
|
const traces = /* @__PURE__ */ new Set();
|
|
9067
9123
|
for (const opId of message.opIds) {
|
|
9068
|
-
const trace = _optionalChain([context, 'access',
|
|
9124
|
+
const trace = _optionalChain([context, 'access', _189 => _189.opStackTraces, 'optionalAccess', _190 => _190.get, 'call', _191 => _191(opId)]);
|
|
9069
9125
|
if (trace) {
|
|
9070
9126
|
traces.add(trace);
|
|
9071
9127
|
}
|
|
@@ -9199,7 +9255,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9199
9255
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9200
9256
|
createOrUpdateRootFromMessage(message);
|
|
9201
9257
|
applyAndSendOps(unacknowledgedOps);
|
|
9202
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
9258
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _192 => _192()]);
|
|
9203
9259
|
notifyStorageStatus();
|
|
9204
9260
|
eventHub.storageDidLoad.notify();
|
|
9205
9261
|
}
|
|
@@ -9420,8 +9476,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9420
9476
|
async function getThreads(options2) {
|
|
9421
9477
|
return httpClient.getThreads({
|
|
9422
9478
|
roomId,
|
|
9423
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
9424
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9479
|
+
query: _optionalChain([options2, 'optionalAccess', _193 => _193.query]),
|
|
9480
|
+
cursor: _optionalChain([options2, 'optionalAccess', _194 => _194.cursor])
|
|
9425
9481
|
});
|
|
9426
9482
|
}
|
|
9427
9483
|
async function getThread(threadId) {
|
|
@@ -9528,7 +9584,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9528
9584
|
function getSubscriptionSettings(options2) {
|
|
9529
9585
|
return httpClient.getSubscriptionSettings({
|
|
9530
9586
|
roomId,
|
|
9531
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9587
|
+
signal: _optionalChain([options2, 'optionalAccess', _195 => _195.signal])
|
|
9532
9588
|
});
|
|
9533
9589
|
}
|
|
9534
9590
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9550,7 +9606,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9550
9606
|
{
|
|
9551
9607
|
[kInternal]: {
|
|
9552
9608
|
get presenceBuffer() {
|
|
9553
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9609
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _196 => _196.buffer, 'access', _197 => _197.presenceUpdates, 'optionalAccess', _198 => _198.data]), () => ( null)));
|
|
9554
9610
|
},
|
|
9555
9611
|
// prettier-ignore
|
|
9556
9612
|
get undoStack() {
|
|
@@ -9565,9 +9621,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9565
9621
|
return context.yjsProvider;
|
|
9566
9622
|
},
|
|
9567
9623
|
setYjsProvider(newProvider) {
|
|
9568
|
-
_optionalChain([context, 'access',
|
|
9624
|
+
_optionalChain([context, 'access', _199 => _199.yjsProvider, 'optionalAccess', _200 => _200.off, 'call', _201 => _201("status", yjsStatusDidChange)]);
|
|
9569
9625
|
context.yjsProvider = newProvider;
|
|
9570
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9626
|
+
_optionalChain([newProvider, 'optionalAccess', _202 => _202.on, 'call', _203 => _203("status", yjsStatusDidChange)]);
|
|
9571
9627
|
context.yjsProviderDidChange.notify();
|
|
9572
9628
|
},
|
|
9573
9629
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9613,7 +9669,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9613
9669
|
source.dispose();
|
|
9614
9670
|
}
|
|
9615
9671
|
eventHub.roomWillDestroy.notify();
|
|
9616
|
-
_optionalChain([context, 'access',
|
|
9672
|
+
_optionalChain([context, 'access', _204 => _204.yjsProvider, 'optionalAccess', _205 => _205.off, 'call', _206 => _206("status", yjsStatusDidChange)]);
|
|
9617
9673
|
syncSourceForStorage.destroy();
|
|
9618
9674
|
syncSourceForYjs.destroy();
|
|
9619
9675
|
uninstallBgTabSpy();
|
|
@@ -9763,7 +9819,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9763
9819
|
}
|
|
9764
9820
|
if (isLiveNode(first)) {
|
|
9765
9821
|
const node = first;
|
|
9766
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9822
|
+
if (_optionalChain([options, 'optionalAccess', _207 => _207.isDeep])) {
|
|
9767
9823
|
const storageCallback = second;
|
|
9768
9824
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9769
9825
|
} else {
|
|
@@ -9842,8 +9898,8 @@ function createClient(options) {
|
|
|
9842
9898
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
9843
9899
|
currentUserId.set(() => userId);
|
|
9844
9900
|
});
|
|
9845
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
9846
|
-
_optionalChain([globalThis, 'access',
|
|
9901
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _208 => _208.polyfills, 'optionalAccess', _209 => _209.fetch]) || /* istanbul ignore next */
|
|
9902
|
+
_optionalChain([globalThis, 'access', _210 => _210.fetch, 'optionalAccess', _211 => _211.bind, 'call', _212 => _212(globalThis)]);
|
|
9847
9903
|
const httpClient = createApiClient({
|
|
9848
9904
|
baseUrl,
|
|
9849
9905
|
fetchPolyfill,
|
|
@@ -9861,7 +9917,7 @@ function createClient(options) {
|
|
|
9861
9917
|
delegates: {
|
|
9862
9918
|
createSocket: makeCreateSocketDelegateForAi(
|
|
9863
9919
|
baseUrl,
|
|
9864
|
-
_optionalChain([clientOptions, 'access',
|
|
9920
|
+
_optionalChain([clientOptions, 'access', _213 => _213.polyfills, 'optionalAccess', _214 => _214.WebSocket])
|
|
9865
9921
|
),
|
|
9866
9922
|
authenticate: async () => {
|
|
9867
9923
|
const resp = await authManager.getAuthValue({
|
|
@@ -9929,7 +9985,7 @@ function createClient(options) {
|
|
|
9929
9985
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
9930
9986
|
roomId,
|
|
9931
9987
|
baseUrl,
|
|
9932
|
-
_optionalChain([clientOptions, 'access',
|
|
9988
|
+
_optionalChain([clientOptions, 'access', _215 => _215.polyfills, 'optionalAccess', _216 => _216.WebSocket])
|
|
9933
9989
|
),
|
|
9934
9990
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
9935
9991
|
})),
|
|
@@ -9952,7 +10008,7 @@ function createClient(options) {
|
|
|
9952
10008
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
9953
10009
|
if (shouldConnect) {
|
|
9954
10010
|
if (typeof atob === "undefined") {
|
|
9955
|
-
if (_optionalChain([clientOptions, 'access',
|
|
10011
|
+
if (_optionalChain([clientOptions, 'access', _217 => _217.polyfills, 'optionalAccess', _218 => _218.atob]) === void 0) {
|
|
9956
10012
|
throw new Error(
|
|
9957
10013
|
"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"
|
|
9958
10014
|
);
|
|
@@ -9964,7 +10020,7 @@ function createClient(options) {
|
|
|
9964
10020
|
return leaseRoom(newRoomDetails);
|
|
9965
10021
|
}
|
|
9966
10022
|
function getRoom(roomId) {
|
|
9967
|
-
const room = _optionalChain([roomsById, 'access',
|
|
10023
|
+
const room = _optionalChain([roomsById, 'access', _219 => _219.get, 'call', _220 => _220(roomId), 'optionalAccess', _221 => _221.room]);
|
|
9968
10024
|
return room ? room : null;
|
|
9969
10025
|
}
|
|
9970
10026
|
function logout() {
|
|
@@ -9984,7 +10040,7 @@ function createClient(options) {
|
|
|
9984
10040
|
const batchedResolveUsers = new Batch(
|
|
9985
10041
|
async (batchedUserIds) => {
|
|
9986
10042
|
const userIds = batchedUserIds.flat();
|
|
9987
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
10043
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _222 => _222({ userIds })]);
|
|
9988
10044
|
warnIfNoResolveUsers();
|
|
9989
10045
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
9990
10046
|
},
|
|
@@ -10002,7 +10058,7 @@ function createClient(options) {
|
|
|
10002
10058
|
const batchedResolveRoomsInfo = new Batch(
|
|
10003
10059
|
async (batchedRoomIds) => {
|
|
10004
10060
|
const roomIds = batchedRoomIds.flat();
|
|
10005
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
10061
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _223 => _223({ roomIds })]);
|
|
10006
10062
|
warnIfNoResolveRoomsInfo();
|
|
10007
10063
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
10008
10064
|
},
|
|
@@ -10055,7 +10111,7 @@ function createClient(options) {
|
|
|
10055
10111
|
}
|
|
10056
10112
|
};
|
|
10057
10113
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10058
|
-
_optionalChain([win, 'optionalAccess',
|
|
10114
|
+
_optionalChain([win, 'optionalAccess', _224 => _224.addEventListener, 'call', _225 => _225("beforeunload", maybePreventClose)]);
|
|
10059
10115
|
}
|
|
10060
10116
|
async function getNotificationSettings(options2) {
|
|
10061
10117
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -10194,7 +10250,7 @@ var commentBodyElementsTypes = {
|
|
|
10194
10250
|
mention: "inline"
|
|
10195
10251
|
};
|
|
10196
10252
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
10197
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
10253
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _226 => _226.content])) {
|
|
10198
10254
|
return;
|
|
10199
10255
|
}
|
|
10200
10256
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -10204,13 +10260,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
10204
10260
|
for (const block of body.content) {
|
|
10205
10261
|
if (type === "all" || type === "block") {
|
|
10206
10262
|
if (guard(block)) {
|
|
10207
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10263
|
+
_optionalChain([visitor, 'optionalCall', _227 => _227(block)]);
|
|
10208
10264
|
}
|
|
10209
10265
|
}
|
|
10210
10266
|
if (type === "all" || type === "inline") {
|
|
10211
10267
|
for (const inline of block.children) {
|
|
10212
10268
|
if (guard(inline)) {
|
|
10213
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10269
|
+
_optionalChain([visitor, 'optionalCall', _228 => _228(inline)]);
|
|
10214
10270
|
}
|
|
10215
10271
|
}
|
|
10216
10272
|
}
|
|
@@ -10244,7 +10300,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
10244
10300
|
userIds
|
|
10245
10301
|
});
|
|
10246
10302
|
for (const [index, userId] of userIds.entries()) {
|
|
10247
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
10303
|
+
const user = _optionalChain([users, 'optionalAccess', _229 => _229[index]]);
|
|
10248
10304
|
if (user) {
|
|
10249
10305
|
resolvedUsers.set(userId, user);
|
|
10250
10306
|
}
|
|
@@ -10363,7 +10419,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
10363
10419
|
text: ({ element }) => element.text,
|
|
10364
10420
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
10365
10421
|
mention: ({ element, user }) => {
|
|
10366
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10422
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _230 => _230.name]), () => ( element.id))}`;
|
|
10367
10423
|
}
|
|
10368
10424
|
};
|
|
10369
10425
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -10393,7 +10449,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
10393
10449
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
10394
10450
|
},
|
|
10395
10451
|
mention: ({ element, user }) => {
|
|
10396
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
10452
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _231 => _231.name]) ? html`${_optionalChain([user, 'optionalAccess', _232 => _232.name])}` : element.id}</span>`;
|
|
10397
10453
|
}
|
|
10398
10454
|
};
|
|
10399
10455
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -10423,19 +10479,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
10423
10479
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
10424
10480
|
},
|
|
10425
10481
|
mention: ({ element, user }) => {
|
|
10426
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10482
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _233 => _233.name]), () => ( element.id))}`;
|
|
10427
10483
|
}
|
|
10428
10484
|
};
|
|
10429
10485
|
async function stringifyCommentBody(body, options) {
|
|
10430
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10431
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10486
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _234 => _234.format]), () => ( "plain"));
|
|
10487
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _235 => _235.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
10432
10488
|
const elements = {
|
|
10433
10489
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
10434
|
-
..._optionalChain([options, 'optionalAccess',
|
|
10490
|
+
..._optionalChain([options, 'optionalAccess', _236 => _236.elements])
|
|
10435
10491
|
};
|
|
10436
10492
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
10437
10493
|
body,
|
|
10438
|
-
_optionalChain([options, 'optionalAccess',
|
|
10494
|
+
_optionalChain([options, 'optionalAccess', _237 => _237.resolveUsers])
|
|
10439
10495
|
);
|
|
10440
10496
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
10441
10497
|
switch (block.type) {
|
|
@@ -10721,12 +10777,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10721
10777
|
}
|
|
10722
10778
|
const newState = Object.assign({}, state);
|
|
10723
10779
|
for (const key in update.updates) {
|
|
10724
|
-
if (_optionalChain([update, 'access',
|
|
10780
|
+
if (_optionalChain([update, 'access', _238 => _238.updates, 'access', _239 => _239[key], 'optionalAccess', _240 => _240.type]) === "update") {
|
|
10725
10781
|
const val = update.node.get(key);
|
|
10726
10782
|
if (val !== void 0) {
|
|
10727
10783
|
newState[key] = lsonToJson(val);
|
|
10728
10784
|
}
|
|
10729
|
-
} else if (_optionalChain([update, 'access',
|
|
10785
|
+
} else if (_optionalChain([update, 'access', _241 => _241.updates, 'access', _242 => _242[key], 'optionalAccess', _243 => _243.type]) === "delete") {
|
|
10730
10786
|
delete newState[key];
|
|
10731
10787
|
}
|
|
10732
10788
|
}
|
|
@@ -10787,12 +10843,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10787
10843
|
}
|
|
10788
10844
|
const newState = Object.assign({}, state);
|
|
10789
10845
|
for (const key in update.updates) {
|
|
10790
|
-
if (_optionalChain([update, 'access',
|
|
10846
|
+
if (_optionalChain([update, 'access', _244 => _244.updates, 'access', _245 => _245[key], 'optionalAccess', _246 => _246.type]) === "update") {
|
|
10791
10847
|
const value = update.node.get(key);
|
|
10792
10848
|
if (value !== void 0) {
|
|
10793
10849
|
newState[key] = lsonToJson(value);
|
|
10794
10850
|
}
|
|
10795
|
-
} else if (_optionalChain([update, 'access',
|
|
10851
|
+
} else if (_optionalChain([update, 'access', _247 => _247.updates, 'access', _248 => _248[key], 'optionalAccess', _249 => _249.type]) === "delete") {
|
|
10796
10852
|
delete newState[key];
|
|
10797
10853
|
}
|
|
10798
10854
|
}
|
|
@@ -10872,9 +10928,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10872
10928
|
const startTime = performance.now();
|
|
10873
10929
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10874
10930
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10875
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10931
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _250 => _250.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
10876
10932
|
const context = {
|
|
10877
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
10933
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _251 => _251.visibilityState]) !== "hidden",
|
|
10878
10934
|
lastSuccessfulPollAt: startTime,
|
|
10879
10935
|
count: 0,
|
|
10880
10936
|
backoff: 0
|
|
@@ -10955,11 +11011,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10955
11011
|
pollNowIfStale();
|
|
10956
11012
|
}
|
|
10957
11013
|
function onVisibilityChange() {
|
|
10958
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
11014
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _252 => _252.visibilityState]) !== "hidden");
|
|
10959
11015
|
}
|
|
10960
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10961
|
-
_optionalChain([win, 'optionalAccess',
|
|
10962
|
-
_optionalChain([win, 'optionalAccess',
|
|
11016
|
+
_optionalChain([doc, 'optionalAccess', _253 => _253.addEventListener, 'call', _254 => _254("visibilitychange", onVisibilityChange)]);
|
|
11017
|
+
_optionalChain([win, 'optionalAccess', _255 => _255.addEventListener, 'call', _256 => _256("online", onVisibilityChange)]);
|
|
11018
|
+
_optionalChain([win, 'optionalAccess', _257 => _257.addEventListener, 'call', _258 => _258("focus", pollNowIfStale)]);
|
|
10963
11019
|
fsm.start();
|
|
10964
11020
|
return {
|
|
10965
11021
|
inc,
|