@vue/runtime-dom 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.
@@ -1441,14 +1441,7 @@ var VueRuntimeDOM = (function (exports) {
1441
1441
  // Note: for a component to be eligible for HMR it also needs the __hmrId option
1442
1442
  // to be set so that its instances can be registered / removed.
1443
1443
  {
1444
- const globalObject = typeof global !== 'undefined'
1445
- ? global
1446
- : typeof self !== 'undefined'
1447
- ? self
1448
- : typeof window !== 'undefined'
1449
- ? window
1450
- : {};
1451
- globalObject.__VUE_HMR_RUNTIME__ = {
1444
+ getGlobalThis().__VUE_HMR_RUNTIME__ = {
1452
1445
  createRecord: tryWrap(createRecord),
1453
1446
  rerender: tryWrap(rerender),
1454
1447
  reload: tryWrap(reload)
@@ -1459,19 +1452,22 @@ var VueRuntimeDOM = (function (exports) {
1459
1452
  const id = instance.type.__hmrId;
1460
1453
  let record = map.get(id);
1461
1454
  if (!record) {
1462
- createRecord(id);
1455
+ createRecord(id, instance.type);
1463
1456
  record = map.get(id);
1464
1457
  }
1465
- record.add(instance);
1458
+ record.instances.add(instance);
1466
1459
  }
1467
1460
  function unregisterHMR(instance) {
1468
- map.get(instance.type.__hmrId).delete(instance);
1461
+ map.get(instance.type.__hmrId).instances.delete(instance);
1469
1462
  }
1470
- function createRecord(id) {
1463
+ function createRecord(id, initialDef) {
1471
1464
  if (map.has(id)) {
1472
1465
  return false;
1473
1466
  }
1474
- map.set(id, new Set());
1467
+ map.set(id, {
1468
+ initialDef: normalizeClassComponent(initialDef),
1469
+ instances: new Set()
1470
+ });
1475
1471
  return true;
1476
1472
  }
1477
1473
  function normalizeClassComponent(component) {
@@ -1482,7 +1478,9 @@ var VueRuntimeDOM = (function (exports) {
1482
1478
  if (!record) {
1483
1479
  return;
1484
1480
  }
1485
- [...record].forEach(instance => {
1481
+ // update initial record (for not-yet-rendered component)
1482
+ record.initialDef.render = newRender;
1483
+ [...record.instances].forEach(instance => {
1486
1484
  if (newRender) {
1487
1485
  instance.render = newRender;
1488
1486
  normalizeClassComponent(instance.type).render = newRender;
@@ -1499,17 +1497,16 @@ var VueRuntimeDOM = (function (exports) {
1499
1497
  if (!record)
1500
1498
  return;
1501
1499
  newComp = normalizeClassComponent(newComp);
1500
+ // update initial def (for not-yet-rendered components)
1501
+ updateComponentDef(record.initialDef, newComp);
1502
1502
  // create a snapshot which avoids the set being mutated during updates
1503
- const instances = [...record];
1503
+ const instances = [...record.instances];
1504
1504
  for (const instance of instances) {
1505
1505
  const oldComp = normalizeClassComponent(instance.type);
1506
1506
  if (!hmrDirtyComponents.has(oldComp)) {
1507
1507
  // 1. Update existing comp definition to match new one
1508
- extend(oldComp, newComp);
1509
- for (const key in oldComp) {
1510
- if (key !== '__file' && !(key in newComp)) {
1511
- delete oldComp[key];
1512
- }
1508
+ if (oldComp !== record.initialDef) {
1509
+ updateComponentDef(oldComp, newComp);
1513
1510
  }
1514
1511
  // 2. mark definition dirty. This forces the renderer to replace the
1515
1512
  // component on patch.
@@ -1555,6 +1552,14 @@ var VueRuntimeDOM = (function (exports) {
1555
1552
  }
1556
1553
  });
1557
1554
  }
1555
+ function updateComponentDef(oldComp, newComp) {
1556
+ extend(oldComp, newComp);
1557
+ for (const key in oldComp) {
1558
+ if (key !== '__file' && !(key in newComp)) {
1559
+ delete oldComp[key];
1560
+ }
1561
+ }
1562
+ }
1558
1563
  function tryWrap(fn) {
1559
1564
  return (id, arg) => {
1560
1565
  try {
@@ -1590,6 +1595,11 @@ var VueRuntimeDOM = (function (exports) {
1590
1595
  replay.push((newHook) => {
1591
1596
  setDevtoolsHook(newHook, target);
1592
1597
  });
1598
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1599
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1600
+ setTimeout(() => {
1601
+ buffer = [];
1602
+ }, 3000);
1593
1603
  }
1594
1604
  }
1595
1605
  function devtoolsInitApp(app, version) {
@@ -7714,9 +7724,11 @@ var VueRuntimeDOM = (function (exports) {
7714
7724
  function finishComponentSetup(instance, isSSR, skipOptions) {
7715
7725
  const Component = instance.type;
7716
7726
  // template / render function normalization
7727
+ // could be already set when returned from setup()
7717
7728
  if (!instance.render) {
7718
- // could be set from setup()
7719
- if (compile && !Component.render) {
7729
+ // only do on-the-fly compile if not in SSR - SSR on-the-fly compliation
7730
+ // is done by server-renderer
7731
+ if (!isSSR && compile && !Component.render) {
7720
7732
  const template = Component.template;
7721
7733
  if (template) {
7722
7734
  {
@@ -8606,15 +8618,21 @@ var VueRuntimeDOM = (function (exports) {
8606
8618
  * only.
8607
8619
  * @internal
8608
8620
  */
8609
- function mergeDefaults(
8610
- // the base props is compiler-generated and guaranteed to be in this shape.
8611
- props, defaults) {
8621
+ function mergeDefaults(raw, defaults) {
8622
+ const props = isArray(raw)
8623
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8624
+ : raw;
8612
8625
  for (const key in defaults) {
8613
- const val = props[key];
8614
- if (val) {
8615
- val.default = defaults[key];
8626
+ const opt = props[key];
8627
+ if (opt) {
8628
+ if (isArray(opt) || isFunction(opt)) {
8629
+ props[key] = { type: opt, default: defaults[key] };
8630
+ }
8631
+ else {
8632
+ opt.default = defaults[key];
8633
+ }
8616
8634
  }
8617
- else if (val === null) {
8635
+ else if (opt === null) {
8618
8636
  props[key] = { default: defaults[key] };
8619
8637
  }
8620
8638
  else {
@@ -8623,6 +8641,23 @@ var VueRuntimeDOM = (function (exports) {
8623
8641
  }
8624
8642
  return props;
8625
8643
  }
8644
+ /**
8645
+ * Used to create a proxy for the rest element when destructuring props with
8646
+ * defineProps().
8647
+ * @internal
8648
+ */
8649
+ function createPropsRestProxy(props, excludedKeys) {
8650
+ const ret = {};
8651
+ for (const key in props) {
8652
+ if (!excludedKeys.includes(key)) {
8653
+ Object.defineProperty(ret, key, {
8654
+ enumerable: true,
8655
+ get: () => props[key]
8656
+ });
8657
+ }
8658
+ }
8659
+ return ret;
8660
+ }
8626
8661
  /**
8627
8662
  * `<script setup>` helper for persisting the current instance context over
8628
8663
  * async/await flows.
@@ -8910,7 +8945,7 @@ var VueRuntimeDOM = (function (exports) {
8910
8945
  }
8911
8946
 
8912
8947
  // Core API ------------------------------------------------------------------
8913
- const version = "3.2.16";
8948
+ const version = "3.2.20";
8914
8949
  /**
8915
8950
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8916
8951
  * @internal
@@ -10520,7 +10555,11 @@ var VueRuntimeDOM = (function (exports) {
10520
10555
  warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
10521
10556
  }
10522
10557
  return container;
10523
- }
10558
+ }
10559
+ /**
10560
+ * @internal
10561
+ */
10562
+ const initDirectivesForSSR = NOOP;
10524
10563
 
10525
10564
  exports.BaseTransition = BaseTransition;
10526
10565
  exports.Comment = Comment;
@@ -10548,6 +10587,7 @@ var VueRuntimeDOM = (function (exports) {
10548
10587
  exports.createElementBlock = createElementBlock;
10549
10588
  exports.createElementVNode = createBaseVNode;
10550
10589
  exports.createHydrationRenderer = createHydrationRenderer;
10590
+ exports.createPropsRestProxy = createPropsRestProxy;
10551
10591
  exports.createRenderer = createRenderer;
10552
10592
  exports.createSSRApp = createSSRApp;
10553
10593
  exports.createSlots = createSlots;
@@ -10572,6 +10612,7 @@ var VueRuntimeDOM = (function (exports) {
10572
10612
  exports.handleError = handleError;
10573
10613
  exports.hydrate = hydrate;
10574
10614
  exports.initCustomFormatter = initCustomFormatter;
10615
+ exports.initDirectivesForSSR = initDirectivesForSSR;
10575
10616
  exports.inject = inject;
10576
10617
  exports.isMemoSame = isMemoSame;
10577
10618
  exports.isProxy = isProxy;