@wevu/compiler 6.18.7 → 6.19.1
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/index.d.mts +56 -1
- package/dist/index.mjs +711 -146
- package/package.json +8 -6
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { WEAPP_VITE_RUNTIME_REACTIVITY_VIRTUAL_ID, WEAPP_VITE_RUNTIME_TEMPLATE_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_ID, WEVU_CLASS_STYLE_RUNTIME_FILE, WEVU_CLASS_STYLE_RUNTIME_MODULE, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_FUNCTION_PROP_PATHS_KEY, WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_IS_PAGE_KEY, WEVU_LAYOUT_HOSTS_KEY, WEVU_LAYOUT_HOST_ID_PREFIX, WEVU_LAYOUT_HOST_REF_PREFIX, WEVU_MODEL_HANDLER, WEVU_OWNER_HANDLER, WEVU_PROPS_ALIASES_KEY, WEVU_PROPS_DERIVED_KEYS_KEY, WEVU_PROPS_KEY, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME, WEVU_SLOT_NAMES_ATTR, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_OWNER_KEY, WEVU_SLOT_OWNER_PROXY_KEY, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_PROPS_DATA_KEY, WEVU_SLOT_PROPS_KEY, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY, WEVU_TEMPLATE_REFS_KEY, WEVU_TEMPLATE_REF_CLASS_PREFIX } from "@weapp-core/constants";
|
|
2
|
+
import { WEAPP_VITE_RUNTIME_REACTIVITY_VIRTUAL_ID, WEAPP_VITE_RUNTIME_TEMPLATE_VIRTUAL_ID, WEAPP_VITE_RUNTIME_VIRTUAL_ID, WEVU_CLASS_STYLE_RUNTIME_FILE, WEVU_CLASS_STYLE_RUNTIME_MODULE, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_FUNCTION_PROP_PATHS_KEY, WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_IS_PAGE_KEY, WEVU_LAYOUT_HOSTS_KEY, WEVU_LAYOUT_HOST_ID_PREFIX, WEVU_LAYOUT_HOST_REF_PREFIX, WEVU_MODEL_HANDLER, WEVU_OWNER_HANDLER, WEVU_PROPS_ALIASES_KEY, WEVU_PROPS_DERIVED_KEYS_KEY, WEVU_PROPS_KEY, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME, WEVU_SLOT_FUNCTION_TOKEN, WEVU_SLOT_NAMES_ATTR, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_OWNER_KEY, WEVU_SLOT_OWNER_PROXY_KEY, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_PROPS_DATA_KEY, WEVU_SLOT_PROPS_KEY, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY, WEVU_TEMPLATE_REFS_KEY, WEVU_TEMPLATE_REF_CLASS_PREFIX } from "@weapp-core/constants";
|
|
3
3
|
import { getMiniProgramRuntimeGlobalKeys, getMiniProgramTemplatePreset, removeExtensionDeep } from "@weapp-core/shared";
|
|
4
4
|
import path from "pathe";
|
|
5
5
|
import { NodeTypes, baseParse } from "@vue/compiler-core";
|
|
@@ -17,6 +17,8 @@ import { LRUCache } from "lru-cache";
|
|
|
17
17
|
import { collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, getRenderPropertyFromComponentOptions, parseJsLikeWithEngine, resolveRenderExpressionFromComponentOptions, toStaticObjectKey, unwrapTypeScriptExpression } from "@weapp-vite/ast";
|
|
18
18
|
import { compileScript, parse } from "vue/compiler-sfc";
|
|
19
19
|
import { fileURLToPath } from "node:url";
|
|
20
|
+
import postcss from "postcss";
|
|
21
|
+
import selectorParser from "postcss-selector-parser";
|
|
20
22
|
import { parse as parse$1 } from "@vue/compiler-dom";
|
|
21
23
|
import { parse as parse$2 } from "comment-json";
|
|
22
24
|
import vm from "node:vm";
|
|
@@ -563,7 +565,8 @@ function resolveMacroAlias(macroName) {
|
|
|
563
565
|
}
|
|
564
566
|
async function evaluateScriptSetupJsonMacro(params) {
|
|
565
567
|
const { preambleContent, originalContent, filename, lang, macroName, macroStatements, bodyPaths, keptStatementPaths, options } = params;
|
|
566
|
-
const
|
|
568
|
+
const combinedContent = preambleContent ? `${preambleContent}\n${originalContent}` : originalContent;
|
|
569
|
+
const ms = new MagicString(combinedContent);
|
|
567
570
|
const dir = path.dirname(filename);
|
|
568
571
|
const tempRoot = resolveWevuConfigTempDir(dir);
|
|
569
572
|
const basename = path.basename(filename, path.extname(filename));
|
|
@@ -928,7 +931,8 @@ function collectWevuPageFeatureFlags(ast) {
|
|
|
928
931
|
for (const stmt of ast.program.body) {
|
|
929
932
|
if (!t.isImportDeclaration(stmt) || !isWevuRuntimeModuleId(stmt.source.value)) continue;
|
|
930
933
|
for (const specifier of stmt.specifiers) if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported)) {
|
|
931
|
-
const
|
|
934
|
+
const importedName = specifier.imported.name;
|
|
935
|
+
const matched = WE_VU_PAGE_HOOK_TO_FEATURE[importedName];
|
|
932
936
|
if (matched) namedHookLocals.set(specifier.local.name, matched);
|
|
933
937
|
} else if (t.isImportNamespaceSpecifier(specifier)) namespaceLocals.add(specifier.local.name);
|
|
934
938
|
}
|
|
@@ -1069,7 +1073,8 @@ function createModuleAnalysis(id, ast) {
|
|
|
1069
1073
|
for (const specifier of stmt.specifiers) if (t.isImportSpecifier(specifier)) {
|
|
1070
1074
|
const imported = specifier.imported;
|
|
1071
1075
|
if (isWevuRuntimeModuleId(source) && t.isIdentifier(imported)) {
|
|
1072
|
-
const
|
|
1076
|
+
const importedName = imported.name;
|
|
1077
|
+
const matched = WE_VU_PAGE_HOOK_TO_FEATURE[importedName];
|
|
1073
1078
|
if (matched) wevuNamedHookLocals.set(specifier.local.name, matched);
|
|
1074
1079
|
}
|
|
1075
1080
|
importedBindings.set(specifier.local.name, {
|
|
@@ -1302,9 +1307,10 @@ function createModuleAnalysisWithOxc(id, code) {
|
|
|
1302
1307
|
//#region src/plugins/wevu/pageFeatures/moduleAnalysis/index.ts
|
|
1303
1308
|
const TS_WITHOUT_JSX_RE = /\.[cm]?ts(?:[?#].*)?$/i;
|
|
1304
1309
|
function parseModuleAnalysisAst(id, code) {
|
|
1310
|
+
const plugins = TS_WITHOUT_JSX_RE.test(id) ? BABEL_TS_MODULE_PLUGINS.filter((plugin) => plugin !== "jsx") : BABEL_TS_MODULE_PLUGINS;
|
|
1305
1311
|
return parse$3(code, {
|
|
1306
1312
|
sourceType: "module",
|
|
1307
|
-
plugins
|
|
1313
|
+
plugins
|
|
1308
1314
|
});
|
|
1309
1315
|
}
|
|
1310
1316
|
function createModuleAnalysisFromCode(id, code, options) {
|
|
@@ -1356,7 +1362,8 @@ function collectWithOxc(code) {
|
|
|
1356
1362
|
if (matched) enabled.add(matched);
|
|
1357
1363
|
} else if (callee?.type === "MemberExpression" && !callee.computed && callee.object?.type === "Identifier" && callee.property?.type === "Identifier") {
|
|
1358
1364
|
if (module.wevuNamespaceLocals.has(callee.object.name)) {
|
|
1359
|
-
const
|
|
1365
|
+
const hook = callee.property.name;
|
|
1366
|
+
const matched = WE_VU_PAGE_HOOK_TO_FEATURE[hook];
|
|
1360
1367
|
if (matched) enabled.add(matched);
|
|
1361
1368
|
}
|
|
1362
1369
|
}
|
|
@@ -1690,7 +1697,8 @@ function collectWevuHookCallsInFunctionBody(module, fn) {
|
|
|
1690
1697
|
if (matched) enabled.add(matched);
|
|
1691
1698
|
} else if (callee?.type === "MemberExpression" && !callee.computed && callee.object?.type === "Identifier" && callee.property?.type === "Identifier") {
|
|
1692
1699
|
if (module.wevuNamespaceLocals.has(callee.object.name)) {
|
|
1693
|
-
const
|
|
1700
|
+
const hook = callee.property.name;
|
|
1701
|
+
const matched = WE_VU_PAGE_HOOK_TO_FEATURE[hook];
|
|
1694
1702
|
if (matched) enabled.add(matched);
|
|
1695
1703
|
}
|
|
1696
1704
|
}
|
|
@@ -2248,7 +2256,7 @@ const JSON_MACRO_RE = /\bdefine(?:App|Page|Component|Sitemap|Theme)Json\s*\(/;
|
|
|
2248
2256
|
const PAGE_META_RE = /\bdefinePageMeta\s*\(/;
|
|
2249
2257
|
function hasMetadataInjectionOptions(options) {
|
|
2250
2258
|
const hasWevuDefaults = options?.wevuDefaults && Object.keys(options.wevuDefaults).length > 0;
|
|
2251
|
-
return Boolean(options?.isApp || options?.skipComponentTransform || options?.minify || options?.sourceMap !== false || options?.templateComponentMeta || hasWevuDefaults || options?.classStyleBindings?.length || options?.templateRefs?.length || options?.layoutHosts?.length || options?.inlineExpressions?.length || options?.functionPropPaths?.length || options?.propsAliases || options?.propsDerivedKeys?.length || options?.relaxStructuredTypeOnlyProps || options?.scopedSlotHostProperties);
|
|
2259
|
+
return Boolean(options?.isTypeScript || options?.isApp || options?.skipComponentTransform || options?.minify || options?.sourceMap !== false || options?.templateComponentMeta || hasWevuDefaults || options?.classStyleBindings?.length || options?.templateRefs?.length || options?.layoutHosts?.length || options?.inlineExpressions?.length || options?.functionPropPaths?.length || options?.propsAliases || options?.propsDerivedKeys?.length || options?.relaxStructuredTypeOnlyProps || options?.scopedSlotHostProperties);
|
|
2252
2260
|
}
|
|
2253
2261
|
function findMatchingCallEnd(source, openParenIndex) {
|
|
2254
2262
|
let depth = 0;
|
|
@@ -2302,7 +2310,7 @@ function findMatchingCallEnd(source, openParenIndex) {
|
|
|
2302
2310
|
return -1;
|
|
2303
2311
|
}
|
|
2304
2312
|
function stripCompiledScriptSetupMarkers(optionsSource) {
|
|
2305
|
-
return optionsSource.replace(/^\s*__name:\s*['"][^'"]+['"],?\n?/m, "").replace(/\{\s*expose:\s*__expose\s*\}/g, "{ expose }").replace(/\b__expose
|
|
2313
|
+
return optionsSource.replace(/^\s*__name:\s*['"][^'"]+['"],?\n?/m, "").replace(/\{\s*expose:\s*__expose\s*\}/g, "{ expose }").replace(/\b__expose(?=\s*\()/g, "expose").replace(/^\s*Object\.defineProperty\(\s*__returned__\s*,\s*['"]__isScriptSetup['"]\s*,\s*\{\s*enumerable:\s*false\s*,\s*value:\s*true\s*\}\s*\);?\n?/m, "");
|
|
2306
2314
|
}
|
|
2307
2315
|
/**
|
|
2308
2316
|
* 转换 Vue compileScript 产出的标准 `<script setup>` 脚本。
|
|
@@ -2327,7 +2335,7 @@ function tryFastTransformCompiledScriptSetup(source, options) {
|
|
|
2327
2335
|
const trailing = afterImport.slice(callEnd + 1).trim();
|
|
2328
2336
|
if (trailing && trailing !== ";") return;
|
|
2329
2337
|
const componentOptions = stripCompiledScriptSetupMarkers(afterImport.slice(openParenIndex + 1, callEnd).trim());
|
|
2330
|
-
const pageMarker = options?.isPage
|
|
2338
|
+
const pageMarker = ` __wevu_isPage: ${options?.isPage === true},\n`;
|
|
2331
2339
|
return {
|
|
2332
2340
|
code: [
|
|
2333
2341
|
`import { ${WE_VU_RUNTIME_APIS.createWevuComponent} } from "${RUNTIME_IMPORT_PATH}";`,
|
|
@@ -2968,6 +2976,13 @@ function buildObjectMapExpression(binding, forStack, level, listId, helpers) {
|
|
|
2968
2976
|
t.returnStatement(resId)
|
|
2969
2977
|
]);
|
|
2970
2978
|
}
|
|
2979
|
+
function buildNumericListNormalization(level, listId) {
|
|
2980
|
+
const indexId = t.identifier(`__wv_numeric_index_${level}`);
|
|
2981
|
+
const numberCheck = t.logicalExpression("&&", t.binaryExpression("===", t.unaryExpression("typeof", listId), t.stringLiteral("number")), t.callExpression(t.memberExpression(t.identifier("Number"), t.identifier("isFinite")), [listId]));
|
|
2982
|
+
const length = t.callExpression(t.memberExpression(t.identifier("Math"), t.identifier("max")), [t.numericLiteral(0), t.callExpression(t.memberExpression(t.identifier("Math"), t.identifier("floor")), [listId])]);
|
|
2983
|
+
const normalized = t.callExpression(t.memberExpression(t.identifier("Array"), t.identifier("from")), [t.objectExpression([t.objectProperty(t.identifier("length"), length)]), t.arrowFunctionExpression([t.identifier("_"), indexId], indexId)]);
|
|
2984
|
+
return t.ifStatement(numberCheck, t.blockStatement([t.expressionStatement(t.assignmentExpression("=", listId, normalized))]));
|
|
2985
|
+
}
|
|
2971
2986
|
function buildForExpression(binding, forStack, level, helpers) {
|
|
2972
2987
|
if (level >= forStack.length) return buildNormalizedExpression(binding, helpers);
|
|
2973
2988
|
const info = forStack[level];
|
|
@@ -2985,6 +3000,7 @@ function buildForExpression(binding, forStack, level, helpers) {
|
|
|
2985
3000
|
const body = t.blockStatement([
|
|
2986
3001
|
listDecl,
|
|
2987
3002
|
listSafeAssign,
|
|
3003
|
+
buildNumericListNormalization(level, listId),
|
|
2988
3004
|
t.ifStatement(arrayCheck, t.blockStatement([t.returnStatement(arrayMap)]), t.ifStatement(objectCheck, objectBlock, t.blockStatement([fallbackReturn])))
|
|
2989
3005
|
]);
|
|
2990
3006
|
return t.callExpression(t.arrowFunctionExpression([], body), []);
|
|
@@ -3242,6 +3258,40 @@ const BABEL_GENERATE_MINI_PROGRAM_OPTIONS = {
|
|
|
3242
3258
|
minimal: true
|
|
3243
3259
|
}
|
|
3244
3260
|
};
|
|
3261
|
+
function stripPatternTypes(node) {
|
|
3262
|
+
if (!node || typeof node !== "object") return;
|
|
3263
|
+
if ("typeAnnotation" in node) node.typeAnnotation = null;
|
|
3264
|
+
if ("optional" in node) node.optional = false;
|
|
3265
|
+
if (node.type === "AssignmentPattern") stripPatternTypes(node.left);
|
|
3266
|
+
else if (node.type === "RestElement") stripPatternTypes(node.argument);
|
|
3267
|
+
else if (node.type === "ObjectPattern") for (const property of node.properties) stripPatternTypes(property.type === "RestElement" ? property.argument : property.value);
|
|
3268
|
+
else if (node.type === "ArrayPattern") for (const element of node.elements) stripPatternTypes(element);
|
|
3269
|
+
}
|
|
3270
|
+
function stripTypeScriptExpression(ast) {
|
|
3271
|
+
traverse(ast, {
|
|
3272
|
+
TSAsExpression(path) {
|
|
3273
|
+
path.replaceWith(path.node.expression);
|
|
3274
|
+
},
|
|
3275
|
+
TSNonNullExpression(path) {
|
|
3276
|
+
path.replaceWith(path.node.expression);
|
|
3277
|
+
},
|
|
3278
|
+
TSTypeAssertion(path) {
|
|
3279
|
+
path.replaceWith(path.node.expression);
|
|
3280
|
+
},
|
|
3281
|
+
Function(path) {
|
|
3282
|
+
path.node.typeParameters = null;
|
|
3283
|
+
path.node.returnType = null;
|
|
3284
|
+
for (const param of path.node.params) stripPatternTypes(param);
|
|
3285
|
+
}
|
|
3286
|
+
});
|
|
3287
|
+
return ast;
|
|
3288
|
+
}
|
|
3289
|
+
function parseTypeScriptExpression(exp) {
|
|
3290
|
+
return stripTypeScriptExpression(parse$3(`(${exp})`, {
|
|
3291
|
+
sourceType: "module",
|
|
3292
|
+
plugins: ["typescript"]
|
|
3293
|
+
}));
|
|
3294
|
+
}
|
|
3245
3295
|
function generateExpression(node) {
|
|
3246
3296
|
const { code } = generate(node, BABEL_GENERATE_MINI_PROGRAM_OPTIONS);
|
|
3247
3297
|
return code;
|
|
@@ -3250,10 +3300,7 @@ function parseBabelExpression(exp) {
|
|
|
3250
3300
|
const cached = babelExpressionCache.get(exp);
|
|
3251
3301
|
if (cached !== void 0) return cached === false ? null : cached;
|
|
3252
3302
|
try {
|
|
3253
|
-
const stmt =
|
|
3254
|
-
sourceType: "module",
|
|
3255
|
-
plugins: ["typescript"]
|
|
3256
|
-
}).program.body[0];
|
|
3303
|
+
const stmt = parseTypeScriptExpression(exp).program.body[0];
|
|
3257
3304
|
if (!stmt || !("expression" in stmt)) {
|
|
3258
3305
|
babelExpressionCache.set(exp, false);
|
|
3259
3306
|
return null;
|
|
@@ -3268,10 +3315,7 @@ function parseBabelExpression(exp) {
|
|
|
3268
3315
|
}
|
|
3269
3316
|
function parseBabelExpressionFile(exp) {
|
|
3270
3317
|
try {
|
|
3271
|
-
const ast =
|
|
3272
|
-
sourceType: "module",
|
|
3273
|
-
plugins: ["typescript"]
|
|
3274
|
-
});
|
|
3318
|
+
const ast = parseTypeScriptExpression(exp);
|
|
3275
3319
|
const stmt = ast.program.body[0];
|
|
3276
3320
|
if (!stmt || !("expression" in stmt)) return null;
|
|
3277
3321
|
return {
|
|
@@ -3676,8 +3720,8 @@ function rewriteDefaultExport(ast, state, options, enabledPageFeatures, serializ
|
|
|
3676
3720
|
const componentExpr = resolveComponentExpression(exportPath.node.declaration, state.defineComponentDecls, state.defineComponentAliases);
|
|
3677
3721
|
const componentOptionsObject = resolveComponentOptionsObject(componentExpr);
|
|
3678
3722
|
const hasPageMarker = componentExpr ? hasStaticPropertyInComponentExpression(componentExpr, WEVU_IS_PAGE_KEY, ast.program) : false;
|
|
3679
|
-
if (componentOptionsObject &&
|
|
3680
|
-
componentOptionsObject.properties.splice(0, 0, t.objectProperty(t.identifier(WEVU_IS_PAGE_KEY), t.booleanLiteral(true)));
|
|
3723
|
+
if (componentOptionsObject && !options?.isApp && !hasPageMarker) {
|
|
3724
|
+
componentOptionsObject.properties.splice(0, 0, t.objectProperty(t.identifier(WEVU_IS_PAGE_KEY), t.booleanLiteral(options?.isPage === true)));
|
|
3681
3725
|
transformed = true;
|
|
3682
3726
|
}
|
|
3683
3727
|
if (componentOptionsObject && enabledPageFeatures.size) transformed = injectWevuPageFeatureFlagsIntoOptionsObject(componentOptionsObject, enabledPageFeatures) || transformed;
|
|
@@ -3755,7 +3799,7 @@ function transformScript(source, options) {
|
|
|
3755
3799
|
const macroVisitors = createMacroVisitors(ast.program, state);
|
|
3756
3800
|
const importVisitors = createImportVisitors(ast.program, state);
|
|
3757
3801
|
const collectVisitors = createCollectVisitors(state);
|
|
3758
|
-
|
|
3802
|
+
const visitor = {
|
|
3759
3803
|
...vueSfcVisitors,
|
|
3760
3804
|
...macroVisitors,
|
|
3761
3805
|
...importVisitors,
|
|
@@ -3768,7 +3812,8 @@ function transformScript(source, options) {
|
|
|
3768
3812
|
runVisitor(vueSfcVisitors.CallExpression, path);
|
|
3769
3813
|
if (!path.removed) runVisitor(macroVisitors.CallExpression, path);
|
|
3770
3814
|
}
|
|
3771
|
-
}
|
|
3815
|
+
};
|
|
3816
|
+
traverse(ast, visitor);
|
|
3772
3817
|
if (options?.templateComponentMeta) state.transformed = pruneTemplateComponentMeta(ast, options.templateComponentMeta) || state.transformed;
|
|
3773
3818
|
state.transformed = rewriteDefaultExport(ast, state, options, enabledPageFeatures, serializedWevuDefaults, parsedWevuDefaults) || state.transformed;
|
|
3774
3819
|
if (!state.transformed) return {
|
|
@@ -3870,8 +3915,35 @@ const EMPTY_STRING_CONCAT_LEFT_RE = /'\s*\+\s*''/g;
|
|
|
3870
3915
|
const EMPTY_STRING_CONCAT_RIGHT_RE = /''\s*\+\s*'/g;
|
|
3871
3916
|
const LEADING_EMPTY_CONCAT_RE = /^\s*''\s*\+\s*/g;
|
|
3872
3917
|
const TRAILING_EMPTY_CONCAT_RE = /\s*\+\s*''\s*$/g;
|
|
3918
|
+
function rewriteVueSlotsExpression(ast) {
|
|
3919
|
+
traverse(ast, {
|
|
3920
|
+
MemberExpression: { exit(path) {
|
|
3921
|
+
const node = path.node;
|
|
3922
|
+
if (!t.isIdentifier(node.object, { name: "$slots" })) return;
|
|
3923
|
+
const access = t.memberExpression(t.identifier("vueSlots"), t.cloneNode(node.property), node.computed);
|
|
3924
|
+
path.replaceWith(t.logicalExpression("&&", t.identifier("vueSlots"), access));
|
|
3925
|
+
path.skip();
|
|
3926
|
+
} },
|
|
3927
|
+
OptionalMemberExpression: { exit(path) {
|
|
3928
|
+
const node = path.node;
|
|
3929
|
+
if (!t.isIdentifier(node.object, { name: "$slots" })) return;
|
|
3930
|
+
const access = t.memberExpression(t.identifier("vueSlots"), t.cloneNode(node.property), node.computed);
|
|
3931
|
+
path.replaceWith(t.logicalExpression("&&", t.identifier("vueSlots"), access));
|
|
3932
|
+
path.skip();
|
|
3933
|
+
} },
|
|
3934
|
+
Identifier: { exit(path) {
|
|
3935
|
+
if (!path.isReferencedIdentifier() || path.node.name !== "$slots") return;
|
|
3936
|
+
const parent = path.parentPath.node;
|
|
3937
|
+
if ((t.isMemberExpression(parent) || t.isOptionalMemberExpression(parent)) && parent.object === path.node) return;
|
|
3938
|
+
path.replaceWith(t.identifier("vueSlots"));
|
|
3939
|
+
path.skip();
|
|
3940
|
+
} }
|
|
3941
|
+
});
|
|
3942
|
+
}
|
|
3873
3943
|
function normalizeWxmlExpression(exp) {
|
|
3874
|
-
|
|
3944
|
+
const hasTypeScriptSyntax = /\s(?:as|satisfies)\s/.test(exp) || /[\w$)\]]!(?=[.[\s,);:?]|$)/.test(exp) || /^\s*<[^>]+>/.test(exp);
|
|
3945
|
+
const needsVueSlotsRewrite = exp.includes("$slots");
|
|
3946
|
+
if (!exp.includes("`") && !exp.includes("??") && !exp.includes("?.") && !hasTypeScriptSyntax && !needsVueSlotsRewrite) return exp;
|
|
3875
3947
|
try {
|
|
3876
3948
|
const ast = parse$3(`(${exp})`, {
|
|
3877
3949
|
sourceType: "module",
|
|
@@ -3879,7 +3951,17 @@ function normalizeWxmlExpression(exp) {
|
|
|
3879
3951
|
});
|
|
3880
3952
|
const stmt = ast.program.body[0];
|
|
3881
3953
|
if (!stmt || !("expression" in stmt)) return exp;
|
|
3954
|
+
if (needsVueSlotsRewrite) rewriteVueSlotsExpression(ast);
|
|
3882
3955
|
traverse(ast, {
|
|
3956
|
+
TSAsExpression(path) {
|
|
3957
|
+
path.replaceWith(path.node.expression);
|
|
3958
|
+
},
|
|
3959
|
+
TSNonNullExpression(path) {
|
|
3960
|
+
path.replaceWith(path.node.expression);
|
|
3961
|
+
},
|
|
3962
|
+
TSTypeAssertion(path) {
|
|
3963
|
+
path.replaceWith(path.node.expression);
|
|
3964
|
+
},
|
|
3883
3965
|
OptionalMemberExpression: { exit(path) {
|
|
3884
3966
|
if (isOptionalChainNode(path.parentPath.node)) return;
|
|
3885
3967
|
path.replaceWith(lowerOptionalChain(path.node));
|
|
@@ -3966,7 +4048,8 @@ function collectExpressionScopeBindings(exp, context) {
|
|
|
3966
4048
|
if (!localSet.size) return [];
|
|
3967
4049
|
const used = [];
|
|
3968
4050
|
const usedSet = /* @__PURE__ */ new Set();
|
|
3969
|
-
|
|
4051
|
+
const file = t.file(t.program([t.expressionStatement(t.cloneNode(exp, true))]));
|
|
4052
|
+
traverse(file, { Identifier(path) {
|
|
3970
4053
|
if (!path.isReferencedIdentifier()) return;
|
|
3971
4054
|
const name = path.node.name;
|
|
3972
4055
|
if (!localSet.has(name)) return;
|
|
@@ -4912,7 +4995,7 @@ async function compileJsxFile(source, filename, options) {
|
|
|
4912
4995
|
}
|
|
4913
4996
|
const normalizedScriptSource = stripRenderOptionFromScript(scriptSource, filename, options?.warn);
|
|
4914
4997
|
const transformedScript = transformScript(normalizedScriptSource, {
|
|
4915
|
-
skipComponentTransform: options?.isApp,
|
|
4998
|
+
skipComponentTransform: options?.skipComponentTransform ?? options?.isApp,
|
|
4916
4999
|
isApp: options?.isApp,
|
|
4917
5000
|
isPage: options?.isPage,
|
|
4918
5001
|
minify: options?.minify,
|
|
@@ -4951,6 +5034,277 @@ async function compileJsxFile(source, filename, options) {
|
|
|
4951
5034
|
};
|
|
4952
5035
|
}
|
|
4953
5036
|
//#endregion
|
|
5037
|
+
//#region src/plugins/uniApp/index.ts
|
|
5038
|
+
const DIRECTIVE_TOKEN_RE = /\/\/\s*#(?:ifdef|ifndef|else|endif)\b[^\r\n]*|\/\*+\s*#(?:ifdef|ifndef|else|endif)\b[\s\S]*?\*\/|<!--\s*#(?:ifdef|ifndef|else|endif)\b[\s\S]*?-->/g;
|
|
5039
|
+
const SCRIPT_EXT_RE = /\.[cm]?[jt]sx?$/i;
|
|
5040
|
+
const STYLE_EXT_RE = /\.(?:css|less|sass|scss|styl|stylus)$/i;
|
|
5041
|
+
const UNI_APP_RUNTIME_MODULE = "@dcloudio/uni-app";
|
|
5042
|
+
function resolveRuntimeImport(source) {
|
|
5043
|
+
if (source === "vue" || source === UNI_APP_RUNTIME_MODULE) return "wevu";
|
|
5044
|
+
}
|
|
5045
|
+
function evaluateCondition(expression, defines, filename, line) {
|
|
5046
|
+
const normalized = expression.replace(/(?:\*\/|-->)\s*$/, "").trim();
|
|
5047
|
+
const tokens = normalized.match(/[A-Z][A-Z0-9_-]*|&&|\|\||[()!]/g) ?? [];
|
|
5048
|
+
if (!tokens.length || tokens.join("") !== normalized.replace(/\s/g, "")) throw new Error(`[uni-app] ${filename}:${line} 包含无效的条件表达式 "${normalized}"`);
|
|
5049
|
+
let index = 0;
|
|
5050
|
+
const parser = {
|
|
5051
|
+
parseAnd() {
|
|
5052
|
+
let value = parser.parsePrimary();
|
|
5053
|
+
while (tokens[index] === "&&") {
|
|
5054
|
+
index += 1;
|
|
5055
|
+
const right = parser.parsePrimary();
|
|
5056
|
+
value = value && right;
|
|
5057
|
+
}
|
|
5058
|
+
return value;
|
|
5059
|
+
},
|
|
5060
|
+
parseOr() {
|
|
5061
|
+
let value = parser.parseAnd();
|
|
5062
|
+
while (tokens[index] === "||") {
|
|
5063
|
+
index += 1;
|
|
5064
|
+
const right = parser.parseAnd();
|
|
5065
|
+
value = value || right;
|
|
5066
|
+
}
|
|
5067
|
+
return value;
|
|
5068
|
+
},
|
|
5069
|
+
parsePrimary() {
|
|
5070
|
+
const token = tokens[index];
|
|
5071
|
+
if (token === "!") {
|
|
5072
|
+
index += 1;
|
|
5073
|
+
return !parser.parsePrimary();
|
|
5074
|
+
}
|
|
5075
|
+
if (token === "(") {
|
|
5076
|
+
index += 1;
|
|
5077
|
+
const value = parser.parseOr();
|
|
5078
|
+
if (tokens[index] !== ")") throw new Error(`[uni-app] ${filename}:${line} 包含无效的条件表达式 "${normalized}"`);
|
|
5079
|
+
index += 1;
|
|
5080
|
+
return value;
|
|
5081
|
+
}
|
|
5082
|
+
if (!token || !/^[A-Z][A-Z0-9_-]*$/.test(token)) throw new Error(`[uni-app] ${filename}:${line} 包含无效的条件表达式 "${normalized}"`);
|
|
5083
|
+
index += 1;
|
|
5084
|
+
return defines.has(token);
|
|
5085
|
+
}
|
|
5086
|
+
};
|
|
5087
|
+
const value = parser.parseOr();
|
|
5088
|
+
if (index !== tokens.length) throw new Error(`[uni-app] ${filename}:${line} 包含无效的条件表达式 "${normalized}"`);
|
|
5089
|
+
return value;
|
|
5090
|
+
}
|
|
5091
|
+
/**
|
|
5092
|
+
* 按目标平台移除 uni-app 条件编译分支,并保留原始换行以稳定错误位置。
|
|
5093
|
+
*/
|
|
5094
|
+
function transformUniAppConditionalCode(source, options) {
|
|
5095
|
+
const defines = new Set(options.target === "h5" ? ["H5", "VUE3"] : [
|
|
5096
|
+
"MP",
|
|
5097
|
+
"MP-WEIXIN",
|
|
5098
|
+
"VUE3"
|
|
5099
|
+
]);
|
|
5100
|
+
const frames = [];
|
|
5101
|
+
let active = true;
|
|
5102
|
+
let changed = false;
|
|
5103
|
+
let cursor = 0;
|
|
5104
|
+
let line = 1;
|
|
5105
|
+
let code = "";
|
|
5106
|
+
for (const match of source.matchAll(DIRECTIVE_TOKEN_RE)) {
|
|
5107
|
+
const offset = match.index;
|
|
5108
|
+
const segment = source.slice(cursor, offset);
|
|
5109
|
+
code += active ? segment : segment.replace(/[^\r\n]/g, "");
|
|
5110
|
+
line += segment.split("\n").length - 1;
|
|
5111
|
+
const directiveSource = match[0].slice(match[0].indexOf("#"));
|
|
5112
|
+
const directiveMatch = directiveSource.match(/^#(ifdef|ifndef|else|endif)\b/);
|
|
5113
|
+
if (!directiveMatch) continue;
|
|
5114
|
+
changed = true;
|
|
5115
|
+
const directive = directiveMatch[1];
|
|
5116
|
+
if (directive === "ifdef" || directive === "ifndef") {
|
|
5117
|
+
const condition = evaluateCondition(directiveSource.slice(directiveMatch[0].length), defines, options.filename, line);
|
|
5118
|
+
frames.push({
|
|
5119
|
+
condition,
|
|
5120
|
+
elseSeen: false,
|
|
5121
|
+
parentActive: active
|
|
5122
|
+
});
|
|
5123
|
+
active = active && (directive === "ifdef" ? condition : !condition);
|
|
5124
|
+
} else {
|
|
5125
|
+
const frame = frames[frames.length - 1];
|
|
5126
|
+
if (!frame) throw new Error(`[uni-app] ${options.filename}:${line} 存在未配对的 #${directive}`);
|
|
5127
|
+
if (directive === "else") {
|
|
5128
|
+
if (frame.elseSeen) throw new Error(`[uni-app] ${options.filename}:${line} 同一条件块不能出现多个 #else`);
|
|
5129
|
+
frame.elseSeen = true;
|
|
5130
|
+
active = frame.parentActive && !frame.condition;
|
|
5131
|
+
} else {
|
|
5132
|
+
frames.pop();
|
|
5133
|
+
active = frame.parentActive;
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5136
|
+
code += match[0].replace(/[^\r\n]/g, "");
|
|
5137
|
+
line += match[0].split("\n").length - 1;
|
|
5138
|
+
cursor = offset + match[0].length;
|
|
5139
|
+
}
|
|
5140
|
+
const trailing = source.slice(cursor);
|
|
5141
|
+
code += active ? trailing : trailing.replace(/[^\r\n]/g, "");
|
|
5142
|
+
if (frames.length) throw new Error(`[uni-app] ${options.filename} 存在未闭合的条件编译块`);
|
|
5143
|
+
return {
|
|
5144
|
+
changed,
|
|
5145
|
+
code
|
|
5146
|
+
};
|
|
5147
|
+
}
|
|
5148
|
+
function normalizeAuxiliaryWxsScripts(source) {
|
|
5149
|
+
const wxsBlocks = [];
|
|
5150
|
+
const withoutScripts = source.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi, (block, attributes, content) => {
|
|
5151
|
+
const src = attributes.match(/\bsrc\s*=\s*["']([^"']+)["']/i)?.[1];
|
|
5152
|
+
const moduleName = attributes.match(/\bmodule\s*=\s*["']([^"']+)["']/i)?.[1];
|
|
5153
|
+
if (!(/\blang\s*=\s*["']wxs["']/i.test(attributes) || src?.endsWith(".wxs")) || !moduleName) return block;
|
|
5154
|
+
wxsBlocks.push(src ? `<wxs module="${moduleName}" src="${src}" />` : `<wxs module="${moduleName}">${content}</wxs>`);
|
|
5155
|
+
return block.replace(/[^\r\n]/g, "");
|
|
5156
|
+
});
|
|
5157
|
+
if (!wxsBlocks.length) return source;
|
|
5158
|
+
return withoutScripts.replace(/<template\b[^>]*>/i, (match) => `${match}\n${wxsBlocks.join("\n")}`);
|
|
5159
|
+
}
|
|
5160
|
+
function analyzeScript(source, filename) {
|
|
5161
|
+
if (!source.trim()) return {
|
|
5162
|
+
source,
|
|
5163
|
+
importSources: [],
|
|
5164
|
+
importEnd: 0,
|
|
5165
|
+
usesFreeUni: false,
|
|
5166
|
+
virtualHostTrueRanges: []
|
|
5167
|
+
};
|
|
5168
|
+
const isJsx = /\.[cm]?[jt]sx$/i.test(filename);
|
|
5169
|
+
const ast = parse$3(source, {
|
|
5170
|
+
sourceType: "module",
|
|
5171
|
+
plugins: [
|
|
5172
|
+
"typescript",
|
|
5173
|
+
"decorators-legacy",
|
|
5174
|
+
...isJsx ? ["jsx"] : []
|
|
5175
|
+
]
|
|
5176
|
+
});
|
|
5177
|
+
const importSources = [];
|
|
5178
|
+
let importEnd = 0;
|
|
5179
|
+
let usesFreeUni = false;
|
|
5180
|
+
const virtualHostTrueRanges = [];
|
|
5181
|
+
traverse(ast, {
|
|
5182
|
+
ImportDeclaration(path) {
|
|
5183
|
+
const sourceNode = path.node.source;
|
|
5184
|
+
if (typeof path.node.end === "number") importEnd = Math.max(importEnd, path.node.end);
|
|
5185
|
+
const replacement = t.isStringLiteral(sourceNode) ? resolveRuntimeImport(sourceNode.value) : void 0;
|
|
5186
|
+
if (replacement) importSources.push({
|
|
5187
|
+
start: sourceNode.start,
|
|
5188
|
+
end: sourceNode.end,
|
|
5189
|
+
replacement
|
|
5190
|
+
});
|
|
5191
|
+
},
|
|
5192
|
+
ExportAllDeclaration(path) {
|
|
5193
|
+
const sourceNode = path.node.source;
|
|
5194
|
+
const replacement = t.isStringLiteral(sourceNode) ? resolveRuntimeImport(sourceNode.value) : void 0;
|
|
5195
|
+
if (replacement) importSources.push({
|
|
5196
|
+
start: sourceNode.start,
|
|
5197
|
+
end: sourceNode.end,
|
|
5198
|
+
replacement
|
|
5199
|
+
});
|
|
5200
|
+
},
|
|
5201
|
+
ExportNamedDeclaration(path) {
|
|
5202
|
+
const sourceNode = path.node.source;
|
|
5203
|
+
const replacement = t.isStringLiteral(sourceNode) ? resolveRuntimeImport(sourceNode.value) : void 0;
|
|
5204
|
+
if (replacement) importSources.push({
|
|
5205
|
+
start: sourceNode.start,
|
|
5206
|
+
end: sourceNode.end,
|
|
5207
|
+
replacement
|
|
5208
|
+
});
|
|
5209
|
+
},
|
|
5210
|
+
ReferencedIdentifier(path) {
|
|
5211
|
+
if (path.node.name === "uni" && !path.scope.hasBinding("uni")) usesFreeUni = true;
|
|
5212
|
+
},
|
|
5213
|
+
ObjectProperty(path) {
|
|
5214
|
+
const key = path.node.key;
|
|
5215
|
+
if (!(!path.node.computed && (t.isIdentifier(key, { name: "virtualHost" }) || t.isStringLiteral(key, { value: "virtualHost" }))) || !t.isBooleanLiteral(path.node.value, { value: true }) || !path.parentPath?.isObjectExpression()) return;
|
|
5216
|
+
const optionsProperty = path.parentPath.parentPath;
|
|
5217
|
+
if (!optionsProperty?.isObjectProperty() || optionsProperty.node.computed || !(t.isIdentifier(optionsProperty.node.key, { name: "options" }) || t.isStringLiteral(optionsProperty.node.key, { value: "options" }))) return;
|
|
5218
|
+
const { start, end } = path.node.value;
|
|
5219
|
+
if (typeof start === "number" && typeof end === "number") virtualHostTrueRanges.push({
|
|
5220
|
+
start,
|
|
5221
|
+
end
|
|
5222
|
+
});
|
|
5223
|
+
}
|
|
5224
|
+
});
|
|
5225
|
+
return {
|
|
5226
|
+
source,
|
|
5227
|
+
importSources,
|
|
5228
|
+
importEnd,
|
|
5229
|
+
usesFreeUni,
|
|
5230
|
+
virtualHostTrueRanges
|
|
5231
|
+
};
|
|
5232
|
+
}
|
|
5233
|
+
function renderScript(analysis, injectUni, disableVirtualHost) {
|
|
5234
|
+
const output = new MagicString(analysis.source);
|
|
5235
|
+
for (const source of analysis.importSources) output.overwrite(source.start, source.end, JSON.stringify(source.replacement));
|
|
5236
|
+
if (injectUni) {
|
|
5237
|
+
const insertion = analysis.importEnd > 0 ? analysis.importEnd : 0;
|
|
5238
|
+
output.prepend(`import { createUniAppHost as __wevuCreateUniAppHost } from 'wevu/internal-runtime'\n`);
|
|
5239
|
+
output.appendLeft(insertion, `${insertion > 0 ? "\n" : ""}const uni = __wevuCreateUniAppHost(wx)\n`);
|
|
5240
|
+
}
|
|
5241
|
+
if (disableVirtualHost) for (const range of analysis.virtualHostTrueRanges) output.overwrite(range.start, range.end, "false");
|
|
5242
|
+
return output.toString();
|
|
5243
|
+
}
|
|
5244
|
+
function transformVueSfc(source, filename, target) {
|
|
5245
|
+
const normalizedSource = normalizeAuxiliaryWxsScripts(source);
|
|
5246
|
+
const { descriptor, errors } = parse(normalizedSource, { filename });
|
|
5247
|
+
if (errors.length) {
|
|
5248
|
+
const error = errors[0];
|
|
5249
|
+
throw new Error(`[uni-app] 解析 ${filename} 失败:${error.message}`);
|
|
5250
|
+
}
|
|
5251
|
+
const blocks = [descriptor.script, descriptor.scriptSetup].filter(Boolean);
|
|
5252
|
+
const analyses = blocks.map((block) => {
|
|
5253
|
+
const lang = block.lang ?? "js";
|
|
5254
|
+
return analyzeScript(block.content, `${filename}.${lang}`);
|
|
5255
|
+
});
|
|
5256
|
+
const injectIndex = analyses.findIndex((analysis) => analysis.usesFreeUni);
|
|
5257
|
+
const output = new MagicString(normalizedSource);
|
|
5258
|
+
for (let index = blocks.length - 1; index >= 0; index -= 1) {
|
|
5259
|
+
const block = blocks[index];
|
|
5260
|
+
const analysis = analyses[index];
|
|
5261
|
+
const code = renderScript(analysis, index === injectIndex, target === "mp-weixin");
|
|
5262
|
+
output.overwrite(block.loc.start.offset, block.loc.end.offset, code);
|
|
5263
|
+
}
|
|
5264
|
+
return output.toString();
|
|
5265
|
+
}
|
|
5266
|
+
/**
|
|
5267
|
+
* 转换单个受控 uni-app 源文件;未命中语法时返回原文。
|
|
5268
|
+
*/
|
|
5269
|
+
function transformUniAppSource(source, options) {
|
|
5270
|
+
const conditional = transformUniAppConditionalCode(source, options);
|
|
5271
|
+
const filename = options.filename.split("?", 1)[0];
|
|
5272
|
+
const blockType = options.blockType ?? (filename.endsWith(".vue") ? "sfc" : SCRIPT_EXT_RE.test(filename) ? "script" : STYLE_EXT_RE.test(filename) ? "style" : void 0);
|
|
5273
|
+
if (blockType === "sfc") {
|
|
5274
|
+
const code = transformVueSfc(conditional.code, filename, options.target);
|
|
5275
|
+
return {
|
|
5276
|
+
changed: conditional.changed || code !== source,
|
|
5277
|
+
code
|
|
5278
|
+
};
|
|
5279
|
+
}
|
|
5280
|
+
if (blockType === "script") {
|
|
5281
|
+
const analysis = analyzeScript(conditional.code, filename);
|
|
5282
|
+
const code = renderScript(analysis, analysis.usesFreeUni, options.target === "mp-weixin" && filename.endsWith(".vue"));
|
|
5283
|
+
return {
|
|
5284
|
+
changed: conditional.changed || code !== source,
|
|
5285
|
+
code
|
|
5286
|
+
};
|
|
5287
|
+
}
|
|
5288
|
+
if (blockType === "style" || blockType === "template") return conditional;
|
|
5289
|
+
return {
|
|
5290
|
+
changed: false,
|
|
5291
|
+
code: source
|
|
5292
|
+
};
|
|
5293
|
+
}
|
|
5294
|
+
/**
|
|
5295
|
+
* 判断文件是否属于项目源码或显式允许的 npm 包。
|
|
5296
|
+
*/
|
|
5297
|
+
function isUniAppCompatibilityFile(filename, srcRoot, include) {
|
|
5298
|
+
const clean = filename.split("?", 1)[0];
|
|
5299
|
+
const relative = path.relative(srcRoot, clean);
|
|
5300
|
+
if (relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative)) return true;
|
|
5301
|
+
const normalized = clean.replace(/\\/g, "/");
|
|
5302
|
+
return include.some((packageName) => {
|
|
5303
|
+
const packagePath = packageName.replace(/^\/+|\/+$/g, "");
|
|
5304
|
+
return normalized.includes(`/node_modules/${packagePath}/`);
|
|
5305
|
+
});
|
|
5306
|
+
}
|
|
5307
|
+
//#endregion
|
|
4954
5308
|
//#region src/utils/text.ts
|
|
4955
5309
|
const CRLF_RE = /\r\n?/g;
|
|
4956
5310
|
/**
|
|
@@ -5302,9 +5656,214 @@ function getSfcCheckMtime(config) {
|
|
|
5302
5656
|
return getReadFileCheckMtime(config);
|
|
5303
5657
|
}
|
|
5304
5658
|
//#endregion
|
|
5659
|
+
//#region src/plugins/vue/compiler/template/htmlTagMapping.ts
|
|
5660
|
+
const DEFAULT_HTML_TO_WXML_TAG_MAP = {
|
|
5661
|
+
a: "navigator",
|
|
5662
|
+
article: "view",
|
|
5663
|
+
aside: "view",
|
|
5664
|
+
b: "text",
|
|
5665
|
+
blockquote: "view",
|
|
5666
|
+
br: "view",
|
|
5667
|
+
button: "button",
|
|
5668
|
+
code: "text",
|
|
5669
|
+
dd: "view",
|
|
5670
|
+
div: "view",
|
|
5671
|
+
dl: "view",
|
|
5672
|
+
dt: "view",
|
|
5673
|
+
em: "text",
|
|
5674
|
+
figcaption: "view",
|
|
5675
|
+
figure: "view",
|
|
5676
|
+
footer: "view",
|
|
5677
|
+
form: "form",
|
|
5678
|
+
h1: "view",
|
|
5679
|
+
h2: "view",
|
|
5680
|
+
h3: "view",
|
|
5681
|
+
h4: "view",
|
|
5682
|
+
h5: "view",
|
|
5683
|
+
h6: "view",
|
|
5684
|
+
header: "view",
|
|
5685
|
+
hr: "view",
|
|
5686
|
+
i: "text",
|
|
5687
|
+
img: "image",
|
|
5688
|
+
input: "input",
|
|
5689
|
+
label: "label",
|
|
5690
|
+
li: "view",
|
|
5691
|
+
main: "view",
|
|
5692
|
+
nav: "view",
|
|
5693
|
+
ol: "view",
|
|
5694
|
+
p: "view",
|
|
5695
|
+
pre: "view",
|
|
5696
|
+
section: "view",
|
|
5697
|
+
small: "text",
|
|
5698
|
+
span: "text",
|
|
5699
|
+
strong: "text",
|
|
5700
|
+
table: "view",
|
|
5701
|
+
tbody: "view",
|
|
5702
|
+
td: "view",
|
|
5703
|
+
textarea: "textarea",
|
|
5704
|
+
tfoot: "view",
|
|
5705
|
+
th: "view",
|
|
5706
|
+
thead: "view",
|
|
5707
|
+
tr: "view",
|
|
5708
|
+
u: "text",
|
|
5709
|
+
ul: "view"
|
|
5710
|
+
};
|
|
5711
|
+
function resolveHtmlTagToWxmlMap(value) {
|
|
5712
|
+
if (value === false) return;
|
|
5713
|
+
if (value === true || value === void 0) return { ...DEFAULT_HTML_TO_WXML_TAG_MAP };
|
|
5714
|
+
return {
|
|
5715
|
+
...DEFAULT_HTML_TO_WXML_TAG_MAP,
|
|
5716
|
+
...Object.fromEntries(Object.entries(value).map(([key, mapped]) => [key.toLowerCase(), mapped]))
|
|
5717
|
+
};
|
|
5718
|
+
}
|
|
5719
|
+
function resolveTemplateTagName(tag, context) {
|
|
5720
|
+
if (!tag) return tag;
|
|
5721
|
+
const lowerTag = tag.toLowerCase();
|
|
5722
|
+
if (tag !== lowerTag) return tag;
|
|
5723
|
+
return context.htmlTagToWxmlMap?.[lowerTag] ?? tag;
|
|
5724
|
+
}
|
|
5725
|
+
function resolveMappedHtmlTagClassName(tag, context, resolvedTag) {
|
|
5726
|
+
if (!context.htmlTagToWxmlTagClass || !tag) return;
|
|
5727
|
+
const lowerTag = tag.toLowerCase();
|
|
5728
|
+
if (tag !== lowerTag) return;
|
|
5729
|
+
const mappedTag = context.htmlTagToWxmlMap?.[lowerTag];
|
|
5730
|
+
if (!mappedTag || (resolvedTag ?? mappedTag ?? tag) === lowerTag) return;
|
|
5731
|
+
return lowerTag;
|
|
5732
|
+
}
|
|
5733
|
+
//#endregion
|
|
5734
|
+
//#region src/plugins/vue/compiler/wxss.ts
|
|
5735
|
+
function findClosingParenthesis(source, openIndex) {
|
|
5736
|
+
let depth = 0;
|
|
5737
|
+
let quote;
|
|
5738
|
+
for (let index = openIndex; index < source.length; index += 1) {
|
|
5739
|
+
const char = source[index];
|
|
5740
|
+
if (quote) {
|
|
5741
|
+
if (char === quote && source[index - 1] !== "\\") quote = void 0;
|
|
5742
|
+
continue;
|
|
5743
|
+
}
|
|
5744
|
+
if (char === "\"" || char === "'") {
|
|
5745
|
+
quote = char;
|
|
5746
|
+
continue;
|
|
5747
|
+
}
|
|
5748
|
+
if (char === "(") depth += 1;
|
|
5749
|
+
else if (char === ")" && --depth === 0) return index;
|
|
5750
|
+
}
|
|
5751
|
+
return -1;
|
|
5752
|
+
}
|
|
5753
|
+
function findTopLevelComma(source) {
|
|
5754
|
+
let depth = 0;
|
|
5755
|
+
let quote;
|
|
5756
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
5757
|
+
const char = source[index];
|
|
5758
|
+
if (quote) {
|
|
5759
|
+
if (char === quote && source[index - 1] !== "\\") quote = void 0;
|
|
5760
|
+
continue;
|
|
5761
|
+
}
|
|
5762
|
+
if (char === "\"" || char === "'") quote = char;
|
|
5763
|
+
else if (char === "(") depth += 1;
|
|
5764
|
+
else if (char === ")") depth -= 1;
|
|
5765
|
+
else if (char === "," && depth === 0) return index;
|
|
5766
|
+
}
|
|
5767
|
+
return -1;
|
|
5768
|
+
}
|
|
5769
|
+
function resolveWxssVarFallback(source) {
|
|
5770
|
+
const openIndex = source.indexOf("(");
|
|
5771
|
+
const closeIndex = openIndex >= 0 ? findClosingParenthesis(source, openIndex) : -1;
|
|
5772
|
+
if (openIndex < 0 || closeIndex < 0) return "initial";
|
|
5773
|
+
const content = source.slice(openIndex + 1, closeIndex);
|
|
5774
|
+
const commaIndex = findTopLevelComma(content);
|
|
5775
|
+
if (commaIndex < 0) return "initial";
|
|
5776
|
+
return flattenWxssVarFallbacks(content.slice(commaIndex + 1));
|
|
5777
|
+
}
|
|
5778
|
+
function flattenWxssVarFallbacks(source) {
|
|
5779
|
+
let result = "";
|
|
5780
|
+
let cursor = 0;
|
|
5781
|
+
while (cursor < source.length) {
|
|
5782
|
+
const varIndex = source.indexOf("var(", cursor);
|
|
5783
|
+
if (varIndex < 0) {
|
|
5784
|
+
result += source.slice(cursor);
|
|
5785
|
+
break;
|
|
5786
|
+
}
|
|
5787
|
+
result += source.slice(cursor, varIndex);
|
|
5788
|
+
const closeIndex = findClosingParenthesis(source, varIndex + 3);
|
|
5789
|
+
if (closeIndex < 0) {
|
|
5790
|
+
result += source.slice(varIndex);
|
|
5791
|
+
break;
|
|
5792
|
+
}
|
|
5793
|
+
result += resolveWxssVarFallback(source.slice(varIndex, closeIndex + 1));
|
|
5794
|
+
cursor = closeIndex + 1;
|
|
5795
|
+
}
|
|
5796
|
+
return result;
|
|
5797
|
+
}
|
|
5798
|
+
function lowerNestedWxssVarsInValue(source) {
|
|
5799
|
+
let result = "";
|
|
5800
|
+
let cursor = 0;
|
|
5801
|
+
let changed = false;
|
|
5802
|
+
while (cursor < source.length) {
|
|
5803
|
+
const varIndex = source.indexOf("var(", cursor);
|
|
5804
|
+
if (varIndex < 0) {
|
|
5805
|
+
result += source.slice(cursor);
|
|
5806
|
+
break;
|
|
5807
|
+
}
|
|
5808
|
+
result += source.slice(cursor, varIndex);
|
|
5809
|
+
const closeIndex = findClosingParenthesis(source, varIndex + 3);
|
|
5810
|
+
if (closeIndex < 0) {
|
|
5811
|
+
result += source.slice(varIndex);
|
|
5812
|
+
break;
|
|
5813
|
+
}
|
|
5814
|
+
const functionSource = source.slice(varIndex, closeIndex + 1);
|
|
5815
|
+
const content = functionSource.slice(4, -1);
|
|
5816
|
+
const commaIndex = findTopLevelComma(content);
|
|
5817
|
+
if (commaIndex >= 0 && content.slice(commaIndex + 1).includes("var(")) {
|
|
5818
|
+
const name = content.slice(0, commaIndex).trim();
|
|
5819
|
+
const fallback = flattenWxssVarFallbacks(content.slice(commaIndex + 1)).trim();
|
|
5820
|
+
result += `var(${name}, ${fallback})`;
|
|
5821
|
+
changed = true;
|
|
5822
|
+
} else result += functionSource;
|
|
5823
|
+
cursor = closeIndex + 1;
|
|
5824
|
+
}
|
|
5825
|
+
return changed ? result : source;
|
|
5826
|
+
}
|
|
5827
|
+
/**
|
|
5828
|
+
* 压平 WXSS 不接受的嵌套 CSS 变量回退值。
|
|
5829
|
+
*/
|
|
5830
|
+
function transformNestedWxssVars(source) {
|
|
5831
|
+
if (!source.includes("var(")) return source;
|
|
5832
|
+
const root = postcss.parse(source);
|
|
5833
|
+
root.walkDecls((declaration) => {
|
|
5834
|
+
declaration.value = lowerNestedWxssVarsInValue(declaration.value);
|
|
5835
|
+
});
|
|
5836
|
+
return root.toString();
|
|
5837
|
+
}
|
|
5838
|
+
//#endregion
|
|
5305
5839
|
//#region src/plugins/vue/compiler/style.ts
|
|
5306
5840
|
const CSS_RULE_RE = /([^{]+)(\{[^}]*\})/g;
|
|
5307
5841
|
const CSS_CLASS_RE = /\.([a-z_][\w-]*)(?:\[[^\]]+\])?\s*\{/gi;
|
|
5842
|
+
function transformVueDeepSelectors(source) {
|
|
5843
|
+
if (!source.includes(":deep") && !source.includes("::v-deep")) return source;
|
|
5844
|
+
const root = postcss.parse(source);
|
|
5845
|
+
const processor = selectorParser((selectors) => {
|
|
5846
|
+
selectors.walkTags((tag) => {
|
|
5847
|
+
const name = tag.value.toLowerCase();
|
|
5848
|
+
if (DEFAULT_HTML_TO_WXML_TAG_MAP[name] !== name && DEFAULT_HTML_TO_WXML_TAG_MAP[name]) tag.replaceWith(selectorParser.className({ value: name }));
|
|
5849
|
+
});
|
|
5850
|
+
selectors.walkPseudos((pseudo) => {
|
|
5851
|
+
if (pseudo.value !== ":deep" && pseudo.value !== "::v-deep") return;
|
|
5852
|
+
const replacement = pseudo.nodes?.[0]?.nodes.map((node) => node.clone()) ?? [];
|
|
5853
|
+
if (replacement.length > 0) pseudo.replaceWith(...replacement);
|
|
5854
|
+
else {
|
|
5855
|
+
const previous = pseudo.prev();
|
|
5856
|
+
const next = pseudo.next();
|
|
5857
|
+
if (next?.type === "combinator" && (!previous || previous.type === "combinator")) next.remove();
|
|
5858
|
+
pseudo.remove();
|
|
5859
|
+
}
|
|
5860
|
+
});
|
|
5861
|
+
});
|
|
5862
|
+
root.walkRules((rule) => {
|
|
5863
|
+
if (rule.selector.includes(":deep") || rule.selector.includes("::v-deep")) rule.selector = processor.processSync(rule.selector);
|
|
5864
|
+
});
|
|
5865
|
+
return root.toString();
|
|
5866
|
+
}
|
|
5308
5867
|
/**
|
|
5309
5868
|
* 转换 scoped CSS
|
|
5310
5869
|
* 为每个选择器添加特定的 scoped 属性
|
|
@@ -5365,18 +5924,18 @@ function transformCssModules(source, id) {
|
|
|
5365
5924
|
* 将 Vue SFC 的 style 块转换为 WXSS
|
|
5366
5925
|
*/
|
|
5367
5926
|
function compileVueStyleToWxss(styleBlock, options) {
|
|
5368
|
-
const { id, scoped, modules } = options;
|
|
5927
|
+
const { id, scoped, modules, preserveDeepSelectors, transformScoped = true } = options;
|
|
5369
5928
|
let code = styleBlock.content;
|
|
5370
|
-
if (scoped || styleBlock.scoped) code = transformScopedCss(code, id);
|
|
5929
|
+
if (transformScoped && (scoped || styleBlock.scoped)) code = transformScopedCss(code, id);
|
|
5371
5930
|
if (modules || styleBlock.module) {
|
|
5372
5931
|
const moduleName = typeof styleBlock.module === "string" ? styleBlock.module : "$style";
|
|
5373
5932
|
const moduleResult = transformCssModules(code, id);
|
|
5374
5933
|
return {
|
|
5375
|
-
code: moduleResult.code,
|
|
5934
|
+
code: preserveDeepSelectors ? moduleResult.code : transformVueDeepSelectors(moduleResult.code),
|
|
5376
5935
|
modules: { [moduleName]: moduleResult.classes }
|
|
5377
5936
|
};
|
|
5378
5937
|
}
|
|
5379
|
-
return { code };
|
|
5938
|
+
return { code: preserveDeepSelectors ? code : transformVueDeepSelectors(code) };
|
|
5380
5939
|
}
|
|
5381
5940
|
//#endregion
|
|
5382
5941
|
//#region src/plugins/vue/compiler/template/classStyleRuntime.ts
|
|
@@ -5637,74 +6196,6 @@ function getClassStyleWxsSource(options = {}) {
|
|
|
5637
6196
|
].join("\n");
|
|
5638
6197
|
}
|
|
5639
6198
|
//#endregion
|
|
5640
|
-
//#region src/plugins/vue/compiler/template/htmlTagMapping.ts
|
|
5641
|
-
const DEFAULT_HTML_TO_WXML_TAG_MAP = {
|
|
5642
|
-
a: "navigator",
|
|
5643
|
-
article: "view",
|
|
5644
|
-
aside: "view",
|
|
5645
|
-
b: "text",
|
|
5646
|
-
blockquote: "view",
|
|
5647
|
-
br: "view",
|
|
5648
|
-
button: "button",
|
|
5649
|
-
code: "text",
|
|
5650
|
-
dd: "view",
|
|
5651
|
-
div: "view",
|
|
5652
|
-
dl: "view",
|
|
5653
|
-
dt: "view",
|
|
5654
|
-
em: "text",
|
|
5655
|
-
figcaption: "view",
|
|
5656
|
-
figure: "view",
|
|
5657
|
-
footer: "view",
|
|
5658
|
-
form: "form",
|
|
5659
|
-
h1: "view",
|
|
5660
|
-
h2: "view",
|
|
5661
|
-
h3: "view",
|
|
5662
|
-
h4: "view",
|
|
5663
|
-
h5: "view",
|
|
5664
|
-
h6: "view",
|
|
5665
|
-
header: "view",
|
|
5666
|
-
hr: "view",
|
|
5667
|
-
i: "text",
|
|
5668
|
-
img: "image",
|
|
5669
|
-
input: "input",
|
|
5670
|
-
label: "label",
|
|
5671
|
-
li: "view",
|
|
5672
|
-
main: "view",
|
|
5673
|
-
nav: "view",
|
|
5674
|
-
ol: "view",
|
|
5675
|
-
p: "view",
|
|
5676
|
-
pre: "view",
|
|
5677
|
-
section: "view",
|
|
5678
|
-
small: "text",
|
|
5679
|
-
span: "text",
|
|
5680
|
-
strong: "text",
|
|
5681
|
-
textarea: "textarea",
|
|
5682
|
-
u: "text",
|
|
5683
|
-
ul: "view"
|
|
5684
|
-
};
|
|
5685
|
-
function resolveHtmlTagToWxmlMap(value) {
|
|
5686
|
-
if (value === false) return;
|
|
5687
|
-
if (value === true || value === void 0) return { ...DEFAULT_HTML_TO_WXML_TAG_MAP };
|
|
5688
|
-
return {
|
|
5689
|
-
...DEFAULT_HTML_TO_WXML_TAG_MAP,
|
|
5690
|
-
...Object.fromEntries(Object.entries(value).map(([key, mapped]) => [key.toLowerCase(), mapped]))
|
|
5691
|
-
};
|
|
5692
|
-
}
|
|
5693
|
-
function resolveTemplateTagName(tag, context) {
|
|
5694
|
-
if (!tag) return tag;
|
|
5695
|
-
const lowerTag = tag.toLowerCase();
|
|
5696
|
-
if (tag !== lowerTag) return tag;
|
|
5697
|
-
return context.htmlTagToWxmlMap?.[lowerTag] ?? tag;
|
|
5698
|
-
}
|
|
5699
|
-
function resolveMappedHtmlTagClassName(tag, context, resolvedTag) {
|
|
5700
|
-
if (!context.htmlTagToWxmlTagClass || !tag) return;
|
|
5701
|
-
const lowerTag = tag.toLowerCase();
|
|
5702
|
-
if (tag !== lowerTag) return;
|
|
5703
|
-
const mappedTag = context.htmlTagToWxmlMap?.[lowerTag];
|
|
5704
|
-
if (!mappedTag || (resolvedTag ?? mappedTag ?? tag) === lowerTag) return;
|
|
5705
|
-
return lowerTag;
|
|
5706
|
-
}
|
|
5707
|
-
//#endregion
|
|
5708
6199
|
//#region src/plugins/vue/compiler/template/elements/forExpression.ts
|
|
5709
6200
|
const IDENTIFIER_RE$5 = /^[A-Z_$][\w$]*$/i;
|
|
5710
6201
|
const FOR_ITEM_ALIAS_PLACEHOLDER = "__wv_for_item__";
|
|
@@ -6061,6 +6552,7 @@ const SCOPED_SLOT_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
6061
6552
|
"encodeURIComponent",
|
|
6062
6553
|
"require",
|
|
6063
6554
|
"arguments",
|
|
6555
|
+
"vueSlots",
|
|
6064
6556
|
WEVU_SLOT_OWNER_KEY,
|
|
6065
6557
|
WEVU_SLOT_PROPS_KEY,
|
|
6066
6558
|
WEVU_SLOT_PROPS_DATA_KEY,
|
|
@@ -6523,19 +7015,6 @@ const JS_RUNTIME_GLOBALS = /* @__PURE__ */ new Set([
|
|
|
6523
7015
|
"getCurrentPages",
|
|
6524
7016
|
...getMiniProgramRuntimeGlobalKeys()
|
|
6525
7017
|
]);
|
|
6526
|
-
function parseJsExpressionFile(exp) {
|
|
6527
|
-
try {
|
|
6528
|
-
const ast = parseJsLike(`(${exp})`);
|
|
6529
|
-
const stmt = ast.program.body[0];
|
|
6530
|
-
if (!stmt || !("expression" in stmt)) return null;
|
|
6531
|
-
return {
|
|
6532
|
-
ast,
|
|
6533
|
-
expression: stmt.expression
|
|
6534
|
-
};
|
|
6535
|
-
} catch {
|
|
6536
|
-
return null;
|
|
6537
|
-
}
|
|
6538
|
-
}
|
|
6539
7018
|
function createMemberAccess(target, prop) {
|
|
6540
7019
|
if (!prop) return target;
|
|
6541
7020
|
if (t.isValidIdentifier(prop)) return t.memberExpression(target, t.identifier(prop));
|
|
@@ -6589,11 +7068,8 @@ function createIdentifierAccessWithPropsFallback(name, context, useRuntimePropHe
|
|
|
6589
7068
|
const hasUsablePropsValue = t.logicalExpression("&&", hasPropsObject, t.logicalExpression("||", hasDefinedPropsValue, hasPropsKey));
|
|
6590
7069
|
const hasStateObject = t.binaryExpression("!=", stateObject, t.nullLiteral());
|
|
6591
7070
|
const hasStateKey = createHasOwnPropertyCall(stateObject, name);
|
|
6592
|
-
const
|
|
6593
|
-
|
|
6594
|
-
const shouldUseStateAccess = isPropsDerivedKey ? t.booleanLiteral(false) : t.logicalExpression("&&", hasStateObject, hasStateKey);
|
|
6595
|
-
const shouldUsePropsAccess = t.logicalExpression("&&", hasUsablePropsValue, isPropsDerivedKey ? t.booleanLiteral(true) : t.unaryExpression("!", hasThisMember));
|
|
6596
|
-
return t.conditionalExpression(shouldUseStateAccess, thisAccess, t.conditionalExpression(shouldUsePropsAccess, propsAccess, thisAccess));
|
|
7071
|
+
const shouldUseStateAccess = Boolean(context.propsDerivedKeys?.includes(name)) ? t.booleanLiteral(false) : t.logicalExpression("&&", hasStateObject, hasStateKey);
|
|
7072
|
+
return t.conditionalExpression(shouldUseStateAccess, thisAccess, t.conditionalExpression(hasUsablePropsValue, propsAccess, thisAccess));
|
|
6597
7073
|
}
|
|
6598
7074
|
function createAliasedPropsAccess(name, propName) {
|
|
6599
7075
|
return createResolvePropValueCall(propName, createThisMemberAccess(name), true);
|
|
@@ -6625,7 +7101,7 @@ function shouldUnrefMemberAccess(node, parent) {
|
|
|
6625
7101
|
function normalizeJsExpressionWithContext(exp, context, options) {
|
|
6626
7102
|
const trimmed = exp.trim();
|
|
6627
7103
|
if (!trimmed) return null;
|
|
6628
|
-
const parsed =
|
|
7104
|
+
const parsed = parseBabelExpressionFile(normalizeWxmlExpression(trimmed));
|
|
6629
7105
|
if (!parsed) {
|
|
6630
7106
|
const hint = options?.hint ? `${options.hint} ` : "";
|
|
6631
7107
|
context.warnings.push(`${hint}模板表达式解析失败,已忽略:${exp}`);
|
|
@@ -6707,6 +7183,11 @@ function shouldFallbackToRuntimeBinding(exp) {
|
|
|
6707
7183
|
OptionalCallExpression(path) {
|
|
6708
7184
|
shouldFallback = true;
|
|
6709
7185
|
path.stop();
|
|
7186
|
+
},
|
|
7187
|
+
UnaryExpression(path) {
|
|
7188
|
+
if (path.node.operator !== "typeof") return;
|
|
7189
|
+
shouldFallback = true;
|
|
7190
|
+
path.stop();
|
|
6710
7191
|
}
|
|
6711
7192
|
});
|
|
6712
7193
|
return shouldFallback;
|
|
@@ -6928,7 +7409,9 @@ function createBindRuntimeAttr(argValue, rawExpValue, context) {
|
|
|
6928
7409
|
return `${argValue}="${renderMustache(bindingRef, context)}"`;
|
|
6929
7410
|
}
|
|
6930
7411
|
function createInlineObjectLiteralAttr(argValue, rawExpValue, context) {
|
|
6931
|
-
const
|
|
7412
|
+
const normalized = normalizeWxmlExpressionWithContext(rawExpValue, context).trim();
|
|
7413
|
+
const parsed = parseBabelExpression(normalized);
|
|
7414
|
+
const expValue = parsed ? generateExpression(parsed) : normalized;
|
|
6932
7415
|
if (context.mustacheInterpolation === "spaced") return `${argValue}="${renderMustache(expValue, context)}"`;
|
|
6933
7416
|
return `${argValue}="{{ ${expValue} }}"`;
|
|
6934
7417
|
}
|
|
@@ -7386,7 +7869,8 @@ function collectElementAttributes(node, context, options) {
|
|
|
7386
7869
|
}
|
|
7387
7870
|
if (mappedTagClass) staticClass = prependStaticClass(staticClass, mappedTagClass);
|
|
7388
7871
|
if (templateRef) {
|
|
7389
|
-
const
|
|
7872
|
+
const refIndex = context.templateRefIndexSeed++;
|
|
7873
|
+
const className = `${WEVU_TEMPLATE_REF_CLASS_PREFIX}${refIndex}`;
|
|
7390
7874
|
staticClass = staticClass ? `${staticClass} ${className}` : className;
|
|
7391
7875
|
context.templateRefs.push({
|
|
7392
7876
|
selector: `.${className}`,
|
|
@@ -7429,6 +7913,29 @@ function collectElementAttributes(node, context, options) {
|
|
|
7429
7913
|
//#region src/plugins/vue/compiler/template/elements/slotProps.ts
|
|
7430
7914
|
const BACKSLASH_RE = /\\/g;
|
|
7431
7915
|
const SINGLE_QUOTE_RE = /'/g;
|
|
7916
|
+
function isFunctionBindingExpression(exp) {
|
|
7917
|
+
try {
|
|
7918
|
+
const stmt = parse$3(`(${exp})`, {
|
|
7919
|
+
sourceType: "module",
|
|
7920
|
+
plugins: ["typescript"]
|
|
7921
|
+
}).program.body[0];
|
|
7922
|
+
const expression = stmt && "expression" in stmt ? stmt.expression : void 0;
|
|
7923
|
+
return t.isArrowFunctionExpression(expression) || t.isFunctionExpression(expression);
|
|
7924
|
+
} catch {
|
|
7925
|
+
return false;
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
function createSlotFunctionBinding(exp, context) {
|
|
7929
|
+
if (!isFunctionBindingExpression(exp)) return null;
|
|
7930
|
+
const inline = registerInlineExpression(`(${exp})(...$event)`, context);
|
|
7931
|
+
if (!inline) {
|
|
7932
|
+
context.warnings.push("作用域插槽函数参数编译失败。");
|
|
7933
|
+
return null;
|
|
7934
|
+
}
|
|
7935
|
+
const scopeBindings = `[${inline.scopeBindings.join(",")}]`;
|
|
7936
|
+
const indexBindings = `[${inline.indexBindings.join(",")}]`;
|
|
7937
|
+
return `[${toWxmlStringLiteral$1(WEVU_SLOT_FUNCTION_TOKEN)},${toWxmlStringLiteral$1(inline.id)},${scopeBindings},${indexBindings}]`;
|
|
7938
|
+
}
|
|
7432
7939
|
function parseSlotPropsExpression(exp, context) {
|
|
7433
7940
|
const trimmed = exp.trim();
|
|
7434
7941
|
if (!trimmed) return {};
|
|
@@ -7488,7 +7995,7 @@ function collectSlotBindingExpression(node, context) {
|
|
|
7488
7995
|
if (prop.arg.content === "name" || hasForDirective && prop.arg.content === "key") continue;
|
|
7489
7996
|
if (rawExpValue) namedBindings.push({
|
|
7490
7997
|
key: prop.arg.content,
|
|
7491
|
-
value: normalizeWxmlExpressionWithContext(rawExpValue, context)
|
|
7998
|
+
value: createSlotFunctionBinding(rawExpValue, context) ?? normalizeWxmlExpressionWithContext(rawExpValue, context)
|
|
7492
7999
|
});
|
|
7493
8000
|
continue;
|
|
7494
8001
|
}
|
|
@@ -7572,7 +8079,8 @@ const SLOT_PRESENCE_IDENTIFIER_RE = /^[A-Z_$][\w$]*$/i;
|
|
|
7572
8079
|
function createSlotPresenceExpression(info) {
|
|
7573
8080
|
const slotName = resolveSlotStaticName(info);
|
|
7574
8081
|
if (!slotName) return;
|
|
7575
|
-
|
|
8082
|
+
const access = SLOT_PRESENCE_IDENTIFIER_RE.test(slotName) ? `${WEVU_SLOT_NAMES_PROP}.${slotName}` : `${WEVU_SLOT_NAMES_PROP}['${slotName.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}']`;
|
|
8083
|
+
return `${WEVU_SLOT_NAMES_PROP}&&${access}`;
|
|
7576
8084
|
}
|
|
7577
8085
|
function buildSlotDeclaration(name, propsExp, children, context, options) {
|
|
7578
8086
|
return {
|
|
@@ -7612,6 +8120,8 @@ function createScopedSlotComponent(context, slotKey, props, children, transformN
|
|
|
7612
8120
|
forIndexSeed: 0,
|
|
7613
8121
|
inlineExpressions: [],
|
|
7614
8122
|
inlineExpressionSeed: 0,
|
|
8123
|
+
templateRefs: [],
|
|
8124
|
+
templateRefIndexSeed: 0,
|
|
7615
8125
|
functionPropPaths: /* @__PURE__ */ new Set(),
|
|
7616
8126
|
functionPropNames: context.functionPropNames
|
|
7617
8127
|
};
|
|
@@ -7627,6 +8137,7 @@ function createScopedSlotComponent(context, slotKey, props, children, transformN
|
|
|
7627
8137
|
asset.classStyleBindings = scopedContext.classStyleBindings.length ? scopedContext.classStyleBindings : void 0;
|
|
7628
8138
|
asset.classStyleWxs = scopedContext.classStyleWxs || void 0;
|
|
7629
8139
|
asset.inlineExpressions = scopedContext.inlineExpressions.length ? scopedContext.inlineExpressions : void 0;
|
|
8140
|
+
asset.templateRefs = scopedContext.templateRefs.length ? scopedContext.templateRefs : void 0;
|
|
7630
8141
|
return {
|
|
7631
8142
|
componentName,
|
|
7632
8143
|
slotKey
|
|
@@ -7835,7 +8346,8 @@ function transformSlotElement(node, context, transformNode) {
|
|
|
7835
8346
|
];
|
|
7836
8347
|
if (context.slotMultipleInstance) scopedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(WEVU_SLOT_SCOPE_KEY, context)}"`);
|
|
7837
8348
|
const scopedTag = `<${genericKey}${scopedAttrs.length ? ` ${scopedAttrs.join(" ")}` : ""} />`;
|
|
7838
|
-
const
|
|
8349
|
+
const nativeFallbackTag = context.forStack.length > 0 ? "" : context.platform.wrapIf(`!${WEVU_SLOT_OWNER_ID_PROP}`, slotTag, (exp) => renderMustache(exp, context));
|
|
8350
|
+
const projectedContent = hasScopeBindings ? `${scopedTag}${nativeFallbackTag}` : `${scopedTag}${context.platform.wrapElse(slotTag)}`;
|
|
7839
8351
|
if (fallbackContent && slotPresentExp) return `${context.platform.wrapIf(slotPresentExp, projectedContent, (exp) => renderMustache(exp, context))}${context.platform.wrapElse(fallbackContent)}`;
|
|
7840
8352
|
return projectedContent;
|
|
7841
8353
|
}
|
|
@@ -7875,6 +8387,15 @@ function hasDirectWevuComponentSlotChild(children, context) {
|
|
|
7875
8387
|
return isWevuComponentTag(element, context);
|
|
7876
8388
|
});
|
|
7877
8389
|
}
|
|
8390
|
+
function hasExplicitWevuComponentSlotDescendant(children, context) {
|
|
8391
|
+
if (!context.wevuComponentTags?.size) return false;
|
|
8392
|
+
return children.some((child) => {
|
|
8393
|
+
if (child.type !== NodeTypes.ELEMENT) return false;
|
|
8394
|
+
const element = child;
|
|
8395
|
+
if (element.tag !== "template" && !isBuiltinTag(resolveTemplateTagName(element.tag, context)) && context.wevuComponentTags.has(element.tag)) return true;
|
|
8396
|
+
return hasExplicitWevuComponentSlotDescendant(element.children, context);
|
|
8397
|
+
});
|
|
8398
|
+
}
|
|
7878
8399
|
function hasMiniProgramComponentSlotDescendant(children, context) {
|
|
7879
8400
|
const componentTags = context.miniProgramComponentTags;
|
|
7880
8401
|
if (!componentTags?.size) return false;
|
|
@@ -7893,16 +8414,24 @@ function hasNativeComponentSlotDescendant(children, context) {
|
|
|
7893
8414
|
return hasNativeComponentSlotDescendant(element.children, context);
|
|
7894
8415
|
});
|
|
7895
8416
|
}
|
|
8417
|
+
function hasForwardedSlotOutlet(children) {
|
|
8418
|
+
return children.some((child) => {
|
|
8419
|
+
if (child.type !== NodeTypes.ELEMENT) return false;
|
|
8420
|
+
const element = child;
|
|
8421
|
+
return element.tag === "slot" || hasForwardedSlotOutlet(element.children);
|
|
8422
|
+
});
|
|
8423
|
+
}
|
|
7896
8424
|
function shouldAugmentPlainSlot(decl, context, ownerNode, hasScopedSlotPropsSibling) {
|
|
7897
8425
|
if (context.scopedSlotsRequireProps) return false;
|
|
8426
|
+
if (hasForwardedSlotOutlet(decl.children)) return false;
|
|
7898
8427
|
if (context.rewriteScopedSlot && !isWevuComponentTag(ownerNode, context)) return false;
|
|
7899
8428
|
if (context.rewriteScopedSlot) {
|
|
7900
8429
|
if (context.scopedSlotsCompiler === "augmented" && !decl.implicitDefault) return true;
|
|
7901
|
-
return context.scopedSlotsCompiler === "augmented" ? hasMiniProgramComponentSlotDescendant(decl.children, context) : hasScopedSlotPropsSibling && hasDirectComponentSlotChild(decl.children, context);
|
|
8430
|
+
return context.scopedSlotsCompiler === "augmented" ? hasMiniProgramComponentSlotDescendant(decl.children, context) || hasExplicitWevuComponentSlotDescendant(decl.children, context) : hasScopedSlotPropsSibling && hasDirectComponentSlotChild(decl.children, context);
|
|
7902
8431
|
}
|
|
7903
8432
|
if (context.scopedSlotsCompiler === "augmented") {
|
|
7904
8433
|
if (!decl.implicitDefault) return true;
|
|
7905
|
-
return hasMiniProgramComponentSlotDescendant(decl.children, context) || !isWevuComponentTag(ownerNode, context) && hasNativeComponentSlotDescendant(decl.children, context);
|
|
8434
|
+
return hasMiniProgramComponentSlotDescendant(decl.children, context) || hasExplicitWevuComponentSlotDescendant(decl.children, context) || !isWevuComponentTag(ownerNode, context) && hasNativeComponentSlotDescendant(decl.children, context);
|
|
7906
8435
|
}
|
|
7907
8436
|
if (!isWevuComponentTag(ownerNode, context)) return false;
|
|
7908
8437
|
return hasScopedSlotPropsSibling || hasDirectWevuComponentSlotChild(decl.children, context);
|
|
@@ -8146,7 +8675,7 @@ function transformComponentWithSlots(node, context, transformNode, options) {
|
|
|
8146
8675
|
if (scopedSlotDeclarations.length) {
|
|
8147
8676
|
const scopePropsExp = buildScopePropsExpression(context);
|
|
8148
8677
|
if (scopePropsExp) mergedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(scopePropsExp, context)}"`);
|
|
8149
|
-
const ownerIdExp = context.rewriteScopedSlot ? `${WEVU_SLOT_OWNER_ID_PROP} || ${WEVU_SLOT_OWNER_ID_KEY} || ''` : `${
|
|
8678
|
+
const ownerIdExp = context.rewriteScopedSlot ? `${WEVU_SLOT_OWNER_ID_PROP} || ${WEVU_SLOT_OWNER_ID_KEY} || ''` : `${WEVU_SLOT_OWNER_ID_KEY} || ''`;
|
|
8150
8679
|
mergedAttrs.push(`${WEVU_SLOT_OWNER_ID_ATTR}="${renderMustache(ownerIdExp, context)}"`);
|
|
8151
8680
|
}
|
|
8152
8681
|
const attrString = mergedAttrs.length ? ` ${mergedAttrs.join(" ")}` : "";
|
|
@@ -8686,6 +9215,12 @@ function isVueSfcSource(source) {
|
|
|
8686
9215
|
function pascalToKebab(name) {
|
|
8687
9216
|
return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2").toLowerCase();
|
|
8688
9217
|
}
|
|
9218
|
+
function kebabToCamel(name) {
|
|
9219
|
+
return name.replace(/-([a-z0-9])/g, (_, character) => character.toUpperCase());
|
|
9220
|
+
}
|
|
9221
|
+
function capitalize(name) {
|
|
9222
|
+
return name ? `${name.charAt(0).toUpperCase()}${name.slice(1)}` : name;
|
|
9223
|
+
}
|
|
8689
9224
|
function extractStringPropertyFromObject(node, keyName) {
|
|
8690
9225
|
for (const property of node.properties) {
|
|
8691
9226
|
if (!t.isObjectProperty(property)) continue;
|
|
@@ -8790,24 +9325,41 @@ function mergeComponentSourceInfo(target, source) {
|
|
|
8790
9325
|
}
|
|
8791
9326
|
function collectTemplateComponentTagInfo(template, filename, warn) {
|
|
8792
9327
|
const warnHandler = resolveWarnHandler(warn);
|
|
8793
|
-
const
|
|
9328
|
+
const autoImportTags = collectVueTemplateTags(template, {
|
|
8794
9329
|
filename,
|
|
8795
9330
|
warnLabel: "组件标签",
|
|
8796
9331
|
warn: (message) => warnHandler(message),
|
|
8797
9332
|
shouldCollect: isAutoImportCandidateTag
|
|
8798
9333
|
});
|
|
8799
|
-
const
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
9334
|
+
const templateTags = collectVueTemplateTags(template, {
|
|
9335
|
+
filename,
|
|
9336
|
+
warnLabel: "脚本导入组件标签",
|
|
9337
|
+
warn: (message) => warnHandler(message),
|
|
9338
|
+
shouldCollect: () => true
|
|
9339
|
+
});
|
|
9340
|
+
const componentNames = /* @__PURE__ */ new Set();
|
|
9341
|
+
const tagsByComponentName = /* @__PURE__ */ new Map();
|
|
9342
|
+
for (const tag of templateTags) {
|
|
9343
|
+
const camelName = kebabToCamel(tag);
|
|
9344
|
+
for (const componentName of [
|
|
9345
|
+
tag,
|
|
9346
|
+
camelName,
|
|
9347
|
+
capitalize(camelName)
|
|
9348
|
+
]) {
|
|
9349
|
+
componentNames.add(componentName);
|
|
9350
|
+
const matchedTags = tagsByComponentName.get(componentName) ?? /* @__PURE__ */ new Set();
|
|
9351
|
+
matchedTags.add(tag);
|
|
9352
|
+
tagsByComponentName.set(componentName, matchedTags);
|
|
9353
|
+
}
|
|
8803
9354
|
}
|
|
8804
9355
|
return {
|
|
8805
|
-
autoImportTags
|
|
8806
|
-
componentNames
|
|
9356
|
+
autoImportTags,
|
|
9357
|
+
componentNames,
|
|
9358
|
+
tagsByComponentName
|
|
8807
9359
|
};
|
|
8808
9360
|
}
|
|
8809
9361
|
async function collectScriptSetupUsingComponents(options) {
|
|
8810
|
-
const { descriptor, descriptorForCompile, filename, compileOptions, autoUsingComponents, templateComponentNames, result } = options;
|
|
9362
|
+
const { descriptor, descriptorForCompile, filename, compileOptions, autoUsingComponents, templateComponentNames, templateTagsByComponentName, result } = options;
|
|
8811
9363
|
if (!descriptor.scriptSetup || !descriptor.template) return;
|
|
8812
9364
|
if (!templateComponentNames?.size) return;
|
|
8813
9365
|
try {
|
|
@@ -8822,11 +9374,13 @@ async function collectScriptSetupUsingComponents(options) {
|
|
|
8822
9374
|
if (!("local" in specifier) || !t.isIdentifier(specifier.local)) continue;
|
|
8823
9375
|
const localName = specifier.local.name;
|
|
8824
9376
|
if (!templateComponentNames.has(localName)) continue;
|
|
9377
|
+
const templateTags = [...templateTagsByComponentName?.get(localName) ?? [localName]];
|
|
8825
9378
|
if (t.isImportDefaultSpecifier(specifier)) pending.push({
|
|
8826
9379
|
localName,
|
|
8827
9380
|
importSource,
|
|
8828
9381
|
importedName: "default",
|
|
8829
|
-
kind: "default"
|
|
9382
|
+
kind: "default",
|
|
9383
|
+
templateTags
|
|
8830
9384
|
});
|
|
8831
9385
|
else if (t.isImportSpecifier(specifier)) {
|
|
8832
9386
|
const importedName = t.isIdentifier(specifier.imported) ? specifier.imported.name : t.isStringLiteral(specifier.imported) ? specifier.imported.value : void 0;
|
|
@@ -8834,12 +9388,13 @@ async function collectScriptSetupUsingComponents(options) {
|
|
|
8834
9388
|
localName,
|
|
8835
9389
|
importSource,
|
|
8836
9390
|
importedName,
|
|
8837
|
-
kind: "named"
|
|
9391
|
+
kind: "named",
|
|
9392
|
+
templateTags
|
|
8838
9393
|
});
|
|
8839
9394
|
}
|
|
8840
9395
|
}
|
|
8841
9396
|
} });
|
|
8842
|
-
const resolvedComponents = await Promise.all(pending.map(async ({ localName, importSource, importedName, kind }) => {
|
|
9397
|
+
const resolvedComponents = await Promise.all(pending.map(async ({ localName, importSource, importedName, kind, templateTags }) => {
|
|
8843
9398
|
let resolved = autoUsingComponents?.resolveUsingComponentPath ? normalizeResolvedUsingComponent(await autoUsingComponents.resolveUsingComponentPath(importSource, filename, {
|
|
8844
9399
|
localName,
|
|
8845
9400
|
importedName,
|
|
@@ -8861,12 +9416,13 @@ async function collectScriptSetupUsingComponents(options) {
|
|
|
8861
9416
|
localName,
|
|
8862
9417
|
importSource,
|
|
8863
9418
|
resolved,
|
|
8864
|
-
componentMeta
|
|
9419
|
+
componentMeta,
|
|
9420
|
+
templateTags
|
|
8865
9421
|
};
|
|
8866
9422
|
}));
|
|
8867
|
-
for (const { localName, importSource, resolved, componentMeta } of resolvedComponents) {
|
|
9423
|
+
for (const { localName, importSource, resolved, componentMeta, templateTags } of resolvedComponents) {
|
|
8868
9424
|
if (resolved?.from) {
|
|
8869
|
-
result.autoUsingComponentsMap[
|
|
9425
|
+
for (const tag of templateTags) result.autoUsingComponentsMap[tag] = resolved.from;
|
|
8870
9426
|
result.autoComponentMeta[localName] = resolved.from;
|
|
8871
9427
|
}
|
|
8872
9428
|
if (isVueSfcSource(importSource) || isWevuSfcComponent(resolved)) {
|
|
@@ -8874,7 +9430,9 @@ async function collectScriptSetupUsingComponents(options) {
|
|
|
8874
9430
|
result.wevuComponentTags.add(pascalToKebab(localName));
|
|
8875
9431
|
}
|
|
8876
9432
|
registerComponentName(result, localName, componentMeta.componentName);
|
|
9433
|
+
for (const tag of templateTags) registerComponentName(result, tag, componentMeta.componentName);
|
|
8877
9434
|
registerMiniProgramComponentTag(result, localName, componentMeta.isMiniProgramComponent);
|
|
9435
|
+
for (const tag of templateTags) registerMiniProgramComponentTag(result, tag, componentMeta.isMiniProgramComponent);
|
|
8878
9436
|
}
|
|
8879
9437
|
} catch (error) {
|
|
8880
9438
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -8929,6 +9487,7 @@ async function collectComponentSourceInfo(options) {
|
|
|
8929
9487
|
compileOptions: options.compileOptions,
|
|
8930
9488
|
autoUsingComponents: options.autoUsingComponents,
|
|
8931
9489
|
templateComponentNames: templateComponentTagInfo?.componentNames,
|
|
9490
|
+
templateTagsByComponentName: templateComponentTagInfo?.tagsByComponentName,
|
|
8932
9491
|
result: scriptSetupResult
|
|
8933
9492
|
}), collectAutoImportWevuComponents({
|
|
8934
9493
|
descriptor: options.descriptor,
|
|
@@ -8980,7 +9539,8 @@ async function evaluateJsLikeConfig(source, filename, lang) {
|
|
|
8980
9539
|
return await withTempDirLock(tempRoot, async () => {
|
|
8981
9540
|
await ensureDir(tempDir);
|
|
8982
9541
|
const tempFile = path.join(tempDir, `${basename}.${unique}.${extension}`);
|
|
8983
|
-
|
|
9542
|
+
const rewritten = rewriteJsLikeImportsForTempDir(source, dir, tempDir);
|
|
9543
|
+
await writeFile(tempFile, rewritten, "utf8");
|
|
8984
9544
|
try {
|
|
8985
9545
|
const { mod } = await bundleRequire({
|
|
8986
9546
|
filepath: tempFile,
|
|
@@ -9158,7 +9718,8 @@ function tryConvertObjectMethodSourceToFunctionExpression(source) {
|
|
|
9158
9718
|
if (!firstProperty) return null;
|
|
9159
9719
|
if (t.isObjectMethod(firstProperty)) {
|
|
9160
9720
|
const functionName = t.isIdentifier(firstProperty.key) ? t.identifier(firstProperty.key.name) : null;
|
|
9161
|
-
|
|
9721
|
+
const functionExpression = t.functionExpression(functionName, firstProperty.params, firstProperty.body, firstProperty.generator, firstProperty.async);
|
|
9722
|
+
return generate(functionExpression).code;
|
|
9162
9723
|
}
|
|
9163
9724
|
if (t.isObjectProperty(firstProperty) && (t.isFunctionExpression(firstProperty.value) || t.isArrowFunctionExpression(firstProperty.value))) return generate(firstProperty.value).code;
|
|
9164
9725
|
} catch {}
|
|
@@ -9793,7 +10354,8 @@ function collectScriptSetupReturnInfo(scriptCode) {
|
|
|
9793
10354
|
}
|
|
9794
10355
|
};
|
|
9795
10356
|
try {
|
|
9796
|
-
|
|
10357
|
+
const ast = parseJsLike(scriptCode);
|
|
10358
|
+
traverse(ast, {
|
|
9797
10359
|
VariableDeclarator(path) {
|
|
9798
10360
|
const init = path.node.init;
|
|
9799
10361
|
if (t.isIdentifier(path.node.id) && t.isIdentifier(init) && propsObjectAliases.has(init.name)) {
|
|
@@ -9878,7 +10440,8 @@ async function compileScriptPhase(descriptor, descriptorForCompile, filename, op
|
|
|
9878
10440
|
} else scriptCode = "export default {}";
|
|
9879
10441
|
if (scriptCode) {
|
|
9880
10442
|
const transformed = transformScript(scriptCode, {
|
|
9881
|
-
|
|
10443
|
+
isTypeScript: descriptor.script?.lang === "ts" || descriptor.script?.lang === "tsx" || descriptor.scriptSetup?.lang === "ts" || descriptor.scriptSetup?.lang === "tsx",
|
|
10444
|
+
skipComponentTransform: options?.skipComponentTransform ?? isAppFile,
|
|
9882
10445
|
isApp: isAppFile,
|
|
9883
10446
|
isPage: options?.isPage === true,
|
|
9884
10447
|
minify: options?.minify,
|
|
@@ -9924,14 +10487,16 @@ function generateScopedId(filename) {
|
|
|
9924
10487
|
}
|
|
9925
10488
|
//#endregion
|
|
9926
10489
|
//#region src/plugins/vue/transform/compileVueFile/style.ts
|
|
9927
|
-
function compileStylePhase(descriptor, filename, result) {
|
|
10490
|
+
function compileStylePhase(descriptor, filename, result, options) {
|
|
9928
10491
|
if (descriptor.styles.length === 0) return;
|
|
9929
10492
|
const scopedId = generateScopedId(filename);
|
|
9930
10493
|
const compiledStyles = descriptor.styles.map((styleBlock) => {
|
|
9931
10494
|
return compileVueStyleToWxss(styleBlock, {
|
|
9932
10495
|
id: scopedId,
|
|
9933
10496
|
scoped: styleBlock.scoped,
|
|
9934
|
-
modules: styleBlock.module
|
|
10497
|
+
modules: styleBlock.module,
|
|
10498
|
+
preserveDeepSelectors: options?.preserveDeepSelectors,
|
|
10499
|
+
transformScoped: options?.transformScoped
|
|
9935
10500
|
});
|
|
9936
10501
|
});
|
|
9937
10502
|
result.style = compiledStyles.map((s) => s.code.trim()).filter(Boolean).join("\n\n");
|
|
@@ -10057,7 +10622,7 @@ async function compileVueFile(source, filename, options) {
|
|
|
10057
10622
|
});
|
|
10058
10623
|
result.script = scriptPhase.script;
|
|
10059
10624
|
result.scriptMap = scriptPhase.scriptMap;
|
|
10060
|
-
compileStylePhase(parsed.descriptor, filename, result);
|
|
10625
|
+
compileStylePhase(parsed.descriptor, filename, result, options?.style);
|
|
10061
10626
|
await compileConfigPhase({
|
|
10062
10627
|
descriptor: parsed.descriptor,
|
|
10063
10628
|
filename,
|
|
@@ -10082,4 +10647,4 @@ async function compileVueFile(source, filename, options) {
|
|
|
10082
10647
|
return result;
|
|
10083
10648
|
}
|
|
10084
10649
|
//#endregion
|
|
10085
|
-
export { CLASS_STYLE_WXS_FILE, CLASS_STYLE_WXS_MODULE, RESERVED_VUE_COMPONENT_TAGS, VUE_COMPONENT_TAG_RE, WE_VU_COMPILER_REACTIVITY_MODULE_ID, WE_VU_COMPILER_RUNTIME_MODULE_ID, WE_VU_COMPILER_TEMPLATE_MODULE_ID, WE_VU_INTERNAL_REACTIVITY_APIS, WE_VU_INTERNAL_REACTIVITY_MODULE_ID, WE_VU_INTERNAL_RUNTIME_MODULE_ID, WE_VU_INTERNAL_TEMPLATE_APIS, WE_VU_INTERNAL_TEMPLATE_MODULE_ID, WE_VU_MODULE_ID, WE_VU_PAGE_HOOK_TO_FEATURE, WE_VU_RUNTIME_APIS, WE_VU_RUNTIME_MODULE_IDS, alipayPlatform, buildClassStyleComputedCode, buildClassStyleWxsTag, builtinComponentsSet, clearFileCaches, collectTargetOptionsObjectsFromCode, collectVueTemplateTags, collectWevuFeaturesFromCodeReachableImports, collectWevuPageFeatureFlags, collectWevuPageFeatureFlagsFromCode, compileConfigBlocks, compileJsxFile, compileVueFile as compileSfc, compileVueFile, compileVueStyleToWxss as compileStyle, compileVueStyleToWxss, compileVueTemplateToWxml as compileTemplate, compileVueTemplateToWxml, createJsonMerger, createPageEntryMatcher, defaultMiniProgramPlatform, defaultMiniProgramTemplatePlatform, defaultPlatform, evaluateJsLikeConfig, extractJsonMacroFromScriptSetup, generateScopedId, getClassStyleWxsSource, getDefaultMiniProgramPlatform, getDefaultMiniProgramTemplatePlatform, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeatureFlagsIntoOptionsObject, injectWevuPageFeaturesInJs, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isInvalidate, isJsonLikeLang, isWevuRuntimeModuleId, loadCache, mayContainJsonMacro, mergeJsonWithStrategy, mtimeCache, normalizeConfigLang, pathExists, preprocessScriptSetupSrc, preprocessScriptSrc, readAndParseSfc, readFile, refreshVueFileJsonConfig, resolveClassStyleWxsLocation, resolveJsLikeLang, resolveSfcBlockSrc, resolveWevuInternalImportModuleId, restoreScriptSetupSrc, restoreScriptSrc, stripJsonMacroCallsFromCode, swanPlatform, transformScript, transformScript as transformSfcScript, ttPlatform, wechatPlatform };
|
|
10650
|
+
export { CLASS_STYLE_WXS_FILE, CLASS_STYLE_WXS_MODULE, RESERVED_VUE_COMPONENT_TAGS, VUE_COMPONENT_TAG_RE, WE_VU_COMPILER_REACTIVITY_MODULE_ID, WE_VU_COMPILER_RUNTIME_MODULE_ID, WE_VU_COMPILER_TEMPLATE_MODULE_ID, WE_VU_INTERNAL_REACTIVITY_APIS, WE_VU_INTERNAL_REACTIVITY_MODULE_ID, WE_VU_INTERNAL_RUNTIME_MODULE_ID, WE_VU_INTERNAL_TEMPLATE_APIS, WE_VU_INTERNAL_TEMPLATE_MODULE_ID, WE_VU_MODULE_ID, WE_VU_PAGE_HOOK_TO_FEATURE, WE_VU_RUNTIME_APIS, WE_VU_RUNTIME_MODULE_IDS, alipayPlatform, buildClassStyleComputedCode, buildClassStyleWxsTag, builtinComponentsSet, clearFileCaches, collectTargetOptionsObjectsFromCode, collectVueTemplateTags, collectWevuFeaturesFromCodeReachableImports, collectWevuPageFeatureFlags, collectWevuPageFeatureFlagsFromCode, compileConfigBlocks, compileJsxFile, compileVueFile as compileSfc, compileVueFile, compileVueStyleToWxss as compileStyle, compileVueStyleToWxss, compileVueTemplateToWxml as compileTemplate, compileVueTemplateToWxml, createJsonMerger, createPageEntryMatcher, defaultMiniProgramPlatform, defaultMiniProgramTemplatePlatform, defaultPlatform, evaluateJsLikeConfig, extractJsonMacroFromScriptSetup, generateScopedId, getClassStyleWxsSource, getDefaultMiniProgramPlatform, getDefaultMiniProgramTemplatePlatform, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeatureFlagsIntoOptionsObject, injectWevuPageFeaturesInJs, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isInvalidate, isJsonLikeLang, isUniAppCompatibilityFile, isWevuRuntimeModuleId, loadCache, mayContainJsonMacro, mergeJsonWithStrategy, mtimeCache, normalizeConfigLang, pathExists, preprocessScriptSetupSrc, preprocessScriptSrc, readAndParseSfc, readFile, refreshVueFileJsonConfig, resolveClassStyleWxsLocation, resolveJsLikeLang, resolveSfcBlockSrc, resolveWevuInternalImportModuleId, restoreScriptSetupSrc, restoreScriptSrc, stripJsonMacroCallsFromCode, swanPlatform, transformNestedWxssVars, transformScript, transformScript as transformSfcScript, transformUniAppConditionalCode, transformUniAppSource, transformVueDeepSelectors, ttPlatform, wechatPlatform };
|