@weapp-vite/miniprogram-automator 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/dist/index.d.mts +39 -54
- package/dist/index.mjs +742 -155
- package/dist/{launch-anJvfi-6.mjs → launch-DuW7r68J.mjs} +2217 -1027
- package/dist/operation.d.mts +1 -7
- package/dist/operation.mjs +3 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
- 提供 `Launcher` 用于启动、连接和复用 DevTools 会话
|
|
17
17
|
- 支持按平台选择自动化后端,默认微信,百度智能小程序提供轻量 TypeScript runtime
|
|
18
18
|
- 支持截图、输入、滚动、点击、页面跳转等自动化操作
|
|
19
|
+
- 对齐官方 0.13.0 的公开 `send()`、`CDP()` 和可等待断开接口
|
|
19
20
|
- 默认输出现代 ESM 与完整类型声明
|
|
20
21
|
- 内置二维码打印与解码辅助能力,便于配合登录、连接流程调试
|
|
21
22
|
- 支持 headless 自动化启动入口
|
|
@@ -157,6 +158,77 @@ else {
|
|
|
157
158
|
|
|
158
159
|
空结果、缺失字段、字符串、负数、非有限数值或已用量超过分配量都会报错;连接超时与其他协议错误原样传播,不会转换为不支持或零内存。每次调用重新探测,不缓存旧会话的能力结果,也不主动触发 GC。该指标仅覆盖 AppService JS 堆,不是 renderer/native 内存、进程 RSS、峰值或可归因的组件独占内存。实际可用性取决于连接的 DevTools/基础库,仍须在目标宿主确认;headless 不提供真实 IDE 堆证据。
|
|
159
160
|
|
|
161
|
+
### 4.8 原始协议与 CDP
|
|
162
|
+
|
|
163
|
+
`send(method, params?, { timeout }?)` 公开原始自动化协议入口,返回宿主原始结果;超时、断开和协议错误继续抛出。错误消息为对象时会序列化展示,错误对象保留原始协议信息。
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
const info = await miniProgram.send('Tool.getInfo', {}, { timeout: 3_000 })
|
|
167
|
+
console.log(info)
|
|
168
|
+
|
|
169
|
+
const cdp = miniProgram.CDP()
|
|
170
|
+
await cdp.enable({ timeout: 3_000 })
|
|
171
|
+
const protocol = await cdp.listProtocol()
|
|
172
|
+
console.log(protocol)
|
|
173
|
+
await cdp.sendCommand('Runtime', 'enable')
|
|
174
|
+
const unsubscribe = cdp.onEvent((domain, event, params) => {
|
|
175
|
+
if (domain === 'Runtime' && event === 'consoleAPICalled') {
|
|
176
|
+
console.log(params)
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
try {
|
|
180
|
+
console.log(await cdp.sendCommand('Runtime', 'evaluate', {
|
|
181
|
+
expression: '40 + 2',
|
|
182
|
+
returnByValue: true,
|
|
183
|
+
}, { timeout: 3_000 }))
|
|
184
|
+
}
|
|
185
|
+
finally {
|
|
186
|
+
unsubscribe()
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
同一连接的 `CDP()` 共享启用状态,并发启用只发起一次初始化,失败后可重试。`sendCommand` 和 `listProtocol` 自动等待启用;可选超时包含初始化所用时间。`onEvent` 返回可重复调用的取消订阅函数,断开连接自动移除本连接注册的监听。结构化日志和堆探测复用同一 CDP 通道;重复 `enableLog` 仍会刷新日志订阅。实际域、命令和结果由目标 DevTools 决定,可先用 `listProtocol()` 查询。
|
|
191
|
+
|
|
192
|
+
### 4.9 触摸事件字段
|
|
193
|
+
|
|
194
|
+
`touchstart`、`touchmove`、`touchend` 和 `dispatchEvent` 均接受标准字段 `changedTouches`,会将触点坐标和触点数组交给页面事件处理器。
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
const point = { identifier: 1, pageX: 40, pageY: 60, clientX: 40, clientY: 60 }
|
|
198
|
+
await button?.touchstart({ touches: [point], changedTouches: [point] })
|
|
199
|
+
await button?.touchend({ touches: [], changedTouches: [point] })
|
|
200
|
+
await button?.dispatchEvent({ eventName: 'touchstart', touches: [point], changedTouches: [point] })
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
旧拼写 `changeTouches` 保留为 deprecated 别名,发送前统一转换为 `changedTouches`;同时传入时以 `changedTouches` 为准。
|
|
204
|
+
|
|
205
|
+
### 4.10 异步断开与迁移
|
|
206
|
+
|
|
207
|
+
`MiniProgram.disconnect()`、`Connection.dispose()` 和 `Transport.close()` 现在返回 `Promise<void>`。调用时立即拒绝未完成 RPC、停止事件订阅并终止本连接,Promise 等待 socket 实际关闭;独立关闭默认最多等待 2 秒。并发调用共享同次清理结果,超时会报告关闭未确认,后续可重新确认迟到的关闭。启动失败清理仍使用启动操作剩余的总预算。
|
|
208
|
+
|
|
209
|
+
原来在同步清理回调或 `finally` 中直接调用 `disconnect()` 的代码,应迁移到可等待的调用链,返回或等待 Promise。`process.on('exit')` 无法等待异步清理,应在主动退出或信号处理流程中先 `await disconnect()`:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
try {
|
|
213
|
+
console.log(await miniProgram.currentPage())
|
|
214
|
+
}
|
|
215
|
+
finally {
|
|
216
|
+
await miniProgram.disconnect()
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`disconnect()` 只断开连接;关闭受管项目窗口仍由持有窗口 owner 的会话 `close()` 负责。重连复用已有窗口的 endpoint,不重新启动 IDE。清理失败会抛出,调用方不能据此记录端口租约、窗口或快照已释放。
|
|
221
|
+
|
|
222
|
+
headless provider 保留同名 `CDP()` 入口,调用会明确报告 `HEADLESS_PROTOCOL_UNSUPPORTED`,不提供 inspector 后端。原始 `send` 仅支持 `Tool.getInfo`、`App.getCurrentPage`、`App.getPageStack`、`App.callFunction`、`App.callWxMethod`;其他协议明确报不支持。headless 的异步断开释放独占运行时,其结果不能证明真实 IDE 窗口已关闭。
|
|
223
|
+
|
|
224
|
+
### 4.11 Headless 原生控件边界
|
|
225
|
+
|
|
226
|
+
`Launcher.launch({ platform: 'wechat', runtimeProvider: 'headless', projectPath })` 使用 simulator 的真实渲染树与原生事件模型。未禁用的 `button form-type="submit"` 可以触发表单默认提交,无需额外调用业务 submit 方法;`rich-text` 的结构化节点和 HTML 内容可以通过通用 `text()` 观察,更新和清空均反映在渲染结果中。
|
|
227
|
+
|
|
228
|
+
一次原生分发在后续监听器同步失败时,仍等待此前已启动的异步处理。单一错误原样抛出;同步和异步处理同时失败时,以 `AggregateError.errors` 保留各错误,并以原同步错误作为 `cause`。
|
|
229
|
+
|
|
230
|
+
表单保留组件/插槽归属,字段值来自当前渲染绑定;未绑定输入的宿主状态、自定义 `wx://form-field` 值导出、reset、真实 `formId` 上报不在此能力范围内。富文本内容保持惰性,不作为 WXML 执行;`attr('nodes')` 仍返回字符串表示。Headless 通过不等于微信 IDE 或真机通过,不能替代目标宿主验收。
|
|
231
|
+
|
|
160
232
|
## 5. 主要导出
|
|
161
233
|
|
|
162
234
|
| 导出 | 说明 |
|
|
@@ -186,3 +258,5 @@ pnpm --filter @weapp-vite/miniprogram-automator typecheck
|
|
|
186
258
|
微信 DevTools 的 `launch` / `connect` 使用一次总 `timeout`(默认 30 秒)。路径准备、端口租约、HTTP 适配、WebSocket、版本与 App ready 均消耗剩余预算,自动重试不重置 deadline。可传 `signal` 取消;成功后连接归调用方管理。
|
|
187
259
|
|
|
188
260
|
失败保留 `cause`,`error.operation` 包含阶段、最后成功阶段、耗时、剩余预算、尝试次数、未退出操作数量及本次资源清理状态。清理 `pending` 表示在预算内未确认退出,不能当作资源已释放。迟到连接只断开自身 WebSocket;启动器只终止持有句柄的 CLI 子进程,不据此认领 IDE 宿主或清理其他项目。无需在 App ready 后再固定等待五秒。
|
|
261
|
+
|
|
262
|
+
启动失败还会附加捕获的 CLI stdout/stderr 尾部输出,最多保留 32,768 个字符,截断时明确标记,并隐藏凭据。输出诊断保留原始 `cause`、错误分类和总预算信息。
|
package/dist/index.d.mts
CHANGED
|
@@ -2,18 +2,13 @@ import { OPERATION_TIMEOUT_CODE, OperationDiagnostics, OperationErrorCategory, O
|
|
|
2
2
|
import { EventEmitter } from "node:events";
|
|
3
3
|
import WebSocket from "ws";
|
|
4
4
|
import { Buffer } from "node:buffer";
|
|
5
|
-
//#region src/smartapp/file.d.ts
|
|
6
5
|
declare function mkdir(dir: string): Promise<void>;
|
|
7
6
|
declare function rmdir(dir: string): Promise<void>;
|
|
8
7
|
declare function wget(url: string, targetPath: string): Promise<void>;
|
|
9
8
|
declare function changeProjectSwanJson(projectPath: string, values: Record<string, unknown>): Promise<void>;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/smartapp/image.d.ts
|
|
12
9
|
declare function drawBorder(imageBuffer: Buffer): Promise<Buffer<ArrayBufferLike>>;
|
|
13
10
|
declare function extract(imageBuffer: Buffer): Promise<Buffer<ArrayBufferLike>>;
|
|
14
11
|
declare function border(imageBuffer: Buffer): Promise<Buffer<ArrayBufferLike>>;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/smartapp/log.d.ts
|
|
17
12
|
/**
|
|
18
13
|
* @file 百度智能小程序自动化日志工具。
|
|
19
14
|
*/
|
|
@@ -24,15 +19,11 @@ interface SmartappLogger {
|
|
|
24
19
|
}
|
|
25
20
|
declare function set(_dir: string, label?: string): SmartappLogger;
|
|
26
21
|
declare function get(label?: string): SmartappLogger;
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/smartapp/time.d.ts
|
|
29
22
|
/**
|
|
30
23
|
* @file 百度智能小程序自动化时间工具。
|
|
31
24
|
*/
|
|
32
25
|
declare function currentTimestamp(): number;
|
|
33
26
|
declare function delay(ms: number): Promise<void>;
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/appServiceHeap.d.ts
|
|
36
27
|
interface AppServiceHeapUsageOptions {
|
|
37
28
|
/** 单次协议请求的超时预算,单位毫秒。 */
|
|
38
29
|
timeout?: number;
|
|
@@ -47,44 +38,58 @@ type AppServiceHeapUsage = {
|
|
|
47
38
|
source: 'appservice-cdp-runtime';
|
|
48
39
|
reason: 'protocol-unimplemented' | 'method-not-found';
|
|
49
40
|
};
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
interface CDPCommandOptions {
|
|
42
|
+
/** 启用通道与执行命令共享的超时预算,单位毫秒。 */
|
|
43
|
+
timeout?: number;
|
|
44
|
+
}
|
|
45
|
+
type CDPEventListener = (domain: string, event: string, params: any) => void;
|
|
46
|
+
interface CDPSession {
|
|
47
|
+
enable: (options?: CDPCommandOptions) => Promise<unknown>;
|
|
48
|
+
sendCommand: <T = any>(domain: string, method: string, params?: Record<string, unknown>, options?: CDPCommandOptions) => Promise<T>;
|
|
49
|
+
listProtocol: (options?: CDPCommandOptions) => Promise<any>;
|
|
50
|
+
onEvent: (listener: CDPEventListener) => () => void;
|
|
51
|
+
}
|
|
52
52
|
/** Transport 的实现。 */
|
|
53
53
|
declare class Transport extends EventEmitter {
|
|
54
54
|
private ws;
|
|
55
|
+
private closed;
|
|
56
|
+
private terminating;
|
|
57
|
+
private closing?;
|
|
55
58
|
constructor(ws: WebSocket);
|
|
56
59
|
send(message: string): void;
|
|
57
|
-
close(): void
|
|
60
|
+
close(): Promise<void>;
|
|
58
61
|
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/Connection.d.ts
|
|
61
62
|
interface SendOptions {
|
|
62
63
|
timeout?: number;
|
|
63
64
|
}
|
|
64
65
|
interface ToolInfo {
|
|
65
66
|
version?: string;
|
|
67
|
+
SDKVersion?: string;
|
|
66
68
|
}
|
|
67
69
|
/** Connection 的实现。 */
|
|
68
70
|
declare class Connection extends EventEmitter {
|
|
69
71
|
private transport;
|
|
70
72
|
private disposed;
|
|
73
|
+
private disposing?;
|
|
71
74
|
private callbacks;
|
|
72
75
|
private useAppServicePageProtocol;
|
|
73
76
|
private useAppServicePageMethod;
|
|
77
|
+
private useComponentCallerBridge;
|
|
74
78
|
constructor(transport: Transport);
|
|
75
79
|
send(method: string, params?: Record<string, any>, options?: SendOptions): Promise<any>;
|
|
76
|
-
dispose(): void
|
|
80
|
+
dispose(): Promise<void>;
|
|
81
|
+
private closeTransport;
|
|
77
82
|
/** 根据 DevTools 版本选择稳定的 Page 协议实现。 */
|
|
78
83
|
configureToolInfo(info: ToolInfo): void;
|
|
79
84
|
get prefersAppServicePageProtocol(): boolean;
|
|
80
85
|
/** 页面方法调用独立选择协议,不影响节点查询及其组件作用域。 */
|
|
81
86
|
get prefersAppServicePageMethod(): boolean;
|
|
87
|
+
/** 仅为实测存在跨上下文 token 错绑的 IDE 与基础库启用真实 caller 桥接。 */
|
|
88
|
+
get prefersComponentCallerBridge(): boolean;
|
|
82
89
|
private onMessage;
|
|
83
90
|
private onClose;
|
|
84
91
|
static create(url: string, timeout?: number, signal?: AbortSignal): Promise<Connection>;
|
|
85
92
|
}
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region src/structuredConsole.d.ts
|
|
88
93
|
interface ConsoleLogOptions {
|
|
89
94
|
/** 使用 CDP 原始参数,并读取 Error 的非枚举数据属性;默认保留 SDK 日志格式。 */
|
|
90
95
|
structured?: boolean;
|
|
@@ -105,8 +110,6 @@ interface StructuredConsoleEntry {
|
|
|
105
110
|
args: ConsoleRemoteObject[];
|
|
106
111
|
[key: string]: unknown;
|
|
107
112
|
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/Native.d.ts
|
|
110
113
|
/** ISwitchTabOptions 的类型定义。 */
|
|
111
114
|
interface ISwitchTabOptions {
|
|
112
115
|
url: string;
|
|
@@ -128,8 +131,6 @@ declare class Native extends EventEmitter {
|
|
|
128
131
|
private send;
|
|
129
132
|
private sendNative;
|
|
130
133
|
}
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region src/Element.d.ts
|
|
133
134
|
/** IElementOptions 的类型定义。 */
|
|
134
135
|
interface IElementOptions {
|
|
135
136
|
elementId: string;
|
|
@@ -156,6 +157,8 @@ interface ITouch {
|
|
|
156
157
|
/** ITouchEventOptions 的类型定义。 */
|
|
157
158
|
interface ITouchEventOptions {
|
|
158
159
|
touches?: ITouch[];
|
|
160
|
+
changedTouches?: ITouch[];
|
|
161
|
+
/** @deprecated 请使用 changedTouches,发送时会自动转换旧字段。 */
|
|
159
162
|
changeTouches?: ITouch[];
|
|
160
163
|
}
|
|
161
164
|
/** IEventOptions 的类型定义。 */
|
|
@@ -163,6 +166,8 @@ interface IEventOptions {
|
|
|
163
166
|
eventName: string;
|
|
164
167
|
$?: string;
|
|
165
168
|
touches?: ITouch[];
|
|
169
|
+
changedTouches?: ITouch[];
|
|
170
|
+
/** @deprecated 请使用 changedTouches,发送时会自动转换旧字段。 */
|
|
166
171
|
changeTouches?: ITouch[];
|
|
167
172
|
detail?: Record<string, any>;
|
|
168
173
|
}
|
|
@@ -178,7 +183,7 @@ declare class Element {
|
|
|
178
183
|
protected nodeId: string | null;
|
|
179
184
|
private videoId;
|
|
180
185
|
private id;
|
|
181
|
-
|
|
186
|
+
protected pageId: number;
|
|
182
187
|
private publicProps?;
|
|
183
188
|
constructor(connection: Connection, options: IElementOptions, elementMap: ElementMap);
|
|
184
189
|
$(selector: string, options?: ElementQueryOptions): Promise<Element | null>;
|
|
@@ -253,8 +258,6 @@ export declare class SliderElement extends Element {
|
|
|
253
258
|
export declare class ContextElement extends Element {
|
|
254
259
|
callContextMethod(method: string, ...args: any[]): Promise<any>;
|
|
255
260
|
}
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/Page.d.ts
|
|
258
261
|
/** IPageOptions 的类型定义。 */
|
|
259
262
|
interface IPageOptions {
|
|
260
263
|
id: number;
|
|
@@ -343,8 +346,6 @@ declare class Page {
|
|
|
343
346
|
private send;
|
|
344
347
|
static create(connection: Connection, options: IPageOptions, pageMap: PageMap): Page;
|
|
345
348
|
}
|
|
346
|
-
//#endregion
|
|
347
|
-
//#region src/MiniProgram.d.ts
|
|
348
349
|
interface IScreenshotOptions {
|
|
349
350
|
path?: string;
|
|
350
351
|
timeout?: number;
|
|
@@ -376,8 +377,11 @@ declare class MiniProgram extends EventEmitter {
|
|
|
376
377
|
private logEnabling?;
|
|
377
378
|
private structuredLogs;
|
|
378
379
|
private structuredConsole;
|
|
380
|
+
private readonly cdp;
|
|
379
381
|
private pageMap;
|
|
380
382
|
private nativeIns?;
|
|
383
|
+
private disconnecting?;
|
|
384
|
+
private closing?;
|
|
381
385
|
constructor(connection: Connection);
|
|
382
386
|
pageStack(): Promise<any>;
|
|
383
387
|
navigateTo(url: string): Promise<Page>;
|
|
@@ -404,7 +408,8 @@ declare class MiniProgram extends EventEmitter {
|
|
|
404
408
|
pageScrollTo(scrollTop: number): Promise<void>;
|
|
405
409
|
close(): Promise<void>;
|
|
406
410
|
remote(auto?: boolean): Promise<void>;
|
|
407
|
-
disconnect(): void
|
|
411
|
+
disconnect(): Promise<void>;
|
|
412
|
+
private stopSubscriptions;
|
|
408
413
|
/** 等待已接收的结构化日志完成 Error 属性检查并发布。 */
|
|
409
414
|
flushConsole(): Promise<void>;
|
|
410
415
|
enableLog(timeout?: number, options?: ConsoleLogOptions): Promise<void>;
|
|
@@ -445,13 +450,16 @@ declare class MiniProgram extends EventEmitter {
|
|
|
445
450
|
private createPageFromPayload;
|
|
446
451
|
private createPagesFromPayloads;
|
|
447
452
|
private readAppFunctionPageStack;
|
|
448
|
-
|
|
453
|
+
/** 返回当前连接共享的 CDP 调试入口。 */
|
|
454
|
+
CDP(): CDPSession;
|
|
455
|
+
/** 发送原始自动化协议,沿用连接的请求超时及清理契约。 */
|
|
456
|
+
send(method: string, params?: Record<string, any>, options?: {
|
|
457
|
+
timeout?: number;
|
|
458
|
+
}): Promise<any>;
|
|
449
459
|
private onLogAdded;
|
|
450
460
|
private onBindingCalled;
|
|
451
461
|
private onExceptionThrown;
|
|
452
462
|
}
|
|
453
|
-
//#endregion
|
|
454
|
-
//#region src/smartapp/types.d.ts
|
|
455
463
|
type SmartappDeviceType = 'android' | 'iOS' | 'web' | 'devtools' | 'simulator';
|
|
456
464
|
type SmartappConnectType = 'usb' | 'wifi' | 'newBaiduCloud' | 'mtpaas';
|
|
457
465
|
interface SmartappLaunchOptions {
|
|
@@ -495,8 +503,6 @@ interface ScreenshotOptions {
|
|
|
495
503
|
path?: string;
|
|
496
504
|
compressionLevel?: number;
|
|
497
505
|
}
|
|
498
|
-
//#endregion
|
|
499
|
-
//#region src/smartapp/Element.d.ts
|
|
500
506
|
declare class SmartappElement {
|
|
501
507
|
private readonly element;
|
|
502
508
|
selectors: string;
|
|
@@ -528,8 +534,6 @@ declare class SmartappElement {
|
|
|
528
534
|
}): Promise<void>;
|
|
529
535
|
screenshot(options?: ScreenshotOptions): Promise<Buffer<ArrayBuffer>>;
|
|
530
536
|
}
|
|
531
|
-
//#endregion
|
|
532
|
-
//#region src/smartapp/Page.d.ts
|
|
533
537
|
declare class SmartappPage {
|
|
534
538
|
private readonly page;
|
|
535
539
|
path: string;
|
|
@@ -540,8 +544,6 @@ declare class SmartappPage {
|
|
|
540
544
|
setData(data: Record<string, unknown>): Promise<void>;
|
|
541
545
|
callMethod(method: string, ...args: unknown[]): Promise<any>;
|
|
542
546
|
}
|
|
543
|
-
//#endregion
|
|
544
|
-
//#region src/smartapp/App.d.ts
|
|
545
547
|
declare class SmartappApp {
|
|
546
548
|
private readonly miniProgram;
|
|
547
549
|
appKey: string;
|
|
@@ -564,8 +566,6 @@ declare class SmartappApp {
|
|
|
564
566
|
$x(_expression: string): Promise<never[]>;
|
|
565
567
|
close(): Promise<void>;
|
|
566
568
|
}
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region src/smartapp/Device.d.ts
|
|
569
569
|
declare class SmartappDevice {
|
|
570
570
|
type: string;
|
|
571
571
|
connectType: string;
|
|
@@ -597,15 +597,11 @@ declare class SmartappDevice {
|
|
|
597
597
|
isInstall(): Promise<boolean>;
|
|
598
598
|
close(): Promise<void>;
|
|
599
599
|
}
|
|
600
|
-
//#endregion
|
|
601
|
-
//#region src/smartapp/index.d.ts
|
|
602
600
|
declare function launch(options?: SmartappLaunchOptions & {
|
|
603
601
|
wsEndpoint?: string;
|
|
604
602
|
}): Promise<SmartappDevice>;
|
|
605
603
|
declare function connect(options: Record<string, unknown>): Promise<SmartappDevice>;
|
|
606
604
|
declare function devices(deviceType: string, _connectType?: string): Promise<SmartappDevicesResult>;
|
|
607
|
-
//#endregion
|
|
608
|
-
//#region src/platform.d.ts
|
|
609
605
|
/**
|
|
610
606
|
* @file 小程序自动化平台适配定义。
|
|
611
607
|
*/
|
|
@@ -621,8 +617,6 @@ export interface IExternalAutomatorModule {
|
|
|
621
617
|
}
|
|
622
618
|
export type NormalizedMiniprogramAutomatorPlatform = Exclude<MiniprogramAutomatorPlatform, 'baidu'>;
|
|
623
619
|
export declare function normalizePlatform(platform?: MiniprogramAutomatorPlatform): NormalizedMiniprogramAutomatorPlatform;
|
|
624
|
-
//#endregion
|
|
625
|
-
//#region src/Launcher.d.ts
|
|
626
620
|
export interface IConnectOptions {
|
|
627
621
|
wsEndpoint: string;
|
|
628
622
|
signal?: AbortSignal;
|
|
@@ -673,8 +667,6 @@ declare class Launcher {
|
|
|
673
667
|
private connectTool;
|
|
674
668
|
private resolveCliPath;
|
|
675
669
|
}
|
|
676
|
-
//#endregion
|
|
677
|
-
//#region src/Automator.d.ts
|
|
678
670
|
/** Automator 的实现。 */
|
|
679
671
|
declare class Automator {
|
|
680
672
|
Element: typeof Element;
|
|
@@ -690,8 +682,6 @@ declare class Automator {
|
|
|
690
682
|
connect(options: IConnectOptions): Promise<unknown>;
|
|
691
683
|
launch(options: ILaunchOptions): Promise<any>;
|
|
692
684
|
}
|
|
693
|
-
//#endregion
|
|
694
|
-
//#region src/launcher/portLease.d.ts
|
|
695
685
|
interface AutomatorPortLease {
|
|
696
686
|
path?: string;
|
|
697
687
|
port: number;
|
|
@@ -701,8 +691,6 @@ interface AutomatorPortLease {
|
|
|
701
691
|
* @description 选择并短暂租约一个自动化端口,避免并发启动选择到同一端口。
|
|
702
692
|
*/
|
|
703
693
|
export declare function acquireAutomatorPortLease(preferredPort?: number): Promise<AutomatorPortLease>;
|
|
704
|
-
//#endregion
|
|
705
|
-
//#region src/util.d.ts
|
|
706
694
|
/** decodeQrCode 的方法封装。 */
|
|
707
695
|
export declare function decodeQrCode(qrCode: string): Promise<string>;
|
|
708
696
|
/** printQrCode 的方法封装。 */
|
|
@@ -711,8 +699,6 @@ export declare function printQrCode(content: string): Promise<void>;
|
|
|
711
699
|
export declare function isPluginPath(p: unknown): boolean;
|
|
712
700
|
/** extractPluginId 的方法封装。 */
|
|
713
701
|
export declare function extractPluginId(p: unknown): string;
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region src/index.d.ts
|
|
716
702
|
export declare const SmartappAutomator: {
|
|
717
703
|
connect: typeof connect;
|
|
718
704
|
devices: typeof devices;
|
|
@@ -737,5 +723,4 @@ export declare const SmartappAutomator: {
|
|
|
737
723
|
delay: typeof delay;
|
|
738
724
|
};
|
|
739
725
|
};
|
|
740
|
-
|
|
741
|
-
export { type AppServiceHeapUsage, type AppServiceHeapUsageOptions, Automator, type AutomatorPortLease, Connection, type ConsoleLogOptions, type ConsoleRemoteObject, Element, Launcher, MiniProgram, Native, OPERATION_TIMEOUT_CODE, OperationDiagnostics, OperationErrorCategory, OperationLifecycle, OperationStepOptions, Page, type StructuredConsoleEntry, Transport, classifyOperationError, isRecoverableOperationError, readWechatLoginState };
|
|
726
|
+
export { type AppServiceHeapUsage, type AppServiceHeapUsageOptions, Automator, type AutomatorPortLease, type CDPCommandOptions, type CDPEventListener, type CDPSession, Connection, type ConsoleLogOptions, type ConsoleRemoteObject, Element, type IEventOptions, type ITouch, type ITouchEventOptions, Launcher, MiniProgram, Native, OPERATION_TIMEOUT_CODE, OperationDiagnostics, OperationErrorCategory, OperationLifecycle, OperationStepOptions, Page, type StructuredConsoleEntry, Transport, classifyOperationError, isRecoverableOperationError, readWechatLoginState };
|