@wevu/compiler 6.15.13 → 6.15.15
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 -0
- package/dist/index.mjs +35 -6
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -276,6 +276,7 @@ interface TemplateCompileOptions {
|
|
|
276
276
|
htmlTagToWxmlTagClass?: boolean;
|
|
277
277
|
scopedSlotsCompiler?: ScopedSlotsCompilerMode;
|
|
278
278
|
scopedSlotsRequireProps?: boolean;
|
|
279
|
+
slotSingleRootNoWrapper?: boolean;
|
|
279
280
|
slotMultipleInstance?: boolean;
|
|
280
281
|
classStyleRuntime?: ClassStyleRuntime | 'auto';
|
|
281
282
|
objectLiteralBindMode?: ObjectLiteralBindMode;
|
|
@@ -402,6 +403,7 @@ interface VueTransformResult {
|
|
|
402
403
|
jsonMacroHash?: string;
|
|
403
404
|
defineOptionsHash?: string;
|
|
404
405
|
sfcSrcDeps?: string[];
|
|
406
|
+
styleBlocks?: SFCStyleBlock[];
|
|
405
407
|
};
|
|
406
408
|
}
|
|
407
409
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -6366,11 +6366,31 @@ function createScopedSlotComponent(context, slotKey, props, children, transformN
|
|
|
6366
6366
|
slotKey
|
|
6367
6367
|
};
|
|
6368
6368
|
}
|
|
6369
|
+
function injectAttributeIntoOpeningTag(source, attr) {
|
|
6370
|
+
if (!source.startsWith("<") || source.startsWith("</") || source.startsWith("<!--")) return null;
|
|
6371
|
+
let tagNameEnd = 1;
|
|
6372
|
+
while (tagNameEnd < source.length) {
|
|
6373
|
+
const char = source[tagNameEnd];
|
|
6374
|
+
if (char === " " || char === "\n" || char === "\r" || char === " " || char === "/" || char === ">") break;
|
|
6375
|
+
tagNameEnd += 1;
|
|
6376
|
+
}
|
|
6377
|
+
if (tagNameEnd <= 1) return null;
|
|
6378
|
+
return `${source.slice(0, tagNameEnd)} ${attr}${source.slice(tagNameEnd)}`;
|
|
6379
|
+
}
|
|
6369
6380
|
function renderSlotFallback(decl, context, transformNode) {
|
|
6370
|
-
const
|
|
6371
|
-
|
|
6381
|
+
const rawRenderedChildren = decl.children.map((child) => ({ code: transformNode(child, context) }));
|
|
6382
|
+
const rawContent = rawRenderedChildren.map((item) => item.code).join("");
|
|
6383
|
+
if (!rawContent) return "";
|
|
6372
6384
|
const slotAttr = renderSlotNameAttribute(decl.name, context, "slot");
|
|
6373
|
-
if (!slotAttr) return
|
|
6385
|
+
if (!slotAttr) return rawContent;
|
|
6386
|
+
if (!context.slotSingleRootNoWrapper) return `<view ${slotAttr}>${rawContent}</view>`;
|
|
6387
|
+
const renderedChildren = rawRenderedChildren.filter((item) => item.code.trim().length > 0);
|
|
6388
|
+
if (!renderedChildren.length) return "";
|
|
6389
|
+
const content = renderedChildren.map((item) => item.code).join("");
|
|
6390
|
+
if (renderedChildren.length === 1) {
|
|
6391
|
+
const projected = injectAttributeIntoOpeningTag(renderedChildren[0].code, slotAttr);
|
|
6392
|
+
if (projected) return projected;
|
|
6393
|
+
}
|
|
6374
6394
|
return `<view ${slotAttr}>${content}</view>`;
|
|
6375
6395
|
}
|
|
6376
6396
|
function transformSlotElement(node, context, transformNode) {
|
|
@@ -6598,7 +6618,7 @@ function transformIfElement(node, context, transformNode) {
|
|
|
6598
6618
|
};
|
|
6599
6619
|
const slotDirective = findSlotDirective(elementWithoutIf);
|
|
6600
6620
|
const templateSlotChildren = elementWithoutIf.children.filter((child) => child.type === NodeTypes.ELEMENT && child.tag === "template" && findSlotDirective(child));
|
|
6601
|
-
const content = slotDirective || templateSlotChildren.length > 0 ? transformComponentWithSlots(elementWithoutIf, context, transformNode) : transformNormalElement(elementWithoutIf, context, transformNode);
|
|
6621
|
+
const content = elementWithoutIf.tag === "slot" ? transformSlotElement(elementWithoutIf, context, transformNode) : slotDirective || templateSlotChildren.length > 0 ? transformComponentWithSlots(elementWithoutIf, context, transformNode) : transformNormalElement(elementWithoutIf, context, transformNode);
|
|
6602
6622
|
const dir = ifDirective;
|
|
6603
6623
|
if (dir.name === "if" && dir.exp) {
|
|
6604
6624
|
const expValue = resolveConditionExpression$1(dir.exp.type === NodeTypes.SIMPLE_EXPRESSION ? dir.exp.content : "", context, "v-if");
|
|
@@ -6744,7 +6764,11 @@ function transformTemplateElement(node, context, transformNode) {
|
|
|
6744
6764
|
function transformElement(node, context, transformNode) {
|
|
6745
6765
|
const { tag } = node;
|
|
6746
6766
|
if (tag === "template") return transformTemplateElement(node, context, transformNode);
|
|
6747
|
-
if (tag === "slot")
|
|
6767
|
+
if (tag === "slot") {
|
|
6768
|
+
const { type } = isStructuralDirective(node);
|
|
6769
|
+
if (type === "if") return transformIfElement(node, context, transformNode);
|
|
6770
|
+
return transformSlotElement(node, context, transformNode);
|
|
6771
|
+
}
|
|
6748
6772
|
if (tag === "component") return transformComponentElement(node, context, transformNode);
|
|
6749
6773
|
if (tag === "transition") return transformTransitionElement(node, context, transformNode);
|
|
6750
6774
|
if (tag === "keep-alive") return transformKeepAliveElement(node, context, transformNode);
|
|
@@ -6812,6 +6836,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
6812
6836
|
const resolvedRuntime = runtimeMode === "auto" ? options?.wxsExtension ? "wxs" : "js" : runtimeMode === "wxs" && !options?.wxsExtension ? "js" : runtimeMode;
|
|
6813
6837
|
const wxsExtension = options?.wxsExtension;
|
|
6814
6838
|
const scopedSlotsRequireProps = options?.scopedSlotsRequireProps ?? options?.scopedSlotsCompiler !== "augmented";
|
|
6839
|
+
const slotSingleRootNoWrapper = options?.slotSingleRootNoWrapper ?? false;
|
|
6815
6840
|
const htmlTagToWxmlMap = resolveHtmlTagToWxmlMap(options?.htmlTagToWxml);
|
|
6816
6841
|
try {
|
|
6817
6842
|
const ast = parse$1(template, {
|
|
@@ -6829,6 +6854,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
6829
6854
|
htmlTagToWxmlTagClass: options?.htmlTagToWxmlTagClass ?? true,
|
|
6830
6855
|
scopedSlotsCompiler: options?.scopedSlotsCompiler ?? "auto",
|
|
6831
6856
|
scopedSlotsRequireProps,
|
|
6857
|
+
slotSingleRootNoWrapper,
|
|
6832
6858
|
slotMultipleInstance: options?.slotMultipleInstance ?? true,
|
|
6833
6859
|
scopedSlotComponents: [],
|
|
6834
6860
|
componentGenerics: {},
|
|
@@ -7696,7 +7722,10 @@ function compileTemplatePhase(descriptor, filename, options, result) {
|
|
|
7696
7722
|
*/
|
|
7697
7723
|
async function compileVueFile(source, filename, options) {
|
|
7698
7724
|
const parsed = await parseVueFile(source, filename, options);
|
|
7699
|
-
const result = { meta: {
|
|
7725
|
+
const result = { meta: {
|
|
7726
|
+
...parsed.meta,
|
|
7727
|
+
styleBlocks: parsed.descriptor.styles
|
|
7728
|
+
} };
|
|
7700
7729
|
const autoUsingComponents = options?.autoUsingComponents?.enabled && parsed.descriptor.scriptSetup && parsed.descriptor.template && options.autoUsingComponents.resolveUsingComponentPath ? options.autoUsingComponents : void 0;
|
|
7701
7730
|
const autoImportTags = options?.autoImportTags?.enabled && parsed.descriptor.template && options.autoImportTags.resolveUsingComponent ? options.autoImportTags : void 0;
|
|
7702
7731
|
const templateCompiled = compileTemplatePhase(parsed.descriptor, filename, options?.template, result);
|
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.15",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,18 +42,18 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@jridgewell/remapping": "^2.3.5",
|
|
45
|
-
"@vue/compiler-core": "^3.5.
|
|
46
|
-
"@vue/compiler-dom": "^3.5.
|
|
45
|
+
"@vue/compiler-core": "^3.5.33",
|
|
46
|
+
"@vue/compiler-dom": "^3.5.33",
|
|
47
47
|
"comment-json": "^5.0.0",
|
|
48
48
|
"lru-cache": "^11.3.5",
|
|
49
49
|
"magic-string": "^0.30.21",
|
|
50
50
|
"merge": "^2.1.1",
|
|
51
51
|
"pathe": "^2.0.3",
|
|
52
|
-
"vue": "^3.5.
|
|
53
|
-
"@weapp-core/constants": "^0.1.
|
|
52
|
+
"vue": "^3.5.33",
|
|
53
|
+
"@weapp-core/constants": "^0.1.2",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.15.
|
|
56
|
-
"rolldown-require": "2.0.
|
|
55
|
+
"@weapp-vite/ast": "6.15.15",
|
|
56
|
+
"rolldown-require": "2.0.15"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public",
|