@vue/compat 3.2.8 → 3.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var types = require('@babel/types');
6
3
  var estreeWalker = require('estree-walker');
7
4
  var parser = require('@babel/parser');
8
5
  var sourceMap = require('source-map');
@@ -1852,21 +1849,14 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // true onl
1852
1849
  return renderFnWithContext;
1853
1850
  }
1854
1851
 
1855
- /**
1856
- * dev only flag to track whether $attrs was used during render.
1857
- * If $attrs was used during render then the warning for failed attrs
1858
- * fallthrough can be suppressed.
1859
- */
1860
- let accessedAttrs = false;
1861
1852
  function markAttrsAccessed() {
1862
- accessedAttrs = true;
1863
1853
  }
1864
1854
  function renderComponentRoot(instance) {
1865
1855
  const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;
1866
1856
  let result;
1857
+ let fallthroughAttrs;
1867
1858
  const prev = setCurrentRenderingInstance(instance);
1868
1859
  try {
1869
- let fallthroughAttrs;
1870
1860
  if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {
1871
1861
  // withProxy is a proxy with a different `has` trap only for
1872
1862
  // runtime-compiled render functions using `with` block.
@@ -1895,95 +1885,57 @@ function renderComponentRoot(instance) {
1895
1885
  ? attrs
1896
1886
  : getFunctionalFallthrough(attrs);
1897
1887
  }
1898
- // attr merging
1899
- // in dev mode, comments are preserved, and it's possible for a template
1900
- // to have comments along side the root element which makes it a fragment
1901
- let root = result;
1902
- let setRoot = undefined;
1903
- if (false &&
1904
- result.patchFlag > 0 &&
1905
- result.patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) ;
1906
- if (fallthroughAttrs && inheritAttrs !== false) {
1907
- const keys = Object.keys(fallthroughAttrs);
1908
- const { shapeFlag } = root;
1909
- if (keys.length) {
1910
- if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1911
- if (propsOptions && keys.some(isModelListener)) {
1912
- // If a v-model listener (onUpdate:xxx) has a corresponding declared
1913
- // prop, it indicates this component expects to handle v-model and
1914
- // it should not fallthrough.
1915
- // related: #1543, #1643, #1989
1916
- fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
1917
- }
1918
- root = cloneVNode(root, fallthroughAttrs);
1919
- }
1920
- else if (false && !accessedAttrs && root.type !== Comment) ;
1921
- }
1922
- }
1923
- if (true &&
1924
- isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
1925
- vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
1926
- root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1927
- const { class: cls, style } = vnode.props || {};
1928
- if (cls || style) {
1929
- if (false && inheritAttrs === false) ;
1930
- root = cloneVNode(root, {
1931
- class: cls,
1932
- style: style
1933
- });
1934
- }
1935
- }
1936
- // inherit directives
1937
- if (vnode.dirs) {
1938
- if (false && !isElementRoot(root)) ;
1939
- root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
1940
- }
1941
- // inherit transition data
1942
- if (vnode.transition) {
1943
- if (false && !isElementRoot(root)) ;
1944
- root.transition = vnode.transition;
1945
- }
1946
- if (false && setRoot) ;
1947
- else {
1948
- result = root;
1949
- }
1950
1888
  }
1951
1889
  catch (err) {
1952
1890
  blockStack.length = 0;
1953
1891
  handleError(err, instance, 1 /* RENDER_FUNCTION */);
1954
1892
  result = createVNode(Comment);
1955
1893
  }
1894
+ // attr merging
1895
+ // in dev mode, comments are preserved, and it's possible for a template
1896
+ // to have comments along side the root element which makes it a fragment
1897
+ let root = result;
1898
+ if (fallthroughAttrs && inheritAttrs !== false) {
1899
+ const keys = Object.keys(fallthroughAttrs);
1900
+ const { shapeFlag } = root;
1901
+ if (keys.length) {
1902
+ if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1903
+ if (propsOptions && keys.some(isModelListener)) {
1904
+ // If a v-model listener (onUpdate:xxx) has a corresponding declared
1905
+ // prop, it indicates this component expects to handle v-model and
1906
+ // it should not fallthrough.
1907
+ // related: #1543, #1643, #1989
1908
+ fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
1909
+ }
1910
+ root = cloneVNode(root, fallthroughAttrs);
1911
+ }
1912
+ }
1913
+ }
1914
+ if (isCompatEnabled("INSTANCE_ATTRS_CLASS_STYLE" /* INSTANCE_ATTRS_CLASS_STYLE */, instance) &&
1915
+ vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */ &&
1916
+ root.shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {
1917
+ const { class: cls, style } = vnode.props || {};
1918
+ if (cls || style) {
1919
+ root = cloneVNode(root, {
1920
+ class: cls,
1921
+ style: style
1922
+ });
1923
+ }
1924
+ }
1925
+ // inherit directives
1926
+ if (vnode.dirs) {
1927
+ root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
1928
+ }
1929
+ // inherit transition data
1930
+ if (vnode.transition) {
1931
+ root.transition = vnode.transition;
1932
+ }
1933
+ {
1934
+ result = root;
1935
+ }
1956
1936
  setCurrentRenderingInstance(prev);
1957
1937
  return result;
1958
1938
  }
