@lynx-js/devtool-connector 0.9.5 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/346.js +635 -0
- package/dist/390.js +262 -35
- package/dist/556.js +9 -4
- package/dist/61.js +3432 -0
- package/dist/63.js +112 -30
- package/dist/712.js +28 -2
- package/dist/872.js +552 -122
- package/dist/962.js +25 -17
- package/dist/client-discovery-errors.d.ts +1 -0
- package/dist/client-id.d.ts +9 -2
- package/dist/command/client.d.ts +28 -0
- package/dist/command/contract.d.ts +255 -0
- package/dist/command/core.d.ts +32 -0
- package/dist/command/index.d.ts +20 -0
- package/dist/command/index.js +224 -0
- package/dist/command/query.d.ts +5 -0
- package/dist/command/reactlynx/controller.d.ts +71 -0
- package/dist/command/reactlynx/model.d.ts +48 -0
- package/dist/command/reactlynx/protocol.d.ts +40 -0
- package/dist/command/reactlynx/session.d.ts +43 -0
- package/dist/command/reactlynx/types.d.ts +73 -0
- package/dist/command/ref-actions.d.ts +17 -0
- package/dist/command/result.d.ts +29 -0
- package/dist/command/screenshot-annotation.d.ts +22 -0
- package/dist/command/screenshot.d.ts +28 -0
- package/dist/command/snapshot.d.ts +79 -0
- package/dist/command/targets.d.ts +15 -0
- package/dist/daemon/device-connection.d.ts +3 -1
- package/dist/daemon/entry.js +11 -0
- package/dist/daemon/index.d.ts +1 -0
- package/dist/daemon/index.js +3 -0
- package/dist/daemon/manager.d.ts +11 -9
- package/dist/daemon/protocol.d.ts +24 -3
- package/dist/daemon/server.d.ts +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +2 -454
- package/dist/streams/customized.d.ts +2 -1
- package/dist/transport/android.d.ts +1 -1
- package/dist/transport/desktop.d.ts +1 -1
- package/dist/transport/index.js +2 -2
- package/dist/transport/ios.d.ts +1 -1
- package/dist/transport/transport.d.ts +7 -1
- package/dist/transport/ws-stream.d.ts +9 -0
- package/dist/types.d.ts +35 -0
- package/package.json +10 -2
- package/dist/187.js +0 -272
- package/dist/43.js +0 -20
- package/dist/677.js +0 -19
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Connector } from '../index.ts';
|
|
2
|
+
/** A bounding box in CDP logical coordinates. */
|
|
3
|
+
export interface Box {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface Point {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RefFlags {
|
|
14
|
+
interactive: boolean;
|
|
15
|
+
visible: boolean;
|
|
16
|
+
offscreen: boolean;
|
|
17
|
+
scrollable: boolean;
|
|
18
|
+
disabled: boolean;
|
|
19
|
+
editable: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Internal hit-test identities. Symbol keys are deliberately omitted from JSON output. */
|
|
22
|
+
export declare const SNAPSHOT_REF_HIT_NODE_IDS: unique symbol;
|
|
23
|
+
declare const SNAPSHOT_REF_VISIBLE_BOX: unique symbol;
|
|
24
|
+
declare const SNAPSHOT_REF_NEEDS_HIT_TEST: unique symbol;
|
|
25
|
+
export declare const SNAPSHOT_REF_ANNOTATION_ROLE: unique symbol;
|
|
26
|
+
export type SnapshotRefAnnotationRole = 'action' | 'editable' | 'scrollable' | 'target' | 'generic';
|
|
27
|
+
/** Refs are stable only within the snapshot that produced them. */
|
|
28
|
+
export interface SnapshotRef {
|
|
29
|
+
ref: string;
|
|
30
|
+
/** Nearest surfaced ancestor in the compact snapshot; omitted for roots. */
|
|
31
|
+
parentRef?: string;
|
|
32
|
+
tag: string;
|
|
33
|
+
text: string;
|
|
34
|
+
nodeId: number;
|
|
35
|
+
backendNodeId?: number;
|
|
36
|
+
center: Point;
|
|
37
|
+
box: Box;
|
|
38
|
+
flags: RefFlags;
|
|
39
|
+
attributes: Record<string, string>;
|
|
40
|
+
[SNAPSHOT_REF_HIT_NODE_IDS]?: ReadonlySet<number>;
|
|
41
|
+
[SNAPSHOT_REF_VISIBLE_BOX]?: Box;
|
|
42
|
+
[SNAPSHOT_REF_NEEDS_HIT_TEST]?: boolean;
|
|
43
|
+
[SNAPSHOT_REF_ANNOTATION_ROLE]?: SnapshotRefAnnotationRole;
|
|
44
|
+
}
|
|
45
|
+
export interface SnapshotResult {
|
|
46
|
+
viewport: Box | undefined;
|
|
47
|
+
refs: SnapshotRef[];
|
|
48
|
+
}
|
|
49
|
+
interface DomBoxModel {
|
|
50
|
+
content?: number[];
|
|
51
|
+
border?: number[];
|
|
52
|
+
}
|
|
53
|
+
/** Lynx DOM node returned by `DOM.getDocumentWithBoxModel`. */
|
|
54
|
+
export interface DomNode {
|
|
55
|
+
nodeId: number;
|
|
56
|
+
backendNodeId?: number;
|
|
57
|
+
nodeName?: string;
|
|
58
|
+
localName?: string;
|
|
59
|
+
nodeValue?: string;
|
|
60
|
+
nodeType?: number;
|
|
61
|
+
attributes?: string[];
|
|
62
|
+
children?: DomNode[];
|
|
63
|
+
/** Field name used by the Lynx CDP protocol. */
|
|
64
|
+
box_model?: DomBoxModel;
|
|
65
|
+
/** Compatibility with callers that already normalized CDP fields to camelCase. */
|
|
66
|
+
boxModel?: DomBoxModel;
|
|
67
|
+
}
|
|
68
|
+
export declare function centerOfQuad(quad: number[]): Point;
|
|
69
|
+
/** Build compact refs from a DOM tree without requiring a live device. */
|
|
70
|
+
export declare function buildRefs(root: DomNode, viewport?: Box): SnapshotRef[];
|
|
71
|
+
/** Filter refs while preserving a valid compact tree among the retained nodes. */
|
|
72
|
+
export declare function filterSnapshotRefs(refs: readonly SnapshotRef[], predicate: (ref: SnapshotRef) => boolean): SnapshotRef[];
|
|
73
|
+
/** Fetch the DOM-derived structure for one Lynx session without live-node enrichment. */
|
|
74
|
+
export declare function buildSnapshotStructure(connector: Connector, clientId: string, sessionId: number, signal?: AbortSignal): Promise<SnapshotResult>;
|
|
75
|
+
/** Enrich a captured snapshot in place so its structure and live metadata stay from one DOM read. */
|
|
76
|
+
export declare function enrichSnapshot(connector: Connector, clientId: string, sessionId: number, snapshot: SnapshotResult, signal?: AbortSignal): Promise<SnapshotResult>;
|
|
77
|
+
/** Fetch a structured snapshot of interactive elements for one Lynx session. */
|
|
78
|
+
export declare function buildSnapshot(connector: Connector, clientId: string, sessionId: number, signal?: AbortSignal): Promise<SnapshotResult>;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Connector } from '../index.ts';
|
|
2
|
+
import type { CommandObject } from './contract.ts';
|
|
3
|
+
import { type CommandResult } from './result.ts';
|
|
4
|
+
export type ResolvedSessionTarget = {
|
|
5
|
+
ok: true;
|
|
6
|
+
params: CommandObject & {
|
|
7
|
+
clientId: string;
|
|
8
|
+
sessionId: number;
|
|
9
|
+
};
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
result: CommandResult<never>;
|
|
13
|
+
};
|
|
14
|
+
/** Resolve optional client/session fields once inside the daemon. */
|
|
15
|
+
export declare function resolveSessionTarget(action: string, params: CommandObject, connector: Connector): Promise<ResolvedSessionTarget>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ClientTarget } from '../client-id.ts';
|
|
1
2
|
import type { Transport, TransportConnectOptions } from '../transport/transport.ts';
|
|
2
3
|
import { type AppInfo } from '../types.ts';
|
|
3
4
|
export interface DeviceConnectionSubscriber {
|
|
@@ -17,7 +18,7 @@ export declare class DeviceConnection {
|
|
|
17
18
|
#private;
|
|
18
19
|
readonly key: string;
|
|
19
20
|
readonly deviceId: string;
|
|
20
|
-
readonly port:
|
|
21
|
+
readonly port: ClientTarget;
|
|
21
22
|
/** Populated after a successful Initialize/Register handshake. */
|
|
22
23
|
appInfo: AppInfo | null;
|
|
23
24
|
constructor(transport: Transport, options: TransportConnectOptions);
|
|
@@ -26,6 +27,7 @@ export declare class DeviceConnection {
|
|
|
26
27
|
* in a try/catch — a failure means the device:port is unreachable.
|
|
27
28
|
*/
|
|
28
29
|
connect(): Promise<void>;
|
|
30
|
+
waitUntilRegistered(): Promise<AppInfo>;
|
|
29
31
|
addSubscriber(subscriber: DeviceConnectionSubscriber): void;
|
|
30
32
|
removeSubscriber(id: number): void;
|
|
31
33
|
get subscriberCount(): number;
|
package/dist/daemon/entry.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import promises from "node:fs/promises";
|
|
2
|
+
import node_os from "node:os";
|
|
3
|
+
import node_path from "node:path";
|
|
1
4
|
import { parseArgs } from "node:util";
|
|
2
5
|
import { AndroidTransport, DesktopTransport, iOSTransport } from "../962.js";
|
|
3
6
|
import "../390.js";
|
|
4
7
|
import { DevtoolDaemon } from "../872.js";
|
|
8
|
+
const DEBUG_ROUTER_DIR = node_path.join(node_os.homedir(), '.DebugRouterConnector');
|
|
9
|
+
const PIDFILE = node_path.join(DEBUG_ROUTER_DIR, 'daemon.pid');
|
|
5
10
|
function getAndroidTransportSpec(env) {
|
|
6
11
|
const port = Number.parseInt(env['ADB_SERVER_PORT'] ?? '5037', 10);
|
|
7
12
|
return {
|
|
@@ -34,6 +39,12 @@ const daemon = new DevtoolDaemon([
|
|
|
34
39
|
}
|
|
35
40
|
});
|
|
36
41
|
await daemon.start(entry_port);
|
|
42
|
+
try {
|
|
43
|
+
await promises.mkdir(DEBUG_ROUTER_DIR, {
|
|
44
|
+
recursive: true
|
|
45
|
+
});
|
|
46
|
+
await promises.writeFile(PIDFILE, String(process.pid), 'utf8');
|
|
47
|
+
} catch {}
|
|
37
48
|
process.on('SIGTERM', ()=>{
|
|
38
49
|
daemon.close().then(()=>{
|
|
39
50
|
process.exit(0);
|
package/dist/daemon/index.d.ts
CHANGED
package/dist/daemon/index.js
CHANGED
package/dist/daemon/manager.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export { DEFAULT_DAEMON_PORT } from './protocol.ts';
|
|
2
|
+
export declare function createDaemonProcessEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
3
|
+
export declare class DaemonLifecycleError extends Error {
|
|
4
|
+
readonly code = "ERR_DAEMON_LIFECYCLE";
|
|
5
|
+
constructor(message: string, options?: ErrorOptions);
|
|
6
|
+
}
|
|
7
|
+
export declare function isDaemonLifecycleError(error: unknown): boolean;
|
|
2
8
|
export declare function resolveDaemonEntryPath(moduleUrl?: string): string;
|
|
3
|
-
/**
|
|
4
|
-
* Manages the daemon process lifecycle.
|
|
5
|
-
*
|
|
6
|
-
* - `ensureRunning()`: checks if the daemon is alive, spawns it if not
|
|
7
|
-
* - `spawn()`: forks a detached daemon process
|
|
8
|
-
* - `kill()`: sends SIGTERM to the daemon
|
|
9
|
-
*/
|
|
9
|
+
/** Manages the single connector daemon bound to a loopback port. */
|
|
10
10
|
export declare class DaemonManager {
|
|
11
11
|
#private;
|
|
12
|
-
static ensureRunning(port?: number
|
|
13
|
-
|
|
12
|
+
static ensureRunning(port?: number, options?: {
|
|
13
|
+
commandProtocol?: boolean;
|
|
14
|
+
}): Promise<string>;
|
|
15
|
+
static kill(port?: number): Promise<void>;
|
|
14
16
|
}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
|
+
import type { ClientTarget } from '../client-id.ts';
|
|
1
2
|
import type { AppInfo } from '../types.ts';
|
|
3
|
+
export declare const DAEMON_PRODUCT = "@lynx-js/devtool-connector";
|
|
4
|
+
export declare const DAEMON_LIFECYCLE_PROTOCOL_VERSION = 1;
|
|
5
|
+
export declare const DAEMON_COMMAND_PROTOCOL_VERSION = 1;
|
|
6
|
+
export interface DaemonMetadata {
|
|
7
|
+
product: typeof DAEMON_PRODUCT;
|
|
8
|
+
version: string;
|
|
9
|
+
lifecycleProtocol: number;
|
|
10
|
+
commandProtocol: number;
|
|
11
|
+
instanceId: string;
|
|
12
|
+
startedAt: number;
|
|
13
|
+
}
|
|
14
|
+
export interface LegacyDaemonMetadata {
|
|
15
|
+
version: string;
|
|
16
|
+
commandProtocol?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface DaemonShutdownRequest {
|
|
19
|
+
expectedInstanceId: string;
|
|
20
|
+
}
|
|
2
21
|
export interface InitializeEvent {
|
|
3
22
|
event: 'Initialize';
|
|
4
23
|
data: number;
|
|
@@ -51,15 +70,15 @@ export interface CustomizedMessage {
|
|
|
51
70
|
data: {
|
|
52
71
|
type: string;
|
|
53
72
|
data: {
|
|
54
|
-
client_id?:
|
|
73
|
+
client_id?: ClientTarget;
|
|
55
74
|
session_id?: number;
|
|
56
75
|
message?: unknown;
|
|
57
76
|
[key: string]: unknown;
|
|
58
77
|
};
|
|
59
|
-
sender?:
|
|
78
|
+
sender?: ClientTarget;
|
|
60
79
|
[key: string]: unknown;
|
|
61
80
|
};
|
|
62
|
-
to?:
|
|
81
|
+
to?: ClientTarget;
|
|
63
82
|
}
|
|
64
83
|
export declare function isCustomizedMessage(msg: unknown): msg is CustomizedMessage;
|
|
65
84
|
export declare function isControlRequest(msg: unknown): msg is ControlRequest;
|
|
@@ -71,3 +90,5 @@ export declare const DAEMON_WS_PATH = "/devtool/connector";
|
|
|
71
90
|
export declare const DAEMON_VERSION_PATH: string;
|
|
72
91
|
export declare const DAEMON_SHUTDOWN_PATH: string;
|
|
73
92
|
export declare const DAEMON_INSPECTOR_PATH: string;
|
|
93
|
+
/** HTTP command endpoint shared with the WebSocket daemon on port 21783. */
|
|
94
|
+
export declare const DAEMON_COMMAND_PATH_PREFIX = "/command/";
|
package/dist/daemon/server.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ReadableStream, type TransformStream } from 'node:stream/web';
|
|
|
2
2
|
export { CDPOutputTransformStream, CDPRequestTransformStream, CDPResponseTransformStream, } from './streams/cdp.ts';
|
|
3
3
|
import { ClientId } from './client-id.ts';
|
|
4
4
|
import type { App, Client, Device, OpenAppOptions, Transport } from './transport/transport.ts';
|
|
5
|
-
import { type CDPRequestMessage, type GlobalKeys, type HeadlessPrepareState, type Session } from './types.ts';
|
|
5
|
+
import { type CDPRequestMessage, type GlobalKeys, type HeadlessPrepareState, type ListSessionResponse, type Session } from './types.ts';
|
|
6
6
|
interface OutputStream<O> extends AsyncDisposable, ReadableStream<O> {
|
|
7
7
|
inputClosed: Promise<void>;
|
|
8
8
|
}
|
|
@@ -17,7 +17,7 @@ export declare class Connector {
|
|
|
17
17
|
listClients(): Promise<Client[]>;
|
|
18
18
|
listDevices(): Promise<Device[]>;
|
|
19
19
|
listAvailableApps(deviceId: string): Promise<App[]>;
|
|
20
|
-
openApp(deviceId: string, packageName: string, options?: OpenAppOptions): Promise<
|
|
20
|
+
openApp(deviceId: string, packageName: string, options?: OpenAppOptions): Promise<string>;
|
|
21
21
|
sendMessage<T, R>(clientId: string, message: T, pipeline?: Pipeline): Promise<R>;
|
|
22
22
|
/**
|
|
23
23
|
* Send a message to the device without waiting for a response.
|
|
@@ -29,6 +29,10 @@ export declare class Connector {
|
|
|
29
29
|
*/
|
|
30
30
|
sendMessageNoReply<T>(clientId: string, message: T): Promise<void>;
|
|
31
31
|
sendAppMessage<Output, Params = never>(clientId: string, method: string, params?: Params): Promise<Output>;
|
|
32
|
+
/**
|
|
33
|
+
* Open a page on the given client by sending an `OpenCard` Customized event.
|
|
34
|
+
*/
|
|
35
|
+
openPage(clientId: string, url: string): Promise<ListSessionResponse>;
|
|
32
36
|
sendCDPMessage<Output, Params = never>(clientId: string, sessionId: number, method: string, params?: Params, isMainThread?: boolean): Promise<Output>;
|
|
33
37
|
sendListSessionMessage(clientId: string): Promise<Session[]>;
|
|
34
38
|
/**
|