@vue/compiler-core 3.4.0-alpha.2 → 3.4.0-alpha.4

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,6 +1,6 @@
1
+ import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, Program, ObjectProperty } from '@babel/types';
1
2
  import { ParserPlugin } from '@babel/parser';
2
3
  import { RawSourceMap, SourceMapGenerator } from 'source-map-js';
3
- import { Node as Node$1, Identifier, Function, BlockStatement as BlockStatement$1, Program, ObjectProperty } from '@babel/types';
4
4
  export { generateCodeFrame } from '@vue/shared';
5
5
 
6
6
  export declare const FRAGMENT: unique symbol;
@@ -45,7 +45,7 @@ export declare const IS_MEMO_SAME: unique symbol;
45
45
  export declare const helperNameMap: Record<symbol, string>;
46
46
  export declare function registerRuntimeHelpers(helpers: Record<symbol, string>): void;
47
47
 
48
- type OptionalOptions = 'decodeEntities' | 'whitespace' | 'isNativeTag' | 'isBuiltInComponent' | keyof CompilerCompatOptions;
48
+ type OptionalOptions = 'decodeEntities' | 'whitespace' | 'isNativeTag' | 'isBuiltInComponent' | 'expressionPlugins' | keyof CompilerCompatOptions;
49
49
  type MergedParserOptions = Omit<Required<ParserOptions>, OptionalOptions> & Pick<ParserOptions, OptionalOptions>;
50
50
  export declare function baseParse(input: string, options?: ParserOptions): RootNode;
51
51
 
@@ -55,7 +55,7 @@ type CompilerCompatConfig = Partial<Record<CompilerDeprecationTypes, boolean | '
55
55
  interface CompilerCompatOptions {
56
56
  compatConfig?: CompilerCompatConfig;
57
57
  }
