wpilog-parser 3.1.1 → 3.2.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/cli.mjs CHANGED
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { o as readRecords, t as catalogEntries, u as diagnostics } from "./catalog-BmNQKX4c.mjs";
2
+ import { a as readRecords, l as diagnostics, t as catalogEntries } from "./catalog-hof8DZhi.mjs";
3
3
  import { Diagnostic, formatDiagnostic } from "nostics";
4
- import tab from "@bomb.sh/tab/cac";
5
- import { cac } from "cac";
4
+ import { RootCommand, script } from "@bomb.sh/tab";
5
+ import { boolean, command, commandsInfo, positional, run } from "@drizzle-team/brocli";
6
6
  import oscStatus from "osc-status";
7
7
  import { readFile } from "node:fs/promises";
8
8
  import { encode } from "@toon-format/toon";
9
9
  // package.json
10
- var version = "3.1.1";
10
+ var version = "3.2.0";
11
+ var description = "Read WPILib wpilog data log files in TypeScript & JavaScript";
11
12
  // src/cli/catalog.ts
12
13
  async function catalogFile(filePath) {
13
14
  let bytes;
@@ -57,42 +58,60 @@ function formatCatalog(entries, format = "toon") {
57
58
  }
58
59
  }
59
60
  // src/cli.ts
