@lynx-js/devtool-connector 0.18.8 → 0.19.1

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
@@ -1,5 +1,37 @@
1
1
  # @lynx-js/devtool-connector
2
2
 
3
+ ## 0.19.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependency `plist` to `^5.1.1`.
8
+ - Updated dependency `ws` to `^8.22.2`.
9
+ - Close subscribed daemon WebSocket sessions when forwarding a message to `DeviceConnection` fails, and preserve the target `transportId` in `Connector` clean-EOF diagnostics.
10
+ - Skip corrupt or stale per-device entries in `~/bdc_config` when loading `iOSBDCTransport` routes so valid BDC endpoints remain discoverable.
11
+ - Keep Peertalk frame buffering amortized when messages arrive in small fragments.
12
+ - Avoid disposing underlying Peertalk connections when `writable.abort()` runs while no write is in flight.
13
+ - Enable TCP keepalive on direct and proxied `createProxySocket` connections so intermediate NAT/proxy idle timeouts do not drop long-lived BDC tunnels.
14
+ - Simplify `PeertalkToMessageTransformStream` frame buffering and remove the unused `MessageToPeertalkTransformStream` class.
15
+ - Simplify `connectWithPeertalk` writer lifecycle and promise chaining in `transport/base.ts`.
16
+
17
+ ## 0.19.0
18
+
19
+ ### Minor Changes
20
+
21
+ - Remove the built-in `agent-lynx --client headless:0` path, replaced by Lynx Simulator, including SpawnTransport and headless runtime preparation. EmbeddedLynx and NodeLynx test runtimes remain available.
22
+ - Include the transport ID in client IDs to route requests directly to the matching transport and isolate daemon connections across transports. Client IDs now use `transportId:deviceId:target`; rediscover clients instead of reusing IDs from older versions.
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependency `@yume-chan/adb-server-node-tcp` to `3.0.0-beta.5`.
27
+ - Updated dependency `@yume-chan/adb` to `3.0.0-beta.5`.
28
+ - Updated dependency `@yume-chan/stream-extra` to `3.0.0-beta.5`.
29
+ - Updated dependency `plist` to `^5.1.0`.
30
+ - Updated dependency `@rslib/core` to `^1.0.6`.
31
+ - Reuse a known target's transport when reconnecting after a disconnect, allowing its connection setup to wait for the device instead of failing on a temporarily empty device scan.
32
+ - Include the actual discovery path in empty `list-clients` errors, including responding HDT/Aiden endpoints and whether they bypassed direct device discovery. Preserve this information through the daemon and clarify that `--no-daemon` still prioritizes HDT/Aiden.
33
+ - Load the Inspector Preact DevTools plugin from the configured network mirror so the panel is reachable in restricted network environments.
34
+
3
35
  ## 0.18.8
4
36
 
5
37
  No changes in this release.
@@ -3,9 +3,9 @@ import "./f1.js";
3
3
  import { createRequire as __rspack_createRequire } from "node:module";
