@blueyerobotics/blueye-ts 3.8.0 → 3.10.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.
@@ -22,7 +22,7 @@ export declare const parse: (rawData: Blob, fixTimes?: boolean) => Promise<Messa
22
22
  * @param rawData The compressed binary data to decompress (gzip format).
23
23
  * @returns A promise that resolves to the decompressed data as a Buffer.
24
24
  */
25
- export declare const decompress: (rawData: Blob) => Promise<Buffer>;
25
+ export declare const decompress: (rawData: Blob) => Promise<Buffer<ArrayBuffer>>;
26
26
  /**
27
27
  * Parse the decompressed binlog data into structured messages.
28
28
  * @param decompressed The gunzipped binlog data.
@@ -35,4 +35,18 @@ export declare const parseMessages: (decompressed: Uint8Array, fixTimes?: boolea
35
35
  * @param messages The messages to fix the times for.
36
36
  * @returns The messages with corrected times.
37
37
  */
38
+ /**
39
+ * Parse a single varint-prefixed BinlogRecord from raw (uncompressed) bytes.
40
+ * Used for streaming playback where individual frames are fetched via HTTP Range requests.
41
+ * @param bytes Raw bytes containing a single varint-length-prefixed BinlogRecord.
42
+ * @returns The parsed message, or null if the record is not a known protocol type.
43
+ */
44
+ export declare const parseFrame: (bytes: Uint8Array) => Message | null;
45
+ /**
46
+ * Parse multiple contiguous varint-prefixed BinlogRecords from raw (uncompressed) bytes.
47
+ * Used for streaming playback where frame batches are fetched via HTTP Range requests.
48
+ * @param bytes Raw bytes containing one or more varint-length-prefixed BinlogRecords.
49
+ * @returns An array of parsed messages.
50
+ */
51
+ export declare const parseFrames: (bytes: Uint8Array) => Message[];
38
52
  export declare const fixMessageTimes: (messages: Message[]) => Message[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fixMessageTimes = exports.parseMessages = exports.decompress = exports.parse = void 0;
3
+ exports.fixMessageTimes = exports.parseFrames = exports.parseFrame = exports.parseMessages = exports.decompress = exports.parse = void 0;
4
4
  const protocol_definitions_1 = require("@blueyerobotics/protocol-definitions");
5
5
  const wire_1 = require("@bufbuild/protobuf/wire");
6
6
  const buffer_1 = require("buffer");
@@ -115,6 +115,27 @@ exports.parseMessages = parseMessages;
115
115
  * @param messages The messages to fix the times for.
116
116
  * @returns The messages with corrected times.
117
117
  */
118
+ /**
119
+ * Parse a single varint-prefixed BinlogRecord from raw (uncompressed) bytes.
120
+ * Used for streaming playback where individual frames are fetched via HTTP Range requests.
121
+ * @param bytes Raw bytes containing a single varint-length-prefixed BinlogRecord.
122
+ * @returns The parsed message, or null if the record is not a known protocol type.
123
+ */
124
+ const parseFrame = (bytes) => {
125
+ const messages = (0, exports.parseFrames)(bytes);
126
+ return messages.length > 0 ? messages[0] : null;
127
+ };
128
+ exports.parseFrame = parseFrame;
129
+ /**
130
+ * Parse multiple contiguous varint-prefixed BinlogRecords from raw (uncompressed) bytes.
131
+ * Used for streaming playback where frame batches are fetched via HTTP Range requests.
132
+ * @param bytes Raw bytes containing one or more varint-length-prefixed BinlogRecords.
133
+ * @returns An array of parsed messages.
134
+ */
135
+ const parseFrames = (bytes) => {
136
+ return (0, exports.parseMessages)(bytes, false);
137
+ };
138
+ exports.parseFrames = parseFrames;
118
139
  const fixMessageTimes = (messages) => {
119
140
  if (messages.length === 0)
120
141
  return messages;
@@ -42,7 +42,6 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
42
42
  level: logLevel,
43
43
  formatOptions: { colors: true, compact: false },
44
44
  });
