@blueyerobotics/blueye-ts 3.0.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/dist/example.js CHANGED
@@ -14,7 +14,7 @@ const main = async () => {
14
14
  await client.sendControl("LightsCtrl", { lights: { value: 1 } });
15
15
  });
16
16
  // subscribe to battery telemetry updates
17
- client.on("BatteryTel", data => {
17
+ client.on("BatteryTel", (data) => {
18
18
  console.log("received BatteryTel:", data);
19
19
  });
20
20
  client.connect();
@@ -38,7 +38,7 @@ export declare class BlueyeClient extends Emitter<Events> {
38
38
  private rpc;
39
39
  private pub;
40
40
  private logger;
41
- constructor({ subUrl, rpcUrl, pubUrl, timeout, logLevel, autoConnect }?: Options);
41
+ constructor({ subUrl, rpcUrl, pubUrl, timeout, logLevel, autoConnect, }?: Options);
42
42
  private updateState;
43
43
  connect(): void;
44
44
  disconnect(): void;
@@ -24,10 +24,13 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
24
24
  rpc;
25
25
  pub;
26
26
  logger;
27
- constructor({ subUrl = DEFAULT_SUB_URL, rpcUrl = DEFAULT_RPC_URL, pubUrl = DEFAULT_PUB_URL, timeout = 2000, logLevel = consola_1.LogLevels.info, autoConnect = false } = {}) {
27
+ constructor({ subUrl = DEFAULT_SUB_URL, rpcUrl = DEFAULT_RPC_URL, pubUrl = DEFAULT_PUB_URL, timeout = 2000, logLevel = consola_1.LogLevels.info, autoConnect = false, } = {}) {
28
28
  super();
29
29
  this.timeout = timeout;
30
- this.logger = (0, consola_1.createConsola)({ level: logLevel, formatOptions: { colors: true, compact: false } });
30
+ this.logger = (0, consola_1.createConsola)({
31
+ level: logLevel,
32
+ formatOptions: { colors: true, compact: false },
33
+ });
31
34
  this.subUrl = subUrl;
32
35
  this.rpcUrl = rpcUrl;
33
36
  this.pubUrl = pubUrl;
@@ -95,13 +98,16 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
95
98
  const encoded = protocol.encode(message).finish();
96
99
  const { key, data } = await Promise.race([
97
100
  new Promise((_, reject) => setTimeout(() => reject(new Error("[rpc] request timed out")), this.timeout)),
98
- new Promise(resolve => {
101
+ new Promise((resolve) => {
99
102
  // @ts-ignore
100
103
  this.rpc.once("message", (topic, msg) => {
101
104
  resolve({ key: topic.toString().split(".").at(-1), data: msg });
102
105
  });
103
- this.rpc.send([buffer_1.Buffer.from(`blueye.protocol.${req}`), buffer_1.Buffer.from(encoded)]);
104
- })
106
+ this.rpc.send([
107
+ buffer_1.Buffer.from(`blueye.protocol.${req}`),
108
+ buffer_1.Buffer.from(encoded),
109
+ ]);
110
+ }),
105
111
  ]);
106
112
  if (key === "Empty") {
107
113
  return null;
@@ -115,7 +121,9 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
115
121
  return result;
116
122
  }
117
123
  async getTelemetry(type) {
118
- const response = await this.sendRequest("GetTelemetryReq", { messageType: type });
124
+ const response = await this.sendRequest("GetTelemetryReq", {
125
+ messageType: type,
126
+ });
119
127
  const { payload } = schema_1.telemetrySchema.parse(response);
120
128
  const { typeUrl, value } = payload;
121
129
  if (!(0, exports.isInProtocol)(typeUrl) || !typeUrl.endsWith("Tel")) {
@@ -133,7 +141,10 @@ class BlueyeClient extends strict_event_emitter_1.Emitter {
133
141
  const message = protocol.create(opts);
134
142
  const encoded = protocol.encode(message).finish();
135
143
  this.logger.debug("[pub] sending control:", ctrl, message);
136
- this.pub.send([buffer_1.Buffer.from(`blueye.protocol.${ctrl}`), buffer_1.Buffer.from(encoded)]);
144
+ this.pub.send([
145
+ buffer_1.Buffer.from(`blueye.protocol.${ctrl}`),
146
+ buffer_1.Buffer.from(encoded),
147
+ ]);
137
148
  }
138
149
  }
139
150
  exports.BlueyeClient = BlueyeClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueyerobotics/blueye-ts",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "A TypeScript client for interacting with Blueye underwater drones.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "author": "Blueye <contact@blueye.no> (https://blueye.no/)",
20
20
  "license": "LGPL-3.0-only",
21
21
  "dependencies": {
22
- "@blueyerobotics/protocol-definitions": "3.2.0-0f78a956",
22
+ "@blueyerobotics/protocol-definitions": "3.2.0-b032513b",
23
23
  "buffer": "^6.0.3",
24
24
  "consola": "^3.4.2",
25
25
  "jszmq": "^0.1.2",
@@ -27,6 +27,6 @@
27
27
  "zod": "^3.25.67"
28
28
  },
29
29
  "devDependencies": {
30
- "typescript": "^5.8.3"
30
+ "typescript": "^5.9.2"
31
31
  }
32
32
  }