@vue/compiler-core 3.2.5 → 3.2.9

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.
@@ -44,43 +44,44 @@ const errorMessages = {
44
44
  [18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
45
45
  [19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
46
46
  [21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
47
- [20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null cahracter.`,
47
+ [20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
48
48
  [22 /* UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
49
49
  // Vue-specific parse errors
50
50
  [23 /* X_INVALID_END_TAG */]: 'Invalid end tag.',
51
51
  [24 /* X_MISSING_END_TAG */]: 'Element is missing end tag.',
52
52
  [25 /* X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
53
- [26 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
53
+ [27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
54
54
  'Note that dynamic directive argument cannot contain spaces.',
55
+ [26 /* X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
55
56
  // transform errors
56
- [27 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
57
- [28 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
58
- [29 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
59
- [30 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
60
- [31 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
61
- [32 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
62
- [33 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
63
- [34 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
64
- [35 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
65
- [36 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
57
+ [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
58
+ [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
59
+ [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
60
+ [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
61
+ [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
62
+ [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
63
+ [34 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
64
+ [35 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
65
+ [36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
66
+ [37 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
66
67
  `When there are multiple named slots, all slots should use <template> ` +
67
68
  `syntax to avoid scope ambiguity.`,
68
- [37 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
69
- [38 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
69
+ [38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
70
+ [39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
70
71
  `default slot. These children will be ignored.`,
71
- [39 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
72
- [40 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
73
- [41 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
74
- [42 /* 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
- [43 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
76
- [44 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
72
+ [40 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
73
+ [41 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
74
+ [42 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
75
+ [43 /* 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 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
77
+ [45 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
77
78
  // generic errors
78
- [45 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
79
- [46 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
80
- [47 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
81
- [48 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
79
+ [46 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
80
+ [47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
81
+ [48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
82
+ [49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
82
83
  // just to fullfill types
83
- [49 /* __EXTEND_POINT__ */]: ``
84
+ [50 /* __EXTEND_POINT__ */]: ``
84
85
  };
85
86
 
86
87
  const FRAGMENT = Symbol(``);
@@ -117,7 +118,6 @@ const TO_HANDLER_KEY = Symbol(``);
117
118
  const SET_BLOCK_TRACKING = Symbol(``);
118
119
  const PUSH_SCOPE_ID = Symbol(``);
119
120
  const POP_SCOPE_ID = Symbol(``);
120
- const WITH_SCOPE_ID = Symbol(``);
121
121
  const WITH_CTX = Symbol(``);
122
122
  const UNREF = Symbol(``);
123
123
  const IS_REF = Symbol(``);
@@ -161,7 +161,6 @@ const helperNameMap = {
161
161
  [SET_BLOCK_TRACKING]: `setBlockTracking`,
162
162
  [PUSH_SCOPE_ID]: `pushScopeId`,
163
163
  [POP_SCOPE_ID]: `popScopeId`,
164
- [WITH_SCOPE_ID]: `withScopeId`,
165
164
  [WITH_CTX]: `withCtx`,
166
165
  [UNREF]: `unref`,
167
166
  [IS_REF]: `isRef`,
@@ -1317,7 +1316,7 @@ function parseAttribute(context, nameSet) {
1317
1316
  }
1318
1317
  }
1319
1318
  const loc = getSelection(context, start);
1320
- if (!context.inVPre && /^(v-|:|\.|@|#)/.test(name)) {
1319
+ if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
1321
1320
  const match = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(name);
1322
1321
  let isPropShorthand = startsWith(name, '.');
1323
1322
  let dirName = match[1] ||
@@ -1336,7 +1335,7 @@ function parseAttribute(context, nameSet) {
1336
1335
  if (content.startsWith('[')) {
1337
1336
  isStatic = false;
1338
1337
  if (!content.endsWith(']')) {
1339
- emitError(context, 26 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1338
+ emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1340
1339
  }
1341
1340
  content = content.substr(1, content.length - 2);
1342
1341
  }
@@ -1391,6 +1390,10 @@ function parseAttribute(context, nameSet) {
1391
1390
  loc
1392
1391
  };
1393
1392
  }
1393
+ // missing directive name or illegal directive name
1394
+ if (!context.inVPre && startsWith(name, 'v-')) {
1395
+ emitError(context, 26 /* X_MISSING_DIRECTIVE_NAME */);
1396
+ }
1394
1397
  return {
1395
1398
  type: 6 /* ATTRIBUTE */,
1396
1399
  name,
@@ -1470,10 +1473,7 @@ function parseInterpolation(context, mode) {
1470
1473
  };
1471
1474
  }
1472
1475
  function parseText(context, mode) {
1473
- const endTokens = ['<', context.options.delimiters[0]];
1474
- if (mode === 3 /* CDATA */) {
1475
- endTokens.push(']]>');
1476
- }
1476
+ const endTokens = mode === 3 /* CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
1477
1477
  let endIndex = context.source.length;
1478
1478
  for (let i = 0; i < endTokens.length; i++) {
1479
1479
  const index = context.source.indexOf(endTokens[i], 1);
@@ -2413,11 +2413,8 @@ function genFunctionPreamble(ast, context) {
2413
2413
  }
2414
2414
  function genModulePreamble(ast, context, genScopeId, inline) {
2415
2415
  const { push, newline, optimizeImports, runtimeModuleName } = context;
2416
- if (genScopeId) {
2417
- ast.helpers.push(WITH_SCOPE_ID);
2418
- if (ast.hoists.length) {
2419
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2420
- }
2416
+ if (genScopeId && ast.hoists.length) {
2417
+ ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
2421
2418
  }
2422
2419
  // generate import statements for helpers
2423
2420
  if (ast.helpers.length) {
@@ -3125,7 +3122,7 @@ function processExpression(node, context,
3125
3122
  // function params
3126
3123
  asParams = false,
3127
3124
  // v-on handler values may contain multiple statements
3128
- asRawStatements = false) {
3125
+ asRawStatements = false, localVars = Object.create(context.identifiers)) {
3129
3126
  if (!context.prefixIdentifiers || !node.content.trim()) {
3130
3127
  return node;
3131
3128
  }
@@ -3139,7 +3136,7 @@ asRawStatements = false) {
3139
3136
  const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
3140
3137
  // ({ x } = y)
3141
3138
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
3142
- if (type === "setup-const" /* SETUP_CONST */) {
3139
+ if (type === "setup-const" /* SETUP_CONST */ || localVars[raw]) {
3143
3140
  return raw;
3144
3141
  }
3145
3142
  else if (type === "setup-ref" /* SETUP_REF */) {
@@ -3163,7 +3160,7 @@ asRawStatements = false) {
3163
3160
  // x = y --> isRef(x) ? x.value = y : x = y
3164
3161
  const { right: rVal, operator } = parent;
3165
3162
  const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
3166
- const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context));
3163
+ const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context, false, false, knownIds));
3167
3164
  return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore\n` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
3168
3165
  }
3169
3166
  else if (isUpdateArg) {
@@ -3249,7 +3246,7 @@ asRawStatements = false) {
3249
3246
  }).program;
3250
3247
  }
3251
3248
  catch (e) {
3252
- context.onError(createCompilerError(43 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3249
+ context.onError(createCompilerError(44 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
3253
3250
  return node;
3254
3251
  }
3255
3252
  const ids = [];
@@ -3379,7 +3376,7 @@ function processIf(node, dir, context, processCodegen) {
3379
3376
  if (dir.name !== 'else' &&
3380
3377
  (!dir.exp || !dir.exp.content.trim())) {
3381
3378
  const loc = dir.exp ? dir.exp.loc : node.loc;
3382
- context.onError(createCompilerError(27 /* X_V_IF_NO_EXPRESSION */, dir.loc));
3379
+ context.onError(createCompilerError(28 /* X_V_IF_NO_EXPRESSION */, dir.loc));
3383
3380
  dir.exp = createSimpleExpression(`true`, false, loc);
3384
3381
  }
3385
3382
  if (context.prefixIdentifiers && dir.exp) {
@@ -3421,7 +3418,7 @@ function processIf(node, dir, context, processCodegen) {
3421
3418
  if (key) {
3422
3419
  sibling.branches.forEach(({ userKey }) => {
3423
3420
  if (isSameKey(userKey, key)) {
3424
- context.onError(createCompilerError(28 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
3421
+ context.onError(createCompilerError(29 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
3425
3422
  }
3426
3423
  });
3427
3424
  }
@@ -3439,7 +3436,7 @@ function processIf(node, dir, context, processCodegen) {
3439
3436
  context.currentNode = null;
3440
3437
  }
3441
3438
  else {
3442
- context.onError(createCompilerError(29 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3439
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3443
3440
  }
3444
3441
  break;
3445
3442
  }
@@ -3584,7 +3581,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3584
3581
  if (c.type === 1 /* ELEMENT */) {
3585
3582
  const key = findProp(c, 'key');
3586
3583
  if (key) {
3587
- context.onError(createCompilerError(32 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
3584
+ context.onError(createCompilerError(33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
3588
3585
  return true;
3589
3586
  }
3590
3587
  }
@@ -3668,7 +3665,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
3668
3665
  // target-agnostic transform used for both Client and SSR
3669
3666
  function processFor(node, dir, context, processCodegen) {
3670
3667
  if (!dir.exp) {
3671
- context.onError(createCompilerError(30 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
3668
+ context.onError(createCompilerError(31 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
3672
3669
  return;
3673
3670
  }
3674
3671
  const parseResult = parseForExpression(
@@ -3676,7 +3673,7 @@ function processFor(node, dir, context, processCodegen) {
3676
3673
  // before expression transform.
3677
3674
  dir.exp, context);
3678
3675
  if (!parseResult) {
3679
- context.onError(createCompilerError(31 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
3676
+ context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
3680
3677
  return;
3681
3678
  }
3682
3679
  const { addIdentifiers, removeIdentifiers, scopes } = context;
@@ -3882,7 +3879,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3882
3879
  }
3883
3880
  if (onComponentSlot) {
3884
3881
  // already has on-component slot - this is incorrect usage.
3885
- context.onError(createCompilerError(36 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
3882
+ context.onError(createCompilerError(37 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
3886
3883
  break;
3887
3884
  }
3888
3885
  hasTemplateSlots = true;
@@ -3929,7 +3926,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3929
3926
  : buildDynamicSlot(slotName, slotFunction);
3930
3927
  }
3931
3928
  else {
3932
- context.onError(createCompilerError(29 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
3929
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
3933
3930
  }
3934
3931
  }
3935
3932
  else if ((vFor = findDir(slotElement, 'for'))) {
@@ -3945,14 +3942,14 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3945
3942
  ]));
3946
3943
  }
3947
3944
  else {
3948
- context.onError(createCompilerError(31 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
3945
+ context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
3949
3946
  }
3950
3947
  }
3951
3948
  else {
3952
3949
  // check duplicate static names
3953
3950
  if (staticSlotName) {
3954
3951
  if (seenSlotNames.has(staticSlotName)) {
3955
- context.onError(createCompilerError(37 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
3952
+ context.onError(createCompilerError(38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
3956
3953
  continue;
3957
3954
  }
3958
3955
  seenSlotNames.add(staticSlotName);
@@ -3982,7 +3979,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3982
3979
  implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
3983
3980
  // implicit default slot (mixed with named slots)
3984
3981
  if (hasNamedDefaultSlot) {
3985
- context.onError(createCompilerError(38 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
3982
+ context.onError(createCompilerError(39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
3986
3983
  }
3987
3984
  else {
3988
3985
  slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
@@ -4337,14 +4334,15 @@ function buildProps(node, context, props = node.props, ssr = false) {
4337
4334
  const prop = props[i];
4338
4335
  if (prop.type === 6 /* ATTRIBUTE */) {
4339
4336
  const { loc, name, value } = prop;
4340
- let isStatic = true;
4337
+ let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
4341
4338
  if (name === 'ref') {
4342
4339
  hasRef = true;
4343
4340
  // in inline mode there is no setupState object, so we can't use string
4344
4341
  // keys to set the ref. Instead, we need to transform it to pass the
4345
4342
  // acrtual ref instead.
4346
- if (context.inline) {
4347
- isStatic = false;
4343
+ if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
4344
+ valueNode = createFunctionExpression(['_value', '_refs']);
4345
+ valueNode.body = createBlockStatement(processInlineRef(context.bindingMetadata, value.content));
4348
4346
  }
4349
4347
  }
4350
4348
  // skip is on <component>, or is="vue:xxx"
@@ -4354,7 +4352,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
4354
4352
  (isCompatEnabled("COMPILER_IS_ON_ELEMENT" /* COMPILER_IS_ON_ELEMENT */, context)))) {
4355
4353
  continue;
4356
4354
  }
4357
- properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
4355
+ properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
4358
4356
  }
4359
4357
  else {
4360
4358
  // directives
@@ -4364,7 +4362,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
4364
4362
  // skip v-slot - it is handled by its dedicated transform.
4365
4363
  if (name === 'slot') {
4366
4364
  if (!isComponent) {
4367
- context.onError(createCompilerError(39 /* X_V_SLOT_MISPLACED */, loc));
4365
+ context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, loc));
4368
4366
  }
4369
4367
  continue;
4370
4368
  }
@@ -4413,8 +4411,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
4413
4411
  }
4414
4412
  else {
4415
4413
  context.onError(createCompilerError(isVBind
4416
- ? 33 /* X_V_BIND_NO_EXPRESSION */
4417
- : 34 /* X_V_ON_NO_EXPRESSION */, loc));
4414
+ ? 34 /* X_V_BIND_NO_EXPRESSION */
4415
+ : 35 /* X_V_ON_NO_EXPRESSION */, loc));
4418
4416
  }
4419
4417
  continue;
4420
4418
  }
@@ -4640,6 +4638,17 @@ function stringifyDynamicPropNames(props) {
4640
4638
  }
4641
4639
  function isComponentTag(tag) {
4642
4640
  return tag[0].toLowerCase() + tag.slice(1) === 'component';
4641
+ }
4642
+ function processInlineRef(bindings, raw) {
4643
+ const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
4644
+ const type = bindings[raw];
4645
+ if (type === "setup-ref" /* SETUP_REF */) {
4646
+ body.push(createSimpleExpression(`${raw}.value = _value`));
4647
+ }
4648
+ else if (type === "setup-let" /* SETUP_LET */) {
4649
+ body.push(createSimpleExpression(`${raw} = _value`));
4650
+ }
4651
+ return body;
4643
4652
  }
4644
4653
 
4645
4654
  const cacheStringFunction = (fn) => {
@@ -4720,7 +4729,7 @@ function processSlotOutlet(node, context) {
4720
4729
  const { props, directives } = buildProps(node, context, nonNameProps);
4721
4730
  slotProps = props;
4722
4731
  if (directives.length) {
4723
- context.onError(createCompilerError(35 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
4732
+ context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
4724
4733
  }
4725
4734
  }
4726
4735
  return {
@@ -4733,7 +4742,7 @@ const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
4733
4742
  const transformOn = (dir, node, context, augmentor) => {
4734
4743
  const { loc, modifiers, arg } = dir;
4735
4744
  if (!dir.exp && !modifiers.length) {
4736
- context.onError(createCompilerError(34 /* X_V_ON_NO_EXPRESSION */, loc));
4745
+ context.onError(createCompilerError(35 /* X_V_ON_NO_EXPRESSION */, loc));
4737
4746
  }
4738
4747
  let eventName;
4739
4748
  if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
@@ -4874,7 +4883,7 @@ const transformBind = (dir, _node, context) => {
4874
4883
  }
4875
4884
  if (!exp ||
4876
4885
  (exp.type === 4 /* SIMPLE_EXPRESSION */ && !exp.content.trim())) {
4877
- context.onError(createCompilerError(33 /* X_V_BIND_NO_EXPRESSION */, loc));
4886
+ context.onError(createCompilerError(34 /* X_V_BIND_NO_EXPRESSION */, loc));
4878
4887
  return {
4879
4888
  props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
4880
4889
  };
@@ -5010,7 +5019,7 @@ const transformOnce = (node, context) => {
5010
5019
  const transformModel = (dir, node, context) => {
5011
5020
  const { exp, arg } = dir;
5012
5021
  if (!exp) {
5013
- context.onError(createCompilerError(40 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
5022
+ context.onError(createCompilerError(41 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
5014
5023
  return createTransformProps();
5015
5024
  }
5016
5025
  const rawExp = exp.loc.source;
@@ -5022,13 +5031,13 @@ const transformModel = (dir, node, context) => {
5022
5031
  bindingType &&
5023
5032
  bindingType !== "setup-const" /* SETUP_CONST */;
5024
5033
  if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
5025
- context.onError(createCompilerError(41 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
5034
+ context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
5026
5035
  return createTransformProps();
5027
5036
  }
5028
5037
  if (context.prefixIdentifiers &&
5029
5038
  isSimpleIdentifier(expString) &&
5030
5039
  context.identifiers[expString]) {
5031
- context.onError(createCompilerError(42 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
5040
+ context.onError(createCompilerError(43 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
5032
5041
  return createTransformProps();
5033
5042
  }
5034
5043
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
@@ -5322,10 +5331,10 @@ function baseCompile(template, options = {}) {
5322
5331
  const isModuleMode = options.mode === 'module';
5323
5332
  const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
5324
5333
  if (!prefixIdentifiers && options.cacheHandlers) {
5325
- onError(createCompilerError(47 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
5334
+ onError(createCompilerError(48 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
5326
5335
  }
5327
5336
  if (options.scopeId && !isModuleMode) {
5328
- onError(createCompilerError(48 /* X_SCOPE_ID_NOT_SUPPORTED */));
5337
+ onError(createCompilerError(49 /* X_SCOPE_ID_NOT_SUPPORTED */));
5329
5338
  }
5330
5339
  const ast = shared.isString(template) ? baseParse(template, options) : template;
5331
5340
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
@@ -5385,7 +5394,6 @@ exports.UNREF = UNREF;
5385
5394
  exports.WITH_CTX = WITH_CTX;
5386
5395
  exports.WITH_DIRECTIVES = WITH_DIRECTIVES;
5387
5396
  exports.WITH_MEMO = WITH_MEMO;
5388
- exports.WITH_SCOPE_ID = WITH_SCOPE_ID;
5389
5397
  exports.advancePositionWithClone = advancePositionWithClone;
5390
5398
  exports.advancePositionWithMutation = advancePositionWithMutation;
5391
5399
  exports.assert = assert;
@@ -411,30 +411,31 @@ export declare const enum ErrorCodes {
411
411
  X_INVALID_END_TAG = 23,
412
412
  X_MISSING_END_TAG = 24,
413
413
  X_MISSING_INTERPOLATION_END = 25,
414
- X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END = 26,
415
- X_V_IF_NO_EXPRESSION = 27,
416
- X_V_IF_SAME_KEY = 28,
417
- X_V_ELSE_NO_ADJACENT_IF = 29,
418
- X_V_FOR_NO_EXPRESSION = 30,
419
- X_V_FOR_MALFORMED_EXPRESSION = 31,
420
- X_V_FOR_TEMPLATE_KEY_PLACEMENT = 32,
421
- X_V_BIND_NO_EXPRESSION = 33,
422
- X_V_ON_NO_EXPRESSION = 34,
423
- X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET = 35,
424
- X_V_SLOT_MIXED_SLOT_USAGE = 36,
425
- X_V_SLOT_DUPLICATE_SLOT_NAMES = 37,
426
- X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN = 38,
427
- X_V_SLOT_MISPLACED = 39,
428
- X_V_MODEL_NO_EXPRESSION = 40,
429
- X_V_MODEL_MALFORMED_EXPRESSION = 41,
430
- X_V_MODEL_ON_SCOPE_VARIABLE = 42,
431
- X_INVALID_EXPRESSION = 43,
432
- X_KEEP_ALIVE_INVALID_CHILDREN = 44,
433
- X_PREFIX_ID_NOT_SUPPORTED = 45,
434
- X_MODULE_MODE_NOT_SUPPORTED = 46,
435
- X_CACHE_HANDLER_NOT_SUPPORTED = 47,
436
- X_SCOPE_ID_NOT_SUPPORTED = 48,
437
- __EXTEND_POINT__ = 49
414
+ X_MISSING_DIRECTIVE_NAME = 26,
415
+ X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END = 27,
416
+ X_V_IF_NO_EXPRESSION = 28,
417
+ X_V_IF_SAME_KEY = 29,
418
+ X_V_ELSE_NO_ADJACENT_IF = 30,
419
+ X_V_FOR_NO_EXPRESSION = 31,
420
+ X_V_FOR_MALFORMED_EXPRESSION = 32,
421
+ X_V_FOR_TEMPLATE_KEY_PLACEMENT = 33,
422
+ X_V_BIND_NO_EXPRESSION = 34,
423
+ X_V_ON_NO_EXPRESSION = 35,
424
+ X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET = 36,
425
+ X_V_SLOT_MIXED_SLOT_USAGE = 37,
426
+ X_V_SLOT_DUPLICATE_SLOT_NAMES = 38,
427
+ X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN = 39,
428
+ X_V_SLOT_MISPLACED = 40,
429
+ X_V_MODEL_NO_EXPRESSION = 41,
430
+ X_V_MODEL_MALFORMED_EXPRESSION = 42,
431
+ X_V_MODEL_ON_SCOPE_VARIABLE = 43,
432
+ X_INVALID_EXPRESSION = 44,
433
+ X_KEEP_ALIVE_INVALID_CHILDREN = 45,
434
+ X_PREFIX_ID_NOT_SUPPORTED = 46,
435
+ X_MODULE_MODE_NOT_SUPPORTED = 47,
436
+ X_CACHE_HANDLER_NOT_SUPPORTED = 48,
437
+ X_SCOPE_ID_NOT_SUPPORTED = 49,
438
+ __EXTEND_POINT__ = 50
438
439
  }
439
440
 
440
441
  declare interface ErrorHandlingOptions {
@@ -781,7 +782,7 @@ export declare interface Position {
781
782
  column: number;
782
783
  }
783
784
 
784
- export declare function processExpression(node: SimpleExpressionNode, context: TransformContext, asParams?: boolean, asRawStatements?: boolean): ExpressionNode;
785
+ export declare function processExpression(node: SimpleExpressionNode, context: TransformContext, asParams?: boolean, asRawStatements?: boolean, localVars?: Record<string, number>): ExpressionNode;
785
786
 
786
787
  export declare function processFor(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (forNode: ForNode) => (() => void) | undefined): (() => void) | undefined;
787
788
 
@@ -1170,6 +1171,4 @@ export declare const WITH_DIRECTIVES: unique symbol;
1170
1171
 
1171
1172
  export declare const WITH_MEMO: unique symbol;
1172
1173
 
1173
- export declare const WITH_SCOPE_ID: unique symbol;
1174
-
1175
1174
  export { }