vue 3.2.18 → 3.2.22

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 {
@@ -1637,27 +1649,52 @@ var Vue = (function (exports) {
1637
1649
  }
1638
1650
 
1639
1651
  let buffer = [];
1652
+ let devtoolsNotInstalled = false;
1640
1653
  function emit(event, ...args) {
1641
1654
  if (exports.devtools) {
1642
1655
  exports.devtools.emit(event, ...args);
1643
1656
  }
1644
- else {
1657
+ else if (!devtoolsNotInstalled) {
1645
1658
  buffer.push({ event, args });
1646
1659
  }
1647
1660
  }
1648
1661
  function setDevtoolsHook(hook, target) {
1662
+ var _a, _b;
1649
1663
  exports.devtools = hook;
1650
1664
  if (exports.devtools) {
1651
1665
  exports.devtools.enabled = true;
1652
1666
  buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
1653
1667
  buffer = [];
1654
1668
  }
1655
- else {
1669
+ else if (
1670
+ // handle late devtools injection - only do this if we are in an actual
1671
+ // browser environment to avoid the timer handle stalling test runner exit
1672
+ // (#4815)
1673
+ // eslint-disable-next-line no-restricted-globals
1674
+ typeof window !== 'undefined' &&
1675
+ // some envs mock window but not fully
1676
+ window.HTMLElement &&
1677
+ // also exclude jsdom
1678
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1656
1679
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1657
1680
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1658
1681
  replay.push((newHook) => {
1659
1682
  setDevtoolsHook(newHook, target);
1660
1683
  });
1684
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1685
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1686
+ setTimeout(() => {
1687
+ if (!exports.devtools) {
1688
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1689
+ devtoolsNotInstalled = true;
1690
+ buffer = [];
1691
+ }
1692
+ }, 3000);
1693
+ }
1694
+ else {
1695
+ // non-browser env, assume not installed
1696
+ devtoolsNotInstalled = true;
1697
+ buffer = [];
1661
1698
  }
1662
1699
  }
1663
1700
  function devtoolsInitApp(app, version) {
@@ -4446,7 +4483,7 @@ var Vue = (function (exports) {
4446
4483
  [bar, this.y]
4447
4484
  ])
4448
4485
  */
4449
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4486
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
4450
4487
  function validateDirectiveName(name) {
4451
4488
  if (isBuiltInDirective(name)) {
4452
4489
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -6363,8 +6400,8 @@ var Vue = (function (exports) {
6363
6400
  *
6364
6401
  * #2080
6365
6402
  * Inside keyed `template` fragment static children, if a fragment is moved,
6366
- * the children will always moved so that need inherit el form previous nodes
6367
- * to ensure correct moved position.
6403
+ * the children will always be moved. Therefore, in order to ensure correct move
6404
+ * position, el should be inherited from previous nodes.
6368
6405
  */
6369
6406
  function traverseStaticChildren(n1, n2, shallow = false) {
6370
6407
  const ch1 = n1.children;
@@ -7144,7 +7181,8 @@ var Vue = (function (exports) {
7144
7181
  else if (isOn(key)) {
7145
7182
  const existing = ret[key];
7146
7183
  const incoming = toMerge[key];
7147
- if (existing !== incoming) {
7184
+ if (existing !== incoming &&
7185
+ !(isArray(existing) && existing.includes(incoming))) {
7148
7186
  ret[key] = existing
7149
7187
  ? [].concat(existing, incoming)
7150
7188
  : incoming;
@@ -8676,15 +8714,21 @@ var Vue = (function (exports) {
8676
8714
  * only.
8677
8715
  * @internal
8678
8716
  */
8679
- function mergeDefaults(
8680
- // the base props is compiler-generated and guaranteed to be in this shape.
8681
- props, defaults) {
8717
+ function mergeDefaults(raw, defaults) {
8718
+ const props = isArray(raw)
8719
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8720
+ : raw;
8682
8721
  for (const key in defaults) {
8683
- const val = props[key];
8684
- if (val) {
8685
- val.default = defaults[key];
8722
+ const opt = props[key];
8723
+ if (opt) {
8724
+ if (isArray(opt) || isFunction(opt)) {
8725
+ props[key] = { type: opt, default: defaults[key] };
8726
+ }
8727
+ else {
8728
+ opt.default = defaults[key];
8729
+ }
8686
8730
  }
8687
- else if (val === null) {
8731
+ else if (opt === null) {
8688
8732
  props[key] = { default: defaults[key] };
8689
8733
  }
8690
8734
  else {
@@ -8693,6 +8737,23 @@ var Vue = (function (exports) {
8693
8737
  }
8694
8738
  return props;
8695
8739
  }
8740
+ /**
8741
+ * Used to create a proxy for the rest element when destructuring props with
8742
+ * defineProps().
8743
+ * @internal
8744
+ */
8745
+ function createPropsRestProxy(props, excludedKeys) {
8746
+ const ret = {};
8747
+ for (const key in props) {
8748
+ if (!excludedKeys.includes(key)) {
8749
+ Object.defineProperty(ret, key, {
8750
+ enumerable: true,
8751
+ get: () => props[key]
8752
+ });
8753
+ }
8754
+ }
8755
+ return ret;
8756
+ }
8696
8757
  /**
8697
8758
  * `<script setup>` helper for persisting the current instance context over
8698
8759
  * async/await flows.
@@ -8980,7 +9041,7 @@ var Vue = (function (exports) {
8980
9041
  }
8981
9042
 
8982
9043
  // Core API ------------------------------------------------------------------
8983
- const version = "3.2.18";
9044
+ const version = "3.2.22";
8984
9045
  /**
8985
9046
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
8986
9047
  * @internal
@@ -9102,16 +9163,8 @@ var Vue = (function (exports) {
9102
9163
 
9103
9164
  function patchStyle(el, prev, next) {
9104
9165
  const style = el.style;
9105
- const currentDisplay = style.display;
9106
- if (!next) {
9107
- el.removeAttribute('style');
9108
- }
9109
- else if (isString(next)) {
9110
- if (prev !== next) {
9111
- style.cssText = next;
9112
- }
9113
- }
9114
- else {
9166
+ const isCssString = isString(next);
9167
+ if (next && !isCssString) {
9115
9168
  for (const key in next) {
9116
9169
  setStyle(style, key, next[key]);
9117
9170
  }
@@ -9123,11 +9176,22 @@ var Vue = (function (exports) {
9123
9176
  }
9124
9177
  }
9125
9178
  }
9126
- // indicates that the `display` of the element is controlled by `v-show`,
9127
- // so we always keep the current `display` value regardless of the `style` value,
9128
- // thus handing over control to `v-show`.
9129
- if ('_vod' in el) {
9130
- style.display = currentDisplay;
9179
+ else {
9180
+ const currentDisplay = style.display;
9181
+ if (isCssString) {
9182
+ if (prev !== next) {
9183
+ style.cssText = next;
9184
+ }
9185
+ }
9186
+ else if (prev) {
9187
+ el.removeAttribute('style');
9188
+ }
9189
+ // indicates that the `display` of the element is controlled by `v-show`,
9190
+ // so we always keep the current `display` value regardless of the `style`
9191
+ // value, thus handing over control to `v-show`.
9192
+ if ('_vod' in el) {
9193
+ style.display = currentDisplay;
9194
+ }
9131
9195
  }
9132
9196
  }
9133
9197
  const importantRE = /\s*!important$/;
@@ -9473,22 +9537,11 @@ var Vue = (function (exports) {
9473
9537
  }
9474
9538
  this.attachShadow({ mode: 'open' });
9475
9539
  }
9476
- // set initial attrs
9477
- for (let i = 0; i < this.attributes.length; i++) {
9478
- this._setAttr(this.attributes[i].name);
9479
- }
9480
- // watch future attr changes
9481
- new MutationObserver(mutations => {
9482
- for (const m of mutations) {
9483
- this._setAttr(m.attributeName);
9484
- }
9485
- }).observe(this, { attributes: true });
9486
9540
  }
9487
9541
  connectedCallback() {
9488
9542
  this._connected = true;
9489
9543
  if (!this._instance) {
9490
9544
  this._resolveDef();
9491
- this._update();
9492
9545
  }
9493
9546
  }
9494
9547
  disconnectedCallback() {
@@ -9507,8 +9560,18 @@ var Vue = (function (exports) {
9507
9560
  if (this._resolved) {
9508
9561
  return;
9509
9562
  }
9563
+ this._resolved = true;
9564
+ // set initial attrs
9565
+ for (let i = 0; i < this.attributes.length; i++) {
9566
+ this._setAttr(this.attributes[i].name);
9567
+ }
9568
+ // watch future attr changes
9569
+ new MutationObserver(mutations => {
9570
+ for (const m of mutations) {
9571
+ this._setAttr(m.attributeName);
9572
+ }
9573
+ }).observe(this, { attributes: true });
9510
9574
  const resolve = (def) => {
9511
- this._resolved = true;
9512
9575
  const { props, styles } = def;
9513
9576
  const hasOptions = !isArray(props);
9514
9577
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9523,14 +9586,11 @@ var Vue = (function (exports) {
9523
9586
  }
9524
9587
  }
9525
9588
  }
9526
- if (numberProps) {
9527
- this._numberProps = numberProps;
9528
- this._update();
9529
- }
9589
+ this._numberProps = numberProps;
9530
9590
  // check if there are props set pre-upgrade or connect
9531
9591
  for (const key of Object.keys(this)) {
9532
9592
  if (key[0] !== '_') {
9533
- this._setProp(key, this[key]);
9593
+ this._setProp(key, this[key], true, false);
9534
9594
  }
9535
9595
  }
9536
9596
  // defining getter/setters on prototype
@@ -9544,7 +9604,10 @@ var Vue = (function (exports) {
9544
9604
  }
9545
9605
  });
9546
9606
  }
9607
+ // apply CSS
9547
9608
  this._applyStyles(styles);
9609
+ // initial render
9610
+ this._update();
9548
9611
  };
9549
9612
  const asyncDef = this._def.__asyncLoader;
9550
9613
  if (asyncDef) {
@@ -9570,10 +9633,10 @@ var Vue = (function (exports) {
9570
9633
  /**
9571
9634
  * @internal
9572
9635
  */
9573
- _setProp(key, val, shouldReflect = true) {
9636
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9574
9637
  if (val !== this._props[key]) {
9575
9638
  this._props[key] = val;
9576
- if (this._instance) {
9639
+ if (shouldUpdate && this._instance) {
9577
9640
  this._update();
9578
9641
  }
9579
9642
  // reflect
@@ -11006,7 +11069,7 @@ var Vue = (function (exports) {
11006
11069
  const isMemberExpression = isMemberExpressionBrowser
11007
11070
  ;
11008
11071
  function getInnerRange(loc, offset, length) {
11009
- const source = loc.source.substr(offset, length);
11072
+ const source = loc.source.slice(offset, offset + length);
11010
11073
  const newLoc = {
11011
11074
  source,
11012
11075
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -11833,10 +11896,10 @@ var Vue = (function (exports) {
11833
11896
  isStatic = false;
11834
11897
  if (!content.endsWith(']')) {
11835
11898
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
11836
- content = content.substr(1);
11899
+ content = content.slice(1);
11837
11900
  }
11838
11901
  else {
11839
- content = content.substr(1, content.length - 2);
11902
+ content = content.slice(1, content.length - 1);
11840
11903
  }
11841
11904
  }
11842
11905
  else if (isSlot) {
@@ -11862,7 +11925,7 @@ var Vue = (function (exports) {
11862
11925
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
11863
11926
  valueLoc.source = valueLoc.source.slice(1, -1);
11864
11927
  }
11865
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
11928
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
11866
11929
  if (isPropShorthand)
11867
11930
  modifiers.push('prop');
11868
11931
  return {
@@ -12072,7 +12135,7 @@ var Vue = (function (exports) {
12072
12135
  }
12073
12136
  function startsWithEndTagOpen(source, tag) {
12074
12137
  return (startsWith(source, '</') &&
12075
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
12138
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
12076
12139
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
12077
12140
  }
12078
12141
 
@@ -14478,7 +14541,7 @@ var Vue = (function (exports) {
14478
14541
  return propsNamesString + `]`;
14479
14542
  }
14480
14543
  function isComponentTag(tag) {
14481
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
14544
+ return tag === 'component' || tag === 'Component';
14482
14545
  }
14483
14546
 
14484
14547
  const transformSlotOutlet = (node, context) => {
@@ -15469,6 +15532,7 @@ var Vue = (function (exports) {
15469
15532
  exports.createElementBlock = createElementBlock;
15470
15533
  exports.createElementVNode = createBaseVNode;
15471
15534
  exports.createHydrationRenderer = createHydrationRenderer;
15535
+ exports.createPropsRestProxy = createPropsRestProxy;
15472
15536
  exports.createRenderer = createRenderer;
15473
15537
  exports.createSSRApp = createSSRApp;
15474
15538
  exports.createSlots = createSlots;