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.
@@ -1438,14 +1438,7 @@ const hmrDirtyComponents = new Set();
1438
1438
  // Note: for a component to be eligible for HMR it also needs the __hmrId option
1439
1439
  // to be set so that its instances can be registered / removed.
1440
1440
  {
1441
- const globalObject = typeof global !== 'undefined'
1442
- ? global
1443
- : typeof self !== 'undefined'
1444
- ? self
1445
- : typeof window !== 'undefined'
1446
- ? window
1447
- : {};
1448
- globalObject.__VUE_HMR_RUNTIME__ = {
1441
+ getGlobalThis().__VUE_HMR_RUNTIME__ = {
1449
1442
  createRecord: tryWrap(createRecord),
1450
1443
  rerender: tryWrap(rerender),
1451
1444
  reload: tryWrap(reload)
@@ -1456,19 +1449,22 @@ function registerHMR(instance) {
1456
1449
  const id = instance.type.__hmrId;
1457
1450
  let record = map.get(id);
1458
1451
  if (!record) {
1459
- createRecord(id);
1452
+ createRecord(id, instance.type);
1460
1453
  record = map.get(id);
1461
1454
  }
1462
- record.add(instance);
1455
+ record.instances.add(instance);
1463
1456
  }
1464
1457
  function unregisterHMR(instance) {
1465
- map.get(instance.type.__hmrId).delete(instance);
1458
+ map.get(instance.type.__hmrId).instances.delete(instance);
1466
1459
  }
1467
- function createRecord(id) {
1460
+ function createRecord(id, initialDef) {
1468
1461
  if (map.has(id)) {
1469
1462
  return false;
1470
1463
  }
1471
- map.set(id, new Set());
1464
+ map.set(id, {
1465
+ initialDef: normalizeClassComponent(initialDef),
1466
+ instances: new Set()
1467
+ });
1472
1468
  return true;
1473
1469
  }
1474
1470
  function normalizeClassComponent(component) {
@@ -1479,7 +1475,9 @@ function rerender(id, newRender) {
1479
1475
  if (!record) {
1480
1476
  return;
1481
1477
  }
1482
- [...record].forEach(instance => {
1478
+ // update initial record (for not-yet-rendered component)
1479
+ record.initialDef.render = newRender;
1480
+ [...record.instances].forEach(instance => {
1483
1481
  if (newRender) {
1484
1482
  instance.render = newRender;
1485
1483
  normalizeClassComponent(instance.type).render = newRender;
@@ -1496,17 +1494,16 @@ function reload(id, newComp) {
1496
1494
  if (!record)
1497
1495
  return;
1498
1496
  newComp = normalizeClassComponent(newComp);
1497
+ // update initial def (for not-yet-rendered components)
1498
+ updateComponentDef(record.initialDef, newComp);
1499
1499
  // create a snapshot which avoids the set being mutated during updates
1500
- const instances = [...record];
1500
+ const instances = [...record.instances];
1501
1501
  for (const instance of instances) {
1502
1502
  const oldComp = normalizeClassComponent(instance.type);
1503
1503
  if (!hmrDirtyComponents.has(oldComp)) {
1504
1504
  // 1. Update existing comp definition to match new one
1505
- extend(oldComp, newComp);
1506
- for (const key in oldComp) {
1507
- if (key !== '__file' && !(key in newComp)) {
1508
- delete oldComp[key];
1509
- }
1505
+ if (oldComp !== record.initialDef) {
1506
+ updateComponentDef(oldComp, newComp);
1510
1507
  }
1511
1508
  // 2. mark definition dirty. This forces the renderer to replace the
1512
1509
  // component on patch.
@@ -1552,6 +1549,14 @@ function reload(id, newComp) {
1552
1549
  }
1553
1550
  });
1554
1551
  }
1552
+ function updateComponentDef(oldComp, newComp) {
1553
+ extend(oldComp, newComp);
1554
+ for (const key in oldComp) {
1555
+ if (key !== '__file' && !(key in newComp)) {
1556
+ delete oldComp[key];
1557
+ }
1558
+ }
1559
+ }
1555
1560
  function tryWrap(fn) {
1556
1561
  return (id, arg) => {
1557
1562
  try {
@@ -1588,6 +1593,11 @@ function setDevtoolsHook(hook, target) {
1588
1593
  replay.push((newHook) => {
1589
1594
  setDevtoolsHook(newHook, target);
1590
1595
  });
1596
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1597
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1598
+ setTimeout(() => {
1599
+ buffer = [];
1600
+ }, 3000);
1591
1601
  }
1592
1602
  }
1593
1603
  function devtoolsInitApp(app, version) {
@@ -7712,9 +7722,11 @@ const isRuntimeOnly = () => !compile;
7712
7722
  function finishComponentSetup(instance, isSSR, skipOptions) {
7713
7723
  const Component = instance.type;
7714
7724
  // template / render function normalization
7725
+ // could be already set when returned from setup()
7715
7726
  if (!instance.render) {
7716
- // could be set from setup()
7717
- if (compile && !Component.render) {
7727
+ // only do on-the-fly compile if not in SSR - SSR on-the-fly compliation
7728
+ // is done by server-renderer
7729
+ if (!isSSR && compile && !Component.render) {
7718
7730
  const template = Component.template;
7719
7731
  if (template) {
7720
7732
  {
@@ -8604,15 +8616,21 @@ function getContext() {
8604
8616
  * only.
8605
8617
  * @internal
8606
8618
  */
8607
- function mergeDefaults(
8608
- // the base props is compiler-generated and guaranteed to be in this shape.
8609
- props, defaults) {
8619
+ function mergeDefaults(raw, defaults) {
8620
+ const props = isArray(raw)
8621
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8622
+ : raw;
8610
8623
  for (const key in defaults) {
8611
- const val = props[key];
8612
- if (val) {
8613
- val.default = defaults[key];
8624
+ const opt = props[key];
8625
+ if (opt) {
8626
+ if (isArray(opt) || isFunction(opt)) {
8627
+ props[key] = { type: opt, default: defaults[key] };
8628
+ }
8629
+ else {
8630
+ opt.default = defaults[key];
8631
+ }
8614
8632
  }
8615
- else if (val === null) {
8633
+ else if (opt === null) {
8616
8634
  props[key] = { default: defaults[key] };
8617
8635
  }
8618
8636
  else {
@@ -8621,6 +8639,23 @@ props, defaults) {
8621
8639
  }
8622
8640
  return props;
8623
8641
  }
8642
+ /**
8643
+ * Used to create a proxy for the rest element when destructuring props with
8644
+ * defineProps().
8645
+ * @internal
8646
+ */
8647
+ function createPropsRestProxy(props, excludedKeys) {
8648
+ const ret = {};
8649
+ for (const key in props) {
8650
+ if (!excludedKeys.includes(key)) {
8651
+ Object.defineProperty(ret, key, {
8652
+ enumerable: true,
8653
+ get: () => props[key]
8654
+ });
8655
+ }
8656
+ }
8657
+ return ret;
8658
+ }
8624
8659
  /**
8625
8660
  * `<script setup>` helper for persisting the current instance context over
8626
8661
  * async/await flows.
@@ -8913,7 +8948,7 @@ function isMemoSame(cached, memo) {
8913
8948
  }
8914
8949
 
8915
8950
  // Core API ------------------------------------------------------------------
8916
- const version = "3.2.16";
8951
+ const version = "3.2.20";
8917
8952
  /**
8918
8953
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8919
8954
  * @internal
@@ -10535,7 +10570,11 @@ function normalizeContainer(container) {
10535
10570
  warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
10536
10571
  }
10537
10572
  return container;
10538
- }
10573
+ }
10574
+ /**
10575
+ * @internal
10576
+ */
10577
+ const initDirectivesForSSR = NOOP;
10539
10578
 
10540
10579
  function initDev() {
10541
10580
  {
@@ -10559,4 +10598,4 @@ const compile$1 = () => {
10559
10598
  }
10560
10599
  };
10561
10600
 
10562
- export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compile$1 as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
10601
+ export { BaseTransition, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compile$1 as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };