homey-api 3.17.8 → 3.17.10
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/lib/HomeyAPI/HomeyAPIV3/DiscoveryManager.js +1 -7
- package/lib/HomeyAPI/HomeyAPIV3/DiscoveryNodeTransport.browser.js +3 -0
- package/lib/HomeyAPI/HomeyAPIV3/SocketSession.js +3 -3
- package/lib/HomeyAPI/HomeyAPIV3/SubscriptionRegistry.js +24 -12
- package/lib/HomeyAPI/HomeyAPIV3.js +2 -1
- package/package.json +7 -1
|
@@ -5,12 +5,6 @@ const APIErrorHomeySubscriptionInactive = require('../../APIErrorHomeySubscripti
|
|
|
5
5
|
const APIErrorHomeyInvalidSerialNumber = require('../../APIErrorHomeyInvalidSerialNumber');
|
|
6
6
|
const Util = require('../../Util');
|
|
7
7
|
|
|
8
|
-
function getRuntimeRequire() {
|
|
9
|
-
// Avoid bundlers statically resolving Node-only discovery transport into the browser build.
|
|
10
|
-
// Using indirect eval so rolldown/vite won't flag it as a direct eval.
|
|
11
|
-
return (0, eval)('require');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
8
|
class DiscoveryManager {
|
|
15
9
|
constructor(homey) {
|
|
16
10
|
this.homey = homey;
|
|
@@ -306,7 +300,7 @@ class DiscoveryManager {
|
|
|
306
300
|
}
|
|
307
301
|
|
|
308
302
|
this.discoveryNodeTransport =
|
|
309
|
-
this.discoveryNodeTransport ||
|
|
303
|
+
this.discoveryNodeTransport || require('./DiscoveryNodeTransport');
|
|
310
304
|
|
|
311
305
|
return this.discoveryNodeTransport;
|
|
312
306
|
}
|
|
@@ -230,12 +230,12 @@ class SocketSession extends EventEmitter {
|
|
|
230
230
|
this.__socket = null;
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
this.__closing = false;
|
|
234
|
+
this.__setPhase(PHASES.IDLE);
|
|
235
|
+
|
|
233
236
|
if (shouldEmitDisconnect) {
|
|
234
237
|
this.emit('disconnect', 'io client disconnect');
|
|
235
238
|
}
|
|
236
|
-
|
|
237
|
-
this.__closing = false;
|
|
238
|
-
this.__setPhase(PHASES.IDLE);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
destroy() {
|
|
@@ -77,6 +77,29 @@ class SubscriptionRegistry {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
async ensureSessionSubscriptions({ revision, homeySocket, isReconnect }) {
|
|
81
|
+
if (!isReconnect) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const reconnectPromises = [];
|
|
86
|
+
|
|
87
|
+
for (const entry of this.__entries.values()) {
|
|
88
|
+
if (entry.consumers.size === 0) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!entry.needsReconnect && entry.subscribedRevision === revision) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.__bindEventSocket(entry, homeySocket);
|
|
97
|
+
reconnectPromises.push(this.__resumeEntry(entry, revision));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
await Promise.all(reconnectPromises);
|
|
101
|
+
}
|
|
102
|
+
|
|
80
103
|
destroy() {
|
|
81
104
|
if (this.__destroyed) return;
|
|
82
105
|
|
|
@@ -232,21 +255,10 @@ class SubscriptionRegistry {
|
|
|
232
255
|
}
|
|
233
256
|
|
|
234
257
|
__onSessionReady({ revision, homeySocket, isReconnect }) {
|
|
235
|
-
if (!isReconnect) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
258
|
// The transport can reconnect before the current Homey namespace is ready.
|
|
240
259
|
// Listen to both reconnect and ready so entries resume promptly, while
|
|
241
260
|
// ready is the point where the active namespace socket can be rebound.
|
|
242
|
-
|
|
243
|
-
if (entry.consumers.size === 0 || !entry.needsReconnect) {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
this.__bindEventSocket(entry, homeySocket);
|
|
248
|
-
this.__resumeEntry(entry, revision);
|
|
249
|
-
}
|
|
261
|
+
this.ensureSessionSubscriptions({ revision, homeySocket, isReconnect }).catch(() => {});
|
|
250
262
|
}
|
|
251
263
|
|
|
252
264
|
__onSessionReconnect() {
|
|
@@ -529,7 +529,8 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
async connect() {
|
|
532
|
-
await this.__socketSession.ensureConnected();
|
|
532
|
+
const readyState = await this.__socketSession.ensureConnected();
|
|
533
|
+
await this.__subscriptionRegistry.ensureSessionSubscriptions(readyState);
|
|
533
534
|
}
|
|
534
535
|
|
|
535
536
|
isConnecting() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homey-api",
|
|
3
|
-
"version": "3.17.
|
|
3
|
+
"version": "3.17.10",
|
|
4
4
|
"description": "Homey API",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "SEE LICENSE",
|
|
@@ -45,6 +45,12 @@
|
|
|
45
45
|
"url": "https://github.com/athombv/node-homey-api/issues"
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/athombv/node-homey-api#readme",
|
|
48
|
+
"react-native": {
|
|
49
|
+
"./lib/HomeyAPI/HomeyAPIV3/DiscoveryNodeTransport.js": "./lib/HomeyAPI/HomeyAPIV3/DiscoveryNodeTransport.browser.js"
|
|
50
|
+
},
|
|
51
|
+
"browser": {
|
|
52
|
+
"./lib/HomeyAPI/HomeyAPIV3/DiscoveryNodeTransport.js": "./lib/HomeyAPI/HomeyAPIV3/DiscoveryNodeTransport.browser.js"
|
|
53
|
+
},
|
|
48
54
|
"engines": {
|
|
49
55
|
"node": ">=24"
|
|
50
56
|
},
|