@pluv/client 0.12.0 → 0.12.1
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +17 -17
- package/dist/index.mjs +17 -17
- package/package.json +5 -5
- package/src/AbstractRoom.ts +1 -1
- package/src/MockedRoom.ts +13 -7
- package/src/PluvRoom.ts +10 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/client@0.12.
|
|
2
|
+
> @pluv/client@0.12.1 build /home/runner/work/pluv/pluv/packages/client
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es6
|
|
9
9
|
[34mESM[39m Build start
|
|
10
10
|
[34mCJS[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m44.05 KB[39m
|
|
12
|
+
[32mCJS[39m ⚡️ Build success in 109ms
|
|
13
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m42.81 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 110ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[32m14.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m14.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4203ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m14.23 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m14.23 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -59,7 +59,7 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
|
|
|
59
59
|
abstract getMyself(): Id<UserInfo<TIO, TPresence>> | null;
|
|
60
60
|
abstract getOther(connectionId: string): Id<UserInfo<TIO, TPresence>> | null;
|
|
61
61
|
abstract getOthers(): readonly Id<UserInfo<TIO, TPresence>>[];
|
|
62
|
-
abstract getStorage<TKey extends keyof TStorage>(key: TKey): TStorage[TKey]
|
|
62
|
+
abstract getStorage<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];
|
|
63
63
|
abstract other(connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>): () => void;
|
|
64
64
|
abstract redo(): void;
|
|
65
65
|
abstract storage<TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void): () => void;
|
|
@@ -162,7 +162,7 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
|
|
|
162
162
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
163
163
|
getOther: (connectionId: string) => Id<UserInfo<TIO, TPresence>> | null;
|
|
164
164
|
getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
|
|
165
|
-
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey]
|
|
165
|
+
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey];
|
|
166
166
|
other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
|
|
167
167
|
redo: () => void;
|
|
168
168
|
storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
|
|
@@ -268,7 +268,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
|
|
|
268
268
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
269
269
|
getOther: (connectionId: string) => Id<UserInfo<TIO, TPresence>> | null;
|
|
270
270
|
getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
|
|
271
|
-
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey]
|
|
271
|
+
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey];
|
|
272
272
|
other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
|
|
273
273
|
redo: () => void;
|
|
274
274
|
storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
|
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ declare abstract class AbstractRoom<TIO extends IOLike, TPresence extends JsonOb
|
|
|
59
59
|
abstract getMyself(): Id<UserInfo<TIO, TPresence>> | null;
|
|
60
60
|
abstract getOther(connectionId: string): Id<UserInfo<TIO, TPresence>> | null;
|
|
61
61
|
abstract getOthers(): readonly Id<UserInfo<TIO, TPresence>>[];
|
|
62
|
-
abstract getStorage<TKey extends keyof TStorage>(key: TKey): TStorage[TKey]
|
|
62
|
+
abstract getStorage<TKey extends keyof TStorage>(key: TKey): TStorage[TKey];
|
|
63
63
|
abstract other(connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>): () => void;
|
|
64
64
|
abstract redo(): void;
|
|
65
65
|
abstract storage<TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void): () => void;
|
|
@@ -162,7 +162,7 @@ declare class PluvRoom<TIO extends IOLike, TPresence extends JsonObject = {}, TS
|
|
|
162
162
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
163
163
|
getOther: (connectionId: string) => Id<UserInfo<TIO, TPresence>> | null;
|
|
164
164
|
getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
|
|
165
|
-
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey]
|
|
165
|
+
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey];
|
|
166
166
|
other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
|
|
167
167
|
redo: () => void;
|
|
168
168
|
storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
|
|
@@ -268,7 +268,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject = {},
|
|
|
268
268
|
getMyself: () => Id<UserInfo<TIO, TPresence>> | null;
|
|
269
269
|
getOther: (connectionId: string) => Id<UserInfo<TIO, TPresence>> | null;
|
|
270
270
|
getOthers: () => readonly Id<UserInfo<TIO, TPresence>>[];
|
|
271
|
-
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey]
|
|
271
|
+
getStorage: <TKey extends keyof TStorage>(key: TKey) => TStorage[TKey];
|
|
272
272
|
other: (connectionId: string, callback: OtherNotifierSubscriptionCallback<TIO>) => (() => void);
|
|
273
273
|
redo: () => void;
|
|
274
274
|
storage: <TKey extends keyof TStorage>(key: TKey, fn: (value: InferYjsSharedTypeJson<TStorage[TKey]>) => void) => (() => void);
|
package/dist/index.js
CHANGED
|
@@ -474,8 +474,11 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
474
474
|
return this._usersManager.getOthers();
|
|
475
475
|
};
|
|
476
476
|
this.getStorage = (key) => {
|
|
477
|
-
|
|
478
|
-
|
|
477
|
+
const sharedType = this._crdtManager.get(key);
|
|
478
|
+
if (typeof sharedType === "undefined") {
|
|
479
|
+
throw new Error(`Could not find storege: ${key.toString()}`);
|
|
480
|
+
}
|
|
481
|
+
return sharedType;
|
|
479
482
|
};
|
|
480
483
|
this.other = (connectionId, callback) => {
|
|
481
484
|
return this._otherNotifier.subscribe(connectionId, callback);
|
|
@@ -612,7 +615,6 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
612
615
|
}
|
|
613
616
|
disconnect() {
|
|
614
617
|
return __async(this, null, function* () {
|
|
615
|
-
var _a;
|
|
616
618
|
if (!this._endpoints.wsEndpoint) {
|
|
617
619
|
throw new Error("Must provide an wsEndpoint.");
|
|
618
620
|
}
|
|
@@ -627,7 +629,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
627
629
|
this._clearInterval(this._intervals.heartbeat);
|
|
628
630
|
this._closeWs();
|
|
629
631
|
yield this._storageStore.destroy();
|
|
630
|
-
|
|
632
|
+
this._crdtManager.destroy();
|
|
631
633
|
this._stateNotifier.subjects["my-presence"].next(null);
|
|
632
634
|
});
|
|
633
635
|
}
|
|
@@ -892,7 +894,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
892
894
|
this._stateNotifier.subjects["others"].next(others);
|
|
893
895
|
}
|
|
894
896
|
_handleRegisteredMessage(message) {
|
|
895
|
-
var _a, _b
|
|
897
|
+
var _a, _b;
|
|
896
898
|
const { connectionId, user } = message;
|
|
897
899
|
if (!connectionId)
|
|
898
900
|
return;
|
|
@@ -912,7 +914,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
912
914
|
const myself = (_a = this._usersManager.myself) != null ? _a : null;
|
|
913
915
|
this._stateNotifier.subjects["my-presence"].next(presence);
|
|
914
916
|
this._stateNotifier.subjects["myself"].next(myself);
|
|
915
|
-
const update = this._state.connection.count > 1 ? (
|
|
917
|
+
const update = this._state.connection.count > 1 ? (_b = this._crdtManager.doc.encodeStateAsUpdate()) != null ? _b : null : null;
|
|
916
918
|
this._sendMessage({
|
|
917
919
|
type: "$INITIALIZE_SESSION",
|
|
918
920
|
data: { presence, update }
|
|
@@ -1295,7 +1297,6 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1295
1297
|
constructor(room, options) {
|
|
1296
1298
|
const { events, initialPresence, initialStorage, presence } = options;
|
|
1297
1299
|
super(room);
|
|
1298
|
-
this._crdtManager = null;
|
|
1299
1300
|
this._crdtNotifier = new CrdtNotifier();
|
|
1300
1301
|
this._eventNotifier = new EventNotifier();
|
|
1301
1302
|
this._otherNotifier = new OtherNotifier();
|
|
@@ -1316,12 +1317,10 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1316
1317
|
observeCrdt: null
|
|
1317
1318
|
};
|
|
1318
1319
|
this.canRedo = () => {
|
|
1319
|
-
|
|
1320
|
-
return !!((_a = this._crdtManager) == null ? void 0 : _a.doc.canRedo());
|
|
1320
|
+
return !!this._crdtManager.doc.canRedo();
|
|
1321
1321
|
};
|
|
1322
1322
|
this.canUndo = () => {
|
|
1323
|
-
|
|
1324
|
-
return !!((_a = this._crdtManager) == null ? void 0 : _a.doc.canUndo());
|
|
1323
|
+
return !!this._crdtManager.doc.canUndo();
|
|
1325
1324
|
};
|
|
1326
1325
|
this.event = (event, callback) => {
|
|
1327
1326
|
return this._eventNotifier.subscribe(event, callback);
|
|
@@ -1339,15 +1338,17 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1339
1338
|
return this._usersManager.getOthers();
|
|
1340
1339
|
};
|
|
1341
1340
|
this.getStorage = (key) => {
|
|
1342
|
-
|
|
1343
|
-
|
|
1341
|
+
const sharedType = this._crdtManager.get(key);
|
|
1342
|
+
if (typeof sharedType === "undefined") {
|
|
1343
|
+
throw new Error(`Could not find storege: ${key.toString()}`);
|
|
1344
|
+
}
|
|
1345
|
+
return sharedType;
|
|
1344
1346
|
};
|
|
1345
1347
|
this.other = (connectionId, callback) => {
|
|
1346
1348
|
return this._otherNotifier.subscribe(connectionId, callback);
|
|
1347
1349
|
};
|
|
1348
1350
|
this.redo = () => {
|
|
1349
|
-
|
|
1350
|
-
(_a = this._crdtManager) == null ? void 0 : _a.doc.redo();
|
|
1351
|
+
this._crdtManager.doc.redo();
|
|
1351
1352
|
};
|
|
1352
1353
|
this.storage = (key, fn) => {
|
|
1353
1354
|
return this._crdtNotifier.subscribe(key, fn);
|
|
@@ -1370,8 +1371,7 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1370
1371
|
}, _origin);
|
|
1371
1372
|
};
|
|
1372
1373
|
this.undo = () => {
|
|
1373
|
-
|
|
1374
|
-
(_a = this._crdtManager) == null ? void 0 : _a.doc.undo();
|
|
1374
|
+
this._crdtManager.doc.undo();
|
|
1375
1375
|
};
|
|
1376
1376
|
this.updateMyPresence = (presence) => {
|
|
1377
1377
|
var _a;
|
package/dist/index.mjs
CHANGED
|
@@ -448,8 +448,11 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
448
448
|
return this._usersManager.getOthers();
|
|
449
449
|
};
|
|
450
450
|
this.getStorage = (key) => {
|
|
451
|
-
|
|
452
|
-
|
|
451
|
+
const sharedType = this._crdtManager.get(key);
|
|
452
|
+
if (typeof sharedType === "undefined") {
|
|
453
|
+
throw new Error(`Could not find storege: ${key.toString()}`);
|
|
454
|
+
}
|
|
455
|
+
return sharedType;
|
|
453
456
|
};
|
|
454
457
|
this.other = (connectionId, callback) => {
|
|
455
458
|
return this._otherNotifier.subscribe(connectionId, callback);
|
|
@@ -586,7 +589,6 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
586
589
|
}
|
|
587
590
|
disconnect() {
|
|
588
591
|
return __async(this, null, function* () {
|
|
589
|
-
var _a;
|
|
590
592
|
if (!this._endpoints.wsEndpoint) {
|
|
591
593
|
throw new Error("Must provide an wsEndpoint.");
|
|
592
594
|
}
|
|
@@ -601,7 +603,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
601
603
|
this._clearInterval(this._intervals.heartbeat);
|
|
602
604
|
this._closeWs();
|
|
603
605
|
yield this._storageStore.destroy();
|
|
604
|
-
|
|
606
|
+
this._crdtManager.destroy();
|
|
605
607
|
this._stateNotifier.subjects["my-presence"].next(null);
|
|
606
608
|
});
|
|
607
609
|
}
|
|
@@ -866,7 +868,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
866
868
|
this._stateNotifier.subjects["others"].next(others);
|
|
867
869
|
}
|
|
868
870
|
_handleRegisteredMessage(message) {
|
|
869
|
-
var _a, _b
|
|
871
|
+
var _a, _b;
|
|
870
872
|
const { connectionId, user } = message;
|
|
871
873
|
if (!connectionId)
|
|
872
874
|
return;
|
|
@@ -886,7 +888,7 @@ var PluvRoom = class extends AbstractRoom {
|
|
|
886
888
|
const myself = (_a = this._usersManager.myself) != null ? _a : null;
|
|
887
889
|
this._stateNotifier.subjects["my-presence"].next(presence);
|
|
888
890
|
this._stateNotifier.subjects["myself"].next(myself);
|
|
889
|
-
const update = this._state.connection.count > 1 ? (
|
|
891
|
+
const update = this._state.connection.count > 1 ? (_b = this._crdtManager.doc.encodeStateAsUpdate()) != null ? _b : null : null;
|
|
890
892
|
this._sendMessage({
|
|
891
893
|
type: "$INITIALIZE_SESSION",
|
|
892
894
|
data: { presence, update }
|
|
@@ -1269,7 +1271,6 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1269
1271
|
constructor(room, options) {
|
|
1270
1272
|
const { events, initialPresence, initialStorage, presence } = options;
|
|
1271
1273
|
super(room);
|
|
1272
|
-
this._crdtManager = null;
|
|
1273
1274
|
this._crdtNotifier = new CrdtNotifier();
|
|
1274
1275
|
this._eventNotifier = new EventNotifier();
|
|
1275
1276
|
this._otherNotifier = new OtherNotifier();
|
|
@@ -1290,12 +1291,10 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1290
1291
|
observeCrdt: null
|
|
1291
1292
|
};
|
|
1292
1293
|
this.canRedo = () => {
|
|
1293
|
-
|
|
1294
|
-
return !!((_a = this._crdtManager) == null ? void 0 : _a.doc.canRedo());
|
|
1294
|
+
return !!this._crdtManager.doc.canRedo();
|
|
1295
1295
|
};
|
|
1296
1296
|
this.canUndo = () => {
|
|
1297
|
-
|
|
1298
|
-
return !!((_a = this._crdtManager) == null ? void 0 : _a.doc.canUndo());
|
|
1297
|
+
return !!this._crdtManager.doc.canUndo();
|
|
1299
1298
|
};
|
|
1300
1299
|
this.event = (event, callback) => {
|
|
1301
1300
|
return this._eventNotifier.subscribe(event, callback);
|
|
@@ -1313,15 +1312,17 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1313
1312
|
return this._usersManager.getOthers();
|
|
1314
1313
|
};
|
|
1315
1314
|
this.getStorage = (key) => {
|
|
1316
|
-
|
|
1317
|
-
|
|
1315
|
+
const sharedType = this._crdtManager.get(key);
|
|
1316
|
+
if (typeof sharedType === "undefined") {
|
|
1317
|
+
throw new Error(`Could not find storege: ${key.toString()}`);
|
|
1318
|
+
}
|
|
1319
|
+
return sharedType;
|
|
1318
1320
|
};
|
|
1319
1321
|
this.other = (connectionId, callback) => {
|
|
1320
1322
|
return this._otherNotifier.subscribe(connectionId, callback);
|
|
1321
1323
|
};
|
|
1322
1324
|
this.redo = () => {
|
|
1323
|
-
|
|
1324
|
-
(_a = this._crdtManager) == null ? void 0 : _a.doc.redo();
|
|
1325
|
+
this._crdtManager.doc.redo();
|
|
1325
1326
|
};
|
|
1326
1327
|
this.storage = (key, fn) => {
|
|
1327
1328
|
return this._crdtNotifier.subscribe(key, fn);
|
|
@@ -1344,8 +1345,7 @@ var MockedRoom = class extends AbstractRoom {
|
|
|
1344
1345
|
}, _origin);
|
|
1345
1346
|
};
|
|
1346
1347
|
this.undo = () => {
|
|
1347
|
-
|
|
1348
|
-
(_a = this._crdtManager) == null ? void 0 : _a.doc.undo();
|
|
1348
|
+
this._crdtManager.doc.undo();
|
|
1349
1349
|
};
|
|
1350
1350
|
this.updateMyPresence = (presence) => {
|
|
1351
1351
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluv/client",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "@pluv/io frontend client",
|
|
5
5
|
"author": "leedavidcs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"wonka": "^6.3.4",
|
|
21
|
-
"@pluv/crdt-yjs": "^0.12.
|
|
22
|
-
"@pluv/types": "^0.12.
|
|
21
|
+
"@pluv/crdt-yjs": "^0.12.1",
|
|
22
|
+
"@pluv/types": "^0.12.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"yjs": "^13.0.0"
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"tsup": "^7.2.0",
|
|
30
30
|
"typescript": "^5.2.2",
|
|
31
31
|
"yjs": "^13.6.8",
|
|
32
|
-
"@pluv/tsconfig": "^0.12.
|
|
33
|
-
"eslint-config-pluv": "^0.12.
|
|
32
|
+
"@pluv/tsconfig": "^0.12.1",
|
|
33
|
+
"eslint-config-pluv": "^0.12.1"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|
package/src/AbstractRoom.ts
CHANGED
package/src/MockedRoom.ts
CHANGED
|
@@ -50,7 +50,7 @@ export class MockedRoom<
|
|
|
50
50
|
TPresence extends JsonObject = {},
|
|
51
51
|
TStorage extends Record<string, AbstractType<any>> = {},
|
|
52
52
|
> extends AbstractRoom<TIO, TPresence, TStorage> {
|
|
53
|
-
private _crdtManager: CrdtManager<TStorage
|
|
53
|
+
private _crdtManager: CrdtManager<TStorage>;
|
|
54
54
|
private _crdtNotifier = new CrdtNotifier<TStorage>();
|
|
55
55
|
private _eventNotifier = new EventNotifier<TIO>();
|
|
56
56
|
private _events?: MockedRoomEvents<TIO>;
|
|
@@ -118,11 +118,11 @@ export class MockedRoom<
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
public canRedo = (): boolean => {
|
|
121
|
-
return !!this._crdtManager
|
|
121
|
+
return !!this._crdtManager.doc.canRedo();
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
public canUndo = (): boolean => {
|
|
125
|
-
return !!this._crdtManager
|
|
125
|
+
return !!this._crdtManager.doc.canUndo();
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
public event = <TEvent extends keyof InferIOOutput<TIO>>(
|
|
@@ -159,8 +159,14 @@ export class MockedRoom<
|
|
|
159
159
|
|
|
160
160
|
public getStorage = <TKey extends keyof TStorage>(
|
|
161
161
|
key: TKey,
|
|
162
|
-
): TStorage[TKey]
|
|
163
|
-
|
|
162
|
+
): TStorage[TKey] => {
|
|
163
|
+
const sharedType = this._crdtManager.get(key);
|
|
164
|
+
|
|
165
|
+
if (typeof sharedType === "undefined") {
|
|
166
|
+
throw new Error(`Could not find storege: ${key.toString()}`);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return sharedType;
|
|
164
170
|
};
|
|
165
171
|
|
|
166
172
|
public other = (
|
|
@@ -171,7 +177,7 @@ export class MockedRoom<
|
|
|
171
177
|
};
|
|
172
178
|
|
|
173
179
|
public redo = (): void => {
|
|
174
|
-
this._crdtManager
|
|
180
|
+
this._crdtManager.doc.redo();
|
|
175
181
|
};
|
|
176
182
|
|
|
177
183
|
public storage = <TKey extends keyof TStorage>(
|
|
@@ -221,7 +227,7 @@ export class MockedRoom<
|
|
|
221
227
|
};
|
|
222
228
|
|
|
223
229
|
public undo = (): void => {
|
|
224
|
-
this._crdtManager
|
|
230
|
+
this._crdtManager.doc.undo();
|
|
225
231
|
};
|
|
226
232
|
|
|
227
233
|
public updateMyPresence = (presence: Partial<TPresence>): void => {
|
package/src/PluvRoom.ts
CHANGED
|
@@ -345,7 +345,7 @@ export class PluvRoom<
|
|
|
345
345
|
|
|
346
346
|
await this._storageStore.destroy();
|
|
347
347
|
|
|
348
|
-
this._crdtManager
|
|
348
|
+
this._crdtManager.destroy();
|
|
349
349
|
|
|
350
350
|
this._stateNotifier.subjects["my-presence"].next(null);
|
|
351
351
|
}
|
|
@@ -384,8 +384,14 @@ export class PluvRoom<
|
|
|
384
384
|
|
|
385
385
|
public getStorage = <TKey extends keyof TStorage>(
|
|
386
386
|
key: TKey,
|
|
387
|
-
): TStorage[TKey]
|
|
388
|
-
|
|
387
|
+
): TStorage[TKey] => {
|
|
388
|
+
const sharedType = this._crdtManager.get(key);
|
|
389
|
+
|
|
390
|
+
if (typeof sharedType === "undefined") {
|
|
391
|
+
throw new Error(`Could not find storege: ${key.toString()}`);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return sharedType;
|
|
389
395
|
};
|
|
390
396
|
|
|
391
397
|
public other = (
|
|
@@ -826,7 +832,7 @@ export class PluvRoom<
|
|
|
826
832
|
|
|
827
833
|
const update =
|
|
828
834
|
this._state.connection.count > 1
|
|
829
|
-
? this._crdtManager
|
|
835
|
+
? this._crdtManager.doc.encodeStateAsUpdate() ?? null
|
|
830
836
|
: null;
|
|
831
837
|
|
|
832
838
|
this._sendMessage({
|