@emeryld/rrroutes-client 2.2.8 → 2.2.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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AnyLeaf, EventMap, InferOutput, Payload, SocketConnectionConfigOutput, SocketSchemaOutput } from '@emeryld/rrroutes-contract';
|
|
2
|
+
import type { BuiltInfinite, BuiltQuery, DataShape, InfiniteUseEndpointResultFor, QueryUseEndpointResultFor, UseEndpointArgs } from '../../routesV3.client.types';
|
|
3
|
+
import type { ClientCtx, ServerEnvelope, SocketClient } from '../socket.client.index';
|
|
4
|
+
type RoomsInput = string | string[] | undefined | null;
|
|
5
|
+
type SocketedBuilt<L extends AnyLeaf> = L['cfg']['feed'] extends true ? BuiltInfinite<L> : BuiltQuery<L>;
|
|
6
|
+
type SocketedRouteResult<L extends AnyLeaf> = (L['cfg']['feed'] extends true ? InfiniteUseEndpointResultFor<L> : QueryUseEndpointResultFor<L>) & {
|
|
7
|
+
rooms: string[];
|
|
8
|
+
};
|
|
9
|
+
export type SocketedRouteOptions<L extends AnyLeaf, Events extends EventMap, K extends keyof Events & string, C extends SocketConnectionConfigOutput> = {
|
|
10
|
+
built: SocketedBuilt<L>;
|
|
11
|
+
event: K;
|
|
12
|
+
toRooms: (data: InferOutput<L>) => RoomsInput;
|
|
13
|
+
applyMessage: (prev: DataShape<L> | undefined, payload: Payload<Events, K>, meta: {
|
|
14
|
+
envelope: ServerEnvelope<Events, K>;
|
|
15
|
+
ctx: ClientCtx;
|
|
16
|
+
}) => DataShape<L> | undefined;
|
|
17
|
+
joinMeta: SocketSchemaOutput<C['joinMetaMessage']>;
|
|
18
|
+
leaveMeta: SocketSchemaOutput<C['leaveMetaMessage']>;
|
|
19
|
+
useSocketClient: () => SocketClient<Events, C>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Compose a GET endpoint with socket wiring:
|
|
23
|
+
* - joins/leaves rooms derived from the endpoint data
|
|
24
|
+
* - subscribes to a socket event and applies messages to the cache
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildSocketedRoute<L extends AnyLeaf, Events extends EventMap, K extends keyof Events & string, C extends SocketConnectionConfigOutput>(options: SocketedRouteOptions<L, Events, K, C>): (...useArgs: UseEndpointArgs<L>) => SocketedRouteResult<L>;
|
|
27
|
+
export {};
|