45
- // @ts-ignore
46
45
  this.sub.on("message", (topic, msg) => {
47
46
  const { key, data } = schema_1.responseSchema.parse({ key: topic, data: msg });
48
47
  if (!(0, exports.isInProtocol)(key) || !key.endsWith("Tel")) {
@@ -107,7 +106,6 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
107
106
  const request = () => {
108
107
  return new Promise((resolve, reject) => {
109
108
  const timer = setTimeout(() => reject(new Error("[rpc] request timed out")), this.timeout);
110
- // @ts-ignore
111
109
  this.rpc.once("message", (topic, msg) => {
112
110
  clearTimeout(timer);
113
111
  resolve({ key: topic.toString().split(".").at(-1), data: msg });
@@ -1,12 +1,11 @@
1
- import { Buffer } from "buffer";
2
1
  import z from "zod";
3
2
  export declare const responseSchema: z.ZodObject<{
4
- key: z.ZodPipe<z.ZodCustom<Buffer, Buffer>, z.ZodTransform<string, Buffer>>;
5
- data: z.ZodCustom<Buffer, Buffer>;
3
+ key: z.ZodPipe<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>, z.ZodTransform<string, Uint8Array<ArrayBuffer>>>;
4
+ data: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
6
5
  }, z.core.$strip>;
7
6
  export declare const telemetrySchema: z.ZodObject<{
8
7
  payload: z.ZodObject<{
9
8
  typeUrl: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
10
- value: z.ZodPipe<z.ZodAny & z.ZodType<Buffer | Uint8Array<ArrayBufferLike>, any, z.core.$ZodTypeInternals<Buffer | Uint8Array<ArrayBufferLike>, any>>, z.ZodTransform<Buffer, any>>;
9
+ value: z.ZodPipe<z.ZodAny & z.ZodType<Buffer<ArrayBuffer> | Buffer<any> | Uint8Array<ArrayBufferLike>, any, z.core.$ZodTypeInternals<Buffer<ArrayBuffer> | Buffer<any> | Uint8Array<ArrayBufferLike>, any>>, z.ZodTransform<Buffer<any>, any>>;
11
10
  }, z.core.$strip>;
12
11
  }, z.core.$strip>;
@@ -4,20 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.telemetrySchema = exports.responseSchema = void 0;
7
- const buffer_1 = require("buffer");
8
7
  const zod_1 = __importDefault(require("zod"));
9
8
  exports.responseSchema = zod_1.default.object({
10
9
  key: zod_1.default
11
- .instanceof(buffer_1.Buffer)
10
+ .instanceof(Uint8Array)
12
11
  .transform((val) => val.toString().split(".").at(-1)),
13
- data: zod_1.default.instanceof(buffer_1.Buffer),
12
+ data: zod_1.default.instanceof(Uint8Array),
14
13
  });
15
14
  exports.telemetrySchema = zod_1.default.object({
16
15
  payload: zod_1.default.object({
17
16
  typeUrl: zod_1.default.string().transform((val) => val.split(".").at(-1)),
18
17
  value: zod_1.default
19
18
  .any()
20
- .refine((val) => val instanceof buffer_1.Buffer || val instanceof Uint8Array)
21
- .transform((val) => (buffer_1.Buffer.isBuffer(val) ? val : buffer_1.Buffer.from(val))),
19
+ .refine((val) => val instanceof Buffer || val instanceof Uint8Array)
20
+ .transform((val) => (Buffer.isBuffer(val) ? val : Buffer.from(val))),
22
21
  }),
23
22
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueyerobotics/blueye-ts",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "A TypeScript client for interacting with Blueye underwater drones.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,6 +26,7 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@biomejs/biome": "2.3.14",
29
+ "@types/node": "^25.4.0",
29
30
  "typescript": "^5.9.3"
30
31
  },
31
32
  "scripts": {