@lynx-js/devtool-connector 0.18.5 → 0.18.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 +4 -0
- package/dist/2.js +1 -1
- package/dist/f1.js +10 -10
- package/dist/t.js +34 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/2.js
CHANGED
|
@@ -1659,7 +1659,7 @@ const DAEMON_SHUTDOWN_PATH = `${DAEMON_WS_PATH}/shutdown`;
|
|
|
1659
1659
|
const DAEMON_INSPECTOR_PATH = `${DAEMON_WS_PATH}/inspector`;
|
|
1660
1660
|
const DAEMON_COMMAND_PATH_PREFIX = "/command/";
|
|
1661
1661
|
var package_namespaceObject = {
|
|
1662
|
-
rE: "0.18.
|
|
1662
|
+
rE: "0.18.6"
|
|
1663
1663
|
};
|
|
1664
1664
|
const CONNECTOR_VERSION = package_namespaceObject.rE;
|
|
1665
1665
|
const node_modules_semver = __webpack_require__("../../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js");
|
package/dist/f1.js
CHANGED
|
@@ -487,7 +487,7 @@ class DaemonTransport {
|
|
|
487
487
|
withDataCleared: options?.withDataCleared,
|
|
488
488
|
restart: options?.restart,
|
|
489
489
|
schema: options?.schema
|
|
490
|
-
});
|
|
490
|
+
}, options?.signal);
|
|
491
491
|
}
|
|
492
492
|
async listClients() {
|
|
493
493
|
const entries = await this.#controlRequest("listClients");
|
|
@@ -503,10 +503,14 @@ class DaemonTransport {
|
|
|
503
503
|
daemon_debug("connect to %s:%o via daemon", deviceId, port);
|
|
504
504
|
const conn = await this.#createWebSocketConnection(signal);
|
|
505
505
|
try {
|
|
506
|
+
const subscribeSignal = signal ? AbortSignal.any([
|
|
507
|
+
signal,
|
|
508
|
+
AbortSignal.timeout(10000)
|
|
509
|
+
]) : void 0;
|
|
506
510
|
await this.#controlRequestOnConn(conn, "subscribe", {
|
|
507
511
|
deviceId,
|
|
508
512
|
port
|
|
509
|
-
},
|
|
513
|
+
}, subscribeSignal);
|
|
510
514
|
} catch (error) {
|
|
511
515
|
await conn[Symbol.asyncDispose]();
|
|
512
516
|
throw new Error(`Failed to subscribe to ${deviceId}:${port}`, {
|
|
@@ -531,21 +535,17 @@ class DaemonTransport {
|
|
|
531
535
|
}
|
|
532
536
|
};
|
|
533
537
|
}
|
|
534
|
-
async #controlRequest(method, params) {
|
|
535
|
-
const conn = await this.#createWebSocketConnection();
|
|
538
|
+
async #controlRequest(method, params, signal) {
|
|
539
|
+
const conn = await this.#createWebSocketConnection(signal);
|
|
536
540
|
try {
|
|
537
|
-
return await this.#controlRequestOnConn(conn, method, params);
|
|
541
|
+
return await this.#controlRequestOnConn(conn, method, params, signal);
|
|
538
542
|
} finally{
|
|
539
543
|
await conn[Symbol.asyncDispose]();
|
|
540
544
|
}
|
|
541
545
|
}
|
|
542
546
|
async #controlRequestOnConn(conn, method, params, callerSignal) {
|
|
543
547
|
const id = randomInt(10000, 50000);
|
|
544
|
-
const
|
|
545
|
-
const signal = callerSignal ? AbortSignal.any([
|
|
546
|
-
callerSignal,
|
|
547
|
-
timeoutSignal
|
|
548
|
-
]) : timeoutSignal;
|
|
548
|
+
const signal = callerSignal ?? AbortSignal.timeout(10000);
|
|
549
549
|
try {
|
|
550
550
|
await this.#writeMessage(conn.writable, JSON.stringify({
|
|
551
551
|
event: "Control",
|
package/dist/t.js
CHANGED
|
@@ -889,12 +889,29 @@ class DevtoolDaemon {
|
|
|
889
889
|
server_debug("new ws client %d", clientId);
|
|
890
890
|
this.#clearIdleTimer();
|
|
891
891
|
let closing = false;
|
|
892
|
+
const closeListeners = new Set();
|
|
893
|
+
const notifyCloseListeners = ()=>{
|
|
894
|
+
for (const listener of closeListeners){
|
|
895
|
+
closeListeners.delete(listener);
|
|
896
|
+
listener();
|
|
897
|
+
}
|
|
898
|
+
};
|
|
892
899
|
const session = {
|
|
893
900
|
id: clientId,
|
|
894
901
|
get isClosing () {
|
|
895
902
|
return closing;
|
|
896
903
|
},
|
|
897
904
|
subscriptions: new Set(),
|
|
905
|
+
onClose (listener) {
|
|
906
|
+
if (closing) {
|
|
907
|
+
listener();
|
|
908
|
+
return ()=>{};
|
|
909
|
+
}
|
|
910
|
+
closeListeners.add(listener);
|
|
911
|
+
return ()=>{
|
|
912
|
+
closeListeners.delete(listener);
|
|
913
|
+
};
|
|
914
|
+
},
|
|
898
915
|
send (message) {
|
|
899
916
|
if (!closing && 1 === ws.readyState) ws.send(JSON.stringify(message));
|
|
900
917
|
},
|
|
@@ -902,6 +919,7 @@ class DevtoolDaemon {
|
|
|
902
919
|
if (closing) return;
|
|
903
920
|
closing = true;
|
|
904
921
|
this.#wsClients.delete(clientId);
|
|
922
|
+
notifyCloseListeners();
|
|
905
923
|
if (void 0 === cause) ws.close(1001, "device disconnected");
|
|
906
924
|
else ws.close(1011, websocketCloseReason(cause));
|
|
907
925
|
}
|
|
@@ -922,6 +940,7 @@ class DevtoolDaemon {
|
|
|
922
940
|
server_debug("ws client %d disconnected", clientId);
|
|
923
941
|
closing = true;
|
|
924
942
|
this.#wsClients.delete(clientId);
|
|
943
|
+
notifyCloseListeners();
|
|
925
944
|
for (const deviceConn of session.subscriptions){
|
|
926
945
|
deviceConn.removeSubscriber(clientId);
|
|
927
946
|
if (!this.#closed && 0 === deviceConn.subscriberCount) this.#scheduleDeviceConnectionCleanup(deviceConn);
|
|
@@ -996,12 +1015,22 @@ class DevtoolDaemon {
|
|
|
996
1015
|
{
|
|
997
1016
|
const p = params ?? {};
|
|
998
1017
|
if (!p.deviceId || !p.packageName) throw new Error("deviceId and packageName are required");
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
schema: p.schema,
|
|
1003
|
-
restart: p.restart
|
|
1018
|
+
const abortController = new AbortController();
|
|
1019
|
+
const removeCloseListener = session.onClose(()=>{
|
|
1020
|
+
abortController.abort(new Error(`Daemon client ${session.id} disconnected before openApp completed`));
|
|
1004
1021
|
});
|
|
1022
|
+
try {
|
|
1023
|
+
const transport = await this.#findTransportWithDeviceId(p.deviceId);
|
|
1024
|
+
abortController.signal.throwIfAborted();
|
|
1025
|
+
await transport.openApp(p.deviceId, p.packageName, {
|
|
1026
|
+
withDataCleared: p.withDataCleared,
|
|
1027
|
+
schema: p.schema,
|
|
1028
|
+
restart: p.restart,
|
|
1029
|
+
signal: abortController.signal
|
|
1030
|
+
});
|
|
1031
|
+
} finally{
|
|
1032
|
+
removeCloseListener();
|
|
1033
|
+
}
|
|
1005
1034
|
result = null;
|
|
1006
1035
|
break;
|
|
1007
1036
|
}
|