@lynx-js/devtool-connector 0.0.0 → 0.1.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/dist/844.js +632 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +600 -0
- package/dist/rslib-runtime.js +38 -0
- package/dist/streams/cdp.d.ts +13 -0
- package/dist/streams/customized.d.ts +32 -0
- package/dist/streams/peertalk.d.ts +8 -0
- package/dist/streams/utils.d.ts +7 -0
- package/dist/takeover.d.ts +1 -0
- package/dist/transport/android.d.ts +12 -0
- package/dist/transport/desktop.d.ts +8 -0
- package/dist/transport/index.d.ts +4 -0
- package/dist/transport/index.js +11223 -0
- package/dist/transport/ios.d.ts +12 -0
- package/dist/transport/transport.d.ts +34 -0
- package/dist/types.d.ts +113 -0
- package/package.json +44 -6
- package/index.js +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NetConnectOpts } from 'node:net';
|
|
2
|
+
import type { App, Connection, Device, Transport, TransportConnectOptions } from './transport.ts';
|
|
3
|
+
export declare class iOSTransport implements Transport {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(options?: NetConnectOpts);
|
|
6
|
+
close(): Promise<void>;
|
|
7
|
+
connect({ deviceId, port, signal }: TransportConnectOptions): Promise<Connection>;
|
|
8
|
+
withConnection<T>(options: TransportConnectOptions, callback: (conn: Connection) => Promise<T>): Promise<T>;
|
|
9
|
+
listDevices(): Promise<Device[]>;
|
|
10
|
+
listAvailableApps(): Promise<App[]>;
|
|
11
|
+
openApp(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReadableStream, WritableStream } from 'node:stream/web';
|
|
2
|
+
import type { AppInfo } from '../types.ts';
|
|
3
|
+
export interface TransportConnectOptions {
|
|
4
|
+
deviceId: string;
|
|
5
|
+
port: number;
|
|
6
|
+
signal?: AbortSignal | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface OpenAppOptions {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
withDataCleared?: boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface Transport {
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
listDevices(): Promise<Device[]>;
|
|
15
|
+
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
16
|
+
openApp(deviceId: string, packageName: string, options?: OpenAppOptions): Promise<void>;
|
|
17
|
+
connect(options: TransportConnectOptions): Promise<Connection>;
|
|
18
|
+
}
|
|
19
|
+
export interface Device {
|
|
20
|
+
id: string;
|
|
21
|
+
os: 'iOS' | 'Android' | 'Desktop' | 'OpenHarmony';
|
|
22
|
+
}
|
|
23
|
+
export interface Client {
|
|
24
|
+
id: string;
|
|
25
|
+
info: AppInfo;
|
|
26
|
+
}
|
|
27
|
+
export interface App {
|
|
28
|
+
packageName: string;
|
|
29
|
+
name: string;
|
|
30
|
+
}
|
|
31
|
+
export interface Connection extends AsyncDisposable {
|
|
32
|
+
readable: ReadableStream<Uint8Array>;
|
|
33
|
+
writable: WritableStream<Uint8Array>;
|
|
34
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
interface Event<E extends string, D> {
|
|
2
|
+
event: E;
|
|
3
|
+
data: D;
|
|
4
|
+
}
|
|
5
|
+
type CustomizedEvent<TType extends string, TData> = Event<'Customized', {
|
|
6
|
+
type: TType;
|
|
7
|
+
sender: number;
|
|
8
|
+
data: TData;
|
|
9
|
+
}>;
|
|
10
|
+
export interface AppInfo {
|
|
11
|
+
App: string;
|
|
12
|
+
AppVersion: string;
|
|
13
|
+
/** Android only */
|
|
14
|
+
AppProcessName?: string;
|
|
15
|
+
/** iOS only */
|
|
16
|
+
bundleId?: string;
|
|
17
|
+
/** OpenHarmony only */
|
|
18
|
+
bundleName?: string;
|
|
19
|
+
debugRouterId: string;
|
|
20
|
+
debugRouterVersion: string;
|
|
21
|
+
deviceModel: string;
|
|
22
|
+
network: string;
|
|
23
|
+
osVersion: string;
|
|
24
|
+
sdkVersion: string;
|
|
25
|
+
}
|
|
26
|
+
export type InitializeRequest = Event<'Initialize', number>;
|
|
27
|
+
export type InitializeResponse = Event<'Register', {
|
|
28
|
+
id: number;
|
|
29
|
+
info: AppInfo;
|
|
30
|
+
}>;
|
|
31
|
+
export type AppResponse = CustomizedEvent<'App', {
|
|
32
|
+
/** JSON string. See {@link AppResponseMessage} for parsed result. */
|
|
33
|
+
message: string;
|
|
34
|
+
}>;
|
|
35
|
+
export interface AppResponseMessage {
|
|
36
|
+
id: number;
|
|
37
|
+
/** JSON string */
|
|
38
|
+
result: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CDPRequestMessage<T = unknown> {
|
|
41
|
+
method: string;
|
|
42
|
+
params?: T | undefined;
|
|
43
|
+
}
|
|
44
|
+
export type CDPRequest = CustomizedEvent<'CDP', {
|
|
45
|
+
client_id: number;
|
|
46
|
+
session_id: number;
|
|
47
|
+
message: CDPRequestMessage & {
|
|
48
|
+
id: number;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
export type CDPResponse = CustomizedEvent<'CDP', {
|
|
52
|
+
/** JSON string. See {@link CDPResponseMessage} for parsed result. */
|
|
53
|
+
message: string;
|
|
54
|
+
}>;
|
|
55
|
+
export type CDPResponseMessage = {
|
|
56
|
+
id: number;
|
|
57
|
+
} & ({
|
|
58
|
+
result: unknown;
|
|
59
|
+
} | {
|
|
60
|
+
error: {
|
|
61
|
+
code: number;
|
|
62
|
+
message: string;
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
export interface Session {
|
|
66
|
+
session_id: number;
|
|
67
|
+
type: '';
|
|
68
|
+
url: string;
|
|
69
|
+
}
|
|
70
|
+
export type ListSessionRequest = CustomizedEvent<'ListSession', Record<string, never>>;
|
|
71
|
+
export type ListSessionResponse = CustomizedEvent<'SessionList', Session[]>;
|
|
72
|
+
export type GlobalKeys = 'enable_devtool';
|
|
73
|
+
export type GetGlobalSwitchRequest = CustomizedEvent<'GetGlobalSwitch', {
|
|
74
|
+
client_id: number;
|
|
75
|
+
session_id: number;
|
|
76
|
+
message: {
|
|
77
|
+
global_key: GlobalKeys;
|
|
78
|
+
};
|
|
79
|
+
}>;
|
|
80
|
+
export type GetGlobalSwitchResponse = CustomizedEvent<'GetGlobalSwitch', {
|
|
81
|
+
client_id: number;
|
|
82
|
+
session_id: number;
|
|
83
|
+
message: string | boolean | {
|
|
84
|
+
global_value: string | boolean;
|
|
85
|
+
};
|
|
86
|
+
}>;
|
|
87
|
+
export type SetGlobalSwitchRequest = CustomizedEvent<'SetGlobalSwitch', {
|
|
88
|
+
client_id: number;
|
|
89
|
+
session_id: number;
|
|
90
|
+
message: {
|
|
91
|
+
global_key: GlobalKeys;
|
|
92
|
+
global_value: boolean;
|
|
93
|
+
};
|
|
94
|
+
}>;
|
|
95
|
+
export type SetGlobalSwitchResponse = CustomizedEvent<'SetGlobalSwitch', {
|
|
96
|
+
client_id: number;
|
|
97
|
+
session_id: number;
|
|
98
|
+
/** JSON string */
|
|
99
|
+
message: string;
|
|
100
|
+
}>;
|
|
101
|
+
export interface CustomizedResponseMap {
|
|
102
|
+
App: AppResponse;
|
|
103
|
+
CDP: CDPResponse;
|
|
104
|
+
}
|
|
105
|
+
export interface CustomizedResponseMessageMap {
|
|
106
|
+
App: AppResponseMessage;
|
|
107
|
+
CDP: CDPResponseMessage;
|
|
108
|
+
}
|
|
109
|
+
export type Response = InitializeResponse | ListSessionResponse | AppResponse | CDPResponse | GetGlobalSwitchResponse | SetGlobalSwitchResponse;
|
|
110
|
+
export declare function isInitializeResponse(response: Response): response is InitializeResponse;
|
|
111
|
+
export declare function isListSessionResponse(response: Response): response is ListSessionResponse;
|
|
112
|
+
export declare function isCustomizedResponseWithType<T extends keyof CustomizedResponseMap>(response: Response, type: T): response is CustomizedResponseMap[T];
|
|
113
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,9 +1,47 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/devtool-connector",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/lynx-family/lynx-stack.git",
|
|
7
|
+
"directory": "packages/mcp-servers/devtool-connector"
|
|
8
|
+
},
|
|
7
9
|
"type": "module",
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./transport": {
|
|
17
|
+
"types": "./dist/transport/index.d.ts",
|
|
18
|
+
"import": "./dist/transport/index.js",
|
|
19
|
+
"default": "./dist/transport/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/debug": "^4.1.12",
|
|
30
|
+
"@types/node": "^24.10.13",
|
|
31
|
+
"@yume-chan/adb": "^2.5.1",
|
|
32
|
+
"@yume-chan/adb-server-node-tcp": "^2.5.2",
|
|
33
|
+
"@yume-chan/stream-extra": "^2.1.0",
|
|
34
|
+
"commander": "^13.1.0",
|
|
35
|
+
"debug": "^4.4.3",
|
|
36
|
+
"rsbuild-plugin-publint": "0.3.4",
|
|
37
|
+
"typescript": "^5.9.3",
|
|
38
|
+
"usbmux-client": "^0.2.1"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.19"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "rslib build",
|
|
45
|
+
"test": "node --test"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|