@pluv/client 2.3.1 → 3.1.0

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
@@ -663,17 +663,6 @@ var PluvRoom = class {
663
663
  this.canUndo = () => {
664
664
  return !!this._crdtManager.doc.canUndo();
665
665
  };
666
- /**
667
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.event instead
668
- */
669
- this.event = new Proxy(
670
- (event, callback) => this._eventNotifier.subscribe(event, callback),
671
- {
672
- get(fn, prop) {
673
- return (callback) => fn(prop, callback);
674
- }
675
- }
676
- );
677
666
  this.getConnection = () => {
678
667
  return Object.freeze(JSON.parse(JSON.stringify(this._state.connection)));
679
668
  };
@@ -700,42 +689,9 @@ var PluvRoom = class {
700
689
  this.getStorageLoaded = () => {
701
690
  return this._state.storage.state === import_types.StorageState.Offline || this._state.storage.state === import_types.StorageState.Synced;
702
691
  };
703
- /**
704
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.other instead
705
- */
706
- this.other = (connectionId, callback) => {
707
- const clientId = this._usersManager.getClientId(connectionId);
708
- if (!clientId) return () => void 0;
709
- return this._usersNotifier.subscribeOther(clientId, callback);
710
- };
711
692
  this.redo = () => {
712
693
  this._crdtManager.doc.redo();
713
694
  };
714
- /**
715
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.storage instead
716
- */
717
- this.storage = new Proxy(
718
- (key, callback) => this._crdtNotifier.subscribe(key, callback),
719
- {
720
- get: (fn, prop) => {
721
- if (!!prop) {
722
- return (callback) => {
723
- return this._crdtNotifier.subcribeRoot(callback);
724
- };
725
- }
726
- return (callback) => {
727
- return fn(prop, callback);
728
- };
729
- }
730
- }
731
- );
732
- /**
733
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.storage instead
734
- * @description Subscribes to the root storage object (serialized)
735
- */
736
- this.storageRoot = (callback) => {
737
- return this._crdtNotifier.subcribeRoot(callback);
738
- };
739
695
  this.subscribe = new Proxy(
740
696
  (name, callback) => this._stateNotifier.subscribe(name, callback),
741
697
  {
@@ -765,9 +721,9 @@ var PluvRoom = class {
765
721
  return fn("storage-loaded", callback);
766
722
  };
767
723
  }
768
- if (prop === "event") return this.event;
769
- if (prop === "other") return this.other;
770
- if (prop === "storage") return this.storage;
724
+ if (prop === "event") return this._event;
725
+ if (prop === "other") return this._other;
726
+ if (prop === "storage") return this._storage;
771
727
  }
772
728
  }
773
729
  );
@@ -795,6 +751,14 @@ var PluvRoom = class {
795
751
  { presence: newPresence }
796
752
  );
797
753
  };
