@weapp-vite/miniprogram-automator 1.4.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/dist/index.d.mts +0 -50
- package/dist/index.mjs +48 -89
- package/dist/{launch-ElaGbFxh.mjs → launch-DuW7r68J.mjs} +1063 -932
- package/dist/operation.d.mts +1 -7
- package/dist/operation.mjs +3 -6
- package/package.json +3 -3
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,8 +38,6 @@ type AppServiceHeapUsage = {
|
|
|
47
38
|
source: 'appservice-cdp-runtime';
|
|
48
39
|
reason: 'protocol-unimplemented' | 'method-not-found';
|
|
49
40
|
};
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/cdp/index.d.ts
|
|
52
41
|
interface CDPCommandOptions {
|
|
53
42
|
/** 启用通道与执行命令共享的超时预算,单位毫秒。 */
|
|
54
43
|
timeout?: number;
|
|
@@ -60,8 +49,6 @@ interface CDPSession {
|
|
|
60
49
|
listProtocol: (options?: CDPCommandOptions) => Promise<any>;
|
|
61
50
|
onEvent: (listener: CDPEventListener) => () => void;
|
|
62
51
|
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/Transport.d.ts
|
|
65
52
|
/** Transport 的实现。 */
|
|
66
53
|
declare class Transport extends EventEmitter {
|
|
67
54
|
private ws;
|
|
@@ -72,8 +59,6 @@ declare class Transport extends EventEmitter {
|
|
|
72
59
|
send(message: string): void;
|
|
73
60
|
close(): Promise<void>;
|
|
74
61
|
}
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region src/Connection.d.ts
|
|
77
62
|
interface SendOptions {
|
|
78
63
|
timeout?: number;
|
|
79
64
|
}
|
|
@@ -105,8 +90,6 @@ declare class Connection extends EventEmitter {
|
|
|
105
90
|
private onClose;
|
|
106
91
|
static create(url: string, timeout?: number, signal?: AbortSignal): Promise<Connection>;
|
|
107
92
|
}
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/structuredConsole.d.ts
|
|
110
93
|
interface ConsoleLogOptions {
|
|
111
94
|
/** 使用 CDP 原始参数,并读取 Error 的非枚举数据属性;默认保留 SDK 日志格式。 */
|
|
112
95
|
structured?: boolean;
|
|
@@ -127,8 +110,6 @@ interface StructuredConsoleEntry {
|
|
|
127
110
|
args: ConsoleRemoteObject[];
|
|
128
111
|
[key: string]: unknown;
|
|
129
112
|
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/Native.d.ts
|
|
132
113
|
/** ISwitchTabOptions 的类型定义。 */
|
|
133
114
|
interface ISwitchTabOptions {
|
|
134
115
|
url: string;
|
|
@@ -150,8 +131,6 @@ declare class Native extends EventEmitter {
|
|
|
150
131
|
private send;
|
|
151
132
|
private sendNative;
|
|
152
133
|
}
|
|
153
|
-
//#endregion
|
|
154
|
-
//#region src/Element.d.ts
|
|
155
134
|
/** IElementOptions 的类型定义。 */
|
|
156
135
|
interface IElementOptions {
|
|
157
136
|
elementId: string;
|
|
@@ -279,8 +258,6 @@ export declare class SliderElement extends Element {
|
|
|
279
258
|
export declare class ContextElement extends Element {
|
|
280
259
|
callContextMethod(method: string, ...args: any[]): Promise<any>;
|
|
281
260
|
}
|
|
282
|
-
//#endregion
|
|
283
|
-
//#region src/Page.d.ts
|
|
284
261
|
/** IPageOptions 的类型定义。 */
|
|
285
262
|
interface IPageOptions {
|
|
286
263
|
id: number;
|
|
@@ -369,8 +346,6 @@ declare class Page {
|
|
|
369
346
|
private send;
|
|
370
347
|
static create(connection: Connection, options: IPageOptions, pageMap: PageMap): Page;
|
|
371
348
|
}
|
|
372
|
-
//#endregion
|
|
373
|
-
//#region src/MiniProgram.d.ts
|
|
374
349
|
interface IScreenshotOptions {
|
|
375
350
|
path?: string;
|
|
376
351
|
timeout?: number;
|
|
@@ -485,8 +460,6 @@ declare class MiniProgram extends EventEmitter {
|
|
|
485
460
|
private onBindingCalled;
|
|
486
461
|
private onExceptionThrown;
|
|
487
462
|
}
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/smartapp/types.d.ts
|
|
490
463
|
type SmartappDeviceType = 'android' | 'iOS' | 'web' | 'devtools' | 'simulator';
|
|
491
464
|
type SmartappConnectType = 'usb' | 'wifi' | 'newBaiduCloud' | 'mtpaas';
|
|
492
465
|
interface SmartappLaunchOptions {
|
|
@@ -530,8 +503,6 @@ interface ScreenshotOptions {
|
|
|
530
503
|
path?: string;
|
|
531
504
|
compressionLevel?: number;
|
|
532
505
|
}
|
|
533
|
-
//#endregion
|
|
534
|
-
//#region src/smartapp/Element.d.ts
|
|
535
506
|
declare class SmartappElement {
|
|
536
507
|
private readonly element;
|
|
537
508
|
selectors: string;
|
|
@@ -563,8 +534,6 @@ declare class SmartappElement {
|
|
|
563
534
|
}): Promise<void>;
|
|
564
535
|
screenshot(options?: ScreenshotOptions): Promise<Buffer<ArrayBuffer>>;
|
|
565
536
|
}
|
|
566
|
-
//#endregion
|
|
567
|
-
//#region src/smartapp/Page.d.ts
|
|
568
537
|
declare class SmartappPage {
|
|
569
538
|
private readonly page;
|
|
570
539
|
path: string;
|
|
@@ -575,8 +544,6 @@ declare class SmartappPage {
|
|
|
575
544
|
setData(data: Record<string, unknown>): Promise<void>;
|
|
576
545
|
callMethod(method: string, ...args: unknown[]): Promise<any>;
|
|
577
546
|
}
|
|
578
|
-
//#endregion
|
|
579
|
-
//#region src/smartapp/App.d.ts
|
|
580
547
|
declare class SmartappApp {
|
|
581
548
|
private readonly miniProgram;
|
|
582
549
|
appKey: string;
|
|
@@ -599,8 +566,6 @@ declare class SmartappApp {
|
|
|
599
566
|
$x(_expression: string): Promise<never[]>;
|
|
600
567
|
close(): Promise<void>;
|
|
601
568
|
}
|
|
602
|
-
//#endregion
|
|
603
|
-
//#region src/smartapp/Device.d.ts
|
|
604
569
|
declare class SmartappDevice {
|
|
605
570
|
type: string;
|
|
606
571
|
connectType: string;
|
|
@@ -632,15 +597,11 @@ declare class SmartappDevice {
|
|
|
632
597
|
isInstall(): Promise<boolean>;
|
|
633
598
|
close(): Promise<void>;
|
|
634
599
|
}
|
|
635
|
-
//#endregion
|
|
636
|
-
//#region src/smartapp/index.d.ts
|
|
637
600
|
declare function launch(options?: SmartappLaunchOptions & {
|
|
638
601
|
wsEndpoint?: string;
|
|
639
602
|
}): Promise<SmartappDevice>;
|
|
640
603
|
declare function connect(options: Record<string, unknown>): Promise<SmartappDevice>;
|
|
641
604
|
declare function devices(deviceType: string, _connectType?: string): Promise<SmartappDevicesResult>;
|
|
642
|
-
//#endregion
|
|
643
|
-
//#region src/platform.d.ts
|
|
644
605
|
/**
|
|
645
606
|
* @file 小程序自动化平台适配定义。
|
|
646
607
|
*/
|
|
@@ -656,8 +617,6 @@ export interface IExternalAutomatorModule {
|
|
|
656
617
|
}
|
|
657
618
|
export type NormalizedMiniprogramAutomatorPlatform = Exclude<MiniprogramAutomatorPlatform, 'baidu'>;
|
|
658
619
|
export declare function normalizePlatform(platform?: MiniprogramAutomatorPlatform): NormalizedMiniprogramAutomatorPlatform;
|
|
659
|
-
//#endregion
|
|
660
|
-
//#region src/Launcher.d.ts
|
|
661
620
|
export interface IConnectOptions {
|
|
662
621
|
wsEndpoint: string;
|
|
663
622
|
signal?: AbortSignal;
|
|
@@ -708,8 +667,6 @@ declare class Launcher {
|
|
|
708
667
|
private connectTool;
|
|
709
668
|
private resolveCliPath;
|
|
710
669
|
}
|
|
711
|
-
//#endregion
|
|
712
|
-
//#region src/Automator.d.ts
|
|
713
670
|
/** Automator 的实现。 */
|
|
714
671
|
declare class Automator {
|
|
715
672
|
Element: typeof Element;
|
|
@@ -725,8 +682,6 @@ declare class Automator {
|
|
|
725
682
|
connect(options: IConnectOptions): Promise<unknown>;
|
|
726
683
|
launch(options: ILaunchOptions): Promise<any>;
|
|
727
684
|
}
|
|
728
|
-
//#endregion
|
|
729
|
-
//#region src/launcher/portLease.d.ts
|
|
730
685
|
interface AutomatorPortLease {
|
|
731
686
|
path?: string;
|
|
732
687
|
port: number;
|
|
@@ -736,8 +691,6 @@ interface AutomatorPortLease {
|
|
|
736
691
|
* @description 选择并短暂租约一个自动化端口,避免并发启动选择到同一端口。
|
|
737
692
|
*/
|
|
738
693
|
export declare function acquireAutomatorPortLease(preferredPort?: number): Promise<AutomatorPortLease>;
|
|
739
|
-
//#endregion
|
|
740
|
-
//#region src/util.d.ts
|
|
741
694
|
/** decodeQrCode 的方法封装。 */
|
|
742
695
|
export declare function decodeQrCode(qrCode: string): Promise<string>;
|
|
743
696
|
/** printQrCode 的方法封装。 */
|
|
@@ -746,8 +699,6 @@ export declare function printQrCode(content: string): Promise<void>;
|
|
|
746
699
|
export declare function isPluginPath(p: unknown): boolean;
|
|
747
700
|
/** extractPluginId 的方法封装。 */
|
|
748
701
|
export declare function extractPluginId(p: unknown): string;
|
|
749
|
-
//#endregion
|
|
750
|
-
//#region src/index.d.ts
|
|
751
702
|
export declare const SmartappAutomator: {
|
|
752
703
|
connect: typeof connect;
|
|
753
704
|
devices: typeof devices;
|
|
@@ -772,5 +723,4 @@ export declare const SmartappAutomator: {
|
|
|
772
723
|
delay: typeof delay;
|
|
773
724
|
};
|
|
774
725
|
};
|
|
775
|
-
//#endregion
|
|
776
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 };
|
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import os from "node:os";
|
|
|
12
12
|
import { spawn } from "node:child_process";
|
|
13
13
|
import { decodeQrCodeFromBase64, renderTerminalQrCode } from "@weapp-vite/qr";
|
|
14
14
|
import { Buffer } from "node:buffer";
|
|
15
|
-
|
|
15
|
+
// src/internal/compat/async.ts
|
|
16
16
|
/**
|
|
17
17
|
* @file 异步控制工具。
|
|
18
18
|
*/
|
|
@@ -46,8 +46,7 @@ async function waitUntil(condition, timeout = 0, interval = 250, signal) {
|
|
|
46
46
|
await sleep$1(Math.min(interval, remaining), signal);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
//#region src/internal/compat/format.ts
|
|
49
|
+
// src/internal/compat/format.ts
|
|
51
50
|
/**
|
|
52
51
|
* @file 标识与格式化工具。
|
|
53
52
|
*/
|
|
@@ -63,8 +62,7 @@ function dateFormat(mask, value = /* @__PURE__ */ new Date()) {
|
|
|
63
62
|
function uuid() {
|
|
64
63
|
return randomUUID();
|
|
65
64
|
}
|
|
66
|
-
|
|
67
|
-
//#region src/internal/compat/network.ts
|
|
65
|
+
// src/internal/compat/network.ts
|
|
68
66
|
/**
|
|
69
67
|
* @file 网络与环境工具。
|
|
70
68
|
*/
|
|
@@ -98,8 +96,7 @@ function isRelative(value) {
|
|
|
98
96
|
return !absolutePathPattern.test(value);
|
|
99
97
|
}
|
|
100
98
|
const isWindows = process.platform === "win32";
|
|
101
|
-
|
|
102
|
-
//#region src/internal/compat/typeGuards.ts
|
|
99
|
+
// src/internal/compat/typeGuards.ts
|
|
103
100
|
/**
|
|
104
101
|
* @file 基础类型守卫工具。
|
|
105
102
|
*/
|
|
@@ -127,8 +124,7 @@ function isPlainObject(value) {
|
|
|
127
124
|
const prototype = Object.getPrototypeOf(value);
|
|
128
125
|
return prototype === null || prototype === Object.prototype;
|
|
129
126
|
}
|
|
130
|
-
|
|
131
|
-
//#region src/internal/compat/object.ts
|
|
127
|
+
// src/internal/compat/object.ts
|
|
132
128
|
/**
|
|
133
129
|
* @file 对象与序列化工具。
|
|
134
130
|
*/
|
|
@@ -195,8 +191,7 @@ function isEmpty(value) {
|
|
|
195
191
|
function stringify(value) {
|
|
196
192
|
return stableSerialize(value);
|
|
197
193
|
}
|
|
198
|
-
|
|
199
|
-
//#region src/internal/compat/strings.ts
|
|
194
|
+
// src/internal/compat/strings.ts
|
|
200
195
|
/**
|
|
201
196
|
* @file 字符串与版本处理工具。
|
|
202
197
|
*/
|
|
@@ -235,8 +230,7 @@ function cmpVersion(versionA, versionB) {
|
|
|
235
230
|
}
|
|
236
231
|
return 0;
|
|
237
232
|
}
|
|
238
|
-
|
|
239
|
-
//#region src/componentCaller/runtime.ts
|
|
233
|
+
// src/componentCaller/runtime.ts
|
|
240
234
|
/** 在同一个 Runtime 上下文持有真实 caller,不转用其他 ContextManager 的 token。 */
|
|
241
235
|
function createComponentCallerSession(expected, observerTimeout) {
|
|
242
236
|
const root = this;
|
|
@@ -371,8 +365,7 @@ function createComponentCallerSession(expected, observerTimeout) {
|
|
|
371
365
|
dispose
|
|
372
366
|
};
|
|
373
367
|
}
|
|
374
|
-
|
|
375
|
-
//#region src/componentCaller/index.ts
|
|
368
|
+
// src/componentCaller/index.ts
|
|
376
369
|
const queues = /* @__PURE__ */ new WeakMap();
|
|
377
370
|
const blocked = /* @__PURE__ */ new WeakMap();
|
|
378
371
|
const owners = /* @__PURE__ */ new WeakMap();
|
|
@@ -533,8 +526,7 @@ async function invokeComponentMethod(connection, target, method, args, native) {
|
|
|
533
526
|
if (queues.get(connection) === settled) queues.delete(connection);
|
|
534
527
|
}
|
|
535
528
|
}
|
|
536
|
-
|
|
537
|
-
//#region src/pageRouteSnapshot.ts
|
|
529
|
+
// src/pageRouteSnapshot.ts
|
|
538
530
|
const ROUTE_ELEMENT_SNAPSHOT_TIMEOUT = 5e3;
|
|
539
531
|
const ROUTE_ELEMENT_SNAPSHOT_EMPTY_RETRIES = 2;
|
|
540
532
|
const ROUTE_ELEMENT_SNAPSHOT_RETRY_DELAY = 220;
|
|
@@ -751,8 +743,7 @@ async function readRouteElementSnapshot(connection, route, query, selector, inde
|
|
|
751
743
|
}
|
|
752
744
|
return null;
|
|
753
745
|
}
|
|
754
|
-
|
|
755
|
-
//#region src/Element.ts
|
|
746
|
+
// src/Element.ts
|
|
756
747
|
function normalizeTouchOptions(options) {
|
|
757
748
|
const { changeTouches, ...payload } = options;
|
|
758
749
|
const changedTouches = options.changedTouches ?? changeTouches;
|
|
@@ -1152,8 +1143,7 @@ var ContextElement = class extends Element {
|
|
|
1152
1143
|
})).result;
|
|
1153
1144
|
}
|
|
1154
1145
|
};
|
|
1155
|
-
|
|
1156
|
-
//#region src/Transport.ts
|
|
1146
|
+
// src/Transport.ts
|
|
1157
1147
|
/** Transport 的实现。 */
|
|
1158
1148
|
var Transport = class extends EventEmitter {
|
|
1159
1149
|
ws;
|
|
@@ -1207,8 +1197,7 @@ var Transport = class extends EventEmitter {
|
|
|
1207
1197
|
return this.closing;
|
|
1208
1198
|
}
|
|
1209
1199
|
};
|
|
1210
|
-
|
|
1211
|
-
//#region src/Connection.ts
|
|
1200
|
+
// src/Connection.ts
|
|
1212
1201
|
/**
|
|
1213
1202
|
* @file 自动化协议连接实现。
|
|
1214
1203
|
*/
|
|
@@ -1226,6 +1215,8 @@ const APP_SERVICE_PAGE_METHOD_VERSIONS = /* @__PURE__ */ new Set([
|
|
|
1226
1215
|
"2.02.2610082",
|
|
1227
1216
|
"2.02.2610092"
|
|
1228
1217
|
]);
|
|
1218
|
+
/** 已确认 Exparser caller token 与 Runtime 对象表错绑的 IDE 与 SDK 精确组合。 */
|
|
1219
|
+
const COMPONENT_CALLER_BRIDGE_COMBINATIONS = /* @__PURE__ */ new Map([["2.02.2608080", /* @__PURE__ */ new Set(["3.17.5"])], ["2.02.2609231", /* @__PURE__ */ new Set(["3.17.5", "3.17.6"])]]);
|
|
1229
1220
|
/** Connection 的实现。 */
|
|
1230
1221
|
var Connection = class Connection extends EventEmitter {
|
|
1231
1222
|
transport;
|
|
@@ -1318,7 +1309,7 @@ var Connection = class Connection extends EventEmitter {
|
|
|
1318
1309
|
const version = String(info.version ?? "");
|
|
1319
1310
|
this.useAppServicePageProtocol = APP_SERVICE_PAGE_PROTOCOL_VERSIONS.has(version);
|
|
1320
1311
|
this.useAppServicePageMethod = this.useAppServicePageProtocol || APP_SERVICE_PAGE_METHOD_VERSIONS.has(version);
|
|
1321
|
-
this.useComponentCallerBridge = version
|
|
1312
|
+
this.useComponentCallerBridge = COMPONENT_CALLER_BRIDGE_COMBINATIONS.get(version)?.has(info.SDKVersion ?? "") ?? false;
|
|
1322
1313
|
}
|
|
1323
1314
|
get prefersAppServicePageProtocol() {
|
|
1324
1315
|
return this.useAppServicePageProtocol;
|
|
@@ -1402,13 +1393,11 @@ var Connection = class Connection extends EventEmitter {
|
|
|
1402
1393
|
});
|
|
1403
1394
|
}
|
|
1404
1395
|
};
|
|
1405
|
-
|
|
1406
|
-
//#region src/headless.ts
|
|
1396
|
+
// src/headless.ts
|
|
1407
1397
|
async function launchHeadlessAutomator(options) {
|
|
1408
|
-
return await (await import("./launch-
|
|
1398
|
+
return await (await import("./launch-DuW7r68J.mjs")).launch({ projectPath: options.projectPath });
|
|
1409
1399
|
}
|
|
1410
|
-
|
|
1411
|
-
//#region src/launcher/diagnostics.ts
|
|
1400
|
+
// src/launcher/diagnostics.ts
|
|
1412
1401
|
/** 将本次 CLI 的有界输出附到原始错误,避免泄露登录票据及账号参数。 */
|
|
1413
1402
|
function attachCliDiagnostics(error, state, secrets = []) {
|
|
1414
1403
|
const original = error instanceof Error ? error : new Error("Failed to launch WeChat DevTools", { cause: error });
|
|
@@ -1425,8 +1414,7 @@ function attachCliDiagnostics(error, state, secrets = []) {
|
|
|
1425
1414
|
target.message += `\ncli output${truncated ? " (truncated; last 32768 characters)" : ""}:\n${output}`;
|
|
1426
1415
|
return target;
|
|
1427
1416
|
}
|
|
1428
|
-
|
|
1429
|
-
//#region src/launcher/portLease.ts
|
|
1417
|
+
// src/launcher/portLease.ts
|
|
1430
1418
|
/**
|
|
1431
1419
|
* @file DevTools 自动化端口租约。
|
|
1432
1420
|
*/
|
|
@@ -1524,8 +1512,7 @@ async function acquireAutomatorPortLease(preferredPort) {
|
|
|
1524
1512
|
}
|
|
1525
1513
|
return createLease(await getPort(0, "127.0.0.1"));
|
|
1526
1514
|
}
|
|
1527
|
-
|
|
1528
|
-
//#region src/launcher/wechatCliFallback.ts
|
|
1515
|
+
// src/launcher/wechatCliFallback.ts
|
|
1529
1516
|
const WECHAT_DEVTOOLS_SERVICE_PORT_RE = /listening\s+on\s+http:\/\/127\.0\.0\.1:(\d{2,5})/i;
|
|
1530
1517
|
function extractWechatDevtoolsServicePort(output) {
|
|
1531
1518
|
const port = Number(output.match(WECHAT_DEVTOOLS_SERVICE_PORT_RE)?.[1]);
|
|
@@ -1584,8 +1571,7 @@ function resolveWechatDevtoolsBootstrapArgs(args) {
|
|
|
1584
1571
|
bootstrapArgs.push("islogin");
|
|
1585
1572
|
return bootstrapArgs;
|
|
1586
1573
|
}
|
|
1587
|
-
|
|
1588
|
-
//#region src/launcher/process.ts
|
|
1574
|
+
// src/launcher/process.ts
|
|
1589
1575
|
const WINDOWS_BATCH_CLI_RE = /\.(?:bat|cmd)$/i;
|
|
1590
1576
|
function shouldUseWindowsCommandShell(cliPath) {
|
|
1591
1577
|
return isWindows && WINDOWS_BATCH_CLI_RE.test(cliPath);
|
|
@@ -1664,11 +1650,9 @@ function spawnWechatCli(cliPath, args, cwd, scope) {
|
|
|
1664
1650
|
child.unref();
|
|
1665
1651
|
return Object.assign(state, { release });
|
|
1666
1652
|
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
//#endregion
|
|
1671
|
-
//#region src/appServiceHeap.ts
|
|
1653
|
+
// package.json
|
|
1654
|
+
var version = "1.5.0";
|
|
1655
|
+
// src/appServiceHeap.ts
|
|
1672
1656
|
function isRecord$1(value) {
|
|
1673
1657
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1674
1658
|
}
|
|
@@ -1704,8 +1688,7 @@ async function readAppServiceHeapUsage(send, options = {}) {
|
|
|
1704
1688
|
totalSize: response.totalSize
|
|
1705
1689
|
};
|
|
1706
1690
|
}
|
|
1707
|
-
|
|
1708
|
-
//#region src/cdp/index.ts
|
|
1691
|
+
// src/cdp/index.ts
|
|
1709
1692
|
/** 单个连接共享 CDP 启用状态与订阅;不创建额外 WebSocket。 */
|
|
1710
1693
|
var CDPController = class {
|
|
1711
1694
|
connection;
|
|
@@ -1810,8 +1793,7 @@ function getCDPController(connection, send) {
|
|
|
1810
1793
|
}
|
|
1811
1794
|
return controller;
|
|
1812
1795
|
}
|
|
1813
|
-
|
|
1814
|
-
//#region src/Native.ts
|
|
1796
|
+
// src/Native.ts
|
|
1815
1797
|
/** Native 的实现。 */
|
|
1816
1798
|
var Native = class extends EventEmitter {
|
|
1817
1799
|
connection;
|
|
@@ -1859,8 +1841,7 @@ var Native = class extends EventEmitter {
|
|
|
1859
1841
|
});
|
|
1860
1842
|
}
|
|
1861
1843
|
};
|
|
1862
|
-
|
|
1863
|
-
//#region src/navigation/query.ts
|
|
1844
|
+
// src/navigation/query.ts
|
|
1864
1845
|
/** 仅核对请求显式携带的参数,保留宿主附加参数及其原始编码形式。 */
|
|
1865
1846
|
function matchesRouteQuery(actual, expected) {
|
|
1866
1847
|
const expectedKeys = Object.keys(expected);
|
|
@@ -1878,8 +1859,7 @@ function matchesRouteQuery(actual, expected) {
|
|
|
1878
1859
|
}
|
|
1879
1860
|
});
|
|
1880
1861
|
}
|
|
1881
|
-
|
|
1882
|
-
//#region src/pageRouteFallback.ts
|
|
1862
|
+
// src/pageRouteFallback.ts
|
|
1883
1863
|
function normalizeFallbackIdPart(value) {
|
|
1884
1864
|
return encodeURIComponent(value).replace(/%/g, "_");
|
|
1885
1865
|
}
|
|
@@ -1904,8 +1884,7 @@ function createRouteFallbackElement(connection, elementMap, pageId, selector, no
|
|
|
1904
1884
|
routeFallbackScopeSelectors: [...scopeSelectors]
|
|
1905
1885
|
}, elementMap);
|
|
1906
1886
|
}
|
|
1907
|
-
|
|
1908
|
-
//#region src/pageRouteMethod.ts
|
|
1887
|
+
// src/pageRouteMethod.ts
|
|
1909
1888
|
const PAGE_CALL_METHOD_FALLBACK_RETRIES$1 = 3;
|
|
1910
1889
|
const PAGE_CALL_METHOD_FALLBACK_RETRY_DELAY$1 = 300;
|
|
1911
1890
|
const ROUTE_METHOD_CALL_STORE = "__weappViteAutomatorMethodCalls__";
|
|
@@ -2056,8 +2035,7 @@ async function callRouteMethodViaAppService(connection, route, query, method, ar
|
|
|
2056
2035
|
await sleep$1(PAGE_CALL_METHOD_FALLBACK_RETRY_DELAY$1);
|
|
2057
2036
|
}
|
|
2058
2037
|
}
|
|
2059
|
-
|
|
2060
|
-
//#region src/Page.ts
|
|
2038
|
+
// src/Page.ts
|
|
2061
2039
|
const PAGE_QUERY_TIMEOUT = 2500;
|
|
2062
2040
|
const PAGE_DATA_TIMEOUT = 12e3;
|
|
2063
2041
|
const PAGE_DATA_PROTOCOL_TIMEOUT = 2500;
|
|
@@ -2933,8 +2911,7 @@ var Page = class Page {
|
|
|
2933
2911
|
return page;
|
|
2934
2912
|
}
|
|
2935
2913
|
};
|
|
2936
|
-
|
|
2937
|
-
//#region src/structuredConsole.ts
|
|
2914
|
+
// src/structuredConsole.ts
|
|
2938
2915
|
function isRecord(value) {
|
|
2939
2916
|
return value !== null && typeof value === "object";
|
|
2940
2917
|
}
|
|
@@ -3027,8 +3004,7 @@ var StructuredConsole = class {
|
|
|
3027
3004
|
}
|
|
3028
3005
|
}
|
|
3029
3006
|
};
|
|
3030
|
-
|
|
3031
|
-
//#region src/util.ts
|
|
3007
|
+
// src/util.ts
|
|
3032
3008
|
/**
|
|
3033
3009
|
* @file 二维码与插件路径工具。
|
|
3034
3010
|
*/
|
|
@@ -3055,8 +3031,7 @@ function extractPluginId(p) {
|
|
|
3055
3031
|
const match = p.match(regPluginId);
|
|
3056
3032
|
return match ? match[1] : "";
|
|
3057
3033
|
}
|
|
3058
|
-
|
|
3059
|
-
//#region src/MiniProgram.ts
|
|
3034
|
+
// src/MiniProgram.ts
|
|
3060
3035
|
const CLOSE_STEP_TIMEOUT = 2e3;
|
|
3061
3036
|
const CURRENT_PAGE_RETRIES = 3;
|
|
3062
3037
|
const CURRENT_PAGE_RETRY_DELAY = 400;
|
|
@@ -3702,13 +3677,11 @@ var MiniProgram = class extends EventEmitter {
|
|
|
3702
3677
|
this.emit("exception", payload);
|
|
3703
3678
|
};
|
|
3704
3679
|
};
|
|
3705
|
-
|
|
3706
|
-
//#region src/platform.ts
|
|
3680
|
+
// src/platform.ts
|
|
3707
3681
|
function normalizePlatform(platform = "wechat") {
|
|
3708
3682
|
return platform === "baidu" ? "swan" : platform;
|
|
3709
3683
|
}
|
|
3710
|
-
|
|
3711
|
-
//#region src/smartapp/errors.ts
|
|
3684
|
+
// src/smartapp/errors.ts
|
|
3712
3685
|
/**
|
|
3713
3686
|
* @file 百度智能小程序自动化错误定义。
|
|
3714
3687
|
*/
|
|
@@ -3721,8 +3694,7 @@ var SmartappUnsupportedError = class extends Error {
|
|
|
3721
3694
|
function unsupported(feature) {
|
|
3722
3695
|
throw new SmartappUnsupportedError(feature);
|
|
3723
3696
|
}
|
|
3724
|
-
|
|
3725
|
-
//#region src/smartapp/time.ts
|
|
3697
|
+
// src/smartapp/time.ts
|
|
3726
3698
|
/**
|
|
3727
3699
|
* @file 百度智能小程序自动化时间工具。
|
|
3728
3700
|
*/
|
|
@@ -3736,8 +3708,7 @@ const time = {
|
|
|
3736
3708
|
currentTimestamp,
|
|
3737
3709
|
delay
|
|
3738
3710
|
};
|
|
3739
|
-
|
|
3740
|
-
//#region src/smartapp/Element.ts
|
|
3711
|
+
// src/smartapp/Element.ts
|
|
3741
3712
|
function getCoreElementId(element, selectors, index) {
|
|
3742
3713
|
if (!element) return `${selectors}:${index}`;
|
|
3743
3714
|
const elementId = Reflect.get(element, "id");
|
|
@@ -3804,8 +3775,7 @@ var SmartappElement = class {
|
|
|
3804
3775
|
return Buffer.alloc(0);
|
|
3805
3776
|
}
|
|
3806
3777
|
};
|
|
3807
|
-
|
|
3808
|
-
//#region src/smartapp/Page.ts
|
|
3778
|
+
// src/smartapp/Page.ts
|
|
3809
3779
|
var SmartappPage = class {
|
|
3810
3780
|
page;
|
|
3811
3781
|
path;
|
|
@@ -3828,8 +3798,7 @@ var SmartappPage = class {
|
|
|
3828
3798
|
return await this.page?.callMethod(method, ...args);
|
|
3829
3799
|
}
|
|
3830
3800
|
};
|
|
3831
|
-
|
|
3832
|
-
//#region src/smartapp/App.ts
|
|
3801
|
+
// src/smartapp/App.ts
|
|
3833
3802
|
var SmartappApp = class {
|
|
3834
3803
|
miniProgram;
|
|
3835
3804
|
appKey;
|
|
@@ -3891,8 +3860,7 @@ var SmartappApp = class {
|
|
|
3891
3860
|
await this.miniProgram?.disconnect();
|
|
3892
3861
|
}
|
|
3893
3862
|
};
|
|
3894
|
-
|
|
3895
|
-
//#region src/smartapp/Device.ts
|
|
3863
|
+
// src/smartapp/Device.ts
|
|
3896
3864
|
var SmartappDevice = class {
|
|
3897
3865
|
type;
|
|
3898
3866
|
connectType;
|
|
@@ -3970,8 +3938,7 @@ var SmartappDevice = class {
|
|
|
3970
3938
|
if (errors.length) throw new AggregateError(errors, "Smartapp device cleanup failed");
|
|
3971
3939
|
}
|
|
3972
3940
|
};
|
|
3973
|
-
|
|
3974
|
-
//#region src/smartapp/file.ts
|
|
3941
|
+
// src/smartapp/file.ts
|
|
3975
3942
|
/**
|
|
3976
3943
|
* @file 百度智能小程序自动化文件工具。
|
|
3977
3944
|
*/
|
|
@@ -4006,8 +3973,7 @@ const file = {
|
|
|
4006
3973
|
rmdir,
|
|
4007
3974
|
wget
|
|
4008
3975
|
};
|
|
4009
|
-
|
|
4010
|
-
//#region src/smartapp/image.ts
|
|
3976
|
+
// src/smartapp/image.ts
|
|
4011
3977
|
async function drawBorder(imageBuffer) {
|
|
4012
3978
|
return imageBuffer;
|
|
4013
3979
|
}
|
|
@@ -4022,8 +3988,7 @@ const image = {
|
|
|
4022
3988
|
drawBorder,
|
|
4023
3989
|
extract
|
|
4024
3990
|
};
|
|
4025
|
-
|
|
4026
|
-
//#region src/smartapp/log.ts
|
|
3991
|
+
// src/smartapp/log.ts
|
|
4027
3992
|
const rawConsole = console;
|
|
4028
3993
|
const loggers = /* @__PURE__ */ new Map();
|
|
4029
3994
|
function createLogger(label) {
|
|
@@ -4047,8 +4012,7 @@ const log = {
|
|
|
4047
4012
|
get,
|
|
4048
4013
|
set
|
|
4049
4014
|
};
|
|
4050
|
-
|
|
4051
|
-
//#region src/smartapp/index.ts
|
|
4015
|
+
// src/smartapp/index.ts
|
|
4052
4016
|
const DEFAULT_CONNECT_TYPE = "usb";
|
|
4053
4017
|
function resolveDeviceType(deviceType) {
|
|
4054
4018
|
switch (deviceType) {
|
|
@@ -4098,8 +4062,7 @@ const SmartappAutomator$1 = {
|
|
|
4098
4062
|
log,
|
|
4099
4063
|
time
|
|
4100
4064
|
};
|
|
4101
|
-
|
|
4102
|
-
//#region src/SwanLauncher.ts
|
|
4065
|
+
// src/SwanLauncher.ts
|
|
4103
4066
|
const smartappAutomatorRuntime = SmartappAutomator$1;
|
|
4104
4067
|
function toSmartappLaunchOptions(options) {
|
|
4105
4068
|
const { cliPath, platform: _platform, runtimeProvider: _runtimeProvider, ...rest } = options;
|
|
@@ -4122,8 +4085,7 @@ var SwanLauncher = class {
|
|
|
4122
4085
|
return await this.automator.connect({ ...options });
|
|
4123
4086
|
}
|
|
4124
4087
|
};
|
|
4125
|
-
|
|
4126
|
-
//#region src/Launcher.ts
|
|
4088
|
+
// src/Launcher.ts
|
|
4127
4089
|
/**
|
|
4128
4090
|
* @file 开发者工具启动与连接流程。
|
|
4129
4091
|
*/
|
|
@@ -4430,8 +4392,7 @@ var Launcher = class {
|
|
|
4430
4392
|
}
|
|
4431
4393
|
}
|
|
4432
4394
|
};
|
|
4433
|
-
|
|
4434
|
-
//#region src/Automator.ts
|
|
4395
|
+
// src/Automator.ts
|
|
4435
4396
|
/** Automator 的实现。 */
|
|
4436
4397
|
var Automator = class {
|
|
4437
4398
|
Element = Element;
|
|
@@ -4451,11 +4412,9 @@ var Automator = class {
|
|
|
4451
4412
|
return await this.launcher.launch(options);
|
|
4452
4413
|
}
|
|
4453
4414
|
};
|
|
4454
|
-
|
|
4455
|
-
//#region src/index.ts
|
|
4415
|
+
// src/index.ts
|
|
4456
4416
|
/**
|
|
4457
4417
|
* @file miniprogram-automator 对外导出入口。
|
|
4458
4418
|
*/
|
|
4459
4419
|
const SmartappAutomator = smartappAutomatorRuntime;
|
|
4460
|
-
//#endregion
|
|
4461
4420
|
export { Automator, Connection, ContextElement, CustomElement, Element, InputElement, Launcher, MiniProgram, MovableViewElement, Native, OPERATION_TIMEOUT_CODE, OperationLifecycle, Page, ScrollViewElement, SliderElement, SmartappAutomator, SwiperElement, SwitchElement, TextareaElement, Transport, acquireAutomatorPortLease, classifyOperationError, decodeQrCode, extractPluginId, isPluginPath, isRecoverableOperationError, normalizePlatform, printQrCode, readWechatLoginState };
|