wpilog-parser 2.4.1 → 3.0.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,6 +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 plain objects, including nested structs and arrays of structs.
29
+ In environments where Content Security Policy blocks runtime code generation, structs are decoded by the interpreter automatically.
30
+
31
+ A summary of the full API is available in [wpilog-parser.api.md](./etc/wpilog-parser.api.md).
32
+
28
33
  ## CLI
29
34
 
30
35
  List every entry available in a log before writing an analysis script:
@@ -41,16 +46,29 @@ npx wpilog-parser catalog ./example.wpilog --json
41
46
 
42
47
  ## Agent skill
43
48
 
44
- 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. Install it into your project with either:
49
+ 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.
50
+ It allows agents to analyze robot log files themselves, and create reports or insights based on the data stored in the WPILOG.
51
+
52
+ You can also install the skill with:
45
53
 
46
54
  ```sh
47
55
  # https://skills.sh/
48
56
  npx skills add jonahsnider/wpilog-parser
49
57
  ```
50
58
 
59
+ With [pnpm 12.11.0 or later](https://pnpm.io/agent-skills), install the package and approve its skill:
60
+
51
61
  ```sh
52
- # https://github.com/antfu/skills-npm
53
- npx skills-npm
62
+ pnpm add wpilog-parser
63
+ pnpm approve
64
+ ```
65
+
66
+ Approving skills for `wpilog-parser` records the following in your project's `pnpm-workspace.yaml`:
67
+
68
+ ```yaml
69
+ permissions:
70
+ wpilog-parser:
71
+ skills: true
54
72
  ```
55
73
 
56
74
  ## Development
@@ -355,10 +355,10 @@ const KnownStructTypeName = {
355
355
  Uint32: "uint32",
356
356
  Uint64: "uint64",
357
357
  Float32: "float32",
358
- /** Equivalent to {@link KnownStructTypeName.Float32} */
358
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float32} */
359
359
  Float: "float",
360
360
  Float64: "float64",
361
- /** Equivalent to {@link KnownStructTypeName.Float64} */
361
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float64} */
362
362
  Double: "double"
363
363
  };
364
364
  //#endregion
