wpilog-parser 2.5.0 → 3.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.
package/README.md CHANGED
@@ -25,9 +25,11 @@ for (const record of parseDataLog(bytes)) {
25
25
 
26
26
  Use `readRecords()` and `decodeRecords()` separately when you need access to raw records or want to transform the record stream before decoding it. Both approaches produce the same decoded records.
27
27
 
28
- Struct schemas are compiled lazily into reusable decoders, and struct payloads are returned as `Map` values.
28
+ Struct schemas are compiled lazily into reusable decoders, and struct payloads are returned as plain objects, including nested structs and arrays of structs.
29
29
  In environments where Content Security Policy blocks runtime code generation, structs are decoded by the interpreter automatically.
30
30
 
31
+ A summary of the full API is available in [wpilog-parser.api.md](./etc/wpilog-parser.api.md).
32
+
31
33
  ## CLI
32
34
 
33
35
  List every entry available in a log before writing an analysis script:
@@ -42,6 +44,22 @@ The default output is [TOON](https://toonformat.dev). JSON, JSONL/NDJSON, and CS
42
44
  npx wpilog-parser catalog ./example.wpilog --json
43
45
  ```
44
46
 
47
+ `wpilog` includes shell completions via `wpilog complete`:
48
+
49
+ ```sh
50
+ # zsh
51
+ source <(wpilog complete zsh)
52
+
53
+ # bash (requires bash 4+ and bash-completion)
54
+ source <(wpilog complete bash)
55
+
56
+ # fish
57
+ wpilog complete fish > ~/.config/fish/completions/wpilog.fish
58
+
59
+ # PowerShell
60
+ wpilog complete powershell | Out-String | Invoke-Expression
61
+ ```
62
+
45
63
  ## Agent skill
46
64
 
47
65
  This package ships an [Agent Skill](https://agentskills.io) at `skills/analyze-wpilog/SKILL.md` that teaches AI coding agents how to use the library.
@@ -1,6 +1,6 @@
1
1
  import { defineDiagnostics } from "nostics";
2
2
  import { CstParser, Lexer, createToken } from "chevrotain";
3
- //#region src/byte-offset.ts
3
+ // src/byte-offset.ts
4
4
  var ByteOffset = class {
5
5
  offset;
6
6
  constructor(offset = 0) {
@@ -26,8 +26,7 @@ var ByteOffset = class {
26
26
  return this.advance(8);
27
27
  }
28
28
  };
29
- //#endregion
30
- //#region src/diagnostics.ts
29
+ // src/diagnostics.ts
31
30
  /** Stable codes for errors callers can act on. */
32
31
  const diagnostics = defineDiagnostics({ codes: {
33
32
  WPILOG_C0001: {
@@ -95,8 +94,7 @@ const diagnostics = defineDiagnostics({ codes: {
95
94
  fix: "Register the struct definition before decoding its records."
96
95
  }
97
96
  } });
98
- //#endregion
99
- //#region src/types.ts
97
+ // src/types.ts
100
98
  /** Control record types in the WPILOG format. */
101
99
  const ControlRecordType = {
102
100
  Start: 0,
@@ -124,8 +122,7 @@ const RecordType = {
124
122
  function isDataRecord(record) {
125
123
  return record.type !== RecordType.Control;
126
124
  }
127
- //#endregion
128
- //#region src/read-records.ts
125
+ // src/read-records.ts
129
126
  const TEXT_ENCODER = new TextEncoder();
130
127
  const TEXT_DECODER$1 = new TextDecoder();
131
128
  const MAGIC = TEXT_ENCODER.encode("WPILOG");
@@ -341,8 +338,7 @@ function* readRecords(input) {
341
338
  };
342
339
  }
343
340
  }
344
- //#endregion
345
- //#region src/struct/types.ts
341
+ // src/struct/types.ts
346
342
  const KnownStructTypeName = {
347
343
  Boolean: "bool",
348
344
  Character: "char",
@@ -355,14 +351,13 @@ const KnownStructTypeName = {
355
351
  Uint32: "uint32",
356
352
  Uint64: "uint64",
357
353
  Float32: "float32",
358
- /** Equivalent to {@link KnownStructTypeName.Float32} */
354
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float32} */
359
355
  Float: "float",
360
356
  Float64: "float64",
361
- /** Equivalent to {@link KnownStructTypeName.Float64} */
357
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float64} */
362
358
  Double: "double"
363
359
  };
364
- //#endregion
365
- //#region src/struct/struct-dependency-graph.ts
360
+ // src/struct/struct-dependency-graph.ts
366
361
  const EMPTY_SET = /* @__PURE__ */ new Set();
367
362
  var StructDependencyGraph = class {
368
363
  allDependencies = new Map(Object.values(KnownStructTypeName).map((type) => [type, EMPTY_SET]));
@@ -406,8 +401,7 @@ var StructDependencyGraph = class {
406
401
  return result;
407
402
  }
408
403
  };
409
- //#endregion
410
- //#region src/struct/struct-decode-queue.ts
404
+ // src/struct/struct-decode-queue.ts
411
405
  var StructDecodeQueue = class {
412
406
  graph = new StructDependencyGraph();
413
407
  queuedRecords = /* @__PURE__ */ new Map();
@@ -434,8 +428,7 @@ var StructDecodeQueue = class {
434
428
  }
435
429
  }
436
430
  };
437
- //#endregion
438
- //#region src/struct/bit-field.ts
431
+ // src/struct/bit-field.ts
439
432
  var BitFieldTracker = class {
440
433
  storageByteLength = 0;
441
434
  bitShift = 0;
@@ -488,8 +481,7 @@ function isSignedInteger(type) {
488
481
  default: return false;
489
482
  }
490
483
  }
491
- //#endregion
492
- //#region src/struct/compile-struct.ts
484
+ // src/struct/compile-struct.ts
493
485
  const READERS = {
494
486
  bool: {
495
487
  method: "getUint8",
@@ -599,6 +591,7 @@ function compileStruct(registry, name) {
599
591
  const functionName = `s${functions.size}`;
600
592
  functions.set(structName, functionName);
601
593
  const statements = [];
594
+ const fields = [];
602
595
  const bitFields = new BitFieldTracker();
603
596
  let offset = 0;
604
597
  for (const [index, member] of registry.getDefinition(structName).entries()) {
@@ -617,12 +610,12 @@ function compileStruct(registry, name) {
617
610
  offset += memberSize;
618
611
  }
619
612
  const key = JSON.stringify(member.name);
620
- statements.push(`result.set(${key}, ${expression});`);
613
+ statements.push(`const v${index} = ${expression};`);
614
+ fields.push(`[${key}]: v${index}`);
621
615
  }
622
616
  sources.push(`function ${functionName}(view, bytes, base) {
623
- const result = new Map();
624
617
  ${statements.join("\n")}
625
- return result;
618
+ return {${fields.join(",")}};
626
619
  }`);
627
620
  return functionName;
628
621
  }
@@ -631,8 +624,7 @@ function compileStruct(registry, name) {
631
624
  ${sources.join("\n")}
632
625
  return ${root};`)(new TextDecoder());
633
626
  }
