@liveblocks/core 2.18.2 → 2.18.3
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 +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +41 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
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 = "2.18.
|
|
9
|
+
var PKG_VERSION = "2.18.3";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -731,9 +731,18 @@ function replacer(_key, value) {
|
|
|
731
731
|
return sorted;
|
|
732
732
|
}, {}) : value;
|
|
733
733
|
}
|
|
734
|
-
function
|
|
734
|
+
function stableStringify(value) {
|
|
735
735
|
return JSON.stringify(value, replacer);
|
|
736
736
|
}
|
|
737
|
+
function stringifyOrLog(value) {
|
|
738
|
+
try {
|
|
739
|
+
return JSON.stringify(value);
|
|
740
|
+
} catch (err) {
|
|
741
|
+
console.error(`Could not stringify: ${err.message}`);
|
|
742
|
+
console.error(value);
|
|
743
|
+
throw err;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
737
746
|
|
|
738
747
|
// src/lib/batch.ts
|
|
739
748
|
var DEFAULT_SIZE = 50;
|
|
@@ -810,7 +819,7 @@ var Batch = class {
|
|
|
810
819
|
}
|
|
811
820
|
get(input) {
|
|
812
821
|
const existingCall = this.#queue.find(
|
|
813
|
-
(call2) =>
|
|
822
|
+
(call2) => stableStringify(call2.input) === stableStringify(input)
|
|
814
823
|
);
|
|
815
824
|
if (existingCall) {
|
|
816
825
|
return existingCall.promise;
|
|
@@ -829,7 +838,7 @@ var Batch = class {
|
|
|
829
838
|
function createBatchStore(batch2) {
|
|
830
839
|
const signal = new MutableSignal(/* @__PURE__ */ new Map());
|
|
831
840
|
function getCacheKey(args) {
|
|
832
|
-
return
|
|
841
|
+
return stableStringify(args);
|
|
833
842
|
}
|
|
834
843
|
function update(cacheKey, state) {
|
|
835
844
|
signal.mutate((cache) => {
|
|
@@ -1938,7 +1947,7 @@ var HttpClient = class {
|
|
|
1938
1947
|
async rawPost(endpoint, authValue, body) {
|
|
1939
1948
|
return await this.#rawFetch(endpoint, authValue, {
|
|
1940
1949
|
method: "POST",
|
|
1941
|
-
body:
|
|
1950
|
+
body: stringifyOrLog(body)
|
|
1942
1951
|
});
|
|
1943
1952
|
}
|
|
1944
1953
|
/**
|
|
@@ -1967,7 +1976,7 @@ var HttpClient = class {
|
|
|
1967
1976
|
{
|
|
1968
1977
|
...options,
|
|
1969
1978
|
method: "POST",
|
|
1970
|
-
body:
|
|
1979
|
+
body: stringifyOrLog(body)
|
|
1971
1980
|
},
|
|
1972
1981
|
params
|
|
1973
1982
|
);
|
|
@@ -3333,7 +3342,7 @@ async function fetchAuthEndpoint(fetch, endpoint, body) {
|
|
|
3333
3342
|
headers: {
|
|
3334
3343
|
"Content-Type": "application/json"
|
|
3335
3344
|
},
|
|
3336
|
-
body:
|
|
3345
|
+
body: stringifyOrLog(body)
|
|
3337
3346
|
});
|
|
3338
3347
|
if (!res.ok) {
|
|
3339
3348
|
const reason = `${(await res.text()).trim() || "reason not provided in auth response"} (${res.status} returned by POST ${endpoint})`;
|
|
@@ -3355,7 +3364,7 @@ async function fetchAuthEndpoint(fetch, endpoint, body) {
|
|
|
3355
3364
|
}
|
|
3356
3365
|
if (!isPlainObject(data) || typeof data.token !== "string") {
|
|
3357
3366
|
throw new Error(
|
|
3358
|
-
`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${endpoint}", but got ${
|
|
3367
|
+
`Expected a JSON response of the form \`{ token: "..." }\` when doing a POST request on "${endpoint}", but got ${stringifyOrLog(
|
|
3359
3368
|
data
|
|
3360
3369
|
)}`
|
|
3361
3370
|
);
|
|
@@ -5978,7 +5987,7 @@ function getTreesDiffOperations(currentItems, newItems) {
|
|
|
5978
5987
|
const currentCrdt = currentItems.get(id);
|
|
5979
5988
|
if (currentCrdt) {
|
|
5980
5989
|
if (crdt.type === 0 /* OBJECT */) {
|
|
5981
|
-
if (currentCrdt.type !== 0 /* OBJECT */ ||
|
|
5990
|
+
if (currentCrdt.type !== 0 /* OBJECT */ || stringifyOrLog(crdt.data) !== stringifyOrLog(currentCrdt.data)) {
|
|
5982
5991
|
ops.push({
|
|
5983
5992
|
type: 3 /* UPDATE_OBJECT */,
|
|
5984
5993
|
id,
|
|
@@ -6714,7 +6723,7 @@ function createRoom(options, config) {
|
|
|
6714
6723
|
const secondHalf = ops.slice(mid);
|
|
6715
6724
|
for (const halfOps of [firstHalf, secondHalf]) {
|
|
6716
6725
|
const half = { ops: halfOps, ...rest };
|
|
6717
|
-
const text =
|
|
6726
|
+
const text = stringifyOrLog([half]);
|
|
6718
6727
|
if (!isTooBigForWebSocket(text)) {
|
|
6719
6728
|
yield text;
|
|
6720
6729
|
} else {
|
|
@@ -6737,7 +6746,7 @@ function createRoom(options, config) {
|
|
|
6737
6746
|
const firstHalf = messages.slice(0, mid);
|
|
6738
6747
|
const secondHalf = messages.slice(mid);
|
|
6739
6748
|
for (const half of [firstHalf, secondHalf]) {
|
|
6740
|
-
const text =
|
|
6749
|
+
const text = stringifyOrLog(half);
|
|
6741
6750
|
if (!isTooBigForWebSocket(text)) {
|
|
6742
6751
|
yield text;
|
|
6743
6752
|
} else {
|
|
@@ -6753,7 +6762,7 @@ function createRoom(options, config) {
|
|
|
6753
6762
|
}
|
|
6754
6763
|
function sendMessages(messages) {
|
|
6755
6764
|
const strategy = config.largeMessageStrategy ?? "default";
|
|
6756
|
-
const text =
|
|
6765
|
+
const text = stringifyOrLog(messages);
|
|
6757
6766
|
if (!isTooBigForWebSocket(text)) {
|
|
6758
6767
|
return managedSocket.send(text);
|
|
6759
6768
|
}
|
|
@@ -8484,7 +8493,7 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8484
8493
|
text: ({ element }) => {
|
|
8485
8494
|
let children = element.text;
|
|
8486
8495
|
if (!children) {
|
|
8487
|
-
return children
|
|
8496
|
+
return html`${children}`;
|
|
8488
8497
|
}
|
|
8489
8498
|
if (element.bold) {
|
|
8490
8499
|
children = html`<strong>${children}</strong>`;
|
|
@@ -8498,13 +8507,13 @@ var stringifyCommentBodyHtmlElements = {
|
|
|
8498
8507
|
if (element.code) {
|
|
8499
8508
|
children = html`<code>${children}</code>`;
|
|
8500
8509
|
}
|
|
8501
|
-
return children
|
|
8510
|
+
return html`${children}`;
|
|
8502
8511
|
},
|
|
8503
8512
|
link: ({ element, href }) => {
|
|
8504
|
-
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text
|
|
8513
|
+
return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
|
|
8505
8514
|
},
|
|
8506
8515
|
mention: ({ element, user }) => {
|
|
8507
|
-
return html`<span data-mention>@${user?.name
|
|
8516
|
+
return html`<span data-mention>@${user?.name ? html`${user?.name}` : element.id}</span>`;
|
|
8508
8517
|
}
|
|
8509
8518
|
};
|
|
8510
8519
|
var stringifyCommentBodyMarkdownElements = {
|
|
@@ -9280,7 +9289,7 @@ export {
|
|
|
9280
9289
|
raise,
|
|
9281
9290
|
resolveUsersInCommentBody,
|
|
9282
9291
|
shallow,
|
|
9283
|
-
|
|
9292
|
+
stableStringify,
|
|
9284
9293
|
stringifyCommentBody,
|
|
9285
9294
|
throwUsageError,
|
|
9286
9295
|
toAbsoluteUrl,
|