@@ -367,9 +367,7 @@ const EMPTY_SET = /* @__PURE__ */ new Set();
367
367
  var StructDependencyGraph = class {
368
368
  allDependencies = new Map(Object.values(KnownStructTypeName).map((type) => [type, EMPTY_SET]));
369
369
  registerSchema(name, innerStructNames) {
370
- const existing = this.allDependencies.get(name);
371
- if (existing) for (const innerStructName of innerStructNames) existing.add(innerStructName);
372
- else this.allDependencies.set(name, new Set(innerStructNames));
370
+ this.allDependencies.set(name, new Set(innerStructNames));
373
371
  if (this.hasCycle(name)) throw diagnostics.WPILOG_R0012({ name });
374
372
  }
375
373
  hasCycle(current, path = /* @__PURE__ */ new Set()) {
@@ -491,6 +489,150 @@ function isSignedInteger(type) {
491
489
  }
492
490
  }
493
491
  //#endregion
492
+ //#region src/struct/compile-struct.ts
493
+ const READERS = {
494
+ bool: {
495
+ method: "getUint8",
496
+ bytes: 1
497
+ },
498
+ char: {
499
+ method: "getUint8",
500
+ bytes: 1
501
+ },
502
+ int8: {
503
+ method: "getInt8",
504
+ bytes: 1
505
+ },
506
+ int16: {
507
+ method: "getInt16",
508
+ bytes: 2
509
+ },
510
+ int32: {
511
+ method: "getInt32",
512
+ bytes: 4
513
+ },
514
+ int64: {
515
+ method: "getBigInt64",
516
+ bytes: 8
517
+ },
518
+ uint8: {
519
+ method: "getUint8",
520
+ bytes: 1
521
+ },
522
+ uint16: {
523
+ method: "getUint16",
524
+ bytes: 2
525
+ },
526
+ uint32: {
527
+ method: "getUint32",
528
+ bytes: 4
529
+ },
530
+ uint64: {
531
+ method: "getBigUint64",
532
+ bytes: 8
533
+ },
534
+ float: {
535
+ method: "getFloat32",
536
+ bytes: 4
537
+ },
538
+ float32: {
539
+ method: "getFloat32",
540
+ bytes: 4
541
+ },
542
+ double: {
543
+ method: "getFloat64",
544
+ bytes: 8
545
+ },
546
+ float64: {
547
+ method: "getFloat64",
548
+ bytes: 8
549
+ }
550
+ };
551
+ /** Probe lazily, once per registry, so CSP restrictions leave the interpreter available. */
552
+ function allowsCodeGeneration() {
553
+ try {
554
+ new Function("");
555
+ return true;
556
+ } catch {
557
+ return false;
558
+ }
559
+ }
560
+ function getBitFieldMethod(bitField) {
561
+ switch (bitField.storageByteLength) {
562
+ case 1: return "getUint8";
563
+ case 2: return "getUint16";
564
+ case 4: return "getUint32";
565
+ case 8: return "getBigUint64";
566
+ default: throw new RangeError("Invalid bit-field storage size");
567
+ }
568
+ }
569
+ function generateBitFieldExpression(type, bitField, offset) {
570
+ const raw = `view.${getBitFieldMethod(bitField)}(base + ${offset}, true)`;
571
+ const bigint = bitField.storageByteLength === 8 ? raw : `BigInt(${raw})`;
572
+ const mask = (1n << BigInt(bitField.bitWidth)) - 1n;
573
+ let expression = `((${bigint} >> ${bitField.bitShift}n) & ${mask}n)`;
574
+ if (type === "bool") return `${expression} !== 0n`;
575
+ if (type.startsWith("int")) expression = `BigInt.asIntN(${bitField.bitWidth}, ${expression})`;
576
+ return type === "int64" || type === "uint64" ? expression : `Number(${expression})`;
577
+ }
578
+ /** Compile a schema snapshot after all of its dependencies have been registered. */
579
+ function compileStruct(registry, name) {
580
+ const functions = /* @__PURE__ */ new Map();
581
+ const sources = [];
582
+ function generateMemberValue(member, index, offset, size, reader, statements) {
583
+ const position = `base + ${offset}`;
584
+ if (member.value === "char") return `textDecoder.decode(bytes.subarray(${position}, ${position} + ${size * (member.arraySize ?? 1)}))`;
585
+ const nested = reader ? void 0 : generate(member.value);
586
+ const read = (at) => {
587
+ if (!reader) return `${nested}(view, bytes, ${at})`;
588
+ const value = `view.${reader.method}(${at}, true)`;
589
+ return member.value === "bool" ? `Boolean(${value})` : value;
590
+ };
591
+ if (member.arraySize === void 0) return read(position);
592
+ const expression = `a${index}`;
593
+ statements.push(`const ${expression} = [];`, `for (let i = 0; i < ${member.arraySize}; i++) ${expression}.push(${read(`${position} + i * ${size}`)});`);
594
+ return expression;
595
+ }
596
+ function generate(structName) {
597
+ const existing = functions.get(structName);
598
+ if (existing) return existing;
599
+ const functionName = `s${functions.size}`;
600
+ functions.set(structName, functionName);
601
+ const statements = [];
602
+ const fields = [];
603
+ const bitFields = new BitFieldTracker();
604
+ let offset = 0;
605
+ for (const [index, member] of registry.getDefinition(structName).entries()) {
606
+ const reader = Object.hasOwn(READERS, member.value) ? READERS[member.value] : void 0;
607
+ const size = reader?.bytes ?? registry.getByteLength(member.value);
608
+ if (typeof size !== "number") throw new TypeError(`Missing schema: ${size}`);
609
+ const memberSize = size * (member.arraySize ?? 1);
610
+ const bitField = bitFields.next(member, memberSize);
611
+ let expression;
612
+ if (bitField) {
613
+ offset += bitField.bytesToAdvance;
614
+ expression = generateBitFieldExpression(member.value, bitField, offset);
615
+ } else {
616
+ offset += bitFields.flush();
617
+ expression = generateMemberValue(member, index, offset, size, reader, statements);
618
+ offset += memberSize;
619
+ }
620
+ const key = JSON.stringify(member.name);
621
+ statements.push(`const v${index} = ${expression};`);
622
+ fields.push(`[${key}]: v${index}`);
623
+ }
624
+ sources.push(`function ${functionName}(view, bytes, base) {
625
+ ${statements.join("\n")}
626
+ return {${fields.join(",")}};
627
+ }`);
628
+ return functionName;
629
+ }
630
+ const root = generate(name);
631
+ return new Function("textDecoder", `"use strict";
632
+ ${sources.join("\n")}
633
+ return ${root};`)(new TextDecoder());
634
+ }
635
+ //#endregion
494
636
  //#region src/struct/lexer.ts
495
637
  const Comma = createToken({
496
638
  name: "Comma",
@@ -741,12 +883,18 @@ var StructRegistry = class StructRegistry {
741
883
  static TEXT_DECODER = new TextDecoder("utf-8");
742
884
  definitions = /* @__PURE__ */ new Map();
743
885
  byteLengths = /* @__PURE__ */ new Map();
886
+ decoders = /* @__PURE__ */ new Map();
887
+ codeGenerationAllowed;
744
888
  structDecodeQueue;
745
889
  constructor(structDecodeQueue) {
746
890
  this.structDecodeQueue = structDecodeQueue;
747
891
  }
748
892
  register(name, definition) {
749
893
  const specification = parseStructSpecification(definition);
894
+ if (this.definitions.has(name) && this.definitions.get(name) !== specification) {
895
+ this.byteLengths.clear();
896
+ this.decoders.clear();
897
+ }
750
898
  this.definitions.set(name, specification);
751
899
  this.structDecodeQueue.registerSchema(name, specification.map((member) => member.value));
752
900
  }
@@ -759,28 +907,65 @@ var StructRegistry = class StructRegistry {
759
907
  const structNameWithoutSuffix = structName.slice(0, -2);
760
908
  const structByteLengthOrBlocker = this.getByteLength(structNameWithoutSuffix);
761
909
  if (typeof structByteLengthOrBlocker === "string") return structByteLengthOrBlocker;
910
+ if (structByteLengthOrBlocker === 0) {
911
+ if (payload.byteLength === 0) return [];
912
+ throw new RangeError("Cannot decode an array of zero-length structs");
913
+ }
762
914
  const elements = payload.byteLength / structByteLengthOrBlocker;
763
915
  const offset = new ByteOffset();
916
+ const decoder = this.getDecoder(structNameWithoutSuffix);
917
+ const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
764
918
  const result = [];
765
919
  for (let i = 0; i < elements; i++) {
766
- const decoded = this.decode(structNameWithoutSuffix, payload, offset);
920
+ const decoded = decoder ? decoder(view, payload, i * structByteLengthOrBlocker) : this.decodeInterpreted(structNameWithoutSuffix, payload, offset);
767
921
  if (typeof decoded === "string") throw new TypeError(`Expected struct ${structNameWithoutSuffix} to be defined if the byte length calculation succeeded`);
768
922
  result.push(decoded);
769
923
  }
770
924
  return result;
771
925
  }
772
- decode(structName, payload, offset = new ByteOffset()) {
926
+ decode(structName, payload, offset) {
927
+ const byteLength = this.getByteLength(structName);
928
+ if (typeof byteLength === "string") return byteLength;
929
+ const decoder = this.getDecoder(structName);
930
+ if (!decoder) return this.decodeInterpreted(structName, payload, offset);
931
+ const result = decoder(new DataView(payload.buffer, payload.byteOffset, payload.byteLength), payload, offset?.get() ?? 0);
932
+ offset?.advance(byteLength);
933
+ return result;
934
+ }
935
+ getDecoder(name) {
936
+ this.codeGenerationAllowed ??= allowsCodeGeneration();
937
+ if (!this.codeGenerationAllowed) return void 0;
938
+ const existing = this.decoders.get(name);
939
+ if (existing) return existing;
940
+ try {
941
+ const decoder = compileStruct(this, name);
942
+ this.decoders.set(name, decoder);
943
+ return decoder;
944
+ } catch (error) {
945
+ if (!(error instanceof EvalError)) throw error;
946
+ this.codeGenerationAllowed = false;
947
+ return;
948
+ }
949
+ }
950
+ /** Decode without runtime code generation, including in CSP-restricted environments. */
951
+ decodeInterpreted(structName, payload, offset = new ByteOffset()) {
773
952
  if (!this.definitions.has(structName)) return structName;
774
953
  const specification = this.getDefinition(structName);
775
- const result = /* @__PURE__ */ new Map();
954
+ const result = {};
776
955
  const view = new DataView(payload.buffer, payload.byteOffset, payload.byteLength);
777
956
  const bitFields = new BitFieldTracker();
778
957
  for (const member of specification) {
958
+ if (member.name === "__proto__") Object.defineProperty(result, member.name, {
959
+ value: void 0,
960
+ enumerable: true,
961
+ writable: true,
962
+ configurable: true
963
+ });
779
964
  const memberByteLength = this.calculateByteLength(member);
780
965
  const bitField = typeof memberByteLength === "number" ? bitFields.next(member, memberByteLength) : void 0;
781
966
  if (bitField) {
782
967
  offset.advance(bitField.bytesToAdvance);
783
- result.set(member.name, decodeBitField(view, offset.get(), member, bitField));
968
+ result[member.name] = decodeBitField(view, offset.get(), member, bitField);
784
969
  continue;
785
970
  }
786
971
  offset.advance(bitFields.flush());
@@ -792,9 +977,9 @@ var StructRegistry = class StructRegistry {
792
977
  array.push(Boolean(view.getUint8(offset.get())));
793
978
  offset.advance8();
794
979
  }
795
- result.set(member.name, array);
980
+ result[member.name] = array;
796
981
  } else {
797
- result.set(member.name, Boolean(view.getUint8(offset.get())));
982
+ result[member.name] = Boolean(view.getUint8(offset.get()));
798
983
  offset.advance8();
799
984
  }
800
985
  break;
@@ -805,9 +990,9 @@ var StructRegistry = class StructRegistry {
805
990
  array.push(view.getInt8(offset.get()));
806
991
  offset.advance8();
807
992
  }
808
- result.set(member.name, array);
993
+ result[member.name] = array;
809
994
  } else {
810
- result.set(member.name, view.getInt8(offset.get()));
995
+ result[member.name] = view.getInt8(offset.get());
811
996
  offset.advance8();
812
997
  }
813
998
  break;
@@ -818,9 +1003,9 @@ var StructRegistry = class StructRegistry {
818
1003
  array.push(view.getInt16(offset.get(), true));
819
1004
  offset.advance16();
820
1005
  }
821
- result.set(member.name, array);
1006
+ result[member.name] = array;
822
1007
  } else {
823
- result.set(member.name, view.getInt16(offset.get(), true));
1008
+ result[member.name] = view.getInt16(offset.get(), true);
824
1009
  offset.advance16();
825
1010
  }
826
1011
  break;
@@ -831,9 +1016,9 @@ var StructRegistry = class StructRegistry {
831
1016
  array.push(view.getInt32(offset.get(), true));
832
1017
  offset.advance32();
833
1018
  }
834
- result.set(member.name, array);
1019
+ result[member.name] = array;
835
1020
  } else {
836
- result.set(member.name, view.getInt32(offset.get(), true));
1021
+ result[member.name] = view.getInt32(offset.get(), true);
837
1022
  offset.advance32();
838
1023
  }
839
1024
  break;
@@ -844,9 +1029,9 @@ var StructRegistry = class StructRegistry {
844
1029
  array.push(view.getBigInt64(offset.get(), true));
845
1030
  offset.advance64();
846
1031
  }
847
- result.set(member.name, array);
1032
+ result[member.name] = array;
848
1033
  } else {
849
- result.set(member.name, view.getBigInt64(offset.get(), true));
1034
+ result[member.name] = view.getBigInt64(offset.get(), true);
850
1035
  offset.advance64();
851
1036
  }
852
1037
  break;
@@ -857,9 +1042,9 @@ var StructRegistry = class StructRegistry {
857
1042
  array.push(view.getUint8(offset.get()));
858
1043
  offset.advance8();
859
1044
  }
860
- result.set(member.name, array);
1045
+ result[member.name] = array;
861
1046
  } else {
862
- result.set(member.name, view.getUint8(offset.get()));
1047
+ result[member.name] = view.getUint8(offset.get());
863
1048
  offset.advance8();
864
1049
  }
865
1050
  break;
@@ -870,9 +1055,9 @@ var StructRegistry = class StructRegistry {
870
1055
  array.push(view.getUint16(offset.get(), true));
871
1056
  offset.advance16();
872
1057
  }
873
- result.set(member.name, array);
1058
+ result[member.name] = array;
874
1059
  } else {
875
- result.set(member.name, view.getUint16(offset.get(), true));
1060
+ result[member.name] = view.getUint16(offset.get(), true);
876
1061
  offset.advance16();
877
1062
  }
