@lynx-js/devtool-connector 0.13.2 → 0.16.3
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 +19 -0
- 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} +854 -3274
- 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 +33 -23
- package/dist/390.js +0 -329
- package/dist/556.js +0 -258
- package/dist/61.js +0 -3432
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Connector } from "../index.js";
|
|
2
|
+
import type { StreamCommandEvent, StreamCommandParams } from "./contract.js";
|
|
3
|
+
import { type CommandResult } from "./result.js";
|
|
4
|
+
/** The sole production implementation of the wait-for-client command. */
|
|
5
|
+
export declare function waitForClientStream(connector: Pick<Connector, "listClients">, params: StreamCommandParams<"wait-for-client">, signal: AbortSignal): AsyncGenerator<CommandResult<StreamCommandEvent<"wait-for-client">>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ClientTarget } from
|
|
2
|
-
import type { Transport, TransportConnectOptions } from
|
|
3
|
-
import { type AppInfo } from
|
|
1
|
+
import type { ClientTarget } from "../client-id.js";
|
|
2
|
+
import type { Transport, TransportConnectOptions } from "../transport/transport.js";
|
|
3
|
+
import { type AppInfo } from "../types.js";
|
|
4
4
|
export interface DeviceConnectionSubscriber {
|
|
5
5
|
readonly id: number;
|
|
6
6
|
send(message: unknown): void;
|
|
@@ -32,6 +32,7 @@ export declare class DeviceConnection {
|
|
|
32
32
|
removeSubscriber(id: number): void;
|
|
33
33
|
get subscriberCount(): number;
|
|
34
34
|
get isDisposed(): boolean;
|
|
35
|
+
get transport(): Transport;
|
|
35
36
|
get isPersistent(): boolean;
|
|
36
37
|
send(message: unknown): Promise<void>;
|
|
37
38
|
dispose(): Promise<void>;
|
package/dist/daemon/entry.js
CHANGED
|
@@ -2,32 +2,27 @@ import promises from "node:fs/promises";
|
|
|
2
2
|
import node_os from "node:os";
|
|
3
3
|
import node_path from "node:path";
|
|
4
4
|
import { parseArgs } from "node:util";
|
|
5
|
-
import { AndroidTransport, DesktopTransport, iOSTransport } from "../
|
|
6
|
-
import "../
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const port = Number.parseInt(env['ADB_SERVER_PORT'] ?? '5037', 10);
|
|
12
|
-
return {
|
|
13
|
-
host: env['ADB_SERVER_HOST'] ?? '127.0.0.1',
|
|
14
|
-
port: Number.isInteger(port) && port > 0 ? port : 5037
|
|
15
|
-
};
|
|
16
|
-
}
|
|
5
|
+
import { AndroidTransport, DesktopTransport, iOSTransport } from "../h.js";
|
|
6
|
+
import { HDTTransport } from "../f1.js";
|
|
7
|
+
import "../2.js";
|
|
8
|
+
import { DevtoolDaemon } from "../t.js";
|
|
9
|
+
const DEBUG_ROUTER_DIR = node_path.join(node_os.homedir(), ".DebugRouterConnector");
|
|
10
|
+
const PIDFILE = node_path.join(DEBUG_ROUTER_DIR, "daemon.pid");
|
|
17
11
|
const { values: values } = parseArgs({
|
|
18
12
|
options: {
|
|
19
13
|
port: {
|
|
20
|
-
type:
|
|
14
|
+
type: "string",
|
|
21
15
|
default: String(21783)
|
|
22
16
|
}
|
|
23
17
|
},
|
|
24
18
|
strict: true
|
|
25
19
|
});
|
|
26
|
-
const
|
|
20
|
+
const port = Number.parseInt(values.port ?? String(21783), 10);
|
|
27
21
|
const daemon = new DevtoolDaemon([
|
|
28
|
-
new AndroidTransport(
|
|
22
|
+
new AndroidTransport(),
|
|
29
23
|
new iOSTransport(),
|
|
30
|
-
new DesktopTransport()
|
|
24
|
+
new DesktopTransport(),
|
|
25
|
+
...HDTTransport.createTransports()
|
|
31
26
|
], {
|
|
32
27
|
onIdle: ()=>{
|
|
33
28
|
daemon.close().then(()=>{
|
|
@@ -38,19 +33,22 @@ const daemon = new DevtoolDaemon([
|
|
|
38
33
|
process.exit(0);
|
|
39
34
|
}
|
|
40
35
|
});
|
|
41
|
-
await daemon.start(
|
|
36
|
+
await daemon.start(port);
|
|
37
|
+
if (process.connected) process.send?.({
|
|
38
|
+
type: "daemon-candidate-ready"
|
|
39
|
+
}, ()=>void 0);
|
|
42
40
|
try {
|
|
43
41
|
await promises.mkdir(DEBUG_ROUTER_DIR, {
|
|
44
42
|
recursive: true
|
|
45
43
|
});
|
|
46
|
-
await promises.writeFile(PIDFILE, String(process.pid),
|
|
44
|
+
await promises.writeFile(PIDFILE, String(process.pid), "utf8");
|
|
47
45
|
} catch {}
|
|
48
|
-
process.on(
|
|
46
|
+
process.on("SIGTERM", ()=>{
|
|
49
47
|
daemon.close().then(()=>{
|
|
50
48
|
process.exit(0);
|
|
51
49
|
});
|
|
52
50
|
});
|
|
53
|
-
process.on(
|
|
51
|
+
process.on("SIGINT", ()=>{
|
|
54
52
|
daemon.close().then(()=>{
|
|
55
53
|
process.exit(0);
|
|
56
54
|
});
|
package/dist/daemon/index.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { DeviceConnection, type DeviceConnectionSubscriber } from "./device-connection.js";
|
|
2
|
+
export { HDT_RES_PATH_PREFIX, type InspectorAssetProvider, InspectorAssets } from "./inspector-assets.js";
|
|
3
|
+
export { createDaemonProcessEnvironment, DAEMON_CONVERGENCE_TIMEOUT_MS, DaemonLifecycle, DaemonLifecycleError, DaemonManager, isDaemonLifecycleError, resolveDaemonEntryPath, } from "./manager.js";
|
|
4
|
+
export * from "./protocol.js";
|
|
5
|
+
export { DevtoolDaemon } from "./server.js";
|
|
6
|
+
export { StaticServer } from "./static-server.js";
|
|
7
|
+
export { TarballCache } from "./tarball-cache.js";
|
package/dist/daemon/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
var daemon_DAEMON_BROWSER_PREVIEW_PROTOCOL_VERSION = 1;
|
|
2
|
+
var daemon_DAEMON_COMMAND_PROTOCOL_VERSION = 1;
|
|
3
|
+
var daemon_DAEMON_CONVERGENCE_TIMEOUT_MS = 15000;
|
|
4
|
+
var daemon_DAEMON_LIFECYCLE_PROTOCOL_VERSION = 1;
|
|
1
5
|
var daemon_DEFAULT_DAEMON_PORT = 21783;
|
|
2
|
-
export { DaemonLifecycleError, DaemonManager, isDaemonLifecycleError } from "../
|
|
3
|
-
export { DevtoolDaemon } from "../
|
|
4
|
-
export { daemon_DEFAULT_DAEMON_PORT as DEFAULT_DAEMON_PORT };
|
|
6
|
+
export { DAEMON_COMMAND_PATH_PREFIX, DAEMON_INSPECTOR_PATH, DAEMON_PRODUCT, DAEMON_SHUTDOWN_PATH, DAEMON_VERSION_PATH, DAEMON_WS_PATH, DaemonLifecycle, DaemonLifecycleError, DaemonManager, createDaemonProcessEnvironment, isControlRequest, isCustomizedMessage, isDaemonLifecycleError, isListClientsRequest, isPingEvent, isRegisterEvent, resolveDaemonEntryPath } from "../2.js";
|
|
7
|
+
export { DeviceConnection, DevtoolDaemon, HDT_RES_PATH_PREFIX, InspectorAssets, StaticServer, TarballCache } from "../t.js";
|
|
8
|
+
export { daemon_DAEMON_BROWSER_PREVIEW_PROTOCOL_VERSION as DAEMON_BROWSER_PREVIEW_PROTOCOL_VERSION, daemon_DAEMON_COMMAND_PROTOCOL_VERSION as DAEMON_COMMAND_PROTOCOL_VERSION, daemon_DAEMON_CONVERGENCE_TIMEOUT_MS as DAEMON_CONVERGENCE_TIMEOUT_MS, daemon_DAEMON_LIFECYCLE_PROTOCOL_VERSION as DAEMON_LIFECYCLE_PROTOCOL_VERSION, daemon_DEFAULT_DAEMON_PORT as DEFAULT_DAEMON_PORT };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const HDT_RES_PATH_PREFIX = "/devtool-frontend/";
|
|
2
|
+
export interface InspectorAssetProvider {
|
|
3
|
+
createInspectorResponse(): Promise<Response>;
|
|
4
|
+
createHdtResourceResponse(pathname: string, acceptEncoding?: string): Promise<Response>;
|
|
5
|
+
}
|
|
6
|
+
/** Shared Inspector wrapper and HDT assets used by every daemon HTTP surface. */
|
|
7
|
+
export declare class InspectorAssets implements InspectorAssetProvider {
|
|
8
|
+
#private;
|
|
9
|
+
createInspectorResponse(): Promise<Response>;
|
|
10
|
+
createHdtResourceResponse(pathname: string, acceptEncoding?: string): Promise<Response>;
|
|
11
|
+
}
|
package/dist/daemon/manager.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { type DaemonIdentity, DEFAULT_DAEMON_PORT } from "./protocol.js";
|
|
2
|
+
export { DEFAULT_DAEMON_PORT };
|
|
3
|
+
export declare const DAEMON_CONVERGENCE_TIMEOUT_MS = 15000;
|
|
2
4
|
export declare function createDaemonProcessEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
3
5
|
export declare class DaemonLifecycleError extends Error {
|
|
4
6
|
readonly code = "ERR_DAEMON_LIFECYCLE";
|
|
@@ -7,10 +9,16 @@ export declare class DaemonLifecycleError extends Error {
|
|
|
7
9
|
export declare function isDaemonLifecycleError(error: unknown): boolean;
|
|
8
10
|
export declare function resolveDaemonEntryPath(moduleUrl?: string): string;
|
|
9
11
|
/** Manages the single connector daemon bound to a loopback port. */
|
|
10
|
-
export declare class
|
|
12
|
+
export declare class DaemonLifecycle {
|
|
11
13
|
#private;
|
|
12
|
-
|
|
14
|
+
protected readonly identity: Readonly<DaemonIdentity>;
|
|
15
|
+
constructor(identity?: DaemonIdentity);
|
|
16
|
+
protected resolveEntryPath(): string;
|
|
17
|
+
protected createProcessEnvironment(): NodeJS.ProcessEnv;
|
|
18
|
+
ensureRunning(port?: number, _options?: {
|
|
13
19
|
commandProtocol?: boolean;
|
|
14
20
|
}): Promise<string>;
|
|
15
|
-
|
|
21
|
+
kill(port?: number): Promise<void>;
|
|
16
22
|
}
|
|
23
|
+
/** Default lifecycle for the standalone public product. */
|
|
24
|
+
export declare const DaemonManager: DaemonLifecycle;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type { ClientTarget } from
|
|
2
|
-
import type { AppInfo } from
|
|
1
|
+
import type { ClientTarget } from "../client-id.js";
|
|
2
|
+
import type { AppInfo } from "../types.js";
|
|
3
3
|
export declare const DAEMON_PRODUCT = "@lynx-js/devtool-connector";
|
|
4
4
|
export declare const DAEMON_LIFECYCLE_PROTOCOL_VERSION = 1;
|
|
5
5
|
export declare const DAEMON_COMMAND_PROTOCOL_VERSION = 1;
|
|
6
|
-
export
|
|
7
|
-
|
|
6
|
+
export declare const DAEMON_BROWSER_PREVIEW_PROTOCOL_VERSION = 1;
|
|
7
|
+
export interface DaemonIdentity {
|
|
8
|
+
product: string;
|
|
8
9
|
version: string;
|
|
9
10
|
lifecycleProtocol: number;
|
|
10
11
|
commandProtocol: number;
|
|
12
|
+
browserPreviewProtocol?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface DaemonMetadata extends DaemonIdentity {
|
|
11
15
|
instanceId: string;
|
|
12
16
|
startedAt: number;
|
|
13
17
|
}
|
|
@@ -19,44 +23,44 @@ export interface DaemonShutdownRequest {
|
|
|
19
23
|
expectedInstanceId: string;
|
|
20
24
|
}
|
|
21
25
|
export interface InitializeEvent {
|
|
22
|
-
event:
|
|
26
|
+
event: "Initialize";
|
|
23
27
|
data: number;
|
|
24
28
|
}
|
|
25
29
|
export interface RegisterEvent {
|
|
26
|
-
event:
|
|
30
|
+
event: "Register";
|
|
27
31
|
data: {
|
|
28
32
|
id: number;
|
|
29
|
-
type:
|
|
33
|
+
type: "Driver";
|
|
30
34
|
};
|
|
31
35
|
}
|
|
32
36
|
export interface ClientListEvent {
|
|
33
|
-
event:
|
|
37
|
+
event: "ClientList";
|
|
34
38
|
data: ClientListEntry[];
|
|
35
39
|
}
|
|
36
40
|
export interface ClientListEntry {
|
|
37
41
|
id: string;
|
|
38
42
|
info: AppInfo;
|
|
39
|
-
type:
|
|
43
|
+
type: "runtime";
|
|
40
44
|
}
|
|
41
45
|
export interface ListClientsRequest {
|
|
42
|
-
event:
|
|
46
|
+
event: "ListClients";
|
|
43
47
|
}
|
|
44
48
|
export interface PingEvent {
|
|
45
|
-
event:
|
|
49
|
+
event: "Ping";
|
|
46
50
|
}
|
|
47
51
|
export interface PongEvent {
|
|
48
|
-
event:
|
|
52
|
+
event: "Pong";
|
|
49
53
|
}
|
|
50
54
|
export interface ControlRequest {
|
|
51
|
-
event:
|
|
55
|
+
event: "Control";
|
|
52
56
|
data: {
|
|
53
57
|
id: number;
|
|
54
|
-
method:
|
|
58
|
+
method: "listClients" | "listDevices" | "listAvailableApps" | "openApp" | "subscribe";
|
|
55
59
|
params?: Record<string, unknown>;
|
|
56
60
|
};
|
|
57
61
|
}
|
|
58
62
|
export interface ControlResponse {
|
|
59
|
-
event:
|
|
63
|
+
event: "ControlResponse";
|
|
60
64
|
data: {
|
|
61
65
|
id: number;
|
|
62
66
|
result?: unknown;
|
|
@@ -66,7 +70,7 @@ export interface ControlResponse {
|
|
|
66
70
|
export type DaemonIncomingMessage = RegisterEvent | ListClientsRequest | PingEvent | ControlRequest | CustomizedMessage;
|
|
67
71
|
export type DaemonOutgoingMessage = InitializeEvent | ClientListEvent | PongEvent | ControlResponse | CustomizedMessage;
|
|
68
72
|
export interface CustomizedMessage {
|
|
69
|
-
event:
|
|
73
|
+
event: "Customized";
|
|
70
74
|
data: {
|
|
71
75
|
type: string;
|
|
72
76
|
data: {
|
package/dist/daemon/server.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ActionCore } from "../command/core.js";
|
|
2
|
+
import type { Transport } from "../transport/transport.js";
|
|
3
|
+
import { type DaemonIdentity } from "./protocol.js";
|
|
4
|
+
import { StaticServer } from "./static-server.js";
|
|
2
5
|
/**
|
|
3
6
|
* The daemon process. Holds real transports, manages persistent device
|
|
4
7
|
* connections, and exposes a WebSocket server for DaemonTransport clients.
|
|
5
8
|
*/
|
|
6
9
|
export declare class DevtoolDaemon {
|
|
7
10
|
#private;
|
|
11
|
+
protected readonly staticServer: StaticServer;
|
|
12
|
+
protected readonly actionCore: ActionCore;
|
|
13
|
+
protected readonly identity: Readonly<DaemonIdentity>;
|
|
8
14
|
constructor(transports: Transport[], options?: {
|
|
9
15
|
onIdle?: () => void;
|
|
10
16
|
onShutdown?: () => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type http from
|
|
1
|
+
import type http from "node:http";
|
|
2
|
+
import { type InspectorAssetProvider } from "./inspector-assets.js";
|
|
2
3
|
export declare class StaticServer {
|
|
3
4
|
#private;
|
|
5
|
+
constructor(assets?: InspectorAssetProvider, resourcePrefix?: string);
|
|
4
6
|
tryHandle(req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
|
5
7
|
}
|