//#region src/types.d.ts /** The parsed WPILOG file header. */ type DataLogHeader = { version: { major: number; minor: number; }; extraHeader: string; }; /** Control record types in the WPILOG format. */ declare enum ControlRecordType { Start = 0, Finish = 1, SetMetadata = 2 } /** A control record that starts a new entry. */ type StartControlRecord = { controlRecordType: ControlRecordType.Start; entryId: number; entryName: string; entryType: string; entryMetadata: string; }; /** A control record that finishes an entry. */ type FinishControlRecord = { controlRecordType: ControlRecordType.Finish; entryId: number; }; /** A control record that sets metadata on an entry. */ type SetMetadataControlRecord = { controlRecordType: ControlRecordType.SetMetadata; entryId: number; entryMetadata: string; }; /** A control record payload (start, finish, or set metadata). */ type ControlRecordPayload = StartControlRecord | FinishControlRecord | SetMetadataControlRecord; /** A raw (undecoded) data log record from the binary format. */ type RawRecord = { entryId: number; /** Timestamp in microseconds. */ timestamp: bigint; payload: Uint8Array; }; /** Discriminated union tag for decoded record types. */ declare enum RecordType { Control = "control", Boolean = "boolean", Int64 = "int64", Float = "float", Double = "double", String = "string", BooleanArray = "boolean[]", Int64Array = "int64[]", FloatArray = "float[]", DoubleArray = "double[]", StringArray = "string[]", Struct = "struct", StructArray = "struct[]", Raw = "raw" } /** Decoded struct payload — a map of field names to values. */ type StructPayload = Map; /** A decoded data record (excludes control records). */ type DataRecord = Extract; /** A decoded control record. */ type ControlRecord = Extract; /** Type guard that narrows a {@link DecodedRecord} to a {@link DataRecord}. */ declare function isDataRecord(record: DecodedRecord): record is DataRecord; /** A decoded data log record. */ type DecodedRecord = { entryId: number; /** Timestamp in microseconds. */ timestamp: bigint; } & ({ type: RecordType.Control; payload: ControlRecordPayload; } | ({ name: string; metadata: string; } & ({ type: RecordType.Raw; payload: Uint8Array; } | { type: RecordType.Boolean; payload: boolean; } | { type: RecordType.Int64; payload: bigint; } | { type: RecordType.Float; payload: number; } | { type: RecordType.Double; payload: number; } | { type: RecordType.String; payload: string; } | { type: RecordType.BooleanArray; payload: boolean[]; } | { type: RecordType.Int64Array; payload: bigint[]; } | { type: RecordType.FloatArray; payload: number[]; } | { type: RecordType.DoubleArray; payload: number[]; } | { type: RecordType.StringArray; payload: string[]; } | { type: RecordType.Struct; structName: string; payload: StructPayload; } | { type: RecordType.StructArray; structName: string; payload: StructPayload[]; }))); //#endregion //#region src/read-records.d.ts /** A raw record or control record yielded by {@link readRecords}. */ type ReadRecord = { kind: 'header'; header: DataLogHeader; } | { kind: 'control'; entryId: number; timestamp: bigint; payload: ControlRecordPayload; } | { kind: 'data'; record: RawRecord; }; /** Accepted input types for {@link readRecords}. */ type DataLogInput = Uint8Array | ArrayBuffer; /** * Read raw WPILOG records from an in-memory buffer. * * Yields a header record first, then control and data records in order. * Data record payloads are not decoded — use {@link decodeRecords} for that. */ declare function readRecords(input: DataLogInput): Generator; //#endregion //#region src/decode-records.d.ts /** Options for {@link decodeRecords}. */ type DecodeRecordsOptions = { /** * When `true`, throw if a data record references an entry ID with no preceding * Start control record (i.e. a corrupt or truncated log). When `false` (default), * such orphan records are silently skipped. */ strict?: boolean; }; /** * Decode raw WPILOG records into typed values. * * Accepts the output of {@link readRecords} and yields fully decoded records, * including struct decoding with dependency resolution. * * By default, data records that reference an entry ID with no preceding Start * control record are silently skipped. Pass `{ strict: true }` to throw instead. */ declare function decodeRecords(records: Iterable, options?: DecodeRecordsOptions): Generator; //#endregion //#region src/struct-payload-to-json.d.ts /** Convert a {@link StructPayload} Map to a plain JSON-compatible object. */ declare function structPayloadToJson(payload: StructPayload): object; //#endregion //#region src/catalog.d.ts /** An entry definition from the WPILOG catalog. */ type CatalogEntry = { entryId: number; name: string; type: string; metadata: string; }; /** * Collect all entry definitions from a WPILOG record stream. * * Iterates through records, collecting Start control records. * Data record bytes are still read from the stream but not decoded, * making this much cheaper than full decoding via {@link decodeRecords}. */ declare function catalogEntries(records: Iterable): Generator; //#endregion //#region src/struct/types.d.ts declare enum KnownStructTypeName { Boolean = "bool", Character = "char", Int8 = "int8", Int16 = "int16", Int32 = "int32", Int64 = "int64", Uint8 = "uint8", Uint16 = "uint16", Uint32 = "uint32", Uint64 = "uint64", Float32 = "float32", /** Equivalent to {@link KnownStructTypeName.Float32} */ Float = "float", Float64 = "float64", /** Equivalent to {@link KnownStructTypeName.Float64} */ Double = "double" } type StructTypeName = KnownStructTypeName | string; type EnumSpecification = Map; type StructSpecification = StructDeclaration[]; type StructDeclaration = { name: string; value: StructTypeName; enumSpecification?: EnumSpecification; arraySize?: number; bitWidth?: number; }; //#endregion //#region src/struct/parse-struct.d.ts /** Parse a WPILib struct specification string into declarations. */ declare function parseStructSpecification(declaration: string): StructDeclaration[]; //#endregion export { type CatalogEntry, type ControlRecord, type ControlRecordPayload, ControlRecordType, type DataLogHeader, type DataLogInput, type DataRecord, type DecodeRecordsOptions, type DecodedRecord, type EnumSpecification, type FinishControlRecord, KnownStructTypeName, type RawRecord, type ReadRecord, RecordType, type SetMetadataControlRecord, type StartControlRecord, type StructDeclaration, type StructPayload, type StructSpecification, type StructTypeName, catalogEntries, decodeRecords, isDataRecord, parseStructSpecification, readRecords, structPayloadToJson };