878
1063
  break;
@@ -883,9 +1068,9 @@ var StructRegistry = class StructRegistry {
883
1068
  array.push(view.getUint32(offset.get(), true));
884
1069
  offset.advance32();
885
1070
  }
886
- result.set(member.name, array);
1071
+ result[member.name] = array;
887
1072
  } else {
888
- result.set(member.name, view.getUint32(offset.get(), true));
1073
+ result[member.name] = view.getUint32(offset.get(), true);
889
1074
  offset.advance32();
890
1075
  }
891
1076
  break;
@@ -896,9 +1081,9 @@ var StructRegistry = class StructRegistry {
896
1081
  array.push(view.getBigUint64(offset.get(), true));
897
1082
  offset.advance64();
898
1083
  }
899
- result.set(member.name, array);
1084
+ result[member.name] = array;
900
1085
  } else {
901
- result.set(member.name, view.getBigUint64(offset.get(), true));
1086
+ result[member.name] = view.getBigUint64(offset.get(), true);
902
1087
  offset.advance64();
903
1088
  }
904
1089
  break;
@@ -910,9 +1095,9 @@ var StructRegistry = class StructRegistry {
910
1095
  array.push(view.getFloat32(offset.get(), true));
911
1096
  offset.advance32();
912
1097
  }
