@vue/compiler-core 3.2.44 → 3.2.46

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,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var shared = require('@vue/shared');
6
4
  var parser = require('@babel/parser');
7
5
  var sourceMap = require('source-map');
@@ -63,7 +61,7 @@ const errorMessages = {
63
61
  [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
64
62
  [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
65
63
  [36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
66
- [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
64
+ [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>. ` +
67
65
  `When there are multiple named slots, all slots should use <template> ` +
68
66
  `syntax to avoid scope ambiguity.`,
69
67
  [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
@@ -73,15 +71,16 @@ const errorMessages = {
73
71
  [41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
74
72
  [42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
75
73
  [43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
76
- [44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
77
- [45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
74
+ [44 /* ErrorCodes.X_V_MODEL_ON_PROPS */]: `v-model cannot be used on a prop, because local prop bindings are not writable.\nUse a v-bind binding combined with a v-on listener that emits update:x event instead.`,
75
+ [45 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
76
+ [46 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
78
77
  // generic errors
79
- [46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
80
- [47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
81
- [48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
82
- [49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
78
+ [47 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
79
+ [48 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
80
+ [49 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
81
+ [50 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
83
82
  // just to fulfill types
84
- [50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
83
+ [51 /* ErrorCodes.__EXTEND_POINT__ */]: ``
85
84
  };
86
85
 
87
86
  const FRAGMENT = Symbol(`Fragment` );
@@ -185,7 +184,7 @@ function createRoot(children, loc = locStub) {
185
184
  return {
186
185
  type: 0 /* NodeTypes.ROOT */,
187
186
  children,
188
- helpers: [],
187
+ helpers: new Set(),
189
188
  components: [],
190
189
  directives: [],
191
190
  hoists: [],
@@ -545,7 +544,7 @@ function hasDynamicKeyVBind(node) {
545
544
  !p.arg.isStatic) // v-bind:[foo]
546
545
  );
547
546
  }
548
- function isText(node) {
547
+ function isText$1(node) {
549
548
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
550
549
  }
551
550
  function isVSlot(p) {
@@ -2104,7 +2103,7 @@ function transform(root, options) {
2104
2103
  createRootCodegen(root, context);
2105
2104
  }
2106
2105
  // finalize meta information
2107
- root.helpers = [...context.helpers.keys()];
2106
+ root.helpers = new Set([...context.helpers.keys()]);
2108
2107
  root.components = [...context.components];
2109
2108
  root.directives = [...context.directives];
2110
2109
  root.imports = context.imports;
@@ -2345,7 +2344,8 @@ function generate(ast, options = {}) {
2345
2344
  if (options.onContextCreated)
2346
2345
  options.onContextCreated(context);
2347
2346
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2348
- const hasHelpers = ast.helpers.length > 0;
2347
+ const helpers = Array.from(ast.helpers);
2348
+ const hasHelpers = helpers.length > 0;
2349
2349
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2350
2350
  const genScopeId = scopeId != null && mode === 'module';
2351
2351
  const isSetupInlined = !!options.inline;
@@ -2384,7 +2384,7 @@ function generate(ast, options = {}) {
2384
2384
  // function mode const declarations should be inside with block
2385
2385
  // also they should be renamed to avoid collision with user properties
2386
2386
  if (hasHelpers) {
2387
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2387
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2388
2388
  push(`\n`);
2389
2389
  newline();
2390
2390
  }
@@ -2450,9 +2450,10 @@ function genFunctionPreamble(ast, context) {
2450
2450
  // In prefix mode, we place the const declaration at top so it's done
2451
2451
  // only once; But if we not prefixing, we place the declaration inside the
2452
2452
  // with block so it doesn't incur the `in` check cost for every helper access.
2453
- if (ast.helpers.length > 0) {
2453
+ const helpers = Array.from(ast.helpers);
2454
+ if (helpers.length > 0) {
2454
2455
  if (prefixIdentifiers) {
2455
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2456
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2456
2457
  }
2457
2458
  else {
2458
2459
  // "with" mode.
@@ -2469,7 +2470,7 @@ function genFunctionPreamble(ast, context) {
2469
2470
  CREATE_TEXT,
2470
2471
  CREATE_STATIC
2471
2472
  ]
2472
- .filter(helper => ast.helpers.includes(helper))
2473
+ .filter(helper => helpers.includes(helper))
2473
2474
  .map(aliasHelper)
2474
2475
  .join(', ');
2475
2476
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2490,25 +2491,27 @@ function genFunctionPreamble(ast, context) {
2490
2491
  function genModulePreamble(ast, context, genScopeId, inline) {
2491
2492
  const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
2492
2493
  if (genScopeId && ast.hoists.length) {
2493
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2494
+ ast.helpers.add(PUSH_SCOPE_ID);
2495
+ ast.helpers.add(POP_SCOPE_ID);
2494
2496
  }
2495
2497
  // generate import statements for helpers
2496
- if (ast.helpers.length) {
2498
+ if (ast.helpers.size) {
2499
+ const helpers = Array.from(ast.helpers);
2497
2500
  if (optimizeImports) {
2498
2501
  // when bundled with webpack with code-split, calling an import binding
2499
2502
  // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
2500
2503
  // incurring both payload size increase and potential perf overhead.
2501
2504
  // therefore we assign the imports to variables (which is a constant ~50b
2502
2505
  // cost per-component instead of scaling with template size)
2503
- push(`import { ${ast.helpers
2506
+ push(`import { ${helpers
2504
2507
  .map(s => helperNameMap[s])
2505
2508
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2506
- push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
2509
+ push(`\n// Binding optimization for webpack code-split\nconst ${helpers
2507
2510
  .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
2508
2511
  .join(', ')}\n`);
2509
2512
  }
2510
2513
  else {
2511
- push(`import { ${ast.helpers
2514
+ push(`import { ${helpers
2512
2515
  .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
2513
2516
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2514
2517
  }
@@ -2585,7 +2588,7 @@ function genImports(importsOptions, context) {
2585
2588
  context.newline();
2586
2589
  });
2587
2590
  }
2588
- function isText$1(n) {
2591
+ function isText(n) {
2589
2592
  return (shared.isString(n) ||
2590
2593
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2591
2594
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2594,7 +2597,7 @@ function isText$1(n) {
2594
2597
  }
2595
2598
  function genNodeListAsArray(nodes, context) {
2596
2599
  const multilines = nodes.length > 3 ||
2597
- (nodes.some(n => shared.isArray(n) || !isText$1(n)));
2600
+ (nodes.some(n => shared.isArray(n) || !isText(n)));
2598
2601
  context.push(`[`);
2599
2602
  multilines && context.indent();
2600
2603
  genNodeList(nodes, context, multilines);
@@ -3496,7 +3499,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3496
3499
  }).program;
3497
3500
  }
3498
3501
  catch (e) {
3499
- context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3502
+ context.onError(createCompilerError(45 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3500
3503
  return node;
3501
3504
  }
3502
3505
  const ids = [];
@@ -4396,7 +4399,7 @@ const transformElement = (node, context) => {
4396
4399
  // 2. Force keep-alive to always be updated, since it uses raw children.
4397
4400
  patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
4398
4401
  if (node.children.length > 1) {
4399
- context.onError(createCompilerError(45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
4402
+ context.onError(createCompilerError(46 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
4400
4403
  start: node.children[0].loc.start,
4401
4404
  end: node.children[node.children.length - 1].loc.end,
4402
4405
  source: ''
@@ -5000,9 +5003,6 @@ function isComponentTag(tag) {
5000
5003
  return tag === 'component' || tag === 'Component';
5001
5004
  }
5002
5005
 
5003
- Object.freeze({})
5004
- ;
5005
- Object.freeze([]) ;
5006
5006
  const cacheStringFunction = (fn) => {
5007
5007
  const cache = Object.create(null);
5008
5008
  return ((str) => {
@@ -5284,11 +5284,11 @@ const transformText = (node, context) => {
5284
5284
  let hasText = false;
5285
5285
  for (let i = 0; i < children.length; i++) {
5286
5286
  const child = children[i];
5287
- if (isText(child)) {
5287
+ if (isText$1(child)) {
5288
5288
  hasText = true;
5289
5289
  for (let j = i + 1; j < children.length; j++) {
5290
5290
  const next = children[j];
5291
- if (isText(next)) {
5291
+ if (isText$1(next)) {
5292
5292
  if (!currentContainer) {
5293
5293
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
5294
5294
  }
@@ -5330,7 +5330,7 @@ const transformText = (node, context) => {
5330
5330
  // runtime normalization.
5331
5331
  for (let i = 0; i < children.length; i++) {
5332
5332
  const child = children[i];
5333
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5333
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5334
5334
  const callArgs = [];
5335
5335
  // createTextVNode defaults to single whitespace, so if it is a
5336
5336
  // single space the code could be an empty call to save bytes.
@@ -5355,13 +5355,13 @@ const transformText = (node, context) => {
5355
5355
  }
5356
5356
  };
5357
5357
 
5358
- const seen = new WeakSet();
5358
+ const seen$1 = new WeakSet();
5359
5359
  const transformOnce = (node, context) => {
5360
5360
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5361
- if (seen.has(node) || context.inVOnce) {
5361
+ if (seen$1.has(node) || context.inVOnce) {
5362
5362
  return;
5363
5363
  }
5364
- seen.add(node);
5364
+ seen$1.add(node);
5365
5365
  context.inVOnce = true;
5366
5366
  context.helper(SET_BLOCK_TRACKING);
5367
5367
  return () => {
@@ -5385,9 +5385,16 @@ const transformModel = (dir, node, context) => {
5385
5385
  // im SFC <script setup> inline mode, the exp may have been transformed into
5386
5386
  // _unref(exp)
5387
5387
  const bindingType = context.bindingMetadata[rawExp];
5388
+ // check props
5389
+ if (bindingType === "props" /* BindingTypes.PROPS */ ||
5390
+ bindingType === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
5391
+ context.onError(createCompilerError(44 /* ErrorCodes.X_V_MODEL_ON_PROPS */, exp.loc));
5392
+ return createTransformProps();
5393
+ }
5388
5394
  const maybeRef = context.inline &&
5389
- bindingType &&
5390
- bindingType !== "setup-const" /* BindingTypes.SETUP_CONST */;
5395
+ (bindingType === "setup-let" /* BindingTypes.SETUP_LET */ ||
5396
+ bindingType === "setup-ref" /* BindingTypes.SETUP_REF */ ||
5397
+ bindingType === "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
5391
5398
  if (!expString.trim() ||
5392
5399
  (!isMemberExpression(expString, context) && !maybeRef)) {
5393
5400
  context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
@@ -5402,7 +5409,7 @@ const transformModel = (dir, node, context) => {
5402
5409
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
5403
5410
  const eventName = arg
5404
5411
  ? isStaticExp(arg)
5405
- ? `onUpdate:${arg.content}`
5412
+ ? `onUpdate:${shared.camelize(arg.content)}`
5406
5413
  : createCompoundExpression(['"onUpdate:" + ', arg])
5407
5414
  : `onUpdate:modelValue`;
5408
5415
  let assignmentExp;
@@ -5630,14 +5637,14 @@ function wrapFilter(exp, filter, context) {
5630
5637
  }
5631
5638
  }
5632
5639
 
5633
- const seen$1 = new WeakSet();
5640
+ const seen = new WeakSet();
5634
5641
  const transformMemo = (node, context) => {
5635
5642
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
5636
5643
  const dir = findDir(node, 'memo');
5637
- if (!dir || seen$1.has(node)) {
5644
+ if (!dir || seen.has(node)) {
5638
5645
  return;
5639
5646
  }
5640
- seen$1.add(node);
5647
+ seen.add(node);
5641
5648
  return () => {
5642
5649
  const codegenNode = node.codegenNode ||
5643
5650
  context.currentNode.codegenNode;
@@ -5691,10 +5698,10 @@ function baseCompile(template, options = {}) {
5691
5698
  const isModuleMode = options.mode === 'module';
5692
5699
  const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
5693
5700
  if (!prefixIdentifiers && options.cacheHandlers) {
5694
- onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
5701
+ onError(createCompilerError(49 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
5695
5702
  }
5696
5703
  if (options.scopeId && !isModuleMode) {
5697
- onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
5704
+ onError(createCompilerError(50 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
5698
5705
  }
5699
5706
  const ast = shared.isString(template) ? baseParse(template, options) : template;
5700
5707
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
@@ -5820,7 +5827,7 @@ exports.isStaticExp = isStaticExp;
5820
5827
  exports.isStaticProperty = isStaticProperty;
5821
5828
  exports.isStaticPropertyKey = isStaticPropertyKey;
5822
5829
  exports.isTemplateNode = isTemplateNode;
5823
- exports.isText = isText;
5830
+ exports.isText = isText$1;
5824
5831
  exports.isVSlot = isVSlot;
5825
5832
  exports.locStub = locStub;
5826
5833
  exports.makeBlock = makeBlock;
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var shared = require('@vue/shared');
6
4
  var parser = require('@babel/parser');
7
5
  var sourceMap = require('source-map');
@@ -62,7 +60,7 @@ const errorMessages = {
62
60
  [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
63
61
  [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
64
62
  [36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
65
- [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
63
+ [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>. ` +
66
64
  `When there are multiple named slots, all slots should use <template> ` +
67
65
  `syntax to avoid scope ambiguity.`,
68
66
  [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
@@ -72,15 +70,16 @@ const errorMessages = {
72
70
  [41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
73
71
  [42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
74
72
  [43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
75
- [44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
76
- [45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
73
+ [44 /* ErrorCodes.X_V_MODEL_ON_PROPS */]: `v-model cannot be used on a prop, because local prop bindings are not writable.\nUse a v-bind binding combined with a v-on listener that emits update:x event instead.`,
74
+ [45 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
75
+ [46 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
77
76
  // generic errors
78
- [46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
79
- [47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
80
- [48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
81
- [49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
77
+ [47 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
78
+ [48 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
79
+ [49 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
80
+ [50 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
82
81
  // just to fulfill types
83
- [50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
82
+ [51 /* ErrorCodes.__EXTEND_POINT__ */]: ``
84
83
  };
85
84
 
86
85
  const FRAGMENT = Symbol(``);
@@ -184,7 +183,7 @@ function createRoot(children, loc = locStub) {
184
183
  return {
185
184
  type: 0 /* NodeTypes.ROOT */,
186
185
  children,
187
- helpers: [],
186
+ helpers: new Set(),
188
187
  components: [],
189
188
  directives: [],
190
189
  hoists: [],
@@ -544,7 +543,7 @@ function hasDynamicKeyVBind(node) {
544
543
  !p.arg.isStatic) // v-bind:[foo]
545
544
  );
546
545
  }
547
- function isText(node) {
546
+ function isText$1(node) {
548
547
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
549
548
  }
550
549
  function isVSlot(p) {
@@ -2060,7 +2059,7 @@ function transform(root, options) {
2060
2059
  createRootCodegen(root, context);
2061
2060
  }
2062
2061
  // finalize meta information
2063
- root.helpers = [...context.helpers.keys()];
2062
+ root.helpers = new Set([...context.helpers.keys()]);
2064
2063
  root.components = [...context.components];
2065
2064
  root.directives = [...context.directives];
2066
2065
  root.imports = context.imports;
@@ -2295,7 +2294,8 @@ function generate(ast, options = {}) {
2295
2294
  if (options.onContextCreated)
2296
2295
  options.onContextCreated(context);
2297
2296
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2298
- const hasHelpers = ast.helpers.length > 0;
2297
+ const helpers = Array.from(ast.helpers);
2298
+ const hasHelpers = helpers.length > 0;
2299
2299
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2300
2300
  const genScopeId = scopeId != null && mode === 'module';
2301
2301
  const isSetupInlined = !!options.inline;
@@ -2334,7 +2334,7 @@ function generate(ast, options = {}) {
2334
2334
  // function mode const declarations should be inside with block
2335
2335
  // also they should be renamed to avoid collision with user properties
2336
2336
  if (hasHelpers) {
2337
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2337
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2338
2338
  push(`\n`);
2339
2339
  newline();
2340
2340
  }
@@ -2400,9 +2400,10 @@ function genFunctionPreamble(ast, context) {
2400
2400
  // In prefix mode, we place the const declaration at top so it's done
2401
2401
  // only once; But if we not prefixing, we place the declaration inside the
2402
2402
  // with block so it doesn't incur the `in` check cost for every helper access.
2403
- if (ast.helpers.length > 0) {
2403
+ const helpers = Array.from(ast.helpers);
2404
+ if (helpers.length > 0) {
2404
2405
  if (prefixIdentifiers) {
2405
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2406
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2406
2407
  }
2407
2408
  else {
2408
2409
  // "with" mode.
@@ -2419,7 +2420,7 @@ function genFunctionPreamble(ast, context) {
2419
2420
  CREATE_TEXT,
2420
2421
  CREATE_STATIC
2421
2422
  ]
2422
- .filter(helper => ast.helpers.includes(helper))
2423
+ .filter(helper => helpers.includes(helper))
2423
2424
  .map(aliasHelper)
2424
2425
  .join(', ');
2425
2426
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2440,25 +2441,27 @@ function genFunctionPreamble(ast, context) {
2440
2441
  function genModulePreamble(ast, context, genScopeId, inline) {
2441
2442
  const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
2442
2443
  if (genScopeId && ast.hoists.length) {
2443
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2444
+ ast.helpers.add(PUSH_SCOPE_ID);
2445
+ ast.helpers.add(POP_SCOPE_ID);
2444
2446
  }
2445
2447
  // generate import statements for helpers
2446
- if (ast.helpers.length) {
2448
+ if (ast.helpers.size) {
2449
+ const helpers = Array.from(ast.helpers);
2447
2450
  if (optimizeImports) {
2448
2451
  // when bundled with webpack with code-split, calling an import binding
2449
2452
  // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
2450
2453
  // incurring both payload size increase and potential perf overhead.
2451
2454
  // therefore we assign the imports to variables (which is a constant ~50b
2452
2455
  // cost per-component instead of scaling with template size)
2453
- push(`import { ${ast.helpers
2456
+ push(`import { ${helpers
2454
2457
  .map(s => helperNameMap[s])
2455
2458
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2456
- push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
2459
+ push(`\n// Binding optimization for webpack code-split\nconst ${helpers
2457
2460
  .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
2458
2461
  .join(', ')}\n`);
2459
2462
  }
2460
2463
  else {
2461
- push(`import { ${ast.helpers
2464
+ push(`import { ${helpers
2462
2465
  .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
2463
2466
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2464
2467
  }
@@ -2535,7 +2538,7 @@ function genImports(importsOptions, context) {
2535
2538
  context.newline();
2536
2539
  });
2537
2540
  }
2538
- function isText$1(n) {
2541
+ function isText(n) {
2539
2542
  return (shared.isString(n) ||
2540
2543
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2541
2544
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2544,7 +2547,7 @@ function isText$1(n) {
2544
2547
  }
2545
2548
  function genNodeListAsArray(nodes, context) {
2546
2549
  const multilines = nodes.length > 3 ||
2547
- (nodes.some(n => shared.isArray(n) || !isText$1(n)));
2550
+ (nodes.some(n => shared.isArray(n) || !isText(n)));
2548
2551
  context.push(`[`);
2549
2552
  multilines && context.indent();
2550
2553
  genNodeList(nodes, context, multilines);
@@ -3433,7 +3436,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3433
3436
  }).program;
3434
3437
  }
3435
3438
  catch (e) {
3436
- context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3439
+ context.onError(createCompilerError(45 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3437
3440
  return node;
3438
3441
  }
3439
3442
  const ids = [];
@@ -5159,11 +5162,11 @@ const transformText = (node, context) => {
5159
5162
  let hasText = false;
5160
5163
  for (let i = 0; i < children.length; i++) {
5161
5164
  const child = children[i];
5162
- if (isText(child)) {
5165
+ if (isText$1(child)) {
5163
5166
  hasText = true;
5164
5167
  for (let j = i + 1; j < children.length; j++) {
5165
5168
  const next = children[j];
5166
- if (isText(next)) {
5169
+ if (isText$1(next)) {
5167
5170
  if (!currentContainer) {
5168
5171
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
5169
5172
  }
@@ -5205,7 +5208,7 @@ const transformText = (node, context) => {
5205
5208
  // runtime normalization.
5206
5209
  for (let i = 0; i < children.length; i++) {
5207
5210
  const child = children[i];
5208
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5211
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5209
5212
  const callArgs = [];
5210
5213
  // createTextVNode defaults to single whitespace, so if it is a
5211
5214
  // single space the code could be an empty call to save bytes.
@@ -5230,13 +5233,13 @@ const transformText = (node, context) => {
5230
5233
  }
5231
5234
  };
5232
5235
 
5233
- const seen = new WeakSet();
5236
+ const seen$1 = new WeakSet();
5234
5237
  const transformOnce = (node, context) => {
5235
5238
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5236
- if (seen.has(node) || context.inVOnce) {
5239
+ if (seen$1.has(node) || context.inVOnce) {
5237
5240
  return;
5238
5241
  }
5239
- seen.add(node);
5242
+ seen$1.add(node);
5240
5243
  context.inVOnce = true;
5241
5244
  context.helper(SET_BLOCK_TRACKING);
5242
5245
  return () => {
@@ -5260,9 +5263,16 @@ const transformModel = (dir, node, context) => {
5260
5263
  // im SFC <script setup> inline mode, the exp may have been transformed into
5261
5264
  // _unref(exp)
5262
5265
  const bindingType = context.bindingMetadata[rawExp];
5266
+ // check props
5267
+ if (bindingType === "props" /* BindingTypes.PROPS */ ||
5268
+ bindingType === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
5269
+ context.onError(createCompilerError(44 /* ErrorCodes.X_V_MODEL_ON_PROPS */, exp.loc));
5270
+ return createTransformProps();
5271
+ }
5263
5272
  const maybeRef = context.inline &&
5264
- bindingType &&
5265
- bindingType !== "setup-const" /* BindingTypes.SETUP_CONST */;
5273
+ (bindingType === "setup-let" /* BindingTypes.SETUP_LET */ ||
5274
+ bindingType === "setup-ref" /* BindingTypes.SETUP_REF */ ||
5275
+ bindingType === "setup-maybe-ref" /* BindingTypes.SETUP_MAYBE_REF */);
5266
5276
  if (!expString.trim() ||
5267
5277
  (!isMemberExpression(expString, context) && !maybeRef)) {
5268
5278
  context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
@@ -5277,7 +5287,7 @@ const transformModel = (dir, node, context) => {
5277
5287
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
5278
5288
  const eventName = arg
5279
5289
  ? isStaticExp(arg)
5280
- ? `onUpdate:${arg.content}`
5290
+ ? `onUpdate:${shared.camelize(arg.content)}`
5281
5291
  : createCompoundExpression(['"onUpdate:" + ', arg])
5282
5292
  : `onUpdate:modelValue`;
5283
5293
  let assignmentExp;
@@ -5504,14 +5514,14 @@ function wrapFilter(exp, filter, context) {
5504
5514
  }
5505
5515
  }
5506
5516
 
5507
- const seen$1 = new WeakSet();
5517
+ const seen = new WeakSet();
5508
5518
  const transformMemo = (node, context) => {
5509
5519
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
5510
5520
  const dir = findDir(node, 'memo');
5511
- if (!dir || seen$1.has(node)) {
5521
+ if (!dir || seen.has(node)) {
5512
5522
  return;
5513
5523
  }
5514
- seen$1.add(node);
5524
+ seen.add(node);
5515
5525
  return () => {
5516
5526
  const codegenNode = node.codegenNode ||
5517
5527
  context.currentNode.codegenNode;
@@ -5565,10 +5575,10 @@ function baseCompile(template, options = {}) {
5565
5575
  const isModuleMode = options.mode === 'module';
5566
5576
  const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
5567
5577
  if (!prefixIdentifiers && options.cacheHandlers) {
5568
- onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
5578
+ onError(createCompilerError(49 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
5569
5579
  }
5570
5580
  if (options.scopeId && !isModuleMode) {
5571
- onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
5581
+ onError(createCompilerError(50 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
5572
5582
  }
5573
5583
  const ast = shared.isString(template) ? baseParse(template, options) : template;
5574
5584
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
@@ -5694,7 +5704,7 @@ exports.isStaticExp = isStaticExp;
5694
5704
  exports.isStaticProperty = isStaticProperty;
5695
5705
  exports.isStaticPropertyKey = isStaticPropertyKey;
5696
5706
  exports.isTemplateNode = isTemplateNode;
5697
- exports.isText = isText;
5707
+ exports.isText = isText$1;
5698
5708
  exports.isVSlot = isVSlot;
5699
5709
  exports.locStub = locStub;
5700
5710
  exports.makeBlock = makeBlock;
@@ -18,7 +18,8 @@ export declare interface ArrayExpression extends Node_2 {
18
18
  elements: Array<string | Node_2>;
19
19
  }
20
20
 
21
- export declare function assert(condition: boolean, msg?: string): void;
21
+ declare function assert_2(condition: boolean, msg?: string): void;
22
+ export { assert_2 as assert }
22
23
 
23
24
  export declare interface AssignmentExpression extends Node_2 {
24
25
  type: NodeTypes.JS_ASSIGNMENT_EXPRESSION;
@@ -446,13 +447,14 @@ export declare const enum ErrorCodes {
446
447
  X_V_MODEL_NO_EXPRESSION = 41,
447
448
  X_V_MODEL_MALFORMED_EXPRESSION = 42,
448
449
  X_V_MODEL_ON_SCOPE_VARIABLE = 43,
449
- X_INVALID_EXPRESSION = 44,
450
- X_KEEP_ALIVE_INVALID_CHILDREN = 45,
451
- X_PREFIX_ID_NOT_SUPPORTED = 46,
452
- X_MODULE_MODE_NOT_SUPPORTED = 47,
453
- X_CACHE_HANDLER_NOT_SUPPORTED = 48,
454
- X_SCOPE_ID_NOT_SUPPORTED = 49,
455
- __EXTEND_POINT__ = 50
450
+ X_V_MODEL_ON_PROPS = 44,
451
+ X_INVALID_EXPRESSION = 45,
452
+ X_KEEP_ALIVE_INVALID_CHILDREN = 46,
453
+ X_PREFIX_ID_NOT_SUPPORTED = 47,
454
+ X_MODULE_MODE_NOT_SUPPORTED = 48,
455
+ X_CACHE_HANDLER_NOT_SUPPORTED = 49,
456
+ X_SCOPE_ID_NOT_SUPPORTED = 50,
457
+ __EXTEND_POINT__ = 51
456
458
  }
457
459
 
458
460
  declare interface ErrorHandlingOptions {
@@ -858,7 +860,7 @@ export declare interface ReturnStatement extends Node_2 {
858
860
  export declare interface RootNode extends Node_2 {
859
861
  type: NodeTypes.ROOT;
860
862
  children: TemplateChildNode[];
861
- helpers: symbol[];
863
+ helpers: Set<symbol>;
862
864
  components: string[];
863
865
  directives: string[];
864
866
  hoists: (JSChildNode | null)[];
@@ -1,4 +1,4 @@
1
- import { isString, hyphenate, NOOP, extend, isObject, NO, isArray, makeMap, isSymbol, EMPTY_OBJ, capitalize, camelize as camelize$1, PatchFlagNames, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
1
+ import { isString, hyphenate, NOOP, extend, isObject, NO, isArray, makeMap, isSymbol, capitalize, camelize as camelize$1, EMPTY_OBJ, PatchFlagNames, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
2
2
  export { generateCodeFrame } from '@vue/shared';
3
3
 
4
4
  function defaultOnError(error) {
@@ -58,7 +58,7 @@ const errorMessages = {
58
58
  [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
59
59
  [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
60
60
  [36 /* ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
61
- [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
61
+ [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>. ` +
62
62
  `When there are multiple named slots, all slots should use <template> ` +
63
63
  `syntax to avoid scope ambiguity.`,
64
64
  [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
@@ -68,15 +68,16 @@ const errorMessages = {
68
68
  [41 /* ErrorCodes.X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
69
69
  [42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
70
70
  [43 /* ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE */]: `v-model cannot be used on v-for or v-slot scope variables because they are not writable.`,
71
- [44 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
72
- [45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
71
+ [44 /* ErrorCodes.X_V_MODEL_ON_PROPS */]: `v-model cannot be used on a prop, because local prop bindings are not writable.\nUse a v-bind binding combined with a v-on listener that emits update:x event instead.`,
72
+ [45 /* ErrorCodes.X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
73
+ [46 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
73
74
  // generic errors
74
- [46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
75
- [47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
76
- [48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
77
- [49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
75
+ [47 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
76
+ [48 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
77
+ [49 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
78
+ [50 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
78
79
  // just to fulfill types
79
- [50 /* ErrorCodes.__EXTEND_POINT__ */]: ``
80
+ [51 /* ErrorCodes.__EXTEND_POINT__ */]: ``
80
81
  };
81
82
 
82
83
  const FRAGMENT = Symbol((process.env.NODE_ENV !== 'production') ? `Fragment` : ``);
@@ -180,7 +181,7 @@ function createRoot(children, loc = locStub) {
180
181
  return {
181
182
  type: 0 /* NodeTypes.ROOT */,
182
183
  children,
183
- helpers: [],
184
+ helpers: new Set(),
184
185
  components: [],
185
186
  directives: [],
186
187
  hoists: [],
@@ -527,7 +528,7 @@ function hasDynamicKeyVBind(node) {
527
528
  !p.arg.isStatic) // v-bind:[foo]
528
529
  );
529
530
  }
530
- function isText(node) {
531
+ function isText$1(node) {
531
532
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
532
533
  }
533
534
  function isVSlot(p) {
@@ -2057,7 +2058,7 @@ function transform(root, options) {
2057
2058
  createRootCodegen(root, context);
2058
2059
  }
2059
2060
  // finalize meta information
2060
- root.helpers = [...context.helpers.keys()];
2061
+ root.helpers = new Set([...context.helpers.keys()]);
2061
2062
  root.components = [...context.components];
2062
2063
  root.directives = [...context.directives];
2063
2064
  root.imports = context.imports;
@@ -2264,12 +2265,16 @@ function generate(ast, options = {}) {
2264
2265
  if (options.onContextCreated)
2265
2266
  options.onContextCreated(context);
2266
2267
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2267
- const hasHelpers = ast.helpers.length > 0;
2268
+ const helpers = Array.from(ast.helpers);
2269
+ const hasHelpers = helpers.length > 0;
2268
2270
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2271
+ const isSetupInlined = !true ;
2269
2272
  // preambles
2270
2273
  // in setup() inline mode, the preamble is generated in a sub context
2271
2274
  // and returned separately.
2272
- const preambleContext = context;
2275
+ const preambleContext = isSetupInlined
2276
+ ? createCodegenContext(ast, options)
2277
+ : context;
2273
2278
  {
2274
2279
  genFunctionPreamble(ast, preambleContext);
2275
2280
  }
@@ -2287,7 +2292,7 @@ function generate(ast, options = {}) {
2287
2292
  // function mode const declarations should be inside with block
2288
2293
  // also they should be renamed to avoid collision with user properties
2289
2294
  if (hasHelpers) {
2290
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2295
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2291
2296
  push(`\n`);
2292
2297
  newline();
2293
2298
  }
@@ -2339,7 +2344,7 @@ function generate(ast, options = {}) {
2339
2344
  return {
2340
2345
  ast,
2341
2346
  code: context.code,
2342
- preamble: ``,
2347
+ preamble: isSetupInlined ? preambleContext.code : ``,
2343
2348
  // SourceMapGenerator does have toJSON() method but it's not in the types
2344
2349
  map: context.map ? context.map.toJSON() : undefined
2345
2350
  };
@@ -2351,7 +2356,8 @@ function genFunctionPreamble(ast, context) {
2351
2356
  // In prefix mode, we place the const declaration at top so it's done
2352
2357
  // only once; But if we not prefixing, we place the declaration inside the
2353
2358
  // with block so it doesn't incur the `in` check cost for every helper access.
2354
- if (ast.helpers.length > 0) {
2359
+ const helpers = Array.from(ast.helpers);
2360
+ if (helpers.length > 0) {
2355
2361
  {
2356
2362
  // "with" mode.
2357
2363
  // save Vue in a separate variable to avoid collision
@@ -2367,7 +2373,7 @@ function genFunctionPreamble(ast, context) {
2367
2373
  CREATE_TEXT,
2368
2374
  CREATE_STATIC
2369
2375
  ]
2370
- .filter(helper => ast.helpers.includes(helper))
2376
+ .filter(helper => helpers.includes(helper))
2371
2377
  .map(aliasHelper)
2372
2378
  .join(', ');
2373
2379
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2414,7 +2420,7 @@ function genHoists(hoists, context) {
2414
2420
  }
2415
2421
  context.pure = false;
2416
2422
  }
2417
- function isText$1(n) {
2423
+ function isText(n) {
2418
2424
  return (isString(n) ||
2419
2425
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2420
2426
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2423,7 +2429,7 @@ function isText$1(n) {
2423
2429
  }
2424
2430
  function genNodeListAsArray(nodes, context) {
2425
2431
  const multilines = nodes.length > 3 ||
2426
- (((process.env.NODE_ENV !== 'production')) && nodes.some(n => isArray(n) || !isText$1(n)));
2432
+ (((process.env.NODE_ENV !== 'production')) && nodes.some(n => isArray(n) || !isText(n)));
2427
2433
  context.push(`[`);
2428
2434
  multilines && context.indent();
2429
2435
  genNodeList(nodes, context, multilines);
@@ -2862,11 +2868,11 @@ const isStaticProperty = (node) => node &&
2862
2868
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
2863
2869
 
2864
2870
  // these keywords should not appear inside expressions, but operators like
2865
- // typeof, instanceof and in are allowed
2871
+ // 'typeof', 'instanceof', and 'in' are allowed
2866
2872
  const prohibitedKeywordRE = new RegExp('\\b' +
2867
- ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
2868
- 'super,throw,while,yield,delete,export,import,return,switch,default,' +
2869
- 'extends,finally,continue,debugger,function,arguments,typeof,void')
2873
+ ('arguments,await,break,case,catch,class,const,continue,debugger,default,' +
2874
+ 'delete,do,else,export,extends,finally,for,function,if,import,let,new,' +
2875
+ 'return,super,switch,throw,try,var,void,while,with,yield')
2870
2876
  .split(',')
2871
2877
  .join('\\b|\\b') +
2872
2878
  '\\b');
@@ -2897,7 +2903,7 @@ function validateBrowserExpression(node, context, asParams = false, asRawStateme
2897
2903
  if (keywordMatch) {
2898
2904
  message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`;
2899
2905
  }
2900
- context.onError(createCompilerError(44 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, message));
2906
+ context.onError(createCompilerError(45 /* ErrorCodes.X_INVALID_EXPRESSION */, node.loc, undefined, message));
2901
2907
  }
2902
2908
  }
2903
2909
 
@@ -3729,7 +3735,7 @@ const transformElement = (node, context) => {
3729
3735
  // 2. Force keep-alive to always be updated, since it uses raw children.
3730
3736
  patchFlag |= 1024 /* PatchFlags.DYNAMIC_SLOTS */;
3731
3737
  if ((process.env.NODE_ENV !== 'production') && node.children.length > 1) {
3732
- context.onError(createCompilerError(45 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
3738
+ context.onError(createCompilerError(46 /* ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN */, {
3733
3739
  start: node.children[0].loc.start,
3734
3740
  end: node.children[node.children.length - 1].loc.end,
3735
3741
  source: ''
@@ -4506,11 +4512,11 @@ const transformText = (node, context) => {
4506
4512
  let hasText = false;
4507
4513
  for (let i = 0; i < children.length; i++) {
4508
4514
  const child = children[i];
4509
- if (isText(child)) {
4515
+ if (isText$1(child)) {
4510
4516
  hasText = true;
4511
4517
  for (let j = i + 1; j < children.length; j++) {
4512
4518
  const next = children[j];
4513
- if (isText(next)) {
4519
+ if (isText$1(next)) {
4514
4520
  if (!currentContainer) {
4515
4521
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
4516
4522
  }
@@ -4552,7 +4558,7 @@ const transformText = (node, context) => {
4552
4558
  // runtime normalization.
4553
4559
  for (let i = 0; i < children.length; i++) {
4554
4560
  const child = children[i];
4555
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
4561
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
4556
4562
  const callArgs = [];
4557
4563
  // createTextVNode defaults to single whitespace, so if it is a
4558
4564
  // single space the code could be an empty call to save bytes.
@@ -4577,13 +4583,13 @@ const transformText = (node, context) => {
4577
4583
  }
4578
4584
  };
4579
4585
 
4580
- const seen = new WeakSet();
4586
+ const seen$1 = new WeakSet();
4581
4587
  const transformOnce = (node, context) => {
4582
4588
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
4583
- if (seen.has(node) || context.inVOnce) {
4589
+ if (seen$1.has(node) || context.inVOnce) {
4584
4590
  return;
4585
4591
  }
4586
- seen.add(node);
4592
+ seen$1.add(node);
4587
4593
  context.inVOnce = true;
4588
4594
  context.helper(SET_BLOCK_TRACKING);
4589
4595
  return () => {
@@ -4606,8 +4612,14 @@ const transformModel = (dir, node, context) => {
4606
4612
  const expString = exp.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ? exp.content : rawExp;
4607
4613
  // im SFC <script setup> inline mode, the exp may have been transformed into
4608
4614
  // _unref(exp)
4609
- context.bindingMetadata[rawExp];
4610
- const maybeRef = !true /* BindingTypes.SETUP_CONST */;
4615
+ const bindingType = context.bindingMetadata[rawExp];
4616
+ // check props
4617
+ if (bindingType === "props" /* BindingTypes.PROPS */ ||
4618
+ bindingType === "props-aliased" /* BindingTypes.PROPS_ALIASED */) {
4619
+ context.onError(createCompilerError(44 /* ErrorCodes.X_V_MODEL_ON_PROPS */, exp.loc));
4620
+ return createTransformProps();
4621
+ }
4622
+ const maybeRef = !true ;
4611
4623
  if (!expString.trim() ||
4612
4624
  (!isMemberExpression(expString) && !maybeRef)) {
4613
4625
  context.onError(createCompilerError(42 /* ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
@@ -4616,7 +4628,7 @@ const transformModel = (dir, node, context) => {
4616
4628
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
4617
4629
  const eventName = arg
4618
4630
  ? isStaticExp(arg)
4619
- ? `onUpdate:${arg.content}`
4631
+ ? `onUpdate:${camelize$1(arg.content)}`
4620
4632
  : createCompoundExpression(['"onUpdate:" + ', arg])
4621
4633
  : `onUpdate:modelValue`;
4622
4634
  let assignmentExp;
@@ -4818,14 +4830,14 @@ function wrapFilter(exp, filter, context) {
4818
4830
  }
4819
4831
  }
4820
4832
 
4821
- const seen$1 = new WeakSet();
4833
+ const seen = new WeakSet();
4822
4834
  const transformMemo = (node, context) => {
4823
4835
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
4824
4836
  const dir = findDir(node, 'memo');
4825
- if (!dir || seen$1.has(node)) {
4837
+ if (!dir || seen.has(node)) {
4826
4838
  return;
4827
4839
  }
4828
- seen$1.add(node);
4840
+ seen.add(node);
4829
4841
  return () => {
4830
4842
  const codegenNode = node.codegenNode ||
4831
4843
  context.currentNode.codegenNode;
@@ -4876,18 +4888,18 @@ function baseCompile(template, options = {}) {
4876
4888
  /* istanbul ignore if */
4877
4889
  {
4878
4890
  if (options.prefixIdentifiers === true) {
4879
- onError(createCompilerError(46 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */));
4891
+ onError(createCompilerError(47 /* ErrorCodes.X_PREFIX_ID_NOT_SUPPORTED */));
4880
4892
  }
4881
4893
  else if (isModuleMode) {
4882
- onError(createCompilerError(47 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */));
4894
+ onError(createCompilerError(48 /* ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED */));
4883
4895
  }
4884
4896
  }
4885
4897
  const prefixIdentifiers = !true ;
4886
4898
  if (options.cacheHandlers) {
4887
- onError(createCompilerError(48 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
4899
+ onError(createCompilerError(49 /* ErrorCodes.X_CACHE_HANDLER_NOT_SUPPORTED */));
4888
4900
  }
4889
4901
  if (options.scopeId && !isModuleMode) {
4890
- onError(createCompilerError(49 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
4902
+ onError(createCompilerError(50 /* ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED */));
4891
4903
  }
4892
4904
  const ast = isString(template) ? baseParse(template, options) : template;
4893
4905
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset();
@@ -4907,4 +4919,4 @@ function baseCompile(template, options = {}) {
4907
4919
 
4908
4920
  const noopDirectiveTransform = () => ({ props: [] });
4909
4921
 
4910
- 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, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, generate, getBaseTransformPreset, getConstantType, getInnerRange, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isBuiltInType, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText, isVSlot, locStub, makeBlock, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
4922
+ 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, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, generate, getBaseTransformPreset, getConstantType, getInnerRange, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isBuiltInType, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, makeBlock, 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.2.44",
3
+ "version": "3.2.46",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.2.44",
35
+ "@vue/shared": "3.2.46",
36
36
  "@babel/parser": "^7.16.4",
37
37
  "estree-walker": "^2.0.2",
38
38
  "source-map": "^0.6.1"