weapp-vite 6.16.8 → 6.16.9

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, i as getCompilerContext } from "./createContext-BLUytiY2.mjs";
1
+ import { g as getRouteRuntimeGlobalKeys, i as getCompilerContext } from "./createContext-BKbuGSJa.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 getDefaultIdeProjectRoot, S as createCjsConfigLoadError, T as isPathInside, _ as resolveWeappConfigFile, b as loadViteConfigFile, f as resolveWeappViteTarget, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, n as syncProjectSupportFiles, p as createSharedBuildConfig, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as checkRuntime, w as shouldPassPlatformArgToIdeOpen, x as parseCommentJson, y as getProjectConfigFileName } from "./createContext-BLUytiY2.mjs";
1
+ import { C as getDefaultIdeProjectRoot, S as createCjsConfigLoadError, T as isPathInside, _ as resolveWeappConfigFile, b as loadViteConfigFile, f as resolveWeappViteTarget, h as resolveHmrProfileJsonPath, m as SHARED_CHUNK_VIRTUAL_PREFIX, n as syncProjectSupportFiles, p as createSharedBuildConfig, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as checkRuntime, w as shouldPassPlatformArgToIdeOpen, x as parseCommentJson, y as getProjectConfigFileName } from "./createContext-BKbuGSJa.mjs";
2
2
  import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
3
- import { h as VERSION } from "./file-B6UGp073.mjs";
3
+ import { h as VERSION } from "./file-CKCR-PsP.mjs";
4
4
  import { o as resolveWeappMcpConfig, s as startWeappViteMcpServer } from "./mcp-DV3K2AVD.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import path, { posix } from "pathe";
@@ -3704,7 +3704,7 @@ function resolveRunnableHotkeyDefinition(input) {
3704
3704
  }
3705
3705
  //#endregion
3706
3706
  //#region package.json
3707
- var version = "6.16.8";
3707
+ var version = "6.16.9";
3708
3708
  //#endregion
3709
3709
  //#region src/cli/devHotkeys/format.ts
3710
3710
  const FULLWIDTH_ASCII_START = 65281;
@@ -1,6 +1,6 @@
1
1
  import { n as applyWeappViteHostMeta } from "./pluginHost-BEnGeaSo.mjs";
2
2
  import { n as configureLogger, r as logger_default } from "./logger-CgxdNjvb.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-B6UGp073.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-CKCR-PsP.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";
@@ -34,7 +34,7 @@ import { getPackageInfo, getPackageInfoSync, resolveModule } from "local-pkg";
34
34
  import { spawn } from "node:child_process";
35
35
  import * as t from "@weapp-vite/ast/babelTypes";
36
36
  import { objectHash } from "@weapp-core/shared/node";
37
- import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_GENERIC_SLOT_OWNER_ID_ATTR, WEVU_GENERIC_SLOT_OWNER_PROPS_ATTR, WEVU_GENERIC_SLOT_PROPS_ATTR, WEVU_GENERIC_SLOT_PROPS_DATA_ATTR, WEVU_GENERIC_SLOT_SCOPE_ATTR, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY } from "@weapp-core/constants";
37
+ import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_VITE_IMPORT_META_ENV_KEY, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEVU_APP_SHELL_COMPONENT_BASE, WEVU_APP_SHELL_TAG_NAME, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY } from "@weapp-core/constants";
38
38
  import { Buffer } from "node:buffer";
39
39
  import { detect } from "package-manager-detector/detect";
40
40
  import tsconfigPaths from "vite-tsconfig-paths";
@@ -13563,6 +13563,23 @@ async function collectNativeLayoutAssets(basePath) {
13563
13563
  };
13564
13564
  }
13565
13565
  //#endregion
13566
+ //#region src/plugins/vue/transform/pageLayout/slot.ts
13567
+ const SLOT_OPEN_TAG_RE = /<slot\b([^>]*)>/gi;
13568
+ const DEFAULT_SLOT_NAME_RE = /(?:^|\s)name\s*=/;
13569
+ function hasDefaultSlotTemplate(template) {
13570
+ if (!template) return false;
13571
+ for (const match of template.matchAll(SLOT_OPEN_TAG_RE)) {
13572
+ const attrs = match[1] ?? "";
13573
+ if (!DEFAULT_SLOT_NAME_RE.test(attrs)) return true;
13574
+ }
13575
+ return false;
13576
+ }
13577
+ function assertTemplateHasDefaultSlot(options) {
13578
+ if (hasDefaultSlotTemplate(options.template)) return;
13579
+ if (options.kind === "app-shell") throw new Error(`${options.filename} 中 app.vue <template> 必须包含默认 <slot />,否则页面内容无法渲染到应用外壳内。`);
13580
+ throw new Error(`${options.filename} 对应的 layout template 必须包含默认 <slot />,否则页面内容无法渲染到布局内。`);
13581
+ }
13582
+ //#endregion
13566
13583
  //#region src/plugins/utils/layoutEntries.ts