634
- //#endregion
635
- //#region src/struct/lexer.ts
627
+ // src/struct/lexer.ts
636
628
  const Comma = createToken({
637
629
  name: "Comma",
638
630
  pattern: ","
@@ -696,8 +688,7 @@ const allTokens = [
696
688
  Identifier
697
689
  ];
698
690
  const lexer = new Lexer(allTokens);
699
- //#endregion
700
- //#region src/struct/parser.ts
691
+ // src/struct/parser.ts
701
692
  var StructParser = class extends CstParser {
702
693
  structSpecification = this.RULE("structSpecification", () => {
703
694
  this.MANY_SEP({
@@ -761,8 +752,7 @@ var StructParser = class extends CstParser {
761
752
  const parser = new StructParser();
762
753
  parser.getBaseCstVisitorConstructor();
763
754
  const BaseStructVisitorWithDefaults = parser.getBaseCstVisitorConstructorWithDefaults();
764
- //#endregion
765
- //#region src/struct/struct-ast-visitor.ts
755
+ // src/struct/struct-ast-visitor.ts
766
756
  var StructAstVisitor = class extends BaseStructVisitorWithDefaults {
767
757
  constructor() {
768
758
  super();
@@ -859,8 +849,7 @@ var StructAstVisitor = class extends BaseStructVisitorWithDefaults {
859
849
  return Number(value.image);
860
850
  }
861
851
  };
862
- //#endregion
863
- //#region src/struct/parse-struct.ts
852
+ // src/struct/parse-struct.ts
864
853
  const structAstVisitor = new StructAstVisitor();
865
854
  const cache = /* @__PURE__ */ new Map();
866
855
  /** Parse a WPILib struct specification string into declarations. */
@@ -876,8 +865,7 @@ function parseStructSpecification(declaration) {
876
865
  cache.set(declaration, created);
877
866
  return created;
878
867
  }
879
- //#endregion
880
- //#region src/struct/struct-registry.ts
868
+ // src/struct/struct-registry.ts
881
869
  var StructRegistry = class StructRegistry {
882
870
  static TEXT_DECODER = new TextDecoder("utf-8");
883
871
  definitions = /* @__PURE__ */ new Map();
@@ -950,15 +938,21 @@ var StructRegistry = class StructRegistry {
950
938
  decodeInterpreted(structName, payload, offset = new ByteOffset()) {
951
939
  if (!this.definitions.has(structName)) return structName;
952
940
  const specification = this.getDefinition(structName);
953
- const result = /* @__PURE__ */ new Map();
941
+ const result = {};
954
942
  const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
955
943
  const bitFields = new BitFieldTracker();
956
944
  for (const member of specification) {
945
+ if (member.name === "__proto__") Object.defineProperty(result, member.name, {
946
+ value: void 0,
947
+ enumerable: true,
948
+ writable: true,
949
+ configurable: true
950
+ });
957
951
  const memberByteLength = this.calculateByteLength(member);
958
952
  const bitField = typeof memberByteLength === "number" ? bitFields.next(member, memberByteLength) : void 0;
959
953
  if (bitField) {
960
954
  offset.advance(bitField.bytesToAdvance);
961
- result.set(member.name, decodeBitField(view, offset.get(), member, bitField));
955
+ result[member.name] = decodeBitField(view, offset.get(), member, bitField);
962
956
  continue;
963
957
  }
964
958
  offset.advance(bitFields.flush());
@@ -970,9 +964,9 @@ var StructRegistry = class StructRegistry {
970
964
  array.push(Boolean(view.getUint8(offset.get())));
971
965
  offset.advance8();
972
966
  }
973
- result.set(member.name, array);
967
+ result[member.name] = array;
974
968
  } else {
975
- result.set(member.name, Boolean(view.getUint8(offset.get())));
969
+ result[member.name] = Boolean(view.getUint8(offset.get()));
976
970
  offset.advance8();
977
971
  }
978
972
  break;
@@ -983,9 +977,9 @@ var StructRegistry = class StructRegistry {
983
977
  array.push(view.getInt8(offset.get()));
984
978
  offset.advance8();
985
979
  }
986
- result.set(member.name, array);
980
+ result[member.name] = array;
987
981
  } else {
988
- result.set(member.name, view.getInt8(offset.get()));
982
+ result[member.name] = view.getInt8(offset.get());
989
983
  offset.advance8();
990
984
  }
991
985
  break;
@@ -996,9 +990,9 @@ var StructRegistry = class StructRegistry {
996
990
  array.push(view.getInt16(offset.get(), true));
997
991
  offset.advance16();
998
992
  }
999
- result.set(member.name, array);
993
+ result[member.name] = array;
1000
994
  } else {
1001
- result.set(member.name, view.getInt16(offset.get(), true));
995
+ result[member.name] = view.getInt16(offset.get(), true);
1002
996
  offset.advance16();
1003
997
  }
1004
998
  break;
@@ -1009,9 +1003,9 @@ var StructRegistry = class StructRegistry {
1009
1003
  array.push(view.getInt32(offset.get(), true));
1010
1004
  offset.advance32();
1011
1005
  }
1012
- result.set(member.name, array);
1006
+ result[member.name] = array;
1013
1007
  } else {
1014
- result.set(member.name, view.getInt32(offset.get(), true));
1008
+ result[member.name] = view.getInt32(offset.get(), true);
1015
1009
  offset.advance32();
1016
1010
  }
1017
1011
  break;
@@ -1022,9 +1016,9 @@ var StructRegistry = class StructRegistry {
1022
1016
  array.push(view.getBigInt64(offset.get(), true));
1023
1017
  offset.advance64();
1024
1018
  }
1025
- result.set(member.name, array);
1019
+ result[member.name] = array;
1026
1020
  } else {
1027
- result.set(member.name, view.getBigInt64(offset.get(), true));
1021
+ result[member.name] = view.getBigInt64(offset.get(), true);
1028
1022
  offset.advance64();
1029
1023
  }
1030
1024
  break;
@@ -1035,9 +1029,9 @@ var StructRegistry = class StructRegistry {
1035
1029
  array.push(view.getUint8(offset.get()));
1036
1030
  offset.advance8();
1037
1031
  }
1038
- result.set(member.name, array);
1032
+ result[member.name] = array;
1039
1033
  } else {
1040
- result.set(member.name, view.getUint8(offset.get()));
1034
+ result[member.name] = view.getUint8(offset.get());
1041
1035
  offset.advance8();
1042
1036
  }
1043
1037
  break;
@@ -1048,9 +1042,9 @@ var StructRegistry = class StructRegistry {
1048
1042
  array.push(view.getUint16(offset.get(), true));
1049
1043
  offset.advance16();
1050
1044
  }
1051
- result.set(member.name, array);
1045
+ result[member.name] = array;
1052
1046
  } else {
1053
- result.set(member.name, view.getUint16(offset.get(), true));
1047
+ result[member.name] = view.getUint16(offset.get(), true);
1054
1048
  offset.advance16();
1055
1049
  }
1056
1050
  break;
@@ -1061,9 +1055,9 @@ var StructRegistry = class StructRegistry {
1061
1055
  array.push(view.getUint32(offset.get(), true));
1062
1056
  offset.advance32();
1063
1057
  }
1064
- result.set(member.name, array);
1058
+ result[member.name] = array;
1065
1059
  } else {
1066
- result.set(member.name, view.getUint32(offset.get(), true));
1060
+ result[member.name] = view.getUint32(offset.get(), true);
1067
1061
  offset.advance32();
1068
1062
  }
1069
1063
  break;
@@ -1074,9 +1068,9 @@ var StructRegistry = class StructRegistry {
1074
1068
  array.push(view.getBigUint64(offset.get(), true));
1075
1069
  offset.advance64();
1076
1070
  }
1077
- result.set(member.name, array);
1071
+ result[member.name] = array;
1078
1072
  } else {
1079
- result.set(member.name, view.getBigUint64(offset.get(), true));
1073
+ result[member.name] = view.getBigUint64(offset.get(), true);
1080
1074
  offset.advance64();
1081
1075
  }
1082
1076
  break;
@@ -1088,9 +1082,9 @@ var StructRegistry = class StructRegistry {
1088
1082
  array.push(view.getFloat32(offset.get(), true));
1089
1083
  offset.advance32();
1090
1084
  }
1091
- result.set(member.name, array);
1085
+ result[member.name] = array;
1092
1086
  } else {
1093
- result.set(member.name, view.getFloat32(offset.get(), true));
1087
+ result[member.name] = view.getFloat32(offset.get(), true);
1094
1088
  offset.advance32();
1095
1089
  }
1096
1090
  break;
@@ -1102,15 +1096,15 @@ var StructRegistry = class StructRegistry {
1102
1096
  array.push(view.getFloat64(offset.get(), true));
1103
1097
  offset.advance64();
1104
1098
  }
1105
- result.set(member.name, array);
1099
+ result[member.name] = array;
1106
1100
  } else {
1107
- result.set(member.name, view.getFloat64(offset.get(), true));
1101
+ result[member.name] = view.getFloat64(offset.get(), true);
1108
1102
  offset.advance64();
1109
1103
  }
1110
1104
  break;
1111
1105
  case KnownStructTypeName.Character:
1112
- if (member.arraySize !== void 0) result.set(member.name, StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance(member.arraySize).get())));
1113
- else result.set(member.name, StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance8().get())));
1106
+ if (member.arraySize !== void 0) result[member.name] = StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance(member.arraySize).get()));
1107
+ else result[member.name] = StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance8().get()));
1114
1108
  break;
