@wevu/compiler 6.16.0 → 6.16.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +21 -6
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -6279,7 +6279,6 @@ 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;
6283
6282
  function renderSlotNameAttribute(info, context, attrName) {
6284
6283
  if (info.type === "static" && info.value !== "default") return `${attrName}="${info.value}"`;
6285
6284
  if (info.type === "dynamic") return `${attrName}="${renderMustache(normalizeWxmlExpressionWithContext(info.exp, context), context)}"`;
@@ -6333,11 +6332,11 @@ function resolveSlotStaticName(info) {
6333
6332
  if (info.type === "default") return "default";
6334
6333
  if (info.type === "static") return info.value || "default";
6335
6334
  }
6335
+ const SLOT_PRESENCE_IDENTIFIER_RE = /^[A-Z_$][\w$]*$/i;
6336
6336
  function createSlotPresenceExpression(info) {
6337
6337
  const slotName = resolveSlotStaticName(info);
6338
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("||")})`;
6339
+ return `${WEVU_SLOT_NAMES_PROP}&&${SLOT_PRESENCE_IDENTIFIER_RE.test(slotName) ? `${WEVU_SLOT_NAMES_PROP}.${slotName}` : `${WEVU_SLOT_NAMES_PROP}['${slotName.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}']`}`;
6341
6340
  }
6342
6341
  function buildSlotDeclaration(name, propsExp, children, context, options) {
6343
6342
  return {
@@ -6494,14 +6493,30 @@ function resolveTemplateSlotCondition(node, context) {
6494
6493
  function pushSlotNamesAttr(attrs, slotNames, context) {
6495
6494
  if (!slotNames.length) return;
6496
6495
  const seen = /* @__PURE__ */ new Set();
6497
- const entries = [];
6496
+ const entries = /* @__PURE__ */ new Map();
6498
6497
  for (const item of slotNames) {
6499
6498
  const dedupeKey = `${item.name}:${item.condition ?? ""}`;
6500
6499
  if (seen.has(dedupeKey)) continue;
6501
6500
  seen.add(dedupeKey);
6502
- entries.push(item.condition ? `((${item.condition}) ? ${item.name} : '')` : item.name);
6501
+ const entry = entries.get(item.name) ?? {
6502
+ conditions: [],
6503
+ unconditional: false
6504
+ };
6505
+ if (item.condition) {
6506
+ if (!entry.unconditional) entry.conditions.push(item.condition);
6507
+ } else {
6508
+ entry.conditions.length = 0;
6509
+ entry.unconditional = true;
6510
+ }
6511
+ entries.set(item.name, entry);
6512
+ }
6513
+ const properties = [];
6514
+ for (const [name, entry] of entries) {
6515
+ const value = entry.conditions.length ? entry.conditions.map((condition) => `(${condition})`).join("||") : "true";
6516
+ properties.push(`[${name}]:${value}`);
6503
6517
  }
6504
- attrs.push(`${WEVU_SLOT_NAMES_ATTR}="${renderMustache(`[${entries.join(",")}]`, context)}"`);
6518
+ const slotNamesRef = registerRuntimeBindingExpression(`{${properties.join(",")}}`, context, { hint: "vue-slots 元数据" });
6519
+ if (slotNamesRef) attrs.push(`${WEVU_SLOT_NAMES_ATTR}="${renderMustache(slotNamesRef, context)}"`);
6505
6520
  }
6506
6521
  function shouldExposePlainSlotPresence(node) {
6507
6522
  return node.tag === "component";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/compiler",
3
3
  "type": "module",
4
- "version": "6.16.0",
4
+ "version": "6.16.2",
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.16.0",
55
+ "@weapp-vite/ast": "6.16.2",
56
56
  "rolldown-require": "2.0.15"
57
57
  },
58
58
  "publishConfig": {