@ntcore-ts/client 1.0.0-beta.2
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/README.md +51 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +4845 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/lib/client.d.ts +262 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/pubsub/base-topic.d.ts +104 -0
- package/dist/lib/pubsub/base-topic.d.ts.map +1 -0
- package/dist/lib/pubsub/index.d.ts +6 -0
- package/dist/lib/pubsub/index.d.ts.map +1 -0
- package/dist/lib/pubsub/json-topic.d.ts +50 -0
- package/dist/lib/pubsub/json-topic.d.ts.map +1 -0
- package/dist/lib/pubsub/prefix-topic.d.ts +45 -0
- package/dist/lib/pubsub/prefix-topic.d.ts.map +1 -0
- package/dist/lib/pubsub/protobuf-schema-manager.d.ts +96 -0
- package/dist/lib/pubsub/protobuf-schema-manager.d.ts.map +1 -0
- package/dist/lib/pubsub/protobuf-topic.d.ts +126 -0
- package/dist/lib/pubsub/protobuf-topic.d.ts.map +1 -0
- package/dist/lib/pubsub/pubsub.d.ts +134 -0
- package/dist/lib/pubsub/pubsub.d.ts.map +1 -0
- package/dist/lib/pubsub/struct-topic.d.ts +40 -0
- package/dist/lib/pubsub/struct-topic.d.ts.map +1 -0
- package/dist/lib/pubsub/topic.d.ts +134 -0
- package/dist/lib/pubsub/topic.d.ts.map +1 -0
- package/dist/lib/socket/messenger.d.ts +104 -0
- package/dist/lib/socket/messenger.d.ts.map +1 -0
- package/dist/lib/socket/socket.d.ts +193 -0
- package/dist/lib/socket/socket.d.ts.map +1 -0
- package/dist/lib/struct/built-in-schemas.d.ts +21 -0
- package/dist/lib/struct/built-in-schemas.d.ts.map +1 -0
- package/dist/lib/struct/geometry.d.ts +129 -0
- package/dist/lib/struct/geometry.d.ts.map +1 -0
- package/dist/lib/struct/index.d.ts +5 -0
- package/dist/lib/struct/index.d.ts.map +1 -0
- package/dist/lib/struct/struct-codec.d.ts +14 -0
- package/dist/lib/struct/struct-codec.d.ts.map +1 -0
- package/dist/lib/struct/struct-descriptor.d.ts +60 -0
- package/dist/lib/struct/struct-descriptor.d.ts.map +1 -0
- package/dist/lib/struct/struct-parser.d.ts +28 -0
- package/dist/lib/struct/struct-parser.d.ts.map +1 -0
- package/dist/lib/struct/struct-schema-manager.d.ts +41 -0
- package/dist/lib/struct/struct-schema-manager.d.ts.map +1 -0
- package/dist/lib/types/index.d.ts +2 -0
- package/dist/lib/types/index.d.ts.map +1 -0
- package/dist/lib/types/schemas.d.ts +269 -0
- package/dist/lib/types/schemas.d.ts.map +1 -0
- package/dist/lib/types/types.d.ts +66 -0
- package/dist/lib/types/types.d.ts.map +1 -0
- package/dist/lib/util/logger.d.ts +60 -0
- package/dist/lib/util/logger.d.ts.map +1 -0
- package/dist/lib/util/util.d.ts +68 -0
- package/dist/lib/util/util.d.ts.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primitive type names and their byte sizes (WPILib struct schema).
|
|
3
|
+
*/
|
|
4
|
+
export declare const PRIMITIVE_SIZES: {
|
|
5
|
+
readonly bool: 1;
|
|
6
|
+
readonly char: 1;
|
|
7
|
+
readonly int8: 1;
|
|
8
|
+
readonly uint8: 1;
|
|
9
|
+
readonly int16: 2;
|
|
10
|
+
readonly uint16: 2;
|
|
11
|
+
readonly int32: 4;
|
|
12
|
+
readonly uint32: 4;
|
|
13
|
+
readonly int64: 8;
|
|
14
|
+
readonly uint64: 8;
|
|
15
|
+
readonly float: 4;
|
|
16
|
+
readonly float32: 4;
|
|
17
|
+
readonly double: 8;
|
|
18
|
+
readonly float64: 8;
|
|
19
|
+
};
|
|
20
|
+
export type PrimitiveTypeName = keyof typeof PRIMITIVE_SIZES;
|
|
21
|
+
/**
|
|
22
|
+
* Descriptor for a single field in a struct (with resolved offset/size for layout).
|
|
23
|
+
*/
|
|
24
|
+
export interface StructFieldDescriptor {
|
|
25
|
+
name: string;
|
|
26
|
+
/** Byte offset of this field within the struct. */
|
|
27
|
+
offset: number;
|
|
28
|
+
/** Storage size in bytes for one element. */
|
|
29
|
+
size: number;
|
|
30
|
+
/** 1 for non-array, >1 for fixed-size array. */
|
|
31
|
+
arraySize: number;
|
|
32
|
+
/** 0 for non-bitfield, 1–N for bitfield width in bits. */
|
|
33
|
+
bitWidth: number;
|
|
34
|
+
/** Bit offset within the storage unit (for coalesced bitfields). */
|
|
35
|
+
bitShift: number;
|
|
36
|
+
/** For enum fields: enum name → integer value. */
|
|
37
|
+
enumValues?: Record<string, number>;
|
|
38
|
+
/** Set for primitive fields. */
|
|
39
|
+
primitive?: PrimitiveTypeName;
|
|
40
|
+
/** Set for nested struct fields (resolved descriptor). */
|
|
41
|
+
nestedDescriptor?: StructDescriptor;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Descriptor for a struct type: type name, total size, and ordered fields.
|
|
45
|
+
*/
|
|
46
|
+
export interface StructDescriptor {
|
|
47
|
+
typeName: string;
|
|
48
|
+
/** Total size in bytes. */
|
|
49
|
+
size: number;
|
|
50
|
+
fields: StructFieldDescriptor[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the size in bytes of a primitive type.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getPrimitiveSize(primitive: PrimitiveTypeName): number;
|
|
56
|
+
/**
|
|
57
|
+
* Returns whether the given string is a known primitive type name.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isPrimitiveType(typeName: string): typeName is PrimitiveTypeName;
|
|
60
|
+
//# sourceMappingURL=struct-descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct-descriptor.d.ts","sourceRoot":"","sources":["../../../src/lib/struct/struct-descriptor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;CAee,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,eAAe,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,gCAAgC;IAChC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,qBAAqB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,iBAAiB,GAAG,MAAM,CAMrE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,IAAI,iBAAiB,CAE/E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type StructDescriptor } from './struct-descriptor';
|
|
2
|
+
export type ParsedField = {
|
|
3
|
+
typeName: string;
|
|
4
|
+
name: string;
|
|
5
|
+
arraySize: number;
|
|
6
|
+
bitWidth: number;
|
|
7
|
+
enumValues?: Record<string, number>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Parses a WPILib struct schema string into a list of field declarations.
|
|
11
|
+
* @param schema - Schema string (e.g. "double x;double y" or "Translation2d translation;Rotation2d rotation").
|
|
12
|
+
* @returns Array of parsed fields.
|
|
13
|
+
* @throws Error on malformed schema.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseSchema(schema: string): ParsedField[];
|
|
16
|
+
/**
|
|
17
|
+
* Builds a StructDescriptor from parsed fields and a resolver for nested struct sizes.
|
|
18
|
+
*
|
|
19
|
+
* Implements the WPILib `StructDescriptor.calculateOffsets()` algorithm for bitfield
|
|
20
|
+
* coalescing. Fields are densely packed with no alignment padding. Consecutive bitfields
|
|
21
|
+
* of the same underlying type share a single storage unit (e.g. two `uint8:4` fields
|
|
22
|
+
* occupy 1 byte, not 2). When the type changes or bits overflow the storage unit, a new
|
|
23
|
+
* unit starts.
|
|
24
|
+
*
|
|
25
|
+
* @see https://github.com/wpilibsuite/allwpilib — StructDescriptor.java, calculateOffsets()
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildStructDescriptor(typeName: string, parsedFields: ParsedField[], getNestedDescriptor: (name: string) => StructDescriptor | null): StructDescriptor;
|
|
28
|
+
//# sourceMappingURL=struct-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct-parser.d.ts","sourceRoot":"","sources":["../../../src/lib/struct/struct-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,qBAAqB,CAAC;AAW7B,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,CAAC;AA0DF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CA6DzD;AA0BD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,WAAW,EAAE,EAC3B,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,GAAG,IAAI,GAC7D,gBAAgB,CAiGlB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { StructDescriptor } from './struct-descriptor';
|
|
2
|
+
import type { PubSubClient } from '../pubsub/pubsub';
|
|
3
|
+
/**
|
|
4
|
+
* Manages struct schema fetching and caching from NetworkTables.
|
|
5
|
+
* Subscribes to `/.schema/struct:*` and parses/caches descriptors by type name.
|
|
6
|
+
*/
|
|
7
|
+
export declare class StructSchemaManager {
|
|
8
|
+
private readonly parsedFieldsCache;
|
|
9
|
+
private readonly descriptorCache;
|
|
10
|
+
private readonly schemaStringCache;
|
|
11
|
+
private readonly pendingTypeNames;
|
|
12
|
+
/** Type names for which we have already published a schema topic (avoids redundant republish). */
|
|
13
|
+
private readonly publishedSchemaTypes;
|
|
14
|
+
private readonly schemaPrefixTopic;
|
|
15
|
+
private readonly client;
|
|
16
|
+
constructor(client: PubSubClient);
|
|
17
|
+
/**
|
|
18
|
+
* Handles schema updates from the prefix topic subscription.
|
|
19
|
+
* Decodes UTF-8 bytes to string, parses schema, and caches descriptor when dependencies are ready.
|
|
20
|
+
* @param value - The value of the schema update (null when a topic is unannounced).
|
|
21
|
+
* @param params - The parameters of the announce message.
|
|
22
|
+
*/
|
|
23
|
+
private handleSchemaUpdate;
|
|
24
|
+
private getNested;
|
|
25
|
+
private tryBuildPending;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the struct descriptor for the given type name or type string (e.g. "Pose2d" or "struct:Pose2d").
|
|
28
|
+
* Returns null if not in cache and not a built-in (built-ins are resolved on first use).
|
|
29
|
+
*/
|
|
30
|
+
fetchDescriptor(typeNameOrTypeString: string): StructDescriptor | null;
|
|
31
|
+
hasSchema(typeString: string): boolean;
|
|
32
|
+
clearCache(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Publishes nested struct schemas to NetworkTables (nested first), then the given descriptor's schema.
|
|
35
|
+
* Used when publishing a struct topic so subscribers can decode.
|
|
36
|
+
*/
|
|
37
|
+
addSchema(descriptor: StructDescriptor): Promise<void>;
|
|
38
|
+
private collectNestedTypeNames;
|
|
39
|
+
private publishSchemaTopic;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=struct-schema-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"struct-schema-manager.d.ts","sourceRoot":"","sources":["../../../src/lib/struct/struct-schema-manager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKrD;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoC;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuC;IACvE,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA6B;IAC/D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAqB;IACtD,kGAAkG;IAClG,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA2B;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,YAAY;IAUhC;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;IAqB1B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,eAAe;IAoBvB;;;OAGG;IACH,eAAe,CAAC,oBAAoB,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAStE,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAItC,UAAU,IAAI,IAAI;IAQlB;;;OAGG;IACG,SAAS,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5D,OAAO,CAAC,sBAAsB;YAgBhB,kBAAkB;CAgCjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Schema for an integer. */
|
|
3
|
+
export declare const finiteNumSchema: z.ZodNumber;
|
|
4
|
+
export declare const integerSchema: z.ZodNumber;
|
|
5
|
+
/** Schema for type numbers in the NT protocol. */
|
|
6
|
+
export declare const typeNumSchema: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<16>, z.ZodLiteral<17>, z.ZodLiteral<18>, z.ZodLiteral<19>, z.ZodLiteral<20>]>;
|
|
7
|
+
/** Schema for type strings in the NT protocol (JSON text frames always use strings per NT 4.1 spec). */
|
|
8
|
+
export declare const typeStringSchema: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
9
|
+
/** Schema for topic properties in the NT protocol. */
|
|
10
|
+
export declare const topicPropertiesSchema: z.ZodObject<{
|
|
11
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
/** Schema for a topic in the NT protocol. */
|
|
16
|
+
export declare const topicSchema: z.ZodObject<{
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
id: z.ZodNumber;
|
|
19
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
20
|
+
properties: z.ZodObject<{
|
|
21
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
/** Schema for subscription options in the NT protocol. */
|
|
27
|
+
export declare const subscriptionOptionsSchema: z.ZodObject<{
|
|
28
|
+
periodic: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
all: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
topicsonly: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
prefix: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
/** Schema for the publish message in the NT protocol. */
|
|
34
|
+
export declare const publishMessageParamsSchema: z.ZodObject<{
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
pubuid: z.ZodNumber;
|
|
37
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
38
|
+
properties: z.ZodObject<{
|
|
39
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
/** Schema for the unpublish message params in the NT protocol. */
|
|
45
|
+
export declare const unpublishMessageParamsSchema: z.ZodObject<{
|
|
46
|
+
pubuid: z.ZodNumber;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
/** Schema for the set properties message params in the NT protocol. */
|
|
49
|
+
export declare const setPropertiesMessageParamsSchema: z.ZodObject<{
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
update: z.ZodObject<{
|
|
52
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
/** Schema for the subscribe message params in the NT protocol. */
|
|
58
|
+
export declare const subscribeMessageParamsSchema: z.ZodObject<{
|
|
59
|
+
topics: z.ZodArray<z.ZodString>;
|
|
60
|
+
subuid: z.ZodNumber;
|
|
61
|
+
options: z.ZodObject<{
|
|
62
|
+
periodic: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
all: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
topicsonly: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
prefix: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
/** Schema for the unsubscribe message params in the NT protocol. */
|
|
69
|
+
export declare const unsubscribeMessageParamsSchema: z.ZodObject<{
|
|
70
|
+
subuid: z.ZodNumber;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
/** Schema for the announce message params in the NT protocol. */
|
|
73
|
+
export declare const announceMessageParamsSchema: z.ZodObject<{
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
id: z.ZodNumber;
|
|
76
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
77
|
+
properties: z.ZodObject<{
|
|
78
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
pubuid: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
/** Schema for the unannounce message params in the NT protocol. */
|
|
85
|
+
export declare const unannounceMessageParamsSchema: z.ZodObject<{
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
id: z.ZodNumber;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
/** Schema for the properties message params in the NT protocol. */
|
|
90
|
+
export declare const propertiesMessageParamsSchema: z.ZodObject<{
|
|
91
|
+
name: z.ZodString;
|
|
92
|
+
ack: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
update: z.ZodObject<{
|
|
94
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
96
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
/** Schema for a publish message in the NT protocol. */
|
|
100
|
+
export declare const publishMessageSchema: z.ZodObject<{
|
|
101
|
+
method: z.ZodLiteral<"publish">;
|
|
102
|
+
params: z.ZodObject<{
|
|
103
|
+
name: z.ZodString;
|
|
104
|
+
pubuid: z.ZodNumber;
|
|
105
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
106
|
+
properties: z.ZodObject<{
|
|
107
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
108
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
109
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
/** Schema for an unpublish message in the NT protocol. */
|
|
114
|
+
export declare const unpublishMessageSchema: z.ZodObject<{
|
|
115
|
+
method: z.ZodLiteral<"unpublish">;
|
|
116
|
+
params: z.ZodObject<{
|
|
117
|
+
pubuid: z.ZodNumber;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
/** Schema for a setproperties message in the NT protocol. */
|
|
121
|
+
export declare const setPropertiesMessageSchema: z.ZodObject<{
|
|
122
|
+
method: z.ZodLiteral<"setproperties">;
|
|
123
|
+
params: z.ZodObject<{
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
update: z.ZodObject<{
|
|
126
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
127
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
128
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
}, z.core.$strip>;
|
|
132
|
+
/** Schema for a subscribe message in the NT protocol. */
|
|
133
|
+
export declare const subscribeMessageSchema: z.ZodObject<{
|
|
134
|
+
method: z.ZodLiteral<"subscribe">;
|
|
135
|
+
params: z.ZodObject<{
|
|
136
|
+
topics: z.ZodArray<z.ZodString>;
|
|
137
|
+
subuid: z.ZodNumber;
|
|
138
|
+
options: z.ZodObject<{
|
|
139
|
+
periodic: z.ZodOptional<z.ZodNumber>;
|
|
140
|
+
all: z.ZodOptional<z.ZodBoolean>;
|
|
141
|
+
topicsonly: z.ZodOptional<z.ZodBoolean>;
|
|
142
|
+
prefix: z.ZodOptional<z.ZodBoolean>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
}, z.core.$strip>;
|
|
146
|
+
/** Schema for an unsubscribe message in the NT protocol. */
|
|
147
|
+
export declare const unsubscribeMessageSchema: z.ZodObject<{
|
|
148
|
+
method: z.ZodLiteral<"unsubscribe">;
|
|
149
|
+
params: z.ZodObject<{
|
|
150
|
+
subuid: z.ZodNumber;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
/** Schema for an announce message in the NT protocol. */
|
|
154
|
+
export declare const announceMessageSchema: z.ZodObject<{
|
|
155
|
+
method: z.ZodLiteral<"announce">;
|
|
156
|
+
params: z.ZodObject<{
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
id: z.ZodNumber;
|
|
159
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
160
|
+
properties: z.ZodObject<{
|
|
161
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
162
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
163
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
164
|
+
}, z.core.$strip>;
|
|
165
|
+
pubuid: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
/** Schema for an unannounce message in the NT protocol. */
|
|
169
|
+
export declare const unannounceMessageSchema: z.ZodObject<{
|
|
170
|
+
method: z.ZodLiteral<"unannounce">;
|
|
171
|
+
params: z.ZodObject<{
|
|
172
|
+
name: z.ZodString;
|
|
173
|
+
id: z.ZodNumber;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
}, z.core.$strip>;
|
|
176
|
+
/** Schema for a properties message in the NT protocol. */
|
|
177
|
+
export declare const propertiesMessageSchema: z.ZodObject<{
|
|
178
|
+
method: z.ZodLiteral<"properties">;
|
|
179
|
+
params: z.ZodObject<{
|
|
180
|
+
name: z.ZodString;
|
|
181
|
+
ack: z.ZodOptional<z.ZodBoolean>;
|
|
182
|
+
update: z.ZodObject<{
|
|
183
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
184
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
185
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
186
|
+
}, z.core.$strip>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
/** Schema for a text frame message in the NT protocol. */
|
|
190
|
+
export declare const messageSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
191
|
+
method: z.ZodLiteral<"publish">;
|
|
192
|
+
params: z.ZodObject<{
|
|
193
|
+
name: z.ZodString;
|
|
194
|
+
pubuid: z.ZodNumber;
|
|
195
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
196
|
+
properties: z.ZodObject<{
|
|
197
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
198
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
199
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
200
|
+
}, z.core.$strip>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
203
|
+
method: z.ZodLiteral<"unpublish">;
|
|
204
|
+
params: z.ZodObject<{
|
|
205
|
+
pubuid: z.ZodNumber;
|
|
206
|
+
}, z.core.$strip>;
|
|
207
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
208
|
+
method: z.ZodLiteral<"setproperties">;
|
|
209
|
+
params: z.ZodObject<{
|
|
210
|
+
name: z.ZodString;
|
|
211
|
+
update: z.ZodObject<{
|
|
212
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
213
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
}, z.core.$strip>;
|
|
217
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
218
|
+
method: z.ZodLiteral<"subscribe">;
|
|
219
|
+
params: z.ZodObject<{
|
|
220
|
+
topics: z.ZodArray<z.ZodString>;
|
|
221
|
+
subuid: z.ZodNumber;
|
|
222
|
+
options: z.ZodObject<{
|
|
223
|
+
periodic: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
all: z.ZodOptional<z.ZodBoolean>;
|
|
225
|
+
topicsonly: z.ZodOptional<z.ZodBoolean>;
|
|
226
|
+
prefix: z.ZodOptional<z.ZodBoolean>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
230
|
+
method: z.ZodLiteral<"unsubscribe">;
|
|
231
|
+
params: z.ZodObject<{
|
|
232
|
+
subuid: z.ZodNumber;
|
|
233
|
+
}, z.core.$strip>;
|
|
234
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
235
|
+
method: z.ZodLiteral<"announce">;
|
|
236
|
+
params: z.ZodObject<{
|
|
237
|
+
name: z.ZodString;
|
|
238
|
+
id: z.ZodNumber;
|
|
239
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"boolean">, z.ZodLiteral<"double">, z.ZodLiteral<"int">, z.ZodLiteral<"float">, z.ZodLiteral<"string">, z.ZodLiteral<"json">, z.ZodLiteral<"raw">, z.ZodLiteral<"rpc">, z.ZodLiteral<"msgpack">, z.ZodLiteral<"structschema">, z.ZodLiteral<"protobuf">, z.ZodLiteral<"boolean[]">, z.ZodLiteral<"double[]">, z.ZodLiteral<"int[]">, z.ZodLiteral<"float[]">, z.ZodLiteral<"string[]">, z.ZodString, z.ZodString, z.ZodString]>;
|
|
240
|
+
properties: z.ZodObject<{
|
|
241
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
242
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
244
|
+
}, z.core.$strip>;
|
|
245
|
+
pubuid: z.ZodOptional<z.ZodNumber>;
|
|
246
|
+
}, z.core.$strip>;
|
|
247
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
248
|
+
method: z.ZodLiteral<"unannounce">;
|
|
249
|
+
params: z.ZodObject<{
|
|
250
|
+
name: z.ZodString;
|
|
251
|
+
id: z.ZodNumber;
|
|
252
|
+
}, z.core.$strip>;
|
|
253
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
254
|
+
method: z.ZodLiteral<"properties">;
|
|
255
|
+
params: z.ZodObject<{
|
|
256
|
+
name: z.ZodString;
|
|
257
|
+
ack: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
update: z.ZodObject<{
|
|
259
|
+
persistent: z.ZodOptional<z.ZodBoolean>;
|
|
260
|
+
retained: z.ZodOptional<z.ZodBoolean>;
|
|
261
|
+
cached: z.ZodOptional<z.ZodBoolean>;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
}, z.core.$strip>;
|
|
264
|
+
}, z.core.$strip>], "method">>;
|
|
265
|
+
/** Schema for a value in the msgpack format. */
|
|
266
|
+
export declare const msgPackValueSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodNumber, z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodArray<z.ZodBoolean>, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodNumber>, z.ZodArray<z.ZodNumber>]>;
|
|
267
|
+
/** Schema for a binary message in the msgpack format. */
|
|
268
|
+
export declare const msgPackSchema: z.ZodTuple<[z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<-1>]>, z.ZodNumber, z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<16>, z.ZodLiteral<17>, z.ZodLiteral<18>, z.ZodLiteral<19>, z.ZodLiteral<20>]>, z.ZodUnion<readonly [z.ZodBoolean, z.ZodNumber, z.ZodNumber, z.ZodString, z.ZodCustom<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>>, z.ZodArray<z.ZodBoolean>, z.ZodArray<z.ZodString>, z.ZodArray<z.ZodNumber>, z.ZodArray<z.ZodNumber>]>], null>;
|
|
269
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/lib/types/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6BAA6B;AAC7B,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,aAAa,aAAwB,CAAC;AAEnD,kDAAkD;AAClD,eAAO,MAAM,aAAa,uNAYxB,CAAC;AAEH,wGAAwG;AACxG,eAAO,MAAM,gBAAgB,mcAoB3B,CAAC;AAEH,sDAAsD;AACtD,eAAO,MAAM,qBAAqB;;;;iBAMtB,CAAC;AAEb,6CAA6C;AAC7C,eAAO,MAAM,WAAW;;;;;;;;;iBAKtB,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,yBAAyB;;;;;iBAO1B,CAAC;AAEb,yDAAyD;AACzD,eAAO,MAAM,0BAA0B;;;;;;;;;iBAKrC,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,4BAA4B;;iBAEvC,CAAC;AAEH,uEAAuE;AACvE,eAAO,MAAM,gCAAgC;;;;;;;iBAG3C,CAAC;AAEH,kEAAkE;AAClE,eAAO,MAAM,4BAA4B;;;;;;;;;iBAIvC,CAAC;AAEH,oEAAoE;AACpE,eAAO,MAAM,8BAA8B;;iBAEzC,CAAC;AAEH,iEAAiE;AACjE,eAAO,MAAM,2BAA2B;;;;;;;;;;iBAEtC,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,6BAA6B;;;iBAGxC,CAAC;AAEH,mEAAmE;AACnE,eAAO,MAAM,6BAA6B;;;;;;;;iBAIxC,CAAC;AAEH,uDAAuD;AACvD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;iBAG/B,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,sBAAsB;;;;;iBAGjC,CAAC;AAEH,6DAA6D;AAC7D,eAAO,MAAM,0BAA0B;;;;;;;;;;iBAGrC,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,sBAAsB;;;;;;;;;;;;iBAGjC,CAAC;AAEH,4DAA4D;AAC5D,eAAO,MAAM,wBAAwB;;;;;iBAGnC,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,2DAA2D;AAC3D,eAAO,MAAM,uBAAuB;;;;;;iBAGlC,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB;;;;;;;;;;;iBAGlC,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAWzB,CAAC;AAEF,gDAAgD;AAChD,eAAO,MAAM,kBAAkB,wPAU7B,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,aAAa,siBAKxB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { typeStringSchema, announceMessageSchema, msgPackSchema, msgPackValueSchema, propertiesMessageSchema, publishMessageSchema, setPropertiesMessageSchema, subscribeMessageSchema, subscriptionOptionsSchema, topicPropertiesSchema, unannounceMessageSchema, unpublishMessageSchema, unsubscribeMessageSchema, typeNumSchema } from './schemas';
|
|
3
|
+
export type TypeString = z.infer<typeof typeStringSchema>;
|
|
4
|
+
export type TypeNum = z.infer<typeof typeNumSchema>;
|
|
5
|
+
export type NetworkTablesTypeInfo = [TypeNum, TypeString];
|
|
6
|
+
export type PublishMessage = z.infer<typeof publishMessageSchema>;
|
|
7
|
+
export type UnpublishMessage = z.infer<typeof unpublishMessageSchema>;
|
|
8
|
+
export type SetPropertiesMessage = z.infer<typeof setPropertiesMessageSchema>;
|
|
9
|
+
export type SubscribeMessage = z.infer<typeof subscribeMessageSchema>;
|
|
10
|
+
export type SubscribeOptions = z.infer<typeof subscriptionOptionsSchema> & {
|
|
11
|
+
/**
|
|
12
|
+
* If true, invoke the callback once with the current value after registering.
|
|
13
|
+
* This is a client-side option and is not sent to the NT server.
|
|
14
|
+
*/
|
|
15
|
+
immediateNotify?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type UnsubscribeMessage = z.infer<typeof unsubscribeMessageSchema>;
|
|
18
|
+
export type AnnounceMessage = z.infer<typeof announceMessageSchema>;
|
|
19
|
+
export type UnannounceMessage = z.infer<typeof unannounceMessageSchema>;
|
|
20
|
+
export type PropertiesMessage = z.infer<typeof propertiesMessageSchema>;
|
|
21
|
+
export type Message = PublishMessage | UnpublishMessage | SetPropertiesMessage | SubscribeMessage | UnsubscribeMessage | AnnounceMessage | UnannounceMessage | PropertiesMessage;
|
|
22
|
+
export type PublishMessageParams = PublishMessage['params'];
|
|
23
|
+
export type UnpublishMessageParams = UnpublishMessage['params'];
|
|
24
|
+
export type SetPropertiesMessageParams = SetPropertiesMessage['params'];
|
|
25
|
+
export type SubscribeMessageParams = SubscribeMessage['params'];
|
|
26
|
+
export type UnsubscribeMessageParams = UnsubscribeMessage['params'];
|
|
27
|
+
export type AnnounceMessageParams = AnnounceMessage['params'];
|
|
28
|
+
export type UnannounceMessageParams = UnannounceMessage['params'];
|
|
29
|
+
export type PropertiesMessageParams = PropertiesMessage['params'];
|
|
30
|
+
export type NetworkTablesTypes = z.infer<typeof msgPackValueSchema>;
|
|
31
|
+
export type BinaryMessage = z.infer<typeof msgPackSchema>;
|
|
32
|
+
export type TopicProperties = z.infer<typeof topicPropertiesSchema>;
|
|
33
|
+
export declare class NetworkTablesTypeInfos {
|
|
34
|
+
static readonly kBoolean: NetworkTablesTypeInfo;
|
|
35
|
+
static readonly kDouble: NetworkTablesTypeInfo;
|
|
36
|
+
static readonly kInteger: NetworkTablesTypeInfo;
|
|
37
|
+
static readonly kFloat: NetworkTablesTypeInfo;
|
|
38
|
+
static readonly kString: NetworkTablesTypeInfo;
|
|
39
|
+
static readonly kJson: [4, "json"];
|
|
40
|
+
static readonly kUint8Array: NetworkTablesTypeInfo;
|
|
41
|
+
static readonly kRPC: NetworkTablesTypeInfo;
|
|
42
|
+
static readonly kMsgpack: NetworkTablesTypeInfo;
|
|
43
|
+
static readonly kProtobuf: NetworkTablesTypeInfo;
|
|
44
|
+
/** Type info for struct schema topics (/.schema/struct:TypeName). Wire type 5 (raw bytes), type string 'structschema'. */
|
|
45
|
+
static readonly kStructSchema: NetworkTablesTypeInfo;
|
|
46
|
+
static readonly kBooleanArray: NetworkTablesTypeInfo;
|
|
47
|
+
static readonly kDoubleArray: NetworkTablesTypeInfo;
|
|
48
|
+
static readonly kIntegerArray: NetworkTablesTypeInfo;
|
|
49
|
+
static readonly kFloatArray: NetworkTablesTypeInfo;
|
|
50
|
+
static readonly kStringArray: NetworkTablesTypeInfo;
|
|
51
|
+
/**
|
|
52
|
+
* Validates and parses a value based on the expected NetworkTables type information.
|
|
53
|
+
* @param expectedTypeInfo - The expected type information from `NetworkTablesTypeInfo`.
|
|
54
|
+
* @param value - The value to validate and parse.
|
|
55
|
+
* @returns The parsed value, matching the expected type.
|
|
56
|
+
* @throws Will throw an error if the value does not match the expected type or if parsing fails.
|
|
57
|
+
*/
|
|
58
|
+
static validateData(expectedTypeInfo: NetworkTablesTypeInfo, value: NetworkTablesTypes): NetworkTablesTypes;
|
|
59
|
+
}
|
|
60
|
+
export interface BinaryMessageData {
|
|
61
|
+
topicId: number;
|
|
62
|
+
serverTime: number;
|
|
63
|
+
typeNum: TypeNum;
|
|
64
|
+
value: NetworkTablesTypes;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Logger, type ILogObj } from 'tslog';
|
|
2
|
+
/**
|
|
3
|
+
* Log levels available for configuration.
|
|
4
|
+
* These map to tslog's log levels:
|
|
5
|
+
* - TRACE = 1 (tslog's trace)
|
|
6
|
+
* - DEBUG = 2 (tslog's debug)
|
|
7
|
+
* - INFO = 3 (tslog's info)
|
|
8
|
+
* - WARN = 4 (tslog's warn)
|
|
9
|
+
* - ERROR = 5 (tslog's error)
|
|
10
|
+
* - FATAL = 6 (tslog's fatal)
|
|
11
|
+
* - SILENT = 99 (disable all logging, not a tslog level)
|
|
12
|
+
*/
|
|
13
|
+
export declare enum LogLevel {
|
|
14
|
+
/** Very detailed debugging information (maps to tslog's trace level 1) */
|
|
15
|
+
TRACE = 1,
|
|
16
|
+
/** Detailed debugging information (maps to tslog's debug level 2) */
|
|
17
|
+
DEBUG = 2,
|
|
18
|
+
/** General informational messages (maps to tslog's info level 3) */
|
|
19
|
+
INFO = 3,
|
|
20
|
+
/** Warning messages (maps to tslog's warn level 4) */
|
|
21
|
+
WARN = 4,
|
|
22
|
+
/** Error messages (maps to tslog's error level 5) */
|
|
23
|
+
ERROR = 5,
|
|
24
|
+
/** Fatal error messages (maps to tslog's fatal level 6) */
|
|
25
|
+
FATAL = 6,
|
|
26
|
+
/** Disable all logging (uses 99, not a tslog level) */
|
|
27
|
+
SILENT = 99
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Module names for granular logging control.
|
|
31
|
+
*/
|
|
32
|
+
export type LoggerModule = 'socket' | 'messenger' | 'pubsub' | 'default';
|
|
33
|
+
/**
|
|
34
|
+
* Gets or creates a logger instance for a specific module.
|
|
35
|
+
* @param module - The module name.
|
|
36
|
+
* @returns A logger instance configured for the module.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getLogger(module?: LoggerModule): Logger<ILogObj>;
|
|
39
|
+
/**
|
|
40
|
+
* Sets the log level for all loggers.
|
|
41
|
+
* @param level - The log level to set.
|
|
42
|
+
*/
|
|
43
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
44
|
+
/**
|
|
45
|
+
* Sets the log level for a specific module.
|
|
46
|
+
* @param module - The module name.
|
|
47
|
+
* @param level - The log level to set.
|
|
48
|
+
*/
|
|
49
|
+
export declare function setModuleLogLevel(module: LoggerModule, level: LogLevel): void;
|
|
50
|
+
/**
|
|
51
|
+
* Gets the current log level for a specific module.
|
|
52
|
+
* @param module - The module name.
|
|
53
|
+
* @returns The current log level.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getModuleLogLevel(module?: LoggerModule): LogLevel;
|
|
56
|
+
export declare const socketLogger: Logger<ILogObj>;
|
|
57
|
+
export declare const messengerLogger: Logger<ILogObj>;
|
|
58
|
+
export declare const pubsubLogger: Logger<ILogObj>;
|
|
59
|
+
export declare const defaultLogger: Logger<ILogObj>;
|
|
60
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/lib/util/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,oBAAY,QAAQ;IAClB,0EAA0E;IAC1E,KAAK,IAAI;IACT,qEAAqE;IACrE,KAAK,IAAI;IACT,oEAAoE;IACpE,IAAI,IAAI;IACR,sDAAsD;IACtD,IAAI,IAAI;IACR,qDAAqD;IACrD,KAAK,IAAI;IACT,2DAA2D;IAC3D,KAAK,IAAI;IACT,uDAAuD;IACvD,MAAM,KAAK;CACZ;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AA2BzE;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAE,YAAwB,GAAG,MAAM,CAAC,OAAO,CAAC,CAS3E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAYjD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAS7E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,YAAwB,GAAG,QAAQ,CAe5E;AAwBD,eAAO,MAAM,YAAY,iBAA8B,CAAC;AACxD,eAAO,MAAM,eAAe,iBAAiC,CAAC;AAC9D,eAAO,MAAM,YAAY,iBAA8B,CAAC;AACxD,eAAO,MAAM,aAAa,iBAA+B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { BinaryMessage, NetworkTablesTypeInfo, NetworkTablesTypes } from '../types/types';
|
|
2
|
+
/** Robot controller used to resolve a team number to a hostname. */
|
|
3
|
+
export type RobotPlatform = 'roborio' | 'systemcore';
|
|
4
|
+
/** SystemCore mDNS name (WPILib `SetServerFixed`). Use as a URI, not as a team mapping. */
|
|
5
|
+
export declare const SYSTEMCORE_MDNS_HOST = "robot.local";
|
|
6
|
+
/**
|
|
7
|
+
* Field/radio IPv4 for a team (`10.TE.AM.2`), matching WPILib `SetServerTeam`.
|
|
8
|
+
* Team 973 → `10.9.73.2`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTeamIpAddress(team: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Hostname used for a team-number connection.
|
|
13
|
+
* RoboRIO (default): `roborio-{team}-frc.local`.
|
|
14
|
+
* SystemCore: `10.TE.AM.2` (WPILib `SetServerTeam`). Use {@link SYSTEMCORE_MDNS_HOST} as a URI for `robot.local`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getRobotAddress(team: number, platform?: RobotPlatform): string;
|
|
17
|
+
export type ParsedRobotAddress = {
|
|
18
|
+
platform: 'roborio';
|
|
19
|
+
team: number;
|
|
20
|
+
} | {
|
|
21
|
+
platform: 'systemcore';
|
|
22
|
+
team: number;
|
|
23
|
+
} | {
|
|
24
|
+
platform: null;
|
|
25
|
+
team: null;
|
|
26
|
+
};
|
|
27
|
+
/** Detects a RoboRIO mDNS name or SystemCore team IP. Other hosts return `{ platform: null, team: null }`. */
|
|
28
|
+
export declare function parseRobotAddress(host: string): ParsedRobotAddress;
|
|
29
|
+
/**
|
|
30
|
+
* Class for holding utility functions.
|
|
31
|
+
*/
|
|
32
|
+
export declare class Util {
|
|
33
|
+
/**
|
|
34
|
+
* Get the DOM time in microseconds.
|
|
35
|
+
* @returns The current microseconds of the DOM.
|
|
36
|
+
*/
|
|
37
|
+
static getMicros(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Given a number, determine if it is a double
|
|
40
|
+
* @param x - A number.
|
|
41
|
+
* @returns Whether it is a double.
|
|
42
|
+
*/
|
|
43
|
+
static isDouble(x: number): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Create a binary message from a topic.
|
|
46
|
+
* @param pubuid - The topic's publisher UID.
|
|
47
|
+
* @param timestamp - The timestamp of the message, matching the server.
|
|
48
|
+
* @param data - The data.
|
|
49
|
+
* @param typeInfo - The type info.
|
|
50
|
+
* @returns The binary message.
|
|
51
|
+
*/
|
|
52
|
+
static createBinaryMessage(pubuid: number, timestamp: number, data: NetworkTablesTypes, typeInfo: NetworkTablesTypeInfo): BinaryMessage;
|
|
53
|
+
/**
|
|
54
|
+
* Create a server URL for connecting to the robot.
|
|
55
|
+
* @param uri - The URI of the robot.
|
|
56
|
+
* @param port - The port of NT server on the robot.
|
|
57
|
+
* @returns The server URL with a unique client ID.
|
|
58
|
+
*/
|
|
59
|
+
static createServerUrl(uri: string, port: number): string;
|
|
60
|
+
/**
|
|
61
|
+
* Get the hostname of a robot for a team number.
|
|
62
|
+
* @param team - The team number.
|
|
63
|
+
* @param platform - RoboRIO mDNS (default) or SystemCore team IP.
|
|
64
|
+
* @returns The hostname or IPv4 address.
|
|
65
|
+
*/
|
|
66
|
+
static getRobotAddress(team: number, platform?: RobotPlatform): string;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/lib/util/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE/F,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,YAAY,CAAC;AAErD,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAQlD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMrD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,aAAyB,GAAG,MAAM,CAKzF;AAED,MAAM,MAAM,kBAAkB,GAC5B;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAEpH,8GAA8G;AAC9G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAiBlE;AAED;;GAEG;AACH,qBAAa,IAAI;IACf;;;OAGG;IACH,MAAM,CAAC,SAAS;IAIhB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM;IAQzB;;;;;;;OAOG;IACH,MAAM,CAAC,mBAAmB,CACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,kBAAkB,EACxB,QAAQ,EAAE,qBAAqB,GAC9B,aAAa;IAIhB;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIzD;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,aAAyB,GAAG,MAAM;CAGlF"}
|