58
- export declare const enum CompilerDeprecationTypes {
58
+ export declare enum CompilerDeprecationTypes {
59
59
  COMPILER_IS_ON_ELEMENT = "COMPILER_IS_ON_ELEMENT",
60
60
  COMPILER_V_BIND_SYNC = "COMPILER_V_BIND_SYNC",
61
61
  COMPILER_V_BIND_OBJECT_ORDER = "COMPILER_V_BIND_OBJECT_ORDER",
@@ -134,12 +134,12 @@ export declare function buildProps(node: ElementNode, context: TransformContext,
134
134
  export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
135
135
 
136
136
  export type Namespace = number;
137
- export declare const enum Namespaces {
137
+ export declare enum Namespaces {
138
138
  HTML = 0,
139
139
  SVG = 1,
140
140
  MATH_ML = 2
141
141
  }
142
- export declare const enum NodeTypes {
142
+ export declare enum NodeTypes {
143
143
  ROOT = 0,
144
144
  ELEMENT = 1,
145
145
  TEXT = 2,
@@ -168,7 +168,7 @@ export declare const enum NodeTypes {
168
168
  JS_SEQUENCE_EXPRESSION = 25,
169
169
  JS_RETURN_STATEMENT = 26
170
170
  }
171
- export declare const enum ElementTypes {
171
+ export declare enum ElementTypes {
172
172
  ELEMENT = 0,
173
173
  COMPONENT = 1,
174
174
  SLOT = 2,
@@ -275,7 +275,7 @@ export interface DirectiveNode extends Node {
275
275
  * Higher levels implies lower levels. e.g. a node that can be stringified
276
276
  * can always be hoisted and skipped for patch.
277
277
  */
278
- export declare const enum ConstantTypes {
278
+ export declare enum ConstantTypes {
279
279
  NOT_CONSTANT = 0,
280
280
  CAN_SKIP_PATCH = 1,
281
281
  CAN_HOIST = 2,
@@ -286,6 +286,12 @@ export interface SimpleExpressionNode extends Node {
286
286
  content: string;
287
287
  isStatic: boolean;
288
288
  constType: ConstantTypes;
289
+ /**
290
+ * - `null` means the expression is a simple identifier that doesn't need
291
+ * parsing
292
+ * - `false` means there was a parsing error
293
+ */
294
+ ast?: Node$1 | null | false;
289
295
  /**
290
296
  * Indicates this is an identifier for a hoist vnode call and points to the
291
297
  * hoisted node.
@@ -304,6 +310,12 @@ export interface InterpolationNode extends Node {
304
310
  }
305
311
  export interface CompoundExpressionNode extends Node {
306
312
  type: NodeTypes.COMPOUND_EXPRESSION;
313
+ /**
314
+ * - `null` means the expression is a simple identifier that doesn't need
315
+ * parsing
316
+ * - `false` means there was a parsing error
317
+ */
318
+ ast?: Node$1 | null | false;
307
319
  children: (SimpleExpressionNode | CompoundExpressionNode | InterpolationNode | TextNode | string | symbol)[];
308
320
  /**
309
321
  * an expression parsed as the params of a function will track
@@ -547,7 +559,7 @@ type InferCompilerError<T> = T extends ErrorCodes ? CoreCompilerError : Compiler
547
559
  export declare function createCompilerError<T extends number>(code: T, loc?: SourceLocation, messages?: {
548
560
  [code: number]: string;
549
561
  }, additionalMessage?: string): InferCompilerError<T>;
550
- export declare const enum ErrorCodes {
562
+ export declare enum ErrorCodes {
551
563
  ABRUPT_CLOSING_OF_EMPTY_COMMENT = 0,
552
564
  CDATA_IN_HTML_CONTENT = 1,
553
565
  DUPLICATE_ATTRIBUTE = 2,
@@ -595,13 +607,12 @@ export declare const enum ErrorCodes {
595
607
  X_V_MODEL_ON_PROPS = 44,
596
608
  X_INVALID_EXPRESSION = 45,
597
609
  X_KEEP_ALIVE_INVALID_CHILDREN = 46,
598
- X_PREFIX_ID_NOT_SUPPORTED = 47,
599
- X_MODULE_MODE_NOT_SUPPORTED = 48,
600
- X_CACHE_HANDLER_NOT_SUPPORTED = 49,
601
- X_SCOPE_ID_NOT_SUPPORTED = 50,
602
- DEPRECATION_VNODE_HOOKS = 51,
603
- DEPRECATION_V_IS = 52,
604
- __EXTEND_POINT__ = 53
610
+ X_VNODE_HOOKS = 47,
611
+ X_PREFIX_ID_NOT_SUPPORTED = 48,
612
+ X_MODULE_MODE_NOT_SUPPORTED = 49,
613
+ X_CACHE_HANDLER_NOT_SUPPORTED = 50,
614
+ X_SCOPE_ID_NOT_SUPPORTED = 51,
615
+ __EXTEND_POINT__ = 52
605
616
  }
606
617
  export declare const errorMessages: Record<ErrorCodes, string>;
607
618
 
@@ -624,8 +635,8 @@ export interface ParserOptions extends ErrorHandlingOptions, CompilerCompatOptio
624
635
  */
625
636
  parseMode?: 'base' | 'html' | 'sfc';
626
637
  /**
627
- * Specify the root namepsace to use when parsing a tempalte.
628
- * Defaults to `Namepsaces.HTML` (0).
638
+ * Specify the root namespace to use when parsing a template.
639
+ * Defaults to `Namespaces.HTML` (0).
629
640
  */
630
641
  ns?: Namespaces;
631
642
  /**
@@ -670,9 +681,20 @@ export interface ParserOptions extends ErrorHandlingOptions, CompilerCompatOptio
670
681
  * This defaults to `true` in development and `false` in production builds.
671
682
  */
672
683
  comments?: boolean;
684
+ /**
685
+ * Parse JavaScript expressions with Babel.
686
+ * @default false
687
+ */
688
+ prefixIdentifiers?: boolean;
689
+ /**
690
+ * A list of parser plugins to enable for `@babel/parser`, which is used to
691
+ * parse expressions in bindings and interpolations.
692
+ * https://babeljs.io/docs/en/next/babel-parser#plugins
693
+ */
694
+ expressionPlugins?: ParserPlugin[];
673
695
  }
674
696
  export type HoistTransform = (children: TemplateChildNode[], context: TransformContext, parent: ParentNode) => void;
675
- export declare const enum BindingTypes {
697
+ export declare enum BindingTypes {
676
698
  /**
677
699
  * returned from data()
678
700
  */
@@ -89,6 +89,90 @@ function registerRuntimeHelpers(helpers) {
89
89
  });
90
90
  }
91
91
 
92
+ const Namespaces = {
93
+ "HTML": 0,
94
+ "0": "HTML",
95
+ "SVG": 1,
96
+ "1": "SVG",
97
+ "MATH_ML": 2,
98
+ "2": "MATH_ML"
99
+ };
100
+ const NodeTypes = {
101
+ "ROOT": 0,
102
+ "0": "ROOT",
103
+ "ELEMENT": 1,
104
+ "1": "ELEMENT",
105
+ "TEXT": 2,
106
+ "2": "TEXT",
107
+ "COMMENT": 3,
108
+ "3": "COMMENT",
109
+ "SIMPLE_EXPRESSION": 4,
110
+ "4": "SIMPLE_EXPRESSION",
111
+ "INTERPOLATION": 5,
112
+ "5": "INTERPOLATION",
113
+ "ATTRIBUTE": 6,
114
+ "6": "ATTRIBUTE",
115
+ "DIRECTIVE": 7,
116
+ "7": "DIRECTIVE",
117
+ "COMPOUND_EXPRESSION": 8,
118
+ "8": "COMPOUND_EXPRESSION",
119
+ "IF": 9,
120
+ "9": "IF",
121
+ "IF_BRANCH": 10,
122
+ "10": "IF_BRANCH",
123
+ "FOR": 11,
124
+ "11": "FOR",
125
+ "TEXT_CALL": 12,
126
+ "12": "TEXT_CALL",
127
+ "VNODE_CALL": 13,
128
+ "13": "VNODE_CALL",
129
+ "JS_CALL_EXPRESSION": 14,
130
+ "14": "JS_CALL_EXPRESSION",
131
+ "JS_OBJECT_EXPRESSION": 15,
132
+ "15": "JS_OBJECT_EXPRESSION",
133
+ "JS_PROPERTY": 16,
134
+ "16": "JS_PROPERTY",
135
+ "JS_ARRAY_EXPRESSION": 17,
136
+ "17": "JS_ARRAY_EXPRESSION",
137
+ "JS_FUNCTION_EXPRESSION": 18,
138
+ "18": "JS_FUNCTION_EXPRESSION",
139
+ "JS_CONDITIONAL_EXPRESSION": 19,
140
+ "19": "JS_CONDITIONAL_EXPRESSION",
141
+ "JS_CACHE_EXPRESSION": 20,
142
+ "20": "JS_CACHE_EXPRESSION",
143
+ "JS_BLOCK_STATEMENT": 21,
144
+ "21": "JS_BLOCK_STATEMENT",
145
+ "JS_TEMPLATE_LITERAL": 22,
146
+ "22": "JS_TEMPLATE_LITERAL",
147
+ "JS_IF_STATEMENT": 23,
148
+ "23": "JS_IF_STATEMENT",
149
+ "JS_ASSIGNMENT_EXPRESSION": 24,
150
+ "24": "JS_ASSIGNMENT_EXPRESSION",
151
+ "JS_SEQUENCE_EXPRESSION": 25,
152
+ "25": "JS_SEQUENCE_EXPRESSION",
153
+ "JS_RETURN_STATEMENT": 26,
154
+ "26": "JS_RETURN_STATEMENT"
155
+ };
156
+ const ElementTypes = {
157
+ "ELEMENT": 0,
158
+ "0": "ELEMENT",
159
+ "COMPONENT": 1,
160
+ "1": "COMPONENT",
161
+ "SLOT": 2,
162
+ "2": "SLOT",
163
+ "TEMPLATE": 3,
164
+ "3": "TEMPLATE"
165
+ };
166
+ const ConstantTypes = {
167
+ "NOT_CONSTANT": 0,
168
+ "0": "NOT_CONSTANT",
169
+ "CAN_SKIP_PATCH": 1,
170
+ "1": "CAN_SKIP_PATCH",
171
+ "CAN_HOIST": 2,
172
+ "2": "CAN_HOIST",
173
+ "CAN_STRINGIFY": 3,
174
+ "3": "CAN_STRINGIFY"
175
+ };
92
176
  const locStub = {
93
177
  start: { line: 1, column: 1, offset: 0 },
94
178
  end: { line: 1, column: 1, offset: 0 },
@@ -343,7 +427,9 @@ class Tokenizer {
343
427
  this.inRCDATA = false;
344
428
  /** For disabling RCDATA tags handling */
345
429
  this.inXML = false;
346
- /** Reocrd newline positions for fast line / column calculation */
430
+ /** For disabling interpolation parsing in v-pre */
431
+ this.inVPre = false;
432
+ /** Record newline positions for fast line / column calculation */
347
433
  this.newlines = [];
348
434
  this.mode = 0;
349
435
  this.delimiterOpen = defaultDelimitersOpen;
@@ -362,6 +448,7 @@ class Tokenizer {
362
448
  this.sectionStart = 0;
363
449
  this.index = 0;
364
450
  this.baseState = 1;
451
+ this.inRCDATA = false;
365
452
  this.currentSequence = void 0;
366
453
  this.newlines.length = 0;
367
454
  this.delimiterOpen = defaultDelimitersOpen;
@@ -400,7 +487,7 @@ class Tokenizer {
400
487
  }
401
488
  this.state = 5;
402
489
  this.sectionStart = this.index;
403
- } else if (c === this.delimiterOpen[0]) {
490
+ } else if (!this.inVPre && c === this.delimiterOpen[0]) {
404
491
  this.state = 2;
405
492
  this.delimiterIndex = 0;
406
493
  this.stateInterpolationOpen(c);
@@ -1082,6 +1169,16 @@ class Tokenizer {
1082
1169
  }
1083
1170
  }
1084
1171
 
1172
+ const CompilerDeprecationTypes = {
1173
+ "COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
1174
+ "COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
1175
+ "COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
1176
+ "COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
1177
+ "COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
1178
+ "COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
1179
+ "COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
1180
+ "COMPILER_FILTERS": "COMPILER_FILTER"
1181
+ };
1085
1182
  const deprecationData = {
1086
1183
  ["COMPILER_IS_ON_ELEMENT"]: {
1087
1184
  message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
@@ -1157,12 +1254,120 @@ function defaultOnWarn(msg) {
1157
1254
  !!(process.env.NODE_ENV !== "production") && console.warn(`[Vue warn] ${msg.message}`);
1158
1255
  }
1159
1256
  function createCompilerError(code, loc, messages, additionalMessage) {
1160
- const msg = !!(process.env.NODE_ENV !== "production") || false ? (messages || errorMessages)[code] + (additionalMessage || ``) : code;
1257
+ const msg = !!(process.env.NODE_ENV !== "production") || false ? (messages || errorMessages)[code] + (additionalMessage || ``) : `https://vuejs.org/errors/#compiler-${code}`;
1161
1258
  const error = new SyntaxError(String(msg));
1162
1259
  error.code = code;
1163
1260
  error.loc = loc;
1164
1261
  return error;
1165
1262
  }
1263
+ const ErrorCodes = {
1264
+ "ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
1265
+ "0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
1266
+ "CDATA_IN_HTML_CONTENT": 1,
1267
+ "1": "CDATA_IN_HTML_CONTENT",
1268
+ "DUPLICATE_ATTRIBUTE": 2,
1269
+ "2": "DUPLICATE_ATTRIBUTE",
1270
+ "END_TAG_WITH_ATTRIBUTES": 3,
1271
+ "3": "END_TAG_WITH_ATTRIBUTES",
1272
+ "END_TAG_WITH_TRAILING_SOLIDUS": 4,
1273
+ "4": "END_TAG_WITH_TRAILING_SOLIDUS",
1274
+ "EOF_BEFORE_TAG_NAME": 5,
1275
+ "5": "EOF_BEFORE_TAG_NAME",
1276
+ "EOF_IN_CDATA": 6,
1277
+ "6": "EOF_IN_CDATA",
1278
+ "EOF_IN_COMMENT": 7,
1279
+ "7": "EOF_IN_COMMENT",
1280
+ "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
1281
+ "8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
1282
+ "EOF_IN_TAG": 9,
1283
+ "9": "EOF_IN_TAG",
1284
+ "INCORRECTLY_CLOSED_COMMENT": 10,
1285
+ "10": "INCORRECTLY_CLOSED_COMMENT",
1286
+ "INCORRECTLY_OPENED_COMMENT": 11,
1287
+ "11": "INCORRECTLY_OPENED_COMMENT",
1288
+ "INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
1289
+ "12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
1290
+ "MISSING_ATTRIBUTE_VALUE": 13,
1291
+ "13": "MISSING_ATTRIBUTE_VALUE",
1292
+ "MISSING_END_TAG_NAME": 14,
1293
+ "14": "MISSING_END_TAG_NAME",
1294
+ "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
1295
+ "15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
1296
+ "NESTED_COMMENT": 16,
1297
+ "16": "NESTED_COMMENT",
1298
+ "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
1299
+ "17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
1300
+ "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
1301
+ "18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
1302
+ "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
1303
+ "19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
1304
+ "UNEXPECTED_NULL_CHARACTER": 20,
1305
+ "20": "UNEXPECTED_NULL_CHARACTER",
1306
+ "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
1307
+ "21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
1308
+ "UNEXPECTED_SOLIDUS_IN_TAG": 22,
1309
+ "22": "UNEXPECTED_SOLIDUS_IN_TAG",
1310
+ "X_INVALID_END_TAG": 23,
1311
+ "23": "X_INVALID_END_TAG",
1312
+ "X_MISSING_END_TAG": 24,
1313
+ "24": "X_MISSING_END_TAG",
1314
+ "X_MISSING_INTERPOLATION_END": 25,
1315
+ "25": "X_MISSING_INTERPOLATION_END",
1316
+ "X_MISSING_DIRECTIVE_NAME": 26,
1317
+ "26": "X_MISSING_DIRECTIVE_NAME",
1318
+ "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
1319
+ "27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
1320
+ "X_V_IF_NO_EXPRESSION": 28,
1321
+ "28": "X_V_IF_NO_EXPRESSION",
1322
+ "X_V_IF_SAME_KEY": 29,
1323
+ "29": "X_V_IF_SAME_KEY",
1324
+ "X_V_ELSE_NO_ADJACENT_IF": 30,
1325
+ "30": "X_V_ELSE_NO_ADJACENT_IF",
1326
+ "X_V_FOR_NO_EXPRESSION": 31,
1327
+ "31": "X_V_FOR_NO_EXPRESSION",
1328
+ "X_V_FOR_MALFORMED_EXPRESSION": 32,
1329
+ "32": "X_V_FOR_MALFORMED_EXPRESSION",
1330
+ "X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
1331
+ "33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
1332
+ "X_V_BIND_NO_EXPRESSION": 34,
1333
+ "34": "X_V_BIND_NO_EXPRESSION",
1334
+ "X_V_ON_NO_EXPRESSION": 35,
1335
+ "35": "X_V_ON_NO_EXPRESSION",
1336
+ "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
1337
+ "36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
1338
+ "X_V_SLOT_MIXED_SLOT_USAGE": 37,
1339
+ "37": "X_V_SLOT_MIXED_SLOT_USAGE",
1340
+ "X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
1341
+ "38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
1342
+ "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
1343
+ "39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
1344
+ "X_V_SLOT_MISPLACED": 40,
1345
+ "40": "X_V_SLOT_MISPLACED",
1346
+ "X_V_MODEL_NO_EXPRESSION": 41,
1347
+ "41": "X_V_MODEL_NO_EXPRESSION",
1348
+ "X_V_MODEL_MALFORMED_EXPRESSION": 42,
1349
+ "42": "X_V_MODEL_MALFORMED_EXPRESSION",
1350
+ "X_V_MODEL_ON_SCOPE_VARIABLE": 43,
1351
+ "43": "X_V_MODEL_ON_SCOPE_VARIABLE",
1352
+ "X_V_MODEL_ON_PROPS": 44,
1353
+ "44": "X_V_MODEL_ON_PROPS",
1354
+ "X_INVALID_EXPRESSION": 45,
1355
+ "45": "X_INVALID_EXPRESSION",
1356
+ "X_KEEP_ALIVE_INVALID_CHILDREN": 46,
1357
+ "46": "X_KEEP_ALIVE_INVALID_CHILDREN",
1358
+ "X_VNODE_HOOKS": 47,
1359
+ "47": "X_VNODE_HOOKS",
1360
+ "X_PREFIX_ID_NOT_SUPPORTED": 48,
1361
+ "48": "X_PREFIX_ID_NOT_SUPPORTED",
1362
+ "X_MODULE_MODE_NOT_SUPPORTED": 49,
1363
+ "49": "X_MODULE_MODE_NOT_SUPPORTED",
1364
+ "X_CACHE_HANDLER_NOT_SUPPORTED": 50,
1365
+ "50": "X_CACHE_HANDLER_NOT_SUPPORTED",
1366
+ "X_SCOPE_ID_NOT_SUPPORTED": 51,
1367
+ "51": "X_SCOPE_ID_NOT_SUPPORTED",
1368
+ "__EXTEND_POINT__": 52,
1369
+ "52": "__EXTEND_POINT__"
1370
+ };
1166
1371
  const errorMessages = {
1167
1372
  // parse errors
1168
1373
  [0]: "Illegal comment.",
@@ -1215,16 +1420,14 @@ const errorMessages = {
1215
1420
  Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
1216
1421
  [45]: `Error parsing JavaScript expression: `,
1217
1422
  [46]: `<KeepAlive> expects exactly one child component.`,
1423
+ [47]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
1218
1424
  // generic errors
1219
- [47]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
1220
- [48]: `ES module mode is not supported in this build of compiler.`,
1221
- [49]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
1222
- [50]: `"scopeId" option is only supported in module mode.`,
1223
- // deprecations
1224
- [51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
1225
- [52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
1425
+ [48]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
1426
+ [49]: `ES module mode is not supported in this build of compiler.`,
1427
+ [50]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
1428
+ [51]: `"scopeId" option is only supported in module mode.`,
1226
1429
  // just to fulfill types
1227
- [53]: ``
1430
+ [52]: ``
1228
1431
  };
1229
1432
 
1230
1433
  const isStaticExp = (p) => p.type === 4 && p.isStatic;
@@ -1533,7 +1736,8 @@ const defaultParserOptions = {
1533
1736
  isCustomElement: NO,
1534
1737
  onError: defaultOnError,
1535
1738
  onWarn: defaultOnWarn,
1536
- comments: !!(process.env.NODE_ENV !== "production")
1739
+ comments: !!(process.env.NODE_ENV !== "production"),
1740
+ prefixIdentifiers: false
1537
1741
  };
1538
1742
  let currentOptions = defaultParserOptions;
1539
1743
  let currentRoot = null;
@@ -1575,7 +1779,7 @@ const tokenizer = new Tokenizer(stack, {
1575
1779
  }
1576
1780
  addNode({
1577
1781
  type: 5,
1578
- content: createSimpleExpression(exp, false, getLoc(innerStart, innerEnd)),
1782
+ content: createExp(exp, false, getLoc(innerStart, innerEnd)),
1579
1783
  loc: getLoc(start, end)
1580
1784
  });
1581
1785
  },
@@ -1668,7 +1872,7 @@ const tokenizer = new Tokenizer(stack, {
1668
1872
  loc: getLoc(start)
1669
1873
  };
1670
1874
  if (name === "pre") {
1671
- inVPre = true;
1875
+ inVPre = tokenizer.inVPre = true;
1672
1876
  currentVPreBoundary = currentOpenTag;
1673
1877
  const props = currentOpenTag.props;
1674
1878
  for (let i = 0; i < props.length; i++) {
@@ -1680,13 +1884,15 @@ const tokenizer = new Tokenizer(stack, {
1680
1884
  }
1681
1885
  },
1682
1886
  ondirarg(start, end) {
1887
+ if (start === end)
1888
+ return;
1683
1889
  const arg = getSlice(start, end);
1684
1890
  if (inVPre) {
1685
1891
  currentProp.name += arg;
1686
1892
  setLocEnd(currentProp.nameLoc, end);
1687
1893
  } else {
1688
1894
  const isStatic = arg[0] !== `[`;
1689
- currentProp.arg = createSimpleExpression(
1895
+ currentProp.arg = createExp(
1690
1896
  isStatic ? arg : arg.slice(1, -1),
1691
1897
  isStatic,
1692
1898
  getLoc(start, end),
@@ -1759,10 +1965,13 @@ const tokenizer = new Tokenizer(stack, {
1759
1965
  tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
1760
1966
  }
1761
1967
  } else {
1762
- currentProp.exp = createSimpleExpression(
1968
+ let expParseMode = 0 /* Normal */;
1969
+ currentProp.exp = createExp(
1763
1970
  currentAttrValue,
1764
1971
  false,
1765
- getLoc(currentAttrStartIndex, currentAttrEndIndex)
1972
+ getLoc(currentAttrStartIndex, currentAttrEndIndex),
1973
+ 0,
1974
+ expParseMode
1766
1975
  );
1767
1976
  if (currentProp.name === "for") {
1768
1977
  currentProp.forParseResult = parseForExpression(currentProp.exp);
@@ -1865,10 +2074,16 @@ function parseForExpression(input) {
1865
2074
  if (!inMatch)
1866
2075
  return;
1867
2076
  const [, LHS, RHS] = inMatch;
1868
- const createAliasExpression = (content, offset) => {
2077
+ const createAliasExpression = (content, offset, asParam = false) => {
1869
2078
  const start = loc.start.offset + offset;
1870
2079
  const end = start + content.length;
1871
- return createSimpleExpression(content, false, getLoc(start, end));
2080
+ return createExp(
2081
+ content,
2082
+ false,
2083
+ getLoc(start, end),
2084
+ 0,
2085
+ asParam ? 1 /* Params */ : 0 /* Normal */
2086
+ );
1872
2087
  };
1873
2088
  const result = {
1874
2089
  source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
@@ -1886,7 +2101,7 @@ function parseForExpression(input) {
1886
2101
  let keyOffset;
1887
2102
  if (keyContent) {
1888
2103
  keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
1889
- result.key = createAliasExpression(keyContent, keyOffset);
2104
+ result.key = createAliasExpression(keyContent, keyOffset, true);
1890
2105
  }
1891
2106
  if (iteratorMatch[2]) {
1892
2107
  const indexContent = iteratorMatch[2].trim();
@@ -1896,13 +2111,14 @@ function parseForExpression(input) {
1896
2111
  exp.indexOf(
1897
2112
  indexContent,
1898
2113
  result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
1899
- )
2114
+ ),
2115
+ true
1900
2116
  );
1901
2117
  }
1902
2118
  }
1903
2119
  }
1904
2120
  if (valueContent) {
1905
- result.value = createAliasExpression(valueContent, trimmedOffset);
2121
+ result.value = createAliasExpression(valueContent, trimmedOffset, true);
1906
2122
  }
1907
2123
  return result;
1908
2124
  }
@@ -1980,7 +2196,7 @@ function onCloseTag(el, end, isImplied = false) {
1980
2196
  inPre--;
1981
2197
  }
1982
2198
  if (currentVPreBoundary === el) {
1983
- inVPre = false;
2199
+ inVPre = tokenizer.inVPre = false;
1984
2200
  currentVPreBoundary = null;
1985
2201
  }
1986
2202
  if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
@@ -2215,8 +2431,14 @@ function dirToAttr(dir) {
2215
2431
  }
2216
2432
  return attr;
2217
2433
  }
2218
- function emitError(code, index) {
2219
- currentOptions.onError(createCompilerError(code, getLoc(index, index)));
2434
+ function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
2435
+ const exp = createSimpleExpression(content, isStatic, loc, constType);
2436
+ return exp;
2437
+ }
2438
+ function emitError(code, index, message) {
2439
+ currentOptions.onError(
2440
+ createCompilerError(code, getLoc(index, index), void 0, message)
2441
+ );
2220
2442
  }
2221
2443
  function reset() {
2222
2444
  tokenizer.reset();
@@ -2247,6 +2469,7 @@ function baseParse(input, options) {
2247
2469
  }
2248
2470
  }
2249
2471
  tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
2472
+ tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
2250
2473
  const delimiters = options == null ? void 0 : options.delimiters;
2251
2474
  if (delimiters) {
2252
2475
  tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
@@ -4435,6 +4658,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4435
4658
  if (isEventHandler && isReservedProp(name)) {
4436
4659
  hasVnodeHook = true;
4437
4660
  }
4661
+ if (isEventHandler && value.type === 14) {
4662
+ value = value.arguments[0];
4663
+ }
4438
4664
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
4439
4665
  return;
4440
4666
  }
@@ -4887,9 +5113,7 @@ const transformOn = (dir, node, context, augmentor) => {
4887
5113
  if (arg.isStatic) {
4888
5114
  let rawName = arg.content;
4889
5115
  if (!!(process.env.NODE_ENV !== "production") && rawName.startsWith("vnode")) {
4890
- context.onWarn(
4891
- createCompilerError(51, arg.loc)
4892
- );
5116
+ context.onError(createCompilerError(47, arg.loc));
4893
5117
  }
4894
5118
  if (rawName.startsWith("vue:")) {
4895
5119
  rawName = `vnode-${rawName.slice(4)}`;
@@ -5370,17 +5594,17 @@ function baseCompile(source, options = {}) {
5370
5594
  const isModuleMode = options.mode === "module";
5371
5595
  {
5372
5596
  if (options.prefixIdentifiers === true) {
5373
- onError(createCompilerError(47));
5374
- } else if (isModuleMode) {
5375
5597
  onError(createCompilerError(48));
5598
+ } else if (isModuleMode) {
5599
+ onError(createCompilerError(49));
5376
5600
  }
5377
5601
  }
5378
5602
  const prefixIdentifiers = false;
5379
5603
  if (options.cacheHandlers) {
5380
- onError(createCompilerError(49));
5604
+ onError(createCompilerError(50));
5381
5605
  }
5382
5606
  if (options.scopeId && !isModuleMode) {
5383
- onError(createCompilerError(50));
5607
+ onError(createCompilerError(51));
5384
5608
  }
5385
5609
  const ast = isString(source) ? baseParse(source, options) : source;
5386
5610
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
@@ -5409,6 +5633,19 @@ function baseCompile(source, options = {}) {
5409
5633
  );
5410
5634
  }
5411
5635
 
5636
+ const BindingTypes = {
5637
+ "DATA": "data",
5638
+ "PROPS": "props",
5639
+ "PROPS_ALIASED": "props-aliased",
5640
+ "SETUP_LET": "setup-let",
5641
+ "SETUP_CONST": "setup-const",
5642
+ "SETUP_REACTIVE_CONST": "setup-reactive-const",
5643
+ "SETUP_MAYBE_REF": "setup-maybe-ref",
5644
+ "SETUP_REF": "setup-ref",
5645
+ "OPTIONS": "options",
5646
+ "LITERAL_CONST": "literal-const"
5647
+ };
5648
+
5412
5649
  const noopDirectiveTransform = () => ({ props: [] });
5413
5650
 
5414
- export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, 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, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
5651
+ 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, 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, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.4.0-alpha.2",
3
+ "version": "3.4.0-alpha.4",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -32,13 +32,13 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
34
34
  "dependencies": {
35
- "@babel/parser": "^7.23.3",
35
+ "@babel/parser": "^7.23.5",
36
36
  "entities": "^4.5.0",
37
37
  "estree-walker": "^2.0.2",
38
38
  "source-map-js": "^1.0.2",
39
- "@vue/shared": "3.4.0-alpha.2"
39
+ "@vue/shared": "3.4.0-alpha.4"
40
40
  },
41
41
  "devDependencies": {
42
- "@babel/types": "^7.23.3"
42
+ "@babel/types": "^7.23.5"
43
43
  }
44
44
  }