@cabloy/vue-runtime-core 3.5.31 → 3.5.33

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.
@@ -3,9 +3,9 @@
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- import { pauseTracking, resetTracking, isRef, toRaw, traverse, shallowRef, readonly, isReactive, ref, isShallow, shallowReadArray, toReactive, shallowReadonly, track, reactive, shallowReactive, trigger, ReactiveEffect, watch as watch$1, customRef, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, isReadonly } from '@vue/reactivity';
6
+ import { pauseTracking, resetTracking, isRef, toRaw, traverse, isReactive, isShallow, shallowReadArray, toReactive, shallowRef, readonly, ref, shallowReadonly, track, reactive, shallowReactive, trigger, ReactiveEffect, watch as watch$1, customRef, isProxy, proxyRefs, markRaw, EffectScope, computed as computed$1, isReadonly } from '@vue/reactivity';
7
7
  export { EffectScope, ReactiveEffect, TrackOpTypes, TriggerOpTypes, customRef, effect, effectScope, getCurrentScope, getCurrentWatcher, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, onScopeDispose, onWatcherCleanup, proxyRefs, reactive, readonly, ref, shallowReactive, shallowReadonly, shallowRef, stop, toRaw, toRef, toRefs, toValue, triggerRef, unref } from '@vue/reactivity';
8
- import { isString, isFunction, isPromise, isArray, EMPTY_OBJ, NOOP, getGlobalThis, extend, isBuiltInDirective, hasOwn, remove, def, isOn, isReservedProp, normalizeClass, stringifyStyle, normalizeStyle, isKnownSvgAttr, isBooleanAttr, isKnownHtmlAttr, includeBooleanAttr, isRenderableAttrValue, getEscapedCssVarName, isObject, isRegExp, invokeArrayFns, toHandlerKey, capitalize, camelize, isSymbol, isGloballyAllowed, NO, hyphenate, EMPTY_ARR, toRawType, makeMap, hasChanged, looseToNumber, isModelListener, toNumber } from '@vue/shared';
8
+ import { isString, isFunction, isPromise, isArray, EMPTY_OBJ, NOOP, getGlobalThis, extend, isBuiltInDirective, remove, isRegExp, invokeArrayFns, toHandlerKey, capitalize, camelize, isObject, hasOwn, def, isOn, isReservedProp, normalizeClass, stringifyStyle, normalizeStyle, isKnownSvgAttr, isBooleanAttr, isKnownHtmlAttr, includeBooleanAttr, isRenderableAttrValue, getEscapedCssVarName, isSymbol, isGloballyAllowed, NO, hyphenate, EMPTY_ARR, toRawType, makeMap, hasChanged, looseToNumber, isModelListener, toNumber } from '@vue/shared';
9
9
  export { camelize, capitalize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared';
10
10
 
11
11
  const stack = [];
@@ -1474,1520 +1474,1519 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
1474
1474
  return ret;
1475
1475
  }
1476
1476
 
