@liveblocks/core 1.12.0-test1 → 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 +52 -4
- package/dist/index.d.ts +52 -4
- package/dist/index.js +170 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +131 -30
- 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.12.0-
|
|
9
|
+
var PKG_VERSION = "1.12.0-test2";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -782,9 +782,13 @@ function logPrematureErrorOrCloseEvent(e) {
|
|
|
782
782
|
};
|
|
783
783
|
}
|
|
784
784
|
function logCloseEvent(event) {
|
|
785
|
+
const details = [`code: ${event.code}`];
|
|
786
|
+
if (event.reason) {
|
|
787
|
+
details.push(`reason: ${event.reason}`);
|
|
788
|
+
}
|
|
785
789
|
return (ctx) => {
|
|
786
790
|
warn(
|
|
787
|
-
`Connection to Liveblocks websocket server closed (
|
|
791
|
+
`Connection to Liveblocks websocket server closed (${details.join(", ")}). Retrying in ${ctx.backoffDelay}ms.`
|
|
788
792
|
);
|
|
789
793
|
};
|
|
790
794
|
}
|
|
@@ -1385,7 +1389,6 @@ function createAuthManager(authOptions) {
|
|
|
1385
1389
|
room: options.roomId
|
|
1386
1390
|
});
|
|
1387
1391
|
const parsed = parseAuthToken(response.token);
|
|
1388
|
-
verifyTokenPermissions(parsed, options);
|
|
1389
1392
|
if (seenTokens.has(parsed.raw)) {
|
|
1390
1393
|
throw new StopRetrying(
|
|
1391
1394
|
"The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
|
|
@@ -1398,7 +1401,6 @@ function createAuthManager(authOptions) {
|
|
|
1398
1401
|
if (response && typeof response === "object") {
|
|
1399
1402
|
if (typeof response.token === "string") {
|
|
1400
1403
|
const parsed = parseAuthToken(response.token);
|
|
1401
|
-
verifyTokenPermissions(parsed, options);
|
|
1402
1404
|
return parsed;
|
|
1403
1405
|
} else if (typeof response.error === "string") {
|
|
1404
1406
|
const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
|
|
@@ -1417,23 +1419,6 @@ function createAuthManager(authOptions) {
|
|
|
1417
1419
|
"Unexpected authentication type. Must be private or custom."
|
|
1418
1420
|
);
|
|
1419
1421
|
}
|
|
1420
|
-
function verifyTokenPermissions(parsedToken, options) {
|
|
1421
|
-
if (!options.roomId && parsedToken.parsed.k === "acc" /* ACCESS_TOKEN */) {
|
|
1422
|
-
if (Object.entries(parsedToken.parsed.perms).length === 0) {
|
|
1423
|
-
return;
|
|
1424
|
-
}
|
|
1425
|
-
for (const [resource, scopes] of Object.entries(
|
|
1426
|
-
parsedToken.parsed.perms
|
|
1427
|
-
)) {
|
|
1428
|
-
if (resource.includes("*") && hasCorrespondingScopes(options.requestedScope, scopes)) {
|
|
1429
|
-
return;
|
|
1430
|
-
}
|
|
1431
|
-
}
|
|
1432
|
-
throw new StopRetrying(
|
|
1433
|
-
"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"
|
|
1434
|
-
);
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
1422
|
async function getAuthValue(requestOptions) {
|
|
1438
1423
|
if (authentication.type === "public") {
|
|
1439
1424
|
return { type: "public", publicApiKey: authentication.publicApiKey };
|
|
@@ -4776,6 +4761,115 @@ function isJsonObject(data) {
|
|
|
4776
4761
|
return !isJsonScalar(data) && !isJsonArray(data);
|
|
4777
4762
|
}
|
|
4778
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
|
+
|
|
4779
4873
|
// src/protocol/ClientMsg.ts
|
|
4780
4874
|
var ClientMsgCode = /* @__PURE__ */ ((ClientMsgCode2) => {
|
|
4781
4875
|
ClientMsgCode2[ClientMsgCode2["UPDATE_PRESENCE"] = 100] = "UPDATE_PRESENCE";
|
|
@@ -5078,19 +5172,20 @@ function createCommentsApi(roomId, getAuthValue, fetchClientApi) {
|
|
|
5078
5172
|
return body;
|
|
5079
5173
|
}
|
|
5080
5174
|
async function getThreads(options) {
|
|
5175
|
+
let query;
|
|
5176
|
+
if (_optionalChain([options, 'optionalAccess', _125 => _125.query])) {
|
|
5177
|
+
query = objectToQuery(options.query);
|
|
5178
|
+
}
|
|
5081
5179
|
const response = await fetchCommentsApi(
|
|
5082
|
-
"/threads
|
|
5180
|
+
"/threads",
|
|
5083
5181
|
{
|
|
5084
|
-
since: _optionalChain([options, 'optionalAccess',
|
|
5182
|
+
since: _optionalChain([options, 'optionalAccess', _126 => _126.since, 'optionalAccess', _127 => _127.toISOString, 'call', _128 => _128()]),
|
|
5183
|
+
query
|
|
5085
5184
|
},
|
|
5086
5185
|
{
|
|
5087
|
-
body: JSON.stringify({
|
|
5088
|
-
..._optionalChain([options, 'optionalAccess', _128 => _128.query, 'optionalAccess', _129 => _129.metadata]) && { metadata: options.query.metadata }
|
|
5089
|
-
}),
|
|
5090
5186
|
headers: {
|
|
5091
5187
|
"Content-Type": "application/json"
|
|
5092
|
-
}
|
|
5093
|
-
method: "POST"
|
|
5188
|
+
}
|
|
5094
5189
|
}
|
|
5095
5190
|
);
|
|
5096
5191
|
if (response.ok) {
|
|
@@ -5444,7 +5539,9 @@ function createRoom(options, config) {
|
|
|
5444
5539
|
}
|
|
5445
5540
|
}
|
|
5446
5541
|
if (activeBatch) {
|
|
5447
|
-
|
|
5542
|
+
for (const op of ops) {
|
|
5543
|
+
activeBatch.ops.push(op);
|
|
5544
|
+
}
|
|
5448
5545
|
for (const [key, value] of storageUpdates) {
|
|
5449
5546
|
activeBatch.updates.storageUpdates.set(
|
|
5450
5547
|
key,
|
|
@@ -5465,7 +5562,7 @@ function createRoom(options, config) {
|
|
|
5465
5562
|
}
|
|
5466
5563
|
},
|
|
5467
5564
|
assertStorageIsWritable: () => {
|
|
5468
|
-
const scopes = _optionalChain([context, 'access',
|
|
5565
|
+
const scopes = _optionalChain([context, 'access', _129 => _129.dynamicSessionInfo, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.scopes]);
|
|
5469
5566
|
if (scopes === void 0) {
|
|
5470
5567
|
return;
|
|
5471
5568
|
}
|
|
@@ -5501,12 +5598,12 @@ function createRoom(options, config) {
|
|
|
5501
5598
|
`/v2/c/rooms/${encodeURIComponent(roomId)}${endpoint}`,
|
|
5502
5599
|
params
|
|
5503
5600
|
);
|
|
5504
|
-
const fetcher = _optionalChain([config, 'access',
|
|
5601
|
+
const fetcher = _optionalChain([config, 'access', _132 => _132.polyfills, 'optionalAccess', _133 => _133.fetch]) || /* istanbul ignore next */
|
|
5505
5602
|
fetch;
|
|
5506
5603
|
return await fetcher(url, {
|
|
5507
5604
|
...options2,
|
|
5508
5605
|
headers: {
|
|
5509
|
-
..._optionalChain([options2, 'optionalAccess',
|
|
5606
|
+
..._optionalChain([options2, 'optionalAccess', _134 => _134.headers]),
|
|
5510
5607
|
Authorization: `Bearer ${getAuthBearerHeaderFromAuthValue(authValue)}`
|
|
5511
5608
|
}
|
|
5512
5609
|
});
|
|
@@ -5533,7 +5630,7 @@ function createRoom(options, config) {
|
|
|
5533
5630
|
}
|
|
5534
5631
|
function sendMessages(messages) {
|
|
5535
5632
|
const serializedPayload = JSON.stringify(messages);
|
|
5536
|
-
const nonce = _optionalChain([context, 'access',
|
|
5633
|
+
const nonce = _optionalChain([context, 'access', _135 => _135.dynamicSessionInfo, 'access', _136 => _136.current, 'optionalAccess', _137 => _137.nonce]);
|
|
5537
5634
|
if (config.unstable_fallbackToHTTP && nonce) {
|
|
5538
5635
|
const size = new TextEncoder().encode(serializedPayload).length;
|
|
5539
5636
|
if (size > MAX_SOCKET_MESSAGE_SIZE) {
|
|
@@ -5795,7 +5892,7 @@ function createRoom(options, config) {
|
|
|
5795
5892
|
}
|
|
5796
5893
|
context.myPresence.patch(patch);
|
|
5797
5894
|
if (context.activeBatch) {
|
|
5798
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5895
|
+
if (_optionalChain([options2, 'optionalAccess', _138 => _138.addToHistory])) {
|
|
5799
5896
|
context.activeBatch.reverseOps.unshift({
|
|
5800
5897
|
type: "presence",
|
|
5801
5898
|
data: oldValues
|
|
@@ -5805,7 +5902,7 @@ function createRoom(options, config) {
|
|
|
5805
5902
|
} else {
|
|
5806
5903
|
flushNowOrSoon();
|
|
5807
5904
|
batchUpdates(() => {
|
|
5808
|
-
if (_optionalChain([options2, 'optionalAccess',
|
|
5905
|
+
if (_optionalChain([options2, 'optionalAccess', _139 => _139.addToHistory])) {
|
|
5809
5906
|
addToUndoStack(
|
|
5810
5907
|
[{ type: "presence", data: oldValues }],
|
|
5811
5908
|
doNotBatchUpdates
|
|
@@ -6003,7 +6100,7 @@ function createRoom(options, config) {
|
|
|
6003
6100
|
if (process.env.NODE_ENV !== "production") {
|
|
6004
6101
|
const traces = /* @__PURE__ */ new Set();
|
|
6005
6102
|
for (const opId of message.opIds) {
|
|
6006
|
-
const trace = _optionalChain([context, 'access',
|
|
6103
|
+
const trace = _optionalChain([context, 'access', _140 => _140.opStackTraces, 'optionalAccess', _141 => _141.get, 'call', _142 => _142(opId)]);
|
|
6007
6104
|
if (trace) {
|
|
6008
6105
|
traces.add(trace);
|
|
6009
6106
|
}
|
|
@@ -6123,7 +6220,10 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6123
6220
|
flushNowOrSoon();
|
|
6124
6221
|
}
|
|
6125
6222
|
function dispatchOps(ops) {
|
|
6126
|
-
context.buffer
|
|
6223
|
+
const { storageOperations } = context.buffer;
|
|
6224
|
+
for (const op of ops) {
|
|
6225
|
+
storageOperations.push(op);
|
|
6226
|
+
}
|
|
6127
6227
|
flushNowOrSoon();
|
|
6128
6228
|
}
|
|
6129
6229
|
let _getStorage$ = null;
|
|
@@ -6132,7 +6232,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6132
6232
|
const unacknowledgedOps = new Map(context.unacknowledgedOps);
|
|
6133
6233
|
createOrUpdateRootFromMessage(message, doNotBatchUpdates);
|
|
6134
6234
|
applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
|
|
6135
|
-
_optionalChain([_resolveStoragePromise, 'optionalCall',
|
|
6235
|
+
_optionalChain([_resolveStoragePromise, 'optionalCall', _143 => _143()]);
|
|
6136
6236
|
notifyStorageStatus();
|
|
6137
6237
|
eventHub.storageDidLoad.notify();
|
|
6138
6238
|
}
|
|
@@ -6407,7 +6507,7 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
6407
6507
|
{
|
|
6408
6508
|
[kInternal]: {
|
|
6409
6509
|
get presenceBuffer() {
|
|
6410
|
-
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)));
|
|
6411
6511
|
},
|
|
6412
6512
|
// prettier-ignore
|
|
6413
6513
|
get undoStack() {
|
|
@@ -6556,7 +6656,7 @@ function makeClassicSubscribeFn(events) {
|
|
|
6556
6656
|
}
|
|
6557
6657
|
if (isLiveNode(first)) {
|
|
6558
6658
|
const node = first;
|
|
6559
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6659
|
+
if (_optionalChain([options, 'optionalAccess', _147 => _147.isDeep])) {
|
|
6560
6660
|
const storageCallback = second;
|
|
6561
6661
|
return subscribeToLiveStructureDeeply(node, storageCallback);
|
|
6562
6662
|
} else {
|
|
@@ -6917,7 +7017,7 @@ function upsertComment(thread, comment) {
|
|
|
6917
7017
|
);
|
|
6918
7018
|
if (existingComment === void 0) {
|
|
6919
7019
|
const updatedAt = new Date(
|
|
6920
|
-
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())
|
|
6921
7021
|
);
|
|
6922
7022
|
const updatedThread = {
|
|
6923
7023
|
...thread,
|
|
@@ -6937,8 +7037,8 @@ function upsertComment(thread, comment) {
|
|
|
6937
7037
|
...thread,
|
|
6938
7038
|
updatedAt: new Date(
|
|
6939
7039
|
Math.max(
|
|
6940
|
-
_optionalChain([thread, 'access',
|
|
6941
|
-
_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()
|
|
6942
7042
|
)
|
|
6943
7043
|
),
|
|
6944
7044
|
comments: updatedComments
|
|
@@ -7003,7 +7103,7 @@ function addReaction(thread, commentId, reaction) {
|
|
|
7003
7103
|
return {
|
|
7004
7104
|
...thread,
|
|
7005
7105
|
updatedAt: new Date(
|
|
7006
|
-
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)
|
|
7007
7107
|
),
|
|
7008
7108
|
comments: updatedComments
|
|
7009
7109
|
};
|
|
@@ -7036,7 +7136,7 @@ function removeReaction(thread, commentId, emoji, userId, removedAt) {
|
|
|
7036
7136
|
return {
|
|
7037
7137
|
...thread,
|
|
7038
7138
|
updatedAt: new Date(
|
|
7039
|
-
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)
|
|
7040
7140
|
),
|
|
7041
7141
|
comments: updatedComments
|
|
7042
7142
|
};
|
|
@@ -7151,12 +7251,12 @@ function createClient(options) {
|
|
|
7151
7251
|
createSocket: makeCreateSocketDelegateForRoom(
|
|
7152
7252
|
roomId,
|
|
7153
7253
|
baseUrl,
|
|
7154
|
-
_optionalChain([clientOptions, 'access',
|
|
7254
|
+
_optionalChain([clientOptions, 'access', _163 => _163.polyfills, 'optionalAccess', _164 => _164.WebSocket])
|
|
7155
7255
|
),
|
|
7156
7256
|
authenticate: makeAuthDelegateForRoom(roomId, authManager)
|
|
7157
7257
|
})),
|
|
7158
7258
|
enableDebugLogging: clientOptions.enableDebugLogging,
|
|
7159
|
-
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess',
|
|
7259
|
+
unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _165 => _165.unstable_batchedUpdates]),
|
|
7160
7260
|
baseUrl,
|
|
7161
7261
|
unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
|
|
7162
7262
|
unstable_streamData: !!clientOptions.unstable_streamData
|
|
@@ -7172,7 +7272,7 @@ function createClient(options) {
|
|
|
7172
7272
|
const shouldConnect = _nullishCoalesce(_nullishCoalesce(options2.autoConnect, () => ( options2.shouldInitiallyConnect)), () => ( true));
|
|
7173
7273
|
if (shouldConnect) {
|
|
7174
7274
|
if (typeof atob === "undefined") {
|
|
7175
|
-
if (_optionalChain([clientOptions, 'access',
|
|
7275
|
+
if (_optionalChain([clientOptions, 'access', _166 => _166.polyfills, 'optionalAccess', _167 => _167.atob]) === void 0) {
|
|
7176
7276
|
throw new Error(
|
|
7177
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"
|
|
7178
7278
|
);
|
|
@@ -7188,11 +7288,11 @@ function createClient(options) {
|
|
|
7188
7288
|
return room;
|
|
7189
7289
|
}
|
|
7190
7290
|
function getRoom(roomId) {
|
|
7191
|
-
const room = _optionalChain([roomsById, 'access',
|
|
7291
|
+
const room = _optionalChain([roomsById, 'access', _168 => _168.get, 'call', _169 => _169(roomId), 'optionalAccess', _170 => _170.room]);
|
|
7192
7292
|
return room ? room : null;
|
|
7193
7293
|
}
|
|
7194
7294
|
function forceLeave(roomId) {
|
|
7195
|
-
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()));
|
|
7196
7296
|
for (const unsub of unsubs) {
|
|
7197
7297
|
unsub();
|
|
7198
7298
|
}
|
|
@@ -7213,7 +7313,7 @@ function createClient(options) {
|
|
|
7213
7313
|
markInboxNotificationAsRead
|
|
7214
7314
|
} = createNotificationsApi({
|
|
7215
7315
|
baseUrl,
|
|
7216
|
-
fetcher: _optionalChain([clientOptions, 'access',
|
|
7316
|
+
fetcher: _optionalChain([clientOptions, 'access', _174 => _174.polyfills, 'optionalAccess', _175 => _175.fetch]) || /* istanbul ignore next */
|
|
7217
7317
|
fetch,
|
|
7218
7318
|
authManager,
|
|
7219
7319
|
currentUserIdStore
|
|
@@ -7227,7 +7327,7 @@ function createClient(options) {
|
|
|
7227
7327
|
const usersStore = createBatchStore(
|
|
7228
7328
|
async (batchedUserIds) => {
|
|
7229
7329
|
const userIds = batchedUserIds.flat();
|
|
7230
|
-
const users = await _optionalChain([resolveUsers, 'optionalCall',
|
|
7330
|
+
const users = await _optionalChain([resolveUsers, 'optionalCall', _176 => _176({ userIds })]);
|
|
7231
7331
|
warnIfNoResolveUsers();
|
|
7232
7332
|
return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
|
|
7233
7333
|
},
|
|
@@ -7241,7 +7341,7 @@ function createClient(options) {
|
|
|
7241
7341
|
const roomsInfoStore = createBatchStore(
|
|
7242
7342
|
async (batchedRoomIds) => {
|
|
7243
7343
|
const roomIds = batchedRoomIds.flat();
|
|
7244
|
-
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall',
|
|
7344
|
+
const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _177 => _177({ roomIds })]);
|
|
7245
7345
|
warnIfNoResolveRoomsInfo();
|
|
7246
7346
|
return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
|
|
7247
7347
|
},
|
|
@@ -7358,7 +7458,7 @@ var commentBodyElementsTypes = {
|
|
|
7358
7458
|
mention: "inline"
|
|
7359
7459
|
};
|
|
7360
7460
|
function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
7361
|
-
if (!body || !_optionalChain([body, 'optionalAccess',
|
|
7461
|
+
if (!body || !_optionalChain([body, 'optionalAccess', _178 => _178.content])) {
|
|
7362
7462
|
return;
|
|
7363
7463
|
}
|
|
7364
7464
|
const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
|
|
@@ -7368,13 +7468,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
|
|
|
7368
7468
|
for (const block of body.content) {
|
|
7369
7469
|
if (type === "all" || type === "block") {
|
|
7370
7470
|
if (guard(block)) {
|
|
7371
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7471
|
+
_optionalChain([visitor, 'optionalCall', _179 => _179(block)]);
|
|
7372
7472
|
}
|
|
7373
7473
|
}
|
|
7374
7474
|
if (type === "all" || type === "inline") {
|
|
7375
7475
|
for (const inline of block.children) {
|
|
7376
7476
|
if (guard(inline)) {
|
|
7377
|
-
_optionalChain([visitor, 'optionalCall',
|
|
7477
|
+
_optionalChain([visitor, 'optionalCall', _180 => _180(inline)]);
|
|
7378
7478
|
}
|
|
7379
7479
|
}
|
|
7380
7480
|
}
|
|
@@ -7399,7 +7499,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
|
|
|
7399
7499
|
userIds
|
|
7400
7500
|
});
|
|
7401
7501
|
for (const [index, userId] of userIds.entries()) {
|
|
7402
|
-
const user = _optionalChain([users, 'optionalAccess',
|
|
7502
|
+
const user = _optionalChain([users, 'optionalAccess', _181 => _181[index]]);
|
|
7403
7503
|
if (user) {
|
|
7404
7504
|
resolvedUsers.set(userId, user);
|
|
7405
7505
|
}
|
|
@@ -7522,7 +7622,7 @@ var stringifyCommentBodyPlainElements = {
|
|
|
7522
7622
|
text: ({ element }) => element.text,
|
|
7523
7623
|
link: ({ element }) => element.url,
|
|
7524
7624
|
mention: ({ element, user }) => {
|
|
7525
|
-
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7625
|
+
return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _182 => _182.name]), () => ( element.id))}`;
|
|
7526
7626
|
}
|
|
7527
7627
|
};
|
|
7528
7628
|
var stringifyCommentBodyHtmlElements = {
|
|
@@ -7552,7 +7652,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
7552
7652
|
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.url}</a>`;
|
|
7553
7653
|
},
|
|
7554
7654
|
mention: ({ element, user }) => {
|
|
7555
|
-
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>`;
|
|
7556
7656
|
}
|
|
7557
7657
|
};
|
|
7558
7658
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -7582,19 +7682,19 @@ var stringifyCommentBodyMarkdownElements = {
|
|
|
7582
7682
|
return markdown`[${element.url}](${href})`;
|
|
7583
7683
|
},
|
|
7584
7684
|
mention: ({ element, user }) => {
|
|
7585
|
-
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
7685
|
+
return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _184 => _184.name]), () => ( element.id))}`;
|
|
7586
7686
|
}
|
|
7587
7687
|
};
|
|
7588
7688
|
async function stringifyCommentBody(body, options) {
|
|
7589
|
-
const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
7590
|
-
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")));
|
|
7591
7691
|
const elements = {
|
|
7592
7692
|
...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
|
|
7593
|
-
..._optionalChain([options, 'optionalAccess',
|
|
7693
|
+
..._optionalChain([options, 'optionalAccess', _187 => _187.elements])
|
|
7594
7694
|
};
|
|
7595
7695
|
const resolvedUsers = await resolveUsersInCommentBody(
|
|
7596
7696
|
body,
|
|
7597
|
-
_optionalChain([options, 'optionalAccess',
|
|
7697
|
+
_optionalChain([options, 'optionalAccess', _188 => _188.resolveUsers])
|
|
7598
7698
|
);
|
|
7599
7699
|
const blocks = body.content.flatMap((block, blockIndex) => {
|
|
7600
7700
|
switch (block.type) {
|
|
@@ -7869,12 +7969,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7869
7969
|
}
|
|
7870
7970
|
const newState = Object.assign({}, state);
|
|
7871
7971
|
for (const key in update.updates) {
|
|
7872
|
-
if (_optionalChain([update, 'access',
|
|
7972
|
+
if (_optionalChain([update, 'access', _189 => _189.updates, 'access', _190 => _190[key], 'optionalAccess', _191 => _191.type]) === "update") {
|
|
7873
7973
|
const val = update.node.get(key);
|
|
7874
7974
|
if (val !== void 0) {
|
|
7875
7975
|
newState[key] = lsonToJson(val);
|
|
7876
7976
|
}
|
|
7877
|
-
} else if (_optionalChain([update, 'access',
|
|
7977
|
+
} else if (_optionalChain([update, 'access', _192 => _192.updates, 'access', _193 => _193[key], 'optionalAccess', _194 => _194.type]) === "delete") {
|
|
7878
7978
|
delete newState[key];
|
|
7879
7979
|
}
|
|
7880
7980
|
}
|
|
@@ -7935,12 +8035,12 @@ function legacy_patchImmutableNode(state, path, update) {
|
|
|
7935
8035
|
}
|
|
7936
8036
|
const newState = Object.assign({}, state);
|
|
7937
8037
|
for (const key in update.updates) {
|
|
7938
|
-
if (_optionalChain([update, 'access',
|
|
8038
|
+
if (_optionalChain([update, 'access', _195 => _195.updates, 'access', _196 => _196[key], 'optionalAccess', _197 => _197.type]) === "update") {
|
|
7939
8039
|
const value = update.node.get(key);
|
|
7940
8040
|
if (value !== void 0) {
|
|
7941
8041
|
newState[key] = lsonToJson(value);
|
|
7942
8042
|
}
|
|
7943
|
-
} else if (_optionalChain([update, 'access',
|
|
8043
|
+
} else if (_optionalChain([update, 'access', _198 => _198.updates, 'access', _199 => _199[key], 'optionalAccess', _200 => _200.type]) === "delete") {
|
|
7944
8044
|
delete newState[key];
|
|
7945
8045
|
}
|
|
7946
8046
|
}
|
|
@@ -8159,5 +8259,6 @@ detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
|
8159
8259
|
|
|
8160
8260
|
|
|
8161
8261
|
|
|
8162
|
-
|
|
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;
|
|
8163
8264
|
//# sourceMappingURL=index.js.map
|