1115
1109
  default: if (member.arraySize !== void 0) {
1116
1110
  const array = [];
@@ -1119,11 +1113,11 @@ var StructRegistry = class StructRegistry {
1119
1113
  if (typeof decoded === "string") return decoded;
1120
1114
  array.push(decoded);
1121
1115
  }
1122
- result.set(member.name, array);
1116
+ result[member.name] = array;
1123
1117
  } else {
1124
1118
  const decoded = this.decodeInterpreted(member.value, payload, offset);
1125
1119
  if (typeof decoded === "string") return decoded;
1126
- result.set(member.name, decoded);
1120
+ result[member.name] = decoded;
1127
1121
  }
1128
1122
  }
1129
1123
  }
@@ -1191,8 +1185,7 @@ var StructRegistry = class StructRegistry {
1191
1185
  return byteLengthForOne;
1192
1186
  }
1193
1187
  };
1194
- //#endregion
1195
- //#region src/decode-records.ts
1188
+ // src/decode-records.ts
1196
1189
  const TEXT_DECODER = new TextDecoder();
1197
1190
  const STRUCT_PREFIX = "struct:";
1198
1191
  const STRUCT_ARRAY_SUFFIX = "[]";
@@ -1489,8 +1482,7 @@ function decodeNonScalarPayload(raw, entryType, name, metadata, view, structRegi
1489
1482
  };
