@lynx-js/devtool-connector 0.9.4 → 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/CHANGELOG.md +6 -0
- 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 +38 -31
- 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 +11 -3
- package/dist/187.js +0 -272
- package/dist/43.js +0 -20
- package/dist/677.js +0 -19
package/dist/962.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Server, Socket } from "net";
|
|
2
|
+
import { createDebug } from "obug";
|
|
2
3
|
import promises from "node:fs/promises";
|
|
3
4
|
import node_os from "node:os";
|
|
4
5
|
import node_path from "node:path";
|
|
@@ -7,7 +8,6 @@ import node_net from "node:net";
|
|
|
7
8
|
import { Duplex } from "node:stream";
|
|
8
9
|
import { on, once } from "node:events";
|
|
9
10
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
10
|
-
import { node_createDebug } from "./187.js";
|
|
11
11
|
import * as __rspack_external_node_net_0373943e from "node:net";
|
|
12
12
|
__webpack_require__.add({
|
|
13
13
|
"../../../node_modules/.pnpm/@xmldom+xmldom@0.9.10/node_modules/@xmldom/xmldom/lib/conventions.js" (__unused_rspack_module, exports) {
|
|
@@ -11189,7 +11189,7 @@ class AdbServerNodeTcpConnector {
|
|
|
11189
11189
|
this.#listeners.clear();
|
|
11190
11190
|
}
|
|
11191
11191
|
}
|
|
11192
|
-
const debug =
|
|
11192
|
+
const debug = createDebug('devtool-mcp-server:takeover');
|
|
11193
11193
|
const DEBUG_ROUTER_DIR = node_path.join(node_os.homedir(), '.DebugRouterConnector');
|
|
11194
11194
|
const DEBUG_ROUTER_LOCK_DIR = node_path.join(DEBUG_ROUTER_DIR, 'lockfile');
|
|
11195
11195
|
const DEBUG_ROUTER_LATEST_FILE = node_path.join(DEBUG_ROUTER_DIR, 'LatestDriverProcess');
|
|
@@ -11297,6 +11297,11 @@ async function connectWithPeertalk(connectRaw, options) {
|
|
|
11297
11297
|
await takeoverDebugRouterLock();
|
|
11298
11298
|
return createMessageConnection(connectRaw, peertalkCodecFactory, options);
|
|
11299
11299
|
}
|
|
11300
|
+
function requireNumericPort(port) {
|
|
11301
|
+
if ('number' == typeof port) return port;
|
|
11302
|
+
if (/^\d+$/.test(port)) return Number(port);
|
|
11303
|
+
throw new TypeError(`Transport requires a numeric port, received target: ${port}`);
|
|
11304
|
+
}
|
|
11300
11305
|
function _ts_add_disposable_resource(env, value, async) {
|
|
11301
11306
|
if (null != value) {
|
|
11302
11307
|
if ("object" != typeof value && "function" != typeof value) throw new TypeError("Object expected.");
|
|
@@ -11358,17 +11363,7 @@ function android_ts_dispose_resources(env) {
|
|
|
11358
11363
|
return next();
|
|
11359
11364
|
})(env);
|
|
11360
11365
|
}
|
|
11361
|
-
const android_debug =
|
|
11362
|
-
const KNOWNS_APPS = [
|
|
11363
|
-
{
|
|
11364
|
-
packageName: 'com.lynx.uiapp',
|
|
11365
|
-
name: 'Lynx Example'
|
|
11366
|
-
},
|
|
11367
|
-
{
|
|
11368
|
-
packageName: 'com.lynx.explorer',
|
|
11369
|
-
name: 'Lynx Explorer'
|
|
11370
|
-
}
|
|
11371
|
-
];
|
|
11366
|
+
const android_debug = createDebug('devtool-mcp-server:connector:android');
|
|
11372
11367
|
class AndroidTransport {
|
|
11373
11368
|
client;
|
|
11374
11369
|
constructor(spec = {
|
|
@@ -11393,12 +11388,13 @@ class AndroidTransport {
|
|
|
11393
11388
|
android_debug('Android transport closed');
|
|
11394
11389
|
}
|
|
11395
11390
|
async #connectRaw({ deviceId, port, signal }) {
|
|
11391
|
+
const numericPort = requireNumericPort(port);
|
|
11396
11392
|
const adb = await this.client.createAdb({
|
|
11397
11393
|
serial: deviceId
|
|
11398
11394
|
});
|
|
11399
|
-
android_debug(`connect: create connection to deviceId: ${deviceId}, port: ${
|
|
11395
|
+
android_debug(`connect: create connection to deviceId: ${deviceId}, port: ${numericPort}`);
|
|
11400
11396
|
signal?.throwIfAborted();
|
|
11401
|
-
const service = `tcp:${
|
|
11397
|
+
const service = `tcp:${numericPort}`;
|
|
11402
11398
|
let socket;
|
|
11403
11399
|
try {
|
|
11404
11400
|
socket = await adb.createSocket(service);
|
|
@@ -11428,7 +11424,7 @@ class AndroidTransport {
|
|
|
11428
11424
|
writable: socket.writable,
|
|
11429
11425
|
async [Symbol.asyncDispose] () {
|
|
11430
11426
|
signal?.removeEventListener('abort', abortHandler);
|
|
11431
|
-
android_debug(`connect: close connection to deviceId: ${deviceId}, port: ${
|
|
11427
|
+
android_debug(`connect: close connection to deviceId: ${deviceId}, port: ${numericPort}`);
|
|
11432
11428
|
try {
|
|
11433
11429
|
await socket.close();
|
|
11434
11430
|
} finally{
|
|
@@ -11459,9 +11455,12 @@ class AndroidTransport {
|
|
|
11459
11455
|
'packages',
|
|
11460
11456
|
'-3'
|
|
11461
11457
|
]);
|
|
11462
|
-
const packages =
|
|
11458
|
+
const packages = output.split('\n').map((line)=>line.replace('package:', '').trim()).filter((i)=>'' !== i);
|
|
11463
11459
|
android_debug("listAvailableApps all packages: %o", packages);
|
|
11464
|
-
return
|
|
11460
|
+
return packages.map((packageName)=>({
|
|
11461
|
+
packageName,
|
|
11462
|
+
name: packageName
|
|
11463
|
+
}));
|
|
11465
11464
|
} catch (e) {
|
|
11466
11465
|
env.error = e;
|
|
11467
11466
|
env.hasError = true;
|
|
@@ -11477,9 +11476,15 @@ class AndroidTransport {
|
|
|
11477
11476
|
hasError: false
|
|
11478
11477
|
};
|
|
11479
11478
|
try {
|
|
11480
|
-
const apps = await this.listAvailableApps(deviceId);
|
|
11481
11479
|
const adb = _ts_add_disposable_resource(env, await this.#createAdb(deviceId), true);
|
|
11482
|
-
|
|
11480
|
+
const pmOutput = await adb.subprocess.noneProtocol.spawnWaitText([
|
|
11481
|
+
'pm',
|
|
11482
|
+
'list',
|
|
11483
|
+
'packages',
|
|
11484
|
+
packageName
|
|
11485
|
+
]);
|
|
11486
|
+
const installed = pmOutput.split('\n').some((line)=>line.trim() === `package:${packageName}`);
|
|
11487
|
+
if (!installed) throw new Error(`package ${packageName} not found`);
|
|
11483
11488
|
if (withDataCleared) {
|
|
11484
11489
|
const output = await adb.subprocess.noneProtocol.spawnWaitText([
|
|
11485
11490
|
'pm',
|
|
@@ -11508,7 +11513,7 @@ class AndroidTransport {
|
|
|
11508
11513
|
}
|
|
11509
11514
|
}
|
|
11510
11515
|
}
|
|
11511
|
-
const desktop_debug =
|
|
11516
|
+
const desktop_debug = createDebug('devtool-mcp-server:connector:desktop');
|
|
11512
11517
|
class DesktopTransport {
|
|
11513
11518
|
async connect(options) {
|
|
11514
11519
|
return connectWithPeertalk((opts)=>this.#connectRaw(opts), options);
|
|
@@ -11532,10 +11537,11 @@ class DesktopTransport {
|
|
|
11532
11537
|
}
|
|
11533
11538
|
async #connectRaw({ deviceId, port, signal }) {
|
|
11534
11539
|
if ('localhost' !== deviceId) throw new Error(`DesktopTransport only supports 'localhost' deviceId, got: ${deviceId}`);
|
|
11535
|
-
|
|
11540
|
+
const numericPort = requireNumericPort(port);
|
|
11541
|
+
desktop_debug(`connect: connecting to 127.0.0.1:${numericPort}`);
|
|
11536
11542
|
const socket = node_net.createConnection({
|
|
11537
11543
|
host: '127.0.0.1',
|
|
11538
|
-
port,
|
|
11544
|
+
port: numericPort,
|
|
11539
11545
|
signal
|
|
11540
11546
|
});
|
|
11541
11547
|
try {
|
|
@@ -11543,18 +11549,18 @@ class DesktopTransport {
|
|
|
11543
11549
|
socket.once('connect', resolve);
|
|
11544
11550
|
socket.once('error', reject);
|
|
11545
11551
|
});
|
|
11546
|
-
desktop_debug(`connect: connected to 127.0.0.1:${
|
|
11552
|
+
desktop_debug(`connect: connected to 127.0.0.1:${numericPort}`);
|
|
11547
11553
|
const { readable, writable } = Duplex.toWeb(socket);
|
|
11548
11554
|
return {
|
|
11549
11555
|
readable,
|
|
11550
11556
|
writable,
|
|
11551
11557
|
async [Symbol.asyncDispose] () {
|
|
11552
|
-
desktop_debug(`connect: closing connection to 127.0.0.1:${
|
|
11558
|
+
desktop_debug(`connect: closing connection to 127.0.0.1:${numericPort}`);
|
|
11553
11559
|
socket.destroy();
|
|
11554
11560
|
}
|
|
11555
11561
|
};
|
|
11556
11562
|
} catch (err) {
|
|
11557
|
-
desktop_debug(`connect: error connecting to 127.0.0.1:${
|
|
11563
|
+
desktop_debug(`connect: error connecting to 127.0.0.1:${numericPort} %O`, err);
|
|
11558
11564
|
socket.destroy();
|
|
11559
11565
|
throw err;
|
|
11560
11566
|
}
|
|
@@ -12100,7 +12106,7 @@ class Usbmux {
|
|
|
12100
12106
|
}
|
|
12101
12107
|
}
|
|
12102
12108
|
}
|
|
12103
|
-
const ios_debug =
|
|
12109
|
+
const ios_debug = createDebug('devtool-mcp-server:connector:ios');
|
|
12104
12110
|
class iOSTransport {
|
|
12105
12111
|
#client;
|
|
12106
12112
|
constructor(options){
|
|
@@ -12113,14 +12119,15 @@ class iOSTransport {
|
|
|
12113
12119
|
ios_debug('iOS transport closed');
|
|
12114
12120
|
}
|
|
12115
12121
|
async #connectRaw({ deviceId, port, signal }) {
|
|
12116
|
-
|
|
12122
|
+
const numericPort = requireNumericPort(port);
|
|
12123
|
+
ios_debug(`connect: create connection to deviceId: ${deviceId}, port: ${numericPort}`);
|
|
12117
12124
|
const id = await this.#resolveUsbmuxDeviceId(deviceId, signal);
|
|
12118
|
-
const conn = await this.#client.connect(id,
|
|
12125
|
+
const conn = await this.#client.connect(id, numericPort, signal);
|
|
12119
12126
|
return {
|
|
12120
12127
|
readable: conn.readable,
|
|
12121
12128
|
writable: conn.writable,
|
|
12122
12129
|
async [Symbol.asyncDispose] () {
|
|
12123
|
-
ios_debug(`connect: close connection to deviceId: ${deviceId}, port: ${
|
|
12130
|
+
ios_debug(`connect: close connection to deviceId: ${deviceId}, port: ${numericPort}`);
|
|
12124
12131
|
conn.dispose();
|
|
12125
12132
|
}
|
|
12126
12133
|
};
|
|
@@ -12148,4 +12155,4 @@ class iOSTransport {
|
|
|
12148
12155
|
throw new Error('Not implemented');
|
|
12149
12156
|
}
|
|
12150
12157
|
}
|
|
12151
|
-
export { AndroidTransport, DesktopTransport, MessageToPeertalkTransformStream, PeertalkToMessageTransformStream, Usbmux, connectWithPeertalk, createMessageConnection, iOSTransport, peertalkCodecFactory };
|
|
12158
|
+
export { AndroidTransport, DesktopTransport, MessageToPeertalkTransformStream, PeertalkToMessageTransformStream, Usbmux, connectWithPeertalk, createMessageConnection, iOSTransport, peertalkCodecFactory, requireNumericPort };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function throwClientDiscoveryFailures(failures: unknown[]): never;
|
package/dist/client-id.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A client address on a device.
|
|
3
|
+
*
|
|
4
|
+
* Numeric targets are debug-router TCP ports. String targets identify clients
|
|
5
|
+
* that are not reachable through a numeric port and are matched verbatim.
|
|
6
|
+
*/
|
|
7
|
+
export type ClientTarget = number | string;
|
|
1
8
|
export declare class ClientId {
|
|
2
|
-
static serialize(deviceId: string,
|
|
9
|
+
static serialize(deviceId: string, target: ClientTarget): string;
|
|
3
10
|
static deserialize(clientId: string): {
|
|
4
11
|
deviceId: string;
|
|
5
|
-
port:
|
|
12
|
+
port: ClientTarget;
|
|
6
13
|
} | null;
|
|
7
14
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CommandAction, CommandClient, CommandData, CommandObject, CommandParams, StreamCommandAction, StreamCommandEvent, StreamCommandParams } from './contract.ts';
|
|
2
|
+
import { type CommandResult } from './result.ts';
|
|
3
|
+
export interface CommandCallOptions {
|
|
4
|
+
port?: number;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
ensureDaemon?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CommandStreamOptions {
|
|
9
|
+
port?: number;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
ensureDaemon?: boolean;
|
|
12
|
+
method?: 'GET' | 'POST';
|
|
13
|
+
}
|
|
14
|
+
export declare function callRawCommand<T = unknown>(action: string, params: CommandObject, options?: CommandCallOptions): Promise<CommandResult<T>>;
|
|
15
|
+
export declare function callCommand<Action extends CommandAction>(action: Action, params: CommandParams<Action>, options?: CommandCallOptions): Promise<CommandResult<CommandData<Action>>>;
|
|
16
|
+
export declare function streamRawCommand<T = unknown>(action: string, params: CommandObject, options?: CommandStreamOptions): AsyncGenerator<CommandResult<T>>;
|
|
17
|
+
export declare function streamCommand<Action extends StreamCommandAction>(action: Action, params: StreamCommandParams<Action>, options?: CommandStreamOptions): AsyncGenerator<CommandResult<StreamCommandEvent<Action>>>;
|
|
18
|
+
export declare class HttpCommandClient implements CommandClient {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(options?: {
|
|
21
|
+
port?: number;
|
|
22
|
+
ensureDaemon?: boolean;
|
|
23
|
+
});
|
|
24
|
+
execute<Action extends CommandAction>(action: Action, params: CommandParams<Action>, options?: Omit<CommandCallOptions, 'port' | 'ensureDaemon'>): Promise<CommandResult<CommandData<Action>>>;
|
|
25
|
+
stream<Action extends StreamCommandAction>(action: Action, params: StreamCommandParams<Action>, options?: Omit<CommandStreamOptions, 'port' | 'ensureDaemon'>): AsyncGenerator<CommandResult<StreamCommandEvent<Action>>>;
|
|
26
|
+
executeRaw<T = unknown>(action: string, params: CommandObject, options?: Omit<CommandCallOptions, 'port' | 'ensureDaemon'>): Promise<CommandResult<T>>;
|
|
27
|
+
streamRaw<T = unknown>(action: string, params: CommandObject, options?: Omit<CommandStreamOptions, 'port' | 'ensureDaemon'>): AsyncGenerator<CommandResult<T>>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import type { ReactLynxComponentData, ReactLynxFindData, ReactLynxLinkData, ReactLynxTreeData } from './reactlynx/types.ts';
|
|
2
|
+
import type { CommandResult } from './result.ts';
|
|
3
|
+
import type { Box, Point, SnapshotRef } from './snapshot.ts';
|
|
4
|
+
export type CommandObject = Record<string, unknown>;
|
|
5
|
+
export interface ClientTarget {
|
|
6
|
+
clientId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SessionTarget extends ClientTarget {
|
|
9
|
+
sessionId?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SnapshotData {
|
|
12
|
+
clientId: string;
|
|
13
|
+
sessionId: number;
|
|
14
|
+
viewport: Box | undefined;
|
|
15
|
+
refs: SnapshotRef[];
|
|
16
|
+
}
|
|
17
|
+
export interface SnapshotRefreshError {
|
|
18
|
+
message: string;
|
|
19
|
+
cause?: string;
|
|
20
|
+
recoverable: boolean;
|
|
21
|
+
nextActions: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface SnapshotAfterResult {
|
|
24
|
+
snapshot?: SnapshotData;
|
|
25
|
+
snapshotError?: SnapshotRefreshError;
|
|
26
|
+
}
|
|
27
|
+
export interface ScreenshotAnnotation {
|
|
28
|
+
ref: string;
|
|
29
|
+
number: number;
|
|
30
|
+
tag: string;
|
|
31
|
+
text?: string;
|
|
32
|
+
/** Bounding box in captured-image pixels, clipped to the screenshot viewport. */
|
|
33
|
+
box: Box;
|
|
34
|
+
}
|
|
35
|
+
export interface CommandMap {
|
|
36
|
+
snapshot: {
|
|
37
|
+
params: SessionTarget & {
|
|
38
|
+
visibleOnly?: boolean;
|
|
39
|
+
};
|
|
40
|
+
data: SnapshotData;
|
|
41
|
+
};
|
|
42
|
+
screenshot: {
|
|
43
|
+
params: SessionTarget & {
|
|
44
|
+
fullscreen?: boolean;
|
|
45
|
+
annotate?: boolean;
|
|
46
|
+
};
|
|
47
|
+
data: {
|
|
48
|
+
clientId: string;
|
|
49
|
+
sessionId: number;
|
|
50
|
+
jpegBase64: string;
|
|
51
|
+
width?: number;
|
|
52
|
+
height?: number;
|
|
53
|
+
snapshot?: SnapshotData;
|
|
54
|
+
annotations?: ScreenshotAnnotation[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
tap: {
|
|
58
|
+
params: SessionTarget & {
|
|
59
|
+
ref: string;
|
|
60
|
+
snapshotAfter?: boolean;
|
|
61
|
+
};
|
|
62
|
+
data: {
|
|
63
|
+
clientId: string;
|
|
64
|
+
sessionId: number;
|
|
65
|
+
ref: string;
|
|
66
|
+
point: Point;
|
|
67
|
+
} & SnapshotAfterResult;
|
|
68
|
+
};
|
|
69
|
+
'long-press': {
|
|
70
|
+
params: SessionTarget & {
|
|
71
|
+
ref: string;
|
|
72
|
+
duration?: number;
|
|
73
|
+
snapshotAfter?: boolean;
|
|
74
|
+
};
|
|
75
|
+
data: {
|
|
76
|
+
clientId: string;
|
|
77
|
+
sessionId: number;
|
|
78
|
+
ref: string;
|
|
79
|
+
point: Point;
|
|
80
|
+
longPress: true;
|
|
81
|
+
} & SnapshotAfterResult;
|
|
82
|
+
};
|
|
83
|
+
fill: {
|
|
84
|
+
params: SessionTarget & {
|
|
85
|
+
ref: string;
|
|
86
|
+
text: string;
|
|
87
|
+
snapshotAfter?: boolean;
|
|
88
|
+
};
|
|
89
|
+
data: {
|
|
90
|
+
clientId: string;
|
|
91
|
+
sessionId: number;
|
|
92
|
+
ref: string;
|
|
93
|
+
value: string;
|
|
94
|
+
} & SnapshotAfterResult;
|
|
95
|
+
};
|
|
96
|
+
clear: {
|
|
97
|
+
params: SessionTarget & {
|
|
98
|
+
ref: string;
|
|
99
|
+
snapshotAfter?: boolean;
|
|
100
|
+
};
|
|
101
|
+
data: {
|
|
102
|
+
clientId: string;
|
|
103
|
+
sessionId: number;
|
|
104
|
+
ref: string;
|
|
105
|
+
value: string;
|
|
106
|
+
} & SnapshotAfterResult;
|
|
107
|
+
};
|
|
108
|
+
scroll: {
|
|
109
|
+
params: SessionTarget & {
|
|
110
|
+
ref: string;
|
|
111
|
+
direction?: 'up' | 'down' | 'left' | 'right';
|
|
112
|
+
snapshotAfter?: boolean;
|
|
113
|
+
};
|
|
114
|
+
data: {
|
|
115
|
+
clientId: string;
|
|
116
|
+
sessionId: number;
|
|
117
|
+
ref: string;
|
|
118
|
+
direction: 'up' | 'down' | 'left' | 'right';
|
|
119
|
+
from: Point;
|
|
120
|
+
to: Point;
|
|
121
|
+
} & SnapshotAfterResult;
|
|
122
|
+
};
|
|
123
|
+
'get-text': {
|
|
124
|
+
params: SessionTarget & {
|
|
125
|
+
ref: string;
|
|
126
|
+
};
|
|
127
|
+
data: {
|
|
128
|
+
clientId: string;
|
|
129
|
+
sessionId: number;
|
|
130
|
+
ref: string;
|
|
131
|
+
text: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
'get-style': {
|
|
135
|
+
params: SessionTarget & {
|
|
136
|
+
ref: string;
|
|
137
|
+
property?: string | string[];
|
|
138
|
+
};
|
|
139
|
+
data: {
|
|
140
|
+
clientId: string;
|
|
141
|
+
sessionId: number;
|
|
142
|
+
ref: string;
|
|
143
|
+
style: Record<string, string>;
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
wait: {
|
|
147
|
+
params: SessionTarget & {
|
|
148
|
+
text?: string;
|
|
149
|
+
ref?: string;
|
|
150
|
+
timeout?: number;
|
|
151
|
+
interval?: number;
|
|
152
|
+
};
|
|
153
|
+
data: {
|
|
154
|
+
clientId: string;
|
|
155
|
+
sessionId: number;
|
|
156
|
+
matched: true;
|
|
157
|
+
by: 'text' | 'ref';
|
|
158
|
+
query: string;
|
|
159
|
+
elapsedMs: number;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
'reactlynx-tree': {
|
|
163
|
+
params: SessionTarget & {
|
|
164
|
+
depth?: number;
|
|
165
|
+
showShells?: boolean;
|
|
166
|
+
};
|
|
167
|
+
data: ReactLynxTreeData;
|
|
168
|
+
};
|
|
169
|
+
'reactlynx-find': {
|
|
170
|
+
params: SessionTarget & {
|
|
171
|
+
pattern: string;
|
|
172
|
+
regex?: boolean;
|
|
173
|
+
showShells?: boolean;
|
|
174
|
+
limit?: number;
|
|
175
|
+
refresh?: boolean;
|
|
176
|
+
};
|
|
177
|
+
data: ReactLynxFindData;
|
|
178
|
+
};
|
|
179
|
+
'reactlynx-component': {
|
|
180
|
+
params: SessionTarget & {
|
|
181
|
+
ref: string;
|
|
182
|
+
showShells?: boolean;
|
|
183
|
+
refresh?: boolean;
|
|
184
|
+
};
|
|
185
|
+
data: ReactLynxComponentData;
|
|
186
|
+
};
|
|
187
|
+
'reactlynx-link': {
|
|
188
|
+
params: SessionTarget & {
|
|
189
|
+
ref: string;
|
|
190
|
+
showShells?: boolean;
|
|
191
|
+
refresh?: boolean;
|
|
192
|
+
};
|
|
193
|
+
data: ReactLynxLinkData;
|
|
194
|
+
};
|
|
195
|
+
'reactlynx-update-prop': {
|
|
196
|
+
params: SessionTarget & {
|
|
197
|
+
ref: string;
|
|
198
|
+
path: string;
|
|
199
|
+
value: unknown;
|
|
200
|
+
showShells?: boolean;
|
|
201
|
+
refresh?: boolean;
|
|
202
|
+
};
|
|
203
|
+
data: ReactLynxComponentData;
|
|
204
|
+
};
|
|
205
|
+
'reactlynx-update-state': {
|
|
206
|
+
params: SessionTarget & {
|
|
207
|
+
ref: string;
|
|
208
|
+
path: string;
|
|
209
|
+
value: unknown;
|
|
210
|
+
showShells?: boolean;
|
|
211
|
+
refresh?: boolean;
|
|
212
|
+
};
|
|
213
|
+
data: ReactLynxComponentData;
|
|
214
|
+
};
|
|
215
|
+
'reactlynx-update-context': {
|
|
216
|
+
params: SessionTarget & {
|
|
217
|
+
ref: string;
|
|
218
|
+
path: string;
|
|
219
|
+
value: unknown;
|
|
220
|
+
showShells?: boolean;
|
|
221
|
+
refresh?: boolean;
|
|
222
|
+
};
|
|
223
|
+
data: ReactLynxComponentData;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
export type CommandAction = keyof CommandMap;
|
|
227
|
+
export type CommandParams<Action extends CommandAction> = CommandMap[Action]['params'];
|
|
228
|
+
export type CommandData<Action extends CommandAction> = CommandMap[Action]['data'];
|
|
229
|
+
export interface WaitProgressData {
|
|
230
|
+
clientId: string;
|
|
231
|
+
sessionId: number;
|
|
232
|
+
matched: false;
|
|
233
|
+
by: 'text' | 'ref';
|
|
234
|
+
query: string;
|
|
235
|
+
elapsedMs: number;
|
|
236
|
+
refCount: number;
|
|
237
|
+
}
|
|
238
|
+
export interface StreamCommandMap {
|
|
239
|
+
wait: {
|
|
240
|
+
params: CommandParams<'wait'>;
|
|
241
|
+
event: WaitProgressData | CommandData<'wait'>;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
export type StreamCommandAction = keyof StreamCommandMap;
|
|
245
|
+
export type StreamCommandParams<Action extends StreamCommandAction> = StreamCommandMap[Action]['params'];
|
|
246
|
+
export type StreamCommandEvent<Action extends StreamCommandAction> = StreamCommandMap[Action]['event'];
|
|
247
|
+
export interface CommandClient {
|
|
248
|
+
execute<Action extends CommandAction>(action: Action, params: CommandParams<Action>, options?: {
|
|
249
|
+
timeoutMs?: number;
|
|
250
|
+
}): Promise<CommandResult<CommandData<Action>>>;
|
|
251
|
+
stream<Action extends StreamCommandAction>(action: Action, params: StreamCommandParams<Action>, options?: {
|
|
252
|
+
signal?: AbortSignal;
|
|
253
|
+
method?: 'GET' | 'POST';
|
|
254
|
+
}): AsyncGenerator<CommandResult<StreamCommandEvent<Action>>>;
|
|
255
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Connector } from '../index.ts';
|
|
2
|
+
import type { CommandAction, CommandData, CommandObject, StreamCommandEvent } from './contract.ts';
|
|
3
|
+
import { type ReactLynxCacheSnapshot } from './reactlynx/controller.ts';
|
|
4
|
+
import { type CommandResult } from './result.ts';
|
|
5
|
+
import { type Box, type SnapshotRef } from './snapshot.ts';
|
|
6
|
+
interface SnapshotEntry {
|
|
7
|
+
createdAt: number;
|
|
8
|
+
viewport: Box | undefined;
|
|
9
|
+
refs: SnapshotRef[];
|
|
10
|
+
}
|
|
11
|
+
export interface ActionContext {
|
|
12
|
+
connector: Connector;
|
|
13
|
+
}
|
|
14
|
+
export type ActionHandlerResult<Action extends CommandAction> = CommandResult<CommandData<Action>>;
|
|
15
|
+
/**
|
|
16
|
+
* Daemon-owned action layer. In-memory DOM and ReactLynx caches deliberately
|
|
17
|
+
* live here so refs survive across independent CLI runs.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ActionCore {
|
|
20
|
+
#private;
|
|
21
|
+
constructor();
|
|
22
|
+
has(action: string): boolean;
|
|
23
|
+
/** `wait` is the only phase-one action with progressive SSE events. */
|
|
24
|
+
hasStream(action: string): boolean;
|
|
25
|
+
actions(): string[];
|
|
26
|
+
streamActions(): string[];
|
|
27
|
+
execute(action: string, params: CommandObject, ctx: ActionContext, signal?: AbortSignal): Promise<CommandResult>;
|
|
28
|
+
stream(action: string, params: CommandObject, ctx: ActionContext, signal: AbortSignal): AsyncGenerator<CommandResult<StreamCommandEvent<'wait'>>>;
|
|
29
|
+
getSnapshot(clientId: string, sessionId: number): SnapshotEntry | undefined;
|
|
30
|
+
getReactLynxCache(clientId: string, sessionId: number): ReactLynxCacheSnapshot | undefined;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type { CommandCallOptions, CommandStreamOptions } from './client.ts';
|
|
2
|
+
export { callCommand, callRawCommand, HttpCommandClient, streamCommand, streamRawCommand, } from './client.ts';
|
|
3
|
+
export type { ClientTarget, CommandAction, CommandClient, CommandData, CommandMap, CommandObject, CommandParams, ScreenshotAnnotation, SessionTarget, SnapshotAfterResult, SnapshotData, SnapshotRefreshError, StreamCommandAction, StreamCommandEvent, StreamCommandMap, StreamCommandParams, WaitProgressData, } from './contract.ts';
|
|
4
|
+
export type { ActionContext } from './core.ts';
|
|
5
|
+
export { ActionCore } from './core.ts';
|
|
6
|
+
export type { FormattedReactLynxTree, ReactLynxLinkRef, ReactLynxTreeState, } from './reactlynx/model.ts';
|
|
7
|
+
export { buildReactLynxUpdatePath, buildRegexMatcher, buildSubstringMatcher, deserializeRendererState, findReactLynxComponents, formatReactLynxTree, parseReactLynxComponentRef, parseReactLynxLinkRef, serializeRendererState, } from './reactlynx/model.ts';
|
|
8
|
+
export type { DevNodeType as ReactLynxDevNodeType, ID as ReactLynxID, RendererState, VNode, } from './reactlynx/protocol.ts';
|
|
9
|
+
export { applyOperationV2, applyRootOrder, createRendererState, DevNodeType, typeTag, } from './reactlynx/protocol.ts';
|
|
10
|
+
export type { ReactLynxCacheInfo, ReactLynxComponentData, ReactLynxFindData, ReactLynxFindMatch, ReactLynxInspectResult, ReactLynxLinkData, ReactLynxLinkedComponent, ReactLynxTargetData, ReactLynxTreeData, ReactLynxUpdateKind, } from './reactlynx/types.ts';
|
|
11
|
+
export type { RefFailureReason } from './ref-actions.ts';
|
|
12
|
+
export { normalizeRef, touchTap, validateRef } from './ref-actions.ts';
|
|
13
|
+
export type { CommandError, CommandFailure, CommandResult, CommandSuccess, } from './result.ts';
|
|
14
|
+
export { fail, ok } from './result.ts';
|
|
15
|
+
export type { CapturedScreenshot, CaptureScreenshotOptions, ScreencastFrameMetadata, } from './screenshot.ts';
|
|
16
|
+
export { captureScreenshot, captureScreenshotFrame, ScreenshotTimeoutError, } from './screenshot.ts';
|
|
17
|
+
export type { AnnotatedScreenshot, AnnotateScreenshotOptions, } from './screenshot-annotation.ts';
|
|
18
|
+
export { annotateScreenshot, ScreenshotAnnotationError, } from './screenshot-annotation.ts';
|
|
19
|
+
export type { Box, DomNode, Point, RefFlags, SnapshotRef, SnapshotResult, } from './snapshot.ts';
|
|
20
|
+
export { buildRefs, buildSnapshot, centerOfQuad } from './snapshot.ts';
|