@liveblocks/core 3.1.0 → 3.1.1
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 +134 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +39 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -630,6 +630,16 @@ type LiveObjectUpdates<TData extends LsonObject> = {
|
|
|
630
630
|
*/
|
|
631
631
|
declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
632
632
|
#private;
|
|
633
|
+
/**
|
|
634
|
+
* Enable or disable detection of too large LiveObjects.
|
|
635
|
+
* When enabled, throws an error if LiveObject static data exceeds 128KB, which
|
|
636
|
+
* is the maximum value the server will be able to accept.
|
|
637
|
+
* By default, this behavior is disabled to avoid the runtime performance
|
|
638
|
+
* overhead on every LiveObject.set() or LiveObject.update() call.
|
|
639
|
+
*
|
|
640
|
+
* @experimental
|
|
641
|
+
*/
|
|
642
|
+
static detectLargeObjects: boolean;
|
|
633
643
|
/** @private Do not use this API directly */
|
|
634
644
|
static _fromItems<O extends LsonObject>(items: IdTuple<SerializedCrdt>[], pool: ManagedPool): LiveObject<O>;
|
|
635
645
|
constructor(obj?: O);
|
package/dist/index.d.ts
CHANGED
|
@@ -630,6 +630,16 @@ type LiveObjectUpdates<TData extends LsonObject> = {
|
|
|
630
630
|
*/
|
|
631
631
|
declare class LiveObject<O extends LsonObject> extends AbstractCrdt {
|
|
632
632
|
#private;
|
|
633
|
+
/**
|
|
634
|
+
* Enable or disable detection of too large LiveObjects.
|
|
635
|
+
* When enabled, throws an error if LiveObject static data exceeds 128KB, which
|
|
636
|
+
* is the maximum value the server will be able to accept.
|
|
637
|
+
* By default, this behavior is disabled to avoid the runtime performance
|
|
638
|
+
* overhead on every LiveObject.set() or LiveObject.update() call.
|
|
639
|
+
*
|
|
640
|
+
* @experimental
|
|
641
|
+
*/
|
|
642
|
+
static detectLargeObjects: boolean;
|
|
633
643
|
/** @private Do not use this API directly */
|
|
634
644
|
static _fromItems<O extends LsonObject>(items: IdTuple<SerializedCrdt>[], pool: ManagedPool): LiveObject<O>;
|
|
635
645
|
constructor(obj?: O);
|
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 = "3.1.
|
|
9
|
+
var PKG_VERSION = "3.1.1";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -3794,8 +3794,8 @@ function createStore_forTools() {
|
|
|
3794
3794
|
return DerivedSignal.from(() => {
|
|
3795
3795
|
return (
|
|
3796
3796
|
// A tool that's registered and scoped to a specific chat ID...
|
|
3797
|
-
(chatId !== void 0 ? toolsByChatId\u03A3.
|
|
3798
|
-
toolsByChatId\u03A3.getOrCreate(kWILDCARD).
|
|
3797
|
+
(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0)?.get() ?? // ...or a globally registered tool
|
|
3798
|
+
toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()
|
|
3799
3799
|
);
|
|
3800
3800
|
});
|
|
3801
3801
|
});
|
|
@@ -6768,9 +6768,20 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6768
6768
|
};
|
|
6769
6769
|
|
|
6770
6770
|
// src/crdts/LiveObject.ts
|
|
6771
|
+
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
6771
6772
|
var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
6772
6773
|
#map;
|
|
6773
6774
|
#propToLastUpdate;
|
|
6775
|
+
/**
|
|
6776
|
+
* Enable or disable detection of too large LiveObjects.
|
|
6777
|
+
* When enabled, throws an error if LiveObject static data exceeds 128KB, which
|
|
6778
|
+
* is the maximum value the server will be able to accept.
|
|
6779
|
+
* By default, this behavior is disabled to avoid the runtime performance
|
|
6780
|
+
* overhead on every LiveObject.set() or LiveObject.update() call.
|
|
6781
|
+
*
|
|
6782
|
+
* @experimental
|
|
6783
|
+
*/
|
|
6784
|
+
static detectLargeObjects = false;
|
|
6774
6785
|
static #buildRootAndParentToChildren(items) {
|
|
6775
6786
|
const parentToChildren = /* @__PURE__ */ new Map();
|
|
6776
6787
|
let root = null;
|
|
@@ -7159,6 +7170,31 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7159
7170
|
*/
|
|
7160
7171
|
update(patch) {
|
|
7161
7172
|
this._pool?.assertStorageIsWritable();
|
|
7173
|
+
if (_LiveObject.detectLargeObjects) {
|
|
7174
|
+
const data = {};
|
|
7175
|
+
for (const [key, value] of this.#map) {
|
|
7176
|
+
if (!isLiveNode(value)) {
|
|
7177
|
+
data[key] = value;
|
|
7178
|
+
}
|
|
7179
|
+
}
|
|
7180
|
+
for (const key of Object.keys(patch)) {
|
|
7181
|
+
const value = patch[key];
|
|
7182
|
+
if (value === void 0) continue;
|
|
7183
|
+
if (!isLiveNode(value)) {
|
|
7184
|
+
data[key] = value;
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
7187
|
+
const jsonString = JSON.stringify(data);
|
|
7188
|
+
const upperBoundSize = jsonString.length * 4;
|
|
7189
|
+
if (upperBoundSize > MAX_LIVE_OBJECT_SIZE) {
|
|
7190
|
+
const preciseSize = new TextEncoder().encode(jsonString).length;
|
|
7191
|
+
if (preciseSize > MAX_LIVE_OBJECT_SIZE) {
|
|
7192
|
+
throw new Error(
|
|
7193
|
+
`LiveObject size exceeded limit: ${preciseSize} bytes > ${MAX_LIVE_OBJECT_SIZE} bytes. See https://liveblocks.io/docs/platform/limits#Liveblocks-Storage-limits`
|
|
7194
|
+
);
|
|
7195
|
+
}
|
|
7196
|
+
}
|
|
7197
|
+
}
|
|
7162
7198
|
if (this._pool === void 0 || this._id === void 0) {
|
|
7163
7199
|
for (const key in patch) {
|
|
7164
7200
|
const newValue = patch[key];
|