1490
1483
  }
1491
1484
  }
1492
- //#endregion
1493
- //#region src/catalog.ts
1485
+ // src/catalog.ts
1494
1486
  /**
1495
1487
  * Collect all entry definitions from a WPILOG record stream.
1496
1488
  *
@@ -1518,5 +1510,4 @@ function* catalogEntries(records) {
1518
1510
  }
1519
1511
  }
1520
1512
  }
1521
- //#endregion
1522
1513
  export { KnownStructTypeName as a, RecordType as c, parseStructSpecification as i, isDataRecord as l, decodeRecords as n, readRecords as o, parseDataLog as r, ControlRecordType as s, catalogEntries as t, diagnostics as u };
package/dist/cli.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import { o as readRecords, t as catalogEntries, u as diagnostics } from "./catalog-CfUKQI7-.mjs";
2
+ import { o as readRecords, t as catalogEntries, u as diagnostics } from "./catalog-DstFMwwV.mjs";
3
3
  import { Diagnostic, formatDiagnostic } from "nostics";
4
+ import tab from "@bomb.sh/tab/cac";
4
5
  import { cac } from "cac";
5
6
  import oscStatus from "osc-status";
6
7
  import { readFile } from "node:fs/promises";
7
8
  import { encode } from "@toon-format/toon";
8
- //#region package.json
9
- var version = "2.5.0";
10
- //#endregion
11
- //#region src/cli/catalog.ts
9
+ // package.json
10
+ var version = "3.1.0";
11
+ // src/cli/catalog.ts
12
12
  async function catalogFile(filePath) {
13
13
  let bytes;
14
14
  try {
@@ -56,10 +56,9 @@ function formatCatalog(entries, format = "toon") {
56
56
  ].map((value) => escapeCsv(value)).join(","))].join("\n");
57
57
  }
58
58
  }
59
- //#endregion
60
- //#region src/cli.ts
59
+ // src/cli.ts
61
60
  const cli = cac("wpilog");
62
- cli.command("catalog <file>", "List the entries available in a WPILOG file").option("--json", "Output as JSON").option("--jsonl, --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) => {
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) => {
63
62
  const format = selectCatalogFormat(options);
64
63
  oscStatus.working({
65
64
  app: "wpilog",
@@ -75,12 +74,18 @@ cli.command("catalog <file>", "List the entries available in a WPILOG file").opt
75
74
  cli.help();
76
75
  cli.version(version);
77
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");
82
+ }
78
83
  const parsed = cli.parse(process.argv, { run: false });
79
- await cli.runMatchedCommand();
80
84
  if (!cli.matchedCommand && !parsed.options.help && !parsed.options.version) {
81
85
  if (parsed.args[0]) throw diagnostics.WPILOG_C0001({ command: parsed.args[0] });
82
86
  cli.outputHelp();
83
87
  }
88
+ await cli.runMatchedCommand();
84
89
  } catch (error) {
85
90
  const message = error instanceof Diagnostic ? formatDiagnostic(error) : error instanceof Error ? error.message : String(error);
86
91
  console.error(error instanceof Diagnostic ? message : `wpilog: ${message}`);
@@ -90,5 +95,4 @@ try {
90
95
  message: "Command failed"
91
96
  });
92
97
  }
93
- //#endregion
94
98
  export {};
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/types.d.ts
2
1
  /** The parsed WPILOG file header. */