913
- result.set(member.name, array);
1098
+ result[member.name] = array;
914
1099
  } else {
915
- result.set(member.name, view.getFloat32(offset.get(), true));
1100
+ result[member.name] = view.getFloat32(offset.get(), true);
916
1101
  offset.advance32();
917
1102
  }
918
1103
  break;
@@ -924,28 +1109,28 @@ var StructRegistry = class StructRegistry {
924
1109
  array.push(view.getFloat64(offset.get(), true));
925
1110
  offset.advance64();
926
1111
  }
927
- result.set(member.name, array);
1112
+ result[member.name] = array;
928
1113
  } else {
929
- result.set(member.name, view.getFloat64(offset.get(), true));
1114
+ result[member.name] = view.getFloat64(offset.get(), true);
930
1115
  offset.advance64();
931
1116
  }
932
1117
  break;
933
1118
  case KnownStructTypeName.Character:
934
- if (member.arraySize !== void 0) result.set(member.name, StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance(member.arraySize).get())));
935
- else result.set(member.name, StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance8().get())));
1119
+ if (member.arraySize !== void 0) result[member.name] = StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance(member.arraySize).get()));
1120
+ else result[member.name] = StructRegistry.TEXT_DECODER.decode(payload.subarray(offset.get(), offset.advance8().get()));
936
1121
  break;
