@liveblocks/yjs
Advanced tools
Comparing version 1.1.0-yjs4 to 1.1.0-yjs5
@@ -35,2 +35,3 @@ import { Room, JsonObject, LsonObject, BaseUserMeta, Json } from '@liveblocks/client'; | ||
constructor(room: Room<P, S, U, E>, doc: Y.Doc, config?: LiveblocksYjsOptions); | ||
private syncDoc; | ||
private updateHandler; | ||
@@ -37,0 +38,0 @@ private resyncHttp; |
@@ -194,6 +194,13 @@ "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; } }var __defProp = Object.defineProperty; | ||
this.unsubscribers = []; | ||
this.syncDoc = () => { | ||
var _a; | ||
this.doc.clientID = ((_a = this.room.getSelf()) == null ? void 0 : _a.connectionId) || this.doc.clientID; | ||
this.awareness.clientID = this.doc.clientID; | ||
const encodedVector = _jsbase64.Base64.fromUint8Array(Y.encodeStateVector(this.doc)); | ||
this.room.getYDoc(encodedVector); | ||
}; | ||
this.updateHandler = (update, origin) => __async(this, null, function* () { | ||
if (origin !== "backend") { | ||
const encodedUpdate = _jsbase64.Base64.fromUint8Array(update); | ||
this.room.updateDoc(encodedUpdate); | ||
this.room.updateYDoc(encodedUpdate); | ||
if (this.httpEndpoint) { | ||
@@ -218,10 +225,4 @@ yield fetch(this.httpEndpoint, { | ||
this.room.events.connection.subscribe((e) => { | ||
var _a2; | ||
if (e === "open") { | ||
this.doc.clientID = ((_a2 = this.room.getSelf()) == null ? void 0 : _a2.connectionId) || this.doc.clientID; | ||
this.awareness.clientID = this.doc.clientID; | ||
const encodedVector = _jsbase64.Base64.fromUint8Array( | ||
Y.encodeStateVector(this.doc) | ||
); | ||
this.room.getDoc(encodedVector); | ||
this.syncDoc(); | ||
} | ||
@@ -231,6 +232,4 @@ }) | ||
this.unsubscribers.push( | ||
this.room.events.docUpdated.subscribe((updates) => { | ||
const decodedUpdates = updates.map(_jsbase64.Base64.toUint8Array); | ||
const update = Y.mergeUpdates(decodedUpdates); | ||
Y.applyUpdate(this.doc, update, "backend"); | ||
this.room.events.docUpdated.subscribe((update) => { | ||
Y.applyUpdate(this.doc, _jsbase64.Base64.toUint8Array(update), "backend"); | ||
}) | ||
@@ -249,3 +248,3 @@ ); | ||
} | ||
this.room.getDoc(); | ||
this.syncDoc(); | ||
} | ||
@@ -252,0 +251,0 @@ resyncHttp() { |
{ | ||
"name": "@liveblocks/yjs", | ||
"version": "1.1.0-yjs4", | ||
"version": "1.1.0-yjs5", | ||
"description": "An integration with . Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.", | ||
@@ -29,4 +29,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/client": "1.1.0-yjs4", | ||
"@liveblocks/core": "1.1.0-yjs4", | ||
"@liveblocks/client": "1.1.0-yjs5", | ||
"@liveblocks/core": "1.1.0-yjs5", | ||
"js-base64": "^3.7.5" | ||
@@ -33,0 +33,0 @@ }, |
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
21232
571
+ Added@liveblocks/client@1.1.0-yjs5(transitive)
+ Added@liveblocks/core@1.1.0-yjs5(transitive)
- Removed@liveblocks/client@1.1.0-yjs4(transitive)
- Removed@liveblocks/core@1.1.0-yjs4(transitive)
Updated@liveblocks/core@1.1.0-yjs5