1959
- /**
1960
- * dev only
1961
- * In dev mode, template root level comments are rendered, which turns the
1962
- * template into a fragment root, but we need to locate the single element
1963
- * root for attrs and scope id processing.
1964
- */
1965
- const getChildRoot = (vnode) => {
1966
- const rawChildren = vnode.children;
1967
- const dynamicChildren = vnode.dynamicChildren;
1968
- const childRoot = filterSingleRoot(rawChildren);
1969
- if (!childRoot) {
1970
- return [vnode, undefined];
1971
- }
1972
- const index = rawChildren.indexOf(childRoot);
1973
- const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
1974
- const setRoot = (updatedRoot) => {
1975
- rawChildren[index] = updatedRoot;
1976
- if (dynamicChildren) {
1977
- if (dynamicIndex > -1) {
1978
- dynamicChildren[dynamicIndex] = updatedRoot;
1979
- }
1980
- else if (updatedRoot.patchFlag > 0) {
1981
- vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
1982
- }
1983
- }
1984
- };
1985
- return [normalizeVNode(childRoot), setRoot];
1986
- };
1987
1939
  function filterSingleRoot(children) {
1988
1940
  let singleRoot;
1989
1941
  for (let i = 0; i < children.length; i++) {
@@ -2024,11 +1976,6 @@ const filterModelListeners = (attrs, props) => {
2024
1976
  }
2025
1977
  return res;
2026
1978
  };
2027
- const isElementRoot = (vnode) => {
2028
- return (vnode.shapeFlag & (6 /* COMPONENT */ | 1 /* ELEMENT */) ||
2029
- vnode.type === Comment // potential v-if branch switch
2030
- );
2031
- };
2032
1979
  function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
2033
1980
  const { props: prevProps, children: prevChildren, component } = prevVNode;
2034
1981
  const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
@@ -2459,8 +2406,8 @@ function normalizeSuspenseChildren(vnode) {
2459
2406
  function normalizeSuspenseSlot(s) {
2460
2407
  let block;
2461
2408
  if (isFunction(s)) {
2462
- const isCompiledSlot = s._c;
2463
- if (isCompiledSlot) {
2409
+ const trackBlock = isBlockTreeEnabled && s._c;
2410
+ if (trackBlock) {
2464
2411
  // disableTracking: false
2465
2412
  // allow block tracking for compiled slots
2466
2413
  // (see ./componentRenderContext.ts)
@@ -2468,7 +2415,7 @@ function normalizeSuspenseSlot(s) {
2468
2415
  openBlock();
2469
2416
  }
2470
2417
  s = s();
2471
- if (isCompiledSlot) {
2418
+ if (trackBlock) {
2472
2419
  s._d = true;
2473
2420
  block = currentBlock;
2474
2421
  closeBlock();
@@ -4285,7 +4232,7 @@ function createCompatVue(createApp, createSingletonApp) {
4285
4232
  return vm;
4286
4233
  }
4287
4234
  }
4288
- Vue.version = "3.2.8";
4235
+ Vue.version = "3.2.12";
4289
4236
  Vue.config = singletonApp.config;
4290
4237
  Vue.use = (p, ...options) => {
4291
4238
  if (p && isFunction(p.install)) {
@@ -8383,7 +8330,6 @@ let postFlushIndex = 0;
8383
8330
  const resolvedPromise = Promise.resolve();
8384
8331
  let currentFlushPromise = null;
8385
8332
  let currentPreFlushParentJob = null;
8386
- const RECURSION_LIMIT = 100;
8387
8333
  function nextTick(fn) {
8388
8334
  const p = currentFlushPromise || resolvedPromise;
8389
8335
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
@@ -8501,11 +8447,17 @@ function flushJobs(seen) {
8501
8447
  // 2. If a component is unmounted during a parent component's update,
8502
8448
  // its update can be skipped.
8503
8449
  queue.sort((a, b) => getId(a) - getId(b));
8450
+ // conditional usage of checkRecursiveUpdate must be determined out of
8451
+ // try ... catch block since Rollup by default de-optimizes treeshaking
8452
+ // inside try-catch. This can leave all warning code unshaked. Although
8453
+ // they would get eventually shaken by a minifier like terser, some minifiers
8454
+ // would fail to do that (e.g. https://github.com/evanw/esbuild/issues/1610)
8455
+ const check = NOOP;
8504
8456
  try {
8505
8457
  for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
8506
8458
  const job = queue[flushIndex];
8507
8459
  if (job && job.active !== false) {
8508
- if (false && checkRecursiveUpdates(seen, job)) ;
8460
+ if (false && check(job)) ;
8509
8461
  // console.log(`running:`, job.id)
8510
8462
  callWithErrorHandling(job, null, 14 /* SCHEDULER */);
8511
8463
  }
@@ -8525,27 +8477,6 @@ function flushJobs(seen) {
8525
8477
  flushJobs(seen);
8526
8478
  }
8527
8479
  }
8528
- }
8529
- function checkRecursiveUpdates(seen, fn) {
8530
- if (!seen.has(fn)) {
8531
- seen.set(fn, 1);
8532
- }
8533
- else {
8534
- const count = seen.get(fn);
8535
- if (count > RECURSION_LIMIT) {
8536
- const instance = fn.ownerInstance;
8537
- const componentName = instance && getComponentName(instance.type);
8538
- warn(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. ` +
8539
- `This means you have a reactive effect that is mutating its own ` +
8540
- `dependencies and thus recursively triggering itself. Possible sources ` +
8541
- `include component template, render function, updated hook or ` +
8542
- `watcher source function.`);
8543
- return true;
8544
- }
8545
- else {
8546
- seen.set(fn, count + 1);
8547
- }
8548
- }
8549
8480
  }
8550
8481
 
8551
8482
  // Simple effect.
@@ -8823,7 +8754,7 @@ function defineExpose(exposed) {
8823
8754
  }
8824
8755
  /**
8825
8756
  * Vue `<script setup>` compiler macro for providing props default values when
8826
- * using type-based `defineProps` decalration.
8757
+ * using type-based `defineProps` declaration.
8827
8758
  *
8828
8759
  * Example usage:
8829
8760
  * ```ts
@@ -8978,7 +8909,7 @@ function isMemoSame(cached, memo) {
8978
8909
  }
8979
8910
 
8980
8911
  // Core API ------------------------------------------------------------------
8981
- const version = "3.2.8";
8912
+ const version = "3.2.12";
8982
8913
  const _ssrUtils = {
8983
8914
  createComponentInstance,
8984
8915
  setupComponent,
@@ -9115,19 +9046,13 @@ function patchClass(el, value, isSVG) {
9115
9046
 
9116
9047
  function patchStyle(el, prev, next) {
9117
9048
  const style = el.style;
9049
+ const currentDisplay = style.display;
9118
9050
  if (!next) {
9119
9051
  el.removeAttribute('style');
9120
9052
  }
9121
9053
  else if (isString(next)) {
9122
9054
  if (prev !== next) {
9123
- const current = style.display;
9124
9055
  style.cssText = next;
9125
- // indicates that the `display` of the element is controlled by `v-show`,
9126
- // so we always keep the current `display` value regardless of the `style` value,
9127
- // thus handing over control to `v-show`.
9128
- if ('_vod' in el) {
9129
- style.display = current;
9130
- }
9131
9056
  }
9132
9057
  }
9133
9058
  else {
@@ -9142,6 +9067,12 @@ function patchStyle(el, prev, next) {
9142
9067
  }
9143
9068
  }
9144
9069
  }
9070
+ // indicates that the `display` of the element is controlled by `v-show`,
9071
+ // so we always keep the current `display` value regardless of the `style` value,
9072
+ // thus handing over control to `v-show`.
9073
+ if ('_vod' in el) {
9074
+ style.display = currentDisplay;
9075
+ }
9145
9076
  }
9146
9077
  const importantRE = /\s*!important$/;
9147
9078
  function setStyle(style, name, val) {
@@ -9507,6 +9438,7 @@ class VueElement extends BaseClass {
9507
9438
  this._instance = null;
9508
9439
  this._connected = false;
9509
9440
  this._resolved = false;
9441
+ this._numberProps = null;
9510
9442
  if (this.shadowRoot && hydrate) {
9511
9443
  hydrate(this._createVNode(), this.shadowRoot);
9512
9444
  }
@@ -9518,18 +9450,17 @@ class VueElement extends BaseClass {
9518
9450
  this._setAttr(this.attributes[i].name);
9519
9451
  }
9520
9452
  // watch future attr changes
9521
- const observer = new MutationObserver(mutations => {
9453
+ new MutationObserver(mutations => {
9522
9454
  for (const m of mutations) {
9523
9455
  this._setAttr(m.attributeName);
9524
9456
  }
9525
- });
9526
- observer.observe(this, { attributes: true });
9457
+ }).observe(this, { attributes: true });
9527
9458
  }
9528
9459
  connectedCallback() {
9529
9460
  this._connected = true;
9530
9461
  if (!this._instance) {
9531
9462
  this._resolveDef();
9532
- render(this._createVNode(), this.shadowRoot);
9463
+ this._update();
9533
9464
  }
9534
9465
  }
9535
9466
  disconnectedCallback() {
@@ -9550,15 +9481,31 @@ class VueElement extends BaseClass {
9550
9481
  }
9551
9482
  const resolve = (def) => {
9552
9483
  this._resolved = true;
9484
+ const { props, styles } = def;
9485
+ const hasOptions = !isArray(props);
9486
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9487
+ // cast Number-type props set before resolve
9488
+ let numberProps;
9489
+ if (hasOptions) {
9490
+ for (const key in this._props) {
9491
+ const opt = props[key];
9492
+ if (opt === Number || (opt && opt.type === Number)) {
9493
+ this._props[key] = toNumber(this._props[key]);
9494
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
9495
+ }
9496
+ }
9497
+ }
9498
+ if (numberProps) {
9499
+ this._numberProps = numberProps;
9500
+ this._update();
9501
+ }
9553
9502
  // check if there are props set pre-upgrade or connect
9554
9503
  for (const key of Object.keys(this)) {
9555
9504
  if (key[0] !== '_') {
9556
9505
  this._setProp(key, this[key]);
9557
9506
  }
9558
9507
  }
9559
- const { props, styles } = def;
9560
9508
  // defining getter/setters on prototype
9561
- const rawKeys = props ? (isArray(props) ? props : Object.keys(props)) : [];
9562
9509
  for (const key of rawKeys.map(camelize)) {
9563
9510
  Object.defineProperty(this, key, {
9564
9511
  get() {
@@ -9580,7 +9527,11 @@ class VueElement extends BaseClass {
9580
9527
  }
9581
9528
  }
9582
9529
  _setAttr(key) {
9583
- this._setProp(camelize(key), toNumber(this.getAttribute(key)), false);
9530
+ let value = this.getAttribute(key);
9531
+ if (this._numberProps && this._numberProps[key]) {
9532
+ value = toNumber(value);
9533
+ }
9534
+ this._setProp(camelize(key), value, false);
9584
9535
  }
9585
9536
  /**
9586
9537
  * @internal
@@ -9595,7 +9546,7 @@ class VueElement extends BaseClass {
9595
9546
  if (val !== this._props[key]) {
9596
9547
  this._props[key] = val;
9597
9548
  if (this._instance) {
9598
- render(this._createVNode(), this.shadowRoot);
9549
+ this._update();
9599
9550
  }
9600
9551
  // reflect
9601
9552
  if (shouldReflect) {
@@ -9611,6 +9562,9 @@ class VueElement extends BaseClass {
9611
9562
  }
9612
9563
  }
9613
9564
  }
9565
+ _update() {
9566
+ render(this._createVNode(), this.shadowRoot);
9567
+ }
9614
9568
  _createVNode() {
9615
9569
  const vnode = createVNode(this._def, extend({}, this._props));
9616
9570
  if (!this._instance) {
@@ -11890,6 +11844,13 @@ function parseAttributes(context, type) {
11890
11844
  emitError(context, 3 /* END_TAG_WITH_ATTRIBUTES */);
11891
11845
  }
11892
11846
  const attr = parseAttribute(context, attributeNames);
11847
+ // Trim whitespace between class
11848
+ // https://github.com/vuejs/vue-next/issues/4251
11849
+ if (attr.type === 6 /* ATTRIBUTE */ &&
11850
+ attr.value &&
11851
+ attr.name === 'class') {
11852
+ attr.value.content = attr.value.content.replace(/\s+/g, ' ').trim();
11853
+ }
11893
11854
  if (type === 0 /* Start */) {
11894
11855
  props.push(attr);
11895
11856
  }
@@ -11952,8 +11913,11 @@ function parseAttribute(context, nameSet) {
11952
11913
  isStatic = false;
11953
11914
  if (!content.endsWith(']')) {
11954
11915
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
11916
+ content = content.substr(1);
11917
+ }
11918
+ else {
11919
+ content = content.substr(1, content.length - 2);
11955
11920
  }
11956
- content = content.substr(1, content.length - 2);
11957
11921
  }
11958
11922
  else if (isSlot) {
11959
11923
  // #1241 special case for v-slot: vuetify relies extensively on slot
@@ -13585,7 +13549,7 @@ function isReferencedIdentifier(id, parent, parentStack) {
13585
13549
  if (id.name === 'arguments') {
13586
13550
  return false;
13587
13551
  }
13588
- if (types.isReferenced(id, parent)) {
13552
+ if (isReferenced(id, parent)) {
13589
13553
  return true;
13590
13554
  }
13591
13555
  // babel's isReferenced check returns false for ids being assigned to, so we
@@ -13698,7 +13662,159 @@ const isFunctionType = (node) => {
13698
13662
  const isStaticProperty = (node) => node &&
13699
13663
  (node.type === 'ObjectProperty' || node.type === 'ObjectMethod') &&
13700
13664
  !node.computed;
13701
- const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
13665
+ const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
13666
+ /**
13667
+ * Copied from https://github.com/babel/babel/blob/main/packages/babel-types/src/validators/isReferenced.ts
13668
+ * To avoid runtime dependency on @babel/types (which includes process references)
13669
+ * This file should not change very often in babel but we may need to keep it
13670
+ * up-to-date from time to time.
13671
+ *
13672
+ * https://github.com/babel/babel/blob/main/LICENSE
13673
+ *
13674
+ */
13675
+ function isReferenced(node, parent, grandparent) {
13676
+ switch (parent.type) {
13677
+ // yes: PARENT[NODE]
13678
+ // yes: NODE.child
13679
+ // no: parent.NODE
13680
+ case 'MemberExpression':
13681
+ case 'OptionalMemberExpression':
13682
+ if (parent.property === node) {
13683
+ return !!parent.computed;
13684
+ }
13685
+ return parent.object === node;
13686
+ case 'JSXMemberExpression':
13687
+ return parent.object === node;
13688
+ // no: let NODE = init;
13689
+ // yes: let id = NODE;
13690
+ case 'VariableDeclarator':
13691
+ return parent.init === node;
13692
+ // yes: () => NODE
13693
+ // no: (NODE) => {}
13694
+ case 'ArrowFunctionExpression':
13695
+ return parent.body === node;
13696
+ // no: class { #NODE; }
13697
+ // no: class { get #NODE() {} }
13698
+ // no: class { #NODE() {} }
13699
+ // no: class { fn() { return this.#NODE; } }
13700
+ case 'PrivateName':
13701
+ return false;
13702
+ // no: class { NODE() {} }
13703
+ // yes: class { [NODE]() {} }
13704
+ // no: class { foo(NODE) {} }
13705
+ case 'ClassMethod':
13706
+ case 'ClassPrivateMethod':
13707
+ case 'ObjectMethod':
13708
+ if (parent.key === node) {
13709
+ return !!parent.computed;
13710
+ }
13711
+ return false;
13712
+ // yes: { [NODE]: "" }
13713
+ // no: { NODE: "" }
13714
+ // depends: { NODE }
13715
+ // depends: { key: NODE }
13716
+ case 'ObjectProperty':
13717
+ if (parent.key === node) {
13718
+ return !!parent.computed;
13719
+ }
13720
+ // parent.value === node
13721
+ return !grandparent || grandparent.type !== 'ObjectPattern';
13722
+ // no: class { NODE = value; }
13723
+ // yes: class { [NODE] = value; }
13724
+ // yes: class { key = NODE; }
13725
+ case 'ClassProperty':
13726
+ if (parent.key === node) {
13727
+ return !!parent.computed;
13728
+ }
13729
+ return true;
13730
+ case 'ClassPrivateProperty':
13731
+ return parent.key !== node;
13732
+ // no: class NODE {}
13733
+ // yes: class Foo extends NODE {}
13734
+ case 'ClassDeclaration':
13735
+ case 'ClassExpression':
13736
+ return parent.superClass === node;
13737
+ // yes: left = NODE;
13738
+ // no: NODE = right;
13739
+ case 'AssignmentExpression':
13740
+ return parent.right === node;
13741
+ // no: [NODE = foo] = [];
13742
+ // yes: [foo = NODE] = [];
13743
+ case 'AssignmentPattern':
13744
+ return parent.right === node;
13745
+ // no: NODE: for (;;) {}
13746
+ case 'LabeledStatement':
13747
+ return false;
13748
+ // no: try {} catch (NODE) {}
13749
+ case 'CatchClause':
13750
+ return false;
13751
+ // no: function foo(...NODE) {}
13752
+ case 'RestElement':
13753
+ return false;
13754
+ case 'BreakStatement':
13755
+ case 'ContinueStatement':
13756
+ return false;
13757
+ // no: function NODE() {}
13758
+ // no: function foo(NODE) {}
13759
+ case 'FunctionDeclaration':
13760
+ case 'FunctionExpression':
13761
+ return false;
13762
+ // no: export NODE from "foo";
13763
+ // no: export * as NODE from "foo";
13764
+ case 'ExportNamespaceSpecifier':
13765
+ case 'ExportDefaultSpecifier':
13766
+ return false;
13767
+ // no: export { foo as NODE };
13768
+ // yes: export { NODE as foo };
13769
+ // no: export { NODE as foo } from "foo";
13770
+ case 'ExportSpecifier':
13771
+ // @ts-expect-error
13772
+ if (grandparent === null || grandparent === void 0 ? void 0 : grandparent.source) {
13773
+ return false;
13774
+ }
13775
+ return parent.local === node;
13776
+ // no: import NODE from "foo";
13777
+ // no: import * as NODE from "foo";
13778
+ // no: import { NODE as foo } from "foo";
13779
+ // no: import { foo as NODE } from "foo";
13780
+ // no: import NODE from "bar";
13781
+ case 'ImportDefaultSpecifier':
13782
+ case 'ImportNamespaceSpecifier':
13783
+ case 'ImportSpecifier':
13784
+ return false;
13785
+ // no: import "foo" assert { NODE: "json" }
13786
+ case 'ImportAttribute':
13787
+ return false;
13788
+ // no: <div NODE="foo" />
13789
+ case 'JSXAttribute':
13790
+ return false;
13791
+ // no: [NODE] = [];
13792
+ // no: ({ NODE }) = [];
13793
+ case 'ObjectPattern':
13794
+ case 'ArrayPattern':
13795
+ return false;
13796
+ // no: new.NODE
13797
+ // no: NODE.target
13798
+ case 'MetaProperty':
13799
+ return false;
13800
+ // yes: type X = { somePropert: NODE }
13801
+ // no: type X = { NODE: OtherType }
13802
+ case 'ObjectTypeProperty':
13803
+ return parent.key !== node;
13804
+ // yes: enum X { Foo = NODE }
13805
+ // no: enum X { NODE }
13806
+ case 'TSEnumMember':
13807
+ return parent.id !== node;
13808
+ // yes: { [NODE]: value }
13809
+ // no: { NODE: value }
13810
+ case 'TSPropertySignature':
13811
+ if (parent.key === node) {
13812
+ return !!parent.computed;
13813
+ }
13814
+ return true;
13815
+ }
13816
+ return true;
13817
+ }
13702
13818
 
13703
13819
  const isLiteralWhitelisted = /*#__PURE__*/ makeMap('true,false,null,this');
13704
13820
  const transformExpression = (node, context) => {
@@ -13737,7 +13853,7 @@ function processExpression(node, context,
13737
13853
  // function params
13738
13854
  asParams = false,
13739
13855
  // v-on handler values may contain multiple statements
13740
- asRawStatements = false) {
13856
+ asRawStatements = false, localVars = Object.create(context.identifiers)) {
13741
13857
  if (!context.prefixIdentifiers || !node.content.trim()) {
13742
13858
  return node;
13743
13859
  }
@@ -13751,7 +13867,7 @@ asRawStatements = false) {
13751
13867
  const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
13752
13868
  // ({ x } = y)
13753
13869
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
13754
- if (type === "setup-const" /* SETUP_CONST */) {
13870
+ if (type === "setup-const" /* SETUP_CONST */ || localVars[raw]) {
13755
13871
  return raw;
13756
13872
  }
13757
13873
  else if (type === "setup-ref" /* SETUP_REF */) {
@@ -13775,7 +13891,7 @@ asRawStatements = false) {
13775
13891
  // x = y --> isRef(x) ? x.value = y : x = y
13776
13892
  const { right: rVal, operator } = parent;
13777
13893
  const rExp = rawExp.slice(rVal.start - 1, rVal.end - 1);
13778
- const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context));
13894
+ const rExpString = stringifyExpression(processExpression(createSimpleExpression(rExp, false), context, false, false, knownIds));
13779
13895
  return `${context.helperString(IS_REF)}(${raw})${context.isTS ? ` //@ts-ignore\n` : ``} ? ${raw}.value ${operator} ${rExpString} : ${raw}`;
13780
13896
  }
13781
13897
  else if (isUpdateArg) {
@@ -14956,7 +15072,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
14956
15072
  // acrtual ref instead.
14957
15073
  if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
14958
15074
  valueNode = createFunctionExpression(['_value', '_refs']);
14959
- valueNode.body = createBlockStatement(processInlineRef(context.bindingMetadata, value.content));
15075
+ valueNode.body = createBlockStatement(processInlineRef(context, value.content));
14960
15076
  }
14961
15077
  }
14962
15078
  // skip is on <component>, or is="vue:xxx"
@@ -15253,14 +15369,18 @@ function stringifyDynamicPropNames(props) {
15253
15369
  function isComponentTag(tag) {
15254
15370
  return tag[0].toLowerCase() + tag.slice(1) === 'component';
15255
15371
  }
15256
- function processInlineRef(bindings, raw) {
15372
+ function processInlineRef(context, raw) {
15257
15373
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
15258
- const type = bindings[raw];
15374
+ const { bindingMetadata, helperString } = context;
15375
+ const type = bindingMetadata[raw];
15259
15376
  if (type === "setup-ref" /* SETUP_REF */) {
15260
15377
  body.push(createSimpleExpression(`${raw}.value = _value`));
15261
15378
  }
15379
+ else if (type === "setup-maybe-ref" /* SETUP_MAYBE_REF */) {
15380
+ body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) && (${raw}.value = _value)`));
15381
+ }
15262
15382
  else if (type === "setup-let" /* SETUP_LET */) {
15263
- body.push(createSimpleExpression(`${raw} = _value`));
15383
+ body.push(createSimpleExpression(`${helperString(IS_REF)}(${raw}) ? ${raw}.value = _value : ${raw} = _value`));
15264
15384
  }
15265
15385
  return body;
15266
15386
  }
@@ -15337,7 +15457,7 @@ function processSlotOutlet(node, context) {
15337
15457
  };
15338
15458
  }
15339
15459
 
15340
- const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^\s*function(?:\s+[\w$]+)?\s*\(/;
15460
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
15341
15461
  const transformOn = (dir, node, context, augmentor) => {
15342
15462
  const { loc, modifiers, arg } = dir;
15343
15463
  if (!dir.exp && !modifiers.length) {
@@ -19004,4 +19124,4 @@ registerRuntimeCompiler(compileToFunction);
19004
19124
  const Vue = createCompatVue$1();
19005
19125
  Vue.compile = compileToFunction;
19006
19126
 
19007
- exports.default = Vue;
19127
+ module.exports = Vue;