13567
13584
  async function registerResolvedPageLayoutEntries(options) {
13568
13585
  const { layouts, entries, explicitEntryTypes, nativeScriptEntries, normalizeEntry, jsonPath } = options;
@@ -18108,6 +18125,46 @@ function createSidecarIgnoredMatcher(ctx, rootDir) {
18108
18125
  };
18109
18126
  }
18110
18127
  //#endregion
18128
+ //#region src/plugins/vue/transform/appShell.ts
18129
+ const APP_VUE_FILE_RE = /[\\/]app\.vue$/;
18130
+ function isAppVueFile(filename) {
18131
+ return APP_VUE_FILE_RE.test(filename);
18132
+ }
18133
+ function hasAppShellTemplate(result) {
18134
+ return Boolean(result?.template?.trim());
18135
+ }
18136
+ function resolveAppShellBase(configService) {
18137
+ return path.join(configService.absoluteSrcRoot, WEVU_APP_SHELL_COMPONENT_BASE);
18138
+ }
18139
+ function resolveAppShellRelativeBase(configService) {
18140
+ return configService.relativeOutputPath(resolveAppShellBase(configService));
18141
+ }
18142
+ function resolveAppShellImportPath(configService) {
18143
+ const relativeBase = resolveAppShellRelativeBase(configService);
18144
+ return relativeBase ? `/${toPosixPath(relativeBase)}` : void 0;
18145
+ }
18146
+ function resolveAppShellLayout(configService) {
18147
+ const importPath = resolveAppShellImportPath(configService);
18148
+ if (!importPath) return;
18149
+ return {
18150
+ file: normalizeWatchPath(resolveAppShellBase(configService)),
18151
+ importPath,
18152
+ kind: "vue",
18153
+ layoutName: "app-shell",
18154
+ tagName: WEVU_APP_SHELL_TAG_NAME
18155
+ };
18156
+ }
18157
+ function applyAppShell(result, filename, appShell) {
18158
+ if (!appShell || !result.template) return result;
18159
+ return applyPageLayout(result, filename, {
18160
+ file: appShell.file,
18161
+ importPath: appShell.importPath,
18162
+ kind: "vue",
18163
+ layoutName: "app-shell",
18164
+ tagName: appShell.tagName
18165
+ });
18166
+ }
18167
+ //#endregion
18111
18168
  //#region src/plugins/core/lifecycle/watch.ts
18112
18169
  const configSuffixes = configExtensions.map((ext) => `.${ext}`);
18113
18170
  const styleSuffixes = supportedCssLangs.map((ext) => `.${ext}`);
