@liveblocks/client
Advanced tools
Comparing version 0.12.0-beta.10 to 0.12.0-beta.11
@@ -16,2 +16,3 @@ import { Op, SerializedCrdtWithId, SerializedList } from "./live"; | ||
generateId(): string; | ||
generateOpId(): string; | ||
} | ||
@@ -18,0 +19,0 @@ declare abstract class AbstractCrdt { |
@@ -13,3 +13,3 @@ "use strict"; | ||
}; | ||
var _Doc_instances, _Doc_clock, _Doc_items, _Doc_root, _Doc_actor, _Doc_dispatch, _Doc_applyCreateRegister, _Doc_applyDeleteRecordKey, _Doc_applyUpdateRecord, _Doc_applyCreateMap, _Doc_applyCreateList, _Doc_applyCreateObject, _Doc_applyDeleteRecord, _Doc_applySetParentKey, _AbstractCrdt_listeners, _AbstractCrdt_deepListeners, _AbstractCrdt_parent, _AbstractCrdt_doc, _AbstractCrdt_id, _LiveObject_map, _LiveMap_map, _LiveRegister_data, _LiveList_items, _LiveListIterator_innerIterator; | ||
var _Doc_instances, _Doc_clock, _Doc_opClock, _Doc_items, _Doc_root, _Doc_actor, _Doc_dispatch, _Doc_applyCreateRegister, _Doc_applyDeleteRecordKey, _Doc_applyUpdateRecord, _Doc_applyCreateMap, _Doc_applyCreateList, _Doc_applyCreateObject, _Doc_applyDeleteRecord, _Doc_applySetParentKey, _AbstractCrdt_listeners, _AbstractCrdt_deepListeners, _AbstractCrdt_parent, _AbstractCrdt_doc, _AbstractCrdt_id, _LiveObject_map, _LiveObject_propToLastUpdate, _LiveMap_map, _LiveRegister_data, _LiveList_items, _LiveListIterator_innerIterator; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -25,2 +25,3 @@ exports.LiveList = exports.LiveMap = exports.LiveObject = exports.Doc = void 0; | ||
_Doc_clock.set(this, 0); | ||
_Doc_opClock.set(this, 0); | ||
_Doc_items.set(this, new Map()); | ||
@@ -127,5 +128,9 @@ _Doc_root.set(this, void 0); | ||
} | ||
generateOpId() { | ||
var _a, _b; | ||
return `${__classPrivateFieldGet(this, _Doc_actor, "f")}:${__classPrivateFieldSet(this, _Doc_opClock, (_b = __classPrivateFieldGet(this, _Doc_opClock, "f"), _a = _b++, _b), "f"), _a}`; | ||
} | ||
} | ||
exports.Doc = Doc; | ||
_Doc_clock = new WeakMap(), _Doc_items = new WeakMap(), _Doc_root = new WeakMap(), _Doc_actor = new WeakMap(), _Doc_dispatch = new WeakMap(), _Doc_instances = new WeakSet(), _Doc_applyCreateRegister = function _Doc_applyCreateRegister(op) { | ||
_Doc_clock = new WeakMap(), _Doc_opClock = new WeakMap(), _Doc_items = new WeakMap(), _Doc_root = new WeakMap(), _Doc_actor = new WeakMap(), _Doc_dispatch = new WeakMap(), _Doc_instances = new WeakSet(), _Doc_applyCreateRegister = function _Doc_applyCreateRegister(op) { | ||
if (__classPrivateFieldGet(this, _Doc_items, "f").has(op.id)) { | ||
@@ -296,2 +301,3 @@ return; | ||
_LiveObject_map.set(this, void 0); | ||
_LiveObject_propToLastUpdate.set(this, new Map()); | ||
for (const key in object) { | ||
@@ -413,2 +419,9 @@ const value = object[key]; | ||
for (const key in op.data) { | ||
const lastOpId = __classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").get(key); | ||
if (lastOpId === op.opId) { | ||
__classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").delete(key); | ||
} | ||
else if (lastOpId != null) { | ||
continue; | ||
} | ||
const oldValue = __classPrivateFieldGet(this, _LiveObject_map, "f").get(key); | ||
@@ -446,3 +459,5 @@ if (isCrdt(oldValue)) { | ||
const ops = []; | ||
const opId = this._doc.generateOpId(); | ||
const updateOp = { | ||
opId, | ||
id: this._id, | ||
@@ -454,2 +469,3 @@ type: live_1.OpType.UpdateObject, | ||
for (const key in overrides) { | ||
__classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").set(key, opId); | ||
const oldValue = __classPrivateFieldGet(this, _LiveObject_map, "f").get(key); | ||
@@ -489,3 +505,3 @@ if (oldValue instanceof LiveObject) { | ||
exports.LiveObject = LiveObject; | ||
_LiveObject_map = new WeakMap(); | ||
_LiveObject_map = new WeakMap(), _LiveObject_propToLastUpdate = new WeakMap(); | ||
class LiveMap extends AbstractCrdt { | ||
@@ -492,0 +508,0 @@ constructor(entries) { |
@@ -117,2 +117,3 @@ import { Presence } from "./types"; | ||
export declare type UpdateObjectOp = { | ||
opId: string; | ||
id: string; | ||
@@ -119,0 +120,0 @@ type: OpType.UpdateObject; |
@@ -16,2 +16,3 @@ import { Op, SerializedCrdtWithId, SerializedList } from "./live"; | ||
generateId(): string; | ||
generateOpId(): string; | ||
} | ||
@@ -18,0 +19,0 @@ declare abstract class AbstractCrdt { |
@@ -12,3 +12,3 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
}; | ||
var _Doc_instances, _Doc_clock, _Doc_items, _Doc_root, _Doc_actor, _Doc_dispatch, _Doc_applyCreateRegister, _Doc_applyDeleteRecordKey, _Doc_applyUpdateRecord, _Doc_applyCreateMap, _Doc_applyCreateList, _Doc_applyCreateObject, _Doc_applyDeleteRecord, _Doc_applySetParentKey, _AbstractCrdt_listeners, _AbstractCrdt_deepListeners, _AbstractCrdt_parent, _AbstractCrdt_doc, _AbstractCrdt_id, _LiveObject_map, _LiveMap_map, _LiveRegister_data, _LiveList_items, _LiveListIterator_innerIterator; | ||
var _Doc_instances, _Doc_clock, _Doc_opClock, _Doc_items, _Doc_root, _Doc_actor, _Doc_dispatch, _Doc_applyCreateRegister, _Doc_applyDeleteRecordKey, _Doc_applyUpdateRecord, _Doc_applyCreateMap, _Doc_applyCreateList, _Doc_applyCreateObject, _Doc_applyDeleteRecord, _Doc_applySetParentKey, _AbstractCrdt_listeners, _AbstractCrdt_deepListeners, _AbstractCrdt_parent, _AbstractCrdt_doc, _AbstractCrdt_id, _LiveObject_map, _LiveObject_propToLastUpdate, _LiveMap_map, _LiveRegister_data, _LiveList_items, _LiveListIterator_innerIterator; | ||
import { remove } from "./utils"; | ||
@@ -22,2 +22,3 @@ import { CrdtType, OpType, } from "./live"; | ||
_Doc_clock.set(this, 0); | ||
_Doc_opClock.set(this, 0); | ||
_Doc_items.set(this, new Map()); | ||
@@ -124,4 +125,8 @@ _Doc_root.set(this, void 0); | ||
} | ||
generateOpId() { | ||
var _a, _b; | ||
return `${__classPrivateFieldGet(this, _Doc_actor, "f")}:${__classPrivateFieldSet(this, _Doc_opClock, (_b = __classPrivateFieldGet(this, _Doc_opClock, "f"), _a = _b++, _b), "f"), _a}`; | ||
} | ||
} | ||
_Doc_clock = new WeakMap(), _Doc_items = new WeakMap(), _Doc_root = new WeakMap(), _Doc_actor = new WeakMap(), _Doc_dispatch = new WeakMap(), _Doc_instances = new WeakSet(), _Doc_applyCreateRegister = function _Doc_applyCreateRegister(op) { | ||
_Doc_clock = new WeakMap(), _Doc_opClock = new WeakMap(), _Doc_items = new WeakMap(), _Doc_root = new WeakMap(), _Doc_actor = new WeakMap(), _Doc_dispatch = new WeakMap(), _Doc_instances = new WeakSet(), _Doc_applyCreateRegister = function _Doc_applyCreateRegister(op) { | ||
if (__classPrivateFieldGet(this, _Doc_items, "f").has(op.id)) { | ||
@@ -292,2 +297,3 @@ return; | ||
_LiveObject_map.set(this, void 0); | ||
_LiveObject_propToLastUpdate.set(this, new Map()); | ||
for (const key in object) { | ||
@@ -409,2 +415,9 @@ const value = object[key]; | ||
for (const key in op.data) { | ||
const lastOpId = __classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").get(key); | ||
if (lastOpId === op.opId) { | ||
__classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").delete(key); | ||
} | ||
else if (lastOpId != null) { | ||
continue; | ||
} | ||
const oldValue = __classPrivateFieldGet(this, _LiveObject_map, "f").get(key); | ||
@@ -442,3 +455,5 @@ if (isCrdt(oldValue)) { | ||
const ops = []; | ||
const opId = this._doc.generateOpId(); | ||
const updateOp = { | ||
opId, | ||
id: this._id, | ||
@@ -450,2 +465,3 @@ type: OpType.UpdateObject, | ||
for (const key in overrides) { | ||
__classPrivateFieldGet(this, _LiveObject_propToLastUpdate, "f").set(key, opId); | ||
const oldValue = __classPrivateFieldGet(this, _LiveObject_map, "f").get(key); | ||
@@ -484,3 +500,3 @@ if (oldValue instanceof LiveObject) { | ||
} | ||
_LiveObject_map = new WeakMap(); | ||
_LiveObject_map = new WeakMap(), _LiveObject_propToLastUpdate = new WeakMap(); | ||
export class LiveMap extends AbstractCrdt { | ||
@@ -487,0 +503,0 @@ constructor(entries) { |
@@ -117,2 +117,3 @@ import { Presence } from "./types"; | ||
export declare type UpdateObjectOp = { | ||
opId: string; | ||
id: string; | ||
@@ -119,0 +120,0 @@ type: OpType.UpdateObject; |
{ | ||
"name": "@liveblocks/client", | ||
"version": "0.12.0-beta.10", | ||
"version": "0.12.0-beta.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
204172
5683