754
+ this._event = new Proxy(
755
+ (event, callback) => this._eventNotifier.subscribe(event, callback),
756
+ {
757
+ get(fn, prop) {
758
+ return (callback) => fn(prop, callback);
759
+ }
760
+ }
761
+ );
798
762
  this._flattenStorageStore = debounce(
799
763
  () => __async(this, null, function* () {
800
764
  const shouldFlatten = yield this._storageStore.getShouldFlatten();
@@ -812,6 +776,26 @@ var PluvRoom = class {
812
776
  DEFAULT_PLUV_CLIENT_ADDON
813
777
  );
814
778
  };
779
+ this._other = (connectionId, callback) => {
780
+ const clientId = this._usersManager.getClientId(connectionId);
781
+ if (!clientId) return () => void 0;
782
+ return this._usersNotifier.subscribeOther(clientId, callback);
783
+ };
784
+ this._storage = new Proxy(
785
+ (key, callback) => this._crdtNotifier.subscribe(key, callback),
786
+ {
787
+ get: (fn, prop) => {
788
+ if (!!prop) {
789
+ return (callback) => {
790
+ return this._crdtNotifier.subcribeRoot(callback);
791
+ };
792
+ }
793
+ return (callback) => {
794
+ return fn(prop, callback);
795
+ };
796
+ }
797
+ }
798
+ );
815
799
  const {
816
800
  addons = [],
817
801
  authEndpoint,
@@ -850,12 +834,6 @@ var PluvRoom = class {
850
834
  });
851
835
  this._crdtManager = new CrdtManager({ initialStorage });
852
836
  }
853
- /**
854
- * @deprecated To be removed in v3. Use `getStorageLoaded` instead.
855
- */
856
- get storageLoaded() {
857
- return this.getStorageLoaded();
858
- }
859
837
  get webSocket() {
860
838
  return this._state.webSocket;
861
839
  }
@@ -1677,10 +1655,6 @@ var infer = (callback) => callback;
1677
1655
  var import_types2 = require("@pluv/types");
1678
1656
  var MockedRoom = class {
1679
1657
  constructor(room, options) {
1680
- /**
1681
- * @deprecated To be removed in v3. Use `getStorageLoaded` instead.
1682
- */
1683
- this.storageLoaded = true;
1684
1658
  this._crdtNotifier = new CrdtNotifier();
1685
1659
  this._eventNotifier = new EventNotifier();
1686
1660
  this._usersNotifier = new UsersNotifier();
@@ -1741,14 +1715,6 @@ var MockedRoom = class {
1741
1715
  this.canUndo = () => {
1742
1716
  return !!this._crdtManager.doc.canUndo();
1743
1717
  };
1744
- this.event = new Proxy(
1745
- (event, callback) => this._eventNotifier.subscribe(event, callback),
1746
- {
1747
- get(fn, prop) {
1748
- return (callback) => fn(prop, callback);
1749
- }
1750
- }
1751
- );
1752
1718
  this.getConnection = () => {
1753
1719
  return Object.freeze(JSON.parse(JSON.stringify(this._state.connection)));
1754
1720
  };
@@ -1769,29 +1735,9 @@ var MockedRoom = class {
1769
1735
  if (typeof sharedType === "undefined") return null;
1770
1736
  return sharedType;
1771
1737
  };
1772
- this.other = (connectionId, callback) => {
1773
- const clientId = this._usersManager.getClientId(connectionId);
1774
- if (!clientId) return () => void 0;
1775
- return this._usersNotifier.subscribeOther(clientId, callback);
1776
- };
1777
1738
  this.redo = () => {
1778
1739
  this._crdtManager.doc.redo();
1779
1740
  };
1780
- this.storage = new Proxy(
1781
- (key, callback) => this._crdtNotifier.subscribe(key, callback),
1782
- {
1783
- get: (fn, prop) => {
1784
- if (!!prop) {
1785
- return (callback) => {
1786
- return this._crdtNotifier.subcribeRoot(callback);
1787
- };
1788
- }
1789
- return (callback) => {
1790
- return fn(prop, callback);
1791
- };
1792
- }
1793
- }
1794
- );
1795
1741
  this.storageRoot = (fn) => {
1796
1742
  return this._crdtNotifier.subcribeRoot(fn);
1797
1743
  };
@@ -1826,9 +1772,9 @@ var MockedRoom = class {
1826
1772
  return fn("storage-loaded", callback);
1827
1773
  };
1828
1774
  }
1829
- if (prop === "event") return this.event;
1830
- if (prop === "other") return this.other;
1831
- if (prop === "storage") return this.storage;
1775
+ if (prop === "event") return this._event;
1776
+ if (prop === "other") return this._other;
1777
+ if (prop === "storage") return this._storage;
1832
1778
  }
1833
1779
  }
1834
1780
  );
@@ -1854,6 +1800,34 @@ var MockedRoom = class {
1854
1800
  this._stateNotifier.subjects["my-presence"].next(myPresence);
1855
1801
  if (!!myself) this._stateNotifier.subjects["myself"].next(myself);
1856
1802
  };
1803
+ this._event = new Proxy(
1804
+ (event, callback) => this._eventNotifier.subscribe(event, callback),
1805
+ {
1806
+ get(fn, prop) {
1807
+ return (callback) => fn(prop, callback);
1808
+ }
1809
+ }
1810
+ );
1811
+ this._other = (connectionId, callback) => {
1812
+ const clientId = this._usersManager.getClientId(connectionId);
1813
+ if (!clientId) return () => void 0;
1814
+ return this._usersNotifier.subscribeOther(clientId, callback);
1815
+ };
1816
+ this._storage = new Proxy(
1817
+ (key, callback) => this._crdtNotifier.subscribe(key, callback),
1818
+ {
1819
+ get: (fn, prop) => {
1820
+ if (!!prop) {
1821
+ return (callback) => {
1822
+ return this._crdtNotifier.subcribeRoot(callback);
1823
+ };
1824
+ }
1825
+ return (callback) => {
1826
+ return fn(prop, callback);
1827
+ };
1828
+ }
1829
+ }
1830
+ );
1857
1831
  const { events, initialPresence, initialStorage, limits, presence, router } = options;
