@liveblocks/core 3.1.0-alpha1 → 3.1.1-prismic1
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 +40 -4
- 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 +37 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;var __defProp = Object.defineProperty;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;var __defProp = Object.defineProperty;
|
|
2
2
|
var __export = (target, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -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-prismic1";
|
|
10
10
|
var PKG_FORMAT = "cjs";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -6768,9 +6768,20 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
|
|
|
6768
6768
|
};
|
|
6769
6769
|
|
|
6770
6770
|
// src/crdts/LiveObject.ts
|
|
6771
|
-
var
|
|
6771
|
+
var MAX_LIVE_OBJECT_SIZE = 128 * 1024;
|
|
6772
|
+
var LiveObject = (_class2 = 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 __initStatic() {this.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
|
_optionalChain([this, 'access', _168 => _168._pool, 'optionalAccess', _169 => _169.assertStorageIsWritable, 'call', _170 => _170()]);
|
|
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];
|
|
@@ -7276,7 +7312,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
|
|
|
7276
7312
|
)
|
|
7277
7313
|
);
|
|
7278
7314
|
}
|
|
7279
|
-
};
|
|
7315
|
+
}, _class2.__initStatic(), _class2);
|
|
7280
7316
|
|
|
7281
7317
|
// src/crdts/liveblocks-helpers.ts
|
|
7282
7318
|
function creationOpToLiveNode(op) {
|