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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-vapor v3.6.0-beta.10
2
+ * @vue/compiler-vapor v3.6.0-beta.12
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -12,6 +12,90 @@ let _vue_shared = require("@vue/shared");
12
12
  let source_map_js = require("source-map-js");
13
13
  let _babel_parser = require("@babel/parser");
14
14
  let estree_walker = require("estree-walker");
15
+ //#region packages/compiler-vapor/src/ir/component.ts
16
+ const IRDynamicPropsKind = {
17
+ "EXPRESSION": 0,
18
+ "0": "EXPRESSION",
19
+ "ATTRIBUTE": 1,
20
+ "1": "ATTRIBUTE"
21
+ };
22
+ const IRSlotType = {
23
+ "STATIC": 0,
24
+ "0": "STATIC",
25
+ "DYNAMIC": 1,
26
+ "1": "DYNAMIC",
27
+ "LOOP": 2,
28
+ "2": "LOOP",
29
+ "CONDITIONAL": 3,
30
+ "3": "CONDITIONAL",
31
+ "EXPRESSION": 4,
32
+ "4": "EXPRESSION"
33
+ };
34
+ //#endregion
35
+ //#region packages/compiler-vapor/src/ir/index.ts
36
+ const IRNodeTypes = {
37
+ "ROOT": 0,
38
+ "0": "ROOT",
39
+ "BLOCK": 1,
40
+ "1": "BLOCK",
41
+ "SET_BLOCK_KEY": 2,
42
+ "2": "SET_BLOCK_KEY",
43
+ "SET_PROP": 3,
44
+ "3": "SET_PROP",
45
+ "SET_DYNAMIC_PROPS": 4,
46
+ "4": "SET_DYNAMIC_PROPS",
47
+ "SET_TEXT": 5,
48
+ "5": "SET_TEXT",
49
+ "SET_EVENT": 6,
50
+ "6": "SET_EVENT",
51
+ "SET_DYNAMIC_EVENTS": 7,
52
+ "7": "SET_DYNAMIC_EVENTS",
53
+ "SET_HTML": 8,
54
+ "8": "SET_HTML",
55
+ "SET_TEMPLATE_REF": 9,
56
+ "9": "SET_TEMPLATE_REF",
57
+ "INSERT_NODE": 10,
58
+ "10": "INSERT_NODE",
59
+ "PREPEND_NODE": 11,
60
+ "11": "PREPEND_NODE",
61
+ "CREATE_COMPONENT_NODE": 12,
62
+ "12": "CREATE_COMPONENT_NODE",
63
+ "SLOT_OUTLET_NODE": 13,
64
+ "13": "SLOT_OUTLET_NODE",
65
+ "DIRECTIVE": 14,
66
+ "14": "DIRECTIVE",
67
+ "IF": 15,
68
+ "15": "IF",
69
+ "FOR": 16,
70
+ "16": "FOR",
71
+ "KEY": 17,
72
+ "17": "KEY",
73
+ "GET_TEXT_CHILD": 18,
74
+ "18": "GET_TEXT_CHILD"
75
+ };
76
+ var TemplateRegistry = class {
77
+ constructor() {
78
+ this.entries = [];
79
+ }
80
+ keys() {
81
+ return this.entries.map(({ content }) => content);
82
+ }
83
+ };
84
+ const DynamicFlag = {
85
+ "NONE": 0,
86
+ "0": "NONE",
87
+ "REFERENCED": 1,
88
+ "1": "REFERENCED",
89
+ "NON_TEMPLATE": 2,
90
+ "2": "NON_TEMPLATE",
91
+ "INSERT": 4,
92
+ "4": "INSERT"
93
+ };
94
+ function isBlockOperation(op) {
95
+ const type = op.type;
96
+ return type === 12 || type === 13 || type === 15 || type === 17 || type === 16;
97
+ }
98
+ //#endregion
15
99
  //#region packages/compiler-vapor/src/transforms/utils.ts