1858
1832
  this.id = room;
1859
1833
  this._events = events;
package/dist/index.mjs CHANGED
@@ -635,17 +635,6 @@ var PluvRoom = class {
635
635
  this.canUndo = () => {
636
636
  return !!this._crdtManager.doc.canUndo();
637
637
  };
638
- /**
639
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.event instead
640
- */
641
- this.event = new Proxy(
642
- (event, callback) => this._eventNotifier.subscribe(event, callback),
643
- {
644
- get(fn, prop) {
645
- return (callback) => fn(prop, callback);
646
- }
647
- }
648
- );
649
638
  this.getConnection = () => {
650
639
  return Object.freeze(JSON.parse(JSON.stringify(this._state.connection)));
651
640
  };
@@ -672,42 +661,9 @@ var PluvRoom = class {
672
661
  this.getStorageLoaded = () => {
673
662
  return this._state.storage.state === StorageState.Offline || this._state.storage.state === StorageState.Synced;
674
663
  };
675
- /**
676
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.other instead
677
- */
678
- this.other = (connectionId, callback) => {
679
- const clientId = this._usersManager.getClientId(connectionId);
680
- if (!clientId) return () => void 0;
681
- return this._usersNotifier.subscribeOther(clientId, callback);
682
- };
683
664
  this.redo = () => {
684
665
  this._crdtManager.doc.redo();
685
666
  };
686
- /**
687
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.storage instead
688
- */
689
- this.storage = new Proxy(
690
- (key, callback) => this._crdtNotifier.subscribe(key, callback),
691
- {
692
- get: (fn, prop) => {
693
- if (!!prop) {
694
- return (callback) => {
695
- return this._crdtNotifier.subcribeRoot(callback);
696
- };
697
- }
698
- return (callback) => {
699
- return fn(prop, callback);
700
- };
701
- }
702
- }
703
- );
704
- /**
705
- * @deprecated To be removed in v3. Use PluvRoom.subscribe.storage instead
706
- * @description Subscribes to the root storage object (serialized)
707
- */
708
- this.storageRoot = (callback) => {
709
- return this._crdtNotifier.subcribeRoot(callback);
710
- };
711
667
  this.subscribe = new Proxy(
712
668
  (name, callback) => this._stateNotifier.subscribe(name, callback),
713
669
  {
@@ -737,9 +693,9 @@ var PluvRoom = class {
737
693
  return fn("storage-loaded", callback);
738
694
  };
739
695
  }
740
- if (prop === "event") return this.event;
741
- if (prop === "other") return this.other;
742
- if (prop === "storage") return this.storage;
696
+ if (prop === "event") return this._event;
697
+ if (prop === "other") return this._other;
698
+ if (prop === "storage") return this._storage;
743
699
  }
744
700
  }
745
701
  );
@@ -767,6 +723,14 @@ var PluvRoom = class {
767
723
  { presence: newPresence }
768
724
  );
769
725
  };
