@vue/compiler-core 3.2.45 → 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. `,
@@ -186,7 +184,7 @@ function createRoot(children, loc = locStub) {
186
184
  return {
187
185
  type: 0 /* NodeTypes.ROOT */,
188
186
  children,
189
- helpers: [],
187
+ helpers: new Set(),
190
188
  components: [],
191
189
  directives: [],
192
190
  hoists: [],
@@ -546,7 +544,7 @@ function hasDynamicKeyVBind(node) {
546
544
  !p.arg.isStatic) // v-bind:[foo]
547
545
  );
548
546
  }
549
- function isText(node) {
547
+ function isText$1(node) {
550
548
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
551
549
  }
552
550
  function isVSlot(p) {
@@ -2105,7 +2103,7 @@ function transform(root, options) {
2105
2103
  createRootCodegen(root, context);
2106
2104
  }
2107
2105
  // finalize meta information
2108
- root.helpers = [...context.helpers.keys()];
2106
+ root.helpers = new Set([...context.helpers.keys()]);
2109
2107
  root.components = [...context.components];
2110
2108
  root.directives = [...context.directives];
2111
2109
  root.imports = context.imports;
@@ -2346,7 +2344,8 @@ function generate(ast, options = {}) {
2346
2344
  if (options.onContextCreated)
2347
2345
  options.onContextCreated(context);
2348
2346
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2349
- const hasHelpers = ast.helpers.length > 0;
2347
+ const helpers = Array.from(ast.helpers);
2348
+ const hasHelpers = helpers.length > 0;
2350
2349
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2351
2350
  const genScopeId = scopeId != null && mode === 'module';
2352
2351
  const isSetupInlined = !!options.inline;
@@ -2385,7 +2384,7 @@ function generate(ast, options = {}) {
2385
2384
  // function mode const declarations should be inside with block
2386
2385
  // also they should be renamed to avoid collision with user properties
2387
2386
  if (hasHelpers) {
2388
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2387
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2389
2388
  push(`\n`);
2390
2389
  newline();
2391
2390
  }
@@ -2451,9 +2450,10 @@ function genFunctionPreamble(ast, context) {
2451
2450
  // In prefix mode, we place the const declaration at top so it's done
2452
2451
  // only once; But if we not prefixing, we place the declaration inside the
2453
2452
  // with block so it doesn't incur the `in` check cost for every helper access.
2454
- if (ast.helpers.length > 0) {
2453
+ const helpers = Array.from(ast.helpers);
2454
+ if (helpers.length > 0) {
2455
2455
  if (prefixIdentifiers) {
2456
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2456
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2457
2457
  }
2458
2458
  else {
2459
2459
  // "with" mode.
@@ -2470,7 +2470,7 @@ function genFunctionPreamble(ast, context) {
2470
2470
  CREATE_TEXT,
2471
2471
  CREATE_STATIC
2472
2472
  ]
2473
- .filter(helper => ast.helpers.includes(helper))
2473
+ .filter(helper => helpers.includes(helper))
2474
2474
  .map(aliasHelper)
2475
2475
  .join(', ');
2476
2476
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2491,25 +2491,27 @@ function genFunctionPreamble(ast, context) {
2491
2491
  function genModulePreamble(ast, context, genScopeId, inline) {
2492
2492
  const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
2493
2493
  if (genScopeId && ast.hoists.length) {
2494
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2494
+ ast.helpers.add(PUSH_SCOPE_ID);
2495
+ ast.helpers.add(POP_SCOPE_ID);
2495
2496
  }
2496
2497
  // generate import statements for helpers
2497
- if (ast.helpers.length) {
2498
+ if (ast.helpers.size) {
2499
+ const helpers = Array.from(ast.helpers);
2498
2500
  if (optimizeImports) {
2499
2501
  // when bundled with webpack with code-split, calling an import binding
2500
2502
  // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
2501
2503
  // incurring both payload size increase and potential perf overhead.
2502
2504
  // therefore we assign the imports to variables (which is a constant ~50b
2503
2505
  // cost per-component instead of scaling with template size)
2504
- push(`import { ${ast.helpers
2506
+ push(`import { ${helpers
2505
2507
  .map(s => helperNameMap[s])
2506
2508
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2507
- push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
2509
+ push(`\n// Binding optimization for webpack code-split\nconst ${helpers
2508
2510
  .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
2509
2511
  .join(', ')}\n`);
2510
2512
  }
2511
2513
  else {
2512
- push(`import { ${ast.helpers
2514
+ push(`import { ${helpers
2513
2515
  .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
2514
2516
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2515
2517
  }
@@ -2586,7 +2588,7 @@ function genImports(importsOptions, context) {
2586
2588
  context.newline();
2587
2589
  });
2588
2590
  }
2589
- function isText$1(n) {
2591
+ function isText(n) {
2590
2592
  return (shared.isString(n) ||
2591
2593
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2592
2594
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2595,7 +2597,7 @@ function isText$1(n) {
2595
2597
  }
2596
2598
  function genNodeListAsArray(nodes, context) {
2597
2599
  const multilines = nodes.length > 3 ||
2598
- (nodes.some(n => shared.isArray(n) || !isText$1(n)));
2600
+ (nodes.some(n => shared.isArray(n) || !isText(n)));
2599
2601
  context.push(`[`);
2600
2602
  multilines && context.indent();
2601
2603
  genNodeList(nodes, context, multilines);
@@ -5001,9 +5003,6 @@ function isComponentTag(tag) {
5001
5003
  return tag === 'component' || tag === 'Component';
5002
5004
  }
5003
5005
 
5004
- Object.freeze({})
5005
- ;
5006
- Object.freeze([]) ;
5007
5006
  const cacheStringFunction = (fn) => {
5008
5007
  const cache = Object.create(null);
5009
5008
  return ((str) => {
@@ -5285,11 +5284,11 @@ const transformText = (node, context) => {
5285
5284
  let hasText = false;
5286
5285
  for (let i = 0; i < children.length; i++) {
5287
5286
  const child = children[i];
5288
- if (isText(child)) {
5287
+ if (isText$1(child)) {
5289
5288
  hasText = true;
5290
5289
  for (let j = i + 1; j < children.length; j++) {
5291
5290
  const next = children[j];
5292
- if (isText(next)) {
5291
+ if (isText$1(next)) {
5293
5292
  if (!currentContainer) {
5294
5293
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
5295
5294
  }
@@ -5331,7 +5330,7 @@ const transformText = (node, context) => {
5331
5330
  // runtime normalization.
5332
5331
  for (let i = 0; i < children.length; i++) {
5333
5332
  const child = children[i];
5334
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5333
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5335
5334
  const callArgs = [];
5336
5335
  // createTextVNode defaults to single whitespace, so if it is a
5337
5336
  // single space the code could be an empty call to save bytes.
@@ -5356,13 +5355,13 @@ const transformText = (node, context) => {
5356
5355
  }
5357
5356
  };
5358
5357
 
5359
- const seen = new WeakSet();
5358
+ const seen$1 = new WeakSet();
5360
5359
  const transformOnce = (node, context) => {
5361
5360
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5362
- if (seen.has(node) || context.inVOnce) {
5361
+ if (seen$1.has(node) || context.inVOnce) {
5363
5362
  return;
5364
5363
  }
5365
- seen.add(node);
5364
+ seen$1.add(node);
5366
5365
  context.inVOnce = true;
5367
5366
  context.helper(SET_BLOCK_TRACKING);
5368
5367
  return () => {
@@ -5410,7 +5409,7 @@ const transformModel = (dir, node, context) => {
5410
5409
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
5411
5410
  const eventName = arg
5412
5411
  ? isStaticExp(arg)
5413
- ? `onUpdate:${arg.content}`
5412
+ ? `onUpdate:${shared.camelize(arg.content)}`
5414
5413
  : createCompoundExpression(['"onUpdate:" + ', arg])
5415
5414
  : `onUpdate:modelValue`;
5416
5415
  let assignmentExp;
@@ -5638,14 +5637,14 @@ function wrapFilter(exp, filter, context) {
5638
5637
  }
5639
5638
  }
5640
5639
 
5641
- const seen$1 = new WeakSet();
5640
+ const seen = new WeakSet();
5642
5641
  const transformMemo = (node, context) => {
5643
5642
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
5644
5643
  const dir = findDir(node, 'memo');
5645
- if (!dir || seen$1.has(node)) {
5644
+ if (!dir || seen.has(node)) {
5646
5645
  return;
5647
5646
  }
5648
- seen$1.add(node);
5647
+ seen.add(node);
5649
5648
  return () => {
5650
5649
  const codegenNode = node.codegenNode ||
5651
5650
  context.currentNode.codegenNode;
@@ -5828,7 +5827,7 @@ exports.isStaticExp = isStaticExp;
5828
5827
  exports.isStaticProperty = isStaticProperty;
5829
5828
  exports.isStaticPropertyKey = isStaticPropertyKey;
5830
5829
  exports.isTemplateNode = isTemplateNode;
5831
- exports.isText = isText;
5830
+ exports.isText = isText$1;
5832
5831
  exports.isVSlot = isVSlot;
5833
5832
  exports.locStub = locStub;
5834
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. `,
@@ -185,7 +183,7 @@ function createRoot(children, loc = locStub) {
185
183
  return {
186
184
  type: 0 /* NodeTypes.ROOT */,
187
185
  children,
188
- helpers: [],
186
+ helpers: new Set(),
189
187
  components: [],
190
188
  directives: [],
191
189
  hoists: [],
@@ -545,7 +543,7 @@ function hasDynamicKeyVBind(node) {
545
543
  !p.arg.isStatic) // v-bind:[foo]
546
544
  );
547
545
  }
548
- function isText(node) {
546
+ function isText$1(node) {
549
547
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
550
548
  }
551
549
  function isVSlot(p) {
@@ -2061,7 +2059,7 @@ function transform(root, options) {
2061
2059
  createRootCodegen(root, context);
2062
2060
  }
2063
2061
  // finalize meta information
2064
- root.helpers = [...context.helpers.keys()];
2062
+ root.helpers = new Set([...context.helpers.keys()]);
2065
2063
  root.components = [...context.components];
2066
2064
  root.directives = [...context.directives];
2067
2065
  root.imports = context.imports;
@@ -2296,7 +2294,8 @@ function generate(ast, options = {}) {
2296
2294
  if (options.onContextCreated)
2297
2295
  options.onContextCreated(context);
2298
2296
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2299
- const hasHelpers = ast.helpers.length > 0;
2297
+ const helpers = Array.from(ast.helpers);
2298
+ const hasHelpers = helpers.length > 0;
2300
2299
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2301
2300
  const genScopeId = scopeId != null && mode === 'module';
2302
2301
  const isSetupInlined = !!options.inline;
@@ -2335,7 +2334,7 @@ function generate(ast, options = {}) {
2335
2334
  // function mode const declarations should be inside with block
2336
2335
  // also they should be renamed to avoid collision with user properties
2337
2336
  if (hasHelpers) {
2338
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2337
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2339
2338
  push(`\n`);
2340
2339
  newline();
2341
2340
  }
@@ -2401,9 +2400,10 @@ function genFunctionPreamble(ast, context) {
2401
2400
  // In prefix mode, we place the const declaration at top so it's done
2402
2401
  // only once; But if we not prefixing, we place the declaration inside the
2403
2402
  // with block so it doesn't incur the `in` check cost for every helper access.
2404
- if (ast.helpers.length > 0) {
2403
+ const helpers = Array.from(ast.helpers);
2404
+ if (helpers.length > 0) {
2405
2405
  if (prefixIdentifiers) {
2406
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2406
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2407
2407
  }
2408
2408
  else {
2409
2409
  // "with" mode.
@@ -2420,7 +2420,7 @@ function genFunctionPreamble(ast, context) {
2420
2420
  CREATE_TEXT,
2421
2421
  CREATE_STATIC
2422
2422
  ]
2423
- .filter(helper => ast.helpers.includes(helper))
2423
+ .filter(helper => helpers.includes(helper))
2424
2424
  .map(aliasHelper)
2425
2425
  .join(', ');
2426
2426
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2441,25 +2441,27 @@ function genFunctionPreamble(ast, context) {
2441
2441
  function genModulePreamble(ast, context, genScopeId, inline) {
2442
2442
  const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
2443
2443
  if (genScopeId && ast.hoists.length) {
2444
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2444
+ ast.helpers.add(PUSH_SCOPE_ID);
2445
+ ast.helpers.add(POP_SCOPE_ID);
2445
2446
  }
2446
2447
  // generate import statements for helpers
2447
- if (ast.helpers.length) {
2448
+ if (ast.helpers.size) {
2449
+ const helpers = Array.from(ast.helpers);
2448
2450
  if (optimizeImports) {
2449
2451
  // when bundled with webpack with code-split, calling an import binding
2450
2452
  // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
2451
2453
  // incurring both payload size increase and potential perf overhead.
2452
2454
  // therefore we assign the imports to variables (which is a constant ~50b
2453
2455
  // cost per-component instead of scaling with template size)
2454
- push(`import { ${ast.helpers
2456
+ push(`import { ${helpers
2455
2457
  .map(s => helperNameMap[s])
2456
2458
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2457
- push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
2459
+ push(`\n// Binding optimization for webpack code-split\nconst ${helpers
2458
2460
  .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
2459
2461
  .join(', ')}\n`);
2460
2462
  }
2461
2463
  else {
2462
- push(`import { ${ast.helpers
2464
+ push(`import { ${helpers
2463
2465
  .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
2464
2466
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2465
2467
  }
@@ -2536,7 +2538,7 @@ function genImports(importsOptions, context) {
2536
2538
  context.newline();
2537
2539
  });
2538
2540
  }
2539
- function isText$1(n) {
2541
+ function isText(n) {
2540
2542
  return (shared.isString(n) ||
2541
2543
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2542
2544
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2545,7 +2547,7 @@ function isText$1(n) {
2545
2547
  }
2546
2548
  function genNodeListAsArray(nodes, context) {
2547
2549
  const multilines = nodes.length > 3 ||
2548
- (nodes.some(n => shared.isArray(n) || !isText$1(n)));
2550
+ (nodes.some(n => shared.isArray(n) || !isText(n)));
2549
2551
  context.push(`[`);
2550
2552
  multilines && context.indent();
2551
2553
  genNodeList(nodes, context, multilines);
@@ -5160,11 +5162,11 @@ const transformText = (node, context) => {
5160
5162
  let hasText = false;
5161
5163
  for (let i = 0; i < children.length; i++) {
5162
5164
  const child = children[i];
5163
- if (isText(child)) {
5165
+ if (isText$1(child)) {
5164
5166
  hasText = true;
5165
5167
  for (let j = i + 1; j < children.length; j++) {
5166
5168
  const next = children[j];
5167
- if (isText(next)) {
5169
+ if (isText$1(next)) {
5168
5170
  if (!currentContainer) {
5169
5171
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
5170
5172
  }
@@ -5206,7 +5208,7 @@ const transformText = (node, context) => {
5206
5208
  // runtime normalization.
5207
5209
  for (let i = 0; i < children.length; i++) {
5208
5210
  const child = children[i];
5209
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5211
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5210
5212
  const callArgs = [];
5211
5213
  // createTextVNode defaults to single whitespace, so if it is a
5212
5214
  // single space the code could be an empty call to save bytes.
@@ -5231,13 +5233,13 @@ const transformText = (node, context) => {
5231
5233
  }
5232
5234
  };
5233
5235
 
5234
- const seen = new WeakSet();
5236
+ const seen$1 = new WeakSet();
5235
5237
  const transformOnce = (node, context) => {
5236
5238
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5237
- if (seen.has(node) || context.inVOnce) {
5239
+ if (seen$1.has(node) || context.inVOnce) {
5238
5240
  return;
5239
5241
  }
5240
- seen.add(node);
5242
+ seen$1.add(node);
5241
5243
  context.inVOnce = true;
5242
5244
  context.helper(SET_BLOCK_TRACKING);
5243
5245
  return () => {
@@ -5285,7 +5287,7 @@ const transformModel = (dir, node, context) => {
5285
5287
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
5286
5288
  const eventName = arg
5287
5289
  ? isStaticExp(arg)
5288
- ? `onUpdate:${arg.content}`
5290
+ ? `onUpdate:${shared.camelize(arg.content)}`
5289
5291
  : createCompoundExpression(['"onUpdate:" + ', arg])
5290
5292
  : `onUpdate:modelValue`;
5291
5293
  let assignmentExp;
@@ -5512,14 +5514,14 @@ function wrapFilter(exp, filter, context) {
5512
5514
  }
5513
5515
  }
5514
5516
 
5515
- const seen$1 = new WeakSet();
5517
+ const seen = new WeakSet();
5516
5518
  const transformMemo = (node, context) => {
5517
5519
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
5518
5520
  const dir = findDir(node, 'memo');
5519
- if (!dir || seen$1.has(node)) {
5521
+ if (!dir || seen.has(node)) {
5520
5522
  return;
5521
5523
  }
5522
- seen$1.add(node);
5524
+ seen.add(node);
5523
5525
  return () => {
5524
5526
  const codegenNode = node.codegenNode ||
5525
5527
  context.currentNode.codegenNode;
@@ -5702,7 +5704,7 @@ exports.isStaticExp = isStaticExp;
5702
5704
  exports.isStaticProperty = isStaticProperty;
5703
5705
  exports.isStaticPropertyKey = isStaticPropertyKey;
5704
5706
  exports.isTemplateNode = isTemplateNode;
5705
- exports.isText = isText;
5707
+ exports.isText = isText$1;
5706
5708
  exports.isVSlot = isVSlot;
5707
5709
  exports.locStub = locStub;
5708
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;
@@ -859,7 +860,7 @@ export declare interface ReturnStatement extends Node_2 {
859
860
  export declare interface RootNode extends Node_2 {
860
861
  type: NodeTypes.ROOT;
861
862
  children: TemplateChildNode[];
862
- helpers: symbol[];
863
+ helpers: Set<symbol>;
863
864
  components: string[];
864
865
  directives: string[];
865
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. `,
@@ -181,7 +181,7 @@ function createRoot(children, loc = locStub) {
181
181
  return {
182
182
  type: 0 /* NodeTypes.ROOT */,
183
183
  children,
184
- helpers: [],
184
+ helpers: new Set(),
185
185
  components: [],
186
186
  directives: [],
187
187
  hoists: [],
@@ -528,7 +528,7 @@ function hasDynamicKeyVBind(node) {
528
528
  !p.arg.isStatic) // v-bind:[foo]
529
529
  );
530
530
  }
531
- function isText(node) {
531
+ function isText$1(node) {
532
532
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
533
533
  }
534
534
  function isVSlot(p) {
@@ -2058,7 +2058,7 @@ function transform(root, options) {
2058
2058
  createRootCodegen(root, context);
2059
2059
  }
2060
2060
  // finalize meta information
2061
- root.helpers = [...context.helpers.keys()];
2061
+ root.helpers = new Set([...context.helpers.keys()]);
2062
2062
  root.components = [...context.components];
2063
2063
  root.directives = [...context.directives];
2064
2064
  root.imports = context.imports;
@@ -2265,12 +2265,16 @@ function generate(ast, options = {}) {
2265
2265
  if (options.onContextCreated)
2266
2266
  options.onContextCreated(context);
2267
2267
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2268
- const hasHelpers = ast.helpers.length > 0;
2268
+ const helpers = Array.from(ast.helpers);
2269
+ const hasHelpers = helpers.length > 0;
2269
2270
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2271
+ const isSetupInlined = !true ;
2270
2272
  // preambles
2271
2273
  // in setup() inline mode, the preamble is generated in a sub context
2272
2274
  // and returned separately.
2273
- const preambleContext = context;
2275
+ const preambleContext = isSetupInlined
2276
+ ? createCodegenContext(ast, options)
2277
+ : context;
2274
2278
  {
2275
2279
  genFunctionPreamble(ast, preambleContext);
2276
2280
  }
@@ -2288,7 +2292,7 @@ function generate(ast, options = {}) {
2288
2292
  // function mode const declarations should be inside with block
2289
2293
  // also they should be renamed to avoid collision with user properties
2290
2294
  if (hasHelpers) {
2291
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2295
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2292
2296
  push(`\n`);
2293
2297
  newline();
2294
2298
  }
@@ -2340,7 +2344,7 @@ function generate(ast, options = {}) {
2340
2344
  return {
2341
2345
  ast,
2342
2346
  code: context.code,
2343
- preamble: ``,
2347
+ preamble: isSetupInlined ? preambleContext.code : ``,
2344
2348
  // SourceMapGenerator does have toJSON() method but it's not in the types
2345
2349
  map: context.map ? context.map.toJSON() : undefined
2346
2350
  };
@@ -2352,7 +2356,8 @@ function genFunctionPreamble(ast, context) {
2352
2356
  // In prefix mode, we place the const declaration at top so it's done
2353
2357
  // only once; But if we not prefixing, we place the declaration inside the
2354
2358
  // with block so it doesn't incur the `in` check cost for every helper access.
2355
- if (ast.helpers.length > 0) {
2359
+ const helpers = Array.from(ast.helpers);
2360
+ if (helpers.length > 0) {
2356
2361
  {
2357
2362
  // "with" mode.
2358
2363
  // save Vue in a separate variable to avoid collision
@@ -2368,7 +2373,7 @@ function genFunctionPreamble(ast, context) {
2368
2373
  CREATE_TEXT,
2369
2374
  CREATE_STATIC
2370
2375
  ]
2371
- .filter(helper => ast.helpers.includes(helper))
2376
+ .filter(helper => helpers.includes(helper))
2372
2377
  .map(aliasHelper)
2373
2378
  .join(', ');
2374
2379
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2415,7 +2420,7 @@ function genHoists(hoists, context) {
2415
2420
  }
2416
2421
  context.pure = false;
2417
2422
  }
2418
- function isText$1(n) {
2423
+ function isText(n) {
2419
2424
  return (isString(n) ||
2420
2425
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2421
2426
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2424,7 +2429,7 @@ function isText$1(n) {
2424
2429
  }
2425
2430
  function genNodeListAsArray(nodes, context) {
2426
2431
  const multilines = nodes.length > 3 ||
2427
- (((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)));
2428
2433
  context.push(`[`);
2429
2434
  multilines && context.indent();
2430
2435
  genNodeList(nodes, context, multilines);
@@ -2863,11 +2868,11 @@ const isStaticProperty = (node) => node &&
2863
2868
  const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
2864
2869
 
2865
2870
  // these keywords should not appear inside expressions, but operators like
2866
- // typeof, instanceof and in are allowed
2871
+ // 'typeof', 'instanceof', and 'in' are allowed
2867
2872
  const prohibitedKeywordRE = new RegExp('\\b' +
2868
- ('do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
2869
- 'super,throw,while,yield,delete,export,import,return,switch,default,' +
2870
- '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')
2871
2876
  .split(',')
2872
2877
  .join('\\b|\\b') +
2873
2878
  '\\b');
@@ -4507,11 +4512,11 @@ const transformText = (node, context) => {
4507
4512
  let hasText = false;
4508
4513
  for (let i = 0; i < children.length; i++) {
4509
4514
  const child = children[i];
4510
- if (isText(child)) {
4515
+ if (isText$1(child)) {
4511
4516
  hasText = true;
4512
4517
  for (let j = i + 1; j < children.length; j++) {
4513
4518
  const next = children[j];
4514
- if (isText(next)) {
4519
+ if (isText$1(next)) {
4515
4520
  if (!currentContainer) {
4516
4521
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
4517
4522
  }
@@ -4553,7 +4558,7 @@ const transformText = (node, context) => {
4553
4558
  // runtime normalization.
4554
4559
  for (let i = 0; i < children.length; i++) {
4555
4560
  const child = children[i];
4556
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
4561
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
4557
4562
  const callArgs = [];
4558
4563
  // createTextVNode defaults to single whitespace, so if it is a
4559
4564
  // single space the code could be an empty call to save bytes.
@@ -4578,13 +4583,13 @@ const transformText = (node, context) => {
4578
4583
  }
4579
4584
  };
4580
4585
 
4581
- const seen = new WeakSet();
4586
+ const seen$1 = new WeakSet();
4582
4587
  const transformOnce = (node, context) => {
4583
4588
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
4584
- if (seen.has(node) || context.inVOnce) {
4589
+ if (seen$1.has(node) || context.inVOnce) {
4585
4590
  return;
4586
4591
  }
4587
- seen.add(node);
4592
+ seen$1.add(node);
4588
4593
  context.inVOnce = true;
4589
4594
  context.helper(SET_BLOCK_TRACKING);
4590
4595
  return () => {
@@ -4623,7 +4628,7 @@ const transformModel = (dir, node, context) => {
4623
4628
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
4624
4629
  const eventName = arg
4625
4630
  ? isStaticExp(arg)
4626
- ? `onUpdate:${arg.content}`
4631
+ ? `onUpdate:${camelize$1(arg.content)}`
4627
4632
  : createCompoundExpression(['"onUpdate:" + ', arg])
4628
4633
  : `onUpdate:modelValue`;
4629
4634
  let assignmentExp;
@@ -4825,14 +4830,14 @@ function wrapFilter(exp, filter, context) {
4825
4830
  }
4826
4831
  }
4827
4832
 
4828
- const seen$1 = new WeakSet();
4833
+ const seen = new WeakSet();
4829
4834
  const transformMemo = (node, context) => {
4830
4835
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
4831
4836
  const dir = findDir(node, 'memo');
4832
- if (!dir || seen$1.has(node)) {
4837
+ if (!dir || seen.has(node)) {
4833
4838
  return;
4834
4839
  }
4835
- seen$1.add(node);
4840
+ seen.add(node);
4836
4841
  return () => {
4837
4842
  const codegenNode = node.codegenNode ||
4838
4843
  context.currentNode.codegenNode;
@@ -4914,4 +4919,4 @@ function baseCompile(template, options = {}) {
4914
4919
 
4915
4920
  const noopDirectiveTransform = () => ({ props: [] });
4916
4921
 
4917
- 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.45",
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.45",
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"