@wevu/compiler 6.15.18 → 6.16.0
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.mjs +21 -4
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -13,7 +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_NAMES_ATTR, 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
|
+
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_NAMES_ATTR, WEVU_SLOT_NAMES_PROP, 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";
|
|
17
17
|
import { compileScript, parse } from "vue/compiler-sfc";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import { parse as parse$1 } from "@vue/compiler-dom";
|
|
@@ -6279,6 +6279,7 @@ function collectSlotBindingExpression(node, context) {
|
|
|
6279
6279
|
}
|
|
6280
6280
|
//#endregion
|
|
6281
6281
|
//#region src/plugins/vue/compiler/template/elements/tag-slot.ts
|
|
6282
|
+
const SLOT_PRESENCE_SCAN_LIMIT = 32;
|
|
6282
6283
|
function renderSlotNameAttribute(info, context, attrName) {
|
|
6283
6284
|
if (info.type === "static" && info.value !== "default") return `${attrName}="${info.value}"`;
|
|
6284
6285
|
if (info.type === "dynamic") return `${attrName}="${renderMustache(normalizeWxmlExpressionWithContext(info.exp, context), context)}"`;
|
|
@@ -6328,6 +6329,16 @@ function stringifySlotName(info, context) {
|
|
|
6328
6329
|
if (info.type === "static") return info.value === "default" ? "'default'" : `'${info.value}'`;
|
|
6329
6330
|
return normalizeWxmlExpressionWithContext(info.exp, context);
|
|
6330
6331
|
}
|
|
6332
|
+
function resolveSlotStaticName(info) {
|
|
6333
|
+
if (info.type === "default") return "default";
|
|
6334
|
+
if (info.type === "static") return info.value || "default";
|
|
6335
|
+
}
|
|
6336
|
+
function createSlotPresenceExpression(info) {
|
|
6337
|
+
const slotName = resolveSlotStaticName(info);
|
|
6338
|
+
if (!slotName) return;
|
|
6339
|
+
const slotLiteral = `'${slotName.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
6340
|
+
return `${WEVU_SLOT_NAMES_PROP}&&(${Array.from({ length: SLOT_PRESENCE_SCAN_LIMIT }, (_, index) => `${WEVU_SLOT_NAMES_PROP}[${index}]==${slotLiteral}`).join("||")})`;
|
|
6341
|
+
}
|
|
6331
6342
|
function buildSlotDeclaration(name, propsExp, children, context, options) {
|
|
6332
6343
|
return {
|
|
6333
6344
|
name,
|
|
@@ -6421,7 +6432,12 @@ function transformSlotElement(node, context, transformNode) {
|
|
|
6421
6432
|
const nameAttr = renderSlotNameAttribute(slotNameInfo, context, "name");
|
|
6422
6433
|
if (nameAttr) slotAttrs.push(nameAttr);
|
|
6423
6434
|
const slotAttrString = slotAttrs.length ? ` ${slotAttrs.join(" ")}` : "";
|
|
6424
|
-
|
|
6435
|
+
let slotTag = `<slot${slotAttrString} />`;
|
|
6436
|
+
if (fallbackContent) {
|
|
6437
|
+
const slotPresentExp = createSlotPresenceExpression(slotNameInfo);
|
|
6438
|
+
if (!slotPropsExp && slotPresentExp) slotTag = `${context.platform.wrapIf(slotPresentExp, slotTag, (exp) => renderMustache(exp, context))}${context.platform.wrapElse(fallbackContent)}`;
|
|
6439
|
+
else slotTag = `<slot${slotAttrString}>${fallbackContent}</slot>`;
|
|
6440
|
+
}
|
|
6425
6441
|
if (!slotPropsExp && (context.scopedSlotsRequireProps || slotNameInfo.type !== "default")) return slotTag;
|
|
6426
6442
|
const genericKey = `scoped-slots-${resolveSlotKey(context, slotNameInfo)}`;
|
|
6427
6443
|
context.componentGenerics[genericKey] = true;
|
|
@@ -6432,7 +6448,8 @@ function transformSlotElement(node, context, transformNode) {
|
|
|
6432
6448
|
`${WEVU_SLOT_PROPS_ATTR}="${renderMustache(slotPropsExp, context)}"`
|
|
6433
6449
|
];
|
|
6434
6450
|
if (context.slotMultipleInstance) scopedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(WEVU_SLOT_SCOPE_KEY, context)}"`);
|
|
6435
|
-
|
|
6451
|
+
const scopedTag = `<${genericKey}${scopedAttrs.length ? ` ${scopedAttrs.join(" ")}` : ""} />`;
|
|
6452
|
+
return `${slotTag}${scopedTag}`;
|
|
6436
6453
|
}
|
|
6437
6454
|
function transformSlotElementPlain(node, context, transformNode) {
|
|
6438
6455
|
const slotNameInfo = resolveSlotNameFromSlotElement(node);
|
|
@@ -6988,7 +7005,7 @@ function normalizeResolvedUsingComponent(result) {
|
|
|
6988
7005
|
return result;
|
|
6989
7006
|
}
|
|
6990
7007
|
function isWevuSfcComponent(result) {
|
|
6991
|
-
return result?.sourceType === "wevu-sfc" || Boolean(result?.resolvedId?.endsWith(".vue"));
|
|
7008
|
+
return result?.sourceType === "wevu-sfc" || Boolean(result?.resolvedId?.endsWith(".vue")) || Boolean(result?.from?.endsWith(".vue"));
|
|
6992
7009
|
}
|
|
6993
7010
|
function isVueSfcSource(source) {
|
|
6994
7011
|
return source.endsWith(".vue");
|
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.16.0",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"vue": "^3.5.33",
|
|
53
53
|
"@weapp-core/constants": "^0.1.4",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.
|
|
55
|
+
"@weapp-vite/ast": "6.16.0",
|
|
56
56
|
"rolldown-require": "2.0.15"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|