@liveblocks/yjs 1.0.12-yjs2 → 1.1.0-yjs1
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 +11 -39
- package/package.json +11 -4
package/dist/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1
|
+
"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; } }var __defProp = Object.defineProperty;
|
|
6
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -19,27 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
19
14
|
}
|
|
20
15
|
return a;
|
|
21
16
|
};
|
|
22
|
-
var __export = (target, all) => {
|
|
23
|
-
for (var name in all)
|
|
24
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
-
};
|
|
26
|
-
var __copyProps = (to, from2, except, desc) => {
|
|
27
|
-
if (from2 && typeof from2 === "object" || typeof from2 === "function") {
|
|
28
|
-
for (let key of __getOwnPropNames(from2))
|
|
29
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
-
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
31
|
-
}
|
|
32
|
-
return to;
|
|
33
|
-
};
|
|
34
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
-
mod
|
|
41
|
-
));
|
|
42
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
17
|
var __async = (__this, __arguments, generator) => {
|
|
44
18
|
return new Promise((resolve, reject) => {
|
|
45
19
|
var fulfilled = (value) => {
|
|
@@ -62,13 +36,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
62
36
|
};
|
|
63
37
|
|
|
64
38
|
// src/index.ts
|
|
65
|
-
var
|
|
66
|
-
__export(src_exports, {
|
|
67
|
-
Awareness: () => Awareness,
|
|
68
|
-
default: () => LiveblocksProvider
|
|
69
|
-
});
|
|
70
|
-
module.exports = __toCommonJS(src_exports);
|
|
71
|
-
var import_js_base64 = require("js-base64");
|
|
39
|
+
var _jsbase64 = require('js-base64');
|
|
72
40
|
|
|
73
41
|
// ../../node_modules/lib0/map.js
|
|
74
42
|
var create = () => /* @__PURE__ */ new Map();
|
|
@@ -141,7 +109,7 @@ var Observable = class {
|
|
|
141
109
|
};
|
|
142
110
|
|
|
143
111
|
// src/index.ts
|
|
144
|
-
var
|
|
112
|
+
var _yjs = require('yjs'); var Y = _interopRequireWildcard(_yjs);
|
|
145
113
|
var Awareness = class extends Observable {
|
|
146
114
|
constructor(doc, room) {
|
|
147
115
|
super();
|
|
@@ -218,7 +186,7 @@ var LiveblocksProvider = class {
|
|
|
218
186
|
this.unsubscribers = [];
|
|
219
187
|
this.updateHandler = (update, origin) => __async(this, null, function* () {
|
|
220
188
|
if (origin !== "backend") {
|
|
221
|
-
const encodedUpdate =
|
|
189
|
+
const encodedUpdate = _jsbase64.Base64.fromUint8Array(update);
|
|
222
190
|
this.room.updateDoc(encodedUpdate);
|
|
223
191
|
if (this.httpEndpoint) {
|
|
224
192
|
yield fetch(this.httpEndpoint, {
|
|
@@ -243,7 +211,7 @@ var LiveblocksProvider = class {
|
|
|
243
211
|
if (e === "open") {
|
|
244
212
|
this.doc.clientID = ((_a2 = this.room.getSelf()) == null ? void 0 : _a2.connectionId) || this.doc.clientID;
|
|
245
213
|
this.awareness.clientID = this.doc.clientID;
|
|
246
|
-
const encodedVector =
|
|
214
|
+
const encodedVector = _jsbase64.Base64.fromUint8Array(
|
|
247
215
|
Y.encodeStateVector(this.doc)
|
|
248
216
|
);
|
|
249
217
|
this.room.getDoc(encodedVector);
|
|
@@ -252,7 +220,7 @@ var LiveblocksProvider = class {
|
|
|
252
220
|
);
|
|
253
221
|
this.unsubscribers.push(
|
|
254
222
|
this.room.events.docUpdated.subscribe((updates) => {
|
|
255
|
-
const decodedUpdates = updates.map(
|
|
223
|
+
const decodedUpdates = updates.map(_jsbase64.Base64.toUint8Array);
|
|
256
224
|
const update = Y.mergeUpdates(decodedUpdates);
|
|
257
225
|
Y.applyUpdate(this.doc, update, "backend");
|
|
258
226
|
})
|
|
@@ -283,7 +251,7 @@ var LiveblocksProvider = class {
|
|
|
283
251
|
return;
|
|
284
252
|
}
|
|
285
253
|
this.lastUpdateDate = new Date(lastUpdate);
|
|
286
|
-
const update = Y.mergeUpdates(updates.map(
|
|
254
|
+
const update = Y.mergeUpdates(updates.map(_jsbase64.Base64.toUint8Array));
|
|
287
255
|
Y.applyUpdate(this.doc, update, "backend");
|
|
288
256
|
});
|
|
289
257
|
}
|
|
@@ -293,3 +261,7 @@ var LiveblocksProvider = class {
|
|
|
293
261
|
this.awareness.destroy();
|
|
294
262
|
}
|
|
295
263
|
};
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
exports.Awareness = Awareness; exports.default = LiveblocksProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveblocks/yjs",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-yjs1",
|
|
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",
|
|
@@ -11,16 +11,23 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "tsup --watch",
|
|
14
|
-
"build": "tsup",
|
|
14
|
+
"build": "tsup --format cjs,esm --dts --clean",
|
|
15
15
|
"format": "eslint --fix src/; prettier --write src/",
|
|
16
16
|
"lint": "eslint src/",
|
|
17
17
|
"test": "jest --silent --verbose --color=always",
|
|
18
18
|
"test:types": "tsd",
|
|
19
19
|
"test:watch": "jest --silent --verbose --color=always --watch"
|
|
20
20
|
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"require": "./dist/index.js",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
21
28
|
"dependencies": {
|
|
22
|
-
"@liveblocks/client": "1.0
|
|
23
|
-
"@liveblocks/core": "1.0
|
|
29
|
+
"@liveblocks/client": "1.1.0-yjs1",
|
|
30
|
+
"@liveblocks/core": "1.1.0-yjs1",
|
|
24
31
|
"js-base64": "^3.7.5"
|
|
25
32
|
},
|
|
26
33
|
"peerDependencies": {
|