weapp-vite 6.16.43 → 6.16.45
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 +210 -103
- package/dist/{config-CobCpW-a.d.mts → config-Ds7MBgQm.d.mts} +2 -2
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-CRpsNCP2.mjs → createContext-Bqsm_duR.mjs} +99 -45
- package/dist/{file-Wkzc9gMS.mjs → file-CsF2X7eL.mjs} +1 -1
- package/dist/file-CsjD5DM3.mjs +2 -0
- package/dist/getInstance-BNM8-aPJ.mjs +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/mcp-YXCIQr-Z.mjs +124 -0
- package/dist/mcp.d.mts +11 -3
- package/dist/mcp.mjs +2 -2
- package/dist/types.d.mts +1 -1
- package/package.json +16 -16
- package/dist/file-iVST36Dh.mjs +0 -2
- package/dist/getInstance-QuyA4zlX.mjs +0 -2
- package/dist/mcp-qmDOTH07.mjs +0 -43
|
@@ -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-CsF2X7eL.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";
|
|
@@ -9146,9 +9146,9 @@ function getWeappViteConfig() {
|
|
|
9146
9146
|
},
|
|
9147
9147
|
mcp: {
|
|
9148
9148
|
enabled: true,
|
|
9149
|
-
autoStart:
|
|
9149
|
+
autoStart: "ai",
|
|
9150
9150
|
host: "127.0.0.1",
|
|
9151
|
-
port:
|
|
9151
|
+
port: "auto",
|
|
9152
9152
|
endpoint: "/mcp",
|
|
9153
9153
|
restEndpoint: "/api/weapp/devtools"
|
|
9154
9154
|
},
|
|
@@ -11037,6 +11037,27 @@ async function collectAppSideFiles(pluginCtx, id, json, jsonService, registerJso
|
|
|
11037
11037
|
await processSideJson(sitemapLocation);
|
|
11038
11038
|
await processSideJson(themeLocation);
|
|
11039
11039
|
}
|
|
11040
|
+
async function collectMiniappConfigFile(pluginCtx, id, configService, jsonService, registerJsonAsset, existsCache, ttlMs) {
|
|
11041
|
+
if (configService.platform !== "weapp") return;
|
|
11042
|
+
const runtimeMiniappConfigPath = path.resolve(path.dirname(id), "app.miniapp.json");
|
|
11043
|
+
if (await addWatchTarget(pluginCtx, runtimeMiniappConfigPath, existsCache, ttlMs)) {
|
|
11044
|
+
registerJsonAsset({
|
|
11045
|
+
fileName: "app.miniapp.json",
|
|
11046
|
+
json: await jsonService.read(runtimeMiniappConfigPath),
|
|
11047
|
+
jsonPath: runtimeMiniappConfigPath,
|
|
11048
|
+
type: "page"
|
|
11049
|
+
});
|
|
11050
|
+
return;
|
|
11051
|
+
}
|
|
11052
|
+
const miniappConfigPath = path.resolve(configService.cwd, "project.miniapp.json");
|
|
11053
|
+
if (!await addWatchTarget(pluginCtx, miniappConfigPath, existsCache, ttlMs)) return;
|
|
11054
|
+
registerJsonAsset({
|
|
11055
|
+
fileName: "app.miniapp.json",
|
|
11056
|
+
json: await jsonService.read(miniappConfigPath),
|
|
11057
|
+
jsonPath: miniappConfigPath,
|
|
11058
|
+
type: "page"
|
|
11059
|
+
});
|
|
11060
|
+
}
|
|
11040
11061
|
async function ensureTemplateScanned(pluginCtx, id, scanTemplateEntry, existsCache, ttlMs) {
|
|
11041
11062
|
const { path: templateEntry, predictions } = await findTemplateEntry(id);
|
|
11042
11063
|
for (const prediction of predictions) await addWatchTarget(pluginCtx, prediction, existsCache, ttlMs);
|
|
@@ -13024,13 +13045,8 @@ function createBuildService(ctx) {
|
|
|
13024
13045
|
const sidecarEntryId = await resolveSnapshotSidecarEntryId(reason);
|
|
13025
13046
|
if (sidecarEntryId) {
|
|
13026
13047
|
markSnapshotEntryDirty(sidecarEntryId);
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
await build(snapshotBuildOptions);
|
|
13030
|
-
return "snapshot";
|
|
13031
|
-
} finally {
|
|
13032
|
-
delete process.env.WEAPP_VITE_FORCE_FULL_HMR_SHARED_CHUNKS;
|
|
13033
|
-
}
|
|
13048
|
+
await build(snapshotBuildOptions);
|
|
13049
|
+
return "snapshot";
|
|
13034
13050
|
}
|
|
13035
13051
|
markSnapshotEntriesFullDirty();
|
|
13036
13052
|
process.env.WEAPP_VITE_FORCE_FULL_HMR_SHARED_CHUNKS = "1";
|
|
@@ -14317,32 +14333,33 @@ function mergeInlineConfig(config, injectBuiltinAliases, ...configs) {
|
|
|
14317
14333
|
//#endregion
|
|
14318
14334
|
//#region src/plugins/utils/scriptlessComponent.ts
|
|
14319
14335
|
const SCRIPTLESS_COMPONENT_STUB = "Component({})";
|
|
14336
|
+
const SLOT_HOST_SCRIPTLESS_COMPONENT_STUB = "Component({properties:{vueSlots:{type:null,value:null},__wvSlotOwnerId:{type:String,value:\"\"},__wvSlotScope:{type:null,value:null}}})";
|
|
14320
14337
|
/**
|
|
14321
14338
|
* 统一生成无脚本组件的脚本产物文件名。
|
|
14322
14339
|
*/
|
|
14323
14340
|
function resolveScriptlessComponentFileName(relativeBase, scriptExtension) {
|
|
14324
14341
|
return `${relativeBase}.${scriptExtension}`;
|
|
14325
14342
|
}
|
|
14326
|
-
function emitScriptlessComponentAsset(pluginCtx, fileName) {
|
|
14343
|
+
function emitScriptlessComponentAsset(pluginCtx, fileName, source = SCRIPTLESS_COMPONENT_STUB) {
|
|
14327
14344
|
pluginCtx.emitFile({
|
|
14328
14345
|
type: "asset",
|
|
14329
14346
|
fileName,
|
|
14330
|
-
source
|
|
14347
|
+
source
|
|
14331
14348
|
});
|
|
14332
14349
|
}
|
|
14333
14350
|
/**
|
|
14334
14351
|
* 在 bundle 中补齐或覆盖无脚本组件占位脚本。
|
|
14335
14352
|
*/
|
|
14336
|
-
function ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension) {
|
|
14353
|
+
function ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension, source = SCRIPTLESS_COMPONENT_STUB) {
|
|
14337
14354
|
const fileName = resolveScriptlessComponentFileName(relativeBase, scriptExtension);
|
|
14338
14355
|
const existing = bundle[fileName];
|
|
14339
14356
|
if (existing) {
|
|
14340
14357
|
if (existing.type === "asset") {
|
|
14341
|
-
if ((existing.source?.toString?.() ?? "") !==
|
|
14358
|
+
if ((existing.source?.toString?.() ?? "") !== source) existing.source = source;
|
|
14342
14359
|
}
|
|
14343
14360
|
return fileName;
|
|
14344
14361
|
}
|
|
14345
|
-
emitScriptlessComponentAsset(pluginCtx, fileName);
|
|
14362
|
+
emitScriptlessComponentAsset(pluginCtx, fileName, source);
|
|
14346
14363
|
return fileName;
|
|
14347
14364
|
}
|
|
14348
14365
|
//#endregion
|
|
@@ -15810,8 +15827,8 @@ function createExtendedLibManager() {
|
|
|
15810
15827
|
function createJsonEmitManager(configService) {
|
|
15811
15828
|
const map = /* @__PURE__ */ new Map();
|
|
15812
15829
|
function register(entry) {
|
|
15813
|
-
if (!entry.jsonPath) return;
|
|
15814
|
-
const fileName = resolveRelativeJsonOutputFileName(configService, entry.jsonPath);
|
|
15830
|
+
if (!entry.jsonPath && !entry.fileName) return;
|
|
15831
|
+
const fileName = entry.fileName ?? resolveRelativeJsonOutputFileName(configService, entry.jsonPath);
|
|
15815
15832
|
const normalizedEntry = entry.type === "app" && fileName === "app.json" ? {
|
|
15816
15833
|
...entry,
|
|
15817
15834
|
json: normalizeAppJson(entry.json)
|
|
@@ -15987,19 +16004,21 @@ function getPlatformLayoutElseDirective(platform) {
|
|
|
15987
16004
|
function toKebabAttrName(key) {
|
|
15988
16005
|
return toKebabCase(key);
|
|
15989
16006
|
}
|
|
16007
|
+
const LAYOUT_SLOT_OWNER_ATTR = `${WEVU_SLOT_OWNER_ID_ATTR}="{{${WEVU_SLOT_OWNER_ID_PROP} || ${WEVU_SLOT_OWNER_ID_KEY} || ''}}"`;
|
|
15990
16008
|
function hasDynamicExpressionLayoutProps(props) {
|
|
15991
16009
|
if (!props) return false;
|
|
15992
16010
|
return Object.values(props).some((value) => typeof value === "object" && value !== null && "kind" in value && value.kind === "expression");
|
|
15993
16011
|
}
|
|
15994
16012
|
function serializeLayoutProps(props) {
|
|
15995
|
-
|
|
15996
|
-
|
|
16013
|
+
const attrs = [LAYOUT_SLOT_OWNER_ATTR];
|
|
16014
|
+
if (!props || Object.keys(props).length === 0) return ` ${attrs.join(" ")}`;
|
|
16015
|
+
attrs.push(...Object.entries(props).map(([key, value]) => {
|
|
15997
16016
|
const attrName = toKebabAttrName(key);
|
|
15998
16017
|
if (typeof value === "string") return `${attrName}="${escapeDoubleQuotedAttr(value)}"`;
|
|
15999
16018
|
if (typeof value === "object" && value && "kind" in value && value.kind === "expression") return `${attrName}="{{${WEVU_LAYOUT_BIND_PREFIX}${key}}}"`;
|
|
16000
16019
|
if (typeof value === "number" || typeof value === "boolean" || value === null) return `${attrName}="{{${String(value)}}}"`;
|
|
16001
16020
|
return "";
|
|
16002
|
-
}).filter(Boolean);
|
|
16021
|
+
}).filter(Boolean));
|
|
16003
16022
|
return attrs.length > 0 ? ` ${attrs.join(" ")}` : "";
|
|
16004
16023
|
}
|
|
16005
16024
|
function collapseNestedLayoutWrapper(template, tagName) {
|
|
@@ -16020,10 +16039,12 @@ function serializeFallbackLayoutValue(value, keyName) {
|
|
|
16020
16039
|
return `(${WEVU_PAGE_LAYOUT_PROPS_KEY}&&${WEVU_PAGE_LAYOUT_PROPS_KEY}.${keyName})!==undefined?${WEVU_PAGE_LAYOUT_PROPS_KEY}.${keyName}:${JSON.stringify(value)}`;
|
|
16021
16040
|
}
|
|
16022
16041
|
function buildDynamicLayoutAttrs(propKeys, currentLayout) {
|
|
16023
|
-
|
|
16024
|
-
return ` ${
|
|
16042
|
+
const attrs = [LAYOUT_SLOT_OWNER_ATTR];
|
|
16043
|
+
if (propKeys.length === 0) return ` ${attrs.join(" ")}`;
|
|
16044
|
+
attrs.push(...propKeys.map((key) => {
|
|
16025
16045
|
return `${toKebabAttrName(key)}="{{${serializeFallbackLayoutValue(currentLayout?.props?.[key], key)}}}"`;
|
|
16026
|
-
})
|
|
16046
|
+
}));
|
|
16047
|
+
return ` ${attrs.join(" ")}`;
|
|
16027
16048
|
}
|
|
16028
16049
|
function buildDynamicLayoutTemplate(innerTemplate, currentLayout, layouts, propKeys, platform) {
|
|
16029
16050
|
return `${layouts.map((layout, index) => {
|
|
@@ -16742,6 +16763,7 @@ async function collectAppEntries(options) {
|
|
|
16742
16763
|
if (!isPluginBuild) {
|
|
16743
16764
|
extendedLibManager.syncFromAppJson(json);
|
|
16744
16765
|
await collectAppSideFiles(pluginCtx, id, json, jsonService, registerJsonAsset, existsCache, pathExistsTtlMs);
|
|
16766
|
+
await collectMiniappConfigFile(pluginCtx, id, configService, jsonService, registerJsonAsset, existsCache, pathExistsTtlMs);
|
|
16745
16767
|
}
|
|
16746
16768
|
const pluginJsonPath = scanService?.pluginJsonPath;
|
|
16747
16769
|
if (isPluginBuild && configService.absolutePluginRoot && pluginJsonPath) {
|
|
@@ -17288,7 +17310,7 @@ function createEntryLoader(options) {
|
|
|
17288
17310
|
if (!relativeLayoutBase || emittedScriptlessVueLayoutJs.has(relativeLayoutBase)) continue;
|
|
17289
17311
|
emittedScriptlessVueLayoutJs.add(relativeLayoutBase);
|
|
17290
17312
|
const { scriptExtension } = resolveCompilerOutputExtensions(configService.outputExtensions);
|
|
17291
|
-
emitScriptlessComponentAsset(this, resolveScriptlessComponentFileName(relativeLayoutBase, scriptExtension));
|
|
17313
|
+
emitScriptlessComponentAsset(this, resolveScriptlessComponentFileName(relativeLayoutBase, scriptExtension), SLOT_HOST_SCRIPTLESS_COMPONENT_STUB);
|
|
17292
17314
|
}
|
|
17293
17315
|
};
|
|
17294
17316
|
if (type === "app") {
|
|
@@ -17554,8 +17576,9 @@ function resolvePendingEntryIds(options) {
|
|
|
17554
17576
|
if (!chunkIds?.size) continue;
|
|
17555
17577
|
for (const chunkId of chunkIds) {
|
|
17556
17578
|
const isSourceSharedChunk = options.sourceSharedChunks?.has(chunkId) === true;
|
|
17579
|
+
const isStableSharedChunk = shouldExpandStableSharedChunk(chunkId, options.sharedChunkImporters?.get(chunkId));
|
|
17557
17580
|
if (dirtyReason === "metadata") continue;
|
|
17558
|
-
if (dirtyReason === "dependency" || !isSourceSharedChunk
|
|
17581
|
+
if (dirtyReason === "dependency" || !isSourceSharedChunk && !isStableSharedChunk) relatedChunkIds.add(chunkId);
|
|
17559
17582
|
}
|
|
17560
17583
|
}
|
|
17561
17584
|
if (!relatedChunkIds.size) return {
|
|
@@ -18817,6 +18840,7 @@ const REQUEST_GLOBAL_FREE_BINDING_TARGETS = new Set([
|
|
|
18817
18840
|
"URL",
|
|
18818
18841
|
"URLSearchParams",
|
|
18819
18842
|
"Blob",
|
|
18843
|
+
"File",
|
|
18820
18844
|
"FormData"
|
|
18821
18845
|
]);
|
|
18822
18846
|
const CODE_USAGE_AUTO_RULES = [
|
|
@@ -18951,7 +18975,7 @@ function resolveRequestGlobalsBindingTargets(targets) {
|
|
|
18951
18975
|
const bindingTargets = [...targets];
|
|
18952
18976
|
if (targets.some((target) => target === "fetch" || target === "Request" || target === "Response" || target === "XMLHttpRequest" || target === "WebSocket")) {
|
|
18953
18977
|
bindingTargets.push("TextEncoder", "TextDecoder");
|
|
18954
|
-
bindingTargets.push("URL", "URLSearchParams", "Blob", "FormData");
|
|
18978
|
+
bindingTargets.push("URL", "URLSearchParams", "Blob", "File", "FormData");
|
|
18955
18979
|
}
|
|
18956
18980
|
if (targets.includes("CustomEvent")) bindingTargets.push("Event");
|
|
18957
18981
|
return [...new Set(bindingTargets)].filter((target) => REQUEST_GLOBAL_FREE_BINDING_TARGETS.has(target));
|
|
@@ -18996,6 +19020,7 @@ function createRequestGlobalsPassiveBindingsCode(targets, explicitBindingTargets
|
|
|
18996
19020
|
if (target === "URL") return `var URL = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URL",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["https://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URL,["https://request-globals.invalid"])?globalThis.URL:${placeholderFactory})`;
|
|
18997
19021
|
if (target === "URLSearchParams") return `var URLSearchParams = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URLSearchParams",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["client=graphql-request"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URLSearchParams,["client=graphql-request"])?globalThis.URLSearchParams:${placeholderFactory})`;
|
|
18998
19022
|
if (target === "Blob") return `var Blob = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Blob",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Blob,[])?globalThis.Blob:${placeholderFactory})`;
|
|
19023
|
+
if (target === "File") return `var File = ${REQUEST_GLOBAL_EXPOSE_HELPER}("File",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[[],"request-globals.bin"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.File,[[],"request-globals.bin"])?globalThis.File:${placeholderFactory})`;
|
|
18999
19024
|
if (target === "FormData") return `var FormData = ${REQUEST_GLOBAL_EXPOSE_HELPER}("FormData",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.FormData,[])?globalThis.FormData:${placeholderFactory})`;
|
|
19000
19025
|
if (target === "Headers") return `var Headers = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Headers",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Headers,[])?globalThis.Headers:${placeholderFactory})`;
|
|
19001
19026
|
if (target === "Request") return `var Request = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Request",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["https://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Request,["https://request-globals.invalid"])?globalThis.Request:${placeholderFactory})`;
|
|
@@ -22978,16 +23003,19 @@ async function loadTransformPageEntries(scanService) {
|
|
|
22978
23003
|
pluginPages
|
|
22979
23004
|
};
|
|
22980
23005
|
}
|
|
22981
|
-
function invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache) {
|
|
23006
|
+
function invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache, styleRefreshTokens) {
|
|
22982
23007
|
if (!configService) return;
|
|
22983
23008
|
for (const [cachedId, cached] of compilationCache.entries()) {
|
|
22984
23009
|
if (cached.isPage) cached.source = void 0;
|
|
22985
23010
|
styleBlocksCache.delete(cachedId);
|
|
23011
|
+
styleRefreshTokens?.delete(cachedId);
|
|
22986
23012
|
}
|
|
22987
23013
|
}
|
|
22988
|
-
function invalidateVueFileCaches(file, compilationCache, styleBlocksCache, options) {
|
|
22989
|
-
if (!options.existsSync(file))
|
|
22990
|
-
|
|
23014
|
+
function invalidateVueFileCaches(file, compilationCache, styleBlocksCache, options, styleRefreshTokens) {
|
|
23015
|
+
if (!options.existsSync(file)) {
|
|
23016
|
+
compilationCache.delete(file);
|
|
23017
|
+
styleRefreshTokens?.delete(file);
|
|
23018
|
+
} else {
|
|
22991
23019
|
const cached = compilationCache.get(file);
|
|
22992
23020
|
if (cached) {
|
|
22993
23021
|
cached.source = void 0;
|
|
@@ -22997,15 +23025,15 @@ function invalidateVueFileCaches(file, compilationCache, styleBlocksCache, optio
|
|
|
22997
23025
|
styleBlocksCache.delete(file);
|
|
22998
23026
|
}
|
|
22999
23027
|
function handleTransformLayoutInvalidation(file, options) {
|
|
23000
|
-
const { configService, compilationCache, styleBlocksCache, isLayoutFile, invalidateResolvedPageLayoutsCache } = options;
|
|
23028
|
+
const { configService, compilationCache, styleBlocksCache, styleRefreshTokens, isLayoutFile, invalidateResolvedPageLayoutsCache } = options;
|
|
23001
23029
|
if (!configService || !isLayoutFile(file, configService)) return false;
|
|
23002
23030
|
invalidateResolvedPageLayoutsCache(configService.absoluteSrcRoot);
|
|
23003
|
-
invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache);
|
|
23031
|
+
invalidatePageLayoutCaches(configService, compilationCache, styleBlocksCache, styleRefreshTokens);
|
|
23004
23032
|
return true;
|
|
23005
23033
|
}
|
|
23006
23034
|
function handleTransformVueFileInvalidation(file, options) {
|
|
23007
23035
|
if (!isVueLikeId(file)) return false;
|
|
23008
|
-
invalidateVueFileCaches(file, options.compilationCache, options.styleBlocksCache, { existsSync: options.existsSync });
|
|
23036
|
+
invalidateVueFileCaches(file, options.compilationCache, options.styleBlocksCache, { existsSync: options.existsSync }, options.styleRefreshTokens);
|
|
23009
23037
|
return true;
|
|
23010
23038
|
}
|
|
23011
23039
|
async function ensureSfcStyleBlocks(filename, styleBlocksCache, options) {
|
|
@@ -23160,7 +23188,7 @@ async function finalizeTransformEntryScript(options) {
|
|
|
23160
23188
|
}
|
|
23161
23189
|
const hasScopedSlotHostGenerics = Boolean(result.componentGenerics && Object.keys(result.componentGenerics).length > 0);
|
|
23162
23190
|
const needsSetupSlotHostProperties = result.script && mayNeedScopedSlotHostPropertiesForSetupSlotsInJs(result.script);
|
|
23163
|
-
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23191
|
+
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("<slot") || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23164
23192
|
const injectedProps = injectScopedSlotHostPropertiesInJs(result.script);
|
|
23165
23193
|
if (injectedProps.transformed) {
|
|
23166
23194
|
result.script = injectedProps.code;
|
|
@@ -23351,7 +23379,7 @@ async function finalizeCompiledVueLikeResult(options) {
|
|
|
23351
23379
|
}
|
|
23352
23380
|
const hasScopedSlotHostGenerics = Boolean(result.componentGenerics && Object.keys(result.componentGenerics).length > 0);
|
|
23353
23381
|
const needsSetupSlotHostProperties = result.script && mayNeedScopedSlotHostPropertiesForSetupSlotsInJs(result.script);
|
|
23354
|
-
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23382
|
+
if (!isPage && !isApp && result.script && (hasScopedSlotHostGenerics || result.template?.includes(WEVU_SLOT_OWNER_ID_PROP) || result.template?.includes("<slot") || result.template?.includes("vueSlots") || needsSetupSlotHostProperties)) {
|
|
23355
23383
|
const injectedProps = injectScopedSlotHostPropertiesInJs(result.script);
|
|
23356
23384
|
if (injectedProps.transformed) result.script = injectedProps.code;
|
|
23357
23385
|
}
|
|
@@ -23527,8 +23555,8 @@ async function emitNativeLayoutAssetsIfNeeded(options) {
|
|
|
23527
23555
|
});
|
|
23528
23556
|
}
|
|
23529
23557
|
function emitScriptlessComponentJsFallbackIfMissing(options) {
|
|
23530
|
-
const { pluginCtx, bundle, relativeBase, scriptExtension } = options;
|
|
23531
|
-
ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension);
|
|
23558
|
+
const { pluginCtx, bundle, relativeBase, scriptExtension, source } = options;
|
|
23559
|
+
ensureScriptlessComponentAsset(pluginCtx, bundle, relativeBase, scriptExtension, source);
|
|
23532
23560
|
}
|
|
23533
23561
|
function resolveVueLayoutScriptFallbackState(options) {
|
|
23534
23562
|
const resolvedOptions = resolveVueLayoutAssetOptions({
|
|
@@ -23574,7 +23602,8 @@ async function emitVueLayoutScriptFallbackIfNeeded(options) {
|
|
|
23574
23602
|
pluginCtx,
|
|
23575
23603
|
bundle,
|
|
23576
23604
|
relativeBase: resolvedOptions.relativeBase,
|
|
23577
|
-
scriptExtension: resolvedOptions.scriptExtension
|
|
23605
|
+
scriptExtension: resolvedOptions.scriptExtension,
|
|
23606
|
+
source: SLOT_HOST_SCRIPTLESS_COMPONENT_STUB
|
|
23578
23607
|
});
|
|
23579
23608
|
}
|
|
23580
23609
|
function createBundleLayoutEmitters(options) {
|
|
@@ -23663,7 +23692,8 @@ function emitAppShellAssetsIfNeeded(options) {
|
|
|
23663
23692
|
pluginCtx: options.pluginCtx,
|
|
23664
23693
|
bundle: options.bundle,
|
|
23665
23694
|
relativeBase,
|
|
23666
|
-
scriptExtension: options.scriptExtension
|
|
23695
|
+
scriptExtension: options.scriptExtension,
|
|
23696
|
+
source: SLOT_HOST_SCRIPTLESS_COMPONENT_STUB
|
|
23667
23697
|
});
|
|
23668
23698
|
}
|
|
23669
23699
|
//#endregion
|
|
@@ -24008,8 +24038,18 @@ function parseUsingComponents(config) {
|
|
|
24008
24038
|
return {};
|
|
24009
24039
|
}
|
|
24010
24040
|
}
|
|
24041
|
+
function createSfcStyleBlocksSignature(styleBlocks) {
|
|
24042
|
+
if (!styleBlocks?.length) return "";
|
|
24043
|
+
return JSON.stringify(styleBlocks.map((styleBlock) => ({
|
|
24044
|
+
attrs: styleBlock.attrs,
|
|
24045
|
+
content: styleBlock.content,
|
|
24046
|
+
lang: styleBlock.lang,
|
|
24047
|
+
module: styleBlock.module,
|
|
24048
|
+
scoped: styleBlock.scoped
|
|
24049
|
+
})));
|
|
24050
|
+
}
|
|
24011
24051
|
async function transformVueLikeFile(options) {
|
|
24012
|
-
const { ctx, pluginCtx, code, id, compilationCache, setAppShell, pageMatcher, setPageMatcher, scanDirtySynced, setScanDirtySynced, reExportResolutionCache, compileOptionsCache, styleBlocksCache, scopedSlotModules, emittedScopedSlotChunks, classStyleRuntimeWarned, readAndParseSfc, createReadAndParseSfcOptions } = options;
|
|
24052
|
+
const { ctx, pluginCtx, code, id, compilationCache, setAppShell, pageMatcher, setPageMatcher, scanDirtySynced, setScanDirtySynced, reExportResolutionCache, compileOptionsCache, styleBlocksCache, styleRefreshTokens, scopedSlotModules, emittedScopedSlotChunks, classStyleRuntimeWarned, readAndParseSfc, createReadAndParseSfcOptions } = options;
|
|
24013
24053
|
const vueTransformTiming = ctx.configService?.weappViteConfig?.debug?.vueTransformTiming;
|
|
24014
24054
|
const { measureStage, reportTiming } = createTransformStageMeasurer(vueTransformTiming);
|
|
24015
24055
|
const configService = ctx.configService;
|
|
@@ -24023,6 +24063,7 @@ async function transformVueLikeFile(options) {
|
|
|
24023
24063
|
});
|
|
24024
24064
|
if (!filename) return null;
|
|
24025
24065
|
try {
|
|
24066
|
+
const previousStyleSignature = createSfcStyleBlocksSignature(compilationCache.get(filename)?.result.meta?.styleBlocks ?? styleBlocksCache.get(filename));
|
|
24026
24067
|
const source = await measureStage("readSource", async () => await loadTransformSource({
|
|
24027
24068
|
code,
|
|
24028
24069
|
filename,
|
|
@@ -24075,8 +24116,15 @@ async function transformVueLikeFile(options) {
|
|
|
24075
24116
|
compileVueFile,
|
|
24076
24117
|
compileJsxFile
|
|
24077
24118
|
})));
|
|
24078
|
-
|
|
24079
|
-
|
|
24119
|
+
const currentStyleBlocks = Array.isArray(result.meta?.styleBlocks) ? result.meta.styleBlocks : styleBlocksCache.get(filename);
|
|
24120
|
+
if (currentStyleBlocks) styleBlocksCache.set(filename, currentStyleBlocks);
|
|
24121
|
+
if (configService.isDev && ctx.runtimeState?.build?.hmr?.dirtyVueEntryIds?.has(filename)) {
|
|
24122
|
+
const currentStyleSignature = createSfcStyleBlocksSignature(currentStyleBlocks);
|
|
24123
|
+
const hmrEventId = ctx.runtimeState.build.hmr.profile.eventId;
|
|
24124
|
+
if (hmrEventId != null && currentStyleSignature && currentStyleSignature !== previousStyleSignature) styleRefreshTokens.set(filename, hmrEventId);
|
|
24125
|
+
else styleRefreshTokens.delete(filename);
|
|
24126
|
+
}
|
|
24127
|
+
const sfcStyleDependencies = syncVueSfcStyleDependencies(ctx, filename, currentStyleBlocks);
|
|
24080
24128
|
for (const dependency of sfcStyleDependencies) addNormalizedWatchFile(pluginCtx, dependency);
|
|
24081
24129
|
registerScopedSlotHostGenerics(ctx, result.scopedSlotComponents, parseUsingComponents(result.config));
|
|
24082
24130
|
await measureStage("finalizeCompiledResult", async () => {
|
|
@@ -24105,7 +24153,7 @@ async function transformVueLikeFile(options) {
|
|
|
24105
24153
|
isPage,
|
|
24106
24154
|
isApp,
|
|
24107
24155
|
isDev: configService.isDev,
|
|
24108
|
-
hmrStyleToken: configService.isDev
|
|
24156
|
+
hmrStyleToken: configService.isDev ? styleRefreshTokens.get(filename) : void 0
|
|
24109
24157
|
}));
|
|
24110
24158
|
reportTiming(filename, isPage);
|
|
24111
24159
|
return {
|
|
@@ -24127,6 +24175,7 @@ function createVueTransformPlugin(ctx) {
|
|
|
24127
24175
|
const reExportResolutionCache = /* @__PURE__ */ new Map();
|
|
24128
24176
|
const compileOptionsCache = /* @__PURE__ */ new Map();
|
|
24129
24177
|
const styleBlocksCache = /* @__PURE__ */ new Map();
|
|
24178
|
+
const styleRefreshTokens = /* @__PURE__ */ new Map();
|
|
24130
24179
|
const scopedSlotModules = /* @__PURE__ */ new Map();
|
|
24131
24180
|
const emittedScopedSlotChunks = /* @__PURE__ */ new Set();
|
|
24132
24181
|
const classStyleRuntimeWarned = { value: false };
|
|
@@ -24186,6 +24235,7 @@ function createVueTransformPlugin(ctx) {
|
|
|
24186
24235
|
reExportResolutionCache,
|
|
24187
24236
|
compileOptionsCache,
|
|
24188
24237
|
styleBlocksCache,
|
|
24238
|
+
styleRefreshTokens,
|
|
24189
24239
|
scopedSlotModules,
|
|
24190
24240
|
emittedScopedSlotChunks,
|
|
24191
24241
|
classStyleRuntimeWarned,
|
|
@@ -24214,12 +24264,14 @@ function createVueTransformPlugin(ctx) {
|
|
|
24214
24264
|
configService: ctx.configService,
|
|
24215
24265
|
compilationCache,
|
|
24216
24266
|
styleBlocksCache,
|
|
24267
|
+
styleRefreshTokens,
|
|
24217
24268
|
isLayoutFile,
|
|
24218
24269
|
invalidateResolvedPageLayoutsCache
|
|
24219
24270
|
});
|
|
24220
24271
|
handleTransformVueFileInvalidation(normalizedId, {
|
|
24221
24272
|
compilationCache,
|
|
24222
24273
|
styleBlocksCache,
|
|
24274
|
+
styleRefreshTokens,
|
|
24223
24275
|
existsSync: fs.existsSync
|
|
24224
24276
|
});
|
|
24225
24277
|
const profile = ctx.runtimeState?.build?.hmr?.profile;
|
|
@@ -24235,12 +24287,14 @@ function createVueTransformPlugin(ctx) {
|
|
|
24235
24287
|
configService: ctx.configService,
|
|
24236
24288
|
compilationCache,
|
|
24237
24289
|
styleBlocksCache,
|
|
24290
|
+
styleRefreshTokens,
|
|
24238
24291
|
isLayoutFile,
|
|
24239
24292
|
invalidateResolvedPageLayoutsCache
|
|
24240
24293
|
})) return [];
|
|
24241
24294
|
if (!handleTransformVueFileInvalidation(file, {
|
|
24242
24295
|
compilationCache,
|
|
24243
24296
|
styleBlocksCache,
|
|
24297
|
+
styleRefreshTokens,
|
|
24244
24298
|
existsSync: fs.existsSync
|
|
24245
24299
|
})) return;
|
|
24246
24300
|
return [];
|
|
@@ -25220,7 +25274,7 @@ function createConfigServicePlugin(ctx) {
|
|
|
25220
25274
|
}
|
|
25221
25275
|
//#endregion
|
|
25222
25276
|
//#region src/runtime/jsonPlugin.ts
|
|
25223
|
-
const APP_CONFIG_RE = /app\.json(?:\.[jt]s)?$/;
|
|
25277
|
+
const APP_CONFIG_RE = /(?:^|[/\\])app\.json(?:\.[jt]s)?$/;
|
|
25224
25278
|
const SCRIPT_JSON_CONFIG_RE = /\.json\.[jt]s$/;
|
|
25225
25279
|
function createJsonService(ctx) {
|
|
25226
25280
|
const cache = ctx.runtimeState.json.cache;
|
|
@@ -25419,7 +25473,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
25419
25473
|
const vueAppPath = await findVueEntry(appBasename);
|
|
25420
25474
|
let configFromVue;
|
|
25421
25475
|
if (!appConfigFile && vueAppPath) {
|
|
25422
|
-
const { extractConfigFromVue } = await import("./file-
|
|
25476
|
+
const { extractConfigFromVue } = await import("./file-CsjD5DM3.mjs");
|
|
25423
25477
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
25424
25478
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
25425
25479
|
}
|
|
@@ -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-BNM8-aPJ.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,4 +1,4 @@
|
|
|
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-
|
|
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-Ds7MBgQm.mjs";
|
|
2
2
|
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-CDNs17Qq.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createContext.d.ts
|
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-
|
|
4
|
+
import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-Bqsm_duR.mjs";
|
|
5
5
|
import { i as createWevuComponent, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-C3z9pDQB.mjs";
|
|
6
6
|
export { WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout };
|
package/dist/json.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-
|
|
1
|
+
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-Ds7MBgQm.mjs";
|
|
2
2
|
export { type App, type Component, type Page, type Sitemap, type Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { r as logger_default } from "./logger-mt4mSTqV.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { connectMiniProgram } from "weapp-ide-cli";
|
|
4
|
+
import { determineAgent } from "@vercel/detect-agent";
|
|
5
|
+
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, startWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
6
|
+
//#region src/aiEnvironment.ts
|
|
7
|
+
const AI_ENV_KEYS = [
|
|
8
|
+
"CODEX_HOME",
|
|
9
|
+
"CODEX_SANDBOX",
|
|
10
|
+
"CODEX_USER_AGENT",
|
|
11
|
+
"CLAUDECODE",
|
|
12
|
+
"CLAUDE_CODE",
|
|
13
|
+
"CURSOR_AGENT",
|
|
14
|
+
"GITHUB_COPILOT_AGENT",
|
|
15
|
+
"OPENAI_AGENT"
|
|
16
|
+
];
|
|
17
|
+
function isTruthyEnvValue(value) {
|
|
18
|
+
if (value === void 0) return false;
|
|
19
|
+
const normalized = value.trim().toLowerCase();
|
|
20
|
+
return normalized !== "" && normalized !== "0" && normalized !== "false" && normalized !== "no";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @description 判断当前命令是否由 AI 开发代理触发。
|
|
24
|
+
*/
|
|
25
|
+
function isAiDevelopmentEnvironment(env = process.env) {
|
|
26
|
+
if (isTruthyEnvValue(env.WEAPP_VITE_AI)) return true;
|
|
27
|
+
return AI_ENV_KEYS.some((key) => isTruthyEnvValue(env[key]));
|
|
28
|
+
}
|
|
29
|
+
function resolveAiDevelopmentEnvironmentFromEnv(env = process.env) {
|
|
30
|
+
if (isTruthyEnvValue(env.WEAPP_VITE_AI)) return {
|
|
31
|
+
agentName: env.WEAPP_VITE_AI.trim(),
|
|
32
|
+
isAgent: true
|
|
33
|
+
};
|
|
34
|
+
if (isAiDevelopmentEnvironment(env)) return { isAgent: true };
|
|
35
|
+
return { isAgent: false };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @description 使用标准 agent 检测库识别 AI 终端,并保留 weapp-vite 显式环境变量兜底。
|
|
39
|
+
*/
|
|
40
|
+
async function detectAiDevelopmentEnvironment(env = process.env) {
|
|
41
|
+
const envResult = resolveAiDevelopmentEnvironmentFromEnv(env);
|
|
42
|
+
if (envResult.isAgent) return envResult;
|
|
43
|
+
try {
|
|
44
|
+
const result = await determineAgent();
|
|
45
|
+
return {
|
|
46
|
+
agentName: result.isAgent ? result.agent.name : void 0,
|
|
47
|
+
isAgent: result.isAgent
|
|
48
|
+
};
|
|
49
|
+
} catch {
|
|
50
|
+
return envResult;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function resolveBooleanLikeEnv(value) {
|
|
54
|
+
if (value === void 0) return;
|
|
55
|
+
const normalized = value.trim().toLowerCase();
|
|
56
|
+
if (!normalized) return;
|
|
57
|
+
if (normalized === "ai") return "ai";
|
|
58
|
+
if ([
|
|
59
|
+
"1",
|
|
60
|
+
"true",
|
|
61
|
+
"yes",
|
|
62
|
+
"on"
|
|
63
|
+
].includes(normalized)) return true;
|
|
64
|
+
if ([
|
|
65
|
+
"0",
|
|
66
|
+
"false",
|
|
67
|
+
"no",
|
|
68
|
+
"off"
|
|
69
|
+
].includes(normalized)) return false;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/mcp.ts
|
|
73
|
+
function normalizeEndpoint(input) {
|
|
74
|
+
const value = typeof input === "string" ? input.trim() : "";
|
|
75
|
+
if (!value) return DEFAULT_MCP_ENDPOINT;
|
|
76
|
+
return value.startsWith("/") ? value : `/${value}`;
|
|
77
|
+
}
|
|
78
|
+
function resolveProjectMcpPort(projectRoot = process.cwd()) {
|
|
79
|
+
let hash = 0;
|
|
80
|
+
for (const char of projectRoot) hash = hash * 31 + char.charCodeAt(0) >>> 0;
|
|
81
|
+
return DEFAULT_MCP_PORT + hash % 2e4;
|
|
82
|
+
}
|
|
83
|
+
function normalizePort(input, cwd) {
|
|
84
|
+
if (input === void 0 || input === "auto") return resolveProjectMcpPort(cwd);
|
|
85
|
+
if (typeof input === "number" && Number.isInteger(input) && input > 0 && input <= 65535) return input;
|
|
86
|
+
return DEFAULT_MCP_PORT;
|
|
87
|
+
}
|
|
88
|
+
function resolveAutoStart(input, options) {
|
|
89
|
+
const env = options.env ?? process.env;
|
|
90
|
+
const value = resolveBooleanLikeEnv(env.WEAPP_VITE_MCP) ?? input ?? "ai";
|
|
91
|
+
if (value === "ai") return options.isAgent ?? resolveAiDevelopmentEnvironmentFromEnv(env).isAgent;
|
|
92
|
+
return value === true;
|
|
93
|
+
}
|
|
94
|
+
function resolveWeappMcpConfig(config, options = {}) {
|
|
95
|
+
if (config === false) return {
|
|
96
|
+
enabled: false,
|
|
97
|
+
autoStart: false,
|
|
98
|
+
host: DEFAULT_MCP_HOST,
|
|
99
|
+
port: DEFAULT_MCP_PORT,
|
|
100
|
+
endpoint: DEFAULT_MCP_ENDPOINT,
|
|
101
|
+
restEndpoint: DEFAULT_RUNTIME_REST_ENDPOINT
|
|
102
|
+
};
|
|
103
|
+
const record = typeof config === "object" && config ? config : {};
|
|
104
|
+
return {
|
|
105
|
+
agentName: options.agentName,
|
|
106
|
+
enabled: record.enabled !== false,
|
|
107
|
+
autoStart: resolveAutoStart(record.autoStart, options),
|
|
108
|
+
host: typeof record.host === "string" && record.host.trim().length > 0 ? record.host.trim() : DEFAULT_MCP_HOST,
|
|
109
|
+
port: normalizePort(record.port, options.cwd),
|
|
110
|
+
endpoint: normalizeEndpoint(record.endpoint),
|
|
111
|
+
restEndpoint: record.restEndpoint === false ? false : normalizeEndpoint(record.restEndpoint ?? DEFAULT_RUNTIME_REST_ENDPOINT)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function startWeappViteMcpServer$1(options) {
|
|
115
|
+
return startWeappViteMcpServer({
|
|
116
|
+
runtimeHooks: { connectMiniProgram },
|
|
117
|
+
...options,
|
|
118
|
+
onReady: options?.onReady ?? ((message) => {
|
|
119
|
+
logger_default.info(message);
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { createWeappViteMcpServer as a, startWeappViteMcpServer$1 as c, DEFAULT_RUNTIME_REST_ENDPOINT as i, detectAiDevelopmentEnvironment as l, DEFAULT_MCP_HOST as n, resolveProjectMcpPort as o, DEFAULT_MCP_PORT as r, resolveWeappMcpConfig as s, DEFAULT_MCP_ENDPOINT as t };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Et as WeappMcpConfig } from "./config-
|
|
1
|
+
import { Et as WeappMcpConfig } from "./config-Ds7MBgQm.mjs";
|
|
2
2
|
import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
|
5
5
|
interface ResolvedWeappMcpConfig {
|
|
6
|
+
agentName?: string;
|
|
6
7
|
enabled: boolean;
|
|
7
8
|
autoStart: boolean;
|
|
8
9
|
host: string;
|
|
@@ -12,7 +13,14 @@ interface ResolvedWeappMcpConfig {
|
|
|
12
13
|
}
|
|
13
14
|
interface WeappViteMcpServerOptions extends StartMcpServerOptions {}
|
|
14
15
|
interface WeappViteMcpServerHandle extends McpServerHandle {}
|
|
15
|
-
|
|
16
|
+
interface ResolveWeappMcpConfigOptions {
|
|
17
|
+
agentName?: string;
|
|
18
|
+
cwd?: string;
|
|
19
|
+
env?: NodeJS.ProcessEnv;
|
|
20
|
+
isAgent?: boolean;
|
|
21
|
+
}
|
|
22
|
+
declare function resolveProjectMcpPort(projectRoot?: string): number;
|
|
23
|
+
declare function resolveWeappMcpConfig(config?: boolean | WeappMcpConfig, options?: ResolveWeappMcpConfigOptions): ResolvedWeappMcpConfig;
|
|
16
24
|
declare function startWeappViteMcpServer(options?: WeappViteMcpServerOptions): Promise<WeappViteMcpServerHandle>;
|
|
17
25
|
//#endregion
|
|
18
|
-
export { type CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, ResolvedWeappMcpConfig, WeappViteMcpServerHandle, WeappViteMcpServerOptions, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
|
26
|
+
export { type CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, ResolveWeappMcpConfigOptions, ResolvedWeappMcpConfig, WeappViteMcpServerHandle, WeappViteMcpServerOptions, createWeappViteMcpServer, resolveProjectMcpPort, resolveWeappMcpConfig, startWeappViteMcpServer };
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createWeappViteMcpServer, i as DEFAULT_RUNTIME_REST_ENDPOINT, n as DEFAULT_MCP_HOST, o as
|
|
2
|
-
export { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, resolveWeappMcpConfig, startWeappViteMcpServer };
|
|
1
|
+
import { a as createWeappViteMcpServer, c as startWeappViteMcpServer, i as DEFAULT_RUNTIME_REST_ENDPOINT, n as DEFAULT_MCP_HOST, o as resolveProjectMcpPort, r as DEFAULT_MCP_PORT, s as resolveWeappMcpConfig, t as DEFAULT_MCP_ENDPOINT } from "./mcp-YXCIQr-Z.mjs";
|
|
2
|
+
export { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, resolveProjectMcpPort, resolveWeappMcpConfig, startWeappViteMcpServer };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { c as Resolver } from "./index-Bmclyjw8.mjs";
|
|
2
2
|
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-C7fCmf92.mjs";
|
|
3
|
-
import { $ as WeappAnalyzeBudgetConfig, $t as GenerateTemplateFileSource, A as Ref, An as WeappLibFileName, At as WeappRouteRules, B as BindingErrorLike, Bn as WeappViteHostMeta, Bt as BuildNpmPackageMeta, Cn as SubPackageStyleConfigObject, Ct as WeappInjectWeapiConfig, D as MethodDefinitions, Dn as WeappLibConfig, Dt as WeappNpmConfig, E as InlineConfig, En as WeappLibComponentJson, Et as WeappMcpConfig, F as RolldownPlugin, Fn as WeappManagedServerTsconfigConfig, Ft as WeappWevuConfig, G as EntryJsonFragment, Gt as GenerateExtensionsOptions, H as BaseEntry, Ht as CopyGlobs, I as RolldownPluginOption, In as WeappManagedSharedTsconfigConfig, It as WeappWorkerConfig, J as ScanComponentItem, Jt as GenerateOptions, K as PageEntry, Kt as GenerateFileType, L as RolldownWatchOptions, Ln as WeappManagedTypeScriptConfig, Lt as Alias, M as RolldownBuild, Mn as WeappLibVueTscOptions, Mt as WeappVueConfig, N as RolldownOptions, Nn as WeappManagedAppTsconfigConfig, Nt as WeappVueTemplateConfig, O as Plugin, On as WeappLibDtsOptions, Ot as WeappRequestRuntimeConfig, P as RolldownOutput, Pn as WeappManagedNodeTsconfigConfig, Pt as WeappWebRuntimeConfig, Q as UserConfig, Qt as GenerateTemplateFactory, R as RolldownWatcher, Rn as WeappWebConfig, Rt as AliasOptions, Sn as SubPackageStyleConfigEntry, St as WeappInjectRequestGlobalsTarget, T as ConfigEnv, Tn as SubPackageStyleScope, Tt as WeappInjectWebRuntimeGlobalsTarget, U as ComponentEntry, Ut as CopyOptions, V as AppEntry, Vt as ChunksConfig, W as Entry, Wt as GenerateDirsOptions, X as ProjectConfig, Xt as GenerateTemplateContext, Y as WxmlDep, Yn as WeappViteRuntime, Yt as GenerateTemplate, Z as SubPackageMetaValue, Zt as GenerateTemplateEntry, _n as SharedChunkDynamicImports, _t as WeappAutoRoutesIncludePattern, an as JsonMergeContext, at as WeappViteConfig, b as ChangeEvent, bn as SharedChunkStrategy, bt as WeappHmrConfig, cn as JsonMergeStrategy, ct as EnhanceOptions, dn as NpmDependencyPattern, dt as MultiPlatformConfig, en as GenerateTemplateInlineSource, et as WeappAnalyzeConfig, fn as NpmMainPackageConfig, ft as ScanWxmlOptions, gn as ResolvedAlias, gt as WeappAutoRoutesInclude, hn as NpmSubPackageConfig, ht as WeappAutoRoutesConfig, in as JsonConfig, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as WeappLibInternalDtsOptions, jt as WeappSubPackageConfig, k as PluginOption, kn as WeappLibEntryContext, kt as WeappRouteRule, ln as MpPlatform, lt as EnhanceWxmlOptions, mn as NpmStrategy, mt as WeappAppPreludeMode, nn as GenerateTemplatesConfig, nt as WeappDebugConfig, on as JsonMergeFunction, ot as AutoImportComponents, pn as NpmPluginPackageConfig, pt as WeappAppPreludeConfig, q as ComponentsMap, qt as GenerateFilenamesOptions, rn as JsFormat, rt as WeappForwardConsoleConfig, sn as JsonMergeStage, st as AutoImportComponentsOption, tn as GenerateTemplateScope, tt as WeappAnalyzeHistoryConfig, un as NpmBuildOptions, ut as HandleWxmlOptions, vn as SharedChunkMode, vt as WeappBuildScopeConfig, w as ComputedDefinitions, wn as SubPackageStyleEntry, wt as WeappInjectWebRuntimeGlobalsConfig, x as WeappVitePluginApi, xn as SubPackage, xt as WeappInjectRequestGlobalsConfig, yn as SharedChunkOverride, yt as WeappBuildScopeObjectConfig, z as ViteDevServer, zt as AlipayNpmMode } from "./config-
|
|
3
|
+
import { $ as WeappAnalyzeBudgetConfig, $t as GenerateTemplateFileSource, A as Ref, An as WeappLibFileName, At as WeappRouteRules, B as BindingErrorLike, Bn as WeappViteHostMeta, Bt as BuildNpmPackageMeta, Cn as SubPackageStyleConfigObject, Ct as WeappInjectWeapiConfig, D as MethodDefinitions, Dn as WeappLibConfig, Dt as WeappNpmConfig, E as InlineConfig, En as WeappLibComponentJson, Et as WeappMcpConfig, F as RolldownPlugin, Fn as WeappManagedServerTsconfigConfig, Ft as WeappWevuConfig, G as EntryJsonFragment, Gt as GenerateExtensionsOptions, H as BaseEntry, Ht as CopyGlobs, I as RolldownPluginOption, In as WeappManagedSharedTsconfigConfig, It as WeappWorkerConfig, J as ScanComponentItem, Jt as GenerateOptions, K as PageEntry, Kt as GenerateFileType, L as RolldownWatchOptions, Ln as WeappManagedTypeScriptConfig, Lt as Alias, M as RolldownBuild, Mn as WeappLibVueTscOptions, Mt as WeappVueConfig, N as RolldownOptions, Nn as WeappManagedAppTsconfigConfig, Nt as WeappVueTemplateConfig, O as Plugin, On as WeappLibDtsOptions, Ot as WeappRequestRuntimeConfig, P as RolldownOutput, Pn as WeappManagedNodeTsconfigConfig, Pt as WeappWebRuntimeConfig, Q as UserConfig, Qt as GenerateTemplateFactory, R as RolldownWatcher, Rn as WeappWebConfig, Rt as AliasOptions, Sn as SubPackageStyleConfigEntry, St as WeappInjectRequestGlobalsTarget, T as ConfigEnv, Tn as SubPackageStyleScope, Tt as WeappInjectWebRuntimeGlobalsTarget, U as ComponentEntry, Ut as CopyOptions, V as AppEntry, Vt as ChunksConfig, W as Entry, Wt as GenerateDirsOptions, X as ProjectConfig, Xt as GenerateTemplateContext, Y as WxmlDep, Yn as WeappViteRuntime, Yt as GenerateTemplate, Z as SubPackageMetaValue, Zt as GenerateTemplateEntry, _n as SharedChunkDynamicImports, _t as WeappAutoRoutesIncludePattern, an as JsonMergeContext, at as WeappViteConfig, b as ChangeEvent, bn as SharedChunkStrategy, bt as WeappHmrConfig, cn as JsonMergeStrategy, ct as EnhanceOptions, dn as NpmDependencyPattern, dt as MultiPlatformConfig, en as GenerateTemplateInlineSource, et as WeappAnalyzeConfig, fn as NpmMainPackageConfig, ft as ScanWxmlOptions, gn as ResolvedAlias, gt as WeappAutoRoutesInclude, hn as NpmSubPackageConfig, ht as WeappAutoRoutesConfig, in as JsonConfig, it as WeappForwardConsoleLogLevel, j as ResolvedConfig, jn as WeappLibInternalDtsOptions, jt as WeappSubPackageConfig, k as PluginOption, kn as WeappLibEntryContext, kt as WeappRouteRule, ln as MpPlatform, lt as EnhanceWxmlOptions, mn as NpmStrategy, mt as WeappAppPreludeMode, nn as GenerateTemplatesConfig, nt as WeappDebugConfig, on as JsonMergeFunction, ot as AutoImportComponents, pn as NpmPluginPackageConfig, pt as WeappAppPreludeConfig, q as ComponentsMap, qt as GenerateFilenamesOptions, rn as JsFormat, rt as WeappForwardConsoleConfig, sn as JsonMergeStage, st as AutoImportComponentsOption, tn as GenerateTemplateScope, tt as WeappAnalyzeHistoryConfig, un as NpmBuildOptions, ut as HandleWxmlOptions, vn as SharedChunkMode, vt as WeappBuildScopeConfig, w as ComputedDefinitions, wn as SubPackageStyleEntry, wt as WeappInjectWebRuntimeGlobalsConfig, x as WeappVitePluginApi, xn as SubPackage, xt as WeappInjectRequestGlobalsConfig, yn as SharedChunkOverride, yt as WeappBuildScopeObjectConfig, z as ViteDevServer, zt as AlipayNpmMode } from "./config-Ds7MBgQm.mjs";
|
|
4
4
|
export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, type ComputedDefinitions, type ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, type InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, type MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, type Plugin, type PluginOption, ProjectConfig, type Ref, ResolvedAlias, type ResolvedConfig, type Resolver, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, type ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappBuildScopeConfig, WeappBuildScopeObjectConfig, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, type WeappViteHostMeta, WeappVitePluginApi, type WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
|