4
4
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
5
5
  __webpack_require__.add({
6
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/buffer-util.js" (module, __unused_rspack_exports, __webpack_require__) {
6
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js" (module, __unused_rspack_exports, __webpack_require__) {
7
7
  const { websocketMask, websocketUnmask } = __rspack_createRequire_require("http");
8
- const { EMPTY_BUFFER } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
8
+ const { EMPTY_BUFFER } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
9
9
  const FastBuffer = Buffer[Symbol.species];
10
10
  function concat(list, totalLength) {
11
11
  if (0 === list.length) return EMPTY_BUFFER;
@@ -70,7 +70,7 @@ __webpack_require__.add({
70
70
  };
71
71
  } catch (e) {}
72
72
  },
73
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js" (module) {
73
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js" (module) {
74
74
  const BINARY_TYPES = [
75
75
  'nodebuffer',
76
76
  'arraybuffer',
@@ -91,8 +91,8 @@ __webpack_require__.add({
91
91
  NOOP: ()=>{}
92
92
  };
93
93
  },
94
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/event-target.js" (module, __unused_rspack_exports, __webpack_require__) {
95
- const { kForOnEventAttribute, kListener } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
94
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/event-target.js" (module, __unused_rspack_exports, __webpack_require__) {
95
+ const { kForOnEventAttribute, kListener } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
96
96
  const kCode = Symbol('kCode');
97
97
  const kData = Symbol('kData');
98
98
  const kError = Symbol('kError');
@@ -236,8 +236,8 @@ __webpack_require__.add({
236
236
  else listener.call(thisArg, event);
237
237
  }
238
238
  },
239
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/extension.js" (module, __unused_rspack_exports, __webpack_require__) {
240
- const { tokenChars } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/validation.js");
239
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js" (module, __unused_rspack_exports, __webpack_require__) {
240
+ const { tokenChars } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js");
241
241
  function push(dest, name, elem) {
242
242
  if (void 0 === dest[name]) dest[name] = [
243
243
  elem
@@ -358,7 +358,7 @@ __webpack_require__.add({
358
358
  parse
359
359
  };
360
360
  },
361
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/limiter.js" (module) {
361
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/limiter.js" (module) {
362
362
  const kDone = Symbol('kDone');
363
363
  const kRun = Symbol('kRun');
364
364
  class Limiter {
@@ -386,11 +386,11 @@ __webpack_require__.add({
386
386
  }
387
387
  module.exports = Limiter;
388
388
  },
389
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/permessage-deflate.js" (module, __unused_rspack_exports, __webpack_require__) {
389
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js" (module, __unused_rspack_exports, __webpack_require__) {
390
390
  const zlib = __rspack_createRequire_require("zlib");
391
- const bufferUtil = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/buffer-util.js");
392
- const Limiter = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/limiter.js");
393
- const { kStatusCode } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
391
+ const bufferUtil = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js");
392
+ const Limiter = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/limiter.js");
393
+ const { kStatusCode } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
394
394
  const FastBuffer = Buffer[Symbol.species];
395
395
  const TRAILER = Buffer.from([
396
396
  0x00,
@@ -595,12 +595,12 @@ __webpack_require__.add({
595
595
  this[kCallback](err);
596
596
  }
597
597
  },
598
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/receiver.js" (module, __unused_rspack_exports, __webpack_require__) {
598
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/receiver.js" (module, __unused_rspack_exports, __webpack_require__) {
599
599
  const { Writable } = __rspack_createRequire_require("stream");
600
- const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/permessage-deflate.js");
601
- const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
602
- const { concat, toArrayBuffer, unmask } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/buffer-util.js");
603
- const { isValidStatusCode, isValidUTF8 } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/validation.js");
600
+ const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js");
601
+ const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
602
+ const { concat, toArrayBuffer, unmask } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js");
603
+ const { isValidStatusCode, isValidUTF8 } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js");
604
604
  const FastBuffer = Buffer[Symbol.species];
605
605
  const GET_INFO = 0;
606
606
  const GET_PAYLOAD_LENGTH_16 = 1;
@@ -822,6 +822,7 @@ __webpack_require__.add({
822
822
  data = this.consume(this._payloadLength);
823
823
  if (this._masked && (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0) unmask(data, this._mask);
824
824
  }
825
+ this._mask = void 0;
825
826
  if (this._opcode > 0x07) return void this.controlMessage(data, cb);
826
827
  if (this._maxFragments > 0 && ++this._numFragments > this._maxFragments) {
827
828
  const error = this.createError(RangeError, 'Too many message fragments', false, 1008, 'WS_ERR_TOO_MANY_BUFFERED_PARTS');
@@ -952,14 +953,14 @@ __webpack_require__.add({
952
953
  }
953
954
  module.exports = Receiver;
954
955
  },
955
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/sender.js" (module, __unused_rspack_exports, __webpack_require__) {
956
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/sender.js" (module, __unused_rspack_exports, __webpack_require__) {
956
957
  const { Duplex } = __rspack_createRequire_require("stream");
957
958
  const { randomFillSync } = __rspack_createRequire_require("crypto");
958
959
  const { types: { isUint8Array } } = __rspack_createRequire_require("util");
959
- const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/permessage-deflate.js");
960
- const { EMPTY_BUFFER, kWebSocket, NOOP } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
961
- const { isBlob, isValidStatusCode } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/validation.js");
962
- const { mask: applyMask, toBuffer } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/buffer-util.js");
960
+ const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js");
961
+ const { EMPTY_BUFFER, kWebSocket, NOOP } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
962
+ const { isBlob, isValidStatusCode } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js");
963
+ const { mask: applyMask, toBuffer } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js");
963
964
  const kByteLength = Symbol('kByteLength');
964
965
  const maskBuffer = Buffer.alloc(4);
965
966
  const RANDOM_POOL_SIZE = 8192;
@@ -1308,8 +1309,8 @@ __webpack_require__.add({
1308
1309
  sender.onerror(err);
1309
1310
  }
1310
1311
  },
1311
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/stream.js" (module, __unused_rspack_exports, __webpack_require__) {
1312
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/websocket.js");
1312
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/stream.js" (module, __unused_rspack_exports, __webpack_require__) {
1313
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js");
1313
1314
  const { Duplex } = __rspack_createRequire_require("stream");
1314
1315
  function emitClose(stream) {
1315
1316
  stream.emit('close');
@@ -1391,8 +1392,8 @@ __webpack_require__.add({
1391
1392
  }
1392
1393
  module.exports = createWebSocketStream;
1393
1394
  },
1394
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/subprotocol.js" (module, __unused_rspack_exports, __webpack_require__) {
1395
- const { tokenChars } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/validation.js");
1395
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/subprotocol.js" (module, __unused_rspack_exports, __webpack_require__) {
1396
+ const { tokenChars } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js");
1396
1397
  function parse(header) {
1397
1398
  const protocols = new Set();
1398
1399
  let start = -1;
@@ -1423,9 +1424,9 @@ __webpack_require__.add({
1423
1424
  parse
1424
1425
  };
1425
1426
  },
1426
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/validation.js" (module, __unused_rspack_exports, __webpack_require__) {
1427
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js" (module, __unused_rspack_exports, __webpack_require__) {
1427
1428
  const { isUtf8 } = __rspack_createRequire_require("buffer");
1428
- const { hasBlob } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
1429
+ const { hasBlob } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
1429
1430
  const tokenChars = [
1430
1431
  0,
1431
1432
  0,
@@ -1595,16 +1596,16 @@ __webpack_require__.add({
1595
1596
  };
1596
1597
  } catch (e) {}
1597
1598
  },
1598
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/websocket-server.js" (module, __unused_rspack_exports, __webpack_require__) {
1599
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket-server.js" (module, __unused_rspack_exports, __webpack_require__) {
1599
1600
  const EventEmitter = __rspack_createRequire_require("events");
1600
1601
  const http = __rspack_createRequire_require("http");
1601
1602
  const { Duplex } = __rspack_createRequire_require("stream");
1602
1603
  const { createHash } = __rspack_createRequire_require("crypto");
1603
- const extension = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/extension.js");
1604
- const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/permessage-deflate.js");
1605
- const subprotocol = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/subprotocol.js");
1606
- const WebSocket = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/websocket.js");
1607
- const { CLOSE_TIMEOUT, GUID, kWebSocket } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
1604
+ const extension = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js");
1605
+ const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js");
1606
+ const subprotocol = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/subprotocol.js");
1607
+ const WebSocket = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js");
1608
+ const { CLOSE_TIMEOUT, GUID, kWebSocket } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
1608
1609
  const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
1609
1610
  const RUNNING = 0;
1610
1611
  const CLOSING = 1;
@@ -1857,23 +1858,24 @@ __webpack_require__.add({
1857
1858
  } else abortHandshake(socket, code, message, headers);
1858
1859
  }
1859
1860
  },
1860
- "../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/websocket.js" (module, __unused_rspack_exports, __webpack_require__) {
1861
+ "../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js" (module, __unused_rspack_exports, __webpack_require__) {
1861
1862
  const EventEmitter = __rspack_createRequire_require("events");
1862
1863
  const https = __rspack_createRequire_require("https");
1863
1864
  const http = __rspack_createRequire_require("http");
1864
1865
  const net = __rspack_createRequire_require("net");
1866
+ const querystring = __rspack_createRequire_require("querystring");
1865
1867
  const tls = __rspack_createRequire_require("tls");
1866
1868
  const { randomBytes, createHash } = __rspack_createRequire_require("crypto");
1867
1869
  const { Duplex, Readable } = __rspack_createRequire_require("stream");
1868
1870
  const { URL } = __rspack_createRequire_require("url");
1869
- const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/permessage-deflate.js");
1870
- const Receiver = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/receiver.js");
1871
- const Sender = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/sender.js");
1872
- const { isBlob } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/validation.js");
1873
- const { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/constants.js");
1874
- const { EventTarget: { addEventListener, removeEventListener } } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/event-target.js");
1875
- const { format, parse } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/extension.js");
1876
- const { toBuffer } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/buffer-util.js");
1871
+ const PerMessageDeflate = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js");
1872
+ const Receiver = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/receiver.js");
1873
+ const Sender = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/sender.js");
1874
+ const { isBlob } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/validation.js");
1875
+ const { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/constants.js");
1876
+ const { EventTarget: { addEventListener, removeEventListener } } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/event-target.js");
1877
+ const { format, parse } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js");
1878
+ const { toBuffer } = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/buffer-util.js");
1877
1879
  const kAborted = Symbol('kAborted');
1878
1880
  const protocolVersions = [
1879
1881
  8,
@@ -2204,8 +2206,10 @@ __webpack_require__.add({
2204
2206
  } catch {
2205
2207
  throw new SyntaxError(`Invalid URL: ${address}`);
2206
2208
  }
2207
- if ('http:' === parsedUrl.protocol) parsedUrl.protocol = 'ws:';
2208
- else if ('https:' === parsedUrl.protocol) parsedUrl.protocol = 'wss:';
2209
+ if ('http:' === parsedUrl.protocol || 'https:' === parsedUrl.protocol) {
2210
+ parsedUrl = new URL(parsedUrl);
2211
+ parsedUrl.protocol = 'http:' === parsedUrl.protocol ? 'ws:' : 'wss:';
2212
+ }
2209
2213
  websocket._url = parsedUrl.href;
2210
2214
  const isSecure = 'wss:' === parsedUrl.protocol;
2211
2215
  const isIpcUrl = 'ws+unix:' === parsedUrl.protocol;
@@ -2256,7 +2260,11 @@ __webpack_require__.add({
2256
2260
  }
2257
2261
  if (opts.origin) if (opts.protocolVersion < 13) opts.headers['Sec-WebSocket-Origin'] = opts.origin;
2258
2262
  else opts.headers.Origin = opts.origin;
2259
- if (parsedUrl.username || parsedUrl.password) opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
2263
+ if (parsedUrl.username || parsedUrl.password) {
2264
+ const username = querystring.unescape(parsedUrl.username);
2265
+ const password = querystring.unescape(parsedUrl.password);
2266
+ opts.auth = `${username}:${password}`;
2267
+ }
2260
2268
  if (isIpcUrl) {
2261
2269
  const i = opts.path.indexOf(':');
2262
2270
  if (-1 === i) {
@@ -2419,8 +2427,12 @@ __webpack_require__.add({
2419
2427
  function receiverOnConclude(code, reason) {
2420
2428
  const websocket = this[kWebSocket];
2421
2429
  websocket._closeFrameReceived = true;
2422
- websocket._closeMessage = reason;
2423
2430
  websocket._closeCode = code;
2431
+ if (0 === reason.length) websocket._closeMessage = EMPTY_BUFFER;
2432
+ else {
2433
+ websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
2434
+ websocket._closeMessage.set(reason);
2435
+ }
2424
2436
  if (void 0 === websocket._socket[kWebSocket]) return;
2425
2437
  websocket._socket.removeListener('data', socketOnData);
2426
2438
  process.nextTick(resume, websocket._socket);
@@ -2515,11 +2527,11 @@ __webpack_require__.add({
2515
2527
  }
2516
2528
  }
2517
2529
  });
2518
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/stream.js");
2519
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/extension.js");
2520
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/permessage-deflate.js");
2521
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/receiver.js");
2522
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/sender.js");
2523
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/subprotocol.js");
2524
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/websocket.js");
2525
- __webpack_require__("../../../node_modules/.pnpm/ws@8.22.1/node_modules/ws/lib/websocket-server.js");
2530
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/stream.js");
2531
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/extension.js");
2532
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/permessage-deflate.js");
2533
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/receiver.js");
2534
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/sender.js");
2535
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/subprotocol.js");
2536
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket.js");
2537
+ __webpack_require__("../../../node_modules/.pnpm/ws@8.22.2/node_modules/ws/lib/websocket-server.js");
package/dist/2.js CHANGED
@@ -1781,7 +1781,7 @@ function log(...args) {
1781
1781
  }
1782
1782
  const defaultOptions = {
1783
1783
  useColors: ansi_useColors(),
1784
- formatArgs: formatArgs,
1784
+ formatArgs,
1785
1785
  formatters: {
1786
1786
  o (v) {
1787
1787
  this.inspectOpts.colors = this.useColors;
@@ -1792,8 +1792,8 @@ const defaultOptions = {
1792
1792
  return inspect(v, this.inspectOpts);
1793
1793
  }
1794
1794
  },
1795
- inspectOpts: inspectOpts,
1796
- log: log,
1795
+ inspectOpts,
1796
+ log,
1797
1797
  humanize: humanize
1798
1798
  };
1799
1799
  function ansi_createDebug(namespace, options) {
@@ -1826,7 +1826,7 @@ const DAEMON_SHUTDOWN_PATH = `${DAEMON_WS_PATH}/shutdown`;
1826
1826
  const DAEMON_INSPECTOR_PATH = `${DAEMON_WS_PATH}/inspector`;
1827
1827
  const DAEMON_COMMAND_PATH_PREFIX = "/command/";
1828
1828
  var package_namespaceObject = {
1829
- rE: "0.18.8"
1829
+ rE: "0.19.1"
1830
1830
  };
1831
1831
  const CONNECTOR_VERSION = package_namespaceObject.rE;
1832
1832
  const node_modules_semver = __webpack_require__("../../../node_modules/.pnpm/semver@7.8.6/node_modules/semver/index.js");
package/dist/a.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { ReadableStream } from "node:stream/web";
2
- import { isGetGlobalSwitchResponse, isInitializeResponse, AppResponseTransformStream, GlobalSwitchRequestTransformStream, isListSessionResponse, isHeadlessPrepareResponse, createCorrelatedFilter, isSetGlobalSwitchResponse, CDPResponseTransformStream, CDPOutputTransformStream, CustomizedResponseTransformStream, CDPRequestTransformStream, CustomizedRequestTransformStream, SessionGuardTransformStream, FilterTransformStream, InspectStream, CustomizedClientIdTransformStream } from "./hb.js";
2
+ import { isGetGlobalSwitchResponse, isInitializeResponse, AppResponseTransformStream, GlobalSwitchRequestTransformStream, isListSessionResponse, createCorrelatedFilter, isSetGlobalSwitchResponse, CDPResponseTransformStream, CDPOutputTransformStream, CustomizedResponseTransformStream, CDPRequestTransformStream, CustomizedRequestTransformStream, SessionGuardTransformStream, FilterTransformStream, InspectStream, CustomizedClientIdTransformStream } from "./hb.js";
3
3
  import { ansi_createDebug, isDaemonLifecycleError } from "./2.js";
4
4
  import { nextRequestId } from "./3.js";
5
- import { DaemonTransport, HDTTransport, ClientId } from "./f1.js";
5
+ import { DaemonTransport, HDTTransport, ClientId, withTransports } from "./f1.js";
6
6
  function throwClientDiscoveryFailures(failures) {
7
7
  if (1 === failures.length) throw failures[0];
8
8
  const details = failures.map((failure)=>failure instanceof Error ? failure.message : String(failure)).join("; ");
@@ -113,39 +113,69 @@ class Connector {
113
113
  const daemonClients = fulfilledDaemonClientResults.flatMap((r)=>r.value);
114
114
  if (fulfilledDaemonClientResults.length > 0) {
115
115
  debug("Using clients from daemon transport: %o", daemonClients);
116
- return daemonClients;
116
+ return withTransports(daemonClients, fulfilledDaemonClientResults.flatMap((r)=>r.value.transports ?? [
117
+ "daemon"
118
+ ]));
117
119
  }
118
120
  const daemonLifecycleFailure = daemonClientResults.filter((result)=>"rejected" === result.status).map((result)=>result.reason).find(isDaemonLifecycleError);
119
121
  if (daemonLifecycleFailure) throw daemonLifecycleFailure;
120
122
  const hdtClientResults = await Promise.allSettled(this.#hdtTransports.map(async (transport)=>{
121
123
  const clients = await transport.listClients();
122
124
  await Promise.allSettled(clients.flatMap(({ id })=>this.#setupClient(transport, id)));
123
- return clients;
125
+ return {
126
+ clients,
127
+ id: transport.id
128
+ };
124
129
  }));
125
130
  const fulfilledHDTClientResults = hdtClientResults.filter((r)=>"fulfilled" === r.status);
126
131
  discoveryFailures.push(...hdtClientResults.filter((r)=>"rejected" === r.status).map((r)=>r.reason));
127
- const hdtClients = fulfilledHDTClientResults.flatMap((r)=>r.value);
132
+ const hdtClients = fulfilledHDTClientResults.flatMap((r)=>r.value.clients);
128
133
  if (fulfilledHDTClientResults.length > 0) {
129
134
  debug("Using clients from HDT transport: %o", hdtClients);
130
- return hdtClients;
135
+ return withTransports(hdtClients, fulfilledHDTClientResults.map((r)=>r.value.id));
136
+ }
137
+ const directTransports = this.#transports.filter((t)=>!(t instanceof DaemonTransport));
138
+ const clientListTransports = directTransports.filter((t)=>!(t instanceof HDTTransport)).filter(hasClientList);
139
+ const deviceProbeTransports = directTransports.filter((t)=>!hasClientList(t));
140
+ const [clientListResults, transportDevices] = await Promise.all([
141
+ Promise.allSettled(clientListTransports.map(async (transport)=>{
142
+ const clients = await transport.listClients();
143
+ await Promise.allSettled(clients.flatMap(({ id })=>this.#setupClient(transport, id)));
144
+ return {
145
+ clients,
146
+ id: transport.id
147
+ };
148
+ })),
149
+ Promise.allSettled(deviceProbeTransports.map(async (transport)=>({
150
+ transport,
151
+ devices: await transport.listDevices()
152
+ })))
153
+ ]);
154
+ for (const result of clientListResults)if ("rejected" === result.status) {
155
+ discoveryFailures.push(result.reason);
156
+ debug("listClients: listClients failed on one transport: %O", result.reason);
131
157
  }
132
- const transportDevices = await Promise.allSettled(this.#transports.filter((t)=>!(t instanceof HDTTransport)).filter((t)=>!(t instanceof DaemonTransport)).map(async (transport)=>({
133
- transport,
134
- devices: await transport.listDevices()
135
- })));
136
158
  for (const result of transportDevices)if ("rejected" === result.status) {
137
159
  discoveryFailures.push(result.reason);
138
160
  debug("listClients: listDevices failed on one transport: %O", result.reason);
139
161
  }
162
+ const fulfilledClientListResults = clientListResults.filter((result)=>"fulfilled" === result.status);
140
163
  const fulfilledTransportDevices = transportDevices.filter((result)=>"fulfilled" === result.status);
141
- if (0 === fulfilledTransportDevices.length && discoveryFailures.length > 0) throwClientDiscoveryFailures(discoveryFailures);
164
+ if (0 === fulfilledClientListResults.length && 0 === fulfilledTransportDevices.length && discoveryFailures.length > 0) throwClientDiscoveryFailures(discoveryFailures);
142
165
  const results = await Promise.allSettled(fulfilledTransportDevices.map((r)=>r.value).flatMap(({ transport, devices })=>devices.flatMap(({ id })=>this.#listClientsForDevice(transport, id))));
143
166
  const fulfilledClientResults = results.filter((r)=>"fulfilled" === r.status);
144
- if (0 === fulfilledClientResults.length && results.length > 0) throwClientDiscoveryFailures([
167
+ if (0 === fulfilledClientListResults.length && 0 === fulfilledClientResults.length && results.length > 0) throwClientDiscoveryFailures([
145
168
  ...discoveryFailures,
146
169
  ...results.filter((result)=>"rejected" === result.status).map((result)=>result.reason)
147
170
  ]);
148
- return fulfilledClientResults.flatMap((r)=>r.value);
171
+ const fulfilledTransports = [
172
+ ...fulfilledClientListResults.map((r)=>r.value.id),
173
+ ...fulfilledTransportDevices.map((r)=>r.value.transport.id)
174
+ ];
175
+ return withTransports([
176
+ ...fulfilledClientListResults.flatMap((r)=>r.value.clients),
177
+ ...fulfilledClientResults.flatMap((r)=>r.value)
178
+ ], fulfilledTransports.length > 0 ? fulfilledTransports : void 0);
149
179
  }
150
180
  async listDevices() {
151
181
  const results = await Promise.allSettled(this.#transports.map((t)=>t.listDevices()));
@@ -256,39 +286,6 @@ class Connector {
256
286
  async sendListSessionMessage(clientId) {
257
287
  return await this.#sendListSessionMessage(clientId);
258
288
  }
259
- async prepareHeadless(clientId) {
260
- const { data: { data: state } } = await this.#sendMessage(clientId, {
261
- event: "Customized",
262
- data: {
263
- type: "HeadlessPrepare",
264
- data: {}
265
- }
266
- }, {
267
- input: [],
268
- output: [
269
- new FilterTransformStream(isHeadlessPrepareResponse)
270
- ]
271
- });
272
- return state;
273
- }
274
- async waitForHeadlessReady(clientId, options = {}) {
275
- const timeoutMs = options.timeoutMs ?? 300000;
276
- const pollIntervalMs = options.pollIntervalMs ?? 1000;
277
- const { setTimeout: delay } = await import("node:timers/promises");
278
- const deadline = Date.now() + timeoutMs;
279
- let lastError;
280
- for(;;){
281
- options.signal?.throwIfAborted();
282
- const state = await this.prepareHeadless(clientId);
283
- options.signal?.throwIfAborted();
284
- if ("ready" === state.status) return;
285
- if ("error" === state.status) lastError = state.message ?? "unknown error";
286
- if (Date.now() >= deadline) throw new Error(void 0 !== lastError ? `Failed to prepare headless runtime: ${lastError}` : `Timed out preparing headless runtime after ${timeoutMs}ms`);
287
- await delay(pollIntervalMs, void 0, options.signal ? {
288
- signal: options.signal
289
- } : {});
290
- }
291
- }
292
289
  async #sendListSessionMessage(clientId) {
293
290
  const id = nextRequestId();
294
291
  const { data: { data: sessions } } = await this.#sendMessage(clientId, {
@@ -337,9 +334,10 @@ class Connector {
337
334
  });
338
335
  }
339
336
  async sendStream(clientId, inputStream, { signal, pipeline } = {}) {
340
- const { deviceId, port } = this.#resolveClientId(clientId);
341
- const transport = await this.#findTransportWithDeviceId(deviceId);
337
+ const { transportId, deviceId, port } = this.#resolveClientId(clientId);
338
+ const transport = await this.#findTransportWithDeviceId(deviceId, transportId);
342
339
  return await this.#connect(transport, {
340
+ transportId,
343
341
  deviceId,
344
342
  port,
345
343
  signal
@@ -367,12 +365,18 @@ class Connector {
367
365
  if (!parsed) throw new Error(`Invalid clientId: ${clientId}`);
368
366
  return parsed;
369
367
  }
370
- async #findTransportWithDeviceId(deviceId) {
368
+ async #findTransportWithDeviceId(deviceId, transportId) {
371
369
  const [onlyTransport] = this.#transports;
372
370
  if (1 === this.#transports.length && onlyTransport instanceof DaemonTransport) return onlyTransport;
373
371
  const daemonTransport = await this.#findTransportWithDeviceIdInPool(this.#daemonTransports, deviceId);
374
372
  if (daemonTransport) return daemonTransport;
375
- const transport = await this.#findTransportWithDeviceIdInPool(this.#transports.filter((t)=>!(t instanceof DaemonTransport)), deviceId);
373
+ const nonDaemonTransports = this.#transports.filter((t)=>!(t instanceof DaemonTransport));
374
+ if (void 0 !== transportId) {
375
+ const matchedById = nonDaemonTransports.find((t)=>t.id === transportId);
376
+ if (matchedById) return matchedById;
377
+ throw new Error(`Transport with id: ${transportId} not found`);
378
+ }
379
+ const transport = await this.#findTransportWithDeviceIdInPool(nonDaemonTransports, deviceId);
376
380
  if (transport) return transport;
377
381
  throw new Error(`Device with id: ${deviceId} not found`);
378
382
  }
@@ -393,7 +397,11 @@ class Connector {
393
397
  }
394
398
  async #connect(transport, options, inputStream, pipeline) {
395
399
  const { deviceId, port } = options;
396
- const conn = await transport.connect(options);
400
+ const conn = transport instanceof DaemonTransport ? await transport.connect(options) : await transport.connect({
401
+ deviceId,
402
+ port,
403
+ signal: options.signal
404
+ });
397
405
  const inputAbortController = new AbortController();
398
406
  const inputAbortReason = new Error("Connector input stream disposed");
399
407
  const inputClosed = [
@@ -429,9 +437,10 @@ class Connector {
429
437
  input: [],
430
438
  output: []
431
439
  }, signal) {
432
- const { deviceId, port } = this.#resolveClientId(clientId);
433
- const transport = await this.#findTransportWithDeviceId(deviceId);
440
+ const { transportId, deviceId, port } = this.#resolveClientId(clientId);
441
+ const transport = await this.#findTransportWithDeviceId(deviceId, transportId);
434
442
  return this.#sendMessageWithTransport(transport, {
443
+ transportId,
435
444
  deviceId,
436
445
  port,
437
446
  signal: signal ?? AbortSignal.timeout(10000)
@@ -455,7 +464,7 @@ class Connector {
455
464
  await outputStream.inputClosed;
456
465
  if (response.done) {
457
466
  options.signal?.throwIfAborted();
458
- const clientId = ClientId.serialize(options.deviceId, options.port);
467
+ const clientId = ClientId.serialize(options.transportId, options.deviceId, options.port);
459
468
  throw new Error(`Transport ${transport.constructor.name} ended cleanly (EOF) while waiting for a response to ${request} on clientId: ${clientId}.`);
460
469
  } else result = response.value;
461
470
  } catch (err) {
@@ -486,7 +495,7 @@ class Connector {
486
495
  const results = await Promise.allSettled(PORTS.map(async (port)=>{
487
496
  const info = await this.#discoverAndSetupClient(transport, deviceId, port, discoverySignal);
488
497
  return {
489
- id: ClientId.serialize(deviceId, port),
498
+ id: ClientId.serialize(transport.id, deviceId, port),
490
499
  info,
491
500
  port
492
501
  };
@@ -581,9 +590,10 @@ class Connector {
581
590
  }
582
591
  }
583
592
  async #setupClient(transport, clientId) {
584
- const { deviceId, port } = this.#resolveClientId(clientId);
593
+ const { transportId, deviceId, port } = this.#resolveClientId(clientId);
585
594
  for (const { key, value } of clientSetupSwitches)try {
586
595
  await this.#sendMessageWithTransport(transport, {
596
+ transportId,
587
597
  deviceId,
588
598
  port,
589
599
  signal: AbortSignal.timeout(3000)
@@ -1,8 +1,9 @@
1
1
  export type ClientTarget = number | string;
2
2
  export declare class ClientId {
3
- static serialize(deviceId: string, target: ClientTarget): string;
4
- static deserialize(clientId: string): {
5
- deviceId: string;
6
- port: ClientTarget;
7
- } | null;
3
+ readonly transportId: string;
4
+ readonly deviceId: string;
5
+ readonly port: ClientTarget;
6
+ constructor(transportId: string, deviceId: string, port: ClientTarget);
7
+ static serialize(transportId: string, deviceId: string, target: ClientTarget): string;
8
+ static deserialize(clientId: string): ClientId | null;
8
9
  }
@@ -26,14 +26,14 @@ export interface OpenData {
26
26
  export interface WaitForClientData {
27
27
  matched: true;
28
28
  clients: Client[];
29
- /** Non-headless clients returned by the latest successful discovery attempt. */
29
+ /** Clients returned by the latest successful discovery attempt. */
30
30
  availableClients: Client[];
31
31
  attempts: number;
32
32
  elapsedMs: number;
33
33
  }
34
34
  export interface WaitForClientProgressData {
35
35
  matched: false;
36
- /** Non-headless clients returned by the latest successful discovery attempt. */
36
+ /** Clients returned by the latest successful discovery attempt. */
37
37
  availableClients: Client[];
38
38
  attempts: number;
39
39
  elapsedMs: number;
@@ -1,12 +1,5 @@
1
1
  import { DaemonManager } from "../2.js";
2
2
  import { fail as result_fail, appendCommandQueryParam, ActionCore } from "../f.js";
3
- const DEFAULT_COMMAND_TIMEOUT_MS = 30000;
4
- const HEADLESS_OPEN_TIMEOUT_MS = 360000;
5
- function getDefaultCommandTimeoutMs(action, params) {
6
- const clientId = params["clientId"];
7
- if ("open" === action && "string" == typeof clientId && clientId.trim().startsWith("headless:")) return HEADLESS_OPEN_TIMEOUT_MS;
8
- return DEFAULT_COMMAND_TIMEOUT_MS;
9
- }
10
3
  const MAX_SSE_BUFFER_LENGTH = 1048576;
11
4
  async function responseText(response) {
12
5
  try {
@@ -66,7 +59,7 @@ function callRawCommand(action, params, options = {}) {
66
59
  function callCommand(action, params, options = {}) {
67
60
  return callRawCommand(action, params, {
68
61
  ...options,
69
- timeoutMs: options.timeoutMs ?? getDefaultCommandTimeoutMs(action, params)
62
+ timeoutMs: options.timeoutMs ?? 30000
70
63
  });
71
64
  }
72
65
  function getStreamUrl(port, action, params) {
@@ -91,7 +84,7 @@ class HttpCommandClient {
91
84
  execute(action, params, options = {}) {
92
85
  return this.executeRaw(action, params, {
93
86
  ...options,
94
- timeoutMs: options.timeoutMs ?? getDefaultCommandTimeoutMs(action, params)
87
+ timeoutMs: options.timeoutMs ?? 30000
95
88
  });
96
89
  }
97
90
  stream(action, params, options = {}) {
@@ -224,7 +217,7 @@ class InProcessCommandClient {
224
217
  }
225
218
  execute(action, params, options = {}) {
226
219
  const commandParams = params;
227
- const signal = AbortSignal.timeout(options.timeoutMs ?? getDefaultCommandTimeoutMs(action, commandParams));
220
+ const signal = AbortSignal.timeout(options.timeoutMs ?? 30000);
228
221
  return this.#core.execute(action, commandParams, {
229
222
  connector: this.#connector
230
223
  }, signal);