@vue/compiler-vapor 3.6.0-beta.11 → 3.6.0-beta.12

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-vapor v3.6.0-beta.11
2
+ * @vue/compiler-vapor v3.6.0-beta.12
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -248,7 +248,8 @@ var TransformContext = class TransformContext {
248
248
  this.operationIndex = this.block.operation.length;
249
249
  this.isLastEffectiveChild = true;
250
250
  this.isOnRightmostPath = true;
251
- this.hasInlineAncestorNeedingClose = false;
251
+ this.templateCloseTags = void 0;
252
+ this.templateCloseBlocks = false;
252
253
  this.globalId = 0;
253
254
  this.nextIdMap = null;
254
255
  this.ifIndex = 0;
@@ -374,11 +375,6 @@ var TransformContext = class TransformContext {
374
375
  while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
375
376
  const isLastEffectiveChild = this.isEffectivelyLastChild(index);
376
377
  const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
377
- let hasInlineAncestorNeedingClose = this.hasInlineAncestorNeedingClose;
378
- if (this.node.type === 1) {
379
- if (this.node.tag === "template") hasInlineAncestorNeedingClose = false;
380
- else if (!hasInlineAncestorNeedingClose && !this.isOnRightmostPath && (0, _vue_shared.isInlineTag)(this.node.tag)) hasInlineAncestorNeedingClose = true;
381
- }
382
378
  return Object.assign(Object.create(TransformContext.prototype), this, {
383
379
  node,
384
380
  parent: this,
@@ -393,7 +389,8 @@ var TransformContext = class TransformContext {
393
389
  effectiveParent,
394
390
  isLastEffectiveChild,
395
391
  isOnRightmostPath,
396
- hasInlineAncestorNeedingClose
392
+ templateCloseTags: this.templateCloseTags,
393
+ templateCloseBlocks: this.templateCloseBlocks
397
394
  });
398
395
  }
399
396
  shiftEffectBoundaries(index, dynamic = this.dynamic) {
@@ -586,6 +583,9 @@ function genCall(name, ...frags) {
586
583
  hasPlaceholder ? name[1] : "null"
587
584
  ], ...frags)];
588
585
  }
586
+ function getParserOptions(plugins) {
587
+ return { plugins: plugins ? plugins.some((plugin) => plugin === "typescript") ? plugins : [...plugins, "typescript"] : ["typescript"] };
588
+ }
589
589
  function codeFragmentToString(code, context) {
590
590
  const { options: { filename, sourceMap } } = context;
591
591
  let map;
@@ -968,9 +968,7 @@ function escapeRegExp(string) {
968
968
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
969
969
  }
970
970
  function parseExp(context, content) {
971
- const plugins = context.options.expressionPlugins;
972
- const options = { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] };
973
- return (0, _babel_parser.parseExpression)(`(${content})`, options);
971
+ return (0, _babel_parser.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
974
972
  }
975
973
  function genVarName(exp) {
976
974
  return `${exp.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/_+$/, "")}`;
@@ -1148,16 +1146,12 @@ function genFor(oper, context) {
1148
1146
  idMap[rawIndex] = `${indexVar}.value`;
1149
1147
  idMap[indexVar] = null;
1150
1148
  }
1151
- const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
1149
+ const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap, context);
1152
1150
  const selectorDeclarations = [];
1153
- const selectorSetup = [];
1151
+ const selectorName = (i) => selectorPatterns.length > 1 ? `_selector${id}_${i}` : `_selector${id}`;
1154
1152
  for (let i = 0; i < selectorPatterns.length; i++) {
1155
1153
  const { selector } = selectorPatterns[i];
1156
- const selectorName = `_selector${id}_${i}`;
1157
- selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
1158
- if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
1159
- selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
1160
- if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
1154
+ selectorDeclarations.push(`const ${selectorName(i)} = `, ...genCall(helper("createSelector"), [`() => `, ...genExpression(selector, context)]), NEWLINE);
1161
1155
  }
1162
1156
  const blockFn = context.withId(() => {
1163
1157
  const frag = [];
@@ -1166,7 +1160,7 @@ function genFor(oper, context) {
1166
1160
  const patternFrag = [];
1167
1161
  for (let i = 0; i < selectorPatterns.length; i++) {
1168
1162
  const { effect } = selectorPatterns[i];
1169
- patternFrag.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
1163
+ patternFrag.push(NEWLINE, `${selectorName(i)}(`, ...genExpression(keyProp, context), `, () => {`, INDENT_START);
1170
1164
  for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
1171
1165
  patternFrag.push(INDENT_END, NEWLINE, `})`);
1172
1166
  }
@@ -1182,11 +1176,14 @@ function genFor(oper, context) {
1182
1176
  if (onlyChild) flags |= 1;
1183
1177
  if (component) flags |= 2;
1184
1178
  if (once) flags |= 4;
1179
+ const onResetCalls = [];
1180
+ for (let i = 0; i < selectorPatterns.length; i++) onResetCalls.push(NEWLINE, `n${id}.onReset(${selectorName(i)}.reset)`);
1185
1181
  return [
1186
1182
  NEWLINE,
1187
1183
  ...selectorDeclarations,
1188
1184
  `const n${id} = `,
1189
- ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0, selectorSetup.length ? selectorSetup : void 0)
1185
+ ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
1186
+ ...onResetCalls
1190
1187
  ];
1191
1188
  function genCallback(expr) {
1192
1189
  if (!expr) return false;
@@ -1272,19 +1269,19 @@ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
1272
1269
  }
1273
1270
  if (pathInfo.dynamic) {
1274
1271
  const node = idMap[id] = (0, _vue_compiler_dom.createSimpleExpression)(path);
1275
- node.ast = (0, _babel_parser.parseExpression)(`(${path})`, { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] });
1272
+ node.ast = (0, _babel_parser.parseExpression)(`(${path})`, getParserOptions(plugins));
1276
1273
  } else idMap[id] = path;
1277
1274
  } else idMap[id] = path;
1278
1275
  });
1279
1276
  return idMap;
1280
1277
  }
1281
- function matchPatterns(render, keyProp, idMap) {
1278
+ function matchPatterns(render, keyProp, idMap, context) {
1282
1279
  const selectorPatterns = [];
1283
1280
  const keyOnlyBindingPatterns = [];
1284
1281
  const removedEffectIndexes = [];
1285
1282
  render.effect = render.effect.filter((effect, index) => {
1286
1283
  if (keyProp !== void 0) {
1287
- const selector = matchSelectorPattern(effect, keyProp.content, idMap);
1284
+ const selector = matchSelectorPattern(effect, keyProp.content, idMap, context);
1288
1285
  if (selector) {
1289
1286
  selectorPatterns.push(selector);
1290
1287
  removedEffectIndexes.push(index);
@@ -1323,7 +1320,7 @@ function matchKeyOnlyBindingPattern(effect, key) {
1323
1320
  }
1324
1321
  }
1325
1322
  }
1326
- function matchSelectorPattern(effect, key, idMap) {
1323
+ function matchSelectorPattern(effect, key, idMap, context) {
1327
1324
  if (effect.expressions.length === 1) {
1328
1325
  const { ast, content } = effect.expressions[0];
1329
1326
  if (typeof ast === "object" && ast) {
@@ -1348,17 +1345,11 @@ function matchSelectorPattern(effect, key, idMap) {
1348
1345
  }, false);
1349
1346
  if (!hasExtraId) {
1350
1347
  const name = content.slice(selector.start - 1, selector.end - 1);
1348
+ const selectorExpression = (0, _vue_compiler_dom.createSimpleExpression)(name, false, selector.loc);
1349
+ selectorExpression.ast = (0, _babel_parser.parseExpression)(`(${name})`, getParserOptions(context.options.expressionPlugins));
1351
1350
  return {
1352
1351
  effect,
1353
- selector: {
1354
- content: name,
1355
- ast: (0, _vue_shared.extend)({}, selector, {
1356
- start: 1,
1357
- end: name.length + 1
1358
- }),
1359
- loc: selector.loc,
1360
- isStatic: false
1361
- }
1352
+ selector: selectorExpression
1362
1353
  };
1363
1354
  }
1364
1355
  }
@@ -1420,6 +1411,7 @@ const helpers = {
1420
1411
  setText: { name: "setText" },
1421
1412
  setHtml: { name: "setHtml" },
1422
1413
  setClass: { name: "setClass" },
1414
+ setClassName: { name: "setClassName" },
1423
1415
  setStyle: { name: "setStyle" },
1424
1416
  setValue: { name: "setValue" },
1425
1417
  setAttr: {
@@ -1439,9 +1431,132 @@ function genSetProp(oper, context) {
1439
1431
  const { helper } = context;
1440
1432
  const { prop: { key, values, modifier }, tag } = oper;
1441
1433
  const resolvedHelper = getRuntimeHelper(tag, key.content, modifier);
1434
+ if (key.content === "class" && !resolvedHelper.isSVG && resolvedHelper.name === "setClass") {
1435
+ const className = genSetClassName(oper, context);
1436
+ if (className) return className;
1437
+ }
1442
1438
  const propValue = genPropValue(values, context);
1443
1439
  return [NEWLINE, ...genCall([helper(resolvedHelper.name), null], `n${oper.element}`, resolvedHelper.needKey ? genExpression(key, context) : false, propValue, resolvedHelper.isSVG && "true")];
1444
1440
  }
1441
+ const MAX_CLASS_NAME_ENTRIES = 31;
1442
+ function genSetClassName(oper, context) {
1443
+ const info = resolveClassName(oper.prop.values, context);
1444
+ if (!info) return;
1445
+ const { helper } = context;
1446
+ const flags = genClassFlags(info.entries, context);
1447
+ const classFragments = info.entries.map((entry) => JSON.stringify(!info.prefix && info.entries.length === 1 ? entry.className : ` ${entry.className}`));
1448
+ const fragments = classFragments.length === 1 ? classFragments[0] : genMulti(DELIMITERS_ARRAY, ...classFragments);
1449
+ return [NEWLINE, ...genCall([helper("setClassName"), "\"\""], `n${oper.element}`, flags, fragments, info.prefix && JSON.stringify(info.prefix), info.suffix && JSON.stringify(info.suffix))];
1450
+ }
1451
+ function resolveClassName(values, context) {
1452
+ let prefix = "";
1453
+ let suffix = "";
1454
+ const entries = [];
1455
+ let sawDynamic = false;
1456
+ let sawSuffix = false;
1457
+ for (const value of values) {
1458
+ const staticValue = getLiteralExpressionValue(value, true);
1459
+ if (staticValue != null) {
1460
+ const normalized = (0, _vue_shared.normalizeClass)(staticValue);
1461
+ if (normalized) if (sawSuffix) suffix = appendClass(suffix, normalized);
1462
+ else if (sawDynamic) {
1463
+ sawSuffix = true;
1464
+ suffix = appendClass(suffix, normalized);
1465
+ } else prefix = appendClass(prefix, normalized);
1466
+ continue;
1467
+ }
1468
+ const ast = value.ast;
1469
+ if (!ast || sawSuffix) return;
1470
+ sawDynamic = true;
1471
+ if (ast.type === "ObjectExpression") {
1472
+ if (!resolveObjectClassName(value, ast, entries, context)) return;
1473
+ } else if (ast.type === "ConditionalExpression") {
1474
+ if (!resolveConditionalClassName(value, ast, entries, context)) return;
1475
+ } else return;
1476
+ }
1477
+ return entries.length && entries.length <= MAX_CLASS_NAME_ENTRIES ? {
1478
+ prefix,
1479
+ suffix,
1480
+ entries
1481
+ } : void 0;
1482
+ }
1483
+ function resolveObjectClassName(source, ast, entries, context) {
1484
+ for (const prop of ast.properties) {
1485
+ if (prop.type !== "ObjectProperty" || prop.computed) return false;
1486
+ const rawClassName = getObjectPropertyName(prop);
1487
+ if (rawClassName == null) return false;
1488
+ const className = (0, _vue_shared.normalizeClass)(rawClassName);
1489
+ if (!className) continue;
1490
+ const value = getBooleanValue(prop.value);
1491
+ entries.push({
1492
+ className,
1493
+ value,
1494
+ condition: value == null ? createSubExpression(source, prop.value, context) : void 0
1495
+ });
1496
+ }
1497
+ return true;
1498
+ }
1499
+ function resolveConditionalClassName(source, ast, entries, context) {
1500
+ const consequent = getStringClassValue(ast.consequent);
1501
+ const alternate = getStringClassValue(ast.alternate);
1502
+ if (consequent && alternate === "") {
1503
+ entries.push({
1504
+ className: consequent,
1505
+ condition: createSubExpression(source, ast.test, context)
1506
+ });
1507
+ return true;
1508
+ } else if (alternate && consequent === "") {
1509
+ entries.push({
1510
+ className: alternate,
1511
+ condition: createSubExpression(source, ast.test, context),
1512
+ negate: true
1513
+ });
1514
+ return true;
1515
+ }
1516
+ return false;
1517
+ }
1518
+ function genClassFlags(entries, context) {
1519
+ const values = [];
1520
+ entries.forEach((entry, index) => {
1521
+ if (index) values.push(" | ");
1522
+ const bit = 1 << index;
1523
+ if (entry.value != null) {
1524
+ values.push(entry.value ? String(bit) : "0");
1525
+ return;
1526
+ }
1527
+ values.push("(", ...genExpression(entry.condition, context), entry.negate ? ` ? 0 : ${bit}` : ` ? ${bit} : 0`, ")");
1528
+ });
1529
+ return values;
1530
+ }
1531
+ function appendClass(base, value) {
1532
+ return base ? value ? `${base} ${value}` : base : value;
1533
+ }
1534
+ function getObjectPropertyName(prop) {
1535
+ const key = prop.key;
1536
+ if (key.type === "Identifier") return key.name;
1537
+ else if (key.type === "StringLiteral") return key.value;
1538
+ else if (key.type === "NumericLiteral") return String(key.value);
1539
+ }
1540
+ function getStringClassValue(node) {
1541
+ if (node.type === "StringLiteral") return (0, _vue_shared.normalizeClass)(node.value);
1542
+ else if (node.type === "TemplateLiteral" && node.expressions.length === 0) return (0, _vue_shared.normalizeClass)(node.quasis[0].value.cooked || "");
1543
+ else if (node.type === "NullLiteral" || node.type === "BooleanLiteral" && !node.value) return "";
1544
+ }
1545
+ function getBooleanValue(node) {
1546
+ if (node.type === "BooleanLiteral") return node.value;
1547
+ }
1548
+ function createSubExpression(source, node, context) {
1549
+ const start = node.start == null ? 0 : node.start - 1;
1550
+ const end = node.end == null ? source.content.length : node.end - 1;
1551
+ const content = source.content.slice(start, end);
1552
+ const expression = (0, _vue_compiler_dom.createSimpleExpression)(content, false, {
1553
+ start: (0, _vue_compiler_dom.advancePositionWithClone)(source.loc.start, source.content, start),
1554
+ end: (0, _vue_compiler_dom.advancePositionWithClone)(source.loc.start, source.content, end),
1555
+ source: content
1556
+ });
1557
+ expression.ast = (0, _vue_compiler_dom.isSimpleIdentifier)(content) ? null : (0, _babel_parser.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
1558
+ return expression;
1559
+ }
1445
1560
  function genDynamicProps$1(oper, context) {
1446
1561
  const { helper } = context;
1447
1562
  const isSVG = (0, _vue_shared.isSVGTag)(oper.tag);
@@ -1851,11 +1966,23 @@ function genDynamicSlot(slot, context, withFunction = false) {
1851
1966
  frag = genConditionalSlot(slot, context);
1852
1967
  break;
1853
1968
  }
1854
- return withFunction ? [
1969
+ if (!withFunction) return frag;
1970
+ return needsDynamicSlotSourceCtx(slot) ? [
1971
+ `${context.helper("withVaporCtx")}(() => (`,
1972
+ ...frag,
1973
+ "))"
1974
+ ] : [
1855
1975
  "() => (",
1856
1976
  ...frag,
1857
1977
  ")"
1858
- ] : frag;
1978
+ ];
1979
+ }
1980
+ function needsDynamicSlotSourceCtx(slot) {
1981
+ switch (slot.slotType) {
1982
+ case 1: return needsVaporCtx(slot.fn);
1983
+ case 2: return needsVaporCtx(slot.fn);
1984
+ case 3: return needsDynamicSlotSourceCtx(slot.positive) || (slot.negative ? needsDynamicSlotSourceCtx(slot.negative) : false);
1985
+ }
1859
1986
  }
1860
1987
  function genBasicDynamicSlot(slot, context) {
1861
1988
  const { name, fn } = slot;
@@ -2409,11 +2536,35 @@ function canOmitEndTag(node, context) {
2409
2536
  const { block, parent } = context;
2410
2537
  if (!parent) return false;
2411
2538
  if (block !== parent.block) return true;
2539
+ if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || (0, _vue_shared.isAlwaysCloseTag)(node.tag) || (0, _vue_shared.isFormattingTag)(node.tag)) || context.templateCloseBlocks && (0, _vue_shared.isBlockTag)(node.tag)) return false;
2412
2540
  if ((0, _vue_shared.isAlwaysCloseTag)(node.tag) && !context.isOnRightmostPath) return false;
2413
2541
  if ((0, _vue_shared.isFormattingTag)(node.tag) || parent.node.type === 1 && node.tag === parent.node.tag) return context.isOnRightmostPath;
2414
- if ((0, _vue_shared.isBlockTag)(node.tag) && context.hasInlineAncestorNeedingClose) return false;
2415
2542
  return context.isLastEffectiveChild;
2416
2543
  }
2544
+ function getChildTemplateCloseState(context) {
2545
+ const { node } = context;
2546
+ if (node.type !== 1 || node.tagType !== 0 || shouldUseCreateElement(node, context)) return;
2547
+ const inSameTemplateAsParent = isInSameTemplateAsParent(context);
2548
+ const inheritedTags = inSameTemplateAsParent ? context.templateCloseTags : void 0;
2549
+ const inheritedBlocks = inSameTemplateAsParent && context.templateCloseBlocks;
2550
+ if (context.root === context.effectiveParent || canOmitEndTag(node, context) || (0, _vue_shared.isVoidTag)(node.tag)) return inheritedTags || inheritedBlocks ? {
2551
+ tags: inheritedTags,
2552
+ blocks: inheritedBlocks
2553
+ } : void 0;
2554
+ const tags = new Set(inheritedTags);
2555
+ tags.add(node.tag);
2556
+ return {
2557
+ tags,
2558
+ blocks: inheritedBlocks || (0, _vue_shared.isInlineTag)(node.tag)
2559
+ };
2560
+ }
2561
+ function isInSameTemplateAsParent(context) {
2562
+ const { parent, node, block } = context;
2563
+ if (!parent || block !== parent.block) return false;
2564
+ const parentNode = parent.node;
2565
+ if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
2566
+ return !shouldUseCreateElement(parentNode, parent) && (0, _vue_compiler_dom.isValidHTMLNesting)(parentNode.tag, node.tag);
2567
+ }
2417
2568
  function isSingleRoot(context) {
2418
2569
  if (context.inVFor) return false;
2419
2570
  let { parent } = context;
@@ -2677,8 +2828,12 @@ const transformChildren = (node, context) => {
2677
2828
  const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
2678
2829
  if (!isFragment && node.type !== 1) return;
2679
2830
  const useCreateElement = node.type === 1 && shouldUseCreateElement(node, context);
2831
+ const childTemplateCloseState = !isFragment && !useCreateElement ? getChildTemplateCloseState(context) : void 0;
2680
2832
  for (const [i, child] of node.children.entries()) {
2681
2833
  const childContext = context.create(child, i);
2834
+ const isInSameTemplate = childTemplateCloseState && child.type === 1 && child.tagType === 0 && isInSameTemplateAsParent(childContext);
2835
+ childContext.templateCloseTags = isInSameTemplate ? childTemplateCloseState.tags : void 0;
2836
+ childContext.templateCloseBlocks = isInSameTemplate ? childTemplateCloseState.blocks : false;
2682
2837
  transformNode(childContext);
2683
2838
  const childDynamic = childContext.dynamic;
2684
2839
  if (isFragment) {
@@ -25319,7 +25319,9 @@ declare class VaporFragment<T extends Block$1 = Block$1> implements TransitionOp
25319
25319
  protected runWithRenderCtx<R>(fn: () => R, scope?: EffectScope): R;
25320
25320
  }
25321
25321
  declare class ForFragment extends VaporFragment<Block$1[]> {
25322
+ resetListeners?: (() => void)[];
25322
25323
  constructor(nodes: Block$1[]);
25324
+ onReset(fn: () => void): void;
25323
25325
  }
25324
25326
  declare class DynamicFragment extends VaporFragment {
25325
25327
  anchor: Node;
@@ -25341,8 +25343,10 @@ declare class DynamicFragment extends VaporFragment {
25341
25343
  }
25342
25344
  interface SlotBoundaryContext {
25343
25345
  parent: SlotBoundaryContext | null;
25344
- getLocalFallback: () => BlockFn | undefined;
25346
+ getFallback: () => BlockFn | undefined;
25347
+ run<R>(fn: () => R, scope?: EffectScope): R;
25345
25348
  markDirty: () => void;
25349
+ redirected?: SlotBoundaryContext;
25346
25350
  }
25347
25351
  declare function isFragment(val: NonNullable<unknown>): val is VaporFragment;
25348
25352
  //#endregion
@@ -25366,9 +25370,8 @@ declare function insert$1(block: Block$1, parent: ParentNode & {
25366
25370
  declare function prepend(parent: ParentNode, ...blocks: Block$1[]): void;
25367
25371
  declare function remove(block: Block$1, parent?: ParentNode): void;
25368
25372
  //#endregion
25369
- //#region packages/runtime-vapor/src/vdomInterop.d.ts
25373
+ //#region packages/runtime-vapor/src/vdomInteropState.d.ts
25370
25374
  declare const interopKey: unique symbol;
25371
- declare const vaporInteropPlugin: Plugin;
25372
25375
  //#endregion
25373
25376
  //#region packages/runtime-vapor/src/componentProps.d.ts
25374
25377
  type RawProps = Record<string, () => unknown> & {
@@ -25648,6 +25651,9 @@ declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporComponent>;
25648
25651
  //#region packages/runtime-vapor/src/apiDefineAsyncComponent.d.ts
25649
25652
  declare function defineVaporAsyncComponent<T extends VaporComponent>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T;
25650
25653
  //#endregion
25654
+ //#region packages/runtime-vapor/src/vdomInterop.d.ts
25655
+ declare const vaporInteropPlugin: Plugin;
25656
+ //#endregion
25651
25657
  //#region packages/runtime-vapor/src/directives/custom.d.ts
25652
25658
  type VaporDirective = (node: Element | VaporComponentInstance, value?: () => any, argument?: string, modifiers?: DirectiveModifiers) => (() => void) | void;
25653
25659
  type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirective | undefined, () => any] | [VaporDirective | undefined, (() => any) | undefined, argument: string] | [VaporDirective | undefined, value: (() => any) | undefined, argument: string | undefined, modifiers: DirectiveModifiers]>;
@@ -25742,6 +25748,7 @@ type TargetElement = Element & {
25742
25748
  $root?: true;
25743
25749
  $html?: string;
25744
25750
  $cls?: string;
25751
+ $clsFlags?: number;
25745
25752
  $sty?: NormalizedStyle | string | undefined;
25746
25753
  value?: string;
25747
25754
  _value?: any;
@@ -25749,7 +25756,8 @@ type TargetElement = Element & {
25749
25756
  declare function setProp(el: any, key: string, value: any): void;
25750
25757
  declare function setAttr(el: any, key: string, value: any, isSVG?: boolean): void;
25751
25758
  declare function setDOMProp(el: any, key: string, value: any, forceHydrate?: boolean, attrName?: string): void;
25752
- declare function setClass(el: TargetElement, value: any, isSVG?: boolean): void;
25759
+ declare function setClass(el: TargetElement, value: any, isSVG?: boolean, isNormalized?: boolean): void;
25760
+ declare function setClassName(el: TargetElement, flags: number, cls: string | string[], prefix?: string, suffix?: string): void;
25753
25761
  declare function setStyle(el: TargetElement, value: any): void;
25754
25762
  declare function setValue(el: TargetElement, value: any, forceHydrate?: boolean): void;
25755
25763
  /**
@@ -25802,9 +25810,29 @@ declare function createKeyedFragment(key: () => any, render: BlockFn): Block$1;
25802
25810
  //#endregion
25803
25811
  //#region packages/runtime-vapor/src/apiCreateFor.d.ts
25804
25812
  type Source = any[] | Record<any, any> | number | Set<any> | Map<any, any>;
25805
- declare const createFor: (src: () => Source, renderItem: (item: ShallowRef<any>, key: ShallowRef<any>, index: ShallowRef<number | undefined>) => Block$1, getKey?: (item: any, key: any, index?: number) => any, flags?: number, setup?: (_: {
25806
- createSelector: (source: () => any) => (cb: () => void) => void;
25807
- }) => void) => ForFragment;
25813
+ declare const createFor: (src: () => Source, renderItem: (item: ShallowRef<any>, key: ShallowRef<any>, index: ShallowRef<number | undefined>) => Block$1, getKey?: (item: any, key: any, index?: number) => any, flags?: number) => ForFragment;
25814
+ interface ForSelector {
25815
+ (key: any, oper: () => void): void;
25816
+ /**
25817
+ * Bulk-reset the selector's internal state. Hook into a v-for's fast-reset
25818
+ * paths via `forFragment.onReset(selector.reset)` so the lazy per-item
25819
+ * `onScopeDispose` teardowns short-circuit instead of doing N individual
25820
+ * Map.delete() calls.
25821
+ */
25822
+ reset(): void;
25823
+ }
25824
+ /**
25825
+ * Builds a key-indexed selector that activates only the opers registered with
25826
+ * the key matching the current source value. Compared to letting each item
25827
+ * subscribe directly, this keeps re-renders on source change O(2) instead of
25828
+ * O(N) (only previous and new active item re-run).
25829
+ *
25830
+ * Selector cleanup follows the current scope. Per-item teardown is auto-wired
25831
+ * via `onScopeDispose` so callers (typically v-for item scopes) don't need
25832
+ * explicit deregistration. For bulk-reset hot paths, attach the selector to
25833
+ * the v-for via `frag.onReset(selector.reset)` to skip the per-item Map ops.
25834
+ */
25835
+ declare function createSelector(source: () => any): ForSelector;
25808
25836
  declare function createForSlots(rawSource: Source, getSlot: (item: any, key: any, index?: number) => DynamicSlot): DynamicSlot[];
25809
25837
  declare function getRestElement(val: any, keys: string[]): any;
25810
25838
  declare function getDefaultValue(val: any, defaultVal: any): any;
@@ -25840,7 +25868,7 @@ declare const VaporTransition: FunctionalVaporComponent<TransitionProps>;
25840
25868
  //#region packages/runtime-vapor/src/components/TransitionGroup.d.ts
25841
25869
  declare const VaporTransitionGroup: DefineVaporComponent<{}, string, TransitionGroupProps>;
25842
25870
  declare namespace index_d_exports {
25843
- export { Block$1 as Block, DefineVaporComponent, DynamicFragment, FunctionalVaporComponent, VaporComponent, VaporComponentInstance, VaporComponentOptions, VaporDirective, VaporElement, VaporElementConstructor, VaporFragment, VaporKeepAlive, VaporKeepAliveContext, VaporPublicProps, VaporRenderResult, VaporSlot, VaporTeleport, VaporTransition, VaporTransitionGroup, VaporTransitionHooks, applyCheckboxModel, applyDynamicModel, applyRadioModel, applySelectModel, applyTextModel, applyVShow, child, createComponent, createComponentWithFallback, createDynamicComponent, createFor, createForSlots, createIf, createInvoker, createKeyedFragment, createPlainElement, createSlot, createTemplateRefSetter, createTextNode, createVaporApp, createVaporSSRApp, defineVaporAsyncComponent, defineVaporComponent, defineVaporCustomElement, defineVaporSSRCustomElement, delegate, delegateEvents, getDefaultValue, getRestElement, insert$1 as insert, isFragment, isVaporComponent, next, nthChild, on, prepend, remove, renderEffect, setAttr, setBlockHtml, setBlockKey, setBlockText, setClass, setDOMProp, setDynamicEvents, setDynamicProps, setElementText, setHtml, setInsertionState, setProp, setStyle, setText, setValue, template, txt, useVaporCssVars, vaporInteropPlugin, withAsyncContext, withVaporCtx, withVaporDirectives };
25871
+ export { Block$1 as Block, DefineVaporComponent, DynamicFragment, FunctionalVaporComponent, VaporComponent, VaporComponentInstance, VaporComponentOptions, VaporDirective, VaporElement, VaporElementConstructor, VaporFragment, VaporKeepAlive, VaporKeepAliveContext, VaporPublicProps, VaporRenderResult, VaporSlot, VaporTeleport, VaporTransition, VaporTransitionGroup, VaporTransitionHooks, applyCheckboxModel, applyDynamicModel, applyRadioModel, applySelectModel, applyTextModel, applyVShow, child, createComponent, createComponentWithFallback, createDynamicComponent, createFor, createForSlots, createIf, createInvoker, createKeyedFragment, createPlainElement, createSelector, createSlot, createTemplateRefSetter, createTextNode, createVaporApp, createVaporSSRApp, defineVaporAsyncComponent, defineVaporComponent, defineVaporCustomElement, defineVaporSSRCustomElement, delegate, delegateEvents, getDefaultValue, getRestElement, insert$1 as insert, isFragment, isVaporComponent, next, nthChild, on, prepend, remove, renderEffect, setAttr, setBlockHtml, setBlockKey, setBlockText, setClass, setClassName, setDOMProp, setDynamicEvents, setDynamicProps, setElementText, setHtml, setInsertionState, setProp, setStyle, setText, setValue, template, txt, useVaporCssVars, vaporInteropPlugin, withAsyncContext, withVaporCtx, withVaporDirectives };
25844
25872
  }
25845
25873
  //#endregion
25846
25874
  //#region temp/packages/compiler-vapor/src/ir/component.d.ts
@@ -28077,7 +28105,8 @@ export declare class TransformContext<T extends AllNode = AllNode> {
28077
28105
  operationIndex: number;
28078
28106
  isLastEffectiveChild: boolean;
28079
28107
  isOnRightmostPath: boolean;
28080
- hasInlineAncestorNeedingClose: boolean;
28108
+ templateCloseTags: Set<string> | undefined;
28109
+ templateCloseBlocks: boolean;
28081
28110
  private globalId;
28082
28111
  private nextIdMap;
28083
28112
  private ifIndex;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-vapor v3.6.0-beta.11
2
+ * @vue/compiler-vapor v3.6.0-beta.12
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -39,6 +39,7 @@ const remove = (arr, el) => {
39
39
  };
40
40
  const isArray$1 = Array.isArray;
41
41
  const isString = (val) => typeof val === "string";
42
+ const isObject = (val) => val !== null && typeof val === "object";
42
43
  const isBuiltInDirective = /* @__PURE__ */ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
43
44
  const cacheStringFunction = (fn) => {
44
45
  const cache = Object.create(null);
@@ -82,6 +83,20 @@ function canSetValueDirectly(tagName) {
82
83
  }
83
84
  const isGloballyAllowed = /* @__PURE__ */ makeMap("Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol");
84
85
  //#endregion
86
+ //#region packages/shared/src/normalizeProp.ts
87
+ function normalizeClass(value) {
88
+ let res = "";
89
+ if (isString(value)) res = value;
90
+ else if (isArray$1(value)) for (let i = 0; i < value.length; i++) {
91
+ const normalized = normalizeClass(value[i]);
92
+ if (normalized) res += normalized + " ";
93
+ }
94
+ else if (isObject(value)) {
95
+ for (const name in value) if (value[name]) res += name + " ";
96
+ }
97
+ return res.trim();
98
+ }
99
+ //#endregion
85
100
  //#region packages/shared/src/domTagConfig.ts
86
101
  const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
87
102
  const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
@@ -515,6 +530,12 @@ var toString = {}.toString;
515
530
  var isArray = Array.isArray || function(arr) {
516
531
  return toString.call(arr) == "[object Array]";
517
532
  };
533
+ /*!
534
+ * The buffer module from node.js, for the browser.
535
+ *
536
+ * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
537
+ * @license MIT
538
+ */
518
539
  /**
519
540
  * If `Buffer.TYPED_ARRAY_SUPPORT`:
520
541
  * === true Use Uint8Array implementation (fastest)
@@ -19114,7 +19135,8 @@ var TransformContext = class TransformContext {
19114
19135
  this.operationIndex = this.block.operation.length;
19115
19136
  this.isLastEffectiveChild = true;
19116
19137
  this.isOnRightmostPath = true;
19117
- this.hasInlineAncestorNeedingClose = false;
19138
+ this.templateCloseTags = void 0;
19139
+ this.templateCloseBlocks = false;
19118
19140
  this.globalId = 0;
19119
19141
  this.nextIdMap = null;
19120
19142
  this.ifIndex = 0;
@@ -19240,11 +19262,6 @@ var TransformContext = class TransformContext {
19240
19262
  while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
19241
19263
  const isLastEffectiveChild = this.isEffectivelyLastChild(index);
19242
19264
  const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
19243
- let hasInlineAncestorNeedingClose = this.hasInlineAncestorNeedingClose;
19244
- if (this.node.type === 1) {
19245
- if (this.node.tag === "template") hasInlineAncestorNeedingClose = false;
19246
- else if (!hasInlineAncestorNeedingClose && !this.isOnRightmostPath && isInlineTag(this.node.tag)) hasInlineAncestorNeedingClose = true;
19247
- }
19248
19265
  return Object.assign(Object.create(TransformContext.prototype), this, {
19249
19266
  node,
19250
19267
  parent: this,
@@ -19259,7 +19276,8 @@ var TransformContext = class TransformContext {
19259
19276
  effectiveParent,
19260
19277
  isLastEffectiveChild,
19261
19278
  isOnRightmostPath,
19262
- hasInlineAncestorNeedingClose
19279
+ templateCloseTags: this.templateCloseTags,
19280
+ templateCloseBlocks: this.templateCloseBlocks
19263
19281
  });
19264
19282
  }
19265
19283
  shiftEffectBoundaries(index, dynamic = this.dynamic) {
@@ -19453,6 +19471,9 @@ function genCall(name, ...frags) {
19453
19471
  hasPlaceholder ? name[1] : "null"
19454
19472
  ], ...frags)];
19455
19473
  }
19474
+ function getParserOptions(plugins) {
19475
+ return { plugins: plugins ? plugins.some((plugin) => plugin === "typescript") ? plugins : [...plugins, "typescript"] : ["typescript"] };
19476
+ }
19456
19477
  function codeFragmentToString(code, context) {
19457
19478
  const { options: { filename, sourceMap } } = context;
19458
19479
  let map;
@@ -19835,9 +19856,7 @@ function escapeRegExp(string) {
19835
19856
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
19836
19857
  }
19837
19858
  function parseExp(context, content) {
19838
- const plugins = context.options.expressionPlugins;
19839
- const options = { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] };
19840
- return (0, import_lib.parseExpression)(`(${content})`, options);
19859
+ return (0, import_lib.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
19841
19860
  }
19842
19861
  function genVarName(exp) {
19843
19862
  return `${exp.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/_+$/, "")}`;
@@ -20015,16 +20034,12 @@ function genFor(oper, context) {
20015
20034
  idMap[rawIndex] = `${indexVar}.value`;
20016
20035
  idMap[indexVar] = null;
20017
20036
  }
20018
- const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
20037
+ const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap, context);
20019
20038
  const selectorDeclarations = [];
20020
- const selectorSetup = [];
20039
+ const selectorName = (i) => selectorPatterns.length > 1 ? `_selector${id}_${i}` : `_selector${id}`;
20021
20040
  for (let i = 0; i < selectorPatterns.length; i++) {
20022
20041
  const { selector } = selectorPatterns[i];
20023
- const selectorName = `_selector${id}_${i}`;
20024
- selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
20025
- if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
20026
- selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
20027
- if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
20042
+ selectorDeclarations.push(`const ${selectorName(i)} = `, ...genCall(helper("createSelector"), [`() => `, ...genExpression(selector, context)]), NEWLINE);
20028
20043
  }
20029
20044
  const blockFn = context.withId(() => {
20030
20045
  const frag = [];
@@ -20033,7 +20048,7 @@ function genFor(oper, context) {
20033
20048
  const patternFrag = [];
20034
20049
  for (let i = 0; i < selectorPatterns.length; i++) {
20035
20050
  const { effect } = selectorPatterns[i];
20036
- patternFrag.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
20051
+ patternFrag.push(NEWLINE, `${selectorName(i)}(`, ...genExpression(keyProp, context), `, () => {`, INDENT_START);
20037
20052
  for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
20038
20053
  patternFrag.push(INDENT_END, NEWLINE, `})`);
20039
20054
  }
@@ -20049,11 +20064,14 @@ function genFor(oper, context) {
20049
20064
  if (onlyChild) flags |= 1;
20050
20065
  if (component) flags |= 2;
20051
20066
  if (once) flags |= 4;
20067
+ const onResetCalls = [];
20068
+ for (let i = 0; i < selectorPatterns.length; i++) onResetCalls.push(NEWLINE, `n${id}.onReset(${selectorName(i)}.reset)`);
20052
20069
  return [
20053
20070
  NEWLINE,
20054
20071
  ...selectorDeclarations,
20055
20072
  `const n${id} = `,
20056
- ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0, selectorSetup.length ? selectorSetup : void 0)
20073
+ ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
20074
+ ...onResetCalls
20057
20075
  ];
20058
20076
  function genCallback(expr) {
20059
20077
  if (!expr) return false;
@@ -20139,19 +20157,19 @@ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
20139
20157
  }
20140
20158
  if (pathInfo.dynamic) {
20141
20159
  const node = idMap[id] = createSimpleExpression(path);
20142
- node.ast = (0, import_lib.parseExpression)(`(${path})`, { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] });
20160
+ node.ast = (0, import_lib.parseExpression)(`(${path})`, getParserOptions(plugins));
20143
20161
  } else idMap[id] = path;
20144
20162
  } else idMap[id] = path;
20145
20163
  });
20146
20164
  return idMap;
20147
20165
  }
20148
- function matchPatterns(render, keyProp, idMap) {
20166
+ function matchPatterns(render, keyProp, idMap, context) {
20149
20167
  const selectorPatterns = [];
20150
20168
  const keyOnlyBindingPatterns = [];
20151
20169
  const removedEffectIndexes = [];
20152
20170
  render.effect = render.effect.filter((effect, index) => {
20153
20171
  if (keyProp !== void 0) {
20154
- const selector = matchSelectorPattern(effect, keyProp.content, idMap);
20172
+ const selector = matchSelectorPattern(effect, keyProp.content, idMap, context);
20155
20173
  if (selector) {
20156
20174
  selectorPatterns.push(selector);
20157
20175
  removedEffectIndexes.push(index);
@@ -20190,7 +20208,7 @@ function matchKeyOnlyBindingPattern(effect, key) {
20190
20208
  }
20191
20209
  }
20192
20210
  }
20193
- function matchSelectorPattern(effect, key, idMap) {
20211
+ function matchSelectorPattern(effect, key, idMap, context) {
20194
20212
  if (effect.expressions.length === 1) {
20195
20213
  const { ast, content } = effect.expressions[0];
20196
20214
  if (typeof ast === "object" && ast) {
@@ -20215,17 +20233,11 @@ function matchSelectorPattern(effect, key, idMap) {
20215
20233
  }, false);
20216
20234
  if (!hasExtraId) {
20217
20235
  const name = content.slice(selector.start - 1, selector.end - 1);
20236
+ const selectorExpression = createSimpleExpression(name, false, selector.loc);
20237
+ selectorExpression.ast = (0, import_lib.parseExpression)(`(${name})`, getParserOptions(context.options.expressionPlugins));
20218
20238
  return {
20219
20239
  effect,
20220
- selector: {
20221
- content: name,
20222
- ast: extend({}, selector, {
20223
- start: 1,
20224
- end: name.length + 1
20225
- }),
20226
- loc: selector.loc,
20227
- isStatic: false
20228
- }
20240
+ selector: selectorExpression
20229
20241
  };
20230
20242
  }
20231
20243
  }
@@ -20287,6 +20299,7 @@ const helpers = {
20287
20299
  setText: { name: "setText" },
20288
20300
  setHtml: { name: "setHtml" },
20289
20301
  setClass: { name: "setClass" },
20302
+ setClassName: { name: "setClassName" },
20290
20303
  setStyle: { name: "setStyle" },
20291
20304
  setValue: { name: "setValue" },
20292
20305
  setAttr: {
@@ -20306,9 +20319,132 @@ function genSetProp(oper, context) {
20306
20319
  const { helper } = context;
20307
20320
  const { prop: { key, values, modifier }, tag } = oper;
20308
20321
  const resolvedHelper = getRuntimeHelper(tag, key.content, modifier);
20322
+ if (key.content === "class" && !resolvedHelper.isSVG && resolvedHelper.name === "setClass") {
20323
+ const className = genSetClassName(oper, context);
20324
+ if (className) return className;
20325
+ }
20309
20326
  const propValue = genPropValue(values, context);
20310
20327
  return [NEWLINE, ...genCall([helper(resolvedHelper.name), null], `n${oper.element}`, resolvedHelper.needKey ? genExpression(key, context) : false, propValue, resolvedHelper.isSVG && "true")];
20311
20328
  }
20329
+ const MAX_CLASS_NAME_ENTRIES = 31;
20330
+ function genSetClassName(oper, context) {
20331
+ const info = resolveClassName(oper.prop.values, context);
20332
+ if (!info) return;
20333
+ const { helper } = context;
20334
+ const flags = genClassFlags(info.entries, context);
20335
+ const classFragments = info.entries.map((entry) => JSON.stringify(!info.prefix && info.entries.length === 1 ? entry.className : ` ${entry.className}`));
20336
+ const fragments = classFragments.length === 1 ? classFragments[0] : genMulti(DELIMITERS_ARRAY, ...classFragments);
20337
+ return [NEWLINE, ...genCall([helper("setClassName"), "\"\""], `n${oper.element}`, flags, fragments, info.prefix && JSON.stringify(info.prefix), info.suffix && JSON.stringify(info.suffix))];
20338
+ }
20339
+ function resolveClassName(values, context) {
20340
+ let prefix = "";
20341
+ let suffix = "";
20342
+ const entries = [];
20343
+ let sawDynamic = false;
20344
+ let sawSuffix = false;
20345
+ for (const value of values) {
20346
+ const staticValue = getLiteralExpressionValue(value, true);
20347
+ if (staticValue != null) {
20348
+ const normalized = normalizeClass(staticValue);
20349
+ if (normalized) if (sawSuffix) suffix = appendClass(suffix, normalized);
20350
+ else if (sawDynamic) {
20351
+ sawSuffix = true;
20352
+ suffix = appendClass(suffix, normalized);
20353
+ } else prefix = appendClass(prefix, normalized);
20354
+ continue;
20355
+ }
20356
+ const ast = value.ast;
20357
+ if (!ast || sawSuffix) return;
20358
+ sawDynamic = true;
20359
+ if (ast.type === "ObjectExpression") {
20360
+ if (!resolveObjectClassName(value, ast, entries, context)) return;
20361
+ } else if (ast.type === "ConditionalExpression") {
20362
+ if (!resolveConditionalClassName(value, ast, entries, context)) return;
20363
+ } else return;
20364
+ }
20365
+ return entries.length && entries.length <= MAX_CLASS_NAME_ENTRIES ? {
20366
+ prefix,
20367
+ suffix,
20368
+ entries
20369
+ } : void 0;
20370
+ }
20371
+ function resolveObjectClassName(source, ast, entries, context) {
20372
+ for (const prop of ast.properties) {
20373
+ if (prop.type !== "ObjectProperty" || prop.computed) return false;
20374
+ const rawClassName = getObjectPropertyName(prop);
20375
+ if (rawClassName == null) return false;
20376
+ const className = normalizeClass(rawClassName);
20377
+ if (!className) continue;
20378
+ const value = getBooleanValue(prop.value);
20379
+ entries.push({
20380
+ className,
20381
+ value,
20382
+ condition: value == null ? createSubExpression(source, prop.value, context) : void 0
20383
+ });
20384
+ }
20385
+ return true;
20386
+ }
20387
+ function resolveConditionalClassName(source, ast, entries, context) {
20388
+ const consequent = getStringClassValue(ast.consequent);
20389
+ const alternate = getStringClassValue(ast.alternate);
20390
+ if (consequent && alternate === "") {
20391
+ entries.push({
20392
+ className: consequent,
20393
+ condition: createSubExpression(source, ast.test, context)
20394
+ });
20395
+ return true;
20396
+ } else if (alternate && consequent === "") {
20397
+ entries.push({
20398
+ className: alternate,
20399
+ condition: createSubExpression(source, ast.test, context),
20400
+ negate: true
20401
+ });
20402
+ return true;
20403
+ }
20404
+ return false;
20405
+ }
20406
+ function genClassFlags(entries, context) {
20407
+ const values = [];
20408
+ entries.forEach((entry, index) => {
20409
+ if (index) values.push(" | ");
20410
+ const bit = 1 << index;
20411
+ if (entry.value != null) {
20412
+ values.push(entry.value ? String(bit) : "0");
20413
+ return;
20414
+ }
20415
+ values.push("(", ...genExpression(entry.condition, context), entry.negate ? ` ? 0 : ${bit}` : ` ? ${bit} : 0`, ")");
20416
+ });
20417
+ return values;
20418
+ }
20419
+ function appendClass(base, value) {
20420
+ return base ? value ? `${base} ${value}` : base : value;
20421
+ }
20422
+ function getObjectPropertyName(prop) {
20423
+ const key = prop.key;
20424
+ if (key.type === "Identifier") return key.name;
20425
+ else if (key.type === "StringLiteral") return key.value;
20426
+ else if (key.type === "NumericLiteral") return String(key.value);
20427
+ }
20428
+ function getStringClassValue(node) {
20429
+ if (node.type === "StringLiteral") return normalizeClass(node.value);
20430
+ else if (node.type === "TemplateLiteral" && node.expressions.length === 0) return normalizeClass(node.quasis[0].value.cooked || "");
20431
+ else if (node.type === "NullLiteral" || node.type === "BooleanLiteral" && !node.value) return "";
20432
+ }
20433
+ function getBooleanValue(node) {
20434
+ if (node.type === "BooleanLiteral") return node.value;
20435
+ }
20436
+ function createSubExpression(source, node, context) {
20437
+ const start = node.start == null ? 0 : node.start - 1;
20438
+ const end = node.end == null ? source.content.length : node.end - 1;
20439
+ const content = source.content.slice(start, end);
20440
+ const expression = createSimpleExpression(content, false, {
20441
+ start: advancePositionWithClone(source.loc.start, source.content, start),
20442
+ end: advancePositionWithClone(source.loc.start, source.content, end),
20443
+ source: content
20444
+ });
20445
+ expression.ast = isSimpleIdentifier(content) ? null : (0, import_lib.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
20446
+ return expression;
20447
+ }
20312
20448
  function genDynamicProps$1(oper, context) {
20313
20449
  const { helper } = context;
20314
20450
  const isSVG = isSVGTag(oper.tag);
@@ -20718,11 +20854,23 @@ function genDynamicSlot(slot, context, withFunction = false) {
20718
20854
  frag = genConditionalSlot(slot, context);
20719
20855
  break;
20720
20856
  }
20721
- return withFunction ? [
20857
+ if (!withFunction) return frag;
20858
+ return needsDynamicSlotSourceCtx(slot) ? [
20859
+ `${context.helper("withVaporCtx")}(() => (`,
20860
+ ...frag,
20861
+ "))"
20862
+ ] : [
20722
20863
  "() => (",
20723
20864
  ...frag,
20724
20865
  ")"
20725
- ] : frag;
20866
+ ];
20867
+ }
20868
+ function needsDynamicSlotSourceCtx(slot) {
20869
+ switch (slot.slotType) {
20870
+ case 1: return needsVaporCtx(slot.fn);
20871
+ case 2: return needsVaporCtx(slot.fn);
20872
+ case 3: return needsDynamicSlotSourceCtx(slot.positive) || (slot.negative ? needsDynamicSlotSourceCtx(slot.negative) : false);
20873
+ }
20726
20874
  }
20727
20875
  function genBasicDynamicSlot(slot, context) {
20728
20876
  const { name, fn } = slot;
@@ -21248,7 +21396,7 @@ const transformVBind = (dir, node, context) => {
21248
21396
  };
21249
21397
  };
21250
21398
  //#endregion
21251
- //#region \0@oxc-project+runtime@0.128.0/helpers/typeof.js
21399
+ //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
21252
21400
  function _typeof(o) {
21253
21401
  "@babel/helpers - typeof";
21254
21402
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -21258,7 +21406,7 @@ function _typeof(o) {
21258
21406
  }, _typeof(o);
21259
21407
  }
21260
21408
  //#endregion
21261
- //#region \0@oxc-project+runtime@0.128.0/helpers/toPrimitive.js
21409
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
21262
21410
  function toPrimitive(t, r) {
21263
21411
  if ("object" != _typeof(t) || !t) return t;
21264
21412
  var e = t[Symbol.toPrimitive];
@@ -21270,13 +21418,13 @@ function toPrimitive(t, r) {
21270
21418
  return ("string" === r ? String : Number)(t);
21271
21419
  }
21272
21420
  //#endregion
21273
- //#region \0@oxc-project+runtime@0.128.0/helpers/toPropertyKey.js
21421
+ //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
21274
21422
  function toPropertyKey(t) {
21275
21423
  var i = toPrimitive(t, "string");
21276
21424
  return "symbol" == _typeof(i) ? i : i + "";
21277
21425
  }
21278
21426
  //#endregion
21279
- //#region \0@oxc-project+runtime@0.128.0/helpers/defineProperty.js
21427
+ //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
21280
21428
  function _defineProperty(e, r, t) {
21281
21429
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
21282
21430
  value: t,
@@ -21286,7 +21434,7 @@ function _defineProperty(e, r, t) {
21286
21434
  }) : e[r] = t, e;
21287
21435
  }
21288
21436
  //#endregion
21289
- //#region \0@oxc-project+runtime@0.128.0/helpers/objectSpread2.js
21437
+ //#region \0@oxc-project+runtime@0.129.0/helpers/objectSpread2.js
21290
21438
  function ownKeys(e, r) {
21291
21439
  var t = Object.keys(e);
21292
21440
  if (Object.getOwnPropertySymbols) {
@@ -21337,11 +21485,35 @@ function canOmitEndTag(node, context) {
21337
21485
  const { block, parent } = context;
21338
21486
  if (!parent) return false;
21339
21487
  if (block !== parent.block) return true;
21488
+ if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || isAlwaysCloseTag(node.tag) || isFormattingTag(node.tag)) || context.templateCloseBlocks && isBlockTag(node.tag)) return false;
21340
21489
  if (isAlwaysCloseTag(node.tag) && !context.isOnRightmostPath) return false;
21341
21490
  if (isFormattingTag(node.tag) || parent.node.type === 1 && node.tag === parent.node.tag) return context.isOnRightmostPath;
21342
- if (isBlockTag(node.tag) && context.hasInlineAncestorNeedingClose) return false;
21343
21491
  return context.isLastEffectiveChild;
21344
21492
  }
21493
+ function getChildTemplateCloseState(context) {
21494
+ const { node } = context;
21495
+ if (node.type !== 1 || node.tagType !== 0 || shouldUseCreateElement(node, context)) return;
21496
+ const inSameTemplateAsParent = isInSameTemplateAsParent(context);
21497
+ const inheritedTags = inSameTemplateAsParent ? context.templateCloseTags : void 0;
21498
+ const inheritedBlocks = inSameTemplateAsParent && context.templateCloseBlocks;
21499
+ if (context.root === context.effectiveParent || canOmitEndTag(node, context) || isVoidTag(node.tag)) return inheritedTags || inheritedBlocks ? {
21500
+ tags: inheritedTags,
21501
+ blocks: inheritedBlocks
21502
+ } : void 0;
21503
+ const tags = new Set(inheritedTags);
21504
+ tags.add(node.tag);
21505
+ return {
21506
+ tags,
21507
+ blocks: inheritedBlocks || isInlineTag(node.tag)
21508
+ };
21509
+ }
21510
+ function isInSameTemplateAsParent(context) {
21511
+ const { parent, node, block } = context;
21512
+ if (!parent || block !== parent.block) return false;
21513
+ const parentNode = parent.node;
21514
+ if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
21515
+ return !shouldUseCreateElement(parentNode, parent) && isValidHTMLNesting(parentNode.tag, node.tag);
21516
+ }
21345
21517
  function isSingleRoot(context) {
21346
21518
  if (context.inVFor) return false;
21347
21519
  let { parent } = context;
@@ -21605,8 +21777,12 @@ const transformChildren = (node, context) => {
21605
21777
  const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
21606
21778
  if (!isFragment && node.type !== 1) return;
21607
21779
  const useCreateElement = node.type === 1 && shouldUseCreateElement(node, context);
21780
+ const childTemplateCloseState = !isFragment && !useCreateElement ? getChildTemplateCloseState(context) : void 0;
21608
21781
  for (const [i, child] of node.children.entries()) {
21609
21782
  const childContext = context.create(child, i);
21783
+ const isInSameTemplate = childTemplateCloseState && child.type === 1 && child.tagType === 0 && isInSameTemplateAsParent(childContext);
21784
+ childContext.templateCloseTags = isInSameTemplate ? childTemplateCloseState.tags : void 0;
21785
+ childContext.templateCloseBlocks = isInSameTemplate ? childTemplateCloseState.blocks : false;
21610
21786
  transformNode(childContext);
21611
21787
  const childDynamic = childContext.dynamic;
21612
21788
  if (isFragment) {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@vue/compiler-vapor",
3
- "version": "3.6.0-beta.11",
3
+ "version": "3.6.0-beta.12",
4
4
  "description": "@vue/compiler-vapor",
5
5
  "main": "dist/compiler-vapor.cjs.js",
6
- "module": "dist/compiler-vapor.esm-bundler.js",
6
+ "module": "dist/compiler-vapor.esm-browser.js",
7
7
  "types": "dist/compiler-vapor.d.ts",
8
8
  "files": [
9
9
  "dist"
@@ -45,7 +45,7 @@
45
45
  "@babel/parser": "^7.29.3",
46
46
  "estree-walker": "^2.0.2",
47
47
  "source-map-js": "^1.2.1",
48
- "@vue/compiler-dom": "3.6.0-beta.11",
49
- "@vue/shared": "3.6.0-beta.11"
48
+ "@vue/compiler-dom": "3.6.0-beta.12",
49
+ "@vue/shared": "3.6.0-beta.12"
50
50
  }
51
51
  }