@liveblocks/yjs 1.1.0-yjs1 → 1.1.0-yjs3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -158,22 +158,21 @@ var Awareness = class extends Observable {
158
158
  return presence["__yjs"];
159
159
  }
160
160
  setLocalState(state) {
161
- const self = this.room.getSelf();
162
- if (!self) {
163
- return;
164
- }
165
161
  this.room.updatePresence({ __yjs: __spreadValues({}, state || {}) });
166
162
  }
167
163
  setLocalStateField(field, value) {
168
164
  const update = { [field]: value };
169
165
  this.room.updatePresence({ __yjs: update });
170
166
  }
171
- // Translate
167
+ // Translate liveblocks presence to yjs awareness
172
168
  getStates() {
173
169
  const others = this.room.getOthers();
174
170
  const states = others.reduce((acc, currentValue) => {
175
171
  if (currentValue.connectionId) {
176
- acc.set(currentValue.connectionId, currentValue.presence["__yjs"]);
172
+ acc.set(
173
+ currentValue.connectionId,
174
+ currentValue.presence["__yjs"] || {}
175
+ );
177
176
  }
178
177
  return acc;
179
178
  }, /* @__PURE__ */ new Map());
package/dist/index.mjs CHANGED
@@ -158,22 +158,21 @@ var Awareness = class extends Observable {
158
158
  return presence["__yjs"];
159
159
  }
160
160
  setLocalState(state) {
161
- const self = this.room.getSelf();
162
- if (!self) {
163
- return;
164
- }
165
161
  this.room.updatePresence({ __yjs: __spreadValues({}, state || {}) });
166
162
  }
167
163
  setLocalStateField(field, value) {
168
164
  const update = { [field]: value };
169
165
  this.room.updatePresence({ __yjs: update });
170
166
  }
171
- // Translate
167
+ // Translate liveblocks presence to yjs awareness
172
168
  getStates() {
173
169
  const others = this.room.getOthers();
174
170
  const states = others.reduce((acc, currentValue) => {
175
171
  if (currentValue.connectionId) {
176
- acc.set(currentValue.connectionId, currentValue.presence["__yjs"]);
172
+ acc.set(
173
+ currentValue.connectionId,
174
+ currentValue.presence["__yjs"] || {}
175
+ );
177
176
  }
178
177
  return acc;
179
178
  }, /* @__PURE__ */ new Map());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liveblocks/yjs",
3
- "version": "1.1.0-yjs1",
3
+ "version": "1.1.0-yjs3",
4
4
  "description": "An integration with . Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -26,8 +26,8 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "@liveblocks/client": "1.1.0-yjs1",
30
- "@liveblocks/core": "1.1.0-yjs1",
29
+ "@liveblocks/client": "1.1.0-yjs3",
30
+ "@liveblocks/core": "1.1.0-yjs3",
31
31
  "js-base64": "^3.7.5"
32
32
  },
33
33
  "peerDependencies": {