@liveblocks/core 2.25.0-aiprivatebeta10 → 2.25.0-aiprivatebeta11
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 +161 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -15
- package/dist/index.d.ts +14 -15
- package/dist/index.js +71 -52
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
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 = "2.25.0-
|
|
9
|
+
var PKG_VERSION = "2.25.0-aiprivatebeta11";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3780,46 +3780,61 @@ var KnowledgeStack = class {
|
|
|
3780
3780
|
function now() {
|
|
3781
3781
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
3782
3782
|
}
|
|
3783
|
+
var kWILDCARD = Symbol("*");
|
|
3783
3784
|
function createStore_forTools() {
|
|
3784
|
-
const toolsByChatId\u03A3 = new DefaultMap(
|
|
3785
|
-
|
|
3786
|
-
return new
|
|
3785
|
+
const toolsByChatId\u03A3 = new DefaultMap(
|
|
3786
|
+
(_chatId) => {
|
|
3787
|
+
return new DefaultMap((_name) => {
|
|
3788
|
+
return new Signal(void 0);
|
|
3789
|
+
});
|
|
3790
|
+
}
|
|
3791
|
+
);
|
|
3792
|
+
const globalOrScopedTool\u03A3 = new DefaultMap((nameAndChat) => {
|
|
3793
|
+
const [name, chatId] = tryParseJson(nameAndChat);
|
|
3794
|
+
return DerivedSignal.from(() => {
|
|
3795
|
+
return (
|
|
3796
|
+
// A tool that's registered and scoped to a specific chat ID...
|
|
3797
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? _optionalChain([toolsByChatId\u03A3, 'access', _57 => _57.get, 'call', _58 => _58(chatId), 'optionalAccess', _59 => _59.get, 'call', _60 => _60(name)]) : void 0), 'optionalAccess', _61 => _61.get, 'call', _62 => _62()]), () => ( // ...or a globally registered tool
|
|
3798
|
+
_optionalChain([toolsByChatId\u03A3, 'access', _63 => _63.getOrCreate, 'call', _64 => _64(kWILDCARD), 'access', _65 => _65.get, 'call', _66 => _66(name), 'optionalAccess', _67 => _67.get, 'call', _68 => _68()])))
|
|
3799
|
+
);
|
|
3787
3800
|
});
|
|
3788
3801
|
});
|
|
3789
|
-
function
|
|
3790
|
-
|
|
3802
|
+
function getTool\u03A3(name, chatId) {
|
|
3803
|
+
const key = JSON.stringify(chatId !== void 0 ? [name, chatId] : [name]);
|
|
3804
|
+
return globalOrScopedTool\u03A3.getOrCreate(key);
|
|
3791
3805
|
}
|
|
3792
|
-
function
|
|
3793
|
-
if (!
|
|
3806
|
+
function registerTool(name, tool, chatId) {
|
|
3807
|
+
if (!tool.execute && !tool.render) {
|
|
3794
3808
|
throw new Error(
|
|
3795
|
-
"A tool definition must have an execute() function, a render
|
|
3809
|
+
"A tool definition must have an execute() function, a render() function, or both."
|
|
3796
3810
|
);
|
|
3797
3811
|
}
|
|
3798
|
-
|
|
3812
|
+
const key = _nullishCoalesce(chatId, () => ( kWILDCARD));
|
|
3813
|
+
toolsByChatId\u03A3.getOrCreate(key).getOrCreate(name).set(tool);
|
|
3814
|
+
return () => unregisterTool(key, name);
|
|
3799
3815
|
}
|
|
3800
|
-
function
|
|
3816
|
+
function unregisterTool(chatId, name) {
|
|
3801
3817
|
const tools = toolsByChatId\u03A3.get(chatId);
|
|
3802
3818
|
if (tools === void 0) return;
|
|
3803
|
-
const tool = tools.get(
|
|
3819
|
+
const tool = tools.get(name);
|
|
3804
3820
|
if (tool === void 0) return;
|
|
3805
3821
|
tool.set(void 0);
|
|
3806
3822
|
}
|
|
3807
|
-
function
|
|
3808
|
-
const
|
|
3809
|
-
|
|
3810
|
-
return Array.from(
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
};
|
|
3816
|
-
})
|
|
3823
|
+
function getToolDescriptions(chatId) {
|
|
3824
|
+
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
3825
|
+
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
3826
|
+
return Array.from([
|
|
3827
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _69 => _69.entries, 'call', _70 => _70()]), () => ( [])),
|
|
3828
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _71 => _71.entries, 'call', _72 => _72()]), () => ( []))
|
|
3829
|
+
]).flatMap(([name, tool\u03A3]) => {
|
|
3830
|
+
const tool = tool\u03A3.get();
|
|
3831
|
+
return tool ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
3832
|
+
});
|
|
3817
3833
|
}
|
|
3818
3834
|
return {
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
removeToolDefinition
|
|
3835
|
+
getToolDescriptions,
|
|
3836
|
+
getTool\u03A3,
|
|
3837
|
+
registerTool
|
|
3823
3838
|
};
|
|
3824
3839
|
}
|
|
3825
3840
|
function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
@@ -3909,7 +3924,7 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
|
3909
3924
|
continue;
|
|
3910
3925
|
}
|
|
3911
3926
|
seenToolCallIds.add(toolCall.toolCallId);
|
|
3912
|
-
const toolDef = toolsStore.
|
|
3927
|
+
const toolDef = toolsStore.getTool\u03A3(toolCall.toolName, message.chatId).get();
|
|
3913
3928
|
const respondSync = (result) => {
|
|
3914
3929
|
setToolResult(
|
|
3915
3930
|
message.chatId,
|
|
@@ -3923,7 +3938,7 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
|
3923
3938
|
);
|
|
3924
3939
|
});
|
|
3925
3940
|
};
|
|
3926
|
-
const executeFn = _optionalChain([toolDef, 'optionalAccess',
|
|
3941
|
+
const executeFn = _optionalChain([toolDef, 'optionalAccess', _73 => _73.execute]);
|
|
3927
3942
|
if (executeFn && autoExecutableMessages.has(message.id)) {
|
|
3928
3943
|
(async () => {
|
|
3929
3944
|
const result = await executeFn(toolCall.args, {
|
|
@@ -4011,8 +4026,8 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
|
4011
4026
|
const spine = [];
|
|
4012
4027
|
let lastVisitedMessage = null;
|
|
4013
4028
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4014
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4015
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4029
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _74 => _74(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _75 => _75.id]), () => ( null));
|
|
4030
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _76 => _76(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _77 => _77.id]), () => ( null));
|
|
4016
4031
|
if (!message2.deletedAt || prev || next) {
|
|
4017
4032
|
const node = {
|
|
4018
4033
|
...message2,
|
|
@@ -4091,16 +4106,16 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
|
4091
4106
|
};
|
|
4092
4107
|
}
|
|
4093
4108
|
function createStore_forUserAiChats() {
|
|
4094
|
-
const
|
|
4109
|
+
const allChatsInclDeleted\u03A3 = new MutableSignal(
|
|
4095
4110
|
SortedList.with((x, y) => y.createdAt < x.createdAt)
|
|
4096
4111
|
);
|
|
4097
|
-
const
|
|
4098
|
-
() => Array.from(
|
|
4112
|
+
const nonDeletedChats\u03A3 = DerivedSignal.from(
|
|
4113
|
+
() => Array.from(allChatsInclDeleted\u03A3.get()).filter((c) => !c.deletedAt)
|
|
4099
4114
|
);
|
|
4100
4115
|
function upsertMany(chats) {
|
|
4101
|
-
|
|
4116
|
+
allChatsInclDeleted\u03A3.mutate((list) => {
|
|
4102
4117
|
for (const chat of chats) {
|
|
4103
|
-
|
|
4118
|
+
list.removeBy((c) => c.id === chat.id, 1);
|
|
4104
4119
|
list.add(chat);
|
|
4105
4120
|
}
|
|
4106
4121
|
});
|
|
@@ -4108,19 +4123,26 @@ function createStore_forUserAiChats() {
|
|
|
4108
4123
|
function upsert(chat) {
|
|
4109
4124
|
upsertMany([chat]);
|
|
4110
4125
|
}
|
|
4111
|
-
function
|
|
4112
|
-
|
|
4126
|
+
function markDeleted(chatId) {
|
|
4127
|
+
allChatsInclDeleted\u03A3.mutate((list) => {
|
|
4128
|
+
const chat = list.find((c) => c.id === chatId);
|
|
4129
|
+
if (!chat) return false;
|
|
4130
|
+
upsert({ ...chat, deletedAt: now() });
|
|
4131
|
+
return void 0;
|
|
4132
|
+
});
|
|
4113
4133
|
}
|
|
4114
4134
|
function getChatById(chatId) {
|
|
4115
|
-
return Array.from(
|
|
4135
|
+
return Array.from(allChatsInclDeleted\u03A3.get()).find(
|
|
4136
|
+
(chat) => chat.id === chatId
|
|
4137
|
+
);
|
|
4116
4138
|
}
|
|
4117
4139
|
return {
|
|
4118
|
-
chats\u03A3,
|
|
4140
|
+
chats\u03A3: nonDeletedChats\u03A3,
|
|
4119
4141
|
getChatById,
|
|
4120
4142
|
// Mutations
|
|
4121
4143
|
upsert,
|
|
4122
4144
|
upsertMany,
|
|
4123
|
-
|
|
4145
|
+
markDeleted
|
|
4124
4146
|
};
|
|
4125
4147
|
}
|
|
4126
4148
|
function createAi(config) {
|
|
@@ -4198,7 +4220,7 @@ function createAi(config) {
|
|
|
4198
4220
|
if ("event" in msg) {
|
|
4199
4221
|
switch (msg.event) {
|
|
4200
4222
|
case "cmd-failed":
|
|
4201
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4223
|
+
_optionalChain([pendingCmd, 'optionalAccess', _78 => _78.reject, 'call', _79 => _79(new Error(msg.error))]);
|
|
4202
4224
|
break;
|
|
4203
4225
|
case "delta": {
|
|
4204
4226
|
const { id, delta } = msg;
|
|
@@ -4220,7 +4242,7 @@ function createAi(config) {
|
|
|
4220
4242
|
context.messagesStore.remove(m.chatId, m.id);
|
|
4221
4243
|
}
|
|
4222
4244
|
for (const chatId of _nullishCoalesce(msg["-chats"], () => ( []))) {
|
|
4223
|
-
context.chatsStore.
|
|
4245
|
+
context.chatsStore.markDeleted(chatId);
|
|
4224
4246
|
context.messagesStore.removeByChatId(chatId);
|
|
4225
4247
|
}
|
|
4226
4248
|
for (const chatId of _nullishCoalesce(msg.clear, () => ( []))) {
|
|
@@ -4246,7 +4268,7 @@ function createAi(config) {
|
|
|
4246
4268
|
context.chatsStore.upsert(msg.chat);
|
|
4247
4269
|
break;
|
|
4248
4270
|
case "delete-chat":
|
|
4249
|
-
context.chatsStore.
|
|
4271
|
+
context.chatsStore.markDeleted(msg.chatId);
|
|
4250
4272
|
context.messagesStore.removeByChatId(msg.chatId);
|
|
4251
4273
|
break;
|
|
4252
4274
|
case "get-message-tree":
|
|
@@ -4276,7 +4298,7 @@ function createAi(config) {
|
|
|
4276
4298
|
return assertNever(msg, "Unhandled case");
|
|
4277
4299
|
}
|
|
4278
4300
|
}
|
|
4279
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4301
|
+
_optionalChain([pendingCmd, 'optionalAccess', _80 => _80.resolve, 'call', _81 => _81(msg)]);
|
|
4280
4302
|
}
|
|
4281
4303
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4282
4304
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4346,6 +4368,7 @@ function createAi(config) {
|
|
|
4346
4368
|
}
|
|
4347
4369
|
async function setToolResult(chatId, messageId, toolCallId, result, options) {
|
|
4348
4370
|
const knowledge = context.knowledge.get();
|
|
4371
|
+
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4349
4372
|
const resp = await sendClientMsgWithResponse({
|
|
4350
4373
|
cmd: "set-tool-result",
|
|
4351
4374
|
chatId,
|
|
@@ -4353,15 +4376,13 @@ function createAi(config) {
|
|
|
4353
4376
|
toolCallId,
|
|
4354
4377
|
result,
|
|
4355
4378
|
generationOptions: {
|
|
4356
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4357
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4358
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4379
|
+
copilotId: _optionalChain([options, 'optionalAccess', _82 => _82.copilotId]),
|
|
4380
|
+
stream: _optionalChain([options, 'optionalAccess', _83 => _83.stream]),
|
|
4381
|
+
timeout: _optionalChain([options, 'optionalAccess', _84 => _84.timeout]),
|
|
4382
|
+
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4383
|
+
// from the global context
|
|
4359
4384
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
4360
|
-
tools:
|
|
4361
|
-
name: tool.name,
|
|
4362
|
-
description: tool.definition.description,
|
|
4363
|
-
parameters: tool.definition.parameters
|
|
4364
|
-
}))
|
|
4385
|
+
tools: tools.length > 0 ? tools : void 0
|
|
4365
4386
|
}
|
|
4366
4387
|
});
|
|
4367
4388
|
if (resp.ok) {
|
|
@@ -4387,21 +4408,20 @@ function createAi(config) {
|
|
|
4387
4408
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4388
4409
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4389
4410
|
const knowledge = context.knowledge.get();
|
|
4411
|
+
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4390
4412
|
const resp = await sendClientMsgWithResponse({
|
|
4391
4413
|
cmd: "ask-in-chat",
|
|
4392
4414
|
chatId,
|
|
4393
4415
|
sourceMessage: userMessage,
|
|
4394
4416
|
targetMessageId,
|
|
4395
4417
|
generationOptions: {
|
|
4396
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4397
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4398
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4418
|
+
copilotId: _optionalChain([options, 'optionalAccess', _85 => _85.copilotId]),
|
|
4419
|
+
stream: _optionalChain([options, 'optionalAccess', _86 => _86.stream]),
|
|
4420
|
+
timeout: _optionalChain([options, 'optionalAccess', _87 => _87.timeout]),
|
|
4421
|
+
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4422
|
+
// from the global context
|
|
4399
4423
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
4400
|
-
tools:
|
|
4401
|
-
name: tool.name,
|
|
4402
|
-
description: tool.definition.description,
|
|
4403
|
-
parameters: tool.definition.parameters
|
|
4404
|
-
}))
|
|
4424
|
+
tools: tools.length > 0 ? tools : void 0
|
|
4405
4425
|
}
|
|
4406
4426
|
});
|
|
4407
4427
|
messagesStore.allowAutoExecuteToolCall(resp.targetMessage.id);
|
|
@@ -4413,14 +4433,13 @@ function createAi(config) {
|
|
|
4413
4433
|
signals: {
|
|
4414
4434
|
chats\u03A3: context.chatsStore.chats\u03A3,
|
|
4415
4435
|
getChatMessagesForBranch\u03A3: context.messagesStore.getChatMessagesForBranch\u03A3,
|
|
4416
|
-
|
|
4436
|
+
getTool\u03A3: context.toolsStore.getTool\u03A3
|
|
4417
4437
|
},
|
|
4418
4438
|
getChatById: context.chatsStore.getChatById,
|
|
4419
4439
|
registerKnowledgeLayer,
|
|
4420
4440
|
deregisterKnowledgeLayer,
|
|
4421
4441
|
updateKnowledge,
|
|
4422
|
-
|
|
4423
|
-
unregisterChatTool: context.toolsStore.removeToolDefinition
|
|
4442
|
+
registerTool: context.toolsStore.registerTool
|
|
4424
4443
|
},
|
|
4425
4444
|
kInternal,
|
|
4426
4445
|
{ enumerable: false }
|
|
@@ -4500,7 +4519,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4500
4519
|
return void 0;
|
|
4501
4520
|
}
|
|
4502
4521
|
async function makeAuthRequest(options) {
|
|
4503
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
4522
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _88 => _88.polyfills, 'optionalAccess', _89 => _89.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
4504
4523
|
if (authentication.type === "private") {
|
|
4505
4524
|
if (fetcher === void 0) {
|
|
4506
4525
|
throw new StopRetrying(
|
|
@@ -4516,7 +4535,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4516
4535
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
4517
4536
|
);
|
|
4518
4537
|
}
|
|
4519
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4538
|
+
_optionalChain([onAuthenticate, 'optionalCall', _90 => _90(parsed.parsed)]);
|
|
4520
4539
|
return parsed;
|
|
4521
4540
|
}
|
|
4522
4541
|
if (authentication.type === "custom") {
|
|
@@ -4524,7 +4543,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4524
4543
|
if (response && typeof response === "object") {
|
|
4525
4544
|
if (typeof response.token === "string") {
|
|
4526
4545
|
const parsed = parseAuthToken(response.token);
|
|
4527
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4546
|
+
_optionalChain([onAuthenticate, 'optionalCall', _91 => _91(parsed.parsed)]);
|
|
4528
4547
|
return parsed;
|
|
4529
4548
|
} else if (typeof response.error === "string") {
|
|
4530
4549
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -4682,7 +4701,7 @@ function sendToPanel(message, options) {
|
|
|
4682
4701
|
...message,
|
|
4683
4702
|
source: "liveblocks-devtools-client"
|
|
4684
4703
|
};
|
|
4685
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
4704
|
+
if (!(_optionalChain([options, 'optionalAccess', _92 => _92.force]) || _bridgeActive)) {
|
|
4686
4705
|
return;
|
|
4687
4706
|
}
|
|
4688
4707
|
window.postMessage(fullMsg, "*");
|
|
@@ -4690,7 +4709,7 @@ function sendToPanel(message, options) {
|
|
|
4690
4709
|
var eventSource = makeEventSource();
|
|
4691
4710
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
4692
4711
|
window.addEventListener("message", (event) => {
|
|
4693
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
4712
|
+
if (event.source === window && _optionalChain([event, 'access', _93 => _93.data, 'optionalAccess', _94 => _94.source]) === "liveblocks-devtools-panel") {
|
|
4694
4713
|
eventSource.notify(event.data);
|
|
4695
4714
|
} else {
|
|
4696
4715
|
}
|
|
@@ -4832,7 +4851,7 @@ function fullSync(room) {
|
|
|
4832
4851
|
msg: "room::sync::full",
|
|
4833
4852
|
roomId: room.id,
|
|
4834
4853
|
status: room.getStatus(),
|
|
4835
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
4854
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _95 => _95.toTreeNode, 'call', _96 => _96("root"), 'access', _97 => _97.payload]), () => ( null)),
|
|
4836
4855
|
me,
|
|
4837
4856
|
others
|
|
4838
4857
|
});
|
|
@@ -5123,7 +5142,7 @@ function createManagedPool(roomId, options) {
|
|
|
5123
5142
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
5124
5143
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
5125
5144
|
dispatch(ops, reverse, storageUpdates) {
|
|
5126
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
5145
|
+
_optionalChain([onDispatch, 'optionalCall', _98 => _98(ops, reverse, storageUpdates)]);
|
|
5127
5146
|
},
|
|
5128
5147
|
assertStorageIsWritable: () => {
|
|
5129
5148
|
if (!isStorageWritable()) {
|
|
@@ -5350,7 +5369,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
5350
5369
|
return [
|
|
5351
5370
|
{
|
|
5352
5371
|
type: 8 /* CREATE_REGISTER */,
|
|
5353
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5372
|
+
opId: _optionalChain([pool, 'optionalAccess', _99 => _99.generateOpId, 'call', _100 => _100()]),
|
|
5354
5373
|
id: this._id,
|
|
5355
5374
|
parentId,
|
|
5356
5375
|
parentKey,
|
|
@@ -5456,7 +5475,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5456
5475
|
const ops = [];
|
|
5457
5476
|
const op = {
|
|
5458
5477
|
id: this._id,
|
|
5459
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5478
|
+
opId: _optionalChain([pool, 'optionalAccess', _101 => _101.generateOpId, 'call', _102 => _102()]),
|
|
5460
5479
|
type: 2 /* CREATE_LIST */,
|
|
5461
5480
|
parentId,
|
|
5462
5481
|
parentKey
|
|
@@ -5727,7 +5746,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5727
5746
|
#applyInsertUndoRedo(op) {
|
|
5728
5747
|
const { id, parentKey: key } = op;
|
|
5729
5748
|
const child = creationOpToLiveNode(op);
|
|
5730
|
-
if (_optionalChain([this, 'access',
|
|
5749
|
+
if (_optionalChain([this, 'access', _103 => _103._pool, 'optionalAccess', _104 => _104.getNode, 'call', _105 => _105(id)]) !== void 0) {
|
|
5731
5750
|
return { modified: false };
|
|
5732
5751
|
}
|
|
5733
5752
|
child._attach(id, nn(this._pool));
|
|
@@ -5735,8 +5754,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5735
5754
|
const existingItemIndex = this._indexOfPosition(key);
|
|
5736
5755
|
let newKey = key;
|
|
5737
5756
|
if (existingItemIndex !== -1) {
|
|
5738
|
-
const before2 = _optionalChain([this, 'access',
|
|
5739
|
-
const after2 = _optionalChain([this, 'access',
|
|
5757
|
+
const before2 = _optionalChain([this, 'access', _106 => _106.#items, 'access', _107 => _107[existingItemIndex], 'optionalAccess', _108 => _108._parentPos]);
|
|
5758
|
+
const after2 = _optionalChain([this, 'access', _109 => _109.#items, 'access', _110 => _110[existingItemIndex + 1], 'optionalAccess', _111 => _111._parentPos]);
|
|
5740
5759
|
newKey = makePosition(before2, after2);
|
|
5741
5760
|
child._setParentLink(this, newKey);
|
|
5742
5761
|
}
|
|
@@ -5750,7 +5769,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5750
5769
|
#applySetUndoRedo(op) {
|
|
5751
5770
|
const { id, parentKey: key } = op;
|
|
5752
5771
|
const child = creationOpToLiveNode(op);
|
|
5753
|
-
if (_optionalChain([this, 'access',
|
|
5772
|
+
if (_optionalChain([this, 'access', _112 => _112._pool, 'optionalAccess', _113 => _113.getNode, 'call', _114 => _114(id)]) !== void 0) {
|
|
5754
5773
|
return { modified: false };
|
|
5755
5774
|
}
|
|
5756
5775
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -5871,7 +5890,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5871
5890
|
} else {
|
|
5872
5891
|
this.#items[existingItemIndex]._setParentLink(
|
|
5873
5892
|
this,
|
|
5874
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5893
|
+
makePosition(newKey, _optionalChain([this, 'access', _115 => _115.#items, 'access', _116 => _116[existingItemIndex + 1], 'optionalAccess', _117 => _117._parentPos]))
|
|
5875
5894
|
);
|
|
5876
5895
|
const previousIndex = this.#items.indexOf(child);
|
|
5877
5896
|
child._setParentLink(this, newKey);
|
|
@@ -5896,7 +5915,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5896
5915
|
if (existingItemIndex !== -1) {
|
|
5897
5916
|
this.#items[existingItemIndex]._setParentLink(
|
|
5898
5917
|
this,
|
|
5899
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5918
|
+
makePosition(newKey, _optionalChain([this, 'access', _118 => _118.#items, 'access', _119 => _119[existingItemIndex + 1], 'optionalAccess', _120 => _120._parentPos]))
|
|
5900
5919
|
);
|
|
5901
5920
|
}
|
|
5902
5921
|
child._setParentLink(this, newKey);
|
|
@@ -5915,7 +5934,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5915
5934
|
if (existingItemIndex !== -1) {
|
|
5916
5935
|
this.#items[existingItemIndex]._setParentLink(
|
|
5917
5936
|
this,
|
|
5918
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5937
|
+
makePosition(newKey, _optionalChain([this, 'access', _121 => _121.#items, 'access', _122 => _122[existingItemIndex + 1], 'optionalAccess', _123 => _123._parentPos]))
|
|
5919
5938
|
);
|
|
5920
5939
|
}
|
|
5921
5940
|
child._setParentLink(this, newKey);
|
|
@@ -5942,7 +5961,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5942
5961
|
if (existingItemIndex !== -1) {
|
|
5943
5962
|
this.#items[existingItemIndex]._setParentLink(
|
|
5944
5963
|
this,
|
|
5945
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5964
|
+
makePosition(newKey, _optionalChain([this, 'access', _124 => _124.#items, 'access', _125 => _125[existingItemIndex + 1], 'optionalAccess', _126 => _126._parentPos]))
|
|
5946
5965
|
);
|
|
5947
5966
|
}
|
|
5948
5967
|
child._setParentLink(this, newKey);
|
|
@@ -6000,7 +6019,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6000
6019
|
* @param element The element to add to the end of the LiveList.
|
|
6001
6020
|
*/
|
|
6002
6021
|
push(element) {
|
|
6003
|
-
_optionalChain([this, 'access',
|
|
6022
|
+
_optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
|
|
6004
6023
|
return this.insert(element, this.length);
|
|
6005
6024
|
}
|
|
6006
6025
|
/**
|
|
@@ -6009,7 +6028,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6009
6028
|
* @param index The index at which you want to insert the element.
|
|
6010
6029
|
*/
|
|
6011
6030
|
insert(element, index) {
|
|
6012
|
-
_optionalChain([this, 'access',
|
|
6031
|
+
_optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.assertStorageIsWritable, 'call', _132 => _132()]);
|
|
6013
6032
|
if (index < 0 || index > this.#items.length) {
|
|
6014
6033
|
throw new Error(
|
|
6015
6034
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -6039,7 +6058,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6039
6058
|
* @param targetIndex The index where the element should be after moving.
|
|
6040
6059
|
*/
|
|
6041
6060
|
move(index, targetIndex) {
|
|
6042
|
-
_optionalChain([this, 'access',
|
|
6061
|
+
_optionalChain([this, 'access', _133 => _133._pool, 'optionalAccess', _134 => _134.assertStorageIsWritable, 'call', _135 => _135()]);
|
|
6043
6062
|
if (targetIndex < 0) {
|
|
6044
6063
|
throw new Error("targetIndex cannot be less than 0");
|
|
6045
6064
|
}
|
|
@@ -6097,7 +6116,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6097
6116
|
* @param index The index of the element to delete
|
|
6098
6117
|
*/
|
|
6099
6118
|
delete(index) {
|
|
6100
|
-
_optionalChain([this, 'access',
|
|
6119
|
+
_optionalChain([this, 'access', _136 => _136._pool, 'optionalAccess', _137 => _137.assertStorageIsWritable, 'call', _138 => _138()]);
|
|
6101
6120
|
if (index < 0 || index >= this.#items.length) {
|
|
6102
6121
|
throw new Error(
|
|
6103
6122
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6130,7 +6149,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6130
6149
|
}
|
|
6131
6150
|
}
|
|
6132
6151
|
clear() {
|
|
6133
|
-
_optionalChain([this, 'access',
|
|
6152
|
+
_optionalChain([this, 'access', _139 => _139._pool, 'optionalAccess', _140 => _140.assertStorageIsWritable, 'call', _141 => _141()]);
|
|
6134
6153
|
if (this._pool) {
|
|
6135
6154
|
const ops = [];
|
|
6136
6155
|
const reverseOps = [];
|
|
@@ -6164,7 +6183,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6164
6183
|
}
|
|
6165
6184
|
}
|
|
6166
6185
|
set(index, item) {
|
|
6167
|
-
_optionalChain([this, 'access',
|
|
6186
|
+
_optionalChain([this, 'access', _142 => _142._pool, 'optionalAccess', _143 => _143.assertStorageIsWritable, 'call', _144 => _144()]);
|
|
6168
6187
|
if (index < 0 || index >= this.#items.length) {
|
|
6169
6188
|
throw new Error(
|
|
6170
6189
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6310,7 +6329,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6310
6329
|
#shiftItemPosition(index, key) {
|
|
6311
6330
|
const shiftedPosition = makePosition(
|
|
6312
6331
|
key,
|
|
6313
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
6332
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _145 => _145.#items, 'access', _146 => _146[index + 1], 'optionalAccess', _147 => _147._parentPos]) : void 0
|
|
6314
6333
|
);
|
|
6315
6334
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
6316
6335
|
}
|
|
@@ -6435,7 +6454,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6435
6454
|
const ops = [];
|
|
6436
6455
|
const op = {
|
|
6437
6456
|
id: this._id,
|
|
6438
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6457
|
+
opId: _optionalChain([pool, 'optionalAccess', _148 => _148.generateOpId, 'call', _149 => _149()]),
|
|
6439
6458
|
type: 7 /* CREATE_MAP */,
|
|
6440
6459
|
parentId,
|
|
6441
6460
|
parentKey
|
|
@@ -6570,7 +6589,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6570
6589
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
6571
6590
|
*/
|
|
6572
6591
|
set(key, value) {
|
|
6573
|
-
_optionalChain([this, 'access',
|
|
6592
|
+
_optionalChain([this, 'access', _150 => _150._pool, 'optionalAccess', _151 => _151.assertStorageIsWritable, 'call', _152 => _152()]);
|
|
6574
6593
|
const oldValue = this.#map.get(key);
|
|
6575
6594
|
if (oldValue) {
|
|
6576
6595
|
oldValue._detach();
|
|
@@ -6616,7 +6635,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6616
6635
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
6617
6636
|
*/
|
|
6618
6637
|
delete(key) {
|
|
6619
|
-
_optionalChain([this, 'access',
|
|
6638
|
+
_optionalChain([this, 'access', _153 => _153._pool, 'optionalAccess', _154 => _154.assertStorageIsWritable, 'call', _155 => _155()]);
|
|
6620
6639
|
const item = this.#map.get(key);
|
|
6621
6640
|
if (item === void 0) {
|
|
6622
6641
|
return false;
|
|
@@ -6795,7 +6814,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
6795
6814
|
if (this._id === void 0) {
|
|
6796
6815
|
throw new Error("Cannot serialize item is not attached");
|
|
6797
6816
|
}
|
|
6798
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
6817
|
+
const opId = _optionalChain([pool, 'optionalAccess', _156 => _156.generateOpId, 'call', _157 => _157()]);
|
|
6799
6818
|
const ops = [];
|
|
6800
6819
|
const op = {
|
|
6801
6820
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -7067,7 +7086,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7067
7086
|
* @param value The value of the property to add
|
|
7068
7087
|
*/
|
|
7069
7088
|
set(key, value) {
|
|
7070
|
-
_optionalChain([this, 'access',
|
|
7089
|
+
_optionalChain([this, 'access', _158 => _158._pool, 'optionalAccess', _159 => _159.assertStorageIsWritable, 'call', _160 => _160()]);
|
|
7071
7090
|
this.update({ [key]: value });
|
|
7072
7091
|
}
|
|
7073
7092
|
/**
|
|
@@ -7082,7 +7101,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7082
7101
|
* @param key The key of the property to delete
|
|
7083
7102
|
*/
|
|
7084
7103
|
delete(key) {
|
|
7085
|
-
_optionalChain([this, 'access',
|
|
7104
|
+
_optionalChain([this, 'access', _161 => _161._pool, 'optionalAccess', _162 => _162.assertStorageIsWritable, 'call', _163 => _163()]);
|
|
7086
7105
|
const keyAsString = key;
|
|
7087
7106
|
const oldValue = this.#map.get(keyAsString);
|
|
7088
7107
|
if (oldValue === void 0) {
|
|
@@ -7135,7 +7154,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7135
7154
|
* @param patch The object used to overrides properties
|
|
7136
7155
|
*/
|
|
7137
7156
|
update(patch) {
|
|
7138
|
-
_optionalChain([this, 'access',
|
|
7157
|
+
_optionalChain([this, 'access', _164 => _164._pool, 'optionalAccess', _165 => _165.assertStorageIsWritable, 'call', _166 => _166()]);
|
|
7139
7158
|
if (this._pool === void 0 || this._id === void 0) {
|
|
7140
7159
|
for (const key in patch) {
|
|
7141
7160
|
const newValue = patch[key];
|
|
@@ -7858,15 +7877,15 @@ function installBackgroundTabSpy() {
|
|
|
7858
7877
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
7859
7878
|
const inBackgroundSince = { current: null };
|
|
7860
7879
|
function onVisibilityChange() {
|
|
7861
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
7880
|
+
if (_optionalChain([doc, 'optionalAccess', _167 => _167.visibilityState]) === "hidden") {
|
|
7862
7881
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
7863
7882
|
} else {
|
|
7864
7883
|
inBackgroundSince.current = null;
|
|
7865
7884
|
}
|
|
7866
7885
|
}
|
|
7867
|
-
_optionalChain([doc, 'optionalAccess',
|
|
7886
|
+
_optionalChain([doc, 'optionalAccess', _168 => _168.addEventListener, 'call', _169 => _169("visibilitychange", onVisibilityChange)]);
|
|
7868
7887
|
const unsub = () => {
|
|
7869
|
-
_optionalChain([doc, 'optionalAccess',
|
|
7888
|
+
_optionalChain([doc, 'optionalAccess', _170 => _170.removeEventListener, 'call', _171 => _171("visibilitychange", onVisibilityChange)]);
|
|
7870
7889
|
};
|
|
7871
7890
|
return [inBackgroundSince, unsub];
|
|
7872
7891
|
}
|
|
@@ -8046,7 +8065,7 @@ function createRoom(options, config) {
|
|
|
8046
8065
|
}
|
|
8047
8066
|
}
|
|
8048
8067
|
function isStorageWritable() {
|
|
8049
|
-
const scopes = _optionalChain([context, 'access',
|
|
8068
|
+
const scopes = _optionalChain([context, 'access', _172 => _172.dynamicSessionInfoSig, 'access', _173 => _173.get, 'call', _174 => _174(), 'optionalAccess', _175 => _175.scopes]);
|
|
8050
8069
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
8051
8070
|
}
|
|
8052
8071
|
const eventHub = {
|
|
@@ -8163,7 +8182,7 @@ function createRoom(options, config) {
|
|
|
8163
8182
|
}
|
|
8164
8183
|
case "experimental-fallback-to-http": {
|
|
8165
8184
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8166
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
8185
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _176 => _176.dynamicSessionInfoSig, 'access', _177 => _177.get, 'call', _178 => _178(), 'optionalAccess', _179 => _179.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
8167
8186
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
8168
8187
|
if (!resp.ok && resp.status === 403) {
|
|
8169
8188
|
managedSocket.reconnect();
|
|
@@ -8214,7 +8233,7 @@ function createRoom(options, config) {
|
|
|
8214
8233
|
} else {
|
|
8215
8234
|
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
8216
8235
|
}
|
|
8217
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
8236
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _180 => _180.get, 'call', _181 => _181(), 'optionalAccess', _182 => _182.canWrite]), () => ( true));
|
|
8218
8237
|
const stackSizeBefore = context.undoStack.length;
|
|
8219
8238
|
for (const key in context.initialStorage) {
|
|
8220
8239
|
if (context.root.get(key) === void 0) {
|
|
@@ -8417,7 +8436,7 @@ function createRoom(options, config) {
|
|
|
8417
8436
|
}
|
|
8418
8437
|
context.myPresence.patch(patch);
|
|
8419
8438
|
if (context.activeBatch) {
|
|
8420
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8439
|
+
if (_optionalChain([options2, 'optionalAccess', _183 => _183.addToHistory])) {
|
|
8421
8440
|
context.activeBatch.reverseOps.pushLeft({
|
|
8422
8441
|
type: "presence",
|
|
8423
8442
|
data: oldValues
|
|
@@ -8426,7 +8445,7 @@ function createRoom(options, config) {
|
|
|
8426
8445
|
context.activeBatch.updates.presence = true;
|
|
8427
8446
|
} else {
|
|
8428
8447
|
flushNowOrSoon();
|
|
8429
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8448
|
+
if (_optionalChain([options2, 'optionalAccess', _184 => _184.addToHistory])) {
|
|
8430
8449
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
8431
8450
|
}
|
|
8432
8451
|
notify({ presence: true });
|
|
@@ -8623,7 +8642,7 @@ function createRoom(options, config) {
|
|
|
8623
8642
|
if (process.env.NODE_ENV !== "production") {
|
|
8624
8643
|
const traces = /* @__PURE__ */ new Set();
|
|
8625
8644
|
for (const opId of message.opIds) {
|
|
8626
|
-
const trace = _optionalChain([context, 'access',
|
|
8645
|
+
const trace = _optionalChain([context, 'access', _185 => _185.opStackTraces, 'optionalAccess', _186 => _186.get, 'call', _187 => _187(opId)]);
|
|
8627
8646
|
if (trace) {
|
|
8628
8647
|
traces.add(trace);
|
|
8629
8648
|
}
|
|
@@ -8757,7 +8776,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
8757
8776
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
8758
8777
|
createOrUpdateRootFromMessage(message);
|
|
8759
8778
|
applyAndSendOps(unacknowledgedOps);
|
|
8760
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
8779
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _188 => _188()]);
|
|
8761
8780
|
notifyStorageStatus();
|
|
8762
8781
|
eventHub.storageDidLoad.notify();
|
|
8763
8782
|
}
|
|
@@ -8980,8 +8999,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
8980
8999
|
async function getThreads(options2) {
|
|
8981
9000
|
return httpClient.getThreads({
|
|
8982
9001
|
roomId,
|
|
8983
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
8984
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9002
|
+
query: _optionalChain([options2, 'optionalAccess', _189 => _189.query]),
|
|
9003
|
+
cursor: _optionalChain([options2, 'optionalAccess', _190 => _190.cursor])
|
|
8985
9004
|
});
|
|
8986
9005
|
}
|
|
8987
9006
|
async function getThread(threadId) {
|
|
@@ -9088,7 +9107,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9088
9107
|
function getSubscriptionSettings(options2) {
|
|
9089
9108
|
return httpClient.getSubscriptionSettings({
|
|
9090
9109
|
roomId,
|
|
9091
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9110
|
+
signal: _optionalChain([options2, 'optionalAccess', _191 => _191.signal])
|
|
9092
9111
|
});
|
|
9093
9112
|
}
|
|
9094
9113
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9110,7 +9129,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9110
9129
|
{
|
|
9111
9130
|
[kInternal]: {
|
|
9112
9131
|
get presenceBuffer() {
|
|
9113
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9132
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _192 => _192.buffer, 'access', _193 => _193.presenceUpdates, 'optionalAccess', _194 => _194.data]), () => ( null)));
|
|
9114
9133
|
},
|
|
9115
9134
|
// prettier-ignore
|
|
9116
9135
|
get undoStack() {
|
|
@@ -9125,9 +9144,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9125
9144
|
return context.yjsProvider;
|
|
9126
9145
|
},
|
|
9127
9146
|
setYjsProvider(newProvider) {
|
|
9128
|
-
_optionalChain([context, 'access',
|
|
9147
|
+
_optionalChain([context, 'access', _195 => _195.yjsProvider, 'optionalAccess', _196 => _196.off, 'call', _197 => _197("status", yjsStatusDidChange)]);
|
|
9129
9148
|
context.yjsProvider = newProvider;
|
|
9130
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9149
|
+
_optionalChain([newProvider, 'optionalAccess', _198 => _198.on, 'call', _199 => _199("status", yjsStatusDidChange)]);
|
|
9131
9150
|
context.yjsProviderDidChange.notify();
|
|
9132
9151
|
},
|
|
9133
9152
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9173,7 +9192,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9173
9192
|
source.dispose();
|
|
9174
9193
|
}
|
|
9175
9194
|
eventHub.roomWillDestroy.notify();
|
|
9176
|
-
_optionalChain([context, 'access',
|
|
9195
|
+
_optionalChain([context, 'access', _200 => _200.yjsProvider, 'optionalAccess', _201 => _201.off, 'call', _202 => _202("status", yjsStatusDidChange)]);
|
|
9177
9196
|
syncSourceForStorage.destroy();
|
|
9178
9197
|
syncSourceForYjs.destroy();
|
|
9179
9198
|
uninstallBgTabSpy();
|
|
@@ -9323,7 +9342,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9323
9342
|
}
|
|
9324
9343
|
if (isLiveNode(first)) {
|
|
9325
9344
|
const node = first;
|
|
9326
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9345
|
+
if (_optionalChain([options, 'optionalAccess', _203 => _203.isDeep])) {
|
|
9327
9346
|
const storageCallback = second;
|
|
9328
9347
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9329
9348
|
} else {
|
|
@@ -9402,8 +9421,8 @@ function createClient(options) {
|
|
|
9402
9421
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
9403
9422
|
currentUserId.set(() => userId);
|
|
9404
9423
|
});
|
|
9405
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
9406
|
-
_optionalChain([globalThis, 'access',
|
|
9424
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _204 => _204.polyfills, 'optionalAccess', _205 => _205.fetch]) || /* istanbul ignore next */
|
|
9425
|
+
_optionalChain([globalThis, 'access', _206 => _206.fetch, 'optionalAccess', _207 => _207.bind, 'call', _208 => _208(globalThis)]);
|
|
9407
9426
|
const httpClient = createApiClient({
|
|
9408
9427
|
baseUrl,
|
|
9409
9428
|
fetchPolyfill,
|
|
@@ -9421,7 +9440,7 @@ function createClient(options) {
|
|
|
9421
9440
|
delegates: {
|
|
9422
9441
|
createSocket: makeCreateSocketDelegateForAi(
|
|
9423
9442
|
baseUrl,
|
|
9424
|
-
_optionalChain([clientOptions, 'access',
|
|
9443
|
+
_optionalChain([clientOptions, 'access', _209 => _209.polyfills, 'optionalAccess', _210 => _210.WebSocket])
|
|
9425
9444
|
),
|
|
9426
9445
|
authenticate: makeAuthDelegateForRoom("default", authManager),
|
|
9427
9446
|
canZombie: () => true
|
|
@@ -9471,7 +9490,7 @@ function createClient(options) {
|
|
|
9471
9490
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
9472
9491
|
roomId,
|
|
9473
9492
|
baseUrl,
|
|
9474
|
-
_optionalChain([clientOptions, 'access',
|
|
9493
|
+
_optionalChain([clientOptions, 'access', _211 => _211.polyfills, 'optionalAccess', _212 => _212.WebSocket])
|
|
9475
9494
|
),
|
|
9476
9495
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
9477
9496
|
})),
|
|
@@ -9494,7 +9513,7 @@ function createClient(options) {
|
|
|
9494
9513
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
9495
9514
|
if (shouldConnect) {
|
|
9496
9515
|
if (typeof atob === "undefined") {
|
|
9497
|
-
if (_optionalChain([clientOptions, 'access',
|
|
9516
|
+
if (_optionalChain([clientOptions, 'access', _213 => _213.polyfills, 'optionalAccess', _214 => _214.atob]) === void 0) {
|
|
9498
9517
|
throw new Error(
|
|
9499
9518
|
"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"
|
|
9500
9519
|
);
|
|
@@ -9506,7 +9525,7 @@ function createClient(options) {
|
|
|
9506
9525
|
return leaseRoom(newRoomDetails);
|
|
9507
9526
|
}
|
|
9508
9527
|
function getRoom(roomId) {
|
|
9509
|
-
const room = _optionalChain([roomsById, 'access',
|
|
9528
|
+
const room = _optionalChain([roomsById, 'access', _215 => _215.get, 'call', _216 => _216(roomId), 'optionalAccess', _217 => _217.room]);
|
|
9510
9529
|
return room ? room : null;
|
|
9511
9530
|
}
|
|
9512
9531
|
function logout() {
|
|
@@ -9526,7 +9545,7 @@ function createClient(options) {
|
|
|
9526
9545
|
const batchedResolveUsers = new Batch(
|
|
9527
9546
|
async (batchedUserIds) => {
|
|
9528
9547
|
const userIds = batchedUserIds.flat();
|
|
9529
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
9548
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _218 => _218({ userIds })]);
|
|
9530
9549
|
warnIfNoResolveUsers();
|
|
9531
9550
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
9532
9551
|
},
|
|
@@ -9544,7 +9563,7 @@ function createClient(options) {
|
|
|
9544
9563
|
const batchedResolveRoomsInfo = new Batch(
|
|
9545
9564
|
async (batchedRoomIds) => {
|
|
9546
9565
|
const roomIds = batchedRoomIds.flat();
|
|
9547
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
9566
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _219 => _219({ roomIds })]);
|
|
9548
9567
|
warnIfNoResolveRoomsInfo();
|
|
9549
9568
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
9550
9569
|
},
|
|
@@ -9597,7 +9616,7 @@ function createClient(options) {
|
|
|
9597
9616
|
}
|
|
9598
9617
|
};
|
|
9599
9618
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
9600
|
-
_optionalChain([win, 'optionalAccess',
|
|
9619
|
+
_optionalChain([win, 'optionalAccess', _220 => _220.addEventListener, 'call', _221 => _221("beforeunload", maybePreventClose)]);
|
|
9601
9620
|
}
|
|
9602
9621
|
async function getNotificationSettings(options2) {
|
|
9603
9622
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -9736,7 +9755,7 @@ var commentBodyElementsTypes = {
|
|
|
9736
9755
|
mention: "inline"
|
|
9737
9756
|
};
|
|
9738
9757
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
9739
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
9758
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _222 => _222.content])) {
|
|
9740
9759
|
return;
|
|
9741
9760
|
}
|
|
9742
9761
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -9746,13 +9765,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
9746
9765
|
for (const block of body.content) {
|
|
9747
9766
|
if (type === "all" || type === "block") {
|
|
9748
9767
|
if (guard(block)) {
|
|
9749
|
-
_optionalChain([visitor, 'optionalCall',
|
|
9768
|
+
_optionalChain([visitor, 'optionalCall', _223 => _223(block)]);
|
|
9750
9769
|
}
|
|
9751
9770
|
}
|
|
9752
9771
|
if (type === "all" || type === "inline") {
|
|
9753
9772
|
for (const inline of block.children) {
|
|
9754
9773
|
if (guard(inline)) {
|
|
9755
|
-
_optionalChain([visitor, 'optionalCall',
|
|
9774
|
+
_optionalChain([visitor, 'optionalCall', _224 => _224(inline)]);
|
|
9756
9775
|
}
|
|
9757
9776
|
}
|
|
9758
9777
|
}
|
|
@@ -9777,7 +9796,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
9777
9796
|
userIds
|
|
9778
9797
|
});
|
|
9779
9798
|
for (const [index, userId] of userIds.entries()) {
|
|
9780
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
9799
|
+
const user = _optionalChain([users, 'optionalAccess', _225 => _225[index]]);
|
|
9781
9800
|
if (user) {
|
|
9782
9801
|
resolvedUsers.set(userId, user);
|
|
9783
9802
|
}
|
|
@@ -9904,7 +9923,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
9904
9923
|
text: ({ element }) => element.text,
|
|
9905
9924
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
9906
9925
|
mention: ({ element, user }) => {
|
|
9907
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
9926
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _226 => _226.name]), () => ( element.id))}`;
|
|
9908
9927
|
}
|
|
9909
9928
|
};
|
|
9910
9929
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -9934,7 +9953,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
9934
9953
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
9935
9954
|
},
|
|
9936
9955
|
mention: ({ element, user }) => {
|
|
9937
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
9956
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _227 => _227.name]) ? html`${_optionalChain([user, 'optionalAccess', _228 => _228.name])}` : element.id}</span>`;
|
|
9938
9957
|
}
|
|
9939
9958
|
};
|
|
9940
9959
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -9964,19 +9983,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
9964
9983
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
9965
9984
|
},
|
|
9966
9985
|
mention: ({ element, user }) => {
|
|
9967
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
9986
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _229 => _229.name]), () => ( element.id))}`;
|
|
9968
9987
|
}
|
|
9969
9988
|
};
|
|
9970
9989
|
async function stringifyCommentBody(body, options) {
|
|
9971
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9972
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9990
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.format]), () => ( "plain"));
|
|
9991
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _231 => _231.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
9973
9992
|
const elements = {
|
|
9974
9993
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
9975
|
-
..._optionalChain([options, 'optionalAccess',
|
|
9994
|
+
..._optionalChain([options, 'optionalAccess', _232 => _232.elements])
|
|
9976
9995
|
};
|
|
9977
9996
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
9978
9997
|
body,
|
|
9979
|
-
_optionalChain([options, 'optionalAccess',
|
|
9998
|
+
_optionalChain([options, 'optionalAccess', _233 => _233.resolveUsers])
|
|
9980
9999
|
);
|
|
9981
10000
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
9982
10001
|
switch (block.type) {
|
|
@@ -10267,12 +10286,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10267
10286
|
}
|
|
10268
10287
|
const newState = Object.assign({}, state);
|
|
10269
10288
|
for (const key in update.updates) {
|
|
10270
|
-
if (_optionalChain([update, 'access',
|
|
10289
|
+
if (_optionalChain([update, 'access', _234 => _234.updates, 'access', _235 => _235[key], 'optionalAccess', _236 => _236.type]) === "update") {
|
|
10271
10290
|
const val = update.node.get(key);
|
|
10272
10291
|
if (val !== void 0) {
|
|
10273
10292
|
newState[key] = lsonToJson(val);
|
|
10274
10293
|
}
|
|
10275
|
-
} else if (_optionalChain([update, 'access',
|
|
10294
|
+
} else if (_optionalChain([update, 'access', _237 => _237.updates, 'access', _238 => _238[key], 'optionalAccess', _239 => _239.type]) === "delete") {
|
|
10276
10295
|
delete newState[key];
|
|
10277
10296
|
}
|
|
10278
10297
|
}
|
|
@@ -10333,12 +10352,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10333
10352
|
}
|
|
10334
10353
|
const newState = Object.assign({}, state);
|
|
10335
10354
|
for (const key in update.updates) {
|
|
10336
|
-
if (_optionalChain([update, 'access',
|
|
10355
|
+
if (_optionalChain([update, 'access', _240 => _240.updates, 'access', _241 => _241[key], 'optionalAccess', _242 => _242.type]) === "update") {
|
|
10337
10356
|
const value = update.node.get(key);
|
|
10338
10357
|
if (value !== void 0) {
|
|
10339
10358
|
newState[key] = lsonToJson(value);
|
|
10340
10359
|
}
|
|
10341
|
-
} else if (_optionalChain([update, 'access',
|
|
10360
|
+
} else if (_optionalChain([update, 'access', _243 => _243.updates, 'access', _244 => _244[key], 'optionalAccess', _245 => _245.type]) === "delete") {
|
|
10342
10361
|
delete newState[key];
|
|
10343
10362
|
}
|
|
10344
10363
|
}
|
|
@@ -10418,9 +10437,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10418
10437
|
const startTime = performance.now();
|
|
10419
10438
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10420
10439
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10421
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10440
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
10422
10441
|
const context = {
|
|
10423
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
10442
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _247 => _247.visibilityState]) !== "hidden",
|
|
10424
10443
|
lastSuccessfulPollAt: startTime,
|
|
10425
10444
|
count: 0,
|
|
10426
10445
|
backoff: 0
|
|
@@ -10501,11 +10520,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10501
10520
|
pollNowIfStale();
|
|
10502
10521
|
}
|
|
10503
10522
|
function onVisibilityChange() {
|
|
10504
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
10523
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _248 => _248.visibilityState]) !== "hidden");
|
|
10505
10524
|
}
|
|
10506
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10507
|
-
_optionalChain([win, 'optionalAccess',
|
|
10508
|
-
_optionalChain([win, 'optionalAccess',
|
|
10525
|
+
_optionalChain([doc, 'optionalAccess', _249 => _249.addEventListener, 'call', _250 => _250("visibilitychange", onVisibilityChange)]);
|
|
10526
|
+
_optionalChain([win, 'optionalAccess', _251 => _251.addEventListener, 'call', _252 => _252("online", onVisibilityChange)]);
|
|
10527
|
+
_optionalChain([win, 'optionalAccess', _253 => _253.addEventListener, 'call', _254 => _254("focus", pollNowIfStale)]);
|
|
10509
10528
|
fsm.start();
|
|
10510
10529
|
return {
|
|
10511
10530
|
inc,
|