@liveblocks/yjs 1.1.1-yjs2 → 1.1.2-beta1
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.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +24 -30
- package/dist/index.mjs +24 -30
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -27,16 +27,20 @@ declare class Awareness extends Observable<unknown> {
|
|
|
27
27
|
setLocalStateField(field: string, value: JsonObject | null): void;
|
|
28
28
|
getStates(): Map<number, unknown>;
|
|
29
29
|
}
|
|
30
|
-
declare class LiveblocksProvider<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json> {
|
|
30
|
+
declare class LiveblocksProvider<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json> extends Observable<unknown> {
|
|
31
31
|
private room;
|
|
32
|
-
private httpEndpoint?;
|
|
33
32
|
private doc;
|
|
34
33
|
private unsubscribers;
|
|
35
34
|
awareness: Awareness;
|
|
35
|
+
private _synced;
|
|
36
36
|
constructor(room: Room<P, S, U, E>, doc: Y.Doc);
|
|
37
37
|
private syncDoc;
|
|
38
|
+
get synced(): boolean;
|
|
39
|
+
set synced(state: boolean);
|
|
38
40
|
private updateHandler;
|
|
39
41
|
destroy(): void;
|
|
42
|
+
disconnect(): void;
|
|
43
|
+
connect(): void;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
export { Awareness, LiveblocksProvider as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -27,16 +27,20 @@ declare class Awareness extends Observable<unknown> {
|
|
|
27
27
|
setLocalStateField(field: string, value: JsonObject | null): void;
|
|
28
28
|
getStates(): Map<number, unknown>;
|
|
29
29
|
}
|
|
30
|
-
declare class LiveblocksProvider<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json> {
|
|
30
|
+
declare class LiveblocksProvider<P extends JsonObject, S extends LsonObject, U extends BaseUserMeta, E extends Json> extends Observable<unknown> {
|
|
31
31
|
private room;
|
|
32
|
-
private httpEndpoint?;
|
|
33
32
|
private doc;
|
|
34
33
|
private unsubscribers;
|
|
35
34
|
awareness: Awareness;
|
|
35
|
+
private _synced;
|
|
36
36
|
constructor(room: Room<P, S, U, E>, doc: Y.Doc);
|
|
37
37
|
private syncDoc;
|
|
38
|
+
get synced(): boolean;
|
|
39
|
+
set synced(state: boolean);
|
|
38
40
|
private updateHandler;
|
|
39
41
|
destroy(): void;
|
|
42
|
+
disconnect(): void;
|
|
43
|
+
connect(): void;
|
|
40
44
|
}
|
|
41
45
|
|
|
42
46
|
export { Awareness, LiveblocksProvider as default };
|
package/dist/index.js
CHANGED
|
@@ -14,26 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
var __async = (__this, __arguments, generator) => {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
var fulfilled = (value) => {
|
|
20
|
-
try {
|
|
21
|
-
step(generator.next(value));
|
|
22
|
-
} catch (e) {
|
|
23
|
-
reject(e);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var rejected = (value) => {
|
|
27
|
-
try {
|
|
28
|
-
step(generator.throw(value));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
17
|
|
|
38
18
|
// src/index.ts
|
|
39
19
|
var _jsbase64 = require('js-base64');
|
|
@@ -188,29 +168,26 @@ var Awareness = class extends Observable {
|
|
|
188
168
|
return states;
|
|
189
169
|
}
|
|
190
170
|
};
|
|
191
|
-
var LiveblocksProvider = class {
|
|
171
|
+
var LiveblocksProvider = class extends Observable {
|
|
192
172
|
constructor(room, doc) {
|
|
173
|
+
var _a;
|
|
174
|
+
super();
|
|
193
175
|
this.unsubscribers = [];
|
|
176
|
+
this._synced = false;
|
|
194
177
|
this.syncDoc = () => {
|
|
195
178
|
var _a;
|
|
179
|
+
this.synced = false;
|
|
196
180
|
this.doc.clientID = ((_a = this.room.getSelf()) == null ? void 0 : _a.connectionId) || this.doc.clientID;
|
|
197
181
|
this.awareness.clientID = this.doc.clientID;
|
|
198
182
|
const encodedVector = _jsbase64.Base64.fromUint8Array(Y.encodeStateVector(this.doc));
|
|
199
183
|
this.room.fetchYDoc(encodedVector);
|
|
200
184
|
};
|
|
201
|
-
this.updateHandler = (update, origin) =>
|
|
185
|
+
this.updateHandler = (update, origin) => {
|
|
202
186
|
if (origin !== "backend") {
|
|
203
187
|
const encodedUpdate = _jsbase64.Base64.fromUint8Array(update);
|
|
204
188
|
this.room.updateYDoc(encodedUpdate);
|
|
205
|
-
if (this.httpEndpoint) {
|
|
206
|
-
yield fetch(this.httpEndpoint, {
|
|
207
|
-
method: "POST",
|
|
208
|
-
body: encodedUpdate
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
189
|
}
|
|
212
|
-
}
|
|
213
|
-
var _a;
|
|
190
|
+
};
|
|
214
191
|
this.doc = doc;
|
|
215
192
|
this.room = room;
|
|
216
193
|
const connectionId = (_a = this.room.getSelf()) == null ? void 0 : _a.connectionId;
|
|
@@ -229,15 +206,32 @@ var LiveblocksProvider = class {
|
|
|
229
206
|
this.unsubscribers.push(
|
|
230
207
|
this.room.events.ydoc.subscribe((update) => {
|
|
231
208
|
Y.applyUpdate(this.doc, _jsbase64.Base64.toUint8Array(update), "backend");
|
|
209
|
+
this.synced = true;
|
|
232
210
|
})
|
|
233
211
|
);
|
|
234
212
|
this.syncDoc();
|
|
235
213
|
}
|
|
214
|
+
// The sync'd property is required by some provider implementations
|
|
215
|
+
get synced() {
|
|
216
|
+
return this._synced;
|
|
217
|
+
}
|
|
218
|
+
set synced(state) {
|
|
219
|
+
if (this._synced !== state) {
|
|
220
|
+
this._synced = state;
|
|
221
|
+
this.emit("synced", [state]);
|
|
222
|
+
this.emit("sync", [state]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
236
225
|
destroy() {
|
|
237
226
|
this.doc.off("update", this.updateHandler);
|
|
238
227
|
this.unsubscribers.forEach((unsub) => unsub());
|
|
239
228
|
this.awareness.destroy();
|
|
240
229
|
}
|
|
230
|
+
// Some provider implementations expect to be able to call connect/disconnect, implement as noop
|
|
231
|
+
disconnect() {
|
|
232
|
+
}
|
|
233
|
+
connect() {
|
|
234
|
+
}
|
|
241
235
|
};
|
|
242
236
|
|
|
243
237
|
|
package/dist/index.mjs
CHANGED
|
@@ -14,26 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
14
14
|
}
|
|
15
15
|
return a;
|
|
16
16
|
};
|
|
17
|
-
var __async = (__this, __arguments, generator) => {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
var fulfilled = (value) => {
|
|
20
|
-
try {
|
|
21
|
-
step(generator.next(value));
|
|
22
|
-
} catch (e) {
|
|
23
|
-
reject(e);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var rejected = (value) => {
|
|
27
|
-
try {
|
|
28
|
-
step(generator.throw(value));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
17
|
|
|
38
18
|
// src/index.ts
|
|
39
19
|
import { Base64 } from "js-base64";
|
|
@@ -188,29 +168,26 @@ var Awareness = class extends Observable {
|
|
|
188
168
|
return states;
|
|
189
169
|
}
|
|
190
170
|
};
|
|
191
|
-
var LiveblocksProvider = class {
|
|
171
|
+
var LiveblocksProvider = class extends Observable {
|
|
192
172
|
constructor(room, doc) {
|
|
173
|
+
var _a;
|
|
174
|
+
super();
|
|
193
175
|
this.unsubscribers = [];
|
|
176
|
+
this._synced = false;
|
|
194
177
|
this.syncDoc = () => {
|
|
195
178
|
var _a;
|
|
179
|
+
this.synced = false;
|
|
196
180
|
this.doc.clientID = ((_a = this.room.getSelf()) == null ? void 0 : _a.connectionId) || this.doc.clientID;
|
|
197
181
|
this.awareness.clientID = this.doc.clientID;
|
|
198
182
|
const encodedVector = Base64.fromUint8Array(Y.encodeStateVector(this.doc));
|
|
199
183
|
this.room.fetchYDoc(encodedVector);
|
|
200
184
|
};
|
|
201
|
-
this.updateHandler = (update, origin) =>
|
|
185
|
+
this.updateHandler = (update, origin) => {
|
|
202
186
|
if (origin !== "backend") {
|
|
203
187
|
const encodedUpdate = Base64.fromUint8Array(update);
|
|
204
188
|
this.room.updateYDoc(encodedUpdate);
|
|
205
|
-
if (this.httpEndpoint) {
|
|
206
|
-
yield fetch(this.httpEndpoint, {
|
|
207
|
-
method: "POST",
|
|
208
|
-
body: encodedUpdate
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
189
|
}
|
|
212
|
-
}
|
|
213
|
-
var _a;
|
|
190
|
+
};
|
|
214
191
|
this.doc = doc;
|
|
215
192
|
this.room = room;
|
|
216
193
|
const connectionId = (_a = this.room.getSelf()) == null ? void 0 : _a.connectionId;
|
|
@@ -229,15 +206,32 @@ var LiveblocksProvider = class {
|
|
|
229
206
|
this.unsubscribers.push(
|
|
230
207
|
this.room.events.ydoc.subscribe((update) => {
|
|
231
208
|
Y.applyUpdate(this.doc, Base64.toUint8Array(update), "backend");
|
|
209
|
+
this.synced = true;
|
|
232
210
|
})
|
|
233
211
|
);
|
|
234
212
|
this.syncDoc();
|
|
235
213
|
}
|
|
214
|
+
// The sync'd property is required by some provider implementations
|
|
215
|
+
get synced() {
|
|
216
|
+
return this._synced;
|
|
217
|
+
}
|
|
218
|
+
set synced(state) {
|
|
219
|
+
if (this._synced !== state) {
|
|
220
|
+
this._synced = state;
|
|
221
|
+
this.emit("synced", [state]);
|
|
222
|
+
this.emit("sync", [state]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
236
225
|
destroy() {
|
|
237
226
|
this.doc.off("update", this.updateHandler);
|
|
238
227
|
this.unsubscribers.forEach((unsub) => unsub());
|
|
239
228
|
this.awareness.destroy();
|
|
240
229
|
}
|
|
230
|
+
// Some provider implementations expect to be able to call connect/disconnect, implement as noop
|
|
231
|
+
disconnect() {
|
|
232
|
+
}
|
|
233
|
+
connect() {
|
|
234
|
+
}
|
|
241
235
|
};
|
|
242
236
|
export {
|
|
243
237
|
Awareness,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/yjs",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2-beta1",
|
|
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",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"build": "tsup && cp dist/index.d.ts dist/index.d.mts",
|
|
15
15
|
"format": "eslint --fix src/; prettier --write src/",
|
|
16
16
|
"lint": "eslint src/",
|
|
17
|
-
"lint:package": "publint --strict && attw
|
|
17
|
+
"lint:package": "publint --strict && attw --pack",
|
|
18
18
|
"test": "jest --silent --verbose --color=always",
|
|
19
19
|
"test:types": "tsd",
|
|
20
20
|
"test:watch": "jest --silent --verbose --color=always --watch"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@liveblocks/client": "1.1.
|
|
36
|
-
"@liveblocks/core": "1.1.
|
|
35
|
+
"@liveblocks/client": "1.1.2-beta1",
|
|
36
|
+
"@liveblocks/core": "1.1.2-beta1",
|
|
37
37
|
"js-base64": "^3.7.5"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|