937
1122
  default: if (member.arraySize !== void 0) {
938
1123
  const array = [];
939
1124
  for (let i = 0; i < member.arraySize; i++) {
940
- const decoded = this.decode(member.value, payload, offset);
1125
+ const decoded = this.decodeInterpreted(member.value, payload, offset);
941
1126
  if (typeof decoded === "string") return decoded;
942
1127
  array.push(decoded);
943
1128
  }
944
- result.set(member.name, array);
1129
+ result[member.name] = array;
945
1130
  } else {
946
- const decoded = this.decode(member.value, payload, offset);
1131
+ const decoded = this.decodeInterpreted(member.value, payload, offset);
947
1132
  if (typeof decoded === "string") return decoded;
948
- result.set(member.name, decoded);
1133
+ result[member.name] = decoded;
949
1134
  }
950
1135
  }
951
1136
  }
@@ -953,6 +1138,7 @@ var StructRegistry = class StructRegistry {
953
1138
  return result;
954
1139
  }
955
1140
  getByteLength(name) {
1141
+ if (!this.definitions.has(name)) return name;
956
1142
  const existing = this.byteLengths.get(name);
957
1143
  if (existing !== void 0) return existing;
958
1144
  const definition = this.getDefinition(name);
package/dist/cli.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { o as readRecords, t as catalogEntries, u as diagnostics } from "./catalog-BT6geQr0.mjs";
2
+ import { o as readRecords, t as catalogEntries, u as diagnostics } from "./catalog-AwcdBV3I.mjs";
3
3
  import { Diagnostic, formatDiagnostic } from "nostics";
4
4
  import { cac } from "cac";
5
+ import oscStatus from "osc-status";
5
6
  import { readFile } from "node:fs/promises";
6
7
  import { encode } from "@toon-format/toon";
7
8
  //#region package.json
8
- var version = "2.4.1";
9
+ var version = "3.0.0";
9
10
  //#endregion
10
11
  //#region src/cli/catalog.ts
11
12
  async function catalogFile(filePath) {
@@ -60,8 +61,16 @@ function formatCatalog(entries, format = "toon") {
60
61
  const cli = cac("wpilog");
61
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) => {
62
63
  const format = selectCatalogFormat(options);
64
+ oscStatus.working({
65
+ app: "wpilog",
66
+ message: "Cataloging log"
67
+ });
63
68
  const entries = await catalogFile(file);
64
69
  console.log(formatCatalog(entries, format));
70
+ oscStatus.done({
71
+ app: "wpilog",
72
+ message: `Cataloged ${entries.length} entries`
73
+ });
65
74
  });
66
75
  cli.help();
67
76
  cli.version(version);
@@ -76,6 +85,10 @@ try {
76
85
  const message = error instanceof Diagnostic ? formatDiagnostic(error) : error instanceof Error ? error.message : String(error);
77
86
  console.error(error instanceof Diagnostic ? message : `wpilog: ${message}`);
78
87
  process.exitCode = 1;
88
+ oscStatus.error({
89
+ app: "wpilog",
90
+ message: "Command failed"
91
+ });
79
92
  }
80
93
  //#endregion
81
94
  export {};
package/dist/index.d.mts CHANGED
@@ -60,8 +60,10 @@ export declare const RecordType: {
60
60
  readonly Raw: 'raw';
61
61
  };
62
62
  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[]>;
63
+ /** Decoded struct payload. Fields, including nested structs, are own properties of a plain object. */
64
+ type StructPayload = {
65
+ [key: string]: number | boolean | bigint | string | StructPayload | number[] | boolean[] | bigint[] | StructPayload[] | undefined;
66
+ };
65
67
  /** A decoded data record (excludes control records). */
66
68
  type DataRecord = Extract<DecodedRecord, {
67
69
  name: string;
@@ -180,10 +182,6 @@ export declare function decodeRecords(records: Iterable<ReadRecord>, options?: D
180
182
  */
181
183
  export declare function parseDataLog(input: DataLogInput, options?: DecodeRecordsOptions): Generator<DecodedRecord>;
182
184
  //#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
185
  //#region src/catalog.d.ts
188
186
  /** An entry definition from the WPILOG catalog. */
189
187
  type CatalogEntry = {
@@ -214,10 +212,10 @@ export declare const KnownStructTypeName: {
214
212
  readonly Uint32: 'uint32';
215
213
  readonly Uint64: 'uint64';
216
214
  readonly Float32: 'float32';
217
- /** Equivalent to {@link KnownStructTypeName.Float32} */
215
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float32} */
218
216
  readonly Float: 'float';
219
217
  readonly Float64: 'float64';
220
- /** Equivalent to {@link KnownStructTypeName.Float64} */
218
+ /** Equivalent to {@link (KnownStructTypeName:variable).Float64} */
221
219
  readonly Double: 'double';
222
220
  };
223
221
  export type KnownStructTypeName = (typeof KnownStructTypeName)[keyof typeof KnownStructTypeName];
package/dist/index.mjs CHANGED
@@ -1,12 +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-BT6geQr0.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) if (value instanceof Map) result[key] = structPayloadToJson(value);
7
- else if (Array.isArray(value) && value.length > 0 && value[0] instanceof Map) result[key] = value.map((v) => structPayloadToJson(v));
8
- else result[key] = value;
9
- return result;
10
- }
11
- //#endregion
12
- 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-AwcdBV3I.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.4.1",
3
+ "version": "3.0.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,13 +29,17 @@
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
  },
@@ -43,11 +47,13 @@
43
47
  "@toon-format/toon": "^4.1.1",
44
48
  "cac": "^7.0.0",
45
49
  "chevrotain": "^13.0.0",
46
- "nostics": "^1.3.0"
50
+ "nostics": "^1.3.0",
51
+ "osc-status": "^1.0.0"
47
52
  },
48
53
  "devDependencies": {
49
- "@codspeed/vitest-plugin": "5.7.1",
50
- "@types/node": "26.6.3",
54
+ "@codspeed/vitest-plugin": "6.1.0",
55
+ "@microsoft/api-extractor": "7.59.4",
56
+ "@types/node": "26.6.5",
51
57
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
52
58
  "typescript": "7.0.2",
53
59
  "vite-plus": "catalog:",
@@ -59,5 +65,6 @@
59
65
  "version": "26.x"
60
66
  }
61
67
  },
62
- "packageManager": "pnpm@12.6.0"
68
+ "packageManager": "pnpm@12.14.0",
69
+ "tsdocMetadata": "./dist/tsdoc-metadata.json"
63
70
  }
@@ -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 },