@pluv/client 2.1.0 → 2.2.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 +44 -0
- package/dist/index.d.mts +49 -56
- package/dist/index.d.ts +49 -56
- package/dist/index.js +80 -27
- package/dist/index.mjs +82 -29
- package/package.json +5 -5
- package/src/CrdtManager.ts +9 -13
- package/src/ListenerManager.ts +21 -0
- package/src/MockedRoom.ts +36 -16
- package/src/PluvClient.ts +8 -8
- package/src/PluvProcedure.ts +27 -25
- package/src/PluvRoom.ts +76 -25
- package/src/PluvRouter.ts +31 -22
- package/src/StateNotifier.ts +2 -2
- package/src/UsersManager.ts +18 -4
- package/src/UsersNotifier.ts +1 -1
- package/src/constants.ts +1 -0
- package/src/createClient.ts +2 -2
- package/src/index.ts +2 -1
- package/src/types.ts +10 -31
package/src/types.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { CrdtType } from "@pluv/crdt";
|
|
2
1
|
import type {
|
|
3
|
-
ConnectionState,
|
|
4
2
|
CrdtDocLike,
|
|
5
3
|
EventRecord,
|
|
6
4
|
Id,
|
|
@@ -19,22 +17,22 @@ export interface AuthorizationState<TIO extends IOLike> {
|
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
export type EventResolver<
|
|
22
|
-
TIO extends IOLike
|
|
23
|
-
TInput extends JsonObject
|
|
24
|
-
TOutput extends EventRecord<string, any
|
|
25
|
-
TPresence extends
|
|
26
|
-
|
|
20
|
+
TIO extends IOLike,
|
|
21
|
+
TInput extends JsonObject,
|
|
22
|
+
TOutput extends EventRecord<string, any>,
|
|
23
|
+
TPresence extends Record<string, any>,
|
|
24
|
+
TDocLike extends CrdtDocLike<any, any>,
|
|
27
25
|
> = (
|
|
28
26
|
data: TInput,
|
|
29
|
-
context: EventResolverContext<TIO, TPresence,
|
|
27
|
+
context: EventResolverContext<TIO, TPresence, TDocLike>,
|
|
30
28
|
) => MaybePromise<TOutput | void>;
|
|
31
29
|
|
|
32
30
|
export interface EventResolverContext<
|
|
33
|
-
TIO extends IOLike
|
|
34
|
-
TPresence extends
|
|
35
|
-
|
|
31
|
+
TIO extends IOLike,
|
|
32
|
+
TPresence extends Record<string, any>,
|
|
33
|
+
TDocLike extends CrdtDocLike<any, any>,
|
|
36
34
|
> {
|
|
37
|
-
doc:
|
|
35
|
+
doc: TDocLike;
|
|
38
36
|
others: readonly UserInfo<TIO, TPresence>[];
|
|
39
37
|
room: string;
|
|
40
38
|
user: UserInfo<TIO, TPresence>;
|
|
@@ -76,25 +74,6 @@ export type PublicKey<TMetadata extends JsonObject> =
|
|
|
76
74
|
| string
|
|
77
75
|
| ((params: PublicKeyParams<TMetadata>) => string);
|
|
78
76
|
|
|
79
|
-
export interface WebSocketConnection {
|
|
80
|
-
/**
|
|
81
|
-
* @description How many times a connection attempt was made. This will increment upon each
|
|
82
|
-
* unsuccessful attempt, and will reset upon a successful connection.
|
|
83
|
-
* @date April 13, 2025
|
|
84
|
-
*/
|
|
85
|
-
attempts: number;
|
|
86
|
-
/**
|
|
87
|
-
* @description How many times the user has connected to the room. This can be more than 1 in
|
|
88
|
-
* the case of reconnects. This is tracked because on the very first connection (i.e. when
|
|
89
|
-
* count is 0) we don't want to send the storage state as an update to the room and overwrite
|
|
90
|
-
* the upstream state.
|
|
91
|
-
* @date April 13, 2025
|
|
92
|
-
*/
|
|
93
|
-
count: number;
|
|
94
|
-
id: string | null;
|
|
95
|
-
state: ConnectionState;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
77
|
export type WithMetadata<TMetadata extends JsonObject = {}> = keyof TMetadata extends never
|
|
99
78
|
? { metadata?: undefined }
|
|
100
79
|
: { metadata: TMetadata };
|