@emeryld/rrroutes-client 2.1.2 → 2.1.4
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.cjs +21 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +21 -7
- package/dist/index.mjs.map +1 -1
- package/dist/sockets/socket.client.context.d.ts +3 -3
- package/dist/sockets/socket.client.index.d.ts +1 -2
- package/dist/sockets/socket.client.sys.d.ts +2 -61
- package/package.json +2 -2
|
@@ -1,67 +1,8 @@
|
|
|
1
1
|
import type { Socket } from 'socket.io-client';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import type { EventMap, SocketConnectionConfig
|
|
3
|
+
import type { EventMap, SocketConnectionConfig } from '@emeryld/rrroutes-contract';
|
|
4
4
|
import { SocketClient } from './socket.client.index';
|
|
5
5
|
export type MaybeSocket = Socket | null;
|
|
6
|
-
type BaseSysLifecycleArgs = {
|
|
7
|
-
socket: MaybeSocket;
|
|
8
|
-
next: () => void;
|
|
9
|
-
startHeartbeat: () => void;
|
|
10
|
-
stopHeartbeat: () => void;
|
|
11
|
-
};
|
|
12
|
-
export type SysConnectHandlerArgs = BaseSysLifecycleArgs & {
|
|
13
|
-
name: Extract<SysEventName, 'sys:connect'>;
|
|
14
|
-
phase: 'connect';
|
|
15
|
-
};
|
|
16
|
-
export type SysReconnectHandlerArgs = BaseSysLifecycleArgs & {
|
|
17
|
-
name: Extract<SysEventName, 'sys:reconnect'>;
|
|
18
|
-
phase: 'reconnect';
|
|
19
|
-
attempt: number;
|
|
20
|
-
};
|
|
21
|
-
export type SysDisconnectHandlerArgs = BaseSysLifecycleArgs & {
|
|
22
|
-
name: Extract<SysEventName, 'sys:disconnect'>;
|
|
23
|
-
phase: 'disconnect';
|
|
24
|
-
reason: string;
|
|
25
|
-
};
|
|
26
|
-
export type SysConnectErrorHandlerArgs = BaseSysLifecycleArgs & {
|
|
27
|
-
name: Extract<SysEventName, 'sys:connect_error'>;
|
|
28
|
-
phase: 'connect_error';
|
|
29
|
-
error: unknown;
|
|
30
|
-
};
|
|
31
|
-
export type SysPingHandlerArgs<C extends SocketConnectionConfig = SocketConnectionConfig> = {
|
|
32
|
-
name: Extract<SysEventName, 'sys:ping'>;
|
|
33
|
-
socket: MaybeSocket;
|
|
34
|
-
buildDefaultPayload: () => z.input<C['pingPayload']>;
|
|
35
|
-
send: (payload: z.input<C['pingPayload']>) => void;
|
|
36
|
-
next: () => void;
|
|
37
|
-
startHeartbeat: () => void;
|
|
38
|
-
stopHeartbeat: () => void;
|
|
39
|
-
};
|
|
40
|
-
export type SysPongHandlerArgs<C extends SocketConnectionConfig = SocketConnectionConfig> = {
|
|
41
|
-
name: Extract<SysEventName, 'sys:pong'>;
|
|
42
|
-
socket: MaybeSocket;
|
|
43
|
-
raw: z.output<C['pongPayload']>;
|
|
44
|
-
latencyMs?: number;
|
|
45
|
-
next: () => void;
|
|
46
|
-
startHeartbeat: () => void;
|
|
47
|
-
stopHeartbeat: () => void;
|
|
48
|
-
};
|
|
49
|
-
export type SysRoomHandlerArgs<Meta extends z.ZodTypeAny = z.ZodTypeAny> = {
|
|
50
|
-
name: Extract<SysEventName, 'sys:room_join' | 'sys:room_leave'>;
|
|
51
|
-
socket: MaybeSocket;
|
|
52
|
-
rooms: string[];
|
|
53
|
-
meta: z.output<Meta>;
|
|
54
|
-
next: () => void;
|
|
55
|
-
startHeartbeat: () => void;
|
|
56
|
-
stopHeartbeat: () => void;
|
|
57
|
-
};
|
|
58
|
-
export type SysConnectHandler = (args: SysConnectHandlerArgs) => void;
|
|
59
|
-
export type SysReconnectHandler = (args: SysReconnectHandlerArgs) => void;
|
|
60
|
-
export type SysDisconnectHandler = (args: SysDisconnectHandlerArgs) => void;
|
|
61
|
-
export type SysConnectErrorHandler = (args: SysConnectErrorHandlerArgs) => void;
|
|
62
|
-
export type SysPingHandler<C extends SocketConnectionConfig = SocketConnectionConfig> = (args: SysPingHandlerArgs<C>) => void;
|
|
63
|
-
export type SysPongHandler<C extends SocketConnectionConfig = SocketConnectionConfig> = (args: SysPongHandlerArgs<C>) => void;
|
|
64
|
-
export type SysRoomHandler<Meta extends z.ZodTypeAny = z.ZodTypeAny> = (args: SysRoomHandlerArgs<Meta>) => void;
|
|
65
6
|
export type SysEventMap<T extends EventMap, C extends SocketConnectionConfig = SocketConnectionConfig> = {
|
|
66
7
|
'sys:connect': (args: {
|
|
67
8
|
socket: Socket;
|
|
@@ -101,7 +42,7 @@ export type SysEventMap<T extends EventMap, C extends SocketConnectionConfig = S
|
|
|
101
42
|
socket: Socket;
|
|
102
43
|
client: SocketClient<T, C>;
|
|
103
44
|
rooms: string | string[];
|
|
104
|
-
meta: z.output<C['
|
|
45
|
+
meta: z.output<C['leaveMetaMessage']>;
|
|
105
46
|
}) => boolean;
|
|
106
47
|
};
|
|
107
48
|
declare const roomValueSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emeryld/rrroutes-client",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dist"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@emeryld/rrroutes-contract": "^2.0
|
|
22
|
+
"@emeryld/rrroutes-contract": "^2.1.0",
|
|
23
23
|
"zod": "^4.1.12"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|