@lynx-js/devtool-connector 0.19.2 → 0.20.0
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 +18 -0
- package/dist/2.js +170 -170
- package/dist/a.js +192 -196
- package/dist/az.js +87 -12
- package/dist/command/index.js +1 -1
- package/dist/command/reactlynx/controller.d.ts +1 -1
- package/dist/command/reactlynx/session.d.ts +3 -0
- package/dist/f.js +213 -105
- package/dist/f1.js +13 -5
- package/dist/h.js +5 -3
- package/dist/h6.js +32 -7
- package/dist/index.d.ts +7 -6
- package/dist/index.js +1 -1
- package/dist/rslib-runtime.js +11 -13
- package/dist/streams/cdp.d.ts +1 -1
- package/dist/streams/customized.d.ts +1 -1
- package/dist/t.js +53 -53
- package/dist/transport/android.d.ts +3 -3
- package/dist/transport/daemon.d.ts +3 -3
- package/dist/transport/index.js +1 -1
- package/dist/transport/ios.d.ts +3 -3
- package/dist/transport/simulator.d.ts +2 -2
- package/dist/transport/transport.d.ts +14 -3
- package/dist/tw.js +15 -7
- package/dist/types.d.ts +6 -4
- package/dist/ws-stream.js +2 -2
- package/package.json +5 -5
- package/public/simulator/entry.mjs +1 -1
package/dist/h6.js
CHANGED
|
@@ -12,7 +12,7 @@ import { setTimeout as promises_setTimeout } from "node:timers/promises";
|
|
|
12
12
|
import { pathToFileURL } from "node:url";
|
|
13
13
|
import { promisify } from "node:util";
|
|
14
14
|
import { ansi_createDebug } from "./2.js";
|
|
15
|
-
import { ClientId, requireNumericPort } from "./f1.js";
|
|
15
|
+
import { Platform, ClientId, requireNumericPort } from "./f1.js";
|
|
16
16
|
const debug = ansi_createDebug("devtool-mcp-server:takeover");
|
|
17
17
|
const DEBUG_ROUTER_DIR = node_path.join(node_os.homedir(), ".DebugRouterConnector");
|
|
18
18
|
const DEBUG_ROUTER_LOCK_DIR = node_path.join(DEBUG_ROUTER_DIR, "lockfile");
|
|
@@ -166,7 +166,7 @@ async function connectWithPeertalk(connectRaw, options, takeoverHDT = true) {
|
|
|
166
166
|
}
|
|
167
167
|
const desktop_debug = ansi_createDebug("devtool-mcp-server:connector:desktop");
|
|
168
168
|
class DesktopTransport {
|
|
169
|
-
id =
|
|
169
|
+
id = Platform.Desktop;
|
|
170
170
|
#takeoverHDT;
|
|
171
171
|
constructor(takeoverHDT = true){
|
|
172
172
|
this.#takeoverHDT = takeoverHDT;
|
|
@@ -195,10 +195,10 @@ class DesktopTransport {
|
|
|
195
195
|
const numericPort = requireNumericPort(port);
|
|
196
196
|
if ("localhost" !== deviceId) throw new Error(`DesktopTransport only supports 'localhost' deviceId, got: ${deviceId}`);
|
|
197
197
|
desktop_debug(`connect: connecting to 127.0.0.1:${numericPort}`);
|
|
198
|
+
signal?.throwIfAborted();
|
|
198
199
|
const socket = node_net.createConnection({
|
|
199
200
|
host: "127.0.0.1",
|
|
200
|
-
port: numericPort
|
|
201
|
-
signal
|
|
201
|
+
port: numericPort
|
|
202
202
|
});
|
|
203
203
|
socket.setNoDelay?.(true);
|
|
204
204
|
const socketClosed = socket.closed ? Promise.resolve() : new Promise((resolve)=>socket.once("close", resolve));
|
|
@@ -212,8 +212,30 @@ class DesktopTransport {
|
|
|
212
212
|
};
|
|
213
213
|
try {
|
|
214
214
|
if (socket.connecting) await new Promise((resolve, reject)=>{
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
const onConnect = ()=>{
|
|
216
|
+
cleanup();
|
|
217
|
+
resolve();
|
|
218
|
+
};
|
|
219
|
+
const onError = (error)=>{
|
|
220
|
+
cleanup();
|
|
221
|
+
reject(error);
|
|
222
|
+
};
|
|
223
|
+
const onAbort = ()=>{
|
|
224
|
+
cleanup();
|
|
225
|
+
socket.destroy();
|
|
226
|
+
reject(signal?.reason ?? new DOMException("The operation was aborted", "AbortError"));
|
|
227
|
+
};
|
|
228
|
+
const cleanup = ()=>{
|
|
229
|
+
socket.off("connect", onConnect);
|
|
230
|
+
socket.off("error", onError);
|
|
231
|
+
signal?.removeEventListener("abort", onAbort);
|
|
232
|
+
};
|
|
233
|
+
socket.once("connect", onConnect);
|
|
234
|
+
socket.once("error", onError);
|
|
235
|
+
signal?.addEventListener("abort", onAbort, {
|
|
236
|
+
once: true
|
|
237
|
+
});
|
|
238
|
+
if (signal?.aborted) onAbort();
|
|
217
239
|
});
|
|
218
240
|
desktop_debug(`connect: connected to 127.0.0.1:${numericPort}`);
|
|
219
241
|
const { readable, writable } = Duplex.toWeb(socket);
|
|
@@ -238,7 +260,7 @@ function duration(ms) {
|
|
|
238
260
|
return ms;
|
|
239
261
|
}
|
|
240
262
|
class LynxSimulatorTransport extends DesktopTransport {
|
|
241
|
-
id =
|
|
263
|
+
id = Platform.Simulator;
|
|
242
264
|
persistent = true;
|
|
243
265
|
#runs = new Map();
|
|
244
266
|
#prepared = new Map();
|
|
@@ -374,6 +396,9 @@ class LynxSimulatorTransport extends DesktopTransport {
|
|
|
374
396
|
"--no-fund",
|
|
375
397
|
"--save-exact",
|
|
376
398
|
"--ignore-scripts=false",
|
|
399
|
+
...host.includes("-") ? [
|
|
400
|
+
"--legacy-peer-deps"
|
|
401
|
+
] : [],
|
|
377
402
|
`${this.#config.core.name}@${this.#config.core.version}`,
|
|
378
403
|
`${this.#config.lynxtron.name}@${host}`,
|
|
379
404
|
...packages
|
package/dist/index.d.ts
CHANGED
|
@@ -2,30 +2,31 @@ import { ReadableStream, type TransformStream } from "node:stream/web";
|
|
|
2
2
|
import { CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream } from "./streams/cdp.js";
|
|
3
3
|
export { CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream };
|
|
4
4
|
import { ClientId } from "./client-id.js";
|
|
5
|
-
import { type App, type ClientList, type Device, type OpenAppOptions, type Transport } from "./transport/transport.js";
|
|
5
|
+
import { type App, type ClientList, type Device, type ListAvailableAppsOptions, type OpenAppOptions, Platform, type Transport } from "./transport/transport.js";
|
|
6
6
|
import { type CDPRequestMessage, type GlobalKeys, type ListSessionResponse, type Session } from "./types.js";
|
|
7
7
|
interface OutputStream<O> extends AsyncDisposable, ReadableStream<O> {
|
|
8
8
|
inputClosed: Promise<void>;
|
|
9
9
|
}
|
|
10
|
-
export { ClientId };
|
|
10
|
+
export { ClientId, Platform };
|
|
11
|
+
export type { ListAvailableAppsOptions, OpenAppOptions };
|
|
11
12
|
type Pipeline = {
|
|
12
13
|
input: TransformStream[];
|
|
13
14
|
output: TransformStream[];
|
|
14
15
|
};
|
|
15
|
-
export declare class Connector {
|
|
16
|
+
export declare class Connector<TPlatform extends string = Platform> {
|
|
16
17
|
#private;
|
|
17
18
|
constructor(transports: Transport[]);
|
|
18
19
|
listClients(): Promise<ClientList>;
|
|
19
20
|
listDevices(): Promise<Device[]>;
|
|
20
|
-
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
21
|
-
openApp(deviceId: string, packageName: string, options?: OpenAppOptions): Promise<string>;
|
|
21
|
+
listAvailableApps(deviceId: string, options?: ListAvailableAppsOptions<TPlatform>): Promise<App[]>;
|
|
22
|
+
openApp(deviceId: string, packageName: string, options?: OpenAppOptions<TPlatform>): Promise<string>;
|
|
22
23
|
sendMessage<T, R>(clientId: string, message: T, pipeline?: Pipeline): Promise<R>;
|
|
23
24
|
sendAppMessage<Output, Params = never>(clientId: string, method: string, params?: Params): Promise<Output>;
|
|
24
25
|
/**
|
|
25
26
|
* Open a page on the given client by sending an `OpenCard` Customized event.
|
|
26
27
|
*/
|
|
27
28
|
openPage(clientId: string, url: string, signal?: AbortSignal): Promise<ListSessionResponse>;
|
|
28
|
-
sendCDPMessage<Output, Params = never>(clientId: string, sessionId: number, method: string, params?: Params, isMainThread?: boolean): Promise<Output>;
|
|
29
|
+
sendCDPMessage<Output, Params = never>(clientId: string, sessionId: number, method: string, params?: Params, isMainThread?: boolean, signal?: AbortSignal): Promise<Output>;
|
|
29
30
|
sendListSessionMessage(clientId: string): Promise<Session[]>;
|
|
30
31
|
getGlobalSwitch(clientId: string, key: GlobalKeys): Promise<boolean>;
|
|
31
32
|
setGlobalSwitch(clientId: string, key: GlobalKeys, value: boolean): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, createCorrelatedFilter, isCustomizedResponseWithType, isGetGlobalSwitchResponse, isInitializeResponse, isListSessionResponse, isSetGlobalSwitchResponse } from "./h.js";
|
|
2
|
-
export { ClientId } from "./f1.js";
|
|
2
|
+
export { ClientId, Platform } from "./f1.js";
|
|
3
3
|
export { Connector } from "./az.js";
|
|
4
4
|
export { nextRequestId } from "./3.js";
|
package/dist/rslib-runtime.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
function
|
|
4
|
-
var cachedModule =
|
|
1
|
+
var modules = {};
|
|
2
|
+
var moduleCache = {};
|
|
3
|
+
function rspackRequire(moduleId) {
|
|
4
|
+
var cachedModule = moduleCache[moduleId];
|
|
5
5
|
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
6
|
-
var module =
|
|
6
|
+
var module = moduleCache[moduleId] = {
|
|
7
7
|
exports: {}
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
modules[moduleId].call(module.exports, module, module.exports, rspackRequire);
|
|
10
10
|
return module.exports;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})();
|
|
18
|
-
export { __webpack_require__ };
|
|
12
|
+
var moduleFactories = modules;
|
|
13
|
+
moduleFactories.add = function(modules) {
|
|
14
|
+
Object.assign(moduleFactories, modules);
|
|
15
|
+
};
|
|
16
|
+
export { rspackRequire, moduleFactories };
|
package/dist/streams/cdp.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare class CDPRequestTransformStream extends CustomizedRequestTransfor
|
|
|
4
4
|
constructor(sessionId: number, fixedId?: number);
|
|
5
5
|
}
|
|
6
6
|
export declare class CDPResponseTransformStream<Output = CDPResponseMessage> extends CustomizedResponseTransformStream<"CDP", Output> {
|
|
7
|
-
constructor(id?: number);
|
|
7
|
+
constructor(id?: number, sessionId?: number);
|
|
8
8
|
}
|
|
9
9
|
export declare class CDPOutputTransformStream<Output> extends ResponseParserTransformStream<CDPResponseMessage, Output> {
|
|
10
10
|
constructor();
|
|
@@ -12,7 +12,7 @@ export declare class CustomizedRequestTransformStream<T = unknown> extends Trans
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
export declare class CustomizedResponseTransformStream<T extends string, Output = T extends keyof CustomizedResponseMessageMap ? CustomizedResponseMessageMap[T] : unknown, Input extends Response | CustomizedResponse = Response | CustomizedResponse> extends TransformStream<Input, Output> {
|
|
15
|
-
constructor(type: T, id?: number);
|
|
15
|
+
constructor(type: T, id?: number, sessionId?: number);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Common response parser that handles JSON parsing and error checking in the payload.
|
package/dist/t.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rspackRequire, moduleFactories } from "./rslib-runtime.js";
|
|
2
2
|
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
|
-
|
|
6
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js" (module
|
|
5
|
+
moduleFactories.add({
|
|
6
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js" (module) {
|
|
7
7
|
const { websocketMask, websocketUnmask } = __rspack_createRequire_require("http");
|
|
8
|
-
const { EMPTY_BUFFER } =
|
|
8
|
+
const { EMPTY_BUFFER } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/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;
|
|
@@ -59,7 +59,7 @@ __webpack_require__.add({
|
|
|
59
59
|
else websocketUnmask(buffer, mask);
|
|
60
60
|
};
|
|
61
61
|
} else if (!process.env.WS_NO_BUFFER_UTIL) try {
|
|
62
|
-
const bufferUtil =
|
|
62
|
+
const bufferUtil = rspackRequire("bufferutil");
|
|
63
63
|
module.exports.mask = function(source, mask, output, offset, length) {
|
|
64
64
|
if (length < 48) _mask(source, mask, output, offset, length);
|
|
65
65
|
else bufferUtil.mask(source, mask, output, offset, length);
|
|
@@ -91,8 +91,8 @@ __webpack_require__.add({
|
|
|
91
91
|
NOOP: ()=>{}
|
|
92
92
|
};
|
|
93
93
|
},
|
|
94
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/event-target.js" (module
|
|
95
|
-
const { kForOnEventAttribute, kListener } =
|
|
94
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/event-target.js" (module) {
|
|
95
|
+
const { kForOnEventAttribute, kListener } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/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.23.0/node_modules/ws/lib/extension.js" (module
|
|
240
|
-
const { tokenChars } =
|
|
239
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/extension.js" (module) {
|
|
240
|
+
const { tokenChars } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/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
|
|
@@ -386,11 +386,11 @@ __webpack_require__.add({
|
|
|
386
386
|
}
|
|
387
387
|
module.exports = Limiter;
|
|
388
388
|
},
|
|
389
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js" (module
|
|
389
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js" (module) {
|
|
390
390
|
const zlib = __rspack_createRequire_require("zlib");
|
|
391
|
-
const bufferUtil =
|
|
392
|
-
const Limiter =
|
|
393
|
-
const { kStatusCode } =
|
|
391
|
+
const bufferUtil = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js");
|
|
392
|
+
const Limiter = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/limiter.js");
|
|
393
|
+
const { kStatusCode } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/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.23.0/node_modules/ws/lib/receiver.js" (module
|
|
598
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/receiver.js" (module) {
|
|
599
599
|
const { Writable } = __rspack_createRequire_require("stream");
|
|
600
|
-
const PerMessageDeflate =
|
|
601
|
-
const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } =
|
|
602
|
-
const { concat, toArrayBuffer, unmask } =
|
|
603
|
-
const { isValidStatusCode, isValidUTF8 } =
|
|
600
|
+
const PerMessageDeflate = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js");
|
|
601
|
+
const { BINARY_TYPES, EMPTY_BUFFER, kStatusCode, kWebSocket } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js");
|
|
602
|
+
const { concat, toArrayBuffer, unmask } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js");
|
|
603
|
+
const { isValidStatusCode, isValidUTF8 } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/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;
|
|
@@ -953,14 +953,14 @@ __webpack_require__.add({
|
|
|
953
953
|
}
|
|
954
954
|
module.exports = Receiver;
|
|
955
955
|
},
|
|
956
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/sender.js" (module
|
|
956
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/sender.js" (module) {
|
|
957
957
|
const { Duplex } = __rspack_createRequire_require("stream");
|
|
958
958
|
const { randomFillSync } = __rspack_createRequire_require("crypto");
|
|
959
959
|
const { types: { isUint8Array } } = __rspack_createRequire_require("util");
|
|
960
|
-
const PerMessageDeflate =
|
|
961
|
-
const { EMPTY_BUFFER, kWebSocket, NOOP } =
|
|
962
|
-
const { isBlob, isValidStatusCode } =
|
|
963
|
-
const { mask: applyMask, toBuffer } =
|
|
960
|
+
const PerMessageDeflate = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js");
|
|
961
|
+
const { EMPTY_BUFFER, kWebSocket, NOOP } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js");
|
|
962
|
+
const { isBlob, isValidStatusCode } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js");
|
|
963
|
+
const { mask: applyMask, toBuffer } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js");
|
|
964
964
|
const kByteLength = Symbol('kByteLength');
|
|
965
965
|
const maskBuffer = Buffer.alloc(4);
|
|
966
966
|
const RANDOM_POOL_SIZE = 8192;
|
|
@@ -1309,8 +1309,8 @@ __webpack_require__.add({
|
|
|
1309
1309
|
sender.onerror(err);
|
|
1310
1310
|
}
|
|
1311
1311
|
},
|
|
1312
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/stream.js" (module
|
|
1313
|
-
|
|
1312
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/stream.js" (module) {
|
|
1313
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js");
|
|
1314
1314
|
const { Duplex } = __rspack_createRequire_require("stream");
|
|
1315
1315
|
function emitClose(stream) {
|
|
1316
1316
|
stream.emit('close');
|
|
@@ -1392,8 +1392,8 @@ __webpack_require__.add({
|
|
|
1392
1392
|
}
|
|
1393
1393
|
module.exports = createWebSocketStream;
|
|
1394
1394
|
},
|
|
1395
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/subprotocol.js" (module
|
|
1396
|
-
const { tokenChars } =
|
|
1395
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/subprotocol.js" (module) {
|
|
1396
|
+
const { tokenChars } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js");
|
|
1397
1397
|
function parse(header) {
|
|
1398
1398
|
const protocols = new Set();
|
|
1399
1399
|
let start = -1;
|
|
@@ -1424,9 +1424,9 @@ __webpack_require__.add({
|
|
|
1424
1424
|
parse
|
|
1425
1425
|
};
|
|
1426
1426
|
},
|
|
1427
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js" (module
|
|
1427
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js" (module) {
|
|
1428
1428
|
const { isUtf8 } = __rspack_createRequire_require("buffer");
|
|
1429
|
-
const { hasBlob } =
|
|
1429
|
+
const { hasBlob } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js");
|
|
1430
1430
|
const tokenChars = [
|
|
1431
1431
|
0,
|
|
1432
1432
|
0,
|
|
@@ -1590,22 +1590,22 @@ __webpack_require__.add({
|
|
|
1590
1590
|
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
1591
1591
|
};
|
|
1592
1592
|
else if (!process.env.WS_NO_UTF_8_VALIDATE) try {
|
|
1593
|
-
const isValidUTF8 =
|
|
1593
|
+
const isValidUTF8 = rspackRequire("utf-8-validate");
|
|
1594
1594
|
module.exports.isValidUTF8 = function(buf) {
|
|
1595
1595
|
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
1596
1596
|
};
|
|
1597
1597
|
} catch (e) {}
|
|
1598
1598
|
},
|
|
1599
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket-server.js" (module
|
|
1599
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket-server.js" (module) {
|
|
1600
1600
|
const EventEmitter = __rspack_createRequire_require("events");
|
|
1601
1601
|
const http = __rspack_createRequire_require("http");
|
|
1602
1602
|
const { Duplex } = __rspack_createRequire_require("stream");
|
|
1603
1603
|
const { createHash } = __rspack_createRequire_require("crypto");
|
|
1604
|
-
const extension =
|
|
1605
|
-
const PerMessageDeflate =
|
|
1606
|
-
const subprotocol =
|
|
1607
|
-
const WebSocket =
|
|
1608
|
-
const { CLOSE_TIMEOUT, GUID, kWebSocket } =
|
|
1604
|
+
const extension = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/extension.js");
|
|
1605
|
+
const PerMessageDeflate = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js");
|
|
1606
|
+
const subprotocol = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/subprotocol.js");
|
|
1607
|
+
const WebSocket = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js");
|
|
1608
|
+
const { CLOSE_TIMEOUT, GUID, kWebSocket } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js");
|
|
1609
1609
|
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
1610
1610
|
const RUNNING = 0;
|
|
1611
1611
|
const CLOSING = 1;
|
|
@@ -1859,7 +1859,7 @@ __webpack_require__.add({
|
|
|
1859
1859
|
} else abortHandshake(socket, code, message, headers);
|
|
1860
1860
|
}
|
|
1861
1861
|
},
|
|
1862
|
-
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js" (module
|
|
1862
|
+
"../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js" (module) {
|
|
1863
1863
|
const EventEmitter = __rspack_createRequire_require("events");
|
|
1864
1864
|
const https = __rspack_createRequire_require("https");
|
|
1865
1865
|
const http = __rspack_createRequire_require("http");
|
|
@@ -1869,14 +1869,14 @@ __webpack_require__.add({
|
|
|
1869
1869
|
const { randomBytes, createHash } = __rspack_createRequire_require("crypto");
|
|
1870
1870
|
const { Duplex, Readable } = __rspack_createRequire_require("stream");
|
|
1871
1871
|
const { URL } = __rspack_createRequire_require("url");
|
|
1872
|
-
const PerMessageDeflate =
|
|
1873
|
-
const Receiver =
|
|
1874
|
-
const Sender =
|
|
1875
|
-
const { isBlob } =
|
|
1876
|
-
const { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } =
|
|
1877
|
-
const { EventTarget: { addEventListener, removeEventListener } } =
|
|
1878
|
-
const { format, parse } =
|
|
1879
|
-
const { toBuffer } =
|
|
1872
|
+
const PerMessageDeflate = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js");
|
|
1873
|
+
const Receiver = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/receiver.js");
|
|
1874
|
+
const Sender = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/sender.js");
|
|
1875
|
+
const { isBlob } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/validation.js");
|
|
1876
|
+
const { BINARY_TYPES, CLOSE_TIMEOUT, EMPTY_BUFFER, GUID, kForOnEventAttribute, kListener, kStatusCode, kWebSocket, NOOP } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/constants.js");
|
|
1877
|
+
const { EventTarget: { addEventListener, removeEventListener } } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/event-target.js");
|
|
1878
|
+
const { format, parse } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/extension.js");
|
|
1879
|
+
const { toBuffer } = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/buffer-util.js");
|
|
1880
1880
|
const kAborted = Symbol('kAborted');
|
|
1881
1881
|
const protocolVersions = [
|
|
1882
1882
|
8,
|
|
@@ -2538,11 +2538,11 @@ __webpack_require__.add({
|
|
|
2538
2538
|
}
|
|
2539
2539
|
}
|
|
2540
2540
|
});
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2541
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/stream.js");
|
|
2542
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/extension.js");
|
|
2543
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/permessage-deflate.js");
|
|
2544
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/receiver.js");
|
|
2545
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/sender.js");
|
|
2546
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/subprotocol.js");
|
|
2547
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js");
|
|
2548
|
+
rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket-server.js");
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type AdbServerClient } from "@yume-chan/adb";
|
|
2
2
|
import type { SocketConnectOpts } from "node:net";
|
|
3
3
|
export type * from "./adb-shell-types.js";
|
|
4
|
-
import { type App, type Connection, type Device, type OpenAppOptions, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
4
|
+
import { type App, type Connection, type Device, type OpenAppOptions, Platform, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
5
5
|
export interface AppIcon {
|
|
6
6
|
readonly data: Uint8Array;
|
|
7
7
|
readonly mimeType: "image/png";
|
|
8
8
|
}
|
|
9
9
|
export declare class AndroidTransport implements Transport {
|
|
10
10
|
#private;
|
|
11
|
-
readonly id
|
|
11
|
+
readonly id: Platform;
|
|
12
12
|
protected readonly client: AdbServerClient;
|
|
13
13
|
constructor(spec?: SocketConnectOpts);
|
|
14
14
|
connect<TInput = unknown, TOutput = unknown>(options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
@@ -20,5 +20,5 @@ export declare class AndroidTransport implements Transport {
|
|
|
20
20
|
} | undefined;
|
|
21
21
|
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
22
22
|
getAppIcon(deviceId: string, packageName: string): Promise<AppIcon>;
|
|
23
|
-
openApp(deviceId: string, packageName: string, { withDataCleared, schema, restart
|
|
23
|
+
openApp(deviceId: string, packageName: string, { withDataCleared, schema, restart }?: OpenAppOptions<string>): Promise<void>;
|
|
24
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type App, type ClientList, type Connection, type Device, type OpenAppOptions, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
1
|
+
import { type App, type ClientList, type Connection, type Device, type ListAvailableAppsOptions, type OpenAppOptions, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
2
2
|
export interface DaemonConnectOptions extends TransportConnectOptions {
|
|
3
3
|
transportId: string;
|
|
4
4
|
}
|
|
@@ -17,8 +17,8 @@ export declare class DaemonTransport implements Transport {
|
|
|
17
17
|
constructor(endpoint?: number | string);
|
|
18
18
|
close(): Promise<void>;
|
|
19
19
|
listDevices(): Promise<Device[]>;
|
|
20
|
-
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
21
|
-
openApp(deviceId: string, packageName: string, options?: OpenAppOptions): Promise<void>;
|
|
20
|
+
listAvailableApps(deviceId: string, options?: ListAvailableAppsOptions<string>): Promise<App[]>;
|
|
21
|
+
openApp(deviceId: string, packageName: string, options?: OpenAppOptions<string>): Promise<void>;
|
|
22
22
|
listClients(): Promise<ClientList>;
|
|
23
23
|
connect<TInput = unknown, TOutput = unknown>(options: DaemonConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
24
24
|
protected ensureDaemonRunning(port: number): Promise<string>;
|
package/dist/transport/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { AndroidTransport, Usbmux, iOSTransport } from "../a.js";
|
|
2
|
-
export { DaemonTransport, HDTTransport, requireNumericPort, withTransports } from "../f1.js";
|
|
2
|
+
export { DaemonTransport, HDTTransport, Platform, requireNumericPort, withTransports } from "../f1.js";
|
|
3
3
|
export { DesktopTransport, LynxSimulatorTransport, PeertalkToMessageTransformStream, connectWithPeertalk, encodePeertalkMessage } from "../h6.js";
|
package/dist/transport/ios.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { NetConnectOpts } from "node:net";
|
|
2
|
-
import { type App, type Connection, type Device, type OpenAppOptions, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
2
|
+
import { type App, type Connection, type Device, type OpenAppOptions, Platform, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
3
3
|
export declare class iOSTransport implements Transport {
|
|
4
4
|
#private;
|
|
5
|
-
readonly id
|
|
5
|
+
readonly id: Platform;
|
|
6
6
|
constructor(options?: NetConnectOpts);
|
|
7
7
|
connect<TInput = unknown, TOutput = unknown>(options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
8
8
|
close(): Promise<void>;
|
|
9
9
|
listDevices(): Promise<Device[]>;
|
|
10
10
|
listAvailableApps(): Promise<App[]>;
|
|
11
|
-
openApp(_: string, __?: string, ___?: OpenAppOptions): Promise<void>;
|
|
11
|
+
openApp(_: string, __?: string, ___?: OpenAppOptions<string>): Promise<void>;
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Connector } from "../index.js";
|
|
2
2
|
import { DesktopTransport } from "./desktop.js";
|
|
3
|
-
import type
|
|
3
|
+
import { type Client, type Connection, type Device, Platform, type TransportConnectOptions } from "./transport.js";
|
|
4
4
|
export interface LynxSimulatorConfig {
|
|
5
5
|
registry: string;
|
|
6
6
|
core: {
|
|
@@ -34,7 +34,7 @@ type LynxSimulatorInfo = {
|
|
|
34
34
|
};
|
|
35
35
|
export declare class LynxSimulatorTransport extends DesktopTransport {
|
|
36
36
|
#private;
|
|
37
|
-
readonly id
|
|
37
|
+
readonly id: Platform;
|
|
38
38
|
readonly persistent = true;
|
|
39
39
|
get active(): boolean;
|
|
40
40
|
constructor(config?: LynxSimulatorConfig);
|
|
@@ -7,7 +7,18 @@ export interface TransportConnectOptions {
|
|
|
7
7
|
signal?: AbortSignal | undefined;
|
|
8
8
|
}
|
|
9
9
|
export declare function requireNumericPort(port: ClientTarget): number;
|
|
10
|
-
export
|
|
10
|
+
export declare const Platform: {
|
|
11
|
+
readonly Android: "android";
|
|
12
|
+
readonly iOS: "ios";
|
|
13
|
+
readonly Desktop: "desktop";
|
|
14
|
+
readonly Simulator: "simulator";
|
|
15
|
+
};
|
|
16
|
+
export type Platform = (typeof Platform)[keyof typeof Platform];
|
|
17
|
+
export interface ListAvailableAppsOptions<TPlatform extends string = Platform> {
|
|
18
|
+
/** Target platform, so the daemon can skip device discovery. */
|
|
19
|
+
platform?: TPlatform | undefined;
|
|
20
|
+
}
|
|
21
|
+
export interface OpenAppOptions<TPlatform extends string = Platform> extends ListAvailableAppsOptions<TPlatform> {
|
|
11
22
|
signal?: AbortSignal;
|
|
12
23
|
withDataCleared?: boolean | undefined;
|
|
13
24
|
/** Stop the app before launching; Android preserves its existing default of true. */
|
|
@@ -20,8 +31,8 @@ export interface Transport {
|
|
|
20
31
|
close(): Promise<void>;
|
|
21
32
|
listDevices(): Promise<Device[]>;
|
|
22
33
|
listClients?(): Promise<Client[]>;
|
|
23
|
-
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
24
|
-
openApp(deviceId: string, packageName: string, options?: OpenAppOptions): Promise<void>;
|
|
34
|
+
listAvailableApps(deviceId: string, options?: ListAvailableAppsOptions<string>): Promise<App[]>;
|
|
35
|
+
openApp(deviceId: string, packageName: string, options?: OpenAppOptions<string>): Promise<void>;
|
|
25
36
|
connect<TInput = unknown, TOutput = unknown>(options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
26
37
|
readonly persistent?: boolean;
|
|
27
38
|
readonly active?: boolean;
|
package/dist/tw.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rspackRequire } from "./rslib-runtime.js";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import node_http from "node:http";
|
|
4
4
|
import node_fs from "node:fs";
|
|
@@ -420,7 +420,7 @@ class StaticServer {
|
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
|
-
const websocket_server =
|
|
423
|
+
const websocket_server = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket-server.js");
|
|
424
424
|
const server_debug = ansi_createDebug("devtool-mcp-server:daemon:server");
|
|
425
425
|
const IDLE_TIMEOUT_MS = 300000;
|
|
426
426
|
const DEVICE_CONN_GRACE_MS = 30000;
|
|
@@ -433,6 +433,7 @@ class DevtoolDaemon {
|
|
|
433
433
|
#hdtTransports;
|
|
434
434
|
#deviceConnections = new Map();
|
|
435
435
|
#pendingDeviceConnections = new Map();
|
|
436
|
+
#pendingClientDiscovery = null;
|
|
436
437
|
#deviceConnectionCleanupTimers = new Map();
|
|
437
438
|
#wsClients = new Map();
|
|
438
439
|
#commandControllers = new Set();
|
|
@@ -1057,10 +1058,10 @@ class DevtoolDaemon {
|
|
|
1057
1058
|
}
|
|
1058
1059
|
case "listAvailableApps":
|
|
1059
1060
|
{
|
|
1060
|
-
const
|
|
1061
|
-
if (!deviceId) throw new Error("deviceId is required");
|
|
1062
|
-
const transport = await this.#findTransportWithDeviceId(deviceId);
|
|
1063
|
-
result = await transport.listAvailableApps(deviceId);
|
|
1061
|
+
const p = params ?? {};
|
|
1062
|
+
if (!p.deviceId) throw new Error("deviceId is required");
|
|
1063
|
+
const transport = await this.#findTransportWithDeviceId(p.deviceId, p.platform);
|
|
1064
|
+
result = await transport.listAvailableApps(p.deviceId);
|
|
1064
1065
|
break;
|
|
1065
1066
|
}
|
|
1066
1067
|
case "openApp":
|
|
@@ -1072,7 +1073,7 @@ class DevtoolDaemon {
|
|
|
1072
1073
|
abortController.abort(new Error(`Daemon client ${session.id} disconnected before openApp completed`));
|
|
1073
1074
|
});
|
|
1074
1075
|
try {
|
|
1075
|
-
const transport = await this.#findTransportWithDeviceId(p.deviceId);
|
|
1076
|
+
const transport = await this.#findTransportWithDeviceId(p.deviceId, p.platform);
|
|
1076
1077
|
abortController.signal.throwIfAborted();
|
|
1077
1078
|
await transport.openApp(p.deviceId, p.packageName, {
|
|
1078
1079
|
withDataCleared: p.withDataCleared,
|
|
@@ -1145,6 +1146,12 @@ class DevtoolDaemon {
|
|
|
1145
1146
|
}
|
|
1146
1147
|
}
|
|
1147
1148
|
async #discoverClients() {
|
|
1149
|
+
this.#pendingClientDiscovery ??= this.#runClientDiscovery().finally(()=>{
|
|
1150
|
+
this.#pendingClientDiscovery = null;
|
|
1151
|
+
});
|
|
1152
|
+
return await this.#pendingClientDiscovery;
|
|
1153
|
+
}
|
|
1154
|
+
async #runClientDiscovery() {
|
|
1148
1155
|
const entries = [];
|
|
1149
1156
|
const transports = [];
|
|
1150
1157
|
const discoveryFailures = [];
|
|
@@ -1324,6 +1331,7 @@ class DevtoolDaemon {
|
|
|
1324
1331
|
if (matchedById) return matchedById;
|
|
1325
1332
|
throw new Error(`Transport with id: ${transportId} not found`);
|
|
1326
1333
|
}
|
|
1334
|
+
for (const conn of this.#deviceConnections.values())if (conn.deviceId === deviceId && !conn.isDisposed) return conn.transport;
|
|
1327
1335
|
for (const transport of this.#transports)try {
|
|
1328
1336
|
const devices = await transport.listDevices();
|
|
1329
1337
|
if (devices.some(({ id })=>id === deviceId)) return transport;
|
package/dist/types.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export type CDPRequest = CustomizedEvent<"CDP", {
|
|
|
61
61
|
};
|
|
62
62
|
}>;
|
|
63
63
|
export type CDPResponse = CustomizedEvent<"CDP", {
|
|
64
|
+
session_id?: number;
|
|
64
65
|
/** JSON string. See {@link CDPResponseMessage} for parsed result. */
|
|
65
66
|
message: string;
|
|
66
67
|
}>;
|
|
@@ -74,6 +75,11 @@ export type CDPResponseMessage = {
|
|
|
74
75
|
message: string;
|
|
75
76
|
};
|
|
76
77
|
});
|
|
78
|
+
/** JSON message envelope for a host-defined Customized protocol. */
|
|
79
|
+
export type CustomizedResponse<T extends string = string> = CustomizedEvent<T, {
|
|
80
|
+
session_id?: number;
|
|
81
|
+
message: string;
|
|
82
|
+
}>;
|
|
77
83
|
export type Session = {
|
|
78
84
|
session_id: number;
|
|
79
85
|
type: "" | "lynx" | "web";
|
|
@@ -110,10 +116,6 @@ export type SetGlobalSwitchResponse = CustomizedEvent<"SetGlobalSwitch", {
|
|
|
110
116
|
/** JSON string */
|
|
111
117
|
message: string;
|
|
112
118
|
}>;
|
|
113
|
-
/** JSON message envelope for a host-defined Customized protocol. */
|
|
114
|
-
export type CustomizedResponse<T extends string = string> = CustomizedEvent<T, {
|
|
115
|
-
message: string;
|
|
116
|
-
}>;
|
|
117
119
|
export type CustomizedResponseMap = {
|
|
118
120
|
App: AppResponse;
|
|
119
121
|
CDP: CDPResponse;
|
package/dist/ws-stream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rspackRequire } from "./rslib-runtime.js";
|
|
2
2
|
import { ReadableStream, WritableStream } from "node:stream/web";
|
|
3
3
|
import "./t.js";
|
|
4
|
-
const websocket =
|
|
4
|
+
const websocket = rspackRequire("../../../node_modules/.pnpm/ws@8.23.0/node_modules/ws/lib/websocket.js");
|
|
5
5
|
function stringifyWebSocketData(data) {
|
|
6
6
|
return "string" == typeof data ? data : data.toString();
|
|
7
7
|
}
|