3
2
  type DataLogHeader = {
4
3
  version: {
@@ -60,8 +59,10 @@ export declare const RecordType: {
60
59
  readonly Raw: 'raw';
61
60
  };
62
61
  export type RecordType = (typeof RecordType)[keyof typeof RecordType];
63
- /** Decoded struct payload — a map of field names to values. */
64
- type StructPayload = Map<string, number | boolean | bigint | string | StructPayload | number[] | boolean[] | bigint[] | StructPayload[]>;
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
+ };
65
66
  /** A decoded data record (excludes control records). */
66
67
  type DataRecord = Extract<DecodedRecord, {
67
68
  name: string;
@@ -125,8 +126,6 @@ type DecodedRecord = {
125
126
  structName: string;
126
127
  payload: StructPayload[];
127
128
  })));
128
- //#endregion
129
- //#region src/read-records.d.ts
130
129
  /** A raw record or control record yielded by {@link readRecords}. */
131
130
  type ReadRecord = {
132
131
  kind: 'header';
@@ -150,8 +149,6 @@ type DataLogInput = Uint8Array | ArrayBuffer;
150
149
  * or an intermediate transformation are not needed.
151
150
  */
152
151
  export declare function readRecords(input: DataLogInput): Generator<ReadRecord>;
153
- //#endregion
154
- //#region src/decode-records.d.ts
155
152
  /** Options for {@link decodeRecords} and {@link parseDataLog}. */
156
153
  type DecodeRecordsOptions = {
157
154
  /**
@@ -179,12 +176,6 @@ export declare function decodeRecords(records: Iterable<ReadRecord>, options?: D
179
176
  * {@link decodeRecords} while preserving the same output and strict-mode behavior.
180
177
  */
181
178
  export declare function parseDataLog(input: DataLogInput, options?: DecodeRecordsOptions): Generator<DecodedRecord>;
182
- //#endregion
183
- //#region src/struct-payload-to-json.d.ts
184
- /** Convert a {@link StructPayload} Map to a plain JSON-compatible object. */
185
- export declare function structPayloadToJson(payload: StructPayload): object;
186
- //#endregion
187
- //#region src/catalog.d.ts
188
179
  /** An entry definition from the WPILOG catalog. */
189
180
  type CatalogEntry = {
190
181
  entryId: number;
@@ -200,8 +191,6 @@ type CatalogEntry = {
200
191
  * making this much cheaper than full decoding via {@link parseDataLog}.
201
192
  */
202
193
  export declare function catalogEntries(records: Iterable<ReadRecord>): Generator<CatalogEntry>;
203
- //#endregion
204
- //#region src/struct/types.d.ts
205
194
  export declare const KnownStructTypeName: {
206
195
  readonly Boolean: 'bool';
207
196
  readonly Character: 'char';
@@ -214,10 +203,10 @@ export declare const KnownStructTypeName: {
214
203
  readonly Uint32: 'uint32';
215
204
  readonly Uint64: 'uint64';
216
205
  readonly Float32: 'float32';
217
- /** Equivalent to {@link KnownStructTypeName.Float32} */
206
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float32} */
218
207
  readonly Float: 'float';
219
208
  readonly Float64: 'float64';
220
- /** Equivalent to {@link KnownStructTypeName.Float64} */
209
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float64} */
221
210
  readonly Double: 'double';
222
211
  };
223
212
  export type KnownStructTypeName = (typeof KnownStructTypeName)[keyof typeof KnownStructTypeName];
@@ -231,9 +220,6 @@ type StructDeclaration = {
231
220
  arraySize?: number;
232
221
  bitWidth?: number;
233
222
  };
234
- //#endregion
235
- //#region src/struct/parse-struct.d.ts
236
223
  /** Parse a WPILib struct specification string into declarations. */
237
224
  export declare function parseStructSpecification(declaration: string): StructDeclaration[];
238
- //#endregion
239
225
  export type { CatalogEntry, ControlRecord, ControlRecordPayload, DataLogHeader, DataLogInput, DataRecord, DecodeRecordsOptions, DecodedRecord, EnumSpecification, FinishControlRecord, RawRecord, ReadRecord, SetMetadataControlRecord, StartControlRecord, StructDeclaration, StructPayload, StructSpecification, StructTypeName };
package/dist/index.mjs CHANGED
@@ -1,22 +1 @@
1
- import { a as KnownStructTypeName, c as RecordType, i as parseStructSpecification, l as isDataRecord, n as decodeRecords, o as readRecords, r as parseDataLog, s as ControlRecordType, t as catalogEntries } from "./catalog-CfUKQI7-.mjs";
2
- //#region src/struct-payload-to-json.ts
3
- /** Convert a {@link StructPayload} Map to a plain JSON-compatible object. */
4
- function structPayloadToJson(payload) {
5
- const result = {};
6
- for (const [key, value] of payload) {
7
- let converted;
8
- if (value instanceof Map) converted = structPayloadToJson(value);
9
- else if (Array.isArray(value) && value.length > 0 && value[0] instanceof Map) converted = value.map((v) => structPayloadToJson(v));
10
- else converted = value;
11
- if (key === "__proto__") Object.defineProperty(result, key, {
12
- value: converted,
13
- enumerable: true,
14
- writable: true,
15
- configurable: true
16
- });
17
- else result[key] = converted;
18
- }
19
- return result;
20
- }
21
- //#endregion
22
- export { ControlRecordType, KnownStructTypeName, RecordType, catalogEntries, decodeRecords, isDataRecord, parseDataLog, parseStructSpecification, readRecords, structPayloadToJson };
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-DstFMwwV.mjs";
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.59.4"
9
+ }
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wpilog-parser",
3
- "version": "2.5.0",
3
+ "version": "3.1.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",
@@ -29,17 +29,22 @@
29
29
  "access": "public"
30
30
  },
31
31
  "scripts": {
32
+ "api:check": "api-extractor run",
33
+ "api:update": "api-extractor run --local",
32
34
  "bench": "vp test bench",
33
35
  "build": "vp pack",
34
36
  "check": "vp check",
35
37
  "dev": "vp pack --watch",
36
38
  "generate": "node ./src/struct/codegen.ts",
39
+ "preapi:check": "vp run build",
40
+ "preapi:update": "vp run build",
37
41
  "prepare": "vp config",
38
- "prepublishOnly": "vp run build",
42
+ "prepublishOnly": "vp run api:check",
39
43
  "start": "node ./src/cli.ts",
40
44
  "test": "vp test"
41
45
  },
42
46
  "dependencies": {
47
+ "@bomb.sh/tab": "^0.0.22",
43
48
  "@toon-format/toon": "^4.1.1",
44
49
  "cac": "^7.0.0",
45
50
  "chevrotain": "^13.0.0",
@@ -48,6 +53,7 @@
48
53
  },
49
54
  "devDependencies": {
50
55
  "@codspeed/vitest-plugin": "6.1.0",
56
+ "@microsoft/api-extractor": "7.59.4",
51
57
  "@types/node": "26.6.5",
52
58
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
53
59
  "typescript": "7.0.2",
@@ -60,5 +66,6 @@
60
66
  "version": "26.x"
61
67
  }
62
68
  },
63
- "packageManager": "pnpm@12.14.0"
69
+ "packageManager": "pnpm@12.15.0",
70
+ "tsdocMetadata": "./dist/tsdoc-metadata.json"
64
71
  }
@@ -42,11 +42,11 @@ for (const record of parseDataLog(bytes)) {
42
42
  ### Decoding structs
43
43
 
44
44
  ```ts
45
- import { parseDataLog, RecordType, structPayloadToJson } from 'wpilog-parser';
45
+ import { parseDataLog, RecordType } from 'wpilog-parser';
46
46
 
47
47
  for (const record of parseDataLog(bytes)) {
48
48
  if (record.type === RecordType.Struct && record.name === '/Robot/Localization/EstimatedPose') {
49
- console.log(record.timestamp, structPayloadToJson(record.payload));
49
+ console.log(record.timestamp, record.payload);
50
50
  // 18688018n {
51
51
  // translation: { x: 10.289, y: 0.47 },
52
52
  // rotation: { value: 1.5707961072652017 },