726
+ this._event = new Proxy(
727
+ (event, callback) => this._eventNotifier.subscribe(event, callback),
728
+ {
729
+ get(fn, prop) {
730
+ return (callback) => fn(prop, callback);
731
+ }
732
+ }
733
+ );
770
734
  this._flattenStorageStore = debounce(
771
735
  () => __async(this, null, function* () {
772
736
  const shouldFlatten = yield this._storageStore.getShouldFlatten();
@@ -784,6 +748,26 @@ var PluvRoom = class {
784
748
  DEFAULT_PLUV_CLIENT_ADDON
785
749
  );
786
750
  };
751
+ this._other = (connectionId, callback) => {
752
+ const clientId = this._usersManager.getClientId(connectionId);
753
+ if (!clientId) return () => void 0;
754
+ return this._usersNotifier.subscribeOther(clientId, callback);
755
+ };
756
+ this._storage = new Proxy(
757
+ (key, callback) => this._crdtNotifier.subscribe(key, callback),
758
+ {
759
+ get: (fn, prop) => {
760
+ if (!!prop) {
761
+ return (callback) => {
762
+ return this._crdtNotifier.subcribeRoot(callback);
763
+ };
764
+ }
765
+ return (callback) => {
766
+ return fn(prop, callback);
767
+ };
768
+ }
769
+ }
770
+ );
787
771
  const {
788
772
  addons = [],
789
773
  authEndpoint,
@@ -822,12 +806,6 @@ var PluvRoom = class {
822
806
  });
823
807
  this._crdtManager = new CrdtManager({ initialStorage });
824
808
  }
825
- /**
826
- * @deprecated To be removed in v3. Use `getStorageLoaded` instead.
827
- */
828
- get storageLoaded() {
829
- return this.getStorageLoaded();
830
- }
831
809
  get webSocket() {
832
810
  return this._state.webSocket;
833
811
  }
@@ -1649,10 +1627,6 @@ var infer = (callback) => callback;
1649
1627
  import { ConnectionState as ConnectionState2, StorageState as StorageState2 } from "@pluv/types";
1650
1628
  var MockedRoom = class {
1651
1629
  constructor(room, options) {
1652
- /**
1653
- * @deprecated To be removed in v3. Use `getStorageLoaded` instead.
1654
- */
1655
- this.storageLoaded = true;
1656
1630
  this._crdtNotifier = new CrdtNotifier();
1657
1631
  this._eventNotifier = new EventNotifier();
1658
1632
  this._usersNotifier = new UsersNotifier();
@@ -1713,14 +1687,6 @@ var MockedRoom = class {
1713
1687
  this.canUndo = () => {
1714
1688
  return !!this._crdtManager.doc.canUndo();
1715
1689
  };
1716
- this.event = new Proxy(
1717
- (event, callback) => this._eventNotifier.subscribe(event, callback),
1718
- {
1719
- get(fn, prop) {
1720
- return (callback) => fn(prop, callback);
1721
- }
1722
- }
1723
- );
1724
1690
  this.getConnection = () => {
1725
1691
  return Object.freeze(JSON.parse(JSON.stringify(this._state.connection)));
1726
1692
  };
@@ -1741,29 +1707,9 @@ var MockedRoom = class {
1741
1707
  if (typeof sharedType === "undefined") return null;
1742
1708
  return sharedType;
1743
1709
  };
1744
- this.other = (connectionId, callback) => {
1745
- const clientId = this._usersManager.getClientId(connectionId);
1746
- if (!clientId) return () => void 0;
1747
- return this._usersNotifier.subscribeOther(clientId, callback);
1748
- };
1749
1710
  this.redo = () => {
1750
1711
  this._crdtManager.doc.redo();
1751
1712
  };
1752
- this.storage = new Proxy(
1753
- (key, callback) => this._crdtNotifier.subscribe(key, callback),
1754
- {
1755
- get: (fn, prop) => {
1756
- if (!!prop) {
1757
- return (callback) => {
1758
- return this._crdtNotifier.subcribeRoot(callback);
1759
- };
1760
- }
1761
- return (callback) => {
1762
- return fn(prop, callback);
1763
- };
1764
- }
1765
- }
1766
- );
1767
1713
  this.storageRoot = (fn) => {
1768
1714
  return this._crdtNotifier.subcribeRoot(fn);
1769
1715
  };
@@ -1798,9 +1744,9 @@ var MockedRoom = class {
1798
1744
  return fn("storage-loaded", callback);
1799
1745
  };
1800
1746
  }
1801
- if (prop === "event") return this.event;
1802
- if (prop === "other") return this.other;
1803
- if (prop === "storage") return this.storage;
1747
+ if (prop === "event") return this._event;
1748
+ if (prop === "other") return this._other;
1749
+ if (prop === "storage") return this._storage;
1804
1750
  }
1805
1751
  }
1806
1752
  );
@@ -1826,6 +1772,34 @@ var MockedRoom = class {
1826
1772
  this._stateNotifier.subjects["my-presence"].next(myPresence);
1827
1773
  if (!!myself) this._stateNotifier.subjects["myself"].next(myself);
1828
1774
  };