@@ -18197,6 +18254,10 @@ async function processChangedFile(state, id, event) {
18197
18254
  if ((event === "create" || isDeletedMissingSelf) && isAutoRouteFile) {
18198
18255
  if (await ctx.autoRoutesService?.handleFileChange(normalizedId, event)) dirtyReasonStats.set("auto-routes-topology", 1);
18199
18256
  }
18257
+ if (event === "update" && isAppVueFile(normalizedId) && resolvedEntryMap.size) for (const entryId of resolvedEntryMap.keys()) {
18258
+ if (entryId === normalizedId) continue;
18259
+ markEntryDirtyWithCause(entryId, "dependency", "app-shell-dependent");
18260
+ }
18200
18261
  invalidateFileCache(normalizedId);
18201
18262
  if (event === "update") {
18202
18263
  const isTemplateFile = isTemplate(normalizedId);
@@ -19205,8 +19266,8 @@ function buildScopedSlotComponentModule(options) {
19205
19266
  const lines = [
19206
19267
  `import { ${computedCode ? `${WE_VU_RUNTIME_APIS.createWevuScopedSlotComponent} as _createWevuScopedSlotComponent, normalizeClass as __wevuNormalizeClass, normalizeStyle as __wevuNormalizeStyle, unref as __wevuUnref` : `${WE_VU_RUNTIME_APIS.createWevuScopedSlotComponent} as _createWevuScopedSlotComponent`} } from '${WE_VU_MODULE_ID}';`,
19207
19268
  "const globalObject = typeof globalThis !== 'undefined' ? globalThis : undefined;",
19208
- `const createWevuScopedSlotComponent = _createWevuScopedSlotComponent`,
19209
- ` ?? globalObject?.${WEVU_SCOPED_SLOT_CREATOR_KEY};`
19269
+ `const createWevuScopedSlotComponent = globalObject?.${WEVU_SCOPED_SLOT_CREATOR_KEY}`,
19270
+ " ?? _createWevuScopedSlotComponent;"
19210
19271
  ];
19211
19272
  if (computedCode) lines.push(`const __wevuComputed = ${computedCode};`);
19212
19273
  if (inlineMapCode) lines.push(`const __wevuInlineMap = ${inlineMapCode};`);
@@ -19588,18 +19649,6 @@ function scanWxml(wxml, options) {
19588
19649
  const LEADING_DOT_SLASH_RE$1 = /^\.\//;
19589
19650
  const SCOPED_SLOT_GENERIC_KEY_RE = /^scoped-slots-/;
19590
19651
  const WEAPP_SCOPED_SLOT_GENERIC_PLACEHOLDER_TEMPLATE = "<view wx:if=\"{{false}}\" />";
19591
- const WEAPP_SCOPED_SLOT_GENERIC_PLACEHOLDER_SCRIPT = `Component({
19592
- properties: {
19593
- ${[
19594
- [WEVU_GENERIC_SLOT_OWNER_ID_ATTR, `{ type: String, value: '' }`],
19595
- [WEVU_GENERIC_SLOT_PROPS_ATTR, "{ type: null, value: null }"],
19596
- [WEVU_GENERIC_SLOT_PROPS_DATA_ATTR, "{ type: null, value: null }"],
19597
- [WEVU_GENERIC_SLOT_OWNER_PROPS_ATTR, "{ type: null, value: null }"],
19598
- [WEVU_GENERIC_SLOT_SCOPE_ATTR, "{ type: null, value: null }"]
19599
- ].map(([name, value]) => ` ${name}: ${value},`).join("\n")}
19600
- },
19601
- })
19602
- `;
19603
19652
  function resolveVueBundlePlatformOptions(options) {
19604
19653
  return {
19605
19654
  normalizeUsingComponents: resolveVueTransformJsonPlatformOptions({
@@ -19698,22 +19747,6 @@ function resolveAlipayGenericPlaceholderBase(relativeBase) {
19698
19747
  function resolveWeappScopedSlotGenericPlaceholderBase(relativeBase) {
19699
19748
  return resolveGenericPlaceholderBase(relativeBase, WEAPP_SCOPED_SLOT_GENERIC_COMPONENT_PLACEHOLDER);
19700
19749
  }
19701
- function emitGenericPlaceholderScriptAsset(ctx, bundle, placeholderBase, scriptExtension, source) {
19702
- const fileName = resolveScriptlessComponentFileName(placeholderBase, scriptExtension);
19703
- const existing = bundle[fileName];
19704
- if (existing) {
19705
- if (existing.type === "asset") {
19706
- if ((existing.source?.toString?.() ?? "") !== source) existing.source = source;
19707
- }
19708
- return fileName;
19709
- }
19710
- ctx.emitFile({
19711
- type: "asset",
19712
- fileName,
19713
- source
19714
- });
19715
- return fileName;
19716
- }
19717
19750
  function emitAlipayGenericPlaceholderAssetsByBase(ctx, bundle, placeholderBase, outputExtensions, options) {
19718
19751
  const templateExtension = outputExtensions?.wxml ?? "wxml";
19719
19752
  const jsonExtension = outputExtensions?.json ?? "json";
@@ -19723,8 +19756,7 @@ function emitAlipayGenericPlaceholderAssetsByBase(ctx, bundle, placeholderBase,
19723
19756
  extension: jsonExtension,
19724
19757
  kind: "component"
19725
19758
  });
19726
- if (options?.scriptSource) emitGenericPlaceholderScriptAsset(ctx, bundle, placeholderBase, scriptExtension, options.scriptSource);
19727
- else ensureScriptlessComponentAsset(ctx, bundle, placeholderBase, scriptExtension);
19759
+ ensureScriptlessComponentAsset(ctx, bundle, placeholderBase, scriptExtension);
19728
19760
  }
19729
19761
  function shouldEmitAlipayGenericPlaceholder(configSource) {
19730
19762
  if (!configSource) return false;
@@ -19776,7 +19808,6 @@ function emitAlipayGenericPlaceholderAssets(ctx, bundle, relativeBase, configSou
19776
19808
  component: true,
19777
19809
  options: { virtualHost: true }
19778
19810
  },
19779
- scriptSource: WEAPP_SCOPED_SLOT_GENERIC_PLACEHOLDER_SCRIPT,
19780
19811
  templateSource: WEAPP_SCOPED_SLOT_GENERIC_PLACEHOLDER_TEMPLATE
19781
19812
  } : void 0);
19782
19813
  }
@@ -19806,7 +19837,6 @@ function emitPlatformConfigSideEffects(bundle, options) {
19806
19837
  component: true,
19807
19838
  options: { virtualHost: true }
19808
19839
  },
19809
- scriptSource: WEAPP_SCOPED_SLOT_GENERIC_PLACEHOLDER_SCRIPT,
19810
19840
  templateSource: WEAPP_SCOPED_SLOT_GENERIC_PLACEHOLDER_TEMPLATE
19811
19841
  } : void 0);
19812
19842
  return;
@@ -19885,7 +19915,8 @@ function resolveClassStyleWxsAsset(ctx, relativeBase, wxsExtension, configServic
19885
19915
  }
19886
19916
  function emitSharedVueEntryAssets(options) {
19887
19917
  const { bundle, pluginCtx, ctx, filename, relativeBase, result, configService, scriptModuleExtension, outputExtensions, platformAssetOptions, scopedSlotDefaults, scopedSlotMergeStrategy } = options;
19888
- if (result.template) emitPlatformTemplateAsset(bundle, {
19918
+ const isAppVue = APP_VUE_LIKE_FILE_RE$1.test(filename);
19919
+ if (result.template && !isAppVue) emitPlatformTemplateAsset(bundle, {
19889
19920
  ctx,
19890
19921
  pluginCtx,
19891
19922
  filename,
@@ -20398,9 +20429,7 @@ function injectPickIntoOptionsObject(optionsObject, keys) {
20398
20429
  * 从编译后的 WXML 模板提取渲染相关的顶层 key。
20399
20430
  */
20400
20431
  function collectSetDataPickKeysFromTemplate(template, options) {
20401
- const keys = new Set(collectSetDataPickKeysFromTemplateCode(template, options));
20402
- for (const key of options?.extraKeys ?? []) if (key) keys.add(key);
20403
- return [...keys].sort((a, b) => a.localeCompare(b));
20432
+ return collectSetDataPickKeysFromTemplateCode(template, options);
20404
20433
  }
20405
20434
  /**
20406
20435
  * 在 wevu 组件脚本中注入 setData.pick。
@@ -20531,7 +20560,7 @@ async function finalizeCompiledVueLikeResult(options) {
20531
20560
  if (injected.transformed) result.script = injected.code;
20532
20561
  }
20533
20562
  if (!isApp && result.script && result.template && isAutoSetDataPickEnabled(configService.weappViteConfig) && mayNeedInjectSetDataPickInJs(result.script)) {
20534
- const keys = collectSetDataPickKeysFromTemplate(result.template, { extraKeys: result.scopedSlotComponents?.flatMap((slot) => slot.ownerKeys ?? []) });
20563
+ const keys = collectSetDataPickKeysFromTemplate(result.template);
20535
20564
  const injectedPick = injectSetDataPickInJs(result.script, keys);
20536
20565
  if (injectedPick.transformed) result.script = injectedPick.code;
20537
20566
  }
@@ -20660,6 +20689,11 @@ async function emitResolvedNativeLayoutStaticAssets(options) {
20660
20689
  });
20661
20690
  for (const asset of staticAssetEntries) {
20662
20691
  if (asset.kind === "template") {
20692
+ assertTemplateHasDefaultSlot({
20693
+ filename: options.assets.template,
20694
+ kind: "page-layout",
20695
+ template: asset.source
20696
+ });
20663
20697
  emitSfcTemplateIfMissing(options.pluginCtx, options.bundle, options.resolvedOptions.relativeBase, asset.source, options.resolvedOptions.templateExtension);
20664
20698
  continue;
20665
20699
  }
@@ -20714,7 +20748,7 @@ async function emitVueLayoutScriptFallbackIfNeeded(options) {
20714
20748
  });
20715
20749
  if (!fallbackState) return;
20716
20750
  const { resolvedOptions } = fallbackState;
20717
- if ((await compileVueLikeFile({
20751
+ const result = await compileVueLikeFile({
20718
20752
  source: await fs.readFile(layoutFilePath, "utf-8"),
20719
20753
  filename: layoutFilePath,
20720
20754
  ctx,
@@ -20723,7 +20757,13 @@ async function emitVueLayoutScriptFallbackIfNeeded(options) {
20723
20757
  isApp: false,
20724
20758
  configService,
20725
20759
  compileOptionsState
20726
- })).script?.trim()) return;
20760
+ });
20761
+ assertTemplateHasDefaultSlot({
20762
+ filename: layoutFilePath,
20763
+ kind: "page-layout",
20764
+ template: result.template
20765
+ });
20766
+ if (result.script?.trim()) return;
20727
20767
  emitScriptlessComponentJsFallbackIfMissing({
20728
20768
  pluginCtx,
20729
20769
  bundle,
@@ -20764,6 +20804,62 @@ async function emitBundlePageLayoutsIfNeeded(options) {
20764
20804
  emitVueLayout: layoutEmitters.emitVueLayout
20765
20805
  });
20766
20806
  }
20807
+ function resolveAppShellComponentConfig(config) {
20808
+ const shellConfig = { styleIsolation: "apply-shared" };
20809
+ if (!config) return JSON.stringify(shellConfig, null, 2);
20810
+ try {
20811
+ const parsed = JSON.parse(config);
20812
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return JSON.stringify(shellConfig, null, 2);
20813
+ for (const key of ["usingComponents", "componentGenerics"]) {
20814
+ const value = parsed[key];
20815
+ if (value && typeof value === "object" && !Array.isArray(value)) shellConfig[key] = value;
20816
+ }
20817
+ return Object.keys(shellConfig).length ? JSON.stringify(shellConfig, null, 2) : void 0;
20818
+ } catch {
20819
+ return;
20820
+ }
20821
+ }
20822
+ function emitAppShellAssetsIfNeeded(options) {
20823
+ const { relativeBase, result } = options;
20824
+ if (!relativeBase || !result.template?.trim()) return;
20825
+ assertTemplateHasDefaultSlot({
20826
+ filename: options.filename,
20827
+ kind: "app-shell",
20828
+ template: result.template
20829
+ });
20830
+ emitBundleVueEntryAssets({
20831
+ bundle: options.bundle,
20832
+ pluginCtx: options.pluginCtx,
20833
+ ctx: options.ctx,
20834
+ filename: relativeBase,
20835
+ relativeBase,
20836
+ result,
20837
+ configService: options.configService,
20838
+ templateExtension: options.templateExtension,
20839
+ scriptModuleExtension: options.scriptModuleExtension,
20840
+ outputExtensions: options.outputExtensions,
20841
+ platformAssetOptions: options.platformAssetOptions
20842
+ });
20843
+ emitSharedVueEntryJsonAsset({
20844
+ bundle: options.bundle,
20845
+ pluginCtx: options.pluginCtx,
20846
+ relativeBase,
20847
+ config: resolveAppShellComponentConfig(result.config),
20848
+ outputExtensions: options.outputExtensions,
20849
+ platformAssetOptions: options.platformAssetOptions,
20850
+ jsonOptions: {
20851
+ defaultConfig: { component: true },
20852
+ kind: "component",
20853
+ extension: options.jsonExtension
20854
+ }
20855
+ });
20856
+ emitScriptlessComponentJsFallbackIfMissing({
20857
+ pluginCtx: options.pluginCtx,
20858
+ bundle: options.bundle,
20859
+ relativeBase,
20860
+ scriptExtension: options.scriptExtension
20861
+ });
20862
+ }
20767
20863
  //#endregion
20768
20864
  //#region src/plugins/vue/transform/bundle/emitCompiledEntry.ts
20769
20865
  async function emitResolvedCompiledVueEntryAssets(options) {
@@ -20771,22 +20867,45 @@ async function emitResolvedCompiledVueEntryAssets(options) {
20771
20867
  const { ctx, pluginCtx } = state;
20772
20868
  const { configService } = ctx;
20773
20869
  if (!configService) return;
20774
- if (cached.isPage && cached.source) await handleCompiledEntryPageLayouts({
20775
- source: cached.source,
20870
+ if (isAppVueFile(filename) && hasAppShellTemplate(result)) emitAppShellAssetsIfNeeded({
20871
+ bundle,
20872
+ pluginCtx,
20873
+ ctx,
20776
20874
  filename,
20875
+ relativeBase: resolveAppShellRelativeBase(configService),
20777
20876
  result,
20778
20877
  configService,
20779
- emitLayouts: async (layouts) => {
20780
- await emitBundlePageLayoutsIfNeeded({
20781
- layouts,
20782
- pluginCtx,
20783
- bundle,
20784
- ctx,
20785
- configService,
20786
- compileOptionsState,
20787
- outputExtensions: options.outputExtensions
20788
- });
20789
- }
20878
+ templateExtension: options.templateExtension,
20879
+ jsonExtension: options.jsonExtension,
20880
+ scriptExtension: options.scriptExtension,
20881
+ scriptModuleExtension: options.scriptModuleExtension,
20882
+ outputExtensions: options.outputExtensions,
20883
+ platformAssetOptions: options.platformAssetOptions
20884
+ });
20885
+ if (cached.isPage && cached.source) {
20886
+ await handleCompiledEntryPageLayouts({
20887
+ source: cached.source,
20888
+ filename,
20889
+ result,
20890
+ configService,
20891
+ emitLayouts: async (layouts) => {
20892
+ await emitBundlePageLayoutsIfNeeded({
20893
+ layouts,
20894
+ pluginCtx,
20895
+ bundle,
20896
+ ctx,
20897
+ configService,
20898
+ compileOptionsState,
20899
+ outputExtensions: options.outputExtensions
20900
+ });
20901
+ }
20902
+ });
20903
+ applyAppShell(result, filename, state.appShell);
20904
+ }
20905
+ if (isLayoutFile(filename, configService)) assertTemplateHasDefaultSlot({
20906
+ filename,
20907
+ kind: "page-layout",
20908
+ template: result.template
20790
20909
  });
20791
20910
  const { shouldEmitComponentJson } = emitCompiledEntryBundleAssets({
20792
20911
  bundle,
@@ -20905,6 +21024,7 @@ async function emitResolvedFallbackPageEntryAssets(options) {
20905
21024
  });
20906
21025
  }
20907
21026
  });
21027
+ applyAppShell(result, options.entryFilePath, options.appShell);
20908
21028
  emitFallbackPageBundleAssets({
20909
21029
  bundle: options.bundle,
20910
21030
  pluginCtx: options.pluginCtx,
@@ -20958,7 +21078,8 @@ async function emitFallbackPageAssets(bundle, state) {
20958
21078
  jsonExtension,
20959
21079
  scriptModuleExtension,
20960
21080
  outputExtensions,
20961
- platformAssetOptions
21081
+ platformAssetOptions,
21082
+ appShell: state.appShell
20962
21083
  });
20963
21084
  } catch (error) {
20964
21085
  const message = error instanceof Error ? error.message : String(error);
@@ -20972,6 +21093,9 @@ function resolveVueBundleEmitState(state) {
20972
21093
  const { ctx, compilationCache } = state;
20973
21094
  const { configService, scanService } = ctx;
20974
21095
  if (!configService || !scanService) return;
21096
+ state.appShell = Array.from(compilationCache.entries()).find(([filename, cached]) => {
21097
+ return isAppVueFile(filename) && hasAppShellTemplate(cached.result);
21098
+ }) ? resolveAppShellLayout(configService) : void 0;
20975
21099
  const emittedEntryIds = Boolean(configService.isDev && ctx.runtimeState?.build?.hmr?.profile?.event === "update" && !ctx.runtimeState.build.hmr.didEmitAllEntries && ctx.runtimeState.build.hmr.lastEmittedEntryIds.size > 0) ? ctx.runtimeState.build.hmr.lastEmittedEntryIds : void 0;
20976
21100
  return { compilationEntries: Array.from(compilationCache.entries()).filter(([id]) => {
20977
21101
  return !emittedEntryIds || emittedEntryIds.has(normalizeFsResolvedId(id));
@@ -21278,10 +21402,7 @@ async function finalizeTransformEntryScript(options) {
21278
21402
  }
21279
21403
  }
21280
21404
  if (!isApp && result.script && result.template && isAutoSetDataPickEnabled(configService.weappViteConfig) && mayNeedTransformSetDataPick(result.template, { platform: configService.platform }) && mayNeedInjectSetDataPickInJs(result.script)) {
21281
- const keys = collectSetDataPickKeysFromTemplate(result.template, {
21282
- astEngine: resolveAstEngine(configService.weappViteConfig),
21283
- extraKeys: result.scopedSlotComponents?.flatMap((slot) => slot.ownerKeys ?? [])
21284
- });
21405
+ const keys = collectSetDataPickKeysFromTemplate(result.template, { astEngine: resolveAstEngine(configService.weappViteConfig) });
21285
21406
  const injectedPick = injectSetDataPickInJs(result.script, keys);
21286
21407
  if (injectedPick.transformed) {
21287
21408
  result.script = injectedPick.code;
@@ -21329,7 +21450,7 @@ async function compileTransformEntryResult(options) {
21329
21450
  return filename.endsWith(".vue") ? await compileVueFile(transformedSource, filename, compileOptions) : await compileJsxFile(transformedSource, filename, compileOptions);
21330
21451
  }
21331
21452
  async function finalizeTransformCompiledResult(options) {
21332
- const { ctx, pluginCtx, filename, source, result, compilationCache, configService, isPage, isApp, scopedSlotModules, emittedScopedSlotChunks, addWatchFile, emitScopedSlotChunks } = options;
21453
+ const { ctx, pluginCtx, filename, source, result, compilationCache, setAppShell, configService, isPage, isApp, scopedSlotModules, emittedScopedSlotChunks, addWatchFile, emitScopedSlotChunks } = options;
21333
21454
  const transformResult = result;
21334
21455
  if (isPage && result.template) await handleTransformEntryPageLayoutFlow({
21335
21456
  pluginCtx,
@@ -21338,7 +21459,8 @@ async function finalizeTransformCompiledResult(options) {
21338
21459
  source,
21339
21460
  result
21340
21461
  });
21341
- registerVueTemplateToken(ctx, filename, result.template);
21462
+ if (isApp) setAppShell?.(hasAppShellTemplate(result) ? resolveAppShellLayout(configService) : void 0);
21463
+ if (!isApp) registerVueTemplateToken(ctx, filename, result.template);
21342
21464
  if (Array.isArray(result.meta?.sfcSrcDeps) && typeof pluginCtx.addWatchFile === "function") for (const dep of result.meta.sfcSrcDeps) addWatchFile(pluginCtx, dep);
21343
21465
  await finalizeTransformEntryScript({
21344
21466
  result: transformResult,
@@ -21430,7 +21552,7 @@ const wevu = wevuPlugin;
21430
21552
  //#endregion
21431
21553
  //#region src/plugins/vue/transform/plugin/transformFile.ts
21432
21554
  async function transformVueLikeFile(options) {
21433
- const { ctx, pluginCtx, code, id, compilationCache, pageMatcher, setPageMatcher, scanDirtySynced, setScanDirtySynced, reExportResolutionCache, compileOptionsCache, styleBlocksCache, scopedSlotModules, emittedScopedSlotChunks, classStyleRuntimeWarned, readAndParseSfc, createReadAndParseSfcOptions } = options;
21555
+ const { ctx, pluginCtx, code, id, compilationCache, setAppShell, pageMatcher, setPageMatcher, scanDirtySynced, setScanDirtySynced, reExportResolutionCache, compileOptionsCache, styleBlocksCache, scopedSlotModules, emittedScopedSlotChunks, classStyleRuntimeWarned, readAndParseSfc, createReadAndParseSfcOptions } = options;
21434
21556
  const vueTransformTiming = ctx.configService?.weappViteConfig?.debug?.vueTransformTiming;
21435
21557
  const { measureStage, reportTiming } = createTransformStageMeasurer(vueTransformTiming);
21436
21558
  const configService = ctx.configService;
@@ -21500,6 +21622,7 @@ async function transformVueLikeFile(options) {
21500
21622
  source: transformedSource,
21501
21623
  result,
21502
21624
  compilationCache,
21625
+ setAppShell,
21503
21626
  configService,
21504
21627
  isPage,
21505
21628
  isApp,
@@ -21531,6 +21654,7 @@ async function transformVueLikeFile(options) {
21531
21654
  //#region src/plugins/vue/transform/plugin/index.ts
21532
21655
  function createVueTransformPlugin(ctx) {
21533
21656
  const compilationCache = /* @__PURE__ */ new Map();
21657
+ let appShell;
21534
21658
  let pageMatcher = null;
21535
21659
  let scanDirtySynced = false;
21536
21660
  const reExportResolutionCache = /* @__PURE__ */ new Map();
@@ -21586,6 +21710,7 @@ function createVueTransformPlugin(ctx) {
21586
21710
  code,
21587
21711
  id,
21588
21712
  compilationCache,
21713
+ setAppShell: (shell) => appShell = shell,
21589
21714
  pageMatcher,
21590
21715
  setPageMatcher: (matcher) => pageMatcher = matcher,
21591
21716
  scanDirtySynced,
@@ -21608,6 +21733,7 @@ function createVueTransformPlugin(ctx) {
21608
21733
  ctx,
21609
21734
  pluginCtx: this,
21610
21735
  compilationCache,
21736
+ appShell,
21611
21737
  reExportResolutionCache,
21612
21738
  compileOptionsCache,
21613
21739
  classStyleRuntimeWarned
@@ -22957,7 +23083,7 @@ async function loadAppEntry(ctx, scanState) {
22957
23083
  const vueAppPath = await findVueEntry(appBasename);
22958
23084
  let configFromVue;
22959
23085
  if (!appConfigFile && vueAppPath) {
22960
- const { extractConfigFromVue } = await import("./file-Dhy30jgW.mjs");
23086
+ const { extractConfigFromVue } = await import("./file-Cj1AceWV.mjs");
22961
23087
  configFromVue = await extractConfigFromVue(vueAppPath);
22962
23088
  if (configFromVue) appConfigFile = vueAppPath;
22963
23089
  }
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
84
84
  }
85
85
  async function resolveAutoRoutesInlineSnapshot() {
86
86
  try {
87
- const { getCompilerContext } = await import("./getInstance-CJR0kbLn.mjs");
87
+ const { getCompilerContext } = await import("./getInstance-iZ7e_smp.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-CKCR-PsP.mjs";
2
+ export { extractConfigFromVue };
@@ -0,0 +1,2 @@
1
+ import { i as getCompilerContext } from "./createContext-BKbuGSJa.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-D0HkutE0.mjs";
2
2
  import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BEnGeaSo.mjs";
3
3
  import { t as defineConfig } from "./config-DJjSbpNX.mjs";
4
- import { c as WEB_PLATFORM_ALIASES, d as isWebPlatform, f as resolveWeappViteTarget, l as getSupportedWeappVitePlatforms, t as createCompilerContext, u as getSupportedWeappViteTargetDescriptors } from "./createContext-BLUytiY2.mjs";
4
+ import { c as WEB_PLATFORM_ALIASES, d as isWebPlatform, f as resolveWeappViteTarget, l as getSupportedWeappVitePlatforms, t as createCompilerContext, u as getSupportedWeappViteTargetDescriptors } from "./createContext-BKbuGSJa.mjs";
5
5
  import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-spnjzaP2.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "6.16.8",
4
+ "version": "6.16.9",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -117,22 +117,22 @@
117
117
  "vite-tsconfig-paths": "^6.1.1",
118
118
  "vue": "^3.5.34",
119
119
  "vue-tsc": "^3.2.8",
120
- "@weapp-core/constants": "^0.1.5",
120
+ "@weapp-core/constants": "^0.1.6",
121
121
  "@weapp-core/init": "6.0.8",
122
122
  "@weapp-core/logger": "3.1.1",
123
123
  "@weapp-core/schematics": "6.0.4",
124
124
  "@weapp-core/shared": "3.0.4",
125
- "@weapp-vite/ast": "6.16.8",
125
+ "@weapp-vite/ast": "6.16.9",
126
126
  "@weapp-vite/mcp": "1.3.2",
127
127
  "@weapp-vite/miniprogram-automator": "1.1.0",
128
128
  "@weapp-vite/volar": "2.1.0",
129
129
  "@weapp-vite/web": "1.3.20",
130
130
  "@wevu/api": "0.2.8",
131
131
  "@wevu/web-apis": "1.2.12",
132
- "vite-plugin-performance": "2.0.1",
133
132
  "rolldown-require": "2.0.15",
133
+ "vite-plugin-performance": "2.0.1",
134
134
  "weapp-ide-cli": "5.2.9",
135
- "wevu": "6.16.8"
135
+ "wevu": "6.16.9"
136
136
  },
137
137
  "publishConfig": {
138
138
  "access": "public",
@@ -1,2 +0,0 @@
1
- import { t as extractConfigFromVue } from "./file-B6UGp073.mjs";
2
- export { extractConfigFromVue };
@@ -1,2 +0,0 @@
1
- import { i as getCompilerContext } from "./createContext-BLUytiY2.mjs";
2
- export { getCompilerContext };