weapp-ide-cli 6.0.0 → 6.0.2
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $ as overwriteCustomConfig, C as configureLocaleFromArgv, H as resolveDevtoolsAutomationDefaults, J as logger_default, Q as createLocaleConfig, T as validateLocaleOption, V as getConfiguredLocale, X as createAutoTrustProjectConfig, Y as createAutoBootstrapDevtoolsConfig, Z as createCustomConfig, a as releaseSharedMiniProgram, et as readCustomConfig, q as colors, r as connectMiniProgram, rt as defaultCustomConfigFilePath, t as acquireSharedMiniProgram, tt as removeCustomConfigKey, w as i18nText, z as resolveCliPath } from "./automator-session-ec0i76Cx.js";
|
|
2
|
-
import { A as isWechatIdeLoggedIn, B as runWechatCliCommand, C as clearWechatIdeCache, F as quitWechatIde, G as transformArgv, H as execute, K as promptForCliPath, L as resetWechatIdeFileUtils, M as openWechatIde, N as openWechatIdeOtherProject, P as previewWechatIde, Q as startWechatIdeEngineBuildByHttp, S as buildWechatIdeNpm, T as closeWechatIdeProject, U as createAlias, W as createPathCompat, Y as pollWechatIdeEngineBuildResultByHttp, _ as autoPreviewWechatIde, a as navigateBack, b as buildWechatIdeApk, c as pageStack, d as remote, f as scrollTo, g as tap, i as input, it as removeOption, j as loginWechatIde, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, nt as readBooleanOption, o as navigateTo, p as switchTab, r as currentPage, rt as readOptionValue, s as pageData, t as audit, tt as parseAutomatorArgs, u as redirectTo, v as autoReplayWechatIde, x as buildWechatIdeIpa, y as autoWechatIde, z as uploadWechatIde } from "./commands-
|
|
2
|
+
import { A as isWechatIdeLoggedIn, B as runWechatCliCommand, C as clearWechatIdeCache, F as quitWechatIde, G as transformArgv, H as execute, K as promptForCliPath, L as resetWechatIdeFileUtils, M as openWechatIde, N as openWechatIdeOtherProject, P as previewWechatIde, Q as startWechatIdeEngineBuildByHttp, S as buildWechatIdeNpm, T as closeWechatIdeProject, U as createAlias, W as createPathCompat, Y as pollWechatIdeEngineBuildResultByHttp, _ as autoPreviewWechatIde, a as navigateBack, b as buildWechatIdeApk, c as pageStack, d as remote, f as scrollTo, g as tap, i as input, it as removeOption, j as loginWechatIde, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, nt as readBooleanOption, o as navigateTo, p as switchTab, r as currentPage, rt as readOptionValue, s as pageData, t as audit, tt as parseAutomatorArgs, u as redirectTo, v as autoReplayWechatIde, x as buildWechatIdeIpa, y as autoWechatIde, z as uploadWechatIde } from "./commands-DuTTBEs8.js";
|
|
3
3
|
import "./run-mcp-DPz-bwrD.js";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
@@ -313,7 +313,7 @@ async function runScreenshot(argv) {
|
|
|
313
313
|
}
|
|
314
314
|
const options = parseScreenshotArgs(argv);
|
|
315
315
|
const isJsonOutput = argv.includes("--json");
|
|
316
|
-
const { takeScreenshot } = await import("./commands-
|
|
316
|
+
const { takeScreenshot } = await import("./commands-BXY57tfS.js");
|
|
317
317
|
const result = await takeScreenshot(options);
|
|
318
318
|
if (isJsonOutput) {
|
|
319
319
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -988,11 +988,15 @@ async function handleConfigCommand(argv) {
|
|
|
988
988
|
const imported = await fs$1.readJSON(inputPath);
|
|
989
989
|
if (!imported || typeof imported !== "object") throw new Error(i18nText("导入文件格式无效:应为 JSON 对象", "Invalid import file format: expected a JSON object"));
|
|
990
990
|
const candidate = imported;
|
|
991
|
+
const cliPath = typeof candidate.cliPath === "string" ? candidate.cliPath : void 0;
|
|
992
|
+
const locale = candidate.locale === "zh" || candidate.locale === "en" ? candidate.locale : void 0;
|
|
993
|
+
const autoBootstrapDevtools = typeof candidate.autoBootstrapDevtools === "boolean" ? candidate.autoBootstrapDevtools : void 0;
|
|
994
|
+
const autoTrustProject = typeof candidate.autoTrustProject === "boolean" ? candidate.autoTrustProject : void 0;
|
|
991
995
|
await overwriteCustomConfig({
|
|
992
|
-
cliPath
|
|
993
|
-
locale
|
|
994
|
-
autoBootstrapDevtools
|
|
995
|
-
autoTrustProject
|
|
996
|
+
cliPath,
|
|
997
|
+
locale,
|
|
998
|
+
autoBootstrapDevtools,
|
|
999
|
+
autoTrustProject
|
|
996
1000
|
});
|
|
997
1001
|
logger_default.info(i18nText(`配置已从 ${colors.green(inputPath)} 导入`, `Config imported from ${colors.green(inputPath)}`));
|
|
998
1002
|
return;
|
|
@@ -1255,11 +1259,11 @@ async function refreshOpenedMiniProgramConsoleLog(options) {
|
|
|
1255
1259
|
miniProgram.disconnect();
|
|
1256
1260
|
}
|
|
1257
1261
|
}
|
|
1258
|
-
function startEnableLogRefresh(miniProgram, options) {
|
|
1262
|
+
function startEnableLogRefresh(miniProgram, options, refreshOpenedSession) {
|
|
1259
1263
|
if (typeof miniProgram.enableLog !== "function") return;
|
|
1260
1264
|
const timer = setInterval(() => {
|
|
1261
1265
|
miniProgram.enableLog().catch(() => {});
|
|
1262
|
-
refreshOpenedMiniProgramConsoleLog(options).catch(() => {});
|
|
1266
|
+
if (refreshOpenedSession) refreshOpenedMiniProgramConsoleLog(options).catch(() => {});
|
|
1263
1267
|
}, ENABLE_LOG_REFRESH_INTERVAL_MS);
|
|
1264
1268
|
return () => {
|
|
1265
1269
|
clearInterval(timer);
|
|
@@ -1269,7 +1273,8 @@ function startEnableLogRefresh(miniProgram, options) {
|
|
|
1269
1273
|
* @description 启动小程序控制台日志转发,并保持 automator 会话常驻。
|
|
1270
1274
|
*/
|
|
1271
1275
|
async function startForwardConsole(options) {
|
|
1272
|
-
const
|
|
1276
|
+
const usesSharedSession = !options.miniProgram;
|
|
1277
|
+
const miniProgram = options.miniProgram ?? await acquireSharedMiniProgram(options);
|
|
1273
1278
|
const logLevels = new Set(options.logLevels?.length ? options.logLevels : DEFAULT_FORWARD_CONSOLE_LEVELS);
|
|
1274
1279
|
const logHandler = options.onLog ?? printForwardConsoleEvent;
|
|
1275
1280
|
const recentLogTimes = /* @__PURE__ */ new Map();
|
|
@@ -1310,7 +1315,7 @@ async function startForwardConsole(options) {
|
|
|
1310
1315
|
auxiliaryMiniProgram.disconnect();
|
|
1311
1316
|
auxiliaryMiniProgram = void 0;
|
|
1312
1317
|
}
|
|
1313
|
-
releaseSharedMiniProgram(options.projectPath, options.sessionId || options.port);
|
|
1318
|
+
if (usesSharedSession) releaseSharedMiniProgram(options.projectPath, options.sessionId || options.port);
|
|
1314
1319
|
};
|
|
1315
1320
|
try {
|
|
1316
1321
|
await enableMiniProgramConsoleLog(miniProgram);
|
|
@@ -1320,8 +1325,8 @@ async function startForwardConsole(options) {
|
|
|
1320
1325
|
}
|
|
1321
1326
|
miniProgram.on("console", onConsole);
|
|
1322
1327
|
miniProgram.on("exception", onException);
|
|
1323
|
-
stopEnableLogRefresh = startEnableLogRefresh(miniProgram, options);
|
|
1324
|
-
auxiliaryTimer = setTimeout(() => {
|
|
1328
|
+
stopEnableLogRefresh = startEnableLogRefresh(miniProgram, options, usesSharedSession);
|
|
1329
|
+
if (usesSharedSession) auxiliaryTimer = setTimeout(() => {
|
|
1325
1330
|
(async () => {
|
|
1326
1331
|
const openedMiniProgram = await connectMiniProgram({
|
|
1327
1332
|
...options,
|
package/dist/cli.js
CHANGED
|
@@ -366,9 +366,10 @@ async function captureFullPageScreenshotBuffer(options) {
|
|
|
366
366
|
}
|
|
367
367
|
if (segments.length === 0) throw new Error("Failed to capture screenshot");
|
|
368
368
|
const width = segments[0].width;
|
|
369
|
+
const height = segments.reduce((sum, segment) => sum + segment.height, 0);
|
|
369
370
|
const merged = new PNG({
|
|
370
371
|
width,
|
|
371
|
-
height
|
|
372
|
+
height
|
|
372
373
|
});
|
|
373
374
|
const bytesPerRow = width * 4;
|
|
374
375
|
let offsetY = 0;
|
|
@@ -1109,7 +1110,7 @@ async function requireElement(page, selector, timeoutMs = 5e3) {
|
|
|
1109
1110
|
let lastError;
|
|
1110
1111
|
while (Date.now() - startedAt <= timeoutMs) {
|
|
1111
1112
|
try {
|
|
1112
|
-
const element = await page.$(selector);
|
|
1113
|
+
const element = await page.$(selector, { fallback: false });
|
|
1113
1114
|
if (element) return element;
|
|
1114
1115
|
} catch (error) {
|
|
1115
1116
|
lastError = error;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $ as overwriteCustomConfig, A as isAutomatorProtocolTimeoutError, B as getConfig, D as formatAutomatorLoginError, E as connectOpenedAutomator, F as launchAutomator, G as isOperatingSystemSupported, H as resolveDevtoolsAutomationDefaults, I as resolveProjectAutomatorPort, K as operatingSystemName, L as bootstrapWechatDevtoolsSettings, M as isDevtoolsExtensionContextInvalidatedError, N as isDevtoolsHttpPortError, O as getAutomatorProtocolTimeoutMethod, P as isRetryableAutomatorLaunchError, Q as createLocaleConfig, R as detectWechatDevtoolsServicePort, S as waitForExclusiveKeypress, U as SupportedPlatformsMap, V as getConfiguredLocale, W as getDefaultCliPath, X as createAutoTrustProjectConfig, Y as createAutoBootstrapDevtoolsConfig, Z as createCustomConfig, _ as promptRetryKeypress, a as releaseSharedMiniProgram, b as createSharedInputSession, c as RETRY_CANCEL_KEYS, d as createWechatIdeLoginRequiredExitError, et as readCustomConfig, f as extractExecutionErrorText, g as isWechatIdeLoginRequiredExitError, h as isWechatIdeLoginRequiredError, i as getSharedMiniProgramSessionCount, it as resolvePath, j as isAutomatorWsConnectError, k as isAutomatorLoginError, l as RETRY_CONFIRM_KEYS, m as formatWechatIdeLoginRequiredError, n as closeSharedMiniProgram, nt as defaultCustomConfigDirPath, o as withMiniProgram, p as formatRetryHotkeyPrompt, r as connectMiniProgram, rt as defaultCustomConfigFilePath, s as runRetryableCommand, t as acquireSharedMiniProgram, tt as removeCustomConfigKey, u as RETRY_PROMPT_INITIAL_IGNORE_MS, v as promptWechatIdeLoginRetry, x as runWithSuspendedSharedInput, y as waitForRetryKeypress, z as resolveCliPath } from "./automator-session-ec0i76Cx.js";
|
|
2
|
-
import { $ as getRuntimeWechatDevtoolsServicePort, A as isWechatIdeLoggedIn, C as clearWechatIdeCache, D as getWechatIdeTestAccounts, E as compileWechatIdeByAutomator, F as quitWechatIde, G as transformArgv, H as execute, I as refreshWechatIdeTicket, J as openWechatIdeProjectByHttp, K as promptForCliPath, L as resetWechatIdeFileUtils, M as openWechatIde, N as openWechatIdeOtherProject, O as getWechatIdeTicket, P as previewWechatIde, Q as startWechatIdeEngineBuildByHttp, R as setWechatIdeTicket, S as buildWechatIdeNpm, T as closeWechatIdeProject, U as createAlias, V as runWechatCliWithRetry, W as createPathCompat, X as requestWechatDevtoolsHttp, Y as pollWechatIdeEngineBuildResultByHttp, Z as resetWechatIdeFileUtilsByHttp, _ as autoPreviewWechatIde, a as navigateBack, b as buildWechatIdeApk, c as pageStack, d as remote, et as setRuntimeWechatDevtoolsServicePort, f as scrollTo, g as tap, h as takeScreenshot, i as input, it as removeOption, j as loginWechatIde, k as getWechatIdeToolInfo, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, nt as readBooleanOption, o as navigateTo, p as switchTab, q as WECHAT_DEVTOOLS_ENGINE_BUILD_STATUSES, r as currentPage, rt as readOptionValue, s as pageData, t as audit, tt as parseAutomatorArgs, u as redirectTo, v as autoReplayWechatIde, w as clearWechatIdeCacheByAutomator, x as buildWechatIdeIpa, y as autoWechatIde, z as uploadWechatIde } from "./commands-
|
|
3
|
-
import { C as parseCompareArgs, S as printScreenshotHelp, _ as AUTOMATOR_COMMAND_NAMES, a as runMinidev, b as runAutomatorCommand, c as runWechatIdeEngineBuild, d as CONFIG_COMMAND_NAME, f as MCP_COMMAND_NAME, g as isWeappIdeTopLevelCommand, h as WECHAT_CLI_COMMAND_NAMES, i as validateWechatCliCommandArgs, l as runWechatIdeEngineBuildByHttp, m as WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, n as parse, o as startForwardConsole, p as MINIDEV_NAMESPACE_COMMAND_NAMES, r as dispatchWechatCliCommand, s as isWechatIdeEngineBuildEndpointMissingError, t as createCli, u as handleConfigCommand, v as getAutomatorCommandHelp, w as printCompareHelp, x as parseScreenshotArgs, y as isAutomatorCommand } from "./cli-
|
|
2
|
+
import { $ as getRuntimeWechatDevtoolsServicePort, A as isWechatIdeLoggedIn, C as clearWechatIdeCache, D as getWechatIdeTestAccounts, E as compileWechatIdeByAutomator, F as quitWechatIde, G as transformArgv, H as execute, I as refreshWechatIdeTicket, J as openWechatIdeProjectByHttp, K as promptForCliPath, L as resetWechatIdeFileUtils, M as openWechatIde, N as openWechatIdeOtherProject, O as getWechatIdeTicket, P as previewWechatIde, Q as startWechatIdeEngineBuildByHttp, R as setWechatIdeTicket, S as buildWechatIdeNpm, T as closeWechatIdeProject, U as createAlias, V as runWechatCliWithRetry, W as createPathCompat, X as requestWechatDevtoolsHttp, Y as pollWechatIdeEngineBuildResultByHttp, Z as resetWechatIdeFileUtilsByHttp, _ as autoPreviewWechatIde, a as navigateBack, b as buildWechatIdeApk, c as pageStack, d as remote, et as setRuntimeWechatDevtoolsServicePort, f as scrollTo, g as tap, h as takeScreenshot, i as input, it as removeOption, j as loginWechatIde, k as getWechatIdeToolInfo, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, nt as readBooleanOption, o as navigateTo, p as switchTab, q as WECHAT_DEVTOOLS_ENGINE_BUILD_STATUSES, r as currentPage, rt as readOptionValue, s as pageData, t as audit, tt as parseAutomatorArgs, u as redirectTo, v as autoReplayWechatIde, w as clearWechatIdeCacheByAutomator, x as buildWechatIdeIpa, y as autoWechatIde, z as uploadWechatIde } from "./commands-DuTTBEs8.js";
|
|
3
|
+
import { C as parseCompareArgs, S as printScreenshotHelp, _ as AUTOMATOR_COMMAND_NAMES, a as runMinidev, b as runAutomatorCommand, c as runWechatIdeEngineBuild, d as CONFIG_COMMAND_NAME, f as MCP_COMMAND_NAME, g as isWeappIdeTopLevelCommand, h as WECHAT_CLI_COMMAND_NAMES, i as validateWechatCliCommandArgs, l as runWechatIdeEngineBuildByHttp, m as WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, n as parse, o as startForwardConsole, p as MINIDEV_NAMESPACE_COMMAND_NAMES, r as dispatchWechatCliCommand, s as isWechatIdeEngineBuildEndpointMissingError, t as createCli, u as handleConfigCommand, v as getAutomatorCommandHelp, w as printCompareHelp, x as parseScreenshotArgs, y as isAutomatorCommand } from "./cli-BNnoX0x-.js";
|
|
4
4
|
import { a as readElementSnapshot, i as registerWeappIdeMcpTools, n as startWeappIdeMcpServer, o as resolveProjectPath, r as createWeappIdeMcpServer, s as toSerializableValue, t as runMcpCommand } from "./run-mcp-DPz-bwrD.js";
|
|
5
5
|
export { AUTOMATOR_COMMAND_NAMES, CONFIG_COMMAND_NAME, MCP_COMMAND_NAME, MINIDEV_NAMESPACE_COMMAND_NAMES, RETRY_CANCEL_KEYS, RETRY_CONFIRM_KEYS, RETRY_PROMPT_INITIAL_IGNORE_MS, SupportedPlatformsMap, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, WECHAT_CLI_COMMAND_NAMES, WECHAT_DEVTOOLS_ENGINE_BUILD_STATUSES, acquireSharedMiniProgram, audit, autoPreviewWechatIde, autoReplayWechatIde, autoWechatIde, bootstrapWechatDevtoolsSettings, buildWechatIdeApk, buildWechatIdeIpa, buildWechatIdeNpm, captureScreenshotBuffer, clearWechatIdeCache, clearWechatIdeCacheByAutomator, closeSharedMiniProgram, closeWechatIdeProject, compileWechatIdeByAutomator, connectMiniProgram, connectOpenedAutomator, createAlias, createAutoBootstrapDevtoolsConfig, createAutoTrustProjectConfig, createCli, createCustomConfig, createLocaleConfig, createPathCompat, createSharedInputSession, createWeappIdeMcpServer, createWechatIdeLoginRequiredExitError, currentPage, defaultCustomConfigDirPath, defaultCustomConfigFilePath, detectWechatDevtoolsServicePort, dispatchWechatCliCommand, execute, extractExecutionErrorText, formatAutomatorLoginError, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getAutomatorCommandHelp, getAutomatorProtocolTimeoutMethod, getConfig, getConfiguredLocale, getDefaultCliPath, getRuntimeWechatDevtoolsServicePort, getSharedMiniProgramSessionCount, getWechatIdeTestAccounts, getWechatIdeTicket, getWechatIdeToolInfo, handleConfigCommand, input, isAutomatorCommand, isAutomatorLoginError, isAutomatorProtocolTimeoutError, isAutomatorWsConnectError, isDevtoolsExtensionContextInvalidatedError, isDevtoolsHttpPortError, isOperatingSystemSupported, isRetryableAutomatorLaunchError, isWeappIdeTopLevelCommand, isWechatIdeEngineBuildEndpointMissingError, isWechatIdeLoggedIn, isWechatIdeLoginRequiredError, isWechatIdeLoginRequiredExitError, launchAutomator, loginWechatIde, navigateBack, navigateTo, openWechatIde, openWechatIdeOtherProject, openWechatIdeProjectByHttp, operatingSystemName, overwriteCustomConfig, pageData, pageStack, parse, parseAutomatorArgs, parseCompareArgs, parseScreenshotArgs, pollWechatIdeEngineBuildResultByHttp, previewWechatIde, printCompareHelp, printScreenshotHelp, promptForCliPath, promptRetryKeypress, promptWechatIdeLoginRetry, quitWechatIde, reLaunch, readBooleanOption, readCustomConfig, readElementSnapshot, readOptionValue, redirectTo, refreshWechatIdeTicket, registerWeappIdeMcpTools, releaseSharedMiniProgram, remote, removeCustomConfigKey, removeOption, requestWechatDevtoolsHttp, resetWechatIdeFileUtils, resetWechatIdeFileUtilsByHttp, resolveCliPath, resolveDevtoolsAutomationDefaults, resolvePath, resolveProjectAutomatorPort, resolveProjectPath, runAutomatorCommand, runMcpCommand, runMinidev, runRetryableCommand, runWechatCliWithRetry, runWechatIdeEngineBuild, runWechatIdeEngineBuildByHttp, runWithSuspendedSharedInput, scrollTo, setRuntimeWechatDevtoolsServicePort, setWechatIdeTicket, startForwardConsole, startWeappIdeMcpServer, startWechatIdeEngineBuildByHttp, switchTab, systemInfo, takeScreenshot, tap, toSerializableValue, transformArgv, uploadWechatIde, validateWechatCliCommandArgs, waitForExclusiveKeypress, waitForRetryKeypress, withMiniProgram };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-ide-cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.2",
|
|
5
5
|
"description": "让微信开发者工具,用起来更加方便!",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,17 +62,17 @@
|
|
|
62
62
|
"registry": "https://registry.npmjs.org/"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
65
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
66
66
|
"cac": "^7.0.0",
|
|
67
|
-
"execa": "10.0.
|
|
67
|
+
"execa": "10.0.1",
|
|
68
68
|
"pathe": "^2.0.3",
|
|
69
69
|
"pixelmatch": "^7.2.0",
|
|
70
70
|
"pngjs": "^7.0.0",
|
|
71
71
|
"zod": "^4.4.3",
|
|
72
|
-
"@weapp-vite/devtools-runtime": "0.4.9",
|
|
73
72
|
"@weapp-core/logger": "3.1.1",
|
|
74
|
-
"@weapp-core/shared": "3.0
|
|
75
|
-
"@weapp-vite/
|
|
73
|
+
"@weapp-core/shared": "3.1.0",
|
|
74
|
+
"@weapp-vite/devtools-runtime": "0.4.11",
|
|
75
|
+
"@weapp-vite/miniprogram-automator": "1.2.10"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"dev": "tsdown -w --sourcemap",
|