@wevu/compiler 6.14.3 → 6.15.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 +2 -1
- package/dist/index.mjs +160 -90
- package/package.json +5 -4
package/dist/index.d.mts
CHANGED
|
@@ -250,6 +250,7 @@ interface ForParseResult {
|
|
|
250
250
|
*/
|
|
251
251
|
interface TemplateCompileOptions {
|
|
252
252
|
platform?: MiniProgramPlatform;
|
|
253
|
+
htmlTagToWxml?: boolean | Record<string, string>;
|
|
253
254
|
scopedSlotsCompiler?: ScopedSlotsCompilerMode;
|
|
254
255
|
scopedSlotsRequireProps?: boolean;
|
|
255
256
|
slotMultipleInstance?: boolean;
|
|
@@ -680,7 +681,7 @@ declare function collectWevuPageFeatureFlagsFromCode(code: string, options?: {
|
|
|
680
681
|
astEngine?: AstEngineName$1;
|
|
681
682
|
}): Set<WevuPageFeatureFlag>;
|
|
682
683
|
//#endregion
|
|
683
|
-
//#region src/plugins/wevu/pageFeatures/moduleAnalysis.d.ts
|
|
684
|
+
//#region src/plugins/wevu/pageFeatures/moduleAnalysis/types.d.ts
|
|
684
685
|
type FunctionLike = t.FunctionDeclaration | t.FunctionExpression | t.ArrowFunctionExpression | t.ObjectMethod | {
|
|
685
686
|
type: string;
|
|
686
687
|
[key: string]: any;
|
package/dist/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import os from "node:os";
|
|
|
13
13
|
import process from "node:process";
|
|
14
14
|
import { collectFeatureFlagsFromCode, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, getRenderPropertyFromComponentOptions, parseJsLikeWithEngine, resolveRenderExpressionFromComponentOptions, toStaticObjectKey, unwrapTypeScriptExpression } from "@weapp-vite/ast";
|
|
15
15
|
import { LRUCache } from "lru-cache";
|
|
16
|
+
import { WEVU_CLASS_STYLE_RUNTIME_FILE, WEVU_CLASS_STYLE_RUNTIME_MODULE, WEVU_EXPRESSION_ERROR_IDENTIFIER, 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_KEY, WEVU_SLOT_OWNER_ATTR, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_OWNER_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 } from "@weapp-core/constants";
|
|
16
17
|
import { compileScript, parse } from "vue/compiler-sfc";
|
|
17
18
|
import { fileURLToPath } from "node:url";
|
|
18
19
|
import { parse as parse$1 } from "@vue/compiler-dom";
|
|
@@ -845,7 +846,7 @@ function collectWevuPageFeatureFlagsFromCode(code, options) {
|
|
|
845
846
|
}
|
|
846
847
|
}
|
|
847
848
|
//#endregion
|
|
848
|
-
//#region src/plugins/wevu/pageFeatures/moduleAnalysis.ts
|
|
849
|
+
//#region src/plugins/wevu/pageFeatures/moduleAnalysis/shared.ts
|
|
849
850
|
function createEmptyModuleAnalysis(id, engine) {
|
|
850
851
|
return {
|
|
851
852
|
id,
|
|
@@ -870,6 +871,15 @@ function getFunctionLikeFromExpression(node) {
|
|
|
870
871
|
if (t.isFunctionExpression(node) || t.isArrowFunctionExpression(node)) return node;
|
|
871
872
|
return null;
|
|
872
873
|
}
|
|
874
|
+
function isOxcFunctionLike(node) {
|
|
875
|
+
return node?.type === "FunctionDeclaration" || node?.type === "FunctionExpression" || node?.type === "ArrowFunctionExpression";
|
|
876
|
+
}
|
|
877
|
+
function getImportedSpecifierName(node) {
|
|
878
|
+
if (node?.type === "Identifier") return node.name;
|
|
879
|
+
if ((node?.type === "StringLiteral" || node?.type === "Literal") && typeof node.value === "string") return node.value;
|
|
880
|
+
}
|
|
881
|
+
//#endregion
|
|
882
|
+
//#region src/plugins/wevu/pageFeatures/moduleAnalysis/babel.ts
|
|
873
883
|
function createModuleAnalysis(id, ast) {
|
|
874
884
|
const localFunctions = /* @__PURE__ */ new Map();
|
|
875
885
|
const exports = /* @__PURE__ */ new Map();
|
|
@@ -999,13 +1009,8 @@ function createModuleAnalysis(id, ast) {
|
|
|
999
1009
|
exports
|
|
1000
1010
|
};
|
|
1001
1011
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
}
|
|
1005
|
-
function getImportedSpecifierName(node) {
|
|
1006
|
-
if (node?.type === "Identifier") return node.name;
|
|
1007
|
-
if ((node?.type === "StringLiteral" || node?.type === "Literal") && typeof node.value === "string") return node.value;
|
|
1008
|
-
}
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/plugins/wevu/pageFeatures/moduleAnalysis/oxc.ts
|
|
1009
1014
|
function resolveOxcParseFilename(id) {
|
|
1010
1015
|
if (path.extname(id)) return id;
|
|
1011
1016
|
return `${id}.js`;
|
|
@@ -1133,6 +1138,8 @@ function createModuleAnalysisWithOxc(id, code) {
|
|
|
1133
1138
|
exports
|
|
1134
1139
|
};
|
|
1135
1140
|
}
|
|
1141
|
+
//#endregion
|
|
1142
|
+
//#region src/plugins/wevu/pageFeatures/moduleAnalysis/index.ts
|
|
1136
1143
|
function createModuleAnalysisFromCode(id, code, options) {
|
|
1137
1144
|
const engine = options?.astEngine ?? "babel";
|
|
1138
1145
|
const cacheKey = createModuleAnalysisCacheKey(id, engine);
|
|
@@ -2204,13 +2211,13 @@ function createValidIdentifier(name, fallback) {
|
|
|
2204
2211
|
function buildNormalizedExpression(binding, helpers) {
|
|
2205
2212
|
if (binding.type === "bind") {
|
|
2206
2213
|
const exp = binding.expAst ? t.cloneNode(binding.expAst, true) : t.identifier("undefined");
|
|
2207
|
-
return t.callExpression(t.arrowFunctionExpression([], t.blockStatement([t.tryStatement(t.blockStatement([t.returnStatement(exp)]), t.catchClause(t.identifier(
|
|
2214
|
+
return t.callExpression(t.arrowFunctionExpression([], t.blockStatement([t.tryStatement(t.blockStatement([t.returnStatement(exp)]), t.catchClause(t.identifier(WEVU_EXPRESSION_ERROR_IDENTIFIER), t.blockStatement([t.returnStatement(t.identifier("undefined"))])), null)])), []);
|
|
2208
2215
|
}
|
|
2209
2216
|
const normalizeHelper = binding.type === "class" ? helpers.normalizeClass : helpers.normalizeStyle;
|
|
2210
2217
|
const errorFallback = binding.errorFallback ?? "";
|
|
2211
2218
|
const exp = binding.expAst ? t.cloneNode(binding.expAst, true) : t.stringLiteral("");
|
|
2212
2219
|
const normalizedCall = t.callExpression(t.cloneNode(normalizeHelper), [exp]);
|
|
2213
|
-
return t.callExpression(t.arrowFunctionExpression([], t.blockStatement([t.tryStatement(t.blockStatement([t.returnStatement(normalizedCall)]), t.catchClause(t.identifier(
|
|
2220
|
+
return t.callExpression(t.arrowFunctionExpression([], t.blockStatement([t.tryStatement(t.blockStatement([t.returnStatement(normalizedCall)]), t.catchClause(t.identifier(WEVU_EXPRESSION_ERROR_IDENTIFIER), t.blockStatement([t.returnStatement(t.stringLiteral(errorFallback))])), null)])), []);
|
|
2214
2221
|
}
|
|
2215
2222
|
function buildArrayMapExpression(binding, forStack, level, listId, helpers) {
|
|
2216
2223
|
const itemParam = createValidIdentifier(forStack[level].item, `__wv_item_${level}`);
|
|
@@ -2574,7 +2581,7 @@ function buildMethodsMergeFromSpreadSources(componentExpr, inlineMapExpr) {
|
|
|
2574
2581
|
return t.callExpression(t.memberExpression(t.identifier("Object"), t.identifier("assign")), [
|
|
2575
2582
|
t.objectExpression([]),
|
|
2576
2583
|
...spreadSources,
|
|
2577
|
-
t.objectExpression([t.objectProperty(createStaticObjectKey$1(
|
|
2584
|
+
t.objectExpression([t.objectProperty(createStaticObjectKey$1(WEVU_INLINE_MAP_KEY), inlineMapExpr)])
|
|
2578
2585
|
]);
|
|
2579
2586
|
}
|
|
2580
2587
|
function injectInlineExpressions(componentExpr, inlineExpressions) {
|
|
@@ -2587,13 +2594,13 @@ function injectInlineExpressions(componentExpr, inlineExpressions) {
|
|
|
2587
2594
|
componentExpr.properties.push(t.objectProperty(createStaticObjectKey$1("methods"), mergedMethods));
|
|
2588
2595
|
return true;
|
|
2589
2596
|
}
|
|
2590
|
-
componentExpr.properties.push(t.objectProperty(createStaticObjectKey$1("methods"), t.objectExpression([t.objectProperty(createStaticObjectKey$1(
|
|
2597
|
+
componentExpr.properties.push(t.objectProperty(createStaticObjectKey$1("methods"), t.objectExpression([t.objectProperty(createStaticObjectKey$1(WEVU_INLINE_MAP_KEY), inlineMapExpr)])));
|
|
2591
2598
|
return true;
|
|
2592
2599
|
}
|
|
2593
2600
|
if (!t.isObjectExpression(methodsProp.value)) return false;
|
|
2594
|
-
const mapProp = getObjectPropertyByKey$1(methodsProp.value,
|
|
2601
|
+
const mapProp = getObjectPropertyByKey$1(methodsProp.value, WEVU_INLINE_MAP_KEY);
|
|
2595
2602
|
if (!mapProp) {
|
|
2596
|
-
methodsProp.value.properties.push(t.objectProperty(createStaticObjectKey$1(
|
|
2603
|
+
methodsProp.value.properties.push(t.objectProperty(createStaticObjectKey$1(WEVU_INLINE_MAP_KEY), inlineMapExpr));
|
|
2597
2604
|
return true;
|
|
2598
2605
|
}
|
|
2599
2606
|
if (t.isObjectExpression(mapProp.value)) {
|
|
@@ -2616,8 +2623,8 @@ function injectLayoutHosts(optionsObject, bindings, warn) {
|
|
|
2616
2623
|
const warnHandler = resolveWarnHandler(warn);
|
|
2617
2624
|
const entries = bindings.map((binding) => buildLayoutHostEntry(binding));
|
|
2618
2625
|
const hostsArray = t.arrayExpression(entries);
|
|
2619
|
-
const key = createStaticObjectKey$1(
|
|
2620
|
-
const existing = getObjectPropertyByKey$1(optionsObject,
|
|
2626
|
+
const key = createStaticObjectKey$1(WEVU_LAYOUT_HOSTS_KEY);
|
|
2627
|
+
const existing = getObjectPropertyByKey$1(optionsObject, WEVU_LAYOUT_HOSTS_KEY);
|
|
2621
2628
|
if (!existing) {
|
|
2622
2629
|
optionsObject.properties.push(t.objectProperty(key, hostsArray));
|
|
2623
2630
|
return true;
|
|
@@ -2630,7 +2637,7 @@ function injectLayoutHosts(optionsObject, bindings, warn) {
|
|
|
2630
2637
|
existing.value = t.arrayExpression([...entries, t.spreadElement(t.cloneNode(existing.value, true))]);
|
|
2631
2638
|
return true;
|
|
2632
2639
|
}
|
|
2633
|
-
warnHandler(
|
|
2640
|
+
warnHandler(`无法自动注入 layout host 元数据,请手动合并 ${WEVU_LAYOUT_HOSTS_KEY}。`);
|
|
2634
2641
|
return false;
|
|
2635
2642
|
}
|
|
2636
2643
|
//#endregion
|
|
@@ -2754,8 +2761,8 @@ function injectTemplateRefs(optionsObject, bindings, warn) {
|
|
|
2754
2761
|
const warnHandler = resolveWarnHandler(warn);
|
|
2755
2762
|
const entries = bindings.map((binding) => buildTemplateRefEntry(binding));
|
|
2756
2763
|
const refsArray = t.arrayExpression(entries);
|
|
2757
|
-
const key = createStaticObjectKey$1(
|
|
2758
|
-
const existing = getObjectPropertyByKey$1(optionsObject,
|
|
2764
|
+
const key = createStaticObjectKey$1(WEVU_TEMPLATE_REFS_KEY);
|
|
2765
|
+
const existing = getObjectPropertyByKey$1(optionsObject, WEVU_TEMPLATE_REFS_KEY);
|
|
2759
2766
|
if (!existing) {
|
|
2760
2767
|
optionsObject.properties.push(t.objectProperty(key, refsArray));
|
|
2761
2768
|
return true;
|
|
@@ -2768,7 +2775,7 @@ function injectTemplateRefs(optionsObject, bindings, warn) {
|
|
|
2768
2775
|
existing.value = t.arrayExpression([...entries, t.spreadElement(t.cloneNode(existing.value, true))]);
|
|
2769
2776
|
return true;
|
|
2770
2777
|
}
|
|
2771
|
-
warnHandler(
|
|
2778
|
+
warnHandler(`无法自动注入 template ref 元数据,请手动合并 ${WEVU_TEMPLATE_REFS_KEY}。`);
|
|
2772
2779
|
return false;
|
|
2773
2780
|
}
|
|
2774
2781
|
//#endregion
|
|
@@ -2875,9 +2882,9 @@ function rewriteDefaultExport(ast, state, options, enabledPageFeatures, serializ
|
|
|
2875
2882
|
const exportPath = state.defaultExportPath;
|
|
2876
2883
|
const componentExpr = resolveComponentExpression(exportPath.node.declaration, state.defineComponentDecls, state.defineComponentAliases);
|
|
2877
2884
|
const componentOptionsObject = resolveComponentOptionsObject(componentExpr);
|
|
2878
|
-
const hasPageMarker = componentExpr ? hasStaticPropertyInComponentExpression(componentExpr,
|
|
2885
|
+
const hasPageMarker = componentExpr ? hasStaticPropertyInComponentExpression(componentExpr, WEVU_IS_PAGE_KEY, ast.program) : false;
|
|
2879
2886
|
if (componentOptionsObject && options?.isPage && !options?.isApp && !hasPageMarker) {
|
|
2880
|
-
componentOptionsObject.properties.splice(0, 0, t.objectProperty(t.identifier(
|
|
2887
|
+
componentOptionsObject.properties.splice(0, 0, t.objectProperty(t.identifier(WEVU_IS_PAGE_KEY), t.booleanLiteral(true)));
|
|
2881
2888
|
transformed = true;
|
|
2882
2889
|
}
|
|
2883
2890
|
if (componentOptionsObject && enabledPageFeatures.size) transformed = injectWevuPageFeatureFlagsIntoOptionsObject(componentOptionsObject, enabledPageFeatures) || transformed;
|
|
@@ -2956,6 +2963,16 @@ function transformScript(source, options) {
|
|
|
2956
2963
|
};
|
|
2957
2964
|
}
|
|
2958
2965
|
//#endregion
|
|
2966
|
+
//#region src/inlineDataset.ts
|
|
2967
|
+
const NON_ALNUM_RE = /[^a-z0-9]+/gi;
|
|
2968
|
+
const LEADING_TRAILING_DASH_RE = /^-+|-+$/g;
|
|
2969
|
+
function normalizeEventDatasetSuffix(eventName) {
|
|
2970
|
+
return eventName.trim().replace(NON_ALNUM_RE, "-").replace(LEADING_TRAILING_DASH_RE, "").toLowerCase() || "event";
|
|
2971
|
+
}
|
|
2972
|
+
function createInlineExpressionId(seed) {
|
|
2973
|
+
return `i${seed.toString(36)}`;
|
|
2974
|
+
}
|
|
2975
|
+
//#endregion
|
|
2959
2976
|
//#region src/plugins/vue/compiler/template/expression/wxml.ts
|
|
2960
2977
|
function templateLiteralToConcat(node) {
|
|
2961
2978
|
const segments = [];
|
|
@@ -3135,7 +3152,7 @@ function collectExpressionScopeBindings(exp, context) {
|
|
|
3135
3152
|
}
|
|
3136
3153
|
function registerInlineExpression$1(exp, context) {
|
|
3137
3154
|
const scopeKeys = collectExpressionScopeBindings(exp, context);
|
|
3138
|
-
const id =
|
|
3155
|
+
const id = createInlineExpressionId(context.inlineExpressionSeed++);
|
|
3139
3156
|
context.inlineExpressions.push({
|
|
3140
3157
|
id,
|
|
3141
3158
|
expression: printExpression(exp),
|
|
@@ -3585,25 +3602,20 @@ function lowerEventName(name) {
|
|
|
3585
3602
|
if (!name) return name;
|
|
3586
3603
|
return name.replace(LEADING_UPPER_RE, (s) => s.toLowerCase()).replace(UPPER_CHAR_RE, (s) => s.toLowerCase());
|
|
3587
3604
|
}
|
|
3588
|
-
function
|
|
3605
|
+
function resolveMappedEventName(rawName, context) {
|
|
3589
3606
|
const resolveEvent = (name) => context.platform.mapEventName(lowerEventName(name));
|
|
3590
|
-
if (CAPTURE_BIND_EVENT_RE.test(rawName))
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
if (
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
}
|
|
3602
|
-
if (CATCH_EVENT_RE.test(rawName)) {
|
|
3603
|
-
const eventName = resolveEvent(rawName.slice(5));
|
|
3604
|
-
return context.platform.eventBindingAttr(`catch:${eventName}`);
|
|
3605
|
-
}
|
|
3606
|
-
const eventName = resolveEvent(rawName.slice(2));
|
|
3607
|
+
if (CAPTURE_BIND_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(11));
|
|
3608
|
+
if (CAPTURE_CATCH_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(12));
|
|
3609
|
+
if (MUT_BIND_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(7));
|
|
3610
|
+
if (CATCH_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(5));
|
|
3611
|
+
return resolveEvent(rawName.slice(2));
|
|
3612
|
+
}
|
|
3613
|
+
function toEventBindingName(rawName, context) {
|
|
3614
|
+
const eventName = resolveMappedEventName(rawName, context);
|
|
3615
|
+
if (CAPTURE_BIND_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`capture-bind:${eventName}`);
|
|
3616
|
+
if (CAPTURE_CATCH_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`capture-catch:${eventName}`);
|
|
3617
|
+
if (MUT_BIND_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`mut-bind:${eventName}`);
|
|
3618
|
+
if (CATCH_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`catch:${eventName}`);
|
|
3607
3619
|
return context.platform.eventBindingAttr(`bind:${eventName}`);
|
|
3608
3620
|
}
|
|
3609
3621
|
function readJsxAttributeExpression(value) {
|
|
@@ -3626,13 +3638,14 @@ function extractJsxKeyExpression(node) {
|
|
|
3626
3638
|
}
|
|
3627
3639
|
function compileEventAttribute(name, value, context) {
|
|
3628
3640
|
const bindAttr = toEventBindingName(name, context);
|
|
3641
|
+
const eventSuffix = normalizeEventDatasetSuffix(resolveMappedEventName(name, context));
|
|
3629
3642
|
const exp = readJsxAttributeExpression(value);
|
|
3630
3643
|
if (!exp) return [];
|
|
3631
3644
|
if (t.isStringLiteral(exp) && exp.value) return [`${bindAttr}="${escapeAttr(exp.value)}"`];
|
|
3632
3645
|
if (t.isIdentifier(exp)) return [`${bindAttr}="${escapeAttr(exp.name)}"`];
|
|
3633
3646
|
if (t.isMemberExpression(exp) && !exp.computed && t.isThisExpression(exp.object) && t.isIdentifier(exp.property)) return [`${bindAttr}="${escapeAttr(exp.property.name)}"`];
|
|
3634
3647
|
const inline = registerInlineExpression$1(exp, context);
|
|
3635
|
-
const attrs = [`data-
|
|
3648
|
+
const attrs = [`data-wi-${eventSuffix}="${inline.id}"`, `${bindAttr}="${WEVU_INLINE_HANDLER}"`];
|
|
3636
3649
|
inline.scopeKeys.forEach((scopeKey, index) => {
|
|
3637
3650
|
attrs.push(`data-wv-s${index}="${renderMustache$1(scopeKey, context)}"`);
|
|
3638
3651
|
});
|
|
@@ -4338,11 +4351,11 @@ function generateHash(str) {
|
|
|
4338
4351
|
/**
|
|
4339
4352
|
* class/style WXS 模块名。
|
|
4340
4353
|
*/
|
|
4341
|
-
const CLASS_STYLE_WXS_MODULE =
|
|
4354
|
+
const CLASS_STYLE_WXS_MODULE = WEVU_CLASS_STYLE_RUNTIME_MODULE;
|
|
4342
4355
|
/**
|
|
4343
4356
|
* class/style WXS 文件名(不含扩展名)。
|
|
4344
4357
|
*/
|
|
4345
|
-
const CLASS_STYLE_WXS_FILE =
|
|
4358
|
+
const CLASS_STYLE_WXS_FILE = WEVU_CLASS_STYLE_RUNTIME_FILE;
|
|
4346
4359
|
function resolveScriptModuleTag(extension) {
|
|
4347
4360
|
return (extension.startsWith(".") ? extension.slice(1) : extension) === "sjs" ? "sjs" : "wxs";
|
|
4348
4361
|
}
|
|
@@ -4351,7 +4364,7 @@ function resolveScriptModuleTag(extension) {
|
|
|
4351
4364
|
*/
|
|
4352
4365
|
function buildClassStyleWxsTag(extension, src) {
|
|
4353
4366
|
const normalized = extension.startsWith(".") ? extension.slice(1) : extension;
|
|
4354
|
-
const resolvedSrc = src ??
|
|
4367
|
+
const resolvedSrc = src ?? `./${CLASS_STYLE_WXS_FILE}.${normalized}`;
|
|
4355
4368
|
return `<${resolveScriptModuleTag(normalized)} module="${CLASS_STYLE_WXS_MODULE}" src="${resolvedSrc}"/>`;
|
|
4356
4369
|
}
|
|
4357
4370
|
/**
|
|
@@ -4592,6 +4605,64 @@ function getClassStyleWxsSource(options = {}) {
|
|
|
4592
4605
|
].join("\n");
|
|
4593
4606
|
}
|
|
4594
4607
|
//#endregion
|
|
4608
|
+
//#region src/plugins/vue/compiler/template/htmlTagMapping.ts
|
|
4609
|
+
const DEFAULT_HTML_TO_WXML_TAG_MAP = {
|
|
4610
|
+
a: "navigator",
|
|
4611
|
+
article: "view",
|
|
4612
|
+
aside: "view",
|
|
4613
|
+
b: "text",
|
|
4614
|
+
blockquote: "view",
|
|
4615
|
+
button: "button",
|
|
4616
|
+
code: "text",
|
|
4617
|
+
dd: "view",
|
|
4618
|
+
div: "view",
|
|
4619
|
+
dl: "view",
|
|
4620
|
+
dt: "view",
|
|
4621
|
+
em: "text",
|
|
4622
|
+
figcaption: "view",
|
|
4623
|
+
figure: "view",
|
|
4624
|
+
footer: "view",
|
|
4625
|
+
form: "form",
|
|
4626
|
+
h1: "view",
|
|
4627
|
+
h2: "view",
|
|
4628
|
+
h3: "view",
|
|
4629
|
+
h4: "view",
|
|
4630
|
+
h5: "view",
|
|
4631
|
+
h6: "view",
|
|
4632
|
+
header: "view",
|
|
4633
|
+
i: "text",
|
|
4634
|
+
img: "image",
|
|
4635
|
+
input: "input",
|
|
4636
|
+
label: "label",
|
|
4637
|
+
li: "view",
|
|
4638
|
+
main: "view",
|
|
4639
|
+
nav: "view",
|
|
4640
|
+
ol: "view",
|
|
4641
|
+
p: "view",
|
|
4642
|
+
pre: "view",
|
|
4643
|
+
section: "view",
|
|
4644
|
+
small: "text",
|
|
4645
|
+
span: "text",
|
|
4646
|
+
strong: "text",
|
|
4647
|
+
textarea: "textarea",
|
|
4648
|
+
u: "text",
|
|
4649
|
+
ul: "view"
|
|
4650
|
+
};
|
|
4651
|
+
function resolveHtmlTagToWxmlMap(value) {
|
|
4652
|
+
if (value === false) return;
|
|
4653
|
+
if (value === true || value === void 0) return { ...DEFAULT_HTML_TO_WXML_TAG_MAP };
|
|
4654
|
+
return {
|
|
4655
|
+
...DEFAULT_HTML_TO_WXML_TAG_MAP,
|
|
4656
|
+
...Object.fromEntries(Object.entries(value).map(([key, mapped]) => [key.toLowerCase(), mapped]))
|
|
4657
|
+
};
|
|
4658
|
+
}
|
|
4659
|
+
function resolveTemplateTagName(tag, context) {
|
|
4660
|
+
if (!tag) return tag;
|
|
4661
|
+
const lowerTag = tag.toLowerCase();
|
|
4662
|
+
if (tag !== lowerTag) return tag;
|
|
4663
|
+
return context.htmlTagToWxmlMap?.[lowerTag] ?? tag;
|
|
4664
|
+
}
|
|
4665
|
+
//#endregion
|
|
4595
4666
|
//#region src/plugins/vue/compiler/template/elements/forExpression.ts
|
|
4596
4667
|
const IDENTIFIER_RE$4 = /^[A-Z_$][\w$]*$/i;
|
|
4597
4668
|
const FOR_ITEM_ALIAS_PLACEHOLDER = "__wv_for_item__";
|
|
@@ -4936,10 +5007,10 @@ const SCOPED_SLOT_GLOBALS = new Set([
|
|
|
4936
5007
|
"encodeURIComponent",
|
|
4937
5008
|
"require",
|
|
4938
5009
|
"arguments",
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
5010
|
+
WEVU_SLOT_OWNER_KEY,
|
|
5011
|
+
WEVU_SLOT_PROPS_KEY,
|
|
5012
|
+
WEVU_SLOT_PROPS_DATA_KEY,
|
|
5013
|
+
WEVU_CLASS_STYLE_RUNTIME_MODULE
|
|
4943
5014
|
]);
|
|
4944
5015
|
function collectScopedSlotLocals(context) {
|
|
4945
5016
|
const locals = /* @__PURE__ */ new Set();
|
|
@@ -4996,10 +5067,10 @@ function rewriteScopedSlotExpression(exp, context) {
|
|
|
4996
5067
|
}
|
|
4997
5068
|
if (locals.has(name)) return;
|
|
4998
5069
|
if (Object.hasOwn(slotProps, name)) {
|
|
4999
|
-
replaceIdentifierWithExpression(path, createMemberAccess(
|
|
5070
|
+
replaceIdentifierWithExpression(path, createMemberAccess(WEVU_SLOT_PROPS_DATA_KEY, slotProps[name]));
|
|
5000
5071
|
return;
|
|
5001
5072
|
}
|
|
5002
|
-
replaceIdentifierWithExpression(path, createMemberAccess(
|
|
5073
|
+
replaceIdentifierWithExpression(path, createMemberAccess(WEVU_SLOT_OWNER_KEY, name));
|
|
5003
5074
|
} });
|
|
5004
5075
|
const stmt = ast.program.body[0];
|
|
5005
5076
|
const updatedExpression = stmt && "expression" in stmt ? stmt.expression : null;
|
|
@@ -5093,7 +5164,7 @@ function normalizeStyleBindingExpression(exp, context) {
|
|
|
5093
5164
|
return null;
|
|
5094
5165
|
};
|
|
5095
5166
|
const buildStylePair = (keyExpr, valueExpr) => {
|
|
5096
|
-
return t.callExpression(t.memberExpression(t.identifier(
|
|
5167
|
+
return t.callExpression(t.memberExpression(t.identifier(WEVU_CLASS_STYLE_RUNTIME_MODULE), t.identifier("stylePair")), [keyExpr, valueExpr]);
|
|
5097
5168
|
};
|
|
5098
5169
|
const visit = (node) => {
|
|
5099
5170
|
if (!node) return;
|
|
@@ -5159,7 +5230,7 @@ const INLINE_GLOBALS = new Set([
|
|
|
5159
5230
|
"encodeURIComponent",
|
|
5160
5231
|
"require",
|
|
5161
5232
|
"arguments",
|
|
5162
|
-
|
|
5233
|
+
WEVU_CLASS_STYLE_RUNTIME_MODULE,
|
|
5163
5234
|
"__wevuUnref",
|
|
5164
5235
|
"globalThis",
|
|
5165
5236
|
"setTimeout",
|
|
@@ -5186,8 +5257,8 @@ function createMemberAccess$1(target, prop) {
|
|
|
5186
5257
|
function resolveSlotPropBinding(slotProps, name) {
|
|
5187
5258
|
if (!Object.hasOwn(slotProps, name)) return null;
|
|
5188
5259
|
const prop = slotProps[name];
|
|
5189
|
-
if (!prop) return
|
|
5190
|
-
return generateExpression(createMemberAccess$1(
|
|
5260
|
+
if (!prop) return WEVU_SLOT_PROPS_DATA_KEY;
|
|
5261
|
+
return generateExpression(createMemberAccess$1(WEVU_SLOT_PROPS_DATA_KEY, prop));
|
|
5191
5262
|
}
|
|
5192
5263
|
function rewriteExpressionAst(ast, locals, options) {
|
|
5193
5264
|
traverse(ast, {
|
|
@@ -5286,7 +5357,7 @@ function registerInlineExpression(exp, context) {
|
|
|
5286
5357
|
const indexBindings = buildInlineIndexBindings(context);
|
|
5287
5358
|
const scopeResolvers = buildScopeResolvers(usedLocals, context, slotProps, indexBindings);
|
|
5288
5359
|
const asset = {
|
|
5289
|
-
id:
|
|
5360
|
+
id: createInlineExpressionId(context.inlineExpressionSeed++),
|
|
5290
5361
|
expression: updatedExpression,
|
|
5291
5362
|
scopeKeys: usedLocals
|
|
5292
5363
|
};
|
|
@@ -5370,12 +5441,12 @@ function createHasOwnPropertyCall(target, key) {
|
|
|
5370
5441
|
}
|
|
5371
5442
|
function createIdentifierAccessWithPropsFallback(name) {
|
|
5372
5443
|
if (name === "props") {
|
|
5373
|
-
const propsObject = createThisMemberAccess(
|
|
5444
|
+
const propsObject = createThisMemberAccess(WEVU_PROPS_KEY);
|
|
5374
5445
|
return t.conditionalExpression(t.binaryExpression("!=", propsObject, t.nullLiteral()), propsObject, createThisMemberAccess("props"));
|
|
5375
5446
|
}
|
|
5376
5447
|
const thisAccess = createThisMemberAccess(name);
|
|
5377
|
-
const propsAccess = createMemberAccess(createThisMemberAccess(
|
|
5378
|
-
const propsObject = createThisMemberAccess(
|
|
5448
|
+
const propsAccess = createMemberAccess(createThisMemberAccess(WEVU_PROPS_KEY), name);
|
|
5449
|
+
const propsObject = createThisMemberAccess(WEVU_PROPS_KEY);
|
|
5379
5450
|
const stateObject = createThisMemberAccess("$state");
|
|
5380
5451
|
const hasPropsObject = t.binaryExpression("!=", propsObject, t.nullLiteral());
|
|
5381
5452
|
const hasDefinedPropsValue = t.binaryExpression("!==", propsAccess, t.identifier("undefined"));
|
|
@@ -5432,10 +5503,10 @@ function normalizeJsExpressionWithContext(exp, context, options) {
|
|
|
5432
5503
|
let replacement;
|
|
5433
5504
|
if (context.rewriteScopedSlot) if (Object.hasOwn(slotProps, name)) {
|
|
5434
5505
|
const prop = slotProps[name];
|
|
5435
|
-
const base = createThisMemberAccess(
|
|
5506
|
+
const base = createThisMemberAccess(WEVU_SLOT_PROPS_DATA_KEY);
|
|
5436
5507
|
replacement = createUnrefCall(prop ? createMemberAccess(base, prop) : base);
|
|
5437
|
-
} else if (name ===
|
|
5438
|
-
else replacement = createUnrefCall(createMemberAccess(createThisMemberAccess(
|
|
5508
|
+
} else if (name === WEVU_SLOT_OWNER_KEY || name === WEVU_SLOT_PROPS_DATA_KEY || name === WEVU_SLOT_PROPS_KEY || name === WEVU_SLOT_SCOPE_KEY) replacement = createUnrefCall(createThisMemberAccess(name));
|
|
5509
|
+
else replacement = createUnrefCall(createMemberAccess(createThisMemberAccess(WEVU_SLOT_OWNER_KEY), name));
|
|
5439
5510
|
else replacement = createUnrefCall(createIdentifierAccessWithPropsFallback(name));
|
|
5440
5511
|
const parent = path.parentPath;
|
|
5441
5512
|
if (parent.isObjectProperty() && parent.node.shorthand && parent.node.key === path.node) {
|
|
@@ -5586,7 +5657,7 @@ function renderClassAttribute(staticClass, dynamicClassExp, context) {
|
|
|
5586
5657
|
for (const part of normalizedParts) parts.push(`(${part})`);
|
|
5587
5658
|
const mergedExp = parts.length > 1 ? `[${parts.join(",")}]` : parts[0];
|
|
5588
5659
|
context.classStyleWxs = true;
|
|
5589
|
-
return `class="${renderMustache(
|
|
5660
|
+
return `class="${renderMustache(`${WEVU_CLASS_STYLE_RUNTIME_MODULE}.cls(${mergedExp})`, context)}"`;
|
|
5590
5661
|
}
|
|
5591
5662
|
const jsParts = [];
|
|
5592
5663
|
if (staticValue) jsParts.push(t.stringLiteral(staticValue));
|
|
@@ -5614,7 +5685,7 @@ function renderStyleAttribute(staticStyle, dynamicStyleExp, vShowExp, context) {
|
|
|
5614
5685
|
}
|
|
5615
5686
|
const mergedExp = parts.length > 1 ? `[${parts.join(",")}]` : parts[0] || "''";
|
|
5616
5687
|
context.classStyleWxs = true;
|
|
5617
|
-
return `style="${renderMustache(
|
|
5688
|
+
return `style="${renderMustache(`${WEVU_CLASS_STYLE_RUNTIME_MODULE}.style(${mergedExp})`, context)}"`;
|
|
5618
5689
|
}
|
|
5619
5690
|
const jsParts = [];
|
|
5620
5691
|
if (staticValue) jsParts.push(t.stringLiteral(staticValue));
|
|
@@ -5747,7 +5818,7 @@ const QUOTE_RE$1 = /"/g;
|
|
|
5747
5818
|
function transformVModel(element, expValue, context) {
|
|
5748
5819
|
const escapedModel = expValue.replace(QUOTE_RE$1, """);
|
|
5749
5820
|
const bindModel = (event) => {
|
|
5750
|
-
return `${context.platform.eventBindingAttr(event)}="
|
|
5821
|
+
return `${context.platform.eventBindingAttr(event)}="${WEVU_MODEL_HANDLER}" data-wv-model="${escapedModel}"`;
|
|
5751
5822
|
};
|
|
5752
5823
|
if (!element) return `value="${renderMustache(expValue, context)}" ${bindModel("input")}`;
|
|
5753
5824
|
const tag = element.tag;
|
|
@@ -5781,11 +5852,6 @@ const isSimpleHandler = (value) => SIMPLE_IDENTIFIER_RE.test(value);
|
|
|
5781
5852
|
function shouldUseDetailPayload(options) {
|
|
5782
5853
|
return options?.isComponent === true;
|
|
5783
5854
|
}
|
|
5784
|
-
const NON_ALNUM_RE = /[^a-z0-9]+/gi;
|
|
5785
|
-
const LEADING_TRAILING_DASH_RE = /^-+|-+$/g;
|
|
5786
|
-
function normalizeEventDatasetSuffix(eventName) {
|
|
5787
|
-
return eventName.trim().replace(NON_ALNUM_RE, "-").replace(LEADING_TRAILING_DASH_RE, "").toLowerCase() || "event";
|
|
5788
|
-
}
|
|
5789
5855
|
const QUOTE_RE = /"/g;
|
|
5790
5856
|
function buildInlineScopeAttrs(scopeBindings, context) {
|
|
5791
5857
|
return scopeBindings.map((binding, index) => {
|
|
@@ -5822,27 +5888,27 @@ function transformOnDirective(node, context, options) {
|
|
|
5822
5888
|
const eventSuffix = normalizeEventDatasetSuffix(mappedEvent);
|
|
5823
5889
|
const eventPrefix = resolveEventPrefix(node.modifiers);
|
|
5824
5890
|
const bindAttr = context.platform.eventBindingAttr(`${eventPrefix}:${mappedEvent}`);
|
|
5825
|
-
const detailAttr = useDetailPayload ? `data-
|
|
5891
|
+
const detailAttr = useDetailPayload ? `data-wd-${eventSuffix}="1"` : "";
|
|
5826
5892
|
if (context.rewriteScopedSlot) {
|
|
5827
5893
|
if (inlineExpression) {
|
|
5828
5894
|
const scopeAttrs = buildInlineScopeAttrs(inlineExpression.scopeBindings, context);
|
|
5829
5895
|
const indexAttrs = buildInlineIndexAttrs(inlineExpression.indexBindings, context);
|
|
5830
5896
|
return [
|
|
5831
5897
|
detailAttr,
|
|
5832
|
-
`data-
|
|
5898
|
+
`data-wi-${eventSuffix}="${inlineExpression.id}"`,
|
|
5833
5899
|
...scopeAttrs,
|
|
5834
5900
|
...indexAttrs,
|
|
5835
|
-
`${bindAttr}="
|
|
5901
|
+
`${bindAttr}="${WEVU_OWNER_HANDLER}"`
|
|
5836
5902
|
].filter(Boolean).join(" ");
|
|
5837
5903
|
}
|
|
5838
5904
|
if (!isInlineExpression && rawExpValue) return [
|
|
5839
5905
|
detailAttr,
|
|
5840
|
-
`data-
|
|
5841
|
-
`${bindAttr}="
|
|
5906
|
+
`data-wh-${eventSuffix}="${rawExpValue}"`,
|
|
5907
|
+
`${bindAttr}="${WEVU_OWNER_HANDLER}"`
|
|
5842
5908
|
].filter(Boolean).join(" ");
|
|
5843
5909
|
if (isInlineExpression) {
|
|
5844
5910
|
context.warnings.push("作用域插槽的事件处理解析失败,请使用简单的方法引用。");
|
|
5845
|
-
return [detailAttr, `${bindAttr}="
|
|
5911
|
+
return [detailAttr, `${bindAttr}="${WEVU_OWNER_HANDLER}"`].filter(Boolean).join(" ");
|
|
5846
5912
|
}
|
|
5847
5913
|
}
|
|
5848
5914
|
const expValue = normalizeWxmlExpressionWithContext(rawExpValue, context);
|
|
@@ -5851,16 +5917,16 @@ function transformOnDirective(node, context, options) {
|
|
|
5851
5917
|
const indexAttrs = buildInlineIndexAttrs(inlineExpression.indexBindings, context);
|
|
5852
5918
|
return [
|
|
5853
5919
|
detailAttr,
|
|
5854
|
-
`data-
|
|
5920
|
+
`data-wi-${eventSuffix}="${inlineExpression.id}"`,
|
|
5855
5921
|
...scopeAttrs,
|
|
5856
5922
|
...indexAttrs,
|
|
5857
|
-
`${bindAttr}="
|
|
5923
|
+
`${bindAttr}="${WEVU_INLINE_HANDLER}"`
|
|
5858
5924
|
].filter(Boolean).join(" ");
|
|
5859
5925
|
}
|
|
5860
5926
|
if (isInlineExpression) return [
|
|
5861
5927
|
detailAttr,
|
|
5862
5928
|
`data-wv-inline-${eventSuffix}="${inlineSource.replace(QUOTE_RE, """)}"`,
|
|
5863
|
-
`${bindAttr}="
|
|
5929
|
+
`${bindAttr}="${WEVU_INLINE_HANDLER}"`
|
|
5864
5930
|
].filter(Boolean).join(" ");
|
|
5865
5931
|
return [detailAttr, `${bindAttr}="${expValue}"`].filter(Boolean).join(" ");
|
|
5866
5932
|
}
|
|
@@ -5898,7 +5964,8 @@ function isBuiltinTag(tag) {
|
|
|
5898
5964
|
}
|
|
5899
5965
|
function collectElementAttributes(node, context, options) {
|
|
5900
5966
|
const { props } = node;
|
|
5901
|
-
const
|
|
5967
|
+
const resolvedTag = options?.resolvedTag ?? resolveTemplateTagName(node.tag, context);
|
|
5968
|
+
const isComponentElement = options?.isComponent ?? !isBuiltinTag(resolvedTag);
|
|
5902
5969
|
const attrs = options?.extraAttrs ? [...options.extraAttrs] : [];
|
|
5903
5970
|
let staticClass;
|
|
5904
5971
|
let staticId;
|
|
@@ -5993,8 +6060,8 @@ function collectElementAttributes(node, context, options) {
|
|
|
5993
6060
|
if (layoutHostKey) if (!staticId && hasDynamicIdBinding) context.warnings.push("layout-host 暂不支持与动态 id 同时使用,当前节点已忽略。");
|
|
5994
6061
|
else {
|
|
5995
6062
|
const hostIndex = context.layoutHostIndexSeed++;
|
|
5996
|
-
const hostId = staticId ||
|
|
5997
|
-
const hostRefName =
|
|
6063
|
+
const hostId = staticId || `${WEVU_LAYOUT_HOST_ID_PREFIX}${hostIndex}`;
|
|
6064
|
+
const hostRefName = `${WEVU_LAYOUT_HOST_REF_PREFIX}${hostIndex}`;
|
|
5998
6065
|
staticId = hostId;
|
|
5999
6066
|
context.templateRefs.push({
|
|
6000
6067
|
selector: `#${hostId}`,
|
|
@@ -6230,8 +6297,8 @@ function transformSlotElement(node, context, transformNode) {
|
|
|
6230
6297
|
const genericKey = `scoped-slots-${resolveSlotKey(context, slotNameInfo)}`;
|
|
6231
6298
|
context.componentGenerics[genericKey] = true;
|
|
6232
6299
|
slotPropsExp = slotPropsExp ?? "[]";
|
|
6233
|
-
const scopedAttrs = [
|
|
6234
|
-
if (context.slotMultipleInstance) scopedAttrs.push(
|
|
6300
|
+
const scopedAttrs = [`${WEVU_SLOT_OWNER_ATTR}="${renderMustache(WEVU_SLOT_OWNER_ID_PROP, context)}"`, `${WEVU_SLOT_PROPS_ATTR}="${renderMustache(slotPropsExp, context)}"`];
|
|
6301
|
+
if (context.slotMultipleInstance) scopedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(WEVU_SLOT_SCOPE_KEY, context)}"`);
|
|
6235
6302
|
return `${slotTag}${`<${genericKey}${scopedAttrs.length ? ` ${scopedAttrs.join(" ")}` : ""} />`}`;
|
|
6236
6303
|
}
|
|
6237
6304
|
function transformSlotElementPlain(node, context, transformNode) {
|
|
@@ -6312,8 +6379,8 @@ function transformComponentWithSlots(node, context, transformNode, options) {
|
|
|
6312
6379
|
if (slotNames.length) mergedAttrs.push(`vue-slots="${renderMustache(`[${slotNames.join(",")}]`, context)}"`);
|
|
6313
6380
|
if (scopedSlotDeclarations.length) {
|
|
6314
6381
|
const scopePropsExp = buildScopePropsExpression(context);
|
|
6315
|
-
if (scopePropsExp) mergedAttrs.push(
|
|
6316
|
-
mergedAttrs.push(
|
|
6382
|
+
if (scopePropsExp) mergedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(scopePropsExp, context)}"`);
|
|
6383
|
+
mergedAttrs.push(`${WEVU_SLOT_OWNER_ID_ATTR}="${renderMustache(`${WEVU_SLOT_OWNER_ID_KEY} || ''`, context)}"`);
|
|
6317
6384
|
}
|
|
6318
6385
|
const attrString = mergedAttrs.length ? ` ${mergedAttrs.join(" ")}` : "";
|
|
6319
6386
|
const { tag } = node;
|
|
@@ -6402,11 +6469,11 @@ function transformComponentElement(node, context, transformNode) {
|
|
|
6402
6469
|
//#endregion
|
|
6403
6470
|
//#region src/plugins/vue/compiler/template/elements/tag-normal.ts
|
|
6404
6471
|
function transformNormalElement(node, context, transformNode) {
|
|
6405
|
-
const
|
|
6472
|
+
const tag = resolveTemplateTagName(node.tag, context);
|
|
6406
6473
|
const slotDirective = findSlotDirective(node);
|
|
6407
6474
|
const templateSlotChildren = node.children.filter((child) => child.type === NodeTypes.ELEMENT && child.tag === "template" && findSlotDirective(child));
|
|
6408
6475
|
if (slotDirective || templateSlotChildren.length > 0) return transformComponentWithSlots(node, context, transformNode);
|
|
6409
|
-
const { attrs, vTextExp } = collectElementAttributes(node, context);
|
|
6476
|
+
const { attrs, vTextExp } = collectElementAttributes(node, context, { resolvedTag: tag });
|
|
6410
6477
|
let children = "";
|
|
6411
6478
|
if (node.children.length > 0) children = node.children.map((child) => transformNode(child, context)).join("");
|
|
6412
6479
|
if (vTextExp !== void 0) children = renderMustache(vTextExp, context);
|
|
@@ -6491,12 +6558,13 @@ function transformForElement(node, context, transformNode) {
|
|
|
6491
6558
|
});
|
|
6492
6559
|
const { attrs, vTextExp } = collectElementAttributes(elementWithoutFor, context, {
|
|
6493
6560
|
forInfo,
|
|
6494
|
-
extraAttrs
|
|
6561
|
+
extraAttrs,
|
|
6562
|
+
resolvedTag: resolveTemplateTagName(elementWithoutFor.tag, context)
|
|
6495
6563
|
});
|
|
6496
6564
|
let children = "";
|
|
6497
6565
|
if (elementWithoutFor.children.length > 0) children = elementWithoutFor.children.map((child) => transformNode(child, context)).join("");
|
|
6498
6566
|
if (vTextExp !== void 0) children = renderMustache(vTextExp, context);
|
|
6499
|
-
const
|
|
6567
|
+
const tag = resolveTemplateTagName(elementWithoutFor.tag, context);
|
|
6500
6568
|
const attrString = attrs.length ? ` ${attrs.join(" ")}` : "";
|
|
6501
6569
|
return children ? `<${tag}${attrString}>${children}</${tag}>` : `<${tag}${attrString} />`;
|
|
6502
6570
|
}));
|
|
@@ -6645,6 +6713,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
6645
6713
|
const resolvedRuntime = runtimeMode === "auto" ? options?.wxsExtension ? "wxs" : "js" : runtimeMode === "wxs" && !options?.wxsExtension ? "js" : runtimeMode;
|
|
6646
6714
|
const wxsExtension = options?.wxsExtension;
|
|
6647
6715
|
const scopedSlotsRequireProps = options?.scopedSlotsRequireProps ?? options?.scopedSlotsCompiler !== "augmented";
|
|
6716
|
+
const htmlTagToWxmlMap = resolveHtmlTagToWxmlMap(options?.htmlTagToWxml);
|
|
6648
6717
|
try {
|
|
6649
6718
|
const ast = parse$1(template, {
|
|
6650
6719
|
isVoidTag: (tag) => HTML_VOID_TAGS.has(tag),
|
|
@@ -6657,6 +6726,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
6657
6726
|
filename,
|
|
6658
6727
|
warnings,
|
|
6659
6728
|
platform: options?.platform ?? wechatPlatform,
|
|
6729
|
+
htmlTagToWxmlMap,
|
|
6660
6730
|
scopedSlotsCompiler: options?.scopedSlotsCompiler ?? "auto",
|
|
6661
6731
|
scopedSlotsRequireProps,
|
|
6662
6732
|
slotMultipleInstance: options?.slotMultipleInstance ?? true,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.15.1",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -44,14 +44,15 @@
|
|
|
44
44
|
"@vue/compiler-core": "^3.5.32",
|
|
45
45
|
"@vue/compiler-dom": "^3.5.32",
|
|
46
46
|
"comment-json": "^4.6.2",
|
|
47
|
-
"lru-cache": "^11.3.
|
|
47
|
+
"lru-cache": "^11.3.3",
|
|
48
48
|
"magic-string": "^0.30.21",
|
|
49
49
|
"merge": "^2.1.1",
|
|
50
50
|
"pathe": "^2.0.3",
|
|
51
51
|
"vue": "^3.5.32",
|
|
52
|
+
"@weapp-core/constants": "0.1.0",
|
|
52
53
|
"@weapp-core/shared": "3.0.3",
|
|
53
|
-
"@weapp-vite/ast": "6.
|
|
54
|
-
"rolldown-require": "2.0.
|
|
54
|
+
"@weapp-vite/ast": "6.15.1",
|
|
55
|
+
"rolldown-require": "2.0.13"
|
|
55
56
|
},
|
|
56
57
|
"publishConfig": {
|
|
57
58
|
"access": "public",
|