@liveblocks/yjs
Advanced tools
Comparing version 2.16.0-toolbars5 to 2.16.0
@@ -39,3 +39,4 @@ import { JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata, Room, User } from '@liveblocks/client'; | ||
private fetchRoomDoc; | ||
constructor({ doc, isRoot, updateDoc, fetchDoc, }: { | ||
private useV2Encoding; | ||
constructor({ doc, isRoot, updateDoc, fetchDoc, useV2Encoding, }: { | ||
doc: Y.Doc; | ||
@@ -45,7 +46,9 @@ isRoot: boolean; | ||
fetchDoc: (vector: string, guid?: string) => void; | ||
useV2Encoding: boolean; | ||
}); | ||
handleServerUpdate: ({ update, stateVector, readOnly, }: { | ||
handleServerUpdate: ({ update, stateVector, readOnly, v2, }: { | ||
update: Uint8Array; | ||
stateVector: string | null; | ||
readOnly: boolean; | ||
v2?: boolean; | ||
}) => void; | ||
@@ -62,2 +65,3 @@ syncDoc: () => void; | ||
offlineSupport_experimental?: boolean; | ||
useV2Encoding_experimental?: boolean; | ||
}; | ||
@@ -82,2 +86,3 @@ declare class LiveblocksYjsProvider<P extends JsonObject = DP, S extends LsonObject = DS, U extends BaseUserMeta = DU, E extends Json = DE, M extends BaseMetadata$1 = DM> extends Observable<unknown> implements IYjsProvider { | ||
private syncDoc; | ||
get useV2Encoding(): boolean; | ||
get synced(): boolean; | ||
@@ -84,0 +89,0 @@ getStatus(): YjsSyncStatus; |
@@ -219,2 +219,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 | ||
constructor({ | ||
@@ -224,7 +225,9 @@ doc, | ||
updateDoc, | ||
fetchDoc | ||
fetchDoc, | ||
useV2Encoding | ||
}) { | ||
super();_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);; | ||
this.doc = doc; | ||
this.doc.on("update", this.updateHandler); | ||
this.useV2Encoding = useV2Encoding; | ||
this.doc.on(useV2Encoding ? "updateV2" : "update", this.updateHandler); | ||
this.updateRoomDoc = (update) => { | ||
@@ -241,9 +244,12 @@ updateDoc(update, isRoot ? void 0 : this.doc.guid); | ||
stateVector, | ||
readOnly | ||
readOnly, | ||
v2 | ||
}) => { | ||
Y.applyUpdate(this.doc, update, "backend"); | ||
const applyUpdate2 = v2 ? Y.applyUpdateV2 : Y.applyUpdate; | ||
applyUpdate2(this.doc, update, "backend"); | ||
if (stateVector) { | ||
if (!readOnly) { | ||
try { | ||
const localUpdate = Y.encodeStateAsUpdate( | ||
const encodeUpdate = this.useV2Encoding ? Y.encodeStateAsUpdateV2 : Y.encodeStateAsUpdate; | ||
const localUpdate = encodeUpdate( | ||
this.doc, | ||
@@ -292,3 +298,3 @@ _jsbase64.Base64.toUint8Array(stateVector) | ||
var PKG_NAME = "@liveblocks/yjs"; | ||
var PKG_VERSION = "2.16.0-toolbars5"; | ||
var PKG_VERSION = "2.16.0"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -317,3 +323,4 @@ | ||
updateDoc: this.updateDoc, | ||
fetchDoc: this.fetchDoc | ||
fetchDoc: this.fetchDoc, | ||
useV2Encoding: _nullishCoalesce(this.options.useV2Encoding_experimental, () => ( false)) | ||
}); | ||
@@ -338,3 +345,3 @@ room[_core.kInternal].setYjsProvider(this); | ||
} | ||
const { stateVector, update: updateStr, guid } = message; | ||
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)); | ||
@@ -356,3 +363,4 @@ const update = _jsbase64.Base64.toUint8Array(updateStr); | ||
stateVector, | ||
readOnly: !canWrite | ||
readOnly: !canWrite, | ||
v2 | ||
})]); | ||
@@ -363,3 +371,4 @@ } else { | ||
stateVector, | ||
readOnly: !canWrite | ||
readOnly: !canWrite, | ||
v2 | ||
}); | ||
@@ -422,3 +431,7 @@ } | ||
this.pending.push(updateId); | ||
this.room.updateYDoc(_jsbase64.Base64.fromUint8Array(update), guid); | ||
this.room.updateYDoc( | ||
_jsbase64.Base64.fromUint8Array(update), | ||
guid, | ||
this.useV2Encoding | ||
); | ||
this.emit("status", [this.getStatus()]); | ||
@@ -428,3 +441,3 @@ } | ||
__init17() {this.fetchDoc = (vector, guid) => { | ||
this.room.fetchYDoc(vector, guid); | ||
this.room.fetchYDoc(vector, guid, this.useV2Encoding); | ||
}} | ||
@@ -440,3 +453,4 @@ __init18() {this.createSubdocHandler = (subdoc) => { | ||
updateDoc: this.updateDoc, | ||
fetchDoc: this.fetchDoc | ||
fetchDoc: this.fetchDoc, | ||
useV2Encoding: _nullishCoalesce(this.options.useV2Encoding_experimental, () => ( false)) | ||
}); | ||
@@ -461,2 +475,5 @@ this.subdocHandlers.set(subdoc.guid, handler); | ||
}} | ||
get useV2Encoding() { | ||
return _nullishCoalesce(this.options.useV2Encoding_experimental, () => ( false)); | ||
} | ||
// The sync'd property is required by some provider implementations | ||
@@ -463,0 +480,0 @@ get synced() { |
{ | ||
"name": "@liveblocks/yjs", | ||
"version": "2.16.0-toolbars5", | ||
"version": "2.16.0", | ||
"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-toolbars5", | ||
"@liveblocks/core": "2.16.0-toolbars5", | ||
"@liveblocks/client": "2.16.0", | ||
"@liveblocks/core": "2.16.0", | ||
"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
131139
1064
0
+ Added@liveblocks/client@2.16.0(transitive)
+ Added@liveblocks/core@2.16.0(transitive)
- Removed@liveblocks/client@2.16.0-toolbars5(transitive)
- Removed@liveblocks/core@2.16.0-toolbars5(transitive)
Updated@liveblocks/client@2.16.0
Updated@liveblocks/core@2.16.0