weapp-vite 6.16.43 → 6.16.44
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-routes.mjs +1 -1
- package/dist/cli.mjs +210 -103
- package/dist/{config-CobCpW-a.d.mts → config-Ds7MBgQm.d.mts} +2 -2
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-CRpsNCP2.mjs → createContext-D2uF0JED.mjs} +95 -37
- package/dist/file-CTUeDbPw.mjs +2 -0
- package/dist/{file-Wkzc9gMS.mjs → file-DBbvHZyc.mjs} +1 -1
- package/dist/getInstance-DwrlgiHQ.mjs +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/mcp-YXCIQr-Z.mjs +124 -0
- package/dist/mcp.d.mts +11 -3
- package/dist/mcp.mjs +2 -2
- package/dist/types.d.mts +1 -1
- package/package.json +19 -19
- package/dist/file-iVST36Dh.mjs +0 -2
- package/dist/getInstance-QuyA4zlX.mjs +0 -2
- package/dist/mcp-qmDOTH07.mjs +0 -43
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-
|
|
1
|
+
import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-D2uF0JED.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 { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, a as formatBytes, b as getProjectConfigFileName, d as syncProjectSupportFiles, f as syncManagedTsconfigBootstrapFiles, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, p as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappViteTarget, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-
|
|
1
|
+
import { C as createCjsConfigLoadError, E as isPathInside, S as parseCommentJson, T as shouldPassPlatformArgToIdeOpen, _ as createBuildScopeConfigFromCli, a as formatBytes, b as getProjectConfigFileName, d as syncProjectSupportFiles, f as syncManagedTsconfigBootstrapFiles, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, p as createSharedBuildConfig, t as createCompilerContext, u as resolveWeappViteTarget, v as resolveWeappConfigFile, w as getDefaultIdeProjectRoot, x as loadViteConfigFile, y as checkRuntime } from "./createContext-D2uF0JED.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
4
|
-
import {
|
|
3
|
+
import { h as VERSION } from "./file-DBbvHZyc.mjs";
|
|
4
|
+
import { c as startWeappViteMcpServer, l as detectAiDevelopmentEnvironment, s as resolveWeappMcpConfig } from "./mcp-YXCIQr-Z.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path, { posix } from "pathe";
|
|
7
7
|
import path$1 from "node:path";
|
|
@@ -9,7 +9,7 @@ import { defu } from "@weapp-core/shared";
|
|
|
9
9
|
import { fs } from "@weapp-core/shared/fs";
|
|
10
10
|
import fs$1 from "node:fs";
|
|
11
11
|
import process from "node:process";
|
|
12
|
-
import fs$2 from "node:fs/promises";
|
|
12
|
+
import fs$2, { mkdir, writeFile } from "node:fs/promises";
|
|
13
13
|
import { build, createServer } from "vite";
|
|
14
14
|
import os from "node:os";
|
|
15
15
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -24,6 +24,7 @@ import { determineAgent } from "@vercel/detect-agent";
|
|
|
24
24
|
import { initConfig } from "@weapp-core/init";
|
|
25
25
|
import { createInterface } from "node:readline/promises";
|
|
26
26
|
import { clearTimeout, setTimeout as setTimeout$1 } from "node:timers";
|
|
27
|
+
import net from "node:net";
|
|
27
28
|
//#region src/cli/runtime.ts
|
|
28
29
|
function logRuntimeTarget(targets, options = {}) {
|
|
29
30
|
if (options.silent) return;
|
|
@@ -412,6 +413,7 @@ async function stabilizeOpenedWechatIdeProject(projectPath, servicePortEnabled,
|
|
|
412
413
|
projectPath
|
|
413
414
|
], options), {
|
|
414
415
|
automatorMode: options.useAutomatorOpen === false ? "skip" : "prefer",
|
|
416
|
+
engineBuildFallbackToCli: true,
|
|
415
417
|
httpMode: "prefer",
|
|
416
418
|
onNonLoginError: (error) => logger_default.error(error),
|
|
417
419
|
preserveProjectRoot: options.useAutomatorOpen === false,
|
|
@@ -3506,9 +3508,117 @@ function registerNpmCommand(cli) {
|
|
|
3506
3508
|
});
|
|
3507
3509
|
}
|
|
3508
3510
|
//#endregion
|
|
3511
|
+
//#region src/cli/mcpDetached.ts
|
|
3512
|
+
function resolveCliEntrypoint() {
|
|
3513
|
+
return process.argv[1];
|
|
3514
|
+
}
|
|
3515
|
+
function resolveManifestPath(cwd) {
|
|
3516
|
+
return path$1.join(cwd, ".weapp-vite", "mcp-runtime.json");
|
|
3517
|
+
}
|
|
3518
|
+
async function isTcpPortOpen(host, port) {
|
|
3519
|
+
return await new Promise((resolve) => {
|
|
3520
|
+
const socket = net.createConnection({
|
|
3521
|
+
host,
|
|
3522
|
+
port
|
|
3523
|
+
});
|
|
3524
|
+
const cleanup = () => {
|
|
3525
|
+
socket.removeAllListeners();
|
|
3526
|
+
socket.destroy();
|
|
3527
|
+
};
|
|
3528
|
+
socket.once("connect", () => {
|
|
3529
|
+
cleanup();
|
|
3530
|
+
resolve(true);
|
|
3531
|
+
});
|
|
3532
|
+
socket.once("error", () => {
|
|
3533
|
+
cleanup();
|
|
3534
|
+
resolve(false);
|
|
3535
|
+
});
|
|
3536
|
+
socket.setTimeout(500, () => {
|
|
3537
|
+
cleanup();
|
|
3538
|
+
resolve(false);
|
|
3539
|
+
});
|
|
3540
|
+
});
|
|
3541
|
+
}
|
|
3542
|
+
async function writeRuntimeManifest(cwd, manifest) {
|
|
3543
|
+
const manifestPath = resolveManifestPath(cwd);
|
|
3544
|
+
await mkdir(path$1.dirname(manifestPath), { recursive: true });
|
|
3545
|
+
await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
3546
|
+
}
|
|
3547
|
+
async function maybeStartDetachedMcpServer(options) {
|
|
3548
|
+
const resolvedMcp = resolveWeappMcpConfig(options.mcpConfig, {
|
|
3549
|
+
agentName: options.agentName,
|
|
3550
|
+
cwd: options.cwd,
|
|
3551
|
+
isAgent: options.isAgent
|
|
3552
|
+
});
|
|
3553
|
+
if (!resolvedMcp.enabled || !resolvedMcp.autoStart) return;
|
|
3554
|
+
const entrypoint = resolveCliEntrypoint();
|
|
3555
|
+
if (!entrypoint) {
|
|
3556
|
+
logger_default.warn("[mcp] 找不到当前 CLI 入口,跳过 MCP 后台自动启动。");
|
|
3557
|
+
return;
|
|
3558
|
+
}
|
|
3559
|
+
const url = `http://${resolvedMcp.host}:${resolvedMcp.port}${resolvedMcp.endpoint}`;
|
|
3560
|
+
const restUrl = resolvedMcp.restEndpoint === false ? void 0 : `http://${resolvedMcp.host}:${resolvedMcp.port}${resolvedMcp.restEndpoint}`;
|
|
3561
|
+
if (await isTcpPortOpen(resolvedMcp.host, resolvedMcp.port)) {
|
|
3562
|
+
logger_default.info(`[mcp] MCP 服务已存在,继续复用:${colors.cyan(url)}`);
|
|
3563
|
+
return;
|
|
3564
|
+
}
|
|
3565
|
+
const args = [
|
|
3566
|
+
entrypoint,
|
|
3567
|
+
"mcp",
|
|
3568
|
+
"--transport",
|
|
3569
|
+
"streamable-http",
|
|
3570
|
+
"--host",
|
|
3571
|
+
resolvedMcp.host,
|
|
3572
|
+
"--port",
|
|
3573
|
+
String(resolvedMcp.port),
|
|
3574
|
+
"--endpoint",
|
|
3575
|
+
resolvedMcp.endpoint,
|
|
3576
|
+
"--workspace-root",
|
|
3577
|
+
options.cwd
|
|
3578
|
+
];
|
|
3579
|
+
if (resolvedMcp.restEndpoint === false) args.push("--no-rest");
|
|
3580
|
+
else args.push("--rest-endpoint", resolvedMcp.restEndpoint);
|
|
3581
|
+
const child = spawn(process.execPath, args, {
|
|
3582
|
+
cwd: options.cwd,
|
|
3583
|
+
detached: true,
|
|
3584
|
+
stdio: "ignore"
|
|
3585
|
+
});
|
|
3586
|
+
child.unref();
|
|
3587
|
+
if (child.pid) await writeRuntimeManifest(options.cwd, {
|
|
3588
|
+
agentName: resolvedMcp.agentName,
|
|
3589
|
+
endpoint: resolvedMcp.endpoint,
|
|
3590
|
+
pid: child.pid,
|
|
3591
|
+
projectRoot: options.cwd,
|
|
3592
|
+
restUrl,
|
|
3593
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3594
|
+
startedBy: "weapp-vite open",
|
|
3595
|
+
transport: "streamable-http",
|
|
3596
|
+
url
|
|
3597
|
+
});
|
|
3598
|
+
const suffix = resolvedMcp.agentName ? `(AI 终端:${resolvedMcp.agentName})` : "";
|
|
3599
|
+
logger_default.success(`MCP 服务已在后台自动启动:${suffix}`);
|
|
3600
|
+
logger_default.info(` ➜ ${colors.cyan(url)}`);
|
|
3601
|
+
if (restUrl) logger_default.info(` REST ➜ ${colors.cyan(restUrl)}`);
|
|
3602
|
+
for (const line of formatMcpQuickStart({
|
|
3603
|
+
httpUrl: url,
|
|
3604
|
+
transport: "http"
|
|
3605
|
+
})) logger_default.info(line);
|
|
3606
|
+
}
|
|
3607
|
+
//#endregion
|
|
3608
|
+
//#region src/cli/mcpOptions.ts
|
|
3609
|
+
function applyMcpCliOptions(config, options) {
|
|
3610
|
+
if (options.mcp === false) return false;
|
|
3611
|
+
if (options.mcp === true) return {
|
|
3612
|
+
...typeof config === "object" && config ? config : {},
|
|
3613
|
+
enabled: true,
|
|
3614
|
+
autoStart: true
|
|
3615
|
+
};
|
|
3616
|
+
return config;
|
|
3617
|
+
}
|
|
3618
|
+
//#endregion
|
|
3509
3619
|
//#region src/cli/commands/open.ts
|
|
3510
3620
|
function registerOpenCommand(cli) {
|
|
3511
|
-
cli.command("open [root]").option("-p, --platform <platform>", `[string] target platform (weapp | web)`).option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).option("--login-retry <mode>", "[string] login retry mode for Wechat DevTools (never | once | always)").option("--login-retry-timeout <ms>", "[number] login retry prompt timeout in milliseconds").option("--non-interactive", "[boolean] fail immediately when Wechat DevTools login has expired").action(async (root, options) => {
|
|
3621
|
+
cli.command("open [root]").option("-p, --platform <platform>", `[string] target platform (weapp | web)`).option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).option("--login-retry <mode>", "[string] login retry mode for Wechat DevTools (never | once | always)").option("--login-retry-timeout <ms>", "[number] login retry prompt timeout in milliseconds").option("--non-interactive", "[boolean] fail immediately when Wechat DevTools login has expired").option("--mcp", "[boolean] auto start MCP service before opening IDE").option("--no-mcp", "[boolean] disable MCP service before opening IDE").action(async (root, options) => {
|
|
3512
3622
|
filterDuplicateOptions(options);
|
|
3513
3623
|
const configFile = resolveConfigFile(options);
|
|
3514
3624
|
const targets = resolveRuntimeTargets(options);
|
|
@@ -3525,6 +3635,14 @@ function registerOpenCommand(cli) {
|
|
|
3525
3635
|
weappViteConfig
|
|
3526
3636
|
});
|
|
3527
3637
|
if (latestHmrSummary) logger_default.info(latestHmrSummary.line);
|
|
3638
|
+
const cwdForMcp = cwd ?? process.cwd();
|
|
3639
|
+
const aiEnvironment = await detectAiDevelopmentEnvironment();
|
|
3640
|
+
await maybeStartDetachedMcpServer({
|
|
3641
|
+
agentName: aiEnvironment.agentName,
|
|
3642
|
+
cwd: cwdForMcp,
|
|
3643
|
+
isAgent: aiEnvironment.isAgent,
|
|
3644
|
+
mcpConfig: applyMcpCliOptions(weappViteConfig?.mcp, options)
|
|
3645
|
+
});
|
|
3528
3646
|
await openIde(platform, projectPath ?? resolveIdeProjectRoot(mpDistRoot, process.cwd()), {
|
|
3529
3647
|
loginRetry: options.loginRetry,
|
|
3530
3648
|
loginRetryTimeout: options.loginRetryTimeout,
|
|
@@ -3781,7 +3899,7 @@ function resolveRunnableHotkeyDefinition(input) {
|
|
|
3781
3899
|
}
|
|
3782
3900
|
//#endregion
|
|
3783
3901
|
//#region package.json
|
|
3784
|
-
var version = "6.16.
|
|
3902
|
+
var version = "6.16.44";
|
|
3785
3903
|
//#endregion
|
|
3786
3904
|
//#region src/cli/devHotkeys/format.ts
|
|
3787
3905
|
const FULLWIDTH_ASCII_START = 65281;
|
|
@@ -3795,6 +3913,19 @@ function formatMcpStatus(state) {
|
|
|
3795
3913
|
if (!state.mcpEnabled) return "已禁用";
|
|
3796
3914
|
return state.mcpRunning ? "运行中" : "未启动";
|
|
3797
3915
|
}
|
|
3916
|
+
function formatMcpHelpRows(state) {
|
|
3917
|
+
if (!state.mcpEnabled || !state.mcpHttpUrl) return [];
|
|
3918
|
+
return [
|
|
3919
|
+
"",
|
|
3920
|
+
"MCP 接入",
|
|
3921
|
+
`HTTP:${colors.cyan(state.mcpHttpUrl)}`,
|
|
3922
|
+
...state.mcpRestUrl ? [`REST:${colors.cyan(state.mcpRestUrl)}`] : [],
|
|
3923
|
+
...formatMcpQuickStart({
|
|
3924
|
+
httpUrl: state.mcpHttpUrl,
|
|
3925
|
+
transport: "http"
|
|
3926
|
+
})
|
|
3927
|
+
];
|
|
3928
|
+
}
|
|
3798
3929
|
function formatFooterLine(state) {
|
|
3799
3930
|
if (state.currentAction) return `执行中 ${state.currentAction}`;
|
|
3800
3931
|
return "就绪 等待操作...";
|
|
@@ -3837,7 +3968,8 @@ function formatDevHotkeyHelpWithState(state) {
|
|
|
3837
3968
|
...retrySections,
|
|
3838
3969
|
"",
|
|
3839
3970
|
`当前状态:${state.currentAction ?? "等待操作"} / MCP ${formatMcpStatus(state)}`,
|
|
3840
|
-
...state.lastAction ? [`最近操作:${state.lastAction}`] : []
|
|
3971
|
+
...state.lastAction ? [`最近操作:${state.lastAction}`] : [],
|
|
3972
|
+
...formatMcpHelpRows(state)
|
|
3841
3973
|
].join("\n");
|
|
3842
3974
|
}
|
|
3843
3975
|
/**
|
|
@@ -3861,41 +3993,52 @@ function resolveProjectLabel(cwd) {
|
|
|
3861
3993
|
}
|
|
3862
3994
|
//#endregion
|
|
3863
3995
|
//#region src/cli/devHotkeys/mcp.ts
|
|
3864
|
-
|
|
3996
|
+
const REG_EADDRINUSE$1 = /EADDRINUSE/;
|
|
3997
|
+
function formatMcpUrl$1(host, port, endpoint) {
|
|
3865
3998
|
return `http://${host}:${port}${endpoint}`;
|
|
3866
3999
|
}
|
|
3867
4000
|
function createToggleMcpAction(options) {
|
|
3868
4001
|
const { cwd, getHandle, resolvedMcp, setHandle } = options;
|
|
3869
|
-
return async function toggleMcp() {
|
|
4002
|
+
return async function toggleMcp(actionOptions = {}) {
|
|
4003
|
+
const silent = actionOptions.silent === true;
|
|
3870
4004
|
if (!resolvedMcp.enabled) {
|
|
3871
4005
|
logger_default.warn("[dev action] MCP 已在配置中禁用,跳过切换。");
|
|
3872
4006
|
return "MCP 已禁用";
|
|
3873
4007
|
}
|
|
3874
4008
|
const existingHandle = getHandle();
|
|
3875
4009
|
if (existingHandle?.close) {
|
|
3876
|
-
const url = formatMcpUrl(resolvedMcp.host, resolvedMcp.port, resolvedMcp.endpoint);
|
|
4010
|
+
const url = formatMcpUrl$1(resolvedMcp.host, resolvedMcp.port, resolvedMcp.endpoint);
|
|
3877
4011
|
logger_default.info(`[dev action] 正在关闭 MCP 服务:${colors.cyan(url)}`);
|
|
3878
4012
|
await existingHandle.close();
|
|
3879
4013
|
setHandle(void 0);
|
|
3880
4014
|
logger_default.success(`[dev action] MCP 服务已关闭:${colors.cyan(url)}`);
|
|
3881
4015
|
return `MCP 已关闭 (${url})`;
|
|
3882
4016
|
}
|
|
3883
|
-
const url = formatMcpUrl(resolvedMcp.host, resolvedMcp.port, resolvedMcp.endpoint);
|
|
3884
|
-
logger_default.info(`[dev action] 正在启动 MCP 服务:${colors.cyan(url)}`);
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
4017
|
+
const url = formatMcpUrl$1(resolvedMcp.host, resolvedMcp.port, resolvedMcp.endpoint);
|
|
4018
|
+
if (!silent) logger_default.info(`[dev action] 正在启动 MCP 服务:${colors.cyan(url)}`);
|
|
4019
|
+
let handle;
|
|
4020
|
+
try {
|
|
4021
|
+
handle = await startWeappViteMcpServer({
|
|
4022
|
+
endpoint: resolvedMcp.endpoint,
|
|
4023
|
+
host: resolvedMcp.host,
|
|
4024
|
+
port: resolvedMcp.port,
|
|
4025
|
+
restEndpoint: resolvedMcp.restEndpoint,
|
|
4026
|
+
transport: "streamable-http",
|
|
4027
|
+
unref: false,
|
|
4028
|
+
onReady: () => {},
|
|
4029
|
+
workspaceRoot: cwd
|
|
4030
|
+
});
|
|
4031
|
+
} catch (error) {
|
|
4032
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4033
|
+
if (REG_EADDRINUSE$1.test(message)) {
|
|
4034
|
+
if (!silent) logger_default.info(`[dev action] MCP 服务已存在,继续复用:${colors.cyan(url)}`);
|
|
4035
|
+
return `MCP 已复用 (${url})`;
|
|
4036
|
+
}
|
|
4037
|
+
throw error;
|
|
4038
|
+
}
|
|
4039
|
+
setHandle(handle);
|
|
4040
|
+
const suffix = resolvedMcp.agentName ? `(AI 终端:${resolvedMcp.agentName})` : "";
|
|
4041
|
+
if (!silent) logger_default.success(`[dev action] MCP 服务已启动:${colors.cyan(url)}${suffix}`);
|
|
3899
4042
|
return `MCP 已启动 (${url})`;
|
|
3900
4043
|
};
|
|
3901
4044
|
}
|
|
@@ -3907,6 +4050,9 @@ function forwardSigint() {
|
|
|
3907
4050
|
function forwardSigtstp() {
|
|
3908
4051
|
process.kill(process.pid, "SIGTSTP");
|
|
3909
4052
|
}
|
|
4053
|
+
function formatMcpUrl(host, port, endpoint) {
|
|
4054
|
+
return `http://${host}:${port}${endpoint}`;
|
|
4055
|
+
}
|
|
3910
4056
|
/**
|
|
3911
4057
|
* @description 在开发态启动终端快捷键,并将动作输出到本地日志。
|
|
3912
4058
|
*/
|
|
@@ -3922,12 +4068,20 @@ function startDevHotkeys(options) {
|
|
|
3922
4068
|
let lastAction;
|
|
3923
4069
|
let lastRenderedPanel = "";
|
|
3924
4070
|
const recentInputs = /* @__PURE__ */ new Map();
|
|
3925
|
-
const resolvedMcp = resolveWeappMcpConfig(options.mcpConfig
|
|
4071
|
+
const resolvedMcp = resolveWeappMcpConfig(options.mcpConfig, {
|
|
4072
|
+
agentName: options.agentName,
|
|
4073
|
+
cwd: options.cwd,
|
|
4074
|
+
isAgent: options.isAgent
|
|
4075
|
+
});
|
|
4076
|
+
const mcpHttpUrl = formatMcpUrl(resolvedMcp.host, resolvedMcp.port, resolvedMcp.endpoint);
|
|
4077
|
+
const mcpRestUrl = resolvedMcp.restEndpoint === false ? void 0 : formatMcpUrl(resolvedMcp.host, resolvedMcp.port, resolvedMcp.restEndpoint);
|
|
3926
4078
|
const getState = () => ({
|
|
3927
4079
|
currentAction,
|
|
3928
4080
|
lastAction,
|
|
3929
4081
|
mcpEnabled: resolvedMcp.enabled,
|
|
4082
|
+
mcpHttpUrl,
|
|
3930
4083
|
mcpRunning: Boolean(mcpHandle?.close),
|
|
4084
|
+
mcpRestUrl,
|
|
3931
4085
|
projectLabel: resolveProjectLabel(options.cwd)
|
|
3932
4086
|
});
|
|
3933
4087
|
let inputSession = createSharedInputSession({
|
|
@@ -4006,6 +4160,19 @@ function startDevHotkeys(options) {
|
|
|
4006
4160
|
if (!closed) printHint();
|
|
4007
4161
|
});
|
|
4008
4162
|
};
|
|
4163
|
+
const runBackgroundAction = (label, pendingLabel, action) => {
|
|
4164
|
+
if (running) return;
|
|
4165
|
+
running = true;
|
|
4166
|
+
currentAction = pendingLabel;
|
|
4167
|
+
action().then((summary) => {
|
|
4168
|
+
if (summary) lastAction = summary;
|
|
4169
|
+
}).catch((error) => {
|
|
4170
|
+
logger_default.error(`[dev action] ${label}失败:${error instanceof Error ? error.message : String(error)}`);
|
|
4171
|
+
}).finally(() => {
|
|
4172
|
+
running = false;
|
|
4173
|
+
currentAction = void 0;
|
|
4174
|
+
});
|
|
4175
|
+
};
|
|
4009
4176
|
const handleInput = (input) => {
|
|
4010
4177
|
if (closed) return;
|
|
4011
4178
|
const normalizedInput = normalizeInputChar(input);
|
|
@@ -4070,8 +4237,8 @@ function startDevHotkeys(options) {
|
|
|
4070
4237
|
};
|
|
4071
4238
|
process.on("SIGCONT", onSigcont);
|
|
4072
4239
|
if (!options.silentStartupHint) printHint();
|
|
4073
|
-
if (resolvedMcp.enabled && resolvedMcp.autoStart)
|
|
4074
|
-
await toggleMcp();
|
|
4240
|
+
if (resolvedMcp.enabled && resolvedMcp.autoStart) runBackgroundAction("MCP 自动启动", "正在启动 MCP 服务", async () => {
|
|
4241
|
+
await toggleMcp({ silent: true });
|
|
4075
4242
|
});
|
|
4076
4243
|
return {
|
|
4077
4244
|
close,
|
|
@@ -4080,72 +4247,6 @@ function startDevHotkeys(options) {
|
|
|
4080
4247
|
};
|
|
4081
4248
|
}
|
|
4082
4249
|
//#endregion
|
|
4083
|
-
//#region src/cli/commands/serve/activeIdeProjects.ts
|
|
4084
|
-
const ACTIVE_IDE_PROJECTS_DIR = path$1.join(os.tmpdir(), "weapp-vite-active-dev-open-projects");
|
|
4085
|
-
function normalizeProjectPath(projectPath) {
|
|
4086
|
-
return path$1.resolve(projectPath);
|
|
4087
|
-
}
|
|
4088
|
-
function resolveRecordPath(projectPath) {
|
|
4089
|
-
return path$1.join(ACTIVE_IDE_PROJECTS_DIR, `${Buffer.from(normalizeProjectPath(projectPath)).toString("base64url")}.json`);
|
|
4090
|
-
}
|
|
4091
|
-
function isProcessAlive(pid) {
|
|
4092
|
-
try {
|
|
4093
|
-
process.kill(pid, 0);
|
|
4094
|
-
return true;
|
|
4095
|
-
} catch (error) {
|
|
4096
|
-
if (error && typeof error === "object" && "code" in error && error.code === "ESRCH") return false;
|
|
4097
|
-
return true;
|
|
4098
|
-
}
|
|
4099
|
-
}
|
|
4100
|
-
async function readRecord(filePath) {
|
|
4101
|
-
try {
|
|
4102
|
-
const raw = await fs$2.readFile(filePath, "utf8");
|
|
4103
|
-
const record = JSON.parse(raw);
|
|
4104
|
-
if (typeof record.pid !== "number" || typeof record.projectPath !== "string") return null;
|
|
4105
|
-
return record;
|
|
4106
|
-
} catch {
|
|
4107
|
-
return null;
|
|
4108
|
-
}
|
|
4109
|
-
}
|
|
4110
|
-
/**
|
|
4111
|
-
* @description 登记当前 dev:open 项目,供后续启动判断是否需要保留其它正在运行的 IDE 窗口。
|
|
4112
|
-
*/
|
|
4113
|
-
async function registerActiveServeIdeProject(projectPath) {
|
|
4114
|
-
const filePath = resolveRecordPath(projectPath);
|
|
4115
|
-
await fs$2.mkdir(path$1.dirname(filePath), { recursive: true });
|
|
4116
|
-
await fs$2.writeFile(filePath, `${JSON.stringify({
|
|
4117
|
-
pid: process.pid,
|
|
4118
|
-
projectPath: normalizeProjectPath(projectPath),
|
|
4119
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4120
|
-
}, null, 2)}\n`, "utf8");
|
|
4121
|
-
return async () => {
|
|
4122
|
-
await fs$2.rm(filePath, { force: true }).catch(() => {});
|
|
4123
|
-
};
|
|
4124
|
-
}
|
|
4125
|
-
/**
|
|
4126
|
-
* @description 检查是否存在其它仍在运行的 dev:open 项目。
|
|
4127
|
-
*/
|
|
4128
|
-
async function hasOtherActiveServeIdeProject(projectPath) {
|
|
4129
|
-
const currentProjectPath = normalizeProjectPath(projectPath);
|
|
4130
|
-
let entries;
|
|
4131
|
-
try {
|
|
4132
|
-
entries = await fs$2.readdir(ACTIVE_IDE_PROJECTS_DIR);
|
|
4133
|
-
} catch {
|
|
4134
|
-
return false;
|
|
4135
|
-
}
|
|
4136
|
-
for (const entry of entries) {
|
|
4137
|
-
if (!entry.endsWith(".json")) continue;
|
|
4138
|
-
const filePath = path$1.join(ACTIVE_IDE_PROJECTS_DIR, entry);
|
|
4139
|
-
const record = await readRecord(filePath);
|
|
4140
|
-
if (!record || !isProcessAlive(record.pid)) {
|
|
4141
|
-
await fs$2.rm(filePath, { force: true }).catch(() => {});
|
|
4142
|
-
continue;
|
|
4143
|
-
}
|
|
4144
|
-
if (normalizeProjectPath(record.projectPath) !== currentProjectPath) return true;
|
|
4145
|
-
}
|
|
4146
|
-
return false;
|
|
4147
|
-
}
|
|
4148
|
-
//#endregion
|
|
4149
4250
|
//#region src/cli/commands/serve/analyze.ts
|
|
4150
4251
|
const REG_DIST_PAGE_ENTRY = /pages\/.+\/index\.js$/;
|
|
4151
4252
|
const REG_DIST_POSIX_SEP = /\\/g;
|
|
@@ -4452,7 +4553,7 @@ function waitForServeShutdownSignal() {
|
|
|
4452
4553
|
//#endregion
|
|
4453
4554
|
//#region src/cli/commands/serve/index.ts
|
|
4454
4555
|
function registerServeCommand(cli) {
|
|
4455
|
-
cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).option("-p, --platform <platform>", `[string] target platform (weapp | web | all)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).option("--login-retry <mode>", "[string] login retry mode for Wechat DevTools (never | once | always)").option("--login-retry-timeout <ms>", "[number] login retry prompt timeout in milliseconds").option("--non-interactive", "[boolean] fail immediately when Wechat DevTools login has expired").option("--host [host]", `[string] web dev server host`).option("--ui", `[boolean] 启动调试 UI(当前提供分析视图)`, { default: false }).option("--analyze", `[boolean] 启动分包分析仪表盘 (实验特性)`, { default: false }).option("--scope <scope>", `[string] 局部构建范围,例如 main,packages/order`).action(async (root, options) => {
|
|
4556
|
+
cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).option("-p, --platform <platform>", `[string] target platform (weapp | web | all)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).option("--login-retry <mode>", "[string] login retry mode for Wechat DevTools (never | once | always)").option("--login-retry-timeout <ms>", "[number] login retry prompt timeout in milliseconds").option("--non-interactive", "[boolean] fail immediately when Wechat DevTools login has expired").option("--mcp", "[boolean] auto start MCP service during dev").option("--no-mcp", "[boolean] disable MCP service during dev").option("--host [host]", `[string] web dev server host`).option("--ui", `[boolean] 启动调试 UI(当前提供分析视图)`, { default: false }).option("--analyze", `[boolean] 启动分包分析仪表盘 (实验特性)`, { default: false }).option("--scope <scope>", `[string] 局部构建范围,例如 main,packages/order`).action(async (root, options) => {
|
|
4456
4557
|
filterDuplicateOptions(options);
|
|
4457
4558
|
const cwd = root ?? process.cwd();
|
|
4458
4559
|
const configFile = resolveConfigFile(options);
|
|
@@ -4497,6 +4598,8 @@ function registerServeCommand(cli) {
|
|
|
4497
4598
|
projectConfigPath: options.projectConfig
|
|
4498
4599
|
});
|
|
4499
4600
|
const { buildService, configService, webService } = ctx;
|
|
4601
|
+
const aiEnvironment = await detectAiDevelopmentEnvironment();
|
|
4602
|
+
const mcpConfig = applyMcpCliOptions(configService.weappViteConfig?.mcp, options);
|
|
4500
4603
|
logRuntimeTarget(targets, { resolvedConfigPlatform: configService.platform });
|
|
4501
4604
|
const enableAnalyze = Boolean(isUiEnabled(options) && targets.runMini);
|
|
4502
4605
|
let analyzeHandle;
|
|
@@ -4527,7 +4630,9 @@ function registerServeCommand(cli) {
|
|
|
4527
4630
|
});
|
|
4528
4631
|
const devHotkeysSession = targets.runMini ? startDevHotkeys({
|
|
4529
4632
|
cwd: configService.cwd,
|
|
4530
|
-
|
|
4633
|
+
agentName: aiEnvironment.agentName,
|
|
4634
|
+
isAgent: aiEnvironment.isAgent,
|
|
4635
|
+
mcpConfig,
|
|
4531
4636
|
openIde: async () => await miniProgramDevActions.openIde({
|
|
4532
4637
|
forceOpen: true,
|
|
4533
4638
|
forceReopen: true
|
|
@@ -4538,7 +4643,6 @@ function registerServeCommand(cli) {
|
|
|
4538
4643
|
silentStartupHint: true,
|
|
4539
4644
|
weappViteConfig: configService.weappViteConfig
|
|
4540
4645
|
}) : void 0;
|
|
4541
|
-
let unregisterActiveIdeProject;
|
|
4542
4646
|
try {
|
|
4543
4647
|
const analyzeController = createAnalyzeController({
|
|
4544
4648
|
configFile,
|
|
@@ -4613,11 +4717,9 @@ function registerServeCommand(cli) {
|
|
|
4613
4717
|
}]);
|
|
4614
4718
|
devHotkeysSession?.suspend();
|
|
4615
4719
|
try {
|
|
4616
|
-
unregisterActiveIdeProject = miniProgramDevActions.projectPath ? await registerActiveServeIdeProject(miniProgramDevActions.projectPath) : void 0;
|
|
4617
|
-
const shouldForceReopen = miniProgramDevActions.projectPath ? !await hasOtherActiveServeIdeProject(miniProgramDevActions.projectPath) : true;
|
|
4618
4720
|
await miniProgramDevActions.openIde({
|
|
4619
4721
|
forceOpen: true,
|
|
4620
|
-
forceReopen:
|
|
4722
|
+
forceReopen: false
|
|
4621
4723
|
});
|
|
4622
4724
|
} finally {
|
|
4623
4725
|
devHotkeysSession?.restore();
|
|
@@ -4626,7 +4728,6 @@ function registerServeCommand(cli) {
|
|
|
4626
4728
|
if (analyzeHandle) await analyzeController.waitForExit();
|
|
4627
4729
|
else if (targets.runMini || targets.runWeb) await waitForServeShutdownSignal();
|
|
4628
4730
|
} finally {
|
|
4629
|
-
await unregisterActiveIdeProject?.();
|
|
4630
4731
|
devHotkeysSession?.close();
|
|
4631
4732
|
ctx.watcherService?.closeAll();
|
|
4632
4733
|
}
|
|
@@ -4736,7 +4837,13 @@ async function maybeAutoStartMcpServer(argv, cliOptions) {
|
|
|
4736
4837
|
} catch (error) {
|
|
4737
4838
|
logger_default.warn(`[mcp] 读取配置失败,使用默认 MCP 配置自动启动:${error instanceof Error ? error.message : String(error)}`);
|
|
4738
4839
|
}
|
|
4739
|
-
const
|
|
4840
|
+
const maybeMcpConfig = rawMcpConfig;
|
|
4841
|
+
const aiEnvironment = await detectAiDevelopmentEnvironment();
|
|
4842
|
+
const resolvedMcp = resolveWeappMcpConfig(maybeMcpConfig, {
|
|
4843
|
+
agentName: aiEnvironment.agentName,
|
|
4844
|
+
cwd: process.cwd(),
|
|
4845
|
+
isAgent: aiEnvironment.isAgent
|
|
4846
|
+
});
|
|
4740
4847
|
if (!resolvedMcp.enabled || !resolvedMcp.autoStart) return;
|
|
4741
4848
|
try {
|
|
4742
4849
|
await startWeappViteMcpServer({
|
|
@@ -420,9 +420,9 @@ interface MultiPlatformConfig {
|
|
|
420
420
|
*/
|
|
421
421
|
interface WeappMcpConfig {
|
|
422
422
|
enabled?: boolean;
|
|
423
|
-
autoStart?: boolean;
|
|
423
|
+
autoStart?: boolean | 'ai';
|
|
424
424
|
host?: string;
|
|
425
|
-
port?: number;
|
|
425
|
+
port?: number | 'auto';
|
|
426
426
|
endpoint?: string;
|
|
427
427
|
/**
|
|
428
428
|
* @description streamable-http 模式下的 DevTools runtime REST 入口;设为 false 可关闭。
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Bn as WeappViteHostMeta, Hn as createWeappViteHostMeta, Un as isWeappViteHost, Vn as applyWeappViteHostMeta, Wn as resolveWeappViteHostMeta, Yn as WeappViteRuntime, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, l as defineConfig, m as Theme, n as UserConfigExport, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson, zn as WEAPP_VITE_HOST_NAME } from "./config-
|
|
1
|
+
import { Bn as WeappViteHostMeta, Hn as createWeappViteHostMeta, Un as isWeappViteHost, Vn as applyWeappViteHostMeta, Wn as resolveWeappViteHostMeta, Yn as WeappViteRuntime, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, l as defineConfig, m as Theme, n as UserConfigExport, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson, zn as WEAPP_VITE_HOST_NAME } from "./config-Ds7MBgQm.mjs";
|
|
2
2
|
export { type App, type Component, type Page, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, type WeappViteConfig, WeappViteHostMeta, type WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as applyWeappViteHostMeta } from "./pluginHost--CaeyWpA.mjs";
|
|
2
2
|
import { n as configureLogger, r as logger_default } from "./logger-mt4mSTqV.mjs";
|
|
3
|
-
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-
|
|
3
|
+
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-DBbvHZyc.mjs";
|
|
4
4
|
import { createRequire, isBuiltin } from "node:module";
|
|
5
5
|
import path, { posix } from "pathe";
|
|
6
6
|
import path$1, { normalize, relative, win32 } from "node:path";
|
|
@@ -9146,9 +9146,9 @@ function getWeappViteConfig() {
|
|
|
9146
9146
|
},
|
|
9147
9147
|
mcp: {
|
|
9148
9148
|
enabled: true,
|
|
9149
|
-
autoStart:
|
|
9149
|
+
autoStart: "ai",
|
|
9150
9150
|
host: "127.0.0.1",
|
|
9151
|
-
port:
|
|
9151
|
+
port: "auto",
|
|
9152
9152
|
endpoint: "/mcp",
|
|
9153
9153
|
restEndpoint: "/api/weapp/devtools"
|
|
9154
9154
|
},
|
|
@@ -11037,6 +11037,27 @@ async function collectAppSideFiles(pluginCtx, id, json, jsonService, registerJso
|
|
|
11037
11037
|
await processSideJson(sitemapLocation);
|
|
11038
11038
|
await processSideJson(themeLocation);
|
|
11039
11039
|
}
|
|
11040
|
+
async function collectMiniappConfigFile(pluginCtx, id, configService, jsonService, registerJsonAsset, existsCache, ttlMs) {
|
|
11041
|
+
if (configService.platform !== "weapp") return;
|
|
11042
|
+
const runtimeMiniappConfigPath = path.resolve(path.dirname(id), "app.miniapp.json");
|
|
11043
|
+
if (await addWatchTarget(pluginCtx, runtimeMiniappConfigPath, existsCache, ttlMs)) {
|
|
11044
|
+
registerJsonAsset({
|
|
11045
|
+
fileName: "app.miniapp.json",
|
|
11046
|
+
json: await jsonService.read(runtimeMiniappConfigPath),
|
|
11047
|
+
jsonPath: runtimeMiniappConfigPath,
|
|
11048
|
+
type: "page"
|
|
11049
|
+
});
|
|
11050
|
+
return;
|
|
11051
|
+
}
|
|
11052
|
+
const miniappConfigPath = path.resolve(configService.cwd, "project.miniapp.json");
|
|
11053
|
+
if (!await addWatchTarget(pluginCtx, miniappConfigPath, existsCache, ttlMs)) return;
|
|
11054
|
+
registerJsonAsset({
|
|
11055
|
+
fileName: "app.miniapp.json",
|
|
11056
|
+
json: await jsonService.read(miniappConfigPath),
|
|
11057
|
+
jsonPath: miniappConfigPath,
|
|
11058
|
+
type: "page"
|
|
11059
|
+
});
|
|
11060
|
+
}
|
|
11040
11061
|
async function ensureTemplateScanned(pluginCtx, id, scanTemplateEntry, existsCache, ttlMs) {
|
|
11041
11062
|
const { path: templateEntry, predictions } = await findTemplateEntry(id);
|
|
11042
11063
|
for (const prediction of predictions) await addWatchTarget(pluginCtx, prediction, existsCache, ttlMs);
|
|
@@ -14317,32 +14338,33 @@ function mergeInlineConfig(config, injectBuiltinAliases, ...configs) {
|
|
|
14317
14338
|
//#endregion
|
|
14318
14339
|
//#region src/plugins/utils/scriptlessComponent.ts
|
|
14319
14340
|
const SCRIPTLESS_COMPONENT_STUB = "Component({})";
|
|
14341
|
+
const SLOT_HOST_SCRIPTLESS_COMPONENT_STUB = "Component({properties:{vueSlots:{type:null,value:null},__wvSlotOwnerId:{type:String,value:\"\"},__wvSlotScope:{type:null,value:null}}})";
|
|
14320
14342
|
/**
|
|
14321
14343
|
* 统一生成无脚本组件的脚本产物文件名。
|
|
14322
14344
|
*/
|
|
14323
14345
|
function resolveScriptlessComponentFileName(relativeBase, scriptExtension) {
|
|
14324
14346
|
return `${relativeBase}.${scriptExtension}`;
|
|
14325
14347
|
}
|
|
14326
|
-
function emitScriptlessComponentAsset(pluginCtx, fileName) {
|
|
14348
|
+
function emitScriptlessComponentAsset(pluginCtx, fileName, source = SCRIPTLESS_COMPONENT_STUB) {
|
|
14327
14349
|
pluginCtx.emitFile({
|
|
14328
14350
|
type: "asset",
|
|
14329
14351
|
fileName,
|
|
14330
|
-
source
|
|
14352
|
+
source
|
|
14331
14353
|
});
|
|
14332
14354
|
}
|
|
14333
14355
|
/**
|
|
14334
14356
|
* 在 bundle 中补齐或覆盖无脚本组件占位脚本。
|
|
14335
14357
|
*/
|
|
14336
|
-
function ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension) {
|
|
14358
|
+
function ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension, source = SCRIPTLESS_COMPONENT_STUB) {
|
|
14337
14359
|
const fileName = resolveScriptlessComponentFileName(relativeBase, scriptExtension);
|
|
14338
14360
|
const existing = bundle[fileName];
|
|
14339
14361
|
if (existing) {
|
|
14340
14362
|
if (existing.type === "asset") {
|
|
14341
|
-
if ((existing.source?.toString?.() ?? "") !==
|
|
14363
|
+
if ((existing.source?.toString?.() ?? "") !== source) existing.source = source;
|
|
14342
14364
|
}
|
|
14343
14365
|
return fileName;
|
|
14344
14366
|
}
|
|
14345
|
-
emitScriptlessComponentAsset(pluginCtx, fileName);
|
|
14367
|
+
emitScriptlessComponentAsset(pluginCtx, fileName, source);
|
|
14346
14368
|
return fileName;
|
|
14347
14369
|
}
|
|
14348
14370
|
//#endregion
|
|
@@ -15810,8 +15832,8 @@ function createExtendedLibManager() {
|
|
|
15810
15832
|
function createJsonEmitManager(configService) {
|
|
15811
15833
|
const map = /* @__PURE__ */ new Map();
|
|
15812
15834
|
function register(entry) {
|
|
15813
|
-
if (!entry.jsonPath) return;
|
|
15814
|
-
const fileName = resolveRelativeJsonOutputFileName(configService, entry.jsonPath);
|
|
15835
|
+
if (!entry.jsonPath && !entry.fileName) return;
|
|
15836
|
+
const fileName = entry.fileName ?? resolveRelativeJsonOutputFileName(configService, entry.jsonPath);
|
|
15815
15837
|
const normalizedEntry = entry.type === "app" && fileName === "app.json" ? {
|
|
15816
15838
|
...entry,
|
|
15817
15839
|
json: normalizeAppJson(entry.json)
|
|
@@ -15987,19 +16009,21 @@ function getPlatformLayoutElseDirective(platform) {
|
|
|
15987
16009
|
function toKebabAttrName(key) {
|
|
15988
16010
|
return toKebabCase(key);
|
|
15989
16011
|
}
|
|
16012
|
+
const LAYOUT_SLOT_OWNER_ATTR = `${WEVU_SLOT_OWNER_ID_ATTR}="{{${WEVU_SLOT_OWNER_ID_PROP} || ${WEVU_SLOT_OWNER_ID_KEY} || ''}}"`;
|
|
15990
16013
|
function hasDynamicExpressionLayoutProps(props) {
|
|
15991
16014
|
if (!props) return false;
|
|
15992
16015
|
return Object.values(props).some((value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "expression");
|
|
15993
16016
|
}
|
|
15994
16017
|
function serializeLayoutProps(props) {
|
|
15995
|
-
|
|
15996
|
-
|
|
16018
|
+
const attrs = [LAYOUT_SLOT_OWNER_ATTR];
|
|
16019
|
+
if (!props || Object.keys(props).length === 0) return ` ${attrs.join(" ")}`;
|
|
16020
|
+
attrs.push(...Object.entries(props).map(([key, value]) => {
|
|
15997
16021
|
const attrName = toKebabAttrName(key);
|
|
15998
16022
|
if (typeof value === "string") return `${attrName}="${escapeDoubleQuotedAttr(value)}"`;
|
|
15999
16023
|
if (typeof value === "object" && value && "kind" in value && value.kind === "expression") return `${attrName}="{{${WEVU_LAYOUT_BIND_PREFIX}${key}}}"`;
|
|
16000
16024
|
if (typeof value === "number" || typeof value === "boolean" || value === null) return `${attrName}="{{${String(value)}}}"`;
|
|
16001
16025
|
return "";
|
|
16002
|
-
}).filter(Boolean);
|
|
16026
|
+
}).filter(Boolean));
|
|
16003
16027
|
return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
16004
16028
|
}
|
|
16005
16029
|
function collapseNestedLayoutWrapper(template, tagName) {
|
|
@@ -16020,10 +16044,12 @@ function serializeFallbackLayoutValue(value, keyName) {
|
|
|
16020
16044
|
return `(${WEVU_PAGE_LAYOUT_PROPS_KEY}&&${WEVU_PAGE_LAYOUT_PROPS_KEY}.${keyName})!==undefined?${WEVU_PAGE_LAYOUT_PROPS_KEY}.${keyName}:${JSON.stringify(value)}`;
|
|
16021
16045
|
}
|
|
16022
16046
|
function buildDynamicLayoutAttrs(propKeys, currentLayout) {
|
|
16023
|
-
|
|
16024
|
-
return ` ${
|
|
16047
|
+
const attrs = [LAYOUT_SLOT_OWNER_ATTR];
|
|
16048
|
+
if (propKeys.length === 0) return ` ${attrs.join(" ")}`;
|
|
16049
|
+
attrs.push(...propKeys.map((key) => {
|
|
16025
16050
|
return `${toKebabAttrName(key)}="{{${serializeFallbackLayoutValue(currentLayout?.props?.[key], key)}}}"`;
|
|
16026
|
-
})
|
|
16051
|
+
}));
|
|
16052
|
+
return ` ${attrs.join(" ")}`;
|
|
16027
16053
|
}
|
|
16028
16054
|
function buildDynamicLayoutTemplate(innerTemplate, currentLayout, layouts, propKeys, platform) {
|
|
16029
16055
|
return `${layouts.map((layout, index) => {
|
|
@@ -16742,6 +16768,7 @@ async function collectAppEntries(options) {
|
|
|
16742
16768
|
if (!isPluginBuild) {
|
|
16743
16769
|
extendedLibManager.syncFromAppJson(json);
|
|
16744
16770
|
await collectAppSideFiles(pluginCtx, id, json, jsonService, registerJsonAsset, existsCache, pathExistsTtlMs);
|
|
16771
|
+
await collectMiniappConfigFile(pluginCtx, id, configService, jsonService, registerJsonAsset, existsCache, pathExistsTtlMs);
|
|
16745
16772
|
}
|
|
16746
16773
|
const pluginJsonPath = scanService?.pluginJsonPath;
|
|
16747
16774
|
if (isPluginBuild && configService.absolutePluginRoot && pluginJsonPath) {
|
|
@@ -17288,7 +17315,7 @@ function createEntryLoader(options) {
|
|
|
17288
17315
|
if (!relativeLayoutBase || emittedScriptlessVueLayoutJs.has(relativeLayoutBase)) continue;
|
|
17289
17316
|
emittedScriptlessVueLayoutJs.add(relativeLayoutBase);
|
|
17290
17317
|
const { scriptExtension } = resolveCompilerOutputExtensions(configService.outputExtensions);
|
|
17291
|
-
emitScriptlessComponentAsset(this, resolveScriptlessComponentFileName(relativeLayoutBase, scriptExtension));
|
|
17318
|
+
emitScriptlessComponentAsset(this, resolveScriptlessComponentFileName(relativeLayoutBase, scriptExtension), SLOT_HOST_SCRIPTLESS_COMPONENT_STUB);
|
|
17292
17319
|
}
|
|
17293
17320
|
};
|
|
17294
17321
|
if (type === "app") {
|
|
@@ -18817,6 +18844,7 @@ const REQUEST_GLOBAL_FREE_BINDING_TARGETS = new Set([
|
|
|
18817
18844
|
"URL",
|
|
18818
18845
|
"URLSearchParams",
|
|
18819
18846
|
"Blob",
|
|
18847
|
+
"File",
|
|
18820
18848
|
"FormData"
|
|
18821
18849
|
]);
|
|
18822
18850
|
const CODE_USAGE_AUTO_RULES = [
|
|
@@ -18951,7 +18979,7 @@ function resolveRequestGlobalsBindingTargets(targets) {
|
|
|
18951
18979
|
const bindingTargets = [...targets];
|
|
18952
18980
|
if (targets.some((target) => target === "fetch" || target === "Request" || target === "Response" || target === "XMLHttpRequest" || target === "WebSocket")) {
|
|
18953
18981
|
bindingTargets.push("TextEncoder", "TextDecoder");
|
|
18954
|
-
bindingTargets.push("URL", "URLSearchParams", "Blob", "FormData");
|
|
18982
|
+
bindingTargets.push("URL", "URLSearchParams", "Blob", "File", "FormData");
|
|
18955
18983
|
}
|
|
18956
18984
|
if (targets.includes("CustomEvent")) bindingTargets.push("Event");
|
|
18957
18985
|
return [...new Set(bindingTargets)].filter((target) => REQUEST_GLOBAL_FREE_BINDING_TARGETS.has(target));
|
|
@@ -18996,6 +19024,7 @@ function createRequestGlobalsPassiveBindingsCode(targets, explicitBindingTargets
|
|
|
18996
19024
|
if (target === "URL") return `var URL = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URL",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["https://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URL,["https://request-globals.invalid"])?globalThis.URL:${placeholderFactory})`;
|
|
18997
19025
|
if (target === "URLSearchParams") return `var URLSearchParams = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URLSearchParams",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["client=graphql-request"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URLSearchParams,["client=graphql-request"])?globalThis.URLSearchParams:${placeholderFactory})`;
|
|
18998
19026
|
if (target === "Blob") return `var Blob = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Blob",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Blob,[])?globalThis.Blob:${placeholderFactory})`;
|
|
19027
|
+
if (target === "File") return `var File = ${REQUEST_GLOBAL_EXPOSE_HELPER}("File",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[[],"request-globals.bin"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.File,[[],"request-globals.bin"])?globalThis.File:${placeholderFactory})`;
|
|
18999
19028
|
if (target === "FormData") return `var FormData = ${REQUEST_GLOBAL_EXPOSE_HELPER}("FormData",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.FormData,[])?globalThis.FormData:${placeholderFactory})`;
|
|
19000
19029
|
if (target === "Headers") return `var Headers = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Headers",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Headers,[])?globalThis.Headers:${placeholderFactory})`;
|
|
19001
19030
|
if (target === "Request") return `var Request = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Request",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["https://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Request,["https://request-globals.invalid"])?globalThis.Request:${placeholderFactory})`;
|
|
@@ -22978,16 +23007,19 @@ async function loadTransformPageEntries(scanService) {
|
|
|
22978
23007
|
pluginPages
|
|
22979
23008
|
};
|
|
22980
23009
|
}
|
|
22981
|
-
function invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache) {
|
|
23010
|
+
function invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache, styleRefreshTokens) {
|
|
22982
23011
|
if (!configService) return;
|
|
22983
23012
|
for (const [cachedId, cached] of compilationCache.entries()) {
|
|
22984
23013
|
if (cached.isPage) cached.source = void 0;
|
|
22985
23014
|
styleBlocksCache.delete(cachedId);
|
|
23015
|
+
styleRefreshTokens?.delete(cachedId);
|
|
22986
23016
|
}
|
|
22987
23017
|
}
|
|
22988
|
-
function invalidateVueFileCaches(file, compilationCache, styleBlocksCache, options) {
|
|
22989
|
-
if (!options.existsSync(file))
|
|
22990
|
-
|
|
23018
|
+
function invalidateVueFileCaches(file, compilationCache, styleBlocksCache, options, styleRefreshTokens) {
|
|
23019
|
+
if (!options.existsSync(file)) {
|
|
23020
|
+
compilationCache.delete(file);
|
|
23021
|
+
styleRefreshTokens?.delete(file);
|
|
23022
|
+
} else {
|
|
22991
23023
|
const cached = compilationCache.get(file);
|
|
22992
23024
|
if (cached) {
|
|
22993
23025
|
cached.source = void 0;
|
|
@@ -22997,15 +23029,15 @@ function invalidateVueFileCaches(file, compilationCache, styleBlocksCache, optio
|
|
|
22997
23029
|
styleBlocksCache.delete(file);
|
|
22998
23030
|
}
|
|
22999
23031
|
function handleTransformLayoutInvalidation(file, options) {
|
|
23000
|
-
const { configService, compilationCache, styleBlocksCache, isLayoutFile, invalidateResolvedPageLayoutsCache } = options;
|
|
23032
|
+
const { configService, compilationCache, styleBlocksCache, styleRefreshTokens, isLayoutFile, invalidateResolvedPageLayoutsCache } = options;
|
|
23001
23033
|
if (!configService || !isLayoutFile(file, configService)) return false;
|
|
23002
23034
|
invalidateResolvedPageLayoutsCache(configService.absoluteSrcRoot);
|
|
23003
|
-
invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache);
|
|
23035
|
+
invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache, styleRefreshTokens);
|
|
23004
23036
|
return true;
|
|
23005
23037
|
}
|
|
23006
23038
|
function handleTransformVueFileInvalidation(file, options) {
|
|
23007
23039
|
if (!isVueLikeId(file)) return false;
|
|
23008
|
-
invalidateVueFileCaches(file, options.compilationCache, options.styleBlocksCache, { existsSync: options.existsSync });
|
|
23040
|
+
invalidateVueFileCaches(file, options.compilationCache, options.styleBlocksCache, { existsSync: options.existsSync }, options.styleRefreshTokens);
|
|
23009
23041
|
return true;
|
|
23010
23042
|
}
|
|
23011
23043
|
async function ensureSfcStyleBlocks(filename, styleBlocksCache, options) {
|
|
@@ -23160,7 +23192,7 @@ async function finalizeTransformEntryScript(options) {
|
|
|
23160
23192
|
}
|
|
23161
23193
|
const hasScopedSlotHostGenerics = Boolean(result.componentGenerics && Object.keys(result.componentGenerics).length > 0);
|
|
23162
23194
|
const needsSetupSlotHostProperties = result.script && mayNeedScopedSlotHostPropertiesForSetupSlotsInJs(result.script);
|
|
23163
|
-
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23195
|
+
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("<slot") || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23164
23196
|
const injectedProps = injectScopedSlotHostPropertiesInJs(result.script);
|
|
23165
23197
|
if (injectedProps.transformed) {
|
|
23166
23198
|
result.script = injectedProps.code;
|
|
@@ -23351,7 +23383,7 @@ async function finalizeCompiledVueLikeResult(options) {
|
|
|
23351
23383
|
}
|
|
23352
23384
|
const hasScopedSlotHostGenerics = Boolean(result.componentGenerics && Object.keys(result.componentGenerics).length > 0);
|
|
23353
23385
|
const needsSetupSlotHostProperties = result.script && mayNeedScopedSlotHostPropertiesForSetupSlotsInJs(result.script);
|
|
23354
|
-
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23386
|
+
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("<slot") || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23355
23387
|
const injectedProps = injectScopedSlotHostPropertiesInJs(result.script);
|
|
23356
23388
|
if (injectedProps.transformed) result.script = injectedProps.code;
|
|
23357
23389
|
}
|
|
@@ -23527,8 +23559,8 @@ async function emitNativeLayoutAssetsIfNeeded(options) {
|
|
|
23527
23559
|
});
|
|
23528
23560
|
}
|
|
23529
23561
|
function emitScriptlessComponentJsFallbackIfMissing(options) {
|
|
23530
|
-
const { pluginCtx, bundle, relativeBase, scriptExtension } = options;
|
|
23531
|
-
ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension);
|
|
23562
|
+
const { pluginCtx, bundle, relativeBase, scriptExtension, source } = options;
|
|
23563
|
+
ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension, source);
|
|
23532
23564
|
}
|
|
23533
23565
|
function resolveVueLayoutScriptFallbackState(options) {
|
|
23534
23566
|
const resolvedOptions = resolveVueLayoutAssetOptions({
|
|
@@ -23574,7 +23606,8 @@ async function emitVueLayoutScriptFallbackIfNeeded(options) {
|
|
|
23574
23606
|
pluginCtx,
|
|
23575
23607
|
bundle,
|
|
23576
23608
|
relativeBase: resolvedOptions.relativeBase,
|
|
23577
|
-
scriptExtension: resolvedOptions.scriptExtension
|
|
23609
|
+
scriptExtension: resolvedOptions.scriptExtension,
|
|
23610
|
+
source: SLOT_HOST_SCRIPTLESS_COMPONENT_STUB
|
|
23578
23611
|
});
|
|
23579
23612
|
}
|
|
23580
23613
|
function createBundleLayoutEmitters(options) {
|
|
@@ -23663,7 +23696,8 @@ function emitAppShellAssetsIfNeeded(options) {
|
|
|
23663
23696
|
pluginCtx: options.pluginCtx,
|
|
23664
23697
|
bundle: options.bundle,
|
|
23665
23698
|
relativeBase,
|
|
23666
|
-
scriptExtension: options.scriptExtension
|
|
23699
|
+
scriptExtension: options.scriptExtension,
|
|
23700
|
+
source: SLOT_HOST_SCRIPTLESS_COMPONENT_STUB
|
|
23667
23701
|
});
|
|
23668
23702
|
}
|
|
23669
23703
|
//#endregion
|
|
@@ -24008,8 +24042,18 @@ function parseUsingComponents(config) {
|
|
|
24008
24042
|
return {};
|
|
24009
24043
|
}
|
|
24010
24044
|
}
|
|
24045
|
+
function createSfcStyleBlocksSignature(styleBlocks) {
|
|
24046
|
+
if (!styleBlocks?.length) return "";
|
|
24047
|
+
return JSON.stringify(styleBlocks.map((styleBlock) => ({
|
|
24048
|
+
attrs: styleBlock.attrs,
|
|
24049
|
+
content: styleBlock.content,
|
|
24050
|
+
lang: styleBlock.lang,
|
|
24051
|
+
module: styleBlock.module,
|
|
24052
|
+
scoped: styleBlock.scoped
|
|
24053
|
+
})));
|
|
24054
|
+
}
|
|
24011
24055
|
async function transformVueLikeFile(options) {
|
|
24012
|
-
const { ctx, pluginCtx, code, id, compilationCache, setAppShell, pageMatcher, setPageMatcher, scanDirtySynced, setScanDirtySynced, reExportResolutionCache, compileOptionsCache, styleBlocksCache, scopedSlotModules, emittedScopedSlotChunks, classStyleRuntimeWarned, readAndParseSfc, createReadAndParseSfcOptions } = options;
|
|
24056
|
+
const { ctx, pluginCtx, code, id, compilationCache, setAppShell, pageMatcher, setPageMatcher, scanDirtySynced, setScanDirtySynced, reExportResolutionCache, compileOptionsCache, styleBlocksCache, styleRefreshTokens, scopedSlotModules, emittedScopedSlotChunks, classStyleRuntimeWarned, readAndParseSfc, createReadAndParseSfcOptions } = options;
|
|
24013
24057
|
const vueTransformTiming = ctx.configService?.weappViteConfig?.debug?.vueTransformTiming;
|
|
24014
24058
|
const { measureStage, reportTiming } = createTransformStageMeasurer(vueTransformTiming);
|
|
24015
24059
|
const configService = ctx.configService;
|
|
@@ -24023,6 +24067,7 @@ async function transformVueLikeFile(options) {
|
|
|
24023
24067
|
});
|
|
24024
24068
|
if (!filename) return null;
|
|
24025
24069
|
try {
|
|
24070
|
+
const previousStyleSignature = createSfcStyleBlocksSignature(compilationCache.get(filename)?.result.meta?.styleBlocks ?? styleBlocksCache.get(filename));
|
|
24026
24071
|
const source = await measureStage("readSource", async () => await loadTransformSource({
|
|
24027
24072
|
code,
|
|
24028
24073
|
filename,
|
|
@@ -24075,8 +24120,15 @@ async function transformVueLikeFile(options) {
|
|
|
24075
24120
|
compileVueFile,
|
|
24076
24121
|
compileJsxFile
|
|
24077
24122
|
})));
|
|
24078
|
-
|
|
24079
|
-
|
|
24123
|
+
const currentStyleBlocks = Array.isArray(result.meta?.styleBlocks) ? result.meta.styleBlocks : styleBlocksCache.get(filename);
|
|
24124
|
+
if (currentStyleBlocks) styleBlocksCache.set(filename, currentStyleBlocks);
|
|
24125
|
+
if (configService.isDev && ctx.runtimeState?.build?.hmr?.dirtyVueEntryIds?.has(filename)) {
|
|
24126
|
+
const currentStyleSignature = createSfcStyleBlocksSignature(currentStyleBlocks);
|
|
24127
|
+
const hmrEventId = ctx.runtimeState.build.hmr.profile.eventId;
|
|
24128
|
+
if (hmrEventId != null && currentStyleSignature && currentStyleSignature !== previousStyleSignature) styleRefreshTokens.set(filename, hmrEventId);
|
|
24129
|
+
else styleRefreshTokens.delete(filename);
|
|
24130
|
+
}
|
|
24131
|
+
const sfcStyleDependencies = syncVueSfcStyleDependencies(ctx, filename, currentStyleBlocks);
|
|
24080
24132
|
for (const dependency of sfcStyleDependencies) addNormalizedWatchFile(pluginCtx, dependency);
|
|
24081
24133
|
registerScopedSlotHostGenerics(ctx, result.scopedSlotComponents, parseUsingComponents(result.config));
|
|
24082
24134
|
await measureStage("finalizeCompiledResult", async () => {
|
|
@@ -24105,7 +24157,7 @@ async function transformVueLikeFile(options) {
|
|
|
24105
24157
|
isPage,
|
|
24106
24158
|
isApp,
|
|
24107
24159
|
isDev: configService.isDev,
|
|
24108
|
-
hmrStyleToken: configService.isDev
|
|
24160
|
+
hmrStyleToken: configService.isDev ? styleRefreshTokens.get(filename) : void 0
|
|
24109
24161
|
}));
|
|
24110
24162
|
reportTiming(filename, isPage);
|
|
24111
24163
|
return {
|
|
@@ -24127,6 +24179,7 @@ function createVueTransformPlugin(ctx) {
|
|
|
24127
24179
|
const reExportResolutionCache = /* @__PURE__ */ new Map();
|
|
24128
24180
|
const compileOptionsCache = /* @__PURE__ */ new Map();
|
|
24129
24181
|
const styleBlocksCache = /* @__PURE__ */ new Map();
|
|
24182
|
+
const styleRefreshTokens = /* @__PURE__ */ new Map();
|
|
24130
24183
|
const scopedSlotModules = /* @__PURE__ */ new Map();
|
|
24131
24184
|
const emittedScopedSlotChunks = /* @__PURE__ */ new Set();
|
|
24132
24185
|
const classStyleRuntimeWarned = { value: false };
|
|
@@ -24186,6 +24239,7 @@ function createVueTransformPlugin(ctx) {
|
|
|
24186
24239
|
reExportResolutionCache,
|
|
24187
24240
|
compileOptionsCache,
|
|
24188
24241
|
styleBlocksCache,
|
|
24242
|
+
styleRefreshTokens,
|
|
24189
24243
|
scopedSlotModules,
|
|
24190
24244
|
emittedScopedSlotChunks,
|
|
24191
24245
|
classStyleRuntimeWarned,
|
|
@@ -24214,12 +24268,14 @@ function createVueTransformPlugin(ctx) {
|
|
|
24214
24268
|
configService: ctx.configService,
|
|
24215
24269
|
compilationCache,
|
|
24216
24270
|
styleBlocksCache,
|
|
24271
|
+
styleRefreshTokens,
|
|
24217
24272
|
isLayoutFile,
|
|
24218
24273
|
invalidateResolvedPageLayoutsCache
|
|
24219
24274
|
});
|
|
24220
24275
|
handleTransformVueFileInvalidation(normalizedId, {
|
|
24221
24276
|
compilationCache,
|
|
24222
24277
|
styleBlocksCache,
|
|
24278
|
+
styleRefreshTokens,
|
|
24223
24279
|
existsSync: fs.existsSync
|
|
24224
24280
|
});
|
|
24225
24281
|
const profile = ctx.runtimeState?.build?.hmr?.profile;
|
|
@@ -24235,12 +24291,14 @@ function createVueTransformPlugin(ctx) {
|
|
|
24235
24291
|
configService: ctx.configService,
|
|
24236
24292
|
compilationCache,
|
|
24237
24293
|
styleBlocksCache,
|
|
24294
|
+
styleRefreshTokens,
|
|
24238
24295
|
isLayoutFile,
|
|
24239
24296
|
invalidateResolvedPageLayoutsCache
|
|
24240
24297
|
})) return [];
|
|
24241
24298
|
if (!handleTransformVueFileInvalidation(file, {
|
|
24242
24299
|
compilationCache,
|
|
24243
24300
|
styleBlocksCache,
|
|
24301
|
+
styleRefreshTokens,
|
|
24244
24302
|
existsSync: fs.existsSync
|
|
24245
24303
|
})) return;
|
|
24246
24304
|
return [];
|
|
@@ -25220,7 +25278,7 @@ function createConfigServicePlugin(ctx) {
|
|
|
25220
25278
|
}
|
|
25221
25279
|
//#endregion
|
|
25222
25280
|
//#region src/runtime/jsonPlugin.ts
|
|
25223
|
-
const APP_CONFIG_RE = /app\.json(?:\.[jt]s)?$/;
|
|
25281
|
+
const APP_CONFIG_RE = /(?:^|[/\\])app\.json(?:\.[jt]s)?$/;
|
|
25224
25282
|
const SCRIPT_JSON_CONFIG_RE = /\.json\.[jt]s$/;
|
|
25225
25283
|
function createJsonService(ctx) {
|
|
25226
25284
|
const cache = ctx.runtimeState.json.cache;
|
|
@@ -25419,7 +25477,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
25419
25477
|
const vueAppPath = await findVueEntry(appBasename);
|
|
25420
25478
|
let configFromVue;
|
|
25421
25479
|
if (!appConfigFile && vueAppPath) {
|
|
25422
|
-
const { extractConfigFromVue } = await import("./file-
|
|
25480
|
+
const { extractConfigFromVue } = await import("./file-CTUeDbPw.mjs");
|
|
25423
25481
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
25424
25482
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
25425
25483
|
}
|
|
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
84
84
|
}
|
|
85
85
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
86
86
|
try {
|
|
87
|
-
const { getCompilerContext } = await import("./getInstance-
|
|
87
|
+
const { getCompilerContext } = await import("./getInstance-DwrlgiHQ.mjs");
|
|
88
88
|
const compilerContext = getCompilerContext();
|
|
89
89
|
const service = compilerContext.autoRoutesService;
|
|
90
90
|
const reference = service?.getReference?.();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $n as WebPlatform, A as Ref, Bn as WeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Gn as ResolveWeappViteTargetOptions, Hn as createWeappViteHostMeta, I as RolldownPluginOption, Jn as WeappVitePlatform, Kn as ResolvedWeappViteTarget, L as RolldownWatchOptions, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Qn as WeappViteTargetKind, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, Un as isWeappViteHost, Vn as applyWeappViteHostMeta, Wn as resolveWeappViteHostMeta, Xn as WeappViteTargetDescriptor, Yn as WeappViteRuntime, Zn as WeappViteTargetInput, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, er as getSupportedWeappVitePlatforms, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, k as PluginOption, l as defineConfig, m as Theme, n as UserConfigExport, nr as isWebPlatform, o as UserConfigFnObject, p as Sitemap, qn as WEB_PLATFORM_ALIASES, r as UserConfigFn, rr as resolveWeappViteTarget, s as UserConfigFnObjectPlain, t as UserConfig, tr as getSupportedWeappViteTargetDescriptors, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer, zn as WEAPP_VITE_HOST_NAME } from "./config-
|
|
1
|
+
import { $n as WebPlatform, A as Ref, Bn as WeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Gn as ResolveWeappViteTargetOptions, Hn as createWeappViteHostMeta, I as RolldownPluginOption, Jn as WeappVitePlatform, Kn as ResolvedWeappViteTarget, L as RolldownWatchOptions, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Qn as WeappViteTargetKind, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, Un as isWeappViteHost, Vn as applyWeappViteHostMeta, Wn as resolveWeappViteHostMeta, Xn as WeappViteTargetDescriptor, Yn as WeappViteRuntime, Zn as WeappViteTargetInput, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, er as getSupportedWeappVitePlatforms, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, k as PluginOption, l as defineConfig, m as Theme, n as UserConfigExport, nr as isWebPlatform, o as UserConfigFnObject, p as Sitemap, qn as WEB_PLATFORM_ALIASES, r as UserConfigFn, rr as resolveWeappViteTarget, s as UserConfigFnObjectPlain, t as UserConfig, tr as getSupportedWeappViteTargetDescriptors, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer, zn as WEAPP_VITE_HOST_NAME } from "./config-Ds7MBgQm.mjs";
|
|
2
2
|
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-CDNs17Qq.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createContext.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-BL8Dhhk6.mjs";
|
|
2
2
|
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost--CaeyWpA.mjs";
|
|
3
3
|
import { t as defineConfig } from "./config-DRGcCi3h.mjs";
|
|
4
|
-
import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-
|
|
4
|
+
import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-D2uF0JED.mjs";
|
|
5
5
|
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-C3z9pDQB.mjs";
|
|
6
6
|
export { WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout };
|
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-Ds7MBgQm.mjs";
|
|
2
2
|
export { type App, type Component, type Page, type Sitemap, type Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { r as logger_default } from "./logger-mt4mSTqV.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { connectMiniProgram } from "weapp-ide-cli";
|
|
4
|
+
import { determineAgent } from "@vercel/detect-agent";
|
|
5
|
+
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, startWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
6
|
+
//#region src/aiEnvironment.ts
|
|
7
|
+
const AI_ENV_KEYS = [
|
|
8
|
+
"CODEX_HOME",
|
|
9
|
+
"CODEX_SANDBOX",
|
|
10
|
+
"CODEX_USER_AGENT",
|
|
11
|
+
"CLAUDECODE",
|
|
12
|
+
"CLAUDE_CODE",
|
|
13
|
+
"CURSOR_AGENT",
|
|
14
|
+
"GITHUB_COPILOT_AGENT",
|
|
15
|
+
"OPENAI_AGENT"
|
|
16
|
+
];
|
|
17
|
+
function isTruthyEnvValue(value) {
|
|
18
|
+
if (value === void 0) return false;
|
|
19
|
+
const normalized = value.trim().toLowerCase();
|
|
20
|
+
return normalized !== "" && normalized !== "0" && normalized !== "false" && normalized !== "no";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @description 判断当前命令是否由 AI 开发代理触发。
|
|
24
|
+
*/
|
|
25
|
+
function isAiDevelopmentEnvironment(env = process.env) {
|
|
26
|
+
if (isTruthyEnvValue(env.WEAPP_VITE_AI)) return true;
|
|
27
|
+
return AI_ENV_KEYS.some((key) => isTruthyEnvValue(env[key]));
|
|
28
|
+
}
|
|
29
|
+
function resolveAiDevelopmentEnvironmentFromEnv(env = process.env) {
|
|
30
|
+
if (isTruthyEnvValue(env.WEAPP_VITE_AI)) return {
|
|
31
|
+
agentName: env.WEAPP_VITE_AI.trim(),
|
|
32
|
+
isAgent: true
|
|
33
|
+
};
|
|
34
|
+
if (isAiDevelopmentEnvironment(env)) return { isAgent: true };
|
|
35
|
+
return { isAgent: false };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @description 使用标准 agent 检测库识别 AI 终端,并保留 weapp-vite 显式环境变量兜底。
|
|
39
|
+
*/
|
|
40
|
+
async function detectAiDevelopmentEnvironment(env = process.env) {
|
|
41
|
+
const envResult = resolveAiDevelopmentEnvironmentFromEnv(env);
|
|
42
|
+
if (envResult.isAgent) return envResult;
|
|
43
|
+
try {
|
|
44
|
+
const result = await determineAgent();
|
|
45
|
+
return {
|
|
46
|
+
agentName: result.isAgent ? result.agent.name : void 0,
|
|
47
|
+
isAgent: result.isAgent
|
|
48
|
+
};
|
|
49
|
+
} catch {
|
|
50
|
+
return envResult;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function resolveBooleanLikeEnv(value) {
|
|
54
|
+
if (value === void 0) return;
|
|
55
|
+
const normalized = value.trim().toLowerCase();
|
|
56
|
+
if (!normalized) return;
|
|
57
|
+
if (normalized === "ai") return "ai";
|
|
58
|
+
if ([
|
|
59
|
+
"1",
|
|
60
|
+
"true",
|
|
61
|
+
"yes",
|
|
62
|
+
"on"
|
|
63
|
+
].includes(normalized)) return true;
|
|
64
|
+
if ([
|
|
65
|
+
"0",
|
|
66
|
+
"false",
|
|
67
|
+
"no",
|
|
68
|
+
"off"
|
|
69
|
+
].includes(normalized)) return false;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/mcp.ts
|
|
73
|
+
function normalizeEndpoint(input) {
|
|
74
|
+
const value = typeof input === "string" ? input.trim() : "";
|
|
75
|
+
if (!value) return DEFAULT_MCP_ENDPOINT;
|
|
76
|
+
return value.startsWith("/") ? value : `/${value}`;
|
|
77
|
+
}
|
|
78
|
+
function resolveProjectMcpPort(projectRoot = process.cwd()) {
|
|
79
|
+
let hash = 0;
|
|
80
|
+
for (const char of projectRoot) hash = hash * 31 + char.charCodeAt(0) >>> 0;
|
|
81
|
+
return DEFAULT_MCP_PORT + hash % 2e4;
|
|
82
|
+
}
|
|
83
|
+
function normalizePort(input, cwd) {
|
|
84
|
+
if (input === void 0 || input === "auto") return resolveProjectMcpPort(cwd);
|
|
85
|
+
if (typeof input === "number" && Number.isInteger(input) && input > 0 && input <= 65535) return input;
|
|
86
|
+
return DEFAULT_MCP_PORT;
|
|
87
|
+
}
|
|
88
|
+
function resolveAutoStart(input, options) {
|
|
89
|
+
const env = options.env ?? process.env;
|
|
90
|
+
const value = resolveBooleanLikeEnv(env.WEAPP_VITE_MCP) ?? input ?? "ai";
|
|
91
|
+
if (value === "ai") return options.isAgent ?? resolveAiDevelopmentEnvironmentFromEnv(env).isAgent;
|
|
92
|
+
return value === true;
|
|
93
|
+
}
|
|
94
|
+
function resolveWeappMcpConfig(config, options = {}) {
|
|
95
|
+
if (config === false) return {
|
|
96
|
+
enabled: false,
|
|
97
|
+
autoStart: false,
|
|
98
|
+
host: DEFAULT_MCP_HOST,
|
|
99
|
+
port: DEFAULT_MCP_PORT,
|
|
100
|
+
endpoint: DEFAULT_MCP_ENDPOINT,
|
|
101
|
+
restEndpoint: DEFAULT_RUNTIME_REST_ENDPOINT
|
|
102
|
+
};
|
|
103
|
+
const record = typeof config === "object" && config ? config : {};
|
|
104
|
+
return {
|
|
105
|
+
agentName: options.agentName,
|
|
106
|
+
enabled: record.enabled !== false,
|
|
107
|
+
autoStart: resolveAutoStart(record.autoStart, options),
|
|
108
|
+
host: typeof record.host === "string" && record.host.trim().length > 0 ? record.host.trim() : DEFAULT_MCP_HOST,
|
|
109
|
+
port: normalizePort(record.port, options.cwd),
|
|
110
|
+
endpoint: normalizeEndpoint(record.endpoint),
|
|
111
|
+
restEndpoint: record.restEndpoint === false ? false : normalizeEndpoint(record.restEndpoint ?? DEFAULT_RUNTIME_REST_ENDPOINT)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function startWeappViteMcpServer$1(options) {
|
|
115
|
+
return startWeappViteMcpServer({
|
|
116
|
+
runtimeHooks: { connectMiniProgram },
|
|
117
|
+
...options,
|
|
118
|
+
onReady: options?.onReady ?? ((message) => {
|
|
119
|
+
logger_default.info(message);
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { createWeappViteMcpServer as a, startWeappViteMcpServer$1 as c, DEFAULT_RUNTIME_REST_ENDPOINT as i, detectAiDevelopmentEnvironment as l, DEFAULT_MCP_HOST as n, resolveProjectMcpPort as o, DEFAULT_MCP_PORT as r, resolveWeappMcpConfig as s, DEFAULT_MCP_ENDPOINT as t };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Et as WeappMcpConfig } from "./config-
|
|
1
|
+
import { Et as WeappMcpConfig } from "./config-Ds7MBgQm.mjs";
|
|
2
2
|
import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
|
5
5
|
interface ResolvedWeappMcpConfig {
|
|
6
|
+
agentName?: string;
|
|
6
7
|
enabled: boolean;
|
|
7
8
|
autoStart: boolean;
|
|
8
9
|
host: string;
|
|
@@ -12,7 +13,14 @@ interface ResolvedWeappMcpConfig {
|
|
|
12
13
|
}
|
|
13
14
|
interface WeappViteMcpServerOptions extends StartMcpServerOptions {}
|
|
14
15
|
interface WeappViteMcpServerHandle extends McpServerHandle {}
|
|
15
|
-
|
|
16
|
+
interface ResolveWeappMcpConfigOptions {
|
|
17
|
+
agentName?: string;
|
|
18
|
+
cwd?: string;
|
|
19
|
+
env?: NodeJS.ProcessEnv;
|
|
20
|
+
isAgent?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare function resolveProjectMcpPort(projectRoot?: string): number;
|
|
23
|
+
declare function resolveWeappMcpConfig(config?: boolean | WeappMcpConfig, options?: ResolveWeappMcpConfigOptions): ResolvedWeappMcpConfig;
|
|
16
24
|
declare function startWeappViteMcpServer(options?: WeappViteMcpServerOptions): Promise<WeappViteMcpServerHandle>;
|
|
17
25
|
//#endregion
|
|
18
|
-
export { type CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, ResolvedWeappMcpConfig, WeappViteMcpServerHandle, WeappViteMcpServerOptions, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
|
26
|
+
export { type CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, ResolveWeappMcpConfigOptions, ResolvedWeappMcpConfig, WeappViteMcpServerHandle, WeappViteMcpServerOptions, createWeappViteMcpServer, resolveProjectMcpPort, resolveWeappMcpConfig, startWeappViteMcpServer };
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createWeappViteMcpServer, i as DEFAULT_RUNTIME_REST_ENDPOINT, n as DEFAULT_MCP_HOST, o as
|
|
2
|
-
export { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
|
1
|
+
import { a as createWeappViteMcpServer, c as startWeappViteMcpServer, i as DEFAULT_RUNTIME_REST_ENDPOINT, n as DEFAULT_MCP_HOST, o as resolveProjectMcpPort, r as DEFAULT_MCP_PORT, s as resolveWeappMcpConfig, t as DEFAULT_MCP_ENDPOINT } from "./mcp-YXCIQr-Z.mjs";
|
|
2
|
+
export { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, resolveProjectMcpPort, resolveWeappMcpConfig, startWeappViteMcpServer };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { c as Resolver } from "./index-Bmclyjw8.mjs";
|
|
2
2
|
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-C7fCmf92.mjs";
|
|
3
|
-
import { $ as WeappAnalyzeBudgetConfig, $t as GenerateTemplateFileSource, A as Ref, An as WeappLibFileName, At as WeappRouteRules, B as BindingErrorLike, Bn as WeappViteHostMeta, Bt as BuildNpmPackageMeta, Cn as SubPackageStyleConfigObject, Ct as WeappInjectWeapiConfig, D as MethodDefinitions, Dn as WeappLibConfig, Dt as WeappNpmConfig, E as InlineConfig, En as WeappLibComponentJson, Et as WeappMcpConfig, F as RolldownPlugin, Fn as WeappManagedServerTsconfigConfig, Ft as WeappWevuConfig, G as EntryJsonFragment, Gt as GenerateExtensionsOptions, H as BaseEntry, Ht as CopyGlobs, I as RolldownPluginOption, In as WeappManagedSharedTsconfigConfig, It as WeappWorkerConfig, J as ScanComponentItem, Jt as GenerateOptions, K as PageEntry, Kt as GenerateFileType, L as RolldownWatchOptions, Ln as WeappManagedTypeScriptConfig, Lt as Alias, M as RolldownBuild, Mn as WeappLibVueTscOptions, Mt as WeappVueConfig, N as RolldownOptions, Nn as WeappManagedAppTsconfigConfig, Nt as WeappVueTemplateConfig, O as Plugin, On as WeappLibDtsOptions, Ot as WeappRequestRuntimeConfig, P as RolldownOutput, Pn as WeappManagedNodeTsconfigConfig, Pt as WeappWebRuntimeConfig, Q as UserConfig, Qt as GenerateTemplateFactory, R as RolldownWatcher, Rn as WeappWebConfig, Rt as AliasOptions, Sn as SubPackageStyleConfigEntry, St as WeappInjectRequestGlobalsTarget, T as ConfigEnv, Tn as SubPackageStyleScope, Tt as WeappInjectWebRuntimeGlobalsTarget, U as ComponentEntry, Ut as CopyOptions, V as AppEntry, Vt as ChunksConfig, W as Entry, Wt as GenerateDirsOptions, X as ProjectConfig, Xt as GenerateTemplateContext, Y as WxmlDep, Yn as WeappViteRuntime, Yt as GenerateTemplate, Z as SubPackageMetaValue, Zt as GenerateTemplateEntry, _n as SharedChunkDynamicImports, _t as WeappAutoRoutesIncludePattern, an as JsonMergeContext, at as WeappViteConfig, b as ChangeEvent, bn as SharedChunkStrategy, bt as WeappHmrConfig, cn as JsonMergeStrategy, ct as EnhanceOptions, dn as NpmDependencyPattern, dt as MultiPlatformConfig, en as GenerateTemplateInlineSource, et as WeappAnalyzeConfig, fn as NpmMainPackageConfig, ft as ScanWxmlOptions, gn as ResolvedAlias, gt as WeappAutoRoutesInclude, hn as NpmSubPackageConfig, ht as WeappAutoRoutesConfig, in as JsonConfig, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as WeappLibInternalDtsOptions, jt as WeappSubPackageConfig, k as PluginOption, kn as WeappLibEntryContext, kt as WeappRouteRule, ln as MpPlatform, lt as EnhanceWxmlOptions, mn as NpmStrategy, mt as WeappAppPreludeMode, nn as GenerateTemplatesConfig, nt as WeappDebugConfig, on as JsonMergeFunction, ot as AutoImportComponents, pn as NpmPluginPackageConfig, pt as WeappAppPreludeConfig, q as ComponentsMap, qt as GenerateFilenamesOptions, rn as JsFormat, rt as WeappForwardConsoleConfig, sn as JsonMergeStage, st as AutoImportComponentsOption, tn as GenerateTemplateScope, tt as WeappAnalyzeHistoryConfig, un as NpmBuildOptions, ut as HandleWxmlOptions, vn as SharedChunkMode, vt as WeappBuildScopeConfig, w as ComputedDefinitions, wn as SubPackageStyleEntry, wt as WeappInjectWebRuntimeGlobalsConfig, x as WeappVitePluginApi, xn as SubPackage, xt as WeappInjectRequestGlobalsConfig, yn as SharedChunkOverride, yt as WeappBuildScopeObjectConfig, z as ViteDevServer, zt as AlipayNpmMode } from "./config-
|
|
3
|
+
import { $ as WeappAnalyzeBudgetConfig, $t as GenerateTemplateFileSource, A as Ref, An as WeappLibFileName, At as WeappRouteRules, B as BindingErrorLike, Bn as WeappViteHostMeta, Bt as BuildNpmPackageMeta, Cn as SubPackageStyleConfigObject, Ct as WeappInjectWeapiConfig, D as MethodDefinitions, Dn as WeappLibConfig, Dt as WeappNpmConfig, E as InlineConfig, En as WeappLibComponentJson, Et as WeappMcpConfig, F as RolldownPlugin, Fn as WeappManagedServerTsconfigConfig, Ft as WeappWevuConfig, G as EntryJsonFragment, Gt as GenerateExtensionsOptions, H as BaseEntry, Ht as CopyGlobs, I as RolldownPluginOption, In as WeappManagedSharedTsconfigConfig, It as WeappWorkerConfig, J as ScanComponentItem, Jt as GenerateOptions, K as PageEntry, Kt as GenerateFileType, L as RolldownWatchOptions, Ln as WeappManagedTypeScriptConfig, Lt as Alias, M as RolldownBuild, Mn as WeappLibVueTscOptions, Mt as WeappVueConfig, N as RolldownOptions, Nn as WeappManagedAppTsconfigConfig, Nt as WeappVueTemplateConfig, O as Plugin, On as WeappLibDtsOptions, Ot as WeappRequestRuntimeConfig, P as RolldownOutput, Pn as WeappManagedNodeTsconfigConfig, Pt as WeappWebRuntimeConfig, Q as UserConfig, Qt as GenerateTemplateFactory, R as RolldownWatcher, Rn as WeappWebConfig, Rt as AliasOptions, Sn as SubPackageStyleConfigEntry, St as WeappInjectRequestGlobalsTarget, T as ConfigEnv, Tn as SubPackageStyleScope, Tt as WeappInjectWebRuntimeGlobalsTarget, U as ComponentEntry, Ut as CopyOptions, V as AppEntry, Vt as ChunksConfig, W as Entry, Wt as GenerateDirsOptions, X as ProjectConfig, Xt as GenerateTemplateContext, Y as WxmlDep, Yn as WeappViteRuntime, Yt as GenerateTemplate, Z as SubPackageMetaValue, Zt as GenerateTemplateEntry, _n as SharedChunkDynamicImports, _t as WeappAutoRoutesIncludePattern, an as JsonMergeContext, at as WeappViteConfig, b as ChangeEvent, bn as SharedChunkStrategy, bt as WeappHmrConfig, cn as JsonMergeStrategy, ct as EnhanceOptions, dn as NpmDependencyPattern, dt as MultiPlatformConfig, en as GenerateTemplateInlineSource, et as WeappAnalyzeConfig, fn as NpmMainPackageConfig, ft as ScanWxmlOptions, gn as ResolvedAlias, gt as WeappAutoRoutesInclude, hn as NpmSubPackageConfig, ht as WeappAutoRoutesConfig, in as JsonConfig, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as WeappLibInternalDtsOptions, jt as WeappSubPackageConfig, k as PluginOption, kn as WeappLibEntryContext, kt as WeappRouteRule, ln as MpPlatform, lt as EnhanceWxmlOptions, mn as NpmStrategy, mt as WeappAppPreludeMode, nn as GenerateTemplatesConfig, nt as WeappDebugConfig, on as JsonMergeFunction, ot as AutoImportComponents, pn as NpmPluginPackageConfig, pt as WeappAppPreludeConfig, q as ComponentsMap, qt as GenerateFilenamesOptions, rn as JsFormat, rt as WeappForwardConsoleConfig, sn as JsonMergeStage, st as AutoImportComponentsOption, tn as GenerateTemplateScope, tt as WeappAnalyzeHistoryConfig, un as NpmBuildOptions, ut as HandleWxmlOptions, vn as SharedChunkMode, vt as WeappBuildScopeConfig, w as ComputedDefinitions, wn as SubPackageStyleEntry, wt as WeappInjectWebRuntimeGlobalsConfig, x as WeappVitePluginApi, xn as SubPackage, xt as WeappInjectRequestGlobalsConfig, yn as SharedChunkOverride, yt as WeappBuildScopeObjectConfig, z as ViteDevServer, zt as AlipayNpmMode } from "./config-Ds7MBgQm.mjs";
|
|
4
4
|
export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, type ComputedDefinitions, type ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, type InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, type MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, type Plugin, type PluginOption, ProjectConfig, type Ref, ResolvedAlias, type ResolvedConfig, type Resolver, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, type ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappBuildScopeConfig, WeappBuildScopeObjectConfig, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, type WeappViteHostMeta, WeappVitePluginApi, type WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, 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.16.
|
|
4
|
+
"version": "6.16.44",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@jridgewell/remapping": "^2.3.5",
|
|
94
94
|
"@vercel/detect-agent": "^1.2.3",
|
|
95
95
|
"@volar/typescript": "^2.4.28",
|
|
96
|
-
"@vue/language-core": "^3.3.
|
|
96
|
+
"@vue/language-core": "^3.3.5",
|
|
97
97
|
"cac": "^7.0.0",
|
|
98
98
|
"chokidar": "^5.0.0",
|
|
99
99
|
"comment-json": "^5.0.0",
|
|
@@ -103,36 +103,36 @@
|
|
|
103
103
|
"lru-cache": "^11.5.1",
|
|
104
104
|
"magic-string": "^0.30.21",
|
|
105
105
|
"merge": "^2.1.1",
|
|
106
|
-
"obug": "^2.1.
|
|
106
|
+
"obug": "^2.1.3",
|
|
107
107
|
"p-queue": "^9.3.0",
|
|
108
108
|
"package-manager-detector": "^1.6.0",
|
|
109
109
|
"pathe": "^2.0.3",
|
|
110
110
|
"picomatch": "^4.0.4",
|
|
111
111
|
"postcss": "^8.5.15",
|
|
112
|
-
"rolldown": "1.1.
|
|
112
|
+
"rolldown": "1.1.1",
|
|
113
113
|
"rolldown-plugin-dts": "0.25.2",
|
|
114
|
-
"semver": "^7.8.
|
|
114
|
+
"semver": "^7.8.4",
|
|
115
115
|
"typescript": "^6.0.3",
|
|
116
116
|
"vite": "8.0.16",
|
|
117
117
|
"vite-tsconfig-paths": "^6.1.1",
|
|
118
|
-
"vue": "^3.5.
|
|
119
|
-
"vue-tsc": "^3.3.
|
|
118
|
+
"vue": "^3.5.38",
|
|
119
|
+
"vue-tsc": "^3.3.5",
|
|
120
120
|
"@weapp-core/constants": "0.1.12",
|
|
121
|
-
"@weapp-core/init": "6.0.10",
|
|
122
121
|
"@weapp-core/logger": "3.1.1",
|
|
123
|
-
"@weapp-core/schematics": "6.0.4",
|
|
124
122
|
"@weapp-core/shared": "3.0.4",
|
|
125
|
-
"@weapp-
|
|
126
|
-
"@weapp-
|
|
127
|
-
"@weapp-vite/
|
|
123
|
+
"@weapp-core/init": "6.0.10",
|
|
124
|
+
"@weapp-core/schematics": "6.0.4",
|
|
125
|
+
"@weapp-vite/ast": "6.16.44",
|
|
126
|
+
"@weapp-vite/mcp": "1.4.4",
|
|
127
|
+
"@weapp-vite/miniprogram-automator": "1.2.3",
|
|
128
128
|
"@weapp-vite/volar": "2.1.0",
|
|
129
|
-
"@weapp-vite/web": "1.3.30",
|
|
130
|
-
"@wevu/api": "0.2.9",
|
|
131
|
-
"@wevu/web-apis": "1.2.20",
|
|
132
|
-
"rolldown-require": "2.0.18",
|
|
133
129
|
"vite-plugin-performance": "2.0.1",
|
|
134
|
-
"
|
|
135
|
-
"
|
|
130
|
+
"wevu": "6.16.44",
|
|
131
|
+
"@weapp-vite/web": "1.3.31",
|
|
132
|
+
"weapp-ide-cli": "5.4.5",
|
|
133
|
+
"@wevu/web-apis": "1.2.21",
|
|
134
|
+
"rolldown-require": "2.0.19",
|
|
135
|
+
"@wevu/api": "0.2.9"
|
|
136
136
|
},
|
|
137
137
|
"publishConfig": {
|
|
138
138
|
"access": "public",
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"oxc-parser": "^0.135.0",
|
|
143
143
|
"oxc-walker": "^1.0.0",
|
|
144
|
-
"tailwindcss": "^4.3.
|
|
144
|
+
"tailwindcss": "^4.3.1",
|
|
145
145
|
"ts-morph": "^28.0.0"
|
|
146
146
|
},
|
|
147
147
|
"scripts": {
|
package/dist/file-iVST36Dh.mjs
DELETED
package/dist/mcp-qmDOTH07.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { r as logger_default } from "./logger-mt4mSTqV.mjs";
|
|
2
|
-
import { connectMiniProgram } from "weapp-ide-cli";
|
|
3
|
-
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, startWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
4
|
-
//#region src/mcp.ts
|
|
5
|
-
function normalizeEndpoint(input) {
|
|
6
|
-
const value = typeof input === "string" ? input.trim() : "";
|
|
7
|
-
if (!value) return DEFAULT_MCP_ENDPOINT;
|
|
8
|
-
return value.startsWith("/") ? value : `/${value}`;
|
|
9
|
-
}
|
|
10
|
-
function normalizePort(input) {
|
|
11
|
-
if (typeof input === "number" && Number.isInteger(input) && input > 0 && input <= 65535) return input;
|
|
12
|
-
return DEFAULT_MCP_PORT;
|
|
13
|
-
}
|
|
14
|
-
function resolveWeappMcpConfig(config) {
|
|
15
|
-
if (config === false) return {
|
|
16
|
-
enabled: false,
|
|
17
|
-
autoStart: false,
|
|
18
|
-
host: DEFAULT_MCP_HOST,
|
|
19
|
-
port: DEFAULT_MCP_PORT,
|
|
20
|
-
endpoint: DEFAULT_MCP_ENDPOINT,
|
|
21
|
-
restEndpoint: DEFAULT_RUNTIME_REST_ENDPOINT
|
|
22
|
-
};
|
|
23
|
-
const record = typeof config === "object" && config ? config : {};
|
|
24
|
-
return {
|
|
25
|
-
enabled: record.enabled !== false,
|
|
26
|
-
autoStart: record.autoStart === true,
|
|
27
|
-
host: typeof record.host === "string" && record.host.trim().length > 0 ? record.host.trim() : DEFAULT_MCP_HOST,
|
|
28
|
-
port: normalizePort(record.port),
|
|
29
|
-
endpoint: normalizeEndpoint(record.endpoint),
|
|
30
|
-
restEndpoint: record.restEndpoint === false ? false : normalizeEndpoint(record.restEndpoint ?? DEFAULT_RUNTIME_REST_ENDPOINT)
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
async function startWeappViteMcpServer$1(options) {
|
|
34
|
-
return startWeappViteMcpServer({
|
|
35
|
-
runtimeHooks: { connectMiniProgram },
|
|
36
|
-
...options,
|
|
37
|
-
onReady: options?.onReady ?? ((message) => {
|
|
38
|
-
logger_default.info(message);
|
|
39
|
-
})
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
export { createWeappViteMcpServer as a, DEFAULT_RUNTIME_REST_ENDPOINT as i, DEFAULT_MCP_HOST as n, resolveWeappMcpConfig as o, DEFAULT_MCP_PORT as r, startWeappViteMcpServer$1 as s, DEFAULT_MCP_ENDPOINT as t };
|