vue 3.2.16 → 3.2.20

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.
@@ -1516,14 +1516,7 @@ var Vue = (function (exports) {
1516
1516
  // Note: for a component to be eligible for HMR it also needs the __hmrId option
1517
1517
  // to be set so that its instances can be registered / removed.
1518
1518
  {
1519
- const globalObject = typeof global !== 'undefined'
1520
- ? global
1521
- : typeof self !== 'undefined'
1522
- ? self
1523
- : typeof window !== 'undefined'
1524
- ? window
1525
- : {};
1526
- globalObject.__VUE_HMR_RUNTIME__ = {
1519
+ getGlobalThis().__VUE_HMR_RUNTIME__ = {
1527
1520
  createRecord: tryWrap(createRecord),
1528
1521
  rerender: tryWrap(rerender),
1529
1522
  reload: tryWrap(reload)
@@ -1534,19 +1527,22 @@ var Vue = (function (exports) {
1534
1527
  const id = instance.type.__hmrId;
1535
1528
  let record = map.get(id);
1536
1529
  if (!record) {
1537
- createRecord(id);
1530
+ createRecord(id, instance.type);
1538
1531
  record = map.get(id);
1539
1532
  }
1540
- record.add(instance);
1533
+ record.instances.add(instance);
1541
1534
  }
1542
1535
  function unregisterHMR(instance) {
1543
- map.get(instance.type.__hmrId).delete(instance);
1536
+ map.get(instance.type.__hmrId).instances.delete(instance);
1544
1537
  }
1545
- function createRecord(id) {
1538
+ function createRecord(id, initialDef) {
1546
1539
  if (map.has(id)) {
1547
1540
  return false;
1548
1541
  }
1549
- map.set(id, new Set());
1542
+ map.set(id, {
1543
+ initialDef: normalizeClassComponent(initialDef),
1544
+ instances: new Set()
1545
+ });
1550
1546
  return true;
1551
1547
  }
1552
1548
  function normalizeClassComponent(component) {
@@ -1557,7 +1553,9 @@ var Vue = (function (exports) {
1557
1553
  if (!record) {
1558
1554
  return;
1559
1555
  }
1560
- [...record].forEach(instance => {
1556
+ // update initial record (for not-yet-rendered component)
1557
+ record.initialDef.render = newRender;
1558
+ [...record.instances].forEach(instance => {
1561
1559
  if (newRender) {
1562
1560
  instance.render = newRender;
1563
1561
  normalizeClassComponent(instance.type).render = newRender;
@@ -1574,17 +1572,16 @@ var Vue = (function (exports) {
1574
1572
  if (!record)
1575
1573
  return;
1576
1574
  newComp = normalizeClassComponent(newComp);
1575
+ // update initial def (for not-yet-rendered components)
1576
+ updateComponentDef(record.initialDef, newComp);
1577
1577
  // create a snapshot which avoids the set being mutated during updates
1578
- const instances = [...record];
1578
+ const instances = [...record.instances];
1579
1579
  for (const instance of instances) {
1580
1580
  const oldComp = normalizeClassComponent(instance.type);
1581
1581
  if (!hmrDirtyComponents.has(oldComp)) {
1582
1582
  // 1. Update existing comp definition to match new one
1583
- extend(oldComp, newComp);
1584
- for (const key in oldComp) {
1585
- if (key !== '__file' && !(key in newComp)) {
1586
- delete oldComp[key];
1587
- }
1583
+ if (oldComp !== record.initialDef) {
1584
+ updateComponentDef(oldComp, newComp);
1588
1585
  }
1589
1586
  // 2. mark definition dirty. This forces the renderer to replace the
1590
1587
  // component on patch.
@@ -1630,6 +1627,14 @@ var Vue = (function (exports) {
1630
1627
  }
1631
1628
  });
1632
1629
  }
1630
+ function updateComponentDef(oldComp, newComp) {
1631
+ extend(oldComp, newComp);
1632
+ for (const key in oldComp) {
1633
+ if (key !== '__file' && !(key in newComp)) {
1634
+ delete oldComp[key];
1635
+ }
1636
+ }
1637
+ }
1633
1638
  function tryWrap(fn) {
1634
1639
  return (id, arg) => {
1635
1640
  try {
@@ -1665,6 +1670,11 @@ var Vue = (function (exports) {
1665
1670
  replay.push((newHook) => {
1666
1671
  setDevtoolsHook(newHook, target);
1667
1672
  });
1673
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1674
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1675
+ setTimeout(() => {
1676
+ buffer = [];
1677
+ }, 3000);
1668
1678
  }
1669
1679
  }
1670
1680
  function devtoolsInitApp(app, version) {
@@ -7789,9 +7799,11 @@ var Vue = (function (exports) {
7789
7799
  function finishComponentSetup(instance, isSSR, skipOptions) {
7790
7800
  const Component = instance.type;
7791
7801
  // template / render function normalization
7802
+ // could be already set when returned from setup()
7792
7803
  if (!instance.render) {
7793
- // could be set from setup()
7794
- if (compile && !Component.render) {
7804
+ // only do on-the-fly compile if not in SSR - SSR on-the-fly compliation
7805
+ // is done by server-renderer
7806
+ if (!isSSR && compile && !Component.render) {
7795
7807
  const template = Component.template;
7796
7808
  if (template) {
7797
7809
  {
@@ -8681,15 +8693,21 @@ var Vue = (function (exports) {
8681
8693
  * only.
8682
8694
  * @internal
8683
8695
  */
8684
- function mergeDefaults(
8685
- // the base props is compiler-generated and guaranteed to be in this shape.
8686
- props, defaults) {
8696
+ function mergeDefaults(raw, defaults) {
8697
+ const props = isArray(raw)
8698
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8699
+ : raw;
8687
8700
  for (const key in defaults) {
8688
- const val = props[key];
8689
- if (val) {
8690
- val.default = defaults[key];
8701
+ const opt = props[key];
8702
+ if (opt) {
8703
+ if (isArray(opt) || isFunction(opt)) {
8704
+ props[key] = { type: opt, default: defaults[key] };
8705
+ }
8706
+ else {
8707
+ opt.default = defaults[key];
8708
+ }
8691
8709
  }
8692
- else if (val === null) {
8710
+ else if (opt === null) {
8693
8711
  props[key] = { default: defaults[key] };
8694
8712
  }
8695
8713
  else {
@@ -8698,6 +8716,23 @@ var Vue = (function (exports) {
8698
8716
  }
8699
8717
  return props;
8700
8718
  }
8719
+ /**
8720
+ * Used to create a proxy for the rest element when destructuring props with
8721
+ * defineProps().
8722
+ * @internal
8723
+ */
8724
+ function createPropsRestProxy(props, excludedKeys) {
8725
+ const ret = {};
8726
+ for (const key in props) {
8727
+ if (!excludedKeys.includes(key)) {
8728
+ Object.defineProperty(ret, key, {
8729
+ enumerable: true,
8730
+ get: () => props[key]
8731
+ });
8732
+ }
8733
+ }
8734
+ return ret;
8735
+ }
8701
8736
  /**
8702
8737
  * `<script setup>` helper for persisting the current instance context over
8703
8738
  * async/await flows.
@@ -8985,7 +9020,7 @@ var Vue = (function (exports) {
8985
9020
  }
8986
9021
 
8987
9022
  // Core API ------------------------------------------------------------------
8988
- const version = "3.2.16";
9023
+ const version = "3.2.20";
8989
9024
  /**
8990
9025
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8991
9026
  * @internal
@@ -10595,7 +10630,11 @@ var Vue = (function (exports) {
10595
10630
  warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
10596
10631
  }
10597
10632
  return container;
10598
- }
10633
+ }
10634
+ /**
10635
+ * @internal
10636
+ */
10637
+ const initDirectivesForSSR = NOOP;
10599
10638
 
10600
10639
  function initDev() {
10601
10640
  {
@@ -11007,7 +11046,7 @@ var Vue = (function (exports) {
11007
11046
  const isMemberExpression = isMemberExpressionBrowser
11008
11047
  ;
11009
11048
  function getInnerRange(loc, offset, length) {
11010
- const source = loc.source.substr(offset, length);
11049
+ const source = loc.source.slice(offset, offset + length);
11011
11050
  const newLoc = {
11012
11051
  source,
11013
11052
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -11834,10 +11873,10 @@ var Vue = (function (exports) {
11834
11873
  isStatic = false;
11835
11874
  if (!content.endsWith(']')) {
11836
11875
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
11837
- content = content.substr(1);
11876
+ content = content.slice(1);
11838
11877
  }
11839
11878
  else {
11840
- content = content.substr(1, content.length - 2);
11879
+ content = content.slice(1, content.length - 1);
11841
11880
  }
11842
11881
  }
11843
11882
  else if (isSlot) {
@@ -11863,7 +11902,7 @@ var Vue = (function (exports) {
11863
11902
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
11864
11903
  valueLoc.source = valueLoc.source.slice(1, -1);
11865
11904
  }
11866
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
11905
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
11867
11906
  if (isPropShorthand)
11868
11907
  modifiers.push('prop');
11869
11908
  return {
@@ -12073,7 +12112,7 @@ var Vue = (function (exports) {
12073
12112
  }
12074
12113
  function startsWithEndTagOpen(source, tag) {
12075
12114
  return (startsWith(source, '</') &&
12076
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
12115
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
12077
12116
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
12078
12117
  }
12079
12118
 
@@ -15470,6 +15509,7 @@ var Vue = (function (exports) {
15470
15509
  exports.createElementBlock = createElementBlock;
15471
15510
  exports.createElementVNode = createBaseVNode;
15472
15511
  exports.createHydrationRenderer = createHydrationRenderer;
15512
+ exports.createPropsRestProxy = createPropsRestProxy;
15473
15513
  exports.createRenderer = createRenderer;
15474
15514
  exports.createSSRApp = createSSRApp;
15475
15515
  exports.createSlots = createSlots;
@@ -15494,6 +15534,7 @@ var Vue = (function (exports) {
15494
15534
  exports.handleError = handleError;
15495
15535
  exports.hydrate = hydrate;
15496
15536
  exports.initCustomFormatter = initCustomFormatter;
15537
+ exports.initDirectivesForSSR = initDirectivesForSSR;
15497
15538
  exports.inject = inject;
15498
15539
  exports.isMemoSame = isMemoSame;
15499
15540
  exports.isProxy = isProxy;