1775
+ this._event = new Proxy(
1776
+ (event, callback) => this._eventNotifier.subscribe(event, callback),
1777
+ {
1778
+ get(fn, prop) {
1779
+ return (callback) => fn(prop, callback);
1780
+ }
1781
+ }
1782
+ );
1783
+ this._other = (connectionId, callback) => {
1784
+ const clientId = this._usersManager.getClientId(connectionId);
1785
+ if (!clientId) return () => void 0;
1786
+ return this._usersNotifier.subscribeOther(clientId, callback);
1787
+ };
1788
+ this._storage = new Proxy(
1789
+ (key, callback) => this._crdtNotifier.subscribe(key, callback),
1790
+ {
1791
+ get: (fn, prop) => {
1792
+ if (!!prop) {
1793
+ return (callback) => {
1794
+ return this._crdtNotifier.subcribeRoot(callback);
1795
+ };
1796
+ }
1797
+ return (callback) => {
1798
+ return fn(prop, callback);
1799
+ };
1800
+ }
1801
+ }
1802
+ );
1829
1803
  const { events, initialPresence, initialStorage, limits, presence, router } = options;
1830
1804
  this.id = room;
1831
1805
  this._events = events;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/client",
3
- "version": "2.3.1",
3
+ "version": "3.1.0",
4
4
  "description": "@pluv/io frontend client",
5
5
  "author": "leedavidcs",
6
6
  "license": "MIT",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "wonka": "^6.3.5",
21
- "@pluv/crdt": "^2.3.1",
22
- "@pluv/types": "^2.3.1"
21
+ "@pluv/crdt": "^3.1.0",
22
+ "@pluv/types": "^3.1.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "eslint": "^9.27.0",
26
26
  "tsup": "^8.5.0",
27
27
  "typescript": "^5.8.3",
28
- "@pluv/tsconfig": "^2.3.1",
29
- "eslint-config-pluv": "^2.3.1"
28
+ "@pluv/tsconfig": "^3.1.0",
29
+ "eslint-config-pluv": "^3.1.0"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tsup src/index.ts --format esm,cjs --dts",
package/src/MockedRoom.ts CHANGED
@@ -75,11 +75,6 @@ export class MockedRoom<
75
75
  {
76
76
  public readonly id: string;
77
77
 
78
- /**
79
- * @deprecated To be removed in v3. Use `getStorageLoaded` instead.
80
- */
81
- public readonly storageLoaded: boolean = true;
82
-
83
78
  private readonly _crdtManager: CrdtManager<TCrdt>;
84
79
  private readonly _crdtNotifier = new CrdtNotifier<InferStorage<TCrdt>>();
85
80
  private readonly _eventNotifier = new EventNotifier<MergeEvents<TEvents, TIO>>();
@@ -211,20 +206,6 @@ export class MockedRoom<
211
206
  return !!this._crdtManager.doc.canUndo();
212
207
  };
213
208
 
214
- public event = new Proxy(
215
- <TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(
216
- event: TEvent,
217
- callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, any>,
218
- ): (() => void) => this._eventNotifier.subscribe(event, callback),
219
- {
220
- get(fn, prop) {
221
- return (
222
- callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, any>,
223
- ): (() => void) => fn(prop as any, callback);
224
- },
225
- },
226
- ) as EventProxy<TIO, TEvents>;
227
-
228
209
  public getConnection = (): WebSocketConnection => {
229
210
  // Create a read-only clone of the connection state
230
211
  return Object.freeze(JSON.parse(JSON.stringify(this._state.connection)));
@@ -275,43 +256,10 @@ export class MockedRoom<
275
256
  return true;
276
257
  }
277
258
 
278
- public other = (
279
- connectionId: string,
280
- callback: OtherSubscriptionCallback<TIO, TPresence>,
281
- ): (() => void) => {
282
- const clientId = this._usersManager.getClientId(connectionId);
283
-
284
- if (!clientId) return () => undefined;
285
-
286
- return this._usersNotifier.subscribeOther(clientId, callback);
287
- };
288
-
289
259
  public redo = (): void => {
290
260
  this._crdtManager.doc.redo();
291
261
  };
292
262
 
