ableton-js 3.2.4 → 3.2.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 +14 -0
- package/index.js +19 -19
- package/midi-script/Internal.py +4 -0
- package/midi-script/Socket.py +7 -17
- package/midi-script/version.py +1 -1
- package/ns/clip.d.ts +1 -0
- package/ns/track.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,22 @@ 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.2.6](https://github.com/leolabs/ableton.js/compare/v3.2.5...v3.2.6)
|
|
8
|
+
|
|
9
|
+
- :bug: Fix Live 11.3.3 hanging in some scenarios [`f3933b1`](https://github.com/leolabs/ableton.js/commit/f3933b1b714d1d87a1e4952bc142d017d513242b)
|
|
10
|
+
- :mute: Make logging less noisy when the heartbeat to Live fails [`2f46968`](https://github.com/leolabs/ableton.js/commit/2f46968db10ce82288fb221d5c6e22e5fb0c6972)
|
|
11
|
+
- :loud_sound: Truncate arguments in the error message when a command times out [`8bd0a9c`](https://github.com/leolabs/ableton.js/commit/8bd0a9cd7f1b4864e163fd22d87997f0d1c3dc30)
|
|
12
|
+
|
|
13
|
+
#### [v3.2.5](https://github.com/leolabs/ableton.js/compare/v3.2.4...v3.2.5)
|
|
14
|
+
|
|
15
|
+
> 27 June 2023
|
|
16
|
+
|
|
17
|
+
- :label: Add missing types for color_index props [`23e0edb`](https://github.com/leolabs/ableton.js/commit/23e0edb13e2972264b8748afa2bcb31a94d47348)
|
|
18
|
+
|
|
7
19
|
#### [v3.2.4](https://github.com/leolabs/ableton.js/compare/v3.2.3...v3.2.4)
|
|
8
20
|
|
|
21
|
+
> 27 June 2023
|
|
22
|
+
|
|
9
23
|
- :sparkles: Add `color_index` to the raw props of clips and tracks [`fc6f38d`](https://github.com/leolabs/ableton.js/commit/fc6f38dbcf0a2293f1cd774656a42cdd2ca6f4fc)
|
|
10
24
|
|
|
11
25
|
#### [v3.2.3](https://github.com/leolabs/ableton.js/compare/v3.2.2...v3.2.3)
|
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.getPackageVersion = exports.Ableton = 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"));
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
10
11
|
const events_1 = require("events");
|
|
11
12
|
const uuid_1 = require("uuid");
|
|
12
13
|
const semver_1 = __importDefault(require("semver"));
|
|
@@ -114,23 +115,10 @@ class Ableton extends events_1.EventEmitter {
|
|
|
114
115
|
this.client.addListener("listening", async () => {
|
|
115
116
|
const port = this.client?.address().port;
|
|
116
117
|
this.logger?.info("Client is bound and listening", { port });
|
|
117
|
-
// Write used port to a file so Live can read from it
|
|
118
|
+
// Write used port to a file so Live can read from it on startup
|
|
118
119
|
await (0, promises_1.writeFile)(this.clientPortFile, String(port));
|
|
119
120
|
});
|
|
120
|
-
|
|
121
|
-
// Try binding to the port that was used last for better start performance
|
|
122
|
-
this.logger?.info("Checking if a stored port exists", {
|
|
123
|
-
file: this.clientPortFile,
|
|
124
|
-
});
|
|
125
|
-
const clientPort = await (0, promises_1.readFile)(this.clientPortFile);
|
|
126
|
-
const port = Number(clientPort.toString());
|
|
127
|
-
this.logger?.info("Trying to bind to the most recent port", { port });
|
|
128
|
-
this.client.bind(port, "127.0.0.1");
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
this.logger?.info("Couldn't bind to last port, binding to any free port instead", { error });
|
|
132
|
-
this.client.bind(undefined, "127.0.0.1");
|
|
133
|
-
}
|
|
121
|
+
this.client.bind(undefined, "127.0.0.1");
|
|
134
122
|
// Wait for the server port file to exist
|
|
135
123
|
await new Promise(async (res) => {
|
|
136
124
|
try {
|
|
@@ -139,7 +127,9 @@ class Ableton extends events_1.EventEmitter {
|
|
|
139
127
|
this.logger?.info("Server port:", { port: this.serverPort });
|
|
140
128
|
res();
|
|
141
129
|
}
|
|
142
|
-
catch (e) {
|
|
130
|
+
catch (e) {
|
|
131
|
+
this.logger?.info("Server doesn't seem to be online yet, waiting for it to go online...");
|
|
132
|
+
}
|
|
143
133
|
// Set up a watcher in case the server port changes
|
|
144
134
|
(0, fs_1.watchFile)(this.serverPortFile, async (curr) => {
|
|
145
135
|
if (curr.isFile()) {
|
|
@@ -153,6 +143,16 @@ class Ableton extends events_1.EventEmitter {
|
|
|
153
143
|
}
|
|
154
144
|
});
|
|
155
145
|
});
|
|
146
|
+
// Send used port to Live in case the plugin is already started
|
|
147
|
+
try {
|
|
148
|
+
const port = this.client.address().port;
|
|
149
|
+
this.logger?.info("Sending port to Live:", { port });
|
|
150
|
+
const result = await this.setProp("internal", "", "client_port", port);
|
|
151
|
+
this.logger?.info("Got response from Live:", { port, result });
|
|
152
|
+
}
|
|
153
|
+
catch (e) {
|
|
154
|
+
this.logger?.info("Live doesn't seem to be loaded yet, waiting...");
|
|
155
|
+
}
|
|
156
156
|
this.logger?.info("Checking connection...");
|
|
157
157
|
const connection = this.waitForConnection();
|
|
158
158
|
if (timeoutMs) {
|
|
@@ -178,9 +178,9 @@ class Ableton extends events_1.EventEmitter {
|
|
|
178
178
|
this.handleConnect("heartbeat");
|
|
179
179
|
}
|
|
180
180
|
catch (e) {
|
|
181
|
-
this.logger?.warn("Heartbeat failed:", { error: e, canceled });
|
|
182
181
|
// If the heartbeat has been canceled, don't emit a disconnect event
|
|
183
|
-
if (!canceled) {
|
|
182
|
+
if (!canceled && this._isConnected) {
|
|
183
|
+
this.logger?.warn("Heartbeat failed:", { error: e, canceled });
|
|
184
184
|
this.handleDisconnect("heartbeat");
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -296,7 +296,7 @@ class Ableton extends events_1.EventEmitter {
|
|
|
296
296
|
const msg = JSON.stringify(payload);
|
|
297
297
|
const timeout = this.options?.commandTimeoutMs ?? 2000;
|
|
298
298
|
const timeoutId = setTimeout(() => {
|
|
299
|
-
const arg = JSON.stringify(command.args);
|
|
299
|
+
const arg = (0, lodash_1.truncate)(JSON.stringify(command.args), { length: 100 });
|
|
300
300
|
const cls = command.nsid
|
|
301
301
|
? `${command.ns}(${command.nsid})`
|
|
302
302
|
: command.ns;
|
package/midi-script/Internal.py
CHANGED
package/midi-script/Socket.py
CHANGED
|
@@ -19,8 +19,8 @@ def split_by_n(seq, n):
|
|
|
19
19
|
server_port_file = "ableton-js-server.port"
|
|
20
20
|
client_port_file = "ableton-js-client.port"
|
|
21
21
|
|
|
22
|
-
client_port_path = os.path.join(tempfile.gettempdir(), client_port_file)
|
|
23
22
|
server_port_path = os.path.join(tempfile.gettempdir(), server_port_file)
|
|
23
|
+
client_port_path = os.path.join(tempfile.gettempdir(), client_port_file)
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class Socket(object):
|
|
@@ -37,22 +37,22 @@ class Socket(object):
|
|
|
37
37
|
self.input_handler = handler
|
|
38
38
|
self._server_addr = ("127.0.0.1", 0)
|
|
39
39
|
self._client_addr = ("127.0.0.1", 39031)
|
|
40
|
-
self._port_file_last_modified = 0
|
|
41
40
|
self._last_error = ""
|
|
42
41
|
self._socket = None
|
|
43
42
|
|
|
44
43
|
self.read_remote_port()
|
|
45
44
|
self.init_socket(True)
|
|
46
45
|
|
|
47
|
-
self.file_timer = Live.Base.Timer(callback=self.read_remote_port,
|
|
48
|
-
interval=1000, repeat=True)
|
|
49
|
-
self.file_timer.start()
|
|
50
|
-
|
|
51
46
|
def log_once(self, msg):
|
|
52
47
|
if self._last_error != msg:
|
|
53
48
|
self._last_error = msg
|
|
54
49
|
self.log_message(msg)
|
|
55
50
|
|
|
51
|
+
def set_client_port(self, port):
|
|
52
|
+
self.log_message("Setting client port: ", str(port))
|
|
53
|
+
self.show_message("Client connected on port " + str(port))
|
|
54
|
+
self._client_addr = ("127.0.0.1", int(port))
|
|
55
|
+
|
|
56
56
|
def read_last_server_port(self):
|
|
57
57
|
try:
|
|
58
58
|
with open(server_port_path) as file:
|
|
@@ -69,16 +69,7 @@ class Socket(object):
|
|
|
69
69
|
'''Reads the port our client is listening on'''
|
|
70
70
|
|
|
71
71
|
try:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
print("Client port file modified: " + str(file.st_mtime) +
|
|
75
|
-
" – last: " + str(self._port_file_last_modified))
|
|
76
|
-
|
|
77
|
-
if file.st_mtime > self._port_file_last_modified:
|
|
78
|
-
self._port_file_last_modified = file.st_mtime
|
|
79
|
-
else:
|
|
80
|
-
# If the file hasn't changed, don't try to open it
|
|
81
|
-
return
|
|
72
|
+
os.stat(client_port_path)
|
|
82
73
|
except Exception as e:
|
|
83
74
|
self.log_once("Couldn't stat remote port file: " + str(e.args))
|
|
84
75
|
return
|
|
@@ -101,7 +92,6 @@ class Socket(object):
|
|
|
101
92
|
|
|
102
93
|
def shutdown(self):
|
|
103
94
|
self.log_message("Shutting down...")
|
|
104
|
-
self.file_timer.stop()
|
|
105
95
|
self._socket.close()
|
|
106
96
|
|
|
107
97
|
def init_socket(self, try_stored=False):
|
package/midi-script/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
version = "3.2.
|
|
1
|
+
version = "3.2.6"
|
package/ns/clip.d.ts
CHANGED
package/ns/track.d.ts
CHANGED