weapp-vite 6.17.1 → 6.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/{createContext-Dg_HER2J.mjs → createContext-Bm3wVI4b.mjs} +48 -3
- package/dist/file-BZkl3L_r.mjs +2 -0
- package/dist/{file-CtueODLX.mjs → file-kdAYpUO6.mjs} +1 -1
- package/dist/getInstance-CQ6SnI35.mjs +2 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/runtime-CRoKWQZn.mjs +122 -0
- package/dist/{runtime-CDNs17Qq.d.mts → runtime-xQwLUxkz.d.mts} +32 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.mjs +2 -2
- package/package.json +13 -13
- package/dist/file-C206GmuT.mjs +0 -2
- package/dist/getInstance-Dw7Y4EkD.mjs +0 -2
- package/dist/runtime-C3z9pDQB.mjs +0 -60
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-
|
|
1
|
+
import { g as getRouteRuntimeGlobalKeys, n as getCompilerContext } from "./createContext-Bm3wVI4b.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-
|
|
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-Bm3wVI4b.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-mt4mSTqV.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
3
|
+
import { h as VERSION } from "./file-kdAYpUO6.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";
|
|
@@ -4024,7 +4024,7 @@ function resolveRunnableHotkeyDefinition(input) {
|
|
|
4024
4024
|
}
|
|
4025
4025
|
//#endregion
|
|
4026
4026
|
//#region package.json
|
|
4027
|
-
var version = "6.17.
|
|
4027
|
+
var version = "6.17.2";
|
|
4028
4028
|
//#endregion
|
|
4029
4029
|
//#region src/cli/devHotkeys/format.ts
|
|
4030
4030
|
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-
|
|
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-kdAYpUO6.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";
|
|
@@ -10453,6 +10453,7 @@ function createAdvancedChunkNameResolver(options) {
|
|
|
10453
10453
|
const REG_NODE_MODULES_DIR = /[\\/]node_modules[\\/]/gi;
|
|
10454
10454
|
const REG_COMMONJS_HELPERS = /commonjsHelpers\.js$/;
|
|
10455
10455
|
const REG_REQUEST_GLOBAL_RUNTIME_VENDOR_ID = /(?:^|[/\\])(?:@wevu[/\\]web-apis|web-apis[/\\]dist[/\\]index\.(?:m?js|cjs)|weapp-vite[/\\](?:dist[/\\]web-apis\.mjs|src[/\\](?:webApis\.ts|runtime[/\\]webApis[/\\]index\.ts)))(?:$|[?#])/;
|
|
10456
|
+
const REG_WEAPP_VITE_RUNTIME_VENDOR_ID = /(?:^|[/\\])weapp-vite[/\\](?:dist[/\\]runtime\.mjs|src[/\\]plugins[/\\]vue[/\\]runtime\.ts)(?:$|[?#])/;
|
|
10456
10457
|
const REG_HASHED_DIST_CHUNK_ID = /(?:^|[/\\])dist[/\\](?:dev[/\\])?([^/\\-]+)-([\w-]{6,})\.(?:m?js|cjs)(?:$|[?#])/;
|
|
10457
10458
|
const STABLE_HASHED_DIST_CHUNK_PRIORITY = ["src"];
|
|
10458
10459
|
function resolveSharedPathRoot(configService, sharedPathRoot) {
|
|
@@ -10563,11 +10564,17 @@ function isRequestGlobalsRuntimeModuleId(id) {
|
|
|
10563
10564
|
if (REG_REQUEST_GLOBAL_RUNTIME_VENDOR_ID.test(cleanedAbsoluteId)) return true;
|
|
10564
10565
|
return resolveDistChunkPackageToken(cleanedAbsoluteId)?.endsWith("web-apis") === true;
|
|
10565
10566
|
}
|
|
10567
|
+
function isWeappViteRuntimeModuleId(id) {
|
|
10568
|
+
const cleanedAbsoluteId = normalizeSharedPathCandidate(id);
|
|
10569
|
+
REG_WEAPP_VITE_RUNTIME_VENDOR_ID.lastIndex = 0;
|
|
10570
|
+
return REG_WEAPP_VITE_RUNTIME_VENDOR_ID.test(cleanedAbsoluteId);
|
|
10571
|
+
}
|
|
10566
10572
|
function resolveStableHashedDistChunkFileName(chunk) {
|
|
10567
10573
|
const candidateIds = [chunk.facadeModuleId, ...chunk.moduleIds ?? []].filter((id) => typeof id === "string");
|
|
10568
10574
|
const matchedChunks = [];
|
|
10569
10575
|
let facadeMatchedChunk;
|
|
10570
10576
|
for (const id of candidateIds) {
|
|
10577
|
+
if (isWeappViteRuntimeModuleId(id)) return "weapp-vendors/weapp-vite-runtime.js";
|
|
10571
10578
|
const cleanedAbsoluteId = normalizeSharedPathCandidate(id);
|
|
10572
10579
|
if (!path.isAbsolute(cleanedAbsoluteId)) continue;
|
|
10573
10580
|
const matched = cleanedAbsoluteId.match(REG_HASHED_DIST_CHUNK_ID);
|
|
@@ -10616,6 +10623,7 @@ function createSharedBuildResolver(configService, getSubPackageRoots) {
|
|
|
10616
10623
|
});
|
|
10617
10624
|
const resolveSharedBuildChunkName = (id, ctx) => {
|
|
10618
10625
|
if (isRequestGlobalsRuntimeModuleId(id)) return REQUEST_GLOBAL_RUNTIME_CHUNK_FILE_BASENAME.replace(/\.js$/, "");
|
|
10626
|
+
if (isWeappViteRuntimeModuleId(id)) return "weapp-vendors/weapp-vite-runtime";
|
|
10619
10627
|
if (configService.isDev) {
|
|
10620
10628
|
const stableHashedDistChunkName = resolveStableHashedDistChunkName({ facadeModuleId: id });
|
|
10621
10629
|
if (stableHashedDistChunkName) return stableHashedDistChunkName;
|
|
@@ -19436,11 +19444,13 @@ function pruneUnchangedDevHmrOutputs(ctx, bundle, rewriteOptions) {
|
|
|
19436
19444
|
const cache = ctx.runtimeState?.build?.output?.emittedSource;
|
|
19437
19445
|
if (!ctx.configService?.isDev || !cache) return;
|
|
19438
19446
|
const isHmrBuild = ctx.runtimeState?.build?.hmr?.profile?.event !== void 0;
|
|
19447
|
+
const emittedChunkFileNames = ctx.runtimeState?.build?.hmr?.lastEmittedChunkFileNames;
|
|
19439
19448
|
rewriteWevuInternalRuntimeImports(bundle, rewriteOptions);
|
|
19440
19449
|
pruneUneventedDevHmrChunks(ctx, bundle);
|
|
19441
19450
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
19442
19451
|
const source = outputSourceToString(output);
|
|
19443
|
-
|
|
19452
|
+
const shouldForceEmitCurrentHmrChunk = isHmrBuild && output.type === "chunk" && (emittedChunkFileNames?.has(fileName) === true || emittedChunkFileNames?.has(output.fileName) === true);
|
|
19453
|
+
if (isHmrBuild && !shouldForceEmitCurrentHmrChunk && cache.get(fileName) === source) {
|
|
19444
19454
|
delete bundle[fileName];
|
|
19445
19455
|
continue;
|
|
19446
19456
|
}
|
|
@@ -20582,6 +20592,33 @@ function isAssetOnlyDevHmrBundle(bundle, state) {
|
|
|
20582
20592
|
function isStableHmrSharedChunk(fileName) {
|
|
20583
20593
|
return fileName.startsWith("weapp-vendors/") || !fileName.includes("/") && fileName !== "app.js";
|
|
20584
20594
|
}
|
|
20595
|
+
function isRuntimeVendorSharedChunk(fileName) {
|
|
20596
|
+
return fileName.startsWith("weapp-vendors/") && /(?:^|[-/])[\w-]*runtime[\w-]*(?:[-.]|$)/.test(fileName);
|
|
20597
|
+
}
|
|
20598
|
+
function resolveImportedChunkId(importerFileName, imported) {
|
|
20599
|
+
if (!imported.startsWith(".")) return imported;
|
|
20600
|
+
const importerSegments = importerFileName.split("/");
|
|
20601
|
+
importerSegments.pop();
|
|
20602
|
+
for (const segment of imported.split("/")) {
|
|
20603
|
+
if (!segment || segment === ".") continue;
|
|
20604
|
+
if (segment === "..") {
|
|
20605
|
+
importerSegments.pop();
|
|
20606
|
+
continue;
|
|
20607
|
+
}
|
|
20608
|
+
importerSegments.push(segment);
|
|
20609
|
+
}
|
|
20610
|
+
return importerSegments.join("/");
|
|
20611
|
+
}
|
|
20612
|
+
function isImportedByActiveHmrChunk(fileName, bundle, activeEntryIds) {
|
|
20613
|
+
if (!activeEntryIds?.size) return false;
|
|
20614
|
+
for (const output of Object.values(bundle)) {
|
|
20615
|
+
if (output?.type !== "chunk") continue;
|
|
20616
|
+
const chunk = output;
|
|
20617
|
+
if (!chunk.facadeModuleId || !activeEntryIds.has(chunk.facadeModuleId)) continue;
|
|
20618
|
+
if ([...Array.isArray(chunk.imports) ? chunk.imports : [], ...Array.isArray(chunk.dynamicImports) ? chunk.dynamicImports : []].some((imported) => resolveImportedChunkId(chunk.fileName, imported) === fileName)) return true;
|
|
20619
|
+
}
|
|
20620
|
+
return false;
|
|
20621
|
+
}
|
|
20585
20622
|
function prunePartialHmrStableSharedChunks(bundle, state) {
|
|
20586
20623
|
if (!state.ctx.configService.isDev || !state.hmrState.hasBuiltOnce || state.hmrState.didEmitAllEntries || state.hmrState.skipSharedChunkRefresh || !state.hmrState.lastEmittedEntryIds?.size) return;
|
|
20587
20624
|
for (const [fileName, output] of Object.entries(bundle)) {
|
|
@@ -20592,6 +20629,14 @@ function prunePartialHmrStableSharedChunks(bundle, state) {
|
|
|
20592
20629
|
continue;
|
|
20593
20630
|
}
|
|
20594
20631
|
const activeEntryIds = state.hmrState.lastHmrEntryIds?.size ? state.hmrState.lastHmrEntryIds : state.hmrState.lastEmittedEntryIds;
|
|
20632
|
+
if (isRuntimeVendorSharedChunk(fileName) && isImportedByActiveHmrChunk(fileName, bundle, activeEntryIds)) {
|
|
20633
|
+
const emittedChunkFileNames = state.ctx.runtimeState?.build?.hmr?.lastEmittedChunkFileNames;
|
|
20634
|
+
if (emittedChunkFileNames) {
|
|
20635
|
+
emittedChunkFileNames.add(fileName);
|
|
20636
|
+
if (output.fileName) emittedChunkFileNames.add(output.fileName);
|
|
20637
|
+
}
|
|
20638
|
+
continue;
|
|
20639
|
+
}
|
|
20595
20640
|
if (!Array.from(knownImporters).every((entryId) => activeEntryIds?.has(entryId))) {
|
|
20596
20641
|
delete bundle[fileName];
|
|
20597
20642
|
continue;
|
|
@@ -25935,7 +25980,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
25935
25980
|
const vueAppPath = await findVueEntry(appBasename);
|
|
25936
25981
|
let configFromVue;
|
|
25937
25982
|
if (!appConfigFile && vueAppPath) {
|
|
25938
|
-
const { extractConfigFromVue } = await import("./file-
|
|
25983
|
+
const { extractConfigFromVue } = await import("./file-BZkl3L_r.mjs");
|
|
25939
25984
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
25940
25985
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
25941
25986
|
}
|
|
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
84
84
|
}
|
|
85
85
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
86
86
|
try {
|
|
87
|
-
const { getCompilerContext } = await import("./getInstance-
|
|
87
|
+
const { getCompilerContext } = await import("./getInstance-CQ6SnI35.mjs");
|
|
88
88
|
const compilerContext = getCompilerContext();
|
|
89
89
|
const service = compilerContext.autoRoutesService;
|
|
90
90
|
const reference = service?.getReference?.();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $n as WebPlatform, A as Ref, Bn as WeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Gn as ResolveWeappViteTargetOptions, Hn as createWeappViteHostMeta, I as RolldownPluginOption, Jn as WeappVitePlatform, Kn as ResolvedWeappViteTarget, L as RolldownWatchOptions, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Qn as WeappViteTargetKind, R as RolldownWatcher, S as CompilerContext, T as ConfigEnv, Un as isWeappViteHost, Vn as applyWeappViteHostMeta, Wn as resolveWeappViteHostMeta, Xn as WeappViteTargetDescriptor, Yn as WeappViteRuntime, Zn as WeappViteTargetInput, _ as definePageJson, a as UserConfigFnNoEnvPlain, at as WeappViteConfig, c as UserConfigFnPromise, d as Component, er as getSupportedWeappVitePlatforms, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, k as PluginOption, l as defineConfig, m as Theme, n as UserConfigExport, nr as isWebPlatform, o as UserConfigFnObject, p as Sitemap, qn as WEB_PLATFORM_ALIASES, r as UserConfigFn, rr as resolveWeappViteTarget, s as UserConfigFnObjectPlain, t as UserConfig, tr as getSupportedWeappViteTargetDescriptors, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer, zn as WEAPP_VITE_HOST_NAME } from "./config-Cxi7xvCa.mjs";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as LayoutHostContext, c as LayoutHostResolver, d as unregisterLayoutHosts, f as waitForLayoutHost, i as LayoutHostBridge, l as registerLayoutHosts, m as createWevuComponent, n as defineProps, o as LayoutHostEntry, p as WevuComponentOptions, r as setPageLayout, s as LayoutHostResolveOptions, t as defineEmits, u as resolveLayoutHost } from "./runtime-xQwLUxkz.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createContext.d.ts
|
|
5
5
|
interface CreateCompilerContextOptions extends Partial<LoadConfigOptions> {
|
|
@@ -12,4 +12,4 @@ interface CreateCompilerContextOptions extends Partial<LoadConfigOptions> {
|
|
|
12
12
|
*/
|
|
13
13
|
declare function createCompilerContext(options?: CreateCompilerContextOptions): Promise<CompilerContext>;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { type App, type Component, type ComputedDefinitions, type ConfigEnv, type InlineConfig, type MethodDefinitions, type Page, type Plugin, type PluginOption, type Ref, ResolveWeappViteTargetOptions, type ResolvedConfig, ResolvedWeappViteTarget, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, type ViteDevServer, WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, type WeappViteConfig, WeappViteHostMeta, WeappVitePlatform, WeappViteRuntime, WeappViteTargetDescriptor, WeappViteTargetInput, WeappViteTargetKind, WebPlatform, type WevuComponentOptions, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout };
|
|
15
|
+
export { type App, type Component, type ComputedDefinitions, type ConfigEnv, type InlineConfig, type LayoutHostBridge, type LayoutHostContext, type LayoutHostEntry, type LayoutHostResolveOptions, type LayoutHostResolver, type MethodDefinitions, type Page, type Plugin, type PluginOption, type Ref, ResolveWeappViteTargetOptions, type ResolvedConfig, ResolvedWeappViteTarget, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, type ViteDevServer, WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, type WeappViteConfig, WeappViteHostMeta, WeappVitePlatform, WeappViteRuntime, WeappViteTargetDescriptor, WeappViteTargetInput, WeappViteTargetKind, WebPlatform, type WevuComponentOptions, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, registerLayoutHosts, resolveLayoutHost, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
|
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-
|
|
5
|
-
import {
|
|
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 };
|
|
4
|
+
import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-Bm3wVI4b.mjs";
|
|
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
|
+
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 };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { createMiniProgramLayoutHostRegistry, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "@weapp-core/shared";
|
|
2
|
+
import { WEVU_PAGE_LAYOUT_SETTER_KEY } from "@weapp-core/constants";
|
|
3
|
+
import { defineComponent } from "wevu";
|
|
4
|
+
//#region src/plugins/vue/createWevuComponent.ts
|
|
5
|
+
/**
|
|
6
|
+
* 从 Vue SFC 的 options 创建 wevu 组件
|
|
7
|
+
* 同时支持 Vue 2 风格(Options API)与 Vue 3 风格(Composition API)
|
|
8
|
+
*
|
|
9
|
+
* 始终使用 defineComponent(其内部会调用小程序的 Component())。
|
|
10
|
+
* 在微信小程序中,Component() 可以同时定义页面与组件。
|
|
11
|
+
*/
|
|
12
|
+
function createWevuComponent(options) {
|
|
13
|
+
const { properties, ...restOptions } = options;
|
|
14
|
+
const mpOptions = {};
|
|
15
|
+
if (properties) mpOptions.properties = properties;
|
|
16
|
+
defineComponent({
|
|
17
|
+
...restOptions,
|
|
18
|
+
...mpOptions
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/plugins/vue/nativeLayoutHost.ts
|
|
23
|
+
const layoutHostRegistry = createMiniProgramLayoutHostRegistry();
|
|
24
|
+
function resolveCurrentPageInstance$1() {
|
|
25
|
+
if (!supportsMiniProgramRuntimeCapability(resolveMiniProgramPlatform(import.meta.env?.PLATFORM), "globalPageStack")) return;
|
|
26
|
+
const getCurrentPagesFn = globalThis.getCurrentPages;
|
|
27
|
+
if (typeof getCurrentPagesFn !== "function") return;
|
|
28
|
+
try {
|
|
29
|
+
const pages = getCurrentPagesFn();
|
|
30
|
+
return pages[pages.length - 1];
|
|
31
|
+
} catch {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function resolvePageKeys(page) {
|
|
36
|
+
return resolveMiniProgramPageKeys(page);
|
|
37
|
+
}
|
|
38
|
+
function resolvePageFromContext(context) {
|
|
39
|
+
return context ?? resolveCurrentPageInstance$1();
|
|
40
|
+
}
|
|
41
|
+
function resolveHostEntry(entry) {
|
|
42
|
+
return typeof entry === "function" ? entry() : entry;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 为当前原生 layout 注册宿主组件,页面可通过 resolveLayoutHost()/waitForLayoutHost() 访问。
|
|
46
|
+
*/
|
|
47
|
+
function registerLayoutHosts(hosts, context) {
|
|
48
|
+
const keys = Array.isArray(hosts) ? hosts : Object.keys(hosts);
|
|
49
|
+
if (!keys.length) return null;
|
|
50
|
+
const pageKeys = resolvePageKeys(resolvePageFromContext());
|
|
51
|
+
if (pageKeys.length === 0) return null;
|
|
52
|
+
const bridge = {
|
|
53
|
+
context,
|
|
54
|
+
keys,
|
|
55
|
+
resolveHost(key) {
|
|
56
|
+
if (!keys.includes(key)) return null;
|
|
57
|
+
if (!Array.isArray(hosts)) return resolveHostEntry(hosts[key]) ?? null;
|
|
58
|
+
return context?.selectComponent?.(key) ?? null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return layoutHostRegistry.register(keys, bridge, pageKeys) ? bridge : null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 移除当前原生 layout 注册的宿主组件。
|
|
65
|
+
*/
|
|
66
|
+
function unregisterLayoutHosts(bridge) {
|
|
67
|
+
if (!bridge) return false;
|
|
68
|
+
return layoutHostRegistry.unregisterBridge(bridge);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 解析当前页面 layout 内暴露的宿主组件。
|
|
72
|
+
*/
|
|
73
|
+
function resolveLayoutHost(key, options = {}) {
|
|
74
|
+
const page = resolvePageFromContext(options.context);
|
|
75
|
+
return layoutHostRegistry.resolveHost(key, resolvePageKeys(page), (bridge, key) => bridge.resolveHost(key));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 等待当前页面 layout 宿主组件可用。
|
|
79
|
+
*/
|
|
80
|
+
function waitForLayoutHost(key, options = {}) {
|
|
81
|
+
return layoutHostRegistry.waitForHost(key, () => resolvePageKeys(resolvePageFromContext(options.context)), (bridge, key) => bridge.resolveHost(key), options);
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/plugins/vue/nativePageLayout.ts
|
|
85
|
+
function resolveCurrentPageInstance() {
|
|
86
|
+
if (!supportsMiniProgramRuntimeCapability(resolveMiniProgramPlatform(import.meta.env?.PLATFORM), "globalPageStack")) return;
|
|
87
|
+
const getCurrentPagesFn = globalThis.getCurrentPages;
|
|
88
|
+
if (typeof getCurrentPagesFn !== "function") return;
|
|
89
|
+
try {
|
|
90
|
+
const pages = getCurrentPagesFn();
|
|
91
|
+
return pages[pages.length - 1];
|
|
92
|
+
} catch {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* 为原生 Page() 页面切换 layout。
|
|
98
|
+
*/
|
|
99
|
+
function setPageLayout(layout, props) {
|
|
100
|
+
const pageSetter = resolveCurrentPageInstance()?.[WEVU_PAGE_LAYOUT_SETTER_KEY];
|
|
101
|
+
if (typeof pageSetter === "function") {
|
|
102
|
+
pageSetter(layout, props);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
throw new Error("setPageLayout() 未找到当前页面实例。请在页面生命周期、事件回调或当前页面上下文中调用。");
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/plugins/vue/runtimeMacros.ts
|
|
109
|
+
/**
|
|
110
|
+
* 说明:Vue 3 风格的 props 声明(用于类型提示)
|
|
111
|
+
*/
|
|
112
|
+
function defineProps(props) {
|
|
113
|
+
return props;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* 说明:Vue 3 风格的 emits 声明(用于类型提示)
|
|
117
|
+
*/
|
|
118
|
+
function defineEmits(emits) {
|
|
119
|
+
return emits;
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { resolveLayoutHost as a, createWevuComponent as c, registerLayoutHosts as i, defineProps as n, unregisterLayoutHosts as o, setPageLayout as r, waitForLayoutHost as s, defineEmits as t };
|
|
@@ -21,6 +21,37 @@ interface WevuComponentOptions<D extends object = Record<string, any>, C extends
|
|
|
21
21
|
*/
|
|
22
22
|
declare function createWevuComponent(options: WevuComponentOptions): void;
|
|
23
23
|
//#endregion
|
|
24
|
+
//#region src/plugins/vue/nativeLayoutHost.d.ts
|
|
25
|
+
type LayoutHostContext = Record<string, any>;
|
|
26
|
+
type LayoutHostResolver = (key: string) => unknown;
|
|
27
|
+
type LayoutHostEntry = unknown | (() => unknown);
|
|
28
|
+
interface LayoutHostBridge {
|
|
29
|
+
context?: LayoutHostContext;
|
|
30
|
+
keys: string[];
|
|
31
|
+
resolveHost: LayoutHostResolver;
|
|
32
|
+
}
|
|
33
|
+
interface LayoutHostResolveOptions {
|
|
34
|
+
context?: LayoutHostContext;
|
|
35
|
+
interval?: number;
|
|
36
|
+
retries?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 为当前原生 layout 注册宿主组件,页面可通过 resolveLayoutHost()/waitForLayoutHost() 访问。
|
|
40
|
+
*/
|
|
41
|
+
declare function registerLayoutHosts(hosts: Record<string, LayoutHostEntry> | string[], context?: LayoutHostContext): LayoutHostBridge | null;
|
|
42
|
+
/**
|
|
43
|
+
* 移除当前原生 layout 注册的宿主组件。
|
|
44
|
+
*/
|
|
45
|
+
declare function unregisterLayoutHosts(bridge: LayoutHostBridge | null | undefined): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 解析当前页面 layout 内暴露的宿主组件。
|
|
48
|
+
*/
|
|
49
|
+
declare function resolveLayoutHost<T = any>(key: string, options?: LayoutHostResolveOptions): NonNullable<T> | null;
|
|
50
|
+
/**
|
|
51
|
+
* 等待当前页面 layout 宿主组件可用。
|
|
52
|
+
*/
|
|
53
|
+
declare function waitForLayoutHost<T = any>(key: string, options?: LayoutHostResolveOptions): Promise<T | null>;
|
|
54
|
+
//#endregion
|
|
24
55
|
//#region src/plugins/vue/nativePageLayout.d.ts
|
|
25
56
|
type ResolveTypedPageLayoutName = keyof WevuPageLayoutMap extends never ? string : Extract<keyof WevuPageLayoutMap, string>;
|
|
26
57
|
type ResolveTypedPageLayoutProps<Name extends string> = Name extends keyof WevuPageLayoutMap ? WevuPageLayoutMap[Name] : Record<string, any>;
|
|
@@ -37,4 +68,4 @@ declare function defineProps<T extends Record<string, any>>(props: T): T;
|
|
|
37
68
|
*/
|
|
38
69
|
declare function defineEmits<T extends Record<string, any> | string[]>(emits: T): T;
|
|
39
70
|
//#endregion
|
|
40
|
-
export {
|
|
71
|
+
export { LayoutHostContext as a, LayoutHostResolver as c, unregisterLayoutHosts as d, waitForLayoutHost as f, LayoutHostBridge as i, registerLayoutHosts as l, createWevuComponent as m, defineProps as n, LayoutHostEntry as o, WevuComponentOptions as p, setPageLayout as r, LayoutHostResolveOptions as s, defineEmits as t, resolveLayoutHost as u };
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { type WevuComponentOptions, createWevuComponent, defineEmits, defineProps, setPageLayout };
|
|
1
|
+
import { a as LayoutHostContext, c as LayoutHostResolver, d as unregisterLayoutHosts, f as waitForLayoutHost, i as LayoutHostBridge, l as registerLayoutHosts, m as createWevuComponent, n as defineProps, o as LayoutHostEntry, p as WevuComponentOptions, r as setPageLayout, s as LayoutHostResolveOptions, t as defineEmits, u as resolveLayoutHost } from "./runtime-xQwLUxkz.mjs";
|
|
2
|
+
export { type LayoutHostBridge, type LayoutHostContext, type LayoutHostEntry, type LayoutHostResolveOptions, type LayoutHostResolver, type WevuComponentOptions, createWevuComponent, defineEmits, defineProps, registerLayoutHosts, resolveLayoutHost, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { createWevuComponent, defineEmits, defineProps, setPageLayout };
|
|
1
|
+
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";
|
|
2
|
+
export { createWevuComponent, defineEmits, defineProps, registerLayoutHosts, resolveLayoutHost, 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.
|
|
4
|
+
"version": "6.17.2",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -119,22 +119,22 @@
|
|
|
119
119
|
"vite-tsconfig-paths": "^6.1.1",
|
|
120
120
|
"vue": "^3.5.38",
|
|
121
121
|
"vue-tsc": "^3.3.5",
|
|
122
|
-
"@weapp-core/
|
|
123
|
-
"@weapp-core/init": "6.0.10",
|
|
124
|
-
"@weapp-core/schematics": "6.0.4",
|
|
125
|
-
"@weapp-core/shared": "3.0.4",
|
|
122
|
+
"@weapp-core/init": "6.0.11",
|
|
126
123
|
"@weapp-core/logger": "3.1.1",
|
|
127
|
-
"@weapp-
|
|
124
|
+
"@weapp-core/schematics": "6.0.4",
|
|
125
|
+
"@weapp-core/constants": "0.1.12",
|
|
126
|
+
"@weapp-core/shared": "3.0.5",
|
|
127
|
+
"@weapp-vite/ast": "6.17.2",
|
|
128
128
|
"@weapp-vite/mcp": "1.4.6",
|
|
129
|
-
"@
|
|
129
|
+
"@weapp-vite/volar": "2.1.0",
|
|
130
130
|
"@weapp-vite/miniprogram-automator": "1.2.5",
|
|
131
|
-
"@
|
|
131
|
+
"@weapp-vite/web": "1.3.33",
|
|
132
|
+
"@wevu/api": "0.2.11",
|
|
133
|
+
"@wevu/web-apis": "1.2.25",
|
|
132
134
|
"rolldown-require": "2.0.19",
|
|
133
135
|
"vite-plugin-performance": "2.0.1",
|
|
134
|
-
"weapp-ide-cli": "5.4.
|
|
135
|
-
"
|
|
136
|
-
"wevu": "6.17.1",
|
|
137
|
-
"@weapp-vite/web": "1.3.32"
|
|
136
|
+
"weapp-ide-cli": "5.4.9",
|
|
137
|
+
"wevu": "6.17.2"
|
|
138
138
|
},
|
|
139
139
|
"publishConfig": {
|
|
140
140
|
"access": "public",
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"benchmark:auto-import:ci": "node --import tsx scripts/benchmark-auto-import-ci.ts",
|
|
160
160
|
"test:dev": "vitest",
|
|
161
161
|
"test": "vitest run",
|
|
162
|
-
"test:types": "cd test-d/auto-routes-define-app-json && tsd && cd ../config-define-config && tsd && cd ../internal-src-types && tsd",
|
|
162
|
+
"test:types": "cd test-d/auto-routes-define-app-json && tsd && cd ../config-define-config && tsd && cd ../internal-src-types && tsd && cd ../runtime-public-types && tsd",
|
|
163
163
|
"lint:src": "eslint src --ext .ts",
|
|
164
164
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
165
165
|
"sync": "cnpm sync weapp-vite"
|
package/dist/file-C206GmuT.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "@weapp-core/shared";
|
|
2
|
-
import { WEVU_PAGE_LAYOUT_SETTER_KEY } from "@weapp-core/constants";
|
|
3
|
-
import { defineComponent } from "wevu";
|
|
4
|
-
//#region src/plugins/vue/createWevuComponent.ts
|
|
5
|
-
/**
|
|
6
|
-
* 从 Vue SFC 的 options 创建 wevu 组件
|
|
7
|
-
* 同时支持 Vue 2 风格(Options API)与 Vue 3 风格(Composition API)
|
|
8
|
-
*
|
|
9
|
-
* 始终使用 defineComponent(其内部会调用小程序的 Component())。
|
|
10
|
-
* 在微信小程序中,Component() 可以同时定义页面与组件。
|
|
11
|
-
*/
|
|
12
|
-
function createWevuComponent(options) {
|
|
13
|
-
const { properties, ...restOptions } = options;
|
|
14
|
-
const mpOptions = {};
|
|
15
|
-
if (properties) mpOptions.properties = properties;
|
|
16
|
-
defineComponent({
|
|
17
|
-
...restOptions,
|
|
18
|
-
...mpOptions
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/plugins/vue/nativePageLayout.ts
|
|
23
|
-
function resolveCurrentPageInstance() {
|
|
24
|
-
if (!supportsMiniProgramRuntimeCapability(resolveMiniProgramPlatform(import.meta.env?.PLATFORM), "globalPageStack")) return;
|
|
25
|
-
const getCurrentPagesFn = globalThis.getCurrentPages;
|
|
26
|
-
if (typeof getCurrentPagesFn !== "function") return;
|
|
27
|
-
try {
|
|
28
|
-
const pages = getCurrentPagesFn();
|
|
29
|
-
return pages[pages.length - 1];
|
|
30
|
-
} catch {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 为原生 Page() 页面切换 layout。
|
|
36
|
-
*/
|
|
37
|
-
function setPageLayout(layout, props) {
|
|
38
|
-
const pageSetter = resolveCurrentPageInstance()?.[WEVU_PAGE_LAYOUT_SETTER_KEY];
|
|
39
|
-
if (typeof pageSetter === "function") {
|
|
40
|
-
pageSetter(layout, props);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
throw new Error("setPageLayout() 未找到当前页面实例。请在页面生命周期、事件回调或当前页面上下文中调用。");
|
|
44
|
-
}
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/plugins/vue/runtimeMacros.ts
|
|
47
|
-
/**
|
|
48
|
-
* 说明:Vue 3 风格的 props 声明(用于类型提示)
|
|
49
|
-
*/
|
|
50
|
-
function defineProps(props) {
|
|
51
|
-
return props;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* 说明:Vue 3 风格的 emits 声明(用于类型提示)
|
|
55
|
-
*/
|
|
56
|
-
function defineEmits(emits) {
|
|
57
|
-
return emits;
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
export { createWevuComponent as i, defineProps as n, setPageLayout as r, defineEmits as t };
|