ableton-js 3.4.4 → 3.4.5

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/CHANGELOG.md CHANGED
@@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [v3.4.5](https://github.com/leolabs/ableton.js/compare/v3.4.4...v3.4.5)
8
+
9
+ - :bug: Fix some pending requests never resolving when Live disconnects, immediately reject pending requests when Live sends a realtime disconnect event [`4c1a3fe`](https://github.com/leolabs/ableton.js/commit/4c1a3fe9465c0b690aa3ae29f79a39fbaa991a61)
10
+
7
11
  #### [v3.4.4](https://github.com/leolabs/ableton.js/compare/v3.4.3...v3.4.4)
8
12
 
13
+ > 1 May 2024
14
+
9
15
  - :sparkles: Add the `tempo_follower_enabled` property [`8cf68c8`](https://github.com/leolabs/ableton.js/commit/8cf68c8e2a261cea6f8ebab8ec9e5db8a8c39195)
10
16
 
11
17
  #### [v3.4.3](https://github.com/leolabs/ableton.js/compare/v3.4.2...v3.4.3)
package/index.d.ts CHANGED
@@ -37,6 +37,11 @@ export declare class TimeoutError extends Error {
37
37
  payload: Command;
38
38
  constructor(message: string, payload: Command);
39
39
  }
40
+ export declare class DisconnectError extends Error {
41
+ message: string;
42
+ payload: Command;
43
+ constructor(message: string, payload: Command);
44
+ }
40
45
  export interface AbletonOptions {
41
46
  /**
42
47
  * Name of the file containing the port of the Remote Script. This
package/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPackageVersion = exports.Ableton = exports.TimeoutError = void 0;
6
+ exports.getPackageVersion = exports.Ableton = exports.DisconnectError = exports.TimeoutError = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const dgram_1 = __importDefault(require("dgram"));
@@ -33,6 +33,16 @@ class TimeoutError extends Error {
33
33
  }
34
34
  }
35
35
  exports.TimeoutError = TimeoutError;
36
+ class DisconnectError extends Error {
37
+ message;
38
+ payload;
39
+ constructor(message, payload) {
40
+ super(message);
41
+ this.message = message;
42
+ this.payload = payload;
43
+ }
44
+ }
45
+ exports.DisconnectError = DisconnectError;
36
46
  class Ableton extends events_1.EventEmitter {
37
47
  options;
38
48
  client;
@@ -76,8 +86,12 @@ class Ableton extends events_1.EventEmitter {
76
86
  if (this._isConnected) {
77
87
  this._isConnected = false;
78
88
  this.eventListeners.clear();
79
- this.msgMap.forEach((msg) => msg.clearTimeout());
80
- this.msgMap.clear();
89
+ // If the disconnect is caused by missed heartbeats, keep
90
+ // pending requests. Live might just be temporarily hanging.
91
+ if (type === "realtime") {
92
+ this.msgMap.forEach((msg) => msg.clearTimeout());
93
+ this.msgMap.clear();
94
+ }
81
95
  this.logger?.info("Live disconnected", { type });
82
96
  this.emit("disconnect", type);
83
97
  }
@@ -308,16 +322,10 @@ class Ableton extends events_1.EventEmitter {
308
322
  };
309
323
  const msg = JSON.stringify(payload);
310
324
  const timeout = this.options?.commandTimeoutMs ?? 2000;
325
+ const arg = (0, lodash_1.truncate)(JSON.stringify(command.args), { length: 100 });
326
+ const cls = command.nsid ? `${command.ns}(${command.nsid})` : command.ns;
311
327
  const timeoutId = setTimeout(() => {
312
- const arg = (0, lodash_1.truncate)(JSON.stringify(command.args), { length: 100 });
313
- const cls = command.nsid
314
- ? `${command.ns}(${command.nsid})`
315
- : command.ns;
316
- rej(new TimeoutError([
317
- `The command ${cls}.${command.name}(${arg}) timed out after ${timeout} ms.`,
318
- `Please make sure that Ableton is running and that you have the latest`,
319
- `version of AbletonJS' MIDI script installed and renamed to "AbletonJS".`,
320
- ].join(" "), payload));
328
+ rej(new TimeoutError(`The command ${cls}.${command.name}(${arg}) timed out after ${timeout} ms.`, payload));
321
329
  }, timeout);
322
330
  const currentTimestamp = Date.now();
323
331
  this.msgMap.set(msgId, {
@@ -336,6 +344,7 @@ class Ableton extends events_1.EventEmitter {
336
344
  rej,
337
345
  clearTimeout: () => {
338
346
  clearTimeout(timeoutId);
347
+ rej(new DisconnectError(`Live disconnected before being able to respond to ${cls}.${command.name}(${arg})`, payload));
339
348
  },
340
349
  });
341
350
  this.sendRaw(msg);
@@ -1 +1 @@
1
- version = "3.4.4"
1
+ version = "3.4.5"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ableton-js",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "description": "Control Ableton Live from Node",
5
5
  "main": "index.js",
6
6
  "author": "Leo Bernard <admin@leolabs.org>",