1477
- /*! #__NO_SIDE_EFFECTS__ */
1478
- // @__NO_SIDE_EFFECTS__
1479
- function defineComponent(options, extraOptions) {
1480
- return isFunction(options) ? (
1481
- // #8236: extend call and options.name access are considered side-effects
1482
- // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1483
- /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
1484
- ) : options;
1485
- }
1486
-
1487
- function useId() {
1488
- const i = getCurrentInstance();
1489
- if (i) {
1490
- return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++;
1491
- } else if (!!(process.env.NODE_ENV !== "production")) {
1492
- warn$1(
1493
- `useId() is called when there is no active component instance to be associated with.`
1494
- );
1495
- }
1496
- return "";
1497
- }
1498
- function markAsyncBoundary(instance) {
1499
- instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
1500
- }
1501
-
1502
- const knownTemplateRefs = /* @__PURE__ */ new WeakSet();
1503
- function useTemplateRef(key) {
1504
- const i = getCurrentInstance();
1505
- const r = shallowRef(null);
1506
- if (i) {
1507
- const refs = i.refs === EMPTY_OBJ ? i.refs = {} : i.refs;
1508
- let desc;
1509
- if (!!(process.env.NODE_ENV !== "production") && (desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable) {
1510
- warn$1(`useTemplateRef('${key}') already exists.`);
1511
- } else {
1512
- Object.defineProperty(refs, key, {
1513
- enumerable: true,
1514
- get: () => r.value,
1515
- set: (val) => r.value = val
1516
- });
1477
+ const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
1478
+ const KeepAliveImpl = {
1479
+ name: `KeepAlive`,
1480
+ // Marker for special handling inside the renderer. We are not using a ===
1481
+ // check directly on KeepAlive in the renderer, because importing it directly
1482
+ // would prevent it from being tree-shaken.
1483
+ __isKeepAlive: true,
1484
+ props: {
1485
+ include: [String, RegExp, Array],
1486
+ exclude: [String, RegExp, Array],
1487
+ max: [String, Number]
1488
+ },
1489
+ setup(props, { slots }) {
1490
+ const instance = getCurrentInstance();
1491
+ const sharedContext = instance.ctx;
1492
+ if (!sharedContext.renderer) {
1493
+ return () => {
1494
+ const children = slots.default && slots.default();
1495
+ return children && children.length === 1 ? children[0] : children;
1496
+ };
1517
1497
  }
1518
- } else if (!!(process.env.NODE_ENV !== "production")) {
1519
- warn$1(
1520
- `useTemplateRef() is called when there is no active component instance to be associated with.`
1521
- );
1522
- }
1523
- const ret = !!(process.env.NODE_ENV !== "production") ? readonly(r) : r;
1524
- if (!!(process.env.NODE_ENV !== "production")) {
1525
- knownTemplateRefs.add(ret);
1526
- }
1527
- return ret;
1528
- }
1529
-
1530
- function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
1531
- if (isArray(rawRef)) {
1532
- rawRef.forEach(
1533
- (r, i) => setRef(
1534
- r,
1535
- oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
1536
- parentSuspense,
1537
- vnode,
1538
- isUnmount
1539
- )
1540
- );
1541
- return;
1542
- }
1543
- if (isAsyncWrapper(vnode) && !isUnmount) {
1544
- if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
1545
- setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
1498
+ const cache = /* @__PURE__ */ new Map();
1499
+ const keys = /* @__PURE__ */ new Set();
1500
+ let current = null;
1501
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
1502
+ instance.__v_cache = cache;
1546
1503
  }
1547
- return;
1548
- }
1549
- const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
1550
- const value = isUnmount ? null : refValue;
1551
- const { i: owner, r: ref } = rawRef;
1552
- if (!!(process.env.NODE_ENV !== "production") && !owner) {
1553
- warn$1(
1554
- `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
1555
- );
1556
- return;
1557
- }
1558
- const oldRef = oldRawRef && oldRawRef.r;
1559
- const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
1560
- const setupState = owner.setupState;
1561
- const rawSetupState = toRaw(setupState);
1562
- const canSetSetupRef = setupState === EMPTY_OBJ ? () => false : (key) => {
1563
- if (!!(process.env.NODE_ENV !== "production")) {
1564
- if (hasOwn(rawSetupState, key) && !isRef(rawSetupState[key])) {
1565
- warn$1(
1566
- `Template ref "${key}" used on a non-ref value. It will not work in the production build.`
1567
- );
1504
+ const parentSuspense = instance.suspense;
1505
+ const {
1506
+ renderer: {
1507
+ p: patch,
1508
+ m: move,
1509
+ um: _unmount,
1510
+ o: { createElement }
1568
1511
  }
1569
- if (knownTemplateRefs.has(rawSetupState[key])) {
1570
- return false;
1512
+ } = sharedContext;
1513
+ const storageContainer = createElement("div");
1514
+ sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
1515
+ const instance2 = vnode.component;
1516
+ move(vnode, container, anchor, 0, parentSuspense);
1517
+ patch(
1518
+ instance2.vnode,
1519
+ vnode,
1520
+ container,
1521
+ anchor,
1522
+ instance2,
1523
+ parentSuspense,
1524
+ namespace,
1525
+ vnode.slotScopeIds,
1526
+ optimized
1527
+ );
1528
+ queuePostRenderEffect(() => {
1529
+ instance2.isDeactivated = false;
1530
+ if (instance2.a) {
1531
+ invokeArrayFns(instance2.a);
1532
+ }
1533
+ const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
1534
+ if (vnodeHook) {
1535
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1536
+ }
1537
+ }, parentSuspense);
1538
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
1539
+ devtoolsComponentAdded(instance2);
1571
1540
  }
1572
- }
1573
- return hasOwn(rawSetupState, key);
1574
- };
1575
- if (oldRef != null && oldRef !== ref) {
1576
- if (isString(oldRef)) {
1577
- refs[oldRef] = null;
1578
- if (canSetSetupRef(oldRef)) {
1579
- setupState[oldRef] = null;
1541
+ };
1542
+ sharedContext.deactivate = (vnode) => {
1543
+ const instance2 = vnode.component;
1544
+ invalidateMount(instance2.m);
1545
+ invalidateMount(instance2.a);
1546
+ move(vnode, storageContainer, null, 1, parentSuspense);
1547
+ queuePostRenderEffect(() => {
1548
+ if (instance2.da) {
1549
+ invokeArrayFns(instance2.da);
1550
+ }
1551
+ const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
1552
+ if (vnodeHook) {
1553
+ invokeVNodeHook(vnodeHook, instance2.parent, vnode);
1554
+ }
1555
+ instance2.isDeactivated = true;
1556
+ }, parentSuspense);
1557
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
1558
+ devtoolsComponentAdded(instance2);
1580
1559
  }
1581
- } else if (isRef(oldRef)) {
1582
- oldRef.value = null;
1560
+ };
1561
+ function unmount(vnode) {
1562
+ resetShapeFlag(vnode);
1563
+ _unmount(vnode, instance, parentSuspense, true);
1583
1564
  }
1584
- }
1585
- if (isFunction(ref)) {
1586
- callWithErrorHandling(ref, owner, 12, [value, refs]);
1587
- } else {
1588
- const _isString = isString(ref);
1589
- const _isRef = isRef(ref);
1590
- if (_isString || _isRef) {
1591
- const doSet = () => {
1592
- if (rawRef.f) {
1593
- const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : ref.value;
1594
- if (isUnmount) {
1595
- isArray(existing) && remove(existing, refValue);
1596
- } else {
1597
- if (!isArray(existing)) {
1598
- if (_isString) {
1599
- refs[ref] = [refValue];
1600
- if (canSetSetupRef(ref)) {
1601
- setupState[ref] = refs[ref];
1602
- }
1603
- } else {
1604
- ref.value = [refValue];
1605
- if (rawRef.k) refs[rawRef.k] = ref.value;
1606
- }
1607
- } else if (!existing.includes(refValue)) {
1608
- existing.push(refValue);
1609
- }
1610
- }
1611
- } else if (_isString) {
1612
- refs[ref] = value;
1613
- if (canSetSetupRef(ref)) {
1614
- setupState[ref] = value;
1615
- }
1616
- } else if (_isRef) {
1617
- ref.value = value;
1618
- if (rawRef.k) refs[rawRef.k] = value;
1619
- } else if (!!(process.env.NODE_ENV !== "production")) {
1620
- warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
1565
+ function pruneCache(filter) {
1566
+ cache.forEach((vnode, key) => {
1567
+ const name = vnode.key;
1568
+ if (name && !filter(name)) {
1569
+ pruneCacheEntry(key);
1621
1570
  }
1622
- };
1623
- if (value) {
1624
- doSet.id = -1;
1625
- queuePostRenderEffect(doSet, parentSuspense);
1626
- } else {
1627
- doSet();
1571
+ });
1572
+ }
1573
+ function pruneCacheEntry(key) {
1574
+ const cached = cache.get(key);
1575
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
1576
+ unmount(cached);
1577
+ } else if (current) {
1578
+ resetShapeFlag(current);
1628
1579
  }
1629
- } else if (!!(process.env.NODE_ENV !== "production")) {
1630
- warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
1580
+ cache.delete(key);
1581
+ keys.delete(key);
1631
1582
  }
1632
- }
1633
- }
1634
-
1635
- let hasLoggedMismatchError = false;
1636
- const logMismatchError = () => {
1637
- if (hasLoggedMismatchError) {
1638
- return;
1639
- }
1640
- console.error("Hydration completed but contains mismatches.");
1641
- hasLoggedMismatchError = true;
1642
- };
1643
- const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
1644
- const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
1645
- const getContainerType = (container) => {
1646
- if (container.nodeType !== 1) return void 0;
1647
- if (isSVGContainer(container)) return "svg";
1648
- if (isMathMLContainer(container)) return "mathml";
1649
- return void 0;
1650
- };
1651
- const isComment = (node) => node.nodeType === 8;
1652
- function createHydrationFunctions(rendererInternals) {
1653
- const {
1654
- mt: mountComponent,
1655
- p: patch,
1656
- o: {
1657
- patchProp,
1658
- createText,
1659
- nextSibling,
1660
- parentNode,
1661
- remove,
1662
- insert,
1663
- createComment
1664
- }
1665
- } = rendererInternals;
1666
- const hydrate = (vnode, container) => {
1667
- if (!container.hasChildNodes()) {
1668
- (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
1669
- `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
1670
- );
1671
- patch(null, vnode, container);
1672
- flushPostFlushCbs();
1673
- container._vnode = vnode;
1674
- return;
1675
- }
1676
- hydrateNode(container.firstChild, vnode, null, null, null);
1677
- flushPostFlushCbs();
1678
- container._vnode = vnode;
1679
- };
1680
- const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
1681
- optimized = optimized || !!vnode.dynamicChildren;
1682
- const isFragmentStart = isComment(node) && node.data === "[";
1683
- const onMismatch = () => handleMismatch(
1684
- node,
1685
- vnode,
1686
- parentComponent,
1687
- parentSuspense,
1688
- slotScopeIds,
1689
- isFragmentStart
1583
+ watch(
1584
+ () => [props.include, props.exclude],
1585
+ ([include, exclude]) => {
1586
+ include && pruneCache((name) => matches(include, name));
1587
+ exclude && pruneCache((name) => !matches(exclude, name));
1588
+ },
1589
+ // prune post-render after `current` has been updated
1590
+ { flush: "post", deep: true }
1690
1591
  );
1691
- const { type, ref, shapeFlag, patchFlag } = vnode;
1692
- let domType = node.nodeType;
1693
- vnode.el = node;
1694
- if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
1695
- def(node, "__vnode", vnode, true);
1696
- def(node, "__vueParentComponent", parentComponent, true);
1697
- }
1698
- if (patchFlag === -2) {
1699
- optimized = false;
1700
- vnode.dynamicChildren = null;
1701
- }
1702
- let nextNode = null;
1703
- switch (type) {
1704
- case Text:
1705
- if (domType !== 3) {
1706
- if (vnode.children === "") {
1707
- insert(vnode.el = createText(""), parentNode(node), node);
1708
- nextNode = node;
1709
- } else {
1710
- nextNode = onMismatch();
1711
- }
1592
+ let pendingCacheKey = null;
1593
+ const cacheSubtree = () => {
1594
+ if (pendingCacheKey != null) {
1595
+ if (isSuspense(instance.subTree.type)) {
1596
+ queuePostRenderEffect(() => {
1597
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1598
+ }, instance.subTree.suspense);
1712
1599
  } else {
1713
- if (node.data !== vnode.children) {
1714
- node.data = vnode.children;
1715
- }
1716
- nextNode = nextSibling(node);
1600
+ cache.set(pendingCacheKey, getInnerChild(instance.subTree));
1717
1601
  }
1718
- break;
1719
- case Comment:
1720
- if (isTemplateNode(node)) {
1721
- nextNode = nextSibling(node);
1722
- replaceNode(
1723
- vnode.el = node.content.firstChild,
1724
- node,
1725
- parentComponent
1726
- );
1727
- } else if (domType !== 8 || isFragmentStart) {
1728
- nextNode = onMismatch();
1729
- } else {
1730
- nextNode = nextSibling(node);
1602
+ }
1603
+ };
1604
+ onMounted(cacheSubtree);
1605
+ onUpdated(cacheSubtree);
1606
+ onBeforeUnmount(() => {
1607
+ cache.forEach((cached) => {
1608
+ const { subTree, suspense } = instance;
1609
+ const vnode = getInnerChild(subTree);
1610
+ if (cached.type === vnode.type && cached.key === vnode.key) {
1611
+ resetShapeFlag(vnode);
1612
+ const da = vnode.component.da;
1613
+ da && queuePostRenderEffect(da, suspense);
1614
+ return;
1731
1615
  }
1732
- break;
1733
- case Static:
1734
- if (isFragmentStart) {
1735
- node = nextSibling(node);
1736
- domType = node.nodeType;
1616
+ unmount(cached);
1617
+ });
1618
+ });
1619
+ return () => {
1620
+ pendingCacheKey = null;
1621
+ if (!slots.default) {
1622
+ return current = null;
1623
+ }
1624
+ const children = slots.default();
1625
+ const rawVNode = children[0];
1626
+ if (children.length > 1) {
1627
+ if (!!(process.env.NODE_ENV !== "production")) {
1628
+ warn$1(`KeepAlive should contain exactly one component child.`);
1737
1629
  }
1738
- if (domType === 1 || domType === 3) {
1739
- nextNode = node;
1740
- const needToAdoptContent = !vnode.children.length;
1741
- for (let i = 0; i < vnode.staticCount; i++) {
1742
- if (needToAdoptContent)
1743
- vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
1744
- if (i === vnode.staticCount - 1) {
1745
- vnode.anchor = nextNode;
1746
- }
1747
- nextNode = nextSibling(nextNode);
1748
- }
1749
- return isFragmentStart ? nextSibling(nextNode) : nextNode;
1750
- } else {
1751
- onMismatch();
1630
+ current = null;
1631
+ return children;
1632
+ } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
1633
+ current = null;
1634
+ return rawVNode;
1635
+ }
1636
+ let vnode = getInnerChild(rawVNode);
1637
+ if (vnode.type === Comment) {
1638
+ current = null;
1639
+ return vnode;
1640
+ }
1641
+ const comp = vnode.type;
1642
+ const name = vnode.key;
1643
+ const { include, exclude, max } = props;
1644
+ if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
1645
+ vnode.shapeFlag &= ~256;
1646
+ current = vnode;
1647
+ current.component.zovaHostProviders = current.zovaHostProviders;
1648
+ return rawVNode;
1649
+ }
1650
+ const key = vnode.key == null ? comp : vnode.key;
1651
+ const cachedVNode = cache.get(key);
1652
+ if (vnode.el) {
1653
+ vnode = cloneVNode(vnode);
1654
+ if (rawVNode.shapeFlag & 128) {
1655
+ rawVNode.ssContent = vnode;
1752
1656
  }
1753
- break;
1754
- case Fragment:
1755
- if (!isFragmentStart) {
1756
- nextNode = onMismatch();
1757
- } else {
1758
- nextNode = hydrateFragment(
1759
- node,
1760
- vnode,
1761
- parentComponent,
1762
- parentSuspense,
1763
- slotScopeIds,
1764
- optimized
1765
- );
1657
+ }
1658
+ pendingCacheKey = key;
1659
+ if (cachedVNode) {
1660
+ vnode.el = cachedVNode.el;
1661
+ vnode.component = cachedVNode.component;
1662
+ if (vnode.transition) {
1663
+ setTransitionHooks(vnode, vnode.transition);
1766
1664
  }
1767
- break;
1768
- default:
1769
- if (shapeFlag & 1) {
1770
- if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
1771
- nextNode = onMismatch();
1772
- } else {
1773
- nextNode = hydrateElement(
1774
- node,
1775
- vnode,
1776
- parentComponent,
1777
- parentSuspense,
1778
- slotScopeIds,
1779
- optimized
1780
- );
1781
- }
1782
- } else if (shapeFlag & 6) {
1783
- vnode.slotScopeIds = slotScopeIds;
1784
- const container = parentNode(node);
1785
- if (isFragmentStart) {
1786
- nextNode = locateClosingAnchor(node);
1787
- } else if (isComment(node) && node.data === "teleport start") {
1788
- nextNode = locateClosingAnchor(node, node.data, "teleport end");
1789
- } else {
1790
- nextNode = nextSibling(node);
1791
- }
1792
- mountComponent(
1793
- vnode,
1794
- container,
1795
- null,
1796
- parentComponent,
1797
- parentSuspense,
1798
- getContainerType(container),
1799
- optimized
1800
- );
1801
- if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
1802
- let subTree;
1803
- if (isFragmentStart) {
1804
- subTree = createVNode(Fragment);
1805
- subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
1806
- } else {
1807
- subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
1808
- }
1809
- subTree.el = node;
1810
- vnode.component.subTree = subTree;
1811
- }
1812
- } else if (shapeFlag & 64) {
1813
- if (domType !== 8) {
1814
- nextNode = onMismatch();
1815
- } else {
1816
- nextNode = vnode.type.hydrate(
1817
- node,
1818
- vnode,
1819
- parentComponent,
1820
- parentSuspense,
1821
- slotScopeIds,
1822
- optimized,
1823
- rendererInternals,
1824
- hydrateChildren
1825
- );
1826
- }
1827
- } else if (shapeFlag & 128) {
1828
- nextNode = vnode.type.hydrate(
1829
- node,
1830
- vnode,
1831
- parentComponent,
1832
- parentSuspense,
1833
- getContainerType(parentNode(node)),
1834
- slotScopeIds,
1835
- optimized,
1836
- rendererInternals,
1837
- hydrateNode
1838
- );
1839
- } else if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) {
1840
- warn$1("Invalid HostVNode type:", type, `(${typeof type})`);
1665
+ vnode.shapeFlag |= 512;
1666
+ keys.delete(key);
1667
+ keys.add(key);
1668
+ } else {
1669
+ keys.add(key);
1670
+ if (max && keys.size > parseInt(max, 10)) {
1671
+ pruneCacheEntry(keys.values().next().value);
1841
1672
  }
1673
+ }
1674
+ vnode.shapeFlag |= 256;
1675
+ current = vnode;
1676
+ current.component.zovaHostProviders = current.zovaHostProviders;
1677
+ return isSuspense(rawVNode.type) ? rawVNode : vnode;
1678
+ };
1679
+ }
1680
+ };
1681
+ const KeepAlive = KeepAliveImpl;
1682
+ function matches(pattern, name) {
1683
+ if (isArray(pattern)) {
1684
+ return pattern.some((p) => matches(p, name));
1685
+ } else if (isString(pattern)) {
1686
+ return pattern.split(",").includes(name);
1687
+ } else if (isRegExp(pattern)) {
1688
+ pattern.lastIndex = 0;
1689
+ return pattern.test(name);
1690
+ }
1691
+ return false;
1692
+ }
1693
+ function onActivated(hook, target) {
1694
+ registerKeepAliveHook(hook, "a", target);
1695
+ }
1696
+ function onDeactivated(hook, target) {
1697
+ registerKeepAliveHook(hook, "da", target);
1698
+ }
1699
+ function registerKeepAliveHook(hook, type, target = currentInstance) {
1700
+ const wrappedHook = hook.__wdc || (hook.__wdc = () => {
1701
+ let current = target;
1702
+ while (current) {
1703
+ if (current.isDeactivated) {
1704
+ return;
1705
+ }
1706
+ current = current.parent;
1842
1707
  }
1843
- if (ref != null) {
1844
- setRef(ref, null, parentSuspense, vnode);
1708
+ return hook();
1709
+ });
1710
+ injectHook(type, wrappedHook, target);
1711
+ if (target) {
1712
+ let current = target.parent;
1713
+ while (current && current.parent) {
1714
+ if (isKeepAlive(current.parent.vnode)) {
1715
+ injectToKeepAliveRoot(wrappedHook, type, target, current);
1716
+ }
1717
+ current = current.parent;
1845
1718
  }
1846
- return nextNode;
1847
- };
1848
- function _getValidZova(instance) {
1849
- while (instance) {
1850
- if (instance.zova) return instance.zova;
1851
- instance = instance.parent;
1719
+ }
1720
+ }
1721
+ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
1722
+ const injected = injectHook(
1723
+ type,
1724
+ hook,
1725
+ keepAliveRoot,
1726
+ true
1727
+ /* prepend */
1728
+ );
1729
+ onUnmounted(() => {
1730
+ remove(keepAliveRoot[type], injected);
1731
+ }, target);
1732
+ }
1733
+ function resetShapeFlag(vnode) {
1734
+ vnode.shapeFlag &= ~256;
1735
+ vnode.shapeFlag &= ~512;
1736
+ }
1737
+ function getInnerChild(vnode) {
1738
+ return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
1739
+ }
1740
+
1741
+ function injectHook(type, hook, target = currentInstance, prepend = false) {
1742
+ if (target) {
1743
+ const hooks = target[type] || (target[type] = []);
1744
+ const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
1745
+ pauseTracking();
1746
+ const reset = setCurrentInstance(target);
1747
+ const res = callWithAsyncErrorHandling(hook, target, type, args);
1748
+ reset();
1749
+ resetTracking();
1750
+ return res;
1751
+ });
1752
+ if (prepend) {
1753
+ hooks.unshift(wrappedHook);
1754
+ } else {
1755
+ hooks.push(wrappedHook);
1852
1756
  }
1757
+ return wrappedHook;
1758
+ } else if (!!(process.env.NODE_ENV !== "production")) {
1759
+ const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
1760
+ warn$1(
1761
+ `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
1762
+ );
1853
1763
  }
1854
- const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1855
- optimized = optimized || !!vnode.dynamicChildren;
1856
- const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
1857
- const forcePatch = type === "input" || type === "option";
1858
- if (!!(process.env.NODE_ENV !== "production") || forcePatch || patchFlag !== -1) {
1859
- if (dirs) {
1860
- invokeDirectiveHook(vnode, null, parentComponent, "created");
1764
+ }
1765
+ const createHook = (lifecycle) => (hook, target = currentInstance) => {
1766
+ if (!isInSSRComponentSetup || lifecycle === "sp") {
1767
+ injectHook(lifecycle, (...args) => hook(...args), target);
1768
+ }
1769
+ if (lifecycle === "m" && target && target.isMounted) {
1770
+ hook();
1771
+ }
1772
+ };
1773
+ const onBeforeMount = createHook("bm");
1774
+ const onMounted = createHook("m");
1775
+ const onBeforeUpdate = createHook(
1776
+ "bu"
1777
+ );
1778
+ const onUpdated = createHook("u");
1779
+ const onBeforeUnmount = createHook(
1780
+ "bum"
1781
+ );
1782
+ const onUnmounted = createHook("um");
1783
+ const onServerPrefetch = createHook(
1784
+ "sp"
1785
+ );
1786
+ const onRenderTriggered = createHook("rtg");
1787
+ const onRenderTracked = createHook("rtc");
1788
+ function onErrorCaptured(hook, target = currentInstance) {
1789
+ injectHook("ec", hook, target);
1790
+ }
1791
+
1792
+ const COMPONENTS = "components";
1793
+ const DIRECTIVES = "directives";
1794
+ function resolveComponent(name, maybeSelfReference) {
1795
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
1796
+ }
1797
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
1798
+ function resolveDynamicComponent(component) {
1799
+ if (isString(component)) {
1800
+ return resolveAsset(COMPONENTS, component, false) || component;
1801
+ } else {
1802
+ return component || NULL_DYNAMIC_COMPONENT;
1803
+ }
1804
+ }
1805
+ function resolveDirective(name) {
1806
+ return resolveAsset(DIRECTIVES, name);
1807
+ }
1808
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
1809
+ const instance = currentRenderingInstance || currentInstance;
1810
+ if (instance) {
1811
+ const Component = instance.type;
1812
+ if (type === COMPONENTS) {
1813
+ const selfName = getComponentName(
1814
+ Component,
1815
+ false
1816
+ );
1817
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
1818
+ return Component;
1861
1819
  }
1862
- let needCallTransitionHooks = false;
1863
- if (isTemplateNode(el)) {
1864
- needCallTransitionHooks = needTransition(
1865
- null,
1866
- // no need check parentSuspense in hydration
1867
- transition
1868
- ) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
1869
- const content = el.content.firstChild;
1870
- if (needCallTransitionHooks) {
1871
- transition.beforeEnter(content);
1872
- }
1873
- replaceNode(content, el, parentComponent);
1874
- vnode.el = el = content;
1820
+ }
1821
+ const res = (
1822
+ // local registration
1823
+ // check instance[type] first which is resolved for options API
1824
+ resolve(instance[type] || Component[type], name) || // global registration
1825
+ resolve(instance.appContext[type], name)
1826
+ );
1827
+ if (!res && maybeSelfReference) {
1828
+ return Component;
1829
+ }
1830
+ if (!!(process.env.NODE_ENV !== "production") && warnMissing && !res) {
1831
+ const extra = type === COMPONENTS ? `
1832
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
1833
+ warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
1834
+ }
1835
+ return res;
1836
+ } else if (!!(process.env.NODE_ENV !== "production")) {
1837
+ warn$1(
1838
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
1839
+ );
1840
+ }
1841
+ }
1842
+ function resolve(registry, name) {
1843
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
1844
+ }
1845
+
1846
+ function renderList(source, renderItem, cache, index) {
1847
+ let ret;
1848
+ const cached = cache && cache[index];
1849
+ const sourceIsArray = isArray(source);
1850
+ if (sourceIsArray || isString(source)) {
1851
+ const sourceIsReactiveArray = sourceIsArray && isReactive(source);
1852
+ let needsWrap = false;
1853
+ if (sourceIsReactiveArray) {
1854
+ needsWrap = !isShallow(source);
1855
+ source = shallowReadArray(source);
1856
+ }
1857
+ ret = new Array(source.length);
1858
+ for (let i = 0, l = source.length; i < l; i++) {
1859
+ ret[i] = renderItem(
1860
+ needsWrap ? toReactive(source[i]) : source[i],
1861
+ i,
1862
+ void 0,
1863
+ cached && cached[i]
1864
+ );
1865
+ }
1866
+ } else if (typeof source === "number") {
1867
+ if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
1868
+ warn$1(`The v-for range expect an integer value but got ${source}.`);
1869
+ }
1870
+ ret = new Array(source);
1871
+ for (let i = 0; i < source; i++) {
1872
+ ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
1873
+ }
1874
+ } else if (isObject(source)) {
1875
+ if (source[Symbol.iterator]) {
1876
+ ret = Array.from(
1877
+ source,
1878
+ (item, i) => renderItem(item, i, void 0, cached && cached[i])
1879
+ );
1880
+ } else {
1881
+ const keys = Object.keys(source);
1882
+ ret = new Array(keys.length);
1883
+ for (let i = 0, l = keys.length; i < l; i++) {
1884
+ const key = keys[i];
1885
+ ret[i] = renderItem(source[key], key, i, cached && cached[i]);
1875
1886
  }
1876
- if (shapeFlag & 16 && // skip if element has innerHTML / textContent
1877
- !(props && (props.innerHTML || props.textContent))) {
1878
- let next = hydrateChildren(
1879
- el.firstChild,
1880
- vnode,
1881
- el,
1882
- parentComponent,
1883
- parentSuspense,
1884
- slotScopeIds,
1885
- optimized
1887
+ }
1888
+ } else {
1889
+ ret = [];
1890
+ }
1891
+ if (cache) {
1892
+ cache[index] = ret;
1893
+ }
1894
+ return ret;
1895
+ }
1896
+
1897
+ function createSlots(slots, dynamicSlots) {
1898
+ for (let i = 0; i < dynamicSlots.length; i++) {
1899
+ const slot = dynamicSlots[i];
1900
+ if (isArray(slot)) {
1901
+ for (let j = 0; j < slot.length; j++) {
1902
+ slots[slot[j].name] = slot[j].fn;
1903
+ }
1904
+ } else if (slot) {
1905
+ slots[slot.name] = slot.key ? (...args) => {
1906
+ const res = slot.fn(...args);
1907
+ if (res) res.key = slot.key;
1908
+ return res;
1909
+ } : slot.fn;
1910
+ }
1911
+ }
1912
+ return slots;
1913
+ }
1914
+
1915
+ /*! #__NO_SIDE_EFFECTS__ */
1916
+ // @__NO_SIDE_EFFECTS__
1917
+ function defineComponent(options, extraOptions) {
1918
+ return isFunction(options) ? (
1919
+ // #8236: extend call and options.name access are considered side-effects
1920
+ // by Rollup, so we have to wrap it in a pure-annotated IIFE.
1921
+ /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
1922
+ ) : options;
1923
+ }
1924
+
1925
+ function useId() {
1926
+ const i = getCurrentInstance();
1927
+ if (i) {
1928
+ return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++;
1929
+ } else if (!!(process.env.NODE_ENV !== "production")) {
1930
+ warn$1(
1931
+ `useId() is called when there is no active component instance to be associated with.`
1932
+ );
1933
+ }
1934
+ return "";
1935
+ }
1936
+ function markAsyncBoundary(instance) {
1937
+ instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
1938
+ }
1939
+
1940
+ const knownTemplateRefs = /* @__PURE__ */ new WeakSet();
1941
+ function useTemplateRef(key) {
1942
+ const i = getCurrentInstance();
1943
+ const r = shallowRef(null);
1944
+ if (i) {
1945
+ const refs = i.refs === EMPTY_OBJ ? i.refs = {} : i.refs;
1946
+ let desc;
1947
+ if (!!(process.env.NODE_ENV !== "production") && (desc = Object.getOwnPropertyDescriptor(refs, key)) && !desc.configurable) {
1948
+ warn$1(`useTemplateRef('${key}') already exists.`);
1949
+ } else {
1950
+ Object.defineProperty(refs, key, {
1951
+ enumerable: true,
1952
+ get: () => r.value,
1953
+ set: (val) => r.value = val
1954
+ });
1955
+ }
1956
+ } else if (!!(process.env.NODE_ENV !== "production")) {
1957
+ warn$1(
1958
+ `useTemplateRef() is called when there is no active component instance to be associated with.`
1959
+ );
1960
+ }
1961
+ const ret = !!(process.env.NODE_ENV !== "production") ? readonly(r) : r;
1962
+ if (!!(process.env.NODE_ENV !== "production")) {
1963
+ knownTemplateRefs.add(ret);
1964
+ }
1965
+ return ret;
1966
+ }
1967
+
1968
+ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
1969
+ if (isArray(rawRef)) {
1970
+ rawRef.forEach(
1971
+ (r, i) => setRef(
1972
+ r,
1973
+ oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
1974
+ parentSuspense,
1975
+ vnode,
1976
+ isUnmount
1977
+ )
1978
+ );
1979
+ return;
1980
+ }
1981
+ if (isAsyncWrapper(vnode) && !isUnmount) {
1982
+ if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
1983
+ setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
1984
+ }
1985
+ return;
1986
+ }
1987
+ const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
1988
+ const value = isUnmount ? null : refValue;
1989
+ const { i: owner, r: ref } = rawRef;
1990
+ if (!!(process.env.NODE_ENV !== "production") && !owner) {
1991
+ warn$1(
1992
+ `Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
1993
+ );
1994
+ return;
1995
+ }
1996
+ const oldRef = oldRawRef && oldRawRef.r;
1997
+ const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
1998
+ const setupState = owner.setupState;
1999
+ const rawSetupState = toRaw(setupState);
2000
+ const canSetSetupRef = setupState === EMPTY_OBJ ? () => false : (key) => {
2001
+ if (!!(process.env.NODE_ENV !== "production")) {
2002
+ if (hasOwn(rawSetupState, key) && !isRef(rawSetupState[key])) {
2003
+ warn$1(
2004
+ `Template ref "${key}" used on a non-ref value. It will not work in the production build.`
1886
2005
  );
1887
- let hasWarned = false;
1888
- while (next) {
1889
- if (!isMismatchAllowed(el, 1 /* CHILDREN */)) {
1890
- if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && !hasWarned) {
1891
- warn$1(
1892
- `Hydration children mismatch on`,
1893
- el,
1894
- `
1895
- Server rendered element contains more child nodes than client vdom.`
1896
- );
1897
- hasWarned = true;
1898
- }
1899
- logMismatchError();
1900
- }
1901
- const cur = next;
1902
- next = next.nextSibling;
1903
- remove(cur);
1904
- }
1905
- } else if (shapeFlag & 8) {
1906
- let clientText = vnode.children;
1907
- if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
1908
- clientText = clientText.slice(1);
1909
- }
1910
- if (el.textContent !== clientText) {
1911
- if (!isMismatchAllowed(el, 0 /* TEXT */)) {
1912
- (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
1913
- `Hydration text content mismatch on`,
1914
- el,
1915
- `
1916
- - rendered on server: ${el.textContent}
1917
- - expected on client: ${vnode.children}`
1918
- );
1919
- logMismatchError();
1920
- }
1921
- el.textContent = vnode.children;
1922
- }
1923
2006
  }
1924
- if (props) {
1925
- if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ || forcePatch || !optimized || patchFlag & (16 | 32)) {
1926
- const isCustomElement = el.tagName.includes("-");
1927
- for (const key in props) {
1928
- let ignore;
1929
- let clientValue = props[key];
1930
- const zova = _getValidZova(parentComponent);
1931
- if (zova) {
1932
- const res = zova.meta.$ssr._hydratePropHasMismatch(
1933
- el,
1934
- key,
1935
- clientValue,
1936
- vnode,
1937
- parentComponent
1938
- );
1939
- if (res.ignore) {
1940
- ignore = true;
2007
+ if (knownTemplateRefs.has(rawSetupState[key])) {
2008
+ return false;
2009
+ }
2010
+ }
2011
+ return hasOwn(rawSetupState, key);
2012
+ };
2013
+ if (oldRef != null && oldRef !== ref) {
2014
+ if (isString(oldRef)) {
2015
+ refs[oldRef] = null;
2016
+ if (canSetSetupRef(oldRef)) {
2017
+ setupState[oldRef] = null;
2018
+ }
2019
+ } else if (isRef(oldRef)) {
2020
+ oldRef.value = null;
2021
+ }
2022
+ }
2023
+ if (isFunction(ref)) {
2024
+ callWithErrorHandling(ref, owner, 12, [value, refs]);
2025
+ } else {
2026
+ const _isString = isString(ref);
2027
+ const _isRef = isRef(ref);
2028
+ if (_isString || _isRef) {
2029
+ const doSet = () => {
2030
+ if (rawRef.f) {
2031
+ const existing = _isString ? canSetSetupRef(ref) ? setupState[ref] : refs[ref] : ref.value;
2032
+ if (isUnmount) {
2033
+ isArray(existing) && remove(existing, refValue);
2034
+ } else {
2035
+ if (!isArray(existing)) {
2036
+ if (_isString) {
2037
+ refs[ref] = [refValue];
2038
+ if (canSetSetupRef(ref)) {
2039
+ setupState[ref] = refs[ref];
2040
+ }
1941
2041
  } else {
1942
- clientValue = res.clientValue;
1943
- }
1944
- }
1945
- if (!ignore) {
1946
- if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && // #11189 skip if this node has directives that have created hooks
1947
- // as it could have mutated the DOM in any possible way
1948
- !(dirs && dirs.some((d) => d.dir.created)) && propHasMismatch(el, key, props[key], vnode, parentComponent)) {
1949
- logMismatchError();
2042
+ ref.value = [refValue];
2043
+ if (rawRef.k) refs[rawRef.k] = ref.value;
1950
2044
  }
1951
- }
1952
- if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
1953
- key[0] === "." || isCustomElement) {
1954
- patchProp(el, key, null, props[key], void 0, parentComponent);
2045
+ } else if (!existing.includes(refValue)) {
2046
+ existing.push(refValue);
1955
2047
  }
1956
2048
  }
1957
- } else if (props.onClick) {
1958
- patchProp(
1959
- el,
1960
- "onClick",
1961
- null,
1962
- props.onClick,
1963
- void 0,
1964
- parentComponent
1965
- );
1966
- } else if (patchFlag & 4 && isReactive(props.style)) {
1967
- for (const key in props.style) props.style[key];
2049
+ } else if (_isString) {
2050
+ refs[ref] = value;
2051
+ if (canSetSetupRef(ref)) {
2052
+ setupState[ref] = value;
2053
+ }
2054
+ } else if (_isRef) {
2055
+ ref.value = value;
2056
+ if (rawRef.k) refs[rawRef.k] = value;
2057
+ } else if (!!(process.env.NODE_ENV !== "production")) {
2058
+ warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
1968
2059
  }
2060
+ };
2061
+ if (value) {
2062
+ doSet.id = -1;
2063
+ queuePostRenderEffect(doSet, parentSuspense);
2064
+ } else {
2065
+ doSet();
1969
2066
  }
1970
- let vnodeHooks;
1971
- if (vnodeHooks = props && props.onVnodeBeforeMount) {
1972
- invokeVNodeHook(vnodeHooks, parentComponent, vnode);
1973
- }
1974
- if (dirs) {
1975
- invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
1976
- }
1977
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
1978
- queueEffectWithSuspense(() => {
1979
- vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
1980
- needCallTransitionHooks && transition.enter(el);
1981
- dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
1982
- }, parentSuspense);
1983
- }
2067
+ } else if (!!(process.env.NODE_ENV !== "production")) {
2068
+ warn$1("Invalid template ref type:", ref, `(${typeof ref})`);
1984
2069
  }
1985
- return el.nextSibling;
1986
- };
1987
- const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
1988
- optimized = optimized || !!parentVNode.dynamicChildren;
1989
- const children = parentVNode.children;
1990
- const l = children.length;
1991
- let hasWarned = false;
1992
- for (let i = 0; i < l; i++) {
1993
- const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
1994
- const isText = vnode.type === Text;
1995
- if (node) {
1996
- if (isText && !optimized) {
1997
- if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
1998
- insert(
1999
- createText(
2000
- node.data.slice(vnode.children.length)
2001
- ),
2002
- container,
2003
- nextSibling(node)
2004
- );
2005
- node.data = vnode.children;
2006
- }
2007
- }
2008
- node = hydrateNode(
2009
- node,
2010
- vnode,
2011
- parentComponent,
2012
- parentSuspense,
2013
- slotScopeIds,
2014
- optimized
2015
- );
2016
- } else if (isText && !vnode.children) {
2017
- insert(vnode.el = createText(""), container);
2018
- } else {
2019
- if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
2020
- if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && !hasWarned) {
2021
- warn$1(
2022
- `Hydration children mismatch on`,
2023
- container,
2024
- `
2025
- Server rendered element contains fewer child nodes than client vdom.`
2026
- );
2027
- hasWarned = true;
2028
- }
2029
- logMismatchError();
2030
- }
2031
- patch(
2032
- null,
2033
- vnode,
2034
- container,
2035
- null,
2036
- parentComponent,
2037
- parentSuspense,
2038
- getContainerType(container),
2039
- slotScopeIds
2040
- );
2041
- }
2070
+ }
2071
+ }
2072
+
2073
+ let hasLoggedMismatchError = false;
2074
+ const logMismatchError = () => {
2075
+ if (hasLoggedMismatchError) {
2076
+ return;
2077
+ }
2078
+ console.error("Hydration completed but contains mismatches.");
2079
+ hasLoggedMismatchError = true;
2080
+ };
2081
+ const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
2082
+ const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
2083
+ const getContainerType = (container) => {
2084
+ if (container.nodeType !== 1) return void 0;
2085
+ if (isSVGContainer(container)) return "svg";
2086
+ if (isMathMLContainer(container)) return "mathml";
2087
+ return void 0;
2088
+ };
2089
+ const isComment = (node) => node.nodeType === 8;
2090
+ function createHydrationFunctions(rendererInternals) {
2091
+ const {
2092
+ mt: mountComponent,
2093
+ p: patch,
2094
+ o: {
2095
+ patchProp,
2096
+ createText,
2097
+ nextSibling,
2098
+ parentNode,
2099
+ remove,
2100
+ insert,
2101
+ createComment
2042
2102
  }
2043
- return node;
2044
- };
2045
- const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
2046
- const { slotScopeIds: fragmentSlotScopeIds } = vnode;
2047
- if (fragmentSlotScopeIds) {
2048
- slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
2103
+ } = rendererInternals;
2104
+ const hydrate = (vnode, container) => {
2105
+ if (!container.hasChildNodes()) {
2106
+ (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
2107
+ `Attempting to hydrate existing markup but container is empty. Performing full mount instead.`
2108
+ );
2109
+ patch(null, vnode, container);
2110
+ flushPostFlushCbs();
2111
+ container._vnode = vnode;
2112
+ return;
2049
2113
  }
2050
- const container = parentNode(node);
2051
- const next = hydrateChildren(
2052
- nextSibling(node),
2114
+ hydrateNode(container.firstChild, vnode, null, null, null);
2115
+ flushPostFlushCbs();
2116
+ container._vnode = vnode;
2117
+ };
2118
+ const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
2119
+ optimized = optimized || !!vnode.dynamicChildren;
2120
+ const isFragmentStart = isComment(node) && node.data === "[";
2121
+ const onMismatch = () => handleMismatch(
2122
+ node,
2053
2123
  vnode,
2054
- container,
2055
2124
  parentComponent,
2056
2125
  parentSuspense,
2057
2126
  slotScopeIds,
2058
- optimized
2127
+ isFragmentStart
2059
2128
  );
2060
- if (next && isComment(next) && next.data === "]") {
2061
- return nextSibling(vnode.anchor = next);
2062
- } else {
2063
- logMismatchError();
2064
- insert(vnode.anchor = createComment(`]`), container, next);
2065
- return next;
2129
+ const { type, ref, shapeFlag, patchFlag } = vnode;
2130
+ let domType = node.nodeType;
2131
+ vnode.el = node;
2132
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
2133
+ def(node, "__vnode", vnode, true);
2134
+ def(node, "__vueParentComponent", parentComponent, true);
2066
2135
  }
2067
- };
2068
- const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
2069
- if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
2070
- (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
2071
- `Hydration node mismatch:
2072
- - rendered on server:`,
2073
- node,
2074
- node.nodeType === 3 ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``,
2075
- `
2076
- - expected on client:`,
2077
- vnode.type
2078
- );
2079
- logMismatchError();
2136
+ if (patchFlag === -2) {
2137
+ optimized = false;
2138
+ vnode.dynamicChildren = null;
2080
2139
  }
2081
- vnode.el = null;
2082
- if (isFragment) {
2083
- const end = locateClosingAnchor(node);
2084
- while (true) {
2085
- const next2 = nextSibling(node);
2086
- if (next2 && next2 !== end) {
2087
- remove(next2);
2140
+ let nextNode = null;
2141
+ switch (type) {
2142
+ case Text:
2143
+ if (domType !== 3) {
2144
+ if (vnode.children === "") {
2145
+ insert(vnode.el = createText(""), parentNode(node), node);
2146
+ nextNode = node;
2147
+ } else {
2148
+ nextNode = onMismatch();
2149
+ }
2088
2150
  } else {
2089
- break;
2151
+ if (node.data !== vnode.children) {
2152
+ node.data = vnode.children;
2153
+ }
2154
+ nextNode = nextSibling(node);
2090
2155
  }
2091
- }
2092
- }
2093
- const next = nextSibling(node);
2094
- const container = parentNode(node);
2095
- remove(node);
2096
- patch(
2097
- null,
2098
- vnode,
2099
- container,
2100
- next,
2101
- parentComponent,
2102
- parentSuspense,
2103
- getContainerType(container),
2104
- slotScopeIds
2105
- );
2106
- if (parentComponent) {
2107
- parentComponent.vnode.el = vnode.el;
2108
- updateHOCHostEl(parentComponent, vnode.el);
2109
- }
2110
- return next;
2111
- };
2112
- const locateClosingAnchor = (node, open = "[", close = "]") => {
2113
- let match = 0;
2114
- while (node) {
2115
- node = nextSibling(node);
2116
- if (node && isComment(node)) {
2117
- if (node.data === open) match++;
2118
- if (node.data === close) {
2119
- if (match === 0) {
2120
- return nextSibling(node);
2121
- } else {
2122
- match--;
2156
+ break;
2157
+ case Comment:
2158
+ if (isTemplateNode(node)) {
2159
+ nextNode = nextSibling(node);
2160
+ replaceNode(
2161
+ vnode.el = node.content.firstChild,
2162
+ node,
2163
+ parentComponent
2164
+ );
2165
+ } else if (domType !== 8 || isFragmentStart) {
2166
+ nextNode = onMismatch();
2167
+ } else {
2168
+ nextNode = nextSibling(node);
2169
+ }
2170
+ break;
2171
+ case Static:
2172
+ if (isFragmentStart) {
2173
+ node = nextSibling(node);
2174
+ domType = node.nodeType;
2175
+ }
2176
+ if (domType === 1 || domType === 3) {
2177
+ nextNode = node;
2178
+ const needToAdoptContent = !vnode.children.length;
2179
+ for (let i = 0; i < vnode.staticCount; i++) {
2180
+ if (needToAdoptContent)
2181
+ vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
2182
+ if (i === vnode.staticCount - 1) {
2183
+ vnode.anchor = nextNode;
2184
+ }
2185
+ nextNode = nextSibling(nextNode);
2123
2186
  }
2187
+ return isFragmentStart ? nextSibling(nextNode) : nextNode;
2188
+ } else {
2189
+ onMismatch();
2124
2190
  }
2125
- }
2126
- }
2127
- return node;
2128
- };
2129
- const replaceNode = (newNode, oldNode, parentComponent) => {
2130
- const parentNode2 = oldNode.parentNode;
2131
- if (parentNode2) {
2132
- parentNode2.replaceChild(newNode, oldNode);
2133
- }
2134
- let parent = parentComponent;
2135
- while (parent) {
2136
- if (parent.vnode.el === oldNode) {
2137
- parent.vnode.el = parent.subTree.el = newNode;
2138
- }
2139
- parent = parent.parent;
2140
- }
2141
- };
2142
- const isTemplateNode = (node) => {
2143
- return node.nodeType === 1 && node.tagName === "TEMPLATE";
2144
- };
2145
- return [hydrate, hydrateNode];
2146
- }
2147
- function propHasMismatch(el, key, clientValue, vnode, instance) {
2148
- let mismatchType;
2149
- let mismatchKey;
2150
- let actual;
2151
- let expected;
2152
- if (key === "class") {
2153
- actual = el.getAttribute("class");
2154
- expected = normalizeClass(clientValue);
2155
- if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
2156
- mismatchType = 2 /* CLASS */;
2157
- mismatchKey = `class`;
2158
- }
2159
- } else if (key === "style") {
2160
- actual = el.getAttribute("style") || "";
2161
- expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
2162
- const actualMap = toStyleMap(actual);
2163
- const expectedMap = toStyleMap(expected);
2164
- if (vnode.dirs) {
2165
- for (const { dir, value } of vnode.dirs) {
2166
- if (dir.name === "show" && !value) {
2167
- expectedMap.set("display", "none");
2168
- }
2169
- }
2170
- }
2171
- if (instance) {
2172
- resolveCssVars(instance, vnode, expectedMap);
2173
- }
2174
- if (!isMapEqual(actualMap, expectedMap)) {
2175
- mismatchType = 3 /* STYLE */;
2176
- mismatchKey = "style";
2177
- }
2178
- } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
2179
- if (isBooleanAttr(key)) {
2180
- actual = el.hasAttribute(key);
2181
- expected = includeBooleanAttr(clientValue);
2182
- } else if (clientValue == null) {
2183
- actual = el.hasAttribute(key);
2184
- expected = false;
2185
- } else {
2186
- if (el.hasAttribute(key)) {
2187
- actual = el.getAttribute(key);
2188
- } else if (key === "value" && el.tagName === "TEXTAREA") {
2189
- actual = el.value;
2190
- } else {
2191
- actual = false;
2192
- }
2193
- expected = isRenderableAttrValue(clientValue) ? String(clientValue) : false;
2194
- }
2195
- if (actual !== expected) {
2196
- mismatchType = 4 /* ATTRIBUTE */;
2197
- mismatchKey = key;
2198
- }
2199
- }
2200
- if (mismatchType != null && !isMismatchAllowed(el, mismatchType)) {
2201
- const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
2202
- const preSegment = `Hydration ${MismatchTypeString[mismatchType]} mismatch on`;
2203
- const postSegment = `
2204
- - rendered on server: ${format(actual)}
2205
- - expected on client: ${format(expected)}
2206
- Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
2207
- You should fix the source of the mismatch.`;
2208
- {
2209
- warn$1(preSegment, el, postSegment);
2210
- }
2211
- return true;
2212
- }
2213
- return false;
2214
- }
2215
- function toClassSet(str) {
2216
- return new Set(str.trim().split(/\s+/));
2217
- }
2218
- function isSetEqual(a, b) {
2219
- if (a.size !== b.size) {
2220
- return false;
2221
- }
2222
- for (const s of a) {
2223
- if (!b.has(s)) {
2224
- return false;
2225
- }
2226
- }
2227
- return true;
2228
- }
2229
- function toStyleMap(str) {
2230
- const styleMap = /* @__PURE__ */ new Map();
2231
- for (const item of str.split(";")) {
2232
- let [key, value] = item.split(":");
2233
- key = key.trim();
2234
- value = value && value.trim();
2235
- if (key && value) {
2236
- styleMap.set(key, value);
2237
- }
2238
- }
2239
- return styleMap;
2240
- }
2241
- function isMapEqual(a, b) {
2242
- if (a.size !== b.size) {
2243
- return false;
2244
- }
2245
- for (const [key, value] of a) {
2246
- if (value !== b.get(key)) {
2247
- return false;
2248
- }
2249
- }
2250
- return true;
2251
- }
2252
- function resolveCssVars(instance, vnode, expectedMap) {
2253
- const root = instance.subTree;
2254
- if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
2255
- const cssVars = instance.getCssVars();
2256
- for (const key in cssVars) {
2257
- expectedMap.set(
2258
- `--${getEscapedCssVarName(key, false)}`,
2259
- String(cssVars[key])
2260
- );
2261
- }
2262
- }
2263
- if (vnode === root && instance.parent) {
2264
- resolveCssVars(instance.parent, instance.vnode, expectedMap);
2265
- }
2266
- }
2267
- const allowMismatchAttr = "data-allow-mismatch";
2268
- const MismatchTypeString = {
2269
- [0 /* TEXT */]: "text",
2270
- [1 /* CHILDREN */]: "children",
2271
- [2 /* CLASS */]: "class",
2272
- [3 /* STYLE */]: "style",
2273
- [4 /* ATTRIBUTE */]: "attribute"
2274
- };
2275
- function isMismatchAllowed(el, allowedType) {
2276
- if (allowedType === 0 /* TEXT */ || allowedType === 1 /* CHILDREN */) {
2277
- while (el && !el.hasAttribute(allowMismatchAttr)) {
2278
- el = el.parentElement;
2279
- }
2280
- }
2281
- const allowedAttr = el && el.getAttribute(allowMismatchAttr);
2282
- if (allowedAttr == null) {
2283
- return false;
2284
- } else if (allowedAttr === "") {
2285
- return true;
2286
- } else {
2287
- const list = allowedAttr.split(",");
2288
- if (allowedType === 0 /* TEXT */ && list.includes("children")) {
2289
- return true;
2290
- }
2291
- return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
2292
- }
2293
- }
2294
-
2295
- const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
2296
- const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
2297
- const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
2298
- const id = requestIdleCallback(hydrate, { timeout });
2299
- return () => cancelIdleCallback(id);
2300
- };
2301
- function elementIsVisibleInViewport(el) {
2302
- const { top, left, bottom, right } = el.getBoundingClientRect();
2303
- const { innerHeight, innerWidth } = window;
2304
- return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
2305
- }
2306
- const hydrateOnVisible = (opts) => (hydrate, forEach) => {
2307
- const ob = new IntersectionObserver((entries) => {
2308
- for (const e of entries) {
2309
- if (!e.isIntersecting) continue;
2310
- ob.disconnect();
2311
- hydrate();
2312
- break;
2313
- }
2314
- }, opts);
2315
- forEach((el) => {
2316
- if (!(el instanceof Element)) return;
2317
- if (elementIsVisibleInViewport(el)) {
2318
- hydrate();
2319
- ob.disconnect();
2320
- return false;
2321
- }
2322
- ob.observe(el);
2323
- });
2324
- return () => ob.disconnect();
2325
- };
2326
- const hydrateOnMediaQuery = (query) => (hydrate) => {
2327
- if (query) {
2328
- const mql = matchMedia(query);
2329
- if (mql.matches) {
2330
- hydrate();
2331
- } else {
2332
- mql.addEventListener("change", hydrate, { once: true });
2333
- return () => mql.removeEventListener("change", hydrate);
2334
- }
2335
- }
2336
- };
2337
- const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => {
2338
- if (isString(interactions)) interactions = [interactions];
2339
- let hasHydrated = false;
2340
- const doHydrate = (e) => {
2341
- if (!hasHydrated) {
2342
- hasHydrated = true;
2343
- teardown();
2344
- hydrate();
2345
- e.target.dispatchEvent(new e.constructor(e.type, e));
2346
- }
2347
- };
2348
- const teardown = () => {
2349
- forEach((el) => {
2350
- for (const i of interactions) {
2351
- el.removeEventListener(i, doHydrate);
2352
- }
2353
- });
2354
- };
2355
- forEach((el) => {
2356
- for (const i of interactions) {
2357
- el.addEventListener(i, doHydrate, { once: true });
2358
- }
2359
- });
2360
- return teardown;
2361
- };
2362
- function forEachElement(node, cb) {
2363
- if (isComment(node) && node.data === "[") {
2364
- let depth = 1;
2365
- let next = node.nextSibling;
2366
- while (next) {
2367
- if (next.nodeType === 1) {
2368
- const result = cb(next);
2369
- if (result === false) {
2370
- break;
2371
- }
2372
- } else if (isComment(next)) {
2373
- if (next.data === "]") {
2374
- if (--depth === 0) break;
2375
- } else if (next.data === "[") {
2376
- depth++;
2377
- }
2378
- }
2379
- next = next.nextSibling;
2380
- }
2381
- } else {
2382
- cb(node);
2383
- }
2384
- }
2385
-
2386
- const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
2387
- function _getValidZova(instance) {
2388
- while (instance) {
2389
- if (instance.zova) return instance.zova;
2390
- instance = instance.parent;
2391
- }
2392
- }
2393
- /*! #__NO_SIDE_EFFECTS__ */
2394
- // @__NO_SIDE_EFFECTS__
2395
- function defineAsyncComponent(source) {
2396
- if (isFunction(source)) {
2397
- source = { loader: source };
2398
- }
2399
- const {
2400
- loader,
2401
- loadingComponent,
2402
- errorComponent,
2403
- delay = 200,
2404
- hydrate: hydrateStrategy,
2405
- timeout,
2406
- // undefined = never times out
2407
- suspensible = true,
2408
- onError: userOnError
2409
- } = source;
2410
- let pendingRequest = null;
2411
- let resolvedComp;
2412
- let retries = 0;
2413
- const retry = () => {
2414
- retries++;
2415
- pendingRequest = null;
2416
- return load();
2417
- };
2418
- const load = () => {
2419
- let thisRequest;
2420
- return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
2421
- err = err instanceof Error ? err : new Error(String(err));
2422
- if (userOnError) {
2423
- return new Promise((resolve, reject) => {
2424
- const userRetry = () => resolve(retry());
2425
- const userFail = () => reject(err);
2426
- userOnError(err, userRetry, userFail, retries + 1);
2427
- });
2428
- } else {
2429
- throw err;
2430
- }
2431
- }).then((comp) => {
2432
- if (thisRequest !== pendingRequest && pendingRequest) {
2433
- return pendingRequest;
2434
- }
2435
- if (!!(process.env.NODE_ENV !== "production") && !comp) {
2436
- warn$1(
2437
- `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
2438
- );
2439
- }
2440
- if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
2441
- comp = comp.default;
2442
- }
2443
- if (!!(process.env.NODE_ENV !== "production") && comp && !isObject(comp) && !isFunction(comp)) {
2444
- throw new Error(`Invalid async component load result: ${comp}`);
2445
- }
2446
- resolvedComp = comp;
2447
- return comp;
2448
- }));
2449
- };
2450
- return defineComponent({
2451
- name: "AsyncComponentWrapper",
2452
- __asyncLoader: load,
2453
- __asyncHydrate(el, instance, hydrate) {
2454
- const doHydrate = hydrateStrategy ? () => {
2455
- const teardown = hydrateStrategy(
2456
- hydrate,
2457
- (cb) => forEachElement(el, cb)
2458
- );
2459
- if (teardown) {
2460
- (instance.bum || (instance.bum = [])).push(teardown);
2191
+ break;
2192
+ case Fragment:
2193
+ if (!isFragmentStart) {
2194
+ nextNode = onMismatch();
2195
+ } else {
2196
+ nextNode = hydrateFragment(
2197
+ node,
2198
+ vnode,
2199
+ parentComponent,
2200
+ parentSuspense,
2201
+ slotScopeIds,
2202
+ optimized
2203
+ );
2461
2204
  }
2462
- } : hydrate;
2463
- if (resolvedComp) {
2464
- doHydrate();
2465
- } else {
2466
- const zova = _getValidZova(instance);
2467
- zova.meta.$ssr._hydratingInc();
2468
- load().then(() => {
2469
- !instance.isUnmounted && doHydrate();
2470
- zova.meta.$ssr._hydratingDec();
2471
- });
2472
- }
2473
- },
2474
- get __asyncResolved() {
2475
- return resolvedComp;
2476
- },
2477
- setup() {
2478
- const instance = currentInstance;
2479
- markAsyncBoundary(instance);
2480
- if (resolvedComp) {
2481
- return () => createInnerComp(resolvedComp, instance);
2482
- }
2483
- const onError = (err) => {
2484
- pendingRequest = null;
2485
- handleError(
2486
- err,
2487
- instance,
2488
- 13,
2489
- !errorComponent
2490
- );
2491
- };
2492
- if (suspensible && instance.suspense || isInSSRComponentSetup) {
2493
- return load().then((comp) => {
2494
- return () => createInnerComp(comp, instance);
2495
- }).catch((err) => {
2496
- onError(err);
2497
- return () => errorComponent ? createVNode(errorComponent, {
2498
- error: err
2499
- }) : null;
2500
- });
2501
- }
2502
- const loaded = ref(false);
2503
- const error = ref();
2504
- const delayed = ref(!!delay);
2505
- if (delay) {
2506
- setTimeout(() => {
2507
- delayed.value = false;
2508
- }, delay);
2509
- }
2510
- if (timeout != null) {
2511
- setTimeout(() => {
2512
- if (!loaded.value && !error.value) {
2513
- const err = new Error(
2514
- `Async component timed out after ${timeout}ms.`
2205
+ break;
2206
+ default:
2207
+ if (shapeFlag & 1) {
2208
+ if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
2209
+ nextNode = onMismatch();
2210
+ } else {
2211
+ nextNode = hydrateElement(
2212
+ node,
2213
+ vnode,
2214
+ parentComponent,
2215
+ parentSuspense,
2216
+ slotScopeIds,
2217
+ optimized
2515
2218
  );
2516
- onError(err);
2517
- error.value = err;
2518
2219
  }
2519
- }, timeout);
2520
- }
2521
- load().then(() => {
2522
- loaded.value = true;
2523
- if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2524
- instance.parent.update();
2525
- }
2526
- }).catch((err) => {
2527
- onError(err);
2528
- error.value = err;
2529
- });
2530
- return () => {
2531
- if (loaded.value && resolvedComp) {
2532
- return createInnerComp(resolvedComp, instance);
2533
- } else if (error.value && errorComponent) {
2534
- return createVNode(errorComponent, {
2535
- error: error.value
2536
- });
2537
- } else if (loadingComponent && !delayed.value) {
2538
- return createVNode(loadingComponent);
2539
- }
2540
- };
2541
- }
2542
- });
2543
- }
2544
- function createInnerComp(comp, parent) {
2545
- const { ref: ref2, props, children, ce } = parent.vnode;
2546
- const vnode = createVNode(comp, props, children);
2547
- vnode.ref = ref2;
2548
- vnode.ce = ce;
2549
- delete parent.vnode.ce;
2550
- vnode.zovaHostProviders = parent.vnode.zovaHostProviders;
2551
- return vnode;
2552
- }
2553
-
2554
- const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
2555
- const KeepAliveImpl = {
2556
- name: `KeepAlive`,
2557
- // Marker for special handling inside the renderer. We are not using a ===
2558
- // check directly on KeepAlive in the renderer, because importing it directly
2559
- // would prevent it from being tree-shaken.
2560
- __isKeepAlive: true,
2561
- props: {
2562
- include: [String, RegExp, Array],
2563
- exclude: [String, RegExp, Array],
2564
- max: [String, Number]
2565
- },
2566
- setup(props, { slots }) {
2567
- const instance = getCurrentInstance();
2568
- const sharedContext = instance.ctx;
2569
- if (!sharedContext.renderer) {
2570
- return () => {
2571
- const children = slots.default && slots.default();
2572
- return children && children.length === 1 ? children[0] : children;
2573
- };
2220
+ } else if (shapeFlag & 6) {
2221
+ vnode.slotScopeIds = slotScopeIds;
2222
+ const container = parentNode(node);
2223
+ if (isFragmentStart) {
2224
+ nextNode = locateClosingAnchor(node);
2225
+ } else if (isComment(node) && node.data === "teleport start") {
2226
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
2227
+ } else {
2228
+ nextNode = nextSibling(node);
2229
+ }
2230
+ mountComponent(
2231
+ vnode,
2232
+ container,
2233
+ null,
2234
+ parentComponent,
2235
+ parentSuspense,
2236
+ getContainerType(container),
2237
+ optimized
2238
+ );
2239
+ if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
2240
+ let subTree;
2241
+ if (isFragmentStart) {
2242
+ subTree = createVNode(Fragment);
2243
+ subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
2244
+ } else {
2245
+ subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
2246
+ }
2247
+ subTree.el = node;
2248
+ vnode.component.subTree = subTree;
2249
+ }
2250
+ } else if (shapeFlag & 64) {
2251
+ if (domType !== 8) {
2252
+ nextNode = onMismatch();
2253
+ } else {
2254
+ nextNode = vnode.type.hydrate(
2255
+ node,
2256
+ vnode,
2257
+ parentComponent,
2258
+ parentSuspense,
2259
+ slotScopeIds,
2260
+ optimized,
2261
+ rendererInternals,
2262
+ hydrateChildren
2263
+ );
2264
+ }
2265
+ } else if (shapeFlag & 128) {
2266
+ nextNode = vnode.type.hydrate(
2267
+ node,
2268
+ vnode,
2269
+ parentComponent,
2270
+ parentSuspense,
2271
+ getContainerType(parentNode(node)),
2272
+ slotScopeIds,
2273
+ optimized,
2274
+ rendererInternals,
2275
+ hydrateNode
2276
+ );
2277
+ } else if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) {
2278
+ warn$1("Invalid HostVNode type:", type, `(${typeof type})`);
2279
+ }
2574
2280
  }
