@liveblocks/yjs
Advanced tools
Comparing version 2.11.0 to 2.11.1
@@ -59,2 +59,3 @@ import { JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata, Room, User } from '@liveblocks/client'; | ||
autoloadSubdocs?: boolean; | ||
offlineSupport_experimental?: boolean; | ||
}; | ||
@@ -70,2 +71,3 @@ declare enum SyncStatus { | ||
private options; | ||
private indexeddbProvider; | ||
private unsubscribers; | ||
@@ -87,2 +89,3 @@ awareness: Awareness<P, S, U, E, M>; | ||
destroy(): void; | ||
clearOfflineData(): Promise<void>; | ||
disconnect(): void; | ||
@@ -89,0 +92,0 @@ connect(): void; |
@@ -76,2 +76,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; }// src/index.ts | ||
// src/index.ts | ||
var _yindexeddb = require('y-indexeddb'); | ||
var _yjs = require('yjs'); var Y2 = _interopRequireWildcard(_yjs); var Y = _interopRequireWildcard(_yjs); | ||
@@ -209,2 +210,3 @@ | ||
var yDocHandler = class extends Observable { | ||
@@ -247,3 +249,4 @@ constructor({ | ||
this.updateHandler = (update, origin) => { | ||
if (origin !== "backend") { | ||
const isFromLocal = origin instanceof _yindexeddb.IndexeddbPersistence; | ||
if (origin !== "backend" && !isFromLocal) { | ||
this.updateRoomDoc(update); | ||
@@ -283,3 +286,3 @@ } | ||
var PKG_NAME = "@liveblocks/yjs"; | ||
var PKG_VERSION = "2.11.0"; | ||
var PKG_VERSION = "2.11.1"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -292,2 +295,3 @@ | ||
super(); | ||
this.indexeddbProvider = null; | ||
this.unsubscribers = []; | ||
@@ -418,2 +422,12 @@ this.subdocHandlers = /* @__PURE__ */ new Map(); | ||
); | ||
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.rootDocHandler.on("synced", () => { | ||
@@ -452,2 +466,6 @@ const state = this.rootDocHandler.synced; | ||
} | ||
async clearOfflineData() { | ||
if (!this.indexeddbProvider) return; | ||
return this.indexeddbProvider.clearData(); | ||
} | ||
// Some provider implementations expect to be able to call connect/disconnect, implement as noop | ||
@@ -454,0 +472,0 @@ disconnect() { |
{ | ||
"name": "@liveblocks/yjs", | ||
"version": "2.11.0", | ||
"version": "2.11.1", | ||
"description": "An integration with . Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.", | ||
@@ -36,5 +36,6 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/client": "2.11.0", | ||
"@liveblocks/core": "2.11.0", | ||
"js-base64": "^3.7.7" | ||
"@liveblocks/client": "2.11.1", | ||
"@liveblocks/core": "2.11.1", | ||
"js-base64": "^3.7.7", | ||
"y-indexeddb": "^9.0.12" | ||
}, | ||
@@ -41,0 +42,0 @@ "peerDependencies": { |
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
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
119098
1012
5
+ Addedy-indexeddb@^9.0.12
+ Added@liveblocks/client@2.11.1(transitive)
+ Added@liveblocks/core@2.11.1(transitive)
+ Addedy-indexeddb@9.0.12(transitive)
- Removed@liveblocks/client@2.11.0(transitive)
- Removed@liveblocks/core@2.11.0(transitive)
Updated@liveblocks/client@2.11.1
Updated@liveblocks/core@2.11.1