@weapp-vite/miniprogram-automator 1.2.4 → 1.2.6
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 +80 -15
- package/dist/index.mjs +966 -79
- package/dist/{launch-2X75zDRY.mjs → launch-mRKloPOa.mjs} +26 -26
- 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>;
|
|
@@ -54,7 +53,7 @@ declare class Connection extends EventEmitter {
|
|
|
54
53
|
dispose(): void;
|
|
55
54
|
private onMessage;
|
|
56
55
|
private onClose;
|
|
57
|
-
static create(url: string): Promise<Connection>;
|
|
56
|
+
static create(url: string, timeout?: number): Promise<Connection>;
|
|
58
57
|
}
|
|
59
58
|
//#endregion
|
|
60
59
|
//#region src/Native.d.ts
|
|
@@ -111,6 +110,9 @@ interface IEventOptions {
|
|
|
111
110
|
detail?: Record<string, any>;
|
|
112
111
|
}
|
|
113
112
|
type ElementMap = Map<string, Element>;
|
|
113
|
+
interface ElementQueryOptions {
|
|
114
|
+
timeout?: number;
|
|
115
|
+
}
|
|
114
116
|
/** Element 的实现。 */
|
|
115
117
|
declare class Element {
|
|
116
118
|
private connection;
|
|
@@ -122,8 +124,8 @@ declare class Element {
|
|
|
122
124
|
private pageId;
|
|
123
125
|
private publicProps?;
|
|
124
126
|
constructor(connection: Connection, options: IElementOptions, elementMap: ElementMap);
|
|
125
|
-
$(selector: string): Promise<Element | null>;
|
|
126
|
-
$$(selector: string): Promise<any>;
|
|
127
|
+
$(selector: string, options?: ElementQueryOptions): Promise<Element | null>;
|
|
128
|
+
$$(selector: string, options?: ElementQueryOptions): Promise<any>;
|
|
127
129
|
size(): Promise<{
|
|
128
130
|
width: any;
|
|
129
131
|
height: any;
|
|
@@ -144,7 +146,9 @@ declare class Element {
|
|
|
144
146
|
touchend(options?: ITouchEventOptions): Promise<void>;
|
|
145
147
|
dispatchEvent(options: IEventOptions): Promise<void>;
|
|
146
148
|
protected _property(name: string | string[]): Promise<any>;
|
|
147
|
-
protected send(method: string, params?: Record<string, any
|
|
149
|
+
protected send(method: string, params?: Record<string, any>, options?: {
|
|
150
|
+
timeout?: number;
|
|
151
|
+
}): Promise<any>;
|
|
148
152
|
protected callFunction(functionName: string, ...args: any[]): Promise<any>;
|
|
149
153
|
private domProperty;
|
|
150
154
|
private getter;
|
|
@@ -202,6 +206,41 @@ interface IPageOptions {
|
|
|
202
206
|
}
|
|
203
207
|
type PageMap = Map<number, Page>;
|
|
204
208
|
type WaitCondition = string | number | (() => unknown | Promise<unknown>);
|
|
209
|
+
interface PageQueryOptions {
|
|
210
|
+
componentSelectors?: string[];
|
|
211
|
+
fallback?: boolean;
|
|
212
|
+
routeOnly?: boolean;
|
|
213
|
+
timeout?: number;
|
|
214
|
+
}
|
|
215
|
+
interface PageDataOptions {
|
|
216
|
+
fallback?: boolean;
|
|
217
|
+
routeOnly?: boolean;
|
|
218
|
+
timeout?: number;
|
|
219
|
+
}
|
|
220
|
+
interface PageCallMethodOptions {
|
|
221
|
+
fallback?: boolean;
|
|
222
|
+
routeOnly?: boolean;
|
|
223
|
+
timeout?: number;
|
|
224
|
+
}
|
|
225
|
+
interface PageRenderedOptions {
|
|
226
|
+
componentSelectors?: string[];
|
|
227
|
+
dataset?: Record<string, string | number | boolean>;
|
|
228
|
+
predicate?: (wxml: string) => boolean;
|
|
229
|
+
selector?: string;
|
|
230
|
+
text?: string;
|
|
231
|
+
timeout?: number;
|
|
232
|
+
}
|
|
233
|
+
interface RenderedNodeSnapshot {
|
|
234
|
+
bottom?: number;
|
|
235
|
+
dataset?: Record<string, unknown>;
|
|
236
|
+
height?: number;
|
|
237
|
+
id?: string;
|
|
238
|
+
left?: number;
|
|
239
|
+
right?: number;
|
|
240
|
+
top?: number;
|
|
241
|
+
width?: number;
|
|
242
|
+
}
|
|
243
|
+
type RenderedSelectorNodesSnapshot = Record<string, RenderedNodeSnapshot[]>;
|
|
205
244
|
/** Page 的实现。 */
|
|
206
245
|
declare class Page {
|
|
207
246
|
private connection;
|
|
@@ -209,20 +248,32 @@ declare class Page {
|
|
|
209
248
|
query: any;
|
|
210
249
|
private id;
|
|
211
250
|
private elementMap;
|
|
251
|
+
private preferRoutePageFallback;
|
|
212
252
|
constructor(connection: Connection, options: IPageOptions);
|
|
253
|
+
updateFromOptions(options: IPageOptions): void;
|
|
213
254
|
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>;
|
|
255
|
+
$(selector: string, options?: PageQueryOptions): Promise<Element | null>;
|
|
256
|
+
$$(selector: string, options?: PageQueryOptions): Promise<any>;
|
|
257
|
+
getElementByXpath(selector: string, options?: PageQueryOptions): Promise<Element | null>;
|
|
258
|
+
getElementsByXpath(selector: string, options?: PageQueryOptions): Promise<any>;
|
|
218
259
|
xpath(selector: string): Promise<Element | null>;
|
|
219
|
-
|
|
260
|
+
wxml(): Promise<any>;
|
|
261
|
+
renderedNodes(selector: string, options?: PageQueryOptions): Promise<RenderedNodeSnapshot[]>;
|
|
262
|
+
renderedSelectorNodes(selectors: string[], options?: PageQueryOptions): Promise<RenderedSelectorNodesSnapshot>;
|
|
263
|
+
waitForRendered(options?: PageRenderedOptions): Promise<any>;
|
|
264
|
+
data(path?: string, options?: PageDataOptions): Promise<any>;
|
|
265
|
+
private readRouteData;
|
|
220
266
|
setData(data: any): Promise<void>;
|
|
221
267
|
size(): Promise<{
|
|
222
268
|
width: any;
|
|
223
269
|
height: any;
|
|
224
270
|
}>;
|
|
225
271
|
callMethod(method: string, ...args: any[]): Promise<any>;
|
|
272
|
+
callMethodWithOptions(method: string, options?: PageCallMethodOptions, ...args: any[]): Promise<any>;
|
|
273
|
+
private queryRouteElement;
|
|
274
|
+
private queryRouteElements;
|
|
275
|
+
private callRouteMethod;
|
|
276
|
+
private setRouteData;
|
|
226
277
|
scrollTop(): Promise<any>;
|
|
227
278
|
private windowProperty;
|
|
228
279
|
private send;
|
|
@@ -245,25 +296,33 @@ interface IToolClearCacheOptions {
|
|
|
245
296
|
}
|
|
246
297
|
type AutomatorCallable = (...args: any[]) => any;
|
|
247
298
|
interface CurrentPageOptions {
|
|
299
|
+
appFunctionFallback?: boolean;
|
|
248
300
|
retries?: number;
|
|
249
301
|
timeout?: number;
|
|
250
302
|
}
|
|
303
|
+
interface EvaluateOptions {
|
|
304
|
+
timeout?: number;
|
|
305
|
+
}
|
|
251
306
|
/** MiniProgram 的实现。 */
|
|
252
307
|
declare class MiniProgram extends EventEmitter {
|
|
253
308
|
private connection;
|
|
254
309
|
private appBindings;
|
|
310
|
+
private logEnabled;
|
|
255
311
|
private pageMap;
|
|
256
312
|
private nativeIns?;
|
|
257
313
|
constructor(connection: Connection);
|
|
258
314
|
pageStack(): Promise<any>;
|
|
259
|
-
navigateTo(url: string): Promise<
|
|
260
|
-
redirectTo(url: string): Promise<
|
|
261
|
-
navigateBack(): Promise<
|
|
262
|
-
reLaunch(url: string): Promise<
|
|
263
|
-
switchTab(url: string): Promise<
|
|
315
|
+
navigateTo(url: string): Promise<Page>;
|
|
316
|
+
redirectTo(url: string): Promise<Page>;
|
|
317
|
+
navigateBack(): Promise<Page>;
|
|
318
|
+
reLaunch(url: string): Promise<Page>;
|
|
319
|
+
switchTab(url: string): Promise<Page>;
|
|
264
320
|
currentPage(options?: CurrentPageOptions): Promise<Page>;
|
|
265
321
|
systemInfo(): Promise<any>;
|
|
266
322
|
callWxMethod(method: string, ...args: any[]): Promise<any>;
|
|
323
|
+
callWxMethodWithOptions(method: string, options?: {
|
|
324
|
+
timeout?: number;
|
|
325
|
+
}, ...args: any[]): Promise<any>;
|
|
267
326
|
private callWxMethodWithTimeout;
|
|
268
327
|
mockWxMethod(method: string, result: any, ...args: any[]): Promise<void>;
|
|
269
328
|
restoreWxMethod(method: string): Promise<void>;
|
|
@@ -271,10 +330,12 @@ declare class MiniProgram extends EventEmitter {
|
|
|
271
330
|
mockPluginWxMethod(pluginId: string, method: string, result: any, ...args: any[]): Promise<void>;
|
|
272
331
|
restorePluginWxMethod(pluginId: string, method: string): Promise<void>;
|
|
273
332
|
evaluate(appFunction: AutomatorCallable | string, ...args: any[]): Promise<any>;
|
|
333
|
+
evaluateWithOptions(appFunction: AutomatorCallable | string, options?: EvaluateOptions, ...args: any[]): Promise<any>;
|
|
274
334
|
pageScrollTo(scrollTop: number): Promise<void>;
|
|
275
335
|
close(): Promise<void>;
|
|
276
336
|
remote(auto?: boolean): Promise<void>;
|
|
277
337
|
disconnect(): void;
|
|
338
|
+
enableLog(): Promise<void>;
|
|
278
339
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
279
340
|
exposeFunction(name: string, bindingFunction: AutomatorCallable): Promise<void>;
|
|
280
341
|
checkVersion(): Promise<void>;
|
|
@@ -309,6 +370,9 @@ declare class MiniProgram extends EventEmitter {
|
|
|
309
370
|
private resolveRouteContextPage;
|
|
310
371
|
private readRoutePollingCurrentPage;
|
|
311
372
|
private readRoutePollingPageStack;
|
|
373
|
+
private createPageFromPayload;
|
|
374
|
+
private createPagesFromPayloads;
|
|
375
|
+
private readAppFunctionPageStack;
|
|
312
376
|
private send;
|
|
313
377
|
private onLogAdded;
|
|
314
378
|
private onBindingCalled;
|
|
@@ -489,6 +553,7 @@ declare function normalizePlatform(platform?: MiniprogramAutomatorPlatform): Nor
|
|
|
489
553
|
//#region src/Launcher.d.ts
|
|
490
554
|
interface IConnectOptions {
|
|
491
555
|
wsEndpoint: string;
|
|
556
|
+
timeout?: number;
|
|
492
557
|
platform?: MiniprogramAutomatorPlatform;
|
|
493
558
|
}
|
|
494
559
|
/** ILaunchOptions 的类型定义。 */
|