@liveblocks/core 1.11.3 → 1.12.0-test2
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.d.mts +78 -4
- package/dist/index.d.ts +78 -4
- package/dist/index.js +173 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
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 = "1.
|
|
9
|
+
var PKG_VERSION = "1.12.0-test2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1389,7 +1389,6 @@ function createAuthManager(authOptions) {
|
|
|
1389
1389
|
room: options.roomId
|
|
1390
1390
|
});
|
|
1391
1391
|
const parsed = parseAuthToken(response.token);
|
|
1392
|
-
verifyTokenPermissions(parsed, options);
|
|
1393
1392
|
if (seenTokens.has(parsed.raw)) {
|
|
1394
1393
|
throw new StopRetrying(
|
|
1395
1394
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
@@ -1402,7 +1401,6 @@ function createAuthManager(authOptions) {
|
|
|
1402
1401
|
if (response && typeof response === "object") {
|
|
1403
1402
|
if (typeof response.token === "string") {
|
|
1404
1403
|
const parsed = parseAuthToken(response.token);
|
|
1405
|
-
verifyTokenPermissions(parsed, options);
|
|
1406
1404
|
return parsed;
|
|
1407
1405
|
} else if (typeof response.error === "string") {
|
|
1408
1406
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -1421,23 +1419,6 @@ function createAuthManager(authOptions) {
|
|
|
1421
1419
|
"Unexpected authentication type. Must be private or custom."
|
|
1422
1420
|
);
|
|
1423
1421
|
}
|
|
1424
|
-
function verifyTokenPermissions(parsedToken, options) {
|
|
1425
|
-
if (!options.roomId && parsedToken.parsed.k === "acc" /* ACCESS_TOKEN */) {
|
|
1426
|
-
if (Object.entries(parsedToken.parsed.perms).length === 0) {
|
|
1427
|
-
return;
|
|
1428
|
-
}
|
|
1429
|
-
for (const [resource, scopes] of Object.entries(
|
|
1430
|
-
parsedToken.parsed.perms
|
|
1431
|
-
)) {
|
|
1432
|
-
if (resource.includes("*") && hasCorrespondingScopes(options.requestedScope, scopes)) {
|
|
1433
|
-
return;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
throw new StopRetrying(
|
|
1437
|
-
"The issued access token doesn't grant enough permissions. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/access-tokens-not-enough-permissions"
|
|
1438
|
-
);
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
1422
|
async function getAuthValue(requestOptions) {
|
|
1442
1423
|
if (authentication.type === "public") {
|
|
1443
1424
|
return { type: "public", publicApiKey: authentication.publicApiKey };
|
|
@@ -2035,6 +2016,18 @@ function convertToCommentUserReaction(data) {
|
|
|
2035
2016
|
function convertToInboxNotificationData(data) {
|
|
2036
2017
|
const notifiedAt = new Date(data.notifiedAt);
|
|
2037
2018
|
const readAt = data.readAt ? new Date(data.readAt) : null;
|
|
2019
|
+
if ("activities" in data) {
|
|
2020
|
+
const activities = data.activities.map((activity) => ({
|
|
2021
|
+
...activity,
|
|
2022
|
+
createdAt: new Date(activity.createdAt)
|
|
2023
|
+
}));
|
|
2024
|
+
return {
|
|
2025
|
+
...data,
|
|
2026
|
+
notifiedAt,
|
|
2027
|
+
readAt,
|
|
2028
|
+
activities
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2038
2031
|
return {
|
|
2039
2032
|
...data,
|
|
2040
2033
|
notifiedAt,
|
|
@@ -4768,6 +4761,115 @@ function isJsonObject(data) {
|
|
|
4768
4761
|
return !isJsonScalar(data) && !isJsonArray(data);
|
|
4769
4762
|
}
|
|
4770
4763
|
|
|
4764
|
+
// src/lib/objectToQuery.ts
|
|
4765
|
+
var identifierRegex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
4766
|
+
function objectToQuery(obj) {
|
|
4767
|
+
let filterList = [];
|
|
4768
|
+
const entries2 = Object.entries(obj);
|
|
4769
|
+
const keyValuePairs = [];
|
|
4770
|
+
const keyValuePairsWithOperator = [];
|
|
4771
|
+
const indexedKeys = [];
|
|
4772
|
+
entries2.forEach(([key, value]) => {
|
|
4773
|
+
if (!identifierRegex.test(key)) {
|
|
4774
|
+
throw new Error("Key must only contain letters, numbers, _");
|
|
4775
|
+
}
|
|
4776
|
+
if (isSimpleValue(value)) {
|
|
4777
|
+
keyValuePairs.push([key, value]);
|
|
4778
|
+
} else if (isValueWithOperator(value)) {
|
|
4779
|
+
keyValuePairsWithOperator.push([key, value]);
|
|
4780
|
+
} else if (typeof value === "object" && !("startsWith" in value)) {
|
|
4781
|
+
indexedKeys.push([key, value]);
|
|
4782
|
+
}
|
|
4783
|
+
});
|
|
4784
|
+
filterList = [
|
|
4785
|
+
...getFiltersFromKeyValuePairs(keyValuePairs),
|
|
4786
|
+
...getFiltersFromKeyValuePairsWithOperator(keyValuePairsWithOperator)
|
|
4787
|
+
];
|
|
4788
|
+
indexedKeys.forEach(([key, value]) => {
|
|
4789
|
+
const nestedEntries = Object.entries(value);
|
|
4790
|
+
const nKeyValuePairs = [];
|
|
4791
|
+
const nKeyValuePairsWithOperator = [];
|
|
4792
|
+
nestedEntries.forEach(([nestedKey, nestedValue]) => {
|
|
4793
|
+
if (isStringEmpty(nestedKey)) {
|
|
4794
|
+
throw new Error("Key cannot be empty");
|
|
4795
|
+
}
|
|
4796
|
+
if (isSimpleValue(nestedValue)) {
|
|
4797
|
+
nKeyValuePairs.push([formatFilterKey(key, nestedKey), nestedValue]);
|
|
4798
|
+
} else if (isValueWithOperator(nestedValue)) {
|
|
4799
|
+
nKeyValuePairsWithOperator.push([
|
|
4800
|
+
formatFilterKey(key, nestedKey),
|
|
4801
|
+
nestedValue
|
|
4802
|
+
]);
|
|
4803
|
+
}
|
|
4804
|
+
});
|
|
4805
|
+
filterList = [
|
|
4806
|
+
...filterList,
|
|
4807
|
+
...getFiltersFromKeyValuePairs(nKeyValuePairs),
|
|
4808
|
+
...getFiltersFromKeyValuePairsWithOperator(nKeyValuePairsWithOperator)
|
|
4809
|
+
];
|
|
4810
|
+
});
|
|
4811
|
+
return filterList.map(
|
|
4812
|
+
({ key, operator, value }) => formatFilter(key, operator, formatFilterValue(value))
|
|
4813
|
+
).join(" AND ");
|
|
4814
|
+
}
|
|
4815
|
+
var getFiltersFromKeyValuePairs = (keyValuePairs) => {
|
|
4816
|
+
const filters = [];
|
|
4817
|
+
keyValuePairs.forEach(([key, value]) => {
|
|
4818
|
+
filters.push({
|
|
4819
|
+
key,
|
|
4820
|
+
operator: ":",
|
|
4821
|
+
value
|
|
4822
|
+
});
|
|
4823
|
+
});
|
|
4824
|
+
return filters;
|
|
4825
|
+
};
|
|
4826
|
+
var getFiltersFromKeyValuePairsWithOperator = (keyValuePairsWithOperator) => {
|
|
4827
|
+
const filters = [];
|
|
4828
|
+
keyValuePairsWithOperator.forEach(([key, value]) => {
|
|
4829
|
+
if ("startsWith" in value && typeof value.startsWith === "string") {
|
|
4830
|
+
filters.push({
|
|
4831
|
+
key,
|
|
4832
|
+
operator: "^",
|
|
4833
|
+
value: value.startsWith
|
|
4834
|
+
});
|
|
4835
|
+
}
|
|
4836
|
+
});
|
|
4837
|
+
return filters;
|
|
4838
|
+
};
|
|
4839
|
+
var isSimpleValue = (value) => {
|
|
4840
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
4841
|
+
return true;
|
|
4842
|
+
}
|
|
4843
|
+
return false;
|
|
4844
|
+
};
|
|
4845
|
+
var isValueWithOperator = (value) => {
|
|
4846
|
+
if (typeof value === "object" && value !== null && "startsWith" in value) {
|
|
4847
|
+
return true;
|
|
4848
|
+
}
|
|
4849
|
+
return false;
|
|
4850
|
+
};
|
|
4851
|
+
var formatFilter = (key, operator, value) => {
|
|
4852
|
+
return `${key}${operator}${value}`;
|
|
4853
|
+
};
|
|
4854
|
+
var formatFilterKey = (key, nestedKey) => {
|
|
4855
|
+
if (nestedKey) {
|
|
4856
|
+
return `${key}[${JSON.stringify(nestedKey)}]`;
|
|
4857
|
+
}
|
|
4858
|
+
return key;
|
|
4859
|
+
};
|
|
4860
|
+
var formatFilterValue = (value) => {
|
|
4861
|
+
if (typeof value === "string") {
|
|
4862
|
+
if (isStringEmpty(value)) {
|
|
4863
|
+
throw new Error("Value cannot be empty");
|
|
4864
|
+
}
|
|
4865
|
+
return JSON.stringify(value);
|
|
4866
|
+
}
|
|
4867
|
+
return value.toString();
|
|
4868
|
+
};
|
|
4869
|
+
var isStringEmpty = (value) => {
|
|
4870
|
+
return !value || value.toString().trim() === "";
|
|
4871
|
+
};
|
|
4872
|
+
|
|
4771
4873
|
// src/protocol/ClientMsg.ts
|
|
4772
4874
|
var ClientMsgCode = /* @__PURE__ */ ((ClientMsgCode2) => {
|
|
4773
4875
|
ClientMsgCode2[ClientMsgCode2["UPDATE_PRESENCE"] = 100] = "UPDATE_PRESENCE";
|
|
@@ -5070,19 +5172,20 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
|
|
|
5070
5172
|
return body;
|
|
5071
5173
|
}
|
|
5072
5174
|
async function getThreads(options) {
|
|
5175
|
+
let query;
|
|
5176
|
+
if (_optionalChain([options, 'optionalAccess', _125 => _125.query])) {
|
|
5177
|
+
query = objectToQuery(options.query);
|
|
5178
|
+
}
|
|
5073
5179
|
const response = await fetchCommentsApi(
|
|
5074
|
-
"/threads
|
|
5180
|
+
"/threads",
|
|
5075
5181
|
{
|
|
5076
|
-
since: _optionalChain([options, 'optionalAccess',
|
|
5182
|
+
since: _optionalChain([options, 'optionalAccess', _126 => _126.since, 'optionalAccess', _127 => _127.toISOString, 'call', _128 => _128()]),
|
|
5183
|
+
query
|
|
5077
5184
|
},
|
|
5078
5185
|
{
|
|
5079
|
-
body: JSON.stringify({
|
|
5080
|
-
..._optionalChain([options, 'optionalAccess', _128 => _128.query, 'optionalAccess', _129 => _129.metadata]) && { metadata: options.query.metadata }
|
|
5081
|
-
}),
|
|
5082
5186
|
headers: {
|
|
5083
5187
|
"Content-Type": "application/json"
|
|
5084
|
-
}
|
|
5085
|
-
method: "POST"
|
|
5188
|
+
}
|
|
5086
5189
|
}
|
|
5087
5190
|
);
|
|
5088
5191
|
if (response.ok) {
|
|
@@ -5459,7 +5562,7 @@ function createRoom(options, config) {
|
|
|
5459
5562
|
}
|
|
5460
5563
|
},
|
|
5461
5564
|
assertStorageIsWritable: () => {
|
|
5462
|
-
const scopes = _optionalChain([context, 'access',
|
|
5565
|
+
const scopes = _optionalChain([context, 'access', _129 => _129.dynamicSessionInfo, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.scopes]);
|
|
5463
5566
|
if (scopes === void 0) {
|
|
5464
5567
|
return;
|
|
5465
5568
|
}
|
|
@@ -5495,12 +5598,12 @@ function createRoom(options, config) {
|
|
|
5495
5598
|
`/v2/c/rooms/${encodeURIComponent(roomId)}${endpoint}`,
|
|
5496
5599
|
params
|
|
5497
5600
|
);
|
|
5498
|
-
const fetcher = _optionalChain([config, 'access',
|
|
5601
|
+
const fetcher = _optionalChain([config, 'access', _132 => _132.polyfills, 'optionalAccess', _133 => _133.fetch]) || /* istanbul ignore next */
|
|
5499
5602
|
fetch;
|
|
5500
5603
|
return await fetcher(url, {
|
|
5501
5604
|
...options2,
|
|
5502
5605
|
headers: {
|
|
5503
|
-
..._optionalChain([options2, 'optionalAccess',
|
|
5606
|
+
..._optionalChain([options2, 'optionalAccess', _134 => _134.headers]),
|
|
5504
5607
|
Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
|
|
5505
5608
|
}
|
|
5506
5609
|
});
|
|
@@ -5527,7 +5630,7 @@ function createRoom(options, config) {
|
|
|
5527
5630
|
}
|
|
5528
5631
|
function sendMessages(messages) {
|
|
5529
5632
|
const serializedPayload = JSON.stringify(messages);
|
|
5530
|
-
const nonce = _optionalChain([context, 'access',
|
|
5633
|
+
const nonce = _optionalChain([context, 'access', _135 => _135.dynamicSessionInfo, 'access', _136 => _136.current, 'optionalAccess', _137 => _137.nonce]);
|
|
5531
5634
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5532
5635
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5533
5636
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
@@ -5789,7 +5892,7 @@ function createRoom(options, config) {
|
|
|
5789
5892
|
}
|
|
5790
5893
|
context.myPresence.patch(patch);
|
|
5791
5894
|
if (context.activeBatch) {
|
|
5792
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5895
|
+
if (_optionalChain([options2, 'optionalAccess', _138 => _138.addToHistory])) {
|
|
5793
5896
|
context.activeBatch.reverseOps.unshift({
|
|
5794
5897
|
type: "presence",
|
|
5795
5898
|
data: oldValues
|
|
@@ -5799,7 +5902,7 @@ function createRoom(options, config) {
|
|
|
5799
5902
|
} else {
|
|
5800
5903
|
flushNowOrSoon();
|
|
5801
5904
|
batchUpdates(() => {
|
|
5802
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5905
|
+
if (_optionalChain([options2, 'optionalAccess', _139 => _139.addToHistory])) {
|
|
5803
5906
|
addToUndoStack(
|
|
5804
5907
|
[{ type: "presence", data: oldValues }],
|
|
5805
5908
|
doNotBatchUpdates
|
|
@@ -5997,7 +6100,7 @@ function createRoom(options, config) {
|
|
|
5997
6100
|
if (process.env.NODE_ENV !== "production") {
|
|
5998
6101
|
const traces = /* @__PURE__ */ new Set();
|
|
5999
6102
|
for (const opId of message.opIds) {
|
|
6000
|
-
const trace = _optionalChain([context, 'access',
|
|
6103
|
+
const trace = _optionalChain([context, 'access', _140 => _140.opStackTraces, 'optionalAccess', _141 => _141.get, 'call', _142 => _142(opId)]);
|
|
6001
6104
|
if (trace) {
|
|
6002
6105
|
traces.add(trace);
|
|
6003
6106
|
}
|
|
@@ -6129,7 +6232,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6129
6232
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
6130
6233
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
6131
6234
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
6132
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
6235
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _143 => _143()]);
|
|
6133
6236
|
notifyStorageStatus();
|
|
6134
6237
|
eventHub.storageDidLoad.notify();
|
|
6135
6238
|
}
|
|
@@ -6404,7 +6507,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6404
6507
|
{
|
|
6405
6508
|
[kInternal]: {
|
|
6406
6509
|
get presenceBuffer() {
|
|
6407
|
-
return deepClone(_nullishCoalesce(_optionalChain([context, 'access',
|
|
6510
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _144 => _144.buffer, 'access', _145 => _145.presenceUpdates, 'optionalAccess', _146 => _146.data]), () => ( null)));
|
|
6408
6511
|
},
|
|
6409
6512
|
// prettier-ignore
|
|
6410
6513
|
get undoStack() {
|
|
@@ -6553,7 +6656,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
6553
6656
|
}
|
|
6554
6657
|
if (isLiveNode(first)) {
|
|
6555
6658
|
const node = first;
|
|
6556
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6659
|
+
if (_optionalChain([options, 'optionalAccess', _147 => _147.isDeep])) {
|
|
6557
6660
|
const storageCallback = second;
|
|
6558
6661
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
6559
6662
|
} else {
|
|
@@ -6617,7 +6720,7 @@ function createClientStore() {
|
|
|
6617
6720
|
threads: deleteKeyImmutable(state.threads, threadId),
|
|
6618
6721
|
inboxNotifications: Object.fromEntries(
|
|
6619
6722
|
Object.entries(state.inboxNotifications).filter(
|
|
6620
|
-
([_id, notification]) => notification.threadId !== threadId
|
|
6723
|
+
([_id, notification]) => notification.kind === "thread" && notification.threadId !== threadId
|
|
6621
6724
|
)
|
|
6622
6725
|
)
|
|
6623
6726
|
};
|
|
@@ -6759,7 +6862,7 @@ function applyOptimisticUpdates(state) {
|
|
|
6759
6862
|
optimisticUpdate.comment
|
|
6760
6863
|
);
|
|
6761
6864
|
const inboxNotification = Object.values(result.inboxNotifications).find(
|
|
6762
|
-
(notification) => notification.
|
|
6865
|
+
(notification) => notification.kind === "thread" && notification.threadId !== thread.id
|
|
6763
6866
|
);
|
|
6764
6867
|
if (inboxNotification === void 0) {
|
|
6765
6868
|
break;
|
|
@@ -6914,7 +7017,7 @@ function upsertComment(thread, comment) {
|
|
|
6914
7017
|
);
|
|
6915
7018
|
if (existingComment === void 0) {
|
|
6916
7019
|
const updatedAt = new Date(
|
|
6917
|
-
Math.max(_optionalChain([thread, 'access',
|
|
7020
|
+
Math.max(_optionalChain([thread, 'access', _148 => _148.updatedAt, 'optionalAccess', _149 => _149.getTime, 'call', _150 => _150()]) || 0, comment.createdAt.getTime())
|
|
6918
7021
|
);
|
|
6919
7022
|
const updatedThread = {
|
|
6920
7023
|
...thread,
|
|
@@ -6934,8 +7037,8 @@ function upsertComment(thread, comment) {
|
|
|
6934
7037
|
...thread,
|
|
6935
7038
|
updatedAt: new Date(
|
|
6936
7039
|
Math.max(
|
|
6937
|
-
_optionalChain([thread, 'access',
|
|
6938
|
-
_optionalChain([comment, 'access',
|
|
7040
|
+
_optionalChain([thread, 'access', _151 => _151.updatedAt, 'optionalAccess', _152 => _152.getTime, 'call', _153 => _153()]) || 0,
|
|
7041
|
+
_optionalChain([comment, 'access', _154 => _154.editedAt, 'optionalAccess', _155 => _155.getTime, 'call', _156 => _156()]) || comment.createdAt.getTime()
|
|
6939
7042
|
)
|
|
6940
7043
|
),
|
|
6941
7044
|
comments: updatedComments
|
|
@@ -7000,7 +7103,7 @@ function addReaction(thread, commentId, reaction) {
|
|
|
7000
7103
|
return {
|
|
7001
7104
|
...thread,
|
|
7002
7105
|
updatedAt: new Date(
|
|
7003
|
-
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access',
|
|
7106
|
+
Math.max(reaction.createdAt.getTime(), _optionalChain([thread, 'access', _157 => _157.updatedAt, 'optionalAccess', _158 => _158.getTime, 'call', _159 => _159()]) || 0)
|
|
7004
7107
|
),
|
|
7005
7108
|
comments: updatedComments
|
|
7006
7109
|
};
|
|
@@ -7033,7 +7136,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
|
|
|
7033
7136
|
return {
|
|
7034
7137
|
...thread,
|
|
7035
7138
|
updatedAt: new Date(
|
|
7036
|
-
Math.max(removedAt.getTime(), _optionalChain([thread, 'access',
|
|
7139
|
+
Math.max(removedAt.getTime(), _optionalChain([thread, 'access', _160 => _160.updatedAt, 'optionalAccess', _161 => _161.getTime, 'call', _162 => _162()]) || 0)
|
|
7037
7140
|
),
|
|
7038
7141
|
comments: updatedComments
|
|
7039
7142
|
};
|
|
@@ -7148,12 +7251,12 @@ function createClient(options) {
|
|
|
7148
7251
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7149
7252
|
roomId,
|
|
7150
7253
|
baseUrl,
|
|
7151
|
-
_optionalChain([clientOptions, 'access',
|
|
7254
|
+
_optionalChain([clientOptions, 'access', _163 => _163.polyfills, 'optionalAccess', _164 => _164.WebSocket])
|
|
7152
7255
|
),
|
|
7153
7256
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7154
7257
|
})),
|
|
7155
7258
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7156
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7259
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _165 => _165.unstable_batchedUpdates]),
|
|
7157
7260
|
baseUrl,
|
|
7158
7261
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7159
7262
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7169,7 +7272,7 @@ function createClient(options) {
|
|
|
7169
7272
|
const shouldConnect = _nullishCoalesce(_nullishCoalesce(options2.autoConnect, () => ( options2.shouldInitiallyConnect)), () => ( true));
|
|
7170
7273
|
if (shouldConnect) {
|
|
7171
7274
|
if (typeof atob === "undefined") {
|
|
7172
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7275
|
+
if (_optionalChain([clientOptions, 'access', _166 => _166.polyfills, 'optionalAccess', _167 => _167.atob]) === void 0) {
|
|
7173
7276
|
throw new Error(
|
|
7174
7277
|
"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"
|
|
7175
7278
|
);
|
|
@@ -7185,11 +7288,11 @@ function createClient(options) {
|
|
|
7185
7288
|
return room;
|
|
7186
7289
|
}
|
|
7187
7290
|
function getRoom(roomId) {
|
|
7188
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7291
|
+
const room = _optionalChain([roomsById, 'access', _168 => _168.get, 'call', _169 => _169(roomId), 'optionalAccess', _170 => _170.room]);
|
|
7189
7292
|
return room ? room : null;
|
|
7190
7293
|
}
|
|
7191
7294
|
function forceLeave(roomId) {
|
|
7192
|
-
const unsubs = _nullishCoalesce(_optionalChain([roomsById, 'access',
|
|
7295
|
+
const unsubs = _nullishCoalesce(_optionalChain([roomsById, 'access', _171 => _171.get, 'call', _172 => _172(roomId), 'optionalAccess', _173 => _173.unsubs]), () => ( /* @__PURE__ */ new Set()));
|
|
7193
7296
|
for (const unsub of unsubs) {
|
|
7194
7297
|
unsub();
|
|
7195
7298
|
}
|
|
@@ -7210,7 +7313,7 @@ function createClient(options) {
|
|
|
7210
7313
|
markInboxNotificationAsRead
|
|
7211
7314
|
} = createNotificationsApi({
|
|
7212
7315
|
baseUrl,
|
|
7213
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7316
|
+
fetcher: _optionalChain([clientOptions, 'access', _174 => _174.polyfills, 'optionalAccess', _175 => _175.fetch]) || /* istanbul ignore next */
|
|
7214
7317
|
fetch,
|
|
7215
7318
|
authManager,
|
|
7216
7319
|
currentUserIdStore
|
|
@@ -7224,7 +7327,7 @@ function createClient(options) {
|
|
|
7224
7327
|
const usersStore = createBatchStore(
|
|
7225
7328
|
async (batchedUserIds) => {
|
|
7226
7329
|
const userIds = batchedUserIds.flat();
|
|
7227
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7330
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _176 => _176({ userIds })]);
|
|
7228
7331
|
warnIfNoResolveUsers();
|
|
7229
7332
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7230
7333
|
},
|
|
@@ -7238,7 +7341,7 @@ function createClient(options) {
|
|
|
7238
7341
|
const roomsInfoStore = createBatchStore(
|
|
7239
7342
|
async (batchedRoomIds) => {
|
|
7240
7343
|
const roomIds = batchedRoomIds.flat();
|
|
7241
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7344
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _177 => _177({ roomIds })]);
|
|
7242
7345
|
warnIfNoResolveRoomsInfo();
|
|
7243
7346
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7244
7347
|
},
|
|
@@ -7355,7 +7458,7 @@ var commentBodyElementsTypes = {
|
|
|
7355
7458
|
mention: "inline"
|
|
7356
7459
|
};
|
|
7357
7460
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7358
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7461
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _178 => _178.content])) {
|
|
7359
7462
|
return;
|
|
7360
7463
|
}
|
|
7361
7464
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7365,13 +7468,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7365
7468
|
for (const block of body.content) {
|
|
7366
7469
|
if (type === "all" || type === "block") {
|
|
7367
7470
|
if (guard(block)) {
|
|
7368
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7471
|
+
_optionalChain([visitor, 'optionalCall', _179 => _179(block)]);
|
|
7369
7472
|
}
|
|
7370
7473
|
}
|
|
7371
7474
|
if (type === "all" || type === "inline") {
|
|
7372
7475
|
for (const inline of block.children) {
|
|
7373
7476
|
if (guard(inline)) {
|
|
7374
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7477
|
+
_optionalChain([visitor, 'optionalCall', _180 => _180(inline)]);
|
|
7375
7478
|
}
|
|
7376
7479
|
}
|
|
7377
7480
|
}
|
|
@@ -7396,7 +7499,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7396
7499
|
userIds
|
|
7397
7500
|
});
|
|
7398
7501
|
for (const [index, userId] of userIds.entries()) {
|
|
7399
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7502
|
+
const user = _optionalChain([users, 'optionalAccess', _181 => _181[index]]);
|
|
7400
7503
|
if (user) {
|
|
7401
7504
|
resolvedUsers.set(userId, user);
|
|
7402
7505
|
}
|
|
@@ -7519,7 +7622,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7519
7622
|
text: ({ element }) => element.text,
|
|
7520
7623
|
link: ({ element }) => element.url,
|
|
7521
7624
|
mention: ({ element, user }) => {
|
|
7522
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7625
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _182 => _182.name]), () => ( element.id))}`;
|
|
7523
7626
|
}
|
|
7524
7627
|
};
|
|
7525
7628
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7549,7 +7652,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7549
7652
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.url}</a>`;
|
|
7550
7653
|
},
|
|
7551
7654
|
mention: ({ element, user }) => {
|
|
7552
|
-
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7655
|
+
return html`<span data-mention>@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _183 => _183.name]), () => ( element.id))}</span>`;
|
|
7553
7656
|
}
|
|
7554
7657
|
};
|
|
7555
7658
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7579,19 +7682,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7579
7682
|
return markdown`[${element.url}](${href})`;
|
|
7580
7683
|
},
|
|
7581
7684
|
mention: ({ element, user }) => {
|
|
7582
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7685
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _184 => _184.name]), () => ( element.id))}`;
|
|
7583
7686
|
}
|
|
7584
7687
|
};
|
|
7585
7688
|
async function stringifyCommentBody(body, options) {
|
|
7586
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7587
|
-
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7689
|
+
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _185 => _185.format]), () => ( "plain"));
|
|
7690
|
+
const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _186 => _186.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
|
|
7588
7691
|
const elements = {
|
|
7589
7692
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7590
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7693
|
+
..._optionalChain([options, 'optionalAccess', _187 => _187.elements])
|
|
7591
7694
|
};
|
|
7592
7695
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7593
7696
|
body,
|
|
7594
|
-
_optionalChain([options, 'optionalAccess',
|
|
7697
|
+
_optionalChain([options, 'optionalAccess', _188 => _188.resolveUsers])
|
|
7595
7698
|
);
|
|
7596
7699
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7597
7700
|
switch (block.type) {
|
|
@@ -7866,12 +7969,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7866
7969
|
}
|
|
7867
7970
|
const newState = Object.assign({}, state);
|
|
7868
7971
|
for (const key in update.updates) {
|
|
7869
|
-
if (_optionalChain([update, 'access',
|
|
7972
|
+
if (_optionalChain([update, 'access', _189 => _189.updates, 'access', _190 => _190[key], 'optionalAccess', _191 => _191.type]) === "update") {
|
|
7870
7973
|
const val = update.node.get(key);
|
|
7871
7974
|
if (val !== void 0) {
|
|
7872
7975
|
newState[key] = lsonToJson(val);
|
|
7873
7976
|
}
|
|
7874
|
-
} else if (_optionalChain([update, 'access',
|
|
7977
|
+
} else if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "delete") {
|
|
7875
7978
|
delete newState[key];
|
|
7876
7979
|
}
|
|
7877
7980
|
}
|
|
@@ -7932,12 +8035,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7932
8035
|
}
|
|
7933
8036
|
const newState = Object.assign({}, state);
|
|
7934
8037
|
for (const key in update.updates) {
|
|
7935
|
-
if (_optionalChain([update, 'access',
|
|
8038
|
+
if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "update") {
|
|
7936
8039
|
const value = update.node.get(key);
|
|
7937
8040
|
if (value !== void 0) {
|
|
7938
8041
|
newState[key] = lsonToJson(value);
|
|
7939
8042
|
}
|
|
7940
|
-
} else if (_optionalChain([update, 'access',
|
|
8043
|
+
} else if (_optionalChain([update, 'access', _198 => _198.updates, 'access', _199 => _199[key], 'optionalAccess', _200 => _200.type]) === "delete") {
|
|
7941
8044
|
delete newState[key];
|
|
7942
8045
|
}
|
|
7943
8046
|
}
|
|
@@ -8155,5 +8258,7 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8155
8258
|
|
|
8156
8259
|
|
|
8157
8260
|
|
|
8158
|
-
|
|
8261
|
+
|
|
8262
|
+
|
|
8263
|
+
exports.ClientMsgCode = ClientMsgCode; exports.CommentsApiError = CommentsApiError; exports.CrdtType = CrdtType; exports.LiveList = LiveList; exports.LiveMap = LiveMap; exports.LiveObject = LiveObject; exports.NotificationsApiError = NotificationsApiError; exports.OpCode = OpCode; exports.ServerMsgCode = ServerMsgCode; exports.WebsocketCloseCodes = WebsocketCloseCodes; exports.ackOp = ackOp; exports.addReaction = addReaction; exports.applyOptimisticUpdates = applyOptimisticUpdates; exports.asPos = asPos; exports.assert = assert; exports.assertNever = assertNever; exports.b64decode = b64decode; exports.cloneLson = cloneLson; exports.console = fancy_console_exports; exports.convertToCommentData = convertToCommentData; exports.convertToCommentUserReaction = convertToCommentUserReaction; exports.convertToInboxNotificationData = convertToInboxNotificationData; exports.convertToThreadData = convertToThreadData; exports.createClient = createClient; exports.deleteComment = deleteComment; exports.deprecate = deprecate; exports.deprecateIf = deprecateIf; exports.detectDupes = detectDupes; exports.errorIf = errorIf; exports.freeze = freeze; exports.getMentionedIdsFromCommentBody = getMentionedIdsFromCommentBody; exports.isChildCrdt = isChildCrdt; exports.isJsonArray = isJsonArray; exports.isJsonObject = isJsonObject; exports.isJsonScalar = isJsonScalar; exports.isLiveNode = isLiveNode; exports.isPlainObject = isPlainObject; exports.isRootCrdt = isRootCrdt; exports.kInternal = kInternal; exports.legacy_patchImmutableObject = legacy_patchImmutableObject; exports.lsonToJson = lsonToJson; exports.makeEventSource = makeEventSource; exports.makePoller = makePoller; exports.makePosition = makePosition; exports.nn = nn; exports.objectToQuery = objectToQuery; exports.patchLiveObjectKey = patchLiveObjectKey; exports.raise = raise; exports.removeReaction = removeReaction; exports.shallow = shallow; exports.stringify = stringify; exports.stringifyCommentBody = stringifyCommentBody; exports.throwUsageError = throwUsageError; exports.toPlainLson = toPlainLson; exports.tryParseJson = tryParseJson; exports.upsertComment = upsertComment; exports.withTimeout = withTimeout;
|
|
8159
8264
|
//# sourceMappingURL=index.js.map
|