ableton-js 3.2.7 → 3.2.9

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,21 @@ 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.9](https://github.com/leolabs/ableton.js/compare/v3.2.8...v3.2.9)
8
+
9
+ - :sparkles: Only send the client port to Live once [`29e9443`](https://github.com/leolabs/ableton.js/commit/29e9443194294f5b55805df909d234b67e52eca2)
10
+ - :sparkles: Send the current client port to Live every time the server port changes [`eb42ce3`](https://github.com/leolabs/ableton.js/commit/eb42ce32f4fa91bd57e4c026a7d29d961afa0a04)
11
+
12
+ #### [v3.2.8](https://github.com/leolabs/ableton.js/compare/v3.2.7...v3.2.8)
13
+
14
+ > 14 July 2023
15
+
16
+ - :wrench: Make fast polling optional, in an attempt to fix flaky behavior in Live 11.3 [`17f1634`](https://github.com/leolabs/ableton.js/commit/17f16342896f5f1989ef7f5147a7b3fce1e924fa)
17
+
7
18
  #### [v3.2.7](https://github.com/leolabs/ableton.js/compare/v3.2.6...v3.2.7)
8
19
 
20
+ > 6 July 2023
21
+
9
22
  - :white_check_mark: Switch from Jest to Vitest for faster testing [`d2af8b7`](https://github.com/leolabs/ableton.js/commit/d2af8b756ff9dfe2d76927d2695fba55226ab480)
10
23
  - :mute: Don't log the result of setting the client port [`2206ab7`](https://github.com/leolabs/ableton.js/commit/2206ab74afc9d2388059d88a863dc8e5eed5a32f)
11
24
  - :sparkles: When client is already starting or started, return a promise that waits for a connection [`97c2e1a`](https://github.com/leolabs/ableton.js/commit/97c2e1a81cbe3e8e7ee2f8ef7d349903b728e67e)
package/index.js CHANGED
@@ -120,12 +120,12 @@ class Ableton extends events_1.EventEmitter {
120
120
  });
121
121
  this.client.bind(undefined, "127.0.0.1");
122
122
  // Wait for the server port file to exist
123
- await new Promise(async (res) => {
123
+ const sentPort = await new Promise(async (res) => {
124
124
  try {
125
125
  const serverPort = await (0, promises_1.readFile)(this.serverPortFile);
126
126
  this.serverPort = Number(serverPort.toString());
127
127
  this.logger?.info("Server port:", { port: this.serverPort });
128
- res();
128
+ res(false);
129
129
  }
130
130
  catch (e) {
131
131
  this.logger?.info("Server doesn't seem to be online yet, waiting for it to go online...");
@@ -138,19 +138,33 @@ class Ableton extends events_1.EventEmitter {
138
138
  if (!isNaN(newPort) && newPort !== this.serverPort) {
139
139
  this.logger?.info("Server port changed:", { port: newPort });
140
140
  this.serverPort = Number(serverPort.toString());
141
+ if (this.client) {
142
+ try {
143
+ const port = this.client.address().port;
144
+ this.logger?.info("Sending port to Live:", { port });
145
+ await this.setProp("internal", "", "client_port", port);
146
+ res(true);
147
+ return;
148
+ }
149
+ catch (e) {
150
+ this.logger?.info("Sending port to Live failed", { e });
151
+ }
152
+ }
141
153
  }
142
- res();
154
+ res(false);
143
155
  }
144
156
  });
145
157
  });
146
158
  // 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
- await this.setProp("internal", "", "client_port", port);
151
- }
152
- catch (e) {
153
- this.logger?.info("Live doesn't seem to be loaded yet, waiting...");
159
+ if (!sentPort) {
160
+ try {
161
+ const port = this.client.address().port;
162
+ this.logger?.info("Sending port to Live:", { port });
163
+ await this.setProp("internal", "", "client_port", port);
164
+ }
165
+ catch (e) {
166
+ this.logger?.info("Live doesn't seem to be loaded yet, waiting...");
167
+ }
154
168
  }
155
169
  this.logger?.info("Checking connection...");
156
170
  const connection = this.waitForConnection();
@@ -1,7 +1,7 @@
1
1
  from __future__ import absolute_import
2
2
 
3
3
  from .version import version
4
- from .Config import DEBUG
4
+ from .Config import DEBUG, FAST_POLLING
5
5
  from .Socket import Socket
6
6
  from .Interface import Interface
7
7
  from .Application import Application
@@ -51,12 +51,14 @@ class AbletonJS(ControlSurface):
51
51
  "clip": Clip(c_instance, self.socket),
52
52
  }
53
53
 
54
- self.recv_loop = Live.Base.Timer(
55
- callback=self.socket.process, interval=10, repeat=True)
56
-
57
- self.recv_loop.start()
58
54
  self.tick()
59
55
 
56
+ if FAST_POLLING:
57
+ self.recv_loop = Live.Base.Timer(
58
+ callback=self.socket.process, interval=10, repeat=True)
59
+
60
+ self.recv_loop.start()
61
+
60
62
  def tick(self):
61
63
  self.socket.process()
62
64
  self.schedule_message(1, self.tick)
@@ -76,7 +78,8 @@ class AbletonJS(ControlSurface):
76
78
 
77
79
  def disconnect(self):
78
80
  self.log_message("Disconnecting")
79
- self.recv_loop.stop()
81
+ if FAST_POLLING:
82
+ self.recv_loop.stop()
80
83
  self.socket.send("disconnect")
81
84
  self.socket.shutdown()
82
85
  Interface.listeners.clear()
@@ -1 +1,3 @@
1
1
  DEBUG = False
2
+
3
+ FAST_POLLING = False
@@ -1 +1 @@
1
- version = "3.2.7"
1
+ version = "3.2.9"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ableton-js",
3
- "version": "3.2.7",
3
+ "version": "3.2.9",
4
4
  "description": "Control Ableton Live from Node",
5
5
  "main": "index.js",
6
6
  "author": "Leo Bernard <admin@leolabs.org>",