@weapp-vite/miniprogram-automator 1.2.5 → 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 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>;
@@ -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>): Promise<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
- data(path?: string): Promise<any>;
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,9 +296,13 @@ 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;
@@ -257,14 +312,17 @@ declare class MiniProgram extends EventEmitter {
257
312
  private nativeIns?;
258
313
  constructor(connection: Connection);
259
314
  pageStack(): Promise<any>;
260
- navigateTo(url: string): Promise<any>;
261
- redirectTo(url: string): Promise<any>;
262
- navigateBack(): Promise<any>;
263
- reLaunch(url: string): Promise<any>;
264
- switchTab(url: string): Promise<any>;
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>;
265
320
  currentPage(options?: CurrentPageOptions): Promise<Page>;
266
321
  systemInfo(): Promise<any>;
267
322
  callWxMethod(method: string, ...args: any[]): Promise<any>;
323
+ callWxMethodWithOptions(method: string, options?: {
324
+ timeout?: number;
325
+ }, ...args: any[]): Promise<any>;
268
326
  private callWxMethodWithTimeout;
269
327
  mockWxMethod(method: string, result: any, ...args: any[]): Promise<void>;
270
328
  restoreWxMethod(method: string): Promise<void>;
@@ -272,6 +330,7 @@ declare class MiniProgram extends EventEmitter {
272
330
  mockPluginWxMethod(pluginId: string, method: string, result: any, ...args: any[]): Promise<void>;
273
331
  restorePluginWxMethod(pluginId: string, method: string): Promise<void>;
274
332
  evaluate(appFunction: AutomatorCallable | string, ...args: any[]): Promise<any>;
333
+ evaluateWithOptions(appFunction: AutomatorCallable | string, options?: EvaluateOptions, ...args: any[]): Promise<any>;
275
334
  pageScrollTo(scrollTop: number): Promise<void>;
276
335
  close(): Promise<void>;
277
336
  remote(auto?: boolean): Promise<void>;
@@ -311,6 +370,9 @@ declare class MiniProgram extends EventEmitter {
311
370
  private resolveRouteContextPage;
312
371
  private readRoutePollingCurrentPage;
313
372
  private readRoutePollingPageStack;
373
+ private createPageFromPayload;
374
+ private createPagesFromPayloads;
375
+ private readAppFunctionPageStack;
314
376
  private send;
315
377
  private onLogAdded;
316
378
  private onBindingCalled;