@liveblocks/core 2.25.0-aiprivatebeta9 → 3.0.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 +261 -217
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +165 -175
- package/dist/index.d.ts +165 -175
- package/dist/index.js +172 -128
- 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 = "
|
|
9
|
+
var PKG_VERSION = "3.0.0";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3780,50 +3780,66 @@ 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
|
-
function createStore_forChatMessages(toolsStore,
|
|
3826
|
-
const
|
|
3840
|
+
function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
3841
|
+
const myMessages = /* @__PURE__ */ new Set();
|
|
3842
|
+
const handledInvocations = /* @__PURE__ */ new Set();
|
|
3827
3843
|
const messagePoolByChatId\u03A3 = new DefaultMap(
|
|
3828
3844
|
(_chatId) => new MutableSignal(
|
|
3829
3845
|
new TreePool(
|
|
@@ -3901,42 +3917,39 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
|
3901
3917
|
});
|
|
3902
3918
|
}
|
|
3903
3919
|
if (message.role === "assistant" && message.status === "awaiting-tool") {
|
|
3904
|
-
|
|
3905
|
-
(
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3920
|
+
if (myMessages.has(message.id)) {
|
|
3921
|
+
for (const toolInvocation of message.contentSoFar.filter(
|
|
3922
|
+
(part) => part.type === "tool-invocation" && part.stage === "executing"
|
|
3923
|
+
)) {
|
|
3924
|
+
if (!handledInvocations.has(toolInvocation.invocationId)) {
|
|
3925
|
+
handledInvocations.add(toolInvocation.invocationId);
|
|
3926
|
+
} else {
|
|
3927
|
+
continue;
|
|
3928
|
+
}
|
|
3929
|
+
const executeFn = _optionalChain([toolsStore, 'access', _73 => _73.getTool\u03A3, 'call', _74 => _74(toolInvocation.name, message.chatId), 'access', _75 => _75.get, 'call', _76 => _76(), 'optionalAccess', _77 => _77.execute]);
|
|
3930
|
+
if (executeFn) {
|
|
3931
|
+
(async () => {
|
|
3932
|
+
const result = await executeFn(toolInvocation.args, {
|
|
3933
|
+
name: toolInvocation.name,
|
|
3934
|
+
invocationId: toolInvocation.invocationId
|
|
3935
|
+
});
|
|
3936
|
+
return await setToolResultFn(
|
|
3937
|
+
message.chatId,
|
|
3938
|
+
message.id,
|
|
3939
|
+
toolInvocation.invocationId,
|
|
3940
|
+
_nullishCoalesce(result, () => ( { data: {} }))
|
|
3941
|
+
// TODO Pass in AiGenerationOptions here, or make the backend use the same options
|
|
3942
|
+
);
|
|
3943
|
+
})().catch((err) => {
|
|
3944
|
+
error2(
|
|
3945
|
+
`Error trying to respond to tool-call: ${String(err)} (in execute())`
|
|
3946
|
+
);
|
|
3931
3947
|
});
|
|
3932
|
-
|
|
3933
|
-
})().catch((err) => {
|
|
3934
|
-
error2(
|
|
3935
|
-
`Error trying to respond to tool-call: ${String(err)} (in execute())`
|
|
3936
|
-
);
|
|
3937
|
-
});
|
|
3948
|
+
}
|
|
3938
3949
|
}
|
|
3939
3950
|
}
|
|
3951
|
+
} else {
|
|
3952
|
+
myMessages.delete(message.id);
|
|
3940
3953
|
}
|
|
3941
3954
|
});
|
|
3942
3955
|
}
|
|
@@ -4008,8 +4021,8 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
|
4008
4021
|
const spine = [];
|
|
4009
4022
|
let lastVisitedMessage = null;
|
|
4010
4023
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4011
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4012
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4024
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _78 => _78(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _79 => _79.id]), () => ( null));
|
|
4025
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _80 => _80(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _81 => _81.id]), () => ( null));
|
|
4013
4026
|
if (!message2.deletedAt || prev || next) {
|
|
4014
4027
|
const node = {
|
|
4015
4028
|
...message2,
|
|
@@ -4081,20 +4094,23 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
|
|
|
4081
4094
|
remove,
|
|
4082
4095
|
removeByChatId,
|
|
4083
4096
|
addDelta,
|
|
4084
|
-
failAllPending
|
|
4097
|
+
failAllPending,
|
|
4098
|
+
markMine(messageId) {
|
|
4099
|
+
myMessages.add(messageId);
|
|
4100
|
+
}
|
|
4085
4101
|
};
|
|
4086
4102
|
}
|
|
4087
4103
|
function createStore_forUserAiChats() {
|
|
4088
|
-
const
|
|
4104
|
+
const allChatsInclDeleted\u03A3 = new MutableSignal(
|
|
4089
4105
|
SortedList.with((x, y) => y.createdAt < x.createdAt)
|
|
4090
4106
|
);
|
|
4091
|
-
const
|
|
4092
|
-
() => Array.from(
|
|
4107
|
+
const nonDeletedChats\u03A3 = DerivedSignal.from(
|
|
4108
|
+
() => Array.from(allChatsInclDeleted\u03A3.get()).filter((c) => !c.deletedAt)
|
|
4093
4109
|
);
|
|
4094
4110
|
function upsertMany(chats) {
|
|
4095
|
-
|
|
4111
|
+
allChatsInclDeleted\u03A3.mutate((list) => {
|
|
4096
4112
|
for (const chat of chats) {
|
|
4097
|
-
|
|
4113
|
+
list.removeBy((c) => c.id === chat.id, 1);
|
|
4098
4114
|
list.add(chat);
|
|
4099
4115
|
}
|
|
4100
4116
|
});
|
|
@@ -4102,19 +4118,26 @@ function createStore_forUserAiChats() {
|
|
|
4102
4118
|
function upsert(chat) {
|
|
4103
4119
|
upsertMany([chat]);
|
|
4104
4120
|
}
|
|
4105
|
-
function
|
|
4106
|
-
|
|
4121
|
+
function markDeleted(chatId) {
|
|
4122
|
+
allChatsInclDeleted\u03A3.mutate((list) => {
|
|
4123
|
+
const chat = list.find((c) => c.id === chatId);
|
|
4124
|
+
if (!chat) return false;
|
|
4125
|
+
upsert({ ...chat, deletedAt: now() });
|
|
4126
|
+
return void 0;
|
|
4127
|
+
});
|
|
4107
4128
|
}
|
|
4108
4129
|
function getChatById(chatId) {
|
|
4109
|
-
return Array.from(
|
|
4130
|
+
return Array.from(allChatsInclDeleted\u03A3.get()).find(
|
|
4131
|
+
(chat) => chat.id === chatId
|
|
4132
|
+
);
|
|
4110
4133
|
}
|
|
4111
4134
|
return {
|
|
4112
|
-
chats\u03A3,
|
|
4135
|
+
chats\u03A3: nonDeletedChats\u03A3,
|
|
4113
4136
|
getChatById,
|
|
4114
4137
|
// Mutations
|
|
4115
4138
|
upsert,
|
|
4116
4139
|
upsertMany,
|
|
4117
|
-
|
|
4140
|
+
markDeleted
|
|
4118
4141
|
};
|
|
4119
4142
|
}
|
|
4120
4143
|
function createAi(config) {
|
|
@@ -4124,7 +4147,6 @@ function createAi(config) {
|
|
|
4124
4147
|
false
|
|
4125
4148
|
// AI doesn't have actors (yet, but it will)
|
|
4126
4149
|
);
|
|
4127
|
-
const clientId = nanoid(7);
|
|
4128
4150
|
const chatsStore = createStore_forUserAiChats();
|
|
4129
4151
|
const toolsStore = createStore_forTools();
|
|
4130
4152
|
const messagesStore = createStore_forChatMessages(toolsStore, setToolResult);
|
|
@@ -4193,7 +4215,7 @@ function createAi(config) {
|
|
|
4193
4215
|
if ("event" in msg) {
|
|
4194
4216
|
switch (msg.event) {
|
|
4195
4217
|
case "cmd-failed":
|
|
4196
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4218
|
+
_optionalChain([pendingCmd, 'optionalAccess', _82 => _82.reject, 'call', _83 => _83(new Error(msg.error))]);
|
|
4197
4219
|
break;
|
|
4198
4220
|
case "delta": {
|
|
4199
4221
|
const { id, delta } = msg;
|
|
@@ -4204,7 +4226,11 @@ function createAi(config) {
|
|
|
4204
4226
|
context.messagesStore.upsert(msg.message);
|
|
4205
4227
|
break;
|
|
4206
4228
|
}
|
|
4229
|
+
case "warning":
|
|
4230
|
+
warn(msg.message);
|
|
4231
|
+
break;
|
|
4207
4232
|
case "error":
|
|
4233
|
+
error2(msg.error);
|
|
4208
4234
|
break;
|
|
4209
4235
|
case "rebooted":
|
|
4210
4236
|
context.messagesStore.failAllPending();
|
|
@@ -4215,7 +4241,7 @@ function createAi(config) {
|
|
|
4215
4241
|
context.messagesStore.remove(m.chatId, m.id);
|
|
4216
4242
|
}
|
|
4217
4243
|
for (const chatId of _nullishCoalesce(msg["-chats"], () => ( []))) {
|
|
4218
|
-
context.chatsStore.
|
|
4244
|
+
context.chatsStore.markDeleted(chatId);
|
|
4219
4245
|
context.messagesStore.removeByChatId(chatId);
|
|
4220
4246
|
}
|
|
4221
4247
|
for (const chatId of _nullishCoalesce(msg.clear, () => ( []))) {
|
|
@@ -4241,7 +4267,7 @@ function createAi(config) {
|
|
|
4241
4267
|
context.chatsStore.upsert(msg.chat);
|
|
4242
4268
|
break;
|
|
4243
4269
|
case "delete-chat":
|
|
4244
|
-
context.chatsStore.
|
|
4270
|
+
context.chatsStore.markDeleted(msg.chatId);
|
|
4245
4271
|
context.messagesStore.removeByChatId(msg.chatId);
|
|
4246
4272
|
break;
|
|
4247
4273
|
case "get-message-tree":
|
|
@@ -4271,7 +4297,7 @@ function createAi(config) {
|
|
|
4271
4297
|
return assertNever(msg, "Unhandled case");
|
|
4272
4298
|
}
|
|
4273
4299
|
}
|
|
4274
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4300
|
+
_optionalChain([pendingCmd, 'optionalAccess', _84 => _84.resolve, 'call', _85 => _85(msg)]);
|
|
4275
4301
|
}
|
|
4276
4302
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4277
4303
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4285,7 +4311,13 @@ function createAi(config) {
|
|
|
4285
4311
|
);
|
|
4286
4312
|
}
|
|
4287
4313
|
});
|
|
4314
|
+
function connectInitially() {
|
|
4315
|
+
if (managedSocket.getStatus() === "initial") {
|
|
4316
|
+
managedSocket.connect();
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4288
4319
|
async function sendClientMsgWithResponse(msg) {
|
|
4320
|
+
connectInitially();
|
|
4289
4321
|
if (managedSocket.getStatus() !== "connected") {
|
|
4290
4322
|
await managedSocket.events.didConnect.waitUntil();
|
|
4291
4323
|
}
|
|
@@ -4339,70 +4371,65 @@ function createAi(config) {
|
|
|
4339
4371
|
function updateKnowledge(layerKey, data, key = nanoid()) {
|
|
4340
4372
|
context.knowledge.updateKnowledge(layerKey, key, data);
|
|
4341
4373
|
}
|
|
4342
|
-
function
|
|
4343
|
-
return context.knowledge.get();
|
|
4344
|
-
}
|
|
4345
|
-
async function setToolResult(chatId, messageId, toolCallId, result, options) {
|
|
4374
|
+
async function setToolResult(chatId, messageId, invocationId, result, options) {
|
|
4346
4375
|
const knowledge = context.knowledge.get();
|
|
4347
|
-
|
|
4376
|
+
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4377
|
+
const resp = await sendClientMsgWithResponse({
|
|
4348
4378
|
cmd: "set-tool-result",
|
|
4349
4379
|
chatId,
|
|
4350
4380
|
messageId,
|
|
4351
|
-
|
|
4352
|
-
clientId,
|
|
4381
|
+
invocationId,
|
|
4353
4382
|
result,
|
|
4354
4383
|
generationOptions: {
|
|
4355
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4356
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4357
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4384
|
+
copilotId: _optionalChain([options, 'optionalAccess', _86 => _86.copilotId]),
|
|
4385
|
+
stream: _optionalChain([options, 'optionalAccess', _87 => _87.stream]),
|
|
4386
|
+
timeout: _optionalChain([options, 'optionalAccess', _88 => _88.timeout]),
|
|
4387
|
+
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4388
|
+
// from the global context
|
|
4358
4389
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
4359
|
-
tools:
|
|
4360
|
-
name: tool.name,
|
|
4361
|
-
description: tool.definition.description,
|
|
4362
|
-
parameters: tool.definition.parameters
|
|
4363
|
-
}))
|
|
4390
|
+
tools: tools.length > 0 ? tools : void 0
|
|
4364
4391
|
}
|
|
4365
4392
|
});
|
|
4393
|
+
if (resp.ok) {
|
|
4394
|
+
messagesStore.markMine(resp.message.id);
|
|
4395
|
+
}
|
|
4366
4396
|
}
|
|
4367
4397
|
return Object.defineProperty(
|
|
4368
4398
|
{
|
|
4369
4399
|
[kInternal]: {
|
|
4370
4400
|
context
|
|
4371
4401
|
},
|
|
4372
|
-
|
|
4373
|
-
reconnect: () => managedSocket.reconnect(),
|
|
4402
|
+
connectInitially,
|
|
4403
|
+
// reconnect: () => managedSocket.reconnect(),
|
|
4374
4404
|
disconnect: () => managedSocket.disconnect(),
|
|
4375
4405
|
getChats,
|
|
4376
4406
|
getOrCreateChat,
|
|
4377
4407
|
deleteChat: (chatId) => {
|
|
4378
|
-
return sendClientMsgWithResponse({
|
|
4379
|
-
cmd: "delete-chat",
|
|
4380
|
-
chatId
|
|
4381
|
-
});
|
|
4408
|
+
return sendClientMsgWithResponse({ cmd: "delete-chat", chatId });
|
|
4382
4409
|
},
|
|
4383
4410
|
getMessageTree,
|
|
4384
4411
|
deleteMessage: (chatId, messageId) => sendClientMsgWithResponse({ cmd: "delete-message", chatId, messageId }),
|
|
4385
4412
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4386
4413
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4387
4414
|
const knowledge = context.knowledge.get();
|
|
4388
|
-
|
|
4415
|
+
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4416
|
+
const resp = await sendClientMsgWithResponse({
|
|
4389
4417
|
cmd: "ask-in-chat",
|
|
4390
4418
|
chatId,
|
|
4391
4419
|
sourceMessage: userMessage,
|
|
4392
4420
|
targetMessageId,
|
|
4393
|
-
clientId,
|
|
4394
4421
|
generationOptions: {
|
|
4395
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4396
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4397
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4422
|
+
copilotId: _optionalChain([options, 'optionalAccess', _89 => _89.copilotId]),
|
|
4423
|
+
stream: _optionalChain([options, 'optionalAccess', _90 => _90.stream]),
|
|
4424
|
+
timeout: _optionalChain([options, 'optionalAccess', _91 => _91.timeout]),
|
|
4425
|
+
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4426
|
+
// from the global context
|
|
4398
4427
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
4399
|
-
tools:
|
|
4400
|
-
name: tool.name,
|
|
4401
|
-
description: tool.definition.description,
|
|
4402
|
-
parameters: tool.definition.parameters
|
|
4403
|
-
}))
|
|
4428
|
+
tools: tools.length > 0 ? tools : void 0
|
|
4404
4429
|
}
|
|
4405
4430
|
});
|
|
4431
|
+
messagesStore.markMine(resp.targetMessage.id);
|
|
4432
|
+
return resp;
|
|
4406
4433
|
},
|
|
4407
4434
|
abort: (messageId) => sendClientMsgWithResponse({ cmd: "abort-ai", messageId }),
|
|
4408
4435
|
setToolResult,
|
|
@@ -4410,15 +4437,13 @@ function createAi(config) {
|
|
|
4410
4437
|
signals: {
|
|
4411
4438
|
chats\u03A3: context.chatsStore.chats\u03A3,
|
|
4412
4439
|
getChatMessagesForBranch\u03A3: context.messagesStore.getChatMessagesForBranch\u03A3,
|
|
4413
|
-
|
|
4440
|
+
getTool\u03A3: context.toolsStore.getTool\u03A3
|
|
4414
4441
|
},
|
|
4415
4442
|
getChatById: context.chatsStore.getChatById,
|
|
4416
4443
|
registerKnowledgeLayer,
|
|
4417
4444
|
deregisterKnowledgeLayer,
|
|
4418
4445
|
updateKnowledge,
|
|
4419
|
-
|
|
4420
|
-
registerChatTool: context.toolsStore.addToolDefinition,
|
|
4421
|
-
unregisterChatTool: context.toolsStore.removeToolDefinition
|
|
4446
|
+
registerTool: context.toolsStore.registerTool
|
|
4422
4447
|
},
|
|
4423
4448
|
kInternal,
|
|
4424
4449
|
{ enumerable: false }
|
|
@@ -4434,7 +4459,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
|
|
|
4434
4459
|
}
|
|
4435
4460
|
const url2 = new URL(baseUrl);
|
|
4436
4461
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
4437
|
-
url2.pathname = "/ai/
|
|
4462
|
+
url2.pathname = "/ai/v4";
|
|
4438
4463
|
if (authValue.type === "secret") {
|
|
4439
4464
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
4440
4465
|
} else if (authValue.type === "public") {
|
|
@@ -4498,7 +4523,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4498
4523
|
return void 0;
|
|
4499
4524
|
}
|
|
4500
4525
|
async function makeAuthRequest(options) {
|
|
4501
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
4526
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _92 => _92.polyfills, 'optionalAccess', _93 => _93.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
4502
4527
|
if (authentication.type === "private") {
|
|
4503
4528
|
if (fetcher === void 0) {
|
|
4504
4529
|
throw new StopRetrying(
|
|
@@ -4514,7 +4539,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4514
4539
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
4515
4540
|
);
|
|
4516
4541
|
}
|
|
4517
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4542
|
+
_optionalChain([onAuthenticate, 'optionalCall', _94 => _94(parsed.parsed)]);
|
|
4518
4543
|
return parsed;
|
|
4519
4544
|
}
|
|
4520
4545
|
if (authentication.type === "custom") {
|
|
@@ -4522,7 +4547,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4522
4547
|
if (response && typeof response === "object") {
|
|
4523
4548
|
if (typeof response.token === "string") {
|
|
4524
4549
|
const parsed = parseAuthToken(response.token);
|
|
4525
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4550
|
+
_optionalChain([onAuthenticate, 'optionalCall', _95 => _95(parsed.parsed)]);
|
|
4526
4551
|
return parsed;
|
|
4527
4552
|
} else if (typeof response.error === "string") {
|
|
4528
4553
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -4680,7 +4705,7 @@ function sendToPanel(message, options) {
|
|
|
4680
4705
|
...message,
|
|
4681
4706
|
source: "liveblocks-devtools-client"
|
|
4682
4707
|
};
|
|
4683
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
4708
|
+
if (!(_optionalChain([options, 'optionalAccess', _96 => _96.force]) || _bridgeActive)) {
|
|
4684
4709
|
return;
|
|
4685
4710
|
}
|
|
4686
4711
|
window.postMessage(fullMsg, "*");
|
|
@@ -4688,7 +4713,7 @@ function sendToPanel(message, options) {
|
|
|
4688
4713
|
var eventSource = makeEventSource();
|
|
4689
4714
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
4690
4715
|
window.addEventListener("message", (event) => {
|
|
4691
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
4716
|
+
if (event.source === window && _optionalChain([event, 'access', _97 => _97.data, 'optionalAccess', _98 => _98.source]) === "liveblocks-devtools-panel") {
|
|
4692
4717
|
eventSource.notify(event.data);
|
|
4693
4718
|
} else {
|
|
4694
4719
|
}
|
|
@@ -4830,7 +4855,7 @@ function fullSync(room) {
|
|
|
4830
4855
|
msg: "room::sync::full",
|
|
4831
4856
|
roomId: room.id,
|
|
4832
4857
|
status: room.getStatus(),
|
|
4833
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
4858
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _99 => _99.toTreeNode, 'call', _100 => _100("root"), 'access', _101 => _101.payload]), () => ( null)),
|
|
4834
4859
|
me,
|
|
4835
4860
|
others
|
|
4836
4861
|
});
|
|
@@ -5121,7 +5146,7 @@ function createManagedPool(roomId, options) {
|
|
|
5121
5146
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
5122
5147
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
5123
5148
|
dispatch(ops, reverse, storageUpdates) {
|
|
5124
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
5149
|
+
_optionalChain([onDispatch, 'optionalCall', _102 => _102(ops, reverse, storageUpdates)]);
|
|
5125
5150
|
},
|
|
5126
5151
|
assertStorageIsWritable: () => {
|
|
5127
5152
|
if (!isStorageWritable()) {
|
|
@@ -5348,7 +5373,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
5348
5373
|
return [
|
|
5349
5374
|
{
|
|
5350
5375
|
type: 8 /* CREATE_REGISTER */,
|
|
5351
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5376
|
+
opId: _optionalChain([pool, 'optionalAccess', _103 => _103.generateOpId, 'call', _104 => _104()]),
|
|
5352
5377
|
id: this._id,
|
|
5353
5378
|
parentId,
|
|
5354
5379
|
parentKey,
|
|
@@ -5454,7 +5479,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5454
5479
|
const ops = [];
|
|
5455
5480
|
const op = {
|
|
5456
5481
|
id: this._id,
|
|
5457
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5482
|
+
opId: _optionalChain([pool, 'optionalAccess', _105 => _105.generateOpId, 'call', _106 => _106()]),
|
|
5458
5483
|
type: 2 /* CREATE_LIST */,
|
|
5459
5484
|
parentId,
|
|
5460
5485
|
parentKey
|
|
@@ -5725,7 +5750,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5725
5750
|
#applyInsertUndoRedo(op) {
|
|
5726
5751
|
const { id, parentKey: key } = op;
|
|
5727
5752
|
const child = creationOpToLiveNode(op);
|
|
5728
|
-
if (_optionalChain([this, 'access',
|
|
5753
|
+
if (_optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.getNode, 'call', _109 => _109(id)]) !== void 0) {
|
|
5729
5754
|
return { modified: false };
|
|
5730
5755
|
}
|
|
5731
5756
|
child._attach(id, nn(this._pool));
|
|
@@ -5733,8 +5758,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5733
5758
|
const existingItemIndex = this._indexOfPosition(key);
|
|
5734
5759
|
let newKey = key;
|
|
5735
5760
|
if (existingItemIndex !== -1) {
|
|
5736
|
-
const before2 = _optionalChain([this, 'access',
|
|
5737
|
-
const after2 = _optionalChain([this, 'access',
|
|
5761
|
+
const before2 = _optionalChain([this, 'access', _110 => _110.#items, 'access', _111 => _111[existingItemIndex], 'optionalAccess', _112 => _112._parentPos]);
|
|
5762
|
+
const after2 = _optionalChain([this, 'access', _113 => _113.#items, 'access', _114 => _114[existingItemIndex + 1], 'optionalAccess', _115 => _115._parentPos]);
|
|
5738
5763
|
newKey = makePosition(before2, after2);
|
|
5739
5764
|
child._setParentLink(this, newKey);
|
|
5740
5765
|
}
|
|
@@ -5748,7 +5773,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5748
5773
|
#applySetUndoRedo(op) {
|
|
5749
5774
|
const { id, parentKey: key } = op;
|
|
5750
5775
|
const child = creationOpToLiveNode(op);
|
|
5751
|
-
if (_optionalChain([this, 'access',
|
|
5776
|
+
if (_optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.getNode, 'call', _118 => _118(id)]) !== void 0) {
|
|
5752
5777
|
return { modified: false };
|
|
5753
5778
|
}
|
|
5754
5779
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -5869,7 +5894,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5869
5894
|
} else {
|
|
5870
5895
|
this.#items[existingItemIndex]._setParentLink(
|
|
5871
5896
|
this,
|
|
5872
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5897
|
+
makePosition(newKey, _optionalChain([this, 'access', _119 => _119.#items, 'access', _120 => _120[existingItemIndex + 1], 'optionalAccess', _121 => _121._parentPos]))
|
|
5873
5898
|
);
|
|
5874
5899
|
const previousIndex = this.#items.indexOf(child);
|
|
5875
5900
|
child._setParentLink(this, newKey);
|
|
@@ -5894,7 +5919,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5894
5919
|
if (existingItemIndex !== -1) {
|
|
5895
5920
|
this.#items[existingItemIndex]._setParentLink(
|
|
5896
5921
|
this,
|
|
5897
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5922
|
+
makePosition(newKey, _optionalChain([this, 'access', _122 => _122.#items, 'access', _123 => _123[existingItemIndex + 1], 'optionalAccess', _124 => _124._parentPos]))
|
|
5898
5923
|
);
|
|
5899
5924
|
}
|
|
5900
5925
|
child._setParentLink(this, newKey);
|
|
@@ -5913,7 +5938,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5913
5938
|
if (existingItemIndex !== -1) {
|
|
5914
5939
|
this.#items[existingItemIndex]._setParentLink(
|
|
5915
5940
|
this,
|
|
5916
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5941
|
+
makePosition(newKey, _optionalChain([this, 'access', _125 => _125.#items, 'access', _126 => _126[existingItemIndex + 1], 'optionalAccess', _127 => _127._parentPos]))
|
|
5917
5942
|
);
|
|
5918
5943
|
}
|
|
5919
5944
|
child._setParentLink(this, newKey);
|
|
@@ -5940,7 +5965,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5940
5965
|
if (existingItemIndex !== -1) {
|
|
5941
5966
|
this.#items[existingItemIndex]._setParentLink(
|
|
5942
5967
|
this,
|
|
5943
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
5968
|
+
makePosition(newKey, _optionalChain([this, 'access', _128 => _128.#items, 'access', _129 => _129[existingItemIndex + 1], 'optionalAccess', _130 => _130._parentPos]))
|
|
5944
5969
|
);
|
|
5945
5970
|
}
|
|
5946
5971
|
child._setParentLink(this, newKey);
|
|
@@ -5998,7 +6023,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5998
6023
|
* @param element The element to add to the end of the LiveList.
|
|
5999
6024
|
*/
|
|
6000
6025
|
push(element) {
|
|
6001
|
-
_optionalChain([this, 'access',
|
|
6026
|
+
_optionalChain([this, 'access', _131 => _131._pool, 'optionalAccess', _132 => _132.assertStorageIsWritable, 'call', _133 => _133()]);
|
|
6002
6027
|
return this.insert(element, this.length);
|
|
6003
6028
|
}
|
|
6004
6029
|
/**
|
|
@@ -6007,7 +6032,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6007
6032
|
* @param index The index at which you want to insert the element.
|
|
6008
6033
|
*/
|
|
6009
6034
|
insert(element, index) {
|
|
6010
|
-
_optionalChain([this, 'access',
|
|
6035
|
+
_optionalChain([this, 'access', _134 => _134._pool, 'optionalAccess', _135 => _135.assertStorageIsWritable, 'call', _136 => _136()]);
|
|
6011
6036
|
if (index < 0 || index > this.#items.length) {
|
|
6012
6037
|
throw new Error(
|
|
6013
6038
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -6037,7 +6062,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6037
6062
|
* @param targetIndex The index where the element should be after moving.
|
|
6038
6063
|
*/
|
|
6039
6064
|
move(index, targetIndex) {
|
|
6040
|
-
_optionalChain([this, 'access',
|
|
6065
|
+
_optionalChain([this, 'access', _137 => _137._pool, 'optionalAccess', _138 => _138.assertStorageIsWritable, 'call', _139 => _139()]);
|
|
6041
6066
|
if (targetIndex < 0) {
|
|
6042
6067
|
throw new Error("targetIndex cannot be less than 0");
|
|
6043
6068
|
}
|
|
@@ -6095,7 +6120,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6095
6120
|
* @param index The index of the element to delete
|
|
6096
6121
|
*/
|
|
6097
6122
|
delete(index) {
|
|
6098
|
-
_optionalChain([this, 'access',
|
|
6123
|
+
_optionalChain([this, 'access', _140 => _140._pool, 'optionalAccess', _141 => _141.assertStorageIsWritable, 'call', _142 => _142()]);
|
|
6099
6124
|
if (index < 0 || index >= this.#items.length) {
|
|
6100
6125
|
throw new Error(
|
|
6101
6126
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6128,7 +6153,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6128
6153
|
}
|
|
6129
6154
|
}
|
|
6130
6155
|
clear() {
|
|
6131
|
-
_optionalChain([this, 'access',
|
|
6156
|
+
_optionalChain([this, 'access', _143 => _143._pool, 'optionalAccess', _144 => _144.assertStorageIsWritable, 'call', _145 => _145()]);
|
|
6132
6157
|
if (this._pool) {
|
|
6133
6158
|
const ops = [];
|
|
6134
6159
|
const reverseOps = [];
|
|
@@ -6162,7 +6187,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6162
6187
|
}
|
|
6163
6188
|
}
|
|
6164
6189
|
set(index, item) {
|
|
6165
|
-
_optionalChain([this, 'access',
|
|
6190
|
+
_optionalChain([this, 'access', _146 => _146._pool, 'optionalAccess', _147 => _147.assertStorageIsWritable, 'call', _148 => _148()]);
|
|
6166
6191
|
if (index < 0 || index >= this.#items.length) {
|
|
6167
6192
|
throw new Error(
|
|
6168
6193
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6308,7 +6333,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6308
6333
|
#shiftItemPosition(index, key) {
|
|
6309
6334
|
const shiftedPosition = makePosition(
|
|
6310
6335
|
key,
|
|
6311
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
6336
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _149 => _149.#items, 'access', _150 => _150[index + 1], 'optionalAccess', _151 => _151._parentPos]) : void 0
|
|
6312
6337
|
);
|
|
6313
6338
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
6314
6339
|
}
|
|
@@ -6433,7 +6458,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6433
6458
|
const ops = [];
|
|
6434
6459
|
const op = {
|
|
6435
6460
|
id: this._id,
|
|
6436
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6461
|
+
opId: _optionalChain([pool, 'optionalAccess', _152 => _152.generateOpId, 'call', _153 => _153()]),
|
|
6437
6462
|
type: 7 /* CREATE_MAP */,
|
|
6438
6463
|
parentId,
|
|
6439
6464
|
parentKey
|
|
@@ -6568,7 +6593,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6568
6593
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
6569
6594
|
*/
|
|
6570
6595
|
set(key, value) {
|
|
6571
|
-
_optionalChain([this, 'access',
|
|
6596
|
+
_optionalChain([this, 'access', _154 => _154._pool, 'optionalAccess', _155 => _155.assertStorageIsWritable, 'call', _156 => _156()]);
|
|
6572
6597
|
const oldValue = this.#map.get(key);
|
|
6573
6598
|
if (oldValue) {
|
|
6574
6599
|
oldValue._detach();
|
|
@@ -6614,7 +6639,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6614
6639
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
6615
6640
|
*/
|
|
6616
6641
|
delete(key) {
|
|
6617
|
-
_optionalChain([this, 'access',
|
|
6642
|
+
_optionalChain([this, 'access', _157 => _157._pool, 'optionalAccess', _158 => _158.assertStorageIsWritable, 'call', _159 => _159()]);
|
|
6618
6643
|
const item = this.#map.get(key);
|
|
6619
6644
|
if (item === void 0) {
|
|
6620
6645
|
return false;
|
|
@@ -6793,7 +6818,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
6793
6818
|
if (this._id === void 0) {
|
|
6794
6819
|
throw new Error("Cannot serialize item is not attached");
|
|
6795
6820
|
}
|
|
6796
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
6821
|
+
const opId = _optionalChain([pool, 'optionalAccess', _160 => _160.generateOpId, 'call', _161 => _161()]);
|
|
6797
6822
|
const ops = [];
|
|
6798
6823
|
const op = {
|
|
6799
6824
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -7065,7 +7090,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7065
7090
|
* @param value The value of the property to add
|
|
7066
7091
|
*/
|
|
7067
7092
|
set(key, value) {
|
|
7068
|
-
_optionalChain([this, 'access',
|
|
7093
|
+
_optionalChain([this, 'access', _162 => _162._pool, 'optionalAccess', _163 => _163.assertStorageIsWritable, 'call', _164 => _164()]);
|
|
7069
7094
|
this.update({ [key]: value });
|
|
7070
7095
|
}
|
|
7071
7096
|
/**
|
|
@@ -7080,7 +7105,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7080
7105
|
* @param key The key of the property to delete
|
|
7081
7106
|
*/
|
|
7082
7107
|
delete(key) {
|
|
7083
|
-
_optionalChain([this, 'access',
|
|
7108
|
+
_optionalChain([this, 'access', _165 => _165._pool, 'optionalAccess', _166 => _166.assertStorageIsWritable, 'call', _167 => _167()]);
|
|
7084
7109
|
const keyAsString = key;
|
|
7085
7110
|
const oldValue = this.#map.get(keyAsString);
|
|
7086
7111
|
if (oldValue === void 0) {
|
|
@@ -7133,7 +7158,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7133
7158
|
* @param patch The object used to overrides properties
|
|
7134
7159
|
*/
|
|
7135
7160
|
update(patch) {
|
|
7136
|
-
_optionalChain([this, 'access',
|
|
7161
|
+
_optionalChain([this, 'access', _168 => _168._pool, 'optionalAccess', _169 => _169.assertStorageIsWritable, 'call', _170 => _170()]);
|
|
7137
7162
|
if (this._pool === void 0 || this._id === void 0) {
|
|
7138
7163
|
for (const key in patch) {
|
|
7139
7164
|
const newValue = patch[key];
|
|
@@ -7751,7 +7776,7 @@ var LiveblocksError = class _LiveblocksError extends Error {
|
|
|
7751
7776
|
get roomId() {
|
|
7752
7777
|
return this.context.roomId;
|
|
7753
7778
|
}
|
|
7754
|
-
/** @
|
|
7779
|
+
/** @internal Use `context.code` instead, to enable type narrowing */
|
|
7755
7780
|
get code() {
|
|
7756
7781
|
return this.context.code;
|
|
7757
7782
|
}
|
|
@@ -7821,11 +7846,9 @@ function defaultMessageFromContext(context) {
|
|
|
7821
7846
|
return "Could not mark all inbox notifications as read";
|
|
7822
7847
|
case "DELETE_ALL_INBOX_NOTIFICATIONS_ERROR":
|
|
7823
7848
|
return "Could not delete all inbox notifications";
|
|
7824
|
-
case "UPDATE_NOTIFICATION_SETTINGS_ERROR":
|
|
7825
|
-
return "Could not update notification settings";
|
|
7826
7849
|
case "UPDATE_ROOM_SUBSCRIPTION_SETTINGS_ERROR":
|
|
7827
7850
|
return "Could not update room subscription settings";
|
|
7828
|
-
case "
|
|
7851
|
+
case "UPDATE_NOTIFICATION_SETTINGS_ERROR":
|
|
7829
7852
|
return "Could not update notification settings";
|
|
7830
7853
|
default:
|
|
7831
7854
|
return assertNever(context, "Unhandled case");
|
|
@@ -7856,15 +7879,15 @@ function installBackgroundTabSpy() {
|
|
|
7856
7879
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
7857
7880
|
const inBackgroundSince = { current: null };
|
|
7858
7881
|
function onVisibilityChange() {
|
|
7859
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
7882
|
+
if (_optionalChain([doc, 'optionalAccess', _171 => _171.visibilityState]) === "hidden") {
|
|
7860
7883
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
7861
7884
|
} else {
|
|
7862
7885
|
inBackgroundSince.current = null;
|
|
7863
7886
|
}
|
|
7864
7887
|
}
|
|
7865
|
-
_optionalChain([doc, 'optionalAccess',
|
|
7888
|
+
_optionalChain([doc, 'optionalAccess', _172 => _172.addEventListener, 'call', _173 => _173("visibilitychange", onVisibilityChange)]);
|
|
7866
7889
|
const unsub = () => {
|
|
7867
|
-
_optionalChain([doc, 'optionalAccess',
|
|
7890
|
+
_optionalChain([doc, 'optionalAccess', _174 => _174.removeEventListener, 'call', _175 => _175("visibilitychange", onVisibilityChange)]);
|
|
7868
7891
|
};
|
|
7869
7892
|
return [inBackgroundSince, unsub];
|
|
7870
7893
|
}
|
|
@@ -8044,7 +8067,7 @@ function createRoom(options, config) {
|
|
|
8044
8067
|
}
|
|
8045
8068
|
}
|
|
8046
8069
|
function isStorageWritable() {
|
|
8047
|
-
const scopes = _optionalChain([context, 'access',
|
|
8070
|
+
const scopes = _optionalChain([context, 'access', _176 => _176.dynamicSessionInfoSig, 'access', _177 => _177.get, 'call', _178 => _178(), 'optionalAccess', _179 => _179.scopes]);
|
|
8048
8071
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
8049
8072
|
}
|
|
8050
8073
|
const eventHub = {
|
|
@@ -8161,7 +8184,7 @@ function createRoom(options, config) {
|
|
|
8161
8184
|
}
|
|
8162
8185
|
case "experimental-fallback-to-http": {
|
|
8163
8186
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8164
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
8187
|
+
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")));
|
|
8165
8188
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
8166
8189
|
if (!resp.ok && resp.status === 403) {
|
|
8167
8190
|
managedSocket.reconnect();
|
|
@@ -8212,7 +8235,7 @@ function createRoom(options, config) {
|
|
|
8212
8235
|
} else {
|
|
8213
8236
|
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
8214
8237
|
}
|
|
8215
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
8238
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _184 => _184.get, 'call', _185 => _185(), 'optionalAccess', _186 => _186.canWrite]), () => ( true));
|
|
8216
8239
|
const stackSizeBefore = context.undoStack.length;
|
|
8217
8240
|
for (const key in context.initialStorage) {
|
|
8218
8241
|
if (context.root.get(key) === void 0) {
|
|
@@ -8415,7 +8438,7 @@ function createRoom(options, config) {
|
|
|
8415
8438
|
}
|
|
8416
8439
|
context.myPresence.patch(patch);
|
|
8417
8440
|
if (context.activeBatch) {
|
|
8418
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8441
|
+
if (_optionalChain([options2, 'optionalAccess', _187 => _187.addToHistory])) {
|
|
8419
8442
|
context.activeBatch.reverseOps.pushLeft({
|
|
8420
8443
|
type: "presence",
|
|
8421
8444
|
data: oldValues
|
|
@@ -8424,7 +8447,7 @@ function createRoom(options, config) {
|
|
|
8424
8447
|
context.activeBatch.updates.presence = true;
|
|
8425
8448
|
} else {
|
|
8426
8449
|
flushNowOrSoon();
|
|
8427
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8450
|
+
if (_optionalChain([options2, 'optionalAccess', _188 => _188.addToHistory])) {
|
|
8428
8451
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
8429
8452
|
}
|
|
8430
8453
|
notify({ presence: true });
|
|
@@ -8621,7 +8644,7 @@ function createRoom(options, config) {
|
|
|
8621
8644
|
if (process.env.NODE_ENV !== "production") {
|
|
8622
8645
|
const traces = /* @__PURE__ */ new Set();
|
|
8623
8646
|
for (const opId of message.opIds) {
|
|
8624
|
-
const trace = _optionalChain([context, 'access',
|
|
8647
|
+
const trace = _optionalChain([context, 'access', _189 => _189.opStackTraces, 'optionalAccess', _190 => _190.get, 'call', _191 => _191(opId)]);
|
|
8625
8648
|
if (trace) {
|
|
8626
8649
|
traces.add(trace);
|
|
8627
8650
|
}
|
|
@@ -8755,7 +8778,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
8755
8778
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
8756
8779
|
createOrUpdateRootFromMessage(message);
|
|
8757
8780
|
applyAndSendOps(unacknowledgedOps);
|
|
8758
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
8781
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _192 => _192()]);
|
|
8759
8782
|
notifyStorageStatus();
|
|
8760
8783
|
eventHub.storageDidLoad.notify();
|
|
8761
8784
|
}
|
|
@@ -8958,8 +8981,6 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
8958
8981
|
others: eventHub.others.observable,
|
|
8959
8982
|
self: eventHub.self.observable,
|
|
8960
8983
|
myPresence: eventHub.myPresence.observable,
|
|
8961
|
-
/** @deprecated */
|
|
8962
|
-
storage: eventHub.storageBatch.observable,
|
|
8963
8984
|
storageBatch: eventHub.storageBatch.observable,
|
|
8964
8985
|
history: eventHub.history.observable,
|
|
8965
8986
|
storageDidLoad: eventHub.storageDidLoad.observable,
|
|
@@ -8978,8 +8999,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
8978
8999
|
async function getThreads(options2) {
|
|
8979
9000
|
return httpClient.getThreads({
|
|
8980
9001
|
roomId,
|
|
8981
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
8982
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9002
|
+
query: _optionalChain([options2, 'optionalAccess', _193 => _193.query]),
|
|
9003
|
+
cursor: _optionalChain([options2, 'optionalAccess', _194 => _194.cursor])
|
|
8983
9004
|
});
|
|
8984
9005
|
}
|
|
8985
9006
|
async function getThread(threadId) {
|
|
@@ -9086,7 +9107,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9086
9107
|
function getSubscriptionSettings(options2) {
|
|
9087
9108
|
return httpClient.getSubscriptionSettings({
|
|
9088
9109
|
roomId,
|
|
9089
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9110
|
+
signal: _optionalChain([options2, 'optionalAccess', _195 => _195.signal])
|
|
9090
9111
|
});
|
|
9091
9112
|
}
|
|
9092
9113
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9108,7 +9129,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9108
9129
|
{
|
|
9109
9130
|
[kInternal]: {
|
|
9110
9131
|
get presenceBuffer() {
|
|
9111
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9132
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _196 => _196.buffer, 'access', _197 => _197.presenceUpdates, 'optionalAccess', _198 => _198.data]), () => ( null)));
|
|
9112
9133
|
},
|
|
9113
9134
|
// prettier-ignore
|
|
9114
9135
|
get undoStack() {
|
|
@@ -9123,9 +9144,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9123
9144
|
return context.yjsProvider;
|
|
9124
9145
|
},
|
|
9125
9146
|
setYjsProvider(newProvider) {
|
|
9126
|
-
_optionalChain([context, 'access',
|
|
9147
|
+
_optionalChain([context, 'access', _199 => _199.yjsProvider, 'optionalAccess', _200 => _200.off, 'call', _201 => _201("status", yjsStatusDidChange)]);
|
|
9127
9148
|
context.yjsProvider = newProvider;
|
|
9128
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9149
|
+
_optionalChain([newProvider, 'optionalAccess', _202 => _202.on, 'call', _203 => _203("status", yjsStatusDidChange)]);
|
|
9129
9150
|
context.yjsProviderDidChange.notify();
|
|
9130
9151
|
},
|
|
9131
9152
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9171,7 +9192,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9171
9192
|
source.dispose();
|
|
9172
9193
|
}
|
|
9173
9194
|
eventHub.roomWillDestroy.notify();
|
|
9174
|
-
_optionalChain([context, 'access',
|
|
9195
|
+
_optionalChain([context, 'access', _204 => _204.yjsProvider, 'optionalAccess', _205 => _205.off, 'call', _206 => _206("status", yjsStatusDidChange)]);
|
|
9175
9196
|
syncSourceForStorage.destroy();
|
|
9176
9197
|
syncSourceForYjs.destroy();
|
|
9177
9198
|
uninstallBgTabSpy();
|
|
@@ -9321,7 +9342,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9321
9342
|
}
|
|
9322
9343
|
if (isLiveNode(first)) {
|
|
9323
9344
|
const node = first;
|
|
9324
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9345
|
+
if (_optionalChain([options, 'optionalAccess', _207 => _207.isDeep])) {
|
|
9325
9346
|
const storageCallback = second;
|
|
9326
9347
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9327
9348
|
} else {
|
|
@@ -9400,8 +9421,8 @@ function createClient(options) {
|
|
|
9400
9421
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
9401
9422
|
currentUserId.set(() => userId);
|
|
9402
9423
|
});
|
|
9403
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
9404
|
-
_optionalChain([globalThis, 'access',
|
|
9424
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _208 => _208.polyfills, 'optionalAccess', _209 => _209.fetch]) || /* istanbul ignore next */
|
|
9425
|
+
_optionalChain([globalThis, 'access', _210 => _210.fetch, 'optionalAccess', _211 => _211.bind, 'call', _212 => _212(globalThis)]);
|
|
9405
9426
|
const httpClient = createApiClient({
|
|
9406
9427
|
baseUrl,
|
|
9407
9428
|
fetchPolyfill,
|
|
@@ -9419,10 +9440,28 @@ function createClient(options) {
|
|
|
9419
9440
|
delegates: {
|
|
9420
9441
|
createSocket: makeCreateSocketDelegateForAi(
|
|
9421
9442
|
baseUrl,
|
|
9422
|
-
_optionalChain([clientOptions, 'access',
|
|
9443
|
+
_optionalChain([clientOptions, 'access', _213 => _213.polyfills, 'optionalAccess', _214 => _214.WebSocket])
|
|
9423
9444
|
),
|
|
9424
|
-
authenticate:
|
|
9425
|
-
|
|
9445
|
+
authenticate: async () => {
|
|
9446
|
+
const resp = await authManager.getAuthValue({
|
|
9447
|
+
requestedScope: "room:read"
|
|
9448
|
+
});
|
|
9449
|
+
if (resp.type === "public") {
|
|
9450
|
+
throw new StopRetrying(
|
|
9451
|
+
"Cannot use AI Copilots with a public API key"
|
|
9452
|
+
);
|
|
9453
|
+
} else if (resp.token.parsed.k === "sec-legacy" /* SECRET_LEGACY */) {
|
|
9454
|
+
throw new StopRetrying("AI Copilots requires an ID or Access token");
|
|
9455
|
+
} else {
|
|
9456
|
+
if (!resp.token.parsed.ai) {
|
|
9457
|
+
throw new StopRetrying(
|
|
9458
|
+
"AI Copilots is not yet enabled for this account. To get started, see https://liveblocks.io/docs/get-started/ai-copilots#Quickstart"
|
|
9459
|
+
);
|
|
9460
|
+
}
|
|
9461
|
+
}
|
|
9462
|
+
return resp;
|
|
9463
|
+
},
|
|
9464
|
+
canZombie: () => false
|
|
9426
9465
|
}
|
|
9427
9466
|
});
|
|
9428
9467
|
function teardownRoom(room) {
|
|
@@ -9469,14 +9508,14 @@ function createClient(options) {
|
|
|
9469
9508
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
9470
9509
|
roomId,
|
|
9471
9510
|
baseUrl,
|
|
9472
|
-
_optionalChain([clientOptions, 'access',
|
|
9511
|
+
_optionalChain([clientOptions, 'access', _215 => _215.polyfills, 'optionalAccess', _216 => _216.WebSocket])
|
|
9473
9512
|
),
|
|
9474
9513
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
9475
9514
|
})),
|
|
9476
9515
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
9477
9516
|
baseUrl,
|
|
9478
9517
|
errorEventSource: liveblocksErrorSource,
|
|
9479
|
-
largeMessageStrategy:
|
|
9518
|
+
largeMessageStrategy: clientOptions.largeMessageStrategy,
|
|
9480
9519
|
unstable_streamData: !!clientOptions.unstable_streamData,
|
|
9481
9520
|
roomHttpClient: httpClient,
|
|
9482
9521
|
createSyncSource
|
|
@@ -9492,7 +9531,7 @@ function createClient(options) {
|
|
|
9492
9531
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
9493
9532
|
if (shouldConnect) {
|
|
9494
9533
|
if (typeof atob === "undefined") {
|
|
9495
|
-
if (_optionalChain([clientOptions, 'access',
|
|
9534
|
+
if (_optionalChain([clientOptions, 'access', _217 => _217.polyfills, 'optionalAccess', _218 => _218.atob]) === void 0) {
|
|
9496
9535
|
throw new Error(
|
|
9497
9536
|
"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"
|
|
9498
9537
|
);
|
|
@@ -9504,7 +9543,7 @@ function createClient(options) {
|
|
|
9504
9543
|
return leaseRoom(newRoomDetails);
|
|
9505
9544
|
}
|
|
9506
9545
|
function getRoom(roomId) {
|
|
9507
|
-
const room = _optionalChain([roomsById, 'access',
|
|
9546
|
+
const room = _optionalChain([roomsById, 'access', _219 => _219.get, 'call', _220 => _220(roomId), 'optionalAccess', _221 => _221.room]);
|
|
9508
9547
|
return room ? room : null;
|
|
9509
9548
|
}
|
|
9510
9549
|
function logout() {
|
|
@@ -9524,7 +9563,7 @@ function createClient(options) {
|
|
|
9524
9563
|
const batchedResolveUsers = new Batch(
|
|
9525
9564
|
async (batchedUserIds) => {
|
|
9526
9565
|
const userIds = batchedUserIds.flat();
|
|
9527
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
9566
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _222 => _222({ userIds })]);
|
|
9528
9567
|
warnIfNoResolveUsers();
|
|
9529
9568
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
9530
9569
|
},
|
|
@@ -9542,7 +9581,7 @@ function createClient(options) {
|
|
|
9542
9581
|
const batchedResolveRoomsInfo = new Batch(
|
|
9543
9582
|
async (batchedRoomIds) => {
|
|
9544
9583
|
const roomIds = batchedRoomIds.flat();
|
|
9545
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
9584
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _223 => _223({ roomIds })]);
|
|
9546
9585
|
warnIfNoResolveRoomsInfo();
|
|
9547
9586
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
9548
9587
|
},
|
|
@@ -9595,7 +9634,7 @@ function createClient(options) {
|
|
|
9595
9634
|
}
|
|
9596
9635
|
};
|
|
9597
9636
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
9598
|
-
_optionalChain([win, 'optionalAccess',
|
|
9637
|
+
_optionalChain([win, 'optionalAccess', _224 => _224.addEventListener, 'call', _225 => _225("beforeunload", maybePreventClose)]);
|
|
9599
9638
|
}
|
|
9600
9639
|
async function getNotificationSettings(options2) {
|
|
9601
9640
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -9734,7 +9773,7 @@ var commentBodyElementsTypes = {
|
|
|
9734
9773
|
mention: "inline"
|
|
9735
9774
|
};
|
|
9736
9775
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
9737
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
9776
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _226 => _226.content])) {
|
|
9738
9777
|
return;
|
|
9739
9778
|
}
|
|
9740
9779
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -9744,38 +9783,47 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
9744
9783
|
for (const block of body.content) {
|
|
9745
9784
|
if (type === "all" || type === "block") {
|
|
9746
9785
|
if (guard(block)) {
|
|
9747
|
-
_optionalChain([visitor, 'optionalCall',
|
|
9786
|
+
_optionalChain([visitor, 'optionalCall', _227 => _227(block)]);
|
|
9748
9787
|
}
|
|
9749
9788
|
}
|
|
9750
9789
|
if (type === "all" || type === "inline") {
|
|
9751
9790
|
for (const inline of block.children) {
|
|
9752
9791
|
if (guard(inline)) {
|
|
9753
|
-
_optionalChain([visitor, 'optionalCall',
|
|
9792
|
+
_optionalChain([visitor, 'optionalCall', _228 => _228(inline)]);
|
|
9754
9793
|
}
|
|
9755
9794
|
}
|
|
9756
9795
|
}
|
|
9757
9796
|
}
|
|
9758
9797
|
}
|
|
9759
|
-
function
|
|
9760
|
-
const
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9798
|
+
function getMentionsFromCommentBody(body, predicate) {
|
|
9799
|
+
const mentionIds = /* @__PURE__ */ new Set();
|
|
9800
|
+
const mentions = [];
|
|
9801
|
+
traverseCommentBody(body, "mention", (mention) => {
|
|
9802
|
+
if (
|
|
9803
|
+
// If this mention isn't already in the list
|
|
9804
|
+
!mentionIds.has(mention.id) && // And the provided predicate is true
|
|
9805
|
+
(predicate ? predicate(mention) : true)
|
|
9806
|
+
) {
|
|
9807
|
+
mentionIds.add(mention.id);
|
|
9808
|
+
mentions.push(mention);
|
|
9809
|
+
}
|
|
9810
|
+
});
|
|
9811
|
+
return mentions;
|
|
9767
9812
|
}
|
|
9768
9813
|
async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
9769
9814
|
const resolvedUsers = /* @__PURE__ */ new Map();
|
|
9770
9815
|
if (!resolveUsers) {
|
|
9771
9816
|
return resolvedUsers;
|
|
9772
9817
|
}
|
|
9773
|
-
const userIds =
|
|
9818
|
+
const userIds = getMentionsFromCommentBody(
|
|
9819
|
+
body,
|
|
9820
|
+
(mention) => mention.kind === "user"
|
|
9821
|
+
).map((mention) => mention.id);
|
|
9774
9822
|
const users = await resolveUsers({
|
|
9775
9823
|
userIds
|
|
9776
9824
|
});
|
|
9777
9825
|
for (const [index, userId] of userIds.entries()) {
|
|
9778
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
9826
|
+
const user = _optionalChain([users, 'optionalAccess', _229 => _229[index]]);
|
|
9779
9827
|
if (user) {
|
|
9780
9828
|
resolvedUsers.set(userId, user);
|
|
9781
9829
|
}
|
|
@@ -9902,7 +9950,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
9902
9950
|
text: ({ element }) => element.text,
|
|
9903
9951
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
9904
9952
|
mention: ({ element, user }) => {
|
|
9905
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
9953
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _230 => _230.name]), () => ( element.id))}`;
|
|
9906
9954
|
}
|
|
9907
9955
|
};
|
|
9908
9956
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -9932,7 +9980,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
9932
9980
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
9933
9981
|
},
|
|
9934
9982
|
mention: ({ element, user }) => {
|
|
9935
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
9983
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _231 => _231.name]) ? html`${_optionalChain([user, 'optionalAccess', _232 => _232.name])}` : element.id}</span>`;
|
|
9936
9984
|
}
|
|
9937
9985
|
};
|
|
9938
9986
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -9962,19 +10010,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
9962
10010
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
9963
10011
|
},
|
|
9964
10012
|
mention: ({ element, user }) => {
|
|
9965
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10013
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _233 => _233.name]), () => ( element.id))}`;
|
|
9966
10014
|
}
|
|
9967
10015
|
};
|
|
9968
10016
|
async function stringifyCommentBody(body, options) {
|
|
9969
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
9970
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10017
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _234 => _234.format]), () => ( "plain"));
|
|
10018
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _235 => _235.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
9971
10019
|
const elements = {
|
|
9972
10020
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
9973
|
-
..._optionalChain([options, 'optionalAccess',
|
|
10021
|
+
..._optionalChain([options, 'optionalAccess', _236 => _236.elements])
|
|
9974
10022
|
};
|
|
9975
10023
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
9976
10024
|
body,
|
|
9977
|
-
_optionalChain([options, 'optionalAccess',
|
|
10025
|
+
_optionalChain([options, 'optionalAccess', _237 => _237.resolveUsers])
|
|
9978
10026
|
);
|
|
9979
10027
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
9980
10028
|
switch (block.type) {
|
|
@@ -10265,12 +10313,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10265
10313
|
}
|
|
10266
10314
|
const newState = Object.assign({}, state);
|
|
10267
10315
|
for (const key in update.updates) {
|
|
10268
|
-
if (_optionalChain([update, 'access',
|
|
10316
|
+
if (_optionalChain([update, 'access', _238 => _238.updates, 'access', _239 => _239[key], 'optionalAccess', _240 => _240.type]) === "update") {
|
|
10269
10317
|
const val = update.node.get(key);
|
|
10270
10318
|
if (val !== void 0) {
|
|
10271
10319
|
newState[key] = lsonToJson(val);
|
|
10272
10320
|
}
|
|
10273
|
-
} else if (_optionalChain([update, 'access',
|
|
10321
|
+
} else if (_optionalChain([update, 'access', _241 => _241.updates, 'access', _242 => _242[key], 'optionalAccess', _243 => _243.type]) === "delete") {
|
|
10274
10322
|
delete newState[key];
|
|
10275
10323
|
}
|
|
10276
10324
|
}
|
|
@@ -10331,12 +10379,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10331
10379
|
}
|
|
10332
10380
|
const newState = Object.assign({}, state);
|
|
10333
10381
|
for (const key in update.updates) {
|
|
10334
|
-
if (_optionalChain([update, 'access',
|
|
10382
|
+
if (_optionalChain([update, 'access', _244 => _244.updates, 'access', _245 => _245[key], 'optionalAccess', _246 => _246.type]) === "update") {
|
|
10335
10383
|
const value = update.node.get(key);
|
|
10336
10384
|
if (value !== void 0) {
|
|
10337
10385
|
newState[key] = lsonToJson(value);
|
|
10338
10386
|
}
|
|
10339
|
-
} else if (_optionalChain([update, 'access',
|
|
10387
|
+
} else if (_optionalChain([update, 'access', _247 => _247.updates, 'access', _248 => _248[key], 'optionalAccess', _249 => _249.type]) === "delete") {
|
|
10340
10388
|
delete newState[key];
|
|
10341
10389
|
}
|
|
10342
10390
|
}
|
|
@@ -10416,9 +10464,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10416
10464
|
const startTime = performance.now();
|
|
10417
10465
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10418
10466
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10419
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10467
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _250 => _250.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
10420
10468
|
const context = {
|
|
10421
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
10469
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _251 => _251.visibilityState]) !== "hidden",
|
|
10422
10470
|
lastSuccessfulPollAt: startTime,
|
|
10423
10471
|
count: 0,
|
|
10424
10472
|
backoff: 0
|
|
@@ -10499,11 +10547,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10499
10547
|
pollNowIfStale();
|
|
10500
10548
|
}
|
|
10501
10549
|
function onVisibilityChange() {
|
|
10502
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
10550
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _252 => _252.visibilityState]) !== "hidden");
|
|
10503
10551
|
}
|
|
10504
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10505
|
-
_optionalChain([win, 'optionalAccess',
|
|
10506
|
-
_optionalChain([win, 'optionalAccess',
|
|
10552
|
+
_optionalChain([doc, 'optionalAccess', _253 => _253.addEventListener, 'call', _254 => _254("visibilitychange", onVisibilityChange)]);
|
|
10553
|
+
_optionalChain([win, 'optionalAccess', _255 => _255.addEventListener, 'call', _256 => _256("online", onVisibilityChange)]);
|
|
10554
|
+
_optionalChain([win, 'optionalAccess', _257 => _257.addEventListener, 'call', _258 => _258("focus", pollNowIfStale)]);
|
|
10507
10555
|
fsm.start();
|
|
10508
10556
|
return {
|
|
10509
10557
|
inc,
|
|
@@ -10533,10 +10581,6 @@ var TextEditorType = /* @__PURE__ */ ((TextEditorType2) => {
|
|
|
10533
10581
|
|
|
10534
10582
|
// src/index.ts
|
|
10535
10583
|
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
10536
|
-
var CommentsApiError = HttpError;
|
|
10537
|
-
var NotificationsApiError = HttpError;
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
10584
|
|
|
10541
10585
|
|
|
10542
10586
|
|
|
@@ -10635,5 +10679,5 @@ var NotificationsApiError = HttpError;
|
|
|
10635
10679
|
|
|
10636
10680
|
|
|
10637
10681
|
|
|
10638
|
-
exports.ClientMsgCode = ClientMsgCode; exports.
|
|
10682
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CrdtType = CrdtType; exports.DefaultMap = DefaultMap; exports.Deque = Deque; exports.DerivedSignal = DerivedSignal; exports.HttpError = HttpError; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.LiveblocksError = LiveblocksError; exports.MutableSignal = MutableSignal; exports.OpCode = OpCode; exports.Permission = Permission; exports.Promise_withResolvers = Promise_withResolvers; exports.ServerMsgCode = ServerMsgCode; exports.Signal = Signal; exports.SortedList = SortedList; exports.TextEditorType = TextEditorType; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.autoRetry = autoRetry; exports.b64decode = b64decode; exports.batch = batch; exports.checkBounds = checkBounds; exports.chunk = chunk; exports.cloneLson = cloneLson; exports.compactObject = compactObject; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToSubscriptionData = convertToSubscriptionData; exports.convertToThreadData = convertToThreadData; exports.convertToUserSubscriptionData = convertToUserSubscriptionData; exports.createClient = createClient; exports.createCommentAttachmentId = createCommentAttachmentId; exports.createCommentId = createCommentId; exports.createInboxNotificationId = createInboxNotificationId; exports.createManagedPool = createManagedPool; exports.createNotificationSettings = createNotificationSettings; exports.createThreadId = createThreadId; exports.defineAiTool = defineAiTool; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.entries = entries; exports.errorIf = errorIf; exports.freeze = freeze; exports.generateCommentUrl = generateCommentUrl; exports.getMentionsFromCommentBody = getMentionsFromCommentBody; exports.getSubscriptionKey = getSubscriptionKey; exports.html = html; exports.htmlSafe = htmlSafe; exports.isChildCrdt = isChildCrdt; exports.isCommentBodyLink = isCommentBodyLink; exports.isCommentBodyMention = isCommentBodyMention; exports.isCommentBodyText = isCommentBodyText; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isNotificationChannelEnabled = isNotificationChannelEnabled; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.isStartsWithOperator = isStartsWithOperator; exports.kInternal = kInternal; exports.keys = keys; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeAbortController = makeAbortController; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.mapValues = mapValues; exports.memoizeOnSuccess = memoizeOnSuccess; exports.nanoid = nanoid; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.patchNotificationSettings = patchNotificationSettings; exports.raise = raise; exports.resolveUsersInCommentBody = resolveUsersInCommentBody; exports.shallow = shallow; exports.shallow2 = shallow2; exports.stableStringify = stableStringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toAbsoluteUrl = toAbsoluteUrl; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.url = url; exports.urljoin = urljoin; exports.wait = wait; exports.withTimeout = withTimeout;
|
|
10639
10683
|
//# sourceMappingURL=index.cjs.map
|