@vue/compiler-core 3.6.0-alpha.3 → 3.6.0-alpha.5

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-core v3.6.0-alpha.3
2
+ * @vue/compiler-core v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -135,14 +135,6 @@ function registerRuntimeHelpers(helpers) {
135
135
  });
136
136
  }
137
137
 
138
- const Namespaces = {
139
- "HTML": 0,
140
- "0": "HTML",
141
- "SVG": 1,
142
- "1": "SVG",
143
- "MATH_ML": 2,
144
- "2": "MATH_ML"
145
- };
146
138
  const NodeTypes = {
147
139
  "ROOT": 0,
148
140
  "0": "ROOT",
@@ -2314,7 +2306,43 @@ function getMemoedVNodeCall(node) {
2314
2306
  return node;
2315
2307
  }
2316
2308
  }
2309
+ function filterNonCommentChildren(node) {
2310
+ return node.children.filter((n) => n.type !== 3);
2311
+ }
2312
+ function hasSingleChild(node) {
2313
+ return filterNonCommentChildren(node).length === 1;
2314
+ }
2315
+ function isSingleIfBlock(parent) {
2316
+ let hasEncounteredIf = false;
2317
+ for (const c of filterNonCommentChildren(parent)) {
2318
+ if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
2319
+ if (hasEncounteredIf) return false;
2320
+ hasEncounteredIf = true;
2321
+ } else if (
2322
+ // node before v-if
2323
+ !hasEncounteredIf || // non else nodes
2324
+ !(c.type === 1 && findDir(c, /^else(-if)?$/, true))
2325
+ ) {
2326
+ return false;
2327
+ }
2328
+ }
2329
+ return true;
2330
+ }
2317
2331
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2332
+ function isAllWhitespace(str) {
2333
+ for (let i = 0; i < str.length; i++) {
2334
+ if (!isWhitespace(str.charCodeAt(i))) {
2335
+ return false;
2336
+ }
2337
+ }
2338
+ return true;
2339
+ }
2340
+ function isWhitespaceText(node) {
2341
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
2342
+ }
2343
+ function isCommentOrWhitespace(node) {
2344
+ return node.type === 3 || isWhitespaceText(node);
2345
+ }
2318
2346
 
2319
2347
  const defaultParserOptions = {
2320
2348
  parseMode: "base",
@@ -2934,14 +2962,6 @@ function condenseWhitespace(nodes) {
2934
2962
  }
2935
2963
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2936
2964
  }
2937
- function isAllWhitespace(str) {
2938
- for (let i = 0; i < str.length; i++) {
2939
- if (!isWhitespace(str.charCodeAt(i))) {
2940
- return false;
2941
- }
2942
- }
2943
- return true;
2944
- }
2945
2965
  function hasNewlineChar(str) {
2946
2966
  for (let i = 0; i < str.length; i++) {
2947
2967
  const c = str.charCodeAt(i);
@@ -4662,17 +4682,14 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4662
4682
  knownIds
4663
4683
  );
4664
4684
  const children = [];
4665
- const isTSNode = TS_NODE_TYPES.includes(ast.type);
4666
4685
  ids.sort((a, b) => a.start - b.start);
4667
4686
  ids.forEach((id, i) => {
4668
4687
  const start = id.start - 1;
4669
4688
  const end = id.end - 1;
4670
4689
  const last = ids[i - 1];
4671
- if (!(isTSNode && i === 0)) {
4672
- const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4673
- if (leadingText.length || id.prefix) {
4674
- children.push(leadingText + (id.prefix || ``));
4675
- }
4690
+ const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4691
+ if (leadingText.length || id.prefix) {
4692
+ children.push(leadingText + (id.prefix || ``));
4676
4693
  }
4677
4694
  const source = rawExp.slice(start, end);
4678
4695
  children.push(
@@ -4687,7 +4704,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4687
4704
  id.isConstant ? 3 : 0
4688
4705
  )
4689
4706
  );
4690
- if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
4707
+ if (i === ids.length - 1 && end < rawExp.length) {
4691
4708
  children.push(rawExp.slice(end));
4692
4709
  }
4693
4710
  });
@@ -4784,13 +4801,11 @@ function processIf(node, dir, context, processCodegen) {
4784
4801
  let i = siblings.indexOf(node);
4785
4802
  while (i-- >= -1) {
4786
4803
  const sibling = siblings[i];
4787
- if (sibling && sibling.type === 3) {
4788
- context.removeNode(sibling);
4789
- comments.unshift(sibling);
4790
- continue;
4791
- }
4792
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
4804
+ if (sibling && isCommentOrWhitespace(sibling)) {
4793
4805
  context.removeNode(sibling);
4806
+ if (sibling.type === 3) {
4807
+ comments.unshift(sibling);
4808
+ }
4794
4809
  continue;
4795
4810
  }
4796
4811
  if (sibling && sibling.type === 9) {
@@ -5308,7 +5323,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
5308
5323
  let prev;
5309
5324
  while (j--) {
5310
5325
  prev = children[j];
5311
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
5326
+ if (!isCommentOrWhitespace(prev)) {
5312
5327
  break;
5313
5328
  }
5314
5329
  }
@@ -5386,7 +5401,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
5386
5401
  } else if (implicitDefaultChildren.length && // #3766
5387
5402
  // with whitespace: 'preserve', whitespaces between slots will end up in
5388
5403
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
5389
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
5404
+ !implicitDefaultChildren.every(isWhitespaceText)) {
5390
5405
  if (hasNamedDefaultSlot) {
5391
5406
  context.onError(
5392
5407
  createCompilerError(
@@ -5459,11 +5474,6 @@ function hasForwardedSlots(children) {
5459
5474
  }
5460
5475
  return false;
5461
5476
  }
5462
- function isNonWhitespaceContent(node) {
5463
- if (node.type !== 2 && node.type !== 12)
5464
- return true;
5465
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
5466
- }
5467
5477
 
5468
5478
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
5469
5479
  const transformElement = (node, context) => {
@@ -6490,7 +6500,7 @@ const transformModel = (dir, node, context) => {
6490
6500
  }
6491
6501
  if (dir.modifiers.length && node.tagType === 1) {
6492
6502
  const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
6493
- const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
6503
+ const modifiersKey = arg ? isStaticExp(arg) ? shared.getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
6494
6504
  props.push(
6495
6505
  createObjectProperty(
6496
6506
  modifiersKey,
@@ -6817,7 +6827,6 @@ exports.MERGE_PROPS = MERGE_PROPS;
6817
6827
  exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
6818
6828
  exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
6819
6829
  exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
6820
- exports.Namespaces = Namespaces;
6821
6830
  exports.NewlineType = NewlineType;
6822
6831
  exports.NodeTypes = NodeTypes;
6823
6832
  exports.OPEN_BLOCK = OPEN_BLOCK;
@@ -6876,6 +6885,7 @@ exports.defaultOnError = defaultOnError;
6876
6885
  exports.defaultOnWarn = defaultOnWarn;
6877
6886
  exports.errorMessages = errorMessages;
6878
6887
  exports.extractIdentifiers = extractIdentifiers;
6888
+ exports.filterNonCommentChildren = filterNonCommentChildren;
6879
6889
  exports.findDir = findDir;
6880
6890
  exports.findProp = findProp;
6881
6891
  exports.forAliasRE = forAliasRE;
@@ -6888,8 +6898,11 @@ exports.getVNodeBlockHelper = getVNodeBlockHelper;
6888
6898
  exports.getVNodeHelper = getVNodeHelper;
6889
6899
  exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
6890
6900
  exports.hasScopeRef = hasScopeRef;
6901
+ exports.hasSingleChild = hasSingleChild;
6891
6902
  exports.helperNameMap = helperNameMap;
6892
6903
  exports.injectProp = injectProp;
6904
+ exports.isAllWhitespace = isAllWhitespace;
6905
+ exports.isCommentOrWhitespace = isCommentOrWhitespace;
6893
6906
  exports.isConstantNode = isConstantNode;
6894
6907
  exports.isCoreComponent = isCoreComponent;
6895
6908
  exports.isFnExpression = isFnExpression;
@@ -6904,6 +6917,7 @@ exports.isMemberExpressionBrowser = isMemberExpressionBrowser;
6904
6917
  exports.isMemberExpressionNode = isMemberExpressionNode;
6905
6918
  exports.isReferencedIdentifier = isReferencedIdentifier;
6906
6919
  exports.isSimpleIdentifier = isSimpleIdentifier;
6920
+ exports.isSingleIfBlock = isSingleIfBlock;
6907
6921
  exports.isSlotOutlet = isSlotOutlet;
6908
6922
  exports.isStaticArgOf = isStaticArgOf;
6909
6923
  exports.isStaticExp = isStaticExp;
@@ -6914,6 +6928,7 @@ exports.isTemplateNode = isTemplateNode;
6914
6928
  exports.isText = isText$1;
6915
6929
  exports.isVPre = isVPre;
6916
6930
  exports.isVSlot = isVSlot;
6931
+ exports.isWhitespaceText = isWhitespaceText;
6917
6932
  exports.locStub = locStub;
6918
6933
  exports.noopDirectiveTransform = noopDirectiveTransform;
6919
6934
  exports.processExpression = processExpression;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.6.0-alpha.3
2
+ * @vue/compiler-core v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -135,14 +135,6 @@ function registerRuntimeHelpers(helpers) {
135
135
  });
136
136
  }
137
137
 
138
- const Namespaces = {
139
- "HTML": 0,
140
- "0": "HTML",
141
- "SVG": 1,
142
- "1": "SVG",
143
- "MATH_ML": 2,
144
- "2": "MATH_ML"
145
- };
146
138
  const NodeTypes = {
147
139
  "ROOT": 0,
148
140
  "0": "ROOT",
@@ -2310,7 +2302,43 @@ function getMemoedVNodeCall(node) {
2310
2302
  return node;
2311
2303
  }
2312
2304
  }
2305
+ function filterNonCommentChildren(node) {
2306
+ return node.children.filter((n) => n.type !== 3);
2307
+ }
2308
+ function hasSingleChild(node) {
2309
+ return filterNonCommentChildren(node).length === 1;
2310
+ }
2311
+ function isSingleIfBlock(parent) {
2312
+ let hasEncounteredIf = false;
2313
+ for (const c of filterNonCommentChildren(parent)) {
2314
+ if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
2315
+ if (hasEncounteredIf) return false;
2316
+ hasEncounteredIf = true;
2317
+ } else if (
2318
+ // node before v-if
2319
+ !hasEncounteredIf || // non else nodes
2320
+ !(c.type === 1 && findDir(c, /^else(-if)?$/, true))
2321
+ ) {
2322
+ return false;
2323
+ }
2324
+ }
2325
+ return true;
2326
+ }
2313
2327
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2328
+ function isAllWhitespace(str) {
2329
+ for (let i = 0; i < str.length; i++) {
2330
+ if (!isWhitespace(str.charCodeAt(i))) {
2331
+ return false;
2332
+ }
2333
+ }
2334
+ return true;
2335
+ }
2336
+ function isWhitespaceText(node) {
2337
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
2338
+ }
2339
+ function isCommentOrWhitespace(node) {
2340
+ return node.type === 3 || isWhitespaceText(node);
2341
+ }
2314
2342
 
2315
2343
  const defaultParserOptions = {
2316
2344
  parseMode: "base",
@@ -2900,14 +2928,6 @@ function condenseWhitespace(nodes) {
2900
2928
  }
2901
2929
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2902
2930
  }
2903
- function isAllWhitespace(str) {
2904
- for (let i = 0; i < str.length; i++) {
2905
- if (!isWhitespace(str.charCodeAt(i))) {
2906
- return false;
2907
- }
2908
- }
2909
- return true;
2910
- }
2911
2931
  function hasNewlineChar(str) {
2912
2932
  for (let i = 0; i < str.length; i++) {
2913
2933
  const c = str.charCodeAt(i);
@@ -4586,17 +4606,14 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4586
4606
  knownIds
4587
4607
  );
4588
4608
  const children = [];
4589
- const isTSNode = TS_NODE_TYPES.includes(ast.type);
4590
4609
  ids.sort((a, b) => a.start - b.start);
4591
4610
  ids.forEach((id, i) => {
4592
4611
  const start = id.start - 1;
4593
4612
  const end = id.end - 1;
4594
4613
  const last = ids[i - 1];
4595
- if (!(isTSNode && i === 0)) {
4596
- const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4597
- if (leadingText.length || id.prefix) {
4598
- children.push(leadingText + (id.prefix || ``));
4599
- }
4614
+ const leadingText = rawExp.slice(last ? last.end - 1 : 0, start);
4615
+ if (leadingText.length || id.prefix) {
4616
+ children.push(leadingText + (id.prefix || ``));
4600
4617
  }
4601
4618
  const source = rawExp.slice(start, end);
4602
4619
  children.push(
@@ -4611,7 +4628,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4611
4628
  id.isConstant ? 3 : 0
4612
4629
  )
4613
4630
  );
4614
- if (i === ids.length - 1 && end < rawExp.length && !isTSNode) {
4631
+ if (i === ids.length - 1 && end < rawExp.length) {
4615
4632
  children.push(rawExp.slice(end));
4616
4633
  }
4617
4634
  });
@@ -4707,11 +4724,7 @@ function processIf(node, dir, context, processCodegen) {
4707
4724
  let i = siblings.indexOf(node);
4708
4725
  while (i-- >= -1) {
4709
4726
  const sibling = siblings[i];
4710
- if (sibling && sibling.type === 3) {
4711
- context.removeNode(sibling);
4712
- continue;
4713
- }
4714
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
4727
+ if (sibling && isCommentOrWhitespace(sibling)) {
4715
4728
  context.removeNode(sibling);
4716
4729
  continue;
4717
4730
  }
@@ -5223,7 +5236,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
5223
5236
  let prev;
5224
5237
  while (j--) {
5225
5238
  prev = children[j];
5226
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
5239
+ if (!isCommentOrWhitespace(prev)) {
5227
5240
  break;
5228
5241
  }
5229
5242
  }
@@ -5301,7 +5314,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
5301
5314
  } else if (implicitDefaultChildren.length && // #3766
5302
5315
  // with whitespace: 'preserve', whitespaces between slots will end up in
5303
5316
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
5304
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
5317
+ !implicitDefaultChildren.every(isWhitespaceText)) {
5305
5318
  if (hasNamedDefaultSlot) {
5306
5319
  context.onError(
5307
5320
  createCompilerError(
@@ -5374,11 +5387,6 @@ function hasForwardedSlots(children) {
5374
5387
  }
5375
5388
  return false;
5376
5389
  }
5377
- function isNonWhitespaceContent(node) {
5378
- if (node.type !== 2 && node.type !== 12)
5379
- return true;
5380
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
5381
- }
5382
5390
 
5383
5391
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
5384
5392
  const transformElement = (node, context) => {
@@ -6372,7 +6380,7 @@ const transformModel = (dir, node, context) => {
6372
6380
  }
6373
6381
  if (dir.modifiers.length && node.tagType === 1) {
6374
6382
  const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
6375
- const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
6383
+ const modifiersKey = arg ? isStaticExp(arg) ? shared.getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
6376
6384
  props.push(
6377
6385
  createObjectProperty(
6378
6386
  modifiersKey,
@@ -6694,7 +6702,6 @@ exports.MERGE_PROPS = MERGE_PROPS;
6694
6702
  exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
6695
6703
  exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
6696
6704
  exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
6697
- exports.Namespaces = Namespaces;
6698
6705
  exports.NewlineType = NewlineType;
6699
6706
  exports.NodeTypes = NodeTypes;
6700
6707
  exports.OPEN_BLOCK = OPEN_BLOCK;
@@ -6753,6 +6760,7 @@ exports.defaultOnError = defaultOnError;
6753
6760
  exports.defaultOnWarn = defaultOnWarn;
6754
6761
  exports.errorMessages = errorMessages;
6755
6762
  exports.extractIdentifiers = extractIdentifiers;
6763
+ exports.filterNonCommentChildren = filterNonCommentChildren;
6756
6764
  exports.findDir = findDir;
6757
6765
  exports.findProp = findProp;
6758
6766
  exports.forAliasRE = forAliasRE;
@@ -6765,8 +6773,11 @@ exports.getVNodeBlockHelper = getVNodeBlockHelper;
6765
6773
  exports.getVNodeHelper = getVNodeHelper;
6766
6774
  exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
6767
6775
  exports.hasScopeRef = hasScopeRef;
6776
+ exports.hasSingleChild = hasSingleChild;
6768
6777
  exports.helperNameMap = helperNameMap;
6769
6778
  exports.injectProp = injectProp;
6779
+ exports.isAllWhitespace = isAllWhitespace;
6780
+ exports.isCommentOrWhitespace = isCommentOrWhitespace;
6770
6781
  exports.isConstantNode = isConstantNode;
6771
6782
  exports.isCoreComponent = isCoreComponent;
6772
6783
  exports.isFnExpression = isFnExpression;
@@ -6781,6 +6792,7 @@ exports.isMemberExpressionBrowser = isMemberExpressionBrowser;
6781
6792
  exports.isMemberExpressionNode = isMemberExpressionNode;
6782
6793
  exports.isReferencedIdentifier = isReferencedIdentifier;
6783
6794
  exports.isSimpleIdentifier = isSimpleIdentifier;
6795
+ exports.isSingleIfBlock = isSingleIfBlock;
6784
6796
  exports.isSlotOutlet = isSlotOutlet;
6785
6797
  exports.isStaticArgOf = isStaticArgOf;
6786
6798
  exports.isStaticExp = isStaticExp;
@@ -6791,6 +6803,7 @@ exports.isTemplateNode = isTemplateNode;
6791
6803
  exports.isText = isText$1;
6792
6804
  exports.isVPre = isVPre;
6793
6805
  exports.isVSlot = isVSlot;
6806
+ exports.isWhitespaceText = isWhitespaceText;
6794
6807
  exports.locStub = locStub;
6795
6808
  exports.noopDirectiveTransform = noopDirectiveTransform;
6796
6809
  exports.processExpression = processExpression;
@@ -1,4 +1,4 @@
1
- import { PatchFlags } from '@vue/shared';
1
+ import { Namespace, PatchFlags, Namespaces } from '@vue/shared';
2
2
  export { generateCodeFrame } from '@vue/shared';
3
3
  import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, SwitchCase, Program, ObjectProperty } from '@babel/types';
4
4
  import { ParserPlugin } from '@babel/parser';
@@ -83,8 +83,8 @@ interface DirectiveTransformResult {
83
83
  ssrTagParts?: TemplateLiteral['elements'];
84
84
  }
85
85
  export type StructuralDirectiveTransform = (node: ElementNode, dir: DirectiveNode, context: TransformContext) => void | (() => void);
86
- interface ImportItem {
87
- exp: string | ExpressionNode;
86
+ export interface ImportItem {
87
+ exp: SimpleExpressionNode;
88
88
  path: string;
89
89
  }
90
90
  export interface TransformContext extends Required<Omit<TransformOptions, keyof CompilerCompatOptions>>, CompilerCompatOptions {
@@ -142,12 +142,6 @@ export declare function buildProps(node: ElementNode, context: TransformContext,
142
142
  };
143
143
  export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
144
144
 
145
- export type Namespace = number;
146
- export declare enum Namespaces {
147
- HTML = 0,
148
- SVG = 1,
149
- MATH_ML = 2
150
- }
151
145
  export declare enum NodeTypes {
152
146
  ROOT = 0,
153
147
  ELEMENT = 1,
@@ -989,7 +983,6 @@ export interface BaseCodegenResult {
989
983
  }
990
984
  export interface CodegenResult extends BaseCodegenResult {
991
985
  ast: RootNode;
992
- helpers: Set<symbol>;
993
986
  }
994
987
  export declare enum NewlineType {
995
988
  /** Start with `\n` */
@@ -1060,7 +1053,13 @@ export declare function injectProp(node: VNodeCall | RenderSlotCall, prop: Prope
1060
1053
  export declare function toValidAssetId(name: string, type: 'component' | 'directive' | 'filter'): string;
1061
1054
  export declare function hasScopeRef(node: TemplateChildNode | IfBranchNode | ExpressionNode | CacheExpression | undefined, ids: TransformContext['identifiers']): boolean;
1062
1055
  export declare function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression): VNodeCall | RenderSlotCall;
1056
+ export declare function filterNonCommentChildren(node: ParentNode): TemplateChildNode[];
1057
+ export declare function hasSingleChild(node: ParentNode): boolean;
1058
+ export declare function isSingleIfBlock(parent: ParentNode): boolean;
1063
1059
  export declare const forAliasRE: RegExp;
1060
+ export declare function isAllWhitespace(str: string): boolean;
1061
+ export declare function isWhitespaceText(node: TemplateChildNode): boolean;
1062
+ export declare function isCommentOrWhitespace(node: TemplateChildNode): boolean;
1064
1063
 
1065
1064
  /**
1066
1065
  * Return value indicates whether the AST walked can be a constant
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @vue/compiler-core v3.6.0-alpha.3
2
+ * @vue/compiler-core v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- import { isString, NOOP, isObject, extend, NO, isSymbol, PatchFlagNames, isArray, EMPTY_OBJ, capitalize, camelize, makeMap, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
6
+ import { isString, NOOP, isObject, extend, NO, isSymbol, PatchFlagNames, isArray, EMPTY_OBJ, capitalize, camelize, makeMap, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey, getModifierPropName } from '@vue/shared';
7
7
  export { generateCodeFrame } from '@vue/shared';
8
8
 
9
9
  const FRAGMENT = Symbol(!!(process.env.NODE_ENV !== "production") ? `Fragment` : ``);
@@ -128,14 +128,6 @@ function registerRuntimeHelpers(helpers) {
128
128
  });
129
129
  }
130
130
 
131
- const Namespaces = {
132
- "HTML": 0,
133
- "0": "HTML",
134
- "SVG": 1,
135
- "1": "SVG",
136
- "MATH_ML": 2,
137
- "2": "MATH_ML"
138
- };
139
131
  const NodeTypes = {
140
132
  "ROOT": 0,
141
133
  "0": "ROOT",
@@ -1975,7 +1967,43 @@ function getMemoedVNodeCall(node) {
1975
1967
  return node;
1976
1968
  }
1977
1969
  }
1970
+ function filterNonCommentChildren(node) {
1971
+ return node.children.filter((n) => n.type !== 3);
1972
+ }
1973
+ function hasSingleChild(node) {
1974
+ return filterNonCommentChildren(node).length === 1;
1975
+ }
1976
+ function isSingleIfBlock(parent) {
1977
+ let hasEncounteredIf = false;
1978
+ for (const c of filterNonCommentChildren(parent)) {
1979
+ if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
1980
+ if (hasEncounteredIf) return false;
1981
+ hasEncounteredIf = true;
1982
+ } else if (
1983
+ // node before v-if
1984
+ !hasEncounteredIf || // non else nodes
1985
+ !(c.type === 1 && findDir(c, /^else(-if)?$/, true))
1986
+ ) {
1987
+ return false;
1988
+ }
1989
+ }
1990
+ return true;
1991
+ }
1978
1992
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
1993
+ function isAllWhitespace(str) {
1994
+ for (let i = 0; i < str.length; i++) {
1995
+ if (!isWhitespace(str.charCodeAt(i))) {
1996
+ return false;
1997
+ }
1998
+ }
1999
+ return true;
2000
+ }
2001
+ function isWhitespaceText(node) {
2002
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
2003
+ }
2004
+ function isCommentOrWhitespace(node) {
2005
+ return node.type === 3 || isWhitespaceText(node);
2006
+ }
1979
2007
 
1980
2008
  const defaultParserOptions = {
1981
2009
  parseMode: "base",
@@ -2598,14 +2626,6 @@ function condenseWhitespace(nodes) {
2598
2626
  }
2599
2627
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2600
2628
  }
2601
- function isAllWhitespace(str) {
2602
- for (let i = 0; i < str.length; i++) {
2603
- if (!isWhitespace(str.charCodeAt(i))) {
2604
- return false;
2605
- }
2606
- }
2607
- return true;
2608
- }
2609
2629
  function hasNewlineChar(str) {
2610
2630
  for (let i = 0; i < str.length; i++) {
2611
2631
  const c = str.charCodeAt(i);
@@ -4052,13 +4072,11 @@ function processIf(node, dir, context, processCodegen) {
4052
4072
  let i = siblings.indexOf(node);
4053
4073
  while (i-- >= -1) {
4054
4074
  const sibling = siblings[i];
4055
- if (sibling && sibling.type === 3) {
4056
- context.removeNode(sibling);
4057
- !!(process.env.NODE_ENV !== "production") && comments.unshift(sibling);
4058
- continue;
4059
- }
4060
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
4075
+ if (sibling && isCommentOrWhitespace(sibling)) {
4061
4076
  context.removeNode(sibling);
4077
+ if (!!(process.env.NODE_ENV !== "production") && sibling.type === 3) {
4078
+ comments.unshift(sibling);
4079
+ }
4062
4080
  continue;
4063
4081
  }
4064
4082
  if (sibling && sibling.type === 9) {
@@ -4530,7 +4548,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4530
4548
  let prev;
4531
4549
  while (j--) {
4532
4550
  prev = children[j];
4533
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
4551
+ if (!isCommentOrWhitespace(prev)) {
4534
4552
  break;
4535
4553
  }
4536
4554
  }
@@ -4608,7 +4626,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4608
4626
  } else if (implicitDefaultChildren.length && // #3766
4609
4627
  // with whitespace: 'preserve', whitespaces between slots will end up in
4610
4628
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
4611
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
4629
+ !implicitDefaultChildren.every(isWhitespaceText)) {
4612
4630
  if (hasNamedDefaultSlot) {
4613
4631
  context.onError(
4614
4632
  createCompilerError(
@@ -4681,11 +4699,6 @@ function hasForwardedSlots(children) {
4681
4699
  }
4682
4700
  return false;
4683
4701
  }
4684
- function isNonWhitespaceContent(node) {
4685
- if (node.type !== 2 && node.type !== 12)
4686
- return true;
4687
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
4688
- }
4689
4702
 
4690
4703
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
4691
4704
  const transformElement = (node, context) => {
@@ -5582,7 +5595,7 @@ const transformModel = (dir, node, context) => {
5582
5595
  ];
5583
5596
  if (dir.modifiers.length && node.tagType === 1) {
5584
5597
  const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
5585
- const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
5598
+ const modifiersKey = arg ? isStaticExp(arg) ? getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
5586
5599
  props.push(
5587
5600
  createObjectProperty(
5588
5601
  modifiersKey,
@@ -5880,4 +5893,4 @@ const BindingTypes = {
5880
5893
 
5881
5894
  const noopDirectiveTransform = () => ({ props: [] });
5882
5895
 
5883
- export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
5896
+ export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, filterNonCommentChildren, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, hasSingleChild, helperNameMap, injectProp, isAllWhitespace, isCommentOrWhitespace, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSingleIfBlock, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, isWhitespaceText, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.6.0-alpha.3",
3
+ "version": "3.6.0-alpha.5",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -50,7 +50,7 @@
50
50
  "entities": "^4.5.0",
51
51
  "estree-walker": "^2.0.2",
52
52
  "source-map-js": "^1.2.1",
53
- "@vue/shared": "3.6.0-alpha.3"
53
+ "@vue/shared": "3.6.0-alpha.5"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.28.5"