Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@liveblocks/yjs

Package Overview
Dependencies
Maintainers
0
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liveblocks/yjs - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

5

dist/index.d.ts

@@ -45,5 +45,6 @@ import { JsonObject, LsonObject, BaseUserMeta, Json, BaseMetadata, Room, User } from '@liveblocks/client';

});
handleServerUpdate: ({ update, stateVector, }: {
handleServerUpdate: ({ update, stateVector, readOnly, }: {
update: string;
stateVector: string | null;
readOnly: boolean;
}) => void;

@@ -58,3 +59,3 @@ syncDoc: () => void;

declare type ProviderOptions = {
autoloadSubdocs: boolean;
autoloadSubdocs?: boolean;
};

@@ -61,0 +62,0 @@ 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> {

50

dist/index.js

@@ -1,2 +0,2 @@

"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 _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
"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
var _core = require('@liveblocks/core');

@@ -214,14 +214,17 @@

update,
stateVector
stateVector,
readOnly
}) => {
Y.applyUpdate(this.doc, _jsbase64.Base64.toUint8Array(update), "backend");
if (stateVector) {
try {
const localUpdate = Y.encodeStateAsUpdate(
this.doc,
_jsbase64.Base64.toUint8Array(stateVector)
);
this.updateRoomDoc(_jsbase64.Base64.fromUint8Array(localUpdate));
} catch (e) {
console.warn(e);
if (!readOnly) {
try {
const localUpdate = Y.encodeStateAsUpdate(
this.doc,
_jsbase64.Base64.toUint8Array(stateVector)
);
this.updateRoomDoc(_jsbase64.Base64.fromUint8Array(localUpdate));
} catch (e) {
console.warn(e);
}
}

@@ -273,3 +276,3 @@ this.synced = true;

var PKG_NAME = "@liveblocks/yjs";
var PKG_VERSION = "2.2.0";
var PKG_VERSION = "2.2.1";
var PKG_FORMAT = "cjs";

@@ -279,7 +282,4 @@

_core.detectDupes.call(void 0, PKG_NAME, PKG_VERSION, PKG_FORMAT);
var DefaultOptions = {
autoloadSubdocs: false
};
var LiveblocksYjsProvider = class extends Observable {
constructor(room, doc, options = DefaultOptions) {
constructor(room, doc, options = {}) {
super();

@@ -309,3 +309,6 @@ this.unsubscribers = [];

this.updateDoc = (update, guid) => {
this.room.updateYDoc(update, guid);
const canWrite = _nullishCoalesce(_optionalChain([this, 'access', _22 => _22.room, 'access', _23 => _23.getSelf, 'call', _24 => _24(), 'optionalAccess', _25 => _25.canWrite]), () => ( true));
if (canWrite) {
this.room.updateYDoc(update, guid);
}
};

@@ -317,3 +320,3 @@ this.fetchDoc = (vector, guid) => {

if (this.subdocHandlers.has(subdoc.guid)) {
_optionalChain([this, 'access', _22 => _22.subdocHandlers, 'access', _23 => _23.get, 'call', _24 => _24(subdoc.guid), 'optionalAccess', _25 => _25.syncDoc, 'call', _26 => _26()]);
_optionalChain([this, 'access', _26 => _26.subdocHandlers, 'access', _27 => _27.get, 'call', _28 => _28(subdoc.guid), 'optionalAccess', _29 => _29.syncDoc, 'call', _30 => _30()]);
return;

@@ -371,6 +374,15 @@ }

const { stateVector, update, guid } = message;
const canWrite = _nullishCoalesce(_optionalChain([this, 'access', _31 => _31.room, 'access', _32 => _32.getSelf, 'call', _33 => _33(), 'optionalAccess', _34 => _34.canWrite]), () => ( true));
if (guid !== void 0) {
_optionalChain([this, 'access', _27 => _27.subdocHandlers, 'access', _28 => _28.get, 'call', _29 => _29(guid), 'optionalAccess', _30 => _30.handleServerUpdate, 'call', _31 => _31({ update, stateVector })]);
_optionalChain([this, 'access', _35 => _35.subdocHandlers, 'access', _36 => _36.get, 'call', _37 => _37(guid), 'optionalAccess', _38 => _38.handleServerUpdate, 'call', _39 => _39({
update,
stateVector,
readOnly: !canWrite
})]);
} else {
this.rootDocHandler.handleServerUpdate({ update, stateVector });
this.rootDocHandler.handleServerUpdate({
update,
stateVector,
readOnly: !canWrite
});
}

@@ -377,0 +389,0 @@ })

{
"name": "@liveblocks/yjs",
"version": "2.2.0",
"version": "2.2.1",
"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.2.0",
"@liveblocks/core": "2.2.0",
"@liveblocks/client": "2.2.1",
"@liveblocks/core": "2.2.1",
"js-base64": "^3.7.7"

@@ -40,0 +40,0 @@ },

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc