@liveblocks/core 3.8.1 → 3.9.1-tiptap1
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 +411 -439
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -19
- package/dist/index.d.ts +46 -19
- package/dist/index.js +348 -376
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "3.
|
|
9
|
+
var PKG_VERSION = "3.9.1-tiptap1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2387,6 +2387,14 @@ function createApiClient({
|
|
|
2387
2387
|
function getGroup(groupId) {
|
|
2388
2388
|
return batchedGetGroups.get(groupId);
|
|
2389
2389
|
}
|
|
2390
|
+
async function getUrlMetadata(_url) {
|
|
2391
|
+
const { metadata } = await httpClient.get(
|
|
2392
|
+
url`/v2/c/urls/metadata`,
|
|
2393
|
+
await authManager.getAuthValue({ requestedScope: "comments:read" }),
|
|
2394
|
+
{ url: _url }
|
|
2395
|
+
);
|
|
2396
|
+
return metadata;
|
|
2397
|
+
}
|
|
2390
2398
|
return {
|
|
2391
2399
|
// Room threads
|
|
2392
2400
|
getThreads,
|
|
@@ -2444,7 +2452,9 @@ function createApiClient({
|
|
|
2444
2452
|
groupsStore,
|
|
2445
2453
|
getGroup,
|
|
2446
2454
|
// AI
|
|
2447
|
-
executeContextualPrompt
|
|
2455
|
+
executeContextualPrompt,
|
|
2456
|
+
// URL metadata
|
|
2457
|
+
getUrlMetadata
|
|
2448
2458
|
};
|
|
2449
2459
|
}
|
|
2450
2460
|
function getBearerTokenFromAuthValue(authValue) {
|
|
@@ -3059,7 +3069,6 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
|
|
|
3059
3069
|
ServerMsgCode2[ServerMsgCode2["ROOM_STATE"] = 104] = "ROOM_STATE";
|
|
3060
3070
|
ServerMsgCode2[ServerMsgCode2["INITIAL_STORAGE_STATE"] = 200] = "INITIAL_STORAGE_STATE";
|
|
3061
3071
|
ServerMsgCode2[ServerMsgCode2["UPDATE_STORAGE"] = 201] = "UPDATE_STORAGE";
|
|
3062
|
-
ServerMsgCode2[ServerMsgCode2["REJECT_STORAGE_OP"] = 299] = "REJECT_STORAGE_OP";
|
|
3063
3072
|
ServerMsgCode2[ServerMsgCode2["UPDATE_YDOC"] = 300] = "UPDATE_YDOC";
|
|
3064
3073
|
ServerMsgCode2[ServerMsgCode2["THREAD_CREATED"] = 400] = "THREAD_CREATED";
|
|
3065
3074
|
ServerMsgCode2[ServerMsgCode2["THREAD_DELETED"] = 407] = "THREAD_DELETED";
|
|
@@ -3070,6 +3079,7 @@ var ServerMsgCode = /* @__PURE__ */ ((ServerMsgCode2) => {
|
|
|
3070
3079
|
ServerMsgCode2[ServerMsgCode2["COMMENT_DELETED"] = 404] = "COMMENT_DELETED";
|
|
3071
3080
|
ServerMsgCode2[ServerMsgCode2["COMMENT_REACTION_ADDED"] = 405] = "COMMENT_REACTION_ADDED";
|
|
3072
3081
|
ServerMsgCode2[ServerMsgCode2["COMMENT_REACTION_REMOVED"] = 406] = "COMMENT_REACTION_REMOVED";
|
|
3082
|
+
ServerMsgCode2[ServerMsgCode2["REJECT_STORAGE_OP"] = 299] = "REJECT_STORAGE_OP";
|
|
3073
3083
|
return ServerMsgCode2;
|
|
3074
3084
|
})(ServerMsgCode || {});
|
|
3075
3085
|
|
|
@@ -3697,240 +3707,6 @@ var ManagedSocket = class {
|
|
|
3697
3707
|
// src/internal.ts
|
|
3698
3708
|
var kInternal = Symbol();
|
|
3699
3709
|
|
|
3700
|
-
// src/lib/shallow.ts
|
|
3701
|
-
function shallowArray(xs, ys) {
|
|
3702
|
-
if (xs.length !== ys.length) {
|
|
3703
|
-
return false;
|
|
3704
|
-
}
|
|
3705
|
-
for (let i = 0; i < xs.length; i++) {
|
|
3706
|
-
if (!Object.is(xs[i], ys[i])) {
|
|
3707
|
-
return false;
|
|
3708
|
-
}
|
|
3709
|
-
}
|
|
3710
|
-
return true;
|
|
3711
|
-
}
|
|
3712
|
-
function shallowObj(objA, objB) {
|
|
3713
|
-
if (!isPlainObject(objA) || !isPlainObject(objB)) {
|
|
3714
|
-
return false;
|
|
3715
|
-
}
|
|
3716
|
-
const keysA = Object.keys(objA);
|
|
3717
|
-
if (keysA.length !== Object.keys(objB).length) {
|
|
3718
|
-
return false;
|
|
3719
|
-
}
|
|
3720
|
-
return keysA.every(
|
|
3721
|
-
(key) => Object.prototype.hasOwnProperty.call(objB, key) && Object.is(objA[key], objB[key])
|
|
3722
|
-
);
|
|
3723
|
-
}
|
|
3724
|
-
function shallow(a, b) {
|
|
3725
|
-
if (Object.is(a, b)) {
|
|
3726
|
-
return true;
|
|
3727
|
-
}
|
|
3728
|
-
const isArrayA = Array.isArray(a);
|
|
3729
|
-
const isArrayB = Array.isArray(b);
|
|
3730
|
-
if (isArrayA || isArrayB) {
|
|
3731
|
-
if (!isArrayA || !isArrayB) {
|
|
3732
|
-
return false;
|
|
3733
|
-
}
|
|
3734
|
-
return shallowArray(a, b);
|
|
3735
|
-
}
|
|
3736
|
-
return shallowObj(a, b);
|
|
3737
|
-
}
|
|
3738
|
-
function shallow2(a, b) {
|
|
3739
|
-
if (!isPlainObject(a) || !isPlainObject(b)) {
|
|
3740
|
-
return shallow(a, b);
|
|
3741
|
-
}
|
|
3742
|
-
const keysA = Object.keys(a);
|
|
3743
|
-
if (keysA.length !== Object.keys(b).length) {
|
|
3744
|
-
return false;
|
|
3745
|
-
}
|
|
3746
|
-
return keysA.every(
|
|
3747
|
-
(key) => Object.prototype.hasOwnProperty.call(b, key) && shallow(a[key], b[key])
|
|
3748
|
-
);
|
|
3749
|
-
}
|
|
3750
|
-
|
|
3751
|
-
// src/lib/TreePool.ts
|
|
3752
|
-
var TreePool = class {
|
|
3753
|
-
#_items;
|
|
3754
|
-
#_childrenOf;
|
|
3755
|
-
#_sorted;
|
|
3756
|
-
#_primaryKey;
|
|
3757
|
-
#_parentKeyFn;
|
|
3758
|
-
#_lt;
|
|
3759
|
-
constructor(primaryKey, parentKey, lt) {
|
|
3760
|
-
this.#_primaryKey = primaryKey;
|
|
3761
|
-
this.#_parentKeyFn = parentKey;
|
|
3762
|
-
this.#_lt = lt;
|
|
3763
|
-
this.#_items = /* @__PURE__ */ new Map();
|
|
3764
|
-
this.#_childrenOf = new DefaultMap(() => /* @__PURE__ */ new Set());
|
|
3765
|
-
this.#_sorted = SortedList.with(lt);
|
|
3766
|
-
}
|
|
3767
|
-
get(id) {
|
|
3768
|
-
return this.#_items.get(id);
|
|
3769
|
-
}
|
|
3770
|
-
getOrThrow(id) {
|
|
3771
|
-
return _nullishCoalesce(this.get(id), () => ( raise(`Item with id ${id} not found`)));
|
|
3772
|
-
}
|
|
3773
|
-
get sorted() {
|
|
3774
|
-
return this.#_sorted;
|
|
3775
|
-
}
|
|
3776
|
-
getParentId(id) {
|
|
3777
|
-
const item = this.getOrThrow(id);
|
|
3778
|
-
return this.#_parentKeyFn(item);
|
|
3779
|
-
}
|
|
3780
|
-
getParent(id) {
|
|
3781
|
-
const parentId = this.getParentId(id);
|
|
3782
|
-
return parentId ? this.getOrThrow(parentId) : null;
|
|
3783
|
-
}
|
|
3784
|
-
getChildren(id) {
|
|
3785
|
-
const childIds = this.#_childrenOf.get(id);
|
|
3786
|
-
if (!childIds) return [];
|
|
3787
|
-
return Array.from(childIds).map(
|
|
3788
|
-
(id2) => this.#_items.get(id2)
|
|
3789
|
-
// eslint-disable-line no-restricted-syntax
|
|
3790
|
-
);
|
|
3791
|
-
}
|
|
3792
|
-
*walkUp(id, predicate) {
|
|
3793
|
-
const includeSelf = true;
|
|
3794
|
-
let nodeId = id;
|
|
3795
|
-
do {
|
|
3796
|
-
const item = this.getOrThrow(nodeId);
|
|
3797
|
-
if (includeSelf || nodeId !== id) {
|
|
3798
|
-
if (!predicate || predicate(item)) {
|
|
3799
|
-
yield item;
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
nodeId = this.#_parentKeyFn(item);
|
|
3803
|
-
} while (nodeId !== null);
|
|
3804
|
-
}
|
|
3805
|
-
// XXXX Generalize
|
|
3806
|
-
*walkLeft(id, predicate) {
|
|
3807
|
-
const self = this.getOrThrow(id);
|
|
3808
|
-
const siblings = SortedList.from(this.getSiblings(id), this.#_lt);
|
|
3809
|
-
for (const sibling of siblings.iterReversed()) {
|
|
3810
|
-
if (this.#_lt(self, sibling)) continue;
|
|
3811
|
-
if (!predicate || predicate(sibling)) {
|
|
3812
|
-
yield sibling;
|
|
3813
|
-
}
|
|
3814
|
-
}
|
|
3815
|
-
}
|
|
3816
|
-
// XXXX Generalize
|
|
3817
|
-
*walkRight(id, predicate) {
|
|
3818
|
-
const self = this.getOrThrow(id);
|
|
3819
|
-
const siblings = SortedList.from(this.getSiblings(id), this.#_lt);
|
|
3820
|
-
for (const sibling of siblings) {
|
|
3821
|
-
if (this.#_lt(sibling, self)) continue;
|
|
3822
|
-
if (!predicate || predicate(sibling)) {
|
|
3823
|
-
yield sibling;
|
|
3824
|
-
}
|
|
3825
|
-
}
|
|
3826
|
-
}
|
|
3827
|
-
// XXXX Generalize
|
|
3828
|
-
*walkDown(id, predicate) {
|
|
3829
|
-
const children = SortedList.from(this.getChildren(id), this.#_lt).rawArray;
|
|
3830
|
-
for (let i = children.length - 1; i >= 0; i--) {
|
|
3831
|
-
const child = children[i];
|
|
3832
|
-
yield* this.walkDown(
|
|
3833
|
-
this.#_primaryKey(child),
|
|
3834
|
-
predicate
|
|
3835
|
-
// "depth-first",
|
|
3836
|
-
// true
|
|
3837
|
-
);
|
|
3838
|
-
if (!predicate || predicate(child)) {
|
|
3839
|
-
yield child;
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
}
|
|
3843
|
-
/** Returns all siblings, not including the item itself. */
|
|
3844
|
-
getSiblings(id) {
|
|
3845
|
-
const self = this.getOrThrow(id);
|
|
3846
|
-
const parentId = this.getParentId(id);
|
|
3847
|
-
return this.getChildren(parentId).filter((item) => item !== self);
|
|
3848
|
-
}
|
|
3849
|
-
[Symbol.iterator]() {
|
|
3850
|
-
return this.#_sorted[Symbol.iterator]();
|
|
3851
|
-
}
|
|
3852
|
-
upsert(item) {
|
|
3853
|
-
const pk = this.#_primaryKey(item);
|
|
3854
|
-
const existing = this.#_items.get(pk);
|
|
3855
|
-
if (existing) {
|
|
3856
|
-
if (this.#_parentKeyFn(existing) !== this.#_parentKeyFn(item)) {
|
|
3857
|
-
throw new Error(
|
|
3858
|
-
"Cannot upsert parent ID changes that change the tree structure. Remove the entry first, and recreate it"
|
|
3859
|
-
);
|
|
3860
|
-
}
|
|
3861
|
-
this.#_sorted.remove(existing);
|
|
3862
|
-
}
|
|
3863
|
-
this.#_items.set(pk, item);
|
|
3864
|
-
this.#_sorted.add(item);
|
|
3865
|
-
const parentId = this.#_parentKeyFn(item);
|
|
3866
|
-
this.#_childrenOf.getOrCreate(parentId).add(pk);
|
|
3867
|
-
}
|
|
3868
|
-
remove(pk) {
|
|
3869
|
-
const item = this.#_items.get(pk);
|
|
3870
|
-
if (!item) return false;
|
|
3871
|
-
const childIds = this.#_childrenOf.get(pk);
|
|
3872
|
-
if (childIds) {
|
|
3873
|
-
throw new Error(
|
|
3874
|
-
`Cannot remove item '${pk}' while it still has children. Remove children first.`
|
|
3875
|
-
);
|
|
3876
|
-
}
|
|
3877
|
-
const parentId = this.#_parentKeyFn(item);
|
|
3878
|
-
const siblings = this.#_childrenOf.get(parentId);
|
|
3879
|
-
if (siblings) {
|
|
3880
|
-
siblings.delete(pk);
|
|
3881
|
-
if (siblings.size === 0) {
|
|
3882
|
-
this.#_childrenOf.delete(parentId);
|
|
3883
|
-
}
|
|
3884
|
-
}
|
|
3885
|
-
this.#_sorted.remove(item);
|
|
3886
|
-
this.#_childrenOf.delete(pk);
|
|
3887
|
-
this.#_items.delete(pk);
|
|
3888
|
-
return true;
|
|
3889
|
-
}
|
|
3890
|
-
clear() {
|
|
3891
|
-
if (this.#_items.size === 0) return false;
|
|
3892
|
-
this.#_childrenOf.clear();
|
|
3893
|
-
this.#_items.clear();
|
|
3894
|
-
this.#_sorted.clear();
|
|
3895
|
-
return true;
|
|
3896
|
-
}
|
|
3897
|
-
};
|
|
3898
|
-
|
|
3899
|
-
// src/protocol/AuthToken.ts
|
|
3900
|
-
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
3901
|
-
Permission2["Read"] = "room:read";
|
|
3902
|
-
Permission2["Write"] = "room:write";
|
|
3903
|
-
Permission2["PresenceWrite"] = "room:presence:write";
|
|
3904
|
-
Permission2["CommentsWrite"] = "comments:write";
|
|
3905
|
-
Permission2["CommentsRead"] = "comments:read";
|
|
3906
|
-
return Permission2;
|
|
3907
|
-
})(Permission || {});
|
|
3908
|
-
function canWriteStorage(scopes) {
|
|
3909
|
-
return scopes.includes("room:write" /* Write */);
|
|
3910
|
-
}
|
|
3911
|
-
function canComment(scopes) {
|
|
3912
|
-
return scopes.includes("comments:write" /* CommentsWrite */) || scopes.includes("room:write" /* Write */);
|
|
3913
|
-
}
|
|
3914
|
-
function isValidAuthTokenPayload(data) {
|
|
3915
|
-
return isPlainObject(data) && (data.k === "acc" /* ACCESS_TOKEN */ || data.k === "id" /* ID_TOKEN */ || data.k === "sec-legacy" /* SECRET_LEGACY */);
|
|
3916
|
-
}
|
|
3917
|
-
function parseAuthToken(rawTokenString) {
|
|
3918
|
-
const tokenParts = rawTokenString.split(".");
|
|
3919
|
-
if (tokenParts.length !== 3) {
|
|
3920
|
-
throw new Error("Authentication error: invalid JWT token");
|
|
3921
|
-
}
|
|
3922
|
-
const payload = tryParseJson(b64decode(tokenParts[1]));
|
|
3923
|
-
if (!(payload && isValidAuthTokenPayload(payload))) {
|
|
3924
|
-
throw new Error(
|
|
3925
|
-
"Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback"
|
|
3926
|
-
);
|
|
3927
|
-
}
|
|
3928
|
-
return {
|
|
3929
|
-
raw: rawTokenString,
|
|
3930
|
-
parsed: payload
|
|
3931
|
-
};
|
|
3932
|
-
}
|
|
3933
|
-
|
|
3934
3710
|
// src/lib/IncrementalJsonParser.ts
|
|
3935
3711
|
var EMPTY_OBJECT = Object.freeze({});
|
|
3936
3712
|
var NULL_KEYWORD_CHARS = Array.from(new Set("null"));
|
|
@@ -4098,97 +3874,239 @@ var IncrementalJsonParser = class {
|
|
|
4098
3874
|
result += suffix;
|
|
4099
3875
|
return _nullishCoalesce(tryParseJson(result), () => ( EMPTY_OBJECT));
|
|
4100
3876
|
}
|
|
4101
|
-
};
|
|
4102
|
-
|
|
4103
|
-
// src/
|
|
4104
|
-
function
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
|
|
4108
|
-
)
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
3877
|
+
};
|
|
3878
|
+
|
|
3879
|
+
// src/lib/shallow.ts
|
|
3880
|
+
function shallowArray(xs, ys) {
|
|
3881
|
+
if (xs.length !== ys.length) {
|
|
3882
|
+
return false;
|
|
3883
|
+
}
|
|
3884
|
+
for (let i = 0; i < xs.length; i++) {
|
|
3885
|
+
if (!Object.is(xs[i], ys[i])) {
|
|
3886
|
+
return false;
|
|
3887
|
+
}
|
|
3888
|
+
}
|
|
3889
|
+
return true;
|
|
3890
|
+
}
|
|
3891
|
+
function shallowObj(objA, objB) {
|
|
3892
|
+
if (!isPlainObject(objA) || !isPlainObject(objB)) {
|
|
3893
|
+
return false;
|
|
3894
|
+
}
|
|
3895
|
+
const keysA = Object.keys(objA);
|
|
3896
|
+
if (keysA.length !== Object.keys(objB).length) {
|
|
3897
|
+
return false;
|
|
3898
|
+
}
|
|
3899
|
+
return keysA.every(
|
|
3900
|
+
(key) => Object.prototype.hasOwnProperty.call(objB, key) && Object.is(objA[key], objB[key])
|
|
3901
|
+
);
|
|
3902
|
+
}
|
|
3903
|
+
function shallow(a, b) {
|
|
3904
|
+
if (Object.is(a, b)) {
|
|
3905
|
+
return true;
|
|
3906
|
+
}
|
|
3907
|
+
const isArrayA = Array.isArray(a);
|
|
3908
|
+
const isArrayB = Array.isArray(b);
|
|
3909
|
+
if (isArrayA || isArrayB) {
|
|
3910
|
+
if (!isArrayA || !isArrayB) {
|
|
3911
|
+
return false;
|
|
3912
|
+
}
|
|
3913
|
+
return shallowArray(a, b);
|
|
3914
|
+
}
|
|
3915
|
+
return shallowObj(a, b);
|
|
3916
|
+
}
|
|
3917
|
+
function shallow2(a, b) {
|
|
3918
|
+
if (!isPlainObject(a) || !isPlainObject(b)) {
|
|
3919
|
+
return shallow(a, b);
|
|
3920
|
+
}
|
|
3921
|
+
const keysA = Object.keys(a);
|
|
3922
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
3923
|
+
return false;
|
|
3924
|
+
}
|
|
3925
|
+
return keysA.every(
|
|
3926
|
+
(key) => Object.prototype.hasOwnProperty.call(b, key) && shallow(a[key], b[key])
|
|
3927
|
+
);
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
// src/lib/TreePool.ts
|
|
3931
|
+
var TreePool = class {
|
|
3932
|
+
#_items;
|
|
3933
|
+
#_childrenOf;
|
|
3934
|
+
#_sorted;
|
|
3935
|
+
#_primaryKey;
|
|
3936
|
+
#_parentKeyFn;
|
|
3937
|
+
#_lt;
|
|
3938
|
+
constructor(primaryKey, parentKey, lt) {
|
|
3939
|
+
this.#_primaryKey = primaryKey;
|
|
3940
|
+
this.#_parentKeyFn = parentKey;
|
|
3941
|
+
this.#_lt = lt;
|
|
3942
|
+
this.#_items = /* @__PURE__ */ new Map();
|
|
3943
|
+
this.#_childrenOf = new DefaultMap(() => /* @__PURE__ */ new Set());
|
|
3944
|
+
this.#_sorted = SortedList.with(lt);
|
|
3945
|
+
}
|
|
3946
|
+
get(id) {
|
|
3947
|
+
return this.#_items.get(id);
|
|
3948
|
+
}
|
|
3949
|
+
getOrThrow(id) {
|
|
3950
|
+
return _nullishCoalesce(this.get(id), () => ( raise(`Item with id ${id} not found`)));
|
|
3951
|
+
}
|
|
3952
|
+
get sorted() {
|
|
3953
|
+
return this.#_sorted;
|
|
3954
|
+
}
|
|
3955
|
+
getParentId(id) {
|
|
3956
|
+
const item = this.getOrThrow(id);
|
|
3957
|
+
return this.#_parentKeyFn(item);
|
|
3958
|
+
}
|
|
3959
|
+
getParent(id) {
|
|
3960
|
+
const parentId = this.getParentId(id);
|
|
3961
|
+
return parentId ? this.getOrThrow(parentId) : null;
|
|
3962
|
+
}
|
|
3963
|
+
getChildren(id) {
|
|
3964
|
+
const childIds = this.#_childrenOf.get(id);
|
|
3965
|
+
if (!childIds) return [];
|
|
3966
|
+
return Array.from(childIds).map(
|
|
3967
|
+
(id2) => this.#_items.get(id2)
|
|
3968
|
+
// eslint-disable-line no-restricted-syntax
|
|
3969
|
+
);
|
|
3970
|
+
}
|
|
3971
|
+
*walkUp(id, predicate) {
|
|
3972
|
+
const includeSelf = true;
|
|
3973
|
+
let nodeId = id;
|
|
3974
|
+
do {
|
|
3975
|
+
const item = this.getOrThrow(nodeId);
|
|
3976
|
+
if (includeSelf || nodeId !== id) {
|
|
3977
|
+
if (!predicate || predicate(item)) {
|
|
3978
|
+
yield item;
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
nodeId = this.#_parentKeyFn(item);
|
|
3982
|
+
} while (nodeId !== null);
|
|
3983
|
+
}
|
|
3984
|
+
// XXXX Generalize
|
|
3985
|
+
*walkLeft(id, predicate) {
|
|
3986
|
+
const self = this.getOrThrow(id);
|
|
3987
|
+
const siblings = SortedList.from(this.getSiblings(id), this.#_lt);
|
|
3988
|
+
for (const sibling of siblings.iterReversed()) {
|
|
3989
|
+
if (this.#_lt(self, sibling)) continue;
|
|
3990
|
+
if (!predicate || predicate(sibling)) {
|
|
3991
|
+
yield sibling;
|
|
3992
|
+
}
|
|
3993
|
+
}
|
|
3994
|
+
}
|
|
3995
|
+
// XXXX Generalize
|
|
3996
|
+
*walkRight(id, predicate) {
|
|
3997
|
+
const self = this.getOrThrow(id);
|
|
3998
|
+
const siblings = SortedList.from(this.getSiblings(id), this.#_lt);
|
|
3999
|
+
for (const sibling of siblings) {
|
|
4000
|
+
if (this.#_lt(sibling, self)) continue;
|
|
4001
|
+
if (!predicate || predicate(sibling)) {
|
|
4002
|
+
yield sibling;
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
}
|
|
4006
|
+
// XXXX Generalize
|
|
4007
|
+
*walkDown(id, predicate) {
|
|
4008
|
+
const children = SortedList.from(this.getChildren(id), this.#_lt).rawArray;
|
|
4009
|
+
for (let i = children.length - 1; i >= 0; i--) {
|
|
4010
|
+
const child = children[i];
|
|
4011
|
+
yield* this.walkDown(
|
|
4012
|
+
this.#_primaryKey(child),
|
|
4013
|
+
predicate
|
|
4014
|
+
// "depth-first",
|
|
4015
|
+
// true
|
|
4016
|
+
);
|
|
4017
|
+
if (!predicate || predicate(child)) {
|
|
4018
|
+
yield child;
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
/** Returns all siblings, not including the item itself. */
|
|
4023
|
+
getSiblings(id) {
|
|
4024
|
+
const self = this.getOrThrow(id);
|
|
4025
|
+
const parentId = this.getParentId(id);
|
|
4026
|
+
return this.getChildren(parentId).filter((item) => item !== self);
|
|
4114
4027
|
}
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
if (_optionalChain([prevPart, 'optionalAccess', _62 => _62.type]) === "reasoning") {
|
|
4118
|
-
prevPart.endedAt ??= endedAt;
|
|
4028
|
+
[Symbol.iterator]() {
|
|
4029
|
+
return this.#_sorted[Symbol.iterator]();
|
|
4119
4030
|
}
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
if (_optionalChain([lastPart, 'optionalAccess', _63 => _63.type]) === "text") {
|
|
4129
|
-
lastPart.text += delta.textDelta;
|
|
4130
|
-
} else {
|
|
4131
|
-
closePart(lastPart, now2);
|
|
4132
|
-
content.push({ type: "text", text: delta.textDelta });
|
|
4133
|
-
}
|
|
4134
|
-
break;
|
|
4135
|
-
case "reasoning-delta":
|
|
4136
|
-
if (_optionalChain([lastPart, 'optionalAccess', _64 => _64.type]) === "reasoning") {
|
|
4137
|
-
lastPart.text += delta.textDelta;
|
|
4138
|
-
} else {
|
|
4139
|
-
closePart(lastPart, now2);
|
|
4140
|
-
content.push({
|
|
4141
|
-
type: "reasoning",
|
|
4142
|
-
text: delta.textDelta,
|
|
4143
|
-
startedAt: now2
|
|
4144
|
-
});
|
|
4031
|
+
upsert(item) {
|
|
4032
|
+
const pk = this.#_primaryKey(item);
|
|
4033
|
+
const existing = this.#_items.get(pk);
|
|
4034
|
+
if (existing) {
|
|
4035
|
+
if (this.#_parentKeyFn(existing) !== this.#_parentKeyFn(item)) {
|
|
4036
|
+
throw new Error(
|
|
4037
|
+
"Cannot upsert parent ID changes that change the tree structure. Remove the entry first, and recreate it"
|
|
4038
|
+
);
|
|
4145
4039
|
}
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4040
|
+
this.#_sorted.remove(existing);
|
|
4041
|
+
}
|
|
4042
|
+
this.#_items.set(pk, item);
|
|
4043
|
+
this.#_sorted.add(item);
|
|
4044
|
+
const parentId = this.#_parentKeyFn(item);
|
|
4045
|
+
this.#_childrenOf.getOrCreate(parentId).add(pk);
|
|
4046
|
+
}
|
|
4047
|
+
remove(pk) {
|
|
4048
|
+
const item = this.#_items.get(pk);
|
|
4049
|
+
if (!item) return false;
|
|
4050
|
+
const childIds = this.#_childrenOf.get(pk);
|
|
4051
|
+
if (childIds) {
|
|
4052
|
+
throw new Error(
|
|
4053
|
+
`Cannot remove item '${pk}' while it still has children. Remove children first.`
|
|
4151
4054
|
);
|
|
4152
|
-
content.push(toolInvocation);
|
|
4153
|
-
break;
|
|
4154
4055
|
}
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4056
|
+
const parentId = this.#_parentKeyFn(item);
|
|
4057
|
+
const siblings = this.#_childrenOf.get(parentId);
|
|
4058
|
+
if (siblings) {
|
|
4059
|
+
siblings.delete(pk);
|
|
4060
|
+
if (siblings.size === 0) {
|
|
4061
|
+
this.#_childrenOf.delete(parentId);
|
|
4158
4062
|
}
|
|
4159
|
-
break;
|
|
4160
4063
|
}
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
replaceOrAppend(content, delta, (x) => x.id, now2);
|
|
4166
|
-
break;
|
|
4167
|
-
default:
|
|
4168
|
-
return assertNever(delta, "Unhandled case");
|
|
4064
|
+
this.#_sorted.remove(item);
|
|
4065
|
+
this.#_childrenOf.delete(pk);
|
|
4066
|
+
this.#_items.delete(pk);
|
|
4067
|
+
return true;
|
|
4169
4068
|
}
|
|
4069
|
+
clear() {
|
|
4070
|
+
if (this.#_items.size === 0) return false;
|
|
4071
|
+
this.#_childrenOf.clear();
|
|
4072
|
+
this.#_items.clear();
|
|
4073
|
+
this.#_sorted.clear();
|
|
4074
|
+
return true;
|
|
4075
|
+
}
|
|
4076
|
+
};
|
|
4077
|
+
|
|
4078
|
+
// src/protocol/AuthToken.ts
|
|
4079
|
+
var Permission = /* @__PURE__ */ ((Permission2) => {
|
|
4080
|
+
Permission2["Read"] = "room:read";
|
|
4081
|
+
Permission2["Write"] = "room:write";
|
|
4082
|
+
Permission2["PresenceWrite"] = "room:presence:write";
|
|
4083
|
+
Permission2["CommentsWrite"] = "comments:write";
|
|
4084
|
+
Permission2["CommentsRead"] = "comments:read";
|
|
4085
|
+
return Permission2;
|
|
4086
|
+
})(Permission || {});
|
|
4087
|
+
function canWriteStorage(scopes) {
|
|
4088
|
+
return scopes.includes("room:write" /* Write */);
|
|
4170
4089
|
}
|
|
4171
|
-
function
|
|
4172
|
-
|
|
4090
|
+
function canComment(scopes) {
|
|
4091
|
+
return scopes.includes("comments:write" /* CommentsWrite */) || scopes.includes("room:write" /* Write */);
|
|
4092
|
+
}
|
|
4093
|
+
function isValidAuthTokenPayload(data) {
|
|
4094
|
+
return isPlainObject(data) && (data.k === "acc" /* ACCESS_TOKEN */ || data.k === "id" /* ID_TOKEN */ || data.k === "sec-legacy" /* SECRET_LEGACY */);
|
|
4095
|
+
}
|
|
4096
|
+
function parseAuthToken(rawTokenString) {
|
|
4097
|
+
const tokenParts = rawTokenString.split(".");
|
|
4098
|
+
if (tokenParts.length !== 3) {
|
|
4099
|
+
throw new Error("Authentication error: invalid JWT token");
|
|
4100
|
+
}
|
|
4101
|
+
const payload = tryParseJson(b64decode(tokenParts[1]));
|
|
4102
|
+
if (!(payload && isValidAuthTokenPayload(payload))) {
|
|
4103
|
+
throw new Error(
|
|
4104
|
+
"Authentication error: expected a valid token but did not get one. Hint: if you are using a callback, ensure the room is passed when creating the token. For more information: https://liveblocks.io/docs/api-reference/liveblocks-client#createClientCallback"
|
|
4105
|
+
);
|
|
4106
|
+
}
|
|
4173
4107
|
return {
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
invocationId,
|
|
4177
|
-
name,
|
|
4178
|
-
// --- Alternative implementation for FRONTEND only ------------------------
|
|
4179
|
-
get partialArgsText() {
|
|
4180
|
-
return parser.source;
|
|
4181
|
-
},
|
|
4182
|
-
// prettier-ignore
|
|
4183
|
-
get partialArgs() {
|
|
4184
|
-
return parser.json;
|
|
4185
|
-
},
|
|
4186
|
-
// prettier-ignore
|
|
4187
|
-
__appendDelta(delta) {
|
|
4188
|
-
parser.append(delta);
|
|
4189
|
-
}
|
|
4190
|
-
// prettier-ignore
|
|
4191
|
-
// ------------------------------------------------------------------------
|
|
4108
|
+
raw: rawTokenString,
|
|
4109
|
+
parsed: payload
|
|
4192
4110
|
};
|
|
4193
4111
|
}
|
|
4194
4112
|
|
|
@@ -4265,7 +4183,7 @@ function createStore_forKnowledge() {
|
|
|
4265
4183
|
}
|
|
4266
4184
|
function getKnowledgeForChat(chatId) {
|
|
4267
4185
|
const globalKnowledge = knowledgeByChatId.getOrCreate(kWILDCARD).get();
|
|
4268
|
-
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access',
|
|
4186
|
+
const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access', _62 => _62.get, 'call', _63 => _63(chatId), 'optionalAccess', _64 => _64.get, 'call', _65 => _65()]), () => ( []));
|
|
4269
4187
|
return [...globalKnowledge, ...scopedKnowledge];
|
|
4270
4188
|
}
|
|
4271
4189
|
return {
|
|
@@ -4290,7 +4208,7 @@ function createStore_forTools() {
|
|
|
4290
4208
|
return DerivedSignal.from(() => {
|
|
4291
4209
|
return (
|
|
4292
4210
|
// A tool that's registered and scoped to a specific chat ID...
|
|
4293
|
-
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess',
|
|
4211
|
+
_nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _66 => _66.get, 'call', _67 => _67()]), () => ( // ...or a globally registered tool
|
|
4294
4212
|
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
|
|
4295
4213
|
);
|
|
4296
4214
|
});
|
|
@@ -4320,8 +4238,8 @@ function createStore_forTools() {
|
|
|
4320
4238
|
const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
|
|
4321
4239
|
const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
|
|
4322
4240
|
return Array.from([
|
|
4323
|
-
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess',
|
|
4324
|
-
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess',
|
|
4241
|
+
..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _68 => _68.entries, 'call', _69 => _69()]), () => ( [])),
|
|
4242
|
+
..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _70 => _70.entries, 'call', _71 => _71()]), () => ( []))
|
|
4325
4243
|
]).flatMap(([name, tool\u03A3]) => {
|
|
4326
4244
|
const tool = tool\u03A3.get();
|
|
4327
4245
|
return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
|
|
@@ -4424,7 +4342,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4424
4342
|
} else {
|
|
4425
4343
|
continue;
|
|
4426
4344
|
}
|
|
4427
|
-
const executeFn = _optionalChain([toolsStore, 'access',
|
|
4345
|
+
const executeFn = _optionalChain([toolsStore, 'access', _72 => _72.getTool\u03A3, 'call', _73 => _73(toolInvocation.name, message.chatId), 'access', _74 => _74.get, 'call', _75 => _75(), 'optionalAccess', _76 => _76.execute]);
|
|
4428
4346
|
if (executeFn) {
|
|
4429
4347
|
(async () => {
|
|
4430
4348
|
const result = await executeFn(toolInvocation.args, {
|
|
@@ -4523,8 +4441,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4523
4441
|
const spine = [];
|
|
4524
4442
|
let lastVisitedMessage = null;
|
|
4525
4443
|
for (const message2 of pool.walkUp(leaf.id)) {
|
|
4526
|
-
const prev = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4527
|
-
const next = _nullishCoalesce(_optionalChain([first, 'call',
|
|
4444
|
+
const prev = _nullishCoalesce(_optionalChain([first, 'call', _77 => _77(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _78 => _78.id]), () => ( null));
|
|
4445
|
+
const next = _nullishCoalesce(_optionalChain([first, 'call', _79 => _79(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _80 => _80.id]), () => ( null));
|
|
4528
4446
|
if (!message2.deletedAt || prev || next) {
|
|
4529
4447
|
const node = {
|
|
4530
4448
|
...message2,
|
|
@@ -4590,7 +4508,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4590
4508
|
const latest = pool.sorted.findRight(
|
|
4591
4509
|
(m) => m.role === "assistant" && !m.deletedAt
|
|
4592
4510
|
);
|
|
4593
|
-
return _optionalChain([latest, 'optionalAccess',
|
|
4511
|
+
return _optionalChain([latest, 'optionalAccess', _81 => _81.copilotId]);
|
|
4594
4512
|
}
|
|
4595
4513
|
return {
|
|
4596
4514
|
// Readers
|
|
@@ -4621,11 +4539,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
|
|
|
4621
4539
|
*getAutoExecutingMessageIds() {
|
|
4622
4540
|
for (const messageId of myMessages) {
|
|
4623
4541
|
const message = getMessageById(messageId);
|
|
4624
|
-
if (_optionalChain([message, 'optionalAccess',
|
|
4542
|
+
if (_optionalChain([message, 'optionalAccess', _82 => _82.role]) === "assistant" && message.status === "awaiting-tool") {
|
|
4625
4543
|
const isAutoExecuting = message.contentSoFar.some((part) => {
|
|
4626
4544
|
if (part.type === "tool-invocation" && part.stage === "executing") {
|
|
4627
4545
|
const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
|
|
4628
|
-
return typeof _optionalChain([tool, 'optionalAccess',
|
|
4546
|
+
return typeof _optionalChain([tool, 'optionalAccess', _83 => _83.execute]) === "function";
|
|
4629
4547
|
}
|
|
4630
4548
|
return false;
|
|
4631
4549
|
});
|
|
@@ -4687,6 +4605,7 @@ function createAi(config) {
|
|
|
4687
4605
|
toolsStore,
|
|
4688
4606
|
knowledgeStore
|
|
4689
4607
|
};
|
|
4608
|
+
const status\u03A3 = new Signal("initial");
|
|
4690
4609
|
const DELTA_THROTTLE = 25;
|
|
4691
4610
|
let pendingDeltas = [];
|
|
4692
4611
|
let deltaBatchTimer = null;
|
|
@@ -4710,7 +4629,7 @@ function createAi(config) {
|
|
|
4710
4629
|
}
|
|
4711
4630
|
}
|
|
4712
4631
|
let lastTokenKey;
|
|
4713
|
-
function onStatusDidChange(
|
|
4632
|
+
function onStatusDidChange(newStatus) {
|
|
4714
4633
|
const authValue = managedSocket.authValue;
|
|
4715
4634
|
if (authValue !== null) {
|
|
4716
4635
|
const tokenKey = getBearerTokenFromAuthValue(authValue);
|
|
@@ -4730,6 +4649,7 @@ function createAi(config) {
|
|
|
4730
4649
|
}
|
|
4731
4650
|
}
|
|
4732
4651
|
}
|
|
4652
|
+
status\u03A3.set(newStatus);
|
|
4733
4653
|
}
|
|
4734
4654
|
let _connectionLossTimerId;
|
|
4735
4655
|
let _hasLostConnection = false;
|
|
@@ -4771,7 +4691,7 @@ function createAi(config) {
|
|
|
4771
4691
|
flushPendingDeltas();
|
|
4772
4692
|
switch (msg.event) {
|
|
4773
4693
|
case "cmd-failed":
|
|
4774
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4694
|
+
_optionalChain([pendingCmd, 'optionalAccess', _84 => _84.reject, 'call', _85 => _85(new Error(msg.error))]);
|
|
4775
4695
|
break;
|
|
4776
4696
|
case "settle": {
|
|
4777
4697
|
context.messagesStore.upsert(msg.message);
|
|
@@ -4848,7 +4768,7 @@ function createAi(config) {
|
|
|
4848
4768
|
return assertNever(msg, "Unhandled case");
|
|
4849
4769
|
}
|
|
4850
4770
|
}
|
|
4851
|
-
_optionalChain([pendingCmd, 'optionalAccess',
|
|
4771
|
+
_optionalChain([pendingCmd, 'optionalAccess', _86 => _86.resolve, 'call', _87 => _87(msg)]);
|
|
4852
4772
|
}
|
|
4853
4773
|
managedSocket.events.onMessage.subscribe(handleServerMessage);
|
|
4854
4774
|
managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
|
|
@@ -4924,9 +4844,9 @@ function createAi(config) {
|
|
|
4924
4844
|
invocationId,
|
|
4925
4845
|
result,
|
|
4926
4846
|
generationOptions: {
|
|
4927
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4928
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4929
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4847
|
+
copilotId: _optionalChain([options, 'optionalAccess', _88 => _88.copilotId]),
|
|
4848
|
+
stream: _optionalChain([options, 'optionalAccess', _89 => _89.stream]),
|
|
4849
|
+
timeout: _optionalChain([options, 'optionalAccess', _90 => _90.timeout]),
|
|
4930
4850
|
// Knowledge and tools aren't coming from the options, but retrieved
|
|
4931
4851
|
// from the global context
|
|
4932
4852
|
knowledge: knowledge.length > 0 ? knowledge : void 0,
|
|
@@ -4944,7 +4864,7 @@ function createAi(config) {
|
|
|
4944
4864
|
}
|
|
4945
4865
|
}
|
|
4946
4866
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
4947
|
-
_optionalChain([win, 'optionalAccess',
|
|
4867
|
+
_optionalChain([win, 'optionalAccess', _91 => _91.addEventListener, 'call', _92 => _92("beforeunload", handleBeforeUnload, { once: true })]);
|
|
4948
4868
|
return Object.defineProperty(
|
|
4949
4869
|
{
|
|
4950
4870
|
[kInternal]: {
|
|
@@ -4963,7 +4883,7 @@ function createAi(config) {
|
|
|
4963
4883
|
clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
|
|
4964
4884
|
askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
|
|
4965
4885
|
const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
|
|
4966
|
-
const requestKnowledge = _optionalChain([options, 'optionalAccess',
|
|
4886
|
+
const requestKnowledge = _optionalChain([options, 'optionalAccess', _93 => _93.knowledge]) || [];
|
|
4967
4887
|
const combinedKnowledge = [...knowledge, ...requestKnowledge];
|
|
4968
4888
|
const tools = context.toolsStore.getToolDescriptions(chatId);
|
|
4969
4889
|
messagesStore.markMine(targetMessageId);
|
|
@@ -4973,9 +4893,9 @@ function createAi(config) {
|
|
|
4973
4893
|
sourceMessage: userMessage,
|
|
4974
4894
|
targetMessageId,
|
|
4975
4895
|
generationOptions: {
|
|
4976
|
-
copilotId: _optionalChain([options, 'optionalAccess',
|
|
4977
|
-
stream: _optionalChain([options, 'optionalAccess',
|
|
4978
|
-
timeout: _optionalChain([options, 'optionalAccess',
|
|
4896
|
+
copilotId: _optionalChain([options, 'optionalAccess', _94 => _94.copilotId]),
|
|
4897
|
+
stream: _optionalChain([options, 'optionalAccess', _95 => _95.stream]),
|
|
4898
|
+
timeout: _optionalChain([options, 'optionalAccess', _96 => _96.timeout]),
|
|
4979
4899
|
// Combine global knowledge with request-specific knowledge
|
|
4980
4900
|
knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
|
|
4981
4901
|
tools: tools.length > 0 ? tools : void 0
|
|
@@ -4988,7 +4908,8 @@ function createAi(config) {
|
|
|
4988
4908
|
getStatus: () => managedSocket.getStatus(),
|
|
4989
4909
|
signals: {
|
|
4990
4910
|
getChatMessagesForBranch\u03A3: context.messagesStore.getChatMessagesForBranch\u03A3,
|
|
4991
|
-
getTool\u03A3: context.toolsStore.getTool\u03A3
|
|
4911
|
+
getTool\u03A3: context.toolsStore.getTool\u03A3,
|
|
4912
|
+
status\u03A3
|
|
4992
4913
|
},
|
|
4993
4914
|
getChatById: context.chatsStore.getChatById,
|
|
4994
4915
|
queryChats: context.chatsStore.findMany,
|
|
@@ -5021,7 +4942,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
|
|
|
5021
4942
|
}
|
|
5022
4943
|
const url2 = new URL(baseUrl);
|
|
5023
4944
|
url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
|
|
5024
|
-
url2.pathname = "/ai/
|
|
4945
|
+
url2.pathname = "/ai/v7";
|
|
5025
4946
|
if (authValue.type === "secret") {
|
|
5026
4947
|
url2.searchParams.set("tok", authValue.token.raw);
|
|
5027
4948
|
} else if (authValue.type === "public") {
|
|
@@ -5033,6 +4954,112 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
|
|
|
5033
4954
|
return new ws(url2.toString());
|
|
5034
4955
|
};
|
|
5035
4956
|
}
|
|
4957
|
+
function replaceOrAppend(content, newItem, keyFn, now2) {
|
|
4958
|
+
const existingIndex = findLastIndex(
|
|
4959
|
+
content,
|
|
4960
|
+
(item) => item.type === newItem.type && keyFn(item) === keyFn(newItem)
|
|
4961
|
+
);
|
|
4962
|
+
if (existingIndex > -1) {
|
|
4963
|
+
content[existingIndex] = newItem;
|
|
4964
|
+
} else {
|
|
4965
|
+
closePart(content[content.length - 1], now2);
|
|
4966
|
+
content.push(newItem);
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
function closePart(prevPart, endedAt) {
|
|
4970
|
+
if (_optionalChain([prevPart, 'optionalAccess', _97 => _97.type]) === "reasoning") {
|
|
4971
|
+
prevPart.endedAt ??= endedAt;
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
function patchContentWithDelta(content, delta) {
|
|
4975
|
+
if (delta === null)
|
|
4976
|
+
return;
|
|
4977
|
+
const parts = content.filter(
|
|
4978
|
+
(part) => part.type !== "sources"
|
|
4979
|
+
);
|
|
4980
|
+
const sources = content.filter((part) => part.type === "sources").flatMap((part) => part.sources);
|
|
4981
|
+
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
4982
|
+
const lastPart = parts[parts.length - 1];
|
|
4983
|
+
switch (delta.type) {
|
|
4984
|
+
case "text-delta":
|
|
4985
|
+
if (_optionalChain([lastPart, 'optionalAccess', _98 => _98.type]) === "text") {
|
|
4986
|
+
lastPart.text += delta.textDelta;
|
|
4987
|
+
} else {
|
|
4988
|
+
closePart(lastPart, now2);
|
|
4989
|
+
parts.push({ type: "text", text: delta.textDelta });
|
|
4990
|
+
}
|
|
4991
|
+
break;
|
|
4992
|
+
case "reasoning-delta":
|
|
4993
|
+
if (_optionalChain([lastPart, 'optionalAccess', _99 => _99.type]) === "reasoning") {
|
|
4994
|
+
lastPart.text += delta.textDelta;
|
|
4995
|
+
} else {
|
|
4996
|
+
closePart(lastPart, now2);
|
|
4997
|
+
parts.push({
|
|
4998
|
+
type: "reasoning",
|
|
4999
|
+
text: delta.textDelta,
|
|
5000
|
+
startedAt: now2
|
|
5001
|
+
});
|
|
5002
|
+
}
|
|
5003
|
+
break;
|
|
5004
|
+
case "tool-stream": {
|
|
5005
|
+
const toolInvocation = createReceivingToolInvocation(
|
|
5006
|
+
delta.invocationId,
|
|
5007
|
+
delta.name
|
|
5008
|
+
);
|
|
5009
|
+
parts.push(toolInvocation);
|
|
5010
|
+
break;
|
|
5011
|
+
}
|
|
5012
|
+
case "tool-delta": {
|
|
5013
|
+
if (_optionalChain([lastPart, 'optionalAccess', _100 => _100.type]) === "tool-invocation" && lastPart.stage === "receiving") {
|
|
5014
|
+
_optionalChain([lastPart, 'access', _101 => _101.__appendDelta, 'optionalCall', _102 => _102(delta.delta)]);
|
|
5015
|
+
}
|
|
5016
|
+
break;
|
|
5017
|
+
}
|
|
5018
|
+
case "tool-invocation":
|
|
5019
|
+
replaceOrAppend(parts, delta, (x) => x.invocationId, now2);
|
|
5020
|
+
break;
|
|
5021
|
+
case "retrieval":
|
|
5022
|
+
replaceOrAppend(parts, delta, (x) => x.id, now2);
|
|
5023
|
+
break;
|
|
5024
|
+
case "source": {
|
|
5025
|
+
sources.push(delta);
|
|
5026
|
+
break;
|
|
5027
|
+
}
|
|
5028
|
+
default:
|
|
5029
|
+
return assertNever(delta, "Unhandled case");
|
|
5030
|
+
}
|
|
5031
|
+
if (sources.length > 0) {
|
|
5032
|
+
parts.push({
|
|
5033
|
+
type: "sources",
|
|
5034
|
+
sources
|
|
5035
|
+
});
|
|
5036
|
+
}
|
|
5037
|
+
content.length = 0;
|
|
5038
|
+
content.push(...parts);
|
|
5039
|
+
}
|
|
5040
|
+
function createReceivingToolInvocation(invocationId, name, partialArgsText = "") {
|
|
5041
|
+
const parser = new IncrementalJsonParser(partialArgsText);
|
|
5042
|
+
return {
|
|
5043
|
+
type: "tool-invocation",
|
|
5044
|
+
stage: "receiving",
|
|
5045
|
+
invocationId,
|
|
5046
|
+
name,
|
|
5047
|
+
// --- Alternative implementation for FRONTEND only ------------------------
|
|
5048
|
+
get partialArgsText() {
|
|
5049
|
+
return parser.source;
|
|
5050
|
+
},
|
|
5051
|
+
// prettier-ignore
|
|
5052
|
+
get partialArgs() {
|
|
5053
|
+
return parser.json;
|
|
5054
|
+
},
|
|
5055
|
+
// prettier-ignore
|
|
5056
|
+
__appendDelta(delta) {
|
|
5057
|
+
parser.append(delta);
|
|
5058
|
+
}
|
|
5059
|
+
// prettier-ignore
|
|
5060
|
+
// ------------------------------------------------------------------------
|
|
5061
|
+
};
|
|
5062
|
+
}
|
|
5036
5063
|
|
|
5037
5064
|
// src/auth-manager.ts
|
|
5038
5065
|
function createAuthManager(authOptions, onAuthenticate) {
|
|
@@ -8161,16 +8188,6 @@ function findNonSerializableValue(value, path = "") {
|
|
|
8161
8188
|
return false;
|
|
8162
8189
|
}
|
|
8163
8190
|
|
|
8164
|
-
// src/lib/debug.ts
|
|
8165
|
-
function captureStackTrace(msg, traceRoot) {
|
|
8166
|
-
const errorLike = { name: msg };
|
|
8167
|
-
if (typeof Error.captureStackTrace !== "function") {
|
|
8168
|
-
return void 0;
|
|
8169
|
-
}
|
|
8170
|
-
Error.captureStackTrace(errorLike, traceRoot);
|
|
8171
|
-
return errorLike.stack;
|
|
8172
|
-
}
|
|
8173
|
-
|
|
8174
8191
|
// src/lib/Deque.ts
|
|
8175
8192
|
var Deque = class {
|
|
8176
8193
|
#data;
|
|
@@ -8581,9 +8598,7 @@ function createRoom(options, config) {
|
|
|
8581
8598
|
redoStack: [],
|
|
8582
8599
|
pausedHistory: null,
|
|
8583
8600
|
activeBatch: null,
|
|
8584
|
-
unacknowledgedOps: /* @__PURE__ */ new Map()
|
|
8585
|
-
// Debug
|
|
8586
|
-
opStackTraces: process.env.NODE_ENV !== "production" ? /* @__PURE__ */ new Map() : void 0
|
|
8601
|
+
unacknowledgedOps: /* @__PURE__ */ new Map()
|
|
8587
8602
|
};
|
|
8588
8603
|
let lastTokenKey;
|
|
8589
8604
|
function onStatusDidChange(newStatus) {
|
|
@@ -8667,16 +8682,6 @@ function createRoom(options, config) {
|
|
|
8667
8682
|
}
|
|
8668
8683
|
});
|
|
8669
8684
|
function onDispatch(ops, reverse, storageUpdates) {
|
|
8670
|
-
if (process.env.NODE_ENV !== "production") {
|
|
8671
|
-
const stackTrace = captureStackTrace("Storage mutation", onDispatch);
|
|
8672
|
-
if (stackTrace) {
|
|
8673
|
-
for (const op of ops) {
|
|
8674
|
-
if (op.opId) {
|
|
8675
|
-
nn(context.opStackTraces).set(op.opId, stackTrace);
|
|
8676
|
-
}
|
|
8677
|
-
}
|
|
8678
|
-
}
|
|
8679
|
-
}
|
|
8680
8685
|
if (context.activeBatch) {
|
|
8681
8686
|
for (const op of ops) {
|
|
8682
8687
|
context.activeBatch.ops.push(op);
|
|
@@ -8993,9 +8998,6 @@ function createRoom(options, config) {
|
|
|
8993
8998
|
source = 0 /* UNDOREDO_RECONNECT */;
|
|
8994
8999
|
} else {
|
|
8995
9000
|
const opId = nn(op.opId);
|
|
8996
|
-
if (process.env.NODE_ENV !== "production") {
|
|
8997
|
-
nn(context.opStackTraces).delete(opId);
|
|
8998
|
-
}
|
|
8999
9001
|
const deleted = context.unacknowledgedOps.delete(opId);
|
|
9000
9002
|
source = deleted ? 2 /* ACK */ : 1 /* REMOTE */;
|
|
9001
9003
|
}
|
|
@@ -9281,38 +9283,6 @@ function createRoom(options, config) {
|
|
|
9281
9283
|
}
|
|
9282
9284
|
break;
|
|
9283
9285
|
}
|
|
9284
|
-
// Receiving a RejectedOps message in the client means that the server is no
|
|
9285
|
-
// longer in sync with the client. Trying to synchronize the client again by
|
|
9286
|
-
// rolling back particular Ops may be hard/impossible. It's fine to not try and
|
|
9287
|
-
// accept the out-of-sync reality and throw an error. We look at this kind of bug
|
|
9288
|
-
// as a developer-owned bug. In production, these errors are not expected to happen.
|
|
9289
|
-
case 299 /* REJECT_STORAGE_OP */: {
|
|
9290
|
-
errorWithTitle(
|
|
9291
|
-
"Storage mutation rejection error",
|
|
9292
|
-
message.reason
|
|
9293
|
-
);
|
|
9294
|
-
if (process.env.NODE_ENV !== "production") {
|
|
9295
|
-
const traces = /* @__PURE__ */ new Set();
|
|
9296
|
-
for (const opId of message.opIds) {
|
|
9297
|
-
const trace = _optionalChain([context, 'access', _200 => _200.opStackTraces, 'optionalAccess', _201 => _201.get, 'call', _202 => _202(opId)]);
|
|
9298
|
-
if (trace) {
|
|
9299
|
-
traces.add(trace);
|
|
9300
|
-
}
|
|
9301
|
-
}
|
|
9302
|
-
if (traces.size > 0) {
|
|
9303
|
-
warnWithTitle(
|
|
9304
|
-
"The following function calls caused the rejected storage mutations:",
|
|
9305
|
-
`
|
|
9306
|
-
|
|
9307
|
-
${Array.from(traces).join("\n\n")}`
|
|
9308
|
-
);
|
|
9309
|
-
}
|
|
9310
|
-
throw new Error(
|
|
9311
|
-
`Storage mutations rejected by server: ${message.reason}`
|
|
9312
|
-
);
|
|
9313
|
-
}
|
|
9314
|
-
break;
|
|
9315
|
-
}
|
|
9316
9286
|
case 400 /* THREAD_CREATED */:
|
|
9317
9287
|
case 407 /* THREAD_DELETED */:
|
|
9318
9288
|
case 401 /* THREAD_METADATA_UPDATED */:
|
|
@@ -9325,6 +9295,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9325
9295
|
eventHub.comments.notify(message);
|
|
9326
9296
|
break;
|
|
9327
9297
|
}
|
|
9298
|
+
default:
|
|
9299
|
+
break;
|
|
9328
9300
|
}
|
|
9329
9301
|
}
|
|
9330
9302
|
notify(updates);
|
|
@@ -9428,7 +9400,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9428
9400
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
9429
9401
|
createOrUpdateRootFromMessage(message);
|
|
9430
9402
|
applyAndSendOps(unacknowledgedOps);
|
|
9431
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
9403
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _200 => _200()]);
|
|
9432
9404
|
notifyStorageStatus();
|
|
9433
9405
|
eventHub.storageDidLoad.notify();
|
|
9434
9406
|
}
|
|
@@ -9649,8 +9621,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9649
9621
|
async function getThreads(options2) {
|
|
9650
9622
|
return httpClient.getThreads({
|
|
9651
9623
|
roomId,
|
|
9652
|
-
query: _optionalChain([options2, 'optionalAccess',
|
|
9653
|
-
cursor: _optionalChain([options2, 'optionalAccess',
|
|
9624
|
+
query: _optionalChain([options2, 'optionalAccess', _201 => _201.query]),
|
|
9625
|
+
cursor: _optionalChain([options2, 'optionalAccess', _202 => _202.cursor])
|
|
9654
9626
|
});
|
|
9655
9627
|
}
|
|
9656
9628
|
async function getThread(threadId) {
|
|
@@ -9757,7 +9729,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9757
9729
|
function getSubscriptionSettings(options2) {
|
|
9758
9730
|
return httpClient.getSubscriptionSettings({
|
|
9759
9731
|
roomId,
|
|
9760
|
-
signal: _optionalChain([options2, 'optionalAccess',
|
|
9732
|
+
signal: _optionalChain([options2, 'optionalAccess', _203 => _203.signal])
|
|
9761
9733
|
});
|
|
9762
9734
|
}
|
|
9763
9735
|
function updateSubscriptionSettings(settings) {
|
|
@@ -9779,7 +9751,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9779
9751
|
{
|
|
9780
9752
|
[kInternal]: {
|
|
9781
9753
|
get presenceBuffer() {
|
|
9782
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
9754
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _204 => _204.buffer, 'access', _205 => _205.presenceUpdates, 'optionalAccess', _206 => _206.data]), () => ( null)));
|
|
9783
9755
|
},
|
|
9784
9756
|
// prettier-ignore
|
|
9785
9757
|
get undoStack() {
|
|
@@ -9794,9 +9766,9 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9794
9766
|
return context.yjsProvider;
|
|
9795
9767
|
},
|
|
9796
9768
|
setYjsProvider(newProvider) {
|
|
9797
|
-
_optionalChain([context, 'access',
|
|
9769
|
+
_optionalChain([context, 'access', _207 => _207.yjsProvider, 'optionalAccess', _208 => _208.off, 'call', _209 => _209("status", yjsStatusDidChange)]);
|
|
9798
9770
|
context.yjsProvider = newProvider;
|
|
9799
|
-
_optionalChain([newProvider, 'optionalAccess',
|
|
9771
|
+
_optionalChain([newProvider, 'optionalAccess', _210 => _210.on, 'call', _211 => _211("status", yjsStatusDidChange)]);
|
|
9800
9772
|
context.yjsProviderDidChange.notify();
|
|
9801
9773
|
},
|
|
9802
9774
|
yjsProviderDidChange: context.yjsProviderDidChange.observable,
|
|
@@ -9842,7 +9814,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
9842
9814
|
source.dispose();
|
|
9843
9815
|
}
|
|
9844
9816
|
eventHub.roomWillDestroy.notify();
|
|
9845
|
-
_optionalChain([context, 'access',
|
|
9817
|
+
_optionalChain([context, 'access', _212 => _212.yjsProvider, 'optionalAccess', _213 => _213.off, 'call', _214 => _214("status", yjsStatusDidChange)]);
|
|
9846
9818
|
syncSourceForStorage.destroy();
|
|
9847
9819
|
syncSourceForYjs.destroy();
|
|
9848
9820
|
uninstallBgTabSpy();
|
|
@@ -9992,7 +9964,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
|
|
|
9992
9964
|
}
|
|
9993
9965
|
if (isLiveNode(first)) {
|
|
9994
9966
|
const node = first;
|
|
9995
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
9967
|
+
if (_optionalChain([options, 'optionalAccess', _215 => _215.isDeep])) {
|
|
9996
9968
|
const storageCallback = second;
|
|
9997
9969
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
9998
9970
|
} else {
|
|
@@ -10072,8 +10044,8 @@ function createClient(options) {
|
|
|
10072
10044
|
const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
|
|
10073
10045
|
currentUserId.set(() => userId);
|
|
10074
10046
|
});
|
|
10075
|
-
const fetchPolyfill = _optionalChain([clientOptions, 'access',
|
|
10076
|
-
_optionalChain([globalThis, 'access',
|
|
10047
|
+
const fetchPolyfill = _optionalChain([clientOptions, 'access', _216 => _216.polyfills, 'optionalAccess', _217 => _217.fetch]) || /* istanbul ignore next */
|
|
10048
|
+
_optionalChain([globalThis, 'access', _218 => _218.fetch, 'optionalAccess', _219 => _219.bind, 'call', _220 => _220(globalThis)]);
|
|
10077
10049
|
const httpClient = createApiClient({
|
|
10078
10050
|
baseUrl,
|
|
10079
10051
|
fetchPolyfill,
|
|
@@ -10091,7 +10063,7 @@ function createClient(options) {
|
|
|
10091
10063
|
delegates: {
|
|
10092
10064
|
createSocket: makeCreateSocketDelegateForAi(
|
|
10093
10065
|
baseUrl,
|
|
10094
|
-
_optionalChain([clientOptions, 'access',
|
|
10066
|
+
_optionalChain([clientOptions, 'access', _221 => _221.polyfills, 'optionalAccess', _222 => _222.WebSocket])
|
|
10095
10067
|
),
|
|
10096
10068
|
authenticate: async () => {
|
|
10097
10069
|
const resp = await authManager.getAuthValue({
|
|
@@ -10153,7 +10125,7 @@ function createClient(options) {
|
|
|
10153
10125
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
10154
10126
|
roomId,
|
|
10155
10127
|
baseUrl,
|
|
10156
|
-
_optionalChain([clientOptions, 'access',
|
|
10128
|
+
_optionalChain([clientOptions, 'access', _223 => _223.polyfills, 'optionalAccess', _224 => _224.WebSocket])
|
|
10157
10129
|
),
|
|
10158
10130
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
10159
10131
|
})),
|
|
@@ -10176,7 +10148,7 @@ function createClient(options) {
|
|
|
10176
10148
|
const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
|
|
10177
10149
|
if (shouldConnect) {
|
|
10178
10150
|
if (typeof atob === "undefined") {
|
|
10179
|
-
if (_optionalChain([clientOptions, 'access',
|
|
10151
|
+
if (_optionalChain([clientOptions, 'access', _225 => _225.polyfills, 'optionalAccess', _226 => _226.atob]) === void 0) {
|
|
10180
10152
|
throw new Error(
|
|
10181
10153
|
"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"
|
|
10182
10154
|
);
|
|
@@ -10188,7 +10160,7 @@ function createClient(options) {
|
|
|
10188
10160
|
return leaseRoom(newRoomDetails);
|
|
10189
10161
|
}
|
|
10190
10162
|
function getRoom(roomId) {
|
|
10191
|
-
const room = _optionalChain([roomsById, 'access',
|
|
10163
|
+
const room = _optionalChain([roomsById, 'access', _227 => _227.get, 'call', _228 => _228(roomId), 'optionalAccess', _229 => _229.room]);
|
|
10192
10164
|
return room ? room : null;
|
|
10193
10165
|
}
|
|
10194
10166
|
function logout() {
|
|
@@ -10204,7 +10176,7 @@ function createClient(options) {
|
|
|
10204
10176
|
const batchedResolveUsers = new Batch(
|
|
10205
10177
|
async (batchedUserIds) => {
|
|
10206
10178
|
const userIds = batchedUserIds.flat();
|
|
10207
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
10179
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _230 => _230({ userIds })]);
|
|
10208
10180
|
warnOnceIf(
|
|
10209
10181
|
!resolveUsers,
|
|
10210
10182
|
"Set the resolveUsers option in createClient to specify user info."
|
|
@@ -10221,7 +10193,7 @@ function createClient(options) {
|
|
|
10221
10193
|
const batchedResolveRoomsInfo = new Batch(
|
|
10222
10194
|
async (batchedRoomIds) => {
|
|
10223
10195
|
const roomIds = batchedRoomIds.flat();
|
|
10224
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
10196
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _231 => _231({ roomIds })]);
|
|
10225
10197
|
warnOnceIf(
|
|
10226
10198
|
!resolveRoomsInfo,
|
|
10227
10199
|
"Set the resolveRoomsInfo option in createClient to specify room info."
|
|
@@ -10238,7 +10210,7 @@ function createClient(options) {
|
|
|
10238
10210
|
const batchedResolveGroupsInfo = new Batch(
|
|
10239
10211
|
async (batchedGroupIds) => {
|
|
10240
10212
|
const groupIds = batchedGroupIds.flat();
|
|
10241
|
-
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall',
|
|
10213
|
+
const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _232 => _232({ groupIds })]);
|
|
10242
10214
|
warnOnceIf(
|
|
10243
10215
|
!resolveGroupsInfo,
|
|
10244
10216
|
"Set the resolveGroupsInfo option in createClient to specify group info."
|
|
@@ -10294,7 +10266,7 @@ function createClient(options) {
|
|
|
10294
10266
|
}
|
|
10295
10267
|
};
|
|
10296
10268
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
10297
|
-
_optionalChain([win, 'optionalAccess',
|
|
10269
|
+
_optionalChain([win, 'optionalAccess', _233 => _233.addEventListener, 'call', _234 => _234("beforeunload", maybePreventClose)]);
|
|
10298
10270
|
}
|
|
10299
10271
|
async function getNotificationSettings(options2) {
|
|
10300
10272
|
const plainSettings = await httpClient.getNotificationSettings(options2);
|
|
@@ -10421,7 +10393,7 @@ var commentBodyElementsTypes = {
|
|
|
10421
10393
|
mention: "inline"
|
|
10422
10394
|
};
|
|
10423
10395
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
10424
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
10396
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _235 => _235.content])) {
|
|
10425
10397
|
return;
|
|
10426
10398
|
}
|
|
10427
10399
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -10431,13 +10403,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
10431
10403
|
for (const block of body.content) {
|
|
10432
10404
|
if (type === "all" || type === "block") {
|
|
10433
10405
|
if (guard(block)) {
|
|
10434
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10406
|
+
_optionalChain([visitor, 'optionalCall', _236 => _236(block)]);
|
|
10435
10407
|
}
|
|
10436
10408
|
}
|
|
10437
10409
|
if (type === "all" || type === "inline") {
|
|
10438
10410
|
for (const inline of block.children) {
|
|
10439
10411
|
if (guard(inline)) {
|
|
10440
|
-
_optionalChain([visitor, 'optionalCall',
|
|
10412
|
+
_optionalChain([visitor, 'optionalCall', _237 => _237(inline)]);
|
|
10441
10413
|
}
|
|
10442
10414
|
}
|
|
10443
10415
|
}
|
|
@@ -10607,7 +10579,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
10607
10579
|
text: ({ element }) => element.text,
|
|
10608
10580
|
link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
|
|
10609
10581
|
mention: ({ element, user, group }) => {
|
|
10610
|
-
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10582
|
+
return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _238 => _238.name]), () => ( _optionalChain([group, 'optionalAccess', _239 => _239.name]))), () => ( element.id))}`;
|
|
10611
10583
|
}
|
|
10612
10584
|
};
|
|
10613
10585
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -10637,7 +10609,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
10637
10609
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
10638
10610
|
},
|
|
10639
10611
|
mention: ({ element, user, group }) => {
|
|
10640
|
-
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess',
|
|
10612
|
+
return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _240 => _240.name]) ? html`${_optionalChain([user, 'optionalAccess', _241 => _241.name])}` : _optionalChain([group, 'optionalAccess', _242 => _242.name]) ? html`${_optionalChain([group, 'optionalAccess', _243 => _243.name])}` : element.id}</span>`;
|
|
10641
10613
|
}
|
|
10642
10614
|
};
|
|
10643
10615
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -10667,20 +10639,20 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
10667
10639
|
return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
|
|
10668
10640
|
},
|
|
10669
10641
|
mention: ({ element, user, group }) => {
|
|
10670
|
-
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
10642
|
+
return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _244 => _244.name]), () => ( _optionalChain([group, 'optionalAccess', _245 => _245.name]))), () => ( element.id))}`;
|
|
10671
10643
|
}
|
|
10672
10644
|
};
|
|
10673
10645
|
async function stringifyCommentBody(body, options) {
|
|
10674
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10675
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
10646
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.format]), () => ( "plain"));
|
|
10647
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _247 => _247.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
10676
10648
|
const elements = {
|
|
10677
10649
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
10678
|
-
..._optionalChain([options, 'optionalAccess',
|
|
10650
|
+
..._optionalChain([options, 'optionalAccess', _248 => _248.elements])
|
|
10679
10651
|
};
|
|
10680
10652
|
const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
|
|
10681
10653
|
body,
|
|
10682
|
-
_optionalChain([options, 'optionalAccess',
|
|
10683
|
-
_optionalChain([options, 'optionalAccess',
|
|
10654
|
+
_optionalChain([options, 'optionalAccess', _249 => _249.resolveUsers]),
|
|
10655
|
+
_optionalChain([options, 'optionalAccess', _250 => _250.resolveGroupsInfo])
|
|
10684
10656
|
);
|
|
10685
10657
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
10686
10658
|
switch (block.type) {
|
|
@@ -10967,12 +10939,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
10967
10939
|
}
|
|
10968
10940
|
const newState = Object.assign({}, state);
|
|
10969
10941
|
for (const key in update.updates) {
|
|
10970
|
-
if (_optionalChain([update, 'access',
|
|
10942
|
+
if (_optionalChain([update, 'access', _251 => _251.updates, 'access', _252 => _252[key], 'optionalAccess', _253 => _253.type]) === "update") {
|
|
10971
10943
|
const val = update.node.get(key);
|
|
10972
10944
|
if (val !== void 0) {
|
|
10973
10945
|
newState[key] = lsonToJson(val);
|
|
10974
10946
|
}
|
|
10975
|
-
} else if (_optionalChain([update, 'access',
|
|
10947
|
+
} else if (_optionalChain([update, 'access', _254 => _254.updates, 'access', _255 => _255[key], 'optionalAccess', _256 => _256.type]) === "delete") {
|
|
10976
10948
|
delete newState[key];
|
|
10977
10949
|
}
|
|
10978
10950
|
}
|
|
@@ -11033,12 +11005,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
11033
11005
|
}
|
|
11034
11006
|
const newState = Object.assign({}, state);
|
|
11035
11007
|
for (const key in update.updates) {
|
|
11036
|
-
if (_optionalChain([update, 'access',
|
|
11008
|
+
if (_optionalChain([update, 'access', _257 => _257.updates, 'access', _258 => _258[key], 'optionalAccess', _259 => _259.type]) === "update") {
|
|
11037
11009
|
const value = update.node.get(key);
|
|
11038
11010
|
if (value !== void 0) {
|
|
11039
11011
|
newState[key] = lsonToJson(value);
|
|
11040
11012
|
}
|
|
11041
|
-
} else if (_optionalChain([update, 'access',
|
|
11013
|
+
} else if (_optionalChain([update, 'access', _260 => _260.updates, 'access', _261 => _261[key], 'optionalAccess', _262 => _262.type]) === "delete") {
|
|
11042
11014
|
delete newState[key];
|
|
11043
11015
|
}
|
|
11044
11016
|
}
|
|
@@ -11118,9 +11090,9 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11118
11090
|
const startTime = performance.now();
|
|
11119
11091
|
const doc = typeof document !== "undefined" ? document : void 0;
|
|
11120
11092
|
const win = typeof window !== "undefined" ? window : void 0;
|
|
11121
|
-
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
11093
|
+
const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _263 => _263.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
|
|
11122
11094
|
const context = {
|
|
11123
|
-
inForeground: _optionalChain([doc, 'optionalAccess',
|
|
11095
|
+
inForeground: _optionalChain([doc, 'optionalAccess', _264 => _264.visibilityState]) !== "hidden",
|
|
11124
11096
|
lastSuccessfulPollAt: startTime,
|
|
11125
11097
|
count: 0,
|
|
11126
11098
|
backoff: 0
|
|
@@ -11201,11 +11173,11 @@ function makePoller(callback, intervalMs, options) {
|
|
|
11201
11173
|
pollNowIfStale();
|
|
11202
11174
|
}
|
|
11203
11175
|
function onVisibilityChange() {
|
|
11204
|
-
setInForeground(_optionalChain([doc, 'optionalAccess',
|
|
11176
|
+
setInForeground(_optionalChain([doc, 'optionalAccess', _265 => _265.visibilityState]) !== "hidden");
|
|
11205
11177
|
}
|
|
11206
|
-
_optionalChain([doc, 'optionalAccess',
|
|
11207
|
-
_optionalChain([win, 'optionalAccess',
|
|
11208
|
-
_optionalChain([win, 'optionalAccess',
|
|
11178
|
+
_optionalChain([doc, 'optionalAccess', _266 => _266.addEventListener, 'call', _267 => _267("visibilitychange", onVisibilityChange)]);
|
|
11179
|
+
_optionalChain([win, 'optionalAccess', _268 => _268.addEventListener, 'call', _269 => _269("online", onVisibilityChange)]);
|
|
11180
|
+
_optionalChain([win, 'optionalAccess', _270 => _270.addEventListener, 'call', _271 => _271("focus", pollNowIfStale)]);
|
|
11209
11181
|
fsm.start();
|
|
11210
11182
|
return {
|
|
11211
11183
|
inc,
|