@lingxia/types 0.10.0 → 0.11.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/dist/automation/index.d.ts +942 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +13 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/generated/i18n.d.ts +1 -1
- package/dist/generated/i18n.d.ts.map +1 -1
- package/dist/generated/i18n.js +29 -0
- package/dist/generated/i18n.js.map +1 -1
- package/dist/generated/logic-web.d.ts +305 -0
- package/dist/generated/logic.d.ts +1909 -0
- package/dist/generated/logic.d.ts.map +1 -0
- package/dist/generated/logic.js +5 -0
- package/dist/generated/logic.js.map +1 -0
- package/dist/index.d.ts +16 -313
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -16
- package/dist/index.js.map +1 -1
- package/dist/logic-globals.d.ts +1 -0
- package/dist/process.d.ts +117 -0
- package/dist/process.d.ts.map +1 -0
- package/dist/process.js +10 -0
- package/dist/process.js.map +1 -0
- package/package.json +73 -47
- package/src/automation/index.ts +1074 -0
- package/src/generated/i18n.ts +29 -0
- package/src/generated/logic-web.d.ts +305 -0
- package/src/generated/logic.ts +2123 -0
- package/src/index.ts +18 -459
- package/src/logic-globals.d.ts +1 -0
- package/src/process.ts +135 -0
- package/dist/app/index.d.ts +0 -328
- package/dist/app/index.d.ts.map +0 -1
- package/dist/app/index.js +0 -6
- package/dist/app/index.js.map +0 -1
- package/dist/device/actions.d.ts +0 -7
- package/dist/device/actions.d.ts.map +0 -1
- package/dist/device/actions.js +0 -6
- package/dist/device/actions.js.map +0 -1
- package/dist/device/index.d.ts +0 -5
- package/dist/device/index.d.ts.map +0 -1
- package/dist/device/index.js +0 -21
- package/dist/device/index.js.map +0 -1
- package/dist/device/info.d.ts +0 -16
- package/dist/device/info.d.ts.map +0 -1
- package/dist/device/info.js +0 -6
- package/dist/device/info.js.map +0 -1
- package/dist/device/network.d.ts +0 -12
- package/dist/device/network.d.ts.map +0 -1
- package/dist/device/network.js +0 -6
- package/dist/device/network.js.map +0 -1
- package/dist/device/wifi.d.ts +0 -20
- package/dist/device/wifi.d.ts.map +0 -1
- package/dist/device/wifi.js +0 -6
- package/dist/device/wifi.js.map +0 -1
- package/dist/display/index.d.ts +0 -8
- package/dist/display/index.d.ts.map +0 -1
- package/dist/display/index.js +0 -6
- package/dist/display/index.js.map +0 -1
- package/dist/env/index.d.ts +0 -8
- package/dist/env/index.d.ts.map +0 -1
- package/dist/env/index.js +0 -6
- package/dist/env/index.js.map +0 -1
- package/dist/file/index.d.ts +0 -146
- package/dist/file/index.d.ts.map +0 -1
- package/dist/file/index.js +0 -6
- package/dist/file/index.js.map +0 -1
- package/dist/input/index.d.ts +0 -18
- package/dist/input/index.d.ts.map +0 -1
- package/dist/input/index.js +0 -8
- package/dist/input/index.js.map +0 -1
- package/dist/location/index.d.ts +0 -19
- package/dist/location/index.d.ts.map +0 -1
- package/dist/location/index.js +0 -6
- package/dist/location/index.js.map +0 -1
- package/dist/lxapp/index.d.ts +0 -11
- package/dist/lxapp/index.d.ts.map +0 -1
- package/dist/lxapp/index.js +0 -6
- package/dist/lxapp/index.js.map +0 -1
- package/dist/media/index.d.ts +0 -372
- package/dist/media/index.d.ts.map +0 -1
- package/dist/media/index.js +0 -6
- package/dist/media/index.js.map +0 -1
- package/dist/navigator/index.d.ts +0 -14
- package/dist/navigator/index.d.ts.map +0 -1
- package/dist/navigator/index.js +0 -6
- package/dist/navigator/index.js.map +0 -1
- package/dist/share/index.d.ts +0 -90
- package/dist/share/index.d.ts.map +0 -1
- package/dist/share/index.js +0 -6
- package/dist/share/index.js.map +0 -1
- package/dist/storage/index.d.ts +0 -13
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js +0 -6
- package/dist/storage/index.js.map +0 -1
- package/dist/system/index.d.ts +0 -9
- package/dist/system/index.d.ts.map +0 -1
- package/dist/system/index.js +0 -6
- package/dist/system/index.js.map +0 -1
- package/dist/transfer/index.d.ts +0 -166
- package/dist/transfer/index.d.ts.map +0 -1
- package/dist/transfer/index.js +0 -6
- package/dist/transfer/index.js.map +0 -1
- package/dist/ui/index.d.ts +0 -134
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -6
- package/dist/ui/index.js.map +0 -1
- package/dist/update/index.d.ts +0 -17
- package/dist/update/index.d.ts.map +0 -1
- package/dist/update/index.js +0 -6
- package/dist/update/index.js.map +0 -1
- package/src/app/index.ts +0 -378
- package/src/device/actions.ts +0 -7
- package/src/device/index.ts +0 -4
- package/src/device/info.ts +0 -17
- package/src/device/network.ts +0 -23
- package/src/device/wifi.ts +0 -23
- package/src/display/index.ts +0 -9
- package/src/env/index.ts +0 -8
- package/src/file/index.ts +0 -171
- package/src/input/index.ts +0 -19
- package/src/location/index.ts +0 -20
- package/src/lxapp/index.ts +0 -12
- package/src/media/index.ts +0 -411
- package/src/navigator/index.ts +0 -16
- package/src/share/index.ts +0 -97
- package/src/storage/index.ts +0 -13
- package/src/system/index.ts +0 -9
- package/src/transfer/index.ts +0 -194
- package/src/ui/index.ts +0 -165
- package/src/update/index.ts +0 -19
|
@@ -0,0 +1,1074 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process UI/runtime automation — `lx.automation()`.
|
|
3
|
+
*
|
|
4
|
+
* Returns a stable selector root. Selecting the calling lxapp requires the
|
|
5
|
+
* `automation` security privilege; cross-lxapp and host surfaces require
|
|
6
|
+
* `host`. `lingxia dev` sessions and the Runner grant both implicitly.
|
|
7
|
+
*
|
|
8
|
+
* This mirrors the devtool (`lxdev`) automation surface as a privilege-scoped,
|
|
9
|
+
* product-side API.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ============================ factory ============================
|
|
13
|
+
|
|
14
|
+
/** Stable automation root; it grants no capability until one is selected. */
|
|
15
|
+
export interface Automation {
|
|
16
|
+
/** Drive the calling/current lxapp. Requires `automation` outside dev. */
|
|
17
|
+
lxapp(): LxAppDriver;
|
|
18
|
+
/** Drive a specific running lxapp. Requires `host` outside dev. */
|
|
19
|
+
lxapp(appid: string): LxAppDriver;
|
|
20
|
+
/** Cross-lxapp lifecycle and host-window capture. */
|
|
21
|
+
readonly lxapps: LxAppManager;
|
|
22
|
+
/** The host app's browser tabs. */
|
|
23
|
+
readonly browser: BrowserDriver;
|
|
24
|
+
/** Simulated-device selection in a host runner. */
|
|
25
|
+
readonly device: DeviceDriver;
|
|
26
|
+
/**
|
|
27
|
+
* Session-less local-OS desktop automation (`lxdev desktop`). Beyond the
|
|
28
|
+
* app sandbox, so restricted to dev/test hosts (`lingxia dev` or the
|
|
29
|
+
* Runner) on top of the `host` privilege. Windows/macOS only.
|
|
30
|
+
*/
|
|
31
|
+
readonly desktop: DesktopDriver;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ============================ page tier ============================
|
|
35
|
+
|
|
36
|
+
/** Fields common to every page action; `page` defaults to the current page. */
|
|
37
|
+
export interface PageTarget {
|
|
38
|
+
/** Configured page name (from lxapp.json); defaults to the current page. */
|
|
39
|
+
page?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PageEvalOptions extends PageTarget {
|
|
43
|
+
/** JavaScript expression or function body evaluated in the page WebView. */
|
|
44
|
+
script: string;
|
|
45
|
+
timeoutMs?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PageQueryOptions extends PageTarget {
|
|
49
|
+
/** CSS selector. */
|
|
50
|
+
css: string;
|
|
51
|
+
/** Target the nth match (single-element mode). */
|
|
52
|
+
index?: number;
|
|
53
|
+
/** Return every match as `{ count, items }` instead of a single element. */
|
|
54
|
+
all?: boolean;
|
|
55
|
+
/** Cap text/value length (default 4096). */
|
|
56
|
+
maxText?: number;
|
|
57
|
+
/** Return untruncated text/value (ignores `maxText`). */
|
|
58
|
+
full?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface PageSelectorOptions extends PageTarget {
|
|
62
|
+
css: string;
|
|
63
|
+
/** Target the nth match. */
|
|
64
|
+
index?: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface PageTypeOptions extends PageSelectorOptions {
|
|
68
|
+
text: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface PagePressOptions extends PageTarget {
|
|
72
|
+
/** Key name, e.g. `Enter`, `Escape`, `Tab`. */
|
|
73
|
+
key: string;
|
|
74
|
+
/** Focus this CSS selector before pressing; otherwise use the current focus. */
|
|
75
|
+
css?: string;
|
|
76
|
+
/** Target the nth selector match. Requires `css`. */
|
|
77
|
+
index?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface PageScrollOptions extends PageTarget {
|
|
81
|
+
/** Horizontal delta in CSS pixels. */
|
|
82
|
+
dx?: number;
|
|
83
|
+
/** Vertical delta in CSS pixels (positive scrolls down). */
|
|
84
|
+
dy?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface PageScrollToOptions extends PageTarget {
|
|
88
|
+
/** CSS selector of the element to reveal (first match). */
|
|
89
|
+
css: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type PageWaitState = 'exists' | 'visible' | 'gone';
|
|
93
|
+
|
|
94
|
+
export interface PageWaitForOptions extends PageTarget {
|
|
95
|
+
css: string;
|
|
96
|
+
/** Condition to await (default `visible`). */
|
|
97
|
+
state?: PageWaitState;
|
|
98
|
+
/** Timeout in ms (default 10000, capped at 60000). */
|
|
99
|
+
timeoutMs?: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** An element's viewport rectangle (viewport-relative CSS pixels). */
|
|
103
|
+
export interface ElementRect {
|
|
104
|
+
left: number;
|
|
105
|
+
top: number;
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
right: number;
|
|
109
|
+
bottom: number;
|
|
110
|
+
center_x: number;
|
|
111
|
+
center_y: number;
|
|
112
|
+
viewport_width: number;
|
|
113
|
+
viewport_height: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** A matched element. Keys are the raw automation payload (snake_case). */
|
|
117
|
+
export interface PageElement {
|
|
118
|
+
exists: true;
|
|
119
|
+
index: number;
|
|
120
|
+
/** Total number of matches for the selector. */
|
|
121
|
+
count: number;
|
|
122
|
+
tag: string;
|
|
123
|
+
/** `<input>` type, else null. */
|
|
124
|
+
type: string | null;
|
|
125
|
+
id: string | null;
|
|
126
|
+
name: string | null;
|
|
127
|
+
role: string | null;
|
|
128
|
+
aria_label: string | null;
|
|
129
|
+
placeholder: string | null;
|
|
130
|
+
/** Viewport-aware visibility (size, style, and in-viewport). */
|
|
131
|
+
visible: boolean;
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
editable: boolean;
|
|
134
|
+
text: string;
|
|
135
|
+
text_truncated: boolean;
|
|
136
|
+
value: string | null;
|
|
137
|
+
value_truncated: boolean;
|
|
138
|
+
rect: ElementRect;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Returned when no element matches (single-element mode). */
|
|
142
|
+
export interface PageElementMiss {
|
|
143
|
+
exists: false;
|
|
144
|
+
index: number;
|
|
145
|
+
count: number;
|
|
146
|
+
visible: false;
|
|
147
|
+
enabled: false;
|
|
148
|
+
editable: false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export type PageQueryResult = PageElement | PageElementMiss;
|
|
152
|
+
|
|
153
|
+
/** Returned by `query` when `all: true`. */
|
|
154
|
+
export interface PageQueryAll {
|
|
155
|
+
count: number;
|
|
156
|
+
items: PageElement[];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface Screenshot {
|
|
160
|
+
format: 'png';
|
|
161
|
+
/** Base64-encoded PNG bytes. */
|
|
162
|
+
base64: string;
|
|
163
|
+
width: number;
|
|
164
|
+
height: number;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Element-level automation of the selected lxapp's page WebViews. */
|
|
168
|
+
export interface PageDriver {
|
|
169
|
+
/** Evaluate JavaScript in the page WebView; resolves to the returned value. */
|
|
170
|
+
eval(options: PageEvalOptions): Promise<unknown>;
|
|
171
|
+
/** Query one element's info. */
|
|
172
|
+
query(options: PageQueryOptions & { all?: false }): Promise<PageQueryResult>;
|
|
173
|
+
/** Query every matching element. */
|
|
174
|
+
query(options: PageQueryOptions & { all: true }): Promise<PageQueryAll>;
|
|
175
|
+
click(options: PageSelectorOptions): Promise<void>;
|
|
176
|
+
/** Type text into an element without clearing existing content. */
|
|
177
|
+
type(options: PageTypeOptions): Promise<void>;
|
|
178
|
+
/** Replace an element's current value. */
|
|
179
|
+
fill(options: PageTypeOptions): Promise<void>;
|
|
180
|
+
press(options: PagePressOptions): Promise<void>;
|
|
181
|
+
/** Scroll the first matching element into view. */
|
|
182
|
+
scrollTo(options: PageScrollToOptions): Promise<void>;
|
|
183
|
+
/** Scroll the page DOM by a pixel delta (nearest scrollable container). */
|
|
184
|
+
scroll(options?: PageScrollOptions): Promise<void>;
|
|
185
|
+
/** Poll until the selector reaches `state`, else reject on timeout. */
|
|
186
|
+
waitFor(options: PageWaitForOptions): Promise<void>;
|
|
187
|
+
screenshot(options?: PageTarget): Promise<Screenshot>;
|
|
188
|
+
/** App-window pointer input at page coordinates (`lxdev lxapp page pointer`). */
|
|
189
|
+
readonly pointer: PagePointer;
|
|
190
|
+
/** App-window keyboard input (`lxdev lxapp page key`). */
|
|
191
|
+
readonly key: PageKey;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ============================ nav tier ============================
|
|
195
|
+
|
|
196
|
+
export interface NavOptions {
|
|
197
|
+
/** Configured page name (from lxapp.json). */
|
|
198
|
+
page: string;
|
|
199
|
+
/** Query forwarded to the destination page. */
|
|
200
|
+
query?: Record<string, unknown>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface NavBackOptions {
|
|
204
|
+
/** Number of pages to pop (default 1). */
|
|
205
|
+
delta?: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** A page's runtime position. */
|
|
209
|
+
export interface PageInfo {
|
|
210
|
+
path: string;
|
|
211
|
+
/** Configured page name, if the path maps to one. */
|
|
212
|
+
name: string | null;
|
|
213
|
+
current: boolean;
|
|
214
|
+
inStack: boolean;
|
|
215
|
+
/** Whether the page has an attached WebView. */
|
|
216
|
+
ready: boolean;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Page-stack navigation for the selected lxapp. Action verbs take a configured
|
|
221
|
+
* page name (`redirect` rejects a tab-bar page); `back` pops; `current`/`stack`
|
|
222
|
+
* read. Unlike the JS `lx.navigateTo` family this returns the landed page, but
|
|
223
|
+
* like it does not wait for the destination WebView (awaiting in-process would
|
|
224
|
+
* deadlock the logic thread).
|
|
225
|
+
*/
|
|
226
|
+
export interface NavDriver {
|
|
227
|
+
/** Push a page onto the stack. */
|
|
228
|
+
to(options: NavOptions): Promise<PageInfo>;
|
|
229
|
+
/** Replace the current page (rejects tab-bar targets). */
|
|
230
|
+
redirect(options: NavOptions): Promise<PageInfo>;
|
|
231
|
+
/** Switch to a configured tab page. */
|
|
232
|
+
switchTab(options: NavOptions): Promise<PageInfo>;
|
|
233
|
+
/** Clear the stack and relaunch at a page. */
|
|
234
|
+
relaunch(options: NavOptions): Promise<PageInfo>;
|
|
235
|
+
back(options?: NavBackOptions): Promise<PageInfo>;
|
|
236
|
+
current(): Promise<PageInfo>;
|
|
237
|
+
/** Status of a configured page by name; omit `page` for the current page. */
|
|
238
|
+
info(options?: PageTarget): Promise<PageInfo>;
|
|
239
|
+
stack(): Promise<PageInfo[]>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ============================ lxapp driver ============================
|
|
243
|
+
|
|
244
|
+
export interface LxAppSummary {
|
|
245
|
+
appid: string;
|
|
246
|
+
currentPage: string | null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface LxAppPageConfig {
|
|
250
|
+
name: string;
|
|
251
|
+
path: string;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface LxAppEvalOptions {
|
|
255
|
+
/** JavaScript expression or function body run in the selected Logic runtime. */
|
|
256
|
+
script: string;
|
|
257
|
+
timeoutMs?: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Capability for one selected running lxapp. */
|
|
261
|
+
export interface LxAppDriver {
|
|
262
|
+
readonly page: PageDriver;
|
|
263
|
+
readonly nav: NavDriver;
|
|
264
|
+
/** Complete runtime snapshot of the selected lxapp. */
|
|
265
|
+
info(): Promise<LxAppRuntimeInfo>;
|
|
266
|
+
/** Configured pages of the selected lxapp. */
|
|
267
|
+
pages(): Promise<LxAppPageConfig[]>;
|
|
268
|
+
/** Logic-runtime eval; self-eval from that Logic runtime is rejected. */
|
|
269
|
+
eval(options: LxAppEvalOptions): Promise<unknown>;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ======================= lxapp manager (host) =======================
|
|
273
|
+
|
|
274
|
+
/** One configured page in a runtime info payload. */
|
|
275
|
+
export interface LxAppPageEntry {
|
|
276
|
+
name: string;
|
|
277
|
+
path: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Runtime snapshot of a running lxapp (raw payload, snake_case keys). */
|
|
281
|
+
export interface LxAppRuntimeInfo {
|
|
282
|
+
appid: string;
|
|
283
|
+
app_name: string;
|
|
284
|
+
version: string;
|
|
285
|
+
release_type: string;
|
|
286
|
+
session_id: number;
|
|
287
|
+
status: string;
|
|
288
|
+
is_home: boolean;
|
|
289
|
+
current_page: string | null;
|
|
290
|
+
initial_route: string;
|
|
291
|
+
pages_count: number;
|
|
292
|
+
page_entries: LxAppPageEntry[];
|
|
293
|
+
page_stack: string[];
|
|
294
|
+
lxapp_dir: string;
|
|
295
|
+
data_dir: string;
|
|
296
|
+
cache_dir: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** Selects a running lxapp by id; defaults to the current app. */
|
|
300
|
+
export interface LxAppRef {
|
|
301
|
+
/** LxApp id, or `"current"` (default). */
|
|
302
|
+
app?: string;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface LxAppOpenOptions {
|
|
306
|
+
appid: string;
|
|
307
|
+
/** Initial page/path. */
|
|
308
|
+
path?: string;
|
|
309
|
+
releaseType?: 'release' | 'preview' | 'developer';
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface LxAppOpenResult {
|
|
313
|
+
appid: string;
|
|
314
|
+
path: string;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Cross-lxapp lifecycle and host-window access. Requires `host` outside dev.
|
|
319
|
+
*
|
|
320
|
+
* `close`, `restart`, and `uninstall` reject when they target the calling app
|
|
321
|
+
* itself. Use `lx.app.exit()` to self-exit.
|
|
322
|
+
*/
|
|
323
|
+
export interface LxAppManager {
|
|
324
|
+
list(): Promise<LxAppRuntimeInfo[]>;
|
|
325
|
+
current(): Promise<LxAppSummary>;
|
|
326
|
+
open(options: LxAppOpenOptions): Promise<LxAppOpenResult>;
|
|
327
|
+
close(options?: LxAppRef): Promise<void>;
|
|
328
|
+
restart(options?: LxAppRef): Promise<void>;
|
|
329
|
+
uninstall(options?: LxAppRef): Promise<void>;
|
|
330
|
+
/** Enumerate the host app's top-level windows (`lxdev lxapp windows`). */
|
|
331
|
+
windows(): Promise<AppWindowInfo[]>;
|
|
332
|
+
/** PNG of a host app window (`lxdev lxapp screenshot`); defaults to the
|
|
333
|
+
* session's focused/main window. */
|
|
334
|
+
screenshot(options?: WindowRef): Promise<Screenshot>;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// ======================= device (host) =======================
|
|
338
|
+
|
|
339
|
+
/** A device preset the runner can simulate (raw payload, snake_case-free). */
|
|
340
|
+
export interface DeviceEntry {
|
|
341
|
+
id: string;
|
|
342
|
+
name: string;
|
|
343
|
+
/** Form-factor group: `phone` | `tablet` | `desktop`. */
|
|
344
|
+
group: string;
|
|
345
|
+
/** Logical width in points. */
|
|
346
|
+
width: number;
|
|
347
|
+
/** Logical height in points. */
|
|
348
|
+
height: number;
|
|
349
|
+
/** True for the currently selected device. */
|
|
350
|
+
current: boolean;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** The active device selection. */
|
|
354
|
+
export interface DeviceState {
|
|
355
|
+
id: string;
|
|
356
|
+
name: string;
|
|
357
|
+
group: string;
|
|
358
|
+
/** Logical width in points (accounts for orientation). */
|
|
359
|
+
width: number;
|
|
360
|
+
height: number;
|
|
361
|
+
/** True when rotated to landscape. */
|
|
362
|
+
landscape: boolean;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export interface DeviceSetOptions {
|
|
366
|
+
/** Device preset id (see `list()`). */
|
|
367
|
+
id: string;
|
|
368
|
+
/** Force landscape (`true`) or portrait (`false`); omit to use the
|
|
369
|
+
* runner's normal device-selection behavior. */
|
|
370
|
+
landscape?: boolean;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Simulated-device control (`lxdev lxapp device`). Only functional in a host
|
|
375
|
+
* runner that registered a device controller; otherwise every call rejects.
|
|
376
|
+
*/
|
|
377
|
+
export interface DeviceDriver {
|
|
378
|
+
list(): Promise<DeviceEntry[]>;
|
|
379
|
+
get(): Promise<DeviceState>;
|
|
380
|
+
set(options: DeviceSetOptions): Promise<DeviceState>;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// ======================= browser (host) =======================
|
|
384
|
+
|
|
385
|
+
/** Selects a browser tab by id; defaults to the current tab. */
|
|
386
|
+
export interface BrowserTabRef {
|
|
387
|
+
/** Tab id, or `"current"` (default). */
|
|
388
|
+
tab?: string;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export interface BrowserOpenOptions {
|
|
392
|
+
url: string;
|
|
393
|
+
/** Reuse an existing tab id instead of opening a new one. */
|
|
394
|
+
tab?: string;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface BrowserEvalOptions extends BrowserTabRef {
|
|
398
|
+
js: string;
|
|
399
|
+
/** After the eval, wait for a navigation it triggers. */
|
|
400
|
+
waitNavigation?: boolean;
|
|
401
|
+
/** With `waitNavigation`: wait until the load completes. */
|
|
402
|
+
complete?: boolean;
|
|
403
|
+
timeoutMs?: number;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
export interface BrowserQueryOptions extends BrowserTabRef {
|
|
407
|
+
css: string;
|
|
408
|
+
maxText?: number;
|
|
409
|
+
/** Return untruncated text/value (ignores `maxText`). */
|
|
410
|
+
full?: boolean;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export interface BrowserSelectorOptions extends BrowserTabRef {
|
|
414
|
+
css: string;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/** `click` / `press` also carry the navigation-sync flags. */
|
|
418
|
+
export interface BrowserClickOptions extends BrowserTabRef {
|
|
419
|
+
css: string;
|
|
420
|
+
/** After the click, wait for a navigation it triggers. */
|
|
421
|
+
waitNavigation?: boolean;
|
|
422
|
+
complete?: boolean;
|
|
423
|
+
timeoutMs?: number;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
export interface BrowserTypeOptions extends BrowserSelectorOptions {
|
|
427
|
+
text: string;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export interface BrowserPressOptions extends BrowserTabRef {
|
|
431
|
+
key: string;
|
|
432
|
+
/** After the press, wait for a navigation it triggers. */
|
|
433
|
+
waitNavigation?: boolean;
|
|
434
|
+
complete?: boolean;
|
|
435
|
+
timeoutMs?: number;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export interface BrowserScrollOptions extends BrowserTabRef {
|
|
439
|
+
dx?: number;
|
|
440
|
+
dy?: number;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* A browser wait condition — pass **exactly one** of the condition fields.
|
|
445
|
+
* `navigation` may add `complete` to wait for load completion.
|
|
446
|
+
*/
|
|
447
|
+
export interface BrowserWaitOptions extends BrowserTabRef {
|
|
448
|
+
/** Wait for page load. */
|
|
449
|
+
loaded?: boolean;
|
|
450
|
+
/** Wait for a selector to exist. */
|
|
451
|
+
exists?: string;
|
|
452
|
+
/** Wait for a selector to be visible. */
|
|
453
|
+
visible?: string;
|
|
454
|
+
/** Wait for a selector to be hidden. */
|
|
455
|
+
hidden?: string;
|
|
456
|
+
/** Wait for a selector to be editable. */
|
|
457
|
+
editable?: string;
|
|
458
|
+
/** Wait until a JS expression is truthy. */
|
|
459
|
+
js?: string;
|
|
460
|
+
/** Wait for the URL to equal this. */
|
|
461
|
+
url?: string;
|
|
462
|
+
/** Wait for the URL to contain this. */
|
|
463
|
+
urlContains?: string;
|
|
464
|
+
/** Wait for a navigation. */
|
|
465
|
+
navigation?: boolean;
|
|
466
|
+
/** With `navigation`: baseline URL to detect a change from (default: any
|
|
467
|
+
* navigation satisfies it). */
|
|
468
|
+
fromUrl?: string;
|
|
469
|
+
/** With `navigation`: wait until the load completes. */
|
|
470
|
+
complete?: boolean;
|
|
471
|
+
/** Timeout in ms (default 10000, capped at 60000). */
|
|
472
|
+
timeoutMs?: number;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export interface BrowserTab {
|
|
476
|
+
tab_id: string;
|
|
477
|
+
path: string;
|
|
478
|
+
session_id: number;
|
|
479
|
+
current_url?: string;
|
|
480
|
+
title?: string;
|
|
481
|
+
can_go_back: boolean;
|
|
482
|
+
can_go_forward: boolean;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface BrowserOpenResult {
|
|
486
|
+
tab: string;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
export type CookieSameSite = 'Lax' | 'Strict' | 'None';
|
|
490
|
+
|
|
491
|
+
export interface CookieSetOptions extends BrowserTabRef {
|
|
492
|
+
name: string;
|
|
493
|
+
value: string;
|
|
494
|
+
url?: string;
|
|
495
|
+
domain?: string;
|
|
496
|
+
/** Cookie path (default `/`). */
|
|
497
|
+
path?: string;
|
|
498
|
+
secure?: boolean;
|
|
499
|
+
httpOnly?: boolean;
|
|
500
|
+
expiresUnixMs?: number;
|
|
501
|
+
sameSite?: CookieSameSite;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface CookieDeleteOptions extends BrowserTabRef {
|
|
505
|
+
name: string;
|
|
506
|
+
domain: string;
|
|
507
|
+
/** Cookie path (default `/`). */
|
|
508
|
+
path?: string;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export interface CookieListOptions extends BrowserTabRef {
|
|
512
|
+
/** List cookies for every domain, not just the tab's URL. */
|
|
513
|
+
all?: boolean;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** A cookie from the WebView store (raw payload, snake_case keys). */
|
|
517
|
+
export interface BrowserCookie {
|
|
518
|
+
name: string;
|
|
519
|
+
value: string;
|
|
520
|
+
domain: string;
|
|
521
|
+
path: string;
|
|
522
|
+
host_only?: boolean;
|
|
523
|
+
secure: boolean;
|
|
524
|
+
http_only: boolean;
|
|
525
|
+
session: boolean;
|
|
526
|
+
expires_unix_ms?: number;
|
|
527
|
+
same_site?: CookieSameSite;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
export interface BrowserCookies {
|
|
531
|
+
list(options?: CookieListOptions): Promise<BrowserCookie[]>;
|
|
532
|
+
set(options: CookieSetOptions): Promise<void>;
|
|
533
|
+
delete(options: CookieDeleteOptions): Promise<void>;
|
|
534
|
+
clear(options?: BrowserTabRef): Promise<void>;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/** The host app's browser tabs (Playwright-like WebView automation). */
|
|
538
|
+
export interface BrowserDriver {
|
|
539
|
+
open(options: BrowserOpenOptions): Promise<BrowserOpenResult>;
|
|
540
|
+
tabs(): Promise<BrowserTab[]>;
|
|
541
|
+
current(): Promise<BrowserTab | null>;
|
|
542
|
+
activate(options?: BrowserTabRef): Promise<BrowserTab>;
|
|
543
|
+
close(options?: BrowserTabRef): Promise<void>;
|
|
544
|
+
reload(options?: BrowserTabRef): Promise<void>;
|
|
545
|
+
back(options?: BrowserTabRef): Promise<void>;
|
|
546
|
+
forward(options?: BrowserTabRef): Promise<void>;
|
|
547
|
+
/** Evaluate JS; with `waitNavigation` resolves to `{ value, navigation }`. */
|
|
548
|
+
eval(options: BrowserEvalOptions): Promise<unknown>;
|
|
549
|
+
query(options: BrowserQueryOptions): Promise<PageElement | PageElementMiss>;
|
|
550
|
+
/** Wait for a condition (pass exactly one condition field). */
|
|
551
|
+
wait(options: BrowserWaitOptions): Promise<unknown>;
|
|
552
|
+
/** Click; with `waitNavigation` resolves to the navigation payload else `null`. */
|
|
553
|
+
click(options: BrowserClickOptions): Promise<unknown>;
|
|
554
|
+
type(options: BrowserTypeOptions): Promise<void>;
|
|
555
|
+
fill(options: BrowserTypeOptions): Promise<void>;
|
|
556
|
+
/** Press; with `waitNavigation` resolves to the navigation payload else `null`. */
|
|
557
|
+
press(options: BrowserPressOptions): Promise<unknown>;
|
|
558
|
+
scroll(options: BrowserScrollOptions): Promise<void>;
|
|
559
|
+
scrollTo(options: BrowserSelectorOptions): Promise<void>;
|
|
560
|
+
screenshot(options?: BrowserTabRef): Promise<Screenshot>;
|
|
561
|
+
readonly cookies: BrowserCookies;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
// ======================= page input (app window) =======================
|
|
565
|
+
|
|
566
|
+
/** Targets a host window; defaults to the session's focused/main window. */
|
|
567
|
+
export interface WindowRef {
|
|
568
|
+
/** Window id from `lxapp.windows()`. */
|
|
569
|
+
window?: string;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export interface AppWindowInfo {
|
|
573
|
+
id: string;
|
|
574
|
+
title?: string;
|
|
575
|
+
width?: number;
|
|
576
|
+
height?: number;
|
|
577
|
+
focused?: boolean;
|
|
578
|
+
main?: boolean;
|
|
579
|
+
visible?: boolean;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/** Result of a dispatched input action. */
|
|
583
|
+
export interface InputResult {
|
|
584
|
+
window_id: string;
|
|
585
|
+
/** The action kind that was dispatched. */
|
|
586
|
+
action: string;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
export type MouseButton = 'left' | 'right' | 'middle';
|
|
590
|
+
|
|
591
|
+
/** A coordinate as `[x, y]` (the `--at X,Y` flag form). */
|
|
592
|
+
export type Point = [number, number];
|
|
593
|
+
|
|
594
|
+
export interface PointerAtOptions extends WindowRef {
|
|
595
|
+
/** Target coordinate in page (CSS) pixels. */
|
|
596
|
+
at: Point;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
export interface PointerButtonOptions extends PointerAtOptions {
|
|
600
|
+
button?: MouseButton;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
export interface PointerClickOptions extends PointerButtonOptions {
|
|
604
|
+
/** Number of clicks to report in the event (default 1). */
|
|
605
|
+
count?: number;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export interface PointerDragOptions extends WindowRef {
|
|
609
|
+
from: Point;
|
|
610
|
+
to: Point;
|
|
611
|
+
button?: MouseButton;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export interface PointerScrollOptions extends PointerAtOptions {
|
|
615
|
+
/** Horizontal scroll delta in page pixels. */
|
|
616
|
+
dx?: number;
|
|
617
|
+
/** Vertical scroll delta in page pixels. */
|
|
618
|
+
dy?: number;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/** App-window pointer input at page coordinates (`lxdev lxapp page pointer`). */
|
|
622
|
+
export interface PagePointer {
|
|
623
|
+
move(options: PointerAtOptions): Promise<InputResult>;
|
|
624
|
+
down(options: PointerButtonOptions): Promise<InputResult>;
|
|
625
|
+
up(options: PointerButtonOptions): Promise<InputResult>;
|
|
626
|
+
click(options: PointerClickOptions): Promise<InputResult>;
|
|
627
|
+
drag(options: PointerDragOptions): Promise<InputResult>;
|
|
628
|
+
scroll(options: PointerScrollOptions): Promise<InputResult>;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** Canonical cross-platform modifier vocabulary; `meta` maps to the platform
|
|
632
|
+
* meta key (Command on macOS, Windows key on Windows). */
|
|
633
|
+
export type KeyModifier = 'ctrl' | 'shift' | 'alt' | 'meta';
|
|
634
|
+
|
|
635
|
+
export interface KeyTypeOptions extends WindowRef {
|
|
636
|
+
text: string;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export interface KeyPressOptions extends WindowRef {
|
|
640
|
+
/** Key name: `return`, `tab`, `escape`, `delete`, `space`, arrows. */
|
|
641
|
+
key: string;
|
|
642
|
+
modifiers?: KeyModifier[];
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/** App-window keyboard input to the focused control (`lxdev lxapp page key`). */
|
|
646
|
+
export interface PageKey {
|
|
647
|
+
type(options: KeyTypeOptions): Promise<InputResult>;
|
|
648
|
+
press(options: KeyPressOptions): Promise<InputResult>;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// ======================= desktop (host, dev/test only) =======================
|
|
652
|
+
|
|
653
|
+
/** A rectangle in backend-native global desktop coordinates. */
|
|
654
|
+
export interface DesktopRect {
|
|
655
|
+
x: number;
|
|
656
|
+
y: number;
|
|
657
|
+
w: number;
|
|
658
|
+
h: number;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/** A monitor/display (raw contract payload, snake_case keys). */
|
|
662
|
+
export interface DesktopDisplay {
|
|
663
|
+
id: string;
|
|
664
|
+
primary: boolean;
|
|
665
|
+
bounds: DesktopRect;
|
|
666
|
+
work_area: DesktopRect;
|
|
667
|
+
scale: number;
|
|
668
|
+
dpi: number;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** A top-level OS window (raw contract payload, snake_case keys). */
|
|
672
|
+
export interface DesktopWindowInfo {
|
|
673
|
+
id: string;
|
|
674
|
+
title: string;
|
|
675
|
+
process: string;
|
|
676
|
+
pid: number;
|
|
677
|
+
bounds: DesktopRect;
|
|
678
|
+
display_id: string;
|
|
679
|
+
scale: number;
|
|
680
|
+
dpi: number;
|
|
681
|
+
visible: boolean;
|
|
682
|
+
focused: boolean;
|
|
683
|
+
minimized: boolean;
|
|
684
|
+
maximized: boolean;
|
|
685
|
+
always_on_top: boolean;
|
|
686
|
+
/** Front-to-back z index (0 = frontmost). */
|
|
687
|
+
z: number;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/** Generic acknowledgement for input/mutation commands. */
|
|
691
|
+
export interface DesktopAck {
|
|
692
|
+
ok: boolean;
|
|
693
|
+
action: string;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export interface DesktopPermissions {
|
|
697
|
+
accessibility: boolean;
|
|
698
|
+
screen_recording: boolean;
|
|
699
|
+
input: boolean;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export interface DesktopCapabilities {
|
|
703
|
+
displays: boolean;
|
|
704
|
+
windows: boolean;
|
|
705
|
+
screenshot: boolean;
|
|
706
|
+
window_screenshot_occlusion_independent: boolean;
|
|
707
|
+
pixel: boolean;
|
|
708
|
+
pointer: boolean;
|
|
709
|
+
key: boolean;
|
|
710
|
+
window_management: boolean;
|
|
711
|
+
clipboard: boolean;
|
|
712
|
+
ax_tree: boolean;
|
|
713
|
+
ocr: boolean;
|
|
714
|
+
image_match: boolean;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
export interface DesktopDoctor {
|
|
718
|
+
backend: string;
|
|
719
|
+
os: string;
|
|
720
|
+
os_version: string;
|
|
721
|
+
capabilities: DesktopCapabilities;
|
|
722
|
+
permissions: DesktopPermissions;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
export interface DesktopPixel {
|
|
726
|
+
x: number;
|
|
727
|
+
y: number;
|
|
728
|
+
hex: string;
|
|
729
|
+
r: number;
|
|
730
|
+
g: number;
|
|
731
|
+
b: number;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export interface DesktopCapture extends Screenshot {
|
|
735
|
+
/** True when the capture ignored occlusion (window PrintWindow path). */
|
|
736
|
+
occlusionIndependent: boolean;
|
|
737
|
+
backend: string;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
export interface DesktopClipboardContent {
|
|
741
|
+
available_formats: string[];
|
|
742
|
+
text: string | null;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/** A node in the native accessibility tree. */
|
|
746
|
+
export interface DesktopAxNode {
|
|
747
|
+
id: string;
|
|
748
|
+
role: string;
|
|
749
|
+
name: string;
|
|
750
|
+
value?: string;
|
|
751
|
+
enabled: boolean;
|
|
752
|
+
focused: boolean;
|
|
753
|
+
rect: DesktopRect;
|
|
754
|
+
children?: DesktopAxNode[];
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
export interface DesktopProcessInfo {
|
|
758
|
+
pid: number;
|
|
759
|
+
name: string;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
export interface DesktopSnapshotOptions {
|
|
763
|
+
/** Window id from `windows()`. */
|
|
764
|
+
window: string;
|
|
765
|
+
/** Skip the accessibility tree. */
|
|
766
|
+
noAx?: boolean;
|
|
767
|
+
/** Limit ax tree depth. */
|
|
768
|
+
depth?: number;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
export interface DesktopSnapshot {
|
|
772
|
+
window: DesktopWindowInfo;
|
|
773
|
+
/** PNG capture, or `null` when unavailable. */
|
|
774
|
+
screenshot: (Screenshot & { occlusionIndependent: boolean }) | null;
|
|
775
|
+
/** AX tree, `null` when `noAx` or unavailable. */
|
|
776
|
+
ax: DesktopAxNode | null;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
export interface DesktopLaunchResult {
|
|
780
|
+
/** Durable target pid — prefer this for follow-up quit/kill. */
|
|
781
|
+
pid: number;
|
|
782
|
+
launcher_pid: number;
|
|
783
|
+
window?: DesktopWindowInfo;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Selects a desktop window: exactly one of `window` (id from `windows()`) or
|
|
788
|
+
* `match` (query `text | title: | class: | process: | pid:`, must resolve to
|
|
789
|
+
* exactly one window).
|
|
790
|
+
*/
|
|
791
|
+
export interface DesktopWindowSel {
|
|
792
|
+
window?: string;
|
|
793
|
+
match?: string;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
export interface DesktopWindowsOptions {
|
|
797
|
+
/** Match query (`text | title: | class: | process: | pid:`). */
|
|
798
|
+
match?: string;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/** Capture target — at most one of `display` / `window` / `region`;
|
|
802
|
+
* omit all to capture the whole virtual screen. */
|
|
803
|
+
export interface DesktopScreenshotOptions {
|
|
804
|
+
/** Monitor by 1-based index (as listed by `displays()`). */
|
|
805
|
+
display?: number;
|
|
806
|
+
/** Window by id (occlusion-independent capture). */
|
|
807
|
+
window?: string;
|
|
808
|
+
/** Region as `[x, y, w, h]` in desktop coordinates. */
|
|
809
|
+
region?: [number, number, number, number];
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
export interface DesktopAtOptions {
|
|
813
|
+
/** Coordinate in backend-native desktop pixels. */
|
|
814
|
+
at: Point;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/** Optional background-input target: a `window` id (resolved to its owning
|
|
818
|
+
* process) or an explicit `pid`. Omit both for foreground input. */
|
|
819
|
+
export interface DesktopInputTarget {
|
|
820
|
+
window?: string;
|
|
821
|
+
pid?: number;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
export interface DesktopPointerAtOptions extends DesktopInputTarget {
|
|
825
|
+
at: Point;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export interface DesktopPointerButtonOptions extends DesktopPointerAtOptions {
|
|
829
|
+
button?: MouseButton;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
export interface DesktopPointerClickOptions extends DesktopPointerButtonOptions {
|
|
833
|
+
count?: number;
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
export interface DesktopPointerDragOptions extends DesktopInputTarget {
|
|
837
|
+
from: Point;
|
|
838
|
+
to: Point;
|
|
839
|
+
button?: MouseButton;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
export interface DesktopPointerScrollOptions extends DesktopPointerAtOptions {
|
|
843
|
+
/** Horizontal scroll delta in notches. */
|
|
844
|
+
dx?: number;
|
|
845
|
+
/** Vertical scroll delta in notches. */
|
|
846
|
+
dy?: number;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/** Synthetic physical mouse input at desktop coordinates. */
|
|
850
|
+
export interface DesktopPointer {
|
|
851
|
+
move(options: DesktopPointerAtOptions): Promise<DesktopAck>;
|
|
852
|
+
down(options: DesktopPointerButtonOptions): Promise<DesktopAck>;
|
|
853
|
+
up(options: DesktopPointerButtonOptions): Promise<DesktopAck>;
|
|
854
|
+
click(options: DesktopPointerClickOptions): Promise<DesktopAck>;
|
|
855
|
+
drag(options: DesktopPointerDragOptions): Promise<DesktopAck>;
|
|
856
|
+
scroll(options: DesktopPointerScrollOptions): Promise<DesktopAck>;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export interface DesktopKeyTypeOptions extends DesktopInputTarget {
|
|
860
|
+
text: string;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
export interface DesktopKeyPressOptions extends DesktopInputTarget {
|
|
864
|
+
key: string;
|
|
865
|
+
modifiers?: KeyModifier[];
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
export interface DesktopKeyNameOptions extends DesktopInputTarget {
|
|
869
|
+
key: string;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/** Synthetic physical keyboard input. */
|
|
873
|
+
export interface DesktopKey {
|
|
874
|
+
/** Type literal text into the focused control. */
|
|
875
|
+
type(options: DesktopKeyTypeOptions): Promise<DesktopAck>;
|
|
876
|
+
press(options: DesktopKeyPressOptions): Promise<DesktopAck>;
|
|
877
|
+
down(options: DesktopKeyNameOptions): Promise<DesktopAck>;
|
|
878
|
+
up(options: DesktopKeyNameOptions): Promise<DesktopAck>;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
export interface DesktopWindowMoveOptions extends DesktopWindowSel {
|
|
882
|
+
/** Target position as `[x, y]` in desktop coordinates. */
|
|
883
|
+
to: Point;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
export interface DesktopWindowResizeOptions extends DesktopWindowSel {
|
|
887
|
+
width: number;
|
|
888
|
+
height: number;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
export interface DesktopWindowMoveDisplayOptions extends DesktopWindowSel {
|
|
892
|
+
/** Display id from `displays()`. */
|
|
893
|
+
display: string;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
export interface DesktopWindowAlwaysOnTopOptions extends DesktopWindowSel {
|
|
897
|
+
on: boolean;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
/** Window management; every verb resolves to the resulting window state. */
|
|
901
|
+
export interface DesktopWindowDriver {
|
|
902
|
+
status(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
903
|
+
focus(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
904
|
+
activate(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
905
|
+
raise(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
906
|
+
minimize(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
907
|
+
maximize(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
908
|
+
restore(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
909
|
+
/** Close a window. Destructive. */
|
|
910
|
+
close(options: DesktopWindowSel): Promise<DesktopWindowInfo>;
|
|
911
|
+
moveTo(options: DesktopWindowMoveOptions): Promise<DesktopWindowInfo>;
|
|
912
|
+
moveToDisplay(options: DesktopWindowMoveDisplayOptions): Promise<DesktopWindowInfo>;
|
|
913
|
+
resize(options: DesktopWindowResizeOptions): Promise<DesktopWindowInfo>;
|
|
914
|
+
setAlwaysOnTop(options: DesktopWindowAlwaysOnTopOptions): Promise<DesktopWindowInfo>;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
export interface DesktopClipboardSetOptions {
|
|
918
|
+
text: string;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/** System clipboard access (Unicode text). */
|
|
922
|
+
export interface DesktopClipboard {
|
|
923
|
+
get(): Promise<DesktopClipboardContent>;
|
|
924
|
+
set(options: DesktopClipboardSetOptions): Promise<DesktopAck>;
|
|
925
|
+
clear(): Promise<DesktopAck>;
|
|
926
|
+
/** Paste into the focused control (Ctrl/Cmd+V). */
|
|
927
|
+
paste(): Promise<DesktopAck>;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
export interface DesktopAxTreeOptions {
|
|
931
|
+
/** Window id from `windows()`. */
|
|
932
|
+
window: string;
|
|
933
|
+
/** Limit tree depth. */
|
|
934
|
+
depth?: number;
|
|
935
|
+
/** Cap the number of nodes. */
|
|
936
|
+
maxNodes?: number;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/** Node match query: `text | name: | role: | value: | id:`. */
|
|
940
|
+
export interface DesktopAxSel {
|
|
941
|
+
window: string;
|
|
942
|
+
match: string;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
export interface DesktopAxQueryOptions extends DesktopAxSel {
|
|
946
|
+
/** Return every match instead of exactly one. */
|
|
947
|
+
all?: boolean;
|
|
948
|
+
/** Target the nth match. */
|
|
949
|
+
index?: number;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
export interface DesktopAxSetValueOptions extends DesktopAxSel {
|
|
953
|
+
value: string;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/** Native accessibility tree inspection and atomic actions — never falls back
|
|
957
|
+
* to physical input silently. */
|
|
958
|
+
export interface DesktopAx {
|
|
959
|
+
tree(options: DesktopAxTreeOptions): Promise<DesktopAxNode>;
|
|
960
|
+
query(options: DesktopAxQueryOptions): Promise<DesktopAxNode[]>;
|
|
961
|
+
/** Atomically match exactly one node and invoke it. */
|
|
962
|
+
invoke(options: DesktopAxSel): Promise<DesktopAck>;
|
|
963
|
+
focus(options: DesktopAxSel): Promise<DesktopAck>;
|
|
964
|
+
setValue(options: DesktopAxSetValueOptions): Promise<DesktopAck>;
|
|
965
|
+
select(options: DesktopAxSel): Promise<DesktopAck>;
|
|
966
|
+
expand(options: DesktopAxSel): Promise<DesktopAck>;
|
|
967
|
+
collapse(options: DesktopAxSel): Promise<DesktopAck>;
|
|
968
|
+
scrollIntoView(options: DesktopAxSel): Promise<DesktopAck>;
|
|
969
|
+
/** The accessible element at a screen point. */
|
|
970
|
+
hitTest(options: DesktopAtOptions): Promise<DesktopAxNode>;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
export interface DesktopWaitWindowOptions {
|
|
974
|
+
match: string;
|
|
975
|
+
/** `visible` (default) | `hidden`. */
|
|
976
|
+
state?: 'visible' | 'hidden';
|
|
977
|
+
/** Timeout in ms (default 5000). */
|
|
978
|
+
timeoutMs?: number;
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
export interface DesktopWaitAxOptions extends DesktopAxSel {
|
|
982
|
+
/** `exists` (default) | `gone` | `enabled` | `focused`. */
|
|
983
|
+
state?: 'exists' | 'gone' | 'enabled' | 'focused';
|
|
984
|
+
timeoutMs?: number;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
export interface DesktopWaitPixelOptions extends DesktopAtOptions {
|
|
988
|
+
/** Expected color as `#rrggbb`. */
|
|
989
|
+
color: string;
|
|
990
|
+
/** Per-channel tolerance (default 0). */
|
|
991
|
+
tolerance?: number;
|
|
992
|
+
timeoutMs?: number;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/** Wait for a condition; rejects with `E_DESKTOP_TIMEOUT` when it never holds. */
|
|
996
|
+
export interface DesktopWait {
|
|
997
|
+
window(options: DesktopWaitWindowOptions): Promise<DesktopWindowInfo>;
|
|
998
|
+
ax(options: DesktopWaitAxOptions): Promise<DesktopAck>;
|
|
999
|
+
pixel(options: DesktopWaitPixelOptions): Promise<DesktopPixel>;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
export interface DesktopAppLaunchOptions {
|
|
1003
|
+
/** Path or PATH-resolved command. */
|
|
1004
|
+
app: string;
|
|
1005
|
+
args?: string[];
|
|
1006
|
+
/** Wait for a window matching this query before resolving. */
|
|
1007
|
+
waitWindow?: string;
|
|
1008
|
+
timeoutMs?: number;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
/** Quit target — exactly one of `match` / `pid` / `window`. */
|
|
1012
|
+
export interface DesktopAppQuitOptions {
|
|
1013
|
+
match?: string;
|
|
1014
|
+
pid?: number;
|
|
1015
|
+
window?: string;
|
|
1016
|
+
/** Terminate instead of a graceful close. */
|
|
1017
|
+
force?: boolean;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/** App lifecycle. */
|
|
1021
|
+
export interface DesktopApp {
|
|
1022
|
+
launch(options: DesktopAppLaunchOptions): Promise<DesktopLaunchResult>;
|
|
1023
|
+
/** Quit an app. Destructive. */
|
|
1024
|
+
quit(options: DesktopAppQuitOptions): Promise<DesktopAck>;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
export interface DesktopProcessListOptions {
|
|
1028
|
+
/** Case-insensitive name substring filter. */
|
|
1029
|
+
filter?: string;
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
export interface DesktopProcessKillOptions {
|
|
1033
|
+
pid: number;
|
|
1034
|
+
force?: boolean;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/** Process inspection/control. */
|
|
1038
|
+
export interface DesktopProcess {
|
|
1039
|
+
list(options?: DesktopProcessListOptions): Promise<DesktopProcessInfo[]>;
|
|
1040
|
+
/** Terminate a process. Destructive. */
|
|
1041
|
+
kill(options: DesktopProcessKillOptions): Promise<DesktopAck>;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/**
|
|
1045
|
+
* Session-less local-OS desktop automation — the in-process mapping of
|
|
1046
|
+
* `lxdev desktop` over the same backend, DTOs, and error taxonomy
|
|
1047
|
+
* (errors carry stable `E_DESKTOP_<CODE>` codes). Windows and macOS;
|
|
1048
|
+
* other platforms reject with `E_DESKTOP_UNSUPPORTED`.
|
|
1049
|
+
*
|
|
1050
|
+
* Coordinates are backend-native global desktop coordinates: physical pixels
|
|
1051
|
+
* on Windows, display points (top-left origin) on macOS.
|
|
1052
|
+
*/
|
|
1053
|
+
export interface DesktopDriver {
|
|
1054
|
+
/** Backend, capability, and permission report. */
|
|
1055
|
+
doctor(): Promise<DesktopDoctor>;
|
|
1056
|
+
/** OS-permission grants; `{ request: true }` triggers the OS prompts. */
|
|
1057
|
+
permissions(options?: { request?: boolean }): Promise<DesktopPermissions>;
|
|
1058
|
+
displays(): Promise<DesktopDisplay[]>;
|
|
1059
|
+
windows(options?: DesktopWindowsOptions): Promise<DesktopWindowInfo[]>;
|
|
1060
|
+
/** Capture the screen (default), a display, a window, or a region. */
|
|
1061
|
+
screenshot(options?: DesktopScreenshotOptions): Promise<DesktopCapture>;
|
|
1062
|
+
/** Read one pixel's color. */
|
|
1063
|
+
pixel(options: DesktopAtOptions): Promise<DesktopPixel>;
|
|
1064
|
+
/** One-shot window info + screenshot + ax tree. */
|
|
1065
|
+
snapshot(options: DesktopSnapshotOptions): Promise<DesktopSnapshot>;
|
|
1066
|
+
readonly window: DesktopWindowDriver;
|
|
1067
|
+
readonly pointer: DesktopPointer;
|
|
1068
|
+
readonly key: DesktopKey;
|
|
1069
|
+
readonly clipboard: DesktopClipboard;
|
|
1070
|
+
readonly ax: DesktopAx;
|
|
1071
|
+
readonly wait: DesktopWait;
|
|
1072
|
+
readonly app: DesktopApp;
|
|
1073
|
+
readonly process: DesktopProcess;
|
|
1074
|
+
}
|