@lynx-js/devtool-connector 0.13.2 → 0.16.2
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/LICENSE +1 -1
- package/README.md +18 -134
- package/dist/2.js +2019 -0
- package/dist/{346.js → a.js} +102 -143
- package/dist/client-id.d.ts +0 -6
- package/dist/command/client.d.ts +8 -7
- package/dist/command/contract.d.ts +82 -24
- package/dist/command/core.d.ts +11 -10
- package/dist/command/in-process-client.d.ts +16 -0
- package/dist/command/index.d.ts +28 -20
- package/dist/command/index.js +177 -159
- package/dist/command/list-clients.d.ts +6 -0
- package/dist/command/list-sessions.d.ts +5 -0
- package/dist/command/open.d.ts +5 -0
- package/dist/command/query.d.ts +1 -1
- package/dist/command/reactlynx/controller.d.ts +3 -3
- package/dist/command/reactlynx/model.d.ts +7 -7
- package/dist/command/reactlynx/protocol.d.ts +0 -1
- package/dist/command/reactlynx/session.d.ts +3 -3
- package/dist/command/reactlynx/types.d.ts +7 -7
- package/dist/command/ref-actions.d.ts +4 -4
- package/dist/command/result.d.ts +0 -1
- package/dist/command/screenshot-annotation.d.ts +2 -2
- package/dist/command/screenshot.d.ts +2 -2
- package/dist/command/snapshot.d.ts +2 -2
- package/dist/command/source-info.d.ts +20 -0
- package/dist/command/targets.d.ts +8 -10
- package/dist/command/timeout.d.ts +3 -0
- package/dist/command/wait-for-client.d.ts +5 -0
- package/dist/daemon/device-connection.d.ts +4 -3
- package/dist/daemon/entry.js +18 -20
- package/dist/daemon/index.d.ts +7 -2
- package/dist/daemon/index.js +7 -3
- package/dist/daemon/inspector-assets.d.ts +11 -0
- package/dist/daemon/manager.d.ts +12 -4
- package/dist/daemon/protocol.d.ts +20 -16
- package/dist/daemon/server.d.ts +7 -1
- package/dist/daemon/static-server.d.ts +3 -1
- package/dist/f.js +5790 -0
- package/dist/f1.js +737 -0
- package/dist/{962.js → h.js} +841 -3259
- package/dist/{712.js → hb.js} +26 -19
- package/dist/i.js +2505 -0
- package/dist/index.d.ts +13 -18
- package/dist/index.js +3 -2
- package/dist/main.d.ts +2 -0
- package/dist/main.js +3 -0
- package/dist/request-id.d.ts +1 -0
- package/dist/streams/cdp.d.ts +3 -3
- package/dist/streams/customized.d.ts +5 -5
- package/dist/streams/index.d.ts +4 -3
- package/dist/streams/index.js +1 -1
- package/dist/streams/utils.d.ts +3 -3
- package/dist/{872.js → t.js} +364 -301
- package/dist/transport/adb-shell-types.d.ts +14 -0
- package/dist/transport/android-app-icon-helper.d.ts +1 -0
- package/dist/transport/android.d.ts +13 -3
- package/dist/transport/base.d.ts +2 -9
- package/dist/transport/daemon.d.ts +3 -2
- package/dist/transport/desktop.d.ts +1 -1
- package/dist/transport/hdt.d.ts +13 -0
- package/dist/transport/index.d.ts +9 -9
- package/dist/transport/index.js +2 -3
- package/dist/transport/ios.d.ts +2 -2
- package/dist/transport/peertalk.d.ts +4 -3
- package/dist/transport/stream-lifecycle.d.ts +4 -0
- package/dist/transport/transport.d.ts +4 -8
- package/dist/transport/usbmux.d.ts +5 -5
- package/dist/transport/ws-stream.d.ts +3 -10
- package/dist/types.d.ts +28 -24
- package/dist/{63.js → ws-stream.js} +23 -24
- package/package.json +32 -22
- package/dist/390.js +0 -329
- package/dist/556.js +0 -258
- package/dist/61.js +0 -3432
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AdbShellProtocolSubprocessService } from "@yume-chan/adb";
|
|
2
|
+
/**
|
|
3
|
+
* @yume-chan/adb 3.0.0-beta.2 removes these internal aliases from shared.d.ts
|
|
4
|
+
* while its public service.d.ts still imports them. Derive the missing types
|
|
5
|
+
* from the unchanged public signatures without altering the upstream classes.
|
|
6
|
+
* Remove this compatibility declaration when the pinned upstream release fixes it.
|
|
7
|
+
*
|
|
8
|
+
* Upstream reference (MIT):
|
|
9
|
+
* https://github.com/yume-chan/ya-webadb/blob/main/libraries/adb/src/service/subprocess/shell/shared.ts
|
|
10
|
+
*/
|
|
11
|
+
declare module "@yume-chan/adb/esm/service/subprocess/shell/shared.js" {
|
|
12
|
+
type AdbShellProtocolId = (typeof AdbShellProtocolSubprocessService.PacketId)[keyof typeof AdbShellProtocolSubprocessService.PacketId];
|
|
13
|
+
type AdbShellProtocolPacket = Awaited<ReturnType<typeof AdbShellProtocolSubprocessService.Packet.deserialize>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ANDROID_APP_ICON_HELPER_JAR: Uint8Array;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { AdbServerClient } from "@yume-chan/adb";
|
|
2
|
+
import type { SocketConnectOpts } from "node:net";
|
|
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";
|
|
5
|
+
export interface AppIcon {
|
|
6
|
+
readonly data: Uint8Array;
|
|
7
|
+
readonly mimeType: "image/png";
|
|
8
|
+
}
|
|
4
9
|
export declare class AndroidTransport implements Transport {
|
|
5
10
|
#private;
|
|
6
11
|
protected readonly client: AdbServerClient;
|
|
@@ -8,6 +13,11 @@ export declare class AndroidTransport implements Transport {
|
|
|
8
13
|
connect<TInput = unknown, TOutput = unknown>(options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
9
14
|
close(): Promise<void>;
|
|
10
15
|
listDevices(): Promise<Device[]>;
|
|
16
|
+
protected getKnownApp(_packageName: string): {
|
|
17
|
+
name?: string;
|
|
18
|
+
activityName?: string;
|
|
19
|
+
} | undefined;
|
|
11
20
|
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
21
|
+
getAppIcon(deviceId: string, packageName: string): Promise<AppIcon>;
|
|
12
22
|
openApp(deviceId: string, packageName: string, { withDataCleared }?: OpenAppOptions): Promise<void>;
|
|
13
23
|
}
|
package/dist/transport/base.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export interface MessageCodecFactory {
|
|
4
|
-
createEncodeTransformStream<TInput = unknown>(): TransformStream<TInput, Uint8Array>;
|
|
5
|
-
createDecodeTransformStream<TOutput = unknown>(): TransformStream<Uint8Array, TOutput>;
|
|
6
|
-
}
|
|
7
|
-
export declare const peertalkCodecFactory: MessageCodecFactory;
|
|
8
|
-
export declare function createMessageConnection<TInput = unknown, TOutput = unknown>(connectRaw: (options: TransportConnectOptions) => Promise<Connection>, codecFactory: MessageCodecFactory, options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
9
|
-
export declare function connectWithPeertalk<TInput = unknown, TOutput = unknown>(connectRaw: (options: TransportConnectOptions) => Promise<Connection>, options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
1
|
+
import type { Connection, TransportConnectOptions } from "./transport.js";
|
|
2
|
+
export declare function connectWithPeertalk<TInput = unknown, TOutput = unknown>(connectRaw: (options: TransportConnectOptions) => Promise<Connection>, options: TransportConnectOptions, takeoverHDT?: boolean): Promise<Connection<TOutput, TInput>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { App, Client, Connection, Device, OpenAppOptions, Transport, TransportConnectOptions } from
|
|
1
|
+
import type { App, Client, Connection, Device, OpenAppOptions, Transport, TransportConnectOptions } from "./transport.js";
|
|
2
2
|
/**
|
|
3
3
|
* A Transport implementation that communicates with devices through the
|
|
4
4
|
* daemon process over WebSocket.
|
|
@@ -10,11 +10,12 @@ import type { App, Client, Connection, Device, OpenAppOptions, Transport, Transp
|
|
|
10
10
|
*/
|
|
11
11
|
export declare class DaemonTransport implements Transport {
|
|
12
12
|
#private;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(endpoint?: number | string);
|
|
14
14
|
close(): Promise<void>;
|
|
15
15
|
listDevices(): Promise<Device[]>;
|
|
16
16
|
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
17
17
|
openApp(deviceId: string, packageName: string, options?: OpenAppOptions): Promise<void>;
|
|
18
18
|
listClients(): Promise<Client[]>;
|
|
19
19
|
connect<TInput = unknown, TOutput = unknown>(options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
20
|
+
protected ensureDaemonRunning(port: number): Promise<string>;
|
|
20
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type App, type Connection, type Device, type Transport, type TransportConnectOptions } from
|
|
1
|
+
import { type App, type Connection, type Device, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
2
2
|
export declare class DesktopTransport implements Transport {
|
|
3
3
|
#private;
|
|
4
4
|
connect<TInput = unknown, TOutput = unknown>(options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { App, Client, Connection, Device, Transport, TransportConnectOptions } from "./transport.js";
|
|
2
|
+
export declare class HDTTransport implements Transport {
|
|
3
|
+
#private;
|
|
4
|
+
static DEFAULT_PORT: number;
|
|
5
|
+
static createTransports(port?: number, backoff?: number): Transport[];
|
|
6
|
+
constructor(urlOrPort: string | number);
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
listClients(): Promise<Client[]>;
|
|
9
|
+
listDevices(): Promise<Device[]>;
|
|
10
|
+
listAvailableApps(): Promise<App[]>;
|
|
11
|
+
openApp(): Promise<void>;
|
|
12
|
+
connect<TInput = unknown, TOutput = unknown>(options: TransportConnectOptions): Promise<Connection<TOutput, TInput>>;
|
|
13
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
1
|
+
export * from "./android.js";
|
|
2
|
+
export * from "./base.js";
|
|
3
|
+
export * from "./daemon.js";
|
|
4
|
+
export * from "./desktop.js";
|
|
5
|
+
export * from "./hdt.js";
|
|
6
|
+
export * from "./ios.js";
|
|
7
|
+
export * from "./peertalk.js";
|
|
8
|
+
export * from "./transport.js";
|
|
9
|
+
export * from "./usbmux.js";
|
package/dist/transport/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { AndroidTransport, DesktopTransport, MessageToPeertalkTransformStream, PeertalkToMessageTransformStream, Usbmux, connectWithPeertalk,
|
|
2
|
-
export { DaemonTransport } from "../
|
|
3
|
-
export { WsWebSocketStream, createWebSocketReadable, wsStreams } from "../63.js";
|
|
1
|
+
export { AndroidTransport, DesktopTransport, MessageToPeertalkTransformStream, PeertalkToMessageTransformStream, Usbmux, connectWithPeertalk, encodePeertalkMessage, iOSTransport, requireNumericPort } from "../h.js";
|
|
2
|
+
export { DaemonTransport, HDTTransport } from "../f1.js";
|
package/dist/transport/ios.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { NetConnectOpts } from
|
|
2
|
-
import { type App, type Connection, type Device, type OpenAppOptions, type Transport, type TransportConnectOptions } from
|
|
1
|
+
import type { NetConnectOpts } from "node:net";
|
|
2
|
+
import { type App, type Connection, type Device, type OpenAppOptions, type Transport, type TransportConnectOptions } from "./transport.js";
|
|
3
3
|
export declare class iOSTransport implements Transport {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(options?: NetConnectOpts);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { TransformStream } from
|
|
2
|
-
import type { Response } from
|
|
3
|
-
export declare class PeertalkToMessageTransformStream extends TransformStream<Uint8Array,
|
|
1
|
+
import { TransformStream } from "node:stream/web";
|
|
2
|
+
import type { CustomizedResponse, Response } from "../types.js";
|
|
3
|
+
export declare class PeertalkToMessageTransformStream<Output extends Response | CustomizedResponse = Response> extends TransformStream<Uint8Array, Output> {
|
|
4
4
|
constructor();
|
|
5
5
|
}
|
|
6
6
|
export declare class MessageToPeertalkTransformStream<TMessage = unknown> extends TransformStream<TMessage, Uint8Array> {
|
|
7
7
|
constructor();
|
|
8
8
|
}
|
|
9
|
+
export declare function encodePeertalkMessage(message: unknown): Uint8Array;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ReadableStream, ReadableStreamReadResult, WritableStream } from "node:stream/web";
|
|
2
|
+
export declare function readOnce<T>(readable: ReadableStream<T>, signal?: AbortSignal): Promise<ReadableStreamReadResult<T>>;
|
|
3
|
+
export declare function writeOnce<T>(writable: WritableStream<T>, chunk: T, signal?: AbortSignal): Promise<void>;
|
|
4
|
+
export declare function readMessages<T>(readable: ReadableStream<T>, signal: AbortSignal): AsyncGenerator<T>;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import type { ReadableStream, WritableStream } from
|
|
2
|
-
import type { ClientTarget } from
|
|
3
|
-
import type { AppInfo } from
|
|
1
|
+
import type { ReadableStream, WritableStream } from "node:stream/web";
|
|
2
|
+
import type { ClientTarget } from "../client-id.js";
|
|
3
|
+
import type { AppInfo } from "../types.js";
|
|
4
4
|
export interface TransportConnectOptions {
|
|
5
5
|
deviceId: string;
|
|
6
6
|
port: ClientTarget;
|
|
7
7
|
signal?: AbortSignal | undefined;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Narrow a {@link ClientTarget} to the numeric debug-router port required by
|
|
11
|
-
* port-forwarding transports.
|
|
12
|
-
*/
|
|
13
9
|
export declare function requireNumericPort(port: ClientTarget): number;
|
|
14
10
|
export interface OpenAppOptions {
|
|
15
11
|
signal?: AbortSignal;
|
|
@@ -26,7 +22,7 @@ export interface Transport {
|
|
|
26
22
|
}
|
|
27
23
|
export interface Device {
|
|
28
24
|
id: string;
|
|
29
|
-
os:
|
|
25
|
+
os: "iOS" | "Android" | "Desktop" | "OpenHarmony" | "HDT";
|
|
30
26
|
}
|
|
31
27
|
export interface Client {
|
|
32
28
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as net from
|
|
2
|
-
import type { ReadableStream, WritableStream } from
|
|
1
|
+
import * as net from "node:net";
|
|
2
|
+
import type { ReadableStream, WritableStream } from "node:stream/web";
|
|
3
3
|
export interface UsbmuxdDeviceProperties {
|
|
4
4
|
ConnectionSpeed: number;
|
|
5
5
|
ConnectionType: string;
|
|
@@ -19,18 +19,18 @@ export interface UsbmuxdListDevicesResponse {
|
|
|
19
19
|
DeviceList: UsbmuxdDeviceRecord[];
|
|
20
20
|
}
|
|
21
21
|
export interface UsbmuxdResultResponse {
|
|
22
|
-
MessageType:
|
|
22
|
+
MessageType: "Result";
|
|
23
23
|
Number: number;
|
|
24
24
|
}
|
|
25
25
|
export interface UsbmuxdConnectRequest {
|
|
26
|
-
MessageType:
|
|
26
|
+
MessageType: "Connect";
|
|
27
27
|
ClientVersionString: string;
|
|
28
28
|
ProgName: string;
|
|
29
29
|
DeviceID: number;
|
|
30
30
|
PortNumber: number;
|
|
31
31
|
}
|
|
32
32
|
export interface UsbmuxdListDevicesRequest {
|
|
33
|
-
MessageType:
|
|
33
|
+
MessageType: "ListDevices";
|
|
34
34
|
ClientVersionString: string;
|
|
35
35
|
ProgName: string;
|
|
36
36
|
}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import { ReadableStream, WritableStream } from
|
|
2
|
-
import { WebSocket } from
|
|
3
|
-
/**
|
|
4
|
-
* Wraps a `ws` WebSocket into a `ReadableStream<string>` of text frames.
|
|
5
|
-
*
|
|
6
|
-
* The stream applies backpressure by pausing the socket once the queue is
|
|
7
|
-
* full, reaches EOF on an orderly close, and errors with a
|
|
8
|
-
* `code`/`reason`-carrying `Error` on an abnormal close.
|
|
9
|
-
*/
|
|
1
|
+
import { ReadableStream, WritableStream } from "node:stream/web";
|
|
2
|
+
import { WebSocket } from "ws";
|
|
10
3
|
export declare function createWebSocketReadable(ws: WebSocket): ReadableStream<string>;
|
|
11
4
|
/**
|
|
12
5
|
* A lightweight wrapper around the `ws` WebSocket that exposes a
|
|
13
6
|
* `WebSocketStream`-compatible interface (opened / closed / close).
|
|
14
7
|
*
|
|
15
|
-
* This allows `DaemonTransport` to work on Node 18+
|
|
8
|
+
* This allows `HDTTransport` and `DaemonTransport` to work on Node 18+
|
|
16
9
|
* without depending on `undici`'s `WebSocketStream` (which requires
|
|
17
10
|
* Node 22+).
|
|
18
11
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ type Event<E extends string, D> = {
|
|
|
2
2
|
event: E;
|
|
3
3
|
data: D;
|
|
4
4
|
};
|
|
5
|
-
type CustomizedEvent<TType extends string, TData> = Event<
|
|
5
|
+
type CustomizedEvent<TType extends string, TData> = Event<"Customized", {
|
|
6
6
|
type: TType;
|
|
7
7
|
data: TData;
|
|
8
8
|
/**
|
|
@@ -34,12 +34,12 @@ export type AppInfo = {
|
|
|
34
34
|
sdkVersion: string;
|
|
35
35
|
osType?: string;
|
|
36
36
|
};
|
|
37
|
-
export type InitializeRequest = Event<
|
|
38
|
-
export type InitializeResponse = Event<
|
|
37
|
+
export type InitializeRequest = Event<"Initialize", number>;
|
|
38
|
+
export type InitializeResponse = Event<"Register", {
|
|
39
39
|
id: number;
|
|
40
40
|
info: AppInfo;
|
|
41
41
|
}>;
|
|
42
|
-
export type AppResponse = CustomizedEvent<
|
|
42
|
+
export type AppResponse = CustomizedEvent<"App", {
|
|
43
43
|
/** JSON string. See {@link AppResponseMessage} for parsed result. */
|
|
44
44
|
message: string;
|
|
45
45
|
}>;
|
|
@@ -52,14 +52,14 @@ export type CDPRequestMessage<T = unknown> = {
|
|
|
52
52
|
method: string;
|
|
53
53
|
params?: T | undefined;
|
|
54
54
|
};
|
|
55
|
-
export type CDPRequest = CustomizedEvent<
|
|
55
|
+
export type CDPRequest = CustomizedEvent<"CDP", {
|
|
56
56
|
client_id: number;
|
|
57
57
|
session_id: number;
|
|
58
58
|
message: CDPRequestMessage & {
|
|
59
59
|
id: number;
|
|
60
60
|
};
|
|
61
61
|
}>;
|
|
62
|
-
export type CDPResponse = CustomizedEvent<
|
|
62
|
+
export type CDPResponse = CustomizedEvent<"CDP", {
|
|
63
63
|
/** JSON string. See {@link CDPResponseMessage} for parsed result. */
|
|
64
64
|
message: string;
|
|
65
65
|
}>;
|
|
@@ -75,7 +75,7 @@ export type CDPResponseMessage = {
|
|
|
75
75
|
});
|
|
76
76
|
export type Session = {
|
|
77
77
|
session_id: number;
|
|
78
|
-
type:
|
|
78
|
+
type: "" | "lynx" | "web";
|
|
79
79
|
url: string;
|
|
80
80
|
/**
|
|
81
81
|
* Headless (embedded-lynx) runtime metadata, present only for sessions
|
|
@@ -88,8 +88,8 @@ export type Session = {
|
|
|
88
88
|
logFile: string;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
-
export type ListSessionRequest = CustomizedEvent<
|
|
92
|
-
export type ListSessionResponse = CustomizedEvent<
|
|
91
|
+
export type ListSessionRequest = CustomizedEvent<"ListSession", Record<string, never>>;
|
|
92
|
+
export type ListSessionResponse = CustomizedEvent<"SessionList", Session[]>;
|
|
93
93
|
/**
|
|
94
94
|
* Readiness probe for the headless (embedded-lynx) runtime. The headless
|
|
95
95
|
* transport downloads its binary lazily on first use; this lets the caller
|
|
@@ -97,27 +97,27 @@ export type ListSessionResponse = CustomizedEvent<'SessionList', Session[]>;
|
|
|
97
97
|
* timeout instead of a single request that could be cut off.
|
|
98
98
|
*/
|
|
99
99
|
export type HeadlessPrepareState = {
|
|
100
|
-
status:
|
|
100
|
+
status: "ready" | "preparing" | "error";
|
|
101
101
|
message?: string;
|
|
102
102
|
};
|
|
103
|
-
export type HeadlessPrepareRequest = CustomizedEvent<
|
|
104
|
-
export type HeadlessPrepareResponse = CustomizedEvent<
|
|
105
|
-
export type GlobalKeys =
|
|
106
|
-
export type GetGlobalSwitchRequest = CustomizedEvent<
|
|
103
|
+
export type HeadlessPrepareRequest = CustomizedEvent<"HeadlessPrepare", Record<string, never>>;
|
|
104
|
+
export type HeadlessPrepareResponse = CustomizedEvent<"HeadlessPrepare", HeadlessPrepareState>;
|
|
105
|
+
export type GlobalKeys = "enable_devtool" | "enable_logbox" | "enable_debug_mode" | "enable_dom_tree" | "enable_quickjs_debug" | "enable_quickjs_cache" | "enable_v8" | "enable_cdp_domain_dom" | "enable_cdp_domain_css" | "enable_cdp_domain_page" | "enable_long_press_menu" | "enable_highlight_touch" | "enable_preview_screen_shot" | "enable_pixel_copy" | "enable_fsp_screenshot";
|
|
106
|
+
export type GetGlobalSwitchRequest = CustomizedEvent<"GetGlobalSwitch", {
|
|
107
107
|
client_id: number;
|
|
108
108
|
session_id: number;
|
|
109
109
|
message: {
|
|
110
110
|
global_key: GlobalKeys;
|
|
111
111
|
};
|
|
112
112
|
}>;
|
|
113
|
-
export type GetGlobalSwitchResponse = CustomizedEvent<
|
|
113
|
+
export type GetGlobalSwitchResponse = CustomizedEvent<"GetGlobalSwitch", {
|
|
114
114
|
client_id: number;
|
|
115
115
|
session_id: number;
|
|
116
116
|
message: string | boolean | {
|
|
117
117
|
global_value: string | boolean;
|
|
118
118
|
};
|
|
119
119
|
}>;
|
|
120
|
-
export type SetGlobalSwitchRequest = CustomizedEvent<
|
|
120
|
+
export type SetGlobalSwitchRequest = CustomizedEvent<"SetGlobalSwitch", {
|
|
121
121
|
client_id: number;
|
|
122
122
|
session_id: number;
|
|
123
123
|
message: {
|
|
@@ -125,12 +125,16 @@ export type SetGlobalSwitchRequest = CustomizedEvent<'SetGlobalSwitch', {
|
|
|
125
125
|
global_value: boolean;
|
|
126
126
|
};
|
|
127
127
|
}>;
|
|
128
|
-
export type SetGlobalSwitchResponse = CustomizedEvent<
|
|
128
|
+
export type SetGlobalSwitchResponse = CustomizedEvent<"SetGlobalSwitch", {
|
|
129
129
|
client_id: number;
|
|
130
130
|
session_id: number;
|
|
131
131
|
/** JSON string */
|
|
132
132
|
message: string;
|
|
133
133
|
}>;
|
|
134
|
+
/** JSON message envelope for a host-defined Customized protocol. */
|
|
135
|
+
export type CustomizedResponse<T extends string = string> = CustomizedEvent<T, {
|
|
136
|
+
message: string;
|
|
137
|
+
}>;
|
|
134
138
|
export type CustomizedResponseMap = {
|
|
135
139
|
App: AppResponse;
|
|
136
140
|
CDP: CDPResponse;
|
|
@@ -140,9 +144,9 @@ export type CustomizedResponseMessageMap = {
|
|
|
140
144
|
CDP: CDPResponseMessage;
|
|
141
145
|
};
|
|
142
146
|
export type Response = InitializeResponse | ListSessionResponse | AppResponse | CDPResponse | GetGlobalSwitchResponse | SetGlobalSwitchResponse | HeadlessPrepareResponse;
|
|
143
|
-
export declare function isInitializeResponse(response: Response): response is InitializeResponse;
|
|
144
|
-
export declare function isHeadlessPrepareResponse(response: Response): response is HeadlessPrepareResponse;
|
|
145
|
-
export declare function isListSessionResponse(response: Response): response is ListSessionResponse;
|
|
147
|
+
export declare function isInitializeResponse(response: Response | CustomizedResponse): response is InitializeResponse;
|
|
148
|
+
export declare function isHeadlessPrepareResponse(response: Response | CustomizedResponse): response is HeadlessPrepareResponse;
|
|
149
|
+
export declare function isListSessionResponse(response: Response | CustomizedResponse): response is ListSessionResponse;
|
|
146
150
|
/**
|
|
147
151
|
* Create a type guard that accepts a Customized response only when its `id`
|
|
148
152
|
* correlates with the given request `id`.
|
|
@@ -166,8 +170,8 @@ export declare function isListSessionResponse(response: Response): response is L
|
|
|
166
170
|
*
|
|
167
171
|
* @see https://github.com/lynx-family/debug-router/issues/162
|
|
168
172
|
*/
|
|
169
|
-
export declare function createCorrelatedFilter<T extends Response>(baseFilter: (response:
|
|
170
|
-
export declare function isGetGlobalSwitchResponse(response: Response): response is GetGlobalSwitchResponse;
|
|
171
|
-
export declare function isSetGlobalSwitchResponse(response: Response): response is SetGlobalSwitchResponse;
|
|
172
|
-
export declare function isCustomizedResponseWithType<T extends
|
|
173
|
+
export declare function createCorrelatedFilter<T extends Input, Input extends Response | CustomizedResponse = Response>(baseFilter: (response: Input) => response is T, requestId: number): (response: Input) => response is T;
|
|
174
|
+
export declare function isGetGlobalSwitchResponse(response: Response | CustomizedResponse): response is GetGlobalSwitchResponse;
|
|
175
|
+
export declare function isSetGlobalSwitchResponse(response: Response | CustomizedResponse): response is SetGlobalSwitchResponse;
|
|
176
|
+
export declare function isCustomizedResponseWithType<T extends string>(response: Response | CustomizedResponse, type: T): response is T extends keyof CustomizedResponseMap ? CustomizedResponseMap[T] : CustomizedResponse<T>;
|
|
173
177
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
1
2
|
import { ReadableStream, WritableStream } from "node:stream/web";
|
|
2
|
-
import
|
|
3
|
+
import "./i.js";
|
|
4
|
+
const websocket = __webpack_require__("../../../node_modules/.pnpm/ws@8.22.0/node_modules/ws/lib/websocket.js");
|
|
3
5
|
function stringifyWebSocketData(data) {
|
|
4
|
-
return
|
|
6
|
+
return "string" == typeof data ? data : data.toString();
|
|
5
7
|
}
|
|
6
8
|
const NORMAL_CLOSE_CODES = new Set([
|
|
7
9
|
1000,
|
|
@@ -10,8 +12,8 @@ const NORMAL_CLOSE_CODES = new Set([
|
|
|
10
12
|
]);
|
|
11
13
|
function createWebSocketCloseError(code, reason) {
|
|
12
14
|
if (NORMAL_CLOSE_CODES.has(code)) return null;
|
|
13
|
-
const text = reason.toString(
|
|
14
|
-
return Object.assign(new Error(`WebSocket closed abnormally (${code})${text ? `: ${text}` :
|
|
15
|
+
const text = reason.toString("utf8");
|
|
16
|
+
return Object.assign(new Error(`WebSocket closed abnormally (${code})${text ? `: ${text}` : ""}`), {
|
|
15
17
|
code,
|
|
16
18
|
reason: text
|
|
17
19
|
});
|
|
@@ -38,14 +40,14 @@ function createOwnedWebSocketReadable(ws) {
|
|
|
38
40
|
paused = false;
|
|
39
41
|
ws.resume();
|
|
40
42
|
}
|
|
41
|
-
ws.off(
|
|
42
|
-
ws.off(
|
|
43
|
-
ws.off(
|
|
43
|
+
ws.off("message", onMessage);
|
|
44
|
+
ws.off("close", onClose);
|
|
45
|
+
ws.off("error", onError);
|
|
44
46
|
};
|
|
45
47
|
const stopAcceptingMessages = ()=>{
|
|
46
48
|
if (!active || !acceptingMessages) return;
|
|
47
49
|
acceptingMessages = false;
|
|
48
|
-
ws.off(
|
|
50
|
+
ws.off("message", onMessage);
|
|
49
51
|
resume();
|
|
50
52
|
};
|
|
51
53
|
const onMessage = (data)=>{
|
|
@@ -72,9 +74,9 @@ function createOwnedWebSocketReadable(ws) {
|
|
|
72
74
|
};
|
|
73
75
|
cleanup = stop;
|
|
74
76
|
prepareForClose = stopAcceptingMessages;
|
|
75
|
-
ws.on(
|
|
76
|
-
ws.on(
|
|
77
|
-
ws.on(
|
|
77
|
+
ws.on("message", onMessage);
|
|
78
|
+
ws.on("close", onClose);
|
|
79
|
+
ws.on("error", onError);
|
|
78
80
|
},
|
|
79
81
|
pull () {
|
|
80
82
|
resume();
|
|
@@ -91,9 +93,6 @@ function createOwnedWebSocketReadable(ws) {
|
|
|
91
93
|
}
|
|
92
94
|
};
|
|
93
95
|
}
|
|
94
|
-
function createWebSocketReadable(ws) {
|
|
95
|
-
return createOwnedWebSocketReadable(ws).readable;
|
|
96
|
-
}
|
|
97
96
|
class WsWebSocketStream {
|
|
98
97
|
#ws;
|
|
99
98
|
#prepareReadableForClose = ()=>{};
|
|
@@ -102,7 +101,7 @@ class WsWebSocketStream {
|
|
|
102
101
|
#resolveClosed;
|
|
103
102
|
#rejectClosed;
|
|
104
103
|
constructor(url){
|
|
105
|
-
this.#ws = new
|
|
104
|
+
this.#ws = new websocket(url);
|
|
106
105
|
this.closed = new Promise((resolve, reject)=>{
|
|
107
106
|
this.#resolveClosed = resolve;
|
|
108
107
|
this.#rejectClosed = reject;
|
|
@@ -117,15 +116,15 @@ class WsWebSocketStream {
|
|
|
117
116
|
const onClose = (code, reason)=>{
|
|
118
117
|
cleanup();
|
|
119
118
|
const error = createWebSocketCloseError(code, reason);
|
|
120
|
-
reject(error ?? new Error(
|
|
119
|
+
reject(error ?? new Error("WebSocket closed before opening."));
|
|
121
120
|
if (error) this.#rejectClosed(error);
|
|
122
121
|
else this.#resolveClosed();
|
|
123
122
|
};
|
|
124
123
|
const cleanup = ()=>{
|
|
125
|
-
ws.removeListener(
|
|
126
|
-
ws.removeListener(
|
|
124
|
+
ws.removeListener("error", onError);
|
|
125
|
+
ws.removeListener("close", onClose);
|
|
127
126
|
};
|
|
128
|
-
ws.once(
|
|
127
|
+
ws.once("open", ()=>{
|
|
129
128
|
cleanup();
|
|
130
129
|
const { readable, prepareForClose } = createOwnedWebSocketReadable(ws);
|
|
131
130
|
this.#prepareReadableForClose = prepareForClose;
|
|
@@ -149,17 +148,17 @@ class WsWebSocketStream {
|
|
|
149
148
|
readable,
|
|
150
149
|
writable
|
|
151
150
|
});
|
|
152
|
-
ws.on(
|
|
151
|
+
ws.on("close", (code, reason)=>{
|
|
153
152
|
const error = createWebSocketCloseError(code, reason);
|
|
154
153
|
if (error) this.#rejectClosed(error);
|
|
155
154
|
else this.#resolveClosed();
|
|
156
155
|
});
|
|
157
|
-
ws.on(
|
|
156
|
+
ws.on("error", (err)=>{
|
|
158
157
|
this.#rejectClosed(err);
|
|
159
158
|
});
|
|
160
159
|
});
|
|
161
|
-
ws.once(
|
|
162
|
-
ws.once(
|
|
160
|
+
ws.once("error", onError);
|
|
161
|
+
ws.once("close", onClose);
|
|
163
162
|
});
|
|
164
163
|
}
|
|
165
164
|
close() {
|
|
@@ -172,4 +171,4 @@ const wsStreams = {
|
|
|
172
171
|
return new WsWebSocketStream(url);
|
|
173
172
|
}
|
|
174
173
|
};
|
|
175
|
-
export {
|
|
174
|
+
export { wsStreams };
|
package/package.json
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/devtool-connector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"repository": {
|
|
5
|
-
"
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/lynx-community/skills.git",
|
|
7
|
+
"directory": "packages/mcp-servers/devtool-connector"
|
|
6
8
|
},
|
|
7
|
-
"
|
|
9
|
+
"files": [
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"dist",
|
|
12
|
+
"public"
|
|
13
|
+
],
|
|
8
14
|
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
9
17
|
"imports": {
|
|
10
18
|
"#daemon-entry": "./dist/daemon/entry.js"
|
|
11
19
|
},
|
|
@@ -37,37 +45,39 @@
|
|
|
37
45
|
},
|
|
38
46
|
"./package.json": "./package.json"
|
|
39
47
|
},
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"CHANGELOG.md",
|
|
44
|
-
"dist",
|
|
45
|
-
"public"
|
|
46
|
-
],
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
47
51
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"semver": "^7.7.3",
|
|
51
|
-
"ws": "^8.21.0"
|
|
52
|
+
"@lynx-js/debug-metadata": "0.1.0",
|
|
53
|
+
"@yume-chan/adb": "3.0.0-beta.2"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
|
-
"@rslib/core": "0.
|
|
55
|
-
"@types/node": "^24.13.
|
|
56
|
-
"@types/semver": "^7.
|
|
56
|
+
"@rslib/core": "1.0.1",
|
|
57
|
+
"@types/node": "^24.13.5",
|
|
58
|
+
"@types/semver": "^7.8.0",
|
|
57
59
|
"@types/ws": "^8.18.1",
|
|
58
|
-
"@yume-chan/adb": "
|
|
59
|
-
"@yume-chan/
|
|
60
|
-
"
|
|
60
|
+
"@yume-chan/adb-server-node-tcp": "3.0.0-beta.2",
|
|
61
|
+
"@yume-chan/stream-extra": "3.0.0-beta.2",
|
|
62
|
+
"dprint": "^0.57.4",
|
|
63
|
+
"jpeg-js": "^0.4.4",
|
|
64
|
+
"obug": "^2.2.1",
|
|
61
65
|
"plist": "^5.0.0",
|
|
62
66
|
"rsbuild-plugin-publint": "^1.0.0",
|
|
63
|
-
"
|
|
67
|
+
"semver": "^7.8.5",
|
|
68
|
+
"typescript": "^7.0.2",
|
|
69
|
+
"ws": "^8.21.3"
|
|
64
70
|
},
|
|
65
71
|
"engines": {
|
|
66
72
|
"node": ">=18.19"
|
|
67
73
|
},
|
|
74
|
+
"license": "Apache-2.0",
|
|
68
75
|
"scripts": {
|
|
69
76
|
"build": "rslib build",
|
|
70
77
|
"test": "node --test --test-concurrency=1 'test/**/*.test.ts'",
|
|
71
|
-
"test:e2e": "node --test --test-concurrency=1 'e2e/**/*.test.ts'"
|
|
78
|
+
"test:e2e": "node --test --test-concurrency=1 'e2e/**/*.test.ts'",
|
|
79
|
+
"test:e2e:public": "node --test --test-concurrency=1 'e2e/public/**/*.test.ts'",
|
|
80
|
+
"format:check": "dprint check --config dprint.jsonc",
|
|
81
|
+
"format": "dprint fmt --config dprint.jsonc"
|
|
72
82
|
}
|
|
73
83
|
}
|