@vue/compiler-core 3.2.45 → 3.2.47

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.
@@ -63,7 +63,7 @@ const errorMessages = {
63
63
  [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
64
64
  [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
65
65
  [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>.` +
66
+ [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>. ` +
67
67
  `When there are multiple named slots, all slots should use <template> ` +
68
68
  `syntax to avoid scope ambiguity.`,
69
69
  [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
@@ -186,7 +186,7 @@ function createRoot(children, loc = locStub) {
186
186
  return {
187
187
  type: 0 /* NodeTypes.ROOT */,
188
188
  children,
189
- helpers: [],
189
+ helpers: new Set(),
190
190
  components: [],
191
191
  directives: [],
192
192
  hoists: [],
@@ -546,7 +546,7 @@ function hasDynamicKeyVBind(node) {
546
546
  !p.arg.isStatic) // v-bind:[foo]
547
547
  );
548
548
  }
549
- function isText(node) {
549
+ function isText$1(node) {
550
550
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
551
551
  }
552
552
  function isVSlot(p) {
@@ -2105,7 +2105,7 @@ function transform(root, options) {
2105
2105
  createRootCodegen(root, context);
2106
2106
  }
2107
2107
  // finalize meta information
2108
- root.helpers = [...context.helpers.keys()];
2108
+ root.helpers = new Set([...context.helpers.keys()]);
2109
2109
  root.components = [...context.components];
2110
2110
  root.directives = [...context.directives];
2111
2111
  root.imports = context.imports;
@@ -2346,7 +2346,8 @@ function generate(ast, options = {}) {
2346
2346
  if (options.onContextCreated)
2347
2347
  options.onContextCreated(context);
2348
2348
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2349
- const hasHelpers = ast.helpers.length > 0;
2349
+ const helpers = Array.from(ast.helpers);
2350
+ const hasHelpers = helpers.length > 0;
2350
2351
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2351
2352
  const genScopeId = scopeId != null && mode === 'module';
2352
2353
  const isSetupInlined = !!options.inline;
@@ -2385,7 +2386,7 @@ function generate(ast, options = {}) {
2385
2386
  // function mode const declarations should be inside with block
2386
2387
  // also they should be renamed to avoid collision with user properties
2387
2388
  if (hasHelpers) {
2388
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2389
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2389
2390
  push(`\n`);
2390
2391
  newline();
2391
2392
  }
@@ -2451,9 +2452,10 @@ function genFunctionPreamble(ast, context) {
2451
2452
  // In prefix mode, we place the const declaration at top so it's done
2452
2453
  // only once; But if we not prefixing, we place the declaration inside the
2453
2454
  // with block so it doesn't incur the `in` check cost for every helper access.
2454
- if (ast.helpers.length > 0) {
2455
+ const helpers = Array.from(ast.helpers);
2456
+ if (helpers.length > 0) {
2455
2457
  if (prefixIdentifiers) {
2456
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2458
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2457
2459
  }
2458
2460
  else {
2459
2461
  // "with" mode.
@@ -2470,7 +2472,7 @@ function genFunctionPreamble(ast, context) {
2470
2472
  CREATE_TEXT,
2471
2473
  CREATE_STATIC
2472
2474
  ]
2473
- .filter(helper => ast.helpers.includes(helper))
2475
+ .filter(helper => helpers.includes(helper))
2474
2476
  .map(aliasHelper)
2475
2477
  .join(', ');
2476
2478
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2491,25 +2493,27 @@ function genFunctionPreamble(ast, context) {
2491
2493
  function genModulePreamble(ast, context, genScopeId, inline) {
2492
2494
  const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
2493
2495
  if (genScopeId && ast.hoists.length) {
2494
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2496
+ ast.helpers.add(PUSH_SCOPE_ID);
2497
+ ast.helpers.add(POP_SCOPE_ID);
2495
2498
  }
2496
2499
  // generate import statements for helpers
2497
- if (ast.helpers.length) {
2500
+ if (ast.helpers.size) {
2501
+ const helpers = Array.from(ast.helpers);
2498
2502
  if (optimizeImports) {
2499
2503
  // when bundled with webpack with code-split, calling an import binding
2500
2504
  // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
2501
2505
  // incurring both payload size increase and potential perf overhead.
2502
2506
  // therefore we assign the imports to variables (which is a constant ~50b
2503
2507
  // cost per-component instead of scaling with template size)
2504
- push(`import { ${ast.helpers
2508
+ push(`import { ${helpers
2505
2509
  .map(s => helperNameMap[s])
2506
2510
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2507
- push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
2511
+ push(`\n// Binding optimization for webpack code-split\nconst ${helpers
2508
2512
  .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
2509
2513
  .join(', ')}\n`);
2510
2514
  }
2511
2515
  else {
2512
- push(`import { ${ast.helpers
2516
+ push(`import { ${helpers
2513
2517
  .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
2514
2518
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2515
2519
  }
@@ -2586,7 +2590,7 @@ function genImports(importsOptions, context) {
2586
2590
  context.newline();
2587
2591
  });
2588
2592
  }
2589
- function isText$1(n) {
2593
+ function isText(n) {
2590
2594
  return (shared.isString(n) ||
2591
2595
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2592
2596
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2595,7 +2599,7 @@ function isText$1(n) {
2595
2599
  }
2596
2600
  function genNodeListAsArray(nodes, context) {
2597
2601
  const multilines = nodes.length > 3 ||
2598
- (nodes.some(n => shared.isArray(n) || !isText$1(n)));
2602
+ (nodes.some(n => shared.isArray(n) || !isText(n)));
2599
2603
  context.push(`[`);
2600
2604
  multilines && context.indent();
2601
2605
  genNodeList(nodes, context, multilines);
@@ -5001,9 +5005,6 @@ function isComponentTag(tag) {
5001
5005
  return tag === 'component' || tag === 'Component';
5002
5006
  }
5003
5007
 
5004
- Object.freeze({})
5005
- ;
5006
- Object.freeze([]) ;
5007
5008
  const cacheStringFunction = (fn) => {
5008
5009
  const cache = Object.create(null);
5009
5010
  return ((str) => {
@@ -5285,11 +5286,11 @@ const transformText = (node, context) => {
5285
5286
  let hasText = false;
5286
5287
  for (let i = 0; i < children.length; i++) {
5287
5288
  const child = children[i];
5288
- if (isText(child)) {
5289
+ if (isText$1(child)) {
5289
5290
  hasText = true;
5290
5291
  for (let j = i + 1; j < children.length; j++) {
5291
5292
  const next = children[j];
5292
- if (isText(next)) {
5293
+ if (isText$1(next)) {
5293
5294
  if (!currentContainer) {
5294
5295
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
5295
5296
  }
@@ -5331,7 +5332,7 @@ const transformText = (node, context) => {
5331
5332
  // runtime normalization.
5332
5333
  for (let i = 0; i < children.length; i++) {
5333
5334
  const child = children[i];
5334
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5335
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5335
5336
  const callArgs = [];
5336
5337
  // createTextVNode defaults to single whitespace, so if it is a
5337
5338
  // single space the code could be an empty call to save bytes.
@@ -5356,13 +5357,13 @@ const transformText = (node, context) => {
5356
5357
  }
5357
5358
  };
5358
5359
 
5359
- const seen = new WeakSet();
5360
+ const seen$1 = new WeakSet();
5360
5361
  const transformOnce = (node, context) => {
5361
5362
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5362
- if (seen.has(node) || context.inVOnce) {
5363
+ if (seen$1.has(node) || context.inVOnce) {
5363
5364
  return;
5364
5365
  }
5365
- seen.add(node);
5366
+ seen$1.add(node);
5366
5367
  context.inVOnce = true;
5367
5368
  context.helper(SET_BLOCK_TRACKING);
5368
5369
  return () => {
@@ -5410,7 +5411,7 @@ const transformModel = (dir, node, context) => {
5410
5411
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
5411
5412
  const eventName = arg
5412
5413
  ? isStaticExp(arg)
5413
- ? `onUpdate:${arg.content}`
5414
+ ? `onUpdate:${shared.camelize(arg.content)}`
5414
5415
  : createCompoundExpression(['"onUpdate:" + ', arg])
5415
5416
  : `onUpdate:modelValue`;
5416
5417
  let assignmentExp;
@@ -5638,14 +5639,14 @@ function wrapFilter(exp, filter, context) {
5638
5639
  }
5639
5640
  }
5640
5641
 
5641
- const seen$1 = new WeakSet();
5642
+ const seen = new WeakSet();
5642
5643
  const transformMemo = (node, context) => {
5643
5644
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
5644
5645
  const dir = findDir(node, 'memo');
5645
- if (!dir || seen$1.has(node)) {
5646
+ if (!dir || seen.has(node)) {
5646
5647
  return;
5647
5648
  }
5648
- seen$1.add(node);
5649
+ seen.add(node);
5649
5650
  return () => {
5650
5651
  const codegenNode = node.codegenNode ||
5651
5652
  context.currentNode.codegenNode;
@@ -5828,7 +5829,7 @@ exports.isStaticExp = isStaticExp;
5828
5829
  exports.isStaticProperty = isStaticProperty;
5829
5830
  exports.isStaticPropertyKey = isStaticPropertyKey;
5830
5831
  exports.isTemplateNode = isTemplateNode;
5831
- exports.isText = isText;
5832
+ exports.isText = isText$1;
5832
5833
  exports.isVSlot = isVSlot;
5833
5834
  exports.locStub = locStub;
5834
5835
  exports.makeBlock = makeBlock;
@@ -62,7 +62,7 @@ const errorMessages = {
62
62
  [34 /* ErrorCodes.X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
63
63
  [35 /* ErrorCodes.X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
64
64
  [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>.` +
65
+ [37 /* ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>. ` +
66
66
  `When there are multiple named slots, all slots should use <template> ` +
67
67
  `syntax to avoid scope ambiguity.`,
68
68
  [38 /* ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
@@ -185,7 +185,7 @@ function createRoot(children, loc = locStub) {
185
185
  return {
186
186
  type: 0 /* NodeTypes.ROOT */,
187
187
  children,
188
- helpers: [],
188
+ helpers: new Set(),
189
189
  components: [],
190
190
  directives: [],
191
191
  hoists: [],
@@ -545,7 +545,7 @@ function hasDynamicKeyVBind(node) {
545
545
  !p.arg.isStatic) // v-bind:[foo]
546
546
  );
547
547
  }
548
- function isText(node) {
548
+ function isText$1(node) {
549
549
  return node.type === 5 /* NodeTypes.INTERPOLATION */ || node.type === 2 /* NodeTypes.TEXT */;
550
550
  }
551
551
  function isVSlot(p) {
@@ -2061,7 +2061,7 @@ function transform(root, options) {
2061
2061
  createRootCodegen(root, context);
2062
2062
  }
2063
2063
  // finalize meta information
2064
- root.helpers = [...context.helpers.keys()];
2064
+ root.helpers = new Set([...context.helpers.keys()]);
2065
2065
  root.components = [...context.components];
2066
2066
  root.directives = [...context.directives];
2067
2067
  root.imports = context.imports;
@@ -2296,7 +2296,8 @@ function generate(ast, options = {}) {
2296
2296
  if (options.onContextCreated)
2297
2297
  options.onContextCreated(context);
2298
2298
  const { mode, push, prefixIdentifiers, indent, deindent, newline, scopeId, ssr } = context;
2299
- const hasHelpers = ast.helpers.length > 0;
2299
+ const helpers = Array.from(ast.helpers);
2300
+ const hasHelpers = helpers.length > 0;
2300
2301
  const useWithBlock = !prefixIdentifiers && mode !== 'module';
2301
2302
  const genScopeId = scopeId != null && mode === 'module';
2302
2303
  const isSetupInlined = !!options.inline;
@@ -2335,7 +2336,7 @@ function generate(ast, options = {}) {
2335
2336
  // function mode const declarations should be inside with block
2336
2337
  // also they should be renamed to avoid collision with user properties
2337
2338
  if (hasHelpers) {
2338
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
2339
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = _Vue`);
2339
2340
  push(`\n`);
2340
2341
  newline();
2341
2342
  }
@@ -2401,9 +2402,10 @@ function genFunctionPreamble(ast, context) {
2401
2402
  // In prefix mode, we place the const declaration at top so it's done
2402
2403
  // only once; But if we not prefixing, we place the declaration inside the
2403
2404
  // with block so it doesn't incur the `in` check cost for every helper access.
2404
- if (ast.helpers.length > 0) {
2405
+ const helpers = Array.from(ast.helpers);
2406
+ if (helpers.length > 0) {
2405
2407
  if (prefixIdentifiers) {
2406
- push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2408
+ push(`const { ${helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`);
2407
2409
  }
2408
2410
  else {
2409
2411
  // "with" mode.
@@ -2420,7 +2422,7 @@ function genFunctionPreamble(ast, context) {
2420
2422
  CREATE_TEXT,
2421
2423
  CREATE_STATIC
2422
2424
  ]
2423
- .filter(helper => ast.helpers.includes(helper))
2425
+ .filter(helper => helpers.includes(helper))
2424
2426
  .map(aliasHelper)
2425
2427
  .join(', ');
2426
2428
  push(`const { ${staticHelpers} } = _Vue\n`);
@@ -2441,25 +2443,27 @@ function genFunctionPreamble(ast, context) {
2441
2443
  function genModulePreamble(ast, context, genScopeId, inline) {
2442
2444
  const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
2443
2445
  if (genScopeId && ast.hoists.length) {
2444
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2446
+ ast.helpers.add(PUSH_SCOPE_ID);
2447
+ ast.helpers.add(POP_SCOPE_ID);
2445
2448
  }
2446
2449
  // generate import statements for helpers
2447
- if (ast.helpers.length) {
2450
+ if (ast.helpers.size) {
2451
+ const helpers = Array.from(ast.helpers);
2448
2452
  if (optimizeImports) {
2449
2453
  // when bundled with webpack with code-split, calling an import binding
2450
2454
  // as a function leads to it being wrapped with `Object(a.b)` or `(0,a.b)`,
2451
2455
  // incurring both payload size increase and potential perf overhead.
2452
2456
  // therefore we assign the imports to variables (which is a constant ~50b
2453
2457
  // cost per-component instead of scaling with template size)
2454
- push(`import { ${ast.helpers
2458
+ push(`import { ${helpers
2455
2459
  .map(s => helperNameMap[s])
2456
2460
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2457
- push(`\n// Binding optimization for webpack code-split\nconst ${ast.helpers
2461
+ push(`\n// Binding optimization for webpack code-split\nconst ${helpers
2458
2462
  .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
2459
2463
  .join(', ')}\n`);
2460
2464
  }
2461
2465
  else {
2462
- push(`import { ${ast.helpers
2466
+ push(`import { ${helpers
2463
2467
  .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
2464
2468
  .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`);
2465
2469
  }
@@ -2536,7 +2540,7 @@ function genImports(importsOptions, context) {
2536
2540
  context.newline();
2537
2541
  });
2538
2542
  }
2539
- function isText$1(n) {
2543
+ function isText(n) {
2540
2544
  return (shared.isString(n) ||
2541
2545
  n.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ ||
2542
2546
  n.type === 2 /* NodeTypes.TEXT */ ||
@@ -2545,7 +2549,7 @@ function isText$1(n) {
2545
2549
  }
2546
2550
  function genNodeListAsArray(nodes, context) {
2547
2551
  const multilines = nodes.length > 3 ||
2548
- (nodes.some(n => shared.isArray(n) || !isText$1(n)));
2552
+ (nodes.some(n => shared.isArray(n) || !isText(n)));
2549
2553
  context.push(`[`);
2550
2554
  multilines && context.indent();
2551
2555
  genNodeList(nodes, context, multilines);
@@ -5160,11 +5164,11 @@ const transformText = (node, context) => {
5160
5164
  let hasText = false;
5161
5165
  for (let i = 0; i < children.length; i++) {
5162
5166
  const child = children[i];
5163
- if (isText(child)) {
5167
+ if (isText$1(child)) {
5164
5168
  hasText = true;
5165
5169
  for (let j = i + 1; j < children.length; j++) {
5166
5170
  const next = children[j];
5167
- if (isText(next)) {
5171
+ if (isText$1(next)) {
5168
5172
  if (!currentContainer) {
5169
5173
  currentContainer = children[i] = createCompoundExpression([child], child.loc);
5170
5174
  }
@@ -5206,7 +5210,7 @@ const transformText = (node, context) => {
5206
5210
  // runtime normalization.
5207
5211
  for (let i = 0; i < children.length; i++) {
5208
5212
  const child = children[i];
5209
- if (isText(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5213
+ if (isText$1(child) || child.type === 8 /* NodeTypes.COMPOUND_EXPRESSION */) {
5210
5214
  const callArgs = [];
5211
5215
  // createTextVNode defaults to single whitespace, so if it is a
5212
5216
  // single space the code could be an empty call to save bytes.
@@ -5231,13 +5235,13 @@ const transformText = (node, context) => {
5231
5235
  }
5232
5236
  };
5233
5237
 
5234
- const seen = new WeakSet();
5238
+ const seen$1 = new WeakSet();
5235
5239
  const transformOnce = (node, context) => {
5236
5240
  if (node.type === 1 /* NodeTypes.ELEMENT */ && findDir(node, 'once', true)) {
5237
- if (seen.has(node) || context.inVOnce) {
5241
+ if (seen$1.has(node) || context.inVOnce) {
5238
5242
  return;
5239
5243
  }
5240
- seen.add(node);
5244
+ seen$1.add(node);
5241
5245
  context.inVOnce = true;
5242
5246
  context.helper(SET_BLOCK_TRACKING);
5243
5247
  return () => {
@@ -5285,7 +5289,7 @@ const transformModel = (dir, node, context) => {
5285
5289
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
5286
5290
  const eventName = arg
5287
5291
  ? isStaticExp(arg)
5288
- ? `onUpdate:${arg.content}`
5292
+ ? `onUpdate:${shared.camelize(arg.content)}`
5289
5293
  : createCompoundExpression(['"onUpdate:" + ', arg])
5290
5294
  : `onUpdate:modelValue`;
5291
5295
  let assignmentExp;
@@ -5512,14 +5516,14 @@ function wrapFilter(exp, filter, context) {
5512
5516
  }
5513
5517
  }
5514
5518
 
5515
- const seen$1 = new WeakSet();
5519
+ const seen = new WeakSet();
5516
5520
  const transformMemo = (node, context) => {
5517
5521
  if (node.type === 1 /* NodeTypes.ELEMENT */) {
5518
5522
  const dir = findDir(node, 'memo');
5519
- if (!dir || seen$1.has(node)) {
5523
+ if (!dir || seen.has(node)) {
5520
5524
  return;
5521
5525
  }
5522
- seen$1.add(node);
5526
+ seen.add(node);
5523
5527
  return () => {
5524
5528
  const codegenNode = node.codegenNode ||
5525
5529
  context.currentNode.codegenNode;
@@ -5702,7 +5706,7 @@ exports.isStaticExp = isStaticExp;
5702
5706
  exports.isStaticProperty = isStaticProperty;
5703
5707
  exports.isStaticPropertyKey = isStaticPropertyKey;
5704
5708
  exports.isTemplateNode = isTemplateNode;
5705
- exports.isText = isText;
5709
+ exports.isText = isText$1;
5706
5710
  exports.isVSlot = isVSlot;
5707
5711
  exports.locStub = locStub;
5708
5712
  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.47",
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.47",
36
36
  "@babel/parser": "^7.16.4",
37
37
  "estree-walker": "^2.0.2",
38
38
  "source-map": "^0.6.1"