@pluv/client 2.0.1 → 2.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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +104 -0
- package/dist/index.d.mts +27 -25
- package/dist/index.d.ts +27 -25
- package/dist/index.js +214 -68
- package/dist/index.mjs +214 -68
- package/package.json +6 -6
- package/src/CrdtNotifier.ts +2 -1
- package/src/MockedRoom.ts +83 -33
- package/src/PluvRoom.ts +160 -58
- package/src/StateNotifier.ts +11 -17
- package/src/UsersNotifier.ts +66 -0
- package/src/OtherNotifier.ts +0 -50
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @pluv/client@2.0
|
|
2
|
+
> @pluv/client@2.1.0 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
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
12
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mCJS[39m ⚡️ Build success in
|
|
11
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m61.64 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 102ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m63.17 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 108ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 4639ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m20.08 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m20.08 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,109 @@
|
|
|
1
1
|
# @pluv/client
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e8d8fbc: **DEPRECATED** Subscribing to data via string parameters on `PluvRoom.subscribe` is deprecated, to be removed in v3. To subscribe to things such as `myself`, `my-presence` and `others`, you must now do so via nested properties on the `subscribe` object (see example below).
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const room = client.createRoom("example-room");
|
|
11
|
+
|
|
12
|
+
// Before (now deprecated)
|
|
13
|
+
room.subscribe("connection", (state) => {});
|
|
14
|
+
room.subscribe("my-presence", (myPresence) => {});
|
|
15
|
+
room.subscribe("myself", (myself) => {});
|
|
16
|
+
room.subscribe("others", (others) => {});
|
|
17
|
+
room.subscribe("storage-loaded", (storageLoaded) => {});
|
|
18
|
+
|
|
19
|
+
// After
|
|
20
|
+
room.subscribe.connection((state) => {});
|
|
21
|
+
room.subscribe.myPresence((myPresence) => {});
|
|
22
|
+
room.subscribe.myself((myself) => {});
|
|
23
|
+
room.subscribe.others((others) => {});
|
|
24
|
+
room.subscribe.storageLoaded((storageLoaded) => {});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- d5ac29e: **DEPRECATED** `PluvRoom.event`, `PluvRoom.storage`, `PluvRoom.storageRoot` and `PluvRoom.other` have all been deprecated, to be removed in v3. These now exist under `PluvRoom.subscribe` instead.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const room = client.createRoom("example-room");
|
|
31
|
+
|
|
32
|
+
// Before (now deprecated)
|
|
33
|
+
room.event.receiveMessage((event) => {});
|
|
34
|
+
room.storage.messages((messages) => {});
|
|
35
|
+
room.storageRoot((storage) => {});
|
|
36
|
+
room.other(("id_...", other) => {});
|
|
37
|
+
|
|
38
|
+
// After
|
|
39
|
+
room.subscribe.event.receiveMessage((event) => {});
|
|
40
|
+
room.subscribe.storage.messages((messages) => {});
|
|
41
|
+
room.subscribe.storageRoot((storage) => {});
|
|
42
|
+
room.subscribe.other(("id_...", other) => {});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- 5ca5cb6: Updated `PluvRoom.storage` to also allow subscribing to storage fields as nested properties.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const client = createClient({
|
|
49
|
+
// ...
|
|
50
|
+
initialStorage: yjs.doc((t) => ({
|
|
51
|
+
messages: yjs.array<string>(),
|
|
52
|
+
})),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const room = client.createRoom("example-room");
|
|
56
|
+
|
|
57
|
+
// The two statements below are equivalent.
|
|
58
|
+
room.storage("messages", (value) => {});
|
|
59
|
+
|
|
60
|
+
// You can now subscribe to storage fields as nested properties like so
|
|
61
|
+
room.storage.messages((value) => {});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- 4acbe1e: Updated `PluvRoom.storage` to also allow subscribing to the root storage when no field is provided.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
const client = createClient({
|
|
68
|
+
// ...
|
|
69
|
+
initialStorage: yjs.doc((t) => ({
|
|
70
|
+
messages: yjs.array<string>(),
|
|
71
|
+
})),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const room = client.createRoom("example-room");
|
|
75
|
+
|
|
76
|
+
room.storage("messages", (value) => {});
|
|
77
|
+
// ^? const value: string[];
|
|
78
|
+
|
|
79
|
+
// You can now subscribe to the storage root when no key is provided
|
|
80
|
+
room.storage((value) => {});
|
|
81
|
+
// ^? const value: { messages: string[] };
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- e8d8fbc: Updated `PluvRoom.subscribe` so that `PluvRoom.event` and `PluvRoom.storage` can be accessed as properties under `PluvRoom.subscribe`.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const room = client.createRoom("example-room");
|
|
88
|
+
|
|
89
|
+
// These are now available under the subscribe object
|
|
90
|
+
room.subscribe.event.receiveEvent((event) => {});
|
|
91
|
+
room.subscribe.storage.messages((data) => {});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- a86ff5e: Updated internal types to simplify the type for `PluvRoom.broadcast` and `PluvRoom.event`.
|
|
97
|
+
- @pluv/crdt@2.1.0
|
|
98
|
+
- @pluv/types@2.1.0
|
|
99
|
+
|
|
100
|
+
## 2.0.2
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- @pluv/crdt@2.0.2
|
|
105
|
+
- @pluv/types@2.0.2
|
|
106
|
+
|
|
3
107
|
## 2.0.1
|
|
4
108
|
|
|
5
109
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CrdtType, AbstractCrdtDocFactory, NoopCrdtDocFactory, InferStorage, InferCrdtJson } from '@pluv/crdt';
|
|
2
2
|
export { CrdtType, InferCrdtJson } from '@pluv/crdt';
|
|
3
|
-
import { IOLike, JsonObject, EventRecord, CrdtDocLike, UserInfo, MaybePromise, Id, ConnectionState, ProcedureLike, InputZodLike, IORouterLike,
|
|
3
|
+
import { IOLike, JsonObject, EventRecord, CrdtDocLike, UserInfo, MaybePromise, Id, ConnectionState, ProcedureLike, InputZodLike, IORouterLike, InferIOAuthorizeUser, InferIOAuthorize, BaseUser, RoomLike, InferIOOutput, InferIOInput, BroadcastProxy, EventProxy, OtherSubscriptionCallback, StorageProxy, SubscribeProxy, UpdateMyPresenceAction, MergeEvents } from '@pluv/types';
|
|
4
4
|
export { BaseUser, ConnectionState, EventMessage, EventNotifierSubscriptionCallback, EventRecord, IOEventMessage, MergeEvents, RoomLike, UserInfo, WebSocketState } from '@pluv/types';
|
|
5
|
-
import { Subject } from 'wonka';
|
|
6
5
|
|
|
7
6
|
declare abstract class AbstractStorageStore {
|
|
8
7
|
room: string;
|
|
@@ -104,16 +103,6 @@ declare class PluvRouter<TIO extends IOLike = IOLike, TPresence extends JsonObje
|
|
|
104
103
|
private _isValidEventName;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
interface StateNotifierSubjects<TIO extends IOLike, TPresence extends JsonObject> {
|
|
108
|
-
connection: Subject<Id<WebSocketState<TIO>>>;
|
|
109
|
-
"my-presence": Subject<TPresence | null>;
|
|
110
|
-
myself: Subject<Readonly<Id<UserInfo<TIO>>> | null>;
|
|
111
|
-
others: Subject<readonly Id<UserInfo<TIO>>[]>;
|
|
112
|
-
"storage-loaded": Subject<boolean>;
|
|
113
|
-
}
|
|
114
|
-
type InferSubjectValue<TIO extends IOLike, TPresence extends JsonObject, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = StateNotifierSubjects<TIO, TPresence>[TSubject] extends Subject<infer IValue> ? Id<IValue> : never;
|
|
115
|
-
type SubscriptionCallback<TIO extends IOLike, TPresence extends JsonObject, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = (value: InferSubjectValue<TIO, TPresence, TSubject>) => void;
|
|
116
|
-
|
|
117
106
|
type UsersManagerConfig<TPresence extends JsonObject = {}> = {
|
|
118
107
|
initialPresence?: TPresence;
|
|
119
108
|
limits: PluvClientLimits;
|
|
@@ -181,7 +170,6 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
181
170
|
private readonly _intervals;
|
|
182
171
|
private readonly _limits;
|
|
183
172
|
private readonly _listeners;
|
|
184
|
-
private readonly _otherNotifier;
|
|
185
173
|
private readonly _publicKey;
|
|
186
174
|
private readonly _reconnectTimeoutMs;
|
|
187
175
|
private readonly _router;
|
|
@@ -190,6 +178,7 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
190
178
|
private readonly _subscriptions;
|
|
191
179
|
private readonly _timeouts;
|
|
192
180
|
private readonly _usersManager;
|
|
181
|
+
private readonly _usersNotifier;
|
|
193
182
|
private _lastMetadata;
|
|
194
183
|
private _state;
|
|
195
184
|
private _windowListeners;
|
|
@@ -197,12 +186,15 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
197
186
|
constructor(room: string, options: RoomConfig<TIO, TMetadata, TPresence, TCrdt, TEvents>);
|
|
198
187
|
get storageLoaded(): boolean;
|
|
199
188
|
get webSocket(): WebSocket | null;
|
|
200
|
-
broadcast:
|
|
189
|
+
broadcast: BroadcastProxy<TIO, TEvents>;
|
|
201
190
|
canRedo: () => boolean;
|
|
202
191
|
canUndo: () => boolean;
|
|
203
192
|
connect(...args: RoomConnectParams<TMetadata>): Promise<void>;
|
|
204
193
|
disconnect(): Promise<void>;
|
|
205
|
-
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated To be removed in v3. Use PluvRoom.subscribe.event instead
|
|
196
|
+
*/
|
|
197
|
+
event: EventProxy<TIO, TEvents>;
|
|
206
198
|
getConnection: () => WebSocketConnection;
|
|
207
199
|
getDoc: () => CrdtDocLike<InferStorage<TCrdt>>;
|
|
208
200
|
getMyPresence: () => TPresence;
|
|
@@ -212,11 +204,21 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
212
204
|
getStorage: <TKey extends keyof InferStorage<TCrdt>>(type: TKey) => InferStorage<TCrdt>[TKey] | null;
|
|
213
205
|
getStorageJson(): InferCrdtJson<InferStorage<TCrdt>> | null;
|
|
214
206
|
getStorageJson<TKey extends keyof InferStorage<TCrdt>>(type: TKey): InferCrdtJson<InferStorage<TCrdt>[TKey]> | null;
|
|
215
|
-
|
|
207
|
+
/**
|
|
208
|
+
* @deprecated To be removed in v3. Use PluvRoom.subscribe.other instead
|
|
209
|
+
*/
|
|
210
|
+
other: (connectionId: string, callback: OtherSubscriptionCallback<TIO, TPresence>) => (() => void);
|
|
216
211
|
redo: () => void;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated To be removed in v3. To be removed in v3. Use PluvRoom.subscribe.storage instead
|
|
214
|
+
*/
|
|
215
|
+
storage: StorageProxy<InferStorage<TCrdt>>;
|
|
216
|
+
/**
|
|
217
|
+
* @deprecated To be removed in v3. Use PluvRoom.subscribe.storage instead
|
|
218
|
+
* @description Subscribes to the root storage object (serialized)
|
|
219
|
+
*/
|
|
220
|
+
storageRoot: (callback: (value: { [P in keyof InferStorage<TCrdt>]: InferCrdtJson<InferStorage<TCrdt>[P]>; }) => void) => (() => void);
|
|
221
|
+
subscribe: SubscribeProxy<TIO, TPresence, InferStorage<TCrdt>, TEvents>;
|
|
220
222
|
transact: (fn: (storage: InferStorage<TCrdt>) => void, origin?: string) => void;
|
|
221
223
|
undo: () => void;
|
|
222
224
|
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|
|
@@ -332,7 +334,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject, TCrdt
|
|
|
332
334
|
private readonly _eventNotifier;
|
|
333
335
|
private readonly _events?;
|
|
334
336
|
private readonly _limits;
|
|
335
|
-
private readonly
|
|
337
|
+
private readonly _usersNotifier;
|
|
336
338
|
private readonly _router;
|
|
337
339
|
private _state;
|
|
338
340
|
private readonly _stateNotifier;
|
|
@@ -340,10 +342,10 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject, TCrdt
|
|
|
340
342
|
private readonly _usersManager;
|
|
341
343
|
constructor(room: string, options: MockedRoomConfig<TIO, TPresence, TCrdt, TEvents>);
|
|
342
344
|
get storageLoaded(): boolean;
|
|
343
|
-
broadcast:
|
|
345
|
+
broadcast: BroadcastProxy<TIO, TEvents>;
|
|
344
346
|
canRedo: () => boolean;
|
|
345
347
|
canUndo: () => boolean;
|
|
346
|
-
event:
|
|
348
|
+
event: EventProxy<TIO, TEvents>;
|
|
347
349
|
getConnection: () => WebSocketConnection;
|
|
348
350
|
getDoc(): CrdtDocLike<InferStorage<TCrdt>>;
|
|
349
351
|
getMyPresence: () => TPresence;
|
|
@@ -353,11 +355,11 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject, TCrdt
|
|
|
353
355
|
getStorage: <TKey extends keyof InferStorage<TCrdt>>(type: TKey) => InferStorage<TCrdt>[TKey] | null;
|
|
354
356
|
getStorageJson(): InferCrdtJson<InferStorage<TCrdt>> | null;
|
|
355
357
|
getStorageJson<TKey extends keyof InferStorage<TCrdt>>(type: TKey): InferCrdtJson<InferStorage<TCrdt>[TKey]> | null;
|
|
356
|
-
other: (connectionId: string, callback:
|
|
358
|
+
other: (connectionId: string, callback: OtherSubscriptionCallback<TIO, TPresence>) => (() => void);
|
|
357
359
|
redo: () => void;
|
|
358
|
-
storage: <
|
|
360
|
+
storage: StorageProxy<InferStorage<TCrdt>>;
|
|
359
361
|
storageRoot: (fn: (value: { [P in keyof InferStorage<TCrdt>]: InferCrdtJson<InferStorage<TCrdt>[P]>; }) => void) => (() => void);
|
|
360
|
-
subscribe: <
|
|
362
|
+
subscribe: SubscribeProxy<TIO, TPresence, InferStorage<TCrdt>, TEvents>;
|
|
361
363
|
transact: (fn: (storage: InferStorage<TCrdt>) => void, origin?: string) => void;
|
|
362
364
|
undo: () => void;
|
|
363
365
|
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CrdtType, AbstractCrdtDocFactory, NoopCrdtDocFactory, InferStorage, InferCrdtJson } from '@pluv/crdt';
|
|
2
2
|
export { CrdtType, InferCrdtJson } from '@pluv/crdt';
|
|
3
|
-
import { IOLike, JsonObject, EventRecord, CrdtDocLike, UserInfo, MaybePromise, Id, ConnectionState, ProcedureLike, InputZodLike, IORouterLike,
|
|
3
|
+
import { IOLike, JsonObject, EventRecord, CrdtDocLike, UserInfo, MaybePromise, Id, ConnectionState, ProcedureLike, InputZodLike, IORouterLike, InferIOAuthorizeUser, InferIOAuthorize, BaseUser, RoomLike, InferIOOutput, InferIOInput, BroadcastProxy, EventProxy, OtherSubscriptionCallback, StorageProxy, SubscribeProxy, UpdateMyPresenceAction, MergeEvents } from '@pluv/types';
|
|
4
4
|
export { BaseUser, ConnectionState, EventMessage, EventNotifierSubscriptionCallback, EventRecord, IOEventMessage, MergeEvents, RoomLike, UserInfo, WebSocketState } from '@pluv/types';
|
|
5
|
-
import { Subject } from 'wonka';
|
|
6
5
|
|
|
7
6
|
declare abstract class AbstractStorageStore {
|
|
8
7
|
room: string;
|
|
@@ -104,16 +103,6 @@ declare class PluvRouter<TIO extends IOLike = IOLike, TPresence extends JsonObje
|
|
|
104
103
|
private _isValidEventName;
|
|
105
104
|
}
|
|
106
105
|
|
|
107
|
-
interface StateNotifierSubjects<TIO extends IOLike, TPresence extends JsonObject> {
|
|
108
|
-
connection: Subject<Id<WebSocketState<TIO>>>;
|
|
109
|
-
"my-presence": Subject<TPresence | null>;
|
|
110
|
-
myself: Subject<Readonly<Id<UserInfo<TIO>>> | null>;
|
|
111
|
-
others: Subject<readonly Id<UserInfo<TIO>>[]>;
|
|
112
|
-
"storage-loaded": Subject<boolean>;
|
|
113
|
-
}
|
|
114
|
-
type InferSubjectValue<TIO extends IOLike, TPresence extends JsonObject, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = StateNotifierSubjects<TIO, TPresence>[TSubject] extends Subject<infer IValue> ? Id<IValue> : never;
|
|
115
|
-
type SubscriptionCallback<TIO extends IOLike, TPresence extends JsonObject, TSubject extends keyof StateNotifierSubjects<TIO, TPresence>> = (value: InferSubjectValue<TIO, TPresence, TSubject>) => void;
|
|
116
|
-
|
|
117
106
|
type UsersManagerConfig<TPresence extends JsonObject = {}> = {
|
|
118
107
|
initialPresence?: TPresence;
|
|
119
108
|
limits: PluvClientLimits;
|
|
@@ -181,7 +170,6 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
181
170
|
private readonly _intervals;
|
|
182
171
|
private readonly _limits;
|
|
183
172
|
private readonly _listeners;
|
|
184
|
-
private readonly _otherNotifier;
|
|
185
173
|
private readonly _publicKey;
|
|
186
174
|
private readonly _reconnectTimeoutMs;
|
|
187
175
|
private readonly _router;
|
|
@@ -190,6 +178,7 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
190
178
|
private readonly _subscriptions;
|
|
191
179
|
private readonly _timeouts;
|
|
192
180
|
private readonly _usersManager;
|
|
181
|
+
private readonly _usersNotifier;
|
|
193
182
|
private _lastMetadata;
|
|
194
183
|
private _state;
|
|
195
184
|
private _windowListeners;
|
|
@@ -197,12 +186,15 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
197
186
|
constructor(room: string, options: RoomConfig<TIO, TMetadata, TPresence, TCrdt, TEvents>);
|
|
198
187
|
get storageLoaded(): boolean;
|
|
199
188
|
get webSocket(): WebSocket | null;
|
|
200
|
-
broadcast:
|
|
189
|
+
broadcast: BroadcastProxy<TIO, TEvents>;
|
|
201
190
|
canRedo: () => boolean;
|
|
202
191
|
canUndo: () => boolean;
|
|
203
192
|
connect(...args: RoomConnectParams<TMetadata>): Promise<void>;
|
|
204
193
|
disconnect(): Promise<void>;
|
|
205
|
-
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated To be removed in v3. Use PluvRoom.subscribe.event instead
|
|
196
|
+
*/
|
|
197
|
+
event: EventProxy<TIO, TEvents>;
|
|
206
198
|
getConnection: () => WebSocketConnection;
|
|
207
199
|
getDoc: () => CrdtDocLike<InferStorage<TCrdt>>;
|
|
208
200
|
getMyPresence: () => TPresence;
|
|
@@ -212,11 +204,21 @@ declare class PluvRoom<TIO extends IOLike<any, any>, TMetadata extends JsonObjec
|
|
|
212
204
|
getStorage: <TKey extends keyof InferStorage<TCrdt>>(type: TKey) => InferStorage<TCrdt>[TKey] | null;
|
|
213
205
|
getStorageJson(): InferCrdtJson<InferStorage<TCrdt>> | null;
|
|
214
206
|
getStorageJson<TKey extends keyof InferStorage<TCrdt>>(type: TKey): InferCrdtJson<InferStorage<TCrdt>[TKey]> | null;
|
|
215
|
-
|
|
207
|
+
/**
|
|
208
|
+
* @deprecated To be removed in v3. Use PluvRoom.subscribe.other instead
|
|
209
|
+
*/
|
|
210
|
+
other: (connectionId: string, callback: OtherSubscriptionCallback<TIO, TPresence>) => (() => void);
|
|
216
211
|
redo: () => void;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated To be removed in v3. To be removed in v3. Use PluvRoom.subscribe.storage instead
|
|
214
|
+
*/
|
|
215
|
+
storage: StorageProxy<InferStorage<TCrdt>>;
|
|
216
|
+
/**
|
|
217
|
+
* @deprecated To be removed in v3. Use PluvRoom.subscribe.storage instead
|
|
218
|
+
* @description Subscribes to the root storage object (serialized)
|
|
219
|
+
*/
|
|
220
|
+
storageRoot: (callback: (value: { [P in keyof InferStorage<TCrdt>]: InferCrdtJson<InferStorage<TCrdt>[P]>; }) => void) => (() => void);
|
|
221
|
+
subscribe: SubscribeProxy<TIO, TPresence, InferStorage<TCrdt>, TEvents>;
|
|
220
222
|
transact: (fn: (storage: InferStorage<TCrdt>) => void, origin?: string) => void;
|
|
221
223
|
undo: () => void;
|
|
222
224
|
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|
|
@@ -332,7 +334,7 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject, TCrdt
|
|
|
332
334
|
private readonly _eventNotifier;
|
|
333
335
|
private readonly _events?;
|
|
334
336
|
private readonly _limits;
|
|
335
|
-
private readonly
|
|
337
|
+
private readonly _usersNotifier;
|
|
336
338
|
private readonly _router;
|
|
337
339
|
private _state;
|
|
338
340
|
private readonly _stateNotifier;
|
|
@@ -340,10 +342,10 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject, TCrdt
|
|
|
340
342
|
private readonly _usersManager;
|
|
341
343
|
constructor(room: string, options: MockedRoomConfig<TIO, TPresence, TCrdt, TEvents>);
|
|
342
344
|
get storageLoaded(): boolean;
|
|
343
|
-
broadcast:
|
|
345
|
+
broadcast: BroadcastProxy<TIO, TEvents>;
|
|
344
346
|
canRedo: () => boolean;
|
|
345
347
|
canUndo: () => boolean;
|
|
346
|
-
event:
|
|
348
|
+
event: EventProxy<TIO, TEvents>;
|
|
347
349
|
getConnection: () => WebSocketConnection;
|
|
348
350
|
getDoc(): CrdtDocLike<InferStorage<TCrdt>>;
|
|
349
351
|
getMyPresence: () => TPresence;
|
|
@@ -353,11 +355,11 @@ declare class MockedRoom<TIO extends IOLike, TPresence extends JsonObject, TCrdt
|
|
|
353
355
|
getStorage: <TKey extends keyof InferStorage<TCrdt>>(type: TKey) => InferStorage<TCrdt>[TKey] | null;
|
|
354
356
|
getStorageJson(): InferCrdtJson<InferStorage<TCrdt>> | null;
|
|
355
357
|
getStorageJson<TKey extends keyof InferStorage<TCrdt>>(type: TKey): InferCrdtJson<InferStorage<TCrdt>[TKey]> | null;
|
|
356
|
-
other: (connectionId: string, callback:
|
|
358
|
+
other: (connectionId: string, callback: OtherSubscriptionCallback<TIO, TPresence>) => (() => void);
|
|
357
359
|
redo: () => void;
|
|
358
|
-
storage: <
|
|
360
|
+
storage: StorageProxy<InferStorage<TCrdt>>;
|
|
359
361
|
storageRoot: (fn: (value: { [P in keyof InferStorage<TCrdt>]: InferCrdtJson<InferStorage<TCrdt>[P]>; }) => void) => (() => void);
|
|
360
|
-
subscribe: <
|
|
362
|
+
subscribe: SubscribeProxy<TIO, TPresence, InferStorage<TCrdt>, TEvents>;
|
|
361
363
|
transact: (fn: (storage: InferStorage<TCrdt>) => void, origin?: string) => void;
|
|
362
364
|
undo: () => void;
|
|
363
365
|
updateMyPresence: (presence: UpdateMyPresenceAction<TPresence>) => void;
|