@vue/compiler-sfc 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.
@@ -1438,6 +1438,10 @@ function compileScript(sfc, options) {
1438
1438
  `${DEFINE_PROPS} declaration.`, node);
1439
1439
  }
1440
1440
  propsRuntimeDefaults = node.arguments[1];
1441
+ if (!propsRuntimeDefaults ||
1442
+ propsRuntimeDefaults.type !== 'ObjectExpression') {
1443
+ error(`The 2nd argument of ${WITH_DEFAULTS} must be an object literal.`, propsRuntimeDefaults || node);
1444
+ }
1441
1445
  }
1442
1446
  else {
1443
1447
  error(`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`, node.arguments[0] || node);
@@ -1488,7 +1492,10 @@ function compileScript(sfc, options) {
1488
1492
  return isQualifiedType(node.declaration);
1489
1493
  }
1490
1494
  };
1491
- for (const node of scriptSetupAst.body) {
1495
+ const body = scriptAst
1496
+ ? [...scriptSetupAst.body, ...scriptAst.body]
1497
+ : scriptSetupAst.body;
1498
+ for (const node of body) {
1492
1499
  const qualified = isQualifiedType(node);
1493
1500
  if (qualified) {
1494
1501
  return qualified;
@@ -1528,17 +1535,24 @@ function compileScript(sfc, options) {
1528
1535
  s.overwrite(node.start + startOffset, node.argument.start + startOffset, `${isStatement ? `;` : ``}(([__temp,__restore]=${helper(`withAsyncContext`)}(()=>(`);
1529
1536
  s.appendLeft(node.end + startOffset, `))),__temp=await __temp,__restore()${isStatement ? `` : `,__temp`})`);
1530
1537
  }
1538
+ /**
1539
+ * check defaults. If the default object is an object literal with only
1540
+ * static properties, we can directly generate more optimzied default
1541
+ * declarations. Otherwise we will have to fallback to runtime merging.
1542
+ */
1543
+ function checkStaticDefaults() {
1544
+ return (propsRuntimeDefaults &&
1545
+ propsRuntimeDefaults.type === 'ObjectExpression' &&
1546
+ propsRuntimeDefaults.properties.every(node => (node.type === 'ObjectProperty' && !node.computed) ||
1547
+ node.type === 'ObjectMethod'));
1548
+ }
1531
1549
  function genRuntimeProps(props) {
1532
1550
  const keys = Object.keys(props);
1533
1551
  if (!keys.length) {
1534
1552
  return ``;
1535
1553
  }
1536
- // check defaults. If the default object is an object literal with only
1537
- // static properties, we can directly generate more optimzied default
1538
- // decalrations. Otherwise we will have to fallback to runtime merging.
1539
- const hasStaticDefaults = propsRuntimeDefaults &&
1540
- propsRuntimeDefaults.type === 'ObjectExpression' &&
1541
- propsRuntimeDefaults.properties.every(node => node.type === 'ObjectProperty' && !node.computed);
1554
+ const hasStaticDefaults = checkStaticDefaults();
1555
+ const scriptSetupSource = scriptSetup.content;
1542
1556
  let propsDecls = `{
1543
1557
  ${keys
1544
1558
  .map(key => {
@@ -1546,8 +1560,13 @@ function compileScript(sfc, options) {
1546
1560
  if (hasStaticDefaults) {
1547
1561
  const prop = propsRuntimeDefaults.properties.find((node) => node.key.name === key);
1548
1562
  if (prop) {
1549
- // prop has corresponding static default value
1550
- defaultString = `default: ${source.slice(prop.value.start + startOffset, prop.value.end + startOffset)}`;
1563
+ if (prop.type === 'ObjectProperty') {
1564
+ // prop has corresponding static default value
1565
+ defaultString = `default: ${scriptSetupSource.slice(prop.value.start, prop.value.end)}`;
1566
+ }
1567
+ else {
1568
+ defaultString = `default() ${scriptSetupSource.slice(prop.body.start, prop.body.end)}`;
1569
+ }
1551
1570
  }
1552
1571
  }
1553
1572
  {
@@ -1559,7 +1578,38 @@ function compileScript(sfc, options) {
1559
1578
  if (propsRuntimeDefaults && !hasStaticDefaults) {
1560
1579
  propsDecls = `${helper('mergeDefaults')}(${propsDecls}, ${source.slice(propsRuntimeDefaults.start + startOffset, propsRuntimeDefaults.end + startOffset)})`;
1561
1580
  }
1562
- return `\n props: ${propsDecls} as unknown as undefined,`;
1581
+ return `\n props: ${propsDecls},`;
1582
+ }
1583
+ function genSetupPropsType(node) {
1584
+ const scriptSetupSource = scriptSetup.content;
1585
+ if (checkStaticDefaults()) {
1586
+ // if withDefaults() is used, we need to remove the optional flags
1587
+ // on props that have default values
1588
+ let res = `{ `;
1589
+ const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
1590
+ for (const m of members) {
1591
+ if ((m.type === 'TSPropertySignature' ||
1592
+ m.type === 'TSMethodSignature') &&
1593
+ m.typeAnnotation &&
1594
+ m.key.type === 'Identifier') {
1595
+ if (propsRuntimeDefaults.properties.some((p) => p.key.name === m.key.name)) {
1596
+ res +=
1597
+ m.key.name +
1598
+ (m.type === 'TSMethodSignature' ? '()' : '') +
1599
+ scriptSetupSource.slice(m.typeAnnotation.start, m.typeAnnotation.end) +
1600
+ ', ';
1601
+ }
1602
+ else {
1603
+ res +=
1604
+ scriptSetupSource.slice(m.start, m.typeAnnotation.end) + `, `;
1605
+ }
1606
+ }
1607
+ }
1608
+ return (res.length ? res.slice(0, -2) : res) + ` }`;
1609
+ }
1610
+ else {
1611
+ return scriptSetupSource.slice(node.start, node.end);
1612
+ }
1563
1613
  }
1564
1614
  // 1. process normal <script> first if it exists
1565
1615
  let scriptAst;
@@ -1756,7 +1806,7 @@ function compileScript(sfc, options) {
1756
1806
  }
1757
1807
  }
1758
1808
  }
1759
- // walk decalrations to record declared bindings
1809
+ // walk declarations to record declared bindings
1760
1810
  if ((node.type === 'VariableDeclaration' ||
1761
1811
  node.type === 'FunctionDeclaration' ||
1762
1812
  node.type === 'ClassDeclaration') &&
@@ -1879,17 +1929,20 @@ function compileScript(sfc, options) {
1879
1929
  // 9. finalize setup() argument signature
1880
1930
  let args = `__props`;
1881
1931
  if (propsTypeDecl) {
1882
- args += `: ${scriptSetup.content.slice(propsTypeDecl.start, propsTypeDecl.end)}`;
1932
+ // mark as any and only cast on assignment
1933
+ // since the user defined complex types may be incompatible with the
1934
+ // inferred type from generated runtime declarations
1935
+ args += `: any`;
1883
1936
  }
1884
1937
  // inject user assignment of props
1885
1938
  // we use a default __props so that template expressions referencing props
1886
1939
  // can use it directly
1887
1940
  if (propsIdentifier) {
1888
- s.prependRight(startOffset, `\nconst ${propsIdentifier} = __props`);
1941
+ s.prependRight(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``}`);
1889
1942
  }
1890
1943
  // inject temp variables for async context preservation
1891
1944
  if (hasAwait) {
1892
- const any = isTS ? `:any` : ``;
1945
+ const any = isTS ? `: any` : ``;
1893
1946
  s.prependRight(startOffset, `\nlet __temp${any}, __restore${any}\n`);
1894
1947
  }
1895
1948
  const destructureElements = hasDefineExposeCall || !options.inlineTemplate ? [`expose`] : [];
@@ -2003,10 +2056,10 @@ function compileScript(sfc, options) {
2003
2056
  // this allows `import { setup } from '*.vue'` for testing purposes.
2004
2057
  if (defaultExport) {
2005
2058
  s.prependLeft(startOffset, `\n${hasAwait ? `async ` : ``}function setup(${args}) {\n`);
2006
- s.append(`\nexport default ${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup})`);
2059
+ s.append(`\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup})`);
2007
2060
  }
2008
2061
  else {
2009
- s.prependLeft(startOffset, `\nexport default ${helper(`defineComponent`)}({${def}${runtimeOptions}\n ${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`);
2062
+ s.prependLeft(startOffset, `\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n ${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`);
2010
2063
  s.appendRight(endOffset, `})`);
2011
2064
  }
2012
2065
  }
@@ -2230,6 +2283,7 @@ function inferRuntimeType(node, declaredTypes) {
2230
2283
  case 'Map':
2231
2284
  case 'WeakSet':
2232
2285
  case 'WeakMap':
2286
+ case 'Date':
2233
2287
  return [node.typeName.name];
2234
2288
  case 'Record':
2235
2289
  case 'Partial':
@@ -2297,7 +2351,7 @@ function genRuntimeEmits(emits) {
2297
2351
  return emits.size
2298
2352
  ? `\n emits: [${Array.from(emits)
2299
2353
  .map(p => JSON.stringify(p))
2300
- .join(', ')}] as unknown as undefined,`
2354
+ .join(', ')}],`
2301
2355
  : ``;
2302
2356
  }
2303
2357
  function isCallOf(node, test) {
@@ -488,43 +488,44 @@ const errorMessages = {
488
488
  [18 /* UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE */]: 'Unquoted attribute value cannot contain U+0022 ("), U+0027 (\'), U+003C (<), U+003D (=), and U+0060 (`).',
489
489
  [19 /* UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME */]: "Attribute name cannot start with '='.",
490
490
  [21 /* UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME */]: "'<?' is allowed only in XML context.",
491
- [20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null cahracter.`,
491
+ [20 /* UNEXPECTED_NULL_CHARACTER */]: `Unexpected null character.`,
492
492
  [22 /* UNEXPECTED_SOLIDUS_IN_TAG */]: "Illegal '/' in tags.",
493
493
  // Vue-specific parse errors
494
494
  [23 /* X_INVALID_END_TAG */]: 'Invalid end tag.',
495
495
  [24 /* X_MISSING_END_TAG */]: 'Element is missing end tag.',
496
496
  [25 /* X_MISSING_INTERPOLATION_END */]: 'Interpolation end sign was not found.',
497
- [26 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
497
+ [27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */]: 'End bracket for dynamic directive argument was not found. ' +
498
498
  'Note that dynamic directive argument cannot contain spaces.',
499
+ [26 /* X_MISSING_DIRECTIVE_NAME */]: 'Legal directive name was expected.',
499
500
  // transform errors
500
- [27 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
501
- [28 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
502
- [29 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
503
- [30 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
504
- [31 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
505
- [32 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
506
- [33 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
507
- [34 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
508
- [35 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
509
- [36 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
501
+ [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
502
+ [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
503
+ [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
504
+ [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
505
+ [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
506
+ [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
507
+ [34 /* X_V_BIND_NO_EXPRESSION */]: `v-bind is missing expression.`,
508
+ [35 /* X_V_ON_NO_EXPRESSION */]: `v-on is missing expression.`,
509
+ [36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */]: `Unexpected custom directive on <slot> outlet.`,
510
+ [37 /* X_V_SLOT_MIXED_SLOT_USAGE */]: `Mixed v-slot usage on both the component and nested <template>.` +
510
511
  `When there are multiple named slots, all slots should use <template> ` +
511
512
  `syntax to avoid scope ambiguity.`,
512
- [37 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
513
- [38 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
513
+ [38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */]: `Duplicate slot names found. `,
514
+ [39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */]: `Extraneous children found when component already has explicitly named ` +
514
515
  `default slot. These children will be ignored.`,
515
- [39 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
516
- [40 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
517
- [41 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
518
- [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.`,
519
- [43 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
520
- [44 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
516
+ [40 /* X_V_SLOT_MISPLACED */]: `v-slot can only be used on components or <template> tags.`,
517
+ [41 /* X_V_MODEL_NO_EXPRESSION */]: `v-model is missing expression.`,
518
+ [42 /* X_V_MODEL_MALFORMED_EXPRESSION */]: `v-model value must be a valid JavaScript member expression.`,
519
+ [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.`,
520
+ [44 /* X_INVALID_EXPRESSION */]: `Error parsing JavaScript expression: `,
521
+ [45 /* X_KEEP_ALIVE_INVALID_CHILDREN */]: `<KeepAlive> expects exactly one child component.`,
521
522
  // generic errors
522
- [45 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
523
- [46 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
524
- [47 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
525
- [48 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
523
+ [46 /* X_PREFIX_ID_NOT_SUPPORTED */]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
524
+ [47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
525
+ [48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
526
+ [49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
526
527
  // just to fullfill types
527
- [49 /* __EXTEND_POINT__ */]: ``
528
+ [50 /* __EXTEND_POINT__ */]: ``
528
529
  };
529
530
 
530
531
  const FRAGMENT = Symbol(`Fragment` );
@@ -561,7 +562,6 @@ const TO_HANDLER_KEY = Symbol(`toHandlerKey` );
561
562
  const SET_BLOCK_TRACKING = Symbol(`setBlockTracking` );
562
563
  const PUSH_SCOPE_ID = Symbol(`pushScopeId` );
563
564
  const POP_SCOPE_ID = Symbol(`popScopeId` );
564
- const WITH_SCOPE_ID = Symbol(`withScopeId` );
565
565
  const WITH_CTX = Symbol(`withCtx` );
566
566
  const UNREF = Symbol(`unref` );
567
567
  const IS_REF = Symbol(`isRef` );
@@ -605,7 +605,6 @@ const helperNameMap = {
605
605
  [SET_BLOCK_TRACKING]: `setBlockTracking`,
606
606
  [PUSH_SCOPE_ID]: `pushScopeId`,
607
607
  [POP_SCOPE_ID]: `popScopeId`,
608
- [WITH_SCOPE_ID]: `withScopeId`,
609
608
  [WITH_CTX]: `withCtx`,
610
609
  [UNREF]: `unref`,
611
610
  [IS_REF]: `isRef`,
@@ -1740,7 +1739,7 @@ function parseAttribute(context, nameSet) {
1740
1739
  }
1741
1740
  }
1742
1741
  const loc = getSelection(context, start);
1743
- if (!context.inVPre && /^(v-|:|\.|@|#)/.test(name)) {
1742
+ if (!context.inVPre && /^(v-[A-Za-z0-9-]|:|\.|@|#)/.test(name)) {
1744
1743
  const match = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(name);
1745
1744
  let isPropShorthand = startsWith(name, '.');
1746
1745
  let dirName = match[1] ||
@@ -1759,7 +1758,7 @@ function parseAttribute(context, nameSet) {
1759
1758
  if (content.startsWith('[')) {
1760
1759
  isStatic = false;
1761
1760
  if (!content.endsWith(']')) {
1762
- emitError(context, 26 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1761
+ emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
1763
1762
  }
1764
1763
  content = content.substr(1, content.length - 2);
1765
1764
  }
@@ -1806,6 +1805,10 @@ function parseAttribute(context, nameSet) {
1806
1805
  loc
1807
1806
  };
1808
1807
  }
1808
+ // missing directive name or illegal directive name
1809
+ if (!context.inVPre && startsWith(name, 'v-')) {
1810
+ emitError(context, 26 /* X_MISSING_DIRECTIVE_NAME */);
1811
+ }
1809
1812
  return {
1810
1813
  type: 6 /* ATTRIBUTE */,
1811
1814
  name,
@@ -1885,10 +1888,7 @@ function parseInterpolation(context, mode) {
1885
1888
  };
1886
1889
  }
1887
1890
  function parseText(context, mode) {
1888
- const endTokens = ['<', context.options.delimiters[0]];
1889
- if (mode === 3 /* CDATA */) {
1890
- endTokens.push(']]>');
1891
- }
1891
+ const endTokens = mode === 3 /* CDATA */ ? [']]>'] : ['<', context.options.delimiters[0]];
1892
1892
  let endIndex = context.source.length;
1893
1893
  for (let i = 0; i < endTokens.length; i++) {
1894
1894
  const index = context.source.indexOf(endTokens[i], 1);
@@ -6040,11 +6040,8 @@ function genFunctionPreamble(ast, context) {
6040
6040
  }
6041
6041
  function genModulePreamble(ast, context, genScopeId, inline) {
6042
6042
  const { push, newline, optimizeImports, runtimeModuleName } = context;
6043
- if (genScopeId) {
6044
- ast.helpers.push(WITH_SCOPE_ID);
6045
- if (ast.hoists.length) {
6046
- ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
6047
- }
6043
+ if (genScopeId && ast.hoists.length) {
6044
+ ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
6048
6045
  }
6049
6046
  // generate import statements for helpers
6050
6047
  if (ast.helpers.length) {
@@ -11700,232 +11697,6 @@ var toFastProperties = function toFastproperties(o) {
11700
11697
  return FastObject(o);
11701
11698
  };
11702
11699
 
11703
- var global = (typeof global !== "undefined" ? global :
11704
- typeof self !== "undefined" ? self :
11705
- typeof window !== "undefined" ? window : {});
11706
-
11707
- // shim for using process in browser
11708
- // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
11709
-
11710
- function defaultSetTimout() {
11711
- throw new Error('setTimeout has not been defined');
11712
- }
11713
- function defaultClearTimeout () {
11714
- throw new Error('clearTimeout has not been defined');
11715
- }
11716
- var cachedSetTimeout = defaultSetTimout;
11717
- var cachedClearTimeout = defaultClearTimeout;
11718
- if (typeof global.setTimeout === 'function') {
11719
- cachedSetTimeout = setTimeout;
11720
- }
11721
- if (typeof global.clearTimeout === 'function') {
11722
- cachedClearTimeout = clearTimeout;
11723
- }
11724
-
11725
- function runTimeout(fun) {
11726
- if (cachedSetTimeout === setTimeout) {
11727
- //normal enviroments in sane situations
11728
- return setTimeout(fun, 0);
11729
- }
11730
- // if setTimeout wasn't available but was latter defined
11731
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
11732
- cachedSetTimeout = setTimeout;
11733
- return setTimeout(fun, 0);
11734
- }
11735
- try {
11736
- // when when somebody has screwed with setTimeout but no I.E. maddness
11737
- return cachedSetTimeout(fun, 0);
11738
- } catch(e){
11739
- try {
11740
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
11741
- return cachedSetTimeout.call(null, fun, 0);
11742
- } catch(e){
11743
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
11744
- return cachedSetTimeout.call(this, fun, 0);
11745
- }
11746
- }
11747
-
11748
-
11749
- }
11750
- function runClearTimeout(marker) {
11751
- if (cachedClearTimeout === clearTimeout) {
11752
- //normal enviroments in sane situations
11753
- return clearTimeout(marker);
11754
- }
11755
- // if clearTimeout wasn't available but was latter defined
11756
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
11757
- cachedClearTimeout = clearTimeout;
11758
- return clearTimeout(marker);
11759
- }
11760
- try {
11761
- // when when somebody has screwed with setTimeout but no I.E. maddness
11762
- return cachedClearTimeout(marker);
11763
- } catch (e){
11764
- try {
11765
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
11766
- return cachedClearTimeout.call(null, marker);
11767
- } catch (e){
11768
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
11769
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
11770
- return cachedClearTimeout.call(this, marker);
11771
- }
11772
- }
11773
-
11774
-
11775
-
11776
- }
11777
- var queue = [];
11778
- var draining = false;
11779
- var currentQueue;
11780
- var queueIndex = -1;
11781
-
11782
- function cleanUpNextTick() {
11783
- if (!draining || !currentQueue) {
11784
- return;
11785
- }
11786
- draining = false;
11787
- if (currentQueue.length) {
11788
- queue = currentQueue.concat(queue);
11789
- } else {
11790
- queueIndex = -1;
11791
- }
11792
- if (queue.length) {
11793
- drainQueue();
11794
- }
11795
- }
11796
-
11797
- function drainQueue() {
11798
- if (draining) {
11799
- return;
11800
- }
11801
- var timeout = runTimeout(cleanUpNextTick);
11802
- draining = true;
11803
-
11804
- var len = queue.length;
11805
- while(len) {
11806
- currentQueue = queue;
11807
- queue = [];
11808
- while (++queueIndex < len) {
11809
- if (currentQueue) {
11810
- currentQueue[queueIndex].run();
11811
- }
11812
- }
11813
- queueIndex = -1;
11814
- len = queue.length;
11815
- }
11816
- currentQueue = null;
11817
- draining = false;
11818
- runClearTimeout(timeout);
11819
- }
11820
- function nextTick(fun) {
11821
- var args = new Array(arguments.length - 1);
11822
- if (arguments.length > 1) {
11823
- for (var i = 1; i < arguments.length; i++) {
11824
- args[i - 1] = arguments[i];
11825
- }
11826
- }
11827
- queue.push(new Item(fun, args));
11828
- if (queue.length === 1 && !draining) {
11829
- runTimeout(drainQueue);
11830
- }
11831
- }
11832
- // v8 likes predictible objects
11833
- function Item(fun, array) {
11834
- this.fun = fun;
11835
- this.array = array;
11836
- }
11837
- Item.prototype.run = function () {
11838
- this.fun.apply(null, this.array);
11839
- };
11840
- var title = 'browser';
11841
- var platform = 'browser';
11842
- var browser = true;
11843
- var env = {};
11844
- var argv = [];
11845
- var version = ''; // empty string to avoid regexp issues
11846
- var versions = {};
11847
- var release = {};
11848
- var config = {};
11849
-
11850
- function noop() {}
11851
-
11852
- var on = noop;
11853
- var addListener = noop;
11854
- var once = noop;
11855
- var off = noop;
11856
- var removeListener = noop;
11857
- var removeAllListeners = noop;
11858
- var emit = noop;
11859
-
11860
- function binding(name) {
11861
- throw new Error('process.binding is not supported');
11862
- }
11863
-
11864
- function cwd () { return '/' }
11865
- function chdir (dir) {
11866
- throw new Error('process.chdir is not supported');
11867
- }function umask() { return 0; }
11868
-
11869
- // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
11870
- var performance = global.performance || {};
11871
- var performanceNow =
11872
- performance.now ||
11873
- performance.mozNow ||
11874
- performance.msNow ||
11875
- performance.oNow ||
11876
- performance.webkitNow ||
11877
- function(){ return (new Date()).getTime() };
11878
-
11879
- // generate timestamp or delta
11880
- // see http://nodejs.org/api/process.html#process_process_hrtime
11881
- function hrtime(previousTimestamp){
11882
- var clocktime = performanceNow.call(performance)*1e-3;
11883
- var seconds = Math.floor(clocktime);
11884
- var nanoseconds = Math.floor((clocktime%1)*1e9);
11885
- if (previousTimestamp) {
11886
- seconds = seconds - previousTimestamp[0];
11887
- nanoseconds = nanoseconds - previousTimestamp[1];
11888
- if (nanoseconds<0) {
11889
- seconds--;
11890
- nanoseconds += 1e9;
11891
- }
11892
- }
11893
- return [seconds,nanoseconds]
11894
- }
11895
-
11896
- var startTime = new Date();
11897
- function uptime() {
11898
- var currentTime = new Date();
11899
- var dif = currentTime - startTime;
11900
- return dif / 1000;
11901
- }
11902
-
11903
- var browser$1 = {
11904
- nextTick: nextTick,
11905
- title: title,
11906
- browser: browser,
11907
- env: env,
11908
- argv: argv,
11909
- version: version,
11910
- versions: versions,
11911
- on: on,
11912
- addListener: addListener,
11913
- once: once,
11914
- off: off,
11915
- removeListener: removeListener,
11916
- removeAllListeners: removeAllListeners,
11917
- emit: emit,
11918
- binding: binding,
11919
- cwd: cwd,
11920
- chdir: chdir,
11921
- umask: umask,
11922
- hrtime: hrtime,
11923
- platform: platform,
11924
- release: release,
11925
- config: config,
11926
- uptime: uptime
11927
- };
11928
-
11929
11700
  var _default$4 = isType;
11930
11701
 
11931
11702
 
@@ -34730,7 +34501,7 @@ function processExpression(node, context,
34730
34501
  // function params
34731
34502
  asParams = false,
34732
34503
  // v-on handler values may contain multiple statements
34733
- asRawStatements = false) {
34504
+ asRawStatements = false, localVars = Object.create(context.identifiers)) {
34734
34505
  if (!context.prefixIdentifiers || !node.content.trim()) {
34735
34506
  return node;
34736
34507
  }
@@ -34744,7 +34515,7 @@ asRawStatements = false) {
34744
34515
  const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
34745
34516
  // ({ x } = y)
34746
34517
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
34747
- if (type === "setup-const" /* SETUP_CONST */) {
34518
+ if (type === "setup-const" /* SETUP_CONST */ || localVars[raw]) {
34748
34519
  return raw;
34749
34520
  }
34750
34521
  else if (type === "setup-ref" /* SETUP_REF */) {
@@ -34768,7 +34539,7 @@ asRawStatements = false) {
34768
34539
  // x = y --> isRef(x) ? x.value = y : x = y
34769
34540
  const { right: rVal, operator } = parent;
34770
34541
  const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
34771
- const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context));
34542
+ const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context, false, false, knownIds));
34772
34543
  return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore\n` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
34773
34544
  }
34774
34545
  else if (isUpdateArg) {
@@ -34854,7 +34625,7 @@ asRawStatements = false) {
34854
34625
  }).program;
34855
34626
  }
34856
34627
  catch (e) {
34857
- context.onError(createCompilerError(43 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
34628
+ context.onError(createCompilerError(44 /* X_INVALID_EXPRESSION */, node.loc, undefined, e.message));
34858
34629
  return node;
34859
34630
  }
34860
34631
  const ids = [];
@@ -34980,7 +34751,7 @@ function processIf(node, dir, context, processCodegen) {
34980
34751
  if (dir.name !== 'else' &&
34981
34752
  (!dir.exp || !dir.exp.content.trim())) {
34982
34753
  const loc = dir.exp ? dir.exp.loc : node.loc;
34983
- context.onError(createCompilerError(27 /* X_V_IF_NO_EXPRESSION */, dir.loc));
34754
+ context.onError(createCompilerError(28 /* X_V_IF_NO_EXPRESSION */, dir.loc));
34984
34755
  dir.exp = createSimpleExpression(`true`, false, loc);
34985
34756
  }
34986
34757
  if (context.prefixIdentifiers && dir.exp) {
@@ -35035,7 +34806,7 @@ function processIf(node, dir, context, processCodegen) {
35035
34806
  if (key) {
35036
34807
  sibling.branches.forEach(({ userKey }) => {
35037
34808
  if (isSameKey(userKey, key)) {
35038
- context.onError(createCompilerError(28 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
34809
+ context.onError(createCompilerError(29 /* X_V_IF_SAME_KEY */, branch.userKey.loc));
35039
34810
  }
35040
34811
  });
35041
34812
  }
@@ -35053,7 +34824,7 @@ function processIf(node, dir, context, processCodegen) {
35053
34824
  context.currentNode = null;
35054
34825
  }
35055
34826
  else {
35056
- context.onError(createCompilerError(29 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
34827
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
35057
34828
  }
35058
34829
  break;
35059
34830
  }
@@ -35204,7 +34975,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
35204
34975
  if (c.type === 1 /* ELEMENT */) {
35205
34976
  const key = findProp(c, 'key');
35206
34977
  if (key) {
35207
- context.onError(createCompilerError(32 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
34978
+ context.onError(createCompilerError(33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */, key.loc));
35208
34979
  return true;
35209
34980
  }
35210
34981
  }
@@ -35289,7 +35060,7 @@ const transformFor = createStructuralDirectiveTransform('for', (node, dir, conte
35289
35060
  // target-agnostic transform used for both Client and SSR
35290
35061
  function processFor(node, dir, context, processCodegen) {
35291
35062
  if (!dir.exp) {
35292
- context.onError(createCompilerError(30 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
35063
+ context.onError(createCompilerError(31 /* X_V_FOR_NO_EXPRESSION */, dir.loc));
35293
35064
  return;
35294
35065
  }
35295
35066
  const parseResult = parseForExpression(
@@ -35297,7 +35068,7 @@ function processFor(node, dir, context, processCodegen) {
35297
35068
  // before expression transform.
35298
35069
  dir.exp, context);
35299
35070
  if (!parseResult) {
35300
- context.onError(createCompilerError(31 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
35071
+ context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, dir.loc));
35301
35072
  return;
35302
35073
  }
35303
35074
  const { addIdentifiers, removeIdentifiers, scopes } = context;
@@ -35503,7 +35274,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
35503
35274
  }
35504
35275
  if (onComponentSlot) {
35505
35276
  // already has on-component slot - this is incorrect usage.
35506
- context.onError(createCompilerError(36 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
35277
+ context.onError(createCompilerError(37 /* X_V_SLOT_MIXED_SLOT_USAGE */, slotDir.loc));
35507
35278
  break;
35508
35279
  }
35509
35280
  hasTemplateSlots = true;
@@ -35550,7 +35321,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
35550
35321
  : buildDynamicSlot(slotName, slotFunction);
35551
35322
  }
35552
35323
  else {
35553
- context.onError(createCompilerError(29 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
35324
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, vElse.loc));
35554
35325
  }
35555
35326
  }
35556
35327
  else if ((vFor = findDir(slotElement, 'for'))) {
@@ -35566,14 +35337,14 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
35566
35337
  ]));
35567
35338
  }
35568
35339
  else {
35569
- context.onError(createCompilerError(31 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
35340
+ context.onError(createCompilerError(32 /* X_V_FOR_MALFORMED_EXPRESSION */, vFor.loc));
35570
35341
  }
35571
35342
  }
35572
35343
  else {
35573
35344
  // check duplicate static names
35574
35345
  if (staticSlotName) {
35575
35346
  if (seenSlotNames.has(staticSlotName)) {
35576
- context.onError(createCompilerError(37 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
35347
+ context.onError(createCompilerError(38 /* X_V_SLOT_DUPLICATE_SLOT_NAMES */, dirLoc));
35577
35348
  continue;
35578
35349
  }
35579
35350
  seenSlotNames.add(staticSlotName);
@@ -35600,7 +35371,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
35600
35371
  implicitDefaultChildren.some(node => isNonWhitespaceContent(node))) {
35601
35372
  // implicit default slot (mixed with named slots)
35602
35373
  if (hasNamedDefaultSlot) {
35603
- context.onError(createCompilerError(38 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
35374
+ context.onError(createCompilerError(39 /* X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN */, implicitDefaultChildren[0].loc));
35604
35375
  }
35605
35376
  else {
35606
35377
  slotsProperties.push(buildDefaultSlotProperty(undefined, implicitDefaultChildren));
@@ -35732,7 +35503,7 @@ const transformElement = (node, context) => {
35732
35503
  // 2. Force keep-alive to always be updated, since it uses raw children.
35733
35504
  patchFlag |= 1024 /* DYNAMIC_SLOTS */;
35734
35505
  if (node.children.length > 1) {
35735
- context.onError(createCompilerError(44 /* X_KEEP_ALIVE_INVALID_CHILDREN */, {
35506
+ context.onError(createCompilerError(45 /* X_KEEP_ALIVE_INVALID_CHILDREN */, {
35736
35507
  start: node.children[0].loc.start,
35737
35508
  end: node.children[node.children.length - 1].loc.end,
35738
35509
  source: ''
@@ -35974,14 +35745,15 @@ function buildProps(node, context, props = node.props, ssr = false) {
35974
35745
  const prop = props[i];
35975
35746
  if (prop.type === 6 /* ATTRIBUTE */) {
35976
35747
  const { loc, name, value } = prop;
35977
- let isStatic = true;
35748
+ let valueNode = createSimpleExpression(value ? value.content : '', true, value ? value.loc : loc);
35978
35749
  if (name === 'ref') {
35979
35750
  hasRef = true;
35980
35751
  // in inline mode there is no setupState object, so we can't use string
35981
35752
  // keys to set the ref. Instead, we need to transform it to pass the
35982
35753
  // acrtual ref instead.
35983
- if (context.inline) {
35984
- isStatic = false;
35754
+ if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
35755
+ valueNode = createFunctionExpression(['_value', '_refs']);
35756
+ valueNode.body = createBlockStatement(processInlineRef(context.bindingMetadata, value.content));
35985
35757
  }
35986
35758
  }
35987
35759
  // skip is on <component>, or is="vue:xxx"
@@ -35991,7 +35763,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
35991
35763
  (false ))) {
35992
35764
  continue;
35993
35765
  }
35994
- properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), createSimpleExpression(value ? value.content : '', isStatic, value ? value.loc : loc)));
35766
+ properties.push(createObjectProperty(createSimpleExpression(name, true, getInnerRange(loc, 0, name.length)), valueNode));
35995
35767
  }
35996
35768
  else {
35997
35769
  // directives
@@ -36001,7 +35773,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
36001
35773
  // skip v-slot - it is handled by its dedicated transform.
36002
35774
  if (name === 'slot') {
36003
35775
  if (!isComponent) {
36004
- context.onError(createCompilerError(39 /* X_V_SLOT_MISPLACED */, loc));
35776
+ context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, loc));
36005
35777
  }
36006
35778
  continue;
36007
35779
  }
@@ -36044,8 +35816,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
36044
35816
  }
36045
35817
  else {
36046
35818
  context.onError(createCompilerError(isVBind
36047
- ? 33 /* X_V_BIND_NO_EXPRESSION */
36048
- : 34 /* X_V_ON_NO_EXPRESSION */, loc));
35819
+ ? 34 /* X_V_BIND_NO_EXPRESSION */
35820
+ : 35 /* X_V_ON_NO_EXPRESSION */, loc));
36049
35821
  }
36050
35822
  continue;
36051
35823
  }
@@ -36265,6 +36037,17 @@ function stringifyDynamicPropNames(props) {
36265
36037
  }
36266
36038
  function isComponentTag(tag) {
36267
36039
  return tag[0].toLowerCase() + tag.slice(1) === 'component';
36040
+ }
36041
+ function processInlineRef(bindings, raw) {
36042
+ const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
36043
+ const type = bindings[raw];
36044
+ if (type === "setup-ref" /* SETUP_REF */) {
36045
+ body.push(createSimpleExpression(`${raw}.value = _value`));
36046
+ }
36047
+ else if (type === "setup-let" /* SETUP_LET */) {
36048
+ body.push(createSimpleExpression(`${raw} = _value`));
36049
+ }
36050
+ return body;
36268
36051
  }
36269
36052
 
36270
36053
  const transformSlotOutlet = (node, context) => {
@@ -36330,7 +36113,7 @@ function processSlotOutlet(node, context) {
36330
36113
  const { props, directives } = buildProps(node, context, nonNameProps);
36331
36114
  slotProps = props;
36332
36115
  if (directives.length) {
36333
- context.onError(createCompilerError(35 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
36116
+ context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
36334
36117
  }
36335
36118
  }
36336
36119
  return {
@@ -36343,7 +36126,7 @@ const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
36343
36126
  const transformOn = (dir, node, context, augmentor) => {
36344
36127
  const { loc, modifiers, arg } = dir;
36345
36128
  if (!dir.exp && !modifiers.length) {
36346
- context.onError(createCompilerError(34 /* X_V_ON_NO_EXPRESSION */, loc));
36129
+ context.onError(createCompilerError(35 /* X_V_ON_NO_EXPRESSION */, loc));
36347
36130
  }
36348
36131
  let eventName;
36349
36132
  if (arg.type === 4 /* SIMPLE_EXPRESSION */) {
@@ -36484,7 +36267,7 @@ const transformBind = (dir, _node, context) => {
36484
36267
  }
36485
36268
  if (!exp ||
36486
36269
  (exp.type === 4 /* SIMPLE_EXPRESSION */ && !exp.content.trim())) {
36487
- context.onError(createCompilerError(33 /* X_V_BIND_NO_EXPRESSION */, loc));
36270
+ context.onError(createCompilerError(34 /* X_V_BIND_NO_EXPRESSION */, loc));
36488
36271
  return {
36489
36272
  props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
36490
36273
  };
@@ -36620,7 +36403,7 @@ const transformOnce = (node, context) => {
36620
36403
  const transformModel = (dir, node, context) => {
36621
36404
  const { exp, arg } = dir;
36622
36405
  if (!exp) {
36623
- context.onError(createCompilerError(40 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
36406
+ context.onError(createCompilerError(41 /* X_V_MODEL_NO_EXPRESSION */, dir.loc));
36624
36407
  return createTransformProps();
36625
36408
  }
36626
36409
  const rawExp = exp.loc.source;
@@ -36632,13 +36415,13 @@ const transformModel = (dir, node, context) => {
36632
36415
  bindingType &&
36633
36416
  bindingType !== "setup-const" /* SETUP_CONST */;
36634
36417
  if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
36635
- context.onError(createCompilerError(41 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
36418
+ context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
36636
36419
  return createTransformProps();
36637
36420
  }
36638
36421
  if (context.prefixIdentifiers &&
36639
36422
  isSimpleIdentifier(expString) &&
36640
36423
  context.identifiers[expString]) {
36641
- context.onError(createCompilerError(42 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
36424
+ context.onError(createCompilerError(43 /* X_V_MODEL_ON_SCOPE_VARIABLE */, exp.loc));
36642
36425
  return createTransformProps();
36643
36426
  }
36644
36427
  const propName = arg ? arg : createSimpleExpression('modelValue', true);
@@ -36768,10 +36551,10 @@ function baseCompile(template, options = {}) {
36768
36551
  const isModuleMode = options.mode === 'module';
36769
36552
  const prefixIdentifiers = (options.prefixIdentifiers === true || isModuleMode);
36770
36553
  if (!prefixIdentifiers && options.cacheHandlers) {
36771
- onError(createCompilerError(47 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
36554
+ onError(createCompilerError(48 /* X_CACHE_HANDLER_NOT_SUPPORTED */));
36772
36555
  }
36773
36556
  if (options.scopeId && !isModuleMode) {
36774
- onError(createCompilerError(48 /* X_SCOPE_ID_NOT_SUPPORTED */));
36557
+ onError(createCompilerError(49 /* X_SCOPE_ID_NOT_SUPPORTED */));
36775
36558
  }
36776
36559
  const ast = isString(template) ? baseParse(template, options) : template;
36777
36560
  const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
@@ -39269,26 +39052,26 @@ function createDOMCompilerError(code, loc) {
39269
39052
  return createCompilerError(code, loc, DOMErrorMessages );
39270
39053
  }
39271
39054
  const DOMErrorMessages = {
39272
- [49 /* X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
39273
- [50 /* X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
39274
- [51 /* X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
39275
- [52 /* X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
39276
- [53 /* X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
39277
- [54 /* X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
39278
- [55 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
39279
- [56 /* X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
39280
- [57 /* X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
39281
- [58 /* X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
39282
- [59 /* X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
39055
+ [50 /* X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
39056
+ [51 /* X_V_HTML_WITH_CHILDREN */]: `v-html will override element children.`,
39057
+ [52 /* X_V_TEXT_NO_EXPRESSION */]: `v-text is missing expression.`,
39058
+ [53 /* X_V_TEXT_WITH_CHILDREN */]: `v-text will override element children.`,
39059
+ [54 /* X_V_MODEL_ON_INVALID_ELEMENT */]: `v-model can only be used on <input>, <textarea> and <select> elements.`,
39060
+ [55 /* X_V_MODEL_ARG_ON_ELEMENT */]: `v-model argument is not supported on plain elements.`,
39061
+ [56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */]: `v-model cannot be used on file inputs since they are read-only. Use a v-on:change listener instead.`,
39062
+ [57 /* X_V_MODEL_UNNECESSARY_VALUE */]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
39063
+ [58 /* X_V_SHOW_NO_EXPRESSION */]: `v-show is missing expression.`,
39064
+ [59 /* X_TRANSITION_INVALID_CHILDREN */]: `<Transition> expects exactly one child element or component.`,
39065
+ [60 /* X_IGNORED_SIDE_EFFECT_TAG */]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
39283
39066
  };
39284
39067
 
39285
39068
  const transformVHtml = (dir, node, context) => {
39286
39069
  const { exp, loc } = dir;
39287
39070
  if (!exp) {
39288
- context.onError(createDOMCompilerError(49 /* X_V_HTML_NO_EXPRESSION */, loc));
39071
+ context.onError(createDOMCompilerError(50 /* X_V_HTML_NO_EXPRESSION */, loc));
39289
39072
  }
39290
39073
  if (node.children.length) {
39291
- context.onError(createDOMCompilerError(50 /* X_V_HTML_WITH_CHILDREN */, loc));
39074
+ context.onError(createDOMCompilerError(51 /* X_V_HTML_WITH_CHILDREN */, loc));
39292
39075
  node.children.length = 0;
39293
39076
  }
39294
39077
  return {
@@ -39301,10 +39084,10 @@ const transformVHtml = (dir, node, context) => {
39301
39084
  const transformVText = (dir, node, context) => {
39302
39085
  const { exp, loc } = dir;
39303
39086
  if (!exp) {
39304
- context.onError(createDOMCompilerError(51 /* X_V_TEXT_NO_EXPRESSION */, loc));
39087
+ context.onError(createDOMCompilerError(52 /* X_V_TEXT_NO_EXPRESSION */, loc));
39305
39088
  }
39306
39089
  if (node.children.length) {
39307
- context.onError(createDOMCompilerError(52 /* X_V_TEXT_WITH_CHILDREN */, loc));
39090
+ context.onError(createDOMCompilerError(53 /* X_V_TEXT_WITH_CHILDREN */, loc));
39308
39091
  node.children.length = 0;
39309
39092
  }
39310
39093
  return {
@@ -39323,12 +39106,12 @@ const transformModel$1 = (dir, node, context) => {
39323
39106
  return baseResult;
39324
39107
  }
39325
39108
  if (dir.arg) {
39326
- context.onError(createDOMCompilerError(54 /* X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
39109
+ context.onError(createDOMCompilerError(55 /* X_V_MODEL_ARG_ON_ELEMENT */, dir.arg.loc));
39327
39110
  }
39328
39111
  function checkDuplicatedValue() {
39329
39112
  const value = findProp(node, 'value');
39330
39113
  if (value) {
39331
- context.onError(createDOMCompilerError(56 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
39114
+ context.onError(createDOMCompilerError(57 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
39332
39115
  }
39333
39116
  }
39334
39117
  const { tag } = node;
@@ -39356,7 +39139,7 @@ const transformModel$1 = (dir, node, context) => {
39356
39139
  break;
39357
39140
  case 'file':
39358
39141
  isInvalidType = true;
39359
- context.onError(createDOMCompilerError(55 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
39142
+ context.onError(createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
39360
39143
  break;
39361
39144
  default:
39362
39145
  // text type
@@ -39390,7 +39173,7 @@ const transformModel$1 = (dir, node, context) => {
39390
39173
  }
39391
39174
  }
39392
39175
  else {
39393
- context.onError(createDOMCompilerError(53 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
39176
+ context.onError(createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
39394
39177
  }
39395
39178
  // native vmodel doesn't need the `modelValue` props since they are also
39396
39179
  // passed to the runtime as `binding.value`. removing it reduces code size.
@@ -39510,7 +39293,7 @@ const transformOn$1 = (dir, node, context) => {
39510
39293
  const transformShow = (dir, node, context) => {
39511
39294
  const { exp, loc } = dir;
39512
39295
  if (!exp) {
39513
- context.onError(createDOMCompilerError(57 /* X_V_SHOW_NO_EXPRESSION */, loc));
39296
+ context.onError(createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */, loc));
39514
39297
  }
39515
39298
  return {
39516
39299
  props: [],
@@ -39525,7 +39308,7 @@ const warnTransitionChildren = (node, context) => {
39525
39308
  if (component === TRANSITION) {
39526
39309
  return () => {
39527
39310
  if (node.children.length && hasMultipleChildren(node)) {
39528
- context.onError(createDOMCompilerError(58 /* X_TRANSITION_INVALID_CHILDREN */, {
39311
+ context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
39529
39312
  start: node.children[0].loc.start,
39530
39313
  end: node.children[node.children.length - 1].loc.end,
39531
39314
  source: ''
@@ -39806,7 +39589,7 @@ const ignoreSideEffectTags = (node, context) => {
39806
39589
  if (node.type === 1 /* ELEMENT */ &&
39807
39590
  node.tagType === 0 /* ELEMENT */ &&
39808
39591
  (node.tag === 'script' || node.tag === 'style')) {
39809
- context.onError(createDOMCompilerError(59 /* X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
39592
+ context.onError(createDOMCompilerError(60 /* X_IGNORED_SIDE_EFFECT_TAG */, node.loc));
39810
39593
  context.removeNode();
39811
39594
  }
39812
39595
  };
@@ -39974,7 +39757,6 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
39974
39757
  SET_BLOCK_TRACKING: SET_BLOCK_TRACKING,
39975
39758
  PUSH_SCOPE_ID: PUSH_SCOPE_ID,
39976
39759
  POP_SCOPE_ID: POP_SCOPE_ID,
39977
- WITH_SCOPE_ID: WITH_SCOPE_ID,
39978
39760
  WITH_CTX: WITH_CTX,
39979
39761
  UNREF: UNREF,
39980
39762
  IS_REF: IS_REF,
@@ -40929,6 +40711,10 @@ function toASCII(input) {
40929
40711
  });
40930
40712
  }
40931
40713
 
40714
+ var global = (typeof global !== "undefined" ? global :
40715
+ typeof self !== "undefined" ? self :
40716
+ typeof window !== "undefined" ? window : {});
40717
+
40932
40718
  var lookup = [];
40933
40719
  var revLookup = [];
40934
40720
  var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;
@@ -44752,17 +44538,17 @@ function createSSRCompilerError(code, loc) {
44752
44538
  return createCompilerError(code, loc, SSRErrorMessages);
44753
44539
  }
44754
44540
  const SSRErrorMessages = {
44755
- [60 /* X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM */]: `Custom directive is missing corresponding SSR transform and will be ignored.`,
44756
- [61 /* X_SSR_UNSAFE_ATTR_NAME */]: `Unsafe attribute name for SSR.`,
44757
- [62 /* X_SSR_NO_TELEPORT_TARGET */]: `Missing the 'to' prop on teleport element.`,
44758
- [63 /* X_SSR_INVALID_AST_NODE */]: `Invalid AST node during SSR transform.`
44541
+ [61 /* X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM */]: `Custom directive is missing corresponding SSR transform and will be ignored.`,
44542
+ [62 /* X_SSR_UNSAFE_ATTR_NAME */]: `Unsafe attribute name for SSR.`,
44543
+ [63 /* X_SSR_NO_TELEPORT_TARGET */]: `Missing the 'to' prop on teleport element.`,
44544
+ [64 /* X_SSR_INVALID_AST_NODE */]: `Invalid AST node during SSR transform.`
44759
44545
  };
44760
44546
 
44761
44547
  // Note: this is a 2nd-pass codegen transform.
44762
44548
  function ssrProcessTeleport(node, context) {
44763
44549
  const targetProp = findProp(node, 'to');
44764
44550
  if (!targetProp) {
44765
- context.onError(createSSRCompilerError(62 /* X_SSR_NO_TELEPORT_TARGET */, node.loc));
44551
+ context.onError(createSSRCompilerError(63 /* X_SSR_NO_TELEPORT_TARGET */, node.loc));
44766
44552
  return;
44767
44553
  }
44768
44554
  let target;
@@ -44774,7 +44560,7 @@ function ssrProcessTeleport(node, context) {
44774
44560
  target = targetProp.exp;
44775
44561
  }
44776
44562
  if (!target) {
44777
- context.onError(createSSRCompilerError(62 /* X_SSR_NO_TELEPORT_TARGET */, targetProp.loc));
44563
+ context.onError(createSSRCompilerError(63 /* X_SSR_NO_TELEPORT_TARGET */, targetProp.loc));
44778
44564
  return;
44779
44565
  }
44780
44566
  const disabledProp = findProp(node, 'disabled', false, true /* allow empty */);
@@ -45181,7 +44967,7 @@ const ssrTransformElement = (node, context) => {
45181
44967
  node.children = [createInterpolation(prop.exp, prop.loc)];
45182
44968
  }
45183
44969
  else if (prop.name === 'slot') {
45184
- context.onError(createCompilerError(39 /* X_V_SLOT_MISPLACED */, prop.loc));
44970
+ context.onError(createCompilerError(40 /* X_V_SLOT_MISPLACED */, prop.loc));
45185
44971
  }
45186
44972
  else if (isTextareaWithValue(node, prop) && prop.exp) {
45187
44973
  if (!hasDynamicVBind) {
@@ -45193,7 +44979,7 @@ const ssrTransformElement = (node, context) => {
45193
44979
  const directiveTransform = context.directiveTransforms[prop.name];
45194
44980
  if (!directiveTransform) {
45195
44981
  // no corresponding ssr directive transform found.
45196
- context.onError(createSSRCompilerError(60 /* X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM */, prop.loc));
44982
+ context.onError(createSSRCompilerError(61 /* X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM */, prop.loc));
45197
44983
  }
45198
44984
  else if (!hasDynamicVBind) {
45199
44985
  const { props, ssrTagParts } = directiveTransform(prop, node, context);
@@ -45235,7 +45021,7 @@ const ssrTransformElement = (node, context) => {
45235
45021
  ]));
45236
45022
  }
45237
45023
  else {
45238
- context.onError(createSSRCompilerError(61 /* X_SSR_UNSAFE_ATTR_NAME */, key.loc));
45024
+ context.onError(createSSRCompilerError(62 /* X_SSR_UNSAFE_ATTR_NAME */, key.loc));
45239
45025
  }
45240
45026
  }
45241
45027
  }
@@ -45430,7 +45216,7 @@ function processChildren(children, context, asFragment = false, disableNestedFra
45430
45216
  // TODO
45431
45217
  break;
45432
45218
  default:
45433
- context.onError(createSSRCompilerError(63 /* X_SSR_INVALID_AST_NODE */, child.loc));
45219
+ context.onError(createSSRCompilerError(64 /* X_SSR_INVALID_AST_NODE */, child.loc));
45434
45220
  // make sure we exhaust all possible types
45435
45221
  const exhaustiveCheck = child;
45436
45222
  return exhaustiveCheck;
@@ -45462,7 +45248,7 @@ function processChildren(children, context, asFragment = false, disableNestedFra
45462
45248
  // `transformText` is not used during SSR compile.
45463
45249
  break;
45464
45250
  default:
45465
- context.onError(createSSRCompilerError(63 /* X_SSR_INVALID_AST_NODE */, child.loc));
45251
+ context.onError(createSSRCompilerError(64 /* X_SSR_INVALID_AST_NODE */, child.loc));
45466
45252
  // make sure we exhaust all possible types
45467
45253
  const exhaustiveCheck = child;
45468
45254
  return exhaustiveCheck;
@@ -45483,7 +45269,7 @@ const ssrTransformModel = (dir, node, context) => {
45483
45269
  function checkDuplicatedValue() {
45484
45270
  const value = findProp(node, 'value');
45485
45271
  if (value) {
45486
- context.onError(createDOMCompilerError(56 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
45272
+ context.onError(createDOMCompilerError(57 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
45487
45273
  }
45488
45274
  }
45489
45275
  if (node.tagType === 0 /* ELEMENT */) {
@@ -45540,7 +45326,7 @@ const ssrTransformModel = (dir, node, context) => {
45540
45326
  }
45541
45327
  break;
45542
45328
  case 'file':
45543
- context.onError(createDOMCompilerError(55 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
45329
+ context.onError(createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
45544
45330
  break;
45545
45331
  default:
45546
45332
  checkDuplicatedValue();
@@ -45562,7 +45348,7 @@ const ssrTransformModel = (dir, node, context) => {
45562
45348
  }
45563
45349
  else if (node.tag === 'select') ;
45564
45350
  else {
45565
- context.onError(createDOMCompilerError(53 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
45351
+ context.onError(createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
45566
45352
  }
45567
45353
  return res;
45568
45354
  }
@@ -45582,7 +45368,7 @@ function findValueBinding(node) {
45582
45368
 
45583
45369
  const ssrTransformShow = (dir, node, context) => {
45584
45370
  if (!dir.exp) {
45585
- context.onError(createDOMCompilerError(57 /* X_V_SHOW_NO_EXPRESSION */));
45371
+ context.onError(createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */));
45586
45372
  }
45587
45373
  return {
45588
45374
  props: [
@@ -45734,7 +45520,7 @@ var CompilerSSR = /*#__PURE__*/Object.freeze({
45734
45520
 
45735
45521
  const hasWarned = {};
45736
45522
  function warnOnce(msg) {
45737
- const isNodeProd = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
45523
+ const isNodeProd = typeof process !== 'undefined' && ({}).NODE_ENV === 'production';
45738
45524
  if (!isNodeProd && !false && !hasWarned[msg]) {
45739
45525
  hasWarned[msg] = true;
45740
45526
  warn(msg);
@@ -45771,7 +45557,8 @@ function compileTemplate(options) {
45771
45557
  const preprocessor = preprocessLang
45772
45558
  ? preprocessCustomRequire
45773
45559
  ? preprocessCustomRequire(preprocessLang)
45774
- : require('consolidate')[preprocessLang]
45560
+ : undefined
45561
+
45775
45562
  : false;
45776
45563
  if (preprocessor) {
45777
45564
  try {
@@ -45912,21 +45699,18 @@ function patchErrors(errors, source, inMap) {
45912
45699
  });
45913
45700
  }
45914
45701
 
45915
- const env$1 = process.env;
45702
+ const env = ({});
45916
45703
 
45917
- const isDisabled = "NO_COLOR" in env$1;
45918
- const isForced = "FORCE_COLOR" in env$1;
45919
- const isWindows = process.platform === "win32";
45704
+ const isDisabled = "NO_COLOR" in env;
45705
+ const isForced = "FORCE_COLOR" in env;
45706
+ const isWindows = "" === "win32";
45920
45707
 
45921
45708
  const isCompatibleTerminal =
45922
- process.stdout != null &&
45923
- process.stdout.isTTY &&
45924
- env$1.TERM &&
45925
- env$1.TERM !== "dumb";
45709
+ null != null ;
45926
45710
 
45927
45711
  const isCI =
45928
- "CI" in env$1 &&
45929
- ("GITHUB_ACTIONS" in env$1 || "GITLAB_CI" in env$1 || "CIRCLECI" in env$1);
45712
+ "CI" in env &&
45713
+ ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
45930
45714
 
45931
45715
  let enabled =
45932
45716
  !isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI);
@@ -52869,7 +52653,7 @@ class LazyResult$2 {
52869
52653
  error.plugin = plugin.postcssPlugin;
52870
52654
  error.setMessage();
52871
52655
  } else if (plugin.postcssVersion) {
52872
- if (browser$1.env.NODE_ENV !== 'production') {
52656
+ if (({}).NODE_ENV !== 'production') {
52873
52657
  let pluginName = plugin.postcssPlugin;
52874
52658
  let pluginVer = plugin.postcssVersion;
52875
52659
  let runtimeVer = this.result.processor.version;
@@ -58919,7 +58703,7 @@ function hasDefaultExport(input) {
58919
58703
  const TO_VAR_SYMBOL = '$';
58920
58704
  const TO_REF_SYMBOL = '$$';
58921
58705
  const shorthands = ['ref', 'computed', 'shallowRef'];
58922
- const transformCheckRE = /[^\w]\$(?:\$|ref|computed|shallowRef)?\(/;
58706
+ const transformCheckRE = /[^\w]\$(?:\$|ref|computed|shallowRef)?\s*(\(|\<)/;
58923
58707
  function shouldTransform(src) {
58924
58708
  return transformCheckRE.test(src);
58925
58709
  }
@@ -59128,7 +58912,7 @@ function transformAST(ast, s, offset = 0, knownRootVars) {
59128
58912
  }
59129
58913
  }
59130
58914
  function checkRefId(scope, id, parent, parentStack) {
59131
- if (id.name in scope) {
58915
+ if (hasOwn(scope, id.name)) {
59132
58916
  if (scope[id.name]) {
59133
58917
  if (isStaticProperty(parent) && parent.shorthand) {
59134
58918
  // let binding used in a property shorthand
@@ -59243,7 +59027,7 @@ function warnExperimental() {
59243
59027
  `You can follow the proposal's status at ${RFC_LINK}.`);
59244
59028
  }
59245
59029
  function warnOnce$2(msg) {
59246
- const isNodeProd = typeof process !== 'undefined' && process.env.NODE_ENV === 'production';
59030
+ const isNodeProd = typeof process !== 'undefined' && ({}).NODE_ENV === 'production';
59247
59031
  if (!isNodeProd && !false && !hasWarned$1[msg]) {
59248
59032
  hasWarned$1[msg] = true;
59249
59033
  warn$1(msg);
@@ -59454,6 +59238,10 @@ function compileScript(sfc, options) {
59454
59238
  `${DEFINE_PROPS} declaration.`, node);
59455
59239
  }
59456
59240
  propsRuntimeDefaults = node.arguments[1];
59241
+ if (!propsRuntimeDefaults ||
59242
+ propsRuntimeDefaults.type !== 'ObjectExpression') {
59243
+ error(`The 2nd argument of ${WITH_DEFAULTS} must be an object literal.`, propsRuntimeDefaults || node);
59244
+ }
59457
59245
  }
59458
59246
  else {
59459
59247
  error(`${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`, node.arguments[0] || node);
@@ -59504,7 +59292,10 @@ function compileScript(sfc, options) {
59504
59292
  return isQualifiedType(node.declaration);
59505
59293
  }
59506
59294
  };
59507
- for (const node of scriptSetupAst.body) {
59295
+ const body = scriptAst
59296
+ ? [...scriptSetupAst.body, ...scriptAst.body]
59297
+ : scriptSetupAst.body;
59298
+ for (const node of body) {
59508
59299
  const qualified = isQualifiedType(node);
59509
59300
  if (qualified) {
59510
59301
  return qualified;
@@ -59544,17 +59335,24 @@ function compileScript(sfc, options) {
59544
59335
  s.overwrite(node.start + startOffset, node.argument.start + startOffset, `${isStatement ? `;` : ``}(([__temp,__restore]=${helper(`withAsyncContext`)}(()=>(`);
59545
59336
  s.appendLeft(node.end + startOffset, `))),__temp=await __temp,__restore()${isStatement ? `` : `,__temp`})`);
59546
59337
  }
59338
+ /**
59339
+ * check defaults. If the default object is an object literal with only
59340
+ * static properties, we can directly generate more optimzied default
59341
+ * declarations. Otherwise we will have to fallback to runtime merging.
59342
+ */
59343
+ function checkStaticDefaults() {
59344
+ return (propsRuntimeDefaults &&
59345
+ propsRuntimeDefaults.type === 'ObjectExpression' &&
59346
+ propsRuntimeDefaults.properties.every(node => (node.type === 'ObjectProperty' && !node.computed) ||
59347
+ node.type === 'ObjectMethod'));
59348
+ }
59547
59349
  function genRuntimeProps(props) {
59548
59350
  const keys = Object.keys(props);
59549
59351
  if (!keys.length) {
59550
59352
  return ``;
59551
59353
  }
59552
- // check defaults. If the default object is an object literal with only
59553
- // static properties, we can directly generate more optimzied default
59554
- // decalrations. Otherwise we will have to fallback to runtime merging.
59555
- const hasStaticDefaults = propsRuntimeDefaults &&
59556
- propsRuntimeDefaults.type === 'ObjectExpression' &&
59557
- propsRuntimeDefaults.properties.every(node => node.type === 'ObjectProperty' && !node.computed);
59354
+ const hasStaticDefaults = checkStaticDefaults();
59355
+ const scriptSetupSource = scriptSetup.content;
59558
59356
  let propsDecls = `{
59559
59357
  ${keys
59560
59358
  .map(key => {
@@ -59562,8 +59360,13 @@ function compileScript(sfc, options) {
59562
59360
  if (hasStaticDefaults) {
59563
59361
  const prop = propsRuntimeDefaults.properties.find((node) => node.key.name === key);
59564
59362
  if (prop) {
59565
- // prop has corresponding static default value
59566
- defaultString = `default: ${source.slice(prop.value.start + startOffset, prop.value.end + startOffset)}`;
59363
+ if (prop.type === 'ObjectProperty') {
59364
+ // prop has corresponding static default value
59365
+ defaultString = `default: ${scriptSetupSource.slice(prop.value.start, prop.value.end)}`;
59366
+ }
59367
+ else {
59368
+ defaultString = `default() ${scriptSetupSource.slice(prop.body.start, prop.body.end)}`;
59369
+ }
59567
59370
  }
59568
59371
  }
59569
59372
  {
@@ -59575,7 +59378,38 @@ function compileScript(sfc, options) {
59575
59378
  if (propsRuntimeDefaults && !hasStaticDefaults) {
59576
59379
  propsDecls = `${helper('mergeDefaults')}(${propsDecls}, ${source.slice(propsRuntimeDefaults.start + startOffset, propsRuntimeDefaults.end + startOffset)})`;
59577
59380
  }
59578
- return `\n props: ${propsDecls} as unknown as undefined,`;
59381
+ return `\n props: ${propsDecls},`;
59382
+ }
59383
+ function genSetupPropsType(node) {
59384
+ const scriptSetupSource = scriptSetup.content;
59385
+ if (checkStaticDefaults()) {
59386
+ // if withDefaults() is used, we need to remove the optional flags
59387
+ // on props that have default values
59388
+ let res = `{ `;
59389
+ const members = node.type === 'TSTypeLiteral' ? node.members : node.body;
59390
+ for (const m of members) {
59391
+ if ((m.type === 'TSPropertySignature' ||
59392
+ m.type === 'TSMethodSignature') &&
59393
+ m.typeAnnotation &&
59394
+ m.key.type === 'Identifier') {
59395
+ if (propsRuntimeDefaults.properties.some((p) => p.key.name === m.key.name)) {
59396
+ res +=
59397
+ m.key.name +
59398
+ (m.type === 'TSMethodSignature' ? '()' : '') +
59399
+ scriptSetupSource.slice(m.typeAnnotation.start, m.typeAnnotation.end) +
59400
+ ', ';
59401
+ }
59402
+ else {
59403
+ res +=
59404
+ scriptSetupSource.slice(m.start, m.typeAnnotation.end) + `, `;
59405
+ }
59406
+ }
59407
+ }
59408
+ return (res.length ? res.slice(0, -2) : res) + ` }`;
59409
+ }
59410
+ else {
59411
+ return scriptSetupSource.slice(node.start, node.end);
59412
+ }
59579
59413
  }
59580
59414
  // 1. process normal <script> first if it exists
59581
59415
  let scriptAst;
@@ -59772,7 +59606,7 @@ function compileScript(sfc, options) {
59772
59606
  }
59773
59607
  }
59774
59608
  }
59775
- // walk decalrations to record declared bindings
59609
+ // walk declarations to record declared bindings
59776
59610
  if ((node.type === 'VariableDeclaration' ||
59777
59611
  node.type === 'FunctionDeclaration' ||
59778
59612
  node.type === 'ClassDeclaration') &&
@@ -59895,17 +59729,20 @@ function compileScript(sfc, options) {
59895
59729
  // 9. finalize setup() argument signature
59896
59730
  let args = `__props`;
59897
59731
  if (propsTypeDecl) {
59898
- args += `: ${scriptSetup.content.slice(propsTypeDecl.start, propsTypeDecl.end)}`;
59732
+ // mark as any and only cast on assignment
59733
+ // since the user defined complex types may be incompatible with the
59734
+ // inferred type from generated runtime declarations
59735
+ args += `: any`;
59899
59736
  }
59900
59737
  // inject user assignment of props
59901
59738
  // we use a default __props so that template expressions referencing props
59902
59739
  // can use it directly
59903
59740
  if (propsIdentifier) {
59904
- s.prependRight(startOffset, `\nconst ${propsIdentifier} = __props`);
59741
+ s.prependRight(startOffset, `\nconst ${propsIdentifier} = __props${propsTypeDecl ? ` as ${genSetupPropsType(propsTypeDecl)}` : ``}`);
59905
59742
  }
59906
59743
  // inject temp variables for async context preservation
59907
59744
  if (hasAwait) {
59908
- const any = isTS ? `:any` : ``;
59745
+ const any = isTS ? `: any` : ``;
59909
59746
  s.prependRight(startOffset, `\nlet __temp${any}, __restore${any}\n`);
59910
59747
  }
59911
59748
  const destructureElements = hasDefineExposeCall || !options.inlineTemplate ? [`expose`] : [];
@@ -60019,10 +59856,10 @@ function compileScript(sfc, options) {
60019
59856
  // this allows `import { setup } from '*.vue'` for testing purposes.
60020
59857
  if (defaultExport) {
60021
59858
  s.prependLeft(startOffset, `\n${hasAwait ? `async ` : ``}function setup(${args}) {\n`);
60022
- s.append(`\nexport default ${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup})`);
59859
+ s.append(`\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n setup})`);
60023
59860
  }
60024
59861
  else {
60025
- s.prependLeft(startOffset, `\nexport default ${helper(`defineComponent`)}({${def}${runtimeOptions}\n ${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`);
59862
+ s.prependLeft(startOffset, `\nexport default /*#__PURE__*/${helper(`defineComponent`)}({${def}${runtimeOptions}\n ${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`);
60026
59863
  s.appendRight(endOffset, `})`);
60027
59864
  }
60028
59865
  }
@@ -60246,6 +60083,7 @@ function inferRuntimeType(node, declaredTypes) {
60246
60083
  case 'Map':
60247
60084
  case 'WeakSet':
60248
60085
  case 'WeakMap':
60086
+ case 'Date':
60249
60087
  return [node.typeName.name];
60250
60088
  case 'Record':
60251
60089
  case 'Partial':
@@ -60313,7 +60151,7 @@ function genRuntimeEmits(emits) {
60313
60151
  return emits.size
60314
60152
  ? `\n emits: [${Array.from(emits)
60315
60153
  .map(p => JSON.stringify(p))
60316
- .join(', ')}] as unknown as undefined,`
60154
+ .join(', ')}],`
60317
60155
  : ``;
60318
60156
  }
60319
60157
  function isCallOf(node, test) {
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.2.5",
3
+ "version": "3.2.9",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
+ "module": "dist/compiler-sfc.esm-browser.js",
6
7
  "types": "dist/compiler-sfc.d.ts",
7
8
  "files": [
8
9
  "dist"
@@ -34,11 +35,11 @@
34
35
  "@babel/parser": "^7.15.0",
35
36
  "@babel/types": "^7.15.0",
36
37
  "@types/estree": "^0.0.48",
37
- "@vue/compiler-core": "3.2.5",
38
- "@vue/compiler-dom": "3.2.5",
39
- "@vue/compiler-ssr": "3.2.5",
40
- "@vue/ref-transform": "3.2.5",
41
- "@vue/shared": "3.2.5",
38
+ "@vue/compiler-core": "3.2.9",
39
+ "@vue/compiler-dom": "3.2.9",
40
+ "@vue/compiler-ssr": "3.2.9",
41
+ "@vue/ref-transform": "3.2.9",
42
+ "@vue/shared": "3.2.9",
42
43
  "consolidate": "^0.16.0",
43
44
  "estree-walker": "^2.0.2",
44
45
  "hash-sum": "^2.0.0",