collaborative-editor
Version:
JSON CRDT str node bindings to any generic plain text editor.
34 lines • 1.18 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReplicatedStr = void 0;
const ID = { sid: 0, time: 0 };
class ReplicatedStr {
constructor(facade) {
var _a, _b;
this.facade = facade;
this.view = facade.view;
this.ins = facade.ins;
this.del = facade.del;
this.findId = (_a = facade.findId) !== null && _a !== void 0 ? _a : (() => ID);
this.findPos = (_b = facade.findPos) !== null && _b !== void 0 ? _b : (() => -1);
this.api = {
onChange: {
listen: this.facade.subscribe,
},
transaction: (callback) => {
if (facade.transaction)
facade.transaction(callback);
else
callback();
},
model: {
get tick() {
var _a, _b;
return (_b = (_a = facade.tick) === null || _a === void 0 ? void 0 : _a.call(facade)) !== null && _b !== void 0 ? _b : 0;
},
},
};
}
}
exports.ReplicatedStr = ReplicatedStr;
//# sourceMappingURL=ReplicatedStr.js.map
;