@wevu/compiler 6.16.9 → 6.16.11
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 +41 -24
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -3343,6 +3343,9 @@ function toAlipayDirectiveEvent(prefix, eventName) {
|
|
|
3343
3343
|
default: return toOnEventName(eventName);
|
|
3344
3344
|
}
|
|
3345
3345
|
}
|
|
3346
|
+
function normalizeMiniProgramEventName$3(name) {
|
|
3347
|
+
return name.includes(":") ? name.replaceAll(":", "-").toLowerCase() : name;
|
|
3348
|
+
}
|
|
3346
3349
|
/**
|
|
3347
3350
|
* 支付宝小程序平台适配器。
|
|
3348
3351
|
*/
|
|
@@ -3364,8 +3367,7 @@ const alipayPlatform = {
|
|
|
3364
3367
|
mapEventName: (eventName) => eventMap$3[eventName] || eventName,
|
|
3365
3368
|
eventBindingAttr: (eventName) => {
|
|
3366
3369
|
const { prefix, name } = parseEventBinding$3(eventName);
|
|
3367
|
-
|
|
3368
|
-
return toAlipayDirectiveEvent(prefix, name);
|
|
3370
|
+
return toAlipayDirectiveEvent(prefix, normalizeMiniProgramEventName$3(name));
|
|
3369
3371
|
}
|
|
3370
3372
|
};
|
|
3371
3373
|
//#endregion
|
|
@@ -3407,6 +3409,9 @@ function parseEventBinding$2(eventName) {
|
|
|
3407
3409
|
function shouldUseColonEventBinding$2(name) {
|
|
3408
3410
|
return name.includes(":") || name.includes("-");
|
|
3409
3411
|
}
|
|
3412
|
+
function normalizeMiniProgramEventName$2(name) {
|
|
3413
|
+
return name.includes(":") ? name.replaceAll(":", "-").toLowerCase() : name;
|
|
3414
|
+
}
|
|
3410
3415
|
const directives$2 = createMiniProgramDirectiveAttrs("wx");
|
|
3411
3416
|
/**
|
|
3412
3417
|
* 默认小程序模板平台实现。
|
|
@@ -3431,12 +3436,13 @@ const defaultMiniProgramPlatform = {
|
|
|
3431
3436
|
mapEventName: (eventName) => eventMap$2[eventName] || eventName,
|
|
3432
3437
|
eventBindingAttr: (eventName) => {
|
|
3433
3438
|
const { prefix, name } = parseEventBinding$2(eventName);
|
|
3439
|
+
const normalizedName = normalizeMiniProgramEventName$2(name);
|
|
3434
3440
|
switch (prefix) {
|
|
3435
|
-
case "catch": return shouldUseColonEventBinding$2(
|
|
3436
|
-
case "capture-bind": return `capture-bind:${
|
|
3437
|
-
case "capture-catch": return `capture-catch:${
|
|
3438
|
-
case "mut-bind": return `mut-bind:${
|
|
3439
|
-
default: return shouldUseColonEventBinding$2(
|
|
3441
|
+
case "catch": return shouldUseColonEventBinding$2(normalizedName) ? `catch:${normalizedName}` : `catch${normalizedName}`;
|
|
3442
|
+
case "capture-bind": return `capture-bind:${normalizedName}`;
|
|
3443
|
+
case "capture-catch": return `capture-catch:${normalizedName}`;
|
|
3444
|
+
case "mut-bind": return `mut-bind:${normalizedName}`;
|
|
3445
|
+
default: return shouldUseColonEventBinding$2(normalizedName) ? `bind:${normalizedName}` : `bind${normalizedName}`;
|
|
3440
3446
|
}
|
|
3441
3447
|
}
|
|
3442
3448
|
};
|
|
@@ -3483,6 +3489,9 @@ function parseEventBinding$1(eventName) {
|
|
|
3483
3489
|
function shouldUseColonEventBinding$1(name) {
|
|
3484
3490
|
return name.includes(":") || name.includes("-");
|
|
3485
3491
|
}
|
|
3492
|
+
function normalizeMiniProgramEventName$1(name) {
|
|
3493
|
+
return name.includes(":") ? name.replaceAll(":", "-").toLowerCase() : name;
|
|
3494
|
+
}
|
|
3486
3495
|
/**
|
|
3487
3496
|
* 百度智能小程序平台适配器。
|
|
3488
3497
|
*/
|
|
@@ -3504,12 +3513,13 @@ const swanPlatform = {
|
|
|
3504
3513
|
mapEventName: (eventName) => eventMap$1[eventName] || eventName,
|
|
3505
3514
|
eventBindingAttr: (eventName) => {
|
|
3506
3515
|
const { prefix, name } = parseEventBinding$1(eventName);
|
|
3516
|
+
const normalizedName = normalizeMiniProgramEventName$1(name);
|
|
3507
3517
|
switch (prefix) {
|
|
3508
|
-
case "catch": return shouldUseColonEventBinding$1(
|
|
3509
|
-
case "capture-bind": return `capture-bind:${
|
|
3510
|
-
case "capture-catch": return `capture-catch:${
|
|
3511
|
-
case "mut-bind": return `mut-bind:${
|
|
3512
|
-
default: return shouldUseColonEventBinding$1(
|
|
3518
|
+
case "catch": return shouldUseColonEventBinding$1(normalizedName) ? `catch:${normalizedName}` : `catch${normalizedName}`;
|
|
3519
|
+
case "capture-bind": return `capture-bind:${normalizedName}`;
|
|
3520
|
+
case "capture-catch": return `capture-catch:${normalizedName}`;
|
|
3521
|
+
case "mut-bind": return `mut-bind:${normalizedName}`;
|
|
3522
|
+
default: return shouldUseColonEventBinding$1(normalizedName) ? `bind:${normalizedName}` : `bind${normalizedName}`;
|
|
3513
3523
|
}
|
|
3514
3524
|
}
|
|
3515
3525
|
};
|
|
@@ -3552,6 +3562,9 @@ function parseEventBinding(eventName) {
|
|
|
3552
3562
|
function shouldUseColonEventBinding(name) {
|
|
3553
3563
|
return name.includes(":") || name.includes("-");
|
|
3554
3564
|
}
|
|
3565
|
+
function normalizeMiniProgramEventName(name) {
|
|
3566
|
+
return name.includes(":") ? name.replaceAll(":", "-").toLowerCase() : name;
|
|
3567
|
+
}
|
|
3555
3568
|
/**
|
|
3556
3569
|
* 抖音小程序平台适配器。
|
|
3557
3570
|
*/
|
|
@@ -3573,12 +3586,13 @@ const ttPlatform = {
|
|
|
3573
3586
|
mapEventName: (eventName) => eventMap[eventName] || eventName,
|
|
3574
3587
|
eventBindingAttr: (eventName) => {
|
|
3575
3588
|
const { prefix, name } = parseEventBinding(eventName);
|
|
3589
|
+
const normalizedName = normalizeMiniProgramEventName(name);
|
|
3576
3590
|
switch (prefix) {
|
|
3577
|
-
case "catch": return shouldUseColonEventBinding(
|
|
3578
|
-
case "capture-bind": return `capture-bind:${
|
|
3579
|
-
case "capture-catch": return `capture-catch:${
|
|
3580
|
-
case "mut-bind": return `mut-bind:${
|
|
3581
|
-
default: return shouldUseColonEventBinding(
|
|
3591
|
+
case "catch": return shouldUseColonEventBinding(normalizedName) ? `catch:${normalizedName}` : `catch${normalizedName}`;
|
|
3592
|
+
case "capture-bind": return `capture-bind:${normalizedName}`;
|
|
3593
|
+
case "capture-catch": return `capture-catch:${normalizedName}`;
|
|
3594
|
+
case "mut-bind": return `mut-bind:${normalizedName}`;
|
|
3595
|
+
default: return shouldUseColonEventBinding(normalizedName) ? `bind:${normalizedName}` : `bind${normalizedName}`;
|
|
3582
3596
|
}
|
|
3583
3597
|
}
|
|
3584
3598
|
};
|
|
@@ -6413,7 +6427,7 @@ function buildSlotDeclaration(name, propsExp, children, context, options) {
|
|
|
6413
6427
|
condition: options?.condition
|
|
6414
6428
|
};
|
|
6415
6429
|
}
|
|
6416
|
-
function createScopedSlotComponent(context, slotKey, props, children, transformNode) {
|
|
6430
|
+
function createScopedSlotComponent(context, slotKey, props, children, transformNode, options) {
|
|
6417
6431
|
const ownerHash = hashString(context.filename);
|
|
6418
6432
|
const index = context.scopedSlotComponents.length;
|
|
6419
6433
|
const id = `${slotKey}-${index}`;
|
|
@@ -6421,6 +6435,7 @@ function createScopedSlotComponent(context, slotKey, props, children, transformN
|
|
|
6421
6435
|
const asset = {
|
|
6422
6436
|
id,
|
|
6423
6437
|
componentName,
|
|
6438
|
+
hostComponentName: options?.hostComponentName,
|
|
6424
6439
|
slotKey,
|
|
6425
6440
|
template: ""
|
|
6426
6441
|
};
|
|
@@ -6587,8 +6602,13 @@ function hasDirectComponentSlotChild(children, context) {
|
|
|
6587
6602
|
return /^[A-Z]/.test(child.tag);
|
|
6588
6603
|
});
|
|
6589
6604
|
}
|
|
6590
|
-
function
|
|
6605
|
+
function isWevuComponentTag(node, context) {
|
|
6606
|
+
return context.wevuComponentTags ? context.wevuComponentTags.has(node.tag) : /^[A-Z]/.test(node.tag);
|
|
6607
|
+
}
|
|
6608
|
+
function shouldAugmentPlainDefaultSlot(decl, context, ownerNode) {
|
|
6591
6609
|
if (context.scopedSlotsRequireProps || !decl.implicitDefault) return false;
|
|
6610
|
+
if (context.scopedSlotsCompiler !== "augmented" && !isWevuComponentTag(ownerNode, context)) return false;
|
|
6611
|
+
if (context.rewriteScopedSlot && !isWevuComponentTag(ownerNode, context)) return false;
|
|
6592
6612
|
if (context.scopedSlotsCompiler === "augmented") return true;
|
|
6593
6613
|
return hasDirectComponentSlotChild(decl.children, context);
|
|
6594
6614
|
}
|
|
@@ -6628,9 +6648,6 @@ function pushSlotNamesAttr(attrs, slotNames, context) {
|
|
|
6628
6648
|
function shouldExposePlainSlotPresence(node) {
|
|
6629
6649
|
return node.tag === "component";
|
|
6630
6650
|
}
|
|
6631
|
-
function isWevuComponentTag(node, context) {
|
|
6632
|
-
return context.wevuComponentTags ? context.wevuComponentTags.has(node.tag) : /^[A-Z]/.test(node.tag);
|
|
6633
|
-
}
|
|
6634
6651
|
function shouldTransformAsComponentWithSlots(node, context, resolvedTag = resolveTemplateTagName(node.tag, context)) {
|
|
6635
6652
|
const slotDirective = findSlotDirective(node);
|
|
6636
6653
|
const templateSlotChildren = node.children.filter((child) => child.type === NodeTypes.ELEMENT && child.tag === "template" && findSlotDirective(child));
|
|
@@ -6679,13 +6696,13 @@ function transformComponentWithSlots(node, context, transformNode, options) {
|
|
|
6679
6696
|
}
|
|
6680
6697
|
const scopedSlotDeclarations = [];
|
|
6681
6698
|
const plainSlotDeclarations = [];
|
|
6682
|
-
for (const decl of slotDeclarations) if (Object.keys(decl.props).length > 0 || shouldAugmentPlainDefaultSlot(decl, context)) scopedSlotDeclarations.push(decl);
|
|
6699
|
+
for (const decl of slotDeclarations) if (Object.keys(decl.props).length > 0 || shouldAugmentPlainDefaultSlot(decl, context, node)) scopedSlotDeclarations.push(decl);
|
|
6683
6700
|
else plainSlotDeclarations.push(decl);
|
|
6684
6701
|
const slotNames = [];
|
|
6685
6702
|
const slotGenericAttrs = [];
|
|
6686
6703
|
for (const decl of scopedSlotDeclarations) {
|
|
6687
6704
|
const slotKey = resolveSlotKey(context, decl.name);
|
|
6688
|
-
const { componentName } = createScopedSlotComponent(context, slotKey, decl.props, decl.children, transformNode);
|
|
6705
|
+
const { componentName } = createScopedSlotComponent(context, slotKey, decl.props, decl.children, transformNode, { hostComponentName: node.tag });
|
|
6689
6706
|
slotNames.push({
|
|
6690
6707
|
name: stringifySlotName(decl.name, context),
|
|
6691
6708
|
condition: decl.condition
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.16.
|
|
4
|
+
"version": "6.16.11",
|
|
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.34",
|
|
53
53
|
"@weapp-core/constants": "^0.1.6",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.16.
|
|
55
|
+
"@weapp-vite/ast": "6.16.11",
|
|
56
56
|
"rolldown-require": "2.0.15"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|