2575
- const cache = /* @__PURE__ */ new Map();
2576
- const keys = /* @__PURE__ */ new Set();
2577
- let current = null;
2578
- if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
2579
- instance.__v_cache = cache;
2281
+ if (ref != null) {
2282
+ setRef(ref, null, parentSuspense, vnode);
2580
2283
  }
2581
- const parentSuspense = instance.suspense;
2582
- const {
2583
- renderer: {
2584
- p: patch,
2585
- m: move,
2586
- um: _unmount,
2587
- o: { createElement }
2284
+ return nextNode;
2285
+ };
2286
+ function _getValidZova(instance) {
2287
+ while (instance) {
2288
+ if (instance.zova) return instance.zova;
2289
+ instance = instance.parent;
2290
+ }
2291
+ }
2292
+ const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
2293
+ optimized = optimized || !!vnode.dynamicChildren;
2294
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
2295
+ const forcePatch = type === "input" || type === "option";
2296
+ if (!!(process.env.NODE_ENV !== "production") || forcePatch || patchFlag !== -1) {
2297
+ if (dirs) {
2298
+ invokeDirectiveHook(vnode, null, parentComponent, "created");
2588
2299
  }
2589
- } = sharedContext;
2590
- const storageContainer = createElement("div");
2591
- sharedContext.activate = (vnode, container, anchor, namespace, optimized) => {
2592
- const instance2 = vnode.component;
2593
- move(vnode, container, anchor, 0, parentSuspense);
2594
- patch(
2595
- instance2.vnode,
2596
- vnode,
2597
- container,
2598
- anchor,
2599
- instance2,
2600
- parentSuspense,
2601
- namespace,
2602
- vnode.slotScopeIds,
2603
- optimized
2604
- );
2605
- queuePostRenderEffect(() => {
2606
- instance2.isDeactivated = false;
2607
- if (instance2.a) {
2608
- invokeArrayFns(instance2.a);
2609
- }
2610
- const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
2611
- if (vnodeHook) {
2612
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
2300
+ let needCallTransitionHooks = false;
2301
+ if (isTemplateNode(el)) {
2302
+ needCallTransitionHooks = needTransition(
2303
+ null,
2304
+ // no need check parentSuspense in hydration
2305
+ transition
2306
+ ) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
2307
+ const content = el.content.firstChild;
2308
+ if (needCallTransitionHooks) {
2309
+ transition.beforeEnter(content);
2613
2310
  }
2614
- }, parentSuspense);
2615
- if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
2616
- devtoolsComponentAdded(instance2);
2311
+ replaceNode(content, el, parentComponent);
2312
+ vnode.el = el = content;
2617
2313
  }
2618
- };
2619
- sharedContext.deactivate = (vnode) => {
2620
- const instance2 = vnode.component;
2621
- invalidateMount(instance2.m);
2622
- invalidateMount(instance2.a);
2623
- move(vnode, storageContainer, null, 1, parentSuspense);
2624
- queuePostRenderEffect(() => {
2625
- if (instance2.da) {
2626
- invokeArrayFns(instance2.da);
2314
+ if (shapeFlag & 16 && // skip if element has innerHTML / textContent
2315
+ !(props && (props.innerHTML || props.textContent))) {
2316
+ let next = hydrateChildren(
2317
+ el.firstChild,
2318
+ vnode,
2319
+ el,
2320
+ parentComponent,
2321
+ parentSuspense,
2322
+ slotScopeIds,
2323
+ optimized
2324
+ );
2325
+ let hasWarned = false;
2326
+ while (next) {
2327
+ if (!isMismatchAllowed(el, 1 /* CHILDREN */)) {
2328
+ if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && !hasWarned) {
2329
+ warn$1(
2330
+ `Hydration children mismatch on`,
2331
+ el,
2332
+ `
2333
+ Server rendered element contains more child nodes than client vdom.`
2334
+ );
2335
+ hasWarned = true;
2336
+ }
2337
+ logMismatchError();
2338
+ }
2339
+ const cur = next;
2340
+ next = next.nextSibling;
2341
+ remove(cur);
2627
2342
  }
2628
- const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
2629
- if (vnodeHook) {
2630
- invokeVNodeHook(vnodeHook, instance2.parent, vnode);
2343
+ } else if (shapeFlag & 8) {
2344
+ let clientText = vnode.children;
2345
+ if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
2346
+ clientText = clientText.slice(1);
2347
+ }
2348
+ if (el.textContent !== clientText) {
2349
+ if (!isMismatchAllowed(el, 0 /* TEXT */)) {
2350
+ (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
2351
+ `Hydration text content mismatch on`,
2352
+ el,
2353
+ `
2354
+ - rendered on server: ${el.textContent}
2355
+ - expected on client: ${vnode.children}`
2356
+ );
2357
+ logMismatchError();
2358
+ }
2359
+ el.textContent = vnode.children;
2631
2360
  }
2632
- instance2.isDeactivated = true;
2633
- }, parentSuspense);
2634
- if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
2635
- devtoolsComponentAdded(instance2);
2636
2361
  }
2637
- };
2638
- function unmount(vnode) {
2639
- resetShapeFlag(vnode);
2640
- _unmount(vnode, instance, parentSuspense, true);
2641
- }
2642
- function pruneCache(filter) {
2643
- cache.forEach((vnode, key) => {
2644
- const name = getComponentName(vnode.type);
2645
- if (name && !filter(name)) {
2646
- pruneCacheEntry(key);
2362
+ if (props) {
2363
+ if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__ || forcePatch || !optimized || patchFlag & (16 | 32)) {
2364
+ const isCustomElement = el.tagName.includes("-");
2365
+ for (const key in props) {
2366
+ let ignore;
2367
+ let clientValue = props[key];
2368
+ const zova = _getValidZova(parentComponent);
2369
+ if (zova) {
2370
+ const res = zova.meta.$ssr._hydratePropHasMismatch(
2371
+ el,
2372
+ key,
2373
+ clientValue,
2374
+ vnode,
2375
+ parentComponent
2376
+ );
2377
+ if (res.ignore) {
2378
+ ignore = true;
2379
+ } else {
2380
+ clientValue = res.clientValue;
2381
+ }
2382
+ }
2383
+ if (!ignore) {
2384
+ if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && // #11189 skip if this node has directives that have created hooks
2385
+ // as it could have mutated the DOM in any possible way
2386
+ !(dirs && dirs.some((d) => d.dir.created)) && propHasMismatch(el, key, props[key], vnode, parentComponent)) {
2387
+ logMismatchError();
2388
+ }
2389
+ }
2390
+ if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
2391
+ key[0] === "." || isCustomElement) {
2392
+ patchProp(el, key, null, props[key], void 0, parentComponent);
2393
+ }
2394
+ }
2395
+ } else if (props.onClick) {
2396
+ patchProp(
2397
+ el,
2398
+ "onClick",
2399
+ null,
2400
+ props.onClick,
2401
+ void 0,
2402
+ parentComponent
2403
+ );
2404
+ } else if (patchFlag & 4 && isReactive(props.style)) {
2405
+ for (const key in props.style) props.style[key];
2647
2406
  }
2648
- });
2407
+ }
2408
+ let vnodeHooks;
2409
+ if (vnodeHooks = props && props.onVnodeBeforeMount) {
2410
+ invokeVNodeHook(vnodeHooks, parentComponent, vnode);
2411
+ }
2412
+ if (dirs) {
2413
+ invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
2414
+ }
2415
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
2416
+ queueEffectWithSuspense(() => {
2417
+ vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
2418
+ needCallTransitionHooks && transition.enter(el);
2419
+ dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
2420
+ }, parentSuspense);
2421
+ }
2649
2422
  }
2650
- function pruneCacheEntry(key) {
2651
- const cached = cache.get(key);
2652
- if (cached && (!current || !isSameVNodeType(cached, current))) {
2653
- unmount(cached);
2654
- } else if (current) {
2655
- resetShapeFlag(current);
2423
+ return el.nextSibling;
2424
+ };
2425
+ const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
2426
+ optimized = optimized || !!parentVNode.dynamicChildren;
2427
+ const children = parentVNode.children;
2428
+ const l = children.length;
2429
+ let hasWarned = false;
2430
+ for (let i = 0; i < l; i++) {
2431
+ const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
2432
+ const isText = vnode.type === Text;
2433
+ if (node) {
2434
+ if (isText && !optimized) {
2435
+ if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
2436
+ insert(
2437
+ createText(
2438
+ node.data.slice(vnode.children.length)
2439
+ ),
2440
+ container,
2441
+ nextSibling(node)
2442
+ );
2443
+ node.data = vnode.children;
2444
+ }
2445
+ }
2446
+ node = hydrateNode(
2447
+ node,
2448
+ vnode,
2449
+ parentComponent,
2450
+ parentSuspense,
2451
+ slotScopeIds,
2452
+ optimized
2453
+ );
2454
+ } else if (isText && !vnode.children) {
2455
+ insert(vnode.el = createText(""), container);
2456
+ } else {
2457
+ if (!isMismatchAllowed(container, 1 /* CHILDREN */)) {
2458
+ if ((!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && !hasWarned) {
2459
+ warn$1(
2460
+ `Hydration children mismatch on`,
2461
+ container,
2462
+ `
2463
+ Server rendered element contains fewer child nodes than client vdom.`
2464
+ );
2465
+ hasWarned = true;
2466
+ }
2467
+ logMismatchError();
2468
+ }
2469
+ patch(
2470
+ null,
2471
+ vnode,
2472
+ container,
2473
+ null,
2474
+ parentComponent,
2475
+ parentSuspense,
2476
+ getContainerType(container),
2477
+ slotScopeIds
2478
+ );
2656
2479
  }
2657
- cache.delete(key);
2658
- keys.delete(key);
2659
2480
  }
2660
- watch(
2661
- () => [props.include, props.exclude],
2662
- ([include, exclude]) => {
2663
- include && pruneCache((name) => matches(include, name));
2664
- exclude && pruneCache((name) => !matches(exclude, name));
2665
- },
2666
- // prune post-render after `current` has been updated
2667
- { flush: "post", deep: true }
2481
+ return node;
2482
+ };
2483
+ const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
2484
+ const { slotScopeIds: fragmentSlotScopeIds } = vnode;
2485
+ if (fragmentSlotScopeIds) {
2486
+ slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
2487
+ }
2488
+ const container = parentNode(node);
2489
+ const next = hydrateChildren(
2490
+ nextSibling(node),
2491
+ vnode,
2492
+ container,
2493
+ parentComponent,
2494
+ parentSuspense,
2495
+ slotScopeIds,
2496
+ optimized
2668
2497
  );
2669
- let pendingCacheKey = null;
2670
- const cacheSubtree = () => {
2671
- if (pendingCacheKey != null) {
2672
- if (isSuspense(instance.subTree.type)) {
2673
- queuePostRenderEffect(() => {
2674
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
2675
- }, instance.subTree.suspense);
2498
+ if (next && isComment(next) && next.data === "]") {
2499
+ return nextSibling(vnode.anchor = next);
2500
+ } else {
2501
+ logMismatchError();
2502
+ insert(vnode.anchor = createComment(`]`), container, next);
2503
+ return next;
2504
+ }
2505
+ };
2506
+ const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
2507
+ if (!isMismatchAllowed(node.parentElement, 1 /* CHILDREN */)) {
2508
+ (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
2509
+ `Hydration node mismatch:
2510
+ - rendered on server:`,
2511
+ node,
2512
+ node.nodeType === 3 ? `(text)` : isComment(node) && node.data === "[" ? `(start of fragment)` : ``,
2513
+ `
2514
+ - expected on client:`,
2515
+ vnode.type
2516
+ );
2517
+ logMismatchError();
2518
+ }
2519
+ vnode.el = null;
2520
+ if (isFragment) {
2521
+ const end = locateClosingAnchor(node);
2522
+ while (true) {
2523
+ const next2 = nextSibling(node);
2524
+ if (next2 && next2 !== end) {
2525
+ remove(next2);
2676
2526
  } else {
2677
- cache.set(pendingCacheKey, getInnerChild(instance.subTree));
2678
- }
2679
- }
2680
- };
2681
- onMounted(cacheSubtree);
2682
- onUpdated(cacheSubtree);
2683
- onBeforeUnmount(() => {
2684
- cache.forEach((cached) => {
2685
- const { subTree, suspense } = instance;
2686
- const vnode = getInnerChild(subTree);
2687
- if (cached.type === vnode.type && cached.key === vnode.key) {
2688
- resetShapeFlag(vnode);
2689
- const da = vnode.component.da;
2690
- da && queuePostRenderEffect(da, suspense);
2691
- return;
2527
+ break;
2692
2528
  }
2693
- unmount(cached);
2694
- });
2695
- });
2696
- return () => {
2697
- pendingCacheKey = null;
2698
- if (!slots.default) {
2699
- return current = null;
2700
2529
  }
2701
- const children = slots.default();
2702
- const rawVNode = children[0];
2703
- if (children.length > 1) {
2704
- if (!!(process.env.NODE_ENV !== "production")) {
2705
- warn$1(`KeepAlive should contain exactly one component child.`);
2530
+ }
2531
+ const next = nextSibling(node);
2532
+ const container = parentNode(node);
2533
+ remove(node);
2534
+ patch(
2535
+ null,
2536
+ vnode,
2537
+ container,
2538
+ next,
2539
+ parentComponent,
2540
+ parentSuspense,
2541
+ getContainerType(container),
2542
+ slotScopeIds
2543
+ );
2544
+ if (parentComponent) {
2545
+ parentComponent.vnode.el = vnode.el;
2546
+ updateHOCHostEl(parentComponent, vnode.el);
2547
+ }
2548
+ return next;
2549
+ };
2550
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
2551
+ let match = 0;
2552
+ while (node) {
2553
+ node = nextSibling(node);
2554
+ if (node && isComment(node)) {
2555
+ if (node.data === open) match++;
2556
+ if (node.data === close) {
2557
+ if (match === 0) {
2558
+ return nextSibling(node);
2559
+ } else {
2560
+ match--;
2561
+ }
2706
2562
  }
2707
- current = null;
2708
- return children;
2709
- } else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
2710
- current = null;
2711
- return rawVNode;
2712
- }
2713
- let vnode = getInnerChild(rawVNode);
2714
- if (vnode.type === Comment) {
2715
- current = null;
2716
- return vnode;
2717
- }
2718
- const comp = vnode.type;
2719
- const name = getComponentName(
2720
- isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
2721
- );
2722
- const { include, exclude, max } = props;
2723
- if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
2724
- vnode.shapeFlag &= ~256;
2725
- current = vnode;
2726
- return rawVNode;
2727
2563
  }
2728
- const key = vnode.key == null ? comp : vnode.key;
2729
- const cachedVNode = cache.get(key);
2730
- if (vnode.el) {
2731
- vnode = cloneVNode(vnode);
2732
- if (rawVNode.shapeFlag & 128) {
2733
- rawVNode.ssContent = vnode;
2734
- }
2564
+ }
2565
+ return node;
2566
+ };
2567
+ const replaceNode = (newNode, oldNode, parentComponent) => {
2568
+ const parentNode2 = oldNode.parentNode;
2569
+ if (parentNode2) {
2570
+ parentNode2.replaceChild(newNode, oldNode);
2571
+ }
2572
+ let parent = parentComponent;
2573
+ while (parent) {
2574
+ if (parent.vnode.el === oldNode) {
2575
+ parent.vnode.el = parent.subTree.el = newNode;
2735
2576
  }
2736
- pendingCacheKey = key;
2737
- if (cachedVNode) {
2738
- vnode.el = cachedVNode.el;
2739
- vnode.component = cachedVNode.component;
2740
- vnode.component.zovaHostProviders = vnode.zovaHostProviders;
2741
- if (vnode.transition) {
2742
- setTransitionHooks(vnode, vnode.transition);
2743
- }
2744
- vnode.shapeFlag |= 512;
2745
- keys.delete(key);
2746
- keys.add(key);
2747
- } else {
2748
- keys.add(key);
2749
- if (max && keys.size > parseInt(max, 10)) {
2750
- pruneCacheEntry(keys.values().next().value);
2577
+ parent = parent.parent;
2578
+ }
2579
+ };
2580
+ const isTemplateNode = (node) => {
2581
+ return node.nodeType === 1 && node.tagName === "TEMPLATE";
2582
+ };
2583
+ return [hydrate, hydrateNode];
2584
+ }
2585
+ function propHasMismatch(el, key, clientValue, vnode, instance) {
2586
+ let mismatchType;
2587
+ let mismatchKey;
2588
+ let actual;
2589
+ let expected;
2590
+ if (key === "class") {
2591
+ actual = el.getAttribute("class");
2592
+ expected = normalizeClass(clientValue);
2593
+ if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
2594
+ mismatchType = 2 /* CLASS */;
2595
+ mismatchKey = `class`;
2596
+ }
2597
+ } else if (key === "style") {
2598
+ actual = el.getAttribute("style") || "";
2599
+ expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
2600
+ const actualMap = toStyleMap(actual);
2601
+ const expectedMap = toStyleMap(expected);
2602
+ if (vnode.dirs) {
2603
+ for (const { dir, value } of vnode.dirs) {
2604
+ if (dir.name === "show" && !value) {
2605
+ expectedMap.set("display", "none");
2751
2606
  }
2752
2607
  }
2753
- vnode.shapeFlag |= 256;
2754
- current = vnode;
2755
- return isSuspense(rawVNode.type) ? rawVNode : vnode;
2756
- };
2757
- }
2758
- };
2759
- const KeepAlive = KeepAliveImpl;
2760
- function matches(pattern, name) {
2761
- if (isArray(pattern)) {
2762
- return pattern.some((p) => matches(p, name));
2763
- } else if (isString(pattern)) {
2764
- return pattern.split(",").includes(name);
2765
- } else if (isRegExp(pattern)) {
2766
- pattern.lastIndex = 0;
2767
- return pattern.test(name);
2768
- }
2769
- return false;
2770
- }
2771
- function onActivated(hook, target) {
2772
- registerKeepAliveHook(hook, "a", target);
2773
- }
2774
- function onDeactivated(hook, target) {
2775
- registerKeepAliveHook(hook, "da", target);
2776
- }
2777
- function registerKeepAliveHook(hook, type, target = currentInstance) {
2778
- const wrappedHook = hook.__wdc || (hook.__wdc = () => {
2779
- let current = target;
2780
- while (current) {
2781
- if (current.isDeactivated) {
2782
- return;
2608
+ }
2609
+ if (instance) {
2610
+ resolveCssVars(instance, vnode, expectedMap);
2611
+ }
2612
+ if (!isMapEqual(actualMap, expectedMap)) {
2613
+ mismatchType = 3 /* STYLE */;
2614
+ mismatchKey = "style";
2615
+ }
2616
+ } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
2617
+ if (isBooleanAttr(key)) {
2618
+ actual = el.hasAttribute(key);
2619
+ expected = includeBooleanAttr(clientValue);
2620
+ } else if (clientValue == null) {
2621
+ actual = el.hasAttribute(key);
2622
+ expected = false;
2623
+ } else {
2624
+ if (el.hasAttribute(key)) {
2625
+ actual = el.getAttribute(key);
2626
+ } else if (key === "value" && el.tagName === "TEXTAREA") {
2627
+ actual = el.value;
2628
+ } else {
2629
+ actual = false;
2783
2630
  }
2784
- current = current.parent;
2631
+ expected = isRenderableAttrValue(clientValue) ? String(clientValue) : false;
2785
2632
  }
2786
- return hook();
2787
- });
2788
- injectHook(type, wrappedHook, target);
2789
- if (target) {
2790
- let current = target.parent;
2791
- while (current && current.parent) {
2792
- if (isKeepAlive(current.parent.vnode)) {
2793
- injectToKeepAliveRoot(wrappedHook, type, target, current);
2794
- }
2795
- current = current.parent;
2633
+ if (actual !== expected) {
2634
+ mismatchType = 4 /* ATTRIBUTE */;
2635
+ mismatchKey = key;
2796
2636
  }
2797
2637
  }
2798
- }
2799
- function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
2800
- const injected = injectHook(
2801
- type,
2802
- hook,
2803
- keepAliveRoot,
2804
- true
2805
- /* prepend */
2806
- );
2807
- onUnmounted(() => {
2808
- remove(keepAliveRoot[type], injected);
2809
- }, target);
2810
- }
2811
- function resetShapeFlag(vnode) {
2812
- vnode.shapeFlag &= ~256;
2813
- vnode.shapeFlag &= ~512;
2814
- }
2815
- function getInnerChild(vnode) {
2816
- return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
2817
- }
2818
-
2819
- function injectHook(type, hook, target = currentInstance, prepend = false) {
2820
- if (target) {
2821
- const hooks = target[type] || (target[type] = []);
2822
- const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
2823
- pauseTracking();
2824
- const reset = setCurrentInstance(target);
2825
- const res = callWithAsyncErrorHandling(hook, target, type, args);
2826
- reset();
2827
- resetTracking();
2828
- return res;
2829
- });
2830
- if (prepend) {
2831
- hooks.unshift(wrappedHook);
2832
- } else {
2833
- hooks.push(wrappedHook);
2638
+ if (mismatchType != null && !isMismatchAllowed(el, mismatchType)) {
2639
+ const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
2640
+ const preSegment = `Hydration ${MismatchTypeString[mismatchType]} mismatch on`;
2641
+ const postSegment = `
2642
+ - rendered on server: ${format(actual)}
2643
+ - expected on client: ${format(expected)}
2644
+ Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
2645
+ You should fix the source of the mismatch.`;
2646
+ {
2647
+ warn$1(preSegment, el, postSegment);
2834
2648
  }
2835
- return wrappedHook;
2836
- } else if (!!(process.env.NODE_ENV !== "production")) {
2837
- const apiName = toHandlerKey(ErrorTypeStrings$1[type].replace(/ hook$/, ""));
2838
- warn$1(
2839
- `${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().` + (` If you are using async setup(), make sure to register lifecycle hooks before the first await statement.` )
2840
- );
2649
+ return true;
2841
2650
  }
2651
+ return false;
2842
2652
  }
2843
- const createHook = (lifecycle) => (hook, target = currentInstance) => {
2844
- if (!isInSSRComponentSetup || lifecycle === "sp") {
2845
- injectHook(lifecycle, (...args) => hook(...args), target);
2653
+ function toClassSet(str) {
2654
+ return new Set(str.trim().split(/\s+/));
2655
+ }
2656
+ function isSetEqual(a, b) {
2657
+ if (a.size !== b.size) {
2658
+ return false;
2846
2659
  }
2847
- if (lifecycle === "m" && target && target.isMounted) {
2848
- hook();
2660
+ for (const s of a) {
2661
+ if (!b.has(s)) {
2662
+ return false;
2663
+ }
2849
2664
  }
2850
- };
2851
- const onBeforeMount = createHook("bm");
2852
- const onMounted = createHook("m");
2853
- const onBeforeUpdate = createHook(
2854
- "bu"
2855
- );
2856
- const onUpdated = createHook("u");
2857
- const onBeforeUnmount = createHook(
2858
- "bum"
2859
- );
2860
- const onUnmounted = createHook("um");
2861
- const onServerPrefetch = createHook(
2862
- "sp"
2863
- );
2864
- const onRenderTriggered = createHook("rtg");
2865
- const onRenderTracked = createHook("rtc");
2866
- function onErrorCaptured(hook, target = currentInstance) {
2867
- injectHook("ec", hook, target);
2868
- }
2869
-
2870
- const COMPONENTS = "components";
2871
- const DIRECTIVES = "directives";
2872
- function resolveComponent(name, maybeSelfReference) {
2873
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2665
+ return true;
2874
2666
  }
2875
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2876
- function resolveDynamicComponent(component) {
2877
- if (isString(component)) {
2878
- return resolveAsset(COMPONENTS, component, false) || component;
2879
- } else {
2880
- return component || NULL_DYNAMIC_COMPONENT;
2667
+ function toStyleMap(str) {
2668
+ const styleMap = /* @__PURE__ */ new Map();
2669
+ for (const item of str.split(";")) {
2670
+ let [key, value] = item.split(":");
2671
+ key = key.trim();
2672
+ value = value && value.trim();
2673
+ if (key && value) {
2674
+ styleMap.set(key, value);
2675
+ }
2881
2676
  }
2677
+ return styleMap;
2882
2678
  }
2883
- function resolveDirective(name) {
2884
- return resolveAsset(DIRECTIVES, name);
2679
+ function isMapEqual(a, b) {
2680
+ if (a.size !== b.size) {
2681
+ return false;
2682
+ }
2683
+ for (const [key, value] of a) {
2684
+ if (value !== b.get(key)) {
2685
+ return false;
2686
+ }
2687
+ }
2688
+ return true;
2885
2689
  }
2886
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2887
- const instance = currentRenderingInstance || currentInstance;
2888
- if (instance) {
2889
- const Component = instance.type;
2890
- if (type === COMPONENTS) {
2891
- const selfName = getComponentName(
2892
- Component,
2893
- false
2690
+ function resolveCssVars(instance, vnode, expectedMap) {
2691
+ const root = instance.subTree;
2692
+ if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
2693
+ const cssVars = instance.getCssVars();
2694
+ for (const key in cssVars) {
2695
+ expectedMap.set(
2696
+ `--${getEscapedCssVarName(key, false)}`,
2697
+ String(cssVars[key])
2894
2698
  );
2895
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
2896
- return Component;
2897
- }
2898
2699
  }
2899
- const res = (
2900
- // local registration
2901
- // check instance[type] first which is resolved for options API
2902
- resolve(instance[type] || Component[type], name) || // global registration
2903
- resolve(instance.appContext[type], name)
2904
- );
2905
- if (!res && maybeSelfReference) {
2906
- return Component;
2700
+ }
2701
+ if (vnode === root && instance.parent) {
2702
+ resolveCssVars(instance.parent, instance.vnode, expectedMap);
2703
+ }
2704
+ }
2705
+ const allowMismatchAttr = "data-allow-mismatch";
2706
+ const MismatchTypeString = {
2707
+ [0 /* TEXT */]: "text",
2708
+ [1 /* CHILDREN */]: "children",
2709
+ [2 /* CLASS */]: "class",
2710
+ [3 /* STYLE */]: "style",
2711
+ [4 /* ATTRIBUTE */]: "attribute"
2712
+ };
2713
+ function isMismatchAllowed(el, allowedType) {
2714
+ if (allowedType === 0 /* TEXT */ || allowedType === 1 /* CHILDREN */) {
2715
+ while (el && !el.hasAttribute(allowMismatchAttr)) {
2716
+ el = el.parentElement;
2907
2717
  }
2908
- if (!!(process.env.NODE_ENV !== "production") && warnMissing && !res) {
2909
- const extra = type === COMPONENTS ? `
2910
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
2911
- warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
2718
+ }
2719
+ const allowedAttr = el && el.getAttribute(allowMismatchAttr);
2720
+ if (allowedAttr == null) {
2721
+ return false;
2722
+ } else if (allowedAttr === "") {
2723
+ return true;
2724
+ } else {
2725
+ const list = allowedAttr.split(",");
2726
+ if (allowedType === 0 /* TEXT */ && list.includes("children")) {
2727
+ return true;
2912
2728
  }
2913
- return res;
2914
- } else if (!!(process.env.NODE_ENV !== "production")) {
2915
- warn$1(
2916
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
2917
- );
2729
+ return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
2918
2730
  }
2919
2731
  }
2920
- function resolve(registry, name) {
2921
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
2922
- }
2923
2732
 
2924
- function renderList(source, renderItem, cache, index) {
2925
- let ret;
2926
- const cached = cache && cache[index];
2927
- const sourceIsArray = isArray(source);
2928
- if (sourceIsArray || isString(source)) {
2929
- const sourceIsReactiveArray = sourceIsArray && isReactive(source);
2930
- let needsWrap = false;
2931
- if (sourceIsReactiveArray) {
2932
- needsWrap = !isShallow(source);
2933
- source = shallowReadArray(source);
2733
+ const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
2734
+ const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
2735
+ const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
2736
+ const id = requestIdleCallback(hydrate, { timeout });
2737
+ return () => cancelIdleCallback(id);
2738
+ };
2739
+ function elementIsVisibleInViewport(el) {
2740
+ const { top, left, bottom, right } = el.getBoundingClientRect();
2741
+ const { innerHeight, innerWidth } = window;
2742
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
2743
+ }
2744
+ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
2745
+ const ob = new IntersectionObserver((entries) => {
2746
+ for (const e of entries) {
2747
+ if (!e.isIntersecting) continue;
2748
+ ob.disconnect();
2749
+ hydrate();
2750
+ break;
2934
2751
  }
2935
- ret = new Array(source.length);
2936
- for (let i = 0, l = source.length; i < l; i++) {
2937
- ret[i] = renderItem(
2938
- needsWrap ? toReactive(source[i]) : source[i],
2939
- i,
2940
- void 0,
2941
- cached && cached[i]
2942
- );
2752
+ }, opts);
2753
+ forEach((el) => {
2754
+ if (!(el instanceof Element)) return;
2755
+ if (elementIsVisibleInViewport(el)) {
2756
+ hydrate();
2757
+ ob.disconnect();
2758
+ return false;
2759
+ }
2760
+ ob.observe(el);
2761
+ });
2762
+ return () => ob.disconnect();
2763
+ };
2764
+ const hydrateOnMediaQuery = (query) => (hydrate) => {
2765
+ if (query) {
2766
+ const mql = matchMedia(query);
2767
+ if (mql.matches) {
2768
+ hydrate();
2769
+ } else {
2770
+ mql.addEventListener("change", hydrate, { once: true });
2771
+ return () => mql.removeEventListener("change", hydrate);
2943
2772
  }
2944
- } else if (typeof source === "number") {
2945
- if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
2946
- warn$1(`The v-for range expect an integer value but got ${source}.`);
2773
+ }
2774
+ };
2775
+ const hydrateOnInteraction = (interactions = []) => (hydrate, forEach) => {
2776
+ if (isString(interactions)) interactions = [interactions];
2777
+ let hasHydrated = false;
2778
+ const doHydrate = (e) => {
2779
+ if (!hasHydrated) {
2780
+ hasHydrated = true;
2781
+ teardown();
2782
+ hydrate();
2783
+ e.target.dispatchEvent(new e.constructor(e.type, e));
2947
2784
  }
2948
- ret = new Array(source);
2949
- for (let i = 0; i < source; i++) {
2950
- ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
2785
+ };
2786
+ const teardown = () => {
2787
+ forEach((el) => {
2788
+ for (const i of interactions) {
2789
+ el.removeEventListener(i, doHydrate);
2790
+ }
2791
+ });
2792
+ };
2793
+ forEach((el) => {
2794
+ for (const i of interactions) {
2795
+ el.addEventListener(i, doHydrate, { once: true });
2951
2796
  }
2952
- } else if (isObject(source)) {
2953
- if (source[Symbol.iterator]) {
2954
- ret = Array.from(
2955
- source,
2956
- (item, i) => renderItem(item, i, void 0, cached && cached[i])
2957
- );
2958
- } else {
2959
- const keys = Object.keys(source);
2960
- ret = new Array(keys.length);
2961
- for (let i = 0, l = keys.length; i < l; i++) {
2962
- const key = keys[i];
2963
- ret[i] = renderItem(source[key], key, i, cached && cached[i]);
2797
+ });
2798
+ return teardown;
2799
+ };
2800
+ function forEachElement(node, cb) {
2801
+ if (isComment(node) && node.data === "[") {
2802
+ let depth = 1;
2803
+ let next = node.nextSibling;
2804
+ while (next) {
2805
+ if (next.nodeType === 1) {
2806
+ const result = cb(next);
2807
+ if (result === false) {
2808
+ break;
2809
+ }
2810
+ } else if (isComment(next)) {
2811
+ if (next.data === "]") {
2812
+ if (--depth === 0) break;
2813
+ } else if (next.data === "[") {
2814
+ depth++;
2815
+ }
2964
2816
  }
2817
+ next = next.nextSibling;
2965
2818
  }
2966
2819
  } else {
2967
- ret = [];
2968
- }
2969
- if (cache) {
2970
- cache[index] = ret;
2820
+ cb(node);
2971
2821
  }
2972
- return ret;
2973
2822
  }
2974
2823
 
2975
- function createSlots(slots, dynamicSlots) {
2976
- for (let i = 0; i < dynamicSlots.length; i++) {
2977
- const slot = dynamicSlots[i];
2978
- if (isArray(slot)) {
2979
- for (let j = 0; j < slot.length; j++) {
2980
- slots[slot[j].name] = slot[j].fn;
2824
+ const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
2825
+ function _getValidZova(instance) {
2826
+ while (instance) {
2827
+ if (instance.zova) return instance.zova;
2828
+ instance = instance.parent;
2829
+ }
2830
+ }
2831
+ /*! #__NO_SIDE_EFFECTS__ */
2832
+ // @__NO_SIDE_EFFECTS__
2833
+ function defineAsyncComponent(source) {
2834
+ if (isFunction(source)) {
2835
+ source = { loader: source };
2836
+ }
2837
+ const {
2838
+ loader,
2839
+ loadingComponent,
2840
+ errorComponent,
2841
+ delay = 200,
2842
+ hydrate: hydrateStrategy,
2843
+ timeout,
2844
+ // undefined = never times out
2845
+ suspensible = true,
2846
+ onError: userOnError
2847
+ } = source;
2848
+ let pendingRequest = null;
2849
+ let resolvedComp;
2850
+ let retries = 0;
2851
+ const retry = () => {
2852
+ retries++;
2853
+ pendingRequest = null;
2854
+ return load();
2855
+ };
2856
+ const load = () => {
2857
+ let thisRequest;
2858
+ return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
2859
+ err = err instanceof Error ? err : new Error(String(err));
2860
+ if (userOnError) {
2861
+ return new Promise((resolve, reject) => {
2862
+ const userRetry = () => resolve(retry());
2863
+ const userFail = () => reject(err);
2864
+ userOnError(err, userRetry, userFail, retries + 1);
2865
+ });
2866
+ } else {
2867
+ throw err;
2981
2868
  }
2982
- } else if (slot) {
2983
- slots[slot.name] = slot.key ? (...args) => {
2984
- const res = slot.fn(...args);
2985
- if (res) res.key = slot.key;
2986
- return res;
2987
- } : slot.fn;
2869
+ }).then((comp) => {
2870
+ if (thisRequest !== pendingRequest && pendingRequest) {
2871
+ return pendingRequest;
2872
+ }
2873
+ if (!!(process.env.NODE_ENV !== "production") && !comp) {
2874
+ warn$1(
2875
+ `Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
2876
+ );
2877
+ }
2878
+ if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
2879
+ comp = comp.default;
2880
+ }
2881
+ if (!!(process.env.NODE_ENV !== "production") && comp && !isObject(comp) && !isFunction(comp)) {
2882
+ throw new Error(`Invalid async component load result: ${comp}`);
2883
+ }
2884
+ resolvedComp = comp;
2885
+ return comp;
2886
+ }));
2887
+ };
2888
+ return defineComponent({
2889
+ name: "AsyncComponentWrapper",
2890
+ __asyncLoader: load,
2891
+ __asyncHydrate(el, instance, hydrate) {
2892
+ const doHydrate = hydrateStrategy ? () => {
2893
+ const teardown = hydrateStrategy(
2894
+ hydrate,
2895
+ (cb) => forEachElement(el, cb)
2896
+ );
2897
+ if (teardown) {
2898
+ (instance.bum || (instance.bum = [])).push(teardown);
2899
+ }
2900
+ } : hydrate;
2901
+ if (resolvedComp) {
2902
+ doHydrate();
2903
+ } else {
2904
+ const zova = _getValidZova(instance);
2905
+ zova.meta.$ssr._hydratingInc();
2906
+ load().then(() => {
2907
+ !instance.isUnmounted && doHydrate();
2908
+ zova.meta.$ssr._hydratingDec();
2909
+ });
2910
+ }
2911
+ },
2912
+ get __asyncResolved() {
2913
+ return resolvedComp;
2914
+ },
2915
+ setup() {
2916
+ const instance = currentInstance;
2917
+ markAsyncBoundary(instance);
2918
+ if (resolvedComp) {
2919
+ return () => createInnerComp(resolvedComp, instance);
2920
+ }
2921
+ const onError = (err) => {
2922
+ pendingRequest = null;
2923
+ handleError(
2924
+ err,
2925
+ instance,
2926
+ 13,
2927
+ !errorComponent
2928
+ );
2929
+ };
2930
+ if (suspensible && instance.suspense || isInSSRComponentSetup) {
2931
+ return load().then((comp) => {
2932
+ return () => createInnerComp(comp, instance);
2933
+ }).catch((err) => {
2934
+ onError(err);
2935
+ return () => errorComponent ? createVNode(errorComponent, {
2936
+ error: err
2937
+ }) : null;
2938
+ });
2939
+ }
2940
+ const loaded = ref(false);
2941
+ const error = ref();
2942
+ const delayed = ref(!!delay);
2943
+ if (delay) {
2944
+ setTimeout(() => {
2945
+ delayed.value = false;
2946
+ }, delay);
2947
+ }
2948
+ if (timeout != null) {
2949
+ setTimeout(() => {
2950
+ if (!loaded.value && !error.value) {
2951
+ const err = new Error(
2952
+ `Async component timed out after ${timeout}ms.`
2953
+ );
2954
+ onError(err);
2955
+ error.value = err;
2956
+ }
2957
+ }, timeout);
2958
+ }
2959
+ load().then(() => {
2960
+ loaded.value = true;
2961
+ if (instance.parent && isKeepAlive(instance.parent.vnode)) {
2962
+ instance.parent.update();
2963
+ }
2964
+ }).catch((err) => {
2965
+ onError(err);
2966
+ error.value = err;
2967
+ });
2968
+ return () => {
2969
+ if (loaded.value && resolvedComp) {
2970
+ return createInnerComp(resolvedComp, instance);
2971
+ } else if (error.value && errorComponent) {
2972
+ return createVNode(errorComponent, {
2973
+ error: error.value
2974
+ });
2975
+ } else if (loadingComponent && !delayed.value) {
2976
+ return createVNode(loadingComponent);
2977
+ }
2978
+ };
2988
2979
  }
2989
- }
2990
- return slots;
2980
+ });
2981
+ }
2982
+ function createInnerComp(comp, parent) {
2983
+ const { ref: ref2, props, children, ce } = parent.vnode;
2984
+ const vnode = createVNode(comp, props, children);
2985
+ vnode.ref = ref2;
2986
+ vnode.ce = ce;
2987
+ delete parent.vnode.ce;
2988
+ vnode.zovaHostProviders = parent.vnode.zovaHostProviders;
2989
+ return vnode;
2991
2990
  }
2992
2991
 
2993
2992
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {