weapp-ide-cli 5.2.1 → 5.2.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.
- package/dist/{cli-DKrUhSmB.js → cli-1zieDX-6.js} +2 -2
- package/dist/cli.js +2 -2
- package/dist/{commands--vppy2pX.js → commands-38LzU5ML.js} +30 -17
- package/dist/commands-msx1PSZ8.js +2 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/commands-Bg8hQbPE.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as createLocaleConfig, C as configureLocaleFromArgv, G as defaultCustomConfigFilePath, H as readCustomConfig, I as resolveCliPath, K as resolvePath, Q as logger_default, R as getConfiguredLocale, T as validateLocaleOption, U as removeCustomConfigKey, V as overwriteCustomConfig, X as operatingSystemName, Y as isOperatingSystemSupported, Z as colors, a as navigateBack, c as pageStack, d as remote, f as scrollTo, g as tap, i as input, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, o as navigateTo, p as switchTab, r as currentPage, s as pageData, t as audit, u as redirectTo, w as i18nText, y as connectMiniProgram, z as createCustomConfig } from "./commands
|
|
1
|
+
import { B as createLocaleConfig, C as configureLocaleFromArgv, G as defaultCustomConfigFilePath, H as readCustomConfig, I as resolveCliPath, K as resolvePath, Q as logger_default, R as getConfiguredLocale, T as validateLocaleOption, U as removeCustomConfigKey, V as overwriteCustomConfig, X as operatingSystemName, Y as isOperatingSystemSupported, Z as colors, a as navigateBack, c as pageStack, d as remote, f as scrollTo, g as tap, i as input, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, o as navigateTo, p as switchTab, r as currentPage, s as pageData, t as audit, u as redirectTo, w as i18nText, y as connectMiniProgram, z as createCustomConfig } from "./commands-38LzU5ML.js";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import { fs as fs$1 } from "@weapp-core/shared";
|
|
4
4
|
import process, { stdin, stdout } from "node:process";
|
|
@@ -402,7 +402,7 @@ async function runScreenshot(argv) {
|
|
|
402
402
|
}
|
|
403
403
|
const options = parseScreenshotArgs(argv);
|
|
404
404
|
const isJsonOutput = argv.includes("--json");
|
|
405
|
-
const { takeScreenshot } = await import("./commands-
|
|
405
|
+
const { takeScreenshot } = await import("./commands-msx1PSZ8.js");
|
|
406
406
|
const result = await takeScreenshot(options);
|
|
407
407
|
if (isJsonOutput) {
|
|
408
408
|
console.log(JSON.stringify(result, null, 2));
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Q as logger_default } from "./commands
|
|
2
|
-
import { n as parse } from "./cli-
|
|
1
|
+
import { Q as logger_default } from "./commands-38LzU5ML.js";
|
|
2
|
+
import { n as parse } from "./cli-1zieDX-6.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
//#region src/cli.ts
|
|
5
5
|
const argv = process.argv.slice(2);
|
|
@@ -166,12 +166,16 @@ async function overwriteCustomConfig(config) {
|
|
|
166
166
|
}
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/config/resolver.ts
|
|
169
|
+
function isCustomConfigJson(value) {
|
|
170
|
+
return typeof value === "object" && value !== null;
|
|
171
|
+
}
|
|
169
172
|
/**
|
|
170
173
|
* @description 读取并解析 CLI 配置(自定义优先)
|
|
171
174
|
*/
|
|
172
175
|
async function getConfig() {
|
|
173
176
|
if (await fs$1.pathExists(defaultCustomConfigFilePath)) try {
|
|
174
|
-
const
|
|
177
|
+
const rawConfig = await fs$1.readJSON(defaultCustomConfigFilePath);
|
|
178
|
+
const config = isCustomConfigJson(rawConfig) ? rawConfig : {};
|
|
175
179
|
const cliPath = typeof config.cliPath === "string" ? config.cliPath.trim() : "";
|
|
176
180
|
const locale = config.locale === "zh" || config.locale === "en" ? config.locale : void 0;
|
|
177
181
|
if (cliPath) {
|
|
@@ -625,10 +629,14 @@ function cropPngRows(source, startRow, rowCount) {
|
|
|
625
629
|
for (let row = 0; row < rowCount; row += 1) {
|
|
626
630
|
const sourceStart = (startRow + row) * bytesPerRow;
|
|
627
631
|
const sourceEnd = sourceStart + bytesPerRow;
|
|
628
|
-
|
|
632
|
+
cropped.data.set(source.data.subarray(sourceStart, sourceEnd), row * bytesPerRow);
|
|
629
633
|
}
|
|
630
634
|
return cropped;
|
|
631
635
|
}
|
|
636
|
+
async function restoreScrollPosition(miniProgram, page, scrollTop) {
|
|
637
|
+
await miniProgram.pageScrollTo(scrollTop);
|
|
638
|
+
await page.waitFor(150);
|
|
639
|
+
}
|
|
632
640
|
/**
|
|
633
641
|
* @description 通过多次滚动和拼接生成整页长截图。
|
|
634
642
|
*/
|
|
@@ -637,6 +645,7 @@ async function captureFullPageScreenshotBuffer(options) {
|
|
|
637
645
|
const page = await miniProgram.currentPage();
|
|
638
646
|
const pageSize = await page.size();
|
|
639
647
|
const systemInfo = await miniProgram.systemInfo();
|
|
648
|
+
const initialScrollTop = typeof page.scrollTop === "function" ? await page.scrollTop() : 0;
|
|
640
649
|
const pageHeight = toPositiveNumber(pageSize.height);
|
|
641
650
|
const viewportHeight = toPositiveNumber(systemInfo.windowHeight);
|
|
642
651
|
if (!pageHeight || !viewportHeight) return decodeScreenshotBuffer(await runWithTimeout(miniProgram.screenshot(), timeoutMs, screenshotTimeoutMessage, "DEVTOOLS_SCREENSHOT_TIMEOUT"));
|
|
@@ -644,20 +653,24 @@ async function captureFullPageScreenshotBuffer(options) {
|
|
|
644
653
|
const positions = createScrollPositions(pageHeight, viewportHeight);
|
|
645
654
|
let coveredUntil = 0;
|
|
646
655
|
let scale = 1;
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
656
|
+
try {
|
|
657
|
+
for (const scrollTop of positions) {
|
|
658
|
+
await miniProgram.pageScrollTo(scrollTop);
|
|
659
|
+
await page.waitFor(150);
|
|
660
|
+
const rawScreenshot = await runWithTimeout(miniProgram.screenshot(), timeoutMs, screenshotTimeoutMessage, "DEVTOOLS_SCREENSHOT_TIMEOUT");
|
|
661
|
+
const png = PNG.sync.read(decodeScreenshotBuffer(rawScreenshot));
|
|
662
|
+
if (viewportHeight > 0) scale = png.height / viewportHeight;
|
|
663
|
+
const visibleEnd = Math.min(scrollTop + viewportHeight, pageHeight);
|
|
664
|
+
const cropTopCss = Math.max(coveredUntil - scrollTop, 0);
|
|
665
|
+
const segmentHeightCss = Math.max(visibleEnd - scrollTop - cropTopCss, 0);
|
|
666
|
+
if (segmentHeightCss <= 0) continue;
|
|
667
|
+
const cropTopRows = Math.min(Math.max(Math.round(cropTopCss * scale), 0), png.height);
|
|
668
|
+
const segmentRows = Math.min(Math.max(Math.round(segmentHeightCss * scale), 1), png.height - cropTopRows);
|
|
669
|
+
segments.push(cropPngRows(png, cropTopRows, segmentRows));
|
|
670
|
+
coveredUntil = visibleEnd;
|
|
671
|
+
}
|
|
672
|
+
} finally {
|
|
673
|
+
await restoreScrollPosition(miniProgram, page, initialScrollTop);
|
|
661
674
|
}
|
|
662
675
|
if (segments.length === 0) throw new Error("Failed to capture screenshot");
|
|
663
676
|
const width = segments[0].width;
|
|
@@ -672,7 +685,7 @@ async function captureFullPageScreenshotBuffer(options) {
|
|
|
672
685
|
for (let row = 0; row < segment.height; row += 1) {
|
|
673
686
|
const sourceStart = row * bytesPerRow;
|
|
674
687
|
const sourceEnd = sourceStart + bytesPerRow;
|
|
675
|
-
|
|
688
|
+
merged.data.set(segment.data.subarray(sourceStart, sourceEnd), (offsetY + row) * bytesPerRow);
|
|
676
689
|
}
|
|
677
690
|
offsetY += segment.height;
|
|
678
691
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
|
-
import * as _weapp_vite_miniprogram_automator0 from "@weapp-vite/miniprogram-automator";
|
|
2
|
+
import * as _$_weapp_vite_miniprogram_automator0 from "@weapp-vite/miniprogram-automator";
|
|
3
3
|
import { Element, MiniProgram, Page } from "@weapp-vite/miniprogram-automator";
|
|
4
|
-
import * as cac
|
|
5
|
-
import * as execa from "execa";
|
|
4
|
+
import * as _$cac from "cac";
|
|
5
|
+
import * as _$execa from "execa";
|
|
6
6
|
|
|
7
7
|
//#region src/cli/automator.d.ts
|
|
8
8
|
interface AutomatorOptions {
|
|
@@ -51,7 +51,7 @@ declare function launchAutomator(options: AutomatorOptions): Promise<any>;
|
|
|
51
51
|
/**
|
|
52
52
|
* @description 连接当前项目已打开的开发者工具自动化会话,不触发新的 IDE 拉起。
|
|
53
53
|
*/
|
|
54
|
-
declare function connectOpenedAutomator(options: AutomatorOptions): Promise<_weapp_vite_miniprogram_automator0.MiniProgram>;
|
|
54
|
+
declare function connectOpenedAutomator(options: AutomatorOptions): Promise<_$_weapp_vite_miniprogram_automator0.MiniProgram>;
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/cli/automator-argv.d.ts
|
|
57
57
|
interface ParsedAutomatorArgs {
|
|
@@ -333,7 +333,7 @@ declare function formatRetryHotkeyPrompt(timeoutMs?: number): string;
|
|
|
333
333
|
/**
|
|
334
334
|
* @description 基于 cac 注册顶层命令,用于统一识别入口。
|
|
335
335
|
*/
|
|
336
|
-
declare function createCli(): cac
|
|
336
|
+
declare function createCli(): _$cac.CAC;
|
|
337
337
|
/**
|
|
338
338
|
* @description CLI 入口解析与分发。
|
|
339
339
|
*/
|
|
@@ -499,7 +499,7 @@ interface ExecuteOptions {
|
|
|
499
499
|
/**
|
|
500
500
|
* @description 执行 CLI 命令并透传输出
|
|
501
501
|
*/
|
|
502
|
-
declare function execute(cliPath: string, argv: string[], options?: ExecuteOptions): Promise<execa.Result<{}>>;
|
|
502
|
+
declare function execute(cliPath: string, argv: string[], options?: ExecuteOptions): Promise<_$execa.Result<{}>>;
|
|
503
503
|
//#endregion
|
|
504
504
|
//#region src/utils/path.d.ts
|
|
505
505
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as isAutomatorProtocolTimeoutError, B as createLocaleConfig, D as formatAutomatorLoginError, E as connectOpenedAutomator, F as launchAutomator, G as defaultCustomConfigFilePath, H as readCustomConfig, I as resolveCliPath, J as getDefaultCliPath, K as resolvePath, L as getConfig, M as isDevtoolsExtensionContextInvalidatedError, N as isDevtoolsHttpPortError, O as getAutomatorProtocolTimeoutMethod, P as isRetryableAutomatorLaunchError, R as getConfiguredLocale, S as withMiniProgram, U as removeCustomConfigKey, V as overwriteCustomConfig, W as defaultCustomConfigDirPath, X as operatingSystemName, Y as isOperatingSystemSupported, _ as acquireSharedMiniProgram, a as navigateBack, b as getSharedMiniProgramSessionCount, c as pageStack, d as remote, f as scrollTo, g as tap, h as takeScreenshot, i as input, j as isAutomatorWsConnectError, k as isAutomatorLoginError, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, o as navigateTo, p as switchTab, q as SupportedPlatformsMap, r as currentPage, s as pageData, t as audit, u as redirectTo, v as closeSharedMiniProgram, x as releaseSharedMiniProgram, y as connectMiniProgram, z as createCustomConfig } from "./commands
|
|
2
|
-
import { A as parseCompareArgs, C as isWeappIdeTopLevelCommand, D as runAutomatorCommand, E as isAutomatorCommand, M as parseAutomatorArgs, N as readOptionValue, O as parseScreenshotArgs, P as removeOption, S as WECHAT_CLI_COMMAND_NAMES, T as getAutomatorCommandHelp, _ as handleConfigCommand, a as createWechatIdeLoginRequiredExitError, b as MINIDEV_NAMESPACE_COMMAND_NAMES, c as formatWechatIdeLoginRequiredError, d as runMinidev, f as execute, g as startForwardConsole, h as transformArgv, i as runWechatCliWithRetry, j as printCompareHelp, k as printScreenshotHelp, l as isWechatIdeLoginRequiredError, m as createPathCompat, n as parse, o as extractExecutionErrorText, p as createAlias, r as validateWechatCliCommandArgs, s as formatRetryHotkeyPrompt, t as createCli, u as waitForRetryKeypress, v as promptForCliPath, w as AUTOMATOR_COMMAND_NAMES, x as WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, y as CONFIG_COMMAND_NAME } from "./cli-
|
|
1
|
+
import { A as isAutomatorProtocolTimeoutError, B as createLocaleConfig, D as formatAutomatorLoginError, E as connectOpenedAutomator, F as launchAutomator, G as defaultCustomConfigFilePath, H as readCustomConfig, I as resolveCliPath, J as getDefaultCliPath, K as resolvePath, L as getConfig, M as isDevtoolsExtensionContextInvalidatedError, N as isDevtoolsHttpPortError, O as getAutomatorProtocolTimeoutMethod, P as isRetryableAutomatorLaunchError, R as getConfiguredLocale, S as withMiniProgram, U as removeCustomConfigKey, V as overwriteCustomConfig, W as defaultCustomConfigDirPath, X as operatingSystemName, Y as isOperatingSystemSupported, _ as acquireSharedMiniProgram, a as navigateBack, b as getSharedMiniProgramSessionCount, c as pageStack, d as remote, f as scrollTo, g as tap, h as takeScreenshot, i as input, j as isAutomatorWsConnectError, k as isAutomatorLoginError, l as reLaunch, m as systemInfo, n as captureScreenshotBuffer, o as navigateTo, p as switchTab, q as SupportedPlatformsMap, r as currentPage, s as pageData, t as audit, u as redirectTo, v as closeSharedMiniProgram, x as releaseSharedMiniProgram, y as connectMiniProgram, z as createCustomConfig } from "./commands-38LzU5ML.js";
|
|
2
|
+
import { A as parseCompareArgs, C as isWeappIdeTopLevelCommand, D as runAutomatorCommand, E as isAutomatorCommand, M as parseAutomatorArgs, N as readOptionValue, O as parseScreenshotArgs, P as removeOption, S as WECHAT_CLI_COMMAND_NAMES, T as getAutomatorCommandHelp, _ as handleConfigCommand, a as createWechatIdeLoginRequiredExitError, b as MINIDEV_NAMESPACE_COMMAND_NAMES, c as formatWechatIdeLoginRequiredError, d as runMinidev, f as execute, g as startForwardConsole, h as transformArgv, i as runWechatCliWithRetry, j as printCompareHelp, k as printScreenshotHelp, l as isWechatIdeLoginRequiredError, m as createPathCompat, n as parse, o as extractExecutionErrorText, p as createAlias, r as validateWechatCliCommandArgs, s as formatRetryHotkeyPrompt, t as createCli, u as waitForRetryKeypress, v as promptForCliPath, w as AUTOMATOR_COMMAND_NAMES, x as WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, y as CONFIG_COMMAND_NAME } from "./cli-1zieDX-6.js";
|
|
3
3
|
export { AUTOMATOR_COMMAND_NAMES, CONFIG_COMMAND_NAME, MINIDEV_NAMESPACE_COMMAND_NAMES, SupportedPlatformsMap, WEAPP_IDE_TOP_LEVEL_COMMAND_NAMES, WECHAT_CLI_COMMAND_NAMES, acquireSharedMiniProgram, audit, captureScreenshotBuffer, closeSharedMiniProgram, connectMiniProgram, connectOpenedAutomator, createAlias, createCli, createCustomConfig, createLocaleConfig, createPathCompat, createWechatIdeLoginRequiredExitError, currentPage, defaultCustomConfigDirPath, defaultCustomConfigFilePath, execute, extractExecutionErrorText, formatAutomatorLoginError, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getAutomatorCommandHelp, getAutomatorProtocolTimeoutMethod, getConfig, getConfiguredLocale, getDefaultCliPath, getSharedMiniProgramSessionCount, handleConfigCommand, input, isAutomatorCommand, isAutomatorLoginError, isAutomatorProtocolTimeoutError, isAutomatorWsConnectError, isDevtoolsExtensionContextInvalidatedError, isDevtoolsHttpPortError, isOperatingSystemSupported, isRetryableAutomatorLaunchError, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, navigateBack, navigateTo, operatingSystemName, overwriteCustomConfig, pageData, pageStack, parse, parseAutomatorArgs, parseCompareArgs, parseScreenshotArgs, printCompareHelp, printScreenshotHelp, promptForCliPath, reLaunch, readCustomConfig, readOptionValue, redirectTo, releaseSharedMiniProgram, remote, removeCustomConfigKey, removeOption, resolveCliPath, resolvePath, runAutomatorCommand, runMinidev, runWechatCliWithRetry, scrollTo, startForwardConsole, switchTab, systemInfo, takeScreenshot, tap, transformArgv, validateWechatCliCommandArgs, waitForRetryKeypress, withMiniProgram };
|
package/package.json
CHANGED