60
- const cli = cac("wpilog");
61
- cli.command("catalog <file>", "List the entries available in a WPILOG file").option("--json", "Output as JSON").option("--jsonl", "Output as newline-delimited JSON").option("--ndjson", "Output as newline-delimited JSON").option("--csv", "Output as CSV").example("wpilog catalog ./example.wpilog").example("wpilog catalog ./example.wpilog --json").action(async (file, options) => {
62
- const format = selectCatalogFormat(options);
63
- oscStatus.working({
64
- app: "wpilog",
65
- message: "Cataloging log"
66
- });
67
- const entries = await catalogFile(file);
68
- console.log(formatCatalog(entries, format));
69
- oscStatus.done({
70
- app: "wpilog",
71
- message: `Cataloged ${entries.length} entries`
72
- });
73
- });
74
- cli.help();
75
- cli.version(version);
76
- try {
77
- await tab(cli);
78
- const completeCommand = cli.commands.find((command) => command.name === "complete");
79
- if (completeCommand) {
80
- completeCommand.description = "Generate shell completion scripts";
81
- completeCommand.usage("complete <zsh|bash|fish|powershell>").example("source <(wpilog complete zsh)").example("source <(wpilog complete bash)").example("wpilog complete fish > ~/.config/fish/completions/wpilog.fish").example("wpilog complete powershell | Out-String | Invoke-Expression");
61
+ const completions = new RootCommand();
62
+ const commands = [command({
63
+ name: "catalog",
64
+ desc: "List the entries available in a WPILOG file",
65
+ options: {
66
+ file: positional().desc("WPILOG file to catalog").required(),
67
+ json: boolean().desc("Output as JSON"),
68
+ jsonl: boolean().desc("Output as newline-delimited JSON"),
69
+ ndjson: boolean().desc("Output as newline-delimited JSON"),
70
+ csv: boolean().desc("Output as CSV")
71
+ },
72
+ async handler(options) {
73
+ const format = selectCatalogFormat(options);
74
+ oscStatus.working({
75
+ app: "wpilog",
76
+ message: "Cataloging log"
77
+ });
78
+ const entries = await catalogFile(options.file);
79
+ console.log(formatCatalog(entries, format));
80
+ oscStatus.done({
81
+ app: "wpilog",
82
+ message: `Cataloged ${entries.length} entries`
83
+ });
82
84
  }
83
- const parsed = cli.parse(process.argv, { run: false });
84
- if (!cli.matchedCommand && !parsed.options.help && !parsed.options.version) {
85
- if (parsed.args[0]) throw diagnostics.WPILOG_C0001({ command: parsed.args[0] });
86
- cli.outputHelp();
85
+ }), command({
86
+ name: "complete",
87
+ desc: "Generate shell completion scripts",
88
+ options: { shell: positional().enum("zsh", "bash", "fish", "powershell").desc("Shell type") },
89
+ handler({ shell }) {
90
+ if (shell) script(shell, "wpilog", "wpilog");
91
+ else completions.parse([]);
87
92
  }
88
- await cli.runMatchedCommand();
89
- } catch (error) {
90
- const message = error instanceof Diagnostic ? formatDiagnostic(error) : error instanceof Error ? error.message : String(error);
91
- console.error(error instanceof Diagnostic ? message : `wpilog: ${message}`);
92
- process.exitCode = 1;
93
- oscStatus.error({
94
- app: "wpilog",
95
- message: "Command failed"
96
- });
93
+ })];
94
+ for (const info of Object.values(commandsInfo(commands))) {
95
+ const completion = completions.command(info.name, info.desc ?? "");
96
+ for (const option of Object.values(info.options ?? {})) if (option.type === "positional") completion.argument(option.name);
97
+ else completion.option(option.name.replace(/^-+/, ""), option.description ?? "");
97
98
  }
99
+ if (process.argv[2] === "complete" && process.argv[3] === "--") completions.parse(process.argv.slice(4));
100
+ else await run(commands, {
101
+ name: "wpilog",
102
+ description,
103
+ version,
104
+ theme(event) {
105
+ if (event.type !== "error") return false;
106
+ oscStatus.error({
107
+ app: "wpilog",
108
+ message: "Command failed"
109
+ });
110
+ if (event.violation === "unknown_error" && event.error instanceof Diagnostic) {
111
+ console.error(formatDiagnostic(event.error));
112
+ return true;
113
+ }
114
+ return false;
115
+ }
116
+ });
98
117
  export {};
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import { EnumSpecification, KnownStructTypeName, StructDeclaration, StructPayload, StructPayload as StructPayload$1, StructSpecification, StructTypeName } from "wpilib-struct";
1
2
  /** The parsed WPILOG file header. */
2
3
  type DataLogHeader = {
3
4
  version: {
@@ -59,10 +60,6 @@ export declare const RecordType: {
59
60
  readonly Raw: 'raw';
60
61
  };
61
62
  export type RecordType = (typeof RecordType)[keyof typeof RecordType];
62
- /** Decoded struct payload. Fields, including nested structs, are own properties of a plain object. */
63
- type StructPayload = {
64
- [key: string]: number | boolean | bigint | string | StructPayload | number[] | boolean[] | bigint[] | StructPayload[] | undefined;
65
- };
66
63
  /** A decoded data record (excludes control records). */
67
64
  type DataRecord = Extract<DecodedRecord, {
68
65
  name: string;
@@ -120,11 +117,11 @@ type DecodedRecord = {
120
117
  } | {
121
118
  type: typeof RecordType.Struct;
122
119
  structName: string;
123
- payload: StructPayload;
120
+ payload: StructPayload$1;
124
121
  } | {
125
122
  type: typeof RecordType.StructArray;
126
123
  structName: string;
127
- payload: StructPayload[];
124
+ payload: StructPayload$1[];
128
125
  })));
129
126
  /** A raw record or control record yielded by {@link readRecords}. */
130
127
  type ReadRecord = {
@@ -191,35 +188,6 @@ type CatalogEntry = {
191
188
  * making this much cheaper than full decoding via {@link parseDataLog}.
192
189
  */
193
190
  export declare function catalogEntries(records: Iterable<ReadRecord>): Generator<CatalogEntry>;
194
- export declare const KnownStructTypeName: {
195
- readonly Boolean: 'bool';
196
- readonly Character: 'char';
197
- readonly Int8: 'int8';
198
- readonly Int16: 'int16';
199
- readonly Int32: 'int32';
200
- readonly Int64: 'int64';
201
- readonly Uint8: 'uint8';
202
- readonly Uint16: 'uint16';
203
- readonly Uint32: 'uint32';
204
- readonly Uint64: 'uint64';
205
- readonly Float32: 'float32';
206
- /** Equivalent to {@link (KnownStructTypeName:variable).Float32} */
207
- readonly Float: 'float';
208
- readonly Float64: 'float64';
209
- /** Equivalent to {@link (KnownStructTypeName:variable).Float64} */
210
- readonly Double: 'double';
211
- };
212
- export type KnownStructTypeName = (typeof KnownStructTypeName)[keyof typeof KnownStructTypeName];
213
- type StructTypeName = string;
214
- type EnumSpecification = Map<string, bigint>;
215
- type StructSpecification = StructDeclaration[];
216
- type StructDeclaration = {
217
- name: string;
218
- value: StructTypeName;
219
- enumSpecification?: EnumSpecification;
220
- arraySize?: number;
221
- bitWidth?: number;
222
- };
223
191
  /** Parse a WPILib struct specification string into declarations. */
224
- export declare function parseStructSpecification(declaration: string): StructDeclaration[];
225
- export type { CatalogEntry, ControlRecord, ControlRecordPayload, DataLogHeader, DataLogInput, DataRecord, DecodeRecordsOptions, DecodedRecord, EnumSpecification, FinishControlRecord, RawRecord, ReadRecord, SetMetadataControlRecord, StartControlRecord, StructDeclaration, StructPayload, StructSpecification, StructTypeName };
192
+ export declare function parseStructSpecification(declaration: string): import("wpilib-struct").StructDeclaration[];
193
+ export { type CatalogEntry, type ControlRecord, type ControlRecordPayload, type DataLogHeader, type DataLogInput, type DataRecord, type DecodeRecordsOptions, type DecodedRecord, type EnumSpecification, type FinishControlRecord, KnownStructTypeName, type RawRecord, type ReadRecord, type SetMetadataControlRecord, type StartControlRecord, type StructDeclaration, type StructPayload, type StructSpecification, type StructTypeName };
package/dist/index.mjs CHANGED
@@ -1 +1,8 @@
1
- export { s as ControlRecordType, a as KnownStructTypeName, c as RecordType, t as catalogEntries, n as decodeRecords, l as isDataRecord, r as parseDataLog, i as parseStructSpecification, o as readRecords } from "./catalog-BmNQKX4c.mjs";
1
+ import { a as readRecords, c as isDataRecord, i as withStructDiagnostics, n as decodeRecords, o as ControlRecordType, r as parseDataLog, s as RecordType, t as catalogEntries } from "./catalog-hof8DZhi.mjs";
2
+ import { KnownStructTypeName, parseStructSpecification as parseStructSpecification$1 } from "wpilib-struct";
3
+ // src/struct/parse-struct.ts
4
+ /** Parse a WPILib struct specification string into declarations. */
5
+ function parseStructSpecification(declaration) {
6
+ return withStructDiagnostics(() => parseStructSpecification$1(declaration));
7
+ }
8
+ export { ControlRecordType, KnownStructTypeName, RecordType, catalogEntries, decodeRecords, isDataRecord, parseDataLog, parseStructSpecification, readRecords };
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.4"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,71 +1,56 @@
1
1
  {
2
- "name": "wpilog-parser",
3
- "version": "3.1.1",
4
- "description": "Read WPILib wpilog data log files in TypeScript & JavaScript",
5
- "homepage": "https://github.com/jonahsnider/wpilog-parser#readme",
6
- "license": "MIT",
7
- "author": {
8
- "name": "Jonah Snider",
9
- "email": "jonah@jonahsnider.com",
10
- "url": "https://jonahsnider.com"
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "git+https://github.com/jonahsnider/wpilog-parser.git"
15
- },
16
- "bin": {
17
- "wpilog": "./dist/cli.mjs"
18
- },
19
- "files": [
20
- "dist",
21
- "skills"
22
- ],
23
- "type": "module",
24
- "exports": {
25
- ".": "./dist/index.mjs",
26
- "./package.json": "./package.json"
27
- },
28
- "publishConfig": {
29
- "access": "public"
30
- },
31
- "scripts": {
32
- "api:check": "api-extractor run",
33
- "api:update": "api-extractor run --local",
34
- "bench": "vp test bench",
35
- "build": "vp pack",
36
- "check": "vp check",
37
- "dev": "vp pack --watch",
38
- "generate": "node ./src/struct/codegen.ts",
39
- "preapi:check": "vp run build",
40
- "preapi:update": "vp run build",
41
- "prepare": "vp config",
42
- "prepublishOnly": "vp run api:check",
43
- "start": "node ./src/cli.ts",
44
- "test": "vp test"
45
- },
46
- "dependencies": {
47
- "@bomb.sh/tab": "^0.0.22",
48
- "@toon-format/toon": "^4.1.1",
49
- "cac": "^7.0.0",
50
- "chevrotain": "^13.0.0",
51
- "nostics": "^1.3.0",
52
- "osc-status": "^1.0.0"
53
- },
54
- "devDependencies": {
55
- "@codspeed/vitest-plugin": "6.1.0",
56
- "@microsoft/api-extractor": "7.59.4",
57
- "@types/node": "26.6.5",
58
- "@typescript/native-preview": "7.0.0-dev.20260707.2",
59
- "typescript": "7.0.2",
60
- "vite-plus": "catalog:",
61
- "vitest": "catalog:"
62
- },
63
- "devEngines": {
64
- "runtime": {
65
- "name": "node",
66
- "version": "26.x"
67
- }
68
- },
69
- "packageManager": "pnpm@12.15.0",
70
- "tsdocMetadata": "./dist/tsdoc-metadata.json"
71
- }
2
+ "name": "wpilog-parser",
3
+ "version": "3.2.0",
4
+ "description": "Read WPILib wpilog data log files in TypeScript & JavaScript",
5
+ "homepage": "https://github.com/jonahsnider/wpilog-parser#readme",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "Jonah Snider",
9
+ "email": "jonah@jonahsnider.com",
10
+ "url": "https://jonahsnider.com"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/jonahsnider/wpilog-parser.git",
15
+ "directory": "packages/wpilog-parser"
16
+ },
17
+ "bin": {
18
+ "wpilog": "./dist/cli.mjs"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "skills"
23
+ ],
24
+ "type": "module",
25
+ "exports": {
26
+ ".": "./dist/index.mjs",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "dependencies": {
33
+ "@bomb.sh/tab": "^0.0.22",
34
+ "@drizzle-team/brocli": "^0.12.1",
35
+ "@toon-format/toon": "^4.1.1",
36
+ "nostics": "^1.3.0",
37
+ "osc-status": "^1.0.0",
38
+ "wpilib-struct": "^1.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@microsoft/api-extractor": "7.60.0",
42
+ "vite-plus": "1.4.0",
43
+ "vitest": "5.0.5"
44
+ },
45
+ "tsdocMetadata": "./dist/tsdoc-metadata.json",
46
+ "scripts": {
47
+ "api:check": "api-extractor run",
48
+ "api:update": "api-extractor run --local",
49
+ "bench": "vp test bench",
50
+ "build": "vp pack",
51
+ "check": "vp check",
52
+ "dev": "vp pack --watch",
53
+ "start": "node ./src/cli.ts",
54
+ "test": "vp test"
55
+ }
56
+ }