@liveblocks/yjs
Advanced tools
Comparing version 1.10.0-beta3 to 1.10.0-beta4
@@ -93,4 +93,8 @@ "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 | ||
{ added: [], updated: [], removed: [event.user.connectionId] }, | ||
"local" | ||
"presence" | ||
]); | ||
this.emit("update", [ | ||
{ added: [], updated: [], removed: [event.user.connectionId] }, | ||
"presence" | ||
]); | ||
} | ||
@@ -100,4 +104,8 @@ if (event.type === "enter") { | ||
{ added: [event.user.connectionId], updated: [], removed: [] }, | ||
"local" | ||
"presence" | ||
]); | ||
this.emit("update", [ | ||
{ added: [event.user.connectionId], updated: [], removed: [] }, | ||
"presence" | ||
]); | ||
} | ||
@@ -107,4 +115,8 @@ if (event.type === "update") { | ||
{ added: [], updated: [event.user.connectionId], removed: [] }, | ||
"local" | ||
"presence" | ||
]); | ||
this.emit("update", [ | ||
{ added: [], updated: [event.user.connectionId], removed: [] }, | ||
"presence" | ||
]); | ||
} | ||
@@ -127,6 +139,24 @@ }); | ||
setLocalState(state) { | ||
const presence = _optionalChain([this, 'access', _2 => _2.room, 'access', _3 => _3.getSelf, 'call', _4 => _4(), 'optionalAccess', _5 => _5.presence, 'access', _6 => _6[Y_PRESENCE_KEY]]); | ||
const presence = _optionalChain([this, 'access', _2 => _2.room, 'access', _3 => _3.getSelf, 'call', _4 => _4(), 'optionalAccess', _5 => _5.presence]); | ||
if (state === null) { | ||
if (presence === void 0) { | ||
return; | ||
} | ||
this.room.updatePresence({ ...presence, [Y_PRESENCE_KEY]: null }); | ||
this.emit("update", [ | ||
{ added: [], updated: [], removed: [this.clientID] }, | ||
"local" | ||
]); | ||
return; | ||
} | ||
const yPresence = _optionalChain([presence, 'optionalAccess', _6 => _6[Y_PRESENCE_KEY]]); | ||
const added = yPresence === void 0 ? [this.clientID] : []; | ||
const updated = yPresence === void 0 ? [] : [this.clientID]; | ||
this.room.updatePresence({ | ||
__yjs: { ...presence || {}, ...state || {} } | ||
[Y_PRESENCE_KEY]: { | ||
...yPresence || {}, | ||
...state || {} | ||
} | ||
}); | ||
this.emit("update", [{ added, updated, removed: [] }, "local"]); | ||
} | ||
@@ -137,3 +167,3 @@ setLocalStateField(field, value) { | ||
this.room.updatePresence({ | ||
__yjs: { ...presence || {}, ...update } | ||
[Y_PRESENCE_KEY]: { ...presence || {}, ...update } | ||
}); | ||
@@ -144,4 +174,5 @@ } | ||
const others = this.room.getOthers(); | ||
const presence = _optionalChain([this, 'access', _12 => _12.room, 'access', _13 => _13.getSelf, 'call', _14 => _14(), 'optionalAccess', _15 => _15.presence, 'access', _16 => _16[Y_PRESENCE_KEY]]); | ||
const states = others.reduce((acc, currentValue) => { | ||
if (currentValue.connectionId) { | ||
if (currentValue.connectionId && currentValue.presence[Y_PRESENCE_KEY] !== void 0) { | ||
acc.set( | ||
@@ -154,2 +185,5 @@ currentValue.connectionId, | ||
}, /* @__PURE__ */ new Map()); | ||
if (presence !== void 0) { | ||
states.set(this.clientID, presence); | ||
} | ||
return states; | ||
@@ -232,3 +266,3 @@ } | ||
var PKG_NAME = "@liveblocks/yjs"; | ||
var PKG_VERSION = "1.10.0-beta3"; | ||
var PKG_VERSION = "1.10.0-beta4"; | ||
var PKG_FORMAT = "cjs"; | ||
@@ -261,3 +295,3 @@ | ||
if (this.subdocHandlers.has(subdoc.guid)) { | ||
_optionalChain([this, 'access', _12 => _12.subdocHandlers, 'access', _13 => _13.get, 'call', _14 => _14(subdoc.guid), 'optionalAccess', _15 => _15.destroy, 'call', _16 => _16()]); | ||
_optionalChain([this, 'access', _17 => _17.subdocHandlers, 'access', _18 => _18.get, 'call', _19 => _19(subdoc.guid), 'optionalAccess', _20 => _20.destroy, 'call', _21 => _21()]); | ||
this.subdocHandlers.delete(subdoc.guid); | ||
@@ -275,3 +309,3 @@ } | ||
if (this.subdocHandlers.has(subdoc.guid)) { | ||
_optionalChain([this, 'access', _17 => _17.subdocHandlers, 'access', _18 => _18.get, 'call', _19 => _19(subdoc.guid), 'optionalAccess', _20 => _20.syncDoc, 'call', _21 => _21()]); | ||
_optionalChain([this, 'access', _22 => _22.subdocHandlers, 'access', _23 => _23.get, 'call', _24 => _24(subdoc.guid), 'optionalAccess', _25 => _25.syncDoc, 'call', _26 => _26()]); | ||
return; | ||
@@ -298,3 +332,3 @@ } | ||
this.syncDoc = () => { | ||
this.rootDoc.clientID = _optionalChain([this, 'access', _22 => _22.room, 'access', _23 => _23.getSelf, 'call', _24 => _24(), 'optionalAccess', _25 => _25.connectionId]) || this.rootDoc.clientID; | ||
this.rootDoc.clientID = _optionalChain([this, 'access', _27 => _27.room, 'access', _28 => _28.getSelf, 'call', _29 => _29(), 'optionalAccess', _30 => _30.connectionId]) || this.rootDoc.clientID; | ||
this.awareness.clientID = this.rootDoc.clientID; | ||
@@ -315,3 +349,3 @@ this.rootDocHandler.syncDoc(); | ||
}); | ||
const connectionId = _optionalChain([this, 'access', _26 => _26.room, 'access', _27 => _27.getSelf, 'call', _28 => _28(), 'optionalAccess', _29 => _29.connectionId]); | ||
const connectionId = _optionalChain([this, 'access', _31 => _31.room, 'access', _32 => _32.getSelf, 'call', _33 => _33(), 'optionalAccess', _34 => _34.connectionId]); | ||
if (connectionId) { | ||
@@ -338,3 +372,3 @@ this.rootDoc.clientID = connectionId; | ||
if (guid !== void 0) { | ||
_optionalChain([this, 'access', _30 => _30.subdocHandlers, 'access', _31 => _31.get, 'call', _32 => _32(guid), 'optionalAccess', _33 => _33.handleServerUpdate, 'call', _34 => _34({ 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 })]); | ||
} else { | ||
@@ -341,0 +375,0 @@ this.rootDocHandler.handleServerUpdate({ update, stateVector }); |
{ | ||
"name": "@liveblocks/yjs", | ||
"version": "1.10.0-beta3", | ||
"version": "1.10.0-beta4", | ||
"description": "An integration with . Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.", | ||
@@ -35,4 +35,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@liveblocks/client": "1.10.0-beta3", | ||
"@liveblocks/core": "1.10.0-beta3", | ||
"@liveblocks/client": "1.10.0-beta4", | ||
"@liveblocks/core": "1.10.0-beta4", | ||
"js-base64": "^3.7.5" | ||
@@ -39,0 +39,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
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
96115
858
+ Added@liveblocks/client@1.10.0-beta4(transitive)
+ Added@liveblocks/core@1.10.0-beta4(transitive)
- Removed@liveblocks/client@1.10.0-beta3(transitive)
- Removed@liveblocks/core@1.10.0-beta3(transitive)