293
- public storage = new Proxy(
294
- <TKey extends keyof InferStorage<TCrdt>>(
295
- key: TKey,
296
- callback: StorageSubscriptionCallback<InferStorage<TCrdt>, TKey>,
297
- ): (() => void) => this._crdtNotifier.subscribe(key, callback),
298
- {
299
- get: (fn, prop) => {
300
- type _Storage = InferStorage<TCrdt>;
301
-
302
- if (!!prop) {
303
- return (callback: StorageRootSubscriptionCallback<_Storage>) => {
304
- return this._crdtNotifier.subcribeRoot(callback);
305
- };
306
- }
307
-
308
- return (callback: StorageSubscriptionCallback<_Storage, keyof _Storage>) => {
309
- return fn(prop as keyof InferStorage<TCrdt>, callback);
310
- };
311
- },
312
- },
313
- ) as StorageProxy<InferStorage<TCrdt>>;
314
-
315
263
  public storageRoot = (
316
264
  fn: (value: {
317
265
  [P in keyof InferStorage<TCrdt>]: InferCrdtJson<InferStorage<TCrdt>[P]>;
@@ -359,9 +307,9 @@ export class MockedRoom<
359
307
  };
360
308
  }
361
309
 
362
- if (prop === "event") return this.event;
363
- if (prop === "other") return this.other;
364
- if (prop === "storage") return this.storage;
310
+ if (prop === "event") return this._event;
311
+ if (prop === "other") return this._other;
312
+ if (prop === "storage") return this._storage;
365
313
  },
366
314
  },
367
315
  ) as SubscribeProxy<TIO, TPresence, InferStorage<TCrdt>, TEvents>;
@@ -404,6 +352,20 @@ export class MockedRoom<
404
352
  if (!!myself) this._stateNotifier.subjects["myself"].next(myself);
405
353
  };
406
354
 
355
+ private _event = new Proxy(
356
+ <TEvent extends keyof InferIOOutput<MergeEvents<TEvents, TIO>>>(
357
+ event: TEvent,
358
+ callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, any>,
359
+ ): (() => void) => this._eventNotifier.subscribe(event, callback),
360
+ {
361
+ get(fn, prop) {
362
+ return (
363
+ callback: EventNotifierSubscriptionCallback<MergeEvents<TEvents, TIO>, any>,
364
+ ): (() => void) => fn(prop as any, callback);
365
+ },
366
+ },
367
+ ) as EventProxy<TIO, TEvents>;
368
+
407
369
  private _observeCrdt(): void {
408
370
  this._subscriptions.observeCrdt?.();
409
371
 
@@ -438,6 +400,17 @@ export class MockedRoom<
438
400
  this._subscriptions.observeCrdt = unsubscribe;
439
401
  }
440
402
 
403
+ private _other = (
404
+ connectionId: string,
405
+ callback: OtherSubscriptionCallback<TIO, TPresence>,
406
+ ): (() => void) => {
407
+ const clientId = this._usersManager.getClientId(connectionId);
408
+
409
+ if (!clientId) return () => undefined;
410
+
411
+ return this._usersNotifier.subscribeOther(clientId, callback);
412
+ };
413
+
441
414
  private _simulateEvent<TEvent extends keyof InferIOInput<MergeEvents<TEvents, TIO>>>(
442
415
  event: TEvent,
443
416
  data: Id<InferIOInput<MergeEvents<TEvents, TIO>>[TEvent]>,
@@ -460,4 +433,26 @@ export class MockedRoom<
460
433
  this._eventNotifier.subject(_type).next(data);
461
434
  });
462
435
  }
436
+
437
+ private _storage = new Proxy(
438
+ <TKey extends keyof InferStorage<TCrdt>>(
439
+ key: TKey,
440
+ callback: StorageSubscriptionCallback<InferStorage<TCrdt>, TKey>,
441
+ ): (() => void) => this._crdtNotifier.subscribe(key, callback),
442
+ {
443
+ get: (fn, prop) => {
444
+ type _Storage = InferStorage<TCrdt>;
445
+
446
+ if (!!prop) {
447
+ return (callback: StorageRootSubscriptionCallback<_Storage>) => {
448
+ return this._crdtNotifier.subcribeRoot(callback);
449
+ };
450
+ }
451
+
452
+ return (callback: StorageSubscriptionCallback<_Storage, keyof _Storage>) => {
453
+ return fn(prop as keyof InferStorage<TCrdt>, callback);
454
+ };
455
+ },
456
+ },
457
+ ) as StorageProxy<InferStorage<TCrdt>>;
463
458
  }