16
100
  const newDynamic = () => ({
17
101
  flags: 1,
@@ -127,6 +211,7 @@ function isTeleportTag(tag) {
127
211
  }
128
212
  function isBuiltInComponent(tag) {
129
213
  if (isTeleportTag(tag)) return "VaporTeleport";
214
+ else if (tag === "Suspense" || tag === "suspense") return "Suspense";
130
215
  else if (isKeepAliveTag(tag)) return "VaporKeepAlive";
131
216
  else if (isTransitionTag(tag)) return "VaporTransition";
132
217
  else if (isTransitionGroupTag(tag)) return "VaporTransitionGroup";
@@ -148,6 +233,8 @@ var TransformContext = class TransformContext {
148
233
  this.index = 0;
149
234
  this.block = this.ir.block;
150
235
  this.template = "";
236
+ this.templateRoot = false;
237
+ this.templateIndexMap = /* @__PURE__ */ new Map();
151
238
  this.childrenTemplate = [];
152
239
  this.dynamic = this.ir.block.dynamic;
153
240
  this.imports = [];
@@ -157,9 +244,12 @@ var TransformContext = class TransformContext {
157
244
  this.component = this.ir.component;
158
245
  this.directive = this.ir.directive;
159
246
  this.slots = [];
247
+ this.effectIndex = this.block.effect.length;
248
+ this.operationIndex = this.block.operation.length;
160
249
  this.isLastEffectiveChild = true;
161
250
  this.isOnRightmostPath = true;
162
- this.hasInlineAncestorNeedingClose = false;
251
+ this.templateCloseTags = void 0;
252
+ this.templateCloseBlocks = false;
163
253
  this.globalId = 0;
164
254
  this.nextIdMap = null;
165
255
  this.ifIndex = 0;
@@ -174,20 +264,28 @@ var TransformContext = class TransformContext {
174
264
  this.initNextIdMap();
175
265
  }
176
266
  enterBlock(ir, isVFor = false) {
177
- const { block, template, dynamic, childrenTemplate, slots } = this;
267
+ const { block, template, templateRoot, templateIndexMap, dynamic, childrenTemplate, slots, effectIndex, operationIndex } = this;
178
268
  this.block = ir;
179
269
  this.dynamic = ir.dynamic;
180
270
  this.template = "";
271
+ this.templateRoot = false;
272
+ this.templateIndexMap = templateIndexMap;
181
273
  this.childrenTemplate = [];
182
274
  this.slots = [];
275
+ this.effectIndex = ir.effect.length;
276
+ this.operationIndex = ir.operation.length;
183
277
  isVFor && this.inVFor++;
184
278
  return () => {
185
279
  this.registerTemplate();
186
280
  this.block = block;
187
281
  this.template = template;
282
+ this.templateRoot = templateRoot;
283
+ this.templateIndexMap = templateIndexMap;
188
284
  this.dynamic = dynamic;
189
285
  this.childrenTemplate = childrenTemplate;
190
286
  this.slots = slots;
287
+ this.effectIndex = effectIndex;
288
+ this.operationIndex = operationIndex;
191
289
  isVFor && this.inVFor--;
192
290
  };
193
291
  }
@@ -212,54 +310,94 @@ var TransformContext = class TransformContext {
212
310
  nextIfIndex() {
213
311
  return this.ifIndex++;
214
312
  }
215
- pushTemplate(content) {
216
- const existingIndex = this.ir.templateIndexMap.get(content);
313
+ getTemplateNamespace() {
314
+ return this.node.type === 1 ? this.node.ns : 0;
315
+ }
316
+ canUseStaticTemplate() {
317
+ if (!this.template) return false;
318
+ if (this.inVFor) return false;
319
+ if (this.dynamic.hasDynamicChild) return false;
320
+ if (this.block.effect.length !== this.effectIndex) return false;
321
+ if (this.block.operation.length !== this.operationIndex) return false;
322
+ if (this.node.type === 2 || this.node.type === 3) return true;
323
+ return this.node.type === 1 && this.node.tagType === 0 && !(this.options.isCustomElement(this.node.tag) || this.node.tag === "template");
324
+ }
325
+ pushTemplate(content, { root = false, static: isStatic = false } = {}) {
326
+ const templateKey = JSON.stringify([
327
+ this.getTemplateNamespace(),
328
+ root,
329
+ isStatic,
330
+ content
331
+ ]);
332
+ const existingIndex = this.templateIndexMap.get(templateKey);
217
333
  if (existingIndex !== void 0) return existingIndex;
218
- const newIndex = this.ir.template.size;
219
- this.ir.template.set(content, this.node.ns);
220
- this.ir.templateIndexMap.set(content, newIndex);
334
+ const ns = this.getTemplateNamespace();
335
+ const newIndex = this.ir.template.entries.length;
336
+ this.ir.template.entries.push({
337
+ content,
338
+ ns,
339
+ root,
340
+ static: isStatic
341
+ });
342
+ this.templateIndexMap.set(templateKey, newIndex);
221
343
  return newIndex;
222
344
  }
223
345
  registerTemplate() {
224
346
  if (!this.template) return -1;
225
- const id = this.pushTemplate(this.template);
347
+ const id = this.pushTemplate(this.template, {
348
+ root: this.templateRoot,
349
+ static: this.canUseStaticTemplate()
350
+ });
226
351
  return this.dynamic.template = id;
227
352
  }
228
- registerEffect(expressions, operation, getIndex = () => this.block.effect.length) {
353
+ registerEffect(expressions, operation, getIndex) {
229
354
  const operations = [operation].flat();
230
355
  expressions = expressions.filter((exp) => !isConstantExpression(exp));
231
356
  if (this.inVOnce || expressions.length === 0 || expressions.every((e) => isStaticExpression(e, this.root.options.bindingMetadata))) return this.registerOperation(...operations);
232
- this.block.effect.splice(getIndex(), 0, {
357
+ const index = getIndex ? getIndex() : this.block.effect.length;
358
+ this.block.effect.splice(index, 0, {
233
359
  expressions,
234
360
  operations
235
361
  });
362
+ if (getIndex) this.shiftEffectBoundaries(index);
236
363
  }
237
364
  registerOperation(...node) {
238
365
  this.block.operation.push(...node);
239
366
  }
367
+ effectBoundary() {
368
+ return {
369
+ operationIndex: this.operationIndex,
370
+ effectIndex: this.effectIndex
371
+ };
372
+ }
240
373
  create(node, index) {
241
374
  let effectiveParent = this;
242
375
  while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) effectiveParent = effectiveParent.parent;
243
376
  const isLastEffectiveChild = this.isEffectivelyLastChild(index);
244
377
  const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
245
- let hasInlineAncestorNeedingClose = this.hasInlineAncestorNeedingClose;
246
- if (this.node.type === 1) {
247
- if (this.node.tag === "template") hasInlineAncestorNeedingClose = false;
248
- else if (!hasInlineAncestorNeedingClose && !this.isOnRightmostPath && (0, _vue_shared.isInlineTag)(this.node.tag)) hasInlineAncestorNeedingClose = true;
249
- }
250
378
  return Object.assign(Object.create(TransformContext.prototype), this, {
251
379
  node,
252
380
  parent: this,
253
381
  index,
254
382
  template: "",
383
+ templateRoot: false,
255
384
  childrenTemplate: [],
385
+ templateIndexMap: this.templateIndexMap,
256
386
  dynamic: newDynamic(),
387
+ effectIndex: this.block.effect.length,
388
+ operationIndex: this.block.operation.length,
257
389
  effectiveParent,
258
390
  isLastEffectiveChild,
259
391
  isOnRightmostPath,
260
- hasInlineAncestorNeedingClose
392
+ templateCloseTags: this.templateCloseTags,
393
+ templateCloseBlocks: this.templateCloseBlocks
261
394
  });
262
395
  }
396
+ shiftEffectBoundaries(index, dynamic = this.dynamic) {
397
+ const operation = dynamic.operation;
398
+ if (operation && isBlockOperation(operation) && operation.effectIndex !== void 0 && operation.effectIndex >= index) operation.effectIndex++;
399
+ for (const child of dynamic.children) this.shiftEffectBoundaries(index, child);
400
+ }
263
401
  isEffectivelyLastChild(index) {
264
402
  const children = this.node.children;
265
403
  if (!children) return true;
@@ -294,9 +432,7 @@ function transform(node, options = {}) {
294
432
  type: 0,
295
433
  node,
296
434
  source: node.source,
297
- template: /* @__PURE__ */ new Map(),
298
- templateIndexMap: /* @__PURE__ */ new Map(),
299
- rootTemplateIndexes: /* @__PURE__ */ new Set(),
435
+ template: new TemplateRegistry(),
300
436
  component: /* @__PURE__ */ new Set(),
301
437
  directive: /* @__PURE__ */ new Set(),
302
438
  block: newBlock(node),
@@ -447,6 +583,9 @@ function genCall(name, ...frags) {
447
583
  hasPlaceholder ? name[1] : "null"
448
584
  ], ...frags)];
449
585
  }
586
+ function getParserOptions(plugins) {
587
+ return { plugins: plugins ? plugins.some((plugin) => plugin === "typescript") ? plugins : [...plugins, "typescript"] : ["typescript"] };
588
+ }
450
589
  function codeFragmentToString(code, context) {
451
590
  const { options: { filename, sourceMap } } = context;
452
591
  let map;
@@ -510,82 +649,6 @@ function codeFragmentToString(code, context) {
510
649
  }
511
650
  }
512
651
  //#endregion
513
- //#region packages/compiler-vapor/src/ir/component.ts
514
- const IRDynamicPropsKind = {
515
- "EXPRESSION": 0,
516
- "0": "EXPRESSION",
517
- "ATTRIBUTE": 1,
518
- "1": "ATTRIBUTE"
519
- };
520
- const IRSlotType = {
521
- "STATIC": 0,
522
- "0": "STATIC",
523
- "DYNAMIC": 1,
524
- "1": "DYNAMIC",
525
- "LOOP": 2,
526
- "2": "LOOP",
527
- "CONDITIONAL": 3,
528
- "3": "CONDITIONAL",
529
- "EXPRESSION": 4,
530
- "4": "EXPRESSION"
531
- };
532
- //#endregion
533
- //#region packages/compiler-vapor/src/ir/index.ts
534
- const IRNodeTypes = {
535
- "ROOT": 0,
536
- "0": "ROOT",
537
- "BLOCK": 1,
538
- "1": "BLOCK",
539
- "SET_BLOCK_KEY": 2,
540
- "2": "SET_BLOCK_KEY",
541
- "SET_PROP": 3,
542
- "3": "SET_PROP",
543
- "SET_DYNAMIC_PROPS": 4,
544
- "4": "SET_DYNAMIC_PROPS",
545
- "SET_TEXT": 5,
546
- "5": "SET_TEXT",
547
- "SET_EVENT": 6,
548
- "6": "SET_EVENT",
549
- "SET_DYNAMIC_EVENTS": 7,
550
- "7": "SET_DYNAMIC_EVENTS",
551
- "SET_HTML": 8,
552
- "8": "SET_HTML",
553
- "SET_TEMPLATE_REF": 9,
554
- "9": "SET_TEMPLATE_REF",
555
- "INSERT_NODE": 10,
556
- "10": "INSERT_NODE",
557
- "PREPEND_NODE": 11,
558
- "11": "PREPEND_NODE",
559
- "CREATE_COMPONENT_NODE": 12,
560
- "12": "CREATE_COMPONENT_NODE",
561
- "SLOT_OUTLET_NODE": 13,
562
- "13": "SLOT_OUTLET_NODE",
563
- "DIRECTIVE": 14,
564
- "14": "DIRECTIVE",
565
- "IF": 15,
566
- "15": "IF",
567
- "FOR": 16,
568
- "16": "FOR",
569
- "KEY": 17,
570
- "17": "KEY",
571
- "GET_TEXT_CHILD": 18,
572
- "18": "GET_TEXT_CHILD"
573
- };
574
- const DynamicFlag = {
575
- "NONE": 0,
576
- "0": "NONE",
577
- "REFERENCED": 1,
578
- "1": "REFERENCED",
579
- "NON_TEMPLATE": 2,
580
- "2": "NON_TEMPLATE",
581
- "INSERT": 4,
582
- "4": "INSERT"
583
- };
584
- function isBlockOperation(op) {
585
- const type = op.type;
586
- return type === 12 || type === 13 || type === 15 || type === 17 || type === 16;
587
- }
588
- //#endregion
589
652
  //#region packages/compiler-vapor/src/generators/dom.ts
590
653
  function genInsertNode({ parent, elements, anchor }, { helper }) {
591
654
  let element = elements.map((el) => `n${el}`).join(", ");
@@ -905,9 +968,7 @@ function escapeRegExp(string) {
905
968
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
906
969
  }
907
970
  function parseExp(context, content) {
908
- const plugins = context.options.expressionPlugins;
909
- const options = { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] };
910
- return (0, _babel_parser.parseExpression)(`(${content})`, options);
971
+ return (0, _babel_parser.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
911
972
  }
912
973
  function genVarName(exp) {
913
974
  return `${exp.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/_+$/, "")}`;
@@ -1085,16 +1146,12 @@ function genFor(oper, context) {
1085
1146
  idMap[rawIndex] = `${indexVar}.value`;
1086
1147
  idMap[indexVar] = null;
1087
1148
  }
1088
- const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
1149
+ const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap, context);
1089
1150
  const selectorDeclarations = [];
1090
- const selectorSetup = [];
1151
+ const selectorName = (i) => selectorPatterns.length > 1 ? `_selector${id}_${i}` : `_selector${id}`;
1091
1152
  for (let i = 0; i < selectorPatterns.length; i++) {
1092
1153
  const { selector } = selectorPatterns[i];
1093
- const selectorName = `_selector${id}_${i}`;
1094
- selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
1095
- if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
1096
- selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
1097
- if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
1154
+ selectorDeclarations.push(`const ${selectorName(i)} = `, ...genCall(helper("createSelector"), [`() => `, ...genExpression(selector, context)]), NEWLINE);
1098
1155
  }
1099
1156
  const blockFn = context.withId(() => {
1100
1157
  const frag = [];
@@ -1103,7 +1160,7 @@ function genFor(oper, context) {
1103
1160
  const patternFrag = [];
1104
1161
  for (let i = 0; i < selectorPatterns.length; i++) {
1105
1162
  const { effect } = selectorPatterns[i];
1106
- patternFrag.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
1163
+ patternFrag.push(NEWLINE, `${selectorName(i)}(`, ...genExpression(keyProp, context), `, () => {`, INDENT_START);
1107
1164
  for (const oper of effect.operations) patternFrag.push(...genOperation(oper, context));
1108
1165
  patternFrag.push(INDENT_END, NEWLINE, `})`);
1109
1166
  }
@@ -1119,11 +1176,14 @@ function genFor(oper, context) {
1119
1176
  if (onlyChild) flags |= 1;
1120
1177
  if (component) flags |= 2;
1121
1178
  if (once) flags |= 4;
1179
+ const onResetCalls = [];
1180
+ for (let i = 0; i < selectorPatterns.length; i++) onResetCalls.push(NEWLINE, `n${id}.onReset(${selectorName(i)}.reset)`);
1122
1181
  return [
1123
1182
  NEWLINE,
1124
1183
  ...selectorDeclarations,
1125
1184
  `const n${id} = `,
1126
- ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0, selectorSetup.length ? selectorSetup : void 0)
1185
+ ...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0),
1186
+ ...onResetCalls
1127
1187
  ];
1128
1188
  function genCallback(expr) {
1129
1189
  if (!expr) return false;
@@ -1209,35 +1269,49 @@ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
1209
1269
  }
1210
1270
  if (pathInfo.dynamic) {
1211
1271
  const node = idMap[id] = (0, _vue_compiler_dom.createSimpleExpression)(path);
1212
- node.ast = (0, _babel_parser.parseExpression)(`(${path})`, { plugins: plugins ? [...plugins, "typescript"] : ["typescript"] });
1272
+ node.ast = (0, _babel_parser.parseExpression)(`(${path})`, getParserOptions(plugins));
1213
1273
  } else idMap[id] = path;
1214
1274
  } else idMap[id] = path;
1215
1275
  });
1216
1276
  return idMap;
1217
1277
  }
1218
- function matchPatterns(render, keyProp, idMap) {
1278
+ function matchPatterns(render, keyProp, idMap, context) {
1219
1279
  const selectorPatterns = [];
1220
1280
  const keyOnlyBindingPatterns = [];
1221
- render.effect = render.effect.filter((effect) => {
1281
+ const removedEffectIndexes = [];
1282
+ render.effect = render.effect.filter((effect, index) => {
1222
1283
  if (keyProp !== void 0) {
1223
- const selector = matchSelectorPattern(effect, keyProp.content, idMap);
1284
+ const selector = matchSelectorPattern(effect, keyProp.content, idMap, context);
1224
1285
  if (selector) {
1225
1286
  selectorPatterns.push(selector);
1287
+ removedEffectIndexes.push(index);
1226
1288
  return false;
1227
1289
  }
1228
1290
  const keyOnly = matchKeyOnlyBindingPattern(effect, keyProp.content);
1229
1291
  if (keyOnly) {
1230
1292
  keyOnlyBindingPatterns.push(keyOnly);
1293
+ removedEffectIndexes.push(index);
1231
1294
  return false;
1232
1295
  }
1233
1296
  }
1234
1297
  return true;
1235
1298
  });
1299
+ if (removedEffectIndexes.length) shiftEffectBoundaries(render.dynamic, removedEffectIndexes);
1236
1300
  return {
1237
1301
  keyOnlyBindingPatterns,
1238
1302
  selectorPatterns
1239
1303
  };
1240
1304
  }
1305
+ function shiftEffectBoundaries(dynamic, removedEffectIndexes) {
1306
+ const operation = dynamic.operation;
1307
+ if (operation && isBlockOperation(operation) && operation.effectIndex !== void 0) {
1308
+ let offset = 0;
1309
+ for (const removedIndex of removedEffectIndexes) if (removedIndex < operation.effectIndex) offset++;
1310
+ else break;
1311
+ operation.effectIndex -= offset;
1312
+ }
1313
+ for (const child of dynamic.children) shiftEffectBoundaries(child, removedEffectIndexes);
1314
+ }
1241
1315
  function matchKeyOnlyBindingPattern(effect, key) {
1242
1316
  if (effect.expressions.length === 1) {
1243
1317
  const { ast, content } = effect.expressions[0];
@@ -1246,7 +1320,7 @@ function matchKeyOnlyBindingPattern(effect, key) {
1246
1320
  }
1247
1321
  }
1248
1322
  }
1249
- function matchSelectorPattern(effect, key, idMap) {
1323
+ function matchSelectorPattern(effect, key, idMap, context) {
1250
1324
  if (effect.expressions.length === 1) {
1251
1325
  const { ast, content } = effect.expressions[0];
1252
1326
  if (typeof ast === "object" && ast) {
@@ -1271,17 +1345,11 @@ function matchSelectorPattern(effect, key, idMap) {
1271
1345
  }, false);
1272
1346
  if (!hasExtraId) {
1273
1347
  const name = content.slice(selector.start - 1, selector.end - 1);
1348
+ const selectorExpression = (0, _vue_compiler_dom.createSimpleExpression)(name, false, selector.loc);
1349
+ selectorExpression.ast = (0, _babel_parser.parseExpression)(`(${name})`, getParserOptions(context.options.expressionPlugins));
1274
1350
  return {
1275
1351
  effect,
1276
- selector: {
1277
- content: name,
1278
- ast: (0, _vue_shared.extend)({}, selector, {
1279
- start: 1,
1280
- end: name.length + 1
1281
- }),
1282
- loc: selector.loc,
1283
- isStatic: false
1284
- }
1352
+ selector: selectorExpression
1285
1353
  };
1286
1354
  }
1287
1355
  }
@@ -1343,6 +1411,7 @@ const helpers = {
1343
1411
  setText: { name: "setText" },
1344
1412
  setHtml: { name: "setHtml" },
1345
1413
  setClass: { name: "setClass" },
1414
+ setClassName: { name: "setClassName" },
1346
1415
  setStyle: { name: "setStyle" },
1347
1416
  setValue: { name: "setValue" },
1348
1417
  setAttr: {
@@ -1362,9 +1431,132 @@ function genSetProp(oper, context) {
1362
1431
  const { helper } = context;
1363
1432
  const { prop: { key, values, modifier }, tag } = oper;
1364
1433
  const resolvedHelper = getRuntimeHelper(tag, key.content, modifier);
1434
+ if (key.content === "class" && !resolvedHelper.isSVG && resolvedHelper.name === "setClass") {
1435
+ const className = genSetClassName(oper, context);
1436
+ if (className) return className;
1437
+ }
1365
1438
  const propValue = genPropValue(values, context);
1366
1439
  return [NEWLINE, ...genCall([helper(resolvedHelper.name), null], `n${oper.element}`, resolvedHelper.needKey ? genExpression(key, context) : false, propValue, resolvedHelper.isSVG && "true")];
1367
1440
  }
1441
+ const MAX_CLASS_NAME_ENTRIES = 31;
1442
+ function genSetClassName(oper, context) {
1443
+ const info = resolveClassName(oper.prop.values, context);
1444
+ if (!info) return;
1445
+ const { helper } = context;
1446
+ const flags = genClassFlags(info.entries, context);
1447
+ const classFragments = info.entries.map((entry) => JSON.stringify(!info.prefix && info.entries.length === 1 ? entry.className : ` ${entry.className}`));
1448
+ const fragments = classFragments.length === 1 ? classFragments[0] : genMulti(DELIMITERS_ARRAY, ...classFragments);
1449
+ return [NEWLINE, ...genCall([helper("setClassName"), "\"\""], `n${oper.element}`, flags, fragments, info.prefix && JSON.stringify(info.prefix), info.suffix && JSON.stringify(info.suffix))];
1450
+ }
1451
+ function resolveClassName(values, context) {
1452
+ let prefix = "";
1453
+ let suffix = "";
1454
+ const entries = [];
1455
+ let sawDynamic = false;
1456
+ let sawSuffix = false;
1457
+ for (const value of values) {
1458
+ const staticValue = getLiteralExpressionValue(value, true);
1459
+ if (staticValue != null) {
1460
+ const normalized = (0, _vue_shared.normalizeClass)(staticValue);
1461
+ if (normalized) if (sawSuffix) suffix = appendClass(suffix, normalized);
1462
+ else if (sawDynamic) {
1463
+ sawSuffix = true;
1464
+ suffix = appendClass(suffix, normalized);
1465
+ } else prefix = appendClass(prefix, normalized);
1466
+ continue;
1467
+ }
1468
+ const ast = value.ast;
1469
+ if (!ast || sawSuffix) return;
1470
+ sawDynamic = true;
1471
+ if (ast.type === "ObjectExpression") {
1472
+ if (!resolveObjectClassName(value, ast, entries, context)) return;
1473
+ } else if (ast.type === "ConditionalExpression") {
1474
+ if (!resolveConditionalClassName(value, ast, entries, context)) return;
1475
+ } else return;
1476
+ }
1477
+ return entries.length && entries.length <= MAX_CLASS_NAME_ENTRIES ? {
1478
+ prefix,
1479
+ suffix,
1480
+ entries
1481
+ } : void 0;
1482
+ }
1483
+ function resolveObjectClassName(source, ast, entries, context) {
1484
+ for (const prop of ast.properties) {
1485
+ if (prop.type !== "ObjectProperty" || prop.computed) return false;
1486
+ const rawClassName = getObjectPropertyName(prop);
1487
+ if (rawClassName == null) return false;
1488
+ const className = (0, _vue_shared.normalizeClass)(rawClassName);
1489
+ if (!className) continue;
1490
+ const value = getBooleanValue(prop.value);
1491
+ entries.push({
1492
+ className,
1493
+ value,
1494
+ condition: value == null ? createSubExpression(source, prop.value, context) : void 0
1495
+ });
1496
+ }
1497
+ return true;
1498
+ }
1499
+ function resolveConditionalClassName(source, ast, entries, context) {
1500
+ const consequent = getStringClassValue(ast.consequent);
1501
+ const alternate = getStringClassValue(ast.alternate);
1502
+ if (consequent && alternate === "") {
1503
+ entries.push({
1504
+ className: consequent,
1505
+ condition: createSubExpression(source, ast.test, context)
1506
+ });
1507
+ return true;
1508
+ } else if (alternate && consequent === "") {
1509
+ entries.push({
1510
+ className: alternate,
1511
+ condition: createSubExpression(source, ast.test, context),
1512
+ negate: true
1513
+ });
1514
+ return true;
1515
+ }
1516
+ return false;
1517
+ }
1518
+ function genClassFlags(entries, context) {
1519
+ const values = [];
1520
+ entries.forEach((entry, index) => {
1521
+ if (index) values.push(" | ");
1522
+ const bit = 1 << index;
1523
+ if (entry.value != null) {
1524
+ values.push(entry.value ? String(bit) : "0");
1525
+ return;
1526
+ }
1527
+ values.push("(", ...genExpression(entry.condition, context), entry.negate ? ` ? 0 : ${bit}` : ` ? ${bit} : 0`, ")");
1528
+ });
1529
+ return values;
1530
+ }
1531
+ function appendClass(base, value) {
1532
+ return base ? value ? `${base} ${value}` : base : value;
1533
+ }
1534
+ function getObjectPropertyName(prop) {
1535
+ const key = prop.key;
1536
+ if (key.type === "Identifier") return key.name;
1537
+ else if (key.type === "StringLiteral") return key.value;
1538
+ else if (key.type === "NumericLiteral") return String(key.value);
1539
+ }
1540
+ function getStringClassValue(node) {
1541
+ if (node.type === "StringLiteral") return (0, _vue_shared.normalizeClass)(node.value);
1542
+ else if (node.type === "TemplateLiteral" && node.expressions.length === 0) return (0, _vue_shared.normalizeClass)(node.quasis[0].value.cooked || "");
1543
+ else if (node.type === "NullLiteral" || node.type === "BooleanLiteral" && !node.value) return "";
1544
+ }
1545
+ function getBooleanValue(node) {
1546
+ if (node.type === "BooleanLiteral") return node.value;
1547
+ }
1548
+ function createSubExpression(source, node, context) {
1549
+ const start = node.start == null ? 0 : node.start - 1;
1550
+ const end = node.end == null ? source.content.length : node.end - 1;
1551
+ const content = source.content.slice(start, end);
1552
+ const expression = (0, _vue_compiler_dom.createSimpleExpression)(content, false, {
1553
+ start: (0, _vue_compiler_dom.advancePositionWithClone)(source.loc.start, source.content, start),
1554
+ end: (0, _vue_compiler_dom.advancePositionWithClone)(source.loc.start, source.content, end),
1555
+ source: content
1556
+ });
1557
+ expression.ast = (0, _vue_compiler_dom.isSimpleIdentifier)(content) ? null : (0, _babel_parser.parseExpression)(`(${content})`, getParserOptions(context.options.expressionPlugins));
1558
+ return expression;
1559
+ }
1368
1560
  function genDynamicProps$1(oper, context) {
1369
1561
  const { helper } = context;
1370
1562
  const isSVG = (0, _vue_shared.isSVGTag)(oper.tag);
@@ -1553,11 +1745,11 @@ function genCreateComponent(operation, context) {
1553
1745
  ];
1554
1746
  }, []),
1555
1747
  `const n${operation.id} = `,
1556
- ...genCall(operation.dynamic && !operation.dynamic.isStatic ? helper("createDynamicComponent") : operation.isCustomElement ? helper("createPlainElement") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, root ? "true" : false, once && "true"),
1748
+ ...genCall(operation.dynamic && !operation.dynamic.isStatic ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, root ? "true" : false, once && "true"),
1557
1749
  ...genDirectivesForElement(operation.id, context)
1558
1750
  ];
1559
1751
  function genTag() {
1560
- if (operation.isCustomElement) return JSON.stringify(operation.tag);
1752
+ if (operation.useCreateElement) return JSON.stringify(operation.tag);
1561
1753
  else if (operation.dynamic) if (operation.dynamic.isStatic) return genCall(helper("resolveDynamicComponent"), genExpression(operation.dynamic, context));
1562
1754
  else return [
1563
1755
  "() => (",
@@ -1774,11 +1966,23 @@ function genDynamicSlot(slot, context, withFunction = false) {
1774
1966
  frag = genConditionalSlot(slot, context);
1775
1967
  break;
1776
1968
  }
1777
- return withFunction ? [
1969
+ if (!withFunction) return frag;
1970
+ return needsDynamicSlotSourceCtx(slot) ? [
1971
+ `${context.helper("withVaporCtx")}(() => (`,
1972
+ ...frag,
1973
+ "))"
1974
+ ] : [
1778
1975
  "() => (",
1779
1976
  ...frag,
1780
1977
  ")"
1781
- ] : frag;
1978
+ ];
1979
+ }
1980
+ function needsDynamicSlotSourceCtx(slot) {
1981
+ switch (slot.slotType) {
1982
+ case 1: return needsVaporCtx(slot.fn);
1983
+ case 2: return needsVaporCtx(slot.fn);
1984
+ case 3: return needsDynamicSlotSourceCtx(slot.positive) || (slot.negative ? needsDynamicSlotSourceCtx(slot.negative) : false);
1985
+ }
1782
1986
  }
1783
1987
  function genBasicDynamicSlot(slot, context) {
1784
1988
  const { name, fn } = slot;
@@ -1993,21 +2197,24 @@ function genEffect({ operations }, context) {
1993
2197
  return frag;
1994
2198
  }
1995
2199
  function genInsertionState(operation, context) {
1996
- const { parent, anchor, logicalIndex, append, last } = operation;
1997
- return [NEWLINE, ...genCall(context.helper("setInsertionState"), `n${parent}`, anchor == null ? void 0 : anchor === -1 ? `0` : append ? "null" : `n${anchor}`, logicalIndex !== void 0 ? String(logicalIndex) : void 0, last && "true")];
2200
+ const { parent, anchor, logicalIndex, append } = operation;
2201
+ return [NEWLINE, ...genCall(context.helper("setInsertionState"), `n${parent}`, anchor == null ? void 0 : anchor === -1 ? `0` : append ? "null" : `n${anchor}`, logicalIndex !== void 0 ? String(logicalIndex) : void 0)];
1998
2202
  }
1999
2203
  //#endregion
2000
2204
  //#region packages/compiler-vapor/src/generators/template.ts
2001
- function genTemplates(templates, rootIndexes, context) {
2205
+ function genTemplates(templates, context) {
2002
2206
  const result = [];
2003
- let i = 0;
2004
- templates.forEach((ns, template) => {
2005
- result.push(`const ${context.tName(i)} = ${context.helper("template")}(${JSON.stringify(template).replace(IMPORT_EXPR_RE, `" + $1 + "`)}${rootIndexes.has(i) ? ", true" : ns ? ", false" : ""}${ns ? `, ${ns}` : ""})\n`);
2006
- i++;
2207
+ templates.forEach(({ content, ns, root, static: isStatic }, i) => {
2208
+ let args = JSON.stringify(content).replace(IMPORT_EXPR_RE, `" + $1 + "`);
2209
+ if (root) args += ", true";
2210
+ else if (isStatic || ns) args += ", false";
2211
+ if (isStatic || ns) args += `, ${isStatic ? "true" : "false"}`;
2212
+ if (ns) args += `, ${ns}`;
2213
+ result.push(`const ${context.tName(i)} = ${context.helper("template")}(${args})\n`);
2007
2214
  });
2008
2215
  return result.join("");
2009
2216
  }
2010
- function genSelf(dynamic, context) {
2217
+ function genSelf(dynamic, context, flushBeforeDynamic) {
2011
2218
  const [frag, push] = buildCodeFragment();
2012
2219
  const { id, template, operation, hasDynamicChild } = dynamic;
2013
2220
  if (id !== void 0 && template !== void 0) {
@@ -2015,10 +2222,10 @@ function genSelf(dynamic, context) {
2015
2222
  push(...genDirectivesForElement(id, context));
2016
2223
  }
2017
2224
  if (operation) push(...genOperationWithInsertionState(operation, context));
2018
- if (hasDynamicChild) push(...genChildren(dynamic, context, push, `n${id}`));
2225
+ if (hasDynamicChild) push(...genChildren(dynamic, context, push, `n${id}`, flushBeforeDynamic));
2019
2226
  return frag;
2020
2227
  }
2021
- function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
2228
+ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`, flushBeforeDynamic) {
2022
2229
  const { helper } = context;
2023
2230
  const [frag, push] = buildCodeFragment();
2024
2231
  const { children } = dynamic;
@@ -2027,12 +2234,14 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
2027
2234
  for (const [index, child] of children.entries()) {
2028
2235
  if (child.flags & 2) offset--;
2029
2236
  if (child.flags & 4 && child.template != null) {
2030
- push(...genSelf(child, context));
2237
+ flushBeforeDynamic && flushBeforeDynamic(child, push);
2238
+ push(...genSelf(child, context, flushBeforeDynamic));
2031
2239
  continue;
2032
2240
  }
2033
2241
  const id = child.flags & 1 ? child.flags & 4 ? child.anchor : child.id : void 0;
2034
2242
  if (id === void 0 && !child.hasDynamicChild) {
2035
- push(...genSelf(child, context));
2243
+ flushBeforeDynamic && flushBeforeDynamic(child, push);
2244
+ push(...genSelf(child, context, flushBeforeDynamic));
2036
2245
  continue;
2037
2246
  }
2038
2247
  const elementIndex = index + offset;
@@ -2048,10 +2257,13 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
2048
2257
  else if (elementIndex > 1) init = genCall(helper("nthChild"), from, String(elementIndex), logicalIndex);
2049
2258
  pushBlock(...init);
2050
2259
  }
2051
- if (id === child.anchor && !child.hasDynamicChild) push(...genSelf(child, context));
2260
+ if (id === child.anchor && !child.hasDynamicChild) {
2261
+ flushBeforeDynamic && flushBeforeDynamic(child, push);
2262
+ push(...genSelf(child, context, flushBeforeDynamic));
2263
+ }
2052
2264
  if (id !== void 0) push(...genDirectivesForElement(id, context));
2053
2265
  prev = [variable, elementIndex];
2054
- push(...genChildren(child, context, pushBlock, variable));
2266
+ push(...genChildren(child, context, pushBlock, variable, flushBeforeDynamic));
2055
2267
  }
2056
2268
  return frag;
2057
2269
  }
@@ -2082,10 +2294,30 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
2082
2294
  }
2083
2295
  genResolveAssets("directive", "resolveDirective");
2084
2296
  }
2085
- for (const child of dynamic.children) push(...genSelf(child, context));
2086
- for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`));
2087
- push(...genOperations(operation, context));
2088
- push(...genEffects(effect, context, genEffectsExtraFrag));
2297
+ let operationIndex = 0;
2298
+ let effectIndex = 0;
2299
+ const flushPendingOperations = (operationEnd, effectEnd, push) => {
2300
+ while (operationIndex < operationEnd) {
2301
+ push(...genOperationWithInsertionState(operation[operationIndex], context));
2302
+ operationIndex++;
2303
+ }
2304
+ if (effectIndex < effectEnd) {
2305
+ push(...genEffects(effect.slice(effectIndex, effectEnd), context));
2306
+ effectIndex = effectEnd;
2307
+ }
2308
+ };
2309
+ const flushBeforeDynamic = (dynamic, push) => {
2310
+ const operation = dynamic.operation;
2311
+ if (operation && isBlockOperation(operation) && operation.operationIndex !== void 0 && operation.effectIndex !== void 0) flushPendingOperations(operation.operationIndex, operation.effectIndex, push);
2312
+ };
2313
+ for (const child of dynamic.children) {
2314
+ flushBeforeDynamic(child, push);
2315
+ push(...genSelf(child, context, flushBeforeDynamic));
2316
+ }
2317
+ for (const child of dynamic.children) if (!child.hasDynamicChild) push(...genChildren(child, context, push, `n${child.id}`, flushBeforeDynamic));
2318
+ if (operationIndex < operation.length) push(...genOperations(operation.slice(operationIndex), context));
2319
+ if (effectIndex < effect.length) push(...genEffects(effect.slice(effectIndex), context, genEffectsExtraFrag));
2320
+ else if (genEffectsExtraFrag) push(...genEffects([], context, genEffectsExtraFrag));
2089
2321
  push(NEWLINE, `return `);
2090
2322
  const returnNodes = returns.map((n) => `n${n}`);
2091
2323
  push(...returnNodes.length > 1 ? genMulti(DELIMITERS_ARRAY, ...returnNodes) : [returnNodes[0] || "null"]);
@@ -2171,7 +2403,7 @@ var CodegenContext = class {
2171
2403
  this.nextIdMap = /* @__PURE__ */ new Map();
2172
2404
  this.lastIdMap = /* @__PURE__ */ new Map();
2173
2405
  this.lastTIndex = -1;
2174
- this.options = (0, _vue_shared.extend)({
2406
+ const defaultOptions = {
2175
2407
  mode: "module",
2176
2408
  prefixIdentifiers: true,
2177
2409
  sourceMap: false,
@@ -2186,7 +2418,8 @@ var CodegenContext = class {
2186
2418
  inline: false,
2187
2419
  bindingMetadata: {},
2188
2420
  expressionPlugins: []
2189
- }, options);
2421
+ };
2422
+ this.options = (0, _vue_shared.extend)(defaultOptions, options);
2190
2423
  this.block = ir.block;
2191
2424
  this.bindingNames = new Set(this.options.bindingMetadata ? Object.keys(this.options.bindingMetadata) : []);
2192
2425
  this.initNextIdMap();
@@ -2207,7 +2440,7 @@ function generate(ir, options = {}) {
2207
2440
  push(INDENT_END, NEWLINE);
2208
2441
  if (!inline) push("}");
2209
2442
  const delegates = genDelegates(context);
2210
- const templates = genTemplates(ir.template, ir.rootTemplateIndexes, context);
2443
+ const templates = genTemplates(ir.template.entries, context);
2211
2444
  const preamble = genHelperImports(context) + genAssetImports(context) + templates + delegates;
2212
2445
  const newlineCount = [...preamble].filter((c) => c === "\n").length;
2213
2446
  if (newlineCount && !inline) frag.unshift(...new Array(newlineCount).fill(LF));
@@ -2239,88 +2472,15 @@ function genAssetImports({ ir }) {
2239
2472
  return imports;
2240
2473
  }
2241
2474
  //#endregion
2242
- //#region packages/compiler-vapor/src/transforms/transformChildren.ts
2243
- const transformChildren = (node, context) => {
2244
- const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
2245
- if (!isFragment && node.type !== 1) return;
2246
- for (const [i, child] of node.children.entries()) {
2247
- const childContext = context.create(child, i);
2248
- transformNode(childContext);
2249
- const childDynamic = childContext.dynamic;
2250
- if (isFragment) {
2251
- childContext.reference();
2252
- childContext.registerTemplate();
2253
- if (!(childDynamic.flags & 2) || childDynamic.flags & 4) context.block.returns.push(childContext.dynamic.id);
2254
- } else context.childrenTemplate.push(childContext.template);
2255
- if (childDynamic.hasDynamicChild || childDynamic.id !== void 0 || childDynamic.flags & 2 || childDynamic.flags & 4) context.dynamic.hasDynamicChild = true;
2256
- context.dynamic.children[i] = childDynamic;
2257
- }
2258
- if (!isFragment) processDynamicChildren(context);
2259
- };
2260
- function processDynamicChildren(context) {
2261
- let prevDynamics = [];
2262
- let staticCount = 0;
2263
- let dynamicCount = 0;
2264
- let lastInsertionChild;
2265
- const children = context.dynamic.children;
2266
- let logicalIndex = 0;
2267
- for (const [index, child] of children.entries()) {
2268
- if (child.flags & 4) {
2269
- child.logicalIndex = logicalIndex;
2270
- prevDynamics.push(lastInsertionChild = child);
2271
- logicalIndex++;
2272
- }
2273
- if (!(child.flags & 2)) {
2274
- child.logicalIndex = logicalIndex;
2275
- if (prevDynamics.length) {
2276
- if (staticCount) {
2277
- context.childrenTemplate[index - prevDynamics.length] = `<!>`;
2278
- prevDynamics[0].flags -= 2;
2279
- const anchor = prevDynamics[0].anchor = context.increaseId();
2280
- registerInsertion(prevDynamics, context, anchor);
2281
- } else registerInsertion(prevDynamics, context, -1);
2282
- dynamicCount += prevDynamics.length;
2283
- prevDynamics = [];
2284
- }
2285
- staticCount++;
2286
- logicalIndex++;
2287
- }
2475
+ //#region packages/compiler-vapor/src/transforms/vBind.ts
2476
+ function normalizeBindShorthand(arg, context) {
2477
+ if (arg.type !== 4 || !arg.isStatic) {
2478
+ context.options.onError((0, _vue_compiler_dom.createCompilerError)(53, arg.loc));
2479
+ return (0, _vue_compiler_dom.createSimpleExpression)("", true, arg.loc);
2288
2480
  }
2289
- if (prevDynamics.length) registerInsertion(prevDynamics, context, dynamicCount + staticCount, true);
2290
- if (lastInsertionChild && lastInsertionChild.operation) lastInsertionChild.operation.last = true;
2291
- }
2292
- function registerInsertion(dynamics, context, anchor, append) {
2293
- for (const child of dynamics) {
2294
- const logicalIndex = child.logicalIndex;
2295
- if (child.template != null) context.registerOperation({
2296
- type: 10,
2297
- elements: dynamics.map((child) => child.id),
2298
- parent: context.reference(),
2299
- anchor: append ? void 0 : anchor
2300
- });
2301
- else if (child.operation && isBlockOperation(child.operation)) {
2302
- child.operation.parent = context.reference();
2303
- child.operation.anchor = anchor;
2304
- child.operation.logicalIndex = logicalIndex;
2305
- child.operation.append = append;
2306
- }
2307
- }
2308
- }
2309
- //#endregion
2310
- //#region packages/compiler-vapor/src/transforms/vOnce.ts
2311
- const transformVOnce = (node, context) => {
2312
- if (node.type === 1 && (0, _vue_compiler_dom.findDir)(node, "once", true)) context.inVOnce = true;
2313
- };
2314
- //#endregion
2315
- //#region packages/compiler-vapor/src/transforms/vBind.ts
2316
- function normalizeBindShorthand(arg, context) {
2317
- if (arg.type !== 4 || !arg.isStatic) {
2318
- context.options.onError((0, _vue_compiler_dom.createCompilerError)(53, arg.loc));
2319
- return (0, _vue_compiler_dom.createSimpleExpression)("", true, arg.loc);
2320
- }
2321
- const exp = (0, _vue_compiler_dom.createSimpleExpression)((0, _vue_shared.camelize)(arg.content), false, arg.loc);
2322
- exp.ast = null;
2323
- return exp;
2481
+ const exp = (0, _vue_compiler_dom.createSimpleExpression)((0, _vue_shared.camelize)(arg.content), false, arg.loc);
2482
+ exp.ast = null;
2483
+ return exp;
2324
2484
  }
2325
2485
  const transformVBind = (dir, node, context) => {
2326
2486
  const { loc, modifiers } = dir;
@@ -2361,13 +2521,13 @@ const transformElement = (node, context) => {
2361
2521
  return function postTransformElement() {
2362
2522
  ({node} = context);
2363
2523
  if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) return;
2364
- const isCustomElement = !!context.options.isCustomElement(node.tag);
2365
- const isComponent = node.tagType === 1 || isCustomElement;
2524
+ const useCreateElement = shouldUseCreateElement(node, context);
2525
+ const isComponent = node.tagType === 1 || useCreateElement;
2366
2526
  const isDynamicComponent = isComponentTag(node.tag);
2367
2527
  const staticKey = resolveStaticKey(node, context, isComponent);
2368
2528
  const propsResult = buildProps(node, context, isComponent, isDynamicComponent, getEffectIndex);
2369
2529
  const singleRoot = isSingleRoot(context);
2370
- if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, isCustomElement);
2530
+ if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement);
2371
2531
  else transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectIndex, context.root === context.effectiveParent || canOmitEndTag(node, context));
2372
2532
  if (parentSlots) context.slots = parentSlots;
2373
2533
  };
@@ -2376,11 +2536,35 @@ function canOmitEndTag(node, context) {
2376
2536
  const { block, parent } = context;
2377
2537
  if (!parent) return false;
2378
2538
  if (block !== parent.block) return true;
2539
+ if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || (0, _vue_shared.isAlwaysCloseTag)(node.tag) || (0, _vue_shared.isFormattingTag)(node.tag)) || context.templateCloseBlocks && (0, _vue_shared.isBlockTag)(node.tag)) return false;
2379
2540
  if ((0, _vue_shared.isAlwaysCloseTag)(node.tag) && !context.isOnRightmostPath) return false;
2380
2541
  if ((0, _vue_shared.isFormattingTag)(node.tag) || parent.node.type === 1 && node.tag === parent.node.tag) return context.isOnRightmostPath;
2381
- if ((0, _vue_shared.isBlockTag)(node.tag) && context.hasInlineAncestorNeedingClose) return false;
2382
2542
  return context.isLastEffectiveChild;
2383
2543
  }
2544
+ function getChildTemplateCloseState(context) {
2545
+ const { node } = context;
2546
+ if (node.type !== 1 || node.tagType !== 0 || shouldUseCreateElement(node, context)) return;
2547
+ const inSameTemplateAsParent = isInSameTemplateAsParent(context);
2548
+ const inheritedTags = inSameTemplateAsParent ? context.templateCloseTags : void 0;
2549
+ const inheritedBlocks = inSameTemplateAsParent && context.templateCloseBlocks;
2550
+ if (context.root === context.effectiveParent || canOmitEndTag(node, context) || (0, _vue_shared.isVoidTag)(node.tag)) return inheritedTags || inheritedBlocks ? {
2551
+ tags: inheritedTags,
2552
+ blocks: inheritedBlocks
2553
+ } : void 0;
2554
+ const tags = new Set(inheritedTags);
2555
+ tags.add(node.tag);
2556
+ return {
2557
+ tags,
2558
+ blocks: inheritedBlocks || (0, _vue_shared.isInlineTag)(node.tag)
2559
+ };
2560
+ }
2561
+ function isInSameTemplateAsParent(context) {
2562
+ const { parent, node, block } = context;
2563
+ if (!parent || block !== parent.block) return false;
2564
+ const parentNode = parent.node;
2565
+ if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
2566
+ return !shouldUseCreateElement(parentNode, parent) && (0, _vue_compiler_dom.isValidHTMLNesting)(parentNode.tag, node.tag);
2567
+ }
2384
2568
  function isSingleRoot(context) {
2385
2569
  if (context.inVFor) return false;
2386
2570
  let { parent } = context;
@@ -2391,11 +2575,11 @@ function isSingleRoot(context) {
2391
2575
  }
2392
2576
  return context.root === parent;
2393
2577
  }
2394
- function transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, isCustomElement) {
2578
+ function transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement) {
2395
2579
  const dynamicComponent = isDynamicComponent ? resolveDynamicComponent(node) : void 0;
2396
2580
  let { tag } = node;
2397
2581
  let asset = true;
2398
- if (!dynamicComponent && !isCustomElement) {
2582
+ if (!dynamicComponent && !useCreateElement) {
2399
2583
  const fromSetup = resolveSetupReference(tag, context);
2400
2584
  if (fromSetup) {
2401
2585
  tag = fromSetup;
@@ -2424,6 +2608,7 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
2424
2608
  context.dynamic.operation = {
2425
2609
  type: 12,
2426
2610
  id,
2611
+ ...context.effectBoundary(),
2427
2612
  tag,
2428
2613
  props: propsResult[0] ? propsResult[1] : [propsResult[1]],
2429
2614
  asset,
@@ -2431,7 +2616,7 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
2431
2616
  slots: [...context.slots],
2432
2617
  once: context.inVOnce,
2433
2618
  dynamic: dynamicComponent,
2434
- isCustomElement
2619
+ useCreateElement
2435
2620
  };
2436
2621
  if (staticKey) context.registerOperation(createSetBlockKey(id, staticKey));
2437
2622
  context.slots = [];
@@ -2493,7 +2678,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
2493
2678
  }
2494
2679
  template += `>` + context.childrenTemplate.join("");
2495
2680
  if (!(0, _vue_shared.isVoidTag)(tag) && !omitEndTag) template += `</${tag}>`;
2496
- if (singleRoot) context.ir.rootTemplateIndexes.add(context.ir.template.size);
2681
+ context.templateRoot = singleRoot;
2497
2682
  if (context.parent && context.parent.node.type === 1 && !(0, _vue_compiler_dom.isValidHTMLNesting)(context.parent.node.tag, tag)) {
2498
2683
  context.reference();
2499
2684
  context.dynamic.template = context.pushTemplate(template);
@@ -2634,6 +2819,89 @@ function mergePropValues(existing, incoming) {
2634
2819
  function isComponentTag(tag) {
2635
2820
  return tag === "component" || tag === "Component";
2636
2821
  }
2822
+ function shouldUseCreateElement(node, context) {
2823
+ return context.options.isCustomElement(node.tag) || node.tagType === 0 && node.tag === "template";
2824
+ }
2825
+ //#endregion
2826
+ //#region packages/compiler-vapor/src/transforms/transformChildren.ts
2827
+ const transformChildren = (node, context) => {
2828
+ const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
2829
+ if (!isFragment && node.type !== 1) return;
2830
+ const useCreateElement = node.type === 1 && shouldUseCreateElement(node, context);
2831
+ const childTemplateCloseState = !isFragment && !useCreateElement ? getChildTemplateCloseState(context) : void 0;
2832
+ for (const [i, child] of node.children.entries()) {
2833
+ const childContext = context.create(child, i);
2834
+ const isInSameTemplate = childTemplateCloseState && child.type === 1 && child.tagType === 0 && isInSameTemplateAsParent(childContext);
2835
+ childContext.templateCloseTags = isInSameTemplate ? childTemplateCloseState.tags : void 0;
2836
+ childContext.templateCloseBlocks = isInSameTemplate ? childTemplateCloseState.blocks : false;
2837
+ transformNode(childContext);
2838
+ const childDynamic = childContext.dynamic;
2839
+ if (isFragment) {
2840
+ childContext.reference();
2841
+ childContext.registerTemplate();
2842
+ if (!(childDynamic.flags & 2) || childDynamic.flags & 4) context.block.returns.push(childContext.dynamic.id);
2843
+ } else if (useCreateElement) {
2844
+ if (childContext.template !== "" || childDynamic.template != null || childDynamic.id !== void 0 || childDynamic.operation !== void 0 || childDynamic.hasDynamicChild === true) {
2845
+ childContext.reference();
2846
+ childContext.registerTemplate();
2847
+ childDynamic.flags |= 6;
2848
+ }
2849
+ } else context.childrenTemplate.push(childContext.template);
2850
+ if (childDynamic.hasDynamicChild || childDynamic.id !== void 0 || childDynamic.flags & 2 || childDynamic.flags & 4) context.dynamic.hasDynamicChild = true;
2851
+ context.dynamic.children[i] = childDynamic;
2852
+ }
2853
+ if (!isFragment) processDynamicChildren(context);
2854
+ };
2855
+ function processDynamicChildren(context) {
2856
+ let prevDynamics = [];
2857
+ let staticCount = 0;
2858
+ const children = context.dynamic.children;
2859
+ let logicalIndex = 0;
2860
+ for (const [index, child] of children.entries()) {
2861
+ if (child.flags & 4) {
2862
+ child.logicalIndex = logicalIndex;
2863
+ prevDynamics.push(child);
2864
+ logicalIndex++;
2865
+ }
2866
+ if (!(child.flags & 2)) {
2867
+ child.logicalIndex = logicalIndex;
2868
+ if (prevDynamics.length) {
2869
+ if (staticCount) {
2870
+ context.childrenTemplate[index - prevDynamics.length] = `<!>`;
2871
+ prevDynamics[0].flags -= 2;
2872
+ const anchor = prevDynamics[0].anchor = context.increaseId();
2873
+ registerInsertion(prevDynamics, context, anchor);
2874
+ } else registerInsertion(prevDynamics, context, -1);
2875
+ prevDynamics = [];
2876
+ }
2877
+ staticCount++;
2878
+ logicalIndex++;
2879
+ }
2880
+ }
2881
+ if (prevDynamics.length) registerInsertion(prevDynamics, context, prevDynamics[0].logicalIndex, true);
2882
+ }
2883
+ function registerInsertion(dynamics, context, anchor, append) {
2884
+ for (const child of dynamics) {
2885
+ const logicalIndex = child.logicalIndex;
2886
+ if (child.template != null) context.registerOperation({
2887
+ type: 10,
2888
+ elements: dynamics.map((child) => child.id),
2889
+ parent: context.reference(),
2890
+ anchor: append ? void 0 : anchor
2891
+ });
2892
+ else if (child.operation && isBlockOperation(child.operation)) {
2893
+ child.operation.parent = context.reference();
2894
+ child.operation.anchor = anchor;
2895
+ child.operation.logicalIndex = logicalIndex;
2896
+ child.operation.append = append;
2897
+ }
2898
+ }
2899
+ }
2900
+ //#endregion
2901
+ //#region packages/compiler-vapor/src/transforms/vOnce.ts
2902
+ const transformVOnce = (node, context) => {
2903
+ if (node.type === 1 && (0, _vue_compiler_dom.findDir)(node, "once", true)) context.inVOnce = true;
2904
+ };
2637
2905
  //#endregion
2638
2906
  //#region packages/compiler-vapor/src/transforms/vHtml.ts
2639
2907
  const transformVHtml = (dir, node, context) => {
@@ -2674,6 +2942,141 @@ function makeMap$1(str) {
2674
2942
  */
2675
2943
  const isVoidTag = /* @__PURE__ */ makeMap$1("area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr");
2676
2944
  //#endregion
2945
+ //#region packages/compiler-vapor/src/transforms/transformText.ts
2946
+ const seen = /* @__PURE__ */ new WeakMap();
2947
+ function markNonTemplate(node, context) {
2948
+ let seenNodes = seen.get(context.root);
2949
+ if (!seenNodes) {
2950
+ seenNodes = /* @__PURE__ */ new WeakSet();
2951
+ seen.set(context.root, seenNodes);
2952
+ }
2953
+ seenNodes.add(node);
2954
+ }
2955
+ const transformText = (node, context) => {
2956
+ if (!seen.has(context.root)) seen.set(context.root, /* @__PURE__ */ new WeakSet());
2957
+ if (seen.get(context.root).has(node)) {
2958
+ context.dynamic.flags |= 2;
2959
+ return;
2960
+ }
2961
+ const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
2962
+ if ((isFragment || node.type === 1 && node.tagType === 0) && node.children.length) {
2963
+ let hasInterp = false;
2964
+ let isAllTextLike = true;
2965
+ for (const c of node.children) if (c.type === 5) hasInterp = true;
2966
+ else if (c.type !== 2) isAllTextLike = false;
2967
+ if (!isFragment && isAllTextLike && hasInterp) {
2968
+ const elementContext = context;
2969
+ if (shouldUseCreateElement(node, elementContext)) processCreateElementTextContainer(node.children, elementContext);
2970
+ else processTextContainer(node.children, elementContext);
2971
+ } else if (hasInterp) for (let i = 0; i < node.children.length; i++) {
2972
+ const c = node.children[i];
2973
+ const prev = node.children[i - 1];
2974
+ if (c.type === 5 && prev && prev.type === 2) markNonTemplate(prev, context);
2975
+ }
2976
+ } else if (node.type === 5) processInterpolation(context);
2977
+ else if (node.type === 2) {
2978
+ var _context$parent;
2979
+ const parent = (_context$parent = context.parent) === null || _context$parent === void 0 ? void 0 : _context$parent.node;
2980
+ if (parent && parent.type === 1 && shouldUseCreateElement(parent, context.parent) && node.content[0] === "<") {
2981
+ materializeLiteralTextNode((0, _vue_compiler_dom.createSimpleExpression)(node.content, true, node.loc), context);
2982
+ return;
2983
+ }
2984
+ const isRootText = !parent || parent.type === 0 || parent.type === 1 && (parent.tagType === 3 || parent.tagType === 1);
2985
+ context.template += isRootText ? node.content : (0, _vue_shared.escapeHtml)(node.content);
2986
+ }
2987
+ };
2988
+ function processInterpolation(context) {
2989
+ const parentNode = context.parent.node;
2990
+ const children = parentNode.children;
2991
+ const nexts = children.slice(context.index);
2992
+ const idx = nexts.findIndex((n) => !isTextLike(n));
2993
+ const nodes = idx > -1 ? nexts.slice(0, idx) : nexts;
2994
+ const prev = children[context.index - 1];
2995
+ if (prev && prev.type === 2) nodes.unshift(prev);
2996
+ const values = processTextLikeChildren(nodes, context);
2997
+ if (values.length === 0 && parentNode.type !== 0) return;
2998
+ const literalValues = values.map((v) => getLiteralExpressionValue(v));
2999
+ if (literalValues.every((v) => v != null) && parentNode.type !== 0) {
3000
+ const text = literalValues.join("");
3001
+ if (parentNode.type === 1 && shouldUseCreateElement(parentNode, context.parent) && text[0] === "<") {
3002
+ materializeLiteralTextNode((0, _vue_compiler_dom.createSimpleExpression)(text, true, context.node.loc), context);
3003
+ return;
3004
+ }
3005
+ const isElementChild = parentNode.type === 1 && parentNode.tagType === 0;
3006
+ context.template += isElementChild ? (0, _vue_shared.escapeHtml)(text) : text;
3007
+ return;
3008
+ }
3009
+ context.template += " ";
3010
+ const id = context.reference();
3011
+ if (values.length === 0) return;
3012
+ context.registerEffect(values, {
3013
+ type: 5,
3014
+ element: id,
3015
+ values
3016
+ });
3017
+ }
3018
+ function processTextContainer(children, context) {
3019
+ const values = processTextLikeChildren(children, context);
3020
+ const literals = values.map((value) => getLiteralExpressionValue(value));
3021
+ if (literals.every((l) => l != null)) context.childrenTemplate = literals.map((l) => (0, _vue_shared.escapeHtml)(String(l)));
3022
+ else {
3023
+ context.childrenTemplate = [" "];
3024
+ context.registerOperation({
3025
+ type: 18,
3026
+ parent: context.reference()
3027
+ });
3028
+ context.registerEffect(values, {
3029
+ type: 5,
3030
+ element: context.reference(),
3031
+ values,
3032
+ generated: true
3033
+ });
3034
+ }
3035
+ }
3036
+ function registerSyntheticTextChild(context, template, values) {
3037
+ const id = context.increaseId();
3038
+ context.dynamic.children[context.node.children.length] = {
3039
+ id,
3040
+ flags: 6,
3041
+ children: [],
3042
+ template: context.pushTemplate(template)
3043
+ };
3044
+ context.dynamic.hasDynamicChild = true;
3045
+ if (values && values.length) context.registerEffect(values, {
3046
+ type: 5,
3047
+ element: id,
3048
+ values
3049
+ });
3050
+ return id;
3051
+ }
3052
+ function processCreateElementTextContainer(children, context) {
3053
+ registerSyntheticTextChild(context, "", processTextLikeChildren(children, context));
3054
+ }
3055
+ function materializeLiteralTextNode(value, context) {
3056
+ const id = context.reference();
3057
+ context.dynamic.flags |= 6;
3058
+ context.dynamic.template = context.pushTemplate("");
3059
+ context.registerEffect([value], {
3060
+ type: 5,
3061
+ element: id,
3062
+ values: [value]
3063
+ });
3064
+ }
3065
+ function processTextLikeChildren(nodes, context) {
3066
+ const exps = [];
3067
+ for (const node of nodes) {
3068
+ let exp;
3069
+ markNonTemplate(node, context);
3070
+ if (node.type === 2) exp = (0, _vue_compiler_dom.createSimpleExpression)(node.content, true, node.loc);
3071
+ else exp = node.content;
3072
+ if (exp.content) exps.push(exp);
3073
+ }
3074
+ return exps;
3075
+ }
3076
+ function isTextLike(node) {
3077
+ return node.type === 5 || node.type === 2;
3078
+ }
3079
+ //#endregion
2677
3080
  //#region packages/compiler-vapor/src/transforms/vText.ts
2678
3081
  const transformVText = (dir, node, context) => {
2679
3082
  let { exp, loc } = dir;
@@ -2684,22 +3087,41 @@ const transformVText = (dir, node, context) => {
2684
3087
  if (node.children.length) {
2685
3088
  context.options.onError((0, _vue_compiler_dom.createDOMCompilerError)(57, loc));
2686
3089
  context.childrenTemplate.length = 0;
3090
+ for (const child of node.children) markNonTemplate(child, context);
2687
3091
  }
2688
3092
  if (isVoidTag(context.node.tag)) return;
2689
3093
  const literal = getLiteralExpressionValue(exp);
2690
- if (literal != null) context.childrenTemplate = [String(literal)];
2691
- else {
2692
- context.childrenTemplate = [" "];
2693
- const isComponent = node.tagType === 1;
2694
- if (!isComponent) context.registerOperation({
2695
- type: 18,
3094
+ const useCreateElement = shouldUseCreateElement(context.node, context);
3095
+ if (literal != null) if (useCreateElement) {
3096
+ const id = registerSyntheticTextChild(context, "", [exp]);
3097
+ context.registerOperation({
3098
+ type: 10,
3099
+ elements: [id],
2696
3100
  parent: context.reference()
2697
3101
  });
3102
+ } else context.childrenTemplate = [String(literal)];
3103
+ else {
3104
+ const isComponent = node.tagType === 1;
3105
+ let id;
3106
+ if (useCreateElement) {
3107
+ id = registerSyntheticTextChild(context, "");
3108
+ context.registerOperation({
3109
+ type: 10,
3110
+ elements: [id],
3111
+ parent: context.reference()
3112
+ });
3113
+ } else if (!isComponent) {
3114
+ context.childrenTemplate = [" "];
3115
+ context.registerOperation({
3116
+ type: 18,
3117
+ parent: context.reference()
3118
+ });
3119
+ }
2698
3120
  context.registerEffect([exp], {
2699
3121
  type: 5,
2700
- element: context.reference(),
3122
+ element: useCreateElement ? id : context.reference(),
2701
3123
  values: [exp],
2702
- generated: true,
3124
+ generated: !useCreateElement,
2703
3125
  isComponent
2704
3126
  });
2705
3127
  }
@@ -2713,6 +3135,7 @@ const transformVOn = (dir, node, context) => {
2713
3135
  const isSlotOutlet = node.tag === "slot";
2714
3136
  if (!exp && !modifiers.length) context.options.onError((0, _vue_compiler_dom.createCompilerError)(35, loc));
2715
3137
  arg = resolveExpression(arg);
3138
+ if (arg.isStatic && arg.content.startsWith("vue:")) arg = (0, _vue_shared.extend)({}, arg, { content: `vnode-${arg.content.slice(4)}` });
2716
3139
  const { keyModifiers, nonKeyModifiers, eventOptionModifiers } = (0, _vue_compiler_dom.resolveModifiers)(arg.isStatic ? `on${arg.content}` : arg, modifiers, null, loc);
2717
3140
  let keyOverride;
2718
3141
  const isStaticClick = arg.isStatic && arg.content.toLowerCase() === "click";
@@ -2812,96 +3235,6 @@ const transformTemplateRef = (node, context) => {
2812
3235
  };
2813
3236
  };
2814
3237
  //#endregion
2815
- //#region packages/compiler-vapor/src/transforms/transformText.ts
2816
- const seen = /* @__PURE__ */ new WeakMap();
2817
- function markNonTemplate(node, context) {
2818
- seen.get(context.root).add(node);
2819
- }
2820
- const transformText = (node, context) => {
2821
- if (!seen.has(context.root)) seen.set(context.root, /* @__PURE__ */ new WeakSet());
2822
- if (seen.get(context.root).has(node)) {
2823
- context.dynamic.flags |= 2;
2824
- return;
2825
- }
2826
- const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
2827
- if ((isFragment || node.type === 1 && node.tagType === 0) && node.children.length) {
2828
- let hasInterp = false;
2829
- let isAllTextLike = true;
2830
- for (const c of node.children) if (c.type === 5) hasInterp = true;
2831
- else if (c.type !== 2) isAllTextLike = false;
2832
- if (!isFragment && isAllTextLike && hasInterp) processTextContainer(node.children, context);
2833
- else if (hasInterp) for (let i = 0; i < node.children.length; i++) {
2834
- const c = node.children[i];
2835
- const prev = node.children[i - 1];
2836
- if (c.type === 5 && prev && prev.type === 2) markNonTemplate(prev, context);
2837
- }
2838
- } else if (node.type === 5) processInterpolation(context);
2839
- else if (node.type === 2) {
2840
- var _context$parent;
2841
- const parent = (_context$parent = context.parent) === null || _context$parent === void 0 ? void 0 : _context$parent.node;
2842
- const isRootText = !parent || parent.type === 0 || parent.type === 1 && (parent.tagType === 3 || parent.tagType === 1);
2843
- context.template += isRootText ? node.content : (0, _vue_shared.escapeHtml)(node.content);
2844
- }
2845
- };
2846
- function processInterpolation(context) {
2847
- const parentNode = context.parent.node;
2848
- const children = parentNode.children;
2849
- const nexts = children.slice(context.index);
2850
- const idx = nexts.findIndex((n) => !isTextLike(n));
2851
- const nodes = idx > -1 ? nexts.slice(0, idx) : nexts;
2852
- const prev = children[context.index - 1];
2853
- if (prev && prev.type === 2) nodes.unshift(prev);
2854
- const values = processTextLikeChildren(nodes, context);
2855
- if (values.length === 0 && parentNode.type !== 0) return;
2856
- const literalValues = values.map((v) => getLiteralExpressionValue(v));
2857
- if (literalValues.every((v) => v != null) && parentNode.type !== 0) {
2858
- const text = literalValues.join("");
2859
- const isElementChild = parentNode.type === 1 && parentNode.tagType === 0;
2860
- context.template += isElementChild ? (0, _vue_shared.escapeHtml)(text) : text;
2861
- return;
2862
- }
2863
- context.template += " ";
2864
- const id = context.reference();
2865
- if (values.length === 0) return;
2866
- context.registerEffect(values, {
2867
- type: 5,
2868
- element: id,
2869
- values
2870
- });
2871
- }
2872
- function processTextContainer(children, context) {
2873
- const values = processTextLikeChildren(children, context);
2874
- const literals = values.map((value) => getLiteralExpressionValue(value));
2875
- if (literals.every((l) => l != null)) context.childrenTemplate = literals.map((l) => (0, _vue_shared.escapeHtml)(String(l)));
2876
- else {
2877
- context.childrenTemplate = [" "];
2878
- context.registerOperation({
2879
- type: 18,
2880
- parent: context.reference()
2881
- });
2882
- context.registerEffect(values, {
2883
- type: 5,
2884
- element: context.reference(),
2885
- values,
2886
- generated: true
2887
- });
2888
- }
2889
- }
2890
- function processTextLikeChildren(nodes, context) {
2891
- const exps = [];
2892
- for (const node of nodes) {
2893
- let exp;
2894
- markNonTemplate(node, context);
2895
- if (node.type === 2) exp = (0, _vue_compiler_dom.createSimpleExpression)(node.content, true, node.loc);
2896
- else exp = node.content;
2897
- if (exp.content) exps.push(exp);
2898
- }
2899
- return exps;
2900
- }
2901
- function isTextLike(node) {
2902
- return node.type === 5 || node.type === 2;
2903
- }
2904
- //#endregion
2905
3238
  //#region packages/compiler-vapor/src/transforms/vModel.ts
2906
3239
  const transformVModel = (dir, node, context) => {
2907
3240
  const { exp, arg } = dir;
@@ -3021,6 +3354,7 @@ function processIf(node, dir, context) {
3021
3354
  context.dynamic.operation = {
3022
3355
  type: 15,
3023
3356
  id,
3357
+ ...context.effectBoundary(),
3024
3358
  blockShape: encodeIfBlockShape(branch, forceMultiRoot),
3025
3359
  condition: dir.exp,
3026
3360
  positive: branch,
@@ -3121,6 +3455,7 @@ function processFor(node, dir, context) {
3121
3455
  context.dynamic.operation = {
3122
3456
  type: 16,
3123
3457
  id,
3458
+ ...context.effectBoundary(),
3124
3459
  source,
3125
3460
  value,
3126
3461
  key,
@@ -3173,6 +3508,7 @@ const transformSlotOutlet = (node, context) => {
3173
3508
  context.dynamic.operation = {
3174
3509
  type: 13,
3175
3510
  id,
3511
+ ...context.effectBoundary(),
3176
3512
  name: slotName,
3177
3513
  props: irProps,
3178
3514
  fallback,
@@ -3372,6 +3708,7 @@ const transformKey = (node, context) => {
3372
3708
  context.dynamic.operation = {
3373
3709
  type: 17,
3374
3710
  id,
3711
+ ...context.effectBoundary(),
3375
3712
  value,
3376
3713
  block
3377
3714
  };
@@ -3439,6 +3776,7 @@ exports.DynamicFlag = DynamicFlag;
3439
3776
  exports.IRDynamicPropsKind = IRDynamicPropsKind;
3440
3777
  exports.IRNodeTypes = IRNodeTypes;
3441
3778
  exports.IRSlotType = IRSlotType;
3779
+ exports.TemplateRegistry = TemplateRegistry;
3442
3780
  exports.VaporErrorCodes = VaporErrorCodes;
3443
3781
  exports.VaporErrorMessages = VaporErrorMessages;
3444
3782
  exports.buildCodeFragment = buildCodeFragment;