vue 3.2.19 → 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.
@@ -1527,19 +1527,22 @@ var Vue = (function (exports) {
1527
1527
  const id = instance.type.__hmrId;
1528
1528
  let record = map.get(id);
1529
1529
  if (!record) {
1530
- createRecord(id);
1530
+ createRecord(id, instance.type);
1531
1531
  record = map.get(id);
1532
1532
  }
1533
- record.add(instance);
1533
+ record.instances.add(instance);
1534
1534
  }
1535
1535
  function unregisterHMR(instance) {
1536
- map.get(instance.type.__hmrId).delete(instance);
1536
+ map.get(instance.type.__hmrId).instances.delete(instance);
1537
1537
  }
1538
- function createRecord(id) {
1538
+ function createRecord(id, initialDef) {
1539
1539
  if (map.has(id)) {
1540
1540
  return false;
1541
1541
  }
1542
- map.set(id, new Set());
1542
+ map.set(id, {
1543
+ initialDef: normalizeClassComponent(initialDef),
1544
+ instances: new Set()
1545
+ });
1543
1546
  return true;
1544
1547
  }
1545
1548
  function normalizeClassComponent(component) {
@@ -1550,7 +1553,9 @@ var Vue = (function (exports) {
1550
1553
  if (!record) {
1551
1554
  return;
1552
1555
  }
1553
- [...record].forEach(instance => {
1556
+ // update initial record (for not-yet-rendered component)
1557
+ record.initialDef.render = newRender;
1558
+ [...record.instances].forEach(instance => {
1554
1559
  if (newRender) {
1555
1560
  instance.render = newRender;
1556
1561
  normalizeClassComponent(instance.type).render = newRender;
@@ -1567,17 +1572,16 @@ var Vue = (function (exports) {
1567
1572
  if (!record)
1568
1573
  return;
1569
1574
  newComp = normalizeClassComponent(newComp);
1575
+ // update initial def (for not-yet-rendered components)
1576
+ updateComponentDef(record.initialDef, newComp);
1570
1577
  // create a snapshot which avoids the set being mutated during updates
1571
- const instances = [...record];
1578
+ const instances = [...record.instances];
1572
1579
  for (const instance of instances) {
1573
1580
  const oldComp = normalizeClassComponent(instance.type);
1574
1581
  if (!hmrDirtyComponents.has(oldComp)) {
1575
1582
  // 1. Update existing comp definition to match new one
1576
- extend(oldComp, newComp);
1577
- for (const key in oldComp) {
1578
- if (key !== '__file' && !(key in newComp)) {
1579
- delete oldComp[key];
1580
- }
1583
+ if (oldComp !== record.initialDef) {
1584
+ updateComponentDef(oldComp, newComp);
1581
1585
  }
1582
1586
  // 2. mark definition dirty. This forces the renderer to replace the
1583
1587
  // component on patch.
@@ -1623,6 +1627,14 @@ var Vue = (function (exports) {
1623
1627
  }
1624
1628
  });
1625
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
+ }
1626
1638
  function tryWrap(fn) {
1627
1639
  return (id, arg) => {
1628
1640
  try {
@@ -1658,6 +1670,11 @@ var Vue = (function (exports) {
1658
1670
  replay.push((newHook) => {
1659
1671
  setDevtoolsHook(newHook, target);
1660
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);
1661
1678
  }
1662
1679
  }
1663
1680
  function devtoolsInitApp(app, version) {
@@ -8676,15 +8693,21 @@ var Vue = (function (exports) {
8676
8693
  * only.
8677
8694
  * @internal
8678
8695
  */
8679
- function mergeDefaults(
8680
- // the base props is compiler-generated and guaranteed to be in this shape.
8681
- props, defaults) {
8696
+ function mergeDefaults(raw, defaults) {
8697
+ const props = isArray(raw)
8698
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8699
+ : raw;
8682
8700
  for (const key in defaults) {
8683
- const val = props[key];
8684
- if (val) {
8685
- 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
+ }
8686
8709
  }
8687
- else if (val === null) {
8710
+ else if (opt === null) {
8688
8711
  props[key] = { default: defaults[key] };
8689
8712
  }
8690
8713
  else {
@@ -8693,6 +8716,23 @@ var Vue = (function (exports) {
8693
8716
  }
8694
8717
  return props;
8695
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
+ }
8696
8736
  /**
8697
8737
  * `<script setup>` helper for persisting the current instance context over
8698
8738
  * async/await flows.
@@ -8980,7 +9020,7 @@ var Vue = (function (exports) {
8980
9020
  }
8981
9021
 
8982
9022
  // Core API ------------------------------------------------------------------
8983
- const version = "3.2.19";
9023
+ const version = "3.2.20";
8984
9024
  /**
8985
9025
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8986
9026
  * @internal
@@ -11006,7 +11046,7 @@ var Vue = (function (exports) {
11006
11046
  const isMemberExpression = isMemberExpressionBrowser
11007
11047
  ;
11008
11048
  function getInnerRange(loc, offset, length) {
11009
- const source = loc.source.substr(offset, length);
11049
+ const source = loc.source.slice(offset, offset + length);
11010
11050
  const newLoc = {
11011
11051
  source,
11012
11052
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -11833,10 +11873,10 @@ var Vue = (function (exports) {
11833
11873
  isStatic = false;
11834
11874
  if (!content.endsWith(']')) {
11835
11875
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
11836
- content = content.substr(1);
11876
+ content = content.slice(1);
11837
11877
  }
11838
11878
  else {
11839
- content = content.substr(1, content.length - 2);
11879
+ content = content.slice(1, content.length - 1);
11840
11880
  }
11841
11881
  }
11842
11882
  else if (isSlot) {
@@ -11862,7 +11902,7 @@ var Vue = (function (exports) {
11862
11902
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
11863
11903
  valueLoc.source = valueLoc.source.slice(1, -1);
11864
11904
  }
11865
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
11905
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
11866
11906
  if (isPropShorthand)
11867
11907
  modifiers.push('prop');
11868
11908
  return {
@@ -12072,7 +12112,7 @@ var Vue = (function (exports) {
12072
12112
  }
12073
12113
  function startsWithEndTagOpen(source, tag) {
12074
12114
  return (startsWith(source, '</') &&
12075
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
12115
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
12076
12116
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
12077
12117
  }
12078
12118
 
@@ -15469,6 +15509,7 @@ var Vue = (function (exports) {
15469
15509
  exports.createElementBlock = createElementBlock;
15470
15510
  exports.createElementVNode = createBaseVNode;
15471
15511
  exports.createHydrationRenderer = createHydrationRenderer;
15512
+ exports.createPropsRestProxy = createPropsRestProxy;
15472
15513
  exports.createRenderer = createRenderer;
15473
15514
  exports.createSSRApp = createSSRApp;
15474
15515
  exports.createSlots = createSlots;