ableton-js 3.4.3 → 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,20 @@ 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
+
11
+ #### [v3.4.4](https://github.com/leolabs/ableton.js/compare/v3.4.3...v3.4.4)
12
+
13
+ > 1 May 2024
14
+
15
+ - :sparkles: Add the `tempo_follower_enabled` property [`8cf68c8`](https://github.com/leolabs/ableton.js/commit/8cf68c8e2a261cea6f8ebab8ec9e5db8a8c39195)
16
+
7
17
  #### [v3.4.3](https://github.com/leolabs/ableton.js/compare/v3.4.2...v3.4.3)
8
18
 
19
+ > 16 March 2024
20
+
9
21
  - :loud_sound: Improve error logging [`5c35106`](https://github.com/leolabs/ableton.js/commit/5c35106a2702fab9bc97ba377478cbc884041c93)
10
22
  - :bug: Fix issues with converting iterables to arrays in Live 10 [`2af2f25`](https://github.com/leolabs/ableton.js/commit/2af2f25453edabbc2a685f7358aa491eb1f79cfc)
11
23
 
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.3"
1
+ version = "3.4.5"
package/ns/song.d.ts CHANGED
@@ -50,6 +50,7 @@ export interface GettableProperties {
50
50
  song_length: number;
51
51
  swing_amount: number;
52
52
  tempo: number;
53
+ tempo_follower_enabled: boolean;
53
54
  tracks: RawTrack[];
54
55
  visible_tracks: RawTrack[];
55
56
  }
@@ -99,6 +100,7 @@ export interface SettableProperties {
99
100
  song_length: number;
100
101
  swing_amount: number;
101
102
  tempo: number;
103
+ tempo_follower_enabled: boolean;
102
104
  visible_tracks: number;
103
105
  }
104
106
  export interface ObservableProperties {
@@ -139,6 +141,7 @@ export interface ObservableProperties {
139
141
  song_length: number;
140
142
  swing_amount: number;
141
143
  tempo: number;
144
+ tempo_follower_enabled: boolean;
142
145
  tracks: RawTrack[];
143
146
  }
144
147
  export interface SmpteTime {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ableton-js",
3
- "version": "3.4.3",
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>",