@novastar/taurus 0.1.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.
@@ -0,0 +1,191 @@
1
+ import { ConnectionOptions } from "tls";
2
+ import { Duplex } from "stream";
3
+ import { ExtractType } from "typed-struct";
4
+
5
+ //#region src/packet.d.ts
6
+ declare const TAURUS_PACKET_FLAG = 1313822273;
7
+ declare const TAURUS_REQUEST = 21073;
8
+ declare const TAURUS_RESPONSE = 21072;
9
+ declare const TAURUS_DISCOVERY = 34901;
10
+ /**
11
+ * Taurus request argument.
12
+ *
13
+ * Wire layout:
14
+ * action UInt8
15
+ * type UInt8
16
+ * reserved UInt16LE
17
+ */
18
+ declare const TaurusRequest: import("typed-struct",{
19
+ with: {
20
+ "resolution-mode": "import"
21
+ }
22
+ }).StructConstructor<{
23
+ action: number;
24
+ type: number;
25
+ }, "TaurusRequest">;
26
+ interface TaurusRequest extends ExtractType<typeof TaurusRequest, false> {}
27
+ /**
28
+ * Taurus response argument.
29
+ *
30
+ * Wire layout:
31
+ * status UInt16LE
32
+ * action UInt8
33
+ * type UInt8
34
+ */
35
+ declare const TaurusResponse: import("typed-struct",{
36
+ with: {
37
+ "resolution-mode": "import"
38
+ }
39
+ }).StructConstructor<{
40
+ status: number;
41
+ action: number;
42
+ type: number;
43
+ }, "TaurusResponse">;
44
+ interface TaurusResponse extends ExtractType<typeof TaurusResponse, false> {}
45
+ /**
46
+ * Taurus packet.
47
+ *
48
+ * The same 4 bytes are exposed as both request and response structures.
49
+ * packetType determines which representation should be used.
50
+ */
51
+ declare const TaurusPacket: import("typed-struct",{
52
+ with: {
53
+ "resolution-mode": "import"
54
+ }
55
+ }).StructConstructor<{
56
+ flag: 1313822273;
57
+ sequence: number;
58
+ packetType: 21073 | 21072 | 34901;
59
+ what: number;
60
+ readonly req: {
61
+ action: number;
62
+ type: number;
63
+ };
64
+ readonly res: {
65
+ status: number;
66
+ action: number;
67
+ type: number;
68
+ };
69
+ length: number;
70
+ encodeType: number;
71
+ checksum: number;
72
+ readonly body: Buffer<ArrayBufferLike>;
73
+ }, "TaurusPacket">;
74
+ interface TaurusPacket extends ExtractType<typeof TaurusPacket, false> {}
75
+ interface TaurusCommand {
76
+ what: number;
77
+ type: number;
78
+ action: number;
79
+ }
80
+ declare const TAURUS_HEADER_SIZE: number;
81
+ /**
82
+ * Calculates Taurus header checksum.
83
+ *
84
+ * The checksum is the sum of all signed 8-bit values preceding
85
+ * the checksum field.
86
+ */
87
+ declare const calculateTaurusHeaderChecksum: (header: Uint8Array) => number;
88
+ /**
89
+ * Returns the full packet size once the complete header is available.
90
+ */
91
+ declare const getTaurusPacketSize: (buffer: Uint8Array) => number | undefined;
92
+ /**
93
+ * Encodes a Taurus request.
94
+ */
95
+ declare const encodeTaurusRequest: (sequence: number, {
96
+ what,
97
+ type,
98
+ action
99
+ }: TaurusCommand, body?: string | Buffer, encodeType?: number) => Buffer;
100
+ /** Encodes the UDP search request used by Taurus players on port 16601. */
101
+ declare const encodeTaurusDiscoveryRequest: (supportsEncryption?: boolean) => Buffer;
102
+ /**
103
+ * Decodes and validates a Taurus packet.
104
+ */
105
+ declare const decodeTaurusPacket: (buffer: Uint8Array) => TaurusPacket;
106
+ //#endregion
107
+ //#region src/connection.d.ts
108
+ declare class TaurusResponseError extends Error {
109
+ readonly status: number;
110
+ readonly responseBody: string;
111
+ constructor(status: number, responseBody: string);
112
+ }
113
+ declare class TaurusConnection {
114
+ #private;
115
+ readonly stream: Duplex;
116
+ readonly timeout: number;
117
+ constructor(stream: Duplex, timeout?: number);
118
+ get closed(): boolean;
119
+ request(command: TaurusCommand, body?: string | Buffer): Promise<TaurusPacket>;
120
+ requestJson<T>(command: TaurusCommand, body?: unknown): Promise<T>;
121
+ close(): void;
122
+ }
123
+ //#endregion
124
+ //#region src/client.d.ts
125
+ declare const TAURUS_MANAGEMENT_PORT = 16606;
126
+ interface TaurusConnectOptions extends Omit<ConnectionOptions, 'host' | 'port'> {
127
+ host: string;
128
+ port?: number;
129
+ timeout?: number;
130
+ privacy?: boolean;
131
+ }
132
+ interface TaurusLoginOptions {
133
+ sn: string;
134
+ password: string;
135
+ username?: string;
136
+ clientId?: string;
137
+ clientName?: string;
138
+ }
139
+ interface TaurusLoginResult {
140
+ logined: boolean;
141
+ validation?: boolean;
142
+ validition?: boolean;
143
+ username?: string;
144
+ sn?: string;
145
+ }
146
+ interface TaurusBrightness {
147
+ brightness?: number;
148
+ ratio?: number;
149
+ solidity: boolean;
150
+ orderId: number;
151
+ }
152
+ declare class TaurusClient {
153
+ readonly connection: TaurusConnection;
154
+ private constructor();
155
+ static connect(options: TaurusConnectOptions): Promise<TaurusClient>;
156
+ login(options: TaurusLoginOptions): Promise<TaurusLoginResult>;
157
+ getBrightness(): Promise<TaurusBrightness>;
158
+ setBrightness(percent: number, persist?: boolean): Promise<void>;
159
+ getEnvironmentBrightness(): Promise<number>;
160
+ close(): void;
161
+ }
162
+ //#endregion
163
+ //#region src/discovery.d.ts
164
+ declare const TAURUS_DISCOVERY_PORT = 16601;
165
+ interface TaurusPlayerInfo {
166
+ address: string;
167
+ aliasName: string;
168
+ encodeType: number;
169
+ height: number;
170
+ modelId: number;
171
+ platform: string;
172
+ privacy: boolean;
173
+ productName: string;
174
+ rotation: number;
175
+ sn: string;
176
+ tcpPort: number;
177
+ width: number;
178
+ ftpPort?: number;
179
+ key?: string;
180
+ logined?: boolean;
181
+ loginedUsernames?: string[];
182
+ syssetFtpPort?: number;
183
+ syssetTcpPort?: number;
184
+ terminalEntrancePortHttps?: number;
185
+ terminalEntrancePortWebSocket?: number;
186
+ }
187
+ declare const parseTaurusDiscoveryResponse: (message: Uint8Array, address: string) => TaurusPlayerInfo | undefined;
188
+ declare const discoverTaurusPlayers: (destination?: string, timeout?: number) => Promise<TaurusPlayerInfo[]>;
189
+ //#endregion
190
+ export { TAURUS_DISCOVERY, TAURUS_DISCOVERY_PORT, TAURUS_HEADER_SIZE, TAURUS_MANAGEMENT_PORT, TAURUS_PACKET_FLAG, TAURUS_REQUEST, TAURUS_RESPONSE, TaurusBrightness, TaurusClient, TaurusCommand, TaurusConnectOptions, TaurusConnection, TaurusLoginOptions, TaurusLoginResult, TaurusPacket, TaurusPlayerInfo, TaurusRequest, TaurusResponse, TaurusResponseError, calculateTaurusHeaderChecksum, decodeTaurusPacket, discoverTaurusPlayers, encodeTaurusDiscoveryRequest, encodeTaurusRequest, getTaurusPacketSize, parseTaurusDiscoveryResponse };
191
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,191 @@
1
+ import { ConnectionOptions } from "tls";
2
+ import { ExtractType } from "typed-struct";
3
+ import { Duplex } from "stream";
4
+
5
+ //#region src/packet.d.ts
6
+ declare const TAURUS_PACKET_FLAG = 1313822273;
7
+ declare const TAURUS_REQUEST = 21073;
8
+ declare const TAURUS_RESPONSE = 21072;
9
+ declare const TAURUS_DISCOVERY = 34901;
10
+ /**
11
+ * Taurus request argument.
12
+ *
13
+ * Wire layout:
14
+ * action UInt8
15
+ * type UInt8
16
+ * reserved UInt16LE
17
+ */
18
+ declare const TaurusRequest: import("typed-struct",{
19
+ with: {
20
+ "resolution-mode": "import"
21
+ }
22
+ }).StructConstructor<{
23
+ action: number;
24
+ type: number;
25
+ }, "TaurusRequest">;
26
+ interface TaurusRequest extends ExtractType<typeof TaurusRequest, false> {}
27
+ /**
28
+ * Taurus response argument.
29
+ *
30
+ * Wire layout:
31
+ * status UInt16LE
32
+ * action UInt8
33
+ * type UInt8
34
+ */
35
+ declare const TaurusResponse: import("typed-struct",{
36
+ with: {
37
+ "resolution-mode": "import"
38
+ }
39
+ }).StructConstructor<{
40
+ status: number;
41
+ action: number;
42
+ type: number;
43
+ }, "TaurusResponse">;
44
+ interface TaurusResponse extends ExtractType<typeof TaurusResponse, false> {}
45
+ /**
46
+ * Taurus packet.
47
+ *
48
+ * The same 4 bytes are exposed as both request and response structures.
49
+ * packetType determines which representation should be used.
50
+ */
51
+ declare const TaurusPacket: import("typed-struct",{
52
+ with: {
53
+ "resolution-mode": "import"
54
+ }
55
+ }).StructConstructor<{
56
+ flag: 1313822273;
57
+ sequence: number;
58
+ packetType: 21073 | 21072 | 34901;
59
+ what: number;
60
+ readonly req: {
61
+ action: number;
62
+ type: number;
63
+ };
64
+ readonly res: {
65
+ status: number;
66
+ action: number;
67
+ type: number;
68
+ };
69
+ length: number;
70
+ encodeType: number;
71
+ checksum: number;
72
+ readonly body: Buffer<ArrayBufferLike>;
73
+ }, "TaurusPacket">;
74
+ interface TaurusPacket extends ExtractType<typeof TaurusPacket, false> {}
75
+ interface TaurusCommand {
76
+ what: number;
77
+ type: number;
78
+ action: number;
79
+ }
80
+ declare const TAURUS_HEADER_SIZE: number;
81
+ /**
82
+ * Calculates Taurus header checksum.
83
+ *
84
+ * The checksum is the sum of all signed 8-bit values preceding
85
+ * the checksum field.
86
+ */
87
+ declare const calculateTaurusHeaderChecksum: (header: Uint8Array) => number;
88
+ /**
89
+ * Returns the full packet size once the complete header is available.
90
+ */
91
+ declare const getTaurusPacketSize: (buffer: Uint8Array) => number | undefined;
92
+ /**
93
+ * Encodes a Taurus request.
94
+ */
95
+ declare const encodeTaurusRequest: (sequence: number, {
96
+ what,
97
+ type,
98
+ action
99
+ }: TaurusCommand, body?: string | Buffer, encodeType?: number) => Buffer;
100
+ /** Encodes the UDP search request used by Taurus players on port 16601. */
101
+ declare const encodeTaurusDiscoveryRequest: (supportsEncryption?: boolean) => Buffer;
102
+ /**
103
+ * Decodes and validates a Taurus packet.
104
+ */
105
+ declare const decodeTaurusPacket: (buffer: Uint8Array) => TaurusPacket;
106
+ //#endregion
107
+ //#region src/connection.d.ts
108
+ declare class TaurusResponseError extends Error {
109
+ readonly status: number;
110
+ readonly responseBody: string;
111
+ constructor(status: number, responseBody: string);
112
+ }
113
+ declare class TaurusConnection {
114
+ #private;
115
+ readonly stream: Duplex;
116
+ readonly timeout: number;
117
+ constructor(stream: Duplex, timeout?: number);
118
+ get closed(): boolean;
119
+ request(command: TaurusCommand, body?: string | Buffer): Promise<TaurusPacket>;
120
+ requestJson<T>(command: TaurusCommand, body?: unknown): Promise<T>;
121
+ close(): void;
122
+ }
123
+ //#endregion
124
+ //#region src/client.d.ts
125
+ declare const TAURUS_MANAGEMENT_PORT = 16606;
126
+ interface TaurusConnectOptions extends Omit<ConnectionOptions, 'host' | 'port'> {
127
+ host: string;
128
+ port?: number;
129
+ timeout?: number;
130
+ privacy?: boolean;
131
+ }
132
+ interface TaurusLoginOptions {
133
+ sn: string;
134
+ password: string;
135
+ username?: string;
136
+ clientId?: string;
137
+ clientName?: string;
138
+ }
139
+ interface TaurusLoginResult {
140
+ logined: boolean;
141
+ validation?: boolean;
142
+ validition?: boolean;
143
+ username?: string;
144
+ sn?: string;
145
+ }
146
+ interface TaurusBrightness {
147
+ brightness?: number;
148
+ ratio?: number;
149
+ solidity: boolean;
150
+ orderId: number;
151
+ }
152
+ declare class TaurusClient {
153
+ readonly connection: TaurusConnection;
154
+ private constructor();
155
+ static connect(options: TaurusConnectOptions): Promise<TaurusClient>;
156
+ login(options: TaurusLoginOptions): Promise<TaurusLoginResult>;
157
+ getBrightness(): Promise<TaurusBrightness>;
158
+ setBrightness(percent: number, persist?: boolean): Promise<void>;
159
+ getEnvironmentBrightness(): Promise<number>;
160
+ close(): void;
161
+ }
162
+ //#endregion
163
+ //#region src/discovery.d.ts
164
+ declare const TAURUS_DISCOVERY_PORT = 16601;
165
+ interface TaurusPlayerInfo {
166
+ address: string;
167
+ aliasName: string;
168
+ encodeType: number;
169
+ height: number;
170
+ modelId: number;
171
+ platform: string;
172
+ privacy: boolean;
173
+ productName: string;
174
+ rotation: number;
175
+ sn: string;
176
+ tcpPort: number;
177
+ width: number;
178
+ ftpPort?: number;
179
+ key?: string;
180
+ logined?: boolean;
181
+ loginedUsernames?: string[];
182
+ syssetFtpPort?: number;
183
+ syssetTcpPort?: number;
184
+ terminalEntrancePortHttps?: number;
185
+ terminalEntrancePortWebSocket?: number;
186
+ }
187
+ declare const parseTaurusDiscoveryResponse: (message: Uint8Array, address: string) => TaurusPlayerInfo | undefined;
188
+ declare const discoverTaurusPlayers: (destination?: string, timeout?: number) => Promise<TaurusPlayerInfo[]>;
189
+ //#endregion
190
+ export { TAURUS_DISCOVERY, TAURUS_DISCOVERY_PORT, TAURUS_HEADER_SIZE, TAURUS_MANAGEMENT_PORT, TAURUS_PACKET_FLAG, TAURUS_REQUEST, TAURUS_RESPONSE, TaurusBrightness, TaurusClient, TaurusCommand, TaurusConnectOptions, TaurusConnection, TaurusLoginOptions, TaurusLoginResult, TaurusPacket, TaurusPlayerInfo, TaurusRequest, TaurusResponse, TaurusResponseError, calculateTaurusHeaderChecksum, decodeTaurusPacket, discoverTaurusPlayers, encodeTaurusDiscoveryRequest, encodeTaurusRequest, getTaurusPacketSize, parseTaurusDiscoveryResponse };
191
+ //# sourceMappingURL=index.d.mts.map