@weapp-vite/miniprogram-automator 1.2.1 → 1.2.3
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 +2 -2
- package/dist/index.mjs +34 -3
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -557,9 +557,9 @@ declare function decodeQrCode(qrCode: string): Promise<string>;
|
|
|
557
557
|
/** printQrCode 的方法封装。 */
|
|
558
558
|
declare function printQrCode(content: string): Promise<void>;
|
|
559
559
|
/** isPluginPath 的方法封装。 */
|
|
560
|
-
declare function isPluginPath(p:
|
|
560
|
+
declare function isPluginPath(p: unknown): boolean;
|
|
561
561
|
/** extractPluginId 的方法封装。 */
|
|
562
|
-
declare function extractPluginId(p:
|
|
562
|
+
declare function extractPluginId(p: unknown): string;
|
|
563
563
|
//#endregion
|
|
564
564
|
//#region src/index.d.ts
|
|
565
565
|
declare const SmartappAutomator: {
|
package/dist/index.mjs
CHANGED
|
@@ -683,7 +683,7 @@ async function acquireAutomatorPortLease(preferredPort) {
|
|
|
683
683
|
}
|
|
684
684
|
//#endregion
|
|
685
685
|
//#region package.json
|
|
686
|
-
var version = "1.2.
|
|
686
|
+
var version = "1.2.3";
|
|
687
687
|
//#endregion
|
|
688
688
|
//#region src/Native.ts
|
|
689
689
|
/** Native 的实现。 */
|
|
@@ -864,10 +864,12 @@ function printQrCode(content) {
|
|
|
864
864
|
}
|
|
865
865
|
/** isPluginPath 的方法封装。 */
|
|
866
866
|
function isPluginPath(p) {
|
|
867
|
+
if (typeof p !== "string") return false;
|
|
867
868
|
return startWith(p, "plugin-private://");
|
|
868
869
|
}
|
|
869
870
|
/** extractPluginId 的方法封装。 */
|
|
870
871
|
function extractPluginId(p) {
|
|
872
|
+
if (typeof p !== "string") return "";
|
|
871
873
|
const match = p.match(regPluginId);
|
|
872
874
|
return match ? match[1] : "";
|
|
873
875
|
}
|
|
@@ -1706,7 +1708,7 @@ const AUTOMATOR_LAUNCH_RETRIES = 3;
|
|
|
1706
1708
|
const DEFAULT_RUNTIME_PROVIDER_ENV = "WEAPP_VITE_AUTOMATOR_RUNTIME_PROVIDER";
|
|
1707
1709
|
const LEGACY_RUNTIME_PROVIDER_ENV = "WEAPP_VITE_E2E_RUNTIME_PROVIDER";
|
|
1708
1710
|
const EXTENSION_CONTEXT_INVALIDATED_RE = /Extension context invalidated/i;
|
|
1709
|
-
const RETRYABLE_LAUNCH_PORT_RE = /Wait timed out after \d+ ms|Failed connecting to ws:\/\/127\.0\.0\.1:\d+|Failed connecting to devtools websocket endpoint/i;
|
|
1711
|
+
const RETRYABLE_LAUNCH_PORT_RE = /Wait timed out after \d+ ms|Failed connecting to ws:\/\/127\.0\.0\.1:\d+|Failed connecting to devtools websocket endpoint|Failed to launch wechat web devTools, please make sure cliPath is correctly specified/i;
|
|
1710
1712
|
const WINDOWS_BATCH_CLI_RE = /\.(?:bat|cmd)$/i;
|
|
1711
1713
|
let localhostListenPatched = false;
|
|
1712
1714
|
function isExtensionContextInvalidatedError(error) {
|
|
@@ -1715,6 +1717,33 @@ function isExtensionContextInvalidatedError(error) {
|
|
|
1715
1717
|
function isRetryableAutomatorPortLaunchError(error) {
|
|
1716
1718
|
return error instanceof Error && RETRYABLE_LAUNCH_PORT_RE.test(error.message);
|
|
1717
1719
|
}
|
|
1720
|
+
function retainPortLeaseUntilSessionClose(miniProgram, portLease) {
|
|
1721
|
+
let released = false;
|
|
1722
|
+
const release = async () => {
|
|
1723
|
+
if (released) return;
|
|
1724
|
+
released = true;
|
|
1725
|
+
await portLease.release();
|
|
1726
|
+
};
|
|
1727
|
+
const target = miniProgram;
|
|
1728
|
+
const rawClose = target.close;
|
|
1729
|
+
const rawDisconnect = target.disconnect;
|
|
1730
|
+
if (typeof rawClose !== "function" && typeof rawDisconnect !== "function") return false;
|
|
1731
|
+
if (typeof rawDisconnect === "function") target.disconnect = function disconnectWithPortLeaseRelease() {
|
|
1732
|
+
try {
|
|
1733
|
+
return rawDisconnect.call(this);
|
|
1734
|
+
} finally {
|
|
1735
|
+
release();
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
if (typeof rawClose === "function") target.close = async function closeWithPortLeaseRelease() {
|
|
1739
|
+
try {
|
|
1740
|
+
return await rawClose.call(this);
|
|
1741
|
+
} finally {
|
|
1742
|
+
await release();
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
return true;
|
|
1746
|
+
}
|
|
1718
1747
|
function patchNetListenToLoopback() {
|
|
1719
1748
|
if (localhostListenPatched) return;
|
|
1720
1749
|
localhostListenPatched = true;
|
|
@@ -1777,6 +1806,7 @@ var Launcher = class {
|
|
|
1777
1806
|
const { cliPath = await this.resolveCliPath(), timeout = DEFAULT_TIMEOUT, projectConfig = {}, ticket = "", cwd = "", account = "", trustProject = false } = options;
|
|
1778
1807
|
let { args = [], projectPath } = options;
|
|
1779
1808
|
const portLease = await acquireAutomatorPortLease(options.port);
|
|
1809
|
+
let releasePortLeaseOnExit = true;
|
|
1780
1810
|
try {
|
|
1781
1811
|
const port = portLease.port;
|
|
1782
1812
|
if (!cliPath) throw new Error("Wechat web devTools not found, please specify cliPath option");
|
|
@@ -1859,10 +1889,11 @@ var Launcher = class {
|
|
|
1859
1889
|
projectPath: resolvedProjectPath,
|
|
1860
1890
|
wsEndpoint: `ws://127.0.0.1:${port}`
|
|
1861
1891
|
});
|
|
1892
|
+
releasePortLeaseOnExit = !retainPortLeaseUntilSessionClose(resolvedMiniProgram, portLease);
|
|
1862
1893
|
await sleep$1(5e3);
|
|
1863
1894
|
return resolvedMiniProgram;
|
|
1864
1895
|
} finally {
|
|
1865
|
-
await portLease.release();
|
|
1896
|
+
if (releasePortLeaseOnExit) await portLease.release();
|
|
1866
1897
|
}
|
|
1867
1898
|
}
|
|
1868
1899
|
async connect(options) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/miniprogram-automator",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"description": "完全兼容微信 miniprogram-automator 的现代化替代实现",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"node": "^20.19.0 || >=22.12.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"obug": "^2.1.
|
|
44
|
+
"obug": "^2.1.3",
|
|
45
45
|
"ws": "^8.21.0",
|
|
46
|
-
"@weapp-vite/qr": "1.1.
|
|
46
|
+
"@weapp-vite/qr": "1.1.1"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/ws": "^8.18.1",
|
|
54
|
-
"sharp": "^0.
|
|
54
|
+
"sharp": "^0.35.1"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"dev": "tsdown -w --sourcemap",
|