weapp-vite 6.17.6 → 6.17.8

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,4 +1,4 @@
1
- import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-BfOAQZMj.mjs";
1
+ import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-C2Rk_kcI.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 { 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-BfOAQZMj.mjs";
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-C2Rk_kcI.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
3
- import { h as VERSION } from "./file-BOLzLiXg.mjs";
3
+ import { h as VERSION } from "./file-CuTGX59g.mjs";
4
4
  import { c as startWeappViteMcpServer, l as detectAiDevelopmentEnvironment, s as resolveWeappMcpConfig } from "./mcp-BG6TliEg.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import path, { posix } from "pathe";
@@ -4122,7 +4122,7 @@ function resolveRunnableHotkeyDefinition(input) {
4122
4122
  }
4123
4123
  //#endregion
4124
4124
  //#region package.json
4125
- var version = "6.17.6";
4125
+ var version = "6.17.8";
4126
4126
  //#endregion
4127
4127
  //#region src/cli/devHotkeys/format.ts
4128
4128
  const FULLWIDTH_ASCII_START = 65281;
@@ -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-BOLzLiXg.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-CuTGX59g.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";
@@ -10458,6 +10458,19 @@ const REG_REQUEST_GLOBAL_RUNTIME_VENDOR_ID = /(?:^|[/\\])(?:@wevu[/\\]web-apis|w
10458
10458
  const REG_WEAPP_VITE_RUNTIME_VENDOR_ID = /(?:^|[/\\])weapp-vite[/\\](?:dist[/\\]runtime\.mjs|src[/\\]plugins[/\\]vue[/\\]runtime\.ts)(?:$|[?#])/;
10459
10459
  const REG_HASHED_DIST_CHUNK_ID = /(?:^|[/\\])dist[/\\](?:dev[/\\])?([^/\\-]+)-([\w-]{6,})\.(?:m?js|cjs)(?:$|[?#])/;
10460
10460
  const STABLE_HASHED_DIST_CHUNK_PRIORITY = ["src"];
10461
+ const STABLE_HASHED_DIST_CHUNK_PRIORITY_BY_PACKAGE = { wevu: [
10462
+ "index",
10463
+ "internal-runtime",
10464
+ "watch",
10465
+ "templateRef",
10466
+ "router",
10467
+ "base",
10468
+ "computed",
10469
+ "toRefs",
10470
+ "store",
10471
+ "template",
10472
+ "ref"
10473
+ ] };
10461
10474
  function resolveSharedPathRoot(configService, sharedPathRoot) {
10462
10475
  const absoluteSrcRoot = configService.absoluteSrcRoot;
10463
10476
  const configuredRoot = sharedPathRoot ? path.resolve(configService.cwd, sharedPathRoot) : absoluteSrcRoot;
@@ -10593,6 +10606,19 @@ function resolveStableHashedDistChunkFileName(chunk) {
10593
10606
  matchedChunks.push(matchedChunk);
10594
10607
  if (id === chunk.facadeModuleId) facadeMatchedChunk = matchedChunk;
10595
10608
  }
10609
+ const packageTokens = /* @__PURE__ */ new Set();
10610
+ for (const { fileName } of matchedChunks) {
10611
+ const fileNameBase = fileName.replace(/^weapp-vendors\//, "").replace(/\.js$/, "");
10612
+ const packageToken = Object.keys(STABLE_HASHED_DIST_CHUNK_PRIORITY_BY_PACKAGE).find((token) => fileNameBase.startsWith(`${token}-`));
10613
+ if (packageToken) packageTokens.add(packageToken);
10614
+ }
10615
+ for (const packageToken of packageTokens) {
10616
+ const priorityBaseNames = STABLE_HASHED_DIST_CHUNK_PRIORITY_BY_PACKAGE[packageToken];
10617
+ for (const priorityBaseName of priorityBaseNames) {
10618
+ const matched = matchedChunks.find((chunk) => chunk.fileName === `weapp-vendors/${packageToken}-${priorityBaseName}.js`);
10619
+ if (matched) return matched.fileName;
10620
+ }
10621
+ }
10596
10622
  if (facadeMatchedChunk) return facadeMatchedChunk.fileName;
10597
10623
  for (const priorityBaseName of STABLE_HASHED_DIST_CHUNK_PRIORITY) {
10598
10624
  const matched = matchedChunks.find((chunk) => chunk.baseName === priorityBaseName);
@@ -13358,6 +13384,7 @@ const PACKAGE_ALIASES = [
13358
13384
  packageName: "wevu",
13359
13385
  distEntry: "dist/internal-runtime.mjs",
13360
13386
  devDistEntry: "dist/dev/internal-runtime.mjs",
13387
+ devWorkspaceEntry: "src/internal-runtime.ts",
13361
13388
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13362
13389
  },
13363
13390
  {
@@ -13365,6 +13392,7 @@ const PACKAGE_ALIASES = [
13365
13392
  packageName: "wevu",
13366
13393
  distEntry: "dist/internal-reactivity.mjs",
13367
13394
  devDistEntry: "dist/dev/internal-reactivity.mjs",
13395
+ devWorkspaceEntry: "src/internal-reactivity.ts",
13368
13396
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13369
13397
  },
13370
13398
  {
@@ -13372,6 +13400,7 @@ const PACKAGE_ALIASES = [
13372
13400
  packageName: "wevu",
13373
13401
  distEntry: "dist/internal-template.mjs",
13374
13402
  devDistEntry: "dist/dev/internal-template.mjs",
13403
+ devWorkspaceEntry: "src/internal-template.ts",
13375
13404
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13376
13405
  },
13377
13406
  {
@@ -13424,11 +13453,11 @@ const PACKAGE_ALIASES = [
13424
13453
  fallbackWorkspacePackagePath: WEVU_WORKSPACE_PACKAGE_PATH
13425
13454
  }
13426
13455
  ];
13427
- function resolveWevuRuntimeDistEntry(target, options) {
13428
- if (!target.devDistEntry || target.packageName !== "wevu") return target.distEntry;
13456
+ function resolveWevuRuntimeDistEntries(target, options) {
13457
+ if (!target.devDistEntry || target.packageName !== "wevu") return [target.distEntry];
13429
13458
  const mode = options.wevuRuntime ?? "auto";
13430
- if (mode === "dev" || mode === "auto" && options.isDev) return target.devDistEntry;
13431
- return target.distEntry;
13459
+ if (mode === "dev" || mode === "auto" && options.isDev) return [target.devWorkspaceEntry, target.devDistEntry].filter((entry) => Boolean(entry));
13460
+ return [target.distEntry];
13432
13461
  }
13433
13462
  function resolveRepoRoot(fromDir) {
13434
13463
  let currentDir = fromDir;
@@ -13439,23 +13468,25 @@ function resolveRepoRoot(fromDir) {
13439
13468
  currentDir = parentDir;
13440
13469
  }
13441
13470
  }
13442
- function resolvePackageEntry(packageName, distEntry, fallbackWorkspacePackagePath) {
13471
+ function resolvePackageEntry(packageName, distEntries, fallbackWorkspacePackagePath) {
13443
13472
  const packageInfo = safeGetPackageInfoSync(packageName);
13444
- if (packageInfo) {
13473
+ if (packageInfo) for (const distEntry of distEntries) {
13445
13474
  const resolvedEntry = path.resolve(packageInfo.rootPath, distEntry);
13446
13475
  if (existsSync(resolvedEntry)) return resolvedEntry;
13447
13476
  }
13448
13477
  if (!fallbackWorkspacePackagePath) return;
13449
13478
  const repoRoot = resolveRepoRoot(path.dirname(fileURLToPath(import.meta.url)));
13450
13479
  if (!repoRoot) return;
13451
- const fallbackEntry = path.resolve(repoRoot, fallbackWorkspacePackagePath, distEntry);
13452
- if (existsSync(fallbackEntry)) return fallbackEntry;
13480
+ for (const distEntry of distEntries) {
13481
+ const fallbackEntry = path.resolve(repoRoot, fallbackWorkspacePackagePath, distEntry);
13482
+ if (existsSync(fallbackEntry)) return fallbackEntry;
13483
+ }
13453
13484
  }
13454
13485
  function resolveBuiltinPackageAliases(options = {}) {
13455
13486
  const aliases = [];
13456
13487
  for (const target of PACKAGE_ALIASES) {
13457
13488
  const { find, packageName, fallbackWorkspacePackagePath } = target;
13458
- const resolvedEntry = resolvePackageEntry(packageName, resolveWevuRuntimeDistEntry(target, options), fallbackWorkspacePackagePath);
13489
+ const resolvedEntry = resolvePackageEntry(packageName, resolveWevuRuntimeDistEntries(target, options), fallbackWorkspacePackagePath);
13459
13490
  if (!resolvedEntry) continue;
13460
13491
  aliases.push({
13461
13492
  find,
@@ -15628,6 +15659,24 @@ function resolveAutoRoutesHotUpdateAction(command, options) {
15628
15659
  };
15629
15660
  }
15630
15661
  //#endregion
15662
+ //#region src/plugins/core/lifecycle/autoRoutesTopology.ts
15663
+ /**
15664
+ * 标记 app 入口依赖的 auto-routes 拓扑已变化。
15665
+ */
15666
+ function markAppEntryForAutoRoutesTopology(ctx, options) {
15667
+ const appEntryId = ctx.scanService?.appEntry?.path ? normalizeFsResolvedId(ctx.scanService.appEntry.path) : void 0;
15668
+ if (appEntryId) invalidateFileCache(appEntryId);
15669
+ invalidateFileCache("weapp-vite/auto-routes");
15670
+ invalidateFileCache("virtual:weapp-vite-auto-routes");
15671
+ invalidateFileCache("\0weapp-vite:auto-routes");
15672
+ for (const target of resolveAutoRoutesAliasTargets(ctx.configService?.packageInfo?.rootPath)) invalidateFileCache(normalizeFsResolvedId(target));
15673
+ options.loadEntry?.invalidateResolveCache?.();
15674
+ ctx.runtimeState.build.hmr.appEntryAutoRoutesSignature = void 0;
15675
+ if (!appEntryId || !options.resolvedEntryMap.has(appEntryId)) return false;
15676
+ options.markEntryDirty(appEntryId, "direct");
15677
+ return true;
15678
+ }
15679
+ //#endregion
15631
15680
  //#region src/plugins/autoRoutes.ts
15632
15681
  /**
15633
15682
  * 路由文件监听器的唯一标识,用于在 sidecarWatcherMap 中注册。
@@ -15636,7 +15685,9 @@ const ROUTE_WATCHER_KEY = "__auto-routes-vue-watcher__";
15636
15685
  function createAutoRoutesPlugin(ctx) {
15637
15686
  const service = ctx.autoRoutesService;
15638
15687
  let resolvedConfig;
15688
+ let devServer;
15639
15689
  const autoRoutesAliasTargets = /* @__PURE__ */ new Set();
15690
+ const autoRoutesTopologyDirtyEntries = /* @__PURE__ */ new Set();
15640
15691
  let routeWatcherStarted = false;
15641
15692
  const refreshAutoRoutesAliasTargets = () => {
15642
15693
  autoRoutesAliasTargets.clear();
@@ -15666,6 +15717,44 @@ function createAutoRoutesPlugin(ctx) {
15666
15717
  * 统一回收,不在 closeBundle 中销毁(build watch 模式下 closeBundle 每次
15667
15718
  * 重编译都会触发,提前销毁会导致后续文件变更无法感知)。
15668
15719
  */
15720
+ function invalidateAutoRoutesVirtualModule() {
15721
+ const virtualModule = devServer?.moduleGraph.getModuleById(RESOLVED_VIRTUAL_ID);
15722
+ if (!virtualModule || !devServer) return;
15723
+ const seen = /* @__PURE__ */ new Set();
15724
+ const invalidateModuleWithImporters = (module) => {
15725
+ if (seen.has(module)) return;
15726
+ seen.add(module);
15727
+ devServer.moduleGraph.invalidateModule(module);
15728
+ for (const importer of module.importers) invalidateModuleWithImporters(importer);
15729
+ };
15730
+ invalidateModuleWithImporters(virtualModule);
15731
+ }
15732
+ function markAutoRoutesTopologyDirty() {
15733
+ return markAppEntryForAutoRoutesTopology(ctx, {
15734
+ resolvedEntryMap: ctx.runtimeState.build.hmr.resolvedEntryMap,
15735
+ markEntryDirty(entryId) {
15736
+ const hmr = ctx.runtimeState.build.hmr;
15737
+ autoRoutesTopologyDirtyEntries.add(entryId);
15738
+ hmr.dirtyEntrySet.add(entryId);
15739
+ hmr.dirtyEntryReasons.set(entryId, "direct");
15740
+ hmr.loadedEntrySet.delete(entryId);
15741
+ hmr.dirtyVueEntryIds ??= /* @__PURE__ */ new Set();
15742
+ hmr.dirtyVueEntryIds.add(entryId);
15743
+ }
15744
+ });
15745
+ }
15746
+ function notifyAppEntryChange() {
15747
+ const appEntryPath = ctx.scanService?.appEntry?.path;
15748
+ if (!appEntryPath || !devServer) return;
15749
+ devServer.watcher.emit("change", appEntryPath);
15750
+ }
15751
+ async function handleRouteStructureChange(filePath, event) {
15752
+ if (await service.handleFileChange(filePath, event)) {
15753
+ invalidateAutoRoutesVirtualModule();
15754
+ markAutoRoutesTopologyDirty();
15755
+ notifyAppEntryChange();
15756
+ }
15757
+ }
15669
15758
  function startRouteFileWatcher() {
15670
15759
  const configService = ctx.configService;
15671
15760
  if (!configService) return;
@@ -15691,12 +15780,12 @@ function createAutoRoutesPlugin(ctx) {
15691
15780
  watcher.on("add", (filePath) => {
15692
15781
  if (!isAutoRoutesWatchFile(filePath, allowedExtensions, isPagesRelatedPath)) return;
15693
15782
  logger_default.info(`[auto-routes:watch] 新增路由文件 ${configService.relativeCwd(filePath)}`);
15694
- service.handleFileChange(filePath, "create");
15783
+ handleRouteStructureChange(filePath, "create");
15695
15784
  });
15696
15785
  watcher.on("unlink", (filePath) => {
15697
15786
  if (!isAutoRoutesWatchFile(filePath, allowedExtensions, isPagesRelatedPath)) return;
15698
15787
  logger_default.info(`[auto-routes:watch] 删除路由文件 ${configService.relativeCwd(filePath)}`);
15699
- service.handleFileChange(filePath, "delete");
15788
+ handleRouteStructureChange(filePath, "delete");
15700
15789
  });
15701
15790
  const { sidecarWatcherMap } = ctx.runtimeState.watcher;
15702
15791
  sidecarWatcherMap.set(ROUTE_WATCHER_KEY, createAutoRoutesSidecarWatcher(watcher));
@@ -15709,6 +15798,9 @@ function createAutoRoutesPlugin(ctx) {
15709
15798
  resolvedConfig = config;
15710
15799
  refreshAutoRoutesAliasTargets();
15711
15800
  },
15801
+ configureServer(server) {
15802
+ devServer = server;
15803
+ },
15712
15804
  buildStart() {
15713
15805
  refreshAutoRoutesAliasTargets();
15714
15806
  startRouteFileWatcher();
@@ -15729,6 +15821,9 @@ function createAutoRoutesPlugin(ctx) {
15729
15821
  map: { mappings: "" }
15730
15822
  };
15731
15823
  },
15824
+ shouldTransformCachedModule({ id }) {
15825
+ return autoRoutesTopologyDirtyEntries.delete(id) || void 0;
15826
+ },
15732
15827
  async watchChange(id, change) {
15733
15828
  const event = change?.event;
15734
15829
  if (service.isRouteFile(id)) {
@@ -17898,9 +17993,163 @@ function useLoadEntry(ctx, options) {
17898
17993
  const IMPLICIT_REQUIRE_RE = /\b(?:const|let|var)\s+[A-Za-z_$][\w$]*\s*=\s*require\((`[^`]+`|'[^']+'|"[^"]+")\);?/g;
17899
17994
  const REQUIRE_CALL_RE = /\brequire\((`[^`]+`|'[^']+'|"[^"]+")\)/g;
17900
17995
  const WEVU_SRC_CHUNK_RE = /(?:^|\/)wevu-src\.js$/;
17996
+ const WEVU_VENDOR_RUNTIME_CHUNK_RE = /(?:^|\/)weapp-vendors\/wevu-[^/]+\.js$/;
17901
17997
  const WEVU_EXPORT_ALIASES = [["defineComponent", "__wevuDefineComponent"], ["createWevuComponent", "__wevuCreateWevuComponent"]];
17902
- const WEVU_INTERNAL_RUNTIME_EXPORTS = ["createApp", "setWevuDefaults"];
17903
- const WEVU_INTERNAL_RUNTIME_EXPORT_SET = new Set(WEVU_INTERNAL_RUNTIME_EXPORTS);
17998
+ const WEVU_SYNTHETIC_SINGLE_PAGE_HOOK_EXPORTS = [
17999
+ "onAddToFavorites",
18000
+ "onSaveExitState",
18001
+ "onShareAppMessage",
18002
+ "onShareTimeline"
18003
+ ];
18004
+ const WEVU_INTERNAL_REACTIVITY_EXPORTS = [
18005
+ "addMutationRecorder",
18006
+ "batch",
18007
+ "computed",
18008
+ "customRef",
18009
+ "effect",
18010
+ "effectScope",
18011
+ "endBatch",
18012
+ "getCurrentScope",
18013
+ "getDeepWatchStrategy",
18014
+ "getReactiveVersion",
18015
+ "isProxy",
18016
+ "isRaw",
18017
+ "isReactive",
18018
+ "isReadonly",
18019
+ "isRef",
18020
+ "isShallowReactive",
18021
+ "isShallowRef",
18022
+ "markRaw",
18023
+ "nextTick",
18024
+ "onScopeDispose",
18025
+ "prelinkReactiveTree",
18026
+ "reactive",
18027
+ "readonly",
18028
+ "ref",
18029
+ "removeMutationRecorder",
18030
+ "setDeepWatchStrategy",
18031
+ "shallowReactive",
18032
+ "shallowReadonly",
18033
+ "shallowRef",
18034
+ "startBatch",
18035
+ "stop",
18036
+ "toRaw",
18037
+ "toRef",
18038
+ "toRefs",
18039
+ "toValue",
18040
+ "touchReactive",
18041
+ "traverse",
18042
+ "triggerRef",
18043
+ "unref",
18044
+ "watch",
18045
+ "watchEffect",
18046
+ "watchPostEffect",
18047
+ "watchSyncEffect"
18048
+ ];
18049
+ const WEVU_INTERNAL_TEMPLATE_EXPORTS = [
18050
+ "normalizeClass",
18051
+ "normalizeStyle",
18052
+ "resolvePropValue"
18053
+ ];
18054
+ const WEVU_INTERNAL_RUNTIME_EXPORTS = [
18055
+ "callHookList",
18056
+ "callHookReturn",
18057
+ "createApp",
18058
+ "createWevuComponent",
18059
+ "createWevuScopedSlotComponent",
18060
+ "defineAppSetup",
18061
+ "defineComponent",
18062
+ "getCurrentInstance",
18063
+ "getCurrentPageStackSnapshot",
18064
+ "getCurrentSetupContext",
18065
+ "getNavigationBarMetrics",
18066
+ "hasInjectionContext",
18067
+ "inject",
18068
+ "injectGlobal",
18069
+ "isNoSetData",
18070
+ "markNoSetData",
18071
+ "mergeModels",
18072
+ "mountRuntimeInstance",
18073
+ "onActivated",
18074
+ "onAddToFavorites",
18075
+ "onAttached",
18076
+ "onBeforeMount",
18077
+ "onBeforeUnmount",
18078
+ "onBeforeUpdate",
18079
+ "onDeactivated",
18080
+ "onDetached",
18081
+ "onError",
18082
+ "onErrorCaptured",
18083
+ "onHide",
18084
+ "onLaunch",
18085
+ "onLoad",
18086
+ "onMemoryWarning",
18087
+ "onMounted",
18088
+ "onMoved",
18089
+ "onPageNotFound",
18090
+ "onPageScroll",
18091
+ "onPullDownRefresh",
18092
+ "onReachBottom",
18093
+ "onReady",
18094
+ "onResize",
18095
+ "onRouteDone",
18096
+ "onSaveExitState",
18097
+ "onServerPrefetch",
18098
+ "onShareAppMessage",
18099
+ "onShareTimeline",
18100
+ "onShow",
18101
+ "onTabItemTap",
18102
+ "onThemeChange",
18103
+ "onUnhandledRejection",
18104
+ "onUnload",
18105
+ "onUnmounted",
18106
+ "onUpdated",
18107
+ "provide",
18108
+ "provideGlobal",
18109
+ "registerApp",
18110
+ "registerComponent",
18111
+ "resetWevuDefaults",
18112
+ "resolveLayoutBridge",
18113
+ "resolveLayoutHost",
18114
+ "resolveRuntimePageLayoutName",
18115
+ "runSetupFunction",
18116
+ "setCurrentInstance",
18117
+ "setCurrentSetupContext",
18118
+ "setGlobalProvidedValue",
18119
+ "setPageLayout",
18120
+ "setRuntimeSetDataVisibility",
18121
+ "setWevuDefaults",
18122
+ "syncRuntimePageLayoutState",
18123
+ "syncRuntimePageLayoutStateFromRuntime",
18124
+ "teardownRuntimeInstance",
18125
+ "use",
18126
+ "useAsyncPullDownRefresh",
18127
+ "useAttrs",
18128
+ "useBindModel",
18129
+ "useBoundingClientRect",
18130
+ "useChangeModel",
18131
+ "useDisposables",
18132
+ "useElementIntersectionObserver",
18133
+ "useIntersectionObserver",
18134
+ "useLayoutBridge",
18135
+ "useLayoutHosts",
18136
+ "useModel",
18137
+ "useNativeInstance",
18138
+ "useNativePageRouter",
18139
+ "useNativeRouter",
18140
+ "useNavigationBarMetrics",
18141
+ "usePageLayout",
18142
+ "usePageScrollThrottle",
18143
+ "usePageStack",
18144
+ "useScrollOffset",
18145
+ "useSelectorFields",
18146
+ "useSelectorQuery",
18147
+ "useSlots",
18148
+ "useTemplateRef",
18149
+ "useUpdatePerformanceListener",
18150
+ "version",
18151
+ "waitForLayoutHost"
18152
+ ];
17904
18153
  const WEVU_RUNTIME_MODULE_IDS = [
17905
18154
  "wevu",
17906
18155
  "wevu/router",
@@ -17931,20 +18180,12 @@ const WEVU_RUNTIME_MODULE_EXPORT_MARKERS = {
17931
18180
  "wevu/fetch": ["createFetch", "useFetch"],
17932
18181
  "wevu/web-apis": ["installWebApis", "createWebApis"],
17933
18182
  "wevu/internal-runtime": WEVU_INTERNAL_RUNTIME_EXPORTS,
17934
- "wevu/internal-reactivity": [
17935
- "ref",
17936
- "reactive",
17937
- "computed",
17938
- "watch",
17939
- "watchEffect",
17940
- "nextTick"
17941
- ],
17942
- "wevu/internal-template": [
17943
- "normalizeClass",
17944
- "normalizeStyle",
17945
- "resolvePropValue"
17946
- ]
18183
+ "wevu/internal-reactivity": WEVU_INTERNAL_REACTIVITY_EXPORTS,
18184
+ "wevu/internal-template": WEVU_INTERNAL_TEMPLATE_EXPORTS
17947
18185
  };
18186
+ const WEVU_INTERNAL_REACTIVITY_EXPORT_SET = new Set(WEVU_INTERNAL_REACTIVITY_EXPORTS);
18187
+ const WEVU_INTERNAL_TEMPLATE_EXPORT_SET = new Set(WEVU_INTERNAL_TEMPLATE_EXPORTS);
18188
+ const WEVU_INTERNAL_RUNTIME_EXPORT_SET = new Set(WEVU_INTERNAL_RUNTIME_EXPORTS);
17948
18189
  const JS_IDENTIFIER_RE = /^[A-Z_$][\w$]*$/i;
17949
18190
  function filterPluginBundleOutputs(bundle, configService) {
17950
18191
  if (configService.pluginOnly) return;
@@ -18115,6 +18356,7 @@ function rememberWevuRuntimeChunk(moduleId, chunk, options) {
18115
18356
  function rememberCurrentWevuRuntimeChunks(bundle, options) {
18116
18357
  const rememberedFileNames = /* @__PURE__ */ new Set();
18117
18358
  for (const moduleId of WEVU_RUNTIME_MODULE_IDS) {
18359
+ if (moduleId === "wevu") continue;
18118
18360
  const chunk = resolveWevuRuntimeChunkByModuleId(bundle, moduleId) ?? resolveWevuInternalChunkByExportMarkers(bundle, WEVU_RUNTIME_MODULE_EXPORT_MARKERS[moduleId], rememberedFileNames);
18119
18361
  rememberWevuRuntimeChunk(moduleId, chunk, options);
18120
18362
  if (chunk?.fileName) rememberedFileNames.add(chunk.fileName);
@@ -18138,6 +18380,61 @@ function formatNamedRequireBindings(bindings) {
18138
18380
  return importedName === localName ? importedName : `${importedName}: ${localName}`;
18139
18381
  }).join(", ");
18140
18382
  }
18383
+ function resolveRootWevuInternalModuleId(importedName) {
18384
+ if (WEVU_INTERNAL_REACTIVITY_EXPORT_SET.has(importedName)) return "wevu/internal-reactivity";
18385
+ if (WEVU_INTERNAL_TEMPLATE_EXPORT_SET.has(importedName)) return "wevu/internal-template";
18386
+ if (WEVU_INTERNAL_RUNTIME_EXPORT_SET.has(importedName)) return "wevu/internal-runtime";
18387
+ }
18388
+ function resolveWevuRuntimeChunkForModuleId(bundle, moduleId, importedNames) {
18389
+ return resolveWevuRuntimeChunkByModuleId(bundle, moduleId) ?? resolveWevuInternalChunk(bundle, importedNames);
18390
+ }
18391
+ function resolveRememberedWevuRuntimeFileName(moduleId, importedNames, options) {
18392
+ const names = [...importedNames];
18393
+ const canUseLegacyRuntimeFileName = moduleId === "wevu/internal-runtime" && names.every((importedName) => WEVU_INTERNAL_RUNTIME_EXPORT_SET.has(importedName));
18394
+ return options.runtimeFileNames?.get(moduleId) ?? (canUseLegacyRuntimeFileName ? options.runtimeFileName : void 0);
18395
+ }
18396
+ function formatWevuRuntimeRequire(fileName, runtimeFileName, bindings) {
18397
+ const specifier = normalizeRelativeRequireSpecifier(fileName, runtimeFileName);
18398
+ return `const { ${formatNamedRequireBindings(bindings)} } = require(${JSON.stringify(specifier)});`;
18399
+ }
18400
+ function rewriteRootWevuImport(bundle, fileName, full, bindings, options, requiredRuntimeFileNames) {
18401
+ const groupedBindings = /* @__PURE__ */ new Map();
18402
+ const remainingBindings = [];
18403
+ for (const binding of bindings) {
18404
+ const moduleId = resolveRootWevuInternalModuleId(binding.importedName);
18405
+ if (!moduleId) {
18406
+ remainingBindings.push(binding);
18407
+ continue;
18408
+ }
18409
+ const group = groupedBindings.get(moduleId) ?? [];
18410
+ group.push(binding);
18411
+ groupedBindings.set(moduleId, group);
18412
+ }
18413
+ if (!groupedBindings.size) return {
18414
+ code: full,
18415
+ changed: false
18416
+ };
18417
+ const statements = [];
18418
+ for (const [moduleId, moduleBindings] of groupedBindings) {
18419
+ const importedNames = moduleBindings.map((binding) => binding.importedName);
18420
+ const runtimeChunk = resolveWevuRuntimeChunkForModuleId(bundle, moduleId, importedNames);
18421
+ const runtimeFileName = runtimeChunk?.fileName ?? resolveRememberedWevuRuntimeFileName(moduleId, importedNames, options);
18422
+ if (!runtimeFileName) return {
18423
+ code: full,
18424
+ changed: false
18425
+ };
18426
+ rememberWevuRuntimeChunk(moduleId, runtimeChunk, options);
18427
+ requiredRuntimeFileNames.add(runtimeFileName);
18428
+ statements.push(formatWevuRuntimeRequire(fileName, runtimeFileName, moduleBindings));
18429
+ }
18430
+ if (remainingBindings.length) statements.push(`import { ${remainingBindings.map(({ importedName, localName }) => {
18431
+ return importedName === localName ? importedName : `${importedName} as ${localName}`;
18432
+ }).join(", ")} } from "wevu";`);
18433
+ return {
18434
+ code: statements.join("\n"),
18435
+ changed: true
18436
+ };
18437
+ }
18141
18438
  function rewriteWevuInternalRuntimeImports(bundle, options = {}) {
18142
18439
  const importRe = /\bimport\s*\{([^}]*)\}\s*from\s*["'](wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?)["'];?/g;
18143
18440
  const requireRe = /\brequire\(\s*(`wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?`|'wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?'|"wevu(?:\/(?:router|store|api|fetch|web-apis|internal-(?:runtime|reactivity|template)))?")\s*\)/g;
@@ -18156,10 +18453,14 @@ function rewriteWevuInternalRuntimeImports(bundle, options = {}) {
18156
18453
  rewritten = rewritten.replace(importRe, (full, importClause, source) => {
18157
18454
  const bindings = parseNamedImportBindings(importClause);
18158
18455
  const importedNames = bindings.map((binding) => binding.importedName);
18159
- const runtimeChunk = isWevuRuntimeModuleId(source) ? resolveWevuRuntimeChunkByModuleId(bundle, source) ?? resolveWevuInternalChunk(bundle, importedNames) : resolveWevuInternalChunk(bundle, importedNames);
18160
- const resolvedInternalModuleId = isWevuRuntimeModuleId(source) ? source : "wevu/internal-runtime";
18161
- const canUseRememberedRuntime = resolvedInternalModuleId === "wevu/internal-runtime" && importedNames.every((importedName) => WEVU_INTERNAL_RUNTIME_EXPORT_SET.has(importedName));
18162
- const rememberedRuntimeFileName = options.runtimeFileNames?.get(resolvedInternalModuleId) ?? (canUseRememberedRuntime ? options.runtimeFileName : void 0);
18456
+ if (source === "wevu") {
18457
+ const result = rewriteRootWevuImport(bundle, fileName, full, bindings, options, requiredRuntimeFileNames);
18458
+ changed ||= result.changed;
18459
+ return result.code;
18460
+ }
18461
+ const resolvedInternalModuleId = source;
18462
+ const runtimeChunk = resolveWevuRuntimeChunkForModuleId(bundle, resolvedInternalModuleId, importedNames);
18463
+ const rememberedRuntimeFileName = resolveRememberedWevuRuntimeFileName(resolvedInternalModuleId, importedNames, options);
18163
18464
  const runtimeFileName = runtimeChunk?.fileName ?? rememberedRuntimeFileName;
18164
18465
  if (!runtimeFileName) return full;
18165
18466
  rememberWevuRuntimeChunk(resolvedInternalModuleId, runtimeChunk, options);
@@ -18282,6 +18583,56 @@ function appendWevuRuntimeExports(chunk, aliases, importedMembers) {
18282
18583
  }
18283
18584
  if (lines.length) chunk.code = `${chunk.code}\n${lines.join("\n")}`;
18284
18585
  }
18586
+ function formatSyntheticSinglePageHookExport(exportName) {
18587
+ return [
18588
+ `function ${exportName}(handler) {`,
18589
+ `\tconst instance = require_weapp_vendors_wevu_base.assertInSetup(${JSON.stringify(exportName)});`,
18590
+ `\trequire_weapp_vendors_wevu_base.pushHook(instance, ${JSON.stringify(exportName)}, handler, { single: true });`,
18591
+ `}`,
18592
+ `Object.defineProperty(exports, ${JSON.stringify(exportName)}, { enumerable: true, get: function() { return ${exportName}; } });`
18593
+ ].join("\n");
18594
+ }
18595
+ function appendSyntheticWevuHookExports(chunk, importedMembers) {
18596
+ if (!chunk.code.includes("require_weapp_vendors_wevu_base")) return;
18597
+ const existingExports = collectExistingExportNames(chunk.code);
18598
+ const lines = [];
18599
+ for (const exportName of WEVU_SYNTHETIC_SINGLE_PAGE_HOOK_EXPORTS) {
18600
+ if (!importedMembers.has(exportName) || existingExports.has(exportName)) continue;
18601
+ lines.push(formatSyntheticSinglePageHookExport(exportName));
18602
+ existingExports.add(exportName);
18603
+ }
18604
+ if (lines.length) chunk.code = `${chunk.code}\n${lines.join("\n")}`;
18605
+ }
18606
+ function resolveWevuBaseChunk(bundle) {
18607
+ return resolveWevuInternalChunk(bundle, ["assertInSetup", "pushHook"]);
18608
+ }
18609
+ function formatSyntheticSinglePageHookFallback(hookName, receiverAccess, baseRequireSpecifier) {
18610
+ const baseRequire = `require(${JSON.stringify(baseRequireSpecifier)})`;
18611
+ return `(${receiverAccess} || function(handler) { const instance = ${baseRequire}.assertInSetup(${JSON.stringify(hookName)}); ${baseRequire}.pushHook(instance, ${JSON.stringify(hookName)}, handler, { single: true }); })(`;
18612
+ }
18613
+ function rewriteSyntheticWevuHookAccess(chunk, wevuChunkFileName, baseChunkFileName, importedMembers) {
18614
+ const hookNames = WEVU_SYNTHETIC_SINGLE_PAGE_HOOK_EXPORTS.filter((name) => importedMembers.has(name));
18615
+ if (!hookNames.length) return;
18616
+ const baseRequireSpecifier = normalizeRelativeRequireSpecifier(chunk.fileName, baseChunkFileName);
18617
+ let nextCode = chunk.code;
18618
+ const localRequireRe = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*require\((`[^`]+`|'[^']+'|"[^"]+")\);?/g;
18619
+ const runtimeRefs = /* @__PURE__ */ new Set();
18620
+ for (const match of nextCode.matchAll(localRequireRe)) if (resolveRequireTarget(chunk.fileName, stripQuotes(match[2])) === wevuChunkFileName) runtimeRefs.add(match[1]);
18621
+ for (const hookName of hookNames) {
18622
+ for (const ref of runtimeRefs) {
18623
+ const memberRe = new RegExp(`\\b${escapeRegExp(ref)}\\.${hookName}\\s*\\(`, "g");
18624
+ nextCode = nextCode.replace(memberRe, () => {
18625
+ return formatSyntheticSinglePageHookFallback(hookName, `${ref}.${hookName}`, baseRequireSpecifier);
18626
+ });
18627
+ }
18628
+ nextCode = nextCode.replace(/require\((`[^`]+`|'[^']+'|"[^"]+")\)\.([A-Za-z_$][\w$]*)\s*\(/g, (full, rawSpecifier, property) => {
18629
+ if (property !== hookName) return full;
18630
+ if (resolveRequireTarget(chunk.fileName, stripQuotes(rawSpecifier)) !== wevuChunkFileName) return full;
18631
+ return formatSyntheticSinglePageHookFallback(hookName, `require(${rawSpecifier}).${hookName}`, baseRequireSpecifier);
18632
+ });
18633
+ }
18634
+ chunk.code = nextCode;
18635
+ }
18285
18636
  function rewriteStableWevuRuntimeAccess(chunk, wevuChunkFileName, aliases) {
18286
18637
  if (!aliases.size) return;
18287
18638
  let nextCode = chunk.code;
@@ -18306,15 +18657,29 @@ function rewriteStableWevuRuntimeAccess(chunk, wevuChunkFileName, aliases) {
18306
18657
  chunk.code = nextCode;
18307
18658
  }
18308
18659
  function stabilizeWevuRuntimeChunkAccess(bundle) {
18309
- const wevuChunk = Object.values(bundle).find((output) => {
18310
- return output?.type === "chunk" && WEVU_SRC_CHUNK_RE.test(output.fileName);
18660
+ const wevuChunks = Object.values(bundle).filter((output) => {
18661
+ return output?.type === "chunk" && (WEVU_SRC_CHUNK_RE.test(output.fileName) || WEVU_VENDOR_RUNTIME_CHUNK_RE.test(output.fileName));
18311
18662
  });
18312
- if (!wevuChunk) return;
18313
- const aliases = resolveWevuExportAliasMap(wevuChunk);
18314
- appendWevuRuntimeExports(wevuChunk, aliases, collectImportedWevuRuntimeMembers(bundle, wevuChunk.fileName));
18315
- for (const output of Object.values(bundle)) {
18316
- if (!output || output.type !== "chunk" || typeof output.code !== "string" || output.fileName === wevuChunk.fileName) continue;
18317
- rewriteStableWevuRuntimeAccess(output, wevuChunk.fileName, aliases);
18663
+ if (!wevuChunks.length) return;
18664
+ const baseChunk = resolveWevuBaseChunk(bundle);
18665
+ for (const wevuChunk of wevuChunks) {
18666
+ const aliases = resolveWevuExportAliasMap(wevuChunk);
18667
+ const importedMembers = collectImportedWevuRuntimeMembers(bundle, wevuChunk.fileName);
18668
+ appendWevuRuntimeExports(wevuChunk, aliases, importedMembers);
18669
+ appendSyntheticWevuHookExports(wevuChunk, importedMembers);
18670
+ for (const output of Object.values(bundle)) {
18671
+ if (!output || output.type !== "chunk" || typeof output.code !== "string" || output.fileName === wevuChunk.fileName) continue;
18672
+ const chunk = output;
18673
+ rewriteStableWevuRuntimeAccess(chunk, wevuChunk.fileName, aliases);
18674
+ if (baseChunk?.fileName) {
18675
+ rewriteSyntheticWevuHookAccess(chunk, wevuChunk.fileName, baseChunk.fileName, importedMembers);
18676
+ if (chunk.code.includes(normalizeRelativeRequireSpecifier(chunk.fileName, baseChunk.fileName))) {
18677
+ const nextImports = new Set(Array.isArray(chunk.imports) ? chunk.imports : []);
18678
+ nextImports.add(baseChunk.fileName);
18679
+ chunk.imports = [...nextImports];
18680
+ }
18681
+ }
18682
+ }
18318
18683
  }
18319
18684
  }
18320
18685
  //#endregion
@@ -18374,26 +18739,73 @@ function collectAffectedSharedChunks(state, startId) {
18374
18739
  for (const chunkId of chunkIds) affected.add(chunkId);
18375
18740
  return affected;
18376
18741
  }
18377
- function refreshModuleGraph(pluginCtx, state) {
18378
- state.moduleImporters.clear();
18379
- state.entryModuleIds.clear();
18380
- if (typeof pluginCtx.getModuleIds !== "function" || typeof pluginCtx.getModuleInfo !== "function") return;
18381
- for (const rawId of pluginCtx.getModuleIds()) {
18742
+ function refreshModuleGraph(pluginCtx, state, bundle, options) {
18743
+ const mode = options?.mode ?? "replace";
18744
+ if (mode === "replace") {
18745
+ state.moduleImporters.clear();
18746
+ state.entryModuleIds.clear();
18747
+ }
18748
+ const addModuleImporter = (moduleId, importerId) => {
18749
+ const normalizedModuleId = normalizeFsResolvedId(moduleId);
18750
+ const normalizedImporterId = normalizeFsResolvedId(importerId);
18751
+ if (normalizedModuleId === normalizedImporterId || isSkippableResolvedId(normalizedModuleId) || isSkippableResolvedId(normalizedImporterId)) return;
18752
+ const importers = state.moduleImporters.get(normalizedModuleId) ?? /* @__PURE__ */ new Set();
18753
+ importers.add(normalizedImporterId);
18754
+ state.moduleImporters.set(normalizedModuleId, importers);
18755
+ };
18756
+ const removeEntryImporter = (entryId) => {
18757
+ const normalizedEntryId = normalizeFsResolvedId(entryId);
18758
+ for (const [moduleId, importers] of state.moduleImporters) {
18759
+ importers.delete(normalizedEntryId);
18760
+ if (!importers.size) state.moduleImporters.delete(moduleId);
18761
+ }
18762
+ };
18763
+ const collectChunkModuleIds = (chunk) => {
18764
+ const moduleIds = /* @__PURE__ */ new Set();
18765
+ if (Array.isArray(chunk.moduleIds)) for (const moduleId of chunk.moduleIds) moduleIds.add(moduleId);
18766
+ for (const moduleId of Object.keys(chunk.modules ?? {})) moduleIds.add(moduleId);
18767
+ return moduleIds;
18768
+ };
18769
+ const collectChunkEntryIds = (chunk, moduleIds) => {
18770
+ const entryIds = /* @__PURE__ */ new Set();
18771
+ const addEntryIfTracked = (rawId) => {
18772
+ if (!rawId) return;
18773
+ const entryId = normalizeFsResolvedId(rawId);
18774
+ if (!isSkippableResolvedId(entryId) && state.resolvedEntryMap.has(entryId)) entryIds.add(entryId);
18775
+ };
18776
+ addEntryIfTracked(chunk.facadeModuleId);
18777
+ for (const moduleId of moduleIds) addEntryIfTracked(moduleId);
18778
+ return entryIds;
18779
+ };
18780
+ if (typeof pluginCtx.getModuleIds === "function" && typeof pluginCtx.getModuleInfo === "function") for (const rawId of pluginCtx.getModuleIds()) {
18382
18781
  const normalizedId = normalizeFsResolvedId(rawId);
18383
18782
  if (isSkippableResolvedId(normalizedId)) continue;
18384
18783
  const info = pluginCtx.getModuleInfo(rawId);
18385
18784
  if (!info) continue;
18386
18785
  if (info.isEntry) state.entryModuleIds.add(normalizedId);
18387
- const importers = /* @__PURE__ */ new Set();
18388
18786
  const importerIds = [];
18389
18787
  if (Array.isArray(info.importers)) importerIds.push(...info.importers);
18390
18788
  if (Array.isArray(info.dynamicImporters)) importerIds.push(...info.dynamicImporters);
18391
- for (const importer of importerIds) {
18392
- const normalizedImporter = normalizeFsResolvedId(importer);
18393
- if (isSkippableResolvedId(normalizedImporter)) continue;
18394
- importers.add(normalizedImporter);
18395
- }
18396
- if (importers.size) state.moduleImporters.set(normalizedId, importers);
18789
+ for (const importer of importerIds) addModuleImporter(normalizedId, importer);
18790
+ }
18791
+ if (!bundle) return;
18792
+ const chunkRecords = [];
18793
+ for (const output of Object.values(bundle)) {
18794
+ if (output?.type !== "chunk") continue;
18795
+ const chunk = output;
18796
+ const moduleIds = collectChunkModuleIds(chunk);
18797
+ const entryIds = collectChunkEntryIds(chunk, moduleIds);
18798
+ if (!entryIds.size) continue;
18799
+ chunkRecords.push({
18800
+ chunk,
18801
+ entryIds,
18802
+ moduleIds
18803
+ });
18804
+ }
18805
+ if (mode === "merge") for (const { entryIds } of chunkRecords) for (const entryId of entryIds) removeEntryImporter(entryId);
18806
+ for (const { entryIds, moduleIds } of chunkRecords) for (const entryId of entryIds) {
18807
+ state.entryModuleIds.add(entryId);
18808
+ for (const moduleId of moduleIds) addModuleImporter(moduleId, entryId);
18397
18809
  }
18398
18810
  }
18399
18811
  function appendSharedChunkImporters(bundle, state, onlyEntryIds, previousImporters, previousDependencies) {
@@ -19526,6 +19938,7 @@ function injectRequestGlobalsIntoSfc(source, targets, options) {
19526
19938
  //#endregion
19527
19939
  //#region src/plugins/outputFinalizer.ts
19528
19940
  const PREPROCESSOR_STYLE_ASSET_RE = /\.(?:less|sass|scss|styl|stylus|pcss|postcss|sss)$/i;
19941
+ const TEMPLATE_ASSET_RE = /\.(?:wxml|axml|swan|ttml|jxml|qml|ksml|xhsml)$/i;
19529
19942
  function outputSourceToString(output) {
19530
19943
  if (output.type === "chunk") return output.code;
19531
19944
  const source = output.source;
@@ -19554,6 +19967,20 @@ function normalizePreprocessorStyleAssets(bundle, styleExtension, emitAsset) {
19554
19967
  });
19555
19968
  }
19556
19969
  }
19970
+ function normalizeTemplateAssets(ctx, bundle) {
19971
+ const { configService } = ctx;
19972
+ for (const output of Object.values(bundle)) {
19973
+ if (output?.type !== "asset" || !TEMPLATE_ASSET_RE.test(output.fileName)) continue;
19974
+ const source = output.source;
19975
+ const code = typeof source === "string" ? source : source instanceof Uint8Array ? Buffer.from(source).toString("utf8") : void 0;
19976
+ if (code === void 0) continue;
19977
+ const result = handleWxml(scanWxml(code, { platform: configService?.platform }), {
19978
+ scriptModuleExtension: configService?.outputExtensions?.wxs,
19979
+ templateExtension: configService?.outputExtensions?.wxml
19980
+ });
19981
+ if (result.code !== code) output.source = result.code;
19982
+ }
19983
+ }
19557
19984
  function pruneUneventedDevHmrChunks(ctx, bundle) {
19558
19985
  const emittedChunkFileNames = ctx.runtimeState?.build?.hmr?.lastEmittedChunkFileNames;
19559
19986
  if (!ctx.configService?.isDev || ctx.runtimeState?.build?.hmr?.profile?.event === void 0 || !emittedChunkFileNames?.size) return;
@@ -19565,6 +19992,7 @@ function pruneUnchangedDevHmrOutputs(ctx, bundle, rewriteOptions) {
19565
19992
  const isHmrBuild = ctx.runtimeState?.build?.hmr?.profile?.event !== void 0;
19566
19993
  const emittedChunkFileNames = ctx.runtimeState?.build?.hmr?.lastEmittedChunkFileNames;
19567
19994
  rewriteWevuInternalRuntimeImports(bundle, rewriteOptions);
19995
+ stabilizeWevuRuntimeChunkAccess(bundle);
19568
19996
  pruneUneventedDevHmrChunks(ctx, bundle);
19569
19997
  for (const [fileName, output] of Object.entries(bundle)) {
19570
19998
  const source = outputSourceToString(output);
@@ -19601,7 +20029,9 @@ function createOutputFinalizerPlugin(ctx) {
19601
20029
  enforce: "post",
19602
20030
  generateBundle(_options, bundle) {
19603
20031
  rewriteWevuInternalRuntimeImports(bundle, wevuRuntimeRewriteOptions);
20032
+ stabilizeWevuRuntimeChunkAccess(bundle);
19604
20033
  normalizePreprocessorStyleAssets(bundle, ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
20034
+ normalizeTemplateAssets(ctx, bundle);
19605
20035
  pruneUnchangedDevHmrOutputs(ctx, bundle, wevuRuntimeRewriteOptions);
19606
20036
  }
19607
20037
  };
@@ -20843,7 +21273,6 @@ function createGenerateBundleHook(state, isPluginBuild) {
20843
21273
  state.hmrState.affectedSharedChunkIds?.clear();
20844
21274
  if (assetOnlyDevHmrBundle) {
20845
21275
  normalizePreprocessorStyleAssets(rolldownBundle, state.ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
20846
- refreshModuleGraph(this, state);
20847
21276
  return;
20848
21277
  }
20849
21278
  function matchSubPackage(filePath) {
@@ -21005,7 +21434,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
21005
21434
  stabilizeWevuRuntimeChunkAccess(rolldownBundle);
21006
21435
  syncChunkImportsFromRequireCalls(rolldownBundle);
21007
21436
  normalizePreprocessorStyleAssets(rolldownBundle, state.ctx.configService.outputExtensions?.wxss, (asset) => this.emitFile(asset));
21008
- refreshModuleGraph(this, state);
21437
+ refreshModuleGraph(this, state, rolldownBundle, { mode: state.ctx.configService.isDev && state.hmrState.hasBuiltOnce ? "merge" : "replace" });
21009
21438
  if (configService.weappViteConfig?.debug?.watchFiles) {
21010
21439
  const watcherService = ctx.watcherService;
21011
21440
  const watcherRoot = subPackageMeta?.subPackage.root ?? "/";
@@ -21932,12 +22361,6 @@ function isAutoRoutesPagesRelatedChange(state, normalizedId) {
21932
22361
  subPackageRoots
21933
22362
  });
21934
22363
  }
21935
- function invalidateAutoRoutesModuleCache(state) {
21936
- invalidateFileCache("weapp-vite/auto-routes");
21937
- invalidateFileCache("virtual:weapp-vite-auto-routes");
21938
- invalidateFileCache("\0weapp-vite:auto-routes");
21939
- for (const target of resolveAutoRoutesAliasTargets(state.ctx.configService?.packageInfo?.rootPath)) invalidateFileCache(normalizeFsResolvedId(target));
21940
- }
21941
22364
  function isConfigFileDependencyChange(state, normalizedId) {
21942
22365
  return state.ctx.configService.configFileDependencies.some((dependency) => normalizeFsResolvedId(dependency) === normalizedId);
21943
22366
  }
@@ -21947,6 +22370,7 @@ function isCurrentSubPackageFile(relativeSrc, subPackageMeta) {
21947
22370
  }
21948
22371
  async function normalizeWatchEvent(id, event, options) {
21949
22372
  if (event === "create" && (options.loadedEntrySet.has(id) || options.resolvedEntryMap.has(id)) && await fs.pathExists(id)) return "update";
22373
+ if (event === "create" && (options.moduleImporters?.has(id) || options.sharedChunkSourceModuleIds?.has(id)) && await fs.pathExists(id)) return "update";
21950
22374
  if (event === "create" && await fs.pathExists(id)) {
21951
22375
  const ext = path.extname(id);
21952
22376
  if (ext) {
@@ -22095,15 +22519,12 @@ async function processChangedFile(state, id, event) {
22095
22519
  }
22096
22520
  return false;
22097
22521
  };
22098
- const markAppEntryForAutoRoutesTopology = () => {
22099
- const appEntryId = scanService.appEntry?.path ? normalizeFsResolvedId(scanService.appEntry.path) : void 0;
22100
- if (!appEntryId || !resolvedEntryMap.has(appEntryId)) return false;
22101
- invalidateFileCache(appEntryId);
22102
- invalidateAutoRoutesModuleCache(state);
22103
- loadEntry?.invalidateResolveCache?.();
22104
- ctx.runtimeState.build.hmr.appEntryAutoRoutesSignature = void 0;
22105
- markEntryDirtyWithCause(appEntryId, "direct", "auto-routes-topology");
22106
- return true;
22522
+ const markAppEntryForAutoRoutesTopology$1 = () => {
22523
+ return markAppEntryForAutoRoutesTopology(ctx, {
22524
+ loadEntry,
22525
+ resolvedEntryMap,
22526
+ markEntryDirty: (entryId) => markEntryDirtyWithCause(entryId, "direct", "auto-routes-topology")
22527
+ });
22107
22528
  };
22108
22529
  const addCssImporterEntries = async (startId) => {
22109
22530
  const { importers, scripts } = await collectAffectedScriptsAndImporters(ctx, startId);
@@ -22119,12 +22540,12 @@ async function processChangedFile(state, id, event) {
22119
22540
  ctx.runtimeState.build.hmr.vueEntryScriptSignatures.delete(normalizedId);
22120
22541
  }
22121
22542
  if ((event === "create" || isDeletedMissingSelf) && isAutoRouteFile) {
22122
- if (await ctx.autoRoutesService?.handleFileChange(normalizedId, event)) markAppEntryForAutoRoutesTopology();
22543
+ if (await ctx.autoRoutesService?.handleFileChange(normalizedId, event)) markAppEntryForAutoRoutesTopology$1();
22123
22544
  } else if ((event === "create" || isDeletedMissingSelf) && isAutoRoutesPagesRelatedChange(state, normalizedId)) {
22124
22545
  const didChangeRoutes = await ctx.autoRoutesService?.handleFileChange(normalizedId, event === "create" ? "create" : "delete");
22125
22546
  const currentSignature = ctx.autoRoutesService?.getSignature?.();
22126
22547
  const appEntrySignature = ctx.runtimeState.build.hmr.appEntryAutoRoutesSignature;
22127
- if (didChangeRoutes || typeof currentSignature === "string" && typeof appEntrySignature === "string" && currentSignature !== appEntrySignature) markAppEntryForAutoRoutesTopology();
22548
+ if (didChangeRoutes || typeof currentSignature === "string" && typeof appEntrySignature === "string" && currentSignature !== appEntrySignature) markAppEntryForAutoRoutesTopology$1();
22128
22549
  }
22129
22550
  if (event === "update" && isAppVueFile(normalizedId) && resolvedEntryMap.size) {
22130
22551
  const isJsonOnlyVueEntryUpdate = await isVueEntryJsonOnlyUpdate(state, normalizedId);
@@ -22263,7 +22684,9 @@ function createWatchChangeHook(state) {
22263
22684
  const event = await normalizeWatchEvent(normalizedId, change.event, {
22264
22685
  emittedJsonPaths: new Set([...state.jsonEmitFilesMap.values()].map((record) => record.entry.jsonPath ? normalizeFsResolvedId(record.entry.jsonPath) : "").filter(Boolean)),
22265
22686
  loadedEntrySet: state.loadedEntrySet,
22266
- resolvedEntryMap: state.resolvedEntryMap
22687
+ moduleImporters: state.moduleImporters,
22688
+ resolvedEntryMap: state.resolvedEntryMap,
22689
+ sharedChunkSourceModuleIds: state.ctx.runtimeState.build.hmr.sharedChunkSourceModuleIds
22267
22690
  });
22268
22691
  state.ctx.runtimeState.build.hmr.profile = {
22269
22692
  ...state.ctx.runtimeState.build.hmr.profile,
@@ -23961,6 +24384,13 @@ async function compileAndFinalizeVueLikeFile(options) {
23961
24384
  isApp: options.isApp
23962
24385
  });
23963
24386
  }
24387
+ function takeDirtyVueEntryId(dirtyVueEntryIds, filename) {
24388
+ if (!dirtyVueEntryIds?.size) return;
24389
+ const normalizedFilename = normalizeFsResolvedId(filename);
24390
+ if (dirtyVueEntryIds.has(filename)) return filename;
24391
+ if (dirtyVueEntryIds.has(normalizedFilename)) return normalizedFilename;
24392
+ for (const entryId of dirtyVueEntryIds) if (normalizeFsResolvedId(entryId) === normalizedFilename) return entryId;
24393
+ }
23964
24394
  async function refreshCompiledVueEntryCacheInDev(options) {
23965
24395
  const { filename, cached, ctx, pluginCtx, configService, compileOptionsState } = options;
23966
24396
  if (!configService.isDev) return cached.result;
@@ -23976,10 +24406,9 @@ async function refreshCompiledVueEntryCacheInDev(options) {
23976
24406
  };
23977
24407
  const source = transformed.source;
23978
24408
  const dirtyVueEntryIds = ctx.runtimeState?.build?.hmr?.dirtyVueEntryIds;
23979
- const normalizedDirtyFilename = normalizeFsResolvedId(filename);
23980
- if (!(dirtyVueEntryIds?.has(normalizedDirtyFilename) === true) && source === cached.source && transformed.signature === cached.autoRoutesSignature) {
24409
+ const dirtyEntryId = takeDirtyVueEntryId(dirtyVueEntryIds, filename);
24410
+ if (!dirtyEntryId && source === cached.source && transformed.signature === cached.autoRoutesSignature) {
23981
24411
  cached.refreshToken = 0;
23982
- dirtyVueEntryIds?.delete(normalizedDirtyFilename);
23983
24412
  return cached.result;
23984
24413
  }
23985
24414
  const compiled = await compileAndFinalizeVueLikeFile({
@@ -23995,7 +24424,7 @@ async function refreshCompiledVueEntryCacheInDev(options) {
23995
24424
  cached.source = source;
23996
24425
  cached.autoRoutesSignature = transformed.signature;
23997
24426
  cached.refreshToken = 0;
23998
- dirtyVueEntryIds?.delete(normalizedDirtyFilename);
24427
+ if (dirtyEntryId) dirtyVueEntryIds?.delete(dirtyEntryId);
23999
24428
  cached.result = compiled;
24000
24429
  return compiled;
24001
24430
  } catch {
@@ -24271,12 +24700,13 @@ function shouldReplaceAppScriptBundleEntry(options) {
24271
24700
  if (!isAppVueFile(options.filename) || !options.isDev || !options.hasDevHmrEvent) return false;
24272
24701
  return true;
24273
24702
  }
24274
- function hasModuleImportDeclaration(script) {
24703
+ function hasUnresolvedModuleImportDeclaration(script) {
24275
24704
  if (!script?.includes("import")) return false;
24276
24705
  try {
24277
24706
  let hasUnresolvedImport = false;
24278
24707
  traverse(parseJsLike(script), { ImportDeclaration(path) {
24279
- if (typeof path.node.source.value === "string") {
24708
+ const source = path.node.source.value;
24709
+ if (typeof source === "string" && !(source === "wevu" || source === "wevu/router" || source === "wevu/store" || source === "wevu/api" || source === "wevu/fetch" || source === "wevu/web-apis" || source === "wevu/internal-runtime" || source === "wevu/internal-reactivity" || source === "wevu/internal-template")) {
24280
24710
  hasUnresolvedImport = true;
24281
24711
  path.stop();
24282
24712
  }
@@ -24364,7 +24794,7 @@ async function emitResolvedCompiledVueEntryAssets(options) {
24364
24794
  runtimeFileName: ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileName,
24365
24795
  runtimeFileNames: ctx.runtimeState?.build?.output?.wevuInternalRuntimeFileNames
24366
24796
  });
24367
- if (hasModuleImportDeclaration(script)) return;
24797
+ if (hasUnresolvedModuleImportDeclaration(script)) return;
24368
24798
  emitSfcScriptAssetReplacingBundleEntry(pluginCtx, bundle, relativeBase, script, options.scriptExtension);
24369
24799
  retainReplacedDevHmrScriptChunk(state, scriptFileName);
24370
24800
  }
@@ -24828,8 +25258,10 @@ const VUE_LOAD_FILTER_RE = /^(?:\0weapp-vite:scoped-slot:|.*[?&]weapp-vite-vue(?
24828
25258
  const SCOPED_SLOT_VIRTUAL_ID_RE = /^\0weapp-vite:scoped-slot:/;
24829
25259
  function invalidateDirtyVueEntryCaches(dirtyVueEntryIds, compilationCache) {
24830
25260
  if (!dirtyVueEntryIds?.size) return;
25261
+ const cachedEntriesByNormalizedId = /* @__PURE__ */ new Map();
25262
+ for (const [cachedId, cached] of compilationCache.entries()) cachedEntriesByNormalizedId.set(normalizeFsResolvedId(cachedId), cached);
24831
25263
  for (const entryId of dirtyVueEntryIds) {
24832
- const cached = compilationCache.get(entryId);
25264
+ const cached = compilationCache.get(entryId) ?? cachedEntriesByNormalizedId.get(normalizeFsResolvedId(entryId));
24833
25265
  if (!cached) continue;
24834
25266
  cached.source = void 0;
24835
25267
  cached.refreshToken = (cached.refreshToken ?? 0) + 1;
@@ -26151,7 +26583,7 @@ async function loadAppEntry(ctx, scanState) {
26151
26583
  const vueAppPath = await findVueEntry(appBasename);
26152
26584
  let configFromVue;
26153
26585
  if (!appConfigFile && vueAppPath) {
26154
- const { extractConfigFromVue } = await import("./file-XBQU6P82.mjs");
26586
+ const { extractConfigFromVue } = await import("./file-DdqbRF9E.mjs");
26155
26587
  configFromVue = await extractConfigFromVue(vueAppPath);
26156
26588
  if (configFromVue) appConfigFile = vueAppPath;
26157
26589
  }
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-BQwQvqtl.mjs");
87
+ const { getCompilerContext } = await import("./getInstance-DTOa17Qa.mjs");
88
88
  const compilerContext = getCompilerContext();
89
89
  const service = compilerContext.autoRoutesService;
90
90
  const reference = service?.getReference?.();
@@ -0,0 +1,2 @@
1
+ import { t as extractConfigFromVue } from "./file-CuTGX59g.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { n as getCompilerContext } from "./createContext-C2Rk_kcI.mjs";
2
+ export { getCompilerContext };
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-BfOAQZMj.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-C2Rk_kcI.mjs";
5
5
  import { a as resolveLayoutHost, c as createWevuComponent, i as registerLayoutHosts, n as defineProps, o as unregisterLayoutHosts, r as setPageLayout, s as waitForLayoutHost, t as defineEmits } from "./runtime-CRoKWQZn.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, registerLayoutHosts, resolveLayoutHost, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.17.6",
4
+ "version": "6.17.8",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -110,7 +110,7 @@
110
110
  "package-manager-detector": "^1.6.0",
111
111
  "pathe": "^2.0.3",
112
112
  "picomatch": "^4.0.4",
113
- "postcss": "^8.5.15",
113
+ "postcss": "^8.5.16",
114
114
  "rolldown": "1.1.3",
115
115
  "rolldown-plugin-dts": "0.26.0",
116
116
  "semver": "^7.8.5",
@@ -124,7 +124,7 @@
124
124
  "@weapp-core/logger": "3.1.1",
125
125
  "@weapp-core/schematics": "6.0.4",
126
126
  "@weapp-core/shared": "3.0.5",
127
- "@weapp-vite/ast": "6.17.6",
127
+ "@weapp-vite/ast": "6.17.8",
128
128
  "@weapp-vite/mcp": "1.4.6",
129
129
  "@weapp-vite/miniprogram-automator": "1.2.5",
130
130
  "@weapp-vite/volar": "2.1.0",
@@ -134,7 +134,7 @@
134
134
  "rolldown-require": "2.0.19",
135
135
  "vite-plugin-performance": "2.0.1",
136
136
  "weapp-ide-cli": "5.4.10",
137
- "wevu": "6.17.6"
137
+ "wevu": "6.17.8"
138
138
  },
139
139
  "publishConfig": {
140
140
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-BOLzLiXg.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { n as getCompilerContext } from "./createContext-BfOAQZMj.mjs";
2
- export { getCompilerContext };