@vue/compiler-sfc 3.6.0-rc.12 → 3.6.0-rc.14

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-sfc v3.6.0-rc.12
2
+ * @vue/compiler-sfc v3.6.0-rc.14
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -352,8 +352,6 @@ const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math
352
352
  const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
353
353
  const FORMATTING_TAGS = "a,b,big,code,em,font,i,nobr,s,small,strike,strong,tt,u";
354
354
  const ALWAYS_CLOSE_TAGS = "title,style,script,noscript,template,object,table,button,textarea,select,iframe,fieldset,form,foreignObject,desc,mi,mo,mn,ms,mtext,annotation-xml";
355
- const INLINE_TAGS = "a,abbr,acronym,b,bdi,bdo,big,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,label,map,mark,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,small,span,strong,sub,sup,svg,textarea,time,u,tt,var,video";
356
- const BLOCK_TAGS = "address,article,aside,blockquote,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,main,menu,nav,ol,p,pre,section,table,ul";
357
355
  /**
358
356
  * Compiler only.
359
357
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
@@ -384,16 +382,6 @@ const isFormattingTag = /*@__PURE__*/ makeMap(FORMATTING_TAGS);
384
382
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
385
383
  */
386
384
  const isAlwaysCloseTag = /*@__PURE__*/ makeMap(ALWAYS_CLOSE_TAGS);
387
- /**
388
- * Compiler only.
389
- * Do NOT use in runtime code paths unless behind `__DEV__` flag.
390
- */
391
- const isInlineTag = /*@__PURE__*/ makeMap(INLINE_TAGS);
392
- /**
393
- * Compiler only.
394
- * Do NOT use in runtime code paths unless behind `__DEV__` flag.
395
- */
396
- const isBlockTag = /*@__PURE__*/ makeMap(BLOCK_TAGS);
397
385
  //#endregion
398
386
  //#region packages/shared/src/domAttrConfig.ts
399
387
  /**
@@ -16730,6 +16718,13 @@ const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
16730
16718
  const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
16731
16719
  const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
16732
16720
  const getExpSource = (exp) => exp.type === 4 ? exp.content : exp.loc.source;
16721
+ const asciiIdentifierRE = /^[A-Za-z_$][\w$]*$/;
16722
+ const isReservedWord = /*@__PURE__*/ makeMap("await,break,case,catch,class,const,continue,debugger,default,delete,do,else,enum,export,extends,false,finally,for,function,if,implements,import,in,instanceof,interface,let,new,null,package,private,protected,public,return,static,super,switch,this,throw,true,try,typeof,undefined,var,void,while,with,yield");
16723
+ const isUnparsedIdentifier = (exp) => {
16724
+ if (exp.ast !== null) return false;
16725
+ const content = getExpSource(exp);
16726
+ return asciiIdentifierRE.test(content) && !isReservedWord(content);
16727
+ };
16733
16728
  /**
16734
16729
  * Simple lexer to check if an expression is a member expression. This is
16735
16730
  * lax and only checks validity at the root level (i.e. does not validate exps
@@ -16787,6 +16782,7 @@ const isMemberExpressionBrowser = (exp) => {
16787
16782
  return !currentOpenBracketCount && !currentOpenParensCount;
16788
16783
  };
16789
16784
  const isMemberExpressionNode = (exp, context) => {
16785
+ if (isUnparsedIdentifier(exp)) return true;
16790
16786
  try {
16791
16787
  let ret = exp.ast || (0, import_lib.parseExpression)(getExpSource(exp), { plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"] });
16792
16788
  ret = unwrapTSNode(ret);
@@ -16799,6 +16795,7 @@ const isMemberExpression$1 = isMemberExpressionNode;
16799
16795
  const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
16800
16796
  const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
16801
16797
  const isFnExpressionNode = (exp, context) => {
16798
+ if (isUnparsedIdentifier(exp)) return false;
16802
16799
  try {
16803
16800
  let ret = exp.ast || (0, import_lib.parseExpression)(getExpSource(exp), { plugins: context.expressionPlugins ? [...context.expressionPlugins, "typescript"] : ["typescript"] });
16804
16801
  if (ret.type === "Program") {
@@ -25065,6 +25062,21 @@ const IRNodeTypes = {
25065
25062
  var TemplateRegistry = class {
25066
25063
  constructor() {
25067
25064
  this.entries = [];
25065
+ this.indexes = /* @__PURE__ */ new Map();
25066
+ }
25067
+ intern(content, ns, root, isStatic) {
25068
+ const key = `${ns}:${root ? 1 : 0}${isStatic ? 1 : 0}${content}`;
25069
+ const existing = this.indexes.get(key);
25070
+ if (existing !== void 0) return existing;
25071
+ const index = this.entries.length;
25072
+ this.entries.push({
25073
+ content,
25074
+ ns,
25075
+ root,
25076
+ static: isStatic
25077
+ });
25078
+ this.indexes.set(key, index);
25079
+ return index;
25068
25080
  }
25069
25081
  keys() {
25070
25082
  return this.entries.map(({ content }) => content);
@@ -25080,6 +25092,22 @@ const DynamicFlag = {
25080
25092
  "INSERT": 4,
25081
25093
  "4": "INSERT"
25082
25094
  };
25095
+ /**
25096
+ * How the parent reaches a child codegen holds on to. Decided once the
25097
+ * parent's children are final (`planAccess`), printed by `genChildren`.
25098
+ */
25099
+ const DynamicAccess = {
25100
+ "REFERENCE": 0,
25101
+ "0": "REFERENCE",
25102
+ "PLACEHOLDER": 1,
25103
+ "1": "PLACEHOLDER",
25104
+ "REUSE": 2,
25105
+ "2": "REUSE",
25106
+ "INLINE": 3,
25107
+ "3": "INLINE",
25108
+ "INLINE_REUSE": 4,
25109
+ "4": "INLINE_REUSE"
25110
+ };
25083
25111
  function isBlockOperation(op) {
25084
25112
  const type = op.type;
25085
25113
  return type === 12 || type === 13 || type === 15 || type === 17 || type === 16;
@@ -25097,7 +25125,9 @@ const newBlock = (node) => ({
25097
25125
  effect: [],
25098
25126
  operation: [],
25099
25127
  returns: [],
25100
- tempId: 0
25128
+ tempId: 0,
25129
+ deferredOperationIndex: 0,
25130
+ deferredEffectIndex: 0
25101
25131
  });
25102
25132
  function wrapTemplate(node, dirs) {
25103
25133
  if (node.tagType === 3) {
@@ -25125,8 +25155,10 @@ function wrapTemplate(node, dirs) {
25125
25155
  const reserved = [];
25126
25156
  const pass = [];
25127
25157
  node.props.forEach((prop) => {
25128
- if (prop.type === 7 && (dirs.includes(prop.name) || prop.name === "bind" && prop.arg && prop.arg.type === 4 && prop.arg.content === "key" && dirs.includes("key"))) reserved.push(prop);
25129
- else pass.push(prop);
25158
+ if (prop.type === 7 && (dirs.includes(prop.name) || prop.name === "bind" && prop.arg && prop.arg.type === 4 && prop.arg.content === "key" && dirs.includes("key"))) {
25159
+ reserved.push(prop);
25160
+ if (prop.name === "bind" && node.tagType === 2) pass.push(prop);
25161
+ } else pass.push(prop);
25130
25162
  });
25131
25163
  return extend({}, node, {
25132
25164
  type: 1,
@@ -25223,75 +25255,139 @@ function isBuiltInComponent(tag) {
25223
25255
  else if (isTransitionGroupTag(tag)) return "VaporTransitionGroup";
25224
25256
  }
25225
25257
  function getBlockShape(block) {
25226
- if (block.returns.length !== 1) return 2;
25227
- const root = block.dynamic.children.find((c) => c.id === block.returns[0]);
25228
- if (root && root.operation && root.operation.type === 15) return 2;
25229
- return block.node.type === 1 && block.node.children.every((child) => child.type === 2 || child.type === 5) ? 2 : 1;
25258
+ const { node } = block;
25259
+ if (node.type !== 1) return 1;
25260
+ const child = node.children.length === 1 ? node.children[0] : void 0;
25261
+ return child && child.type === 1 && !findDir(child, "if") ? 1 : 2;
25262
+ }
25263
+ /** the number of `v-if` / `v-else-if` nodes in the chain starting at `head` */
25264
+ function getIfChainLength(head) {
25265
+ let length = 1;
25266
+ let negative = head.negative;
25267
+ while (negative && negative.type === 15) {
25268
+ length++;
25269
+ negative = negative.negative;
25270
+ }
25271
+ return length;
25272
+ }
25273
+ function isLongIfChain(head) {
25274
+ return getIfChainLength(head) - 1 > 10;
25275
+ }
25276
+ function isSlotTemplate(node) {
25277
+ return node.type === 1 && isTemplateNode(node) && node.props.some(isVSlot);
25278
+ }
25279
+ function isVModelOperation(oper) {
25280
+ return oper.type === 14 && oper.builtin === true && oper.name === "model";
25281
+ }
25282
+ function isVModelListener(oper, modelElements) {
25283
+ return (oper.type === 7 || oper.type === 8 || oper.type === 4 && oper.listeners || oper.type === 3 && !oper.prop.modifier && isOn(oper.prop.key.content)) && modelElements.has(oper.element);
25230
25284
  }
25231
25285
  //#endregion
25232
25286
  //#region packages/compiler-vapor/src/transform.ts
25233
25287
  init_objectSpread2();
25234
- const generatedVarRE = /^[nxr](\d+)$/;
25235
- const childContextInfoCache = /* @__PURE__ */ new WeakMap();
25288
+ const idWithTrailingDigitsRE = /^([A-Za-z_$][\w$]*?)(\d+)$/;
25289
+ function collectReservedNames(bindingMetadata) {
25290
+ const names = new Set(bindingMetadata ? Object.keys(bindingMetadata) : []);
25291
+ const ids = /* @__PURE__ */ new Map();
25292
+ for (const name of names) {
25293
+ const m = idWithTrailingDigitsRE.exec(name);
25294
+ if (!m) continue;
25295
+ let set = ids.get(m[1]);
25296
+ if (!set) ids.set(m[1], set = /* @__PURE__ */ new Set());
25297
+ set.add(Number(m[2]));
25298
+ }
25299
+ return {
25300
+ names,
25301
+ ids
25302
+ };
25303
+ }
25304
+ const ORDER_STRIDE = 1 << 20;
25236
25305
  var TransformContext = class TransformContext {
25237
- constructor(ir, node, options = {}) {
25306
+ constructor(ir, node, options = EMPTY_OBJ, parent = null, index = 0) {
25238
25307
  this.ir = ir;
25239
25308
  this.node = node;
25240
- this.selfName = null;
25241
- this.parent = null;
25242
- this.effectiveParent = null;
25243
- this.index = 0;
25244
- this.block = this.ir.block;
25309
+ this.parent = parent;
25310
+ this.index = index;
25311
+ if (parent) {
25312
+ this.root = parent.root;
25313
+ this.options = parent.options;
25314
+ this.selfName = parent.selfName;
25315
+ this.block = parent.block;
25316
+ this.dynamic = newDynamic();
25317
+ this.imports = parent.imports;
25318
+ this.inVOnce = parent.inVOnce && !isComponentNode(parent.node);
25319
+ this.inVFor = parent.inVFor;
25320
+ this.comment = parent.comment;
25321
+ this.slots = parent.slots;
25322
+ this.ifHeads = parent.ifHeads;
25323
+ this.effectOrder = parent.effectOrder;
25324
+ this.templateCloseTags = parent.templateCloseTags;
25325
+ this.templateCloseBlocks = parent.templateCloseBlocks;
25326
+ let effectiveParent = parent;
25327
+ while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
25328
+ this.effectiveParent = effectiveParent;
25329
+ const childInfo = parent.getChildContextInfo();
25330
+ const isLastEffectiveChild = childInfo.isLastEffectiveChild[index];
25331
+ this.isLastEffectiveChild = isLastEffectiveChild;
25332
+ this.isOnRightmostPath = parent.isOnRightmostPath && isLastEffectiveChild;
25333
+ this.isSingleRoot = parent.isSingleRootChild(childInfo);
25334
+ this.isSlotRoot = parent.isSlotRootChild(childInfo);
25335
+ } else {
25336
+ this.root = this;
25337
+ this.options = extend({}, defaultOptions, options);
25338
+ this.selfName = options.filename ? getSelfName(options.filename) : null;
25339
+ this.block = ir.block;
25340
+ this.dynamic = ir.block.dynamic;
25341
+ this.imports = [];
25342
+ this.inVOnce = false;
25343
+ this.inVFor = 0;
25344
+ this.comment = [];
25345
+ this.slots = [];
25346
+ this.ifHeads = /* @__PURE__ */ new Map();
25347
+ this.effectOrder = /* @__PURE__ */ new Map();
25348
+ this.templateCloseTags = void 0;
25349
+ this.templateCloseBlocks = false;
25350
+ this.effectiveParent = null;
25351
+ this.isLastEffectiveChild = true;
25352
+ this.isOnRightmostPath = true;
25353
+ this.isSingleRoot = false;
25354
+ this.isSlotRoot = false;
25355
+ }
25245
25356
  this.template = "";
25246
25357
  this.templateRoot = false;
25247
- this.templateIndexMap = /* @__PURE__ */ new Map();
25248
25358
  this.childrenTemplate = [];
25249
- this.dynamic = this.ir.block.dynamic;
25250
- this.imports = [];
25251
- this.inVOnce = false;
25252
- this.inVFor = 0;
25253
- this.comment = [];
25254
- this.component = this.ir.component;
25255
- this.directive = this.ir.directive;
25256
- this.slots = [];
25359
+ this.component = ir.component;
25360
+ this.directive = ir.directive;
25257
25361
  this.effectIndex = this.block.effect.length;
25258
25362
  this.operationIndex = this.block.operation.length;
25259
- this.isLastEffectiveChild = true;
25260
- this.isOnRightmostPath = true;
25261
- this.isSingleRoot = false;
25262
- this.templateCloseTags = void 0;
25263
- this.templateCloseBlocks = false;
25363
+ this.templateScope = 0;
25364
+ this.ifHead = null;
25365
+ this.ifTail = null;
25264
25366
  this.globalId = 0;
25265
25367
  this.nextIdMap = null;
25266
25368
  this.ifIndex = 0;
25267
- this.increaseId = () => {
25268
- const id = getNextId(this.nextIdMap, this.globalId);
25269
- this.globalId = getNextId(this.nextIdMap, id + 1);
25270
- return id;
25271
- };
25272
- this.options = extend({}, defaultOptions, options);
25273
- this.root = this;
25274
- if (options.filename) this.selfName = getSelfName(options.filename);
25275
- this.initNextIdMap();
25369
+ this.nextOrder = 0;
25370
+ this.childInfo = null;
25371
+ this.order = this.allocateOrder();
25372
+ if (!parent) this.initNextIdMap();
25276
25373
  }
25277
25374
  enterBlock(ir, isVFor = false) {
25278
- const { block, template, templateRoot, templateIndexMap, dynamic, childrenTemplate, slots, effectIndex, operationIndex } = this;
25375
+ const { block, template, templateRoot, dynamic, childrenTemplate, slots, effectIndex, operationIndex } = this;
25279
25376
  this.block = ir;
25280
25377
  this.dynamic = ir.dynamic;
25281
25378
  this.template = "";
25282
25379
  this.templateRoot = false;
25283
- this.templateIndexMap = templateIndexMap;
25284
25380
  this.childrenTemplate = [];
25285
25381
  this.slots = [];
25286
25382
  this.effectIndex = ir.effect.length;
25287
25383
  this.operationIndex = ir.operation.length;
25288
25384
  isVFor && this.inVFor++;
25289
25385
  return () => {
25386
+ this.finalizeBlock(ir);
25290
25387
  this.registerTemplate();
25291
25388
  this.block = block;
25292
25389
  this.template = template;
25293
25390
  this.templateRoot = templateRoot;
25294
- this.templateIndexMap = templateIndexMap;
25295
25391
  this.dynamic = dynamic;
25296
25392
  this.childrenTemplate = childrenTemplate;
25297
25393
  this.slots = slots;
@@ -25300,17 +25396,26 @@ var TransformContext = class TransformContext {
25300
25396
  isVFor && this.inVFor--;
25301
25397
  };
25302
25398
  }
25399
+ allocateOrder() {
25400
+ const root = this.root;
25401
+ const order = root.nextOrder;
25402
+ root.nextOrder += ORDER_STRIDE;
25403
+ return order;
25404
+ }
25405
+ increaseId() {
25406
+ const root = this.root;
25407
+ const id = getNextId(root.nextIdMap, root.globalId);
25408
+ root.globalId = getNextId(root.nextIdMap, id + 1);
25409
+ return id;
25410
+ }
25303
25411
  initNextIdMap() {
25304
- const binding = this.root.options.bindingMetadata;
25305
- if (!binding) return;
25306
- const keys = Object.keys(binding);
25307
- if (keys.length === 0) return;
25308
- const numbers = /* @__PURE__ */ new Set();
25309
- for (const name of keys) {
25310
- const m = generatedVarRE.exec(name);
25311
- if (m) numbers.add(Number(m[1]));
25312
- }
25313
- if (numbers.size === 0) return;
25412
+ const { ids } = this.ir.reservedNames;
25413
+ const numbers = [
25414
+ ...ids.get("n") || [],
25415
+ ...ids.get("x") || [],
25416
+ ...ids.get("r") || []
25417
+ ];
25418
+ if (numbers.length === 0) return;
25314
25419
  this.globalId = getNextId(this.nextIdMap = buildNextIdMap(numbers), 0);
25315
25420
  }
25316
25421
  reference() {
@@ -25318,8 +25423,11 @@ var TransformContext = class TransformContext {
25318
25423
  this.dynamic.flags |= 1;
25319
25424
  return this.dynamic.id = this.increaseId();
25320
25425
  }
25321
- nextIfIndex() {
25322
- return this.ifIndex++;
25426
+ nextIfIndex(count = 1) {
25427
+ const root = this.root;
25428
+ const index = root.ifIndex;
25429
+ root.ifIndex += count;
25430
+ return index;
25323
25431
  }
25324
25432
  getTemplateNamespace() {
25325
25433
  return this.node.type === 1 ? this.node.ns : 0;
@@ -25334,24 +25442,7 @@ var TransformContext = class TransformContext {
25334
25442
  return this.node.type === 1 && this.node.tagType === 0 && !(this.options.isCustomElement(this.node.tag) || this.node.tag === "template");
25335
25443
  }
25336
25444
  pushTemplate(content, { root = false, static: isStatic = false } = {}) {
25337
- const templateKey = JSON.stringify([
25338
- this.getTemplateNamespace(),
25339
- root,
25340
- isStatic,
25341
- content
25342
- ]);
25343
- const existingIndex = this.templateIndexMap.get(templateKey);
25344
- if (existingIndex !== void 0) return existingIndex;
25345
- const ns = this.getTemplateNamespace();
25346
- const newIndex = this.ir.template.entries.length;
25347
- this.ir.template.entries.push({
25348
- content,
25349
- ns,
25350
- root,
25351
- static: isStatic
25352
- });
25353
- this.templateIndexMap.set(templateKey, newIndex);
25354
- return newIndex;
25445
+ return this.ir.template.intern(content, this.getTemplateNamespace(), root, isStatic);
25355
25446
  }
25356
25447
  registerTemplate() {
25357
25448
  if (!this.template) return -1;
@@ -25361,8 +25452,8 @@ var TransformContext = class TransformContext {
25361
25452
  });
25362
25453
  return this.dynamic.template = id;
25363
25454
  }
25364
- registerEffect(expressions, operation, getIndex, preserveOrder = false) {
25365
- const operations = [operation].flat();
25455
+ registerEffect(expressions, operation, getOrder, preserveOrder = false) {
25456
+ const operations = isArray$3(operation) ? operation : [operation];
25366
25457
  expressions = expressions.filter((exp) => !isConstantExpression(exp, this.root.options.bindingMetadata));
25367
25458
  const once = expressions.every((e) => isConstantBinding$1(e, this.root.options.bindingMetadata));
25368
25459
  const needsEffect = operations.some((op) => op.type === 4 && op.listeners);
@@ -25370,12 +25461,12 @@ var TransformContext = class TransformContext {
25370
25461
  this.registerOperation(...operations);
25371
25462
  return false;
25372
25463
  }
25373
- const index = getIndex ? getIndex() : this.block.effect.length;
25374
- this.block.effect.splice(index, 0, _objectSpread2({
25464
+ const effect = _objectSpread2({
25375
25465
  expressions,
25376
25466
  operations
25377
- }, once && !needsEffect ? { once: true } : {}));
25378
- if (getIndex) this.shiftEffectBoundaries(index);
25467
+ }, once && !needsEffect ? { once: true } : {});
25468
+ this.effectOrder.set(effect, getOrder ? getOrder() : this.allocateOrder());
25469
+ this.block.effect.push(effect);
25379
25470
  return true;
25380
25471
  }
25381
25472
  registerOperation(...node) {
@@ -25384,49 +25475,68 @@ var TransformContext = class TransformContext {
25384
25475
  effectBoundary() {
25385
25476
  return {
25386
25477
  operationIndex: this.operationIndex,
25387
- effectIndex: this.effectIndex
25478
+ effectIndex: this.order
25388
25479
  };
25389
25480
  }
25390
- create(node, index) {
25391
- let effectiveParent = this;
25392
- while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
25393
- const childInfo = this.getChildContextInfo();
25394
- const isLastEffectiveChild = childInfo.isLastEffectiveChild[index];
25395
- const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
25396
- const isSingleRoot = this.isSingleRootChild(childInfo);
25397
- return Object.assign(Object.create(TransformContext.prototype), this, {
25398
- node,
25399
- parent: this,
25400
- index,
25401
- inVOnce: this.inVOnce && !isComponentNode(this.node),
25402
- template: "",
25403
- templateRoot: false,
25404
- childrenTemplate: [],
25405
- templateIndexMap: this.templateIndexMap,
25406
- dynamic: newDynamic(),
25407
- effectIndex: this.block.effect.length,
25408
- operationIndex: this.block.operation.length,
25409
- effectiveParent,
25410
- isLastEffectiveChild,
25411
- isOnRightmostPath,
25412
- isSingleRoot,
25413
- templateCloseTags: this.templateCloseTags,
25414
- templateCloseBlocks: this.templateCloseBlocks
25415
- });
25481
+ finalizeBlock(block) {
25482
+ const { effect, operation } = block;
25483
+ const { effectOrder } = this;
25484
+ effect.sort((a, b) => effectOrder.get(a) - effectOrder.get(b));
25485
+ const modelElements = /* @__PURE__ */ new Set();
25486
+ for (const oper of operation) if (isVModelOperation(oper)) modelElements.add(oper.element);
25487
+ let operationIndexes;
25488
+ if (modelElements.size) {
25489
+ const immediate = [];
25490
+ const models = [];
25491
+ const listeners = [];
25492
+ operationIndexes = [];
25493
+ for (const oper of operation) {
25494
+ operationIndexes.push(immediate.length);
25495
+ (isVModelOperation(oper) ? models : isVModelListener(oper, modelElements) ? listeners : immediate).push(oper);
25496
+ }
25497
+ operationIndexes.push(immediate.length);
25498
+ operation.length = 0;
25499
+ operation.push(...immediate, ...models, ...listeners);
25500
+ block.deferredOperationIndex = immediate.length;
25501
+ const immediateEffects = [];
25502
+ const listenerEffects = [];
25503
+ for (const e of effect) (e.operations.every((oper) => isVModelListener(oper, modelElements)) ? listenerEffects : immediateEffects).push(e);
25504
+ effect.length = 0;
25505
+ effect.push(...immediateEffects, ...listenerEffects);
25506
+ block.deferredEffectIndex = immediateEffects.length;
25507
+ } else {
25508
+ block.deferredOperationIndex = operation.length;
25509
+ block.deferredEffectIndex = effect.length;
25510
+ }
25511
+ const resolveBoundaries = (dynamic) => {
25512
+ const oper = dynamic.operation;
25513
+ if (oper && isBlockOperation(oper) && oper.effectIndex !== void 0) {
25514
+ let lo = 0;
25515
+ let hi = block.deferredEffectIndex;
25516
+ while (lo < hi) {
25517
+ const mid = lo + hi >> 1;
25518
+ if (effectOrder.get(effect[mid]) < oper.effectIndex) lo = mid + 1;
25519
+ else hi = mid;
25520
+ }
25521
+ oper.effectIndex = lo;
25522
+ if (operationIndexes) oper.operationIndex = operationIndexes[oper.operationIndex];
25523
+ }
25524
+ for (const child of dynamic.children) resolveBoundaries(child);
25525
+ };
25526
+ resolveBoundaries(block.dynamic);
25416
25527
  }
25417
- shiftEffectBoundaries(index, dynamic = this.dynamic) {
25418
- const operation = dynamic.operation;
25419
- if (operation && isBlockOperation(operation) && operation.effectIndex !== void 0 && operation.effectIndex >= index) operation.effectIndex++;
25420
- for (const child of dynamic.children) this.shiftEffectBoundaries(index, child);
25528
+ create(node, index) {
25529
+ return new TransformContext(this.ir, node, EMPTY_OBJ, this, index);
25421
25530
  }
25422
25531
  getChildContextInfo() {
25423
25532
  const node = this.node;
25424
25533
  if (node.type !== 0 && node.type !== 1) return {
25425
25534
  node,
25426
25535
  hasSingleRootChild: true,
25536
+ hasSingleSlotRootChild: false,
25427
25537
  isLastEffectiveChild: []
25428
25538
  };
25429
- const cached = childContextInfoCache.get(this);
25539
+ const cached = this.childInfo;
25430
25540
  if (cached && cached.node === node) return cached;
25431
25541
  const { children } = node;
25432
25542
  const isLastEffectiveChild = new Array(children.length);
@@ -25435,18 +25545,29 @@ var TransformContext = class TransformContext {
25435
25545
  isLastEffectiveChild[i] = !hasFollowingEffectiveChild;
25436
25546
  if (!isComponentChild(children[i])) hasFollowingEffectiveChild = true;
25437
25547
  }
25548
+ const hasSingleRoot = hasSingleRootChild(children);
25438
25549
  const childInfo = {
25439
25550
  node,
25440
- hasSingleRootChild: hasSingleRootChild(children),
25551
+ hasSingleRootChild: hasSingleRoot,
25552
+ hasSingleSlotRootChild: node.type === 1 && node.tagType === 1 && !isBuiltInComponent(node.tag) && (children.some(isSlotTemplate) ? hasSingleRootChild(children.filter((child) => !isSlotTemplate(child))) : hasSingleRoot),
25441
25553
  isLastEffectiveChild
25442
25554
  };
25443
- childContextInfoCache.set(this, childInfo);
25555
+ this.childInfo = childInfo;
25444
25556
  return childInfo;
25445
25557
  }
25558
+ isSlotRootChild(childInfo) {
25559
+ const node = this.node;
25560
+ if (node.type !== 1) return false;
25561
+ if (node.tagType === 1) return childInfo.hasSingleSlotRootChild;
25562
+ return node.tagType === 3 && childInfo.hasSingleRootChild && (isSlotTemplate(node) || this.isSlotRoot && !findDir$1(node, "for"));
25563
+ }
25446
25564
  isSingleRootChild(childInfo) {
25447
- if (this.inVFor || !childInfo.hasSingleRootChild) return false;
25448
- if (this.node.type === 0) return true;
25449
- return this.node.type === 1 && (this.node.tagType === 3 || isTransitionNode(this.node) || isKeepAliveTag(this.node.tag)) && !!this.parent && this.isSingleRoot;
25565
+ if (!childInfo.hasSingleRootChild) return false;
25566
+ const node = this.node;
25567
+ if (node.type === 0) return true;
25568
+ if (node.type !== 1 || !this.parent) return false;
25569
+ if (node.tagType === 3) return this.isSingleRoot && !findDir$1(node, "for");
25570
+ return isTransitionNode(node) || isKeepAliveTag(node.tag);
25450
25571
  }
25451
25572
  };
25452
25573
  function hasSingleRootChild(children) {
@@ -25504,13 +25625,24 @@ function transform(node, options = {}) {
25504
25625
  component: /* @__PURE__ */ new Set(),
25505
25626
  directive: /* @__PURE__ */ new Set(),
25506
25627
  block: newBlock(node),
25507
- hasTemplateRef: false
25628
+ hasTemplateRef: false,
25629
+ reservedNames: collectReservedNames(options.bindingMetadata)
25508
25630
  };
25509
25631
  const context = new TransformContext(ir, node, options);
25510
25632
  transformNode(context);
25633
+ finalizeIfChains(context);
25634
+ context.finalizeBlock(ir.block);
25511
25635
  ir.node.imports = context.imports;
25636
+ ir.node.transformed = true;
25512
25637
  return ir;
25513
25638
  }
25639
+ function finalizeIfChains(context) {
25640
+ context.ifHeads.forEach((inVOnce, head) => {
25641
+ if (!isLongIfChain(head)) return;
25642
+ head.once = inVOnce;
25643
+ if (!inVOnce) head.index = context.nextIfIndex(Math.ceil((getIfChainLength(head) + 1) / 2));
25644
+ });
25645
+ }
25514
25646
  function transformNode(context) {
25515
25647
  let { node } = context;
25516
25648
  const { nodeTransforms } = context.options;
@@ -25583,7 +25715,7 @@ function isComponentNode(node) {
25583
25715
  * effects at a v-once site has them run once like compiled ones do.
25584
25716
  */
25585
25717
  function genOnce(call, context) {
25586
- return genCall(context.helper("withOnce"), ["() => ", ...call]);
25718
+ return genCall(context.helper("withOnce"), ["() => ", call]);
25587
25719
  }
25588
25720
  const IMPORT_EXP_START = "__IMPORT_EXP_START__";
25589
25721
  const IMPORT_EXP_END = "__IMPORT_EXP_END__";
@@ -25593,6 +25725,9 @@ const NEWLINE = Symbol(`newline`);
25593
25725
  const LF = Symbol(`line feed`);
25594
25726
  const INDENT_START = Symbol(`indent start`);
25595
25727
  const INDENT_END = Symbol(`indent end`);
25728
+ function isNestedFragments(frag) {
25729
+ return isArray$3(frag) && typeof frag[1] !== "number";
25730
+ }
25596
25731
  function buildCodeFragment(...frag) {
25597
25732
  return [
25598
25733
  frag,
@@ -25601,21 +25736,24 @@ function buildCodeFragment(...frag) {
25601
25736
  ];
25602
25737
  }
25603
25738
  function genMulti([left, right, seg, placeholder], ...frags) {
25604
- if (placeholder) {
25605
- while (frags.length > 0 && !frags[frags.length - 1]) frags.pop();
25606
- frags = frags.map((frag) => frag || placeholder);
25607
- } else frags = frags.filter(Boolean);
25608
- const frag = [];
25609
- push(left);
25610
- for (let [i, fn] of frags.entries()) {
25611
- push(fn);
25612
- if (i < frags.length - 1) push(seg);
25613
- }
25614
- push(right);
25739
+ const frag = [left];
25740
+ pushJoined(frag, frags, seg, placeholder);
25741
+ frag.push(right);
25615
25742
  return frag;
25616
- function push(fn) {
25617
- if (!isArray$3(fn)) fn = [fn];
25618
- frag.push(...fn);
25743
+ }
25744
+ function pushJoined(frag, frags, seg, placeholder) {
25745
+ let end = frags.length;
25746
+ if (placeholder) while (end > 0 && !frags[end - 1]) end--;
25747
+ let first = true;
25748
+ for (let i = 0; i < end; i++) {
25749
+ let fn = frags[i];
25750
+ if (!fn) {
25751
+ if (!placeholder) continue;
25752
+ fn = placeholder;
25753
+ }
25754
+ if (!first) frag.push(seg);
25755
+ frag.push(fn);
25756
+ first = false;
25619
25757
  }
25620
25758
  }
25621
25759
  const DELIMITERS_ARRAY = [
@@ -25656,12 +25794,12 @@ const DELIMITERS_OBJECT_NEWLINE = [
25656
25794
  ];
25657
25795
  function genCall(name, ...frags) {
25658
25796
  const hasPlaceholder = isArray$3(name);
25659
- return [hasPlaceholder ? name[0] : name, ...genMulti([
25660
- "(",
25661
- ")",
25662
- ", ",
25663
- hasPlaceholder ? name[1] : "null"
25664
- ], ...frags)];
25797
+ const fnName = hasPlaceholder ? name[0] : name;
25798
+ const placeholder = hasPlaceholder ? name[1] : "null";
25799
+ const frag = [fnName, "("];
25800
+ pushJoined(frag, frags, ", ", placeholder);
25801
+ frag.push(")");
25802
+ return frag;
25665
25803
  }
25666
25804
  function getParserOptions(plugins) {
25667
25805
  return { plugins: plugins ? plugins.some((plugin) => plugin === "typescript") ? plugins : [...plugins, "typescript"] : ["typescript"] };
@@ -25681,40 +25819,58 @@ function codeFragmentToString(code, context) {
25681
25819
  offset: 0
25682
25820
  };
25683
25821
  let indentLevel = 0;
25684
- for (let frag of code) {
25685
- if (!frag) continue;
25686
- if (frag === NEWLINE) frag = [`\n${` `.repeat(indentLevel)}`, 0];
25687
- else if (frag === INDENT_START) {
25688
- indentLevel++;
25689
- continue;
25690
- } else if (frag === INDENT_END) {
25691
- indentLevel--;
25692
- continue;
25693
- } else if (frag === LF) {
25694
- pos.line++;
25695
- pos.column = 0;
25696
- pos.offset++;
25697
- continue;
25698
- }
25699
- if (isString$1(frag)) frag = [frag];
25700
- let [code, newlineIndex = -2, loc, name] = frag;
25701
- codegen += code;
25702
- if (map) {
25703
- if (loc) addMapping(loc.start, name);
25704
- if (newlineIndex === -3) advancePositionWithMutation(pos, code);
25822
+ emit(code);
25823
+ return [codegen, map];
25824
+ function emit(code) {
25825
+ for (let frag of code) {
25826
+ if (!frag) continue;
25827
+ if (isNestedFragments(frag)) {
25828
+ emit(frag);
25829
+ continue;
25830
+ }
25831
+ let code;
25832
+ let newlineIndex = -2;
25833
+ let loc;
25834
+ let name;
25835
+ if (frag === NEWLINE) {
25836
+ code = `\n${` `.repeat(indentLevel)}`;
25837
+ newlineIndex = 0;
25838
+ } else if (frag === INDENT_START) {
25839
+ indentLevel++;
25840
+ continue;
25841
+ } else if (frag === INDENT_END) {
25842
+ indentLevel--;
25843
+ continue;
25844
+ } else if (frag === LF) {
25845
+ pos.line++;
25846
+ pos.column = 0;
25847
+ pos.offset++;
25848
+ continue;
25849
+ } else if (isString$1(frag)) code = frag;
25705
25850
  else {
25706
- pos.offset += code.length;
25707
- if (newlineIndex === -2) pos.column += code.length;
25851
+ const mapped = frag;
25852
+ code = mapped[0];
25853
+ newlineIndex = mapped[1];
25854
+ loc = mapped[2];
25855
+ name = mapped[3];
25856
+ }
25857
+ codegen += code;
25858
+ if (map) {
25859
+ if (loc) addMapping(loc.start, name);
25860
+ if (newlineIndex === -3) advancePositionWithMutation(pos, code);
25708
25861
  else {
25709
- if (newlineIndex === -1) newlineIndex = code.length - 1;
25710
- pos.line++;
25711
- pos.column = code.length - newlineIndex;
25862
+ pos.offset += code.length;
25863
+ if (newlineIndex === -2) pos.column += code.length;
25864
+ else {
25865
+ if (newlineIndex === -1) newlineIndex = code.length - 1;
25866
+ pos.line++;
25867
+ pos.column = code.length - newlineIndex;
25868
+ }
25712
25869
  }
25870
+ if (loc && loc !== locStub) addMapping(loc.end);
25713
25871
  }
25714
- if (loc && loc !== locStub) addMapping(loc.end);
25715
25872
  }
25716
25873
  }
25717
- return [codegen, map];
25718
25874
  function addMapping(loc, name = null) {
25719
25875
  const { _names, _mappings } = map;
25720
25876
  if (name !== null && !_names.has(name)) _names.add(name);
@@ -25737,7 +25893,7 @@ function genFlags(flags, names) {
25737
25893
  function genInsertNode({ parent, elements, anchor }, { helper }) {
25738
25894
  let element = elements.map((el) => `n${el}`).join(", ");
25739
25895
  if (elements.length > 1) element = `[${element}]`;
25740
- return [NEWLINE, ...genCall(helper("insert"), element, `n${parent}`, anchor === void 0 ? void 0 : `n${anchor}`)];
25896
+ return [NEWLINE, genCall(helper("insert"), element, `n${parent}`, anchor === void 0 ? void 0 : `n${anchor}`)];
25741
25897
  }
25742
25898
  //#endregion
25743
25899
  //#region packages/compiler-vapor/src/generators/expression.ts
@@ -25793,7 +25949,7 @@ function genExpression(node, context, assignment, asParams = false) {
25793
25949
  if (start < lastEnd) return;
25794
25950
  const leadingText = content.slice(lastEnd, start);
25795
25951
  if (leadingText.length) push([leadingText, -3]);
25796
- push(...genIdentifier(asParams ? id.name : source, context, {
25952
+ push(genIdentifier(asParams ? id.name : source, context, {
25797
25953
  start: advancePositionWithClone(node.loc.start, source, start),
25798
25954
  end: advancePositionWithClone(node.loc.start, source, end),
25799
25955
  source
@@ -25833,7 +25989,11 @@ function genIdentifier(raw, context, loc, assignment, id, parent, parentStack, s
25833
25989
  -2,
25834
25990
  loc
25835
25991
  ]];
25836
- } else return genExpression(replacement, context, assignment);
25992
+ } else {
25993
+ const exp = genExpression(replacement, context, assignment);
25994
+ if (parent && parent.type === "ObjectProperty" && parent.shorthand) return [`${name}: `, exp];
25995
+ return exp;
25996
+ }
25837
25997
  }
25838
25998
  let prefix;
25839
25999
  let type = bindingMetadata && bindingMetadata[raw];
@@ -25860,7 +26020,7 @@ function genIdentifier(raw, context, loc, assignment, id, parent, parentStack, s
25860
26020
  return [
25861
26021
  prefix,
25862
26022
  `${helper("isRef")}(${raw}) ? ${raw}.value ${operator} `,
25863
- ...genExpression(rightExp, context),
26023
+ genExpression(rightExp, context),
25864
26024
  ` : `,
25865
26025
  [
25866
26026
  raw,
@@ -26246,14 +26406,14 @@ function genDeclarations(declarations, context, shouldDeclare) {
26246
26406
  if (isIdentifier) {
26247
26407
  const varName = ids[name] = context.getUniqueLocalName(`_${name}`, varNames);
26248
26408
  if (shouldDeclare) push(`const `);
26249
- push(`${varName} = `, ...genExpression(value, context), NEWLINE);
26409
+ push(`${varName} = `, genExpression(value, context), NEWLINE);
26250
26410
  }
26251
26411
  });
26252
26412
  declarations.forEach(({ name, isIdentifier, value }) => {
26253
26413
  if (!isIdentifier) {
26254
26414
  const varName = context.getUniqueLocalName(`_${name}`, varNames);
26255
26415
  if (shouldDeclare) push(`const `);
26256
- push(`${varName} = `, ...context.withId(() => genExpression(value, context), ids), NEWLINE);
26416
+ push(`${varName} = `, context.withId(() => genExpression(value, context), ids), NEWLINE);
26257
26417
  ids[name] = varName;
26258
26418
  }
26259
26419
  });
@@ -26334,19 +26494,19 @@ function genSetEvent(oper, context) {
26334
26494
  if (!context.block.operation.some(isSameDelegateEvent)) return [
26335
26495
  NEWLINE,
26336
26496
  `n${element}.$evt${key.content} = `,
26337
- ...genDirectHandler()
26497
+ genDirectHandler()
26338
26498
  ];
26339
26499
  }
26340
26500
  const name = genName();
26341
26501
  const eventOptions = genEventOptions();
26342
- return [NEWLINE, ...genCall(helper(effect ? "onBinding" : delegate ? "delegate" : "on"), `n${element}`, name, genHandler(), eventOptions)];
26502
+ return [NEWLINE, genCall(helper(effect ? "onBinding" : delegate ? "delegate" : "on"), `n${element}`, name, genHandler(), eventOptions)];
26343
26503
  function genHandler() {
26344
26504
  return handler || (handler = genEventHandler(context, [value], modifiers, { hoisted: oper }));
26345
26505
  }
26346
26506
  function genInvoker() {
26347
26507
  return [
26348
26508
  `${helper("createInvoker")}(`,
26349
- ...genHandler(),
26509
+ genHandler(),
26350
26510
  `)`
26351
26511
  ];
26352
26512
  }
@@ -26360,13 +26520,13 @@ function genSetEvent(oper, context) {
26360
26520
  const replacement = JSON.stringify(keyOverride[1]);
26361
26521
  const wrapped = [
26362
26522
  "(",
26363
- ...expr,
26523
+ expr,
26364
26524
  ")"
26365
26525
  ];
26366
26526
  return [
26367
- ...wrapped,
26527
+ wrapped,
26368
26528
  ` === ${find} ? ${replacement} : `,
26369
- ...wrapped
26529
+ wrapped
26370
26530
  ];
26371
26531
  } else return genExpression(key, context);
26372
26532
  }
@@ -26381,15 +26541,14 @@ function genSetEvent(oper, context) {
26381
26541
  }
26382
26542
  function genSetDynamicEvents(oper, context) {
26383
26543
  const { helper } = context;
26384
- return [NEWLINE, ...genCall(helper("setDynamicEvents"), `n${oper.element}`, genExpression(oper.event, context))];
26544
+ return [NEWLINE, genCall(helper("setDynamicEvents"), `n${oper.element}`, genExpression(oper.event, context))];
26385
26545
  }
26386
- const hoistedHandlers = /* @__PURE__ */ new WeakMap();
26387
26546
  function genHoistedHandlers(effects, context) {
26388
26547
  const [frag, push] = buildCodeFragment();
26389
26548
  const declare = (node, key, values, modifiers) => {
26390
26549
  const name = getUniqueHandlerName(context, `_on_${key.content.replace(/-/g, "_")}`);
26391
- hoistedHandlers.set(node, name);
26392
- push(NEWLINE, `const ${name} = `, ...genEventHandler(context, values, modifiers));
26550
+ context.hoistedHandlers.set(node, name);
26551
+ push(NEWLINE, `const ${name} = `, genEventHandler(context, values, modifiers));
26393
26552
  };
26394
26553
  for (const { operations } of effects) for (const oper of operations) if (oper.type === 7) declare(oper, oper.key, [oper.value], oper.modifiers);
26395
26554
  else if (oper.type === 4) for (const props of oper.props) {
@@ -26406,7 +26565,7 @@ function genEventHandler(context, values, modifiers = {
26406
26565
  keys: []
26407
26566
  }, options = {}) {
26408
26567
  const { asComponentProp = false, extraWrap = false, modifierHelper = "runtime", hoisted } = options;
26409
- const hoistedName = hoisted && hoistedHandlers.get(hoisted);
26568
+ const hoistedName = hoisted && context.hoistedHandlers.get(hoisted);
26410
26569
  if (hoistedName) return [hoistedName];
26411
26570
  const useVaporModifierHelper = modifierHelper === "vapor";
26412
26571
  let handlerExp = [];
@@ -26421,7 +26580,7 @@ function genEventHandler(context, values, modifiers = {
26421
26580
  exp = [
26422
26581
  `e => `,
26423
26582
  isTSNode ? "(" : "",
26424
- ...exp,
26583
+ exp,
26425
26584
  isTSNode ? ")" : "",
26426
26585
  `(e)`
26427
26586
  ];
@@ -26434,16 +26593,16 @@ function genEventHandler(context, values, modifiers = {
26434
26593
  exp = [
26435
26594
  referencesEvent ? "$event => " : "() => ",
26436
26595
  hasMultipleStatements ? "{" : "(",
26437
- ...expr,
26596
+ expr,
26438
26597
  hasMultipleStatements ? "}" : ")"
26439
26598
  ];
26440
26599
  }
26441
- handlerExp = handlerExp.concat([index !== 0 ? ", " : "", ...exp]);
26600
+ handlerExp = handlerExp.concat([index !== 0 ? ", " : "", exp]);
26442
26601
  }
26443
26602
  });
26444
26603
  if (values.length > 1) handlerExp = [
26445
26604
  "[",
26446
- ...handlerExp,
26605
+ handlerExp,
26447
26606
  "]"
26448
26607
  ];
26449
26608
  }
@@ -26472,7 +26631,7 @@ function genFor(oper, context) {
26472
26631
  const { source, value, key, index, render, keyProp, once, id, component, onlyChild, slotRoot, wrappedRows } = oper;
26473
26632
  const sourceExpr = [
26474
26633
  "() => (",
26475
- ...genExpression(source, context),
26634
+ genExpression(source, context),
26476
26635
  ")"
26477
26636
  ];
26478
26637
  const plugins = context.options.expressionPlugins;
@@ -26501,23 +26660,23 @@ function genFor(oper, context) {
26501
26660
  const selectorName = (i) => selectorPatterns.length > 1 ? `_selector${id}_${i}` : `_selector${id}`;
26502
26661
  for (let i = 0; i < selectorPatterns.length; i++) {
26503
26662
  const { selector } = selectorPatterns[i];
26504
- selectorDeclarations.push(`const ${selectorName(i)} = `, ...genCall(helper("createSelector"), [`() => `, ...genExpression(selector, context)]), NEWLINE);
26663
+ selectorDeclarations.push(`const ${selectorName(i)} = `, genCall(helper("createSelector"), [`() => `, genExpression(selector, context)]), NEWLINE);
26505
26664
  }
26506
26665
  const blockFn = context.withId(() => {
26507
26666
  const frag = [];
26508
- frag.push("(", ...args, ") => {", INDENT_START);
26509
- if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(...genBlockContent(render, context, false, () => {
26667
+ frag.push("(", args, ") => {", INDENT_START);
26668
+ if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(genBlockContent(render, context, false, () => {
26510
26669
  const patternFrag = [];
26511
26670
  for (let i = 0; i < selectorPatterns.length; i++) {
26512
26671
  const { effect } = selectorPatterns[i];
26513
- patternFrag.push(NEWLINE, `${selectorName(i)}(`, ...genExpression(keyProp, context), `, () => {`, INDENT_START);
26514
- for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
26672
+ patternFrag.push(NEWLINE, `${selectorName(i)}(`, genExpression(keyProp, context), `, () => {`, INDENT_START);
26673
+ for (const oper of effect.operations) patternFrag.push(genOperation(oper, context));
26515
26674
  patternFrag.push(INDENT_END, NEWLINE, `})`);
26516
26675
  }
26517
- for (const { effect } of keyOnlyBindingPatterns) for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
26676
+ for (const { effect } of keyOnlyBindingPatterns) for (const oper of effect.operations) patternFrag.push(genOperation(oper, context));
26518
26677
  return patternFrag;
26519
26678
  }, skippedEffectIndexes));
26520
- else frag.push(...genBlockContent(render, context));
26679
+ else frag.push(genBlockContent(render, context));
26521
26680
  frag.push(INDENT_END, NEWLINE, "}");
26522
26681
  return frag;
26523
26682
  }, idMap);
@@ -26527,17 +26686,17 @@ function genFor(oper, context) {
26527
26686
  for (let i = 0; i < selectorPatterns.length; i++) onResetCalls.push(NEWLINE, `n${id}.onReset(${selectorName(i)}.reset)`);
26528
26687
  return [
26529
26688
  NEWLINE,
26530
- ...selectorDeclarations,
26689
+ selectorDeclarations,
26531
26690
  `const n${id} = `,
26532
- ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags),
26533
- ...onResetCalls
26691
+ genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags),
26692
+ onResetCalls
26534
26693
  ];
26535
26694
  function genCallback(expr) {
26536
26695
  if (!expr) return false;
26537
26696
  return context.withId(() => [
26538
- ...genAliasParams(value, key, index, context),
26697
+ genAliasParams(value, key, index, context),
26539
26698
  " => (",
26540
- ...genExpression(expr, context),
26699
+ genExpression(expr, context),
26541
26700
  ")"
26542
26701
  ], genSimpleIdMap());
26543
26702
  }
@@ -26592,7 +26751,7 @@ function isFragmentBlock(block) {
26592
26751
  const child = getSingleReturnedChild(block);
26593
26752
  const operation = child && child.operation;
26594
26753
  if (!operation) return false;
26595
- return operation.type === 13 || operation.type === 16 || operation.type === 17 || operation.type === 15 && !operation.once || operation.type === 12 && !!operation.dynamic && !operation.dynamic.isStatic;
26754
+ return operation.type === 13 || operation.type === 16 || operation.type === 17 || operation.type === 15 && !operation.once || operation.type === 12 && !operation.once && !!operation.dynamic && !operation.dynamic.isStatic;
26596
26755
  }
26597
26756
  function getSingleReturnedChild(block) {
26598
26757
  if (block.returns.length !== 1) return;
@@ -26745,10 +26904,8 @@ function matchSelectorPattern(effect, key, idMap, context) {
26745
26904
  if (typeof node === "object" && node && node.type === "BinaryExpression" && node.operator === "===" && node.left.type !== "PrivateName") {
26746
26905
  const { left, right } = node;
26747
26906
  for (const [a, b] of [[left, right], [right, left]]) {
26748
- const aIsKey = content.slice(a.start - 1, a.end - 1) === key;
26749
- const bIsKey = isKeyOnlyBinding(b, key, content);
26750
- const bVars = analyzeVariableScopes(b, idMap);
26751
- if (aIsKey && !bIsKey && !bVars.length) matcheds.push([a, b]);
26907
+ if (content.slice(a.start - 1, a.end - 1) !== key) continue;
26908
+ if (!isKeyOnlyBinding(b, key, content) && !analyzeVariableScopes(b, idMap).length) matcheds.push([a, b]);
26752
26909
  }
26753
26910
  }
26754
26911
  } });
@@ -26800,28 +26957,29 @@ function isKeyOnlyBinding(expr, key, source) {
26800
26957
  function genSetHtml(oper, context) {
26801
26958
  const { helper } = context;
26802
26959
  const { value, element } = oper;
26803
- return [NEWLINE, ...genCall(helper("setHtml"), `n${element}`, genExpression(value, context))];
26960
+ return [NEWLINE, genCall(helper("setHtml"), `n${element}`, genExpression(value, context))];
26804
26961
  }
26805
26962
  //#endregion
26806
26963
  //#region packages/compiler-vapor/src/generators/if.ts
26807
26964
  function genIf(oper, context, isNested = false) {
26965
+ if (!isNested && isLongIfChain(oper)) return genIfChain(oper, context);
26808
26966
  const { helper } = context;
26809
26967
  const { condition, positive, negative, once, slotRoot, index, blockShape } = oper;
26810
26968
  const [frag, push] = buildCodeFragment();
26811
26969
  const flags = genIfFlags(blockShape, once, slotRoot, negative ? index : void 0);
26812
26970
  const conditionExpr = [
26813
26971
  "() => (",
26814
- ...genExpression(condition, context),
26972
+ genExpression(condition, context),
26815
26973
  ")"
26816
26974
  ];
26817
26975
  let positiveArg = genBlock(positive, context);
26818
26976
  let negativeArg = false;
26819
26977
  if (negative) {
26820
26978
  if (negative.type === 1) negativeArg = genBlock(negative, context);
26821
- else negativeArg = ["() => ", ...genIf(negative, context, true)];
26979
+ else negativeArg = ["() => ", genIf(negative, context, true)];
26822
26980
  }
26823
26981
  if (!isNested) push(NEWLINE, `const n${oper.id} = `);
26824
- push(...genCall(helper("createIf"), conditionExpr, positiveArg, negativeArg, flags));
26982
+ push(genCall(helper("createIf"), conditionExpr, positiveArg, negativeArg, flags));
26825
26983
  return frag;
26826
26984
  }
26827
26985
  function genIfFlags(blockShape, once, slotRoot, index) {
@@ -26849,9 +27007,61 @@ function genBlockShapeName(flags) {
26849
27007
  case 0: return "EMPTY";
26850
27008
  case 1: return "SINGLE_ROOT";
26851
27009
  case 2: return "MULTI_ROOT";
27010
+ case 3: return "ELSE_IF";
26852
27011
  }
26853
27012
  return "UNKNOWN";
26854
27013
  }
27014
+ function genIfChain(oper, context) {
27015
+ const { helper } = context;
27016
+ const [frag, push] = buildCodeFragment();
27017
+ const selector = ["() => ", INDENT_START];
27018
+ const blocks = [];
27019
+ const branchFlags = [];
27020
+ let slotRoot = false;
27021
+ let node = oper;
27022
+ for (let i = 0;; i++) {
27023
+ if (i > 0) selector.push(NEWLINE, ": ");
27024
+ selector.push("(", genExpression(node.condition, context), `) ? ${i}`);
27025
+ blocks.push(genBlock(node.positive, context));
27026
+ branchFlags.push(node.blockShape & 35);
27027
+ if (node.slotRoot) slotRoot = true;
27028
+ const { negative } = node;
27029
+ if (negative && negative.type === 15) {
27030
+ node = negative;
27031
+ continue;
27032
+ }
27033
+ selector.push(NEWLINE, `: ${i + 1}`, INDENT_END);
27034
+ if (negative) blocks.push(genBlock(negative, context));
27035
+ branchFlags.push(node.blockShape >> 2 & 3 | (node.blockShape & 64 ? 32 : 0));
27036
+ break;
27037
+ }
27038
+ push(NEWLINE, `const n${oper.id} = `, genCall(helper("createIfChain"), selector, genMulti(DELIMITERS_ARRAY, ...blocks), genIfChainBranchFlags(branchFlags, blocks.length), genIfChainFlags(oper.once, slotRoot, oper.index)));
27039
+ return frag;
27040
+ }
27041
+ function genIfChainBranchFlags(branchFlags, blockCount) {
27042
+ if (branchFlags.every((flags, i) => flags === (i < blockCount ? 1 : 0))) return false;
27043
+ return genMulti(DELIMITERS_ARRAY, ...branchFlags.map((flags) => {
27044
+ const names = [genBlockShapeName(flags)];
27045
+ if (flags & 32) names.push("NO_SCOPE");
27046
+ return genFlags(flags, names);
27047
+ }));
27048
+ }
27049
+ function genIfChainFlags(once, slotRoot, index) {
27050
+ let flags = 0;
27051
+ const names = [];
27052
+ if (once) {
27053
+ flags |= 16;
27054
+ names.push("ONCE");
27055
+ } else {
27056
+ flags |= index + 1 << 8;
27057
+ names.push(`KEYED_INDEX_${index}`);
27058
+ }
27059
+ if (slotRoot) {
27060
+ flags |= 128;
27061
+ names.push("SLOT_ROOT");
27062
+ }
27063
+ return genFlags(flags, names);
27064
+ }
26855
27065
  //#endregion
26856
27066
  //#region packages/compiler-vapor/src/generators/prop.ts
26857
27067
  const helpers = {
@@ -26885,7 +27095,7 @@ function genSetProp(oper, context) {
26885
27095
  }
26886
27096
  const propValue = genPropValue(values, context);
26887
27097
  const call = genCall([helper(resolvedHelper.name), null], `n${oper.element}`, resolvedHelper.needKey ? genExpression(key, context) : false, propValue, resolvedHelper.isSVG && "true");
26888
- return [NEWLINE, ...oper.once ? genOnce(call, context) : call];
27098
+ return [NEWLINE, oper.once ? genOnce(call, context) : call];
26889
27099
  }
26890
27100
  const optionsModifierRE = /(Once|Passive|Capture)$/;
26891
27101
  const optionsModifierEventRE = /^on:?(?:Once|Passive|Capture)$/;
@@ -26893,7 +27103,7 @@ function genSetListener(oper, context) {
26893
27103
  const { helper } = context;
26894
27104
  const { element, effect, prop } = oper;
26895
27105
  const value = genPropValue(prop.values, context);
26896
- if (effect) return [NEWLINE, ...genCall(helper("setListener"), `n${element}`, JSON.stringify(prop.key.content), value)];
27106
+ if (effect) return [NEWLINE, genCall(helper("setListener"), `n${element}`, JSON.stringify(prop.key.content), value)];
26897
27107
  let name = prop.key.content;
26898
27108
  const options = [];
26899
27109
  let m;
@@ -26902,7 +27112,7 @@ function genSetListener(oper, context) {
26902
27112
  options.push([`${m[1].toLowerCase()}: true`]);
26903
27113
  }
26904
27114
  const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
26905
- return [NEWLINE, ...genCall(helper("on"), `n${element}`, JSON.stringify(event), value, options.length ? genMulti(DELIMITERS_OBJECT, ...options) : void 0)];
27115
+ return [NEWLINE, genCall(helper("on"), `n${element}`, JSON.stringify(event), value, options.length ? genMulti(DELIMITERS_OBJECT, ...options) : void 0)];
26906
27116
  }
26907
27117
  const MAX_CLASS_NAME_ENTRIES = 31;
26908
27118
  function genSetClassName(oper, context) {
@@ -26912,7 +27122,7 @@ function genSetClassName(oper, context) {
26912
27122
  const flags = genClassFlags(info.entries, context);
26913
27123
  const classFragments = info.entries.map((entry) => JSON.stringify(!info.prefix && info.entries.length === 1 ? entry.className : ` ${entry.className}`));
26914
27124
  const fragments = classFragments.length === 1 ? classFragments[0] : genMulti(DELIMITERS_ARRAY, ...classFragments);
26915
- return [NEWLINE, ...genCall([helper("setClassName"), "\"\""], `n${oper.element}`, flags, fragments, info.prefix && JSON.stringify(info.prefix), info.suffix && JSON.stringify(info.suffix))];
27125
+ return [NEWLINE, genCall([helper("setClassName"), "\"\""], `n${oper.element}`, flags, fragments, info.prefix && JSON.stringify(info.prefix), info.suffix && JSON.stringify(info.suffix))];
26916
27126
  }
26917
27127
  function resolveClassName(values, context) {
26918
27128
  let prefix = "";
@@ -26993,7 +27203,7 @@ function genClassFlags(entries, context) {
26993
27203
  values.push(entry.value ? String(bit) : "0");
26994
27204
  return;
26995
27205
  }
26996
- values.push("((", ...genExpression(entry.condition, context), ")", entry.negate ? ` ? 0 : ${bit}` : ` ? ${bit} : 0`, ")");
27206
+ values.push("((", genExpression(entry.condition, context), ")", entry.negate ? ` ? 0 : ${bit}` : ` ? ${bit} : 0`, ")");
26997
27207
  });
26998
27208
  return values;
26999
27209
  }
@@ -27035,10 +27245,10 @@ function genDynamicProps$1(oper, context) {
27035
27245
  return props.handler ? genCall(helper("toHandlers"), value, "true") : value;
27036
27246
  });
27037
27247
  const call = genCall(helper("setDynamicProps"), `n${oper.element}`, genMulti(DELIMITERS_ARRAY, ...values), genDynamicPropNames$1(oper, context), oper.isSVG && "true");
27038
- return [NEWLINE, ...oper.once ? genOnce(call, context) : call];
27248
+ return [NEWLINE, oper.once ? genOnce(call, context) : call];
27039
27249
  }
27040
27250
  function genSyncSelectValue(oper, context) {
27041
- return [NEWLINE, ...genCall(context.helper("syncSelectValue"), `n${oper.element}`, genDynamicPropNames$1(oper, context))];
27251
+ return [NEWLINE, genCall(context.helper("syncSelectValue"), `n${oper.element}`, genDynamicPropNames$1(oper, context))];
27042
27252
  }
27043
27253
  function genDynamicPropNames$1(oper, context) {
27044
27254
  const { bindingMetadata } = context.options;
@@ -27049,14 +27259,17 @@ function genDynamicPropNames$1(oper, context) {
27049
27259
  if (!id) context.dynamicPropNames.set(json, id = context.kName(context.dynamicPropNames.size));
27050
27260
  return id;
27051
27261
  }
27052
- function genLiteralObjectProps(props, context) {
27262
+ function genLiteralObjectProps(props, context, isComponent = false) {
27053
27263
  const entries = [];
27054
27264
  const listeners = createHandlerGroups(entries);
27055
- for (const prop of props) if (isListenerProp(prop)) listeners.add(getStaticPropKeyName(prop, true), genPropKey(prop, context, true), prop.handler ? genEventHandler(context, prop.values, prop.handlerModifiers, { hoisted: prop }) : genPropValue(prop.values, context));
27265
+ for (const prop of props) if (isListenerProp(prop)) listeners.add(getStaticPropKeyName(prop, !isComponent), genPropKey(prop, context, !isComponent), prop.handler ? genEventHandler(context, prop.values, prop.handlerModifiers, {
27266
+ hoisted: prop,
27267
+ asComponentProp: isComponent
27268
+ }) : genPropValue(prop.values, context));
27056
27269
  else entries.push([
27057
- ...genPropKey(prop, context),
27270
+ genPropKey(prop, context),
27058
27271
  `: `,
27059
- ...genPropValue(prop.values, context)
27272
+ genPropValue(prop.values, context)
27060
27273
  ]);
27061
27274
  listeners.fill();
27062
27275
  return genMulti(DELIMITERS_OBJECT, ...entries);
@@ -27081,10 +27294,10 @@ function createHandlerGroups(entries, prefix = "", delimiters = DELIMITERS_ARRAY
27081
27294
  },
27082
27295
  fill() {
27083
27296
  for (const { keyFrag, handlers, index } of groups.values()) entries[index] = [
27084
- ...keyFrag,
27297
+ keyFrag,
27085
27298
  ": ",
27086
27299
  prefix,
27087
- ...handlers.length > 1 ? genMulti(delimiters, ...handlers) : handlers[0]
27300
+ handlers.length > 1 ? genMulti(delimiters, ...handlers) : handlers[0]
27088
27301
  ];
27089
27302
  }
27090
27303
  };
@@ -27113,20 +27326,20 @@ function genPropKey(prop, context, preserveCase = false) {
27113
27326
  key = genCall(helper("camelize"), key);
27114
27327
  } else if (modifier) key = [
27115
27328
  "(",
27116
- ...key,
27329
+ key,
27117
27330
  " || \"\"",
27118
27331
  ")"
27119
27332
  ];
27120
- else if (!handler && !model) key = node.ast === null ? [...key, " || \"\""] : [
27333
+ else if (!handler && !model) key = node.ast === null ? [key, " || \"\""] : [
27121
27334
  "(",
27122
- ...key,
27335
+ key,
27123
27336
  ") || \"\""
27124
27337
  ];
27125
27338
  if (handler) key = genCall(helper("toHandlerKey"), key);
27126
27339
  return [
27127
27340
  "[",
27128
27341
  modifier && `${JSON.stringify(modifier)} + `,
27129
- ...key,
27342
+ key,
27130
27343
  handlerModifierPostfix ? ` + ${JSON.stringify(handlerModifierPostfix)}` : void 0,
27131
27344
  "]"
27132
27345
  ];
@@ -27162,14 +27375,14 @@ function genSetTemplateRef(oper, context) {
27162
27375
  const [refValue, refKey] = genRefValue(oper.value, context);
27163
27376
  if (!oper.effect && !oper.refFor && oper.value.isStatic) return genSetStaticTemplateRef(oper, refValue, refKey, context);
27164
27377
  context.needsTemplateRefSetter = true;
27165
- return [NEWLINE, ...genCall(setTemplateRefIdent, `n${oper.element}`, refValue, oper.refFor && "true", refKey)];
27378
+ return [NEWLINE, genCall(setTemplateRefIdent, `n${oper.element}`, refValue, oper.refFor && "true", refKey)];
27166
27379
  }
27167
27380
  function genSetStaticTemplateRef(oper, refValue, refKey, context) {
27168
- return [NEWLINE, ...genCall(context.helper("setStaticTemplateRef"), `n${oper.element}`, refValue, oper.refFor && "true", refKey)];
27381
+ return [NEWLINE, genCall(context.helper("setStaticTemplateRef"), `n${oper.element}`, refValue, oper.refFor && "true", refKey)];
27169
27382
  }
27170
27383
  function genSetTemplateRefBinding(oper, context) {
27171
27384
  const [refValue, refKey] = genRefValue(oper.value, context);
27172
- return [NEWLINE, ...genCall([context.helper("setTemplateRefBinding"), "undefined"], `n${oper.element}`, ["() => ", ...refValue], ...oper.refFor || refKey ? [oper.refFor && "true", refKey] : [])];
27385
+ return [NEWLINE, genCall([context.helper("setTemplateRefBinding"), "undefined"], `n${oper.element}`, ["() => ", refValue], ...oper.refFor || refKey ? [oper.refFor && "true", refKey] : [])];
27173
27386
  }
27174
27387
  function genRefValue(value, context) {
27175
27388
  if (value && context.options.inline) {
@@ -27184,7 +27397,7 @@ function genSetText(oper, context) {
27184
27397
  const { helper } = context;
27185
27398
  const { element, values, generated } = oper;
27186
27399
  const texts = combineValues(values, context);
27187
- return [NEWLINE, ...genCall(helper("setText"), `${generated ? "x" : "n"}${element}`, texts)];
27400
+ return [NEWLINE, genCall(helper("setText"), `${generated ? "x" : "n"}${element}`, texts)];
27188
27401
  }
27189
27402
  function combineValues(values, context) {
27190
27403
  return values.flatMap((value, i) => {
@@ -27215,14 +27428,14 @@ function genVModel(oper, context) {
27215
27428
  const { modelType, element, dir: { exp, modifiers } } = oper;
27216
27429
  return genCall(context.helper(helperMap[modelType]), `n${element}`, [
27217
27430
  `() => (`,
27218
- ...genExpression(exp, context),
27431
+ genExpression(exp, context),
27219
27432
  `)`
27220
27433
  ], genModelHandler(exp, context), modifiers.length ? `{ ${genDirectiveModifiers(modifiers.map((e) => e.content))} }` : void 0);
27221
27434
  }
27222
27435
  function genModelHandler(exp, context) {
27223
27436
  return [
27224
27437
  `${context.options.isTS ? `(_value: any)` : `_value`} => (`,
27225
- ...genExpression(exp, context, "_value"),
27438
+ genExpression(exp, context, "_value"),
27226
27439
  ")"
27227
27440
  ];
27228
27441
  }
@@ -27251,22 +27464,22 @@ function genCreateComponent(operation, context) {
27251
27464
  return [
27252
27465
  ...acc,
27253
27466
  `const ${name} = `,
27254
- ...handler,
27467
+ handler,
27255
27468
  NEWLINE
27256
27469
  ];
27257
27470
  }, []);
27258
27471
  return [
27259
27472
  NEWLINE,
27260
- ...inlineHandlers,
27261
- ...slotDeclarations.length ? genMulti([
27473
+ inlineHandlers,
27474
+ slotDeclarations.length ? genMulti([
27262
27475
  "let ",
27263
27476
  NEWLINE,
27264
27477
  ", "
27265
27478
  ], ...slotDeclarations) : [],
27266
27479
  `const n${operation.id} = `,
27267
- ...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags : root ? "true" : false, isRuntimeDynamicComponent ? operation.key && [
27480
+ genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags : root && (root === true ? "true" : genFlags(root, ["SLOT"])), isRuntimeDynamicComponent ? operation.key && [
27268
27481
  "() => (",
27269
- ...genExpression(operation.key, context),
27482
+ genExpression(operation.key, context),
27270
27483
  ")"
27271
27484
  ] : once && "true", useAssetComponentHelper ? maybeSelfReference && "true" : nsArg, useAssetComponentHelper && nsArg)
27272
27485
  ];
@@ -27276,7 +27489,7 @@ function genCreateComponent(operation, context) {
27276
27489
  if (operation.dynamic.isStatic) return genCall(helper("resolveDynamicComponent"), genExpression(operation.dynamic, context));
27277
27490
  else return [
27278
27491
  "() => (",
27279
- ...genExpression(operation.dynamic, context),
27492
+ genExpression(operation.dynamic, context),
27280
27493
  ")"
27281
27494
  ];
27282
27495
  } else if (useAssetComponentHelper) {
@@ -27284,22 +27497,25 @@ function genCreateComponent(operation, context) {
27284
27497
  return JSON.stringify(name);
27285
27498
  } else if (operation.asset) return toValidAssetId(operation.tag, "component");
27286
27499
  else {
27287
- const { tag, slotScopeNamespace } = operation;
27500
+ const { tag } = operation;
27288
27501
  const builtInTag = isBuiltInComponent(tag);
27289
27502
  if (builtInTag) {
27290
27503
  helper(builtInTag);
27291
27504
  return `_${builtInTag}`;
27292
27505
  }
27293
- return [...genExpression(extend(createSimpleExpression(slotScopeNamespace || tag, false), { ast: null }), context), slotScopeNamespace && tag.slice(slotScopeNamespace.length)];
27506
+ return genExpression(extend(createSimpleExpression(tag, false), { ast: null }), context);
27294
27507
  }
27295
27508
  }
27296
27509
  }
27297
27510
  function genDynamicComponentFlags(root, once, slotRoot, ns) {
27298
27511
  let flags = 0;
27299
27512
  const names = [];
27300
- if (root) {
27513
+ if (root === true) {
27301
27514
  flags |= 1;
27302
27515
  names.push("SINGLE_ROOT");
27516
+ } else if (root) {
27517
+ flags |= 32;
27518
+ names.push("SLOT_SINGLE_ROOT");
27303
27519
  }
27304
27520
  if (once) {
27305
27521
  flags |= 2;
@@ -27361,7 +27577,7 @@ function genStaticProps(props, context, dynamicProps, directStaticLiteralProps =
27361
27577
  if (!prop.handler) {
27362
27578
  handlerGroups.add(keyName, keyFrag, [
27363
27579
  "(",
27364
- ...genPropValue(prop.values, context),
27580
+ genPropValue(prop.values, context),
27365
27581
  ")"
27366
27582
  ]);
27367
27583
  continue;
@@ -27384,29 +27600,29 @@ function genStaticProps(props, context, dynamicProps, directStaticLiteralProps =
27384
27600
  } else {
27385
27601
  const keyFrag = [
27386
27602
  "[\"onUpdate:\" + ",
27387
- ...genExpression(prop.key, context),
27603
+ genExpression(prop.key, context),
27388
27604
  "]"
27389
27605
  ];
27390
27606
  args.push([
27391
- ...keyFrag,
27607
+ keyFrag,
27392
27608
  ": () => ",
27393
- ...genModelHandler(prop.values[0], context)
27609
+ genModelHandler(prop.values[0], context)
27394
27610
  ]);
27395
27611
  }
27396
27612
  const { key, modelModifiers } = prop;
27397
27613
  if (modelModifiers && modelModifiers.length) {
27398
27614
  const modifiersKey = key.isStatic ? genStaticModifierPropKey(key.content) : [
27399
27615
  "[",
27400
- ...genExpression(key, context),
27616
+ genExpression(key, context),
27401
27617
  " + \"Modifiers\"]"
27402
27618
  ];
27403
27619
  const modifiersVal = genDirectiveModifiers(modelModifiers);
27404
- args.push([...modifiersKey, directStaticLiteralProps ? `: { ${modifiersVal} }` : `: () => ({ ${modifiersVal} })`]);
27620
+ args.push([modifiersKey, directStaticLiteralProps ? `: { ${modifiersVal} }` : `: () => ({ ${modifiersVal} })`]);
27405
27621
  }
27406
27622
  }
27407
27623
  }
27408
27624
  handlerGroups.fill();
27409
- if (dynamicProps) args.push([`$: `, ...dynamicProps]);
27625
+ if (dynamicProps) args.push([`$: `, dynamicProps]);
27410
27626
  return genMulti(args.length > 1 ? DELIMITERS_OBJECT_NEWLINE : DELIMITERS_OBJECT, ...args);
27411
27627
  }
27412
27628
  function genDynamicProps(props, context, directStaticLiteralProps = false) {
@@ -27422,23 +27638,23 @@ function genDynamicProps(props, context, directStaticLiteralProps = false) {
27422
27638
  const entries = [genProp(p, context)];
27423
27639
  const updateKey = p.key.isStatic ? [JSON.stringify(`onUpdate:${camelize(p.key.content)}`)] : [
27424
27640
  "[\"onUpdate:\" + ",
27425
- ...genExpression(p.key, context),
27641
+ genExpression(p.key, context),
27426
27642
  "]"
27427
27643
  ];
27428
27644
  entries.push([
27429
- ...updateKey,
27645
+ updateKey,
27430
27646
  ": ",
27431
- ...genModelHandler(p.values[0], context)
27647
+ genModelHandler(p.values[0], context)
27432
27648
  ]);
27433
27649
  const { modelModifiers } = p;
27434
27650
  if (modelModifiers && modelModifiers.length) {
27435
27651
  const modifiersKey = p.key.isStatic ? genStaticModifierPropKey(p.key.content) : [
27436
27652
  "[",
27437
- ...genExpression(p.key, context),
27653
+ genExpression(p.key, context),
27438
27654
  " + \"Modifiers\"]"
27439
27655
  ];
27440
27656
  const modifiersVal = genDirectiveModifiers(modelModifiers);
27441
- entries.push([...modifiersKey, `: { ${modifiersVal} }`]);
27657
+ entries.push([modifiersKey, `: { ${modifiersVal} }`]);
27442
27658
  }
27443
27659
  expr = genMulti(DELIMITERS_OBJECT_NEWLINE, ...entries);
27444
27660
  } else expr = genMulti(DELIMITERS_OBJECT, genProp(p, context, false, false));
@@ -27448,7 +27664,7 @@ function genDynamicProps(props, context, directStaticLiteralProps = false) {
27448
27664
  }
27449
27665
  frags.push([
27450
27666
  "() => (",
27451
- ...expr,
27667
+ expr,
27452
27668
  ")"
27453
27669
  ]);
27454
27670
  }
@@ -27456,16 +27672,17 @@ function genDynamicProps(props, context, directStaticLiteralProps = false) {
27456
27672
  }
27457
27673
  function genProp(prop, context, isStatic, wrapHandler = true, directStaticLiteral = false) {
27458
27674
  let values = genPropValue(prop.values, context);
27675
+ if (prop.normalize) values = genCall(context.helper(prop.normalize === "class" ? "normalizeClass" : "normalizeStyle"), values);
27459
27676
  if (prop.toDisplayString) values = genCall(context.helper("toDisplayString"), values);
27460
27677
  return [
27461
- ...genPropKey(prop, context),
27678
+ genPropKey(prop, context),
27462
27679
  ": ",
27463
- ...prop.handler ? genEventHandler(context, prop.values, prop.handlerModifiers, {
27680
+ prop.handler ? genEventHandler(context, prop.values, prop.handlerModifiers, {
27464
27681
  asComponentProp: true,
27465
27682
  extraWrap: wrapHandler
27466
27683
  }) : isStatic ? directStaticLiteral ? values : [
27467
27684
  "() => (",
27468
- ...values,
27685
+ values,
27469
27686
  ")"
27470
27687
  ] : values
27471
27688
  ];
@@ -27533,8 +27750,8 @@ function getSingleDefaultSlot({ slots }) {
27533
27750
  return names.length === 1 && names[0] === "default" ? slots.default : void 0;
27534
27751
  }
27535
27752
  function genStaticSlots({ slots }, context, slotDeclarations, dynamicSlots) {
27536
- const args = Object.keys(slots).map((name) => [`${JSON.stringify(name)}: `, ...genSlotBlockWithProps(slots[name], context)]);
27537
- if (dynamicSlots) args.push([`$: `, ...genDynamicSlots(dynamicSlots, context, slotDeclarations)]);
27753
+ const args = Object.keys(slots).map((name) => [`${JSON.stringify(name)}: `, genSlotBlockWithProps(slots[name], context)]);
27754
+ if (dynamicSlots) args.push([`$: `, genDynamicSlots(dynamicSlots, context, slotDeclarations)]);
27538
27755
  return genMulti(DELIMITERS_OBJECT_NEWLINE, ...args);
27539
27756
  }
27540
27757
  function genDynamicSlots(slots, context, slotDeclarations) {
@@ -27554,7 +27771,7 @@ function genDynamicSlot(slot, context, slotDeclarations, withFunction = false) {
27554
27771
  if (!withFunction) return frag;
27555
27772
  return [
27556
27773
  "() => (",
27557
- ...frag,
27774
+ frag,
27558
27775
  ")"
27559
27776
  ];
27560
27777
  }
@@ -27562,9 +27779,9 @@ function genBasicDynamicSlot(slot, context, slotDeclarations) {
27562
27779
  const { name, fn } = slot;
27563
27780
  const slotName = context.getUniqueLocalName("s");
27564
27781
  slotDeclarations.push(slotName);
27565
- return genMulti(DELIMITERS_OBJECT_NEWLINE, ["name: ", ...genExpression(name, context)], [
27782
+ return genMulti(DELIMITERS_OBJECT_NEWLINE, ["name: ", genExpression(name, context)], [
27566
27783
  `fn: ${slotName} || (${slotName} = `,
27567
- ...genSlotBlockWithProps(fn, context, false),
27784
+ genSlotBlockWithProps(fn, context, false),
27568
27785
  ")"
27569
27786
  ]);
27570
27787
  }
@@ -27593,13 +27810,13 @@ function genLoopSlot(slot, context) {
27593
27810
  idMap[indexVar] = null;
27594
27811
  }
27595
27812
  const renderSlot = [
27596
- ...genMulti([
27813
+ genMulti([
27597
27814
  "(",
27598
27815
  ")",
27599
27816
  ", "
27600
27817
  ], ...args),
27601
27818
  " => ",
27602
- ...context.withId(() => genSlotBlockWithProps(fn, context, false), idMap)
27819
+ context.withId(() => genSlotBlockWithProps(fn, context, false), idMap)
27603
27820
  ];
27604
27821
  exitScope();
27605
27822
  const rawIdMap = {};
@@ -27609,34 +27826,34 @@ function genLoopSlot(slot, context) {
27609
27826
  collect(indexToPathMap);
27610
27827
  const rawParams = context.withId(() => genAliasParams(value, key, index, context), rawIdMap);
27611
27828
  const getName = [
27612
- ...rawParams,
27829
+ rawParams,
27613
27830
  " => (",
27614
- ...context.withId(() => genExpression(name, context), rawIdMap),
27831
+ context.withId(() => genExpression(name, context), rawIdMap),
27615
27832
  ")"
27616
27833
  ];
27617
27834
  const getKey = keyProp && [
27618
- ...rawParams,
27835
+ rawParams,
27619
27836
  " => (",
27620
- ...context.withId(() => genExpression(keyProp, context), rawIdMap),
27837
+ context.withId(() => genExpression(keyProp, context), rawIdMap),
27621
27838
  ")"
27622
27839
  ];
27623
- return [...genCall(context.helper("createForSlots"), [
27840
+ return [genCall(context.helper("createForSlots"), [
27624
27841
  "() => (",
27625
- ...genExpression(source, context),
27842
+ genExpression(source, context),
27626
27843
  ")"
27627
27844
  ], renderSlot, getName, getKey)];
27628
27845
  }
27629
27846
  function genConditionalSlot(slot, context, slotDeclarations) {
27630
27847
  const { condition, positive, negative } = slot;
27631
27848
  return [
27632
- ...genExpression(condition, context),
27849
+ genExpression(condition, context),
27633
27850
  INDENT_START,
27634
27851
  NEWLINE,
27635
27852
  "? ",
27636
- ...genDynamicSlot(positive, context, slotDeclarations),
27853
+ genDynamicSlot(positive, context, slotDeclarations),
27637
27854
  NEWLINE,
27638
27855
  ": ",
27639
- ...negative ? genDynamicSlot(negative, context, slotDeclarations) : ["void 0"],
27856
+ negative ? genDynamicSlot(negative, context, slotDeclarations) : ["void 0"],
27640
27857
  INDENT_END
27641
27858
  ];
27642
27859
  }
@@ -27655,8 +27872,7 @@ function genSlotBlockWithProps(oper, context, emitNonStableFlag = true) {
27655
27872
  const idMap = idToPathMap.size ? buildDestructureIdMap(idToPathMap, propsName || "", context.options.expressionPlugins) : {};
27656
27873
  if (propsName) idMap[propsName] = null;
27657
27874
  const exitSlotBlock = context.enterSlotBlock();
27658
- const hasStableRoot = hasStableSlotRoot(oper, context);
27659
- if (!hasStableRoot) markSlotRootOperations(oper, context);
27875
+ const hasStableRoot = markSlotRootOperations(oper, context);
27660
27876
  let blockFn = context.withId(() => genBlock(oper, context, propsName ? [propsName] : []), idMap);
27661
27877
  if (emitNonStableFlag && !hasStableRoot) blockFn = genCall(context.helper("extend"), blockFn, [`{ _: ${genFlags(1, ["NON_STABLE"])} }`]);
27662
27878
  exitSlotBlock();
@@ -27675,15 +27891,36 @@ function genSlotOutlet(oper, context) {
27675
27891
  fallbackArg = genBlock(fallback, context);
27676
27892
  }
27677
27893
  const createSlot = helper("createSlot");
27678
- const rawPropsArg = genRawProps(oper.props, context, true);
27894
+ const rawPropsArg = genSlotProps(oper.props, context);
27679
27895
  const nameArg = name.isStatic && name.content === "default" && !rawPropsArg && !fallbackArg && !flags ? void 0 : name.isStatic ? genExpression(name, context) : [
27680
27896
  "() => (",
27681
- ...genExpression(name, context),
27897
+ genExpression(name, context),
27682
27898
  ")"
27683
27899
  ];
27684
- push(NEWLINE, `const n${id} = `, ...genCall(createSlot, nameArg, rawPropsArg, fallbackArg, genSlotFlags(flags)));
27900
+ push(NEWLINE, `const n${id} = `, genCall(createSlot, nameArg, rawPropsArg, fallbackArg, genSlotFlags(flags)));
27685
27901
  return frag;
27686
27902
  }
27903
+ function genSlotProps(props, context) {
27904
+ if (!props.length) return;
27905
+ const first = props[0];
27906
+ if (props.length === 1 && isArray$3(first) && first.every((prop) => prop.key.isStatic)) return genRawProps(props, context, true);
27907
+ const { helper } = context;
27908
+ const groups = props.map((group) => {
27909
+ if (isArray$3(group)) return genLiteralObjectProps(group, context, true);
27910
+ const value = genExpression(group.value, context);
27911
+ return group.handler ? genCall(helper("toHandlers"), value) : value;
27912
+ });
27913
+ let value = groups[0];
27914
+ if (groups.length > 1) value = genCall(helper("mergeProps"), ...groups);
27915
+ else if (isArray$3(first)) {
27916
+ if (first.some((prop) => !prop.key.isStatic && !prop.handler)) value = genCall(helper("normalizeProps"), value);
27917
+ } else if (!first.handler) value = genCall(helper("normalizeProps"), genCall(helper("guardReactiveProps"), value));
27918
+ return [
27919
+ "{ $: [() => (",
27920
+ value,
27921
+ ")] }"
27922
+ ];
27923
+ }
27687
27924
  function genSlotFlags(flags) {
27688
27925
  if (!flags) return;
27689
27926
  const names = [];
@@ -27698,7 +27935,7 @@ function genVShow(oper, context) {
27698
27935
  const { element } = oper;
27699
27936
  return genCall(context.helper("applyVShow"), `n${element}`, [
27700
27937
  `() => (`,
27701
- ...genExpression(oper.dir.exp, context),
27938
+ genExpression(oper.dir.exp, context),
27702
27939
  `)`
27703
27940
  ]);
27704
27941
  }
@@ -27715,7 +27952,7 @@ function genBuiltinDirective(oper, context) {
27715
27952
  break;
27716
27953
  default: return [];
27717
27954
  }
27718
- return [NEWLINE, ...oper.once ? genOnce(call, context) : call];
27955
+ return [NEWLINE, oper.once ? genOnce(call, context) : call];
27719
27956
  }
27720
27957
  /**
27721
27958
  * user directives via `withVaporDirectives`, emitted at the end of the block
@@ -27729,7 +27966,7 @@ function genCustomDirectives(operations, context) {
27729
27966
  else byElement.set(oper.element, [oper]);
27730
27967
  }
27731
27968
  const [frag, push] = buildCodeFragment();
27732
- for (const dirs of byElement.values()) push(...genElementDirectives(dirs, context));
27969
+ for (const dirs of byElement.values()) push(genElementDirectives(dirs, context));
27733
27970
  return frag;
27734
27971
  }
27735
27972
  function genElementDirectives(opers, context) {
@@ -27738,17 +27975,17 @@ function genElementDirectives(opers, context) {
27738
27975
  const directiveItems = opers.map(genDirectiveItem);
27739
27976
  const directives = genMulti(DELIMITERS_ARRAY, ...directiveItems);
27740
27977
  const call = genCall(helper("withVaporDirectives"), element, directives);
27741
- return [NEWLINE, ...opers[0].once ? genOnce(call, context) : call];
27978
+ return [NEWLINE, opers[0].once ? genOnce(call, context) : call];
27742
27979
  function genDirectiveItem({ dir, name, asset }) {
27743
27980
  const directiveVar = asset ? toValidAssetId(name, "directive") : genExpression(extend(createSimpleExpression(name, false), { ast: null }), context);
27744
27981
  const value = dir.exp && [
27745
27982
  "() => (",
27746
- ...genExpression(dir.exp, context),
27983
+ genExpression(dir.exp, context),
27747
27984
  ")"
27748
27985
  ];
27749
27986
  const argument = dir.arg && [
27750
27987
  "() => (",
27751
- ...genExpression(dir.arg, context),
27988
+ genExpression(dir.arg, context),
27752
27989
  ")"
27753
27990
  ];
27754
27991
  const modifiers = !!dir.modifiers.length && [
@@ -27765,27 +28002,27 @@ function genKey(oper, context) {
27765
28002
  const { id, value, block, slotRoot } = oper;
27766
28003
  const [frag, push] = buildCodeFragment();
27767
28004
  const blockFn = genBlock(block, context);
27768
- push(NEWLINE, `const n${id} = `, ...genCall(context.helper("createKeyedFragment"), [
28005
+ push(NEWLINE, `const n${id} = `, genCall(context.helper("createKeyedFragment"), [
27769
28006
  `() => (`,
27770
- ...genExpression(value, context),
28007
+ genExpression(value, context),
27771
28008
  ")"
27772
28009
  ], blockFn, slotRoot ? "true" : false));
27773
28010
  return frag;
27774
28011
  }
27775
28012
  function genSetBlockKey(oper, context) {
27776
- return [NEWLINE, ...genCall(context.helper("setBlockKey"), `n${oper.element}`, genExpression(oper.value, context))];
28013
+ return [NEWLINE, genCall(context.helper("setBlockKey"), `n${oper.element}`, genExpression(oper.value, context))];
27777
28014
  }
27778
28015
  //#endregion
27779
28016
  //#region packages/compiler-vapor/src/generators/operation.ts
27780
28017
  function genOperations(opers, context) {
27781
28018
  const [frag, push] = buildCodeFragment();
27782
- for (const operation of opers) push(...genOperationWithInsertionState(operation, context));
28019
+ for (const operation of opers) push(genOperationWithInsertionState(operation, context));
27783
28020
  return frag;
27784
28021
  }
27785
28022
  function genOperationWithInsertionState(oper, context) {
27786
28023
  const [frag, push] = buildCodeFragment();
27787
- if (isBlockOperation(oper) && oper.parent) push(...genInsertionState(oper, context));
27788
- push(...genOperation(oper, context));
28024
+ if (isBlockOperation(oper) && oper.parent) push(genInsertionState(oper, context));
28025
+ push(genOperation(oper, context));
27789
28026
  return frag;
27790
28027
  }
27791
28028
  function genOperation(oper, context) {
@@ -27816,12 +28053,12 @@ function genEffects(effects, context, genExtraFrag) {
27816
28053
  for (let i = 0; i < effects.length; i++) {
27817
28054
  const effect = effects[i];
27818
28055
  if (effect.once) {
27819
- push(...genReactiveEffects(effects.slice(start, i), context));
27820
- push(...genOperations(effect.operations, context));
28056
+ push(genReactiveEffects(effects.slice(start, i), context));
28057
+ push(genOperations(effect.operations, context));
27821
28058
  start = i + 1;
27822
28059
  }
27823
28060
  }
27824
- push(...genReactiveEffects(effects.slice(start), context, genExtraFrag));
28061
+ push(genReactiveEffects(effects.slice(start), context, genExtraFrag));
27825
28062
  return frag;
27826
28063
  }
27827
28064
  function genReactiveEffects(effects, context, genExtraFrag) {
@@ -27838,16 +28075,18 @@ function genReactiveEffects(effects, context, genExtraFrag) {
27838
28075
  }
27839
28076
  const handlerFrags = genHoistedHandlers(effects, context);
27840
28077
  return context.withExpressionReplacements(expressionReplacements, () => {
27841
- push(...declarationFrags);
27842
- for (let i = 0; i < effects.length; i++) {
27843
- const effect = effects[i];
27844
- operationsCount += effect.operations.length;
27845
- const frags = context.withId(() => genEffect(effect, context), ids);
27846
- i > 0 && push(NEWLINE);
27847
- if (frag[frag.length - 1] === ")" && frags[0] === "(") push(";");
27848
- push(...frags);
27849
- }
27850
- if (frag.filter((frag) => frag === NEWLINE).length > 1 || operationsCount > 1 || declarationFrags.length > 0) {
28078
+ push(declarationFrags);
28079
+ context.withId(() => {
28080
+ for (let i = 0; i < effects.length; i++) {
28081
+ const effect = effects[i];
28082
+ operationsCount += effect.operations.length;
28083
+ const frags = genEffect(effect, context);
28084
+ i > 0 && push(NEWLINE);
28085
+ if (lastFragment(frag) === ")" && firstFragment(frags) === "(") push(";");
28086
+ push(frags);
28087
+ }
28088
+ }, ids);
28089
+ if (countNewlines(frag) > 1 || operationsCount > 1 || declarationFrags.length > 0) {
27851
28090
  unshift(`{`, INDENT_START, NEWLINE);
27852
28091
  push(INDENT_END, NEWLINE, "}");
27853
28092
  if (!effects.length) unshift(NEWLINE);
@@ -27857,21 +28096,53 @@ function genReactiveEffects(effects, context, genExtraFrag) {
27857
28096
  push(`)`);
27858
28097
  }
27859
28098
  if (!shouldDeclare && varNames.length) unshift(NEWLINE, `let `, varNames.join(", "));
27860
- if (genExtraFrag) push(...context.withId(genExtraFrag, ids));
27861
- unshift(...handlerFrags);
28099
+ if (genExtraFrag) push(context.withId(genExtraFrag, ids));
28100
+ unshift(handlerFrags);
27862
28101
  return frag;
27863
28102
  });
27864
28103
  }
27865
28104
  function genEffect({ operations }, context) {
27866
28105
  const [frag, push] = buildCodeFragment();
27867
28106
  const operationsExps = genOperations(operations, context);
27868
- if (operationsExps.filter((frag) => frag === NEWLINE).length > 1) push(...operationsExps);
27869
- else push(...operationsExps.filter((frag) => frag !== NEWLINE));
28107
+ if (countNewlines(operationsExps) > 1) push(operationsExps);
28108
+ else push(withoutNewlines(operationsExps));
27870
28109
  return frag;
27871
28110
  }
28111
+ const NO_FRAGMENT = Symbol();
28112
+ function firstFragment(frags) {
28113
+ for (const frag of frags) if (isNestedFragments(frag)) {
28114
+ const inner = firstFragment(frag);
28115
+ if (inner !== NO_FRAGMENT) return inner;
28116
+ } else return frag;
28117
+ return NO_FRAGMENT;
28118
+ }
28119
+ function lastFragment(frags) {
28120
+ for (let i = frags.length - 1; i >= 0; i--) {
28121
+ const frag = frags[i];
28122
+ if (isNestedFragments(frag)) {
28123
+ const inner = lastFragment(frag);
28124
+ if (inner !== NO_FRAGMENT) return inner;
28125
+ } else return frag;
28126
+ }
28127
+ return NO_FRAGMENT;
28128
+ }
28129
+ function countNewlines(frags) {
28130
+ let count = 0;
28131
+ for (const frag of frags) if (frag === NEWLINE) count++;
28132
+ else if (isNestedFragments(frag)) count += countNewlines(frag);
28133
+ return count;
28134
+ }
28135
+ function withoutNewlines(frags, out = []) {
28136
+ for (const frag of frags) {
28137
+ if (frag === NEWLINE) continue;
28138
+ if (isNestedFragments(frag)) withoutNewlines(frag, out);
28139
+ else out.push(frag);
28140
+ }
28141
+ return out;
28142
+ }
27872
28143
  function genInsertionState(operation, context) {
27873
28144
  const { parent, anchor, appendIndex } = operation;
27874
- return [NEWLINE, ...genCall(context.helper("setInsertionState"), `n${parent}`, anchor != null ? `n${anchor}` : appendIndex ? String(appendIndex) : void 0)];
28145
+ return [NEWLINE, genCall(context.helper("setInsertionState"), `n${parent}`, anchor != null ? `n${anchor}` : appendIndex ? String(appendIndex) : void 0)];
27875
28146
  }
27876
28147
  //#endregion
27877
28148
  //#region packages/compiler-vapor/src/generators/template.ts
@@ -27890,88 +28161,52 @@ function genSelf(dynamic, context, flushBeforeDynamic) {
27890
28161
  const [frag, push] = buildCodeFragment();
27891
28162
  const { id, template, operation, hasDynamicChild } = dynamic;
27892
28163
  if (id !== void 0 && template !== void 0) {
27893
- if (operation && operation.type === 11 && operation.appendIndex !== void 0) push(...genInsertionState(operation, context));
28164
+ if (operation && operation.type === 11 && operation.appendIndex !== void 0) push(genInsertionState(operation, context));
27894
28165
  push(NEWLINE, `const n${id} = ${context.tName(template)}()`);
27895
28166
  }
27896
- if (operation) push(...genOperationWithInsertionState(operation, context));
27897
- if (hasDynamicChild) push(...genChildren(dynamic, context, push, `n${id}`, flushBeforeDynamic));
28167
+ if (operation) push(genOperationWithInsertionState(operation, context));
28168
+ if (hasDynamicChild) push(genChildren(dynamic, context, push, `n${id}`, flushBeforeDynamic));
27898
28169
  return frag;
27899
28170
  }
27900
28171
  function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flushBeforeDynamic) {
27901
28172
  const [frag, push] = buildCodeFragment();
27902
- const { children } = dynamic;
27903
- let offset = 0;
27904
- /**
27905
- * `reusable` means the previous access target is a p* cursor that can be
27906
- * reassigned by the next lookup. Referenced n* variables must stay stable.
27907
- */
27908
28173
  let prev;
27909
- for (const [index, child] of children.entries()) {
27910
- if (child.flags & 2) offset--;
27911
- if (child.flags & 4 && child.template != null) {
27912
- if (child.anchor !== void 0) {
27913
- const elementIndex = index + offset;
27914
- const variable = `n${child.anchor}`;
27915
- pushBlock(NEWLINE, `const ${variable} = `, ...genAccessPath(context, from, elementIndex, prev));
27916
- prev = [
27917
- variable,
27918
- elementIndex,
27919
- false
27920
- ];
27921
- }
27922
- flushBeforeDynamic && flushBeforeDynamic(child, push);
27923
- push(...genSelf(child, context, flushBeforeDynamic));
27924
- continue;
27925
- }
27926
- const id = child.flags & 1 ? child.flags & 4 ? child.anchor : child.id : void 0;
27927
- const ownsSubtree = child.operation !== void 0;
27928
- if (id === void 0 && (!child.hasDynamicChild || ownsSubtree)) {
28174
+ for (const child of dynamic.children) {
28175
+ const { access } = child;
28176
+ if (!access) {
27929
28177
  flushBeforeDynamic && flushBeforeDynamic(child, push);
27930
- push(...genSelf(child, context, flushBeforeDynamic));
28178
+ push(genSelf(child, context, flushBeforeDynamic));
27931
28179
  continue;
27932
28180
  }
27933
- const elementIndex = index + offset;
27934
- const inlinePlaceholder = id === void 0 && canInlinePlaceholder(child) && child.template == null && child.operation === void 0 && !(child.flags & 6);
27935
- const accessPath = genAccessPath(context, from, elementIndex, prev, child.isText);
27936
- if (inlinePlaceholder) {
27937
- if (prev && prev[2]) {
27938
- push(...genChildren(child, context, pushBlock, [
28181
+ const accessPath = genAccessPath(context, from, access, prev, child.isText);
28182
+ switch (access.kind) {
28183
+ case 3:
28184
+ push(genChildren(child, context, pushBlock, accessPath, flushBeforeDynamic));
28185
+ continue;
28186
+ case 4:
28187
+ push(genChildren(child, context, pushBlock, [
27939
28188
  "(",
27940
- prev[0],
28189
+ prev,
27941
28190
  " = ",
27942
- ...accessPath,
28191
+ accessPath,
27943
28192
  ")"
27944
28193
  ], flushBeforeDynamic));
27945
- prev = [
27946
- prev[0],
27947
- elementIndex,
27948
- true
27949
- ];
27950
- continue;
27951
- }
27952
- if (!hasAdjacentFollowingAccessChild(children, index, elementIndex, offset)) {
27953
- push(...genChildren(child, context, pushBlock, accessPath, flushBeforeDynamic));
27954
28194
  continue;
27955
- }
27956
- }
27957
- let variable;
27958
- if (id === void 0 && prev && prev[2]) {
27959
- variable = prev[0];
27960
- pushBlock(NEWLINE, `${variable} = `, ...accessPath);
27961
- } else {
27962
- variable = id === void 0 ? context.pName(context.block.tempId++) : `n${id}`;
27963
- pushBlock(NEWLINE, id === void 0 ? `let ${variable} = ` : `const ${variable} = `, ...accessPath);
28195
+ case 2:
28196
+ pushBlock(NEWLINE, `${prev} = `, accessPath);
28197
+ break;
28198
+ case 1:
28199
+ prev = context.pName(context.block.tempId++);
28200
+ pushBlock(NEWLINE, `let ${prev} = `, accessPath);
28201
+ break;
28202
+ case 0:
28203
+ prev = `n${access.id}`;
28204
+ pushBlock(NEWLINE, `const ${prev} = `, accessPath);
27964
28205
  }
27965
- if (id === child.anchor && (!child.hasDynamicChild || ownsSubtree)) {
28206
+ if (child.operation) {
27966
28207
  flushBeforeDynamic && flushBeforeDynamic(child, push);
27967
- push(...genSelf(child, context, flushBeforeDynamic));
27968
- }
27969
- prev = [
27970
- variable,
27971
- elementIndex,
27972
- id === void 0
27973
- ];
27974
- if (!ownsSubtree) push(...genChildren(child, context, pushBlock, variable, flushBeforeDynamic));
28208
+ push(genSelf(child, context, flushBeforeDynamic));
28209
+ } else if (child.hasDynamicChild) push(genChildren(child, context, pushBlock, prev, flushBeforeDynamic));
27975
28210
  }
27976
28211
  return frag;
27977
28212
  }
@@ -27979,80 +28214,25 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flush
27979
28214
  * Build one DOM lookup path while preserving the fast sibling walk:
27980
28215
  * adjacent nodes use _next(prev), otherwise fall back to _nthChild(parent).
27981
28216
  */
27982
- function genAccessPath({ helper }, from, elementIndex, prev, isText) {
28217
+ function genAccessPath({ helper }, from, { index, adjacent }, prev, isText) {
27983
28218
  const textHint = isText ? "true" : void 0;
27984
- if (prev) return elementIndex - prev[1] === 1 ? genCall(helper("next"), prev[0], textHint) : genCall(helper("nthChild"), from, String(elementIndex), textHint);
27985
- if (elementIndex === 0) return genCall(helper("child"), from, textHint);
27986
- if (elementIndex === 1) {
28219
+ if (adjacent) return genCall(helper("next"), prev, textHint);
28220
+ if (index === 0) return genCall(helper("child"), from, textHint);
28221
+ if (index === 1) {
27987
28222
  const firstChild = genCall(helper("child"), from);
27988
28223
  return genCall(helper("next"), firstChild, textHint);
27989
28224
  }
27990
- return genCall(helper("nthChild"), from, String(elementIndex), textHint);
27991
- }
27992
- /**
27993
- * Only inline a placeholder when materializing it would not save a parent
27994
- * lookup. If its child tree needs the parent more than once, keep p* so the
27995
- * generated code does not duplicate _child/_nthChild work.
27996
- */
27997
- function canInlinePlaceholder(dynamic) {
27998
- return dynamic.hasDynamicChild === true && countParentAccessUsages(dynamic) === 1;
27999
- }
28000
- /**
28001
- * A following access can reuse the current placeholder cursor only when it is
28002
- * the next DOM sibling. Gapped siblings need _nthChild(parent, index) instead.
28003
- * Kept in lockstep with genChildren's traversal rules.
28004
- */
28005
- function hasAdjacentFollowingAccessChild(children, index, elementIndex, offset) {
28006
- let futureOffset = offset;
28007
- for (let i = index + 1; i < children.length; i++) {
28008
- const child = children[i];
28009
- if (child.flags & 2) futureOffset--;
28010
- if (child.flags & 4 && child.anchor === void 0) continue;
28011
- if (!!(child.flags & 1) || child.hasDynamicChild) return i + futureOffset - elementIndex === 1;
28012
- }
28013
- return false;
28014
- }
28015
- /**
28016
- * Mirrors genChildren's traversal closely enough to count how many emitted
28017
- * access paths would start from this placeholder's parent. This is the guard
28018
- * that keeps inline placeholders from duplicating parent lookups.
28019
- */
28020
- function countParentAccessUsages(dynamic) {
28021
- let usages = 0;
28022
- let offset = 0;
28023
- let prev;
28024
- for (const [index, child] of dynamic.children.entries()) {
28025
- if (child.flags & 2) offset--;
28026
- if (child.flags & 4 && child.template != null && child.anchor === void 0) continue;
28027
- const id = child.flags & 1 ? child.flags & 4 ? child.anchor : child.id : void 0;
28028
- if (id === void 0 && !child.hasDynamicChild) continue;
28029
- const elementIndex = index + offset;
28030
- const usesParent = !prev || elementIndex - prev[0] !== 1;
28031
- if (id === void 0 && canInlinePlaceholder(child) && child.template == null && child.operation === void 0 && !(child.flags & 6)) {
28032
- if (prev && prev[1]) {
28033
- if (usesParent) usages++;
28034
- prev = [elementIndex, true];
28035
- continue;
28036
- }
28037
- if (!hasAdjacentFollowingAccessChild(dynamic.children, index, elementIndex, offset)) {
28038
- if (usesParent) usages++;
28039
- continue;
28040
- }
28041
- }
28042
- if (usesParent) usages++;
28043
- prev = [elementIndex, id === void 0];
28044
- }
28045
- return usages;
28225
+ return genCall(helper("nthChild"), from, String(index), textHint);
28046
28226
  }
28047
28227
  //#endregion
28048
28228
  //#region packages/compiler-vapor/src/generators/block.ts
28049
28229
  function genBlock(oper, context, args = [], root) {
28050
28230
  return [
28051
28231
  "(",
28052
- ...args,
28232
+ args,
28053
28233
  ") => {",
28054
28234
  INDENT_START,
28055
- ...genBlockContent(oper, context, root),
28235
+ genBlockContent(oper, context, root),
28056
28236
  INDENT_END,
28057
28237
  NEWLINE,
28058
28238
  "}"
@@ -28060,17 +28240,9 @@ function genBlock(oper, context, args = [], root) {
28060
28240
  }
28061
28241
  function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffectIndexes) {
28062
28242
  const [frag, push] = buildCodeFragment();
28063
- const { dynamic, effect, operation, returns } = block;
28064
- const modelOperations = operation.filter(isVModelOperation);
28065
- const modelElements = new Set(modelOperations.map((oper) => oper.element));
28066
- const isModelListener = (oper) => isVModelListener(oper, modelElements);
28067
- const isDeferred = (oper) => isVModelOperation(oper) || isModelListener(oper);
28068
- const modelListenerEffects = [];
28069
- if (modelElements.size) {
28070
- for (let i = 0; i < effect.length; i++) if (!(skippedEffectIndexes && skippedEffectIndexes.has(i)) && effect[i].operations.every(isModelListener)) modelListenerEffects.push(effect[i]);
28071
- }
28243
+ const { dynamic, effect, operation, returns, deferredOperationIndex, deferredEffectIndex } = block;
28072
28244
  const resetBlock = context.enterBlock(block);
28073
- const singleUseAssetComponentNames = root ? collectSingleUseAssetComponents(block) : void 0;
28245
+ const singleUseAssetComponentNames = root ? collectSingleUseAssetComponents(block, context.ir.component) : void 0;
28074
28246
  const prevSingleUseAssetComponentNames = context.singleUseAssetComponentNames;
28075
28247
  if (singleUseAssetComponentNames) context.singleUseAssetComponentNames = singleUseAssetComponentNames;
28076
28248
  if (root) {
@@ -28079,7 +28251,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffec
28079
28251
  const id = toValidAssetId(name, "component");
28080
28252
  const maybeSelfReference = name.endsWith("__self");
28081
28253
  if (maybeSelfReference) name = name.slice(0, -6);
28082
- push(NEWLINE, `const ${id} = `, ...genCall(context.helper("resolveComponent"), JSON.stringify(name), maybeSelfReference ? "true" : void 0));
28254
+ push(NEWLINE, `const ${id} = `, genCall(context.helper("resolveComponent"), JSON.stringify(name), maybeSelfReference ? "true" : void 0));
28083
28255
  }
28084
28256
  genResolveAssets("directive", "resolveDirective");
28085
28257
  }
@@ -28087,12 +28259,11 @@ function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffec
28087
28259
  let effectIndex = 0;
28088
28260
  const flushPendingOperations = (operationEnd, effectEnd, push) => {
28089
28261
  while (operationIndex < operationEnd) {
28090
- const oper = operation[operationIndex];
28091
- if (!isDeferred(oper)) push(...genOperationWithInsertionState(oper, context));
28262
+ push(genOperationWithInsertionState(operation[operationIndex], context));
28092
28263
  operationIndex++;
28093
28264
  }
28094
28265
  if (effectIndex < effectEnd) {
28095
- push(...genEffectRange(effectIndex, effectEnd));
28266
+ push(genEffectRange(effectIndex, effectEnd));
28096
28267
  effectIndex = effectEnd;
28097
28268
  }
28098
28269
  };
@@ -28102,45 +28273,36 @@ function genBlockContent(block, context, root, genEffectsExtraFrag, skippedEffec
28102
28273
  };
28103
28274
  for (const child of dynamic.children) {
28104
28275
  flushBeforeDynamic(child, push);
28105
- push(...genSelf(child, context, flushBeforeDynamic));
28106
- }
28107
- for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`, flushBeforeDynamic));
28108
- if (operationIndex < operation.length) push(...genOperations(operation.slice(operationIndex).filter((oper) => !isDeferred(oper)), context));
28109
- if (effectIndex < effect.length) push(...genEffectRange(effectIndex, effect.length, genEffectsExtraFrag));
28110
- else if (genEffectsExtraFrag) push(...genEffects([], context, genEffectsExtraFrag));
28111
- if (modelOperations.length) {
28112
- push(...genOperations(modelOperations, context));
28113
- push(...genOperations(operation.filter(isModelListener), context));
28114
- if (modelListenerEffects.length) push(...genEffects(modelListenerEffects, context));
28115
- }
28116
- push(...genCustomDirectives(operation, context));
28276
+ push(genSelf(child, context, flushBeforeDynamic));
28277
+ }
28278
+ if (operationIndex < deferredOperationIndex) push(genOperations(operation.slice(operationIndex, deferredOperationIndex), context));
28279
+ if (effectIndex < deferredEffectIndex) push(genEffectRange(effectIndex, deferredEffectIndex, genEffectsExtraFrag));
28280
+ else if (genEffectsExtraFrag) push(genEffects([], context, genEffectsExtraFrag));
28281
+ if (deferredOperationIndex < operation.length) push(genOperations(operation.slice(deferredOperationIndex), context));
28282
+ if (deferredEffectIndex < effect.length) push(genEffectRange(deferredEffectIndex, effect.length));
28283
+ push(genCustomDirectives(operation, context));
28117
28284
  push(NEWLINE, `return `);
28118
28285
  const returnNodes = returns.map((n) => `n${n}`);
28119
- push(...returnNodes.length > 1 ? genMulti(DELIMITERS_ARRAY, ...returnNodes) : [returnNodes[0] || "[]"]);
28286
+ push(returnNodes.length > 1 ? genMulti(DELIMITERS_ARRAY, ...returnNodes) : [returnNodes[0] || "[]"]);
28120
28287
  resetBlock();
28121
28288
  context.singleUseAssetComponentNames = prevSingleUseAssetComponentNames;
28122
28289
  return frag;
28123
28290
  function genEffectRange(start, end, genExtraFrag) {
28124
- if (!skippedEffectIndexes && !modelListenerEffects.length) return genEffects(effect.slice(start, end), context, genExtraFrag);
28291
+ if (!skippedEffectIndexes) return genEffects(effect.slice(start, end), context, genExtraFrag);
28125
28292
  const effects = [];
28126
- for (let i = start; i < end; i++) if (!(skippedEffectIndexes && skippedEffectIndexes.has(i)) && !modelListenerEffects.includes(effect[i])) effects.push(effect[i]);
28293
+ for (let i = start; i < end; i++) if (!skippedEffectIndexes.has(i)) effects.push(effect[i]);
28127
28294
  if (effects.length || genExtraFrag) return genEffects(effects, context, genExtraFrag);
28128
28295
  return [];
28129
28296
  }
28130
28297
  function genResolveAssets(kind, helper) {
28131
- for (const name of context.ir[kind]) push(NEWLINE, `const ${toValidAssetId(name, kind)} = `, ...genCall(context.helper(helper), JSON.stringify(name)));
28298
+ for (const name of context.ir[kind]) push(NEWLINE, `const ${toValidAssetId(name, kind)} = `, genCall(context.helper(helper), JSON.stringify(name)));
28132
28299
  }
28133
28300
  }
28134
- function isVModelOperation(oper) {
28135
- return oper.type === 14 && oper.builtin === true && oper.name === "model";
28136
- }
28137
- function isVModelListener(oper, modelElements) {
28138
- return (oper.type === 7 || oper.type === 8 || oper.type === 4 && oper.listeners || oper.type === 3 && !oper.prop.modifier && isOn(oper.prop.key.content)) && modelElements.has(oper.element);
28139
- }
28140
28301
  function markSlotRootOperations(block, context) {
28141
- if (hasStableSlotRoot(block, context)) return;
28142
- for (let i = 0; i < block.returns.length; i++) {
28143
- const child = findReturnedDynamic$1(block, block.returns[i]);
28302
+ const roots = getReturnedDynamics(block);
28303
+ if (hasStableSlotRoot(roots, context)) return true;
28304
+ for (let i = 0; i < roots.length; i++) {
28305
+ const child = roots[i];
28144
28306
  const operation = child && child.operation;
28145
28307
  if (!operation) continue;
28146
28308
  if (operation.type === 15) markSlotRootIf(operation, context);
@@ -28151,6 +28313,7 @@ function markSlotRootOperations(block, context) {
28151
28313
  } else if (operation.type === 12) markSlotRootComponent(operation);
28152
28314
  else if (operation.type === 13) operation.flags |= 4;
28153
28315
  }
28316
+ return false;
28154
28317
  }
28155
28318
  function markSlotRootIf(operation, context) {
28156
28319
  if (!operation.once) operation.slotRoot = true;
@@ -28167,52 +28330,47 @@ function markSlotRootFor(operation, context) {
28167
28330
  function markSlotRootComponent(operation) {
28168
28331
  if (!operation.once && operation.dynamic && !operation.dynamic.isStatic) operation.slotRoot = true;
28169
28332
  }
28170
- function findReturnedDynamic$1(block, id) {
28171
- for (let i = 0; i < block.dynamic.children.length; i++) {
28172
- const child = block.dynamic.children[i];
28173
- if (child.id === id) return child;
28333
+ function getReturnedDynamics(block) {
28334
+ const { children } = block.dynamic;
28335
+ const byId = /* @__PURE__ */ new Map();
28336
+ for (let i = 0; i < children.length; i++) {
28337
+ const child = children[i];
28338
+ if (child.id !== void 0) byId.set(child.id, child);
28174
28339
  }
28340
+ return block.returns.map((id) => byId.get(id));
28175
28341
  }
28176
28342
  const commentOnlyTemplateRE = /^(?:<!--[\s\S]*?-->)+$/;
28177
- function hasStableSlotRoot(block, context) {
28178
- let hasValidRoot = false;
28179
- for (let i = 0; i < block.returns.length; i++) {
28180
- const id = block.returns[i];
28181
- const child = findReturnedDynamic$1(block, id);
28343
+ function hasStableSlotRoot(roots, context) {
28344
+ for (let i = 0; i < roots.length; i++) {
28345
+ const child = roots[i];
28182
28346
  const operation = child && child.operation;
28183
28347
  if (!operation) {
28184
- if (child && isStableTemplateSlotRoot(child, context)) hasValidRoot = true;
28348
+ if (child && isStableTemplateSlotRoot(child, context)) return true;
28185
28349
  continue;
28186
28350
  }
28187
28351
  switch (operation.type) {
28188
28352
  case 12:
28189
- if (!operation.dynamic || operation.dynamic.isStatic) {
28190
- hasValidRoot = true;
28191
- continue;
28192
- }
28353
+ if (!operation.dynamic || operation.dynamic.isStatic) return true;
28193
28354
  continue;
28194
28355
  case 17:
28195
- if (hasStableSlotRoot(operation.block, context)) {
28196
- hasValidRoot = true;
28197
- continue;
28198
- }
28356
+ if (hasStableSlotRoot(getReturnedDynamics(operation.block), context)) return true;
28199
28357
  continue;
28200
28358
  default: continue;
28201
28359
  }
28202
28360
  }
28203
- return hasValidRoot;
28361
+ return false;
28204
28362
  }
28205
28363
  function isStableTemplateSlotRoot(child, context) {
28206
28364
  if (child.template == null) return false;
28207
28365
  const content = context.ir.template.entries[child.template].content;
28208
28366
  return content !== "" && !commentOnlyTemplateRE.test(content.trim());
28209
28367
  }
28210
- function collectSingleUseAssetComponents(block) {
28368
+ function collectSingleUseAssetComponents(block, assetComponents) {
28211
28369
  const usageMap = /* @__PURE__ */ new Map();
28212
28370
  const seenOperations = /* @__PURE__ */ new Set();
28213
28371
  visitBlock(block, true);
28214
28372
  const names = /* @__PURE__ */ new Set();
28215
- for (const [name, usage] of usageMap) if (usage.count === 1 && usage.root) names.add(name);
28373
+ for (const [name, usage] of usageMap) if (usage.count === 1 && usage.root && assetComponents.has(name)) names.add(name);
28216
28374
  return names;
28217
28375
  function visitBlock(block, rootCandidate) {
28218
28376
  visitDynamic(block.dynamic, rootCandidate);
@@ -28273,7 +28431,6 @@ function collectSingleUseAssetComponents(block) {
28273
28431
  }
28274
28432
  //#endregion
28275
28433
  //#region packages/compiler-vapor/src/generate.ts
28276
- const idWithTrailingDigitsRE = /^([A-Za-z_$][\w$]*)(\d+)$/;
28277
28434
  const helperNameAliases = {
28278
28435
  withVaporKeys: "withKeys",
28279
28436
  withVaporModifiers: "withModifiers"
@@ -28303,7 +28460,7 @@ var CodegenContext = class {
28303
28460
  identifiers[id].unshift(map[id] || id);
28304
28461
  }
28305
28462
  const ret = fn();
28306
- ids.forEach((id) => remove(identifiers[id], map[id] || id));
28463
+ for (const id of ids) identifiers[id].shift();
28307
28464
  return ret;
28308
28465
  }
28309
28466
  enterBlock(block) {
@@ -28330,8 +28487,7 @@ var CodegenContext = class {
28330
28487
  if (name === "_ctx" || name === setTemplateRefIdent) return false;
28331
28488
  if (this.bindingNames.has(name) || reservedNames.has(name)) return false;
28332
28489
  if ((_this$identifiers$nam = this.identifiers[name]) === null || _this$identifiers$nam === void 0 ? void 0 : _this$identifiers$nam.length) return false;
28333
- for (const alias of this.helpers.values()) if (alias === name) return false;
28334
- return true;
28490
+ return !this.helperAliases.has(name);
28335
28491
  }
28336
28492
  findAvailableName(base, reservedNames) {
28337
28493
  if (this.isNameAvailable(base, reservedNames)) return base;
@@ -28344,20 +28500,6 @@ var CodegenContext = class {
28344
28500
  next = id + 1;
28345
28501
  }
28346
28502
  }
28347
- initNextIdMap() {
28348
- if (this.bindingNames.size === 0) return;
28349
- const map = /* @__PURE__ */ new Map();
28350
- for (const name of this.bindingNames) {
28351
- const m = idWithTrailingDigitsRE.exec(name);
28352
- if (!m) continue;
28353
- const prefix = m[1];
28354
- const num = Number(m[2]);
28355
- let set = map.get(prefix);
28356
- if (!set) map.set(prefix, set = /* @__PURE__ */ new Set());
28357
- set.add(num);
28358
- }
28359
- for (const [prefix, nums] of map) this.nextIdMap.set(prefix, buildNextIdMap(nums));
28360
- }
28361
28503
  tName(i) {
28362
28504
  let name = this.templateVars.get(i);
28363
28505
  if (name) return name;
@@ -28382,8 +28524,9 @@ var CodegenContext = class {
28382
28524
  }
28383
28525
  constructor(ir, options) {
28384
28526
  this.ir = ir;
28385
- this.bindingNames = /* @__PURE__ */ new Set();
28386
28527
  this.helpers = /* @__PURE__ */ new Map();
28528
+ this.helperAliases = /* @__PURE__ */ new Set();
28529
+ this.hoistedHandlers = /* @__PURE__ */ new Map();
28387
28530
  this.needsTemplateRefSetter = false;
28388
28531
  this.inSlotBlock = false;
28389
28532
  this.helper = (name) => {
@@ -28391,6 +28534,7 @@ var CodegenContext = class {
28391
28534
  const base = `_${helperNameAliases[name] || name}`;
28392
28535
  const alias = this.findAvailableName(base, this.generatedLocalNames);
28393
28536
  this.helpers.set(name, alias);
28537
+ this.helperAliases.add(alias);
28394
28538
  return alias;
28395
28539
  };
28396
28540
  this.delegates = /* @__PURE__ */ new Set();
@@ -28421,8 +28565,8 @@ var CodegenContext = class {
28421
28565
  };
28422
28566
  this.options = extend(defaultOptions, options);
28423
28567
  this.block = ir.block;
28424
- this.bindingNames = new Set(this.options.bindingMetadata ? Object.keys(this.options.bindingMetadata) : []);
28425
- this.initNextIdMap();
28568
+ this.bindingNames = ir.reservedNames.names;
28569
+ for (const [prefix, nums] of ir.reservedNames.ids) this.nextIdMap.set(prefix, buildNextIdMap(nums));
28426
28570
  }
28427
28571
  };
28428
28572
  function generate(ir, options = {}) {
@@ -28438,15 +28582,21 @@ function generate(ir, options = {}) {
28438
28582
  const templateRefSetterHelper = ir.hasTemplateRef ? context.helper("createTemplateRefSetter") : void 0;
28439
28583
  const body = genBlockContent(ir.block, context, true);
28440
28584
  if (context.needsTemplateRefSetter) push(NEWLINE, `const ${setTemplateRefIdent} = ${templateRefSetterHelper}()`);
28441
- else if (templateRefSetterHelper) context.helpers.delete("createTemplateRefSetter");
28442
- push(...body);
28585
+ else if (templateRefSetterHelper) {
28586
+ context.helpers.delete("createTemplateRefSetter");
28587
+ context.helperAliases.delete(templateRefSetterHelper);
28588
+ }
28589
+ push(body);
28443
28590
  push(INDENT_END, NEWLINE);
28444
28591
  if (!inline) push("}");
28445
28592
  const delegates = genDelegates(context);
28446
28593
  const templates = genTemplates(ir.template.entries, context);
28447
28594
  const preamble = genHelperImports(context) + genAssetImports(context) + templates + genDynamicPropNames(context) + delegates;
28448
- const newlineCount = [...preamble].filter((c) => c === "\n").length;
28449
- if (newlineCount && !inline) frag.unshift(...new Array(newlineCount).fill(LF));
28595
+ if (!inline) {
28596
+ let newlineCount = 0;
28597
+ for (let i = preamble.indexOf("\n"); i !== -1; i = preamble.indexOf("\n", i + 1)) newlineCount++;
28598
+ if (newlineCount) frag.unshift(...new Array(newlineCount).fill(LF));
28599
+ }
28450
28600
  let [code, map] = codeFragmentToString(frag, context);
28451
28601
  if (!inline) code = preamble + code;
28452
28602
  return {
@@ -28463,7 +28613,7 @@ function genDynamicPropNames({ dynamicPropNames }) {
28463
28613
  return code;
28464
28614
  }
28465
28615
  function genDelegates({ delegates, helper }) {
28466
- return delegates.size ? genCall(helper("delegateEvents"), ...Array.from(delegates).map((v) => `"${v}"`)).join("") + "\n" : "";
28616
+ return delegates.size ? `${helper("delegateEvents")}(${Array.from(delegates).map((v) => `"${v}"`).join(", ")})\n` : "";
28467
28617
  }
28468
28618
  function genHelperImports({ helpers, options }) {
28469
28619
  let imports = "";
@@ -28480,6 +28630,94 @@ function genAssetImports({ ir }) {
28480
28630
  return imports;
28481
28631
  }
28482
28632
  //#endregion
28633
+ //#region packages/compiler-vapor/src/htmlNesting.ts
28634
+ const isPClosingTag = /*@__PURE__*/ makeMap("address,article,aside,blockquote,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,main,menu,nav,ol,p,pre,section,summary,table,ul");
28635
+ const isForeign = (ns) => ns !== 0;
28636
+ const isScopeBoundaryTag = /*@__PURE__*/ makeMap("caption,object,select,table,td,th");
28637
+ const isFormattingMarkerTag = /*@__PURE__*/ makeMap("caption,object,td,th");
28638
+ const isSpecialTag = /*@__PURE__*/ makeMap("address,area,article,aside,base,blockquote,body,br,button,caption,col,colgroup,dd,details,div,dl,dt,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,iframe,img,input,li,link,main,menu,meta,nav,noscript,object,ol,p,param,pre,script,section,select,source,style,summary,table,tbody,td,template,textarea,tfoot,th,thead,title,tr,track,ul,wbr");
28639
+ const endsListItemSearch = (tag) => isSpecialTag(tag) && tag !== "address" && tag !== "div" && tag !== "p";
28640
+ /**
28641
+ * End tags with handling of their own pop whatever is still open below them.
28642
+ * Any other end tag is ignored when it meets a special element on its way up
28643
+ * the stack, and a formatting end tag runs the adoption agency around one, so
28644
+ * under those an open special descendant has to close itself.
28645
+ */
28646
+ const popsOpenDescendants = /*@__PURE__*/ makeMap("address,article,aside,blockquote,button,caption,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,h1,h2,h3,h4,h5,h6,header,hgroup,li,main,menu,nav,object,ol,p,pre,section,summary,table,tbody,td,tfoot,th,thead,tr,ul");
28647
+ /**
28648
+ * Html start tags that end foreign content: the parser pops the open svg or
28649
+ * mathml elements and inserts these in the html namespace, while vdom creates
28650
+ * them in the foreign namespace their ast node carries. Only at html
28651
+ * integration points (`foreignObject`, `mi`, ...) do html children stay.
28652
+ */
28653
+ const isForeignBreakoutTag = /*@__PURE__*/ makeMap("b,blockquote,body,br,code,dd,div,dl,dt,em,embed,h1,h2,h3,h4,h5,h6,head,hr,i,img,li,menu,meta,ol,p,pre,ruby,s,small,span,strong,sub,sup,table,u,ul,var");
28654
+ /**
28655
+ * Table parts whose text content other than whitespace the parser
28656
+ * foster-parents in front of the table.
28657
+ */
28658
+ const isFosterParentingTag = /*@__PURE__*/ makeMap("colgroup,table,tbody,tfoot,thead,tr");
28659
+ const isImpliedEndTag = /*@__PURE__*/ makeMap("dd,dt,li,optgroup,option,p,rp,rt");
28660
+ /**
28661
+ * The scope the children of `tag` see, given the scope `tag` itself was
28662
+ * written in (0 when it starts a template).
28663
+ */
28664
+ function enterOpenScope(scope, tag, ns) {
28665
+ if (isForeign(ns)) {
28666
+ scope &= -104;
28667
+ return scope;
28668
+ }
28669
+ if (isScopeBoundaryTag(tag)) scope &= -8;
28670
+ if (isFormattingMarkerTag(tag)) scope &= -9;
28671
+ if (endsListItemSearch(tag)) scope &= -97;
28672
+ switch (tag) {
28673
+ case "p": return scope | 1;
28674
+ case "button": return scope & -2 | 2;
28675
+ case "ruby": return scope | 4;
28676
+ case "a": return scope | 8;
28677
+ case "form": return scope | 16;
28678
+ case "li": return scope | 32;
28679
+ case "dd":
28680
+ case "dt": return scope | 64;
28681
+ }
28682
+ return scope;
28683
+ }
28684
+ /**
28685
+ * Whether the html parser places an element written under `parent` there, so
28686
+ * that both can share a template string. Two layers: `isValidHTMLNesting`
28687
+ * rejects what the parent itself cannot hold (table, row, select and raw-text
28688
+ * content models, void parents), `closesOpenAncestor` the start tags that end
28689
+ * an element still open above. The end-tag omission in transformElement
28690
+ * assumes only elements passing both share a template.
28691
+ */
28692
+ function keepsInTemplate(tag, ns, parentTag, scope) {
28693
+ return isValidHTMLNesting(parentTag, tag) && !closesOpenAncestor(tag, ns, parentTag, scope);
28694
+ }
28695
+ /**
28696
+ * Whether the html parser, on the start tag of `tag`, closes an element that
28697
+ * is still open above it in the same template - the `<p>` of
28698
+ * `<p><span><div>`, the `<li>` of `<li><span><li>`, a link inside a link. The
28699
+ * element would then end up elsewhere than the compiler expects, so it has to
28700
+ * go into a template of its own. Transcribed from the "in body" insertion mode
28701
+ * of https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody
28702
+ * for the native html tags the compiler knows; `scope` is what the parent
28703
+ * leaves open (`enterOpenScope`).
28704
+ */
28705
+ function closesOpenAncestor(tag, ns, parentTag, scope) {
28706
+ if (isForeign(ns)) return false;
28707
+ if (isPClosingTag(tag) && scope & 1) return true;
28708
+ switch (tag) {
28709
+ case "li": return !!(scope & 32);
28710
+ case "dd":
28711
+ case "dt": return !!(scope & 64);
28712
+ case "button": return !!(scope & 2);
28713
+ case "a": return !!(scope & 8);
28714
+ case "form": return !!(scope & 16);
28715
+ case "rt":
28716
+ case "rp": return !!(scope & 4) && isImpliedEndTag(parentTag);
28717
+ }
28718
+ return false;
28719
+ }
28720
+ //#endregion
28483
28721
  //#region packages/compiler-vapor/src/transforms/vBind.ts
28484
28722
  function normalizeBindShorthand(arg, context) {
28485
28723
  if (arg.type !== 4 || !arg.isStatic) {
@@ -28500,10 +28738,10 @@ const transformVBind = (dir, node, context) => {
28500
28738
  context.options.onError(createCompilerError(34, loc));
28501
28739
  exp = createSimpleExpression("", true, loc);
28502
28740
  }
28503
- arg = resolveExpression(arg);
28741
+ if (node.tagType !== 2) arg = resolveExpression(arg);
28504
28742
  const excludeNumber = node.tagType === 1 || node.tagType === 2 || !!context.options.isCustomElement(node.tag) || modifiersString.includes("prop") || !arg.isStatic || isSpecialBooleanAttr(arg.content) || isCheckboxValueProp(node, arg.content) || !modifiersString.includes("attr") && (isFoldableBooleanAttr(arg.content) || isModelValueProp(node, arg.content));
28505
28743
  exp = resolveExpression(exp, excludeNumber);
28506
- if (arg.isStatic && isReservedProp(arg.content)) return;
28744
+ if (arg.isStatic && isReservedProp(arg.content) && !(arg.content === "key" && node.tagType === 2)) return;
28507
28745
  let camel = false;
28508
28746
  if (modifiersString.includes("camel")) {
28509
28747
  if (arg.isStatic) arg = extend({}, arg, { content: camelize(arg.content) });
@@ -28530,6 +28768,8 @@ const transformKey = (node, context) => {
28530
28768
  }
28531
28769
  const dir = findProp(node, "key", true, true);
28532
28770
  if (!dir || dir.type === 6) return;
28771
+ const parent = context.parent && context.parent.node;
28772
+ if (node.tagType === 2 && parent && parent.type === 1 && parent.props.includes(dir)) return;
28533
28773
  let value;
28534
28774
  value = dir.exp || normalizeBindShorthand(dir.arg, context);
28535
28775
  if (isStaticExpression(value, context.options.bindingMetadata)) return;
@@ -28632,8 +28872,8 @@ function isFoldableBooleanAttr(key) {
28632
28872
  return isBooleanAttr(key) || key === "hidden";
28633
28873
  }
28634
28874
  const transformElement = (node, context) => {
28635
- let effectIndex = context.block.effect.length;
28636
- const getEffectIndex = () => effectIndex++;
28875
+ let effectOrder = context.order;
28876
+ const getEffectOrder = () => ++effectOrder;
28637
28877
  if (node.type === 1 && node.children.length) ignoreVHtmlChildren(node, context, "node");
28638
28878
  let parentSlots;
28639
28879
  if (node.type === 1 && (node.tagType === 1 || shouldUseCreateElement(node, context))) {
@@ -28647,10 +28887,10 @@ const transformElement = (node, context) => {
28647
28887
  const isComponent = node.tagType === 1 || useCreateElement;
28648
28888
  const isDynamicComponent = isComponentTag(node.tag);
28649
28889
  const staticKey = dynamicComponentKeys.has(node) ? void 0 : resolveStaticKey(node, context, isComponent);
28650
- const propsResult = buildProps(node, context, isComponent, isDynamicComponent, getEffectIndex);
28890
+ const propsResult = buildProps(node, context, isComponent, isDynamicComponent, getEffectOrder);
28651
28891
  const singleRoot = context.isSingleRoot;
28652
- if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement);
28653
- else transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectIndex, context.root === context.effectiveParent || canOmitEndTag(node, context));
28892
+ if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot || context.isSlotRoot && !useCreateElement && 2, context, isDynamicComponent, useCreateElement);
28893
+ else transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectOrder, context.root === context.effectiveParent || canOmitEndTag(node, context));
28654
28894
  if (parentSlots) context.slots = parentSlots;
28655
28895
  };
28656
28896
  };
@@ -28658,7 +28898,7 @@ function canOmitEndTag(node, context) {
28658
28898
  const { block, parent } = context;
28659
28899
  if (!parent) return false;
28660
28900
  if (block !== parent.block) return true;
28661
- if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || context.templateCloseTags.has("form") || context.templateCloseTags.has("li") && (node.tag === "ul" || node.tag === "ol") || isAlwaysCloseTag(node.tag) || isFormattingTag(node.tag)) || context.templateCloseBlocks && isBlockTag(node.tag)) return false;
28901
+ if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || context.templateCloseTags.has("form") || context.templateCloseTags.has("li") && (node.tag === "ul" || node.tag === "ol") || isAlwaysCloseTag(node.tag) || isFormattingTag(node.tag)) || context.templateCloseBlocks && isSpecialTag(node.tag)) return false;
28662
28902
  if (isAlwaysCloseTag(node.tag) && !context.isOnRightmostPath) return false;
28663
28903
  if (isFormattingTag(node.tag) || parent.node.type === 1 && (node.tag === parent.node.tag || parent.node.ns !== 0 && node.ns !== parent.node.ns)) return context.isOnRightmostPath;
28664
28904
  return context.isLastEffectiveChild;
@@ -28666,9 +28906,8 @@ function canOmitEndTag(node, context) {
28666
28906
  function getChildTemplateCloseState(context) {
28667
28907
  const { node } = context;
28668
28908
  if (node.type !== 1 || node.tagType !== 0 || shouldUseCreateElement(node, context)) return;
28669
- const inSameTemplateAsParent = isInSameTemplateAsParent(context);
28670
- const inheritedTags = inSameTemplateAsParent ? context.templateCloseTags : void 0;
28671
- const inheritedBlocks = inSameTemplateAsParent && context.templateCloseBlocks;
28909
+ const inheritedTags = context.templateCloseTags;
28910
+ const inheritedBlocks = context.templateCloseBlocks;
28672
28911
  if (context.root === context.effectiveParent || canOmitEndTag(node, context) || isVoidTag(node.tag)) return inheritedTags || inheritedBlocks ? {
28673
28912
  tags: inheritedTags,
28674
28913
  blocks: inheritedBlocks
@@ -28677,25 +28916,28 @@ function getChildTemplateCloseState(context) {
28677
28916
  tags.add(node.tag);
28678
28917
  return {
28679
28918
  tags,
28680
- blocks: inheritedBlocks || isInlineTag(node.tag)
28919
+ blocks: !popsOpenDescendants(node.tag)
28681
28920
  };
28682
28921
  }
28683
- function isInSameTemplateAsParent(context) {
28684
- const { parent, node, block } = context;
28685
- if (!parent || block !== parent.block) return false;
28922
+ /**
28923
+ * The parent whose template string the element would be written into: a
28924
+ * plain element in the same block that is not created with createElement.
28925
+ */
28926
+ function getTemplateParent(context) {
28927
+ const { parent, block } = context;
28928
+ if (!parent || block !== parent.block) return;
28686
28929
  const parentNode = parent.node;
28687
- if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
28688
- return !shouldUseCreateElement(parentNode, parent) && isValidHTMLNesting(parentNode.tag, node.tag);
28930
+ if (parentNode.type === 1 && parentNode.tagType === 0 && !shouldUseCreateElement(parentNode, parent)) return parent;
28689
28931
  }
28690
- function transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement) {
28691
- const dynamicComponent = isDynamicComponent ? resolveDynamicComponent(node) : void 0;
28932
+ function transformComponentElement(node, propsResult, staticKey, root, context, isDynamicComponent, useCreateElement) {
28933
+ let dynamicComponent = isDynamicComponent ? resolveDynamicComponent(node) : void 0;
28692
28934
  let { tag } = node;
28693
- let asset = true;
28694
- let slotScopeNamespace;
28935
+ let asset = !useCreateElement;
28695
28936
  if (!dynamicComponent && !useCreateElement) {
28696
28937
  const isProp = findProp(node, "is");
28697
28938
  if (isProp && isProp.type === 6 && isVueIsValue(isProp)) tag = isProp.value.content.slice(4);
28698
- const resolved = resolveSlotScopeReference(tag, context) || resolveSetupReference(tag, context);
28939
+ const slotScopeTag = resolveSlotScopeReference(tag, context);
28940
+ const resolved = slotScopeTag || resolveSetupReference(tag, context);
28699
28941
  if (resolved) {
28700
28942
  tag = resolved;
28701
28943
  asset = false;
@@ -28705,6 +28947,7 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
28705
28947
  tag = builtInTag;
28706
28948
  asset = false;
28707
28949
  }
28950
+ let slotScopeNamespace;
28708
28951
  const dotIndex = tag.indexOf(".");
28709
28952
  if (dotIndex > 0) {
28710
28953
  slotScopeNamespace = resolveSlotScopeReference(tag.slice(0, dotIndex), context);
@@ -28714,6 +28957,10 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
28714
28957
  asset = false;
28715
28958
  }
28716
28959
  }
28960
+ if (slotScopeTag && !builtInTag || slotScopeNamespace) {
28961
+ dynamicComponent = createSimpleExpression(tag, false, node.loc);
28962
+ dynamicComponent.ast = isSimpleIdentifier(tag) ? null : (0, import_lib.parseExpression)(`(${tag})`, getParserOptions(context.options.expressionPlugins));
28963
+ }
28717
28964
  if (asset) {
28718
28965
  if (context.selfName && capitalize(camelize(tag)) === context.selfName) tag += `__self`;
28719
28966
  context.component.add(tag);
@@ -28735,10 +28982,9 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
28735
28982
  id
28736
28983
  }, context.effectBoundary()), {}, {
28737
28984
  tag,
28738
- slotScopeNamespace,
28739
28985
  props,
28740
28986
  asset,
28741
- root: singleRoot,
28987
+ root,
28742
28988
  slots: [...context.slots],
28743
28989
  once: context.inVOnce,
28744
28990
  dynamic: dynamicComponent,
@@ -28815,7 +29061,7 @@ const inputValueDepKeys = [
28815
29061
  const NEEDS_QUOTES_RE = /[\s"'`=<>]/;
28816
29062
  const LEADING_NEWLINE_RE = /^\r?\n/;
28817
29063
  const UNSAFE_ATTR_NAME_RE = /[\u0000-\u0020"'<=/>]/;
28818
- function transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectIndex, omitEndTag) {
29064
+ function transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectOrder, omitEndTag) {
28819
29065
  const { tag } = node;
28820
29066
  const { scopeId } = context.options;
28821
29067
  const isSVG = node.ns === 1;
@@ -28832,7 +29078,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
28832
29078
  props: dynamicArgs,
28833
29079
  isSVG,
28834
29080
  once: isSelect && context.inVOnce
28835
- }, getEffectIndex);
29081
+ }, getEffectOrder);
28836
29082
  if (isSelect && !context.inVOnce) context.registerEffect([], {
28837
29083
  type: 5,
28838
29084
  element: context.reference(),
@@ -28866,7 +29112,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
28866
29112
  tag,
28867
29113
  isSVG
28868
29114
  };
28869
- operation.effect = context.registerEffect(values, operation, getEffectIndex, needsOrderedProps && hasEffect);
29115
+ operation.effect = context.registerEffect(values, operation, getEffectOrder, needsOrderedProps && hasEffect);
28870
29116
  hasEffect = operation.effect || hasEffect;
28871
29117
  }
28872
29118
  } else if (canStringifyAttrName && context.imports.some((imported) => values[0].content.includes(imported.exp.content))) template += ` ${key.content}="${IMPORT_EXP_START}${values[0].content}${IMPORT_EXP_END}"`;
@@ -28887,7 +29133,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
28887
29133
  tag,
28888
29134
  isSVG,
28889
29135
  once: isSelectValue && (context.inVOnce || !hasDynamicKeys && values.every((exp) => isConstantBinding$1(exp, context.options.bindingMetadata)))
28890
- }, isSelectValue ? void 0 : getEffectIndex, isSelectValue || (needsOrderedProps || tag === "input" && prop === valueProp) && hasEffect) || hasEffect;
29136
+ }, isSelectValue ? void 0 : getEffectOrder, isSelectValue || (needsOrderedProps || tag === "input" && prop === valueProp) && hasEffect) || hasEffect;
28891
29137
  if (tag === "input" && inputValueDepKeys.includes(key.content)) hasValueDep = true;
28892
29138
  }
28893
29139
  }
@@ -28896,14 +29142,14 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
28896
29142
  element: context.reference(),
28897
29143
  props: [nativeOnProps],
28898
29144
  isSVG
28899
- }, getEffectIndex);
29145
+ }, getEffectOrder);
28900
29146
  }
28901
29147
  let children = context.childrenTemplate.join("");
28902
29148
  if (node.ns === 0 && parserOptions.isIgnoreNewlineTag(tag) && LEADING_NEWLINE_RE.test(children)) children = `\n` + children;
28903
29149
  template += `>` + children;
28904
29150
  if (!isVoidTag(tag) && !omitEndTag) template += `</${tag}>`;
28905
29151
  context.templateRoot = singleRoot;
28906
- if (context.parent && context.parent.node.type === 1 && !isValidHTMLNesting(context.parent.node.tag, tag)) {
29152
+ if (context.parent && context.parent.node.type === 1 && !isValidHTMLNesting(context.parent.node.tag, tag) || !(context.templateScope & 128) && getTemplateParent(context) !== void 0) {
28907
29153
  context.reference();
28908
29154
  context.dynamic.template = context.pushTemplate(template);
28909
29155
  context.dynamic.flags |= 6;
@@ -29059,21 +29305,18 @@ function createSetBlockKey(element, value) {
29059
29305
  value
29060
29306
  };
29061
29307
  }
29062
- function buildProps(node, context, isComponent, isDynamicComponent, getEffectIndex) {
29308
+ function buildProps(node, context, isComponent, isDynamicComponent, getEffectOrder) {
29063
29309
  const props = node.props;
29310
+ const isSlot = node.tagType === 2;
29064
29311
  if (props.length === 0) return [false, []];
29065
29312
  const dynamicArgs = [];
29066
29313
  const dynamicExpr = [];
29067
29314
  let results = [];
29068
- let resolvedBind;
29069
- let resolvedBindProps;
29070
29315
  const deferListeners = !isComponent && !!findDir(node, "model") && props.some((prop) => prop.type === 7 && prop.name === "on" && !prop.arg) && mergesListeners(node, context) && props.every((prop) => {
29071
29316
  if (prop.type !== 7 || prop.name !== "bind") return true;
29072
29317
  if (prop.arg) return prop.arg.type === 4 && prop.arg.isStatic;
29073
29318
  if (!prop.exp) return false;
29074
- resolvedBind = prop;
29075
- resolvedBindProps = resolveNativeObjectLiteralBindProps(prop.exp, context, props, prop);
29076
- return !!resolvedBindProps;
29319
+ return !!resolveNativeObjectLiteralBindProps(prop.exp, context, props, prop);
29077
29320
  });
29078
29321
  let listenerResults = [];
29079
29322
  function pushMergeArg(listeners = false) {
@@ -29094,7 +29337,7 @@ function buildProps(node, context, isComponent, isDynamicComponent, getEffectInd
29094
29337
  if (prop.type === 7 && !prop.arg) {
29095
29338
  if (prop.name === "bind") {
29096
29339
  if (prop.exp) {
29097
- const objectLiteralProps = isComponent ? resolveComponentObjectLiteralBindProps(prop.exp, context, props, prop) : prop === resolvedBind ? resolvedBindProps : resolveNativeObjectLiteralBindProps(prop.exp, context, props, prop);
29340
+ const objectLiteralProps = isSlot ? void 0 : isComponent ? resolveComponentObjectLiteralBindProps(prop.exp, context, props, prop) : resolveNativeObjectLiteralBindProps(prop.exp, context, props, prop);
29098
29341
  if (objectLiteralProps) {
29099
29342
  if (isComponent) pushStaticObjectLiteralProps(objectLiteralProps);
29100
29343
  else {
@@ -29117,7 +29360,7 @@ function buildProps(node, context, isComponent, isDynamicComponent, getEffectInd
29117
29360
  continue;
29118
29361
  } else if (prop.name === "on") {
29119
29362
  if (prop.exp) {
29120
- const objectLiteralProps = isComponent ? resolveComponentObjectLiteralOnProps(prop.exp, context, props, prop) : void 0;
29363
+ const objectLiteralProps = isComponent && !isSlot ? resolveComponentObjectLiteralOnProps(prop.exp, context, props, prop) : void 0;
29121
29364
  if (objectLiteralProps) pushStaticObjectLiteralProps(objectLiteralProps);
29122
29365
  else if (isComponent || mergesListeners(node, context)) {
29123
29366
  dynamicExpr.push(prop.exp);
@@ -29131,7 +29374,7 @@ function buildProps(node, context, isComponent, isDynamicComponent, getEffectInd
29131
29374
  type: 8,
29132
29375
  element: context.reference(),
29133
29376
  event: prop.exp
29134
- }, getEffectIndex);
29377
+ }, getEffectOrder);
29135
29378
  } else context.options.onError(createCompilerError(35, prop.loc));
29136
29379
  continue;
29137
29380
  }
@@ -29146,7 +29389,10 @@ function buildProps(node, context, isComponent, isDynamicComponent, getEffectInd
29146
29389
  dynamicExpr.push(result.key);
29147
29390
  if (!result.handler) dynamicExpr.push(result.value);
29148
29391
  if (deferListeners) listenerResults.push(result);
29149
- else if (isComponent && !result.key.isStatic) {
29392
+ else if (isSlot && result.handler && !result.key.isStatic) {
29393
+ pushMergeArg();
29394
+ dynamicArgs.push([resolveDirectiveResult(result)]);
29395
+ } else if (isComponent && !isSlot && !result.key.isStatic) {
29150
29396
  pushMergeArg();
29151
29397
  dynamicArgs.push(extend(resolveDirectiveResult(result), { kind: 1 }));
29152
29398
  } else results.push(result);
@@ -29160,7 +29406,7 @@ function buildProps(node, context, isComponent, isDynamicComponent, getEffectInd
29160
29406
  props: dynamicArgs,
29161
29407
  isSVG: node.ns === 1,
29162
29408
  listeners: true
29163
- }, getEffectIndex);
29409
+ }, getEffectOrder);
29164
29410
  return [false, dedupeProperties(results)];
29165
29411
  }
29166
29412
  if (dynamicArgs.length || results.some(({ key }) => !key.isStatic)) {
@@ -29173,10 +29419,10 @@ function buildProps(node, context, isComponent, isDynamicComponent, getEffectInd
29173
29419
  }
29174
29420
  return [false, dedupeProperties(results)];
29175
29421
  }
29176
- function resolveObjectLiteralProps(exp, context, keyTransform, isValidKey) {
29422
+ function resolveObjectLiteralKeys(exp, keyTransform, isValidKey) {
29177
29423
  const ast = exp.ast;
29178
29424
  if (!ast || ast.type !== "ObjectExpression") return;
29179
- const props = [];
29425
+ const keys = [];
29180
29426
  const knownKeys = /* @__PURE__ */ new Set();
29181
29427
  for (const property of ast.properties) {
29182
29428
  if (property.type !== "ObjectProperty" || property.computed) return;
@@ -29186,17 +29432,21 @@ function resolveObjectLiteralProps(exp, context, keyTransform, isValidKey) {
29186
29432
  if (keyTransform) key = keyTransform(key);
29187
29433
  if (knownKeys.has(key)) return;
29188
29434
  knownKeys.add(key);
29189
- props.push({
29190
- key: createSimpleExpression(key, true),
29191
- values: [resolveExpression(createObjectBindSubExpression(exp, property.value, context), true)]
29192
- });
29435
+ keys.push(key);
29193
29436
  }
29194
- return props;
29437
+ return keys;
29438
+ }
29439
+ function materializeObjectLiteralProps(exp, keys, context) {
29440
+ const properties = exp.ast.properties;
29441
+ return keys.map((key, i) => ({
29442
+ key: createSimpleExpression(key, true),
29443
+ values: [resolveExpression(createObjectBindSubExpression(exp, properties[i].value, context), true)]
29444
+ }));
29195
29445
  }
29196
29446
  function resolveComponentObjectLiteralBindProps(exp, context, nodeProps, currentProp) {
29197
- const props = resolveObjectLiteralProps(exp, context, void 0, isSafeObjectLiteralBindKey);
29198
- if (!props || hasComponentObjectLiteralBindConflict(nodeProps, currentProp, props)) return;
29199
- return props;
29447
+ const keys = resolveObjectLiteralKeys(exp, void 0, isSafeObjectLiteralBindKey);
29448
+ if (!keys || hasComponentObjectLiteralBindConflict(nodeProps, currentProp, keys)) return;
29449
+ return materializeObjectLiteralProps(exp, keys, context);
29200
29450
  }
29201
29451
  const listenerMerge = /* @__PURE__ */ new WeakMap();
29202
29452
  function mergesListeners(node, context) {
@@ -29227,15 +29477,20 @@ function resolveListenerMerge(node, context) {
29227
29477
  }
29228
29478
  return hasVOnObject && hasStaticListener;
29229
29479
  }
29480
+ const nativeObjectLiteralBindProps = /* @__PURE__ */ new WeakMap();
29230
29481
  function resolveNativeObjectLiteralBindProps(exp, context, nodeProps, currentProp) {
29231
- const props = resolveObjectLiteralProps(exp, context, void 0, isSafeNativeObjectLiteralBindKey);
29232
- if (!props || hasNativeObjectLiteralBindConflict(nodeProps, currentProp, props)) return;
29233
- return props;
29482
+ let props = nativeObjectLiteralBindProps.get(currentProp);
29483
+ if (props === void 0) {
29484
+ const keys = resolveObjectLiteralKeys(exp, void 0, isSafeNativeObjectLiteralBindKey);
29485
+ props = keys && !hasNativeObjectLiteralBindConflict(nodeProps, currentProp, keys) ? materializeObjectLiteralProps(exp, keys, context) : null;
29486
+ nativeObjectLiteralBindProps.set(currentProp, props);
29487
+ }
29488
+ return props || void 0;
29234
29489
  }
29235
29490
  function resolveComponentObjectLiteralOnProps(exp, context, nodeProps, currentProp) {
29236
- const props = resolveObjectLiteralProps(exp, context, toHandlerKey);
29237
- if (!props || hasComponentObjectLiteralBindConflict(nodeProps, currentProp, props)) return;
29238
- return props;
29491
+ const keys = resolveObjectLiteralKeys(exp, toHandlerKey);
29492
+ if (!keys || hasComponentObjectLiteralBindConflict(nodeProps, currentProp, keys)) return;
29493
+ return materializeObjectLiteralProps(exp, keys, context);
29239
29494
  }
29240
29495
  function isSafeNativeObjectLiteralBindKey(key) {
29241
29496
  return key !== "" && !UNSAFE_ATTR_NAME_RE.test(key) && isSafeObjectLiteralBindKey(key) && !isOn(key) && key.charCodeAt(0) !== 46 && key.charCodeAt(0) !== 94;
@@ -29243,8 +29498,8 @@ function isSafeNativeObjectLiteralBindKey(key) {
29243
29498
  function isSafeObjectLiteralBindKey(key) {
29244
29499
  return !isReservedProp(key);
29245
29500
  }
29246
- function hasComponentObjectLiteralBindConflict(props, currentProp, objectLiteralProps) {
29247
- const keys = createComponentConflictKeySet(objectLiteralProps.map((prop) => prop.key.content));
29501
+ function hasComponentObjectLiteralBindConflict(props, currentProp, objectLiteralKeys) {
29502
+ const keys = createComponentConflictKeySet(objectLiteralKeys);
29248
29503
  for (const prop of props) {
29249
29504
  if (prop === currentProp) continue;
29250
29505
  let key;
@@ -29270,8 +29525,8 @@ function hasComponentModelKey(keys, prop) {
29270
29525
  const key = arg ? arg.content : "modelValue";
29271
29526
  return hasComponentKey(keys, key) || hasComponentKey(keys, `onUpdate:${camelize(key)}`) || prop.modifiers.length > 0 && hasComponentKey(keys, getModifierPropName(key));
29272
29527
  }
29273
- function hasNativeObjectLiteralBindConflict(props, currentProp, objectLiteralProps) {
29274
- const keys = new Set(objectLiteralProps.map((prop) => prop.key.content));
29528
+ function hasNativeObjectLiteralBindConflict(props, currentProp, objectLiteralKeys) {
29529
+ const keys = new Set(objectLiteralKeys);
29275
29530
  for (const prop of props) {
29276
29531
  if (prop === currentProp) continue;
29277
29532
  let key;
@@ -29356,7 +29611,7 @@ function createStaticStyleExpression(value, context) {
29356
29611
  function transformProp(prop, node, context) {
29357
29612
  let { name } = prop;
29358
29613
  if (prop.type === 6) {
29359
- if (isReservedProp(name)) return;
29614
+ if (isReservedProp(name) && !(name === "key" && node.tagType === 2)) return;
29360
29615
  return {
29361
29616
  key: createSimpleExpression(prop.name, true, prop.nameLoc),
29362
29617
  value: prop.value ? name === "style" && node.tagType === 1 ? createStaticStyleExpression(prop.value, context) : createSimpleExpression(prop.value.content, true, prop.value.loc) : EMPTY_EXPRESSION
@@ -29420,7 +29675,7 @@ function mergePropValues(existing, incoming) {
29420
29675
  existing.values.push(...newValues);
29421
29676
  }
29422
29677
  function shouldUseCreateElement(node, context) {
29423
- return context.options.isCustomElement(node.tag) || node.tagType === 0 && node.tag === "template";
29678
+ return context.options.isCustomElement(node.tag) || node.tagType === 0 && (node.tag === "template" || node.ns !== 0 && isForeignBreakoutTag(node.tag));
29424
29679
  }
29425
29680
  //#endregion
29426
29681
  //#region packages/compiler-vapor/src/transforms/transformChildren.ts
@@ -29428,12 +29683,16 @@ const transformChildren = (node, context) => {
29428
29683
  const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
29429
29684
  if (!isFragment && node.type !== 1) return;
29430
29685
  const useCreateElement = node.type === 1 && shouldUseCreateElement(node, context);
29431
- const childTemplateCloseState = !isFragment && !useCreateElement ? getChildTemplateCloseState(context) : void 0;
29686
+ const hostsTemplate = node.type === 1 && node.tagType === 0 && !useCreateElement;
29687
+ const childTemplateCloseState = hostsTemplate ? getChildTemplateCloseState(context) : void 0;
29688
+ const childScope = hostsTemplate ? enterOpenScope(context.templateScope, node.tag, node.ns) : 0;
29432
29689
  for (const [i, child] of node.children.entries()) {
29433
29690
  const childContext = context.create(child, i);
29434
- const isInSameTemplate = childTemplateCloseState && child.type === 1 && child.tagType === 0 && isInSameTemplateAsParent(childContext);
29435
- childContext.templateCloseTags = isInSameTemplate ? childTemplateCloseState.tags : void 0;
29436
- childContext.templateCloseBlocks = isInSameTemplate ? childTemplateCloseState.blocks : false;
29691
+ const isInSameTemplate = hostsTemplate && child.type === 1 && child.tagType === 0 && keepsInTemplate(child.tag, child.ns, node.tag, childScope);
29692
+ const closeState = isInSameTemplate ? childTemplateCloseState : void 0;
29693
+ childContext.templateScope = isInSameTemplate ? childScope | 128 : 0;
29694
+ childContext.templateCloseTags = closeState && closeState.tags;
29695
+ childContext.templateCloseBlocks = !!closeState && closeState.blocks;
29437
29696
  transformNode(childContext);
29438
29697
  const childDynamic = childContext.dynamic;
29439
29698
  const createsNode = isFragment || childContext.template !== "" || childDynamic.template != null || childDynamic.id !== void 0 || childDynamic.operation !== void 0 || childDynamic.hasDynamicChild === true;
@@ -29483,6 +29742,52 @@ function processDynamicChildren(context, useCreateElement) {
29483
29742
  }
29484
29743
  unitIndex++;
29485
29744
  } else if (!(child.flags & 2)) unitIndex++;
29745
+ if (context.dynamic.hasDynamicChild) planAccess(children);
29746
+ }
29747
+ /**
29748
+ * Decide how codegen reaches each child it has to hold on to, now that the
29749
+ * children's flags, anchors and own plans are final. Static, absent and
29750
+ * appended children need no lookup; a child created by its own operation is
29751
+ * reached through its anchor at most. Adjacent lookups chain off the previous
29752
+ * one with `next()`; a placeholder gets a variable only when a lookup chains
29753
+ * off it, otherwise it is written inline into its single descendant lookup.
29754
+ */
29755
+ function planAccess(children) {
29756
+ let index = 0;
29757
+ let prev;
29758
+ let pending;
29759
+ for (const child of children) {
29760
+ if (child.flags & 2) continue;
29761
+ const id = child.anchor !== void 0 ? child.anchor : child.id;
29762
+ let uses = 0;
29763
+ if (id === void 0 && child.hasDynamicChild) {
29764
+ for (const c of child.children) if (c.access && !c.access.adjacent) uses++;
29765
+ }
29766
+ if (id === void 0 && uses === 0) {
29767
+ pending = void 0;
29768
+ index++;
29769
+ continue;
29770
+ }
29771
+ if (pending) {
29772
+ pending.kind = 1;
29773
+ prev = pending;
29774
+ pending = void 0;
29775
+ }
29776
+ const reusable = prev !== void 0 && prev.kind !== 0;
29777
+ let kind;
29778
+ if (id !== void 0) kind = 0;
29779
+ else if (uses > 1) kind = reusable ? 2 : 1;
29780
+ else kind = reusable ? 4 : 3;
29781
+ const access = child.access = {
29782
+ kind,
29783
+ index,
29784
+ adjacent: prev !== void 0 && index === prev.index + 1,
29785
+ id
29786
+ };
29787
+ if (kind === 3) pending = access;
29788
+ else prev = access;
29789
+ index++;
29790
+ }
29486
29791
  }
29487
29792
  //#endregion
29488
29793
  //#region packages/compiler-vapor/src/transforms/vOnce.ts
@@ -29511,7 +29816,7 @@ function getSiblingIf(context, reverse) {
29511
29816
  if (!parent) return;
29512
29817
  const siblings = parent.node.children;
29513
29818
  let sibling;
29514
- let i = siblings.indexOf(context.node);
29819
+ let i = context.index;
29515
29820
  while (reverse ? --i >= 0 : ++i < siblings.length) {
29516
29821
  sibling = siblings[i];
29517
29822
  if (!isCommentOrWhitespace(sibling)) break;
@@ -29561,7 +29866,7 @@ const transformText = (node, context) => {
29561
29866
  const createElementParent = parent && parent.type === 1 && shouldUseCreateElement(parent, context.parent);
29562
29867
  const isRootText = !parent || parent.type === 0 || parent.type === 1 && (parent.tagType === 3 || parent.tagType === 1);
29563
29868
  const isRawText = createElementParent || isRootText;
29564
- if (isRawText && node.content[0] === "<") {
29869
+ if (needsTextNode(parent, node.content, isRawText)) {
29565
29870
  materializeLiteralTextNode(createSimpleExpression(node.content, true, node.loc), context);
29566
29871
  return;
29567
29872
  }
@@ -29577,7 +29882,7 @@ function processInterpolation(context) {
29577
29882
  const isElementChild = parentNode.type === 1 && parentNode.tagType === 0;
29578
29883
  if (text !== null && parentNode.type !== 0 && (isElementChild || text !== "")) {
29579
29884
  const isRawText = !isElementChild || parentNode.type === 1 && shouldUseCreateElement(parentNode, context.parent);
29580
- if (isRawText && text[0] === "<") {
29885
+ if (needsTextNode(parentNode, text, isRawText)) {
29581
29886
  materializeLiteralTextNode(createSimpleExpression(text, true, context.node.loc), context);
29582
29887
  return;
29583
29888
  }
@@ -29643,6 +29948,16 @@ function registerSyntheticTextChild(context, template, values) {
29643
29948
  function processCreateElementTextContainer(children, context) {
29644
29949
  registerSyntheticTextChild(context, "", processTextLikeChildren(children, context));
29645
29950
  }
29951
+ /**
29952
+ * Text that cannot be written into a template string and is created
29953
+ * imperatively instead: unescaped text starting with "<" (the runtime only
29954
+ * turns a template into a text node when it does not start with "<", see
29955
+ * `template()` in runtime-vapor), and text other than ascii whitespace in a
29956
+ * table part, which the parser would move in front of the table.
29957
+ */
29958
+ function needsTextNode(parent, text, isRawText) {
29959
+ return isRawText && text[0] === "<" || !!parent && parent.type === 1 && parent.ns === 0 && isFosterParentingTag(parent.tag) && !isAllWhitespace(text);
29960
+ }
29646
29961
  function materializeLiteralTextNode(value, context) {
29647
29962
  const id = context.reference();
29648
29963
  context.dynamic.flags |= 6;
@@ -29775,7 +30090,7 @@ const transformVOn = (dir, node, context) => {
29775
30090
  } else if (nonDelegateModifiers) nonDelegateModifiers.push(modifier);
29776
30091
  }
29777
30092
  if (nonDelegateModifiers) modifiers = nonDelegateModifiers;
29778
- arg = resolveExpression(arg);
30093
+ arg = isSlotOutlet ? arg : resolveExpression(arg);
29779
30094
  if (arg.isStatic && arg.content.startsWith("vue:")) {
29780
30095
  if (node.tagType === 0) {
29781
30096
  context.options.onWarn(createVaporCompilerError(102, loc));
@@ -30007,7 +30322,7 @@ function processIf(node, dir, context) {
30007
30322
  const [branch, onExit] = createIfBranch(node, context);
30008
30323
  return () => {
30009
30324
  onExit();
30010
- context.dynamic.operation = _objectSpread2(_objectSpread2({
30325
+ const operation = _objectSpread2(_objectSpread2({
30011
30326
  type: 15,
30012
30327
  id
30013
30328
  }, context.effectBoundary()), {}, {
@@ -30017,25 +30332,24 @@ function processIf(node, dir, context) {
30017
30332
  index: context.root.nextIfIndex(),
30018
30333
  once: context.inVOnce || isStaticExpression(dir.exp, context.options.bindingMetadata)
30019
30334
  });
30335
+ context.dynamic.operation = operation;
30336
+ context.root.ifHeads.set(operation, context.inVOnce);
30337
+ const parent = context.parent;
30338
+ parent.ifHead = parent.ifTail = operation;
30020
30339
  };
30021
30340
  } else {
30022
30341
  const siblingIf = getSiblingIf(context, true);
30023
- const siblings = context.parent && context.parent.dynamic.children;
30024
- let lastIfNode;
30025
- if (siblings) {
30026
- let i = siblings.length;
30027
- while (i--) if (siblings[i].operation && siblings[i].operation.type === 15) {
30028
- lastIfNode = siblings[i].operation;
30029
- break;
30030
- }
30031
- }
30032
- if (!siblingIf || !lastIfNode || lastIfNode.type !== 15) {
30342
+ const parent = context.parent;
30343
+ const head = parent && parent.ifHead;
30344
+ if (!siblingIf || !head) {
30033
30345
  context.options.onError(createCompilerError(30, node.loc));
30034
30346
  return;
30035
30347
  }
30036
- while (lastIfNode.negative && lastIfNode.negative.type === 15) lastIfNode = lastIfNode.negative;
30348
+ const lastIfNode = parent.ifTail;
30349
+ context.inVOnce = parent.inVOnce && !isComponentNode(parent.node) || !!context.root.ifHeads.get(head);
30037
30350
  if (dir.name === "else-if" && lastIfNode.negative) context.options.onError(createCompilerError(30, node.loc));
30038
30351
  checkSameKey(node, context);
30352
+ if (!context.inVOnce) context.node = node = extend({}, node, { props: node.props.filter((prop) => prop.type !== 7 || prop.name !== "once") });
30039
30353
  const comments = context.comment;
30040
30354
  if (comments.length) {
30041
30355
  if (!isInTransition(context)) {
@@ -30045,8 +30359,9 @@ function processIf(node, dir, context) {
30045
30359
  comments.length = 0;
30046
30360
  }
30047
30361
  const [branch, onExit] = createIfBranch(node, context);
30048
- if (dir.name === "else") lastIfNode.negative = branch;
30049
- else lastIfNode.negative = {
30362
+ let negative;
30363
+ if (dir.name === "else") negative = branch;
30364
+ else negative = parent.ifTail = {
30050
30365
  type: 15,
30051
30366
  id: -1,
30052
30367
  condition: dir.exp,
@@ -30055,10 +30370,11 @@ function processIf(node, dir, context) {
30055
30370
  blockShape: 0,
30056
30371
  once: context.inVOnce || isStaticExpression(dir.exp, context.options.bindingMetadata)
30057
30372
  };
30373
+ lastIfNode.negative = negative;
30058
30374
  return () => {
30059
30375
  onExit();
30060
- if (lastIfNode.negative.type === 15) lastIfNode.negative.blockShape = encodeIfBlockShape(lastIfNode.negative.positive, forceMultiRoot, void 0, allowNoScope);
30061
- lastIfNode.blockShape = encodeIfBlockShape(lastIfNode.positive, forceMultiRoot, lastIfNode.negative, allowNoScope);
30376
+ if (negative.type === 15) negative.blockShape = encodeIfBlockShape(negative.positive, forceMultiRoot, void 0, allowNoScope);
30377
+ lastIfNode.blockShape = encodeIfBlockShape(lastIfNode.positive, forceMultiRoot, negative, allowNoScope);
30062
30378
  };
30063
30379
  }
30064
30380
  }
@@ -30074,14 +30390,14 @@ function createIfBranch(node, context) {
30074
30390
  return [branch, exitBlock];
30075
30391
  }
30076
30392
  function encodeIfBlockShape(positive, forceMultiRoot = false, negative, allowNoScope = true) {
30077
- if (forceMultiRoot) return 10;
30393
+ if (forceMultiRoot) return 2 | (negative && negative.type === 15 ? 3 : 2) << 2;
30078
30394
  const positiveNoScope = allowNoScope && canSkipIfBranchScope(positive);
30079
30395
  const negativeNoScope = allowNoScope && negative && negative.type !== 15 && canSkipIfBranchScope(negative);
30080
30396
  return getBlockShape(positive) | getNegativeIfBranchShape(negative) << 2 | (positiveNoScope ? 32 : 0) | (negativeNoScope ? 64 : 0);
30081
30397
  }
30082
30398
  function getNegativeIfBranchShape(negative) {
30083
30399
  if (!negative) return 0;
30084
- return negative.type === 15 ? 1 : getBlockShape(negative);
30400
+ return negative.type === 15 ? 3 : getBlockShape(negative);
30085
30401
  }
30086
30402
  function canSkipIfBranchScope(block) {
30087
30403
  if (block.effect.length || block.operation.length) return false;
@@ -30220,6 +30536,15 @@ const transformSlotOutlet = (node, context) => {
30220
30536
  if (slotProps.length) {
30221
30537
  const [isDynamic, props] = buildProps(extend({}, node, { props: slotProps }), context, true);
30222
30538
  irProps = isDynamic ? props : [props];
30539
+ if (!isDynamic) for (const prop of props) {
30540
+ const name = prop.key.content;
30541
+ if (prop.key.isStatic && !prop.handler && !prop.modifier && (name === "class" || name === "style")) {
30542
+ const value = prop.values[0];
30543
+ if (prop.values.length === 1 && value.isStatic) {
30544
+ if (name === "class") value.content = value.content.trim();
30545
+ } else prop.normalize = name;
30546
+ }
30547
+ }
30223
30548
  }
30224
30549
  return () => {
30225
30550
  exitBlock && exitBlock();
@@ -30240,6 +30565,7 @@ const transformSlotOutlet = (node, context) => {
30240
30565
  function createFallback(node, context) {
30241
30566
  if (!node.children.length) return [];
30242
30567
  context.isSingleRoot = false;
30568
+ context.isSlotRoot = false;
30243
30569
  context.node = node = extend({}, node, {
30244
30570
  type: 1,
30245
30571
  tag: "template",
@@ -30268,11 +30594,11 @@ const transformVSlot = (node, context) => {
30268
30594
  function transformComponentSlot(node, dir, context) {
30269
30595
  const { children } = node;
30270
30596
  const arg = dir && dir.arg;
30271
- const hasTemplateSlots = children.some(isSlotTemplateChild);
30597
+ const hasTemplateSlots = children.some(isSlotTemplate);
30272
30598
  const isTransitionHost = isTransitionHostNode(node);
30273
30599
  const emptyTextNodes = [];
30274
30600
  const nonSlotTemplateChildren = children.filter((n) => {
30275
- if (isSlotTemplateChild(n)) return false;
30601
+ if (isSlotTemplate(n)) return false;
30276
30602
  if (n.type === 3 && (hasTemplateSlots || isTransitionHost)) {
30277
30603
  ignoreComment(n, context);
30278
30604
  return false;
@@ -30396,9 +30722,6 @@ function isNonWhitespaceContent(node) {
30396
30722
  if (node.type !== 2) return true;
30397
30723
  return !!node.content.trim();
30398
30724
  }
30399
- function isSlotTemplateChild(node) {
30400
- return node.type === 1 && isTemplateNode(node) && !!findDir(node, "slot", true);
30401
- }
30402
30725
  //#endregion
30403
30726
  //#region packages/compiler-vapor/src/transforms/transformTransition.ts
30404
30727
  const transformTransition = (node, context) => {
@@ -30470,6 +30793,7 @@ function getBaseTransformPreset() {
30470
30793
  //#region packages/compiler-vapor/src/index.ts
30471
30794
  var src_exports$1 = /* @__PURE__ */ __exportAll({
30472
30795
  CodegenContext: () => CodegenContext,
30796
+ DynamicAccess: () => DynamicAccess,
30473
30797
  DynamicFlag: () => DynamicFlag,
30474
30798
  IRDynamicPropsKind: () => IRDynamicPropsKind,
30475
30799
  IRNodeTypes: () => IRNodeTypes,
@@ -30556,22 +30880,47 @@ registerRuntimeHelpers(ssrHelpers);
30556
30880
  //#region packages/compiler-ssr/src/transforms/ssrVIf.ts
30557
30881
  const ssrTransformIf = createStructuralDirectiveTransform$1(/^(?:if|else|else-if)$/, processIf$1);
30558
30882
  function ssrProcessIf(node, context, disableNestedFragments = false, disableComment = false) {
30559
- const [rootBranch] = node.branches;
30560
- const ifStatement = createIfStatement(rootBranch.condition, processIfBranch(rootBranch, context, disableNestedFragments));
30883
+ const { branches } = node;
30884
+ const ranged = !!context.options.vapor && hasLookalikeBranches(branches);
30885
+ const [rootBranch] = branches;
30886
+ const ifStatement = createIfStatement(rootBranch.condition, processIfBranch(rootBranch, context, disableNestedFragments, ranged && 0));
30561
30887
  context.pushStatement(ifStatement);
30562
30888
  let currentIf = ifStatement;
30563
- for (let i = 1; i < node.branches.length; i++) {
30564
- const branch = node.branches[i];
30565
- const branchBlockStatement = processIfBranch(branch, context, disableNestedFragments);
30889
+ for (let i = 1; i < branches.length; i++) {
30890
+ const branch = branches[i];
30891
+ const branchBlockStatement = processIfBranch(branch, context, disableNestedFragments, ranged && i);
30566
30892
  if (branch.condition) currentIf = currentIf.alternate = createIfStatement(branch.condition, branchBlockStatement);
30567
30893
  else currentIf.alternate = branchBlockStatement;
30568
30894
  }
30569
30895
  if (!currentIf.alternate && (!disableComment || context.options.vapor)) currentIf.alternate = createBlockStatement([createCallExpression(`_push`, ["`<!---->`"])]);
30570
30896
  }
30571
- function processIfBranch(branch, context, disableNestedFragments = false) {
30897
+ function processIfBranch(branch, context, disableNestedFragments = false, index = false) {
30898
+ if (index !== false) {
30899
+ const childContext = createChildContext(context);
30900
+ childContext.pushStringPart(`<!--[${index}-->`);
30901
+ processChildren(branch, childContext);
30902
+ childContext.pushStringPart(`<!--]-->`);
30903
+ return createBlockStatement(childContext.body);
30904
+ }
30572
30905
  const { children } = branch;
30573
30906
  return processChildrenAsStatement(branch, context, !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && !(children.length === 1 && children[0].type === 11));
30574
30907
  }
30908
+ /**
30909
+ * Whether two branches of a chain could start with the same node. Branches
30910
+ * that each render one plain element, all of different tags, are told apart
30911
+ * by the tag.
30912
+ */
30913
+ function hasLookalikeBranches(branches) {
30914
+ if (branches.length < 2) return false;
30915
+ const tags = /* @__PURE__ */ new Set();
30916
+ for (const { children } of branches) {
30917
+ const nodes = children.filter((child) => child.type !== 3);
30918
+ const root = nodes.length === 1 ? nodes[0] : void 0;
30919
+ if (!root || root.type !== 1 || root.tagType !== 0 || tags.has(root.tag)) return true;
30920
+ tags.add(root.tag);
30921
+ }
30922
+ return false;
30923
+ }
30575
30924
  //#endregion
30576
30925
  //#region packages/compiler-ssr/src/transforms/ssrVFor.ts
30577
30926
  const ssrTransformFor = createStructuralDirectiveTransform$1("for", processFor$1);
@@ -44342,7 +44691,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
44342
44691
  //#endregion
44343
44692
  //#region packages/compiler-sfc/src/index.ts
44344
44693
  init_objectSpread2();
44345
- const version = "3.6.0-rc.12";
44694
+ const version = "3.6.0-rc.14";
44346
44695
  const parseCache = parseCache$1;
44347
44696
  const errorMessages = _objectSpread2(_objectSpread2({}, errorMessages$1), DOMErrorMessages);
44348
44697
  const walk = walk$2;