@emeryld/rrroutes-client 2.7.12 → 2.8.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.cjs +161 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +160 -106
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.types.d.ts +7 -1
- package/dist/sockets/socket.client.context.connection.d.ts +34 -14
- package/dist/sockets/socket.client.context.d.ts +1 -1
- package/dist/sockets/socket.client.context.provider.d.ts +4 -2
- package/package.json +1 -1
|
@@ -276,7 +276,13 @@ export type BuiltMutation<L extends AnyLeafLowProfile> = BuiltCommon<L> & {
|
|
|
276
276
|
fetch: MutationFetcher<L>;
|
|
277
277
|
};
|
|
278
278
|
/** Type-safe union that resolves to the correct built helper for a leaf. */
|
|
279
|
-
|
|
279
|
+
type BuiltLeafMetadata<L extends AnyLeafLowProfile> = {
|
|
280
|
+
metadata: {
|
|
281
|
+
leaf: L;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
/** Type-safe union that resolves to the correct built helper for a leaf. */
|
|
285
|
+
export type BuiltForLeaf<L extends AnyLeafLowProfile> = (L['method'] extends 'get' ? L['cfg']['feed'] extends true ? BuiltInfinite<L> : BuiltQuery<L> : BuiltMutation<L>) & BuiltLeafMetadata<L>;
|
|
280
286
|
type LeafFromBuilt<B> = B extends BuiltForLeaf<infer L> ? L : AnyLeafLowProfile;
|
|
281
287
|
type SetDataUpdaterFromBuilt<B> = B extends {
|
|
282
288
|
setData: (updater: infer U, ...args: any[]) => any;
|
|
@@ -4,19 +4,20 @@ type Rooms = string[] | string | undefined;
|
|
|
4
4
|
export type UseSocketConnectionDebugEvent = {
|
|
5
5
|
type: 'lifecycle';
|
|
6
6
|
phase: 'effect_start' | 'effect_cleanup' | 'client_missing';
|
|
7
|
-
event
|
|
8
|
-
rooms
|
|
9
|
-
autoJoin
|
|
10
|
-
autoLeave
|
|
7
|
+
event?: string;
|
|
8
|
+
rooms?: string[];
|
|
9
|
+
autoJoin?: boolean;
|
|
10
|
+
autoLeave?: boolean;
|
|
11
11
|
} | {
|
|
12
12
|
type: 'subscription';
|
|
13
|
-
phase: 'register' | 'unregister' | 'message';
|
|
13
|
+
phase: 'register' | 'unregister' | 'message' | 'message_dropped_duplicate';
|
|
14
14
|
event: string;
|
|
15
|
+
dedupeKey?: string;
|
|
15
16
|
} | {
|
|
16
17
|
type: 'room';
|
|
17
18
|
phase: 'join_attempt' | 'join_ok' | 'join_error' | 'leave_attempt' | 'leave_ok' | 'leave_error' | 'join_skip' | 'leave_skip';
|
|
18
19
|
rooms: string[];
|
|
19
|
-
reason?: 'no_rooms' | 'auto_disabled';
|
|
20
|
+
reason?: 'no_rooms' | 'auto_disabled' | 'disabled';
|
|
20
21
|
err?: string;
|
|
21
22
|
};
|
|
22
23
|
export type UseSocketConnectionDebugOptions = {
|
|
@@ -26,21 +27,40 @@ export type UseSocketConnectionDebugOptions = {
|
|
|
26
27
|
subscription?: boolean;
|
|
27
28
|
room?: boolean;
|
|
28
29
|
warnIfClientMissing?: boolean;
|
|
29
|
-
throwIfClientMissing?: boolean;
|
|
30
30
|
};
|
|
31
|
-
export type
|
|
32
|
-
event: K;
|
|
31
|
+
export type UseSocketRoomsArgs<C extends SocketConnectionConfigOutput> = {
|
|
33
32
|
rooms?: Rooms;
|
|
33
|
+
joinMeta: SocketSchemaOutput<C['joinMetaMessage']>;
|
|
34
|
+
leaveMeta: SocketSchemaOutput<C['leaveMetaMessage']>;
|
|
35
|
+
autoJoin?: boolean;
|
|
36
|
+
autoLeave?: boolean;
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
onCleanup?: () => void;
|
|
39
|
+
debug?: UseSocketConnectionDebugOptions;
|
|
40
|
+
};
|
|
41
|
+
export type UseSocketEventArgs<T extends EventMap, K extends keyof T & string, C extends SocketConnectionConfigOutput> = {
|
|
42
|
+
event: K;
|
|
34
43
|
onMessage: (payload: Payload<T, K>, meta?: {
|
|
35
44
|
envelope: ServerEnvelope<T[K]['__out']>;
|
|
36
45
|
ctx: ClientCtx;
|
|
37
46
|
}) => void;
|
|
47
|
+
enabled?: boolean;
|
|
38
48
|
onCleanup?: () => void;
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
messageDeduplication?: false | {
|
|
50
|
+
ttlMs?: number;
|
|
51
|
+
key?: (payload: Payload<T, K>, meta?: {
|
|
52
|
+
envelope: ServerEnvelope<T[K]['__out']>;
|
|
53
|
+
ctx: ClientCtx;
|
|
54
|
+
}) => string | undefined;
|
|
55
|
+
};
|
|
41
56
|
debug?: UseSocketConnectionDebugOptions;
|
|
42
|
-
|
|
43
|
-
leaveMeta: SocketSchemaOutput<C['leaveMetaMessage']>;
|
|
57
|
+
_configBrand?: C;
|
|
44
58
|
};
|
|
45
|
-
export
|
|
59
|
+
export type UseSocketConnectionArgs<T extends EventMap, K extends keyof T & string, C extends SocketConnectionConfigOutput> = [
|
|
60
|
+
rooms: UseSocketRoomsArgs<C>,
|
|
61
|
+
event: UseSocketEventArgs<T, K, C>
|
|
62
|
+
];
|
|
63
|
+
export declare function useSocketRooms<C extends SocketConnectionConfigOutput>(args: UseSocketRoomsArgs<C>): void;
|
|
64
|
+
export declare function useSocketEvent<T extends EventMap, K extends keyof T & string, C extends SocketConnectionConfigOutput>(args: UseSocketEventArgs<T, K, C>): void;
|
|
65
|
+
export declare function useSocketConnection<T extends EventMap, K extends keyof T & string, C extends SocketConnectionConfigOutput>(roomsArgs: UseSocketRoomsArgs<C>, eventArgs: UseSocketEventArgs<T, K, C>): void;
|
|
46
66
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { buildSocketProvider } from './socket.client.context.provider';
|
|
2
2
|
export { useSocketClient } from './socket.client.context.client';
|
|
3
|
-
export {
|
|
3
|
+
export { type UseSocketConnectionDebugEvent, type UseSocketConnectionDebugOptions, type UseSocketConnectionArgs, type UseSocketEventArgs, type UseSocketRoomsArgs, } from './socket.client.context.connection';
|
|
4
4
|
export type { SocketProviderDebugEvent, SocketProviderDebugOptions, } from './socket.client.context.debug';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EventMap, SocketConnectionConfigOutput, SocketSchemaOutput } from '@emeryld/rrroutes-contract';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { Socket } from 'socket.io-client';
|
|
4
|
-
import { type UseSocketConnectionArgs } from './socket.client.context.connection';
|
|
4
|
+
import { type UseSocketEventArgs, type UseSocketConnectionArgs, type UseSocketRoomsArgs } from './socket.client.context.connection';
|
|
5
5
|
import { SocketProviderDebugOptions } from './socket.client.context.debug';
|
|
6
6
|
import { SocketClient, type SocketClientOptions } from './socket.client.core';
|
|
7
7
|
type BaseOptions<T extends EventMap, C extends SocketConnectionConfigOutput> = Omit<SocketClientOptions<T, C>, 'socket'>;
|
|
@@ -37,6 +37,8 @@ export declare function buildSocketProvider<T extends EventMap, C extends Socket
|
|
|
37
37
|
destroyLeaveMeta: SocketSchemaOutput<C["leaveMetaMessage"]>;
|
|
38
38
|
}>) => import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
useSocketClient: () => SocketClient<T, C> | null;
|
|
40
|
-
|
|
40
|
+
useSocketRooms: (p: UseSocketRoomsArgs<C>) => void;
|
|
41
|
+
useSocketEvent: <K extends keyof T & string>(p: UseSocketEventArgs<T, K, C>) => void;
|
|
42
|
+
useSocketConnection: <K extends keyof T & string>(rooms: UseSocketRoomsArgs<C>, event: UseSocketEventArgs<T, K, C>) => void;
|
|
41
43
|
};
|
|
42
44
|
export {};
|