@liveblocks/core 3.5.1 → 3.5.2
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 +347 -241
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +253 -147
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.5.
|
|
9
|
+
var PKG_VERSION = "3.5.2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3817,99 +3817,174 @@ function parseAuthToken(rawTokenString) {
|
|
|
3817
3817
|
};
|
|
3818
3818
|
}
|
|
3819
3819
|
|
|
3820
|
-
// src/lib/
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
}
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3820
|
+
// src/lib/IncrementalJsonParser.ts
|
|
3821
|
+
var EMPTY_OBJECT = Object.freeze({});
|
|
3822
|
+
var NULL_KEYWORD_CHARS = Array.from(new Set("null"));
|
|
3823
|
+
var TRUE_KEYWORD_CHARS = Array.from(new Set("true"));
|
|
3824
|
+
var FALSE_KEYWORD_CHARS = Array.from(new Set("false"));
|
|
3825
|
+
var ALL_KEYWORD_CHARS = Array.from(new Set("nulltruefalse"));
|
|
3826
|
+
function stripChar(str, chars) {
|
|
3827
|
+
const lastChar = str[str.length - 1];
|
|
3828
|
+
if (chars.includes(lastChar)) {
|
|
3829
|
+
return str.slice(0, -1);
|
|
3830
|
+
}
|
|
3831
|
+
return str;
|
|
3832
|
+
}
|
|
3833
|
+
var IncrementalJsonParser = class {
|
|
3834
|
+
// Input
|
|
3835
|
+
#sourceText = "";
|
|
3836
|
+
// Output
|
|
3837
|
+
#cachedJson;
|
|
3838
|
+
/** How much we've already parsed */
|
|
3839
|
+
#scanIndex = 0;
|
|
3840
|
+
/** Whether the last char processed was a backslash */
|
|
3841
|
+
#escaped = false;
|
|
3842
|
+
/**
|
|
3843
|
+
* Start position of the last unterminated string, -1 if we're not inside
|
|
3844
|
+
* a string currently.
|
|
3845
|
+
*
|
|
3846
|
+
* Example: '{"a": "foo'
|
|
3847
|
+
* ^
|
|
3848
|
+
*/
|
|
3849
|
+
#lastUnterminatedString = -1;
|
|
3850
|
+
/**
|
|
3851
|
+
* Start position of the last fully terminated string we've seen.
|
|
3852
|
+
*
|
|
3853
|
+
* Example: '{"a": "foo'
|
|
3854
|
+
* ^
|
|
3855
|
+
*/
|
|
3856
|
+
#lastTerminatedString = -1;
|
|
3857
|
+
/** The bracket stack of expected closing chars. For input '{"a": ["foo', the stack would be ['}', ']']. */
|
|
3858
|
+
#stack = [];
|
|
3859
|
+
constructor(text = "") {
|
|
3860
|
+
this.append(text);
|
|
3861
|
+
}
|
|
3862
|
+
get source() {
|
|
3863
|
+
return this.#sourceText;
|
|
3864
|
+
}
|
|
3865
|
+
get json() {
|
|
3866
|
+
if (this.#cachedJson === void 0) {
|
|
3867
|
+
this.#cachedJson = this.#parse();
|
|
3868
|
+
}
|
|
3869
|
+
return this.#cachedJson;
|
|
3870
|
+
}
|
|
3871
|
+
/** Whether we're currently inside an unterminated string, e.g. '{"hello' */
|
|
3872
|
+
get #inString() {
|
|
3873
|
+
return this.#lastUnterminatedString >= 0;
|
|
3874
|
+
}
|
|
3875
|
+
append(delta) {
|
|
3876
|
+
if (delta) {
|
|
3877
|
+
if (this.#sourceText === "") {
|
|
3878
|
+
delta = delta.trimStart();
|
|
3879
3879
|
}
|
|
3880
|
+
this.#sourceText += delta;
|
|
3881
|
+
this.#cachedJson = void 0;
|
|
3880
3882
|
}
|
|
3881
3883
|
}
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3884
|
+
#autocompleteTail(output) {
|
|
3885
|
+
if (this.#inString) {
|
|
3886
|
+
return "";
|
|
3887
|
+
}
|
|
3888
|
+
const lastChar = output.charAt(output.length - 1);
|
|
3889
|
+
if (lastChar === "") return "";
|
|
3890
|
+
if (lastChar === "-") {
|
|
3891
|
+
return "0";
|
|
3892
|
+
}
|
|
3893
|
+
if (!ALL_KEYWORD_CHARS.includes(lastChar)) return "";
|
|
3894
|
+
if (NULL_KEYWORD_CHARS.includes(lastChar)) {
|
|
3895
|
+
if (output.endsWith("nul")) return "l";
|
|
3896
|
+
if (output.endsWith("nu")) return "ll";
|
|
3897
|
+
if (output.endsWith("n")) return "ull";
|
|
3898
|
+
}
|
|
3899
|
+
if (TRUE_KEYWORD_CHARS.includes(lastChar)) {
|
|
3900
|
+
if (output.endsWith("tru")) return "e";
|
|
3901
|
+
if (output.endsWith("tr")) return "ue";
|
|
3902
|
+
if (output.endsWith("t")) return "rue";
|
|
3903
|
+
}
|
|
3904
|
+
if (FALSE_KEYWORD_CHARS.includes(lastChar)) {
|
|
3905
|
+
if (output.endsWith("fals")) return "e";
|
|
3906
|
+
if (output.endsWith("fal")) return "se";
|
|
3907
|
+
if (output.endsWith("fa")) return "lse";
|
|
3908
|
+
if (output.endsWith("f")) return "alse";
|
|
3909
|
+
}
|
|
3910
|
+
return "";
|
|
3911
|
+
}
|
|
3912
|
+
/**
|
|
3913
|
+
* Updates the internal parsing state by processing any new content
|
|
3914
|
+
* that has been appended since the last parse. This updates the state with
|
|
3915
|
+
* facts only. Any interpretation is left to the #parse() method.
|
|
3916
|
+
*/
|
|
3917
|
+
#catchup() {
|
|
3918
|
+
const newContent = this.#sourceText.slice(this.#scanIndex);
|
|
3919
|
+
for (let i = 0; i < newContent.length; i++) {
|
|
3920
|
+
const ch = newContent[i];
|
|
3921
|
+
const absolutePos = this.#scanIndex + i;
|
|
3922
|
+
if (this.#inString) {
|
|
3923
|
+
if (this.#escaped) {
|
|
3924
|
+
this.#escaped = false;
|
|
3925
|
+
} else if (ch === "\\") {
|
|
3926
|
+
this.#escaped = true;
|
|
3927
|
+
} else if (ch === '"') {
|
|
3928
|
+
this.#lastTerminatedString = this.#lastUnterminatedString;
|
|
3929
|
+
this.#lastUnterminatedString = -1;
|
|
3930
|
+
}
|
|
3931
|
+
} else {
|
|
3932
|
+
if (ch === '"') {
|
|
3933
|
+
this.#lastUnterminatedString = absolutePos;
|
|
3934
|
+
} else if (ch === "{") {
|
|
3935
|
+
this.#stack.push("}");
|
|
3936
|
+
} else if (ch === "[") {
|
|
3937
|
+
this.#stack.push("]");
|
|
3938
|
+
} else if (ch === "}" && this.#stack.length > 0 && this.#stack[this.#stack.length - 1] === "}") {
|
|
3939
|
+
this.#stack.pop();
|
|
3940
|
+
} else if (ch === "]" && this.#stack.length > 0 && this.#stack[this.#stack.length - 1] === "]") {
|
|
3941
|
+
this.#stack.pop();
|
|
3942
|
+
}
|
|
3903
3943
|
}
|
|
3904
|
-
pos--;
|
|
3905
3944
|
}
|
|
3945
|
+
this.#scanIndex = this.#sourceText.length;
|
|
3906
3946
|
}
|
|
3907
|
-
|
|
3908
|
-
|
|
3947
|
+
#parse() {
|
|
3948
|
+
this.#catchup();
|
|
3949
|
+
let result = this.#sourceText;
|
|
3950
|
+
if (result.charAt(0) !== "{") {
|
|
3951
|
+
return EMPTY_OBJECT;
|
|
3952
|
+
}
|
|
3953
|
+
if (result.endsWith("}")) {
|
|
3954
|
+
const quickCheck = tryParseJson(result);
|
|
3955
|
+
if (quickCheck) {
|
|
3956
|
+
return quickCheck;
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
if (this.#inString) {
|
|
3960
|
+
if (this.#escaped) {
|
|
3961
|
+
result = result.slice(0, -1);
|
|
3962
|
+
}
|
|
3963
|
+
result += '"';
|
|
3964
|
+
}
|
|
3965
|
+
result = result.trimEnd();
|
|
3966
|
+
result = stripChar(result, ",.");
|
|
3967
|
+
result = result + this.#autocompleteTail(result);
|
|
3968
|
+
const suffix = this.#stack.reduceRight((acc, ch) => acc + ch, "");
|
|
3969
|
+
{
|
|
3970
|
+
const attempt = tryParseJson(result + suffix);
|
|
3971
|
+
if (attempt) {
|
|
3972
|
+
return attempt;
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
if (this.#inString) {
|
|
3976
|
+
result = result.slice(0, this.#lastUnterminatedString);
|
|
3977
|
+
} else {
|
|
3978
|
+
result = stripChar(result, ":");
|
|
3979
|
+
if (result.endsWith('"')) {
|
|
3980
|
+
result = result.slice(0, this.#lastTerminatedString);
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
result = stripChar(result, ",");
|
|
3984
|
+
result += suffix;
|
|
3985
|
+
return _nullishCoalesce(tryParseJson(result), () => ( EMPTY_OBJECT));
|
|
3909
3986
|
}
|
|
3910
|
-
|
|
3911
|
-
return _nullishCoalesce(tryParseJson(result), () => ( {}));
|
|
3912
|
-
}
|
|
3987
|
+
};
|
|
3913
3988
|
|
|
3914
3989
|
// src/types/ai.ts
|
|
3915
3990
|
function patchContentWithDelta(content, delta) {
|
|
@@ -3933,28 +4008,16 @@ function patchContentWithDelta(content, delta) {
|
|
|
3933
4008
|
}
|
|
3934
4009
|
break;
|
|
3935
4010
|
case "tool-stream": {
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
stage: "receiving",
|
|
3941
|
-
invocationId: delta.invocationId,
|
|
3942
|
-
name: delta.name,
|
|
3943
|
-
partialArgsText: "",
|
|
3944
|
-
get partialArgs() {
|
|
3945
|
-
if (this.partialArgsText !== _cacheKey) {
|
|
3946
|
-
_cachedArgs = parsePartialJsonObject(this.partialArgsText);
|
|
3947
|
-
_cacheKey = this.partialArgsText;
|
|
3948
|
-
}
|
|
3949
|
-
return _cachedArgs;
|
|
3950
|
-
}
|
|
3951
|
-
};
|
|
4011
|
+
const toolInvocation = createReceivingToolInvocation(
|
|
4012
|
+
delta.invocationId,
|
|
4013
|
+
delta.name
|
|
4014
|
+
);
|
|
3952
4015
|
content.push(toolInvocation);
|
|
3953
4016
|
break;
|
|
3954
4017
|
}
|
|
3955
4018
|
case "tool-delta": {
|
|
3956
4019
|
if (_optionalChain([lastPart, 'optionalAccess', _57 => _57.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
3957
|
-
lastPart.
|
|
4020
|
+
_optionalChain([lastPart, 'access', _58 => _58.__appendDelta, 'optionalCall', _59 => _59(delta.delta)]);
|
|
3958
4021
|
}
|
|
3959
4022
|
break;
|
|
3960
4023
|
}
|
|
@@ -3974,6 +4037,25 @@ function patchContentWithDelta(content, delta) {
|
|
|
3974
4037
|
return assertNever(delta, "Unhandled case");
|
|
3975
4038
|
}
|
|
3976
4039
|
}
|
|
4040
|
+
function createReceivingToolInvocation(invocationId, name, partialArgsText = "") {
|
|
4041
|
+
const parser = new IncrementalJsonParser(partialArgsText);
|
|
4042
|
+
return {
|
|
4043
|
+
type: "tool-invocation",
|
|
4044
|
+
stage: "receiving",
|
|
4045
|
+
invocationId,
|
|
4046
|
+
name,
|
|
4047
|
+
get partialArgsText() {
|
|
4048
|
+
return parser.source;
|
|
4049
|
+
},
|
|
4050
|
+
get partialArgs() {
|
|
4051
|
+
return parser.json;
|
|
4052
|
+
},
|
|
4053
|
+
// Internal method to append deltas
|
|
4054
|
+
__appendDelta(delta) {
|
|
4055
|
+
parser.append(delta);
|
|
4056
|
+
}
|
|
4057
|
+
};
|
|
4058
|
+
}
|
|
3977
4059
|
|
|
3978
4060
|
// src/ai.ts
|
|
3979
4061
|
var DEFAULT_REQUEST_TIMEOUT = 4e3;
|
|
@@ -4056,7 +4138,7 @@ function createStore_forTools() {
|
|
|
4056
4138
|
return DerivedSignal.from(() => {
|
|
4057
4139
|
return (
|
|
4058
4140
|
// A tool that's registered and scoped to a specific chat ID...
|
|
4059
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4141
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _60 => _60.get, 'call', _61 => _61()]), () => ( // ...or a globally registered tool
|
|
4060
4142
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4061
4143
|
);
|
|
4062
4144
|
});
|
|
@@ -4086,8 +4168,8 @@ function createStore_forTools() {
|
|
|
4086
4168
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4087
4169
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4088
4170
|
return Array.from([
|
|
4089
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4090
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4171
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _62 => _62.entries, 'call', _63 => _63()]), () => ( [])),
|
|
4172
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _64 => _64.entries, 'call', _65 => _65()]), () => ( []))
|
|
4091
4173
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4092
4174
|
const tool = tool\u03A3.get();
|
|
4093
4175
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4190,7 +4272,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4190
4272
|
} else {
|
|
4191
4273
|
continue;
|
|
4192
4274
|
}
|
|
4193
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4275
|
+
const executeFn = _optionalChain([toolsStore, 'access', _66 => _66.getTool\u03A3, 'call', _67 => _67(toolInvocation.name, message.chatId), 'access', _68 => _68.get, 'call', _69 => _69(), 'optionalAccess', _70 => _70.execute]);
|
|
4194
4276
|
if (executeFn) {
|
|
4195
4277
|
(async () => {
|
|
4196
4278
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4289,8 +4371,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4289
4371
|
const spine = [];
|
|
4290
4372
|
let lastVisitedMessage = null;
|
|
4291
4373
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4292
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4293
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4374
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _71 => _71(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _72 => _72.id]), () => ( null));
|
|
4375
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _73 => _73(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _74 => _74.id]), () => ( null));
|
|
4294
4376
|
if (!message2.deletedAt || prev || next) {
|
|
4295
4377
|
const node = {
|
|
4296
4378
|
...message2,
|
|
@@ -4356,7 +4438,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4356
4438
|
const latest = pool.sorted.findRight(
|
|
4357
4439
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4358
4440
|
);
|
|
4359
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4441
|
+
return _optionalChain([latest, 'optionalAccess', _75 => _75.copilotId]);
|
|
4360
4442
|
}
|
|
4361
4443
|
return {
|
|
4362
4444
|
// Readers
|
|
@@ -4425,6 +4507,28 @@ function createAi(config) {
|
|
|
4425
4507
|
toolsStore,
|
|
4426
4508
|
knowledge: new KnowledgeStack()
|
|
4427
4509
|
};
|
|
4510
|
+
const DELTA_THROTTLE = 25;
|
|
4511
|
+
let pendingDeltas = [];
|
|
4512
|
+
let deltaBatchTimer = null;
|
|
4513
|
+
function flushPendingDeltas() {
|
|
4514
|
+
const currentQueue = pendingDeltas;
|
|
4515
|
+
pendingDeltas = [];
|
|
4516
|
+
if (deltaBatchTimer !== null) {
|
|
4517
|
+
clearTimeout(deltaBatchTimer);
|
|
4518
|
+
deltaBatchTimer = null;
|
|
4519
|
+
}
|
|
4520
|
+
batch(() => {
|
|
4521
|
+
for (const { id, delta } of currentQueue) {
|
|
4522
|
+
context.messagesStore.addDelta(id, delta);
|
|
4523
|
+
}
|
|
4524
|
+
});
|
|
4525
|
+
}
|
|
4526
|
+
function enqueueDelta(id, delta) {
|
|
4527
|
+
pendingDeltas.push({ id, delta });
|
|
4528
|
+
if (deltaBatchTimer === null) {
|
|
4529
|
+
deltaBatchTimer = setTimeout(flushPendingDeltas, DELTA_THROTTLE);
|
|
4530
|
+
}
|
|
4531
|
+
}
|
|
4428
4532
|
let lastTokenKey;
|
|
4429
4533
|
function onStatusDidChange(_newStatus) {
|
|
4430
4534
|
const authValue = managedSocket.authValue;
|
|
@@ -4464,6 +4568,7 @@ function createAi(config) {
|
|
|
4464
4568
|
function onDidConnect() {
|
|
4465
4569
|
}
|
|
4466
4570
|
function onDidDisconnect() {
|
|
4571
|
+
flushPendingDeltas();
|
|
4467
4572
|
}
|
|
4468
4573
|
function handleServerMessage(event) {
|
|
4469
4574
|
if (typeof event.data !== "string")
|
|
@@ -4478,50 +4583,51 @@ function createAi(config) {
|
|
|
4478
4583
|
return;
|
|
4479
4584
|
}
|
|
4480
4585
|
if ("event" in msg) {
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
case "warning":
|
|
4495
|
-
warn(msg.message);
|
|
4496
|
-
break;
|
|
4497
|
-
case "error":
|
|
4498
|
-
error2(msg.error);
|
|
4499
|
-
break;
|
|
4500
|
-
case "rebooted":
|
|
4501
|
-
context.messagesStore.failAllPending();
|
|
4502
|
-
break;
|
|
4503
|
-
case "sync":
|
|
4504
|
-
batch(() => {
|
|
4505
|
-
for (const m of _nullishCoalesce(msg["-messages"], () => ( []))) {
|
|
4506
|
-
context.messagesStore.remove(m.chatId, m.id);
|
|
4507
|
-
}
|
|
4508
|
-
for (const chatId of _nullishCoalesce(msg["-chats"], () => ( []))) {
|
|
4509
|
-
context.chatsStore.markDeleted(chatId);
|
|
4510
|
-
context.messagesStore.removeByChatId(chatId);
|
|
4511
|
-
}
|
|
4512
|
-
for (const chatId of _nullishCoalesce(msg.clear, () => ( []))) {
|
|
4513
|
-
context.messagesStore.removeByChatId(chatId);
|
|
4514
|
-
}
|
|
4515
|
-
if (msg.chats) {
|
|
4516
|
-
context.chatsStore.upsertMany(msg.chats);
|
|
4517
|
-
}
|
|
4518
|
-
if (msg.messages) {
|
|
4519
|
-
context.messagesStore.upsertMany(msg.messages);
|
|
4586
|
+
if (msg.event === "delta") {
|
|
4587
|
+
const { id, delta } = msg;
|
|
4588
|
+
enqueueDelta(id, delta);
|
|
4589
|
+
} else {
|
|
4590
|
+
batch(() => {
|
|
4591
|
+
flushPendingDeltas();
|
|
4592
|
+
switch (msg.event) {
|
|
4593
|
+
case "cmd-failed":
|
|
4594
|
+
_optionalChain([pendingCmd, 'optionalAccess', _76 => _76.reject, 'call', _77 => _77(new Error(msg.error))]);
|
|
4595
|
+
break;
|
|
4596
|
+
case "settle": {
|
|
4597
|
+
context.messagesStore.upsert(msg.message);
|
|
4598
|
+
break;
|
|
4520
4599
|
}
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4600
|
+
case "warning":
|
|
4601
|
+
warn(msg.message);
|
|
4602
|
+
break;
|
|
4603
|
+
case "error":
|
|
4604
|
+
error2(msg.error);
|
|
4605
|
+
break;
|
|
4606
|
+
case "rebooted":
|
|
4607
|
+
context.messagesStore.failAllPending();
|
|
4608
|
+
break;
|
|
4609
|
+
case "sync":
|
|
4610
|
+
for (const m of _nullishCoalesce(msg["-messages"], () => ( []))) {
|
|
4611
|
+
context.messagesStore.remove(m.chatId, m.id);
|
|
4612
|
+
}
|
|
4613
|
+
for (const chatId of _nullishCoalesce(msg["-chats"], () => ( []))) {
|
|
4614
|
+
context.chatsStore.markDeleted(chatId);
|
|
4615
|
+
context.messagesStore.removeByChatId(chatId);
|
|
4616
|
+
}
|
|
4617
|
+
for (const chatId of _nullishCoalesce(msg.clear, () => ( []))) {
|
|
4618
|
+
context.messagesStore.removeByChatId(chatId);
|
|
4619
|
+
}
|
|
4620
|
+
if (msg.chats) {
|
|
4621
|
+
context.chatsStore.upsertMany(msg.chats);
|
|
4622
|
+
}
|
|
4623
|
+
if (msg.messages) {
|
|
4624
|
+
context.messagesStore.upsertMany(msg.messages);
|
|
4625
|
+
}
|
|
4626
|
+
break;
|
|
4627
|
+
default:
|
|
4628
|
+
return assertNever(msg, "Unhandled case");
|
|
4629
|
+
}
|
|
4630
|
+
});
|
|
4525
4631
|
}
|
|
4526
4632
|
} else {
|
|
4527
4633
|
switch (msg.cmd) {
|
|
@@ -4562,7 +4668,7 @@ function createAi(config) {
|
|
|
4562
4668
|
return assertNever(msg, "Unhandled case");
|
|
4563
4669
|
}
|
|
4564
4670
|
}
|
|
4565
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4671
|
+
_optionalChain([pendingCmd, 'optionalAccess', _78 => _78.resolve, 'call', _79 => _79(msg)]);
|
|
4566
4672
|
}
|
|
4567
4673
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4568
4674
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4647,9 +4753,9 @@ function createAi(config) {
|
|
|
4647
4753
|
invocationId,
|
|
4648
4754
|
result,
|
|
4649
4755
|
generationOptions: {
|
|
4650
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4651
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4652
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4756
|
+
copilotId: _optionalChain([options, 'optionalAccess', _80 => _80.copilotId]),
|
|
4757
|
+
stream: _optionalChain([options, 'optionalAccess', _81 => _81.stream]),
|
|
4758
|
+
timeout: _optionalChain([options, 'optionalAccess', _82 => _82.timeout]),
|
|
4653
4759
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4654
4760
|
// from the global context
|
|
4655
4761
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -4678,7 +4784,7 @@ function createAi(config) {
|
|
|
4678
4784
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4679
4785
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4680
4786
|
const globalKnowledge = context.knowledge.get();
|
|
4681
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
4787
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _83 => _83.knowledge]) || [];
|
|
4682
4788
|
const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
|
|
4683
4789
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4684
4790
|
messagesStore.markMine(targetMessageId);
|
|
@@ -4688,9 +4794,9 @@ function createAi(config) {
|
|
|
4688
4794
|
sourceMessage: userMessage,
|
|
4689
4795
|
targetMessageId,
|
|
4690
4796
|
generationOptions: {
|
|
4691
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4692
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4693
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4797
|
+
copilotId: _optionalChain([options, 'optionalAccess', _84 => _84.copilotId]),
|
|
4798
|
+
stream: _optionalChain([options, 'optionalAccess', _85 => _85.stream]),
|
|
4799
|
+
timeout: _optionalChain([options, 'optionalAccess', _86 => _86.timeout]),
|
|
4694
4800
|
// Combine global knowledge with request-specific knowledge
|
|
4695
4801
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
4696
4802
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -4791,7 +4897,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4791
4897
|
return void 0;
|
|
4792
4898
|
}
|
|
4793
4899
|
async function makeAuthRequest(options) {
|
|
4794
|
-
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access',
|
|
4900
|
+
const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _87 => _87.polyfills, 'optionalAccess', _88 => _88.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
|
|
4795
4901
|
if (authentication.type === "private") {
|
|
4796
4902
|
if (fetcher === void 0) {
|
|
4797
4903
|
throw new StopRetrying(
|
|
@@ -4807,7 +4913,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4807
4913
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
4808
4914
|
);
|
|
4809
4915
|
}
|
|
4810
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4916
|
+
_optionalChain([onAuthenticate, 'optionalCall', _89 => _89(parsed.parsed)]);
|
|
4811
4917
|
return parsed;
|
|
4812
4918
|
}
|
|
4813
4919
|
if (authentication.type === "custom") {
|
|
@@ -4815,7 +4921,7 @@ function createAuthManager(authOptions, onAuthenticate) {
|
|
|
4815
4921
|
if (response && typeof response === "object") {
|
|
4816
4922
|
if (typeof response.token === "string") {
|
|
4817
4923
|
const parsed = parseAuthToken(response.token);
|
|
4818
|
-
_optionalChain([onAuthenticate, 'optionalCall',
|
|
4924
|
+
_optionalChain([onAuthenticate, 'optionalCall', _90 => _90(parsed.parsed)]);
|
|
4819
4925
|
return parsed;
|
|
4820
4926
|
} else if (typeof response.error === "string") {
|
|
4821
4927
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -4973,7 +5079,7 @@ function sendToPanel(message, options) {
|
|
|
4973
5079
|
...message,
|
|
4974
5080
|
source: "liveblocks-devtools-client"
|
|
4975
5081
|
};
|
|
4976
|
-
if (!(_optionalChain([options, 'optionalAccess',
|
|
5082
|
+
if (!(_optionalChain([options, 'optionalAccess', _91 => _91.force]) || _bridgeActive)) {
|
|
4977
5083
|
return;
|
|
4978
5084
|
}
|
|
4979
5085
|
window.postMessage(fullMsg, "*");
|
|
@@ -4981,7 +5087,7 @@ function sendToPanel(message, options) {
|
|
|
4981
5087
|
var eventSource = makeEventSource();
|
|
4982
5088
|
if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
4983
5089
|
window.addEventListener("message", (event) => {
|
|
4984
|
-
if (event.source === window && _optionalChain([event, 'access',
|
|
5090
|
+
if (event.source === window && _optionalChain([event, 'access', _92 => _92.data, 'optionalAccess', _93 => _93.source]) === "liveblocks-devtools-panel") {
|
|
4985
5091
|
eventSource.notify(event.data);
|
|
4986
5092
|
} else {
|
|
4987
5093
|
}
|
|
@@ -5123,7 +5229,7 @@ function fullSync(room) {
|
|
|
5123
5229
|
msg: "room::sync::full",
|
|
5124
5230
|
roomId: room.id,
|
|
5125
5231
|
status: room.getStatus(),
|
|
5126
|
-
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess',
|
|
5232
|
+
storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _94 => _94.toTreeNode, 'call', _95 => _95("root"), 'access', _96 => _96.payload]), () => ( null)),
|
|
5127
5233
|
me,
|
|
5128
5234
|
others
|
|
5129
5235
|
});
|
|
@@ -5414,7 +5520,7 @@ function createManagedPool(roomId, options) {
|
|
|
5414
5520
|
generateId: () => `${getCurrentConnectionId()}:${clock++}`,
|
|
5415
5521
|
generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
|
|
5416
5522
|
dispatch(ops, reverse, storageUpdates) {
|
|
5417
|
-
_optionalChain([onDispatch, 'optionalCall',
|
|
5523
|
+
_optionalChain([onDispatch, 'optionalCall', _97 => _97(ops, reverse, storageUpdates)]);
|
|
5418
5524
|
},
|
|
5419
5525
|
assertStorageIsWritable: () => {
|
|
5420
5526
|
if (!isStorageWritable()) {
|
|
@@ -5641,7 +5747,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
|
|
|
5641
5747
|
return [
|
|
5642
5748
|
{
|
|
5643
5749
|
type: 8 /* CREATE_REGISTER */,
|
|
5644
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5750
|
+
opId: _optionalChain([pool, 'optionalAccess', _98 => _98.generateOpId, 'call', _99 => _99()]),
|
|
5645
5751
|
id: this._id,
|
|
5646
5752
|
parentId,
|
|
5647
5753
|
parentKey,
|
|
@@ -5747,7 +5853,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
5747
5853
|
const ops = [];
|
|
5748
5854
|
const op = {
|
|
5749
5855
|
id: this._id,
|
|
5750
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
5856
|
+
opId: _optionalChain([pool, 'optionalAccess', _100 => _100.generateOpId, 'call', _101 => _101()]),
|
|
5751
5857
|
type: 2 /* CREATE_LIST */,
|
|
5752
5858
|
parentId,
|
|
5753
5859
|
parentKey
|
|
@@ -6018,7 +6124,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6018
6124
|
#applyInsertUndoRedo(op) {
|
|
6019
6125
|
const { id, parentKey: key } = op;
|
|
6020
6126
|
const child = creationOpToLiveNode(op);
|
|
6021
|
-
if (_optionalChain([this, 'access',
|
|
6127
|
+
if (_optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.getNode, 'call', _104 => _104(id)]) !== void 0) {
|
|
6022
6128
|
return { modified: false };
|
|
6023
6129
|
}
|
|
6024
6130
|
child._attach(id, nn(this._pool));
|
|
@@ -6026,8 +6132,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6026
6132
|
const existingItemIndex = this._indexOfPosition(key);
|
|
6027
6133
|
let newKey = key;
|
|
6028
6134
|
if (existingItemIndex !== -1) {
|
|
6029
|
-
const before2 = _optionalChain([this, 'access',
|
|
6030
|
-
const after2 = _optionalChain([this, 'access',
|
|
6135
|
+
const before2 = _optionalChain([this, 'access', _105 => _105.#items, 'access', _106 => _106[existingItemIndex], 'optionalAccess', _107 => _107._parentPos]);
|
|
6136
|
+
const after2 = _optionalChain([this, 'access', _108 => _108.#items, 'access', _109 => _109[existingItemIndex + 1], 'optionalAccess', _110 => _110._parentPos]);
|
|
6031
6137
|
newKey = makePosition(before2, after2);
|
|
6032
6138
|
child._setParentLink(this, newKey);
|
|
6033
6139
|
}
|
|
@@ -6041,7 +6147,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6041
6147
|
#applySetUndoRedo(op) {
|
|
6042
6148
|
const { id, parentKey: key } = op;
|
|
6043
6149
|
const child = creationOpToLiveNode(op);
|
|
6044
|
-
if (_optionalChain([this, 'access',
|
|
6150
|
+
if (_optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.getNode, 'call', _113 => _113(id)]) !== void 0) {
|
|
6045
6151
|
return { modified: false };
|
|
6046
6152
|
}
|
|
6047
6153
|
this.#unacknowledgedSets.set(key, nn(op.opId));
|
|
@@ -6162,7 +6268,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6162
6268
|
} else {
|
|
6163
6269
|
this.#items[existingItemIndex]._setParentLink(
|
|
6164
6270
|
this,
|
|
6165
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6271
|
+
makePosition(newKey, _optionalChain([this, 'access', _114 => _114.#items, 'access', _115 => _115[existingItemIndex + 1], 'optionalAccess', _116 => _116._parentPos]))
|
|
6166
6272
|
);
|
|
6167
6273
|
const previousIndex = this.#items.indexOf(child);
|
|
6168
6274
|
child._setParentLink(this, newKey);
|
|
@@ -6187,7 +6293,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6187
6293
|
if (existingItemIndex !== -1) {
|
|
6188
6294
|
this.#items[existingItemIndex]._setParentLink(
|
|
6189
6295
|
this,
|
|
6190
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6296
|
+
makePosition(newKey, _optionalChain([this, 'access', _117 => _117.#items, 'access', _118 => _118[existingItemIndex + 1], 'optionalAccess', _119 => _119._parentPos]))
|
|
6191
6297
|
);
|
|
6192
6298
|
}
|
|
6193
6299
|
child._setParentLink(this, newKey);
|
|
@@ -6206,7 +6312,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6206
6312
|
if (existingItemIndex !== -1) {
|
|
6207
6313
|
this.#items[existingItemIndex]._setParentLink(
|
|
6208
6314
|
this,
|
|
6209
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6315
|
+
makePosition(newKey, _optionalChain([this, 'access', _120 => _120.#items, 'access', _121 => _121[existingItemIndex + 1], 'optionalAccess', _122 => _122._parentPos]))
|
|
6210
6316
|
);
|
|
6211
6317
|
}
|
|
6212
6318
|
child._setParentLink(this, newKey);
|
|
@@ -6233,7 +6339,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6233
6339
|
if (existingItemIndex !== -1) {
|
|
6234
6340
|
this.#items[existingItemIndex]._setParentLink(
|
|
6235
6341
|
this,
|
|
6236
|
-
makePosition(newKey, _optionalChain([this, 'access',
|
|
6342
|
+
makePosition(newKey, _optionalChain([this, 'access', _123 => _123.#items, 'access', _124 => _124[existingItemIndex + 1], 'optionalAccess', _125 => _125._parentPos]))
|
|
6237
6343
|
);
|
|
6238
6344
|
}
|
|
6239
6345
|
child._setParentLink(this, newKey);
|
|
@@ -6291,7 +6397,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6291
6397
|
* @param element The element to add to the end of the LiveList.
|
|
6292
6398
|
*/
|
|
6293
6399
|
push(element) {
|
|
6294
|
-
_optionalChain([this, 'access',
|
|
6400
|
+
_optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
|
|
6295
6401
|
return this.insert(element, this.length);
|
|
6296
6402
|
}
|
|
6297
6403
|
/**
|
|
@@ -6300,7 +6406,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6300
6406
|
* @param index The index at which you want to insert the element.
|
|
6301
6407
|
*/
|
|
6302
6408
|
insert(element, index) {
|
|
6303
|
-
_optionalChain([this, 'access',
|
|
6409
|
+
_optionalChain([this, 'access', _129 => _129._pool, 'optionalAccess', _130 => _130.assertStorageIsWritable, 'call', _131 => _131()]);
|
|
6304
6410
|
if (index < 0 || index > this.#items.length) {
|
|
6305
6411
|
throw new Error(
|
|
6306
6412
|
`Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
|
|
@@ -6330,7 +6436,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6330
6436
|
* @param targetIndex The index where the element should be after moving.
|
|
6331
6437
|
*/
|
|
6332
6438
|
move(index, targetIndex) {
|
|
6333
|
-
_optionalChain([this, 'access',
|
|
6439
|
+
_optionalChain([this, 'access', _132 => _132._pool, 'optionalAccess', _133 => _133.assertStorageIsWritable, 'call', _134 => _134()]);
|
|
6334
6440
|
if (targetIndex < 0) {
|
|
6335
6441
|
throw new Error("targetIndex cannot be less than 0");
|
|
6336
6442
|
}
|
|
@@ -6388,7 +6494,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6388
6494
|
* @param index The index of the element to delete
|
|
6389
6495
|
*/
|
|
6390
6496
|
delete(index) {
|
|
6391
|
-
_optionalChain([this, 'access',
|
|
6497
|
+
_optionalChain([this, 'access', _135 => _135._pool, 'optionalAccess', _136 => _136.assertStorageIsWritable, 'call', _137 => _137()]);
|
|
6392
6498
|
if (index < 0 || index >= this.#items.length) {
|
|
6393
6499
|
throw new Error(
|
|
6394
6500
|
`Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6421,7 +6527,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6421
6527
|
}
|
|
6422
6528
|
}
|
|
6423
6529
|
clear() {
|
|
6424
|
-
_optionalChain([this, 'access',
|
|
6530
|
+
_optionalChain([this, 'access', _138 => _138._pool, 'optionalAccess', _139 => _139.assertStorageIsWritable, 'call', _140 => _140()]);
|
|
6425
6531
|
if (this._pool) {
|
|
6426
6532
|
const ops = [];
|
|
6427
6533
|
const reverseOps = [];
|
|
@@ -6455,7 +6561,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6455
6561
|
}
|
|
6456
6562
|
}
|
|
6457
6563
|
set(index, item) {
|
|
6458
|
-
_optionalChain([this, 'access',
|
|
6564
|
+
_optionalChain([this, 'access', _141 => _141._pool, 'optionalAccess', _142 => _142.assertStorageIsWritable, 'call', _143 => _143()]);
|
|
6459
6565
|
if (index < 0 || index >= this.#items.length) {
|
|
6460
6566
|
throw new Error(
|
|
6461
6567
|
`Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
|
|
@@ -6601,7 +6707,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
|
|
|
6601
6707
|
#shiftItemPosition(index, key) {
|
|
6602
6708
|
const shiftedPosition = makePosition(
|
|
6603
6709
|
key,
|
|
6604
|
-
this.#items.length > index + 1 ? _optionalChain([this, 'access',
|
|
6710
|
+
this.#items.length > index + 1 ? _optionalChain([this, 'access', _144 => _144.#items, 'access', _145 => _145[index + 1], 'optionalAccess', _146 => _146._parentPos]) : void 0
|
|
6605
6711
|
);
|
|
6606
6712
|
this.#items[index]._setParentLink(this, shiftedPosition);
|
|
6607
6713
|
}
|
|
@@ -6726,7 +6832,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6726
6832
|
const ops = [];
|
|
6727
6833
|
const op = {
|
|
6728
6834
|
id: this._id,
|
|
6729
|
-
opId: _optionalChain([pool, 'optionalAccess',
|
|
6835
|
+
opId: _optionalChain([pool, 'optionalAccess', _147 => _147.generateOpId, 'call', _148 => _148()]),
|
|
6730
6836
|
type: 7 /* CREATE_MAP */,
|
|
6731
6837
|
parentId,
|
|
6732
6838
|
parentKey
|
|
@@ -6861,7 +6967,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6861
6967
|
* @param value The value of the element to add. Should be serializable to JSON.
|
|
6862
6968
|
*/
|
|
6863
6969
|
set(key, value) {
|
|
6864
|
-
_optionalChain([this, 'access',
|
|
6970
|
+
_optionalChain([this, 'access', _149 => _149._pool, 'optionalAccess', _150 => _150.assertStorageIsWritable, 'call', _151 => _151()]);
|
|
6865
6971
|
const oldValue = this.#map.get(key);
|
|
6866
6972
|
if (oldValue) {
|
|
6867
6973
|
oldValue._detach();
|
|
@@ -6907,7 +7013,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6907
7013
|
* @returns true if an element existed and has been removed, or false if the element does not exist.
|
|
6908
7014
|
*/
|
|
6909
7015
|
delete(key) {
|
|
6910
|
-
_optionalChain([this, 'access',
|
|
7016
|
+
_optionalChain([this, 'access', _152 => _152._pool, 'optionalAccess', _153 => _153.assertStorageIsWritable, 'call', _154 => _154()]);
|
|
6911
7017
|
const item = this.#map.get(key);
|
|
6912
7018
|
if (item === void 0) {
|
|
6913
7019
|
return false;
|
|
@@ -7097,7 +7203,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7097
7203
|
if (this._id === void 0) {
|
|
7098
7204
|
throw new Error("Cannot serialize item is not attached");
|
|
7099
7205
|
}
|
|
7100
|
-
const opId = _optionalChain([pool, 'optionalAccess',
|
|
7206
|
+
const opId = _optionalChain([pool, 'optionalAccess', _155 => _155.generateOpId, 'call', _156 => _156()]);
|
|
7101
7207
|
const ops = [];
|
|
7102
7208
|
const op = {
|
|
7103
7209
|
type: 4 /* CREATE_OBJECT */,
|
|
@@ -7369,7 +7475,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7369
7475
|
* @param value The value of the property to add
|
|
7370
7476
|
*/
|
|
7371
7477
|
set(key, value) {
|
|
7372
|
-
_optionalChain([this, 'access',
|
|
7478
|
+
_optionalChain([this, 'access', _157 => _157._pool, 'optionalAccess', _158 => _158.assertStorageIsWritable, 'call', _159 => _159()]);
|
|
7373
7479
|
this.update({ [key]: value });
|
|
7374
7480
|
}
|
|
7375
7481
|
/**
|
|
@@ -7384,7 +7490,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7384
7490
|
* @param key The key of the property to delete
|
|
7385
7491
|
*/
|
|
7386
7492
|
delete(key) {
|
|
7387
|
-
_optionalChain([this, 'access',
|
|
7493
|
+
_optionalChain([this, 'access', _160 => _160._pool, 'optionalAccess', _161 => _161.assertStorageIsWritable, 'call', _162 => _162()]);
|
|
7388
7494
|
const keyAsString = key;
|
|
7389
7495
|
const oldValue = this.#map.get(keyAsString);
|
|
7390
7496
|
if (oldValue === void 0) {
|
|
@@ -7437,7 +7543,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
|
|
|
7437
7543
|
* @param patch The object used to overrides properties
|
|
7438
7544
|
*/
|
|
7439
7545
|
update(patch) {
|
|
7440
|
-
_optionalChain([this, 'access',
|
|
7546
|
+
_optionalChain([this, 'access', _163 => _163._pool, 'optionalAccess', _164 => _164.assertStorageIsWritable, 'call', _165 => _165()]);
|
|
7441
7547
|
if (_LiveObject.detectLargeObjects) {
|
|
7442
7548
|
const data = {};
|
|
7443
7549
|
for (const [key, value] of this.#map) {
|
|
@@ -8185,15 +8291,15 @@ function installBackgroundTabSpy() {
|
|
|
8185
8291
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
8186
8292
|
const inBackgroundSince = { current: null };
|
|
8187
8293
|
function onVisibilityChange() {
|
|
8188
|
-
if (_optionalChain([doc, 'optionalAccess',
|
|
8294
|
+
if (_optionalChain([doc, 'optionalAccess', _166 => _166.visibilityState]) === "hidden") {
|
|
8189
8295
|
inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
|
|
8190
8296
|
} else {
|
|
8191
8297
|
inBackgroundSince.current = null;
|
|
8192
8298
|
}
|
|
8193
8299
|
}
|
|
8194
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8300
|
+
_optionalChain([doc, 'optionalAccess', _167 => _167.addEventListener, 'call', _168 => _168("visibilitychange", onVisibilityChange)]);
|
|
8195
8301
|
const unsub = () => {
|
|
8196
|
-
_optionalChain([doc, 'optionalAccess',
|
|
8302
|
+
_optionalChain([doc, 'optionalAccess', _169 => _169.removeEventListener, 'call', _170 => _170("visibilitychange", onVisibilityChange)]);
|
|
8197
8303
|
};
|
|
8198
8304
|
return [inBackgroundSince, unsub];
|
|
8199
8305
|
}
|
|
@@ -8373,7 +8479,7 @@ function createRoom(options, config) {
|
|
|
8373
8479
|
}
|
|
8374
8480
|
}
|
|
8375
8481
|
function isStorageWritable() {
|
|
8376
|
-
const scopes = _optionalChain([context, 'access',
|
|
8482
|
+
const scopes = _optionalChain([context, 'access', _171 => _171.dynamicSessionInfoSig, 'access', _172 => _172.get, 'call', _173 => _173(), 'optionalAccess', _174 => _174.scopes]);
|
|
8377
8483
|
return scopes !== void 0 ? canWriteStorage(scopes) : true;
|
|
8378
8484
|
}
|
|
8379
8485
|
const eventHub = {
|
|
@@ -8499,7 +8605,7 @@ function createRoom(options, config) {
|
|
|
8499
8605
|
}
|
|
8500
8606
|
case "experimental-fallback-to-http": {
|
|
8501
8607
|
warn("Message is too large for websockets, so sending over HTTP instead");
|
|
8502
|
-
const nonce = _nullishCoalesce(_optionalChain([context, 'access',
|
|
8608
|
+
const nonce = _nullishCoalesce(_optionalChain([context, 'access', _175 => _175.dynamicSessionInfoSig, 'access', _176 => _176.get, 'call', _177 => _177(), 'optionalAccess', _178 => _178.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
|
|
8503
8609
|
void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
|
|
8504
8610
|
if (!resp.ok && resp.status === 403) {
|
|
8505
8611
|
managedSocket.reconnect();
|
|
@@ -8550,7 +8656,7 @@ function createRoom(options, config) {
|
|
|
8550
8656
|
} else {
|
|
8551
8657
|
context.root = LiveObject._fromItems(message.items, context.pool);
|
|
8552
8658
|
}
|
|
8553
|
-
const canWrite = _nullishCoalesce(_optionalChain([self, 'access',
|
|
8659
|
+
const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _179 => _179.get, 'call', _180 => _180(), 'optionalAccess', _181 => _181.canWrite]), () => ( true));
|
|
8554
8660
|
const stackSizeBefore = context.undoStack.length;
|
|
8555
8661
|
for (const key in context.initialStorage) {
|
|
8556
8662
|
if (context.root.get(key) === void 0) {
|
|
@@ -8753,7 +8859,7 @@ function createRoom(options, config) {
|
|
|
8753
8859
|
}
|
|
8754
8860
|
context.myPresence.patch(patch);
|
|
8755
8861
|
if (context.activeBatch) {
|
|
8756
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8862
|
+
if (_optionalChain([options2, 'optionalAccess', _182 => _182.addToHistory])) {
|
|
8757
8863
|
context.activeBatch.reverseOps.pushLeft({
|
|
8758
8864
|
type: "presence",
|
|
8759
8865
|
data: oldValues
|
|
@@ -8762,7 +8868,7 @@ function createRoom(options, config) {
|
|
|
8762
8868
|
context.activeBatch.updates.presence = true;
|
|
8763
8869
|
} else {
|
|
8764
8870
|
flushNowOrSoon();
|
|
8765
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
8871
|
+
if (_optionalChain([options2, 'optionalAccess', _183 => _183.addToHistory])) {
|
|
8766
8872
|
addToUndoStack([{ type: "presence", data: oldValues }]);
|
|
8767
8873
|
}
|
|
8768
8874
|
notify({ presence: true });
|
|
@@ -8959,7 +9065,7 @@ function createRoom(options, config) {
|
|
|
8959
9065
|
if (process.env.NODE_ENV !== "production") {
|
|
8960
9066
|
const traces = /* @__PURE__ */ new Set();
|
|
8961
9067
|
for (const opId of message.opIds) {
|
|
8962
|
-
const trace = _optionalChain([context, 'access',
|
|
9068
|
+
const trace = _optionalChain([context, 'access', _184 => _184.opStackTraces, 'optionalAccess', _185 => _185.get, 'call', _186 => _186(opId)]);
|
|
8963
9069
|
if (trace) {
|
|
8964
9070
|
traces.add(trace);
|
|
8965
9071
|
}
|
|
@@ -9093,7 +9199,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9093
9199
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9094
9200
|
createOrUpdateRootFromMessage(message);
|
|
9095
9201
|
applyAndSendOps(unacknowledgedOps);
|
|
9096
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
9202
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _187 => _187()]);
|
|
9097
9203
|
notifyStorageStatus();
|
|
9098
9204
|
eventHub.storageDidLoad.notify();
|
|
9099
9205
|
}
|
|
@@ -9314,8 +9420,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9314
9420
|
async function getThreads(options2) {
|
|
9315
9421
|
return httpClient.getThreads({
|
|
9316
9422
|
roomId,
|
|
9317
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
9318
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9423
|
+
query: _optionalChain([options2, 'optionalAccess', _188 => _188.query]),
|
|
9424
|
+
cursor: _optionalChain([options2, 'optionalAccess', _189 => _189.cursor])
|
|
9319
9425
|
});
|
|
9320
9426
|
}
|
|
9321
9427
|
async function getThread(threadId) {
|
|
@@ -9422,7 +9528,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9422
9528
|
function getSubscriptionSettings(options2) {
|
|
9423
9529
|
return httpClient.getSubscriptionSettings({
|
|
9424
9530
|
roomId,
|
|
9425
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9531
|
+
signal: _optionalChain([options2, 'optionalAccess', _190 => _190.signal])
|
|
9426
9532
|
});
|
|
9427
9533
|
}
|
|
9428
9534
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9444,7 +9550,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9444
9550
|
{
|
|
9445
9551
|
[kInternal]: {
|
|
9446
9552
|
get presenceBuffer() {
|
|
9447
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9553
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _191 => _191.buffer, 'access', _192 => _192.presenceUpdates, 'optionalAccess', _193 => _193.data]), () => ( null)));
|
|
9448
9554
|
},
|
|
9449
9555
|
// prettier-ignore
|
|
9450
9556
|
get undoStack() {
|
|
@@ -9459,9 +9565,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9459
9565
|
return context.yjsProvider;
|
|
9460
9566
|
},
|
|
9461
9567
|
setYjsProvider(newProvider) {
|
|
9462
|
-
_optionalChain([context, 'access',
|
|
9568
|
+
_optionalChain([context, 'access', _194 => _194.yjsProvider, 'optionalAccess', _195 => _195.off, 'call', _196 => _196("status", yjsStatusDidChange)]);
|
|
9463
9569
|
context.yjsProvider = newProvider;
|
|
9464
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9570
|
+
_optionalChain([newProvider, 'optionalAccess', _197 => _197.on, 'call', _198 => _198("status", yjsStatusDidChange)]);
|
|
9465
9571
|
context.yjsProviderDidChange.notify();
|
|
9466
9572
|
},
|
|
9467
9573
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9507,7 +9613,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9507
9613
|
source.dispose();
|
|
9508
9614
|
}
|
|
9509
9615
|
eventHub.roomWillDestroy.notify();
|
|
9510
|
-
_optionalChain([context, 'access',
|
|
9616
|
+
_optionalChain([context, 'access', _199 => _199.yjsProvider, 'optionalAccess', _200 => _200.off, 'call', _201 => _201("status", yjsStatusDidChange)]);
|
|
9511
9617
|
syncSourceForStorage.destroy();
|
|
9512
9618
|
syncSourceForYjs.destroy();
|
|
9513
9619
|
uninstallBgTabSpy();
|
|
@@ -9657,7 +9763,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9657
9763
|
}
|
|
9658
9764
|
if (isLiveNode(first)) {
|
|
9659
9765
|
const node = first;
|
|
9660
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9766
|
+
if (_optionalChain([options, 'optionalAccess', _202 => _202.isDeep])) {
|
|
9661
9767
|
const storageCallback = second;
|
|
9662
9768
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9663
9769
|
} else {
|
|
@@ -9736,8 +9842,8 @@ function createClient(options) {
|
|
|
9736
9842
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
9737
9843
|
currentUserId.set(() => userId);
|
|
9738
9844
|
});
|
|
9739
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
9740
|
-
_optionalChain([globalThis, 'access',
|
|
9845
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _203 => _203.polyfills, 'optionalAccess', _204 => _204.fetch]) || /* istanbul ignore next */
|
|
9846
|
+
_optionalChain([globalThis, 'access', _205 => _205.fetch, 'optionalAccess', _206 => _206.bind, 'call', _207 => _207(globalThis)]);
|
|
9741
9847
|
const httpClient = createApiClient({
|
|
9742
9848
|
baseUrl,
|
|
9743
9849
|
fetchPolyfill,
|
|
@@ -9755,7 +9861,7 @@ function createClient(options) {
|
|
|
9755
9861
|
delegates: {
|
|
9756
9862
|
createSocket: makeCreateSocketDelegateForAi(
|
|
9757
9863
|
baseUrl,
|
|
9758
|
-
_optionalChain([clientOptions, 'access',
|
|
9864
|
+
_optionalChain([clientOptions, 'access', _208 => _208.polyfills, 'optionalAccess', _209 => _209.WebSocket])
|
|
9759
9865
|
),
|
|
9760
9866
|
authenticate: async () => {
|
|
9761
9867
|
const resp = await authManager.getAuthValue({
|
|
@@ -9823,7 +9929,7 @@ function createClient(options) {
|
|
|
9823
9929
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
9824
9930
|
roomId,
|
|
9825
9931
|
baseUrl,
|
|
9826
|
-
_optionalChain([clientOptions, 'access',
|
|
9932
|
+
_optionalChain([clientOptions, 'access', _210 => _210.polyfills, 'optionalAccess', _211 => _211.WebSocket])
|
|
9827
9933
|
),
|
|
9828
9934
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
9829
9935
|
})),
|
|
@@ -9846,7 +9952,7 @@ function createClient(options) {
|
|
|
9846
9952
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
9847
9953
|
if (shouldConnect) {
|
|
9848
9954
|
if (typeof atob === "undefined") {
|
|
9849
|
-
if (_optionalChain([clientOptions, 'access',
|
|
9955
|
+
if (_optionalChain([clientOptions, 'access', _212 => _212.polyfills, 'optionalAccess', _213 => _213.atob]) === void 0) {
|
|
9850
9956
|
throw new Error(
|
|
9851
9957
|
"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"
|
|
9852
9958
|
);
|
|
@@ -9858,7 +9964,7 @@ function createClient(options) {
|
|
|
9858
9964
|
return leaseRoom(newRoomDetails);
|
|
9859
9965
|
}
|
|
9860
9966
|
function getRoom(roomId) {
|
|
9861
|
-
const room = _optionalChain([roomsById, 'access',
|
|
9967
|
+
const room = _optionalChain([roomsById, 'access', _214 => _214.get, 'call', _215 => _215(roomId), 'optionalAccess', _216 => _216.room]);
|
|
9862
9968
|
return room ? room : null;
|
|
9863
9969
|
}
|
|
9864
9970
|
function logout() {
|
|
@@ -9878,7 +9984,7 @@ function createClient(options) {
|
|
|
9878
9984
|
const batchedResolveUsers = new Batch(
|
|
9879
9985
|
async (batchedUserIds) => {
|
|
9880
9986
|
const userIds = batchedUserIds.flat();
|
|
9881
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
9987
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _217 => _217({ userIds })]);
|
|
9882
9988
|
warnIfNoResolveUsers();
|
|
9883
9989
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
9884
9990
|
},
|
|
@@ -9896,7 +10002,7 @@ function createClient(options) {
|
|
|
9896
10002
|
const batchedResolveRoomsInfo = new Batch(
|
|
9897
10003
|
async (batchedRoomIds) => {
|
|
9898
10004
|
const roomIds = batchedRoomIds.flat();
|
|
9899
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
10005
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _218 => _218({ roomIds })]);
|
|
9900
10006
|
warnIfNoResolveRoomsInfo();
|
|
9901
10007
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
9902
10008
|
},
|
|
@@ -9949,7 +10055,7 @@ function createClient(options) {
|
|
|
9949
10055
|
}
|
|
9950
10056
|
};
|
|
9951
10057
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
9952
|
-
_optionalChain([win, 'optionalAccess',
|
|
10058
|
+
_optionalChain([win, 'optionalAccess', _219 => _219.addEventListener, 'call', _220 => _220("beforeunload", maybePreventClose)]);
|
|
9953
10059
|
}
|
|
9954
10060
|
async function getNotificationSettings(options2) {
|
|
9955
10061
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -10088,7 +10194,7 @@ var commentBodyElementsTypes = {
|
|
|
10088
10194
|
mention: "inline"
|
|
10089
10195
|
};
|
|
10090
10196
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
10091
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
10197
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _221 => _221.content])) {
|
|
10092
10198
|
return;
|
|
10093
10199
|
}
|
|
10094
10200
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -10098,13 +10204,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
10098
10204
|
for (const block of body.content) {
|
|
10099
10205
|
if (type === "all" || type === "block") {
|
|
10100
10206
|
if (guard(block)) {
|
|
10101
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10207
|
+
_optionalChain([visitor, 'optionalCall', _222 => _222(block)]);
|
|
10102
10208
|
}
|
|
10103
10209
|
}
|
|
10104
10210
|
if (type === "all" || type === "inline") {
|
|
10105
10211
|
for (const inline of block.children) {
|
|
10106
10212
|
if (guard(inline)) {
|
|
10107
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10213
|
+
_optionalChain([visitor, 'optionalCall', _223 => _223(inline)]);
|
|
10108
10214
|
}
|
|
10109
10215
|
}
|
|
10110
10216
|
}
|
|
@@ -10138,7 +10244,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
10138
10244
|
userIds
|
|
10139
10245
|
});
|
|
10140
10246
|
for (const [index, userId] of userIds.entries()) {
|
|
10141
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
10247
|
+
const user = _optionalChain([users, 'optionalAccess', _224 => _224[index]]);
|
|
10142
10248
|
if (user) {
|
|
10143
10249
|
resolvedUsers.set(userId, user);
|
|
10144
10250
|
}
|
|
@@ -10257,7 +10363,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
10257
10363
|
text: ({ element }) => element.text,
|
|
10258
10364
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
10259
10365
|
mention: ({ element, user }) => {
|
|
10260
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10366
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _225 => _225.name]), () => ( element.id))}`;
|
|
10261
10367
|
}
|
|
10262
10368
|
};
|
|
10263
10369
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -10287,7 +10393,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
10287
10393
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
10288
10394
|
},
|
|
10289
10395
|
mention: ({ element, user }) => {
|
|
10290
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
10396
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _226 => _226.name]) ? html`${_optionalChain([user, 'optionalAccess', _227 => _227.name])}` : element.id}</span>`;
|
|
10291
10397
|
}
|
|
10292
10398
|
};
|
|
10293
10399
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -10317,19 +10423,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
10317
10423
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
10318
10424
|
},
|
|
10319
10425
|
mention: ({ element, user }) => {
|
|
10320
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10426
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _228 => _228.name]), () => ( element.id))}`;
|
|
10321
10427
|
}
|
|
10322
10428
|
};
|
|
10323
10429
|
async function stringifyCommentBody(body, options) {
|
|
10324
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10325
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10430
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _229 => _229.format]), () => ( "plain"));
|
|
10431
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
10326
10432
|
const elements = {
|
|
10327
10433
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
10328
|
-
..._optionalChain([options, 'optionalAccess',
|
|
10434
|
+
..._optionalChain([options, 'optionalAccess', _231 => _231.elements])
|
|
10329
10435
|
};
|
|
10330
10436
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
10331
10437
|
body,
|
|
10332
|
-
_optionalChain([options, 'optionalAccess',
|
|
10438
|
+
_optionalChain([options, 'optionalAccess', _232 => _232.resolveUsers])
|
|
10333
10439
|
);
|
|
10334
10440
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
10335
10441
|
switch (block.type) {
|
|
@@ -10615,12 +10721,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10615
10721
|
}
|
|
10616
10722
|
const newState = Object.assign({}, state);
|
|
10617
10723
|
for (const key in update.updates) {
|
|
10618
|
-
if (_optionalChain([update, 'access',
|
|
10724
|
+
if (_optionalChain([update, 'access', _233 => _233.updates, 'access', _234 => _234[key], 'optionalAccess', _235 => _235.type]) === "update") {
|
|
10619
10725
|
const val = update.node.get(key);
|
|
10620
10726
|
if (val !== void 0) {
|
|
10621
10727
|
newState[key] = lsonToJson(val);
|
|
10622
10728
|
}
|
|
10623
|
-
} else if (_optionalChain([update, 'access',
|
|
10729
|
+
} else if (_optionalChain([update, 'access', _236 => _236.updates, 'access', _237 => _237[key], 'optionalAccess', _238 => _238.type]) === "delete") {
|
|
10624
10730
|
delete newState[key];
|
|
10625
10731
|
}
|
|
10626
10732
|
}
|
|
@@ -10681,12 +10787,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10681
10787
|
}
|
|
10682
10788
|
const newState = Object.assign({}, state);
|
|
10683
10789
|
for (const key in update.updates) {
|
|
10684
|
-
if (_optionalChain([update, 'access',
|
|
10790
|
+
if (_optionalChain([update, 'access', _239 => _239.updates, 'access', _240 => _240[key], 'optionalAccess', _241 => _241.type]) === "update") {
|
|
10685
10791
|
const value = update.node.get(key);
|
|
10686
10792
|
if (value !== void 0) {
|
|
10687
10793
|
newState[key] = lsonToJson(value);
|
|
10688
10794
|
}
|
|
10689
|
-
} else if (_optionalChain([update, 'access',
|
|
10795
|
+
} else if (_optionalChain([update, 'access', _242 => _242.updates, 'access', _243 => _243[key], 'optionalAccess', _244 => _244.type]) === "delete") {
|
|
10690
10796
|
delete newState[key];
|
|
10691
10797
|
}
|
|
10692
10798
|
}
|
|
@@ -10766,9 +10872,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10766
10872
|
const startTime = performance.now();
|
|
10767
10873
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
10768
10874
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10769
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10875
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
10770
10876
|
const context = {
|
|
10771
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
10877
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _246 => _246.visibilityState]) !== "hidden",
|
|
10772
10878
|
lastSuccessfulPollAt: startTime,
|
|
10773
10879
|
count: 0,
|
|
10774
10880
|
backoff: 0
|
|
@@ -10849,11 +10955,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
10849
10955
|
pollNowIfStale();
|
|
10850
10956
|
}
|
|
10851
10957
|
function onVisibilityChange() {
|
|
10852
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
10958
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _247 => _247.visibilityState]) !== "hidden");
|
|
10853
10959
|
}
|
|
10854
|
-
_optionalChain([doc, 'optionalAccess',
|
|
10855
|
-
_optionalChain([win, 'optionalAccess',
|
|
10856
|
-
_optionalChain([win, 'optionalAccess',
|
|
10960
|
+
_optionalChain([doc, 'optionalAccess', _248 => _248.addEventListener, 'call', _249 => _249("visibilitychange", onVisibilityChange)]);
|
|
10961
|
+
_optionalChain([win, 'optionalAccess', _250 => _250.addEventListener, 'call', _251 => _251("online", onVisibilityChange)]);
|
|
10962
|
+
_optionalChain([win, 'optionalAccess', _252 => _252.addEventListener, 'call', _253 => _253("focus", pollNowIfStale)]);
|
|
10857
10963
|
fsm.start();
|
|
10858
10964
|
return {
|
|
10859
10965
|
inc,
|