@wevu/compiler 6.15.3 → 6.15.5
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 +1 -0
- package/dist/index.mjs +18 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -251,6 +251,7 @@ interface ForParseResult {
|
|
|
251
251
|
interface TemplateCompileOptions {
|
|
252
252
|
platform?: MiniProgramPlatform;
|
|
253
253
|
htmlTagToWxml?: boolean | Record<string, string>;
|
|
254
|
+
htmlTagToWxmlTagClass?: boolean;
|
|
254
255
|
scopedSlotsCompiler?: ScopedSlotsCompilerMode;
|
|
255
256
|
scopedSlotsRequireProps?: boolean;
|
|
256
257
|
slotMultipleInstance?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -4612,6 +4612,7 @@ const DEFAULT_HTML_TO_WXML_TAG_MAP = {
|
|
|
4612
4612
|
aside: "view",
|
|
4613
4613
|
b: "text",
|
|
4614
4614
|
blockquote: "view",
|
|
4615
|
+
br: "view",
|
|
4615
4616
|
button: "button",
|
|
4616
4617
|
code: "text",
|
|
4617
4618
|
dd: "view",
|
|
@@ -4630,6 +4631,7 @@ const DEFAULT_HTML_TO_WXML_TAG_MAP = {
|
|
|
4630
4631
|
h5: "view",
|
|
4631
4632
|
h6: "view",
|
|
4632
4633
|
header: "view",
|
|
4634
|
+
hr: "view",
|
|
4633
4635
|
i: "text",
|
|
4634
4636
|
img: "image",
|
|
4635
4637
|
input: "input",
|
|
@@ -4662,6 +4664,14 @@ function resolveTemplateTagName(tag, context) {
|
|
|
4662
4664
|
if (tag !== lowerTag) return tag;
|
|
4663
4665
|
return context.htmlTagToWxmlMap?.[lowerTag] ?? tag;
|
|
4664
4666
|
}
|
|
4667
|
+
function resolveMappedHtmlTagClassName(tag, context, resolvedTag) {
|
|
4668
|
+
if (!context.htmlTagToWxmlTagClass || !tag) return;
|
|
4669
|
+
const lowerTag = tag.toLowerCase();
|
|
4670
|
+
if (tag !== lowerTag) return;
|
|
4671
|
+
const mappedTag = context.htmlTagToWxmlMap?.[lowerTag];
|
|
4672
|
+
if (!mappedTag || (resolvedTag ?? mappedTag ?? tag) === lowerTag) return;
|
|
4673
|
+
return lowerTag;
|
|
4674
|
+
}
|
|
4665
4675
|
//#endregion
|
|
4666
4676
|
//#region src/plugins/vue/compiler/template/elements/forExpression.ts
|
|
4667
4677
|
const IDENTIFIER_RE$4 = /^[A-Z_$][\w$]*$/i;
|
|
@@ -5973,11 +5983,17 @@ const builtinTagSet = new Set(components.map((tag) => tag.toLowerCase()));
|
|
|
5973
5983
|
function isBuiltinTag(tag) {
|
|
5974
5984
|
return builtinTagSet.has(tag.toLowerCase());
|
|
5975
5985
|
}
|
|
5986
|
+
function prependStaticClass(staticClass, className) {
|
|
5987
|
+
const tokens = staticClass?.split(/\s+/).filter(Boolean) ?? [];
|
|
5988
|
+
if (!tokens.includes(className)) tokens.unshift(className);
|
|
5989
|
+
return tokens.join(" ");
|
|
5990
|
+
}
|
|
5976
5991
|
function collectElementAttributes(node, context, options) {
|
|
5977
5992
|
const { props } = node;
|
|
5978
5993
|
const resolvedTag = options?.resolvedTag ?? resolveTemplateTagName(node.tag, context);
|
|
5979
5994
|
const isComponentElement = options?.isComponent ?? !isBuiltinTag(resolvedTag);
|
|
5980
5995
|
const attrs = options?.extraAttrs ? [...options.extraAttrs] : [];
|
|
5996
|
+
const mappedTagClass = resolveMappedHtmlTagClassName(node.tag, context, resolvedTag);
|
|
5981
5997
|
let staticClass;
|
|
5982
5998
|
let staticId;
|
|
5983
5999
|
let dynamicClassExp;
|
|
@@ -6057,6 +6073,7 @@ function collectElementAttributes(node, context, options) {
|
|
|
6057
6073
|
if (dir) attrs.push(dir);
|
|
6058
6074
|
}
|
|
6059
6075
|
}
|
|
6076
|
+
if (mappedTagClass) staticClass = prependStaticClass(staticClass, mappedTagClass);
|
|
6060
6077
|
if (templateRef) {
|
|
6061
6078
|
const className = `__wv-ref-${context.templateRefIndexSeed++}`;
|
|
6062
6079
|
staticClass = staticClass ? `${staticClass} ${className}` : className;
|
|
@@ -6742,6 +6759,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
6742
6759
|
warnings,
|
|
6743
6760
|
platform: options?.platform ?? wechatPlatform,
|
|
6744
6761
|
htmlTagToWxmlMap,
|
|
6762
|
+
htmlTagToWxmlTagClass: options?.htmlTagToWxmlTagClass ?? true,
|
|
6745
6763
|
scopedSlotsCompiler: options?.scopedSlotsCompiler ?? "auto",
|
|
6746
6764
|
scopedSlotsRequireProps,
|
|
6747
6765
|
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.15.
|
|
4
|
+
"version": "6.15.5",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"merge": "^2.1.1",
|
|
50
50
|
"pathe": "^2.0.3",
|
|
51
51
|
"vue": "^3.5.32",
|
|
52
|
-
"@weapp-core/constants": "0.1.
|
|
52
|
+
"@weapp-core/constants": "^0.1.1",
|
|
53
53
|
"@weapp-core/shared": "3.0.3",
|
|
54
|
-
"@weapp-vite/ast": "6.15.
|
|
54
|
+
"@weapp-vite/ast": "6.15.5",
|
|
55
55
|
"rolldown-require": "2.0.13"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|