@weapp-vite/miniprogram-automator 1.2.21 → 1.2.23
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 +4 -0
- package/dist/index.mjs +24 -6
- package/dist/{launch-BNQZTcKo.mjs → launch-CSjvON-f.mjs} +693 -162
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -52,12 +52,15 @@ declare class Connection extends EventEmitter {
|
|
|
52
52
|
private transport;
|
|
53
53
|
private callbacks;
|
|
54
54
|
private useAppServicePageProtocol;
|
|
55
|
+
private useAppServicePageMethod;
|
|
55
56
|
constructor(transport: Transport);
|
|
56
57
|
send(method: string, params?: Record<string, any>, options?: SendOptions): Promise<any>;
|
|
57
58
|
dispose(): void;
|
|
58
59
|
/** 根据 DevTools 版本选择稳定的 Page 协议实现。 */
|
|
59
60
|
configureToolInfo(info: ToolInfo): void;
|
|
60
61
|
get prefersAppServicePageProtocol(): boolean;
|
|
62
|
+
/** 页面方法调用独立选择协议,不影响节点查询及其组件作用域。 */
|
|
63
|
+
get prefersAppServicePageMethod(): boolean;
|
|
61
64
|
private onMessage;
|
|
62
65
|
private onClose;
|
|
63
66
|
static create(url: string, timeout?: number): Promise<Connection>;
|
|
@@ -294,6 +297,7 @@ declare class Page {
|
|
|
294
297
|
waitFor(condition: WaitCondition): Promise<void>;
|
|
295
298
|
$(selector: string, options?: PageQueryOptions): Promise<Element | null>;
|
|
296
299
|
$$(selector: string, options?: PageQueryOptions): Promise<any>;
|
|
300
|
+
private queryPageElements;
|
|
297
301
|
getElementByXpath(selector: string, options?: PageQueryOptions): Promise<Element | null>;
|
|
298
302
|
getElementsByXpath(selector: string, options?: PageQueryOptions): Promise<Element[]>;
|
|
299
303
|
xpath(selector: string): Promise<Element | null>;
|
package/dist/index.mjs
CHANGED
|
@@ -839,11 +839,14 @@ const REQUEST_TIMEOUT = 3e4;
|
|
|
839
839
|
const CONNECT_TIMEOUT = 3e4;
|
|
840
840
|
/** Page frame 定向消息失效、需要切换到 App-service Page 协议的 DevTools 版本。 */
|
|
841
841
|
const APP_SERVICE_PAGE_PROTOCOL_VERSIONS = /* @__PURE__ */ new Set(["2.01.2510290"]);
|
|
842
|
+
/** 仅页面方法调用失效的版本,元素查询仍保留原生组件作用域。 */
|
|
843
|
+
const APP_SERVICE_PAGE_METHOD_VERSIONS = /* @__PURE__ */ new Set(["2.02.2608070", "2.02.2609231"]);
|
|
842
844
|
/** Connection 的实现。 */
|
|
843
845
|
var Connection = class Connection extends EventEmitter {
|
|
844
846
|
transport;
|
|
845
847
|
callbacks = /* @__PURE__ */ new Map();
|
|
846
848
|
useAppServicePageProtocol = false;
|
|
849
|
+
useAppServicePageMethod = false;
|
|
847
850
|
constructor(transport) {
|
|
848
851
|
super();
|
|
849
852
|
this.transport = transport;
|
|
@@ -886,11 +889,17 @@ var Connection = class Connection extends EventEmitter {
|
|
|
886
889
|
}
|
|
887
890
|
/** 根据 DevTools 版本选择稳定的 Page 协议实现。 */
|
|
888
891
|
configureToolInfo(info) {
|
|
889
|
-
|
|
892
|
+
const version = String(info.version ?? "");
|
|
893
|
+
this.useAppServicePageProtocol = APP_SERVICE_PAGE_PROTOCOL_VERSIONS.has(version);
|
|
894
|
+
this.useAppServicePageMethod = this.useAppServicePageProtocol || APP_SERVICE_PAGE_METHOD_VERSIONS.has(version);
|
|
890
895
|
}
|
|
891
896
|
get prefersAppServicePageProtocol() {
|
|
892
897
|
return this.useAppServicePageProtocol;
|
|
893
898
|
}
|
|
899
|
+
/** 页面方法调用独立选择协议,不影响节点查询及其组件作用域。 */
|
|
900
|
+
get prefersAppServicePageMethod() {
|
|
901
|
+
return this.useAppServicePageMethod;
|
|
902
|
+
}
|
|
894
903
|
onMessage = (message) => {
|
|
895
904
|
debugProtocol(`${dateFormat("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${message}`);
|
|
896
905
|
const { id, method, error, result, params } = JSON.parse(message);
|
|
@@ -943,7 +952,7 @@ var Connection = class Connection extends EventEmitter {
|
|
|
943
952
|
//#endregion
|
|
944
953
|
//#region src/headless.ts
|
|
945
954
|
async function launchHeadlessAutomator(options) {
|
|
946
|
-
return await (await import("./launch-
|
|
955
|
+
return await (await import("./launch-CSjvON-f.mjs")).launch({ projectPath: options.projectPath });
|
|
947
956
|
}
|
|
948
957
|
//#endregion
|
|
949
958
|
//#region src/launcher/portLease.ts
|
|
@@ -1098,7 +1107,7 @@ function resolveWechatDevtoolsBootstrapArgs(args) {
|
|
|
1098
1107
|
}
|
|
1099
1108
|
//#endregion
|
|
1100
1109
|
//#region package.json
|
|
1101
|
-
var version = "1.2.
|
|
1110
|
+
var version = "1.2.23";
|
|
1102
1111
|
//#endregion
|
|
1103
1112
|
//#region src/Native.ts
|
|
1104
1113
|
/** Native 的实现。 */
|
|
@@ -1420,7 +1429,7 @@ var Page = class Page {
|
|
|
1420
1429
|
async $(selector, options = {}) {
|
|
1421
1430
|
if (options.routeOnly || options.fallback !== false && this.preferAppServicePageProtocol) return await this.queryRouteElement(selector, options);
|
|
1422
1431
|
try {
|
|
1423
|
-
const element = await this.
|
|
1432
|
+
const element = await this.queryPageElements("Page.getElement", selector, options);
|
|
1424
1433
|
return Element.create(this.connection, {
|
|
1425
1434
|
...element,
|
|
1426
1435
|
pageId: this.id
|
|
@@ -1436,7 +1445,7 @@ var Page = class Page {
|
|
|
1436
1445
|
async $$(selector, options = {}) {
|
|
1437
1446
|
if (options.routeOnly || options.fallback !== false && this.preferAppServicePageProtocol) return await this.queryRouteElements(selector, options);
|
|
1438
1447
|
try {
|
|
1439
|
-
const { elements } = await this.
|
|
1448
|
+
const { elements } = await this.queryPageElements("Page.getElements", selector, options);
|
|
1440
1449
|
return elements.map((element) => {
|
|
1441
1450
|
return Element.create(this.connection, {
|
|
1442
1451
|
...element,
|
|
@@ -1449,6 +1458,15 @@ var Page = class Page {
|
|
|
1449
1458
|
return await this.queryRouteElements(selector, options);
|
|
1450
1459
|
}
|
|
1451
1460
|
}
|
|
1461
|
+
async queryPageElements(method, selector, options) {
|
|
1462
|
+
const timeout = options.timeout ?? PAGE_QUERY_TIMEOUT;
|
|
1463
|
+
try {
|
|
1464
|
+
return await this.send(method, { selector }, { timeout });
|
|
1465
|
+
} catch (error) {
|
|
1466
|
+
if (options.fallback === false || !isRecoverablePageProtocolError(error, method)) throw error;
|
|
1467
|
+
return await this.send(method, { selector }, { timeout });
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1452
1470
|
async getElementByXpath(selector, options = {}) {
|
|
1453
1471
|
try {
|
|
1454
1472
|
const element = await this.send("Page.getElementByXpath", { selector }, { timeout: options.timeout ?? PAGE_QUERY_TIMEOUT });
|
|
@@ -2084,7 +2102,7 @@ var Page = class Page {
|
|
|
2084
2102
|
return await this.callMethodWithOptions(method, {}, ...args);
|
|
2085
2103
|
}
|
|
2086
2104
|
async callMethodWithOptions(method, options = {}, ...args) {
|
|
2087
|
-
if (options.routeOnly || options.fallback !== false && this.preferAppServicePageProtocol) return await this.callRouteMethod(method, args, options.timeout);
|
|
2105
|
+
if (options.routeOnly || options.fallback !== false && (this.preferAppServicePageProtocol || this.connection.prefersAppServicePageMethod)) return await this.callRouteMethod(method, args, options.timeout);
|
|
2088
2106
|
try {
|
|
2089
2107
|
return (await this.send("Page.callMethod", {
|
|
2090
2108
|
method,
|