@emeryld/rrroutes-client 2.8.9 → 2.8.10
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 +131 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +131 -6
- package/dist/index.mjs.map +1 -1
- package/dist/sockets/socket.client.core.d.ts +40 -0
- package/dist/sockets/socket.client.debug.d.ts +2 -2
- package/package.json +2 -2
|
@@ -43,6 +43,28 @@ export type HeartbeatClientOptions = {
|
|
|
43
43
|
/** Give up waiting for pong after this many ms. Default 7_500. */
|
|
44
44
|
timeoutMs?: number;
|
|
45
45
|
};
|
|
46
|
+
export type SocketReconnectionMode = 'managed' | 'manual' | 'inherit';
|
|
47
|
+
/**
|
|
48
|
+
* Controls reconnect ownership independently from room restoration.
|
|
49
|
+
*
|
|
50
|
+
* - `managed`: RRRoutes configures Socket.IO's Manager.
|
|
51
|
+
* - `manual`: RRRoutes disables Manager retries; the consumer calls
|
|
52
|
+
* `client.connect()` (or `socket.connect()`) with its own policy.
|
|
53
|
+
* - `inherit`: RRRoutes leaves the injected Socket.IO Manager untouched.
|
|
54
|
+
*
|
|
55
|
+
* Desired rooms are restored after every successful reconnect by default in
|
|
56
|
+
* all modes, including consumer-managed reconnects.
|
|
57
|
+
*/
|
|
58
|
+
export type SocketReconnectionOptions = {
|
|
59
|
+
mode?: SocketReconnectionMode;
|
|
60
|
+
restoreRooms?: boolean;
|
|
61
|
+
attempts?: number;
|
|
62
|
+
delayMs?: number;
|
|
63
|
+
delayMaxMs?: number;
|
|
64
|
+
randomizationFactor?: number;
|
|
65
|
+
timeoutMs?: number | false;
|
|
66
|
+
};
|
|
67
|
+
export type SocketReconnectionConfig = boolean | SocketReconnectionOptions;
|
|
46
68
|
export type SocketClientOptions<T extends EventMap = EventMap, C extends SocketConnectionConfigOutput = SocketConnectionConfigOutput> = {
|
|
47
69
|
/** Inject an existing socket.io-client Socket. Can be null while bootstrapping. */
|
|
48
70
|
socket: MaybeSocket;
|
|
@@ -63,6 +85,13 @@ export type SocketClientOptions<T extends EventMap = EventMap, C extends SocketC
|
|
|
63
85
|
debug?: SocketClientDebugOptions;
|
|
64
86
|
/** Optional heartbeat configuration. If provided, the client will start the heartbeat loop on the default 'sys:connect' handler. */
|
|
65
87
|
heartbeat?: HeartbeatClientOptions;
|
|
88
|
+
/**
|
|
89
|
+
* Reconnect behavior. `true` enables RRRoutes-managed Socket.IO defaults;
|
|
90
|
+
* `false` disables Manager retries for a consumer-managed policy. Omit it
|
|
91
|
+
* to inherit the injected socket's Manager configuration. Room restoration
|
|
92
|
+
* remains enabled unless `restoreRooms` is explicitly false.
|
|
93
|
+
*/
|
|
94
|
+
reconnection?: SocketReconnectionConfig;
|
|
66
95
|
sys: SysEventMap<T, C>;
|
|
67
96
|
};
|
|
68
97
|
export declare class SocketClient<T extends EventMap, C extends SocketConnectionConfigOutput = SocketConnectionConfigOutput> {
|
|
@@ -74,6 +103,7 @@ export declare class SocketClient<T extends EventMap, C extends SocketConnection
|
|
|
74
103
|
private readonly sysEvents;
|
|
75
104
|
private readonly roomJoinSchema;
|
|
76
105
|
private readonly roomLeaveSchema;
|
|
106
|
+
private readonly reconnection;
|
|
77
107
|
private readonly hb;
|
|
78
108
|
private hbTimer;
|
|
79
109
|
/** keep references so we can .off() later */
|
|
@@ -83,7 +113,9 @@ export declare class SocketClient<T extends EventMap, C extends SocketConnection
|
|
|
83
113
|
private readonly onConnectError;
|
|
84
114
|
private readonly onPong;
|
|
85
115
|
private readonly roomCounts;
|
|
116
|
+
private readonly roomJoinMeta;
|
|
86
117
|
private readonly handlerMap;
|
|
118
|
+
private hasConnected;
|
|
87
119
|
private snapshotSocketConfig;
|
|
88
120
|
private logSocketConfigSnapshot;
|
|
89
121
|
private getValidationDetails;
|
|
@@ -92,9 +124,17 @@ export declare class SocketClient<T extends EventMap, C extends SocketConnection
|
|
|
92
124
|
private getNamespace;
|
|
93
125
|
constructor(events: T, opts: SocketClientOptions<T, C>);
|
|
94
126
|
private getSysEvent;
|
|
127
|
+
private resolveReconnectionOptions;
|
|
128
|
+
private configureReconnection;
|
|
95
129
|
private dbg;
|
|
96
130
|
/** internal stats snapshot */
|
|
97
131
|
stats(): ClientStatsSnapshot;
|
|
132
|
+
/**
|
|
133
|
+
* Re-emit joins for all rooms with active references without incrementing
|
|
134
|
+
* their reference counts. This is safe to call after any externally or
|
|
135
|
+
* internally managed reconnect.
|
|
136
|
+
*/
|
|
137
|
+
restoreRooms(): Promise<string[]>;
|
|
98
138
|
private toArray;
|
|
99
139
|
private rollbackJoinIncrement;
|
|
100
140
|
private rollbackLeaveDecrement;
|
|
@@ -20,7 +20,7 @@ type DebugDetails = {
|
|
|
20
20
|
};
|
|
21
21
|
export type SocketClientDebugEvent<K extends string = string> = ({
|
|
22
22
|
type: 'connection';
|
|
23
|
-
phase: 'connect_event' | 'reconnect_event' | 'disconnect_event' | 'connect_error_event' | 'connect' | 'disconnect';
|
|
23
|
+
phase: 'connect_event' | 'reconnect_event' | 'reconnect_config' | 'disconnect_event' | 'connect_error_event' | 'connect' | 'disconnect';
|
|
24
24
|
id?: string;
|
|
25
25
|
attempt?: number;
|
|
26
26
|
reason?: string;
|
|
@@ -38,7 +38,7 @@ export type SocketClientDebugEvent<K extends string = string> = ({
|
|
|
38
38
|
err?: string;
|
|
39
39
|
} & DebugDetails['details']) | ({
|
|
40
40
|
type: 'room';
|
|
41
|
-
phase: 'join' | 'leave';
|
|
41
|
+
phase: 'join' | 'leave' | 'restore';
|
|
42
42
|
rooms: string[];
|
|
43
43
|
err?: string;
|
|
44
44
|
} & DebugDetails) | ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emeryld/rrroutes-client",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@jest/globals": "^30.4.1",
|
|
33
|
-
"@types/react": "^18.3.
|
|
33
|
+
"@types/react": "^18.3.31",
|
|
34
34
|
"@types/react-native": "^0.73.0"
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|