@weapp-vite/miniprogram-automator 1.2.5 → 1.2.7
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/index.d.mts +83 -14
- package/dist/index.mjs +950 -74
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import WebSocket from "ws";
|
|
3
3
|
import { Buffer } from "node:buffer";
|
|
4
|
-
|
|
5
4
|
//#region src/smartapp/file.d.ts
|
|
6
5
|
declare function mkdir(dir: string): Promise<void>;
|
|
7
6
|
declare function rmdir(dir: string): Promise<void>;
|
|
@@ -45,13 +44,20 @@ declare class Transport extends EventEmitter {
|
|
|
45
44
|
interface SendOptions {
|
|
46
45
|
timeout?: number;
|
|
47
46
|
}
|
|
47
|
+
interface ToolInfo {
|
|
48
|
+
version?: string;
|
|
49
|
+
}
|
|
48
50
|
/** Connection 的实现。 */
|
|
49
51
|
declare class Connection extends EventEmitter {
|
|
50
52
|
private transport;
|
|
51
53
|
private callbacks;
|
|
54
|
+
private useAppServicePageProtocol;
|
|
52
55
|
constructor(transport: Transport);
|
|
53
56
|
send(method: string, params?: Record<string, any>, options?: SendOptions): Promise<any>;
|
|
54
57
|
dispose(): void;
|
|
58
|
+
/** 根据 DevTools 版本选择稳定的 Page 协议实现。 */
|
|
59
|
+
configureToolInfo(info: ToolInfo): void;
|
|
60
|
+
get prefersAppServicePageProtocol(): boolean;
|
|
55
61
|
private onMessage;
|
|
56
62
|
private onClose;
|
|
57
63
|
static create(url: string, timeout?: number): Promise<Connection>;
|
|
@@ -111,6 +117,9 @@ interface IEventOptions {
|
|
|
111
117
|
detail?: Record<string, any>;
|
|
112
118
|
}
|
|
113
119
|
type ElementMap = Map<string, Element>;
|
|
120
|
+
interface ElementQueryOptions {
|
|
121
|
+
timeout?: number;
|
|
122
|
+
}
|
|
114
123
|
/** Element 的实现。 */
|
|
115
124
|
declare class Element {
|
|
116
125
|
private connection;
|
|
@@ -122,8 +131,8 @@ declare class Element {
|
|
|
122
131
|
private pageId;
|
|
123
132
|
private publicProps?;
|
|
124
133
|
constructor(connection: Connection, options: IElementOptions, elementMap: ElementMap);
|
|
125
|
-
$(selector: string): Promise<Element | null>;
|
|
126
|
-
$$(selector: string): Promise<any>;
|
|
134
|
+
$(selector: string, options?: ElementQueryOptions): Promise<Element | null>;
|
|
135
|
+
$$(selector: string, options?: ElementQueryOptions): Promise<any>;
|
|
127
136
|
size(): Promise<{
|
|
128
137
|
width: any;
|
|
129
138
|
height: any;
|
|
@@ -144,7 +153,9 @@ declare class Element {
|
|
|
144
153
|
touchend(options?: ITouchEventOptions): Promise<void>;
|
|
145
154
|
dispatchEvent(options: IEventOptions): Promise<void>;
|
|
146
155
|
protected _property(name: string | string[]): Promise<any>;
|
|
147
|
-
protected send(method: string, params?: Record<string, any
|
|
156
|
+
protected send(method: string, params?: Record<string, any>, options?: {
|
|
157
|
+
timeout?: number;
|
|
158
|
+
}): Promise<any>;
|
|
148
159
|
protected callFunction(functionName: string, ...args: any[]): Promise<any>;
|
|
149
160
|
private domProperty;
|
|
150
161
|
private getter;
|
|
@@ -202,6 +213,41 @@ interface IPageOptions {
|
|
|
202
213
|
}
|
|
203
214
|
type PageMap = Map<number, Page>;
|
|
204
215
|
type WaitCondition = string | number | (() => unknown | Promise<unknown>);
|
|
216
|
+
interface PageQueryOptions {
|
|
217
|
+
componentSelectors?: string[];
|
|
218
|
+
fallback?: boolean;
|
|
219
|
+
routeOnly?: boolean;
|
|
220
|
+
timeout?: number;
|
|
221
|
+
}
|
|
222
|
+
interface PageDataOptions {
|
|
223
|
+
fallback?: boolean;
|
|
224
|
+
routeOnly?: boolean;
|
|
225
|
+
timeout?: number;
|
|
226
|
+
}
|
|
227
|
+
interface PageCallMethodOptions {
|
|
228
|
+
fallback?: boolean;
|
|
229
|
+
routeOnly?: boolean;
|
|
230
|
+
timeout?: number;
|
|
231
|
+
}
|
|
232
|
+
interface PageRenderedOptions {
|
|
233
|
+
componentSelectors?: string[];
|
|
234
|
+
dataset?: Record<string, string | number | boolean>;
|
|
235
|
+
predicate?: (wxml: string) => boolean;
|
|
236
|
+
selector?: string;
|
|
237
|
+
text?: string;
|
|
238
|
+
timeout?: number;
|
|
239
|
+
}
|
|
240
|
+
interface RenderedNodeSnapshot {
|
|
241
|
+
bottom?: number;
|
|
242
|
+
dataset?: Record<string, unknown>;
|
|
243
|
+
height?: number;
|
|
244
|
+
id?: string;
|
|
245
|
+
left?: number;
|
|
246
|
+
right?: number;
|
|
247
|
+
top?: number;
|
|
248
|
+
width?: number;
|
|
249
|
+
}
|
|
250
|
+
type RenderedSelectorNodesSnapshot = Record<string, RenderedNodeSnapshot[]>;
|
|
205
251
|
/** Page 的实现。 */
|
|
206
252
|
declare class Page {
|
|
207
253
|
private connection;
|
|
@@ -209,20 +255,32 @@ declare class Page {
|
|
|
209
255
|
query: any;
|
|
210
256
|
private id;
|
|
211
257
|
private elementMap;
|
|
258
|
+
private preferAppServicePageProtocol;
|
|
212
259
|
constructor(connection: Connection, options: IPageOptions);
|
|
260
|
+
updateFromOptions(options: IPageOptions): void;
|
|
213
261
|
waitFor(condition: WaitCondition): Promise<void>;
|
|
214
|
-
$(selector: string): Promise<Element | null>;
|
|
215
|
-
$$(selector: string): Promise<any>;
|
|
216
|
-
getElementByXpath(selector: string): Promise<Element | null>;
|
|
217
|
-
getElementsByXpath(selector: string): Promise<any>;
|
|
262
|
+
$(selector: string, options?: PageQueryOptions): Promise<Element | null>;
|
|
263
|
+
$$(selector: string, options?: PageQueryOptions): Promise<any>;
|
|
264
|
+
getElementByXpath(selector: string, options?: PageQueryOptions): Promise<Element | null>;
|
|
265
|
+
getElementsByXpath(selector: string, options?: PageQueryOptions): Promise<any>;
|
|
218
266
|
xpath(selector: string): Promise<Element | null>;
|
|
219
|
-
|
|
267
|
+
wxml(): Promise<any>;
|
|
268
|
+
renderedNodes(selector: string, options?: PageQueryOptions): Promise<RenderedNodeSnapshot[]>;
|
|
269
|
+
renderedSelectorNodes(selectors: string[], options?: PageQueryOptions): Promise<RenderedSelectorNodesSnapshot>;
|
|
270
|
+
waitForRendered(options?: PageRenderedOptions): Promise<any>;
|
|
271
|
+
data(path?: string, options?: PageDataOptions): Promise<any>;
|
|
272
|
+
private readRouteData;
|
|
220
273
|
setData(data: any): Promise<void>;
|
|
221
274
|
size(): Promise<{
|
|
222
275
|
width: any;
|
|
223
276
|
height: any;
|
|
224
277
|
}>;
|
|
225
278
|
callMethod(method: string, ...args: any[]): Promise<any>;
|
|
279
|
+
callMethodWithOptions(method: string, options?: PageCallMethodOptions, ...args: any[]): Promise<any>;
|
|
280
|
+
private queryRouteElement;
|
|
281
|
+
private queryRouteElements;
|
|
282
|
+
private callRouteMethod;
|
|
283
|
+
private setRouteData;
|
|
226
284
|
scrollTop(): Promise<any>;
|
|
227
285
|
private windowProperty;
|
|
228
286
|
private send;
|
|
@@ -245,9 +303,13 @@ interface IToolClearCacheOptions {
|
|
|
245
303
|
}
|
|
246
304
|
type AutomatorCallable = (...args: any[]) => any;
|
|
247
305
|
interface CurrentPageOptions {
|
|
306
|
+
appFunctionFallback?: boolean;
|
|
248
307
|
retries?: number;
|
|
249
308
|
timeout?: number;
|
|
250
309
|
}
|
|
310
|
+
interface EvaluateOptions {
|
|
311
|
+
timeout?: number;
|
|
312
|
+
}
|
|
251
313
|
/** MiniProgram 的实现。 */
|
|
252
314
|
declare class MiniProgram extends EventEmitter {
|
|
253
315
|
private connection;
|
|
@@ -257,14 +319,17 @@ declare class MiniProgram extends EventEmitter {
|
|
|
257
319
|
private nativeIns?;
|
|
258
320
|
constructor(connection: Connection);
|
|
259
321
|
pageStack(): Promise<any>;
|
|
260
|
-
navigateTo(url: string): Promise<
|
|
261
|
-
redirectTo(url: string): Promise<
|
|
262
|
-
navigateBack(): Promise<
|
|
263
|
-
reLaunch(url: string): Promise<
|
|
264
|
-
switchTab(url: string): Promise<
|
|
322
|
+
navigateTo(url: string): Promise<Page>;
|
|
323
|
+
redirectTo(url: string): Promise<Page>;
|
|
324
|
+
navigateBack(): Promise<Page>;
|
|
325
|
+
reLaunch(url: string): Promise<Page>;
|
|
326
|
+
switchTab(url: string): Promise<Page>;
|
|
265
327
|
currentPage(options?: CurrentPageOptions): Promise<Page>;
|
|
266
328
|
systemInfo(): Promise<any>;
|
|
267
329
|
callWxMethod(method: string, ...args: any[]): Promise<any>;
|
|
330
|
+
callWxMethodWithOptions(method: string, options?: {
|
|
331
|
+
timeout?: number;
|
|
332
|
+
}, ...args: any[]): Promise<any>;
|
|
268
333
|
private callWxMethodWithTimeout;
|
|
269
334
|
mockWxMethod(method: string, result: any, ...args: any[]): Promise<void>;
|
|
270
335
|
restoreWxMethod(method: string): Promise<void>;
|
|
@@ -272,6 +337,7 @@ declare class MiniProgram extends EventEmitter {
|
|
|
272
337
|
mockPluginWxMethod(pluginId: string, method: string, result: any, ...args: any[]): Promise<void>;
|
|
273
338
|
restorePluginWxMethod(pluginId: string, method: string): Promise<void>;
|
|
274
339
|
evaluate(appFunction: AutomatorCallable | string, ...args: any[]): Promise<any>;
|
|
340
|
+
evaluateWithOptions(appFunction: AutomatorCallable | string, options?: EvaluateOptions, ...args: any[]): Promise<any>;
|
|
275
341
|
pageScrollTo(scrollTop: number): Promise<void>;
|
|
276
342
|
close(): Promise<void>;
|
|
277
343
|
remote(auto?: boolean): Promise<void>;
|
|
@@ -311,6 +377,9 @@ declare class MiniProgram extends EventEmitter {
|
|
|
311
377
|
private resolveRouteContextPage;
|
|
312
378
|
private readRoutePollingCurrentPage;
|
|
313
379
|
private readRoutePollingPageStack;
|
|
380
|
+
private createPageFromPayload;
|
|
381
|
+
private createPagesFromPayloads;
|
|
382
|
+
private readAppFunctionPageStack;
|
|
314
383
|
private send;
|
|
315
384
|
private onLogAdded;
|
|
316
385
|
private onBindingCalled;
|