wpilog-parser 2.2.0 → 2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wpilog-parser",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Read WPILib wpilog data log files in TypeScript & JavaScript",
5
5
  "homepage": "https://github.com/jonahsnider/wpilog-parser#readme",
6
6
  "license": "MIT",
@@ -13,6 +13,9 @@
13
13
  "type": "git",
14
14
  "url": "git+https://github.com/jonahsnider/wpilog-parser.git"
15
15
  },
16
+ "bin": {
17
+ "wpilog": "./dist/cli.mjs"
18
+ },
16
19
  "files": [
17
20
  "dist",
18
21
  "skills"
@@ -30,27 +33,31 @@
30
33
  "build": "vp pack",
31
34
  "check": "vp check",
32
35
  "dev": "vp pack --watch",
33
- "generate": "bun run ./src/struct/codegen.ts",
36
+ "generate": "node ./src/struct/codegen.ts",
34
37
  "prepare": "vp config",
35
38
  "prepublishOnly": "vp run build",
39
+ "start": "node ./src/cli.ts",
36
40
  "test": "vp test"
37
41
  },
38
42
  "dependencies": {
39
- "chevrotain": "^12.0.0"
43
+ "@toon-format/toon": "^4.1.1",
44
+ "cac": "^7.0.0",
45
+ "chevrotain": "^13.0.0",
46
+ "nostics": "^1.3.0"
40
47
  },
41
48
  "devDependencies": {
42
- "@codspeed/vitest-plugin": "^5.2.0",
43
- "@types/node": "24.12.2",
44
- "@typescript/native-preview": "7.0.0-dev.20260425.1",
45
- "typescript": "6.0.3",
46
- "vite-plus": "0.1.19"
47
- },
48
- "overrides": {
49
- "vite": "npm:@voidzero-dev/vite-plus-core@latest",
50
- "vitest": "npm:@voidzero-dev/vite-plus-test@latest"
51
- },
52
- "packageManager": "bun@1.3.10",
53
- "patchedDependencies": {
54
- "@codspeed/vitest-plugin@5.2.0": "patches/@codspeed%2Fvitest-plugin@5.2.0.patch"
55
- }
49
+ "@codspeed/vitest-plugin": "5.7.1",
50
+ "@types/node": "26.6.3",
51
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
52
+ "typescript": "7.0.2",
53
+ "vite-plus": "catalog:",
54
+ "vitest": "catalog:"
55
+ },
56
+ "devEngines": {
57
+ "runtime": {
58
+ "name": "node",
59
+ "version": "26.x"
60
+ }
61
+ },
62
+ "packageManager": "pnpm@12.6.0"
56
63
  }
@@ -10,38 +10,27 @@ WPILOG is the binary log format used by logging libraries in the FRC ecosystem.
10
10
 
11
11
  ## Creating a project
12
12
 
13
- 1. Init a project using `bun init` or similar
13
+ 1. Init a project using `pnpm init` or similar
14
14
  2. Add `wpilog-parser` as a dependency
15
- 3. Create a `.ts` file for catalogging the records in the WPILOG file
16
-
17
- ```ts
18
- import { readFile } from 'node:fs/promises';
19
- import { readRecords, catalogEntries } from 'wpilog-parser';
20
-
21
- const bytes = await readFile('./example.wpilog');
22
-
23
- for (const catalogEntry of catalogEntries(readRecords(bytes))) {
24
- console.log(catalogEntry);
25
- // {
26
- // entryId: 3,
27
- // name: "/Robot/DogLog/Options",
28
- // type: "string",
29
- // metadata: "{\"source\":\"DogLog\"}",
30
- // }
31
- }
15
+ 3. Catalog the entries in the WPILOG file before deciding what to analyze
16
+
17
+ ```sh
18
+ pnpm wpilog catalog ./example.wpilog
32
19
  ```
33
20
 
21
+ The default output is plaintext. Use `--json`, `--jsonl`/`--ndjson`, or `--csv` when another format is more useful.
22
+
34
23
  ## Analyzing logs
35
24
 
36
- Use `decodeRecords` to parse record contents. Filter by `name` and narrow on `type`:
25
+ Use `parseDataLog` to parse DataLog bytes. Filter by `name` and narrow on `type`:
37
26
 
38
27
  ```ts
39
28
  import { readFile } from 'node:fs/promises';
40
- import { readRecords, decodeRecords, isDataRecord, RecordType } from 'wpilog-parser';
29
+ import { isDataRecord, parseDataLog, RecordType } from 'wpilog-parser';
41
30
 
42
31
  const bytes = await readFile('./example.wpilog');
43
32
 
44
- for (const record of decodeRecords(readRecords(bytes))) {
33
+ for (const record of parseDataLog(bytes)) {
45
34
  if (!isDataRecord(record)) continue;
46
35
 
47
36
  if (record.name === '/Robot/Intake/Voltage' && record.type === RecordType.Double) {
@@ -53,9 +42,9 @@ for (const record of decodeRecords(readRecords(bytes))) {
53
42
  ### Decoding structs
54
43
 
55
44
  ```ts
56
- import { structPayloadToJson, RecordType } from 'wpilog-parser';
45
+ import { parseDataLog, RecordType, structPayloadToJson } from 'wpilog-parser';
57
46
 
58
- for (const record of decodeRecords(readRecords(bytes))) {
47
+ for (const record of parseDataLog(bytes)) {
59
48
  if (record.type === RecordType.Struct && record.name === '/Robot/Localization/EstimatedPose') {
60
49
  console.log(record.timestamp, structPayloadToJson(record.payload));
61
50
  // 18688018n {
@@ -69,7 +58,7 @@ for (const record of decodeRecords(readRecords(bytes))) {
69
58
  ### Strict mode
70
59
 
71
60
  ```ts
72
- for (const record of decodeRecords(readRecords(bytes), { strict: true })) {
61
+ for (const record of parseDataLog(bytes, { strict: true })) {
73
62
  // throws on orphan data records instead of skipping
74
63
  }
75
64
  ```
@@ -90,7 +79,7 @@ The mode flags (`autonomous`, `test`) reflect what the DS _would_ run if enabled
90
79
  ### Tracking enable/mode durations
91
80
 
92
81
  ```ts
93
- import { readRecords, decodeRecords, isDataRecord, RecordType } from 'wpilog-parser';
82
+ import { isDataRecord, parseDataLog, RecordType } from 'wpilog-parser';
94
83
 
95
84
  type Mode = 'auto' | 'teleop' | 'test';
96
85
  function modeOf(auto: boolean, test: boolean): Mode {
@@ -105,7 +94,7 @@ let test = false;
105
94
  let enabledSince: bigint | null = null;
106
95
  const totals = { auto: 0n, teleop: 0n, test: 0n };
107
96
 
108
- for (const r of decodeRecords(readRecords(bytes))) {
97
+ for (const r of parseDataLog(bytes)) {
109
98
  if (!isDataRecord(r) || r.type !== RecordType.Boolean) continue;
110
99
 
111
100
  const wasEnabled = enabled;