ableton-js 3.4.4 → 3.4.6

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.6](https://github.com/leolabs/ableton.js/compare/v3.4.5...v3.4.6)
8
+
9
+ - Get `song.view.get('detail_clip')` working [`#118`](https://github.com/leolabs/ableton.js/pull/118)
10
+
11
+ #### [v3.4.5](https://github.com/leolabs/ableton.js/compare/v3.4.4...v3.4.5)
12
+
13
+ > 3 May 2024
14
+
15
+ - :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)
16
+
7
17
  #### [v3.4.4](https://github.com/leolabs/ableton.js/compare/v3.4.3...v3.4.4)
8
18
 
19
+ > 1 May 2024
20
+
9
21
  - :sparkles: Add the `tempo_follower_enabled` property [`8cf68c8`](https://github.com/leolabs/ableton.js/commit/8cf68c8e2a261cea6f8ebab8ec9e5db8a8c39195)
10
22
 
11
23
  #### [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);
@@ -3,6 +3,7 @@ from .Interface import Interface
3
3
  from .DeviceParameter import DeviceParameter
4
4
  from .Scene import Scene
5
5
  from .Track import Track
6
+ from .Clip import Clip
6
7
  from .ClipSlot import ClipSlot
7
8
 
8
9
 
@@ -13,6 +14,12 @@ class SongView(Interface):
13
14
  def get_ns(self, nsid):
14
15
  return self.ableton.song().view
15
16
 
17
+ def get_detail_clip(self, ns):
18
+ return Clip.serialize_clip(ns.detail_clip)
19
+
20
+ def set_detail_clip(self, ns, clip_id):
21
+ ns.detail_clip = Interface.get_obj(clip_id)
22
+
16
23
  def select_device(self, ns, device_id):
17
24
  return ns.select_device(Interface.get_obj(device_id))
18
25
 
@@ -1 +1 @@
1
- version = "3.4.4"
1
+ version = "3.4.6"
package/ns/song-view.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- import { Ableton } from "..";
2
1
  import { Namespace } from ".";
3
- import { Device } from "./device";
4
- import { Track, RawTrack } from "./track";
5
- import { Scene, RawScene } from "./scene";
6
- import { RawDeviceParameter, DeviceParameter } from "./device-parameter";
2
+ import { Ableton } from "..";
3
+ import { Clip, RawClip } from "./clip";
7
4
  import { ClipSlot, RawClipSlot } from "./clip-slot";
5
+ import { Device } from "./device";
6
+ import { DeviceParameter, RawDeviceParameter } from "./device-parameter";
7
+ import { RawScene, Scene } from "./scene";
8
+ import { RawTrack, Track } from "./track";
8
9
  export interface GettableProperties {
9
- detail_clip: any;
10
+ detail_clip: RawClip;
10
11
  draw_mode: boolean;
11
12
  follow_song: boolean;
12
13
  highlighted_clip_slot: RawClipSlot;
@@ -16,21 +17,22 @@ export interface GettableProperties {
16
17
  selected_track: RawTrack;
17
18
  }
18
19
  export interface TransformedProperties {
20
+ detail_clip: Clip;
19
21
  selected_parameter: DeviceParameter;
20
22
  selected_scene: Scene;
21
23
  selected_track: Track;
22
24
  highlighted_clip_slot: ClipSlot;
23
25
  }
24
26
  export interface SettableProperties {
25
- detail_clip: any;
27
+ detail_clip: RawClip["id"];
26
28
  draw_mode: boolean;
27
29
  follow_song: boolean;
28
30
  highlighted_clip_slot: number;
29
- selected_scene: RawScene['id'];
30
- selected_track: RawTrack['id'];
31
+ selected_scene: RawScene["id"];
32
+ selected_track: RawTrack["id"];
31
33
  }
32
34
  export interface ObservableProperties {
33
- detail_clip: any;
35
+ detail_clip: RawClip | null;
34
36
  draw_mode: any;
35
37
  follow_song: any;
36
38
  highlighted_clip_slot: any;
package/ns/song-view.js CHANGED
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SongView = void 0;
4
4
  const _1 = require(".");
5
- const track_1 = require("./track");
6
- const scene_1 = require("./scene");
7
- const device_parameter_1 = require("./device-parameter");
5
+ const clip_1 = require("./clip");
8
6
  const clip_slot_1 = require("./clip-slot");
7
+ const device_parameter_1 = require("./device-parameter");
8
+ const scene_1 = require("./scene");
9
+ const track_1 = require("./track");
9
10
  class SongView extends _1.Namespace {
10
11
  constructor(ableton) {
11
12
  super(ableton, "song-view");
@@ -14,8 +15,10 @@ class SongView extends _1.Namespace {
14
15
  selected_track: (track) => new track_1.Track(ableton, track),
15
16
  selected_scene: (scene) => new scene_1.Scene(ableton, scene),
16
17
  highlighted_clip_slot: (slot) => new clip_slot_1.ClipSlot(ableton, slot),
18
+ detail_clip: (clip) => new clip_1.Clip(ableton, clip),
17
19
  };
18
20
  this.cachedProps = {
21
+ detail_clip: true,
19
22
  selected_parameter: true,
20
23
  selected_track: true,
21
24
  selected_scene: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ableton-js",
3
- "version": "3.4.4",
3
+ "version": "3.4.6",
4
4
  "description": "Control Ableton Live from Node",
5
5
  "main": "index.js",
6
6
  "author": "Leo Bernard <admin@leolabs.org>",