weapp-vite 6.13.4 → 6.14.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/auto-import-components/resolvers.d.mts +1 -1
- package/dist/auto-routes.d.mts +1 -1
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +532 -160
- package/dist/config-DJjSbpNX.mjs +6 -0
- package/dist/{config-CiuNcUYK.d.mts → config-bkgtM4wZ.d.mts} +2 -2
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +2 -6
- package/dist/{createContext-Bb4OSo1-.mjs → createContext-BolxgJjC.mjs} +5 -11
- package/dist/file-DgJb3pIf.mjs +2 -0
- package/dist/{file-Cf3pf5w7.mjs → file-Ej-4GoYg.mjs} +2 -18
- package/dist/getInstance-CVtFkrEA.mjs +2 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +4 -4
- package/dist/json-D0HkutE0.mjs +33 -0
- package/dist/json.d.mts +1 -1
- package/dist/json.mjs +1 -32
- package/dist/mcp-DRlj32v4.mjs +39 -0
- package/dist/mcp.d.mts +1 -1
- package/dist/mcp.mjs +1 -38
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/types.d.mts +3 -3
- package/package.json +9 -9
- package/dist/rolldown-runtime-twds-ZHy.mjs +0 -14
- /package/dist/{index-CUFOUU8V.d.mts → index-hN5mdpQ_.d.mts} +0 -0
- /package/dist/{logger-gutcwWKE.mjs → logger-CgxdNjvb.mjs} +0 -0
- /package/dist/{routes-o20IHwXa.d.mts → routes-DiEBrMtj.d.mts} +0 -0
- /package/dist/{runtime-CpQutkhu.d.mts → runtime-58wbbRDf.d.mts} +0 -0
- /package/dist/{runtime-gyZnAGCZ.mjs → runtime-tVnzZwtl.mjs} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ExternalMetadataFileCandidates, c as Resolver, d as ResolverObject, f as ResolverSupportFilesStrategy, i as CreateResolver, l as ResolverFn, n as VantResolver, o as Options, r as TDesignResolver, s as ResolvedValue, t as WeuiResolver, u as ResolverMeta } from "../index-
|
|
1
|
+
import { a as ExternalMetadataFileCandidates, c as Resolver, d as ResolverObject, f as ResolverSupportFilesStrategy, i as CreateResolver, l as ResolverFn, n as VantResolver, o as Options, r as TDesignResolver, s as ResolvedValue, t as WeuiResolver, u as ResolverMeta } from "../index-hN5mdpQ_.mjs";
|
|
2
2
|
export { CreateResolver, ExternalMetadataFileCandidates, Options, ResolvedValue, Resolver, ResolverFn, ResolverMeta, ResolverObject, ResolverSupportFilesStrategy, TDesignResolver, VantResolver, WeuiResolver };
|
package/dist/auto-routes.d.mts
CHANGED
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getCompilerContext,
|
|
1
|
+
import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-BolxgJjC.mjs";
|
|
2
2
|
//#region src/auto-routes.ts
|
|
3
3
|
const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
|
|
4
4
|
function createGetter(resolver) {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { r as logger_default, t as colors } from "./logger-
|
|
3
|
-
import {
|
|
4
|
-
import { resolveWeappMcpConfig, startWeappViteMcpServer } from "./mcp.mjs";
|
|
1
|
+
import { S as isPathInside, _ as DEFAULT_MP_PLATFORM, b as resolveMiniPlatform, c as createSharedBuildConfig, d as resolveWeappConfigFile, f as checkRuntime, g as createCjsConfigLoadError, h as parseCommentJson, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as loadViteConfigFile, n as syncProjectSupportFiles, p as getProjectConfigFileName, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as getDefaultIdeProjectRoot, x as shouldPassPlatformArgToIdeOpen, y as normalizeMiniPlatform } from "./createContext-BolxgJjC.mjs";
|
|
2
|
+
import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
|
|
3
|
+
import { m as VERSION } from "./file-Ej-4GoYg.mjs";
|
|
4
|
+
import { a as resolveWeappMcpConfig, o as startWeappViteMcpServer } from "./mcp-DRlj32v4.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import { defu, fs } from "@weapp-core/shared";
|
|
7
7
|
import path, { posix } from "pathe";
|
|
@@ -14,10 +14,11 @@ import fs$2 from "node:fs";
|
|
|
14
14
|
import { cac } from "cac";
|
|
15
15
|
import { resolveCommand } from "package-manager-detector/commands";
|
|
16
16
|
import { promisify } from "node:util";
|
|
17
|
-
import { formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getConfig, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, parse, startForwardConsole, waitForRetryKeypress } from "weapp-ide-cli";
|
|
17
|
+
import { closeSharedMiniProgram, connectOpenedAutomator, formatRetryHotkeyPrompt, formatWechatIdeLoginRequiredError, getConfig, isWeappIdeTopLevelCommand, isWechatIdeLoginRequiredError, launchAutomator, parse, startForwardConsole, takeScreenshot, waitForRetryKeypress } from "weapp-ide-cli";
|
|
18
18
|
import { generateJs, generateJson, generateWxml, generateWxss } from "@weapp-core/schematics";
|
|
19
19
|
import { determineAgent } from "@vercel/detect-agent";
|
|
20
20
|
import { initConfig } from "@weapp-core/init";
|
|
21
|
+
import { emitKeypressEvents } from "node:readline";
|
|
21
22
|
//#region src/analyze/subpackages/classifier.ts
|
|
22
23
|
const VIRTUAL_MODULE_INDICATOR = "\0";
|
|
23
24
|
const VIRTUAL_PREFIX = `${SHARED_CHUNK_VIRTUAL_PREFIX}/`;
|
|
@@ -950,13 +951,27 @@ function logBuildPackageSizeReport(options) {
|
|
|
950
951
|
//#region src/cli/openIde.ts
|
|
951
952
|
const execFileAsync = promisify(execFile);
|
|
952
953
|
async function openWechatIdeByAutomator(projectPath) {
|
|
953
|
-
|
|
954
|
-
(await new Launcher().launch({
|
|
954
|
+
(await launchAutomator({
|
|
955
955
|
projectPath,
|
|
956
956
|
trustProject: true
|
|
957
957
|
})).disconnect();
|
|
958
958
|
}
|
|
959
959
|
/**
|
|
960
|
+
* @description 若当前项目已在微信开发者工具中打开且自动化可连通,则直接复用现有会话,避免重复拉起 IDE。
|
|
961
|
+
*/
|
|
962
|
+
async function tryReuseOpenedWechatIde(projectPath) {
|
|
963
|
+
try {
|
|
964
|
+
(await connectOpenedAutomator({
|
|
965
|
+
projectPath,
|
|
966
|
+
timeout: 3e3
|
|
967
|
+
})).disconnect();
|
|
968
|
+
logger_default.info("目标项目已在微信开发者工具中打开,跳过重复打开。");
|
|
969
|
+
return true;
|
|
970
|
+
} catch {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
960
975
|
* @description 执行 IDE 打开流程,并在登录失效时允许按键重试。
|
|
961
976
|
*/
|
|
962
977
|
async function runWechatIdeOpenWithRetry(argv) {
|
|
@@ -1017,6 +1032,7 @@ function resolveIdeProjectRoot(mpDistRoot, cwd) {
|
|
|
1017
1032
|
}
|
|
1018
1033
|
async function openIde(platform, projectPath, options = {}) {
|
|
1019
1034
|
if (platform === "weapp" && projectPath && options.trustProject !== false) try {
|
|
1035
|
+
if (await tryReuseOpenedWechatIde(projectPath)) return;
|
|
1020
1036
|
await openWechatIdeByAutomator(projectPath);
|
|
1021
1037
|
return;
|
|
1022
1038
|
} catch (error) {
|
|
@@ -1665,6 +1681,339 @@ function registerPrepareCommand(cli) {
|
|
|
1665
1681
|
});
|
|
1666
1682
|
}
|
|
1667
1683
|
//#endregion
|
|
1684
|
+
//#region package.json
|
|
1685
|
+
var version = "6.14.0";
|
|
1686
|
+
//#endregion
|
|
1687
|
+
//#region src/cli/devHotkeys.ts
|
|
1688
|
+
const DEV_SCREENSHOT_DIR = ".tmp/weapp-vite-dev-screenshots";
|
|
1689
|
+
const DEFAULT_SCREENSHOT_TIMEOUT = 3e4;
|
|
1690
|
+
const REG_PENDING_PREFIX = /^正在/;
|
|
1691
|
+
const FULLWIDTH_ASCII_START = 65281;
|
|
1692
|
+
const FULLWIDTH_ASCII_END = 65374;
|
|
1693
|
+
const FULLWIDTH_ASCII_OFFSET = 65248;
|
|
1694
|
+
const HOTKEY_DEDUP_WINDOW_MS = 32;
|
|
1695
|
+
function formatMcpUrl(host, port, endpoint) {
|
|
1696
|
+
return `http://${host}:${port}${endpoint}`;
|
|
1697
|
+
}
|
|
1698
|
+
function forwardSigint() {
|
|
1699
|
+
process.kill(process.pid, "SIGINT");
|
|
1700
|
+
}
|
|
1701
|
+
function forwardSigtstp() {
|
|
1702
|
+
process.kill(process.pid, "SIGTSTP");
|
|
1703
|
+
}
|
|
1704
|
+
function formatProjectLabel(cwd) {
|
|
1705
|
+
return path.basename(cwd) || cwd;
|
|
1706
|
+
}
|
|
1707
|
+
function formatMcpStatus(state) {
|
|
1708
|
+
if (!state.mcpEnabled) return "已禁用";
|
|
1709
|
+
return state.mcpRunning ? "运行中" : "未启动";
|
|
1710
|
+
}
|
|
1711
|
+
function formatFooterLine(state) {
|
|
1712
|
+
if (state.currentAction) return `执行中 ${state.currentAction}`;
|
|
1713
|
+
return "就绪 等待操作...";
|
|
1714
|
+
}
|
|
1715
|
+
/**
|
|
1716
|
+
* @description 生成带状态的开发态快捷键帮助文本。
|
|
1717
|
+
*/
|
|
1718
|
+
function formatDevHotkeyHelpWithState(state) {
|
|
1719
|
+
const key = (value) => colors.bold(colors.green(value));
|
|
1720
|
+
const actionRows = [{
|
|
1721
|
+
key: key("s"),
|
|
1722
|
+
description: "截图当前页面并保存到本地"
|
|
1723
|
+
}, {
|
|
1724
|
+
key: key("m"),
|
|
1725
|
+
description: "开关 MCP 服务"
|
|
1726
|
+
}];
|
|
1727
|
+
const processRows = [
|
|
1728
|
+
{
|
|
1729
|
+
key: key("q"),
|
|
1730
|
+
description: "退出当前 dev"
|
|
1731
|
+
},
|
|
1732
|
+
{
|
|
1733
|
+
key: key("Ctrl+C"),
|
|
1734
|
+
description: "强制中断当前 dev"
|
|
1735
|
+
},
|
|
1736
|
+
{
|
|
1737
|
+
key: key("Ctrl+Z"),
|
|
1738
|
+
description: "暂时挂起当前 dev,恢复终端控制"
|
|
1739
|
+
}
|
|
1740
|
+
];
|
|
1741
|
+
const helpRows = [{
|
|
1742
|
+
key: key("h"),
|
|
1743
|
+
description: "重新显示这份帮助"
|
|
1744
|
+
}];
|
|
1745
|
+
const keyColumnWidth = Math.max(...[
|
|
1746
|
+
...actionRows,
|
|
1747
|
+
...processRows,
|
|
1748
|
+
...helpRows
|
|
1749
|
+
].map((row) => row.key.length));
|
|
1750
|
+
const formatRows = (rows) => rows.map(({ key, description }) => `按 ${key.padEnd(keyColumnWidth)} ${description}`);
|
|
1751
|
+
return [
|
|
1752
|
+
`${colors.bold(colors.green("DEV"))} weapp-vite v${version} ${state.projectLabel ?? "weapp"}`,
|
|
1753
|
+
"",
|
|
1754
|
+
"快捷命令",
|
|
1755
|
+
...formatRows(actionRows),
|
|
1756
|
+
"",
|
|
1757
|
+
"进程控制",
|
|
1758
|
+
...formatRows(processRows),
|
|
1759
|
+
"",
|
|
1760
|
+
"帮助",
|
|
1761
|
+
...formatRows(helpRows),
|
|
1762
|
+
"",
|
|
1763
|
+
`当前状态:${state.currentAction ?? "等待操作"} / MCP ${formatMcpStatus(state)}`
|
|
1764
|
+
].join("\n");
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* @description 生成带状态的开发态快捷键简短提示。
|
|
1768
|
+
*/
|
|
1769
|
+
function formatDevHotkeyHintWithState(state) {
|
|
1770
|
+
const key = (value) => colors.bold(colors.green(value));
|
|
1771
|
+
if (state.currentAction) return `${formatFooterLine(state)},按 ${key("h")} 显示帮助,按 ${key("q")} 退出`;
|
|
1772
|
+
return `开发快捷键已就绪,按 ${key("h")} 显示帮助,按 ${key("q")} 退出`;
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* @description 生成开发态截图输出路径。
|
|
1776
|
+
*/
|
|
1777
|
+
function resolveDevScreenshotOutputPath(cwd, now = /* @__PURE__ */ new Date()) {
|
|
1778
|
+
const stamp = now.toISOString().replace(/[:.]/g, "-");
|
|
1779
|
+
return path.join(cwd, DEV_SCREENSHOT_DIR, `screenshot-${stamp}.png`);
|
|
1780
|
+
}
|
|
1781
|
+
function formatLogPath(cwd, targetPath) {
|
|
1782
|
+
const relativePath = path.relative(cwd, targetPath);
|
|
1783
|
+
if (!relativePath || relativePath.startsWith("..")) return targetPath;
|
|
1784
|
+
return relativePath;
|
|
1785
|
+
}
|
|
1786
|
+
function formatResolvedScreenshotPath(cwd, fallbackPath, result) {
|
|
1787
|
+
return formatLogPath(cwd, result.path ?? fallbackPath);
|
|
1788
|
+
}
|
|
1789
|
+
function normalizeInputChar(input) {
|
|
1790
|
+
if (input.length !== 1) return input;
|
|
1791
|
+
const codePoint = input.codePointAt(0);
|
|
1792
|
+
if (!codePoint) return input;
|
|
1793
|
+
if (codePoint >= FULLWIDTH_ASCII_START && codePoint <= FULLWIDTH_ASCII_END) return String.fromCodePoint(codePoint - FULLWIDTH_ASCII_OFFSET);
|
|
1794
|
+
return input;
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1797
|
+
* @description 执行当前页面截图并输出结果日志。
|
|
1798
|
+
*/
|
|
1799
|
+
async function runScreenshotAction(options) {
|
|
1800
|
+
const outputPath = resolveDevScreenshotOutputPath(options.cwd);
|
|
1801
|
+
await fs$1.mkdir(path.dirname(outputPath), { recursive: true });
|
|
1802
|
+
logger_default.info(`[dev action] 正在截图当前页面,输出到 ${colors.cyan(formatLogPath(options.cwd, outputPath))}`);
|
|
1803
|
+
const result = await takeScreenshot({
|
|
1804
|
+
fullPage: true,
|
|
1805
|
+
projectPath: options.projectPath,
|
|
1806
|
+
sharedSession: true,
|
|
1807
|
+
outputPath,
|
|
1808
|
+
timeout: DEFAULT_SCREENSHOT_TIMEOUT
|
|
1809
|
+
});
|
|
1810
|
+
const resolvedPath = formatResolvedScreenshotPath(options.cwd, outputPath, result);
|
|
1811
|
+
logger_default.success(`[dev action] 当前页面截图完成:${colors.cyan(resolvedPath)}`);
|
|
1812
|
+
return resolvedPath;
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* @description 在开发态启动终端快捷键,并将动作输出到本地日志。
|
|
1816
|
+
*/
|
|
1817
|
+
function startDevHotkeys(options) {
|
|
1818
|
+
if (options.platform !== "weapp" || !process.stdin.isTTY) return;
|
|
1819
|
+
emitKeypressEvents(process.stdin);
|
|
1820
|
+
const hasSetRawMode = typeof process.stdin.setRawMode === "function";
|
|
1821
|
+
if (hasSetRawMode) process.stdin.setRawMode(true);
|
|
1822
|
+
process.stdin.resume();
|
|
1823
|
+
let closed = false;
|
|
1824
|
+
let running = false;
|
|
1825
|
+
let mcpHandle;
|
|
1826
|
+
let onData;
|
|
1827
|
+
let onKeypress;
|
|
1828
|
+
let onSigcont;
|
|
1829
|
+
let currentAction;
|
|
1830
|
+
let lastAction;
|
|
1831
|
+
let lastRenderedPanel = "";
|
|
1832
|
+
const recentInputs = /* @__PURE__ */ new Map();
|
|
1833
|
+
const resolvedMcp = resolveWeappMcpConfig(options.mcpConfig);
|
|
1834
|
+
const getState = () => ({
|
|
1835
|
+
currentAction,
|
|
1836
|
+
lastAction,
|
|
1837
|
+
mcpEnabled: resolvedMcp.enabled,
|
|
1838
|
+
mcpRunning: Boolean(mcpHandle?.close),
|
|
1839
|
+
projectLabel: formatProjectLabel(options.cwd)
|
|
1840
|
+
});
|
|
1841
|
+
const detachTerminal = () => {
|
|
1842
|
+
if (hasSetRawMode) process.stdin.setRawMode(false);
|
|
1843
|
+
process.stdin.pause();
|
|
1844
|
+
};
|
|
1845
|
+
const attachTerminal = () => {
|
|
1846
|
+
if (closed) return;
|
|
1847
|
+
if (hasSetRawMode) process.stdin.setRawMode(true);
|
|
1848
|
+
process.stdin.resume();
|
|
1849
|
+
};
|
|
1850
|
+
const ensureTerminalActive = () => {
|
|
1851
|
+
if (closed) return;
|
|
1852
|
+
if (hasSetRawMode) process.stdin.setRawMode(true);
|
|
1853
|
+
process.stdin.resume();
|
|
1854
|
+
};
|
|
1855
|
+
const close = () => {
|
|
1856
|
+
if (closed) return;
|
|
1857
|
+
closed = true;
|
|
1858
|
+
if (onData) process.stdin.off("data", onData);
|
|
1859
|
+
if (onKeypress) process.stdin.off("keypress", onKeypress);
|
|
1860
|
+
if (onSigcont) process.off("SIGCONT", onSigcont);
|
|
1861
|
+
detachTerminal();
|
|
1862
|
+
if (mcpHandle?.close) mcpHandle.close().catch((error) => {
|
|
1863
|
+
logger_default.warn(`[dev action] MCP 服务关闭失败:${error instanceof Error ? error.message : String(error)}`);
|
|
1864
|
+
});
|
|
1865
|
+
closeSharedMiniProgram(options.projectPath).catch((error) => {
|
|
1866
|
+
logger_default.warn(`[dev action] DevTools 会话关闭失败:${error instanceof Error ? error.message : String(error)}`);
|
|
1867
|
+
});
|
|
1868
|
+
};
|
|
1869
|
+
const printPanel = (message, force = false) => {
|
|
1870
|
+
if (!force && message === lastRenderedPanel) return;
|
|
1871
|
+
lastRenderedPanel = message;
|
|
1872
|
+
logger_default.info(message);
|
|
1873
|
+
};
|
|
1874
|
+
const printHelp = () => {
|
|
1875
|
+
printPanel(formatDevHotkeyHelpWithState(getState()), true);
|
|
1876
|
+
ensureTerminalActive();
|
|
1877
|
+
};
|
|
1878
|
+
const printHint = () => {
|
|
1879
|
+
printPanel(formatDevHotkeyHintWithState(getState()));
|
|
1880
|
+
ensureTerminalActive();
|
|
1881
|
+
};
|
|
1882
|
+
const restore = () => {
|
|
1883
|
+
if (closed) return;
|
|
1884
|
+
if (onData) process.stdin.off("data", onData);
|
|
1885
|
+
if (onKeypress) process.stdin.off("keypress", onKeypress);
|
|
1886
|
+
attachTerminal();
|
|
1887
|
+
if (onData) process.stdin.on("data", onData);
|
|
1888
|
+
if (onKeypress) process.stdin.on("keypress", onKeypress);
|
|
1889
|
+
printHint();
|
|
1890
|
+
};
|
|
1891
|
+
const suspend = () => {
|
|
1892
|
+
lastRenderedPanel = "";
|
|
1893
|
+
detachTerminal();
|
|
1894
|
+
forwardSigtstp();
|
|
1895
|
+
};
|
|
1896
|
+
const toggleMcp = async () => {
|
|
1897
|
+
if (!resolvedMcp.enabled) {
|
|
1898
|
+
logger_default.warn("[dev action] MCP 已在配置中禁用,跳过切换。");
|
|
1899
|
+
return "MCP 已禁用";
|
|
1900
|
+
}
|
|
1901
|
+
if (mcpHandle?.close) {
|
|
1902
|
+
const url = formatMcpUrl(resolvedMcp.host, resolvedMcp.port, resolvedMcp.endpoint);
|
|
1903
|
+
logger_default.info(`[dev action] 正在关闭 MCP 服务:${colors.cyan(url)}`);
|
|
1904
|
+
await mcpHandle.close();
|
|
1905
|
+
mcpHandle = void 0;
|
|
1906
|
+
logger_default.success(`[dev action] MCP 服务已关闭:${colors.cyan(url)}`);
|
|
1907
|
+
return `MCP 已关闭 (${url})`;
|
|
1908
|
+
}
|
|
1909
|
+
const url = formatMcpUrl(resolvedMcp.host, resolvedMcp.port, resolvedMcp.endpoint);
|
|
1910
|
+
logger_default.info(`[dev action] 正在启动 MCP 服务:${colors.cyan(url)}`);
|
|
1911
|
+
mcpHandle = await startWeappViteMcpServer({
|
|
1912
|
+
endpoint: resolvedMcp.endpoint,
|
|
1913
|
+
host: resolvedMcp.host,
|
|
1914
|
+
port: resolvedMcp.port,
|
|
1915
|
+
transport: "streamable-http",
|
|
1916
|
+
unref: false,
|
|
1917
|
+
workspaceRoot: options.cwd
|
|
1918
|
+
});
|
|
1919
|
+
logger_default.success(`[dev action] MCP 服务已启动:${colors.cyan(url)}`);
|
|
1920
|
+
return `MCP 已启动 (${url})`;
|
|
1921
|
+
};
|
|
1922
|
+
const runAction = (label, pendingLabel, action) => {
|
|
1923
|
+
if (running) {
|
|
1924
|
+
const current = currentAction ?? "已有命令";
|
|
1925
|
+
logger_default.warn(`[dev action] 当前正在${current.replace(REG_PENDING_PREFIX, "")},请稍后再试。`);
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
running = true;
|
|
1929
|
+
currentAction = pendingLabel;
|
|
1930
|
+
printHint();
|
|
1931
|
+
action().then((summary) => {
|
|
1932
|
+
if (summary) lastAction = summary;
|
|
1933
|
+
}).catch((error) => {
|
|
1934
|
+
logger_default.error(`[dev action] ${label}失败:${error instanceof Error ? error.message : String(error)}`);
|
|
1935
|
+
}).finally(() => {
|
|
1936
|
+
running = false;
|
|
1937
|
+
currentAction = void 0;
|
|
1938
|
+
if (!closed) printHint();
|
|
1939
|
+
});
|
|
1940
|
+
};
|
|
1941
|
+
const handleInput = (input) => {
|
|
1942
|
+
if (closed) return;
|
|
1943
|
+
const normalizedInput = normalizeInputChar(input);
|
|
1944
|
+
if (normalizedInput === "") {
|
|
1945
|
+
close();
|
|
1946
|
+
forwardSigint();
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
if (normalizedInput === "") {
|
|
1950
|
+
suspend();
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
const normalized = normalizedInput.toLowerCase();
|
|
1954
|
+
if (normalized === "q") {
|
|
1955
|
+
close();
|
|
1956
|
+
forwardSigint();
|
|
1957
|
+
return;
|
|
1958
|
+
}
|
|
1959
|
+
if (normalized === "h") {
|
|
1960
|
+
printHelp();
|
|
1961
|
+
return;
|
|
1962
|
+
}
|
|
1963
|
+
if (normalized === "s") {
|
|
1964
|
+
runAction("截图", "正在截图当前页面", async () => {
|
|
1965
|
+
return `截图已保存到 ${await runScreenshotAction(options)}`;
|
|
1966
|
+
});
|
|
1967
|
+
return;
|
|
1968
|
+
}
|
|
1969
|
+
if (normalized === "m") runAction("MCP 切换", mcpHandle?.close ? "正在关闭 MCP 服务" : "正在启动 MCP 服务", async () => {
|
|
1970
|
+
return await toggleMcp();
|
|
1971
|
+
});
|
|
1972
|
+
};
|
|
1973
|
+
const handleInputOnce = (input, source) => {
|
|
1974
|
+
const normalizedInput = normalizeInputChar(input);
|
|
1975
|
+
const now = Date.now();
|
|
1976
|
+
for (const [token, timestamp] of recentInputs) if (now - timestamp > HOTKEY_DEDUP_WINDOW_MS) recentInputs.delete(token);
|
|
1977
|
+
const dedupKey = normalizedInput;
|
|
1978
|
+
const recentEntry = recentInputs.get(dedupKey);
|
|
1979
|
+
if (recentEntry !== void 0) {
|
|
1980
|
+
const [recentSource, recentTimestamp] = recentEntry.split(":");
|
|
1981
|
+
if (recentSource !== source && now - Number(recentTimestamp) <= HOTKEY_DEDUP_WINDOW_MS) return;
|
|
1982
|
+
}
|
|
1983
|
+
recentInputs.set(dedupKey, `${source}:${now}`);
|
|
1984
|
+
handleInput(normalizedInput);
|
|
1985
|
+
};
|
|
1986
|
+
onData = (chunk) => {
|
|
1987
|
+
const text = typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
|
|
1988
|
+
for (const char of text) handleInputOnce(char, "data");
|
|
1989
|
+
};
|
|
1990
|
+
process.stdin.on("data", onData);
|
|
1991
|
+
onKeypress = (str, key) => {
|
|
1992
|
+
if (key?.ctrl && key.name === "c") {
|
|
1993
|
+
handleInputOnce("", "keypress");
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
if (key?.ctrl && key.name === "z") {
|
|
1997
|
+
handleInputOnce("", "keypress");
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
if (typeof str === "string" && str) handleInputOnce(str, "keypress");
|
|
2001
|
+
};
|
|
2002
|
+
process.stdin.on("keypress", onKeypress);
|
|
2003
|
+
onSigcont = () => {
|
|
2004
|
+
restore();
|
|
2005
|
+
};
|
|
2006
|
+
process.on("SIGCONT", onSigcont);
|
|
2007
|
+
if (!options.silentStartupHint) printHint();
|
|
2008
|
+
if (resolvedMcp.enabled && resolvedMcp.autoStart) runAction("MCP 自动启动", "正在启动 MCP 服务", async () => {
|
|
2009
|
+
await toggleMcp();
|
|
2010
|
+
});
|
|
2011
|
+
return {
|
|
2012
|
+
close,
|
|
2013
|
+
restore
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
//#endregion
|
|
1668
2017
|
//#region src/cli/commands/serve.ts
|
|
1669
2018
|
function emitDashboardEvents(handle, events) {
|
|
1670
2019
|
handle?.emitRuntimeEvents(events);
|
|
@@ -1680,6 +2029,17 @@ const REG_DIST_POSIX_SEP = /\\/g;
|
|
|
1680
2029
|
function hasAnalyzeData(result) {
|
|
1681
2030
|
return result.packages.length > 0 || result.modules.length > 0;
|
|
1682
2031
|
}
|
|
2032
|
+
function waitForServeShutdownSignal() {
|
|
2033
|
+
return new Promise((resolve) => {
|
|
2034
|
+
const onSignal = () => {
|
|
2035
|
+
process.off("SIGINT", onSignal);
|
|
2036
|
+
process.off("SIGTERM", onSignal);
|
|
2037
|
+
resolve();
|
|
2038
|
+
};
|
|
2039
|
+
process.on("SIGINT", onSignal);
|
|
2040
|
+
process.on("SIGTERM", onSignal);
|
|
2041
|
+
});
|
|
2042
|
+
}
|
|
1683
2043
|
async function collectOutputFiles(root) {
|
|
1684
2044
|
const entries = await fs$1.readdir(root, { withFileTypes: true });
|
|
1685
2045
|
const files = [];
|
|
@@ -1811,165 +2171,181 @@ function registerServeCommand(cli) {
|
|
|
1811
2171
|
const enableAnalyze = Boolean(isUiEnabled(options) && targets.runMini);
|
|
1812
2172
|
let analyzeHandle;
|
|
1813
2173
|
let analyzeRunId = 0;
|
|
1814
|
-
const
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
2174
|
+
const devHotkeysSession = targets.runMini ? startDevHotkeys({
|
|
2175
|
+
cwd: configService.cwd,
|
|
2176
|
+
mcpConfig: configService.weappViteConfig?.weapp?.mcp,
|
|
2177
|
+
platform: configService.platform,
|
|
2178
|
+
projectPath: resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd),
|
|
2179
|
+
silentStartupHint: true
|
|
2180
|
+
}) : void 0;
|
|
2181
|
+
try {
|
|
2182
|
+
const runAnalyze = async () => {
|
|
2183
|
+
const startedAt = Date.now();
|
|
2184
|
+
try {
|
|
2185
|
+
const result = await analyzeSubpackages(await createCompilerContext({
|
|
2186
|
+
key: `serve-ui-analyze:${process.pid}:${++analyzeRunId}`,
|
|
2187
|
+
cwd: configService.cwd,
|
|
2188
|
+
mode: configService.mode,
|
|
2189
|
+
isDev: false,
|
|
2190
|
+
configFile,
|
|
2191
|
+
inlineConfig: createInlineConfig(targets.mpPlatform),
|
|
2192
|
+
cliPlatform: targets.rawPlatform,
|
|
2193
|
+
projectConfigPath: options.projectConfig,
|
|
2194
|
+
syncSupportFiles: false
|
|
2195
|
+
}));
|
|
2196
|
+
if (hasAnalyzeData(result)) return {
|
|
2197
|
+
result,
|
|
2198
|
+
durationMs: Date.now() - startedAt,
|
|
2199
|
+
mode: "full"
|
|
2200
|
+
};
|
|
2201
|
+
} catch (error) {
|
|
2202
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2203
|
+
logger_default.warn(`[ui] 完整分析失败,已回退到 dist 文件扫描:${message}`);
|
|
2204
|
+
return {
|
|
2205
|
+
result: await analyzeUiFallback(ctx),
|
|
2206
|
+
durationMs: Date.now() - startedAt,
|
|
2207
|
+
mode: "fallback",
|
|
2208
|
+
fallbackReason: message
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
1836
2211
|
return {
|
|
1837
2212
|
result: await analyzeUiFallback(ctx),
|
|
1838
2213
|
durationMs: Date.now() - startedAt,
|
|
1839
2214
|
mode: "fallback",
|
|
1840
|
-
fallbackReason:
|
|
2215
|
+
fallbackReason: "完整分析结果为空,已回退到 dist 文件扫描。"
|
|
1841
2216
|
};
|
|
1842
|
-
}
|
|
1843
|
-
return {
|
|
1844
|
-
result: await analyzeUiFallback(ctx),
|
|
1845
|
-
durationMs: Date.now() - startedAt,
|
|
1846
|
-
mode: "fallback",
|
|
1847
|
-
fallbackReason: "完整分析结果为空,已回退到 dist 文件扫描。"
|
|
1848
2217
|
};
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
if (!analyzeHandle) return;
|
|
1852
|
-
emitDashboardEvents(analyzeHandle, [{
|
|
1853
|
-
kind: reason === "watch" ? "hmr" : "build",
|
|
1854
|
-
level: "info",
|
|
1855
|
-
title: reason === "watch" ? "analyze refresh started" : "initial analyze started",
|
|
1856
|
-
detail: reason === "watch" ? "检测到新的构建结束事件,开始刷新 analyze 面板。" : "开发态 UI 已启动,开始生成第一份 analyze 结果。",
|
|
1857
|
-
tags: reason === "watch" ? ["watch", "analyze"] : ["initial", "analyze"]
|
|
1858
|
-
}]);
|
|
1859
|
-
const next = await runAnalyze();
|
|
1860
|
-
if (next.mode === "fallback") emitDashboardEvents(analyzeHandle, [{
|
|
1861
|
-
kind: "diagnostic",
|
|
1862
|
-
level: "warning",
|
|
1863
|
-
title: "analyze fallback enabled",
|
|
1864
|
-
detail: next.fallbackReason ?? "完整分析不可用,已回退到 dist 文件扫描。",
|
|
1865
|
-
durationMs: next.durationMs,
|
|
1866
|
-
tags: ["analyze", "fallback"]
|
|
1867
|
-
}]);
|
|
1868
|
-
await analyzeHandle.update(next.result);
|
|
1869
|
-
emitDashboardEvents(analyzeHandle, [{
|
|
1870
|
-
kind: next.mode === "fallback" ? "diagnostic" : "build",
|
|
1871
|
-
level: next.mode === "fallback" ? "warning" : "success",
|
|
1872
|
-
title: reason === "watch" ? "analyze refresh completed" : "initial analyze completed",
|
|
1873
|
-
detail: next.mode === "fallback" ? `analyze 已回退到 dist 扫描,当前包含 ${next.result.packages.length} 个包。` : `analyze 已刷新完成,当前包含 ${next.result.packages.length} 个包与 ${next.result.modules.length} 个模块。`,
|
|
1874
|
-
durationMs: next.durationMs,
|
|
1875
|
-
tags: next.mode === "fallback" ? ["analyze", "fallback"] : ["analyze", reason === "watch" ? "refresh" : "initial"]
|
|
1876
|
-
}]);
|
|
1877
|
-
};
|
|
1878
|
-
if (targets.runMini) {
|
|
1879
|
-
const miniBuildStartedAt = Date.now();
|
|
1880
|
-
const buildResult = await buildService.build(options);
|
|
1881
|
-
logger_default.success(`小程序初次构建完成,耗时:${formatDuration(Date.now() - miniBuildStartedAt)}`);
|
|
1882
|
-
if (enableAnalyze) {
|
|
1883
|
-
const initialAnalyze = await runAnalyze();
|
|
1884
|
-
analyzeHandle = await startAnalyzeDashboard(initialAnalyze.result, {
|
|
1885
|
-
watch: true,
|
|
1886
|
-
cwd: configService.cwd,
|
|
1887
|
-
packageManagerAgent: configService.packageManager.agent,
|
|
1888
|
-
silentStartupLog: true
|
|
1889
|
-
}) ?? void 0;
|
|
2218
|
+
const triggerAnalyzeUpdate = async (reason = "watch") => {
|
|
2219
|
+
if (!analyzeHandle) return;
|
|
1890
2220
|
emitDashboardEvents(analyzeHandle, [{
|
|
1891
|
-
kind: "
|
|
1892
|
-
level: "
|
|
1893
|
-
title: "
|
|
1894
|
-
detail:
|
|
1895
|
-
|
|
1896
|
-
tags: ["dev", "ui"]
|
|
2221
|
+
kind: reason === "watch" ? "hmr" : "build",
|
|
2222
|
+
level: "info",
|
|
2223
|
+
title: reason === "watch" ? "analyze refresh started" : "initial analyze started",
|
|
2224
|
+
detail: reason === "watch" ? "检测到新的构建结束事件,开始刷新 analyze 面板。" : "开发态 UI 已启动,开始生成第一份 analyze 结果。",
|
|
2225
|
+
tags: reason === "watch" ? ["watch", "analyze"] : ["initial", "analyze"]
|
|
1897
2226
|
}]);
|
|
1898
|
-
|
|
2227
|
+
const next = await runAnalyze();
|
|
2228
|
+
if (next.mode === "fallback") emitDashboardEvents(analyzeHandle, [{
|
|
1899
2229
|
kind: "diagnostic",
|
|
1900
2230
|
level: "warning",
|
|
1901
|
-
title: "
|
|
1902
|
-
detail:
|
|
1903
|
-
durationMs:
|
|
1904
|
-
tags: [
|
|
1905
|
-
"analyze",
|
|
1906
|
-
"fallback",
|
|
1907
|
-
"initial"
|
|
1908
|
-
]
|
|
2231
|
+
title: "analyze fallback enabled",
|
|
2232
|
+
detail: next.fallbackReason ?? "完整分析不可用,已回退到 dist 文件扫描。",
|
|
2233
|
+
durationMs: next.durationMs,
|
|
2234
|
+
tags: ["analyze", "fallback"]
|
|
1909
2235
|
}]);
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
2236
|
+
await analyzeHandle.update(next.result);
|
|
2237
|
+
emitDashboardEvents(analyzeHandle, [{
|
|
2238
|
+
kind: next.mode === "fallback" ? "diagnostic" : "build",
|
|
2239
|
+
level: next.mode === "fallback" ? "warning" : "success",
|
|
2240
|
+
title: reason === "watch" ? "analyze refresh completed" : "initial analyze completed",
|
|
2241
|
+
detail: next.mode === "fallback" ? `analyze 已回退到 dist 扫描,当前包含 ${next.result.packages.length} 个包。` : `analyze 已刷新完成,当前包含 ${next.result.packages.length} 个包与 ${next.result.modules.length} 个模块。`,
|
|
2242
|
+
durationMs: next.durationMs,
|
|
2243
|
+
tags: next.mode === "fallback" ? ["analyze", "fallback"] : ["analyze", reason === "watch" ? "refresh" : "initial"]
|
|
2244
|
+
}]);
|
|
2245
|
+
};
|
|
2246
|
+
if (targets.runMini) {
|
|
2247
|
+
const miniBuildStartedAt = Date.now();
|
|
2248
|
+
const buildResult = await buildService.build(options);
|
|
2249
|
+
logger_default.success(`小程序初次构建完成,耗时:${formatDuration(Date.now() - miniBuildStartedAt)}`);
|
|
2250
|
+
if (enableAnalyze) {
|
|
2251
|
+
const initialAnalyze = await runAnalyze();
|
|
2252
|
+
analyzeHandle = await startAnalyzeDashboard(initialAnalyze.result, {
|
|
2253
|
+
watch: true,
|
|
2254
|
+
cwd: configService.cwd,
|
|
2255
|
+
packageManagerAgent: configService.packageManager.agent,
|
|
2256
|
+
silentStartupLog: true
|
|
2257
|
+
}) ?? void 0;
|
|
2258
|
+
emitDashboardEvents(analyzeHandle, [{
|
|
2259
|
+
kind: "command",
|
|
2260
|
+
level: "success",
|
|
2261
|
+
title: "dev ui session ready",
|
|
2262
|
+
detail: `开发态分析面板已启动,当前包含 ${initialAnalyze.result.packages.length} 个包。`,
|
|
2263
|
+
durationMs: initialAnalyze.durationMs,
|
|
2264
|
+
tags: ["dev", "ui"]
|
|
2265
|
+
}]);
|
|
2266
|
+
if (initialAnalyze.mode === "fallback") emitDashboardEvents(analyzeHandle, [{
|
|
2267
|
+
kind: "diagnostic",
|
|
2268
|
+
level: "warning",
|
|
2269
|
+
title: "initial analyze fallback enabled",
|
|
2270
|
+
detail: initialAnalyze.fallbackReason ?? "完整分析不可用,已回退到 dist 文件扫描。",
|
|
2271
|
+
durationMs: initialAnalyze.durationMs,
|
|
2272
|
+
tags: [
|
|
2273
|
+
"analyze",
|
|
2274
|
+
"fallback",
|
|
2275
|
+
"initial"
|
|
2276
|
+
]
|
|
2277
|
+
}]);
|
|
2278
|
+
let updating = false;
|
|
2279
|
+
if (analyzeHandle && buildResult && typeof buildResult.on === "function") buildResult.on("event", (event) => {
|
|
2280
|
+
if (event.code !== "END" || updating) return;
|
|
2281
|
+
updating = true;
|
|
2282
|
+
triggerAnalyzeUpdate("watch").finally(() => {
|
|
2283
|
+
updating = false;
|
|
2284
|
+
});
|
|
1916
2285
|
});
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2286
|
+
if (analyzeHandle) {
|
|
2287
|
+
updating = true;
|
|
2288
|
+
await triggerAnalyzeUpdate("initial");
|
|
2289
|
+
updating = false;
|
|
2290
|
+
}
|
|
1922
2291
|
}
|
|
1923
2292
|
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
}
|
|
1939
|
-
|
|
2293
|
+
let webServer;
|
|
2294
|
+
if (targets.runWeb) {
|
|
2295
|
+
const webServerStartedAt = Date.now();
|
|
2296
|
+
try {
|
|
2297
|
+
webServer = await webService?.startDevServer();
|
|
2298
|
+
logger_default.success(`Web 开发服务启动完成,耗时:${formatDuration(Date.now() - webServerStartedAt)}`);
|
|
2299
|
+
emitDashboardEvents(analyzeHandle, [{
|
|
2300
|
+
kind: "system",
|
|
2301
|
+
level: "success",
|
|
2302
|
+
title: "web dev server started",
|
|
2303
|
+
detail: "Web 开发服务器已启动,可与小程序调试 UI 并行工作。",
|
|
2304
|
+
durationMs: Date.now() - webServerStartedAt,
|
|
2305
|
+
tags: ["dev", "web"]
|
|
2306
|
+
}]);
|
|
2307
|
+
} catch (error) {
|
|
2308
|
+
emitDashboardEvents(analyzeHandle, [{
|
|
2309
|
+
kind: "diagnostic",
|
|
2310
|
+
level: "error",
|
|
2311
|
+
title: "web dev server failed",
|
|
2312
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
2313
|
+
durationMs: Date.now() - webServerStartedAt,
|
|
2314
|
+
tags: ["dev", "web"]
|
|
2315
|
+
}]);
|
|
2316
|
+
logger_default.error(error);
|
|
2317
|
+
throw error;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
if (targets.runMini) {
|
|
2321
|
+
logBuildAppFinish(configService, webServer, {
|
|
2322
|
+
skipWeb: !targets.runWeb,
|
|
2323
|
+
uiUrls: analyzeHandle?.urls
|
|
2324
|
+
});
|
|
2325
|
+
devHotkeysSession?.restore();
|
|
2326
|
+
} else if (targets.runWeb) logBuildAppFinish(configService, webServer, { skipMini: true });
|
|
2327
|
+
if (options.open && targets.runMini) {
|
|
1940
2328
|
emitDashboardEvents(analyzeHandle, [{
|
|
1941
|
-
kind: "
|
|
1942
|
-
level: "
|
|
1943
|
-
title: "
|
|
1944
|
-
detail:
|
|
1945
|
-
|
|
1946
|
-
tags: ["dev", "web"]
|
|
2329
|
+
kind: "command",
|
|
2330
|
+
level: "info",
|
|
2331
|
+
title: "opening ide",
|
|
2332
|
+
detail: "开发服务已就绪,准备打开 IDE 项目。",
|
|
2333
|
+
tags: ["ide", "open"]
|
|
1947
2334
|
}]);
|
|
1948
|
-
|
|
1949
|
-
|
|
2335
|
+
if (!await maybeStartForwardConsole({
|
|
2336
|
+
platform: configService.platform,
|
|
2337
|
+
mpDistRoot: configService.mpDistRoot,
|
|
2338
|
+
cwd: configService.cwd,
|
|
2339
|
+
weappViteConfig: configService.weappViteConfig
|
|
2340
|
+
})) await openIde(configService.platform, resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd), { trustProject: options.trustProject });
|
|
2341
|
+
devHotkeysSession?.restore();
|
|
1950
2342
|
}
|
|
2343
|
+
if (analyzeHandle) await analyzeHandle.waitForExit();
|
|
2344
|
+
else if (targets.runMini || targets.runWeb) await waitForServeShutdownSignal();
|
|
2345
|
+
} finally {
|
|
2346
|
+
devHotkeysSession?.close();
|
|
2347
|
+
ctx.watcherService?.closeAll();
|
|
1951
2348
|
}
|
|
1952
|
-
if (targets.runMini) logBuildAppFinish(configService, webServer, {
|
|
1953
|
-
skipWeb: !targets.runWeb,
|
|
1954
|
-
uiUrls: analyzeHandle?.urls
|
|
1955
|
-
});
|
|
1956
|
-
else if (targets.runWeb) logBuildAppFinish(configService, webServer, { skipMini: true });
|
|
1957
|
-
if (options.open && targets.runMini) {
|
|
1958
|
-
emitDashboardEvents(analyzeHandle, [{
|
|
1959
|
-
kind: "command",
|
|
1960
|
-
level: "info",
|
|
1961
|
-
title: "opening ide",
|
|
1962
|
-
detail: "开发服务已就绪,准备打开 IDE 项目。",
|
|
1963
|
-
tags: ["ide", "open"]
|
|
1964
|
-
}]);
|
|
1965
|
-
if (!await maybeStartForwardConsole({
|
|
1966
|
-
platform: configService.platform,
|
|
1967
|
-
mpDistRoot: configService.mpDistRoot,
|
|
1968
|
-
cwd: configService.cwd,
|
|
1969
|
-
weappViteConfig: configService.weappViteConfig
|
|
1970
|
-
})) await openIde(configService.platform, resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd), { trustProject: options.trustProject });
|
|
1971
|
-
}
|
|
1972
|
-
if (analyzeHandle) await analyzeHandle.waitForExit();
|
|
1973
2349
|
});
|
|
1974
2350
|
}
|
|
1975
2351
|
//#endregion
|
|
@@ -2058,13 +2434,12 @@ const SKIP_COMMANDS = new Set([
|
|
|
2058
2434
|
"ide",
|
|
2059
2435
|
"mcp"
|
|
2060
2436
|
]);
|
|
2061
|
-
const
|
|
2437
|
+
const REG_EADDRINUSE = /EADDRINUSE/;
|
|
2062
2438
|
let started = false;
|
|
2063
2439
|
function shouldAutoStartMcp(argv) {
|
|
2064
2440
|
const command = argv[0];
|
|
2065
2441
|
if (!command || command.startsWith("-")) return true;
|
|
2066
2442
|
if (SKIP_COMMANDS.has(command)) return false;
|
|
2067
|
-
if (DEV_COMMANDS.has(command)) return true;
|
|
2068
2443
|
return command.includes("/") || command.includes("\\") || command.startsWith(".");
|
|
2069
2444
|
}
|
|
2070
2445
|
async function maybeAutoStartMcpServer(argv, cliOptions) {
|
|
@@ -2094,7 +2469,7 @@ async function maybeAutoStartMcpServer(argv, cliOptions) {
|
|
|
2094
2469
|
logger_default.info(` ➜ ${colors.cyan(mcpUrl)}`);
|
|
2095
2470
|
} catch (error) {
|
|
2096
2471
|
const message = error instanceof Error ? error.message : String(error);
|
|
2097
|
-
if (
|
|
2472
|
+
if (REG_EADDRINUSE.test(message)) {
|
|
2098
2473
|
logger_default.info(`[mcp] 端口 ${resolvedMcp.port} 已被占用,跳过自动启动。`);
|
|
2099
2474
|
started = true;
|
|
2100
2475
|
return;
|
|
@@ -2174,22 +2549,19 @@ function resolveManagedTsconfigBootstrapRoot(args) {
|
|
|
2174
2549
|
return path.resolve(firstArg);
|
|
2175
2550
|
}
|
|
2176
2551
|
try {
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
if (await tryRunIdeCommand(args)) return;
|
|
2552
|
+
const args = process.argv.slice(2);
|
|
2553
|
+
if (!await tryRunIdeCommand(args)) {
|
|
2180
2554
|
const managedTsconfigBootstrapRoot = resolveManagedTsconfigBootstrapRoot(args);
|
|
2181
2555
|
if (managedTsconfigBootstrapRoot) await syncManagedTsconfigBootstrapFiles(managedTsconfigBootstrapRoot);
|
|
2182
2556
|
cli.parse(process.argv, { run: false });
|
|
2183
2557
|
await maybeAutoStartMcpServer(args, cli.options);
|
|
2184
2558
|
await cli.runMatchedCommand();
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2559
|
+
}
|
|
2560
|
+
} catch (error) {
|
|
2561
|
+
if (!handlePrepareLifecycleError(process.argv.slice(2), error)) {
|
|
2187
2562
|
handleCLIError(error);
|
|
2188
2563
|
process.exitCode = 1;
|
|
2189
|
-
}
|
|
2190
|
-
} catch (error) {
|
|
2191
|
-
handleCLIError(error);
|
|
2192
|
-
process.exitCode = 1;
|
|
2564
|
+
}
|
|
2193
2565
|
}
|
|
2194
2566
|
//#endregion
|
|
2195
2567
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as Resolver, s as ResolvedValue } from "./index-
|
|
2
|
-
import { t as AutoRoutes } from "./routes-
|
|
1
|
+
import { c as Resolver, s as ResolvedValue } from "./index-hN5mdpQ_.mjs";
|
|
2
|
+
import { t as AutoRoutes } from "./routes-DiEBrMtj.mjs";
|
|
3
3
|
import { LRUCache } from "lru-cache";
|
|
4
4
|
import { LoggerConfig } from "@weapp-core/logger";
|
|
5
5
|
import { WeappAstConfig } from "@weapp-vite/ast";
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { An as createWeappViteHostMeta, Dn as WeappViteHostMeta, En as WEAPP_VITE_HOST_NAME, Mn as resolveWeappViteHostMeta, On as WeappViteRuntime, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, jn as isWeappViteHost, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-
|
|
1
|
+
import { An as createWeappViteHostMeta, Dn as WeappViteHostMeta, En as WEAPP_VITE_HOST_NAME, Mn as resolveWeappViteHostMeta, On as WeappViteRuntime, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, jn as isWeappViteHost, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-bkgtM4wZ.mjs";
|
|
2
2
|
export { App, Component, Page, Sitemap, Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, WeappViteConfig, WeappViteHostMeta, WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
package/dist/config.mjs
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-D0HkutE0.mjs";
|
|
2
2
|
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-SJdl15d3.mjs";
|
|
3
|
-
|
|
4
|
-
function defineConfig(config) {
|
|
5
|
-
return config;
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
3
|
+
import { t as defineConfig } from "./config-DJjSbpNX.mjs";
|
|
8
4
|
export { WEAPP_VITE_HOST_NAME, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-twds-ZHy.mjs";
|
|
2
1
|
import { n as applyWeappViteHostMeta } from "./pluginHost-SJdl15d3.mjs";
|
|
3
|
-
import { n as configureLogger, r as logger_default } from "./logger-
|
|
4
|
-
import { _ as
|
|
2
|
+
import { n as configureLogger, r as logger_default } from "./logger-CgxdNjvb.mjs";
|
|
3
|
+
import { _ as supportedCssLangs, a as findJsonEntry, c as inlineAutoRoutesImports, g as jsExtensions, h as configExtensions, i as findJsEntry, l as isJsOrTs, n as extractConfigFromVue, o as findTemplateEntry, p as touch, r as findCssEntry, s as findVueEntry, t as changeFileExtension, u as isTemplate, v as templateExtensions, y as vueExtensions } from "./file-Ej-4GoYg.mjs";
|
|
5
4
|
import { createRequire, isBuiltin } from "node:module";
|
|
6
5
|
import { addExtension, defu, fs, get, isEmptyObject, isObject, objectHash, removeExtension, removeExtensionDeep, set } from "@weapp-core/shared";
|
|
7
6
|
import { LRUCache } from "lru-cache";
|
|
@@ -11973,7 +11972,7 @@ function createEntryResolver(configService) {
|
|
|
11973
11972
|
const matched = await resolveEntryPath(normalized, createCachedEntryResolveOptions(configService ?? {}, { kind: "default" }));
|
|
11974
11973
|
if (matched) resolvedSource = matched;
|
|
11975
11974
|
}
|
|
11976
|
-
const resolvedId = await pluginCtx.resolve(resolvedSource) ?? null;
|
|
11975
|
+
const resolvedId = await pluginCtx.resolve(resolvedSource) ?? (path.isAbsolute(resolvedSource) && await fs.pathExists(resolvedSource) ? { id: resolvedSource } : null);
|
|
11977
11976
|
entryResolutionCache.set(normalized, resolvedId);
|
|
11978
11977
|
return resolvedId;
|
|
11979
11978
|
}
|
|
@@ -19690,7 +19689,7 @@ function createScanService(ctx) {
|
|
|
19690
19689
|
const vueAppPath = await findVueEntry(appBasename);
|
|
19691
19690
|
let configFromVue;
|
|
19692
19691
|
if (!appConfigFile && vueAppPath) {
|
|
19693
|
-
const { extractConfigFromVue } = await import("./file-
|
|
19692
|
+
const { extractConfigFromVue } = await import("./file-DgJb3pIf.mjs");
|
|
19694
19693
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
19695
19694
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
19696
19695
|
}
|
|
@@ -20146,11 +20145,6 @@ function createCompilerContextInstance() {
|
|
|
20146
20145
|
}
|
|
20147
20146
|
//#endregion
|
|
20148
20147
|
//#region src/context/getInstance.ts
|
|
20149
|
-
var getInstance_exports = /* @__PURE__ */ __exportAll({
|
|
20150
|
-
getCompilerContext: () => getCompilerContext,
|
|
20151
|
-
resetCompilerContext: () => resetCompilerContext,
|
|
20152
|
-
setActiveCompilerContextKey: () => setActiveCompilerContextKey
|
|
20153
|
-
});
|
|
20154
20148
|
const compilerContextMap = /* @__PURE__ */ new Map();
|
|
20155
20149
|
const DEFAULT_KEY = "default";
|
|
20156
20150
|
let activeCompilerContextKey = DEFAULT_KEY;
|
|
@@ -20537,4 +20531,4 @@ async function createCompilerContext(options) {
|
|
|
20537
20531
|
return ctx;
|
|
20538
20532
|
}
|
|
20539
20533
|
//#endregion
|
|
20540
|
-
export {
|
|
20534
|
+
export { isPathInside as S, DEFAULT_MP_PLATFORM as _, resetCompilerContext as a, resolveMiniPlatform as b, createSharedBuildConfig as c, resolveWeappConfigFile as d, checkRuntime as f, createCjsConfigLoadError as g, parseCommentJson as h, getCompilerContext as i, SHARED_CHUNK_VIRTUAL_PREFIX as l, loadViteConfigFile as m, syncProjectSupportFiles as n, setActiveCompilerContextKey as o, getProjectConfigFileName as p, syncManagedTsconfigBootstrapFiles as r, formatBytes as s, createCompilerContext as t, getRouteRuntimeGlobalKeys as u, getDefaultIdeProjectRoot as v, shouldPassPlatformArgToIdeOpen as x, normalizeMiniPlatform as y };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-twds-ZHy.mjs";
|
|
2
1
|
import { createRequire } from "node:module";
|
|
3
2
|
import { fs } from "@weapp-core/shared";
|
|
4
3
|
import path from "pathe";
|
|
@@ -40,21 +39,6 @@ const supportedCssLangs = [
|
|
|
40
39
|
const templateExtensions = ["wxml", "html"];
|
|
41
40
|
//#endregion
|
|
42
41
|
//#region src/utils/file.ts
|
|
43
|
-
var file_exports = /* @__PURE__ */ __exportAll({
|
|
44
|
-
changeFileExtension: () => changeFileExtension,
|
|
45
|
-
extractConfigFromVue: () => extractConfigFromVue,
|
|
46
|
-
findCssEntry: () => findCssEntry,
|
|
47
|
-
findJsEntry: () => findJsEntry,
|
|
48
|
-
findJsonEntry: () => findJsonEntry,
|
|
49
|
-
findTemplateEntry: () => findTemplateEntry,
|
|
50
|
-
findVueEntry: () => findVueEntry,
|
|
51
|
-
inlineAutoRoutesImports: () => inlineAutoRoutesImports,
|
|
52
|
-
isJsOrTs: () => isJsOrTs,
|
|
53
|
-
isTemplate: () => isTemplate,
|
|
54
|
-
normalizeFileExtension: () => normalizeFileExtension,
|
|
55
|
-
resolveAutoRoutesInlineSnapshot: () => resolveAutoRoutesInlineSnapshot,
|
|
56
|
-
touch: () => touch
|
|
57
|
-
});
|
|
58
42
|
const pathExistsInFlight = /* @__PURE__ */ new Map();
|
|
59
43
|
const vueConfigCache = /* @__PURE__ */ new Map();
|
|
60
44
|
const configMtimeInFlight = /* @__PURE__ */ new Map();
|
|
@@ -102,7 +86,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
102
86
|
}
|
|
103
87
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
104
88
|
try {
|
|
105
|
-
const { getCompilerContext } = await import("./
|
|
89
|
+
const { getCompilerContext } = await import("./getInstance-CVtFkrEA.mjs");
|
|
106
90
|
const compilerContext = getCompilerContext();
|
|
107
91
|
const service = compilerContext.autoRoutesService;
|
|
108
92
|
const reference = service?.getReference?.();
|
|
@@ -291,4 +275,4 @@ async function extractConfigFromVue(vueFilePath) {
|
|
|
291
275
|
}
|
|
292
276
|
}
|
|
293
277
|
//#endregion
|
|
294
|
-
export {
|
|
278
|
+
export { supportedCssLangs as _, findJsonEntry as a, inlineAutoRoutesImports as c, normalizeFileExtension as d, resolveAutoRoutesInlineSnapshot as f, jsExtensions as g, configExtensions as h, findJsEntry as i, isJsOrTs as l, VERSION as m, extractConfigFromVue as n, findTemplateEntry as o, touch as p, findCssEntry as r, findVueEntry as s, changeFileExtension as t, isTemplate as u, templateExtensions as v, vueExtensions as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Ref, An as createWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, Dn as WeappViteHostMeta, E as InlineConfig, En as WEAPP_VITE_HOST_NAME, F as RolldownPlugin, I as RolldownPluginOption, L as RolldownWatchOptions, M as RolldownBuild, Mn as resolveWeappViteHostMeta, N as RolldownOptions, O as Plugin, On as WeappViteRuntime, P as RolldownOutput, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, jn as isWeappViteHost, k as PluginOption, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-
|
|
2
|
-
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-
|
|
1
|
+
import { A as Ref, An as createWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, Dn as WeappViteHostMeta, E as InlineConfig, En as WEAPP_VITE_HOST_NAME, F as RolldownPlugin, I as RolldownPluginOption, L as RolldownWatchOptions, M as RolldownBuild, Mn as resolveWeappViteHostMeta, N as RolldownOptions, O as Plugin, On as WeappViteRuntime, P as RolldownOutput, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, jn as isWeappViteHost, k as PluginOption, kn as applyWeappViteHostMeta, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer } from "./config-bkgtM4wZ.mjs";
|
|
2
|
+
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-58wbbRDf.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createContext.d.ts
|
|
5
5
|
interface CreateCompilerContextOptions extends Partial<LoadConfigOptions> {
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-D0HkutE0.mjs";
|
|
2
2
|
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-SJdl15d3.mjs";
|
|
3
|
-
import { defineConfig } from "./config.mjs";
|
|
4
|
-
import { t as createCompilerContext } from "./createContext-
|
|
5
|
-
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-
|
|
3
|
+
import { t as defineConfig } from "./config-DJjSbpNX.mjs";
|
|
4
|
+
import { t as createCompilerContext } from "./createContext-BolxgJjC.mjs";
|
|
5
|
+
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-tVnzZwtl.mjs";
|
|
6
6
|
export { WEAPP_VITE_HOST_NAME, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta, setPageLayout };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/json.ts
|
|
2
|
+
/**
|
|
3
|
+
* @description 定义 app.json(支持直接对象或函数形式)
|
|
4
|
+
*/
|
|
5
|
+
const defineAppJson = (config) => {
|
|
6
|
+
return config;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* @description 定义 page.json(支持直接对象或函数形式)
|
|
10
|
+
*/
|
|
11
|
+
const definePageJson = (config) => {
|
|
12
|
+
return config;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @description 定义 component.json(支持直接对象或函数形式)
|
|
16
|
+
*/
|
|
17
|
+
const defineComponentJson = (config) => {
|
|
18
|
+
return config;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @description 定义 sitemap.json(支持直接对象或函数形式)
|
|
22
|
+
*/
|
|
23
|
+
const defineSitemapJson = (config) => {
|
|
24
|
+
return config;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @description 定义 theme.json(支持直接对象或函数形式)
|
|
28
|
+
*/
|
|
29
|
+
const defineThemeJson = (config) => {
|
|
30
|
+
return config;
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { defineThemeJson as a, defineSitemapJson as i, defineComponentJson as n, definePageJson as r, defineAppJson as t };
|
package/dist/json.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-
|
|
1
|
+
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-bkgtM4wZ.mjs";
|
|
2
2
|
export { App, Component, Page, Sitemap, Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
|
package/dist/json.mjs
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @description 定义 app.json(支持直接对象或函数形式)
|
|
4
|
-
*/
|
|
5
|
-
const defineAppJson = (config) => {
|
|
6
|
-
return config;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* @description 定义 page.json(支持直接对象或函数形式)
|
|
10
|
-
*/
|
|
11
|
-
const definePageJson = (config) => {
|
|
12
|
-
return config;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* @description 定义 component.json(支持直接对象或函数形式)
|
|
16
|
-
*/
|
|
17
|
-
const defineComponentJson = (config) => {
|
|
18
|
-
return config;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @description 定义 sitemap.json(支持直接对象或函数形式)
|
|
22
|
-
*/
|
|
23
|
-
const defineSitemapJson = (config) => {
|
|
24
|
-
return config;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* @description 定义 theme.json(支持直接对象或函数形式)
|
|
28
|
-
*/
|
|
29
|
-
const defineThemeJson = (config) => {
|
|
30
|
-
return config;
|
|
31
|
-
};
|
|
32
|
-
//#endregion
|
|
1
|
+
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-D0HkutE0.mjs";
|
|
33
2
|
export { defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { r as logger_default } from "./logger-CgxdNjvb.mjs";
|
|
2
|
+
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, createWeappViteMcpServer, startWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
|
+
//#region src/mcp.ts
|
|
4
|
+
function normalizeEndpoint(input) {
|
|
5
|
+
const value = typeof input === "string" ? input.trim() : "";
|
|
6
|
+
if (!value) return DEFAULT_MCP_ENDPOINT;
|
|
7
|
+
return value.startsWith("/") ? value : `/${value}`;
|
|
8
|
+
}
|
|
9
|
+
function normalizePort(input) {
|
|
10
|
+
if (typeof input === "number" && Number.isInteger(input) && input > 0 && input <= 65535) return input;
|
|
11
|
+
return DEFAULT_MCP_PORT;
|
|
12
|
+
}
|
|
13
|
+
function resolveWeappMcpConfig(config) {
|
|
14
|
+
if (config === false) return {
|
|
15
|
+
enabled: false,
|
|
16
|
+
autoStart: false,
|
|
17
|
+
host: DEFAULT_MCP_HOST,
|
|
18
|
+
port: DEFAULT_MCP_PORT,
|
|
19
|
+
endpoint: DEFAULT_MCP_ENDPOINT
|
|
20
|
+
};
|
|
21
|
+
const record = typeof config === "object" && config ? config : {};
|
|
22
|
+
return {
|
|
23
|
+
enabled: record.enabled !== false,
|
|
24
|
+
autoStart: record.autoStart === true,
|
|
25
|
+
host: typeof record.host === "string" && record.host.trim().length > 0 ? record.host.trim() : DEFAULT_MCP_HOST,
|
|
26
|
+
port: normalizePort(record.port),
|
|
27
|
+
endpoint: normalizeEndpoint(record.endpoint)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function startWeappViteMcpServer$1(options) {
|
|
31
|
+
return startWeappViteMcpServer({
|
|
32
|
+
...options,
|
|
33
|
+
onReady: options?.onReady ?? ((message) => {
|
|
34
|
+
logger_default.info(message);
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { resolveWeappMcpConfig as a, createWeappViteMcpServer as i, DEFAULT_MCP_HOST as n, startWeappViteMcpServer$1 as o, DEFAULT_MCP_PORT as r, DEFAULT_MCP_ENDPOINT as t };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _t as WeappMcpConfig } from "./config-
|
|
1
|
+
import { _t as WeappMcpConfig } from "./config-bkgtM4wZ.mjs";
|
|
2
2
|
import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,39 +1,2 @@
|
|
|
1
|
-
import { r as
|
|
2
|
-
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, createWeappViteMcpServer, startWeappViteMcpServer as startWeappViteMcpServer$1 } from "@weapp-vite/mcp";
|
|
3
|
-
//#region src/mcp.ts
|
|
4
|
-
function normalizeEndpoint(input) {
|
|
5
|
-
const value = typeof input === "string" ? input.trim() : "";
|
|
6
|
-
if (!value) return DEFAULT_MCP_ENDPOINT;
|
|
7
|
-
return value.startsWith("/") ? value : `/${value}`;
|
|
8
|
-
}
|
|
9
|
-
function normalizePort(input) {
|
|
10
|
-
if (typeof input === "number" && Number.isInteger(input) && input > 0 && input <= 65535) return input;
|
|
11
|
-
return DEFAULT_MCP_PORT;
|
|
12
|
-
}
|
|
13
|
-
function resolveWeappMcpConfig(config) {
|
|
14
|
-
if (config === false) return {
|
|
15
|
-
enabled: false,
|
|
16
|
-
autoStart: false,
|
|
17
|
-
host: DEFAULT_MCP_HOST,
|
|
18
|
-
port: DEFAULT_MCP_PORT,
|
|
19
|
-
endpoint: DEFAULT_MCP_ENDPOINT
|
|
20
|
-
};
|
|
21
|
-
const record = typeof config === "object" && config ? config : {};
|
|
22
|
-
return {
|
|
23
|
-
enabled: record.enabled !== false,
|
|
24
|
-
autoStart: record.autoStart === true,
|
|
25
|
-
host: typeof record.host === "string" && record.host.trim().length > 0 ? record.host.trim() : DEFAULT_MCP_HOST,
|
|
26
|
-
port: normalizePort(record.port),
|
|
27
|
-
endpoint: normalizeEndpoint(record.endpoint)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
async function startWeappViteMcpServer(options) {
|
|
31
|
-
return startWeappViteMcpServer$1({
|
|
32
|
-
...options,
|
|
33
|
-
onReady: options?.onReady ?? ((message) => {
|
|
34
|
-
logger_default.info(message);
|
|
35
|
-
})
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
1
|
+
import { a as resolveWeappMcpConfig, i as createWeappViteMcpServer, n as DEFAULT_MCP_HOST, o as startWeappViteMcpServer, r as DEFAULT_MCP_PORT, t as DEFAULT_MCP_ENDPOINT } from "./mcp-DRlj32v4.mjs";
|
|
39
2
|
export { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-
|
|
1
|
+
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-58wbbRDf.mjs";
|
|
2
2
|
export { WevuComponentOptions, createWevuComponent, defineEmits, defineProps, setPageLayout };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-
|
|
1
|
+
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-tVnzZwtl.mjs";
|
|
2
2
|
export { createWevuComponent, defineEmits, defineProps, setPageLayout };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Resolver } from "./index-
|
|
2
|
-
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-
|
|
3
|
-
import { $ as WeappDebugConfig, $t as NpmBuildOptions, A as Ref, At as ChunksConfig, B as BindingErrorLike, Bt as GenerateTemplateEntry, Cn as WeappManagedSharedTsconfigConfig, Ct as WeappVueTemplateConfig, D as MethodDefinitions, Dn as WeappViteHostMeta, Dt as AliasOptions, E as InlineConfig, Et as Alias, F as RolldownPlugin, Ft as GenerateFileType, G as EntryJsonFragment, Gt as GenerateTemplatesConfig, H as BaseEntry, Ht as GenerateTemplateFileSource, I as RolldownPluginOption, It as GenerateFilenamesOptions, J as ScanComponentItem, Jt as JsonMergeContext, K as PageEntry, Kt as JsFormat, L as RolldownWatchOptions, Lt as GenerateOptions, M as RolldownBuild, Mt as CopyOptions, N as RolldownOptions, Nt as GenerateDirsOptions, O as Plugin, On as WeappViteRuntime, Ot as AlipayNpmMode, P as RolldownOutput, Pt as GenerateExtensionsOptions, Q as UserConfig, Qt as MpPlatform, R as RolldownWatcher, Rt as GenerateTemplate, Sn as WeappManagedServerTsconfigConfig, St as WeappVueConfig, T as ConfigEnv, Tn as WeappWebConfig, Tt as WeappWorkerConfig, U as ComponentEntry, Ut as GenerateTemplateInlineSource, V as AppEntry, Vt as GenerateTemplateFactory, W as Entry, Wt as GenerateTemplateScope, X as ProjectConfig, Xt as JsonMergeStage, Y as WxmlDep, Yt as JsonMergeFunction, Z as SubPackageMetaValue, Zt as JsonMergeStrategy, _n as WeappLibFileName, _t as WeappMcpConfig, an as SharedChunkMode, at as EnhanceOptions, b as ChangeEvent, bn as WeappManagedAppTsconfigConfig, bt as WeappRouteRules, cn as SubPackage, ct as MultiPlatformConfig, dn as SubPackageStyleEntry, dt as WeappAutoRoutesInclude, en as NpmMainPackageConfig, et as WeappForwardConsoleConfig, fn as SubPackageStyleScope, ft as WeappAutoRoutesIncludePattern, gn as WeappLibEntryContext, gt as WeappInjectWeapiConfig, hn as WeappLibDtsOptions, ht as WeappInjectRequestGlobalsTarget, in as SharedChunkDynamicImports, it as AutoImportComponentsOption, j as ResolvedConfig, jt as CopyGlobs, k as PluginOption, kt as BuildNpmPackageMeta, ln as SubPackageStyleConfigEntry, lt as ScanWxmlOptions, mn as WeappLibConfig, mt as WeappInjectRequestGlobalsConfig, nn as NpmSubPackageConfig, nt as WeappViteConfig, on as SharedChunkOverride, ot as EnhanceWxmlOptions, pn as WeappLibComponentJson, pt as WeappHmrConfig, q as ComponentsMap, qt as JsonConfig, rn as ResolvedAlias, rt as AutoImportComponents, sn as SharedChunkStrategy, st as HandleWxmlOptions, tn as NpmPluginPackageConfig, tt as WeappForwardConsoleLogLevel, un as SubPackageStyleConfigObject, ut as WeappAutoRoutesConfig, vn as WeappLibInternalDtsOptions, vt as WeappNpmConfig, w as ComputedDefinitions, wn as WeappManagedTypeScriptConfig, wt as WeappWevuConfig, x as WeappVitePluginApi, xn as WeappManagedNodeTsconfigConfig, xt as WeappSubPackageConfig, yn as WeappLibVueTscOptions, yt as WeappRouteRule, z as ViteDevServer, zt as GenerateTemplateContext } from "./config-
|
|
1
|
+
import { c as Resolver } from "./index-hN5mdpQ_.mjs";
|
|
2
|
+
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-DiEBrMtj.mjs";
|
|
3
|
+
import { $ as WeappDebugConfig, $t as NpmBuildOptions, A as Ref, At as ChunksConfig, B as BindingErrorLike, Bt as GenerateTemplateEntry, Cn as WeappManagedSharedTsconfigConfig, Ct as WeappVueTemplateConfig, D as MethodDefinitions, Dn as WeappViteHostMeta, Dt as AliasOptions, E as InlineConfig, Et as Alias, F as RolldownPlugin, Ft as GenerateFileType, G as EntryJsonFragment, Gt as GenerateTemplatesConfig, H as BaseEntry, Ht as GenerateTemplateFileSource, I as RolldownPluginOption, It as GenerateFilenamesOptions, J as ScanComponentItem, Jt as JsonMergeContext, K as PageEntry, Kt as JsFormat, L as RolldownWatchOptions, Lt as GenerateOptions, M as RolldownBuild, Mt as CopyOptions, N as RolldownOptions, Nt as GenerateDirsOptions, O as Plugin, On as WeappViteRuntime, Ot as AlipayNpmMode, P as RolldownOutput, Pt as GenerateExtensionsOptions, Q as UserConfig, Qt as MpPlatform, R as RolldownWatcher, Rt as GenerateTemplate, Sn as WeappManagedServerTsconfigConfig, St as WeappVueConfig, T as ConfigEnv, Tn as WeappWebConfig, Tt as WeappWorkerConfig, U as ComponentEntry, Ut as GenerateTemplateInlineSource, V as AppEntry, Vt as GenerateTemplateFactory, W as Entry, Wt as GenerateTemplateScope, X as ProjectConfig, Xt as JsonMergeStage, Y as WxmlDep, Yt as JsonMergeFunction, Z as SubPackageMetaValue, Zt as JsonMergeStrategy, _n as WeappLibFileName, _t as WeappMcpConfig, an as SharedChunkMode, at as EnhanceOptions, b as ChangeEvent, bn as WeappManagedAppTsconfigConfig, bt as WeappRouteRules, cn as SubPackage, ct as MultiPlatformConfig, dn as SubPackageStyleEntry, dt as WeappAutoRoutesInclude, en as NpmMainPackageConfig, et as WeappForwardConsoleConfig, fn as SubPackageStyleScope, ft as WeappAutoRoutesIncludePattern, gn as WeappLibEntryContext, gt as WeappInjectWeapiConfig, hn as WeappLibDtsOptions, ht as WeappInjectRequestGlobalsTarget, in as SharedChunkDynamicImports, it as AutoImportComponentsOption, j as ResolvedConfig, jt as CopyGlobs, k as PluginOption, kt as BuildNpmPackageMeta, ln as SubPackageStyleConfigEntry, lt as ScanWxmlOptions, mn as WeappLibConfig, mt as WeappInjectRequestGlobalsConfig, nn as NpmSubPackageConfig, nt as WeappViteConfig, on as SharedChunkOverride, ot as EnhanceWxmlOptions, pn as WeappLibComponentJson, pt as WeappHmrConfig, q as ComponentsMap, qt as JsonConfig, rn as ResolvedAlias, rt as AutoImportComponents, sn as SharedChunkStrategy, st as HandleWxmlOptions, tn as NpmPluginPackageConfig, tt as WeappForwardConsoleLogLevel, un as SubPackageStyleConfigObject, ut as WeappAutoRoutesConfig, vn as WeappLibInternalDtsOptions, vt as WeappNpmConfig, w as ComputedDefinitions, wn as WeappManagedTypeScriptConfig, wt as WeappWevuConfig, x as WeappVitePluginApi, xn as WeappManagedNodeTsconfigConfig, xt as WeappSubPackageConfig, yn as WeappLibVueTscOptions, yt as WeappRouteRule, z as ViteDevServer, zt as GenerateTemplateContext } from "./config-bkgtM4wZ.mjs";
|
|
4
4
|
export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, ComputedDefinitions, ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmMainPackageConfig, NpmPluginPackageConfig, NpmSubPackageConfig, PageEntry, Plugin, PluginOption, ProjectConfig, Ref, ResolvedAlias, ResolvedConfig, Resolver, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, ViteDevServer, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.14.0",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -118,19 +118,19 @@
|
|
|
118
118
|
"vue-tsc": "^3.2.6",
|
|
119
119
|
"@weapp-core/init": "6.0.6",
|
|
120
120
|
"@weapp-core/logger": "3.1.1",
|
|
121
|
-
"@weapp-core/schematics": "6.0.4",
|
|
122
121
|
"@weapp-core/shared": "3.0.3",
|
|
123
|
-
"@weapp-
|
|
122
|
+
"@weapp-core/schematics": "6.0.4",
|
|
123
|
+
"@weapp-vite/ast": "6.14.0",
|
|
124
124
|
"@weapp-vite/mcp": "1.2.0",
|
|
125
|
+
"@weapp-vite/miniprogram-automator": "1.0.2",
|
|
125
126
|
"@weapp-vite/volar": "2.0.8",
|
|
126
|
-
"@weapp-vite/miniprogram-automator": "1.0.1",
|
|
127
127
|
"@weapp-vite/web": "1.3.11",
|
|
128
|
-
"@wevu/api": "0.2.
|
|
129
|
-
"@wevu/web-apis": "1.1.
|
|
128
|
+
"@wevu/api": "0.2.3",
|
|
129
|
+
"@wevu/web-apis": "1.1.1",
|
|
130
130
|
"rolldown-require": "2.0.12",
|
|
131
|
-
"
|
|
132
|
-
"wevu": "6.
|
|
133
|
-
"
|
|
131
|
+
"vite-plugin-performance": "2.0.1",
|
|
132
|
+
"wevu": "6.14.0",
|
|
133
|
+
"weapp-ide-cli": "5.2.1"
|
|
134
134
|
},
|
|
135
135
|
"publishConfig": {
|
|
136
136
|
"access": "public",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __exportAll = (all, no_symbols) => {
|
|
5
|
-
let target = {};
|
|
6
|
-
for (var name in all) __defProp(target, name, {
|
|
7
|
-
get: all[name],
|
|
8
|
-
enumerable: true
|
|
9
|
-
});
|
|
10
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
-
return target;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { __exportAll as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|