weapp-vite 6.14.1 → 6.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-hN5mdpQ_.mjs";
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-6QUk3Zbc.mjs";
2
2
  export { CreateResolver, ExternalMetadataFileCandidates, Options, ResolvedValue, Resolver, ResolverFn, ResolverMeta, ResolverObject, ResolverSupportFilesStrategy, TDesignResolver, VantResolver, WeuiResolver };
@@ -109,6 +109,7 @@ const TDesignResolver = (opts) => {
109
109
  }, {});
110
110
  return {
111
111
  components: Object.freeze({ ...map }),
112
+ componentLookupStrategy: "static",
112
113
  supportFilesStrategy,
113
114
  resolve(componentName) {
114
115
  const from = map[componentName];
@@ -241,6 +242,7 @@ const VantResolver = (opts) => {
241
242
  }, {});
242
243
  return {
243
244
  components: Object.freeze({ ...map }),
245
+ componentLookupStrategy: "static",
244
246
  supportFilesStrategy,
245
247
  resolve(componentName) {
246
248
  const from = map[componentName];
@@ -311,6 +313,7 @@ const WeuiResolver = (opts) => {
311
313
  }, {});
312
314
  return {
313
315
  components: Object.freeze({ ...map }),
316
+ componentLookupStrategy: "static",
314
317
  supportFilesStrategy,
315
318
  resolve(componentName) {
316
319
  const from = map[componentName];
@@ -1,4 +1,4 @@
1
- import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-DT4tLA1C.mjs";
1
+ import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-BWIKo9nG.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,6 +1,6 @@
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-DT4tLA1C.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-BWIKo9nG.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
3
- import { m as VERSION } from "./file-BkvmW6_2.mjs";
3
+ import { m as VERSION } from "./file-B1jggPxp.mjs";
4
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";
@@ -960,21 +960,6 @@ async function openWechatIdeByAutomator(projectPath) {
960
960
  })).disconnect();
961
961
  }
962
962
  /**
963
- * @description 若当前项目已在微信开发者工具中打开且自动化可连通,则直接复用现有会话,避免重复拉起 IDE。
964
- */
965
- async function tryReuseOpenedWechatIde(projectPath) {
966
- try {
967
- (await connectOpenedAutomator({
968
- projectPath,
969
- timeout: 3e3
970
- })).disconnect();
971
- logger_default.info("目标项目已在微信开发者工具中打开,跳过重复打开。");
972
- return true;
973
- } catch {
974
- return false;
975
- }
976
- }
977
- /**
978
963
  * @description 执行 IDE 打开流程,并在登录失效时允许按键重试。
979
964
  */
980
965
  async function runWechatIdeOpenWithRetry(argv) {
@@ -990,7 +975,7 @@ async function runWechatIdeOpenWithRetry(argv) {
990
975
  logger_default.error("检测到微信开发者工具登录状态失效,请先登录后重试。");
991
976
  logger_default.warn(formatWechatIdeLoginRequiredError(error));
992
977
  logger_default.info(formatRetryHotkeyPrompt());
993
- if (!await waitForRetryKeypress()) {
978
+ if (await waitForRetryKeypress() !== "retry") {
994
979
  logger_default.warn("已取消重试。完成登录后请重新执行当前命令。");
995
980
  retrying = false;
996
981
  continue;
@@ -1033,20 +1018,6 @@ function resolveIdeProjectPath(mpDistRoot) {
1033
1018
  function resolveIdeProjectRoot(mpDistRoot, cwd) {
1034
1019
  return resolveIdeProjectPath(mpDistRoot) ?? cwd;
1035
1020
  }
1036
- async function openIde(platform, projectPath, options = {}) {
1037
- if (platform === "weapp" && projectPath && options.trustProject !== false) try {
1038
- if (await tryReuseOpenedWechatIde(projectPath)) return;
1039
- await openWechatIdeByAutomator(projectPath);
1040
- return;
1041
- } catch (error) {
1042
- logger_default.warn("通过 automator 启动微信开发者工具并自动信任项目失败,回退到普通 open 流程。");
1043
- logger_default.error(error);
1044
- }
1045
- const argv = ["open", "-p"];
1046
- if (projectPath) argv.push(projectPath);
1047
- if (shouldPassPlatformArgToIdeOpen(platform)) argv.push("--platform", platform);
1048
- await runWechatIdeOpenWithRetry(argv);
1049
- }
1050
1021
  async function closeIde() {
1051
1022
  const config = await getConfig();
1052
1023
  const cliPath = config.cliPath?.trim() ? config.cliPath : null;
@@ -1075,6 +1046,51 @@ async function closeIde() {
1075
1046
  return false;
1076
1047
  }
1077
1048
  }
1049
+ function formatReuseOpenedWechatIdePrompt() {
1050
+ return `目标项目已在微信开发者工具中打开,已跳过重复打开。按 ${colors.bold(colors.green("r"))} 关闭当前窗口后重新打开。`;
1051
+ }
1052
+ /**
1053
+ * @description 若当前项目已在微信开发者工具中打开且自动化可连通,则直接复用现有会话,避免重复拉起 IDE。
1054
+ */
1055
+ async function tryReuseOpenedWechatIde(projectPath) {
1056
+ let miniProgram;
1057
+ try {
1058
+ miniProgram = await connectOpenedAutomator({
1059
+ projectPath,
1060
+ timeout: 3e3
1061
+ });
1062
+ } catch {
1063
+ return null;
1064
+ }
1065
+ miniProgram.disconnect();
1066
+ logger_default.info(formatReuseOpenedWechatIdePrompt());
1067
+ if (await waitForRetryKeypress() !== "retry") return {
1068
+ reopened: false,
1069
+ reused: true
1070
+ };
1071
+ logger_default.info(colors.bold(colors.green("正在关闭当前已打开项目,并重新拉起微信开发者工具...")));
1072
+ if (!await closeIde()) logger_default.warn("关闭当前微信开发者工具失败,仍继续尝试重新打开目标项目。");
1073
+ await openWechatIdeByAutomator(projectPath);
1074
+ return {
1075
+ reopened: true,
1076
+ reused: false
1077
+ };
1078
+ }
1079
+ async function openIde(platform, projectPath, options = {}) {
1080
+ if (platform === "weapp" && projectPath && options.trustProject !== false) try {
1081
+ const reuseResult = await tryReuseOpenedWechatIde(projectPath);
1082
+ if (reuseResult?.reused || reuseResult?.reopened) return;
1083
+ await openWechatIdeByAutomator(projectPath);
1084
+ return;
1085
+ } catch (error) {
1086
+ logger_default.warn("通过 automator 启动微信开发者工具并自动信任项目失败,回退到普通 open 流程。");
1087
+ logger_default.error(error);
1088
+ }
1089
+ const argv = ["open", "-p"];
1090
+ if (projectPath) argv.push(projectPath);
1091
+ if (platform && shouldPassPlatformArgToIdeOpen(platform)) argv.push("--platform", platform);
1092
+ await runWechatIdeOpenWithRetry(argv);
1093
+ }
1078
1094
  /**
1079
1095
  * @description 解析 IDE 相关命令所需的平台、项目目录与配置上下文。
1080
1096
  */
@@ -1137,6 +1153,7 @@ function registerBuildCommand(cli) {
1137
1153
  inlineConfig,
1138
1154
  cliPlatform: targets.rawPlatform,
1139
1155
  projectConfigPath: options.projectConfig,
1156
+ emitDefaultAutoImportOutputs: false,
1140
1157
  syncSupportFiles: false,
1141
1158
  preloadAppEntry: false
1142
1159
  });
@@ -1958,7 +1975,7 @@ async function handleDoctor(clientName, options) {
1958
1975
  logger_default.success("MCP 客户端配置检查通过。");
1959
1976
  }
1960
1977
  async function handleServer(options) {
1961
- const resolvedTransport = options.transport === "http" ? "streamable-http" : options.transport;
1978
+ const resolvedTransport = options.transport === "http" ? "streamable-http" : options.transport === "command" ? void 0 : options.transport;
1962
1979
  await startWeappViteMcpServer({
1963
1980
  endpoint: options.endpoint,
1964
1981
  host: options.host,
@@ -2051,10 +2068,10 @@ function registerPrepareCommand(cli) {
2051
2068
  }
2052
2069
  //#endregion
2053
2070
  //#region package.json
2054
- var version = "6.14.1";
2071
+ var version = "6.14.3";
2055
2072
  //#endregion
2056
2073
  //#region src/cli/devHotkeys.ts
2057
- const DEV_SCREENSHOT_DIR = ".tmp/weapp-vite-dev-screenshots";
2074
+ const DEV_SCREENSHOT_DIR = ".weapp-vite/dev-screenshots";
2058
2075
  const DEFAULT_SCREENSHOT_TIMEOUT = 3e4;
2059
2076
  const REG_PENDING_PREFIX = /^正在/;
2060
2077
  const FULLWIDTH_ASCII_START = 65281;
@@ -2346,7 +2363,7 @@ function startDevHotkeys(options) {
2346
2363
  const handleInputOnce = (input, source) => {
2347
2364
  const normalizedInput = normalizeInputChar(input);
2348
2365
  const now = Date.now();
2349
- for (const [token, timestamp] of recentInputs) if (now - timestamp > HOTKEY_DEDUP_WINDOW_MS) recentInputs.delete(token);
2366
+ for (const [token, timestamp] of recentInputs) if (now - Number(timestamp.split(":")[1] ?? 0) > HOTKEY_DEDUP_WINDOW_MS) recentInputs.delete(token);
2350
2367
  const dedupKey = normalizedInput;
2351
2368
  const recentEntry = recentInputs.get(dedupKey);
2352
2369
  if (recentEntry !== void 0) {
@@ -2502,21 +2519,12 @@ function registerServeCommand(cli) {
2502
2519
  }
2503
2520
  };
2504
2521
  if (targets.runMini) {
2505
- const buildWatch = typeof inlineConfig?.build?.watch === "object" && inlineConfig.build.watch ? inlineConfig.build.watch : {};
2506
- const buildChokidar = "chokidar" in buildWatch ? buildWatch.chokidar : void 0;
2507
2522
  const existingServer = inlineConfig?.server ?? {};
2508
2523
  inlineConfig = {
2509
2524
  ...inlineConfig,
2510
2525
  build: {
2511
2526
  ...inlineConfig?.build ?? {},
2512
- watch: {
2513
- ...buildWatch,
2514
- chokidar: {
2515
- ...buildChokidar ?? {},
2516
- usePolling: true,
2517
- interval: 100
2518
- }
2519
- }
2527
+ watch: typeof inlineConfig?.build?.watch === "object" && inlineConfig.build.watch ? { ...inlineConfig.build.watch } : {}
2520
2528
  },
2521
2529
  server: {
2522
2530
  ...existingServer,
@@ -2546,9 +2554,9 @@ function registerServeCommand(cli) {
2546
2554
  let analyzeRunId = 0;
2547
2555
  const devHotkeysSession = targets.runMini ? startDevHotkeys({
2548
2556
  cwd: configService.cwd,
2549
- mcpConfig: configService.weappViteConfig?.weapp?.mcp,
2557
+ mcpConfig: configService.weappViteConfig?.mcp,
2550
2558
  platform: configService.platform,
2551
- projectPath: resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd),
2559
+ projectPath: resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd) ?? configService.cwd,
2552
2560
  silentStartupHint: true
2553
2561
  }) : void 0;
2554
2562
  try {
@@ -1,4 +1,4 @@
1
- import { c as Resolver, s as ResolvedValue } from "./index-hN5mdpQ_.mjs";
1
+ import { c as Resolver, s as ResolvedValue } from "./index-6QUk3Zbc.mjs";
2
2
  import { t as AutoRoutes } from "./routes-DiEBrMtj.mjs";
3
3
  import { LRUCache } from "lru-cache";
4
4
  import { LoggerConfig } from "@weapp-core/logger";
@@ -351,6 +351,7 @@ interface ScanWxmlOptions {
351
351
  * @description WXML 处理阶段配置
352
352
  */
353
353
  interface HandleWxmlOptions {
354
+ defineImportMetaEnv?: Record<string, any>;
354
355
  removeComment?: boolean;
355
356
  transformEvent?: boolean;
356
357
  scriptModuleExtension?: string;
@@ -1022,6 +1023,7 @@ interface LoadConfigOptions {
1022
1023
  cwd: string;
1023
1024
  isDev: boolean;
1024
1025
  mode: string;
1026
+ emitDefaultAutoImportOutputs?: boolean;
1025
1027
  pluginOnly?: boolean;
1026
1028
  inlineConfig?: InlineConfig;
1027
1029
  configFile?: string;
@@ -1037,6 +1039,7 @@ interface LoadConfigResult {
1037
1039
  cwd: string;
1038
1040
  isDev: boolean;
1039
1041
  mode: string;
1042
+ emitDefaultAutoImportOutputs: boolean;
1040
1043
  chunksConfigured?: boolean;
1041
1044
  projectConfig: Record<string, any>;
1042
1045
  projectConfigPath?: string;
@@ -1085,6 +1088,7 @@ interface ConfigService {
1085
1088
  readonly defineImportMetaEnv: Record<string, any>;
1086
1089
  readonly cwd: string;
1087
1090
  readonly isDev: boolean;
1091
+ readonly emitDefaultAutoImportOutputs: boolean;
1088
1092
  readonly mpDistRoot: string;
1089
1093
  readonly outDir: string;
1090
1094
  readonly inlineConfig: InlineConfig;
@@ -1202,7 +1206,18 @@ interface RemovalRange {
1202
1206
  end: number;
1203
1207
  }
1204
1208
  interface WxmlToken {
1209
+ /**
1210
+ * @description 参与常规组件分析的标签集合。
1211
+ * 会应用 `excludeComponent` 过滤,通常会排除宿主内置组件,
1212
+ * 供原有的 `usingComponents` 推断与模板依赖聚合使用。
1213
+ */
1205
1214
  components: ComponentsMap;
1215
+ /**
1216
+ * @description 供自动导入使用的完整标签集合。
1217
+ * 不会因为“这是宿主内置组件名”而被提前过滤,
1218
+ * 用来支持“本地组件与内置组件重名时仍优先命中用户组件”的场景。
1219
+ */
1220
+ autoImportComponents?: ComponentsMap;
1206
1221
  deps: WxmlDep[];
1207
1222
  removalRanges: RemovalRange[];
1208
1223
  commentTokens: Token[];
@@ -1367,7 +1382,15 @@ interface WxmlService {
1367
1382
  depsMap: Map<string, Set<string>>;
1368
1383
  importerMap: Map<string, Set<string>>;
1369
1384
  tokenMap: Map<string, ScanWxmlResult>;
1385
+ /**
1386
+ * @description 常规组件索引缓存。
1387
+ * 这里沿用历史行为,只保留“应参与 usingComponents 推断”的组件标签。
1388
+ */
1370
1389
  wxmlComponentsMap: Map<string, ComponentsMap>;
1390
+ /**
1391
+ * @description 常规组件聚合缓存。
1392
+ * 会递归合并 import/include 进来的模板组件,但仍遵循内置组件过滤规则。
1393
+ */
1371
1394
  aggregatedComponentsMap: Map<string, ComponentsMap>;
1372
1395
  addDeps: (filepath: string, deps?: string[]) => Promise<void>;
1373
1396
  setDeps: (filepath: string, deps?: string[]) => Promise<void>;
@@ -1375,7 +1398,10 @@ interface WxmlService {
1375
1398
  getImporters: (filepath: string) => Set<string>;
1376
1399
  getAllDeps: () => Set<string>;
1377
1400
  getAggregatedComponents: (filepathOrBaseName: string) => ComponentsMap | undefined;
1378
- clearAll: () => void;
1401
+ getAggregatedAutoImportComponents: (filepathOrBaseName: string) => ComponentsMap | undefined;
1402
+ clearAll: (options?: {
1403
+ clearEmittedCode?: boolean;
1404
+ }) => void;
1379
1405
  analyze: (wxml: string) => ScanWxmlResult;
1380
1406
  scan: (filepath: string) => Promise<ScanWxmlResult | undefined>;
1381
1407
  setWxmlComponentsMap: (absPath: string, components: ComponentsMap) => void;
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-GqcM7sq1.mjs";
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-BMpfbpQb.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,4 +1,4 @@
1
- import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-D0HkutE0.mjs";
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 { t as defineConfig } from "./config-DJjSbpNX.mjs";
1
+ import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-wnfVS9jE.mjs";
2
+ import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BzPJL4F-.mjs";
3
+ import { t as defineConfig } from "./config-B2xtjEug.mjs";
4
4
  export { WEAPP_VITE_HOST_NAME, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };