@liveblocks/yjs
Advanced tools
Comparing version 2.16.0 to 2.16.1-ai
@@ -70,2 +70,3 @@ import { JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata, Room, User } from '@liveblocks/client'; | ||
private indexeddbProvider; | ||
private isPaused; | ||
private unsubscribers; | ||
@@ -77,2 +78,3 @@ awareness: Awareness<P, S, U, E, M>; | ||
constructor(room: Room<P, S, U, E, M>, doc: Y.Doc, options?: ProviderOptions | undefined); | ||
private setupOfflineSupport; | ||
private handleSubdocs; | ||
@@ -87,2 +89,4 @@ private getUniqueUpdateId; | ||
get synced(): boolean; | ||
pause(): Promise<void>; | ||
unpause(): void; | ||
getStatus(): YjsSyncStatus; | ||
@@ -89,0 +93,0 @@ destroy(): void; |
@@ -295,3 +295,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } 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 _class3;// src/index.ts | ||
var PKG_NAME = "@liveblocks/yjs"; | ||
var PKG_VERSION = "2.16.0"; | ||
var PKG_VERSION = "2.16.1-ai"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -306,9 +306,10 @@ | ||
__init10() {this.indexeddbProvider = null} | ||
__init11() {this.unsubscribers = []} | ||
__init11() {this.isPaused = false} | ||
__init12() {this.unsubscribers = []} | ||
__init12() {this.subdocHandlers = /* @__PURE__ */ new Map()} | ||
__init13() {this.pending = []} | ||
__init13() {this.subdocHandlers = /* @__PURE__ */ new Map()} | ||
__init14() {this.pending = []} | ||
constructor(room, doc, options = {}) { | ||
super();_class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);_class3.prototype.__init14.call(this);_class3.prototype.__init15.call(this);_class3.prototype.__init16.call(this);_class3.prototype.__init17.call(this);_class3.prototype.__init18.call(this);_class3.prototype.__init19.call(this);_class3.prototype.__init20.call(this);; | ||
super();_class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);_class3.prototype.__init12.call(this);_class3.prototype.__init13.call(this);_class3.prototype.__init14.call(this);_class3.prototype.__init15.call(this);_class3.prototype.__init16.call(this);_class3.prototype.__init17.call(this);_class3.prototype.__init18.call(this);_class3.prototype.__init19.call(this);_class3.prototype.__init20.call(this);_class3.prototype.__init21.call(this);_class3.prototype.__init22.call(this);; | ||
this.rootDoc = doc; | ||
@@ -343,3 +344,3 @@ this.room = room; | ||
const { stateVector, update: updateStr, guid, v2 } = message; | ||
const canWrite = _nullishCoalesce(_optionalChain([this, 'access', _31 => _31.room, 'access', _32 => _32.getSelf, 'call', _33 => _33(), 'optionalAccess', _34 => _34.canWrite]), () => ( true)); | ||
const canWrite = _nullishCoalesce(_optionalChain([this, 'access', _34 => _34.room, 'access', _35 => _35.getSelf, 'call', _36 => _36(), 'optionalAccess', _37 => _37.canWrite]), () => ( true)); | ||
const update = _jsbase64.Base64.toUint8Array(updateStr); | ||
@@ -357,3 +358,3 @@ let foundPendingUpdate = false; | ||
if (guid !== void 0) { | ||
_optionalChain([this, 'access', _35 => _35.subdocHandlers, 'access', _36 => _36.get, 'call', _37 => _37(guid), 'optionalAccess', _38 => _38.handleServerUpdate, 'call', _39 => _39({ | ||
_optionalChain([this, 'access', _38 => _38.subdocHandlers, 'access', _39 => _39.get, 'call', _40 => _40(guid), 'optionalAccess', _41 => _41.handleServerUpdate, 'call', _42 => _42({ | ||
update, | ||
@@ -377,10 +378,3 @@ stateVector, | ||
if (options.offlineSupport_experimental) { | ||
this.indexeddbProvider = new (0, _yindexeddb.IndexeddbPersistence)(room.id, this.rootDoc); | ||
const onIndexedDbSync = () => { | ||
this.rootDocHandler.synced = true; | ||
}; | ||
this.indexeddbProvider.on("synced", onIndexedDbSync); | ||
this.unsubscribers.push(() => { | ||
_optionalChain([this, 'access', _40 => _40.indexeddbProvider, 'optionalAccess', _41 => _41.off, 'call', _42 => _42("synced", onIndexedDbSync)]); | ||
}); | ||
this.setupOfflineSupport(); | ||
} | ||
@@ -399,3 +393,16 @@ this.rootDocHandler.on("synced", () => { | ||
} | ||
__init14() {this.handleSubdocs = ({ | ||
__init15() {this.setupOfflineSupport = () => { | ||
this.indexeddbProvider = new (0, _yindexeddb.IndexeddbPersistence)( | ||
this.room.id, | ||
this.rootDoc | ||
); | ||
const onIndexedDbSync = () => { | ||
this.rootDocHandler.synced = true; | ||
}; | ||
this.indexeddbProvider.on("synced", onIndexedDbSync); | ||
this.unsubscribers.push(() => { | ||
_optionalChain([this, 'access', _43 => _43.indexeddbProvider, 'optionalAccess', _44 => _44.off, 'call', _45 => _45("synced", onIndexedDbSync)]); | ||
}); | ||
}} | ||
__init16() {this.handleSubdocs = ({ | ||
loaded, | ||
@@ -415,3 +422,3 @@ removed, | ||
if (this.subdocHandlers.has(subdoc.guid)) { | ||
_optionalChain([this, 'access', _43 => _43.subdocHandlers, 'access', _44 => _44.get, 'call', _45 => _45(subdoc.guid), 'optionalAccess', _46 => _46.destroy, 'call', _47 => _47()]); | ||
_optionalChain([this, 'access', _46 => _46.subdocHandlers, 'access', _47 => _47.get, 'call', _48 => _48(subdoc.guid), 'optionalAccess', _49 => _49.destroy, 'call', _50 => _50()]); | ||
this.subdocHandlers.delete(subdoc.guid); | ||
@@ -421,9 +428,9 @@ } | ||
}} | ||
__init15() {this.getUniqueUpdateId = (update) => { | ||
__init17() {this.getUniqueUpdateId = (update) => { | ||
const clock = _nullishCoalesce(Y2.parseUpdateMeta(update).to.get(this.rootDoc.clientID), () => ( "-1")); | ||
return this.rootDoc.clientID + ":" + clock; | ||
}} | ||
__init16() {this.updateDoc = (update, guid) => { | ||
const canWrite = _nullishCoalesce(_optionalChain([this, 'access', _48 => _48.room, 'access', _49 => _49.getSelf, 'call', _50 => _50(), 'optionalAccess', _51 => _51.canWrite]), () => ( true)); | ||
if (canWrite) { | ||
__init18() {this.updateDoc = (update, guid) => { | ||
const canWrite = _nullishCoalesce(_optionalChain([this, 'access', _51 => _51.room, 'access', _52 => _52.getSelf, 'call', _53 => _53(), 'optionalAccess', _54 => _54.canWrite]), () => ( true)); | ||
if (canWrite && !this.isPaused) { | ||
const updateId = this.getUniqueUpdateId(update); | ||
@@ -439,8 +446,8 @@ this.pending.push(updateId); | ||
}} | ||
__init17() {this.fetchDoc = (vector, guid) => { | ||
__init19() {this.fetchDoc = (vector, guid) => { | ||
this.room.fetchYDoc(vector, guid, this.useV2Encoding); | ||
}} | ||
__init18() {this.createSubdocHandler = (subdoc) => { | ||
__init20() {this.createSubdocHandler = (subdoc) => { | ||
if (this.subdocHandlers.has(subdoc.guid)) { | ||
_optionalChain([this, 'access', _52 => _52.subdocHandlers, 'access', _53 => _53.get, 'call', _54 => _54(subdoc.guid), 'optionalAccess', _55 => _55.syncDoc, 'call', _56 => _56()]); | ||
_optionalChain([this, 'access', _55 => _55.subdocHandlers, 'access', _56 => _56.get, 'call', _57 => _57(subdoc.guid), 'optionalAccess', _58 => _58.syncDoc, 'call', _59 => _59()]); | ||
return; | ||
@@ -458,3 +465,3 @@ } | ||
// attempt to load a subdoc of a given guid | ||
__init19() {this.loadSubdoc = (guid) => { | ||
__init21() {this.loadSubdoc = (guid) => { | ||
for (const subdoc of this.rootDoc.subdocs) { | ||
@@ -468,3 +475,3 @@ if (subdoc.guid === guid) { | ||
}} | ||
__init20() {this.syncDoc = () => { | ||
__init22() {this.syncDoc = () => { | ||
this.rootDocHandler.syncDoc(); | ||
@@ -482,2 +489,12 @@ for (const [_, handler] of this.subdocHandlers) { | ||
} | ||
async pause() { | ||
await _optionalChain([this, 'access', _60 => _60.indexeddbProvider, 'optionalAccess', _61 => _61.destroy, 'call', _62 => _62()]); | ||
this.indexeddbProvider = null; | ||
this.isPaused = true; | ||
} | ||
unpause() { | ||
this.isPaused = false; | ||
this.setupOfflineSupport(); | ||
this.rootDocHandler.syncDoc(); | ||
} | ||
getStatus() { | ||
@@ -484,0 +501,0 @@ if (!this.synced) { |
{ | ||
"name": "@liveblocks/yjs", | ||
"version": "2.16.0", | ||
"version": "2.16.1-ai", | ||
"description": "An integration with . Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.", | ||
@@ -36,4 +36,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/client": "2.16.0", | ||
"@liveblocks/core": "2.16.0", | ||
"@liveblocks/client": "2.16.1-ai", | ||
"@liveblocks/core": "2.16.1-ai", | ||
"js-base64": "^3.7.7", | ||
@@ -40,0 +40,0 @@ "y-indexeddb": "^9.0.12" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
133877
1102
1
+ Added@liveblocks/client@2.16.1-ai(transitive)
+ Added@liveblocks/core@2.16.1-ai(transitive)
- Removed@liveblocks/client@2.16.0(transitive)
- Removed@liveblocks/core@2.16.0(transitive)
Updated@liveblocks/client@2.16.1-ai
Updated@liveblocks/core@2.16.1-ai