@blueyerobotics/blueye-ts 1.3.0 → 1.4.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/src/client.d.ts +7 -5
- package/package.json +1 -1
package/dist/src/client.d.ts
CHANGED
|
@@ -2,11 +2,13 @@ import { blueye } from "@blueyerobotics/protocol-definitions";
|
|
|
2
2
|
import { LogLevel } from "consola";
|
|
3
3
|
import { Emitter } from "strict-event-emitter";
|
|
4
4
|
export type Protocol = typeof blueye.protocol;
|
|
5
|
-
export type
|
|
6
|
-
export type
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
export type
|
|
5
|
+
export type ProtocolType = "Req" | "Rep" | "Tel" | "Ctrl";
|
|
6
|
+
export type ProtocolKey = Extract<keyof Protocol, `${string}${ProtocolType}`>;
|
|
7
|
+
export type Req = keyof Pick<Protocol, Extract<ProtocolKey, `${string}Req`>>;
|
|
8
|
+
export type Rep = keyof Pick<Protocol, Extract<ProtocolKey, `${string}Rep`>>;
|
|
9
|
+
export type Tel = keyof Pick<Protocol, Extract<ProtocolKey, `${string}Tel`>>;
|
|
10
|
+
export type Ctrl = keyof Pick<Protocol, Extract<ProtocolKey, `${string}Ctrl`>>;
|
|
11
|
+
export type ReqToRep<T extends Req> = T extends `${infer Prefix}Req` ? `${Prefix}Rep` extends ProtocolKey ? Protocol[`${Prefix}Rep`] : never : never;
|
|
10
12
|
export type MsgHandler<T extends Req> = Protocol[T];
|
|
11
13
|
export type CreateArgs<T extends Req> = Parameters<MsgHandler<T>["create"]>[0];
|
|
12
14
|
export type DecodedOutput<T extends Req> = ReturnType<ReqToRep<T>["decode"]>;
|