weapp-vite 6.17.0 → 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 +128 -82
- package/dist/{createContext-C-aCFA7T.mjs → createContext-Bm3wVI4b.mjs} +84 -39
- package/dist/file-BZkl3L_r.mjs +2 -0
- package/dist/{file-Byezg0ta.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 +17 -17
- package/dist/file-BrdaHBHs.mjs +0 -2
- package/dist/getInstance-COXqNkGN.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";
|
|
@@ -285,8 +285,10 @@ function disconnectMiniProgram(miniProgram) {
|
|
|
285
285
|
}
|
|
286
286
|
async function openWechatIdeByAutomator(projectPath) {
|
|
287
287
|
disconnectMiniProgram(await launchAutomator({
|
|
288
|
+
persistAsDefaultSession: true,
|
|
288
289
|
preserveProjectRoot: true,
|
|
289
290
|
projectPath,
|
|
291
|
+
port: resolveProjectAutomatorPort(projectPath),
|
|
290
292
|
trustProject: true
|
|
291
293
|
}));
|
|
292
294
|
}
|
|
@@ -294,6 +296,7 @@ async function connectOpenedProject(projectPath) {
|
|
|
294
296
|
try {
|
|
295
297
|
return await connectOpenedAutomator({
|
|
296
298
|
projectPath,
|
|
299
|
+
port: resolveProjectAutomatorPort(projectPath),
|
|
297
300
|
timeout: 3e3
|
|
298
301
|
});
|
|
299
302
|
} catch {
|
|
@@ -345,11 +348,17 @@ function shouldLogAutomatorFallbackError() {
|
|
|
345
348
|
const flag = process.env.WEAPP_VITE_DEBUG_AUTOMATOR_OPEN;
|
|
346
349
|
return flag === "1" || flag === "true";
|
|
347
350
|
}
|
|
351
|
+
const PREPARE_AUTOMATOR_SESSION_TIMEOUT = 8e3;
|
|
352
|
+
const RESET_FILEUTILS_ENV = "WEAPP_VITE_RESET_IDE_FILEUTILS";
|
|
348
353
|
function isWechatIdeOpenRecoveryDisabled(options) {
|
|
349
354
|
if (options.openRecovery === false) return true;
|
|
350
355
|
const flag = process.env.WEAPP_VITE_DISABLE_IDE_OPEN_RECOVERY;
|
|
351
356
|
return flag === "1" || flag === "true";
|
|
352
357
|
}
|
|
358
|
+
function shouldResetWechatIdeFileUtils() {
|
|
359
|
+
const flag = process.env[RESET_FILEUTILS_ENV];
|
|
360
|
+
return flag === "1" || flag === "true";
|
|
361
|
+
}
|
|
353
362
|
/**
|
|
354
363
|
* @description 执行 IDE 打开流程,并在登录失效时允许按键重试。
|
|
355
364
|
*/
|
|
@@ -417,7 +426,7 @@ async function prepareOpenedWechatIdeAutomatorSession(projectPath, options) {
|
|
|
417
426
|
preserveProjectRoot: true,
|
|
418
427
|
projectPath,
|
|
419
428
|
port: resolveProjectAutomatorPort(projectPath),
|
|
420
|
-
timeout:
|
|
429
|
+
timeout: PREPARE_AUTOMATOR_SESSION_TIMEOUT,
|
|
421
430
|
trustProject: options.trustProject !== false
|
|
422
431
|
})).disconnect?.();
|
|
423
432
|
return { ok: true };
|
|
@@ -441,7 +450,7 @@ async function stabilizeOpenedWechatIdeProject(projectPath, servicePortEnabled,
|
|
|
441
450
|
reason: "service-port-disabled"
|
|
442
451
|
};
|
|
443
452
|
try {
|
|
444
|
-
await executeWechatIdeCliCommand(appendLoginRetryArgv([
|
|
453
|
+
if (shouldResetWechatIdeFileUtils()) await executeWechatIdeCliCommand(appendLoginRetryArgv([
|
|
445
454
|
"reset-fileutils",
|
|
446
455
|
"-p",
|
|
447
456
|
projectPath
|
|
@@ -548,7 +557,7 @@ async function openIde(platform, projectPath, options = {}) {
|
|
|
548
557
|
const openResult = await tryOpenWechatIdeByAutomator(projectPath, normalizedOptions);
|
|
549
558
|
if (openResult === "reused") return;
|
|
550
559
|
if (openResult) {
|
|
551
|
-
await verifyAndRecoverOpenedWechatIdeProject(platform, projectPath, bootstrapResult?.servicePortEnabled, normalizedOptions);
|
|
560
|
+
if (!normalizedOptions.skipPostOpenHealthCheck) await verifyAndRecoverOpenedWechatIdeProject(platform, projectPath, bootstrapResult?.servicePortEnabled, normalizedOptions);
|
|
552
561
|
return;
|
|
553
562
|
}
|
|
554
563
|
} catch (error) {
|
|
@@ -563,7 +572,8 @@ async function openIde(platform, projectPath, options = {}) {
|
|
|
563
572
|
if (!await closeIde()) logger_default.warn("关闭当前微信开发者工具失败,仍继续尝试打开目标项目。");
|
|
564
573
|
}
|
|
565
574
|
await runWechatIdeOpenWithRetry(createIdeOpenArgv(platform, projectPath, normalizedOptions));
|
|
566
|
-
if (platform === "weapp" && projectPath) await
|
|
575
|
+
if (platform === "weapp" && projectPath && normalizedOptions.prepareAutomatorSession) await prepareOpenedWechatIdeAutomatorSession(projectPath, normalizedOptions);
|
|
576
|
+
if (platform === "weapp" && projectPath && !normalizedOptions.skipPostOpenHealthCheck) await verifyAndRecoverOpenedWechatIdeProject(platform, projectPath, bootstrapResult?.servicePortEnabled, normalizedOptions);
|
|
567
577
|
}
|
|
568
578
|
/**
|
|
569
579
|
* @description 解析 IDE 相关命令所需的平台、项目目录与配置上下文。
|
|
@@ -962,7 +972,7 @@ function analyzeComponentUsage(options) {
|
|
|
962
972
|
visit(edge.component, page, nextStack);
|
|
963
973
|
}
|
|
964
974
|
};
|
|
965
|
-
for (const page of pages) visit(page, page, new Set([page]));
|
|
975
|
+
for (const page of pages) visit(page, page, /* @__PURE__ */ new Set([page]));
|
|
966
976
|
return Array.from(usageMap.values()).map((usage) => {
|
|
967
977
|
const pages = Array.from(usage.pages.values()).sort((left, right) => left.page.localeCompare(right.page));
|
|
968
978
|
const suggestions = [createComponentSuggestion(usage)].filter((item) => Boolean(item));
|
|
@@ -2511,7 +2521,7 @@ function resolveSubPackageRoot(fileName, roots) {
|
|
|
2511
2521
|
function collectPackageSizeReports(output, subPackageMap) {
|
|
2512
2522
|
const outputs = Array.isArray(output) ? output : [output];
|
|
2513
2523
|
const roots = [...subPackageMap?.keys() ?? []].filter(Boolean).sort((a, b) => b.length - a.length || a.localeCompare(b));
|
|
2514
|
-
const packageBytes = new Map([["__main__", 0]]);
|
|
2524
|
+
const packageBytes = /* @__PURE__ */ new Map([["__main__", 0]]);
|
|
2515
2525
|
for (const root of roots) packageBytes.set(root, 0);
|
|
2516
2526
|
for (const current of outputs) for (const item of current.output ?? []) {
|
|
2517
2527
|
const root = resolveSubPackageRoot(item.fileName, roots) ?? "__main__";
|
|
@@ -2853,6 +2863,56 @@ const DEFAULT_FORWARD_CONSOLE_LEVELS = [
|
|
|
2853
2863
|
let activeForwardConsoleSession;
|
|
2854
2864
|
const FORWARD_CONSOLE_RETRY_DELAY_MS = 1e3;
|
|
2855
2865
|
const FORWARD_CONSOLE_RETRY_TIMES = 5;
|
|
2866
|
+
async function detectAgent() {
|
|
2867
|
+
try {
|
|
2868
|
+
const result = await determineAgent();
|
|
2869
|
+
return {
|
|
2870
|
+
isAgent: result.isAgent,
|
|
2871
|
+
agentName: result.isAgent ? result.agent.name : void 0
|
|
2872
|
+
};
|
|
2873
|
+
} catch {
|
|
2874
|
+
return {
|
|
2875
|
+
isAgent: false,
|
|
2876
|
+
agentName: void 0
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
function formatForwardConsolePrefix(level, color) {
|
|
2881
|
+
const label = `[mini:${level.padEnd(5)}]`;
|
|
2882
|
+
if (!color) return label;
|
|
2883
|
+
if (level === "error") return colors.bold(colors.red(label));
|
|
2884
|
+
if (level === "warn") return colors.bold(colors.yellow(label));
|
|
2885
|
+
if (level === "info") return colors.bold(colors.cyan(label));
|
|
2886
|
+
if (level === "debug") return colors.dim(label);
|
|
2887
|
+
return colors.bold(colors.green(label));
|
|
2888
|
+
}
|
|
2889
|
+
function formatForwardConsoleMessage(level, message, color) {
|
|
2890
|
+
if (!color) return message;
|
|
2891
|
+
if (level === "error") return colors.red(message);
|
|
2892
|
+
if (level === "warn") return colors.yellow(message);
|
|
2893
|
+
if (level === "debug") return colors.dim(message);
|
|
2894
|
+
return message;
|
|
2895
|
+
}
|
|
2896
|
+
function writeForwardConsoleLine(line) {
|
|
2897
|
+
process.stdout.write(`${line}\n`);
|
|
2898
|
+
}
|
|
2899
|
+
function isDevtoolsPortNotReadyError(error) {
|
|
2900
|
+
return error instanceof Error && (error.message === "DEVTOOLS_HTTP_PORT_ERROR" || error.message === "DEVTOOLS_WS_CONNECT_ERROR" || error.message === "DEVTOOLS_EXTENSION_CONTEXT_INVALIDATED");
|
|
2901
|
+
}
|
|
2902
|
+
function sleep(ms) {
|
|
2903
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2904
|
+
}
|
|
2905
|
+
async function withForwardConsoleRetry(runner) {
|
|
2906
|
+
let lastError;
|
|
2907
|
+
for (let attempt = 0; attempt <= FORWARD_CONSOLE_RETRY_TIMES; attempt++) try {
|
|
2908
|
+
return await runner();
|
|
2909
|
+
} catch (error) {
|
|
2910
|
+
lastError = error;
|
|
2911
|
+
if (!isDevtoolsPortNotReadyError(error) || attempt === FORWARD_CONSOLE_RETRY_TIMES) break;
|
|
2912
|
+
await sleep(FORWARD_CONSOLE_RETRY_DELAY_MS);
|
|
2913
|
+
}
|
|
2914
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
2915
|
+
}
|
|
2856
2916
|
/**
|
|
2857
2917
|
* @description 解析 forwardConsole 配置,并在 auto 模式下检测 AI 终端。
|
|
2858
2918
|
*/
|
|
@@ -2893,93 +2953,71 @@ async function resolveForwardConsoleOptions(config) {
|
|
|
2893
2953
|
};
|
|
2894
2954
|
}
|
|
2895
2955
|
/**
|
|
2896
|
-
* @description 在 weapp 开发态按需启动控制台转发。
|
|
2897
|
-
*/
|
|
2898
|
-
async function maybeStartForwardConsole(options) {
|
|
2899
|
-
if (options.platform !== "weapp") return false;
|
|
2900
|
-
const projectPath = resolveIdeProjectPath(options.mpDistRoot) ?? options.cwd;
|
|
2901
|
-
if (!projectPath) return false;
|
|
2902
|
-
const resolved = await resolveForwardConsoleOptions(options.weappViteConfig);
|
|
2903
|
-
if (!resolved.enabled) return false;
|
|
2904
|
-
if (activeForwardConsoleSession) return true;
|
|
2905
|
-
try {
|
|
2906
|
-
activeForwardConsoleSession = await startForwardConsoleBridge({
|
|
2907
|
-
agentName: resolved.agentName,
|
|
2908
|
-
projectPath,
|
|
2909
|
-
logLevels: resolved.logLevels,
|
|
2910
|
-
unhandledErrors: resolved.unhandledErrors,
|
|
2911
|
-
onReadyMessage: "[forwardConsole] 已连接微信开发者工具日志"
|
|
2912
|
-
});
|
|
2913
|
-
return true;
|
|
2914
|
-
} catch (error) {
|
|
2915
|
-
activeForwardConsoleSession = void 0;
|
|
2916
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
2917
|
-
logger_default.warn(`[forwardConsole] 启动失败,回退到普通 IDE 打开流程:${message}`);
|
|
2918
|
-
return false;
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
/**
|
|
2922
2956
|
* @description 统一启动 DevTools 日志桥,并在 IDE 刚启动时做短暂重试。
|
|
2923
2957
|
*/
|
|
2924
2958
|
async function startForwardConsoleBridge(options) {
|
|
2925
2959
|
return await withForwardConsoleRetry(async () => {
|
|
2960
|
+
const color = options.color ?? true;
|
|
2926
2961
|
return await startForwardConsole({
|
|
2927
2962
|
projectPath: options.projectPath,
|
|
2928
2963
|
logLevels: options.logLevels,
|
|
2964
|
+
openedOnly: options.openedOnly,
|
|
2965
|
+
port: options.port,
|
|
2929
2966
|
unhandledErrors: options.unhandledErrors,
|
|
2930
2967
|
onReady: () => {
|
|
2931
2968
|
const suffix = options.agentName ? `(AI 终端:${options.agentName})` : "";
|
|
2932
2969
|
logger_default.info(`${options.onReadyMessage}${suffix}`);
|
|
2933
2970
|
},
|
|
2934
2971
|
onLog: (event) => {
|
|
2935
|
-
|
|
2936
|
-
if (event.level === "error") {
|
|
2937
|
-
logger_default.error(line);
|
|
2938
|
-
return;
|
|
2939
|
-
}
|
|
2940
|
-
if (event.level === "warn") {
|
|
2941
|
-
logger_default.warn(line);
|
|
2942
|
-
return;
|
|
2943
|
-
}
|
|
2944
|
-
if (event.level === "info") {
|
|
2945
|
-
logger_default.info(line);
|
|
2946
|
-
return;
|
|
2947
|
-
}
|
|
2948
|
-
logger_default.log(line);
|
|
2972
|
+
writeForwardConsoleLine(`${formatForwardConsolePrefix(event.level, color)} ${formatForwardConsoleMessage(event.level, event.message, color)}`);
|
|
2949
2973
|
}
|
|
2950
2974
|
});
|
|
2951
2975
|
});
|
|
2952
2976
|
}
|
|
2953
|
-
|
|
2977
|
+
/**
|
|
2978
|
+
* @description 在 weapp 开发态按需启动控制台转发。
|
|
2979
|
+
*/
|
|
2980
|
+
async function maybeStartForwardConsole(options) {
|
|
2981
|
+
if (options.platform !== "weapp") return false;
|
|
2982
|
+
const projectPath = resolveIdeProjectPath(options.mpDistRoot) ?? options.cwd;
|
|
2983
|
+
if (!projectPath) return false;
|
|
2984
|
+
const resolved = await resolveForwardConsoleOptions(options.weappViteConfig);
|
|
2985
|
+
if (!resolved.enabled) return false;
|
|
2986
|
+
if (activeForwardConsoleSession) return true;
|
|
2987
|
+
const bridgeOptions = {
|
|
2988
|
+
agentName: resolved.agentName,
|
|
2989
|
+
color: !resolved.agentName,
|
|
2990
|
+
projectPath,
|
|
2991
|
+
port: resolveProjectAutomatorPort(projectPath),
|
|
2992
|
+
logLevels: resolved.logLevels,
|
|
2993
|
+
openedOnly: options.openedOnly,
|
|
2994
|
+
unhandledErrors: resolved.unhandledErrors,
|
|
2995
|
+
onReadyMessage: "[forwardConsole] 已连接微信开发者工具日志"
|
|
2996
|
+
};
|
|
2954
2997
|
try {
|
|
2955
|
-
|
|
2956
|
-
return
|
|
2957
|
-
isAgent: result.isAgent,
|
|
2958
|
-
agentName: result.isAgent ? result.agent.name : void 0
|
|
2959
|
-
};
|
|
2960
|
-
} catch {
|
|
2961
|
-
return {
|
|
2962
|
-
isAgent: false,
|
|
2963
|
-
agentName: void 0
|
|
2964
|
-
};
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
async function withForwardConsoleRetry(runner) {
|
|
2968
|
-
let lastError;
|
|
2969
|
-
for (let attempt = 0; attempt <= FORWARD_CONSOLE_RETRY_TIMES; attempt++) try {
|
|
2970
|
-
return await runner();
|
|
2998
|
+
activeForwardConsoleSession = await startForwardConsoleBridge(bridgeOptions);
|
|
2999
|
+
return true;
|
|
2971
3000
|
} catch (error) {
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3001
|
+
if (!isDevtoolsPortNotReadyError(error)) {
|
|
3002
|
+
activeForwardConsoleSession = void 0;
|
|
3003
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3004
|
+
logger_default.warn(`[forwardConsole] 启动失败,回退到普通 IDE 打开流程:${message}`);
|
|
3005
|
+
return false;
|
|
3006
|
+
}
|
|
3007
|
+
try {
|
|
3008
|
+
activeForwardConsoleSession = await startForwardConsoleBridge({
|
|
3009
|
+
...bridgeOptions,
|
|
3010
|
+
openedOnly: true,
|
|
3011
|
+
port: void 0
|
|
3012
|
+
});
|
|
3013
|
+
return true;
|
|
3014
|
+
} catch (fallbackError) {
|
|
3015
|
+
activeForwardConsoleSession = void 0;
|
|
3016
|
+
const message = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
3017
|
+
logger_default.warn(`[forwardConsole] 启动失败,回退到普通 IDE 打开流程:${message}`);
|
|
3018
|
+
return false;
|
|
3019
|
+
}
|
|
2975
3020
|
}
|
|
2976
|
-
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
2977
|
-
}
|
|
2978
|
-
function isDevtoolsPortNotReadyError(error) {
|
|
2979
|
-
return error instanceof Error && error.message === "DEVTOOLS_HTTP_PORT_ERROR";
|
|
2980
|
-
}
|
|
2981
|
-
function sleep(ms) {
|
|
2982
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2983
3021
|
}
|
|
2984
3022
|
//#endregion
|
|
2985
3023
|
//#region src/cli/hmrProfileSummary.ts
|
|
@@ -3154,6 +3192,7 @@ async function runIdeCommand(action, root, options) {
|
|
|
3154
3192
|
if (latestHmrSummary) logger_default.info(latestHmrSummary.line);
|
|
3155
3193
|
const session = await startForwardConsoleBridge({
|
|
3156
3194
|
projectPath: resolved.projectPath,
|
|
3195
|
+
port: resolveProjectAutomatorPort(resolved.projectPath),
|
|
3157
3196
|
agentName: void 0,
|
|
3158
3197
|
logLevels: forwardConsoleOptions.logLevels,
|
|
3159
3198
|
unhandledErrors: forwardConsoleOptions.unhandledErrors,
|
|
@@ -3985,7 +4024,7 @@ function resolveRunnableHotkeyDefinition(input) {
|
|
|
3985
4024
|
}
|
|
3986
4025
|
//#endregion
|
|
3987
4026
|
//#region package.json
|
|
3988
|
-
var version = "6.17.
|
|
4027
|
+
var version = "6.17.2";
|
|
3989
4028
|
//#endregion
|
|
3990
4029
|
//#region src/cli/devHotkeys/format.ts
|
|
3991
4030
|
const FULLWIDTH_ASCII_START = 65281;
|
|
@@ -4617,6 +4656,7 @@ function createServeMiniProgramDevActions(options) {
|
|
|
4617
4656
|
openIde: async (openOptions = {}) => {
|
|
4618
4657
|
if (!openOptions.forceOpen && await options.tryReuseForwardConsole?.()) return "已通过控制台转发复用当前开发者工具会话";
|
|
4619
4658
|
await options.openIde(projectPath, openOptions);
|
|
4659
|
+
await options.tryReuseForwardConsole?.();
|
|
4620
4660
|
return openOptions.forceReopen ? "已重新打开微信开发者工具项目" : "已打开或复用微信开发者工具项目";
|
|
4621
4661
|
},
|
|
4622
4662
|
rebuild: async () => {
|
|
@@ -4638,6 +4678,9 @@ function waitForServeShutdownSignal() {
|
|
|
4638
4678
|
}
|
|
4639
4679
|
//#endregion
|
|
4640
4680
|
//#region src/cli/commands/serve/index.ts
|
|
4681
|
+
function writePostOpenSeparator() {
|
|
4682
|
+
process.stdout?.write?.("\n");
|
|
4683
|
+
}
|
|
4641
4684
|
function registerServeCommand(cli) {
|
|
4642
4685
|
cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).option("-p, --platform <platform>", `[string] target platform (weapp | web | all)`).option("--project-config <path>", `[string] project config path (miniprogram only)`).option("--trust-project", "[boolean] auto trust Wechat DevTools project on open", { default: true }).option("--login-retry <mode>", "[string] login retry mode for Wechat DevTools (never | once | always)").option("--login-retry-timeout <ms>", "[number] login retry prompt timeout in milliseconds").option("--non-interactive", "[boolean] fail immediately when Wechat DevTools login has expired").option("--no-open-recovery", "[boolean] disable automatic Wechat DevTools close-and-reopen recovery").option("--mcp", "[boolean] auto start MCP service during dev").option("--no-mcp", "[boolean] disable MCP service during dev").option("--host [host]", `[string] web dev server host`).option("--ui", `[boolean] 启动调试 UI(当前提供分析视图)`, { default: false }).option("--analyze", `[boolean] 启动分包分析仪表盘 (实验特性)`, { default: false }).option("--scope <scope>", `[string] 局部构建范围,例如 main,packages/order`).action(async (root, options) => {
|
|
4643
4686
|
filterDuplicateOptions(options);
|
|
@@ -4699,11 +4742,14 @@ function registerServeCommand(cli) {
|
|
|
4699
4742
|
loginRetry: options.loginRetry,
|
|
4700
4743
|
loginRetryTimeout: options.loginRetryTimeout,
|
|
4701
4744
|
nonInteractive: options.nonInteractive,
|
|
4702
|
-
openRecovery:
|
|
4745
|
+
openRecovery: false,
|
|
4746
|
+
prepareAutomatorSession: true,
|
|
4703
4747
|
reuseOpenedProject: !openOptions?.forceReopen,
|
|
4748
|
+
skipPostOpenHealthCheck: true,
|
|
4704
4749
|
trustProject: options.trustProject,
|
|
4705
|
-
useAutomatorOpen:
|
|
4750
|
+
useAutomatorOpen: true
|
|
4706
4751
|
});
|
|
4752
|
+
writePostOpenSeparator();
|
|
4707
4753
|
},
|
|
4708
4754
|
projectPath: resolveIdeProjectRoot(configService.mpDistRoot, configService.cwd),
|
|
4709
4755
|
tryReuseForwardConsole: async () => {
|
|
@@ -4822,7 +4868,7 @@ function registerServeCommand(cli) {
|
|
|
4822
4868
|
}
|
|
4823
4869
|
//#endregion
|
|
4824
4870
|
//#region src/cli/error.ts
|
|
4825
|
-
const watchLimitErrorCodes = new Set(["EMFILE", "ENOSPC"]);
|
|
4871
|
+
const watchLimitErrorCodes = /* @__PURE__ */ new Set(["EMFILE", "ENOSPC"]);
|
|
4826
4872
|
const watchLimitMessagePattern = /EMFILE|ENOSPC|unable to start FSEvent stream/i;
|
|
4827
4873
|
function findWatchLimitErrorCode(error) {
|
|
4828
4874
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -4858,7 +4904,7 @@ function handleCLIError(error) {
|
|
|
4858
4904
|
}
|
|
4859
4905
|
//#endregion
|
|
4860
4906
|
//#region src/cli/ide.ts
|
|
4861
|
-
const WEAPP_VITE_NATIVE_COMMANDS = new Set([
|
|
4907
|
+
const WEAPP_VITE_NATIVE_COMMANDS = /* @__PURE__ */ new Set([
|
|
4862
4908
|
"dev",
|
|
4863
4909
|
"serve",
|
|
4864
4910
|
"build",
|
|
@@ -4898,7 +4944,7 @@ async function tryRunIdeCommand(argv) {
|
|
|
4898
4944
|
}
|
|
4899
4945
|
//#endregion
|
|
4900
4946
|
//#region src/cli/mcpAutoStart.ts
|
|
4901
|
-
const SKIP_COMMANDS = new Set([
|
|
4947
|
+
const SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
4902
4948
|
"--help",
|
|
4903
4949
|
"--version",
|
|
4904
4950
|
"-h",
|
|
@@ -5001,7 +5047,7 @@ registerMcpCommand(cli);
|
|
|
5001
5047
|
registerServeCommand(cli);
|
|
5002
5048
|
cli.help();
|
|
5003
5049
|
cli.version(VERSION);
|
|
5004
|
-
const skipManagedTsconfigBootstrapCommands = new Set([
|
|
5050
|
+
const skipManagedTsconfigBootstrapCommands = /* @__PURE__ */ new Set([
|
|
5005
5051
|
"g",
|
|
5006
5052
|
"generate",
|
|
5007
5053
|
"ide",
|
|
@@ -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";
|
|
@@ -13,7 +13,7 @@ import { createDebug } from "obug";
|
|
|
13
13
|
import fs$1, { existsSync, readFileSync } from "node:fs";
|
|
14
14
|
import { parse } from "vue/compiler-sfc";
|
|
15
15
|
import { BABEL_TS_MODULE_PARSER_OPTIONS, generate, getVisitorKeys, parse as parse$2, parseJsLike, traverse } from "@weapp-vite/ast/babel";
|
|
16
|
-
import
|
|
16
|
+
import pm from "picomatch";
|
|
17
17
|
import { VUE_COMPONENT_TAG_RE, WE_VU_INTERNAL_REACTIVITY_MODULE_ID, WE_VU_INTERNAL_RUNTIME_MODULE_ID, WE_VU_INTERNAL_TEMPLATE_MODULE_ID, WE_VU_RUNTIME_APIS, buildClassStyleComputedCode, collectVueTemplateTags, compileJsxFile, compileVueFile, createJsonMerger, createPageEntryMatcher, createPageEntryMatcher as createPageEntryMatcher$1, getClassStyleWxsSource, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, pathExists, readAndParseSfc, readFile as readFile$1, resolveClassStyleWxsLocation, stripJsonMacroCallsFromCode } from "wevu/compiler";
|
|
18
18
|
import process from "node:process";
|
|
19
19
|
import { parse as parse$1, stringify } from "comment-json";
|
|
@@ -1328,7 +1328,7 @@ function createMetadataHelpers(state) {
|
|
|
1328
1328
|
function collectAllComponentNames(options) {
|
|
1329
1329
|
const { collectResolverComponents, registry, componentMetadataMap, manifestCache } = options;
|
|
1330
1330
|
const resolverEntries = collectResolverComponents();
|
|
1331
|
-
const names = new Set([...Object.keys(resolverEntries)]);
|
|
1331
|
+
const names = /* @__PURE__ */ new Set([...Object.keys(resolverEntries)]);
|
|
1332
1332
|
for (const key of registry.keys()) names.add(key);
|
|
1333
1333
|
for (const key of componentMetadataMap.keys()) names.add(key);
|
|
1334
1334
|
for (const key of manifestCache.keys()) names.add(key);
|
|
@@ -1451,7 +1451,7 @@ function createHtmlCustomDataDefinition(componentNames, getMetadata, baseTags =
|
|
|
1451
1451
|
const metadata = getMetadata(name);
|
|
1452
1452
|
const combinedTypes = metadata.types;
|
|
1453
1453
|
const docs = metadata.docs;
|
|
1454
|
-
const attributeNames = new Set([...combinedTypes.keys(), ...docs.keys()]);
|
|
1454
|
+
const attributeNames = /* @__PURE__ */ new Set([...combinedTypes.keys(), ...docs.keys()]);
|
|
1455
1455
|
const attributes = Array.from(attributeNames).sort((a, b) => a.localeCompare(b)).map((propName) => {
|
|
1456
1456
|
const type = combinedTypes.get(propName);
|
|
1457
1457
|
const doc = docs.get(propName);
|
|
@@ -5368,7 +5368,7 @@ function createRegistryHelpers(state) {
|
|
|
5368
5368
|
}
|
|
5369
5369
|
const nextKey = globs.join("\0");
|
|
5370
5370
|
if (!state.autoImportState.matcher || state.autoImportState.matcherKey !== nextKey) {
|
|
5371
|
-
state.autoImportState.matcher =
|
|
5371
|
+
state.autoImportState.matcher = pm(globs, { windows: true });
|
|
5372
5372
|
state.autoImportState.matcherKey = nextKey;
|
|
5373
5373
|
}
|
|
5374
5374
|
return state.autoImportState.matcher;
|
|
@@ -5816,7 +5816,7 @@ function createRule(pattern) {
|
|
|
5816
5816
|
};
|
|
5817
5817
|
return {
|
|
5818
5818
|
pattern,
|
|
5819
|
-
match:
|
|
5819
|
+
match: pm(pattern, { dot: true })
|
|
5820
5820
|
};
|
|
5821
5821
|
}
|
|
5822
5822
|
function isDefaultAutoRouteInclude(include) {
|
|
@@ -5852,7 +5852,7 @@ function createAutoRoutesMatcher(include, subPackageRoots = []) {
|
|
|
5852
5852
|
}
|
|
5853
5853
|
function getRoots(absoluteSrcRoot) {
|
|
5854
5854
|
if (isDefault) {
|
|
5855
|
-
const roots = new Set([path.join(absoluteSrcRoot, "pages")]);
|
|
5855
|
+
const roots = /* @__PURE__ */ new Set([path.join(absoluteSrcRoot, "pages")]);
|
|
5856
5856
|
for (const root of normalizedSubPackageRoots) roots.add(path.join(absoluteSrcRoot, root));
|
|
5857
5857
|
return Array.from(roots, (root) => normalizePath$1(root));
|
|
5858
5858
|
}
|
|
@@ -5911,7 +5911,7 @@ function resolveWeappAutoRoutesConfig(config) {
|
|
|
5911
5911
|
//#region src/runtime/autoRoutesPlugin/generatedPaths.ts
|
|
5912
5912
|
const AUTO_ROUTES_CACHE_FILE$1 = ".weapp-vite/auto-routes.cache.json";
|
|
5913
5913
|
const TYPED_ROUTER_OUTPUT_FILE$1 = ".weapp-vite/typed-router.d.ts";
|
|
5914
|
-
const GENERATED_DIRECTORY_NAMES = new Set([
|
|
5914
|
+
const GENERATED_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
|
|
5915
5915
|
".cache",
|
|
5916
5916
|
".rolldown-require",
|
|
5917
5917
|
".rolldown-require-cache",
|
|
@@ -5924,7 +5924,7 @@ const GENERATED_DIRECTORY_NAMES = new Set([
|
|
|
5924
5924
|
"miniprogram_npm",
|
|
5925
5925
|
"node_modules"
|
|
5926
5926
|
]);
|
|
5927
|
-
const GENERATED_FILE_NAMES = new Set([path.basename(AUTO_ROUTES_CACHE_FILE$1), path.basename(TYPED_ROUTER_OUTPUT_FILE$1)]);
|
|
5927
|
+
const GENERATED_FILE_NAMES = /* @__PURE__ */ new Set([path.basename(AUTO_ROUTES_CACHE_FILE$1), path.basename(TYPED_ROUTER_OUTPUT_FILE$1)]);
|
|
5928
5928
|
function stripQuery(candidate) {
|
|
5929
5929
|
return candidate.split("?")[0];
|
|
5930
5930
|
}
|
|
@@ -5973,7 +5973,7 @@ const TEMPLATE_EXTENSIONS = new Set(templateExtensions.map((ext) => `.${ext}`));
|
|
|
5973
5973
|
const VUE_EXTENSIONS = new Set(vueExtensions.map((ext) => `.${ext}`));
|
|
5974
5974
|
const STYLE_EXTENSIONS = new Set(supportedCssLangs.map((ext) => `.${ext}`));
|
|
5975
5975
|
const CONFIG_SUFFIXES = configExtensions.map((ext) => `.${ext}`);
|
|
5976
|
-
const SKIPPED_DIRECTORIES = new Set([
|
|
5976
|
+
const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
5977
5977
|
".git",
|
|
5978
5978
|
".husky",
|
|
5979
5979
|
".idea",
|
|
@@ -6374,7 +6374,7 @@ function applyBuildScopeToAutoRoutes(routes, scope) {
|
|
|
6374
6374
|
...subPackage,
|
|
6375
6375
|
root: normalizeRoot(subPackage.root)
|
|
6376
6376
|
}));
|
|
6377
|
-
const scopedEntries = new Set([...scope.includeMainPackage ? routes.pages : [], ...subPackages.flatMap((subPackage) => subPackage.pages.map((page) => `${subPackage.root}/${page}`))]);
|
|
6377
|
+
const scopedEntries = /* @__PURE__ */ new Set([...scope.includeMainPackage ? routes.pages : [], ...subPackages.flatMap((subPackage) => subPackage.pages.map((page) => `${subPackage.root}/${page}`))]);
|
|
6378
6378
|
return {
|
|
6379
6379
|
pages: scope.includeMainPackage ? routes.pages : [],
|
|
6380
6380
|
entries: routes.entries.filter((entry) => scopedEntries.has(entry)),
|
|
@@ -7105,7 +7105,7 @@ function createAutoRoutesServicePlugin(ctx) {
|
|
|
7105
7105
|
//#region src/plugins/utils/invalidateEntry/shared.ts
|
|
7106
7106
|
const watchedCssExts = new Set(supportedCssLangs.map((ext) => `.${ext}`));
|
|
7107
7107
|
const watchedTemplateExts = new Set(templateExtensions.map((ext) => `.${ext}`));
|
|
7108
|
-
const watchedScriptModuleExts = new Set([
|
|
7108
|
+
const watchedScriptModuleExts = /* @__PURE__ */ new Set([
|
|
7109
7109
|
".wxs",
|
|
7110
7110
|
".sjs",
|
|
7111
7111
|
".wxs.ts",
|
|
@@ -7120,7 +7120,7 @@ const sidecarSuffixes = [
|
|
|
7120
7120
|
...watchedTemplateExts,
|
|
7121
7121
|
...watchedScriptModuleExts
|
|
7122
7122
|
];
|
|
7123
|
-
const defaultIgnoredDirNames = new Set([
|
|
7123
|
+
const defaultIgnoredDirNames = /* @__PURE__ */ new Set([
|
|
7124
7124
|
"node_modules",
|
|
7125
7125
|
"miniprogram_npm",
|
|
7126
7126
|
".git",
|
|
@@ -7129,7 +7129,7 @@ const defaultIgnoredDirNames = new Set([
|
|
|
7129
7129
|
".turbo",
|
|
7130
7130
|
".weapp-vite"
|
|
7131
7131
|
]);
|
|
7132
|
-
const watchLimitErrorCodes = new Set(["EMFILE", "ENOSPC"]);
|
|
7132
|
+
const watchLimitErrorCodes = /* @__PURE__ */ new Set(["EMFILE", "ENOSPC"]);
|
|
7133
7133
|
function isSidecarFile(filePath) {
|
|
7134
7134
|
return sidecarSuffixes.some((suffix) => filePath.endsWith(suffix));
|
|
7135
7135
|
}
|
|
@@ -7455,7 +7455,7 @@ function shouldRewriteWevuComponentType(value) {
|
|
|
7455
7455
|
}
|
|
7456
7456
|
//#endregion
|
|
7457
7457
|
//#region src/runtime/libDts/shared.ts
|
|
7458
|
-
const DTS_INPUT_EXTENSIONS = new Set([
|
|
7458
|
+
const DTS_INPUT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
7459
7459
|
".ts",
|
|
7460
7460
|
".tsx",
|
|
7461
7461
|
".mts",
|
|
@@ -7717,7 +7717,7 @@ async function generateVueDtsWithInternal(configService, vueEntries, dtsOptions)
|
|
|
7717
7717
|
...rawVueCompilerOptions ?? {}
|
|
7718
7718
|
};
|
|
7719
7719
|
const rewriteWevuComponentType = shouldRewriteWevuComponentType(vueCompilerOptions.lib);
|
|
7720
|
-
const rootNames = Array.from(new Set([...(parsedTs?.fileNames ?? []).map((file) => path.isAbsolute(file) ? file : path.resolve(configService.cwd, file)), ...vueEntries.map((entry) => entry.input)])).map(normalizePath);
|
|
7720
|
+
const rootNames = Array.from(/* @__PURE__ */ new Set([...(parsedTs?.fileNames ?? []).map((file) => path.isAbsolute(file) ? file : path.resolve(configService.cwd, file)), ...vueEntries.map((entry) => entry.input)])).map(normalizePath);
|
|
7721
7721
|
const host = ts.createCompilerHost(compilerOptions);
|
|
7722
7722
|
const program = proxyCreateProgram(ts, ts.createProgram, (tsInstance, options) => {
|
|
7723
7723
|
return { languagePlugins: [createVueLanguagePlugin(tsInstance, options.options, vueCompilerOptions, (id) => id)] };
|
|
@@ -7973,7 +7973,7 @@ function getDerivedScriptModuleTagNames() {
|
|
|
7973
7973
|
return MINI_PROGRAM_PLATFORM_ADAPTERS.flatMap((adapter) => Object.values(adapter.scriptModuleTagByExtension ?? {})).filter((value) => typeof value === "string" && value.length > 0);
|
|
7974
7974
|
}
|
|
7975
7975
|
function getScriptModuleTagNames() {
|
|
7976
|
-
return [
|
|
7976
|
+
return [.../* @__PURE__ */ new Set([...DEFAULT_SCRIPT_MODULE_TAG_NAMES, ...getDerivedScriptModuleTagNames()])];
|
|
7977
7977
|
}
|
|
7978
7978
|
function isScriptModuleTagName(tagName) {
|
|
7979
7979
|
return typeof tagName === "string" && getScriptModuleTagNames().includes(tagName);
|
|
@@ -8246,7 +8246,7 @@ async function normalizeMiniprogramPackageJsModules(pkgRoot, options) {
|
|
|
8246
8246
|
const WX_TEMPLATE_REFERENCE_RE = /\.wxml\b|\.wxss\b|\.wxs\b/;
|
|
8247
8247
|
const ESM_SYNTAX_RE = /\bimport\s|\bexport\s/;
|
|
8248
8248
|
const NULLISH_COALESCING_RE = /\?\?/;
|
|
8249
|
-
const ALIPAY_TEXT_FILE_EXTENSIONS = new Set([
|
|
8249
|
+
const ALIPAY_TEXT_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
8250
8250
|
".js",
|
|
8251
8251
|
".json",
|
|
8252
8252
|
".axml",
|
|
@@ -9689,7 +9689,7 @@ function collectEffectivePrefixes(importer, options, state) {
|
|
|
9689
9689
|
const result = {
|
|
9690
9690
|
prefixes: Array.from(aggregatedPrefixes),
|
|
9691
9691
|
hasRealMain,
|
|
9692
|
-
ignored: Array.from(new Set([...aggregatedIgnored, ...ignored]))
|
|
9692
|
+
ignored: Array.from(/* @__PURE__ */ new Set([...aggregatedIgnored, ...ignored]))
|
|
9693
9693
|
};
|
|
9694
9694
|
state.cache.set(importer, result);
|
|
9695
9695
|
state.stack.delete(importer);
|
|
@@ -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) {
|
|
@@ -10480,7 +10481,7 @@ function resolveNodeModulesSharedPath(cleanedAbsoluteId) {
|
|
|
10480
10481
|
}
|
|
10481
10482
|
function createStringOrRegExpMatcher(pattern) {
|
|
10482
10483
|
if (typeof pattern === "string") {
|
|
10483
|
-
const matcher =
|
|
10484
|
+
const matcher = pm(pattern, { dot: true });
|
|
10484
10485
|
return (value) => matcher(value);
|
|
10485
10486
|
}
|
|
10486
10487
|
if (isRegexp(pattern)) return (value) => {
|
|
@@ -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;
|
|
@@ -10756,7 +10764,7 @@ function resolveAbsolutePath(ctx, candidate) {
|
|
|
10756
10764
|
function matchesAutoImportGlobs(ctx, candidate) {
|
|
10757
10765
|
const { autoImportService, configService } = ctx;
|
|
10758
10766
|
if (!autoImportService || !configService) return false;
|
|
10759
|
-
const targets = new Set([
|
|
10767
|
+
const targets = /* @__PURE__ */ new Set([
|
|
10760
10768
|
candidate,
|
|
10761
10769
|
configService.relativeCwd(candidate),
|
|
10762
10770
|
configService.relativeAbsoluteSrcRoot(candidate)
|
|
@@ -13667,7 +13675,7 @@ const ECMASCRIPT_SHORTHAND_YEAR_MAP = {
|
|
|
13667
13675
|
15: 2024
|
|
13668
13676
|
};
|
|
13669
13677
|
const MIN_SUPPORTED_ECMA_YEAR = 2015;
|
|
13670
|
-
const NON_CONCRETE_BUILD_TARGETS = new Set([
|
|
13678
|
+
const NON_CONCRETE_BUILD_TARGETS = /* @__PURE__ */ new Set([
|
|
13671
13679
|
"esnext",
|
|
13672
13680
|
"latest",
|
|
13673
13681
|
"modules"
|
|
@@ -15287,7 +15295,7 @@ function stripQueryAndHash(value) {
|
|
|
15287
15295
|
}
|
|
15288
15296
|
function createPathMatcher(patterns, options) {
|
|
15289
15297
|
if (!patterns.length) return () => false;
|
|
15290
|
-
return
|
|
15298
|
+
return pm(patterns.map((pattern) => normalizePath$1(pattern)), options);
|
|
15291
15299
|
}
|
|
15292
15300
|
function createAssetPathVariants(file, roots) {
|
|
15293
15301
|
const variants = [file];
|
|
@@ -16468,7 +16476,7 @@ function analyzePageLayoutSourceUncached(source, filename) {
|
|
|
16468
16476
|
if (setupLayout !== void 0) layoutMeta = setupLayout;
|
|
16469
16477
|
}
|
|
16470
16478
|
const dynamicSwitch = Boolean(scriptAst && hasSetPageLayoutCallInProgram(scriptAst) || scriptSetupAst && hasSetPageLayoutCallInProgram(scriptSetupAst));
|
|
16471
|
-
const dynamicPropKeys = dynamicSwitch ? Array.from(new Set([...scriptAst ? collectSetPageLayoutPropKeysFromProgram(scriptAst) : [], ...scriptSetupAst ? collectSetPageLayoutPropKeysFromProgram(scriptSetupAst) : []])) : [];
|
|
16479
|
+
const dynamicPropKeys = dynamicSwitch ? Array.from(/* @__PURE__ */ new Set([...scriptAst ? collectSetPageLayoutPropKeysFromProgram(scriptAst) : [], ...scriptSetupAst ? collectSetPageLayoutPropKeysFromProgram(scriptSetupAst) : []])) : [];
|
|
16472
16480
|
return {
|
|
16473
16481
|
layoutMeta,
|
|
16474
16482
|
dynamicSwitch,
|
|
@@ -16523,7 +16531,7 @@ function normalizePageRouteCandidates(filename, configService) {
|
|
|
16523
16531
|
next = next.replace(TRAILING_INDEX_RE, "");
|
|
16524
16532
|
return next === "" ? "/" : next;
|
|
16525
16533
|
})();
|
|
16526
|
-
return Array.from(new Set([shorthand, fullPath]));
|
|
16534
|
+
return Array.from(/* @__PURE__ */ new Set([shorthand, fullPath]));
|
|
16527
16535
|
}
|
|
16528
16536
|
function normalizeRouteRuleLayoutMeta(input) {
|
|
16529
16537
|
if (input === false) return { disabled: true };
|
|
@@ -16552,7 +16560,7 @@ function resolveRouteRuleLayoutMeta(filename, configService) {
|
|
|
16552
16560
|
const routeCandidates = normalizePageRouteCandidates(filename, configService);
|
|
16553
16561
|
let matched;
|
|
16554
16562
|
for (const [pattern, rule] of Object.entries(routeRules)) {
|
|
16555
|
-
if (!routeCandidates.some((candidate) =>
|
|
16563
|
+
if (!routeCandidates.some((candidate) => pm(pattern)(candidate))) continue;
|
|
16556
16564
|
const normalizedMeta = normalizeRouteRuleLayoutMeta(rule?.appLayout);
|
|
16557
16565
|
const patternSegments = pattern.split("/").filter(Boolean);
|
|
16558
16566
|
const wildcardMatches = pattern.match(ROUTE_RULE_GLOB_TOKEN_RE) ?? [];
|
|
@@ -16678,7 +16686,7 @@ async function resolvePageLayoutPlan(source, filename, configService) {
|
|
|
16678
16686
|
currentLayout,
|
|
16679
16687
|
dynamicSwitch,
|
|
16680
16688
|
layouts,
|
|
16681
|
-
dynamicPropKeys: dynamicSwitch ? Array.from(new Set([...Object.keys(currentLayout?.props ?? {}), ...analyzedSource?.dynamicPropKeys ?? []])) : []
|
|
16689
|
+
dynamicPropKeys: dynamicSwitch ? Array.from(/* @__PURE__ */ new Set([...Object.keys(currentLayout?.props ?? {}), ...analyzedSource?.dynamicPropKeys ?? []])) : []
|
|
16682
16690
|
};
|
|
16683
16691
|
}
|
|
16684
16692
|
function isLayoutFile(filename, configService) {
|
|
@@ -17459,12 +17467,12 @@ function createEntryLoader(options) {
|
|
|
17459
17467
|
const componentEntries = analyzeCommonJson(json);
|
|
17460
17468
|
const pendingAutoImportMap = ctx.runtimeState?.autoImport?.pendingEntriesByImporter;
|
|
17461
17469
|
const vueBaseName = vueEntryPath ? removeExtensionDeep(vueEntryPath) : void 0;
|
|
17462
|
-
const pendingAutoImportEntries = Array.from(new Set([...Array.from(pendingAutoImportMap?.get(baseName) ?? []), ...Array.from(vueBaseName ? pendingAutoImportMap?.get(vueBaseName) ?? [] : [])]));
|
|
17470
|
+
const pendingAutoImportEntries = Array.from(/* @__PURE__ */ new Set([...Array.from(pendingAutoImportMap?.get(baseName) ?? []), ...Array.from(vueBaseName ? pendingAutoImportMap?.get(vueBaseName) ?? [] : [])]));
|
|
17463
17471
|
if (pendingAutoImportEntries.length) {
|
|
17464
17472
|
pendingAutoImportMap?.delete(baseName);
|
|
17465
17473
|
if (vueBaseName) pendingAutoImportMap?.delete(vueBaseName);
|
|
17466
17474
|
}
|
|
17467
|
-
const mergedComponentEntries = Array.from(new Set([...componentEntries, ...pendingAutoImportEntries]));
|
|
17475
|
+
const mergedComponentEntries = Array.from(/* @__PURE__ */ new Set([...componentEntries, ...pendingAutoImportEntries]));
|
|
17468
17476
|
entries.push(...mergedComponentEntries);
|
|
17469
17477
|
for (const componentEntry of mergedComponentEntries) {
|
|
17470
17478
|
const normalizedComponentEntry = normalizeEntry(componentEntry, jsonPath);
|
|
@@ -18316,7 +18324,7 @@ function appendSharedChunkImporters(bundle, state, onlyEntryIds, previousImporte
|
|
|
18316
18324
|
const addSharedChunkModule = (moduleId, chunkId) => {
|
|
18317
18325
|
const current = state.hmrSharedChunksByModule.get(moduleId);
|
|
18318
18326
|
if (current) current.add(chunkId);
|
|
18319
|
-
else state.hmrSharedChunksByModule.set(moduleId, new Set([chunkId]));
|
|
18327
|
+
else state.hmrSharedChunksByModule.set(moduleId, /* @__PURE__ */ new Set([chunkId]));
|
|
18320
18328
|
};
|
|
18321
18329
|
const pruneSharedChunkModules = (chunkId, nextModuleIds) => {
|
|
18322
18330
|
if (!nextModuleIds.size) return;
|
|
@@ -18346,10 +18354,10 @@ function appendSharedChunkImporters(bundle, state, onlyEntryIds, previousImporte
|
|
|
18346
18354
|
const addSharedChunkImporter = (chunkId, entryId) => {
|
|
18347
18355
|
const current = state.hmrSharedChunkImporters.get(chunkId);
|
|
18348
18356
|
if (current) current.add(entryId);
|
|
18349
|
-
else state.hmrSharedChunkImporters.set(chunkId, new Set([entryId]));
|
|
18357
|
+
else state.hmrSharedChunkImporters.set(chunkId, /* @__PURE__ */ new Set([entryId]));
|
|
18350
18358
|
const currentChunkIds = state.hmrSharedChunksByEntry.get(entryId);
|
|
18351
18359
|
if (currentChunkIds) currentChunkIds.add(chunkId);
|
|
18352
|
-
else state.hmrSharedChunksByEntry.set(entryId, new Set([chunkId]));
|
|
18360
|
+
else state.hmrSharedChunksByEntry.set(entryId, /* @__PURE__ */ new Set([chunkId]));
|
|
18353
18361
|
};
|
|
18354
18362
|
const restoreMissingChunkImporters = (entryId, chunkId, visited) => {
|
|
18355
18363
|
if (visited.has(chunkId)) return;
|
|
@@ -18690,8 +18698,8 @@ function getStyleMatcher(entry) {
|
|
|
18690
18698
|
if (cached) return cached;
|
|
18691
18699
|
const includePatterns = entry.include?.length ? entry.include : ["**/*"];
|
|
18692
18700
|
const excludePatterns = entry.exclude?.length ? entry.exclude : void 0;
|
|
18693
|
-
const matcher = { include:
|
|
18694
|
-
if (excludePatterns?.length) matcher.exclude =
|
|
18701
|
+
const matcher = { include: pm(includePatterns, { dot: true }) };
|
|
18702
|
+
if (excludePatterns?.length) matcher.exclude = pm(excludePatterns, { dot: true });
|
|
18695
18703
|
styleMatcherCache.set(entry, matcher);
|
|
18696
18704
|
return matcher;
|
|
18697
18705
|
}
|
|
@@ -19021,7 +19029,7 @@ const REQUEST_RUNTIME_REQUEST_TARGETS = [
|
|
|
19021
19029
|
"AbortSignal",
|
|
19022
19030
|
"XMLHttpRequest"
|
|
19023
19031
|
];
|
|
19024
|
-
const REQUEST_RUNTIME_CORE_USAGE_TARGETS = new Set([
|
|
19032
|
+
const REQUEST_RUNTIME_CORE_USAGE_TARGETS = /* @__PURE__ */ new Set([
|
|
19025
19033
|
"fetch",
|
|
19026
19034
|
"Headers",
|
|
19027
19035
|
"Request",
|
|
@@ -19036,7 +19044,7 @@ const DEFAULT_REQUEST_GLOBAL_DEPENDENCIES = [
|
|
|
19036
19044
|
];
|
|
19037
19045
|
const DEFAULT_ABORT_GLOBAL_DEPENDENCIES = ["@tanstack/query-core", "@tanstack/vue-query"];
|
|
19038
19046
|
const WEBSOCKET_USAGE_HINT_RE = /\bwebsocket\b/iu;
|
|
19039
|
-
const REQUEST_GLOBAL_FREE_BINDING_TARGETS = new Set([
|
|
19047
|
+
const REQUEST_GLOBAL_FREE_BINDING_TARGETS = /* @__PURE__ */ new Set([
|
|
19040
19048
|
...FULL_REQUEST_GLOBAL_TARGETS,
|
|
19041
19049
|
"URL",
|
|
19042
19050
|
"URLSearchParams",
|
|
@@ -19085,7 +19093,7 @@ function resolveAppPreludeWebRuntimeConfig(appPrelude, warn) {
|
|
|
19085
19093
|
};
|
|
19086
19094
|
}
|
|
19087
19095
|
function hasMatchedDependency(packageJson, patterns) {
|
|
19088
|
-
return [
|
|
19096
|
+
return [.../* @__PURE__ */ new Set([
|
|
19089
19097
|
...Object.keys(packageJson?.dependencies ?? {}),
|
|
19090
19098
|
...Object.keys(packageJson?.devDependencies ?? {}),
|
|
19091
19099
|
...Object.keys(packageJson?.peerDependencies ?? {})
|
|
@@ -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",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"node": "^20.19.0 || >=22.12.0"
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"@babel/preset-env": "^8.0.
|
|
93
|
+
"@babel/preset-env": "^8.0.2",
|
|
94
94
|
"@babel/preset-typescript": "^8.0.1",
|
|
95
95
|
"@jridgewell/remapping": "^2.3.5",
|
|
96
96
|
"@vercel/detect-agent": "^1.2.3",
|
|
@@ -111,37 +111,37 @@
|
|
|
111
111
|
"pathe": "^2.0.3",
|
|
112
112
|
"picomatch": "^4.0.4",
|
|
113
113
|
"postcss": "^8.5.15",
|
|
114
|
-
"rolldown": "1.1.
|
|
114
|
+
"rolldown": "1.1.2",
|
|
115
115
|
"rolldown-plugin-dts": "0.26.0",
|
|
116
|
-
"semver": "^7.8.
|
|
116
|
+
"semver": "^7.8.5",
|
|
117
117
|
"typescript": "^6.0.3",
|
|
118
118
|
"vite": "8.0.16",
|
|
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",
|
|
122
|
+
"@weapp-core/init": "6.0.11",
|
|
124
123
|
"@weapp-core/logger": "3.1.1",
|
|
125
124
|
"@weapp-core/schematics": "6.0.4",
|
|
126
|
-
"@weapp-core/
|
|
127
|
-
"@weapp-
|
|
128
|
-
"@weapp-vite/
|
|
129
|
-
"@weapp-vite/
|
|
125
|
+
"@weapp-core/constants": "0.1.12",
|
|
126
|
+
"@weapp-core/shared": "3.0.5",
|
|
127
|
+
"@weapp-vite/ast": "6.17.2",
|
|
128
|
+
"@weapp-vite/mcp": "1.4.6",
|
|
130
129
|
"@weapp-vite/volar": "2.1.0",
|
|
131
|
-
"@weapp-vite/
|
|
132
|
-
"@
|
|
133
|
-
"@wevu/
|
|
130
|
+
"@weapp-vite/miniprogram-automator": "1.2.5",
|
|
131
|
+
"@weapp-vite/web": "1.3.33",
|
|
132
|
+
"@wevu/api": "0.2.11",
|
|
133
|
+
"@wevu/web-apis": "1.2.25",
|
|
134
134
|
"rolldown-require": "2.0.19",
|
|
135
135
|
"vite-plugin-performance": "2.0.1",
|
|
136
|
-
"weapp-ide-cli": "5.4.
|
|
137
|
-
"wevu": "6.17.
|
|
136
|
+
"weapp-ide-cli": "5.4.9",
|
|
137
|
+
"wevu": "6.17.2"
|
|
138
138
|
},
|
|
139
139
|
"publishConfig": {
|
|
140
140
|
"access": "public",
|
|
141
141
|
"registry": "https://registry.npmjs.org"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
-
"oxc-parser": "^0.
|
|
144
|
+
"oxc-parser": "^0.137.0",
|
|
145
145
|
"oxc-walker": "^1.0.0",
|
|
146
146
|
"tailwindcss": "^4.3.1",
|
|
147
147
|
"ts-morph": "^28.0.0"
|
|
@@ -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-BrdaHBHs.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 };
|