How to use devtoolsUnmountApp method in Playwright Internal

Best JavaScript code snippet using playwright-internal

vue.js

Source:vue.js Github

copy

Full Screen

...1379 Comment,1380 Static1381 });1382}1383function devtoolsUnmountApp(app) {1384 if (!devtools)1385 return;1386 devtools.emit("app:unmount" /* APP_UNMOUNT */, app);1387}1388const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);1389const devtoolsComponentUpdated = /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);1390const devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);1391function createDevtoolsComponentHook(hook) {1392 return (component) => {1393 if (!devtools)1394 return;1395 devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined);1396 };1397}1398function devtoolsComponentEmit(component, event, params) {1399 if (!devtools)1400 return;1401 devtools.emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);1402}1403function emit(instance, event, ...args) {1404 const props = instance.vnode.props || EMPTY_OBJ;1405 if ( __VUE_PROD_DEVTOOLS__) {1406 devtoolsComponentEmit(instance, event, args);1407 }1408 let handlerName = `on${capitalize(event)}`;1409 let handler = props[handlerName];1410 // for v-model update:xxx events, also trigger kebab-case equivalent1411 // for props passed via kebab-case1412 if (!handler && event.startsWith('update:')) {1413 handlerName = `on${capitalize(hyphenate(event))}`;1414 handler = props[handlerName];1415 }1416 if (!handler) {1417 handler = props[handlerName + `Once`];1418 if (!instance.emitted) {1419 (instance.emitted = {})[handlerName] = true;1420 }1421 else if (instance.emitted[handlerName]) {1422 return;1423 }1424 }1425 if (handler) {1426 callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);1427 }1428}1429function normalizeEmitsOptions(comp, appContext, asMixin = false) {1430 const appId = appContext.app ? appContext.app._uid : -1;1431 const cache = comp.__emits || (comp.__emits = {});1432 const cached = cache[appId];1433 if (cached !== undefined) {1434 return cached;1435 }1436 const raw = comp.emits;1437 let normalized = {};1438 // apply mixin/extends props1439 let hasExtends = false;1440 if (__VUE_OPTIONS_API__ && !isFunction(comp)) {1441 const extendEmits = (raw) => {1442 hasExtends = true;1443 extend(normalized, normalizeEmitsOptions(raw, appContext, true));1444 };1445 if (!asMixin && appContext.mixins.length) {1446 appContext.mixins.forEach(extendEmits);1447 }1448 if (comp.extends) {1449 extendEmits(comp.extends);1450 }1451 if (comp.mixins) {1452 comp.mixins.forEach(extendEmits);1453 }1454 }1455 if (!raw && !hasExtends) {1456 return (cache[appId] = null);1457 }1458 if (isArray(raw)) {1459 raw.forEach(key => (normalized[key] = null));1460 }1461 else {1462 extend(normalized, raw);1463 }1464 return (cache[appId] = normalized);1465}1466// Check if an incoming prop key is a declared emit event listener.1467// e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are1468// both considered matched listeners.1469function isEmitListener(options, key) {1470 if (!options || !isOn(key)) {1471 return false;1472 }1473 key = key.replace(/Once$/, '');1474 return (hasOwn(options, key[2].toLowerCase() + key.slice(3)) ||1475 hasOwn(options, key.slice(2)));1476}1477// mark the current rendering instance for asset resolution (e.g.1478// resolveComponent, resolveDirective) during render1479let currentRenderingInstance = null;1480function setCurrentRenderingInstance(instance) {1481 currentRenderingInstance = instance;1482}1483// dev only flag to track whether $attrs was used during render.1484// If $attrs was used during render then the warning for failed attrs1485// fallthrough can be suppressed.1486let accessedAttrs = false;1487function markAttrsAccessed() {1488 accessedAttrs = true;1489}1490function renderComponentRoot(instance) {1491 const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx } = instance;1492 let result;1493 currentRenderingInstance = instance;1494 try {1495 let fallthroughAttrs;1496 if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {1497 // withProxy is a proxy with a different `has` trap only for1498 // runtime-compiled render functions using `with` block.1499 const proxyToUse = withProxy || proxy;1500 result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));1501 fallthroughAttrs = attrs;1502 }1503 else {1504 // functional1505 const render = Component;1506 // in dev, mark attrs accessed if optional props (attrs === props)1507 if (("production" !== 'production') && attrs === props) ;1508 result = normalizeVNode(render.length > 11509 ? render(props, ("production" !== 'production')1510 ? {1511 get attrs() {1512 markAttrsAccessed();1513 return attrs;1514 },1515 slots,1516 emit1517 }1518 : { attrs, slots, emit })1519 : render(props, null /* we know it doesn't need it */));1520 fallthroughAttrs = Component.props1521 ? attrs1522 : getFunctionalFallthrough(attrs);1523 }1524 // attr merging1525 // in dev mode, comments are preserved, and it's possible for a template1526 // to have comments along side the root element which makes it a fragment1527 let root = result;1528 let setRoot = undefined;1529 if (("production" !== 'production')) ;1530 if (Component.inheritAttrs !== false && fallthroughAttrs) {1531 const keys = Object.keys(fallthroughAttrs);1532 const { shapeFlag } = root;1533 if (keys.length) {1534 if (shapeFlag & 1 /* ELEMENT */ ||1535 shapeFlag & 6 /* COMPONENT */) {1536 if (propsOptions && keys.some(isModelListener)) {1537 // If a v-model listener (onUpdate:xxx) has a corresponding declared1538 // prop, it indicates this component expects to handle v-model and1539 // it should not fallthrough.1540 // related: #1543, #1643, #19891541 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);1542 }1543 root = cloneVNode(root, fallthroughAttrs);1544 }1545 else if (("production" !== 'production') && !accessedAttrs && root.type !== Comment) ;1546 }1547 }1548 // inherit directives1549 if (vnode.dirs) {1550 if (("production" !== 'production') && !isElementRoot(root)) ;1551 root.dirs = vnode.dirs;1552 }1553 // inherit transition data1554 if (vnode.transition) {1555 if (("production" !== 'production') && !isElementRoot(root)) ;1556 root.transition = vnode.transition;1557 }1558 if (("production" !== 'production') && setRoot) ;1559 else {1560 result = root;1561 }1562 }1563 catch (err) {1564 handleError(err, instance, 1 /* RENDER_FUNCTION */);1565 result = createVNode(Comment);1566 }1567 currentRenderingInstance = null;1568 return result;1569}1570/**1571 * dev only1572 * In dev mode, template root level comments are rendered, which turns the1573 * template into a fragment root, but we need to locate the single element1574 * root for attrs and scope id processing.1575 */1576const getChildRoot = (vnode) => {1577 if (vnode.type !== Fragment) {1578 return [vnode, undefined];1579 }1580 const rawChildren = vnode.children;1581 const dynamicChildren = vnode.dynamicChildren;1582 const childRoot = filterSingleRoot(rawChildren);1583 if (!childRoot) {1584 return [vnode, undefined];1585 }1586 const index = rawChildren.indexOf(childRoot);1587 const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;1588 const setRoot = (updatedRoot) => {1589 rawChildren[index] = updatedRoot;1590 if (dynamicIndex > -1) {1591 dynamicChildren[dynamicIndex] = updatedRoot;1592 }1593 else if (dynamicChildren && updatedRoot.patchFlag > 0) {1594 dynamicChildren.push(updatedRoot);1595 }1596 };1597 return [normalizeVNode(childRoot), setRoot];1598};1599/**1600 * dev only1601 */1602function filterSingleRoot(children) {1603 const filtered = children.filter(child => {1604 return !(isVNode(child) &&1605 child.type === Comment &&1606 child.children !== 'v-if');1607 });1608 return filtered.length === 1 && isVNode(filtered[0]) ? filtered[0] : null;1609}1610const getFunctionalFallthrough = (attrs) => {1611 let res;1612 for (const key in attrs) {1613 if (key === 'class' || key === 'style' || isOn(key)) {1614 (res || (res = {}))[key] = attrs[key];1615 }1616 }1617 return res;1618};1619const filterModelListeners = (attrs, props) => {1620 const res = {};1621 for (const key in attrs) {1622 if (!isModelListener(key) || !(key.slice(9) in props)) {1623 res[key] = attrs[key];1624 }1625 }1626 return res;1627};1628const isElementRoot = (vnode) => {1629 return (vnode.shapeFlag & 6 /* COMPONENT */ ||1630 vnode.shapeFlag & 1 /* ELEMENT */ ||1631 vnode.type === Comment // potential v-if branch switch1632 );1633};1634function shouldUpdateComponent(prevVNode, nextVNode, optimized) {1635 const { props: prevProps, children: prevChildren, component } = prevVNode;1636 const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;1637 const emits = component.emitsOptions;1638 // force child update for runtime directive or transition on component vnode.1639 if (nextVNode.dirs || nextVNode.transition) {1640 return true;1641 }1642 if (optimized && patchFlag > 0) {1643 if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {1644 // slot content that references values that might have changed,1645 // e.g. in a v-for1646 return true;1647 }1648 if (patchFlag & 16 /* FULL_PROPS */) {1649 if (!prevProps) {1650 return !!nextProps;1651 }1652 // presence of this flag indicates props are always non-null1653 return hasPropsChanged(prevProps, nextProps, emits);1654 }1655 else if (patchFlag & 8 /* PROPS */) {1656 const dynamicProps = nextVNode.dynamicProps;1657 for (let i = 0; i < dynamicProps.length; i++) {1658 const key = dynamicProps[i];1659 if (nextProps[key] !== prevProps[key] &&1660 !isEmitListener(emits, key)) {1661 return true;1662 }1663 }1664 }1665 }1666 else {1667 // this path is only taken by manually written render functions1668 // so presence of any children leads to a forced update1669 if (prevChildren || nextChildren) {1670 if (!nextChildren || !nextChildren.$stable) {1671 return true;1672 }1673 }1674 if (prevProps === nextProps) {1675 return false;1676 }1677 if (!prevProps) {1678 return !!nextProps;1679 }1680 if (!nextProps) {1681 return true;1682 }1683 return hasPropsChanged(prevProps, nextProps, emits);1684 }1685 return false;1686}1687function hasPropsChanged(prevProps, nextProps, emitsOptions) {1688 const nextKeys = Object.keys(nextProps);1689 if (nextKeys.length !== Object.keys(prevProps).length) {1690 return true;1691 }1692 for (let i = 0; i < nextKeys.length; i++) {1693 const key = nextKeys[i];1694 if (nextProps[key] !== prevProps[key] &&1695 !isEmitListener(emitsOptions, key)) {1696 return true;1697 }1698 }1699 return false;1700}1701function updateHOCHostEl({ vnode, parent }, el // HostNode1702) {1703 while (parent && parent.subTree === vnode) {1704 (vnode = parent.vnode).el = el;1705 parent = parent.parent;1706 }1707}1708const isSuspense = (type) => type.__isSuspense;1709// Suspense exposes a component-like API, and is treated like a component1710// in the compiler, but internally it's a special built-in type that hooks1711// directly into the renderer.1712const SuspenseImpl = {1713 // In order to make Suspense tree-shakable, we need to avoid importing it1714 // directly in the renderer. The renderer checks for the __isSuspense flag1715 // on a vnode's type and calls the `process` method, passing in renderer1716 // internals.1717 __isSuspense: true,1718 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, 1719 // platform-specific impl passed from renderer1720 rendererInternals) {1721 if (n1 == null) {1722 mountSuspense(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, rendererInternals);1723 }1724 else {1725 patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, optimized, rendererInternals);1726 }1727 },1728 hydrate: hydrateSuspense,1729 create: createSuspenseBoundary1730};1731// Force-casted public typing for h and TSX props inference1732const Suspense = ( SuspenseImpl1733 );1734function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, isSVG, optimized, rendererInternals) {1735 const { p: patch, o: { createElement } } = rendererInternals;1736 const hiddenContainer = createElement('div');1737 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, isSVG, optimized, rendererInternals));1738 // start mounting the content subtree in an off-dom container1739 patch(null, (suspense.pendingBranch = vnode.ssContent), hiddenContainer, null, parentComponent, suspense, isSVG, optimized);1740 // now check if we have encountered any async deps1741 if (suspense.deps > 0) {1742 // has async1743 // mount the fallback tree1744 patch(null, vnode.ssFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context1745 isSVG, optimized);1746 setActiveBranch(suspense, vnode.ssFallback);1747 }1748 else {1749 // Suspense has no async deps. Just resolve.1750 suspense.resolve();1751 }1752}1753function patchSuspense(n1, n2, container, anchor, parentComponent, isSVG, optimized, { p: patch, um: unmount, o: { createElement } }) {1754 const suspense = (n2.suspense = n1.suspense);1755 suspense.vnode = n2;1756 n2.el = n1.el;1757 const newBranch = n2.ssContent;1758 const newFallback = n2.ssFallback;1759 const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;1760 if (pendingBranch) {1761 suspense.pendingBranch = newBranch;1762 if (isSameVNodeType(newBranch, pendingBranch)) {1763 // same root type but content may have changed.1764 patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);1765 if (suspense.deps <= 0) {1766 suspense.resolve();1767 }1768 else if (isInFallback) {1769 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context1770 isSVG, optimized);1771 setActiveBranch(suspense, newFallback);1772 }1773 }1774 else {1775 // toggled before pending tree is resolved1776 suspense.pendingId++;1777 if (isHydrating) {1778 // if toggled before hydration is finished, the current DOM tree is1779 // no longer valid. set it as the active branch so it will be unmounted1780 // when resolved1781 suspense.isHydrating = false;1782 suspense.activeBranch = pendingBranch;1783 }1784 else {1785 unmount(pendingBranch, parentComponent, suspense);1786 }1787 // increment pending ID. this is used to invalidate async callbacks1788 // reset suspense state1789 suspense.deps = 0;1790 // discard effects from pending branch1791 suspense.effects.length = 0;1792 // discard previous container1793 suspense.hiddenContainer = createElement('div');1794 if (isInFallback) {1795 // already in fallback state1796 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);1797 if (suspense.deps <= 0) {1798 suspense.resolve();1799 }1800 else {1801 patch(activeBranch, newFallback, container, anchor, parentComponent, null, // fallback tree will not have suspense context1802 isSVG, optimized);1803 setActiveBranch(suspense, newFallback);1804 }1805 }1806 else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {1807 // toggled "back" to current active branch1808 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, optimized);1809 // force resolve1810 suspense.resolve(true);1811 }1812 else {1813 // switched to a 3rd branch1814 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);1815 if (suspense.deps <= 0) {1816 suspense.resolve();1817 }1818 }1819 }1820 }1821 else {1822 if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {1823 // root did not change, just normal patch1824 patch(activeBranch, newBranch, container, anchor, parentComponent, suspense, isSVG, optimized);1825 setActiveBranch(suspense, newBranch);1826 }1827 else {1828 // root node toggled1829 // invoke @pending event1830 const onPending = n2.props && n2.props.onPending;1831 if (isFunction(onPending)) {1832 onPending();1833 }1834 // mount pending branch in off-dom container1835 suspense.pendingBranch = newBranch;1836 suspense.pendingId++;1837 patch(null, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, isSVG, optimized);1838 if (suspense.deps <= 0) {1839 // incoming branch has no async deps, resolve now.1840 suspense.resolve();1841 }1842 else {1843 const { timeout, pendingId } = suspense;1844 if (timeout > 0) {1845 setTimeout(() => {1846 if (suspense.pendingId === pendingId) {1847 suspense.fallback(newFallback);1848 }1849 }, timeout);1850 }1851 else if (timeout === 0) {1852 suspense.fallback(newFallback);1853 }1854 }1855 }1856 }1857}1858function createSuspenseBoundary(vnode, parent, parentComponent, container, hiddenContainer, anchor, isSVG, optimized, rendererInternals, isHydrating = false) {1859 const { p: patch, m: move, um: unmount, n: next, o: { parentNode, remove } } = rendererInternals;1860 const timeout = toNumber(vnode.props && vnode.props.timeout);1861 const suspense = {1862 vnode,1863 parent,1864 parentComponent,1865 isSVG,1866 optimized,1867 container,1868 hiddenContainer,1869 anchor,1870 deps: 0,1871 pendingId: 0,1872 timeout: typeof timeout === 'number' ? timeout : -1,1873 activeBranch: null,1874 pendingBranch: null,1875 isInFallback: true,1876 isHydrating,1877 isUnmounted: false,1878 effects: [],1879 resolve(resume = false) {1880 const { vnode, activeBranch, pendingBranch, pendingId, effects, parentComponent, container } = suspense;1881 if (suspense.isHydrating) {1882 suspense.isHydrating = false;1883 }1884 else if (!resume) {1885 const delayEnter = activeBranch &&1886 pendingBranch.transition &&1887 pendingBranch.transition.mode === 'out-in';1888 if (delayEnter) {1889 activeBranch.transition.afterLeave = () => {1890 if (pendingId === suspense.pendingId) {1891 move(pendingBranch, container, anchor, 0 /* ENTER */);1892 }1893 };1894 }1895 // this is initial anchor on mount1896 let { anchor } = suspense;1897 // unmount current active tree1898 if (activeBranch) {1899 // if the fallback tree was mounted, it may have been moved1900 // as part of a parent suspense. get the latest anchor for insertion1901 anchor = next(activeBranch);1902 unmount(activeBranch, parentComponent, suspense, true);1903 }1904 if (!delayEnter) {1905 // move content from off-dom container to actual container1906 move(pendingBranch, container, anchor, 0 /* ENTER */);1907 }1908 }1909 setActiveBranch(suspense, pendingBranch);1910 suspense.pendingBranch = null;1911 suspense.isInFallback = false;1912 // flush buffered effects1913 // check if there is a pending parent suspense1914 let parent = suspense.parent;1915 let hasUnresolvedAncestor = false;1916 while (parent) {1917 if (parent.pendingBranch) {1918 // found a pending parent suspense, merge buffered post jobs1919 // into that parent1920 parent.effects.push(...effects);1921 hasUnresolvedAncestor = true;1922 break;1923 }1924 parent = parent.parent;1925 }1926 // no pending parent suspense, flush all jobs1927 if (!hasUnresolvedAncestor) {1928 queuePostFlushCb(effects);1929 }1930 suspense.effects = [];1931 // invoke @resolve event1932 const onResolve = vnode.props && vnode.props.onResolve;1933 if (isFunction(onResolve)) {1934 onResolve();1935 }1936 },1937 fallback(fallbackVNode) {1938 if (!suspense.pendingBranch) {1939 return;1940 }1941 const { vnode, activeBranch, parentComponent, container, isSVG, optimized } = suspense;1942 // invoke @fallback event1943 const onFallback = vnode.props && vnode.props.onFallback;1944 if (isFunction(onFallback)) {1945 onFallback();1946 }1947 const anchor = next(activeBranch);1948 const mountFallback = () => {1949 if (!suspense.isInFallback) {1950 return;1951 }1952 // mount the fallback tree1953 patch(null, fallbackVNode, container, anchor, parentComponent, null, // fallback tree will not have suspense context1954 isSVG, optimized);1955 setActiveBranch(suspense, fallbackVNode);1956 };1957 const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === 'out-in';1958 if (delayEnter) {1959 activeBranch.transition.afterLeave = mountFallback;1960 }1961 // unmount current active branch1962 unmount(activeBranch, parentComponent, null, // no suspense so unmount hooks fire now1963 true // shouldRemove1964 );1965 suspense.isInFallback = true;1966 if (!delayEnter) {1967 mountFallback();1968 }1969 },1970 move(container, anchor, type) {1971 suspense.activeBranch &&1972 move(suspense.activeBranch, container, anchor, type);1973 suspense.container = container;1974 },1975 next() {1976 return suspense.activeBranch && next(suspense.activeBranch);1977 },1978 registerDep(instance, setupRenderEffect) {1979 if (!suspense.pendingBranch) {1980 return;1981 }1982 const hydratedEl = instance.vnode.el;1983 suspense.deps++;1984 instance1985 .asyncDep.catch(err => {1986 handleError(err, instance, 0 /* SETUP_FUNCTION */);1987 })1988 .then(asyncSetupResult => {1989 // retry when the setup() promise resolves.1990 // component may have been unmounted before resolve.1991 if (instance.isUnmounted ||1992 suspense.isUnmounted ||1993 suspense.pendingId !== instance.suspenseId) {1994 return;1995 }1996 suspense.deps--;1997 // retry from this component1998 instance.asyncResolved = true;1999 const { vnode } = instance;2000 handleSetupResult(instance, asyncSetupResult);2001 if (hydratedEl) {2002 // vnode may have been replaced if an update happened before the2003 // async dep is resolved.2004 vnode.el = hydratedEl;2005 }2006 const placeholder = !hydratedEl && instance.subTree.el;2007 setupRenderEffect(instance, vnode, 2008 // component may have been moved before resolve.2009 // if this is not a hydration, instance.subTree will be the comment2010 // placeholder.2011 parentNode(hydratedEl || instance.subTree.el), 2012 // anchor will not be used if this is hydration, so only need to2013 // consider the comment placeholder case.2014 hydratedEl ? null : next(instance.subTree), suspense, isSVG, optimized);2015 if (placeholder) {2016 remove(placeholder);2017 }2018 updateHOCHostEl(instance, vnode.el);2019 if (suspense.deps === 0) {2020 suspense.resolve();2021 }2022 });2023 },2024 unmount(parentSuspense, doRemove) {2025 suspense.isUnmounted = true;2026 if (suspense.activeBranch) {2027 unmount(suspense.activeBranch, parentComponent, parentSuspense, doRemove);2028 }2029 if (suspense.pendingBranch) {2030 unmount(suspense.pendingBranch, parentComponent, parentSuspense, doRemove);2031 }2032 }2033 };2034 return suspense;2035}2036function hydrateSuspense(node, vnode, parentComponent, parentSuspense, isSVG, optimized, rendererInternals, hydrateNode) {2037 /* eslint-disable no-restricted-globals */2038 const suspense = (vnode.suspense = createSuspenseBoundary(vnode, parentSuspense, parentComponent, node.parentNode, document.createElement('div'), null, isSVG, optimized, rendererInternals, true /* hydrating */));2039 // there are two possible scenarios for server-rendered suspense:2040 // - success: ssr content should be fully resolved2041 // - failure: ssr content should be the fallback branch.2042 // however, on the client we don't really know if it has failed or not2043 // attempt to hydrate the DOM assuming it has succeeded, but we still2044 // need to construct a suspense boundary first2045 const result = hydrateNode(node, (suspense.pendingBranch = vnode.ssContent), parentComponent, suspense, optimized);2046 if (suspense.deps === 0) {2047 suspense.resolve();2048 }2049 return result;2050 /* eslint-enable no-restricted-globals */2051}2052function normalizeSuspenseChildren(vnode) {2053 const { shapeFlag, children } = vnode;2054 let content;2055 let fallback;2056 if (shapeFlag & 32 /* SLOTS_CHILDREN */) {2057 content = normalizeSuspenseSlot(children.default);2058 fallback = normalizeSuspenseSlot(children.fallback);2059 }2060 else {2061 content = normalizeSuspenseSlot(children);2062 fallback = normalizeVNode(null);2063 }2064 return {2065 content,2066 fallback2067 };2068}2069function normalizeSuspenseSlot(s) {2070 if (isFunction(s)) {2071 s = s();2072 }2073 if (isArray(s)) {2074 const singleChild = filterSingleRoot(s);2075 s = singleChild;2076 }2077 return normalizeVNode(s);2078}2079function queueEffectWithSuspense(fn, suspense) {2080 if (suspense && suspense.pendingBranch) {2081 if (isArray(fn)) {2082 suspense.effects.push(...fn);2083 }2084 else {2085 suspense.effects.push(fn);2086 }2087 }2088 else {2089 queuePostFlushCb(fn);2090 }2091}2092function setActiveBranch(suspense, branch) {2093 suspense.activeBranch = branch;2094 const { vnode, parentComponent } = suspense;2095 const el = (vnode.el = branch.el);2096 // in case suspense is the root node of a component,2097 // recursively update the HOC el2098 if (parentComponent && parentComponent.subTree === vnode) {2099 parentComponent.vnode.el = el;2100 updateHOCHostEl(parentComponent, el);2101 }2102}2103let isRenderingCompiledSlot = 0;2104const setCompiledSlotRendering = (n) => (isRenderingCompiledSlot += n);2105/**2106 * Compiler runtime helper for rendering `<slot/>`2107 * @private2108 */2109function renderSlot(slots, name, props = {}, 2110// this is not a user-facing function, so the fallback is always generated by2111// the compiler and guaranteed to be a function returning an array2112fallback) {2113 let slot = slots[name];2114 // a compiled slot disables block tracking by default to avoid manual2115 // invocation interfering with template-based block tracking, but in2116 // `renderSlot` we can be sure that it's template-based so we can force2117 // enable it.2118 isRenderingCompiledSlot++;2119 const rendered = (openBlock(),2120 createBlock(Fragment, { key: props.key }, slot ? slot(props) : fallback ? fallback() : [], slots._ === 1 /* STABLE */2121 ? 64 /* STABLE_FRAGMENT */2122 : -2 /* BAIL */));2123 isRenderingCompiledSlot--;2124 return rendered;2125}2126/**2127 * Wrap a slot function to memoize current rendering instance2128 * @private2129 */2130function withCtx(fn, ctx = currentRenderingInstance) {2131 if (!ctx)2132 return fn;2133 const renderFnWithContext = (...args) => {2134 // If a user calls a compiled slot inside a template expression (#1745), it2135 // can mess up block tracking, so by default we need to push a null block to2136 // avoid that. This isn't necessary if rendering a compiled `<slot>`.2137 if (!isRenderingCompiledSlot) {2138 openBlock(true /* null block that disables tracking */);2139 }2140 const owner = currentRenderingInstance;2141 setCurrentRenderingInstance(ctx);2142 const res = fn(...args);2143 setCurrentRenderingInstance(owner);2144 if (!isRenderingCompiledSlot) {2145 closeBlock();2146 }2147 return res;2148 };2149 renderFnWithContext._c = true;2150 return renderFnWithContext;2151}2152// SFC scoped style ID management.2153let currentScopeId = null;2154const scopeIdStack = [];2155/**2156 * @private2157 */2158function pushScopeId(id) {2159 scopeIdStack.push((currentScopeId = id));2160}2161/**2162 * @private2163 */2164function popScopeId() {2165 scopeIdStack.pop();2166 currentScopeId = scopeIdStack[scopeIdStack.length - 1] || null;2167}2168/**2169 * @private2170 */2171function withScopeId(id) {2172 return ((fn) => withCtx(function () {2173 pushScopeId(id);2174 const res = fn.apply(this, arguments);2175 popScopeId();2176 return res;2177 }));2178}2179const isTeleport = (type) => type.__isTeleport;2180const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === '');2181const resolveTarget = (props, select) => {2182 const targetSelector = props && props.to;2183 if (isString(targetSelector)) {2184 if (!select) {2185 return null;2186 }2187 else {2188 const target = select(targetSelector);2189 return target;2190 }2191 }2192 else {2193 return targetSelector;2194 }2195};2196const TeleportImpl = {2197 __isTeleport: true,2198 process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized, internals) {2199 const { mc: mountChildren, pc: patchChildren, pbc: patchBlockChildren, o: { insert, querySelector, createText, createComment } } = internals;2200 const disabled = isTeleportDisabled(n2.props);2201 const { shapeFlag, children } = n2;2202 if (n1 == null) {2203 // insert anchors in the main view2204 const placeholder = (n2.el = createText(''));2205 const mainAnchor = (n2.anchor = createText(''));2206 insert(placeholder, container, anchor);2207 insert(mainAnchor, container, anchor);2208 const target = (n2.target = resolveTarget(n2.props, querySelector));2209 const targetAnchor = (n2.targetAnchor = createText(''));2210 if (target) {2211 insert(targetAnchor, target);2212 }2213 const mount = (container, anchor) => {2214 // Teleport *always* has Array children. This is enforced in both the2215 // compiler and vnode children normalization.2216 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {2217 mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, optimized);2218 }2219 };2220 if (disabled) {2221 mount(container, mainAnchor);2222 }2223 else if (target) {2224 mount(target, targetAnchor);2225 }2226 }2227 else {2228 // update content2229 n2.el = n1.el;2230 const mainAnchor = (n2.anchor = n1.anchor);2231 const target = (n2.target = n1.target);2232 const targetAnchor = (n2.targetAnchor = n1.targetAnchor);2233 const wasDisabled = isTeleportDisabled(n1.props);2234 const currentContainer = wasDisabled ? container : target;2235 const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;2236 if (n2.dynamicChildren) {2237 // fast path when the teleport happens to be a block root2238 patchBlockChildren(n1.dynamicChildren, n2.dynamicChildren, currentContainer, parentComponent, parentSuspense, isSVG);2239 // even in block tree mode we need to make sure all root-level nodes2240 // in the teleport inherit previous DOM references so that they can2241 // be moved in future patches.2242 if (n2.shapeFlag & 16 /* ARRAY_CHILDREN */) {2243 const oldChildren = n1.children;2244 const children = n2.children;2245 for (let i = 0; i < children.length; i++) {2246 // only inherit for non-patched nodes (i.e. static ones)2247 if (!children[i].el) {2248 children[i].el = oldChildren[i].el;2249 }2250 }2251 }2252 }2253 else if (!optimized) {2254 patchChildren(n1, n2, currentContainer, currentAnchor, parentComponent, parentSuspense, isSVG);2255 }2256 if (disabled) {2257 if (!wasDisabled) {2258 // enabled -> disabled2259 // move into main container2260 moveTeleport(n2, container, mainAnchor, internals, 1 /* TOGGLE */);2261 }2262 }2263 else {2264 // target changed2265 if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {2266 const nextTarget = (n2.target = resolveTarget(n2.props, querySelector));2267 if (nextTarget) {2268 moveTeleport(n2, nextTarget, null, internals, 0 /* TARGET_CHANGE */);2269 }2270 }2271 else if (wasDisabled) {2272 // disabled -> enabled2273 // move into teleport target2274 moveTeleport(n2, target, targetAnchor, internals, 1 /* TOGGLE */);2275 }2276 }2277 }2278 },2279 remove(vnode, { r: remove, o: { remove: hostRemove } }) {2280 const { shapeFlag, children, anchor } = vnode;2281 hostRemove(anchor);2282 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {2283 for (let i = 0; i < children.length; i++) {2284 remove(children[i]);2285 }2286 }2287 },2288 move: moveTeleport,2289 hydrate: hydrateTeleport2290};2291function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2 /* REORDER */) {2292 // move target anchor if this is a target change.2293 if (moveType === 0 /* TARGET_CHANGE */) {2294 insert(vnode.targetAnchor, container, parentAnchor);2295 }2296 const { el, anchor, shapeFlag, children, props } = vnode;2297 const isReorder = moveType === 2 /* REORDER */;2298 // move main view anchor if this is a re-order.2299 if (isReorder) {2300 insert(el, container, parentAnchor);2301 }2302 // if this is a re-order and teleport is enabled (content is in target)2303 // do not move children. So the opposite is: only move children if this2304 // is not a reorder, or the teleport is disabled2305 if (!isReorder || isTeleportDisabled(props)) {2306 // Teleport has either Array children or no children.2307 if (shapeFlag & 16 /* ARRAY_CHILDREN */) {2308 for (let i = 0; i < children.length; i++) {2309 move(children[i], container, parentAnchor, 2 /* REORDER */);2310 }2311 }2312 }2313 // move main view anchor if this is a re-order.2314 if (isReorder) {2315 insert(anchor, container, parentAnchor);2316 }2317}2318function hydrateTeleport(node, vnode, parentComponent, parentSuspense, optimized, { o: { nextSibling, parentNode, querySelector } }, hydrateChildren) {2319 const target = (vnode.target = resolveTarget(vnode.props, querySelector));2320 if (target) {2321 // if multiple teleports rendered to the same target element, we need to2322 // pick up from where the last teleport finished instead of the first node2323 const targetNode = target._lpa || target.firstChild;2324 if (vnode.shapeFlag & 16 /* ARRAY_CHILDREN */) {2325 if (isTeleportDisabled(vnode.props)) {2326 vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, optimized);2327 vnode.targetAnchor = targetNode;2328 }2329 else {2330 vnode.anchor = nextSibling(node);2331 vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, optimized);2332 }2333 target._lpa =2334 vnode.targetAnchor && nextSibling(vnode.targetAnchor);2335 }2336 }2337 return vnode.anchor && nextSibling(vnode.anchor);2338}2339// Force-casted public typing for h and TSX props inference2340const Teleport = TeleportImpl;2341const COMPONENTS = 'components';2342const DIRECTIVES = 'directives';2343/**2344 * @private2345 */2346function resolveComponent(name) {2347 return resolveAsset(COMPONENTS, name) || name;2348}2349const NULL_DYNAMIC_COMPONENT = Symbol();2350/**2351 * @private2352 */2353function resolveDynamicComponent(component) {2354 if (isString(component)) {2355 return resolveAsset(COMPONENTS, component, false) || component;2356 }2357 else {2358 // invalid types will fallthrough to createVNode and raise warning2359 return (component || NULL_DYNAMIC_COMPONENT);2360 }2361}2362/**2363 * @private2364 */2365function resolveDirective(name) {2366 return resolveAsset(DIRECTIVES, name);2367}2368// implementation2369function resolveAsset(type, name, warnMissing = true) {2370 const instance = currentRenderingInstance || currentInstance;2371 if (instance) {2372 const Component = instance.type;2373 // self name has highest priority2374 if (type === COMPONENTS) {2375 const selfName = Component.displayName || Component.name;2376 if (selfName &&2377 (selfName === name ||2378 selfName === camelize(name) ||2379 selfName === capitalize(camelize(name)))) {2380 return Component;2381 }2382 }2383 const res = 2384 // local registration2385 // check instance[type] first for components with mixin or extends.2386 resolve(instance[type] || Component[type], name) ||2387 // global registration2388 resolve(instance.appContext[type], name);2389 return res;2390 }2391}2392function resolve(registry, name) {2393 return (registry &&2394 (registry[name] ||2395 registry[camelize(name)] ||2396 registry[capitalize(camelize(name))]));2397}2398const Fragment = Symbol( undefined);2399const Text = Symbol( undefined);2400const Comment = Symbol( undefined);2401const Static = Symbol( undefined);2402// Since v-if and v-for are the two possible ways node structure can dynamically2403// change, once we consider v-if branches and each v-for fragment a block, we2404// can divide a template into nested blocks, and within each block the node2405// structure would be stable. This allows us to skip most children diffing2406// and only worry about the dynamic nodes (indicated by patch flags).2407const blockStack = [];2408let currentBlock = null;2409/**2410 * Open a block.2411 * This must be called before `createBlock`. It cannot be part of `createBlock`2412 * because the children of the block are evaluated before `createBlock` itself2413 * is called. The generated code typically looks like this:2414 *2415 * ```js2416 * function render() {2417 * return (openBlock(),createBlock('div', null, [...]))2418 * }2419 * ```2420 * disableTracking is true when creating a v-for fragment block, since a v-for2421 * fragment always diffs its children.2422 *2423 * @private2424 */2425function openBlock(disableTracking = false) {2426 blockStack.push((currentBlock = disableTracking ? null : []));2427}2428function closeBlock() {2429 blockStack.pop();2430 currentBlock = blockStack[blockStack.length - 1] || null;2431}2432// Whether we should be tracking dynamic child nodes inside a block.2433// Only tracks when this value is > 02434// We are not using a simple boolean because this value may need to be2435// incremented/decremented by nested usage of v-once (see below)2436let shouldTrack$1 = 1;2437/**2438 * Block tracking sometimes needs to be disabled, for example during the2439 * creation of a tree that needs to be cached by v-once. The compiler generates2440 * code like this:2441 *2442 * ``` js2443 * _cache[1] || (2444 * setBlockTracking(-1),2445 * _cache[1] = createVNode(...),2446 * setBlockTracking(1),2447 * _cache[1]2448 * )2449 * ```2450 *2451 * @private2452 */2453function setBlockTracking(value) {2454 shouldTrack$1 += value;2455}2456/**2457 * Create a block root vnode. Takes the same exact arguments as `createVNode`.2458 * A block root keeps track of dynamic nodes within the block in the2459 * `dynamicChildren` array.2460 *2461 * @private2462 */2463function createBlock(type, props, children, patchFlag, dynamicProps) {2464 const vnode = createVNode(type, props, children, patchFlag, dynamicProps, true /* isBlock: prevent a block from tracking itself */);2465 // save current block children on the block vnode2466 vnode.dynamicChildren = currentBlock || EMPTY_ARR;2467 // close block2468 closeBlock();2469 // a block is always going to be patched, so track it as a child of its2470 // parent block2471 if (shouldTrack$1 > 0 && currentBlock) {2472 currentBlock.push(vnode);2473 }2474 return vnode;2475}2476function isVNode(value) {2477 return value ? value.__v_isVNode === true : false;2478}2479function isSameVNodeType(n1, n2) {2480 return n1.type === n2.type && n1.key === n2.key;2481}2482/**2483 * Internal API for registering an arguments transform for createVNode2484 * used for creating stubs in the test-utils2485 * It is *internal* but needs to be exposed for test-utils to pick up proper2486 * typings2487 */2488function transformVNodeArgs(transformer) {2489}2490const InternalObjectKey = `__vInternal`;2491const normalizeKey = ({ key }) => key != null ? key : null;2492const normalizeRef = ({ ref }) => {2493 return (ref != null2494 ? isArray(ref)2495 ? ref2496 : { i: currentRenderingInstance, r: ref }2497 : null);2498};2499const createVNode = ( _createVNode);2500function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {2501 if (!type || type === NULL_DYNAMIC_COMPONENT) {2502 type = Comment;2503 }2504 if (isVNode(type)) {2505 // createVNode receiving an existing vnode. This happens in cases like2506 // <component :is="vnode"/>2507 // #2078 make sure to merge refs during the clone instead of overwriting it2508 const cloned = cloneVNode(type, props, true /* mergeRef: true */);2509 if (children) {2510 normalizeChildren(cloned, children);2511 }2512 return cloned;2513 }2514 // class component normalization.2515 if (isClassComponent(type)) {2516 type = type.__vccOpts;2517 }2518 // class & style normalization.2519 if (props) {2520 // for reactive or proxy objects, we need to clone it to enable mutation.2521 if (isProxy(props) || InternalObjectKey in props) {2522 props = extend({}, props);2523 }2524 let { class: klass, style } = props;2525 if (klass && !isString(klass)) {2526 props.class = normalizeClass(klass);2527 }2528 if (isObject(style)) {2529 // reactive state objects need to be cloned since they are likely to be2530 // mutated2531 if (isProxy(style) && !isArray(style)) {2532 style = extend({}, style);2533 }2534 props.style = normalizeStyle(style);2535 }2536 }2537 // encode the vnode type information into a bitmap2538 const shapeFlag = isString(type)2539 ? 1 /* ELEMENT */2540 : isSuspense(type)2541 ? 128 /* SUSPENSE */2542 : isTeleport(type)2543 ? 64 /* TELEPORT */2544 : isObject(type)2545 ? 4 /* STATEFUL_COMPONENT */2546 : isFunction(type)2547 ? 2 /* FUNCTIONAL_COMPONENT */2548 : 0;2549 const vnode = {2550 __v_isVNode: true,2551 ["__v_skip" /* SKIP */]: true,2552 type,2553 props,2554 key: props && normalizeKey(props),2555 ref: props && normalizeRef(props),2556 scopeId: currentScopeId,2557 children: null,2558 component: null,2559 suspense: null,2560 ssContent: null,2561 ssFallback: null,2562 dirs: null,2563 transition: null,2564 el: null,2565 anchor: null,2566 target: null,2567 targetAnchor: null,2568 staticCount: 0,2569 shapeFlag,2570 patchFlag,2571 dynamicProps,2572 dynamicChildren: null,2573 appContext: null2574 };2575 normalizeChildren(vnode, children);2576 // normalize suspense children2577 if ( shapeFlag & 128 /* SUSPENSE */) {2578 const { content, fallback } = normalizeSuspenseChildren(vnode);2579 vnode.ssContent = content;2580 vnode.ssFallback = fallback;2581 }2582 if (shouldTrack$1 > 0 &&2583 // avoid a block node from tracking itself2584 !isBlockNode &&2585 // has current parent block2586 currentBlock &&2587 // presence of a patch flag indicates this node needs patching on updates.2588 // component nodes also should always be patched, because even if the2589 // component doesn't need to update, it needs to persist the instance on to2590 // the next vnode so that it can be properly unmounted later.2591 (patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) &&2592 // the EVENTS flag is only for hydration and if it is the only flag, the2593 // vnode should not be considered dynamic due to handler caching.2594 patchFlag !== 32 /* HYDRATE_EVENTS */) {2595 currentBlock.push(vnode);2596 }2597 return vnode;2598}2599function cloneVNode(vnode, extraProps, mergeRef = false) {2600 // This is intentionally NOT using spread or extend to avoid the runtime2601 // key enumeration cost.2602 const { props, ref, patchFlag } = vnode;2603 const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;2604 return {2605 __v_isVNode: true,2606 ["__v_skip" /* SKIP */]: true,2607 type: vnode.type,2608 props: mergedProps,2609 key: mergedProps && normalizeKey(mergedProps),2610 ref: extraProps && extraProps.ref2611 ? // #2078 in the case of <component :is="vnode" ref="extra"/>2612 // if the vnode itself already has a ref, cloneVNode will need to merge2613 // the refs so the single vnode can be set on multiple refs2614 mergeRef && ref2615 ? isArray(ref)2616 ? ref.concat(normalizeRef(extraProps))2617 : [ref, normalizeRef(extraProps)]2618 : normalizeRef(extraProps)2619 : ref,2620 scopeId: vnode.scopeId,2621 children: vnode.children,2622 target: vnode.target,2623 targetAnchor: vnode.targetAnchor,2624 staticCount: vnode.staticCount,2625 shapeFlag: vnode.shapeFlag,2626 // if the vnode is cloned with extra props, we can no longer assume its2627 // existing patch flag to be reliable and need to add the FULL_PROPS flag.2628 // note: perserve flag for fragments since they use the flag for children2629 // fast paths only.2630 patchFlag: extraProps && vnode.type !== Fragment2631 ? patchFlag === -1 // hoisted node2632 ? 16 /* FULL_PROPS */2633 : patchFlag | 16 /* FULL_PROPS */2634 : patchFlag,2635 dynamicProps: vnode.dynamicProps,2636 dynamicChildren: vnode.dynamicChildren,2637 appContext: vnode.appContext,2638 dirs: vnode.dirs,2639 transition: vnode.transition,2640 // These should technically only be non-null on mounted VNodes. However,2641 // they *should* be copied for kept-alive vnodes. So we just always copy2642 // them since them being non-null during a mount doesn't affect the logic as2643 // they will simply be overwritten.2644 component: vnode.component,2645 suspense: vnode.suspense,2646 ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),2647 ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),2648 el: vnode.el,2649 anchor: vnode.anchor2650 };2651}2652/**2653 * @private2654 */2655function createTextVNode(text = ' ', flag = 0) {2656 return createVNode(Text, null, text, flag);2657}2658/**2659 * @private2660 */2661function createStaticVNode(content, numberOfNodes) {2662 // A static vnode can contain multiple stringified elements, and the number2663 // of elements is necessary for hydration.2664 const vnode = createVNode(Static, null, content);2665 vnode.staticCount = numberOfNodes;2666 return vnode;2667}2668/**2669 * @private2670 */2671function createCommentVNode(text = '', 2672// when used as the v-else branch, the comment node must be created as a2673// block to ensure correct updates.2674asBlock = false) {2675 return asBlock2676 ? (openBlock(), createBlock(Comment, null, text))2677 : createVNode(Comment, null, text);2678}2679function normalizeVNode(child) {2680 if (child == null || typeof child === 'boolean') {2681 // empty placeholder2682 return createVNode(Comment);2683 }2684 else if (isArray(child)) {2685 // fragment2686 return createVNode(Fragment, null, child);2687 }2688 else if (typeof child === 'object') {2689 // already vnode, this should be the most common since compiled templates2690 // always produce all-vnode children arrays2691 return child.el === null ? child : cloneVNode(child);2692 }2693 else {2694 // strings and numbers2695 return createVNode(Text, null, String(child));2696 }2697}2698// optimized normalization for template-compiled render fns2699function cloneIfMounted(child) {2700 return child.el === null ? child : cloneVNode(child);2701}2702function normalizeChildren(vnode, children) {2703 let type = 0;2704 const { shapeFlag } = vnode;2705 if (children == null) {2706 children = null;2707 }2708 else if (isArray(children)) {2709 type = 16 /* ARRAY_CHILDREN */;2710 }2711 else if (typeof children === 'object') {2712 if (shapeFlag & 1 /* ELEMENT */ || shapeFlag & 64 /* TELEPORT */) {2713 // Normalize slot to plain children for plain element and Teleport2714 const slot = children.default;2715 if (slot) {2716 // _c marker is added by withCtx() indicating this is a compiled slot2717 slot._c && setCompiledSlotRendering(1);2718 normalizeChildren(vnode, slot());2719 slot._c && setCompiledSlotRendering(-1);2720 }2721 return;2722 }2723 else {2724 type = 32 /* SLOTS_CHILDREN */;2725 const slotFlag = children._;2726 if (!slotFlag && !(InternalObjectKey in children)) {2727 children._ctx = currentRenderingInstance;2728 }2729 else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) {2730 // a child component receives forwarded slots from the parent.2731 // its slot type is determined by its parent's slot type.2732 if (currentRenderingInstance.vnode.patchFlag & 1024 /* DYNAMIC_SLOTS */) {2733 children._ = 2 /* DYNAMIC */;2734 vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */;2735 }2736 else {2737 children._ = 1 /* STABLE */;2738 }2739 }2740 }2741 }2742 else if (isFunction(children)) {2743 children = { default: children, _ctx: currentRenderingInstance };2744 type = 32 /* SLOTS_CHILDREN */;2745 }2746 else {2747 children = String(children);2748 // force teleport children to array so it can be moved around2749 if (shapeFlag & 64 /* TELEPORT */) {2750 type = 16 /* ARRAY_CHILDREN */;2751 children = [createTextVNode(children)];2752 }2753 else {2754 type = 8 /* TEXT_CHILDREN */;2755 }2756 }2757 vnode.children = children;2758 vnode.shapeFlag |= type;2759}2760function mergeProps(...args) {2761 const ret = extend({}, args[0]);2762 for (let i = 1; i < args.length; i++) {2763 const toMerge = args[i];2764 for (const key in toMerge) {2765 if (key === 'class') {2766 if (ret.class !== toMerge.class) {2767 ret.class = normalizeClass([ret.class, toMerge.class]);2768 }2769 }2770 else if (key === 'style') {2771 ret.style = normalizeStyle([ret.style, toMerge.style]);2772 }2773 else if (isOn(key)) {2774 const existing = ret[key];2775 const incoming = toMerge[key];2776 if (existing !== incoming) {2777 ret[key] = existing2778 ? [].concat(existing, toMerge[key])2779 : incoming;2780 }2781 }2782 else {2783 ret[key] = toMerge[key];2784 }2785 }2786 }2787 return ret;2788}2789function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison2790isSSR = false) {2791 const props = {};2792 const attrs = {};2793 def(attrs, InternalObjectKey, 1);2794 setFullProps(instance, rawProps, props, attrs);2795 if (isStateful) {2796 // stateful2797 instance.props = isSSR ? props : shallowReactive(props);2798 }2799 else {2800 if (!instance.type.props) {2801 // functional w/ optional props, props === attrs2802 instance.props = attrs;2803 }2804 else {2805 // functional w/ declared props2806 instance.props = props;2807 }2808 }2809 instance.attrs = attrs;2810}2811function updateProps(instance, rawProps, rawPrevProps, optimized) {2812 const { props, attrs, vnode: { patchFlag } } = instance;2813 const rawCurrentProps = toRaw(props);2814 const [options] = instance.propsOptions;2815 if (2816 // always force full diff if hmr is enabled2817 2818 (optimized || patchFlag > 0) &&2819 !(patchFlag & 16 /* FULL_PROPS */)) {2820 if (patchFlag & 8 /* PROPS */) {2821 // Compiler-generated props & no keys change, just set the updated2822 // the props.2823 const propsToUpdate = instance.vnode.dynamicProps;2824 for (let i = 0; i < propsToUpdate.length; i++) {2825 const key = propsToUpdate[i];2826 // PROPS flag guarantees rawProps to be non-null2827 const value = rawProps[key];2828 if (options) {2829 // attr / props separation was done on init and will be consistent2830 // in this code path, so just check if attrs have it.2831 if (hasOwn(attrs, key)) {2832 attrs[key] = value;2833 }2834 else {2835 const camelizedKey = camelize(key);2836 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance);2837 }2838 }2839 else {2840 attrs[key] = value;2841 }2842 }2843 }2844 }2845 else {2846 // full props update.2847 setFullProps(instance, rawProps, props, attrs);2848 // in case of dynamic props, check if we need to delete keys from2849 // the props object2850 let kebabKey;2851 for (const key in rawCurrentProps) {2852 if (!rawProps ||2853 // for camelCase2854 (!hasOwn(rawProps, key) &&2855 // it's possible the original props was passed in as kebab-case2856 // and converted to camelCase (#955)2857 ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {2858 if (options) {2859 if (rawPrevProps &&2860 // for camelCase2861 (rawPrevProps[key] !== undefined ||2862 // for kebab-case2863 rawPrevProps[kebabKey] !== undefined)) {2864 props[key] = resolvePropValue(options, rawProps || EMPTY_OBJ, key, undefined, instance);2865 }2866 }2867 else {2868 delete props[key];2869 }2870 }2871 }2872 // in the case of functional component w/o props declaration, props and2873 // attrs point to the same object so it should already have been updated.2874 if (attrs !== rawCurrentProps) {2875 for (const key in attrs) {2876 if (!rawProps || !hasOwn(rawProps, key)) {2877 delete attrs[key];2878 }2879 }2880 }2881 }2882 // trigger updates for $attrs in case it's used in component slots2883 trigger(instance, "set" /* SET */, '$attrs');2884}2885function setFullProps(instance, rawProps, props, attrs) {2886 const [options, needCastKeys] = instance.propsOptions;2887 if (rawProps) {2888 for (const key in rawProps) {2889 const value = rawProps[key];2890 // key, ref are reserved and never passed down2891 if (isReservedProp(key)) {2892 continue;2893 }2894 // prop option names are camelized during normalization, so to support2895 // kebab -> camel conversion here we need to camelize the key.2896 let camelKey;2897 if (options && hasOwn(options, (camelKey = camelize(key)))) {2898 props[camelKey] = value;2899 }2900 else if (!isEmitListener(instance.emitsOptions, key)) {2901 // Any non-declared (either as a prop or an emitted event) props are put2902 // into a separate `attrs` object for spreading. Make sure to preserve2903 // original key casing2904 attrs[key] = value;2905 }2906 }2907 }2908 if (needCastKeys) {2909 const rawCurrentProps = toRaw(props);2910 for (let i = 0; i < needCastKeys.length; i++) {2911 const key = needCastKeys[i];2912 props[key] = resolvePropValue(options, rawCurrentProps, key, rawCurrentProps[key], instance);2913 }2914 }2915}2916function resolvePropValue(options, props, key, value, instance) {2917 const opt = options[key];2918 if (opt != null) {2919 const hasDefault = hasOwn(opt, 'default');2920 // default values2921 if (hasDefault && value === undefined) {2922 const defaultValue = opt.default;2923 if (opt.type !== Function && isFunction(defaultValue)) {2924 setCurrentInstance(instance);2925 value = defaultValue(props);2926 setCurrentInstance(null);2927 }2928 else {2929 value = defaultValue;2930 }2931 }2932 // boolean casting2933 if (opt[0 /* shouldCast */]) {2934 if (!hasOwn(props, key) && !hasDefault) {2935 value = false;2936 }2937 else if (opt[1 /* shouldCastTrue */] &&2938 (value === '' || value === hyphenate(key))) {2939 value = true;2940 }2941 }2942 }2943 return value;2944}2945function normalizePropsOptions(comp, appContext, asMixin = false) {2946 const appId = appContext.app ? appContext.app._uid : -1;2947 const cache = comp.__props || (comp.__props = {});2948 const cached = cache[appId];2949 if (cached) {2950 return cached;2951 }2952 const raw = comp.props;2953 const normalized = {};2954 const needCastKeys = [];2955 // apply mixin/extends props2956 let hasExtends = false;2957 if (__VUE_OPTIONS_API__ && !isFunction(comp)) {2958 const extendProps = (raw) => {2959 hasExtends = true;2960 const [props, keys] = normalizePropsOptions(raw, appContext, true);2961 extend(normalized, props);2962 if (keys)2963 needCastKeys.push(...keys);2964 };2965 if (!asMixin && appContext.mixins.length) {2966 appContext.mixins.forEach(extendProps);2967 }2968 if (comp.extends) {2969 extendProps(comp.extends);2970 }2971 if (comp.mixins) {2972 comp.mixins.forEach(extendProps);2973 }2974 }2975 if (!raw && !hasExtends) {2976 return (cache[appId] = EMPTY_ARR);2977 }2978 if (isArray(raw)) {2979 for (let i = 0; i < raw.length; i++) {2980 const normalizedKey = camelize(raw[i]);2981 if (validatePropName(normalizedKey)) {2982 normalized[normalizedKey] = EMPTY_OBJ;2983 }2984 }2985 }2986 else if (raw) {2987 for (const key in raw) {2988 const normalizedKey = camelize(key);2989 if (validatePropName(normalizedKey)) {2990 const opt = raw[key];2991 const prop = (normalized[normalizedKey] =2992 isArray(opt) || isFunction(opt) ? { type: opt } : opt);2993 if (prop) {2994 const booleanIndex = getTypeIndex(Boolean, prop.type);2995 const stringIndex = getTypeIndex(String, prop.type);2996 prop[0 /* shouldCast */] = booleanIndex > -1;2997 prop[1 /* shouldCastTrue */] =2998 stringIndex < 0 || booleanIndex < stringIndex;2999 // if the prop needs boolean casting or default value3000 if (booleanIndex > -1 || hasOwn(prop, 'default')) {3001 needCastKeys.push(normalizedKey);3002 }3003 }3004 }3005 }3006 }3007 return (cache[appId] = [normalized, needCastKeys]);3008}3009// use function string name to check type constructors3010// so that it works across vms / iframes.3011function getType(ctor) {3012 const match = ctor && ctor.toString().match(/^\s*function (\w+)/);3013 return match ? match[1] : '';3014}3015function isSameType(a, b) {3016 return getType(a) === getType(b);3017}3018function getTypeIndex(type, expectedTypes) {3019 if (isArray(expectedTypes)) {3020 for (let i = 0, len = expectedTypes.length; i < len; i++) {3021 if (isSameType(expectedTypes[i], type)) {3022 return i;3023 }3024 }3025 }3026 else if (isFunction(expectedTypes)) {3027 return isSameType(expectedTypes, type) ? 0 : -1;3028 }3029 return -1;3030}3031/**3032 * dev only3033 */3034function validatePropName(key) {3035 if (key[0] !== '$') {3036 return true;3037 }3038 return false;3039}3040function injectHook(type, hook, target = currentInstance, prepend = false) {3041 if (target) {3042 const hooks = target[type] || (target[type] = []);3043 // cache the error handling wrapper for injected hooks so the same hook3044 // can be properly deduped by the scheduler. "__weh" stands for "with error3045 // handling".3046 const wrappedHook = hook.__weh ||3047 (hook.__weh = (...args) => {3048 if (target.isUnmounted) {3049 return;3050 }3051 // disable tracking inside all lifecycle hooks3052 // since they can potentially be called inside effects.3053 pauseTracking();3054 // Set currentInstance during hook invocation.3055 // This assumes the hook does not synchronously trigger other hooks, which3056 // can only be false when the user does something really funky.3057 setCurrentInstance(target);3058 const res = callWithAsyncErrorHandling(hook, target, type, args);3059 setCurrentInstance(null);3060 resetTracking();3061 return res;3062 });3063 if (prepend) {3064 hooks.unshift(wrappedHook);3065 }3066 else {3067 hooks.push(wrappedHook);3068 }3069 return wrappedHook;3070 }3071}3072const createHook = (lifecycle) => (hook, target = currentInstance) => 3073// post-create lifecycle registrations are noops during SSR3074!isInSSRComponentSetup && injectHook(lifecycle, hook, target);3075const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);3076const onMounted = createHook("m" /* MOUNTED */);3077const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);3078const onUpdated = createHook("u" /* UPDATED */);3079const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);3080const onUnmounted = createHook("um" /* UNMOUNTED */);3081const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);3082const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);3083const onErrorCaptured = (hook, target = currentInstance) => {3084 injectHook("ec" /* ERROR_CAPTURED */, hook, target);3085};3086function useTransitionState() {3087 const state = {3088 isMounted: false,3089 isLeaving: false,3090 isUnmounting: false,3091 leavingVNodes: new Map()3092 };3093 onMounted(() => {3094 state.isMounted = true;3095 });3096 onBeforeUnmount(() => {3097 state.isUnmounting = true;3098 });3099 return state;3100}3101const TransitionHookValidator = [Function, Array];3102const BaseTransitionImpl = {3103 name: `BaseTransition`,3104 props: {3105 mode: String,3106 appear: Boolean,3107 persisted: Boolean,3108 // enter3109 onBeforeEnter: TransitionHookValidator,3110 onEnter: TransitionHookValidator,3111 onAfterEnter: TransitionHookValidator,3112 onEnterCancelled: TransitionHookValidator,3113 // leave3114 onBeforeLeave: TransitionHookValidator,3115 onLeave: TransitionHookValidator,3116 onAfterLeave: TransitionHookValidator,3117 onLeaveCancelled: TransitionHookValidator,3118 // appear3119 onBeforeAppear: TransitionHookValidator,3120 onAppear: TransitionHookValidator,3121 onAfterAppear: TransitionHookValidator,3122 onAppearCancelled: TransitionHookValidator3123 },3124 setup(props, { slots }) {3125 const instance = getCurrentInstance();3126 const state = useTransitionState();3127 let prevTransitionKey;3128 return () => {3129 const children = slots.default && getTransitionRawChildren(slots.default(), true);3130 if (!children || !children.length) {3131 return;3132 }3133 // there's no need to track reactivity for these props so use the raw3134 // props for a bit better perf3135 const rawProps = toRaw(props);3136 const { mode } = rawProps;3137 // at this point children has a guaranteed length of 1.3138 const child = children[0];3139 if (state.isLeaving) {3140 return emptyPlaceholder(child);3141 }3142 // in the case of <transition><keep-alive/></transition>, we need to3143 // compare the type of the kept-alive children.3144 const innerChild = getKeepAliveChild(child);3145 if (!innerChild) {3146 return emptyPlaceholder(child);3147 }3148 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);3149 setTransitionHooks(innerChild, enterHooks);3150 const oldChild = instance.subTree;3151 const oldInnerChild = oldChild && getKeepAliveChild(oldChild);3152 let transitionKeyChanged = false;3153 const { getTransitionKey } = innerChild.type;3154 if (getTransitionKey) {3155 const key = getTransitionKey();3156 if (prevTransitionKey === undefined) {3157 prevTransitionKey = key;3158 }3159 else if (key !== prevTransitionKey) {3160 prevTransitionKey = key;3161 transitionKeyChanged = true;3162 }3163 }3164 // handle mode3165 if (oldInnerChild &&3166 oldInnerChild.type !== Comment &&3167 (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {3168 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);3169 // update old tree's hooks in case of dynamic transition3170 setTransitionHooks(oldInnerChild, leavingHooks);3171 // switching between different views3172 if (mode === 'out-in') {3173 state.isLeaving = true;3174 // return placeholder node and queue update when leave finishes3175 leavingHooks.afterLeave = () => {3176 state.isLeaving = false;3177 instance.update();3178 };3179 return emptyPlaceholder(child);3180 }3181 else if (mode === 'in-out') {3182 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {3183 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);3184 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;3185 // early removal callback3186 el._leaveCb = () => {3187 earlyRemove();3188 el._leaveCb = undefined;3189 delete enterHooks.delayedLeave;3190 };3191 enterHooks.delayedLeave = delayedLeave;3192 };3193 }3194 }3195 return child;3196 };3197 }3198};3199// export the public type for h/tsx inference3200// also to avoid inline import() in generated d.ts files3201const BaseTransition = BaseTransitionImpl;3202function getLeavingNodesForType(state, vnode) {3203 const { leavingVNodes } = state;3204 let leavingVNodesCache = leavingVNodes.get(vnode.type);3205 if (!leavingVNodesCache) {3206 leavingVNodesCache = Object.create(null);3207 leavingVNodes.set(vnode.type, leavingVNodesCache);3208 }3209 return leavingVNodesCache;3210}3211// The transition hooks are attached to the vnode as vnode.transition3212// and will be called at appropriate timing in the renderer.3213function resolveTransitionHooks(vnode, props, state, instance) {3214 const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;3215 const key = String(vnode.key);3216 const leavingVNodesCache = getLeavingNodesForType(state, vnode);3217 const callHook = (hook, args) => {3218 hook &&3219 callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);3220 };3221 const hooks = {3222 mode,3223 persisted,3224 beforeEnter(el) {3225 let hook = onBeforeEnter;3226 if (!state.isMounted) {3227 if (appear) {3228 hook = onBeforeAppear || onBeforeEnter;3229 }3230 else {3231 return;3232 }3233 }3234 // for same element (v-show)3235 if (el._leaveCb) {3236 el._leaveCb(true /* cancelled */);3237 }3238 // for toggled element with same key (v-if)3239 const leavingVNode = leavingVNodesCache[key];3240 if (leavingVNode &&3241 isSameVNodeType(vnode, leavingVNode) &&3242 leavingVNode.el._leaveCb) {3243 // force early removal (not cancelled)3244 leavingVNode.el._leaveCb();3245 }3246 callHook(hook, [el]);3247 },3248 enter(el) {3249 let hook = onEnter;3250 let afterHook = onAfterEnter;3251 let cancelHook = onEnterCancelled;3252 if (!state.isMounted) {3253 if (appear) {3254 hook = onAppear || onEnter;3255 afterHook = onAfterAppear || onAfterEnter;3256 cancelHook = onAppearCancelled || onEnterCancelled;3257 }3258 else {3259 return;3260 }3261 }3262 let called = false;3263 const done = (el._enterCb = (cancelled) => {3264 if (called)3265 return;3266 called = true;3267 if (cancelled) {3268 callHook(cancelHook, [el]);3269 }3270 else {3271 callHook(afterHook, [el]);3272 }3273 if (hooks.delayedLeave) {3274 hooks.delayedLeave();3275 }3276 el._enterCb = undefined;3277 });3278 if (hook) {3279 hook(el, done);3280 if (hook.length <= 1) {3281 done();3282 }3283 }3284 else {3285 done();3286 }3287 },3288 leave(el, remove) {3289 const key = String(vnode.key);3290 if (el._enterCb) {3291 el._enterCb(true /* cancelled */);3292 }3293 if (state.isUnmounting) {3294 return remove();3295 }3296 callHook(onBeforeLeave, [el]);3297 let called = false;3298 const done = (el._leaveCb = (cancelled) => {3299 if (called)3300 return;3301 called = true;3302 remove();3303 if (cancelled) {3304 callHook(onLeaveCancelled, [el]);3305 }3306 else {3307 callHook(onAfterLeave, [el]);3308 }3309 el._leaveCb = undefined;3310 if (leavingVNodesCache[key] === vnode) {3311 delete leavingVNodesCache[key];3312 }3313 });3314 leavingVNodesCache[key] = vnode;3315 if (onLeave) {3316 onLeave(el, done);3317 if (onLeave.length <= 1) {3318 done();3319 }3320 }3321 else {3322 done();3323 }3324 },3325 clone(vnode) {3326 return resolveTransitionHooks(vnode, props, state, instance);3327 }3328 };3329 return hooks;3330}3331// the placeholder really only handles one special case: KeepAlive3332// in the case of a KeepAlive in a leave phase we need to return a KeepAlive3333// placeholder with empty content to avoid the KeepAlive instance from being3334// unmounted.3335function emptyPlaceholder(vnode) {3336 if (isKeepAlive(vnode)) {3337 vnode = cloneVNode(vnode);3338 vnode.children = null;3339 return vnode;3340 }3341}3342function getKeepAliveChild(vnode) {3343 return isKeepAlive(vnode)3344 ? vnode.children3345 ? vnode.children[0]3346 : undefined3347 : vnode;3348}3349function setTransitionHooks(vnode, hooks) {3350 if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {3351 setTransitionHooks(vnode.component.subTree, hooks);3352 }3353 else if ( vnode.shapeFlag & 128 /* SUSPENSE */) {3354 vnode.ssContent.transition = hooks.clone(vnode.ssContent);3355 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);3356 }3357 else {3358 vnode.transition = hooks;3359 }3360}3361function getTransitionRawChildren(children, keepComment = false) {3362 let ret = [];3363 let keyedFragmentCount = 0;3364 for (let i = 0; i < children.length; i++) {3365 const child = children[i];3366 // handle fragment children case, e.g. v-for3367 if (child.type === Fragment) {3368 if (child.patchFlag & 128 /* KEYED_FRAGMENT */)3369 keyedFragmentCount++;3370 ret = ret.concat(getTransitionRawChildren(child.children, keepComment));3371 }3372 // comment placeholders should be skipped, e.g. v-if3373 else if (keepComment || child.type !== Comment) {3374 ret.push(child);3375 }3376 }3377 // #1126 if a transition children list contains multiple sub fragments, these3378 // fragments will be merged into a flat children array. Since each v-for3379 // fragment may contain different static bindings inside, we need to de-top3380 // these children to force full diffs to ensure correct behavior.3381 if (keyedFragmentCount > 1) {3382 for (let i = 0; i < ret.length; i++) {3383 ret[i].patchFlag = -2 /* BAIL */;3384 }3385 }3386 return ret;3387}3388const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;3389const KeepAliveImpl = {3390 name: `KeepAlive`,3391 // Marker for special handling inside the renderer. We are not using a ===3392 // check directly on KeepAlive in the renderer, because importing it directly3393 // would prevent it from being tree-shaken.3394 __isKeepAlive: true,3395 inheritRef: true,3396 props: {3397 include: [String, RegExp, Array],3398 exclude: [String, RegExp, Array],3399 max: [String, Number]3400 },3401 setup(props, { slots }) {3402 const cache = new Map();3403 const keys = new Set();3404 let current = null;3405 const instance = getCurrentInstance();3406 const parentSuspense = instance.suspense;3407 // KeepAlive communicates with the instantiated renderer via the3408 // ctx where the renderer passes in its internals,3409 // and the KeepAlive instance exposes activate/deactivate implementations.3410 // The whole point of this is to avoid importing KeepAlive directly in the3411 // renderer to facilitate tree-shaking.3412 const sharedContext = instance.ctx;3413 const { renderer: { p: patch, m: move, um: _unmount, o: { createElement } } } = sharedContext;3414 const storageContainer = createElement('div');3415 sharedContext.activate = (vnode, container, anchor, isSVG, optimized) => {3416 const instance = vnode.component;3417 move(vnode, container, anchor, 0 /* ENTER */, parentSuspense);3418 // in case props have changed3419 patch(instance.vnode, vnode, container, anchor, instance, parentSuspense, isSVG, optimized);3420 queuePostRenderEffect(() => {3421 instance.isDeactivated = false;3422 if (instance.a) {3423 invokeArrayFns(instance.a);3424 }3425 const vnodeHook = vnode.props && vnode.props.onVnodeMounted;3426 if (vnodeHook) {3427 invokeVNodeHook(vnodeHook, instance.parent, vnode);3428 }3429 }, parentSuspense);3430 };3431 sharedContext.deactivate = (vnode) => {3432 const instance = vnode.component;3433 move(vnode, storageContainer, null, 1 /* LEAVE */, parentSuspense);3434 queuePostRenderEffect(() => {3435 if (instance.da) {3436 invokeArrayFns(instance.da);3437 }3438 const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;3439 if (vnodeHook) {3440 invokeVNodeHook(vnodeHook, instance.parent, vnode);3441 }3442 instance.isDeactivated = true;3443 }, parentSuspense);3444 };3445 function unmount(vnode) {3446 // reset the shapeFlag so it can be properly unmounted3447 resetShapeFlag(vnode);3448 _unmount(vnode, instance, parentSuspense);3449 }3450 function pruneCache(filter) {3451 cache.forEach((vnode, key) => {3452 const name = getName(vnode.type);3453 if (name && (!filter || !filter(name))) {3454 pruneCacheEntry(key);3455 }3456 });3457 }3458 function pruneCacheEntry(key) {3459 const cached = cache.get(key);3460 if (!current || cached.type !== current.type) {3461 unmount(cached);3462 }3463 else if (current) {3464 // current active instance should no longer be kept-alive.3465 // we can't unmount it now but it might be later, so reset its flag now.3466 resetShapeFlag(current);3467 }3468 cache.delete(key);3469 keys.delete(key);3470 }3471 // prune cache on include/exclude prop change3472 watch(() => [props.include, props.exclude], ([include, exclude]) => {3473 include && pruneCache(name => matches(include, name));3474 exclude && pruneCache(name => !matches(exclude, name));3475 }, 3476 // prune post-render after `current` has been updated3477 { flush: 'post' });3478 // cache sub tree after render3479 let pendingCacheKey = null;3480 const cacheSubtree = () => {3481 // fix #1621, the pendingCacheKey could be 03482 if (pendingCacheKey != null) {3483 cache.set(pendingCacheKey, getInnerChild(instance.subTree));3484 }3485 };3486 onMounted(cacheSubtree);3487 onUpdated(cacheSubtree);3488 onBeforeUnmount(() => {3489 cache.forEach(cached => {3490 const { subTree, suspense } = instance;3491 const vnode = getInnerChild(subTree);3492 if (cached.type === vnode.type) {3493 // current instance will be unmounted as part of keep-alive's unmount3494 resetShapeFlag(vnode);3495 // but invoke its deactivated hook here3496 const da = vnode.component.da;3497 da && queuePostRenderEffect(da, suspense);3498 return;3499 }3500 unmount(cached);3501 });3502 });3503 return () => {3504 pendingCacheKey = null;3505 if (!slots.default) {3506 return null;3507 }3508 const children = slots.default();3509 const rawVNode = children[0];3510 if (children.length > 1) {3511 current = null;3512 return children;3513 }3514 else if (!isVNode(rawVNode) ||3515 (!(rawVNode.shapeFlag & 4 /* STATEFUL_COMPONENT */) &&3516 !(rawVNode.shapeFlag & 128 /* SUSPENSE */))) {3517 current = null;3518 return rawVNode;3519 }3520 let vnode = getInnerChild(rawVNode);3521 const comp = vnode.type;3522 const name = getName(comp);3523 const { include, exclude, max } = props;3524 if ((include && (!name || !matches(include, name))) ||3525 (exclude && name && matches(exclude, name))) {3526 current = vnode;3527 return rawVNode;3528 }3529 const key = vnode.key == null ? comp : vnode.key;3530 const cachedVNode = cache.get(key);3531 // clone vnode if it's reused because we are going to mutate it3532 if (vnode.el) {3533 vnode = cloneVNode(vnode);3534 if (rawVNode.shapeFlag & 128 /* SUSPENSE */) {3535 rawVNode.ssContent = vnode;3536 }3537 }3538 // #1513 it's possible for the returned vnode to be cloned due to attr3539 // fallthrough or scopeId, so the vnode here may not be the final vnode3540 // that is mounted. Instead of caching it directly, we store the pending3541 // key and cache `instance.subTree` (the normalized vnode) in3542 // beforeMount/beforeUpdate hooks.3543 pendingCacheKey = key;3544 if (cachedVNode) {3545 // copy over mounted state3546 vnode.el = cachedVNode.el;3547 vnode.component = cachedVNode.component;3548 if (vnode.transition) {3549 // recursively update transition hooks on subTree3550 setTransitionHooks(vnode, vnode.transition);3551 }3552 // avoid vnode being mounted as fresh3553 vnode.shapeFlag |= 512 /* COMPONENT_KEPT_ALIVE */;3554 // make this key the freshest3555 keys.delete(key);3556 keys.add(key);3557 }3558 else {3559 keys.add(key);3560 // prune oldest entry3561 if (max && keys.size > parseInt(max, 10)) {3562 pruneCacheEntry(keys.values().next().value);3563 }3564 }3565 // avoid vnode being unmounted3566 vnode.shapeFlag |= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;3567 current = vnode;3568 return rawVNode;3569 };3570 }3571};3572// export the public type for h/tsx inference3573// also to avoid inline import() in generated d.ts files3574const KeepAlive = KeepAliveImpl;3575function getName(comp) {3576 return comp.displayName || comp.name;3577}3578function matches(pattern, name) {3579 if (isArray(pattern)) {3580 return pattern.some((p) => matches(p, name));3581 }3582 else if (isString(pattern)) {3583 return pattern.split(',').indexOf(name) > -1;3584 }3585 else if (pattern.test) {3586 return pattern.test(name);3587 }3588 /* istanbul ignore next */3589 return false;3590}3591function onActivated(hook, target) {3592 registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);3593}3594function onDeactivated(hook, target) {3595 registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);3596}3597function registerKeepAliveHook(hook, type, target = currentInstance) {3598 // cache the deactivate branch check wrapper for injected hooks so the same3599 // hook can be properly deduped by the scheduler. "__wdc" stands for "with3600 // deactivation check".3601 const wrappedHook = hook.__wdc ||3602 (hook.__wdc = () => {3603 // only fire the hook if the target instance is NOT in a deactivated branch.3604 let current = target;3605 while (current) {3606 if (current.isDeactivated) {3607 return;3608 }3609 current = current.parent;3610 }3611 hook();3612 });3613 injectHook(type, wrappedHook, target);3614 // In addition to registering it on the target instance, we walk up the parent3615 // chain and register it on all ancestor instances that are keep-alive roots.3616 // This avoids the need to walk the entire component tree when invoking these3617 // hooks, and more importantly, avoids the need to track child components in3618 // arrays.3619 if (target) {3620 let current = target.parent;3621 while (current && current.parent) {3622 if (isKeepAlive(current.parent.vnode)) {3623 injectToKeepAliveRoot(wrappedHook, type, target, current);3624 }3625 current = current.parent;3626 }3627 }3628}3629function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {3630 // injectHook wraps the original for error handling, so make sure to remove3631 // the wrapped version.3632 const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);3633 onUnmounted(() => {3634 remove(keepAliveRoot[type], injected);3635 }, target);3636}3637function resetShapeFlag(vnode) {3638 let shapeFlag = vnode.shapeFlag;3639 if (shapeFlag & 256 /* COMPONENT_SHOULD_KEEP_ALIVE */) {3640 shapeFlag -= 256 /* COMPONENT_SHOULD_KEEP_ALIVE */;3641 }3642 if (shapeFlag & 512 /* COMPONENT_KEPT_ALIVE */) {3643 shapeFlag -= 512 /* COMPONENT_KEPT_ALIVE */;3644 }3645 vnode.shapeFlag = shapeFlag;3646}3647function getInnerChild(vnode) {3648 return vnode.shapeFlag & 128 /* SUSPENSE */ ? vnode.ssContent : vnode;3649}3650const isInternalKey = (key) => key[0] === '_' || key === '$stable';3651const normalizeSlotValue = (value) => isArray(value)3652 ? value.map(normalizeVNode)3653 : [normalizeVNode(value)];3654const normalizeSlot = (key, rawSlot, ctx) => withCtx((props) => {3655 return normalizeSlotValue(rawSlot(props));3656}, ctx);3657const normalizeObjectSlots = (rawSlots, slots) => {3658 const ctx = rawSlots._ctx;3659 for (const key in rawSlots) {3660 if (isInternalKey(key))3661 continue;3662 const value = rawSlots[key];3663 if (isFunction(value)) {3664 slots[key] = normalizeSlot(key, value, ctx);3665 }3666 else if (value != null) {3667 const normalized = normalizeSlotValue(value);3668 slots[key] = () => normalized;3669 }3670 }3671};3672const normalizeVNodeSlots = (instance, children) => {3673 const normalized = normalizeSlotValue(children);3674 instance.slots.default = () => normalized;3675};3676const initSlots = (instance, children) => {3677 if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {3678 const type = children._;3679 if (type) {3680 instance.slots = children;3681 // make compiler marker non-enumerable3682 def(children, '_', type);3683 }3684 else {3685 normalizeObjectSlots(children, (instance.slots = {}));3686 }3687 }3688 else {3689 instance.slots = {};3690 if (children) {3691 normalizeVNodeSlots(instance, children);3692 }3693 }3694 def(instance.slots, InternalObjectKey, 1);3695};3696const updateSlots = (instance, children) => {3697 const { vnode, slots } = instance;3698 let needDeletionCheck = true;3699 let deletionComparisonTarget = EMPTY_OBJ;3700 if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {3701 const type = children._;3702 if (type) {3703 // compiled slots.3704 if (type === 1 /* STABLE */) {3705 // compiled AND stable.3706 // no need to update, and skip stale slots removal.3707 needDeletionCheck = false;3708 }3709 else {3710 // compiled but dynamic (v-if/v-for on slots) - update slots, but skip3711 // normalization.3712 extend(slots, children);3713 }3714 }3715 else {3716 needDeletionCheck = !children.$stable;3717 normalizeObjectSlots(children, slots);3718 }3719 deletionComparisonTarget = children;3720 }3721 else if (children) {3722 // non slot object children (direct value) passed to a component3723 normalizeVNodeSlots(instance, children);3724 deletionComparisonTarget = { default: 1 };3725 }3726 // delete stale slots3727 if (needDeletionCheck) {3728 for (const key in slots) {3729 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {3730 delete slots[key];3731 }3732 }3733 }3734};3735/**3736 * Adds directives to a VNode.3737 */3738function withDirectives(vnode, directives) {3739 const internalInstance = currentRenderingInstance;3740 if (internalInstance === null) {3741 return vnode;3742 }3743 const instance = internalInstance.proxy;3744 const bindings = vnode.dirs || (vnode.dirs = []);3745 for (let i = 0; i < directives.length; i++) {3746 let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];3747 if (isFunction(dir)) {3748 dir = {3749 mounted: dir,3750 updated: dir3751 };3752 }3753 bindings.push({3754 dir,3755 instance,3756 value,3757 oldValue: void 0,3758 arg,3759 modifiers3760 });3761 }3762 return vnode;3763}3764function invokeDirectiveHook(vnode, prevVNode, instance, name) {3765 const bindings = vnode.dirs;3766 const oldBindings = prevVNode && prevVNode.dirs;3767 for (let i = 0; i < bindings.length; i++) {3768 const binding = bindings[i];3769 if (oldBindings) {3770 binding.oldValue = oldBindings[i].value;3771 }3772 const hook = binding.dir[name];3773 if (hook) {3774 callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [3775 vnode.el,3776 binding,3777 vnode,3778 prevVNode3779 ]);3780 }3781 }3782}3783function createAppContext() {3784 return {3785 app: null,3786 config: {3787 isNativeTag: NO,3788 performance: false,3789 globalProperties: {},3790 optionMergeStrategies: {},3791 isCustomElement: NO,3792 errorHandler: undefined,3793 warnHandler: undefined3794 },3795 mixins: [],3796 components: {},3797 directives: {},3798 provides: Object.create(null)3799 };3800}3801let uid$1 = 0;3802function createAppAPI(render, hydrate) {3803 return function createApp(rootComponent, rootProps = null) {3804 if (rootProps != null && !isObject(rootProps)) {3805 rootProps = null;3806 }3807 const context = createAppContext();3808 const installedPlugins = new Set();3809 let isMounted = false;3810 const app = (context.app = {3811 _uid: uid$1++,3812 _component: rootComponent,3813 _props: rootProps,3814 _container: null,3815 _context: context,3816 version,3817 get config() {3818 return context.config;3819 },3820 set config(v) {3821 },3822 use(plugin, ...options) {3823 if (installedPlugins.has(plugin)) ;3824 else if (plugin && isFunction(plugin.install)) {3825 installedPlugins.add(plugin);3826 plugin.install(app, ...options);3827 }3828 else if (isFunction(plugin)) {3829 installedPlugins.add(plugin);3830 plugin(app, ...options);3831 }3832 else ;3833 return app;3834 },3835 mixin(mixin) {3836 if (__VUE_OPTIONS_API__) {3837 if (!context.mixins.includes(mixin)) {3838 context.mixins.push(mixin);3839 }3840 }3841 return app;3842 },3843 component(name, component) {3844 if (!component) {3845 return context.components[name];3846 }3847 context.components[name] = component;3848 return app;3849 },3850 directive(name, directive) {3851 if (!directive) {3852 return context.directives[name];3853 }3854 context.directives[name] = directive;3855 return app;3856 },3857 mount(rootContainer, isHydrate) {3858 if (!isMounted) {3859 const vnode = createVNode(rootComponent, rootProps);3860 // store app context on the root VNode.3861 // this will be set on the root instance on initial mount.3862 vnode.appContext = context;3863 if (isHydrate && hydrate) {3864 hydrate(vnode, rootContainer);3865 }3866 else {3867 render(vnode, rootContainer);3868 }3869 isMounted = true;3870 app._container = rootContainer;3871 rootContainer.__vue_app__ = app;3872 if ( __VUE_PROD_DEVTOOLS__) {3873 devtoolsInitApp(app, version);3874 }3875 return vnode.component.proxy;3876 }3877 },3878 unmount() {3879 if (isMounted) {3880 render(null, app._container);3881 if ( __VUE_PROD_DEVTOOLS__) {3882 devtoolsUnmountApp(app);3883 }3884 }3885 },3886 provide(key, value) {3887 // TypeScript doesn't allow symbols as index type3888 // https://github.com/Microsoft/TypeScript/issues/245873889 context.provides[key] = value;3890 return app;3891 }3892 });3893 return app;3894 };3895}3896let hasMismatch = false;...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

...1373 Comment,1374 Static1375 });1376}1377function devtoolsUnmountApp(app) {1378 emit("app:unmount" /* APP_UNMOUNT */, app);1379}1380const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);1381const devtoolsComponentUpdated = 1382/*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);1383const devtoolsComponentRemoved = 1384/*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);1385function createDevtoolsComponentHook(hook) {1386 return (component) => {1387 emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);1388 };1389}1390function devtoolsComponentEmit(component, event, params) {1391 emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);1392}1393function emit$1(instance, event, ...rawArgs) {1394 const props = instance.vnode.props || EMPTY_OBJ;1395 let args = rawArgs;1396 const isModelListener = event.startsWith('update:');1397 // for v-model update:xxx events, apply modifiers on args1398 const modelArg = isModelListener && event.slice(7);1399 if (modelArg && modelArg in props) {1400 const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;1401 const { number, trim } = props[modifiersKey] || EMPTY_OBJ;1402 if (trim) {1403 args = rawArgs.map(a => a.trim());1404 }1405 else if (number) {1406 args = rawArgs.map(toNumber);1407 }1408 }1409 if (__VUE_PROD_DEVTOOLS__) {1410 devtoolsComponentEmit(instance, event, args);1411 }1412 let handlerName;1413 let handler = props[(handlerName = toHandlerKey(event))] ||1414 // also try camelCase event handler (#2249)1415 props[(handlerName = toHandlerKey(camelize(event)))];1416 // for v-model update:xxx events, also trigger kebab-case equivalent1417 // for props passed via kebab-case1418 if (!handler && isModelListener) {1419 handler = props[(handlerName = toHandlerKey(hyphenate(event)))];1420 }1421 if (handler) {1422 callWithAsyncErrorHandling(handler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);1423 }1424 const onceHandler = props[handlerName + `Once`];1425 if (onceHandler) {1426 if (!instance.emitted) {1427 instance.emitted = {};1428 }1429 else if (instance.emitted[handlerName]) {1430 return;1431 }1432 instance.emitted[handlerName] = true;1433 callWithAsyncErrorHandling(onceHandler, instance, 6 /* COMPONENT_EVENT_HANDLER */, args);1434 }1435}1436function normalizeEmitsOptions(comp, appContext, asMixin = false) {1437 const cache = appContext.emitsCache;1438 const cached = cache.get(comp);1439 if (cached !== undefined) {1440 return cached;1441 }1442 const raw = comp.emits;1443 let normalized = {};1444 // apply mixin/extends props1445 let hasExtends = false;1446 if (__VUE_OPTIONS_API__ && !isFunction(comp)) {1447 const extendEmits = (raw) => {1448 const normalizedFromExtend = normalizeEmitsOptions(raw, appContext, true);1449 if (normalizedFromExtend) {1450 hasExtends = true;1451 extend(normalized, normalizedFromExtend);1452 }1453 };1454 if (!asMixin && appContext.mixins.length) {1455 appContext.mixins.forEach(extendEmits);1456 }1457 if (comp.extends) {1458 extendEmits(comp.extends);1459 }1460 if (comp.mixins) {1461 comp.mixins.forEach(extendEmits);1462 }1463 }1464 if (!raw && !hasExtends) {1465 cache.set(comp, null);1466 return null;1467 }1468 if (isArray(raw)) {1469 raw.forEach(key => (normalized[key] = null));1470 }1471 else {1472 extend(normalized, raw);1473 }1474 cache.set(comp, normalized);1475 return normalized;1476}1477// Check if an incoming prop key is a declared emit event listener.1478// e.g. With `emits: { click: null }`, props named `onClick` and `onclick` are1479// both considered matched listeners.1480function isEmitListener(options, key) {1481 if (!options || !isOn(key)) {1482 return false;1483 }1484 key = key.slice(2).replace(/Once$/, '');1485 return (hasOwn(options, key[0].toLowerCase() + key.slice(1)) ||1486 hasOwn(options, hyphenate(key)) ||1487 hasOwn(options, key));1488}1489/**1490 * mark the current rendering instance for asset resolution (e.g.1491 * resolveComponent, resolveDirective) during render1492 */1493let currentRenderingInstance = null;1494let currentScopeId = null;1495/**1496 * Note: rendering calls maybe nested. The function returns the parent rendering1497 * instance if present, which should be restored after the render is done:1498 *1499 * ```js1500 * const prev = setCurrentRenderingInstance(i)1501 * // ...render1502 * setCurrentRenderingInstance(prev)1503 * ```1504 */1505function setCurrentRenderingInstance(instance) {1506 const prev = currentRenderingInstance;1507 currentRenderingInstance = instance;1508 currentScopeId = (instance && instance.type.__scopeId) || null;1509 return prev;1510}1511/**1512 * Wrap a slot function to memoize current rendering instance1513 * @private compiler helper1514 */1515function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only1516) {1517 if (!ctx)1518 return fn;1519 // already normalized1520 if (fn._n) {1521 return fn;1522 }1523 const renderFnWithContext = (...args) => {1524 // If a user calls a compiled slot inside a template expression (#1745), it1525 // can mess up block tracking, so by default we disable block tracking and1526 // force bail out when invoking a compiled slot (indicated by the ._d flag).1527 // This isn't necessary if rendering a compiled `<slot>`, so we flip the1528 // ._d flag off when invoking the wrapped fn inside `renderSlot`.1529 if (renderFnWithContext._d) {1530 setBlockTracking(-1);1531 }1532 const prevInstance = setCurrentRenderingInstance(ctx);1533 const res = fn(...args);1534 setCurrentRenderingInstance(prevInstance);1535 if (renderFnWithContext._d) {1536 setBlockTracking(1);1537 }1538 if (__VUE_PROD_DEVTOOLS__) {1539 devtoolsComponentUpdated(ctx);1540 }1541 return res;1542 };1543 // mark normalized to avoid duplicated wrapping1544 renderFnWithContext._n = true;1545 // mark this as compiled by default1546 // this is used in vnode.ts -> normalizeChildren() to set the slot1547 // rendering flag.1548 renderFnWithContext._c = true;1549 // disable block tracking by default1550 renderFnWithContext._d = true;1551 return renderFnWithContext;1552}1553function markAttrsAccessed() {1554}1555function renderComponentRoot(instance) {1556 const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;1557 let result;1558 let fallthroughAttrs;1559 const prev = setCurrentRenderingInstance(instance);1560 try {1561 if (vnode.shapeFlag & 4 /* STATEFUL_COMPONENT */) {1562 // withProxy is a proxy with a different `has` trap only for1563 // runtime-compiled render functions using `with` block.1564 const proxyToUse = withProxy || proxy;1565 result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));1566 fallthroughAttrs = attrs;1567 }1568 else {1569 // functional1570 const render = Component;1571 // in dev, mark attrs accessed if optional props (attrs === props)1572 if (("production" !== 'production') && attrs === props) ;1573 result = normalizeVNode(render.length > 11574 ? render(props, ("production" !== 'production')1575 ? {1576 get attrs() {1577 markAttrsAccessed();1578 return attrs;1579 },1580 slots,1581 emit1582 }1583 : { attrs, slots, emit })1584 : render(props, null /* we know it doesn't need it */));1585 fallthroughAttrs = Component.props1586 ? attrs1587 : getFunctionalFallthrough(attrs);1588 }1589 }1590 catch (err) {1591 blockStack.length = 0;1592 handleError(err, instance, 1 /* RENDER_FUNCTION */);1593 result = createVNode(Comment);1594 }1595 // attr merging1596 // in dev mode, comments are preserved, and it's possible for a template1597 // to have comments along side the root element which makes it a fragment1598 let root = result;1599 if (fallthroughAttrs && inheritAttrs !== false) {1600 const keys = Object.keys(fallthroughAttrs);1601 const { shapeFlag } = root;1602 if (keys.length) {1603 if (shapeFlag & (1 /* ELEMENT */ | 6 /* COMPONENT */)) {1604 if (propsOptions && keys.some(isModelListener)) {1605 // If a v-model listener (onUpdate:xxx) has a corresponding declared1606 // prop, it indicates this component expects to handle v-model and1607 // it should not fallthrough.1608 // related: #1543, #1643, #19891609 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);1610 }1611 root = cloneVNode(root, fallthroughAttrs);1612 }1613 }1614 }1615 // inherit directives1616 if (vnode.dirs) {1617 root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;1618 }1619 // inherit transition data1620 if (vnode.transition) {1621 root.transition = vnode.transition;1622 }1623 {1624 result = root;1625 }1626 setCurrentRenderingInstance(prev);1627 return result;1628}1629const getFunctionalFallthrough = (attrs) => {1630 let res;1631 for (const key in attrs) {1632 if (key === 'class' || key === 'style' || isOn(key)) {1633 (res || (res = {}))[key] = attrs[key];1634 }1635 }1636 return res;1637};1638const filterModelListeners = (attrs, props) => {1639 const res = {};1640 for (const key in attrs) {1641 if (!isModelListener(key) || !(key.slice(9) in props)) {1642 res[key] = attrs[key];1643 }1644 }1645 return res;1646};1647function shouldUpdateComponent(prevVNode, nextVNode, optimized) {1648 const { props: prevProps, children: prevChildren, component } = prevVNode;1649 const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;1650 const emits = component.emitsOptions;1651 // force child update for runtime directive or transition on component vnode.1652 if (nextVNode.dirs || nextVNode.transition) {1653 return true;1654 }1655 if (optimized && patchFlag >= 0) {1656 if (patchFlag & 1024 /* DYNAMIC_SLOTS */) {1657 // slot content that references values that might have changed,1658 // e.g. in a v-for1659 return true;1660 }1661 if (patchFlag & 16 /* FULL_PROPS */) {1662 if (!prevProps) {1663 return !!nextProps;1664 }1665 // presence of this flag indicates props are always non-null1666 return hasPropsChanged(prevProps, nextProps, emits);1667 }1668 else if (patchFlag & 8 /* PROPS */) {1669 const dynamicProps = nextVNode.dynamicProps;1670 for (let i = 0; i < dynamicProps.length; i++) {1671 const key = dynamicProps[i];1672 if (nextProps[key] !== prevProps[key] &&1673 !isEmitListener(emits, key)) {1674 return true;1675 }1676 }1677 }1678 }1679 else {1680 // this path is only taken by manually written render functions1681 // so presence of any children leads to a forced update1682 if (prevChildren || nextChildren) {1683 if (!nextChildren || !nextChildren.$stable) {1684 return true;1685 }1686 }1687 if (prevProps === nextProps) {1688 return false;1689 }1690 if (!prevProps) {1691 return !!nextProps;1692 }1693 if (!nextProps) {1694 return true;1695 }1696 return hasPropsChanged(prevProps, nextProps, emits);1697 }1698 return false;1699}1700function hasPropsChanged(prevProps, nextProps, emitsOptions) {1701 const nextKeys = Object.keys(nextProps);1702 if (nextKeys.length !== Object.keys(prevProps).length) {1703 return true;1704 }1705 for (let i = 0; i < nextKeys.length; i++) {1706 const key = nextKeys[i];1707 if (nextProps[key] !== prevProps[key] &&1708 !isEmitListener(emitsOptions, key)) {1709 return true;1710 }1711 }1712 return false;1713}1714function updateHOCHostEl({ vnode, parent }, el // HostNode1715) {1716 while (parent && parent.subTree === vnode) {1717 (vnode = parent.vnode).el = el;1718 parent = parent.parent;1719 }1720}1721const isSuspense = (type) => type.__isSuspense;1722function queueEffectWithSuspense(fn, suspense) {1723 if (suspense && suspense.pendingBranch) {1724 if (isArray(fn)) {1725 suspense.effects.push(...fn);1726 }1727 else {1728 suspense.effects.push(fn);1729 }1730 }1731 else {1732 queuePostFlushCb(fn);1733 }1734}1735function provide(key, value) {1736 if (!currentInstance) ;1737 else {1738 let provides = currentInstance.provides;1739 // by default an instance inherits its parent's provides object1740 // but when it needs to provide values of its own, it creates its1741 // own provides object using parent provides object as prototype.1742 // this way in `inject` we can simply look up injections from direct1743 // parent and let the prototype chain do the work.1744 const parentProvides = currentInstance.parent && currentInstance.parent.provides;1745 if (parentProvides === provides) {1746 provides = currentInstance.provides = Object.create(parentProvides);1747 }1748 // TS doesn't allow symbol as index type1749 provides[key] = value;1750 }1751}1752function inject(key, defaultValue, treatDefaultAsFactory = false) {1753 // fallback to `currentRenderingInstance` so that this can be called in1754 // a functional component1755 const instance = currentInstance || currentRenderingInstance;1756 if (instance) {1757 // #24001758 // to support `app.use` plugins,1759 // fallback to appContext's `provides` if the instance is at root1760 const provides = instance.parent == null1761 ? instance.vnode.appContext && instance.vnode.appContext.provides1762 : instance.parent.provides;1763 if (provides && key in provides) {1764 // TS doesn't allow symbol as index type1765 return provides[key];1766 }1767 else if (arguments.length > 1) {1768 return treatDefaultAsFactory && isFunction(defaultValue)1769 ? defaultValue.call(instance.proxy)1770 : defaultValue;1771 }1772 else ;1773 }1774}1775// initial value for watchers to trigger on undefined initial values1776const INITIAL_WATCHER_VALUE = {};1777// implementation1778function watch(source, cb, options) {1779 return doWatch(source, cb, options);1780}1781function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {1782 const instance = currentInstance;1783 let getter;1784 let forceTrigger = false;1785 let isMultiSource = false;1786 if (isRef(source)) {1787 getter = () => source.value;1788 forceTrigger = isShallow(source);1789 }1790 else if (isReactive(source)) {1791 getter = () => source;1792 deep = true;1793 }1794 else if (isArray(source)) {1795 isMultiSource = true;1796 forceTrigger = source.some(isReactive);1797 getter = () => source.map(s => {1798 if (isRef(s)) {1799 return s.value;1800 }1801 else if (isReactive(s)) {1802 return traverse(s);1803 }1804 else if (isFunction(s)) {1805 return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */);1806 }1807 else ;1808 });1809 }1810 else if (isFunction(source)) {1811 if (cb) {1812 // getter with cb1813 getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */);1814 }1815 else {1816 // no cb -> simple effect1817 getter = () => {1818 if (instance && instance.isUnmounted) {1819 return;1820 }1821 if (cleanup) {1822 cleanup();1823 }1824 return callWithAsyncErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onCleanup]);1825 };1826 }1827 }1828 else {1829 getter = NOOP;1830 }1831 if (cb && deep) {1832 const baseGetter = getter;1833 getter = () => traverse(baseGetter());1834 }1835 let cleanup;1836 let onCleanup = (fn) => {1837 cleanup = effect.onStop = () => {1838 callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */);1839 };1840 };1841 // in SSR there is no need to setup an actual effect, and it should be noop1842 // unless it's eager1843 if (isInSSRComponentSetup) {1844 // we will also not call the invalidate callback (+ runner is not set up)1845 onCleanup = NOOP;1846 if (!cb) {1847 getter();1848 }1849 else if (immediate) {1850 callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [1851 getter(),1852 isMultiSource ? [] : undefined,1853 onCleanup1854 ]);1855 }1856 return NOOP;1857 }1858 let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;1859 const job = () => {1860 if (!effect.active) {1861 return;1862 }1863 if (cb) {1864 // watch(source, cb)1865 const newValue = effect.run();1866 if (deep ||1867 forceTrigger ||1868 (isMultiSource1869 ? newValue.some((v, i) => hasChanged(v, oldValue[i]))1870 : hasChanged(newValue, oldValue)) ||1871 (false )) {1872 // cleanup before running cb again1873 if (cleanup) {1874 cleanup();1875 }1876 callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [1877 newValue,1878 // pass undefined as the old value when it's changed for the first time1879 oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,1880 onCleanup1881 ]);1882 oldValue = newValue;1883 }1884 }1885 else {1886 // watchEffect1887 effect.run();1888 }1889 };1890 // important: mark the job as a watcher callback so that scheduler knows1891 // it is allowed to self-trigger (#1727)1892 job.allowRecurse = !!cb;1893 let scheduler;1894 if (flush === 'sync') {1895 scheduler = job; // the scheduler function gets called directly1896 }1897 else if (flush === 'post') {1898 scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);1899 }1900 else {1901 // default: 'pre'1902 scheduler = () => {1903 if (!instance || instance.isMounted) {1904 queuePreFlushCb(job);1905 }1906 else {1907 // with 'pre' option, the first call must happen before1908 // the component is mounted so it is called synchronously.1909 job();1910 }1911 };1912 }1913 const effect = new ReactiveEffect(getter, scheduler);1914 // initial run1915 if (cb) {1916 if (immediate) {1917 job();1918 }1919 else {1920 oldValue = effect.run();1921 }1922 }1923 else if (flush === 'post') {1924 queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);1925 }1926 else {1927 effect.run();1928 }1929 return () => {1930 effect.stop();1931 if (instance && instance.scope) {1932 remove(instance.scope.effects, effect);1933 }1934 };1935}1936// this.$watch1937function instanceWatch(source, value, options) {1938 const publicThis = this.proxy;1939 const getter = isString(source)1940 ? source.includes('.')1941 ? createPathGetter(publicThis, source)1942 : () => publicThis[source]1943 : source.bind(publicThis, publicThis);1944 let cb;1945 if (isFunction(value)) {1946 cb = value;1947 }1948 else {1949 cb = value.handler;1950 options = value;1951 }1952 const cur = currentInstance;1953 setCurrentInstance(this);1954 const res = doWatch(getter, cb.bind(publicThis), options);1955 if (cur) {1956 setCurrentInstance(cur);1957 }1958 else {1959 unsetCurrentInstance();1960 }1961 return res;1962}1963function createPathGetter(ctx, path) {1964 const segments = path.split('.');1965 return () => {1966 let cur = ctx;1967 for (let i = 0; i < segments.length && cur; i++) {1968 cur = cur[segments[i]];1969 }1970 return cur;1971 };1972}1973function traverse(value, seen) {1974 if (!isObject(value) || value["__v_skip" /* SKIP */]) {1975 return value;1976 }1977 seen = seen || new Set();1978 if (seen.has(value)) {1979 return value;1980 }1981 seen.add(value);1982 if (isRef(value)) {1983 traverse(value.value, seen);1984 }1985 else if (isArray(value)) {1986 for (let i = 0; i < value.length; i++) {1987 traverse(value[i], seen);1988 }1989 }1990 else if (isSet(value) || isMap(value)) {1991 value.forEach((v) => {1992 traverse(v, seen);1993 });1994 }1995 else if (isPlainObject(value)) {1996 for (const key in value) {1997 traverse(value[key], seen);1998 }1999 }2000 return value;2001}2002function useTransitionState() {2003 const state = {2004 isMounted: false,2005 isLeaving: false,2006 isUnmounting: false,2007 leavingVNodes: new Map()2008 };2009 onMounted(() => {2010 state.isMounted = true;2011 });2012 onBeforeUnmount(() => {2013 state.isUnmounting = true;2014 });2015 return state;2016}2017const TransitionHookValidator = [Function, Array];2018const BaseTransitionImpl = {2019 name: `BaseTransition`,2020 props: {2021 mode: String,2022 appear: Boolean,2023 persisted: Boolean,2024 // enter2025 onBeforeEnter: TransitionHookValidator,2026 onEnter: TransitionHookValidator,2027 onAfterEnter: TransitionHookValidator,2028 onEnterCancelled: TransitionHookValidator,2029 // leave2030 onBeforeLeave: TransitionHookValidator,2031 onLeave: TransitionHookValidator,2032 onAfterLeave: TransitionHookValidator,2033 onLeaveCancelled: TransitionHookValidator,2034 // appear2035 onBeforeAppear: TransitionHookValidator,2036 onAppear: TransitionHookValidator,2037 onAfterAppear: TransitionHookValidator,2038 onAppearCancelled: TransitionHookValidator2039 },2040 setup(props, { slots }) {2041 const instance = getCurrentInstance();2042 const state = useTransitionState();2043 let prevTransitionKey;2044 return () => {2045 const children = slots.default && getTransitionRawChildren(slots.default(), true);2046 if (!children || !children.length) {2047 return;2048 }2049 // there's no need to track reactivity for these props so use the raw2050 // props for a bit better perf2051 const rawProps = toRaw(props);2052 const { mode } = rawProps;2053 // at this point children has a guaranteed length of 1.2054 const child = children[0];2055 if (state.isLeaving) {2056 return emptyPlaceholder(child);2057 }2058 // in the case of <transition><keep-alive/></transition>, we need to2059 // compare the type of the kept-alive children.2060 const innerChild = getKeepAliveChild(child);2061 if (!innerChild) {2062 return emptyPlaceholder(child);2063 }2064 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);2065 setTransitionHooks(innerChild, enterHooks);2066 const oldChild = instance.subTree;2067 const oldInnerChild = oldChild && getKeepAliveChild(oldChild);2068 let transitionKeyChanged = false;2069 const { getTransitionKey } = innerChild.type;2070 if (getTransitionKey) {2071 const key = getTransitionKey();2072 if (prevTransitionKey === undefined) {2073 prevTransitionKey = key;2074 }2075 else if (key !== prevTransitionKey) {2076 prevTransitionKey = key;2077 transitionKeyChanged = true;2078 }2079 }2080 // handle mode2081 if (oldInnerChild &&2082 oldInnerChild.type !== Comment &&2083 (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {2084 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);2085 // update old tree's hooks in case of dynamic transition2086 setTransitionHooks(oldInnerChild, leavingHooks);2087 // switching between different views2088 if (mode === 'out-in') {2089 state.isLeaving = true;2090 // return placeholder node and queue update when leave finishes2091 leavingHooks.afterLeave = () => {2092 state.isLeaving = false;2093 instance.update();2094 };2095 return emptyPlaceholder(child);2096 }2097 else if (mode === 'in-out' && innerChild.type !== Comment) {2098 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {2099 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);2100 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;2101 // early removal callback2102 el._leaveCb = () => {2103 earlyRemove();2104 el._leaveCb = undefined;2105 delete enterHooks.delayedLeave;2106 };2107 enterHooks.delayedLeave = delayedLeave;2108 };2109 }2110 }2111 return child;2112 };2113 }2114};2115// export the public type for h/tsx inference2116// also to avoid inline import() in generated d.ts files2117const BaseTransition = BaseTransitionImpl;2118function getLeavingNodesForType(state, vnode) {2119 const { leavingVNodes } = state;2120 let leavingVNodesCache = leavingVNodes.get(vnode.type);2121 if (!leavingVNodesCache) {2122 leavingVNodesCache = Object.create(null);2123 leavingVNodes.set(vnode.type, leavingVNodesCache);2124 }2125 return leavingVNodesCache;2126}2127// The transition hooks are attached to the vnode as vnode.transition2128// and will be called at appropriate timing in the renderer.2129function resolveTransitionHooks(vnode, props, state, instance) {2130 const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;2131 const key = String(vnode.key);2132 const leavingVNodesCache = getLeavingNodesForType(state, vnode);2133 const callHook = (hook, args) => {2134 hook &&2135 callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args);2136 };2137 const hooks = {2138 mode,2139 persisted,2140 beforeEnter(el) {2141 let hook = onBeforeEnter;2142 if (!state.isMounted) {2143 if (appear) {2144 hook = onBeforeAppear || onBeforeEnter;2145 }2146 else {2147 return;2148 }2149 }2150 // for same element (v-show)2151 if (el._leaveCb) {2152 el._leaveCb(true /* cancelled */);2153 }2154 // for toggled element with same key (v-if)2155 const leavingVNode = leavingVNodesCache[key];2156 if (leavingVNode &&2157 isSameVNodeType(vnode, leavingVNode) &&2158 leavingVNode.el._leaveCb) {2159 // force early removal (not cancelled)2160 leavingVNode.el._leaveCb();2161 }2162 callHook(hook, [el]);2163 },2164 enter(el) {2165 let hook = onEnter;2166 let afterHook = onAfterEnter;2167 let cancelHook = onEnterCancelled;2168 if (!state.isMounted) {2169 if (appear) {2170 hook = onAppear || onEnter;2171 afterHook = onAfterAppear || onAfterEnter;2172 cancelHook = onAppearCancelled || onEnterCancelled;2173 }2174 else {2175 return;2176 }2177 }2178 let called = false;2179 const done = (el._enterCb = (cancelled) => {2180 if (called)2181 return;2182 called = true;2183 if (cancelled) {2184 callHook(cancelHook, [el]);2185 }2186 else {2187 callHook(afterHook, [el]);2188 }2189 if (hooks.delayedLeave) {2190 hooks.delayedLeave();2191 }2192 el._enterCb = undefined;2193 });2194 if (hook) {2195 hook(el, done);2196 if (hook.length <= 1) {2197 done();2198 }2199 }2200 else {2201 done();2202 }2203 },2204 leave(el, remove) {2205 const key = String(vnode.key);2206 if (el._enterCb) {2207 el._enterCb(true /* cancelled */);2208 }2209 if (state.isUnmounting) {2210 return remove();2211 }2212 callHook(onBeforeLeave, [el]);2213 let called = false;2214 const done = (el._leaveCb = (cancelled) => {2215 if (called)2216 return;2217 called = true;2218 remove();2219 if (cancelled) {2220 callHook(onLeaveCancelled, [el]);2221 }2222 else {2223 callHook(onAfterLeave, [el]);2224 }2225 el._leaveCb = undefined;2226 if (leavingVNodesCache[key] === vnode) {2227 delete leavingVNodesCache[key];2228 }2229 });2230 leavingVNodesCache[key] = vnode;2231 if (onLeave) {2232 onLeave(el, done);2233 if (onLeave.length <= 1) {2234 done();2235 }2236 }2237 else {2238 done();2239 }2240 },2241 clone(vnode) {2242 return resolveTransitionHooks(vnode, props, state, instance);2243 }2244 };2245 return hooks;2246}2247// the placeholder really only handles one special case: KeepAlive2248// in the case of a KeepAlive in a leave phase we need to return a KeepAlive2249// placeholder with empty content to avoid the KeepAlive instance from being2250// unmounted.2251function emptyPlaceholder(vnode) {2252 if (isKeepAlive(vnode)) {2253 vnode = cloneVNode(vnode);2254 vnode.children = null;2255 return vnode;2256 }2257}2258function getKeepAliveChild(vnode) {2259 return isKeepAlive(vnode)2260 ? vnode.children2261 ? vnode.children[0]2262 : undefined2263 : vnode;2264}2265function setTransitionHooks(vnode, hooks) {2266 if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) {2267 setTransitionHooks(vnode.component.subTree, hooks);2268 }2269 else if (vnode.shapeFlag & 128 /* SUSPENSE */) {2270 vnode.ssContent.transition = hooks.clone(vnode.ssContent);2271 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);2272 }2273 else {2274 vnode.transition = hooks;2275 }2276}2277function getTransitionRawChildren(children, keepComment = false) {2278 let ret = [];2279 let keyedFragmentCount = 0;2280 for (let i = 0; i < children.length; i++) {2281 const child = children[i];2282 // handle fragment children case, e.g. v-for2283 if (child.type === Fragment) {2284 if (child.patchFlag & 128 /* KEYED_FRAGMENT */)2285 keyedFragmentCount++;2286 ret = ret.concat(getTransitionRawChildren(child.children, keepComment));2287 }2288 // comment placeholders should be skipped, e.g. v-if2289 else if (keepComment || child.type !== Comment) {2290 ret.push(child);2291 }2292 }2293 // #1126 if a transition children list contains multiple sub fragments, these2294 // fragments will be merged into a flat children array. Since each v-for2295 // fragment may contain different static bindings inside, we need to de-op2296 // these children to force full diffs to ensure correct behavior.2297 if (keyedFragmentCount > 1) {2298 for (let i = 0; i < ret.length; i++) {2299 ret[i].patchFlag = -2 /* BAIL */;2300 }2301 }2302 return ret;2303}2304const isAsyncWrapper = (i) => !!i.type.__asyncLoader;2305const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;2306function onActivated(hook, target) {2307 registerKeepAliveHook(hook, "a" /* ACTIVATED */, target);2308}2309function onDeactivated(hook, target) {2310 registerKeepAliveHook(hook, "da" /* DEACTIVATED */, target);2311}2312function registerKeepAliveHook(hook, type, target = currentInstance) {2313 // cache the deactivate branch check wrapper for injected hooks so the same2314 // hook can be properly deduped by the scheduler. "__wdc" stands for "with2315 // deactivation check".2316 const wrappedHook = hook.__wdc ||2317 (hook.__wdc = () => {2318 // only fire the hook if the target instance is NOT in a deactivated branch.2319 let current = target;2320 while (current) {2321 if (current.isDeactivated) {2322 return;2323 }2324 current = current.parent;2325 }2326 return hook();2327 });2328 injectHook(type, wrappedHook, target);2329 // In addition to registering it on the target instance, we walk up the parent2330 // chain and register it on all ancestor instances that are keep-alive roots.2331 // This avoids the need to walk the entire component tree when invoking these2332 // hooks, and more importantly, avoids the need to track child components in2333 // arrays.2334 if (target) {2335 let current = target.parent;2336 while (current && current.parent) {2337 if (isKeepAlive(current.parent.vnode)) {2338 injectToKeepAliveRoot(wrappedHook, type, target, current);2339 }2340 current = current.parent;2341 }2342 }2343}2344function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {2345 // injectHook wraps the original for error handling, so make sure to remove2346 // the wrapped version.2347 const injected = injectHook(type, hook, keepAliveRoot, true /* prepend */);2348 onUnmounted(() => {2349 remove(keepAliveRoot[type], injected);2350 }, target);2351}2352function injectHook(type, hook, target = currentInstance, prepend = false) {2353 if (target) {2354 const hooks = target[type] || (target[type] = []);2355 // cache the error handling wrapper for injected hooks so the same hook2356 // can be properly deduped by the scheduler. "__weh" stands for "with error2357 // handling".2358 const wrappedHook = hook.__weh ||2359 (hook.__weh = (...args) => {2360 if (target.isUnmounted) {2361 return;2362 }2363 // disable tracking inside all lifecycle hooks2364 // since they can potentially be called inside effects.2365 pauseTracking();2366 // Set currentInstance during hook invocation.2367 // This assumes the hook does not synchronously trigger other hooks, which2368 // can only be false when the user does something really funky.2369 setCurrentInstance(target);2370 const res = callWithAsyncErrorHandling(hook, target, type, args);2371 unsetCurrentInstance();2372 resetTracking();2373 return res;2374 });2375 if (prepend) {2376 hooks.unshift(wrappedHook);2377 }2378 else {2379 hooks.push(wrappedHook);2380 }2381 return wrappedHook;2382 }2383}2384const createHook = (lifecycle) => (hook, target = currentInstance) => 2385// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)2386(!isInSSRComponentSetup || lifecycle === "sp" /* SERVER_PREFETCH */) &&2387 injectHook(lifecycle, hook, target);2388const onBeforeMount = createHook("bm" /* BEFORE_MOUNT */);2389const onMounted = createHook("m" /* MOUNTED */);2390const onBeforeUpdate = createHook("bu" /* BEFORE_UPDATE */);2391const onUpdated = createHook("u" /* UPDATED */);2392const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */);2393const onUnmounted = createHook("um" /* UNMOUNTED */);2394const onServerPrefetch = createHook("sp" /* SERVER_PREFETCH */);2395const onRenderTriggered = createHook("rtg" /* RENDER_TRIGGERED */);2396const onRenderTracked = createHook("rtc" /* RENDER_TRACKED */);2397function onErrorCaptured(hook, target = currentInstance) {2398 injectHook("ec" /* ERROR_CAPTURED */, hook, target);2399}2400let shouldCacheAccess = true;2401function applyOptions(instance) {2402 const options = resolveMergedOptions(instance);2403 const publicThis = instance.proxy;2404 const ctx = instance.ctx;2405 // do not cache property access on public proxy during state initialization2406 shouldCacheAccess = false;2407 // call beforeCreate first before accessing other options since2408 // the hook may mutate resolved options (#2791)2409 if (options.beforeCreate) {2410 callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */);2411 }2412 const { 2413 // state2414 data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions, 2415 // lifecycle2416 created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch, 2417 // public API2418 expose, inheritAttrs, 2419 // assets2420 components, directives, filters } = options;2421 const checkDuplicateProperties = null;2422 // options initialization order (to be consistent with Vue 2):2423 // - props (already done outside of this function)2424 // - inject2425 // - methods2426 // - data (deferred since it relies on `this` access)2427 // - computed2428 // - watch (deferred since it relies on `this` access)2429 if (injectOptions) {2430 resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);2431 }2432 if (methods) {2433 for (const key in methods) {2434 const methodHandler = methods[key];2435 if (isFunction(methodHandler)) {2436 // In dev mode, we use the `createRenderContext` function to define2437 // methods to the proxy target, and those are read-only but2438 // reconfigurable, so it needs to be redefined here2439 {2440 ctx[key] = methodHandler.bind(publicThis);2441 }2442 }2443 }2444 }2445 if (dataOptions) {2446 const data = dataOptions.call(publicThis, publicThis);2447 if (!isObject(data)) ;2448 else {2449 instance.data = reactive(data);2450 }2451 }2452 // state initialization complete at this point - start caching access2453 shouldCacheAccess = true;2454 if (computedOptions) {2455 for (const key in computedOptions) {2456 const opt = computedOptions[key];2457 const get = isFunction(opt)2458 ? opt.bind(publicThis, publicThis)2459 : isFunction(opt.get)2460 ? opt.get.bind(publicThis, publicThis)2461 : NOOP;2462 const set = !isFunction(opt) && isFunction(opt.set)2463 ? opt.set.bind(publicThis)2464 : NOOP;2465 const c = computed({2466 get,2467 set2468 });2469 Object.defineProperty(ctx, key, {2470 enumerable: true,2471 configurable: true,2472 get: () => c.value,2473 set: v => (c.value = v)2474 });2475 }2476 }2477 if (watchOptions) {2478 for (const key in watchOptions) {2479 createWatcher(watchOptions[key], ctx, publicThis, key);2480 }2481 }2482 if (provideOptions) {2483 const provides = isFunction(provideOptions)2484 ? provideOptions.call(publicThis)2485 : provideOptions;2486 Reflect.ownKeys(provides).forEach(key => {2487 provide(key, provides[key]);2488 });2489 }2490 if (created) {2491 callHook(created, instance, "c" /* CREATED */);2492 }2493 function registerLifecycleHook(register, hook) {2494 if (isArray(hook)) {2495 hook.forEach(_hook => register(_hook.bind(publicThis)));2496 }2497 else if (hook) {2498 register(hook.bind(publicThis));2499 }2500 }2501 registerLifecycleHook(onBeforeMount, beforeMount);2502 registerLifecycleHook(onMounted, mounted);2503 registerLifecycleHook(onBeforeUpdate, beforeUpdate);2504 registerLifecycleHook(onUpdated, updated);2505 registerLifecycleHook(onActivated, activated);2506 registerLifecycleHook(onDeactivated, deactivated);2507 registerLifecycleHook(onErrorCaptured, errorCaptured);2508 registerLifecycleHook(onRenderTracked, renderTracked);2509 registerLifecycleHook(onRenderTriggered, renderTriggered);2510 registerLifecycleHook(onBeforeUnmount, beforeUnmount);2511 registerLifecycleHook(onUnmounted, unmounted);2512 registerLifecycleHook(onServerPrefetch, serverPrefetch);2513 if (isArray(expose)) {2514 if (expose.length) {2515 const exposed = instance.exposed || (instance.exposed = {});2516 expose.forEach(key => {2517 Object.defineProperty(exposed, key, {2518 get: () => publicThis[key],2519 set: val => (publicThis[key] = val)2520 });2521 });2522 }2523 else if (!instance.exposed) {2524 instance.exposed = {};2525 }2526 }2527 // options that are handled when creating the instance but also need to be2528 // applied from mixins2529 if (render && instance.render === NOOP) {2530 instance.render = render;2531 }2532 if (inheritAttrs != null) {2533 instance.inheritAttrs = inheritAttrs;2534 }2535 // asset options.2536 if (components)2537 instance.components = components;2538 if (directives)2539 instance.directives = directives;2540}2541function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {2542 if (isArray(injectOptions)) {2543 injectOptions = normalizeInject(injectOptions);2544 }2545 for (const key in injectOptions) {2546 const opt = injectOptions[key];2547 let injected;2548 if (isObject(opt)) {2549 if ('default' in opt) {2550 injected = inject(opt.from || key, opt.default, true /* treat default function as factory */);2551 }2552 else {2553 injected = inject(opt.from || key);2554 }2555 }2556 else {2557 injected = inject(opt);2558 }2559 if (isRef(injected)) {2560 // TODO remove the check in 3.32561 if (unwrapRef) {2562 Object.defineProperty(ctx, key, {2563 enumerable: true,2564 configurable: true,2565 get: () => injected.value,2566 set: v => (injected.value = v)2567 });2568 }2569 else {2570 ctx[key] = injected;2571 }2572 }2573 else {2574 ctx[key] = injected;2575 }2576 }2577}2578function callHook(hook, instance, type) {2579 callWithAsyncErrorHandling(isArray(hook)2580 ? hook.map(h => h.bind(instance.proxy))2581 : hook.bind(instance.proxy), instance, type);2582}2583function createWatcher(raw, ctx, publicThis, key) {2584 const getter = key.includes('.')2585 ? createPathGetter(publicThis, key)2586 : () => publicThis[key];2587 if (isString(raw)) {2588 const handler = ctx[raw];2589 if (isFunction(handler)) {2590 watch(getter, handler);2591 }2592 }2593 else if (isFunction(raw)) {2594 watch(getter, raw.bind(publicThis));2595 }2596 else if (isObject(raw)) {2597 if (isArray(raw)) {2598 raw.forEach(r => createWatcher(r, ctx, publicThis, key));2599 }2600 else {2601 const handler = isFunction(raw.handler)2602 ? raw.handler.bind(publicThis)2603 : ctx[raw.handler];2604 if (isFunction(handler)) {2605 watch(getter, handler, raw);2606 }2607 }2608 }2609 else ;2610}2611/**2612 * Resolve merged options and cache it on the component.2613 * This is done only once per-component since the merging does not involve2614 * instances.2615 */2616function resolveMergedOptions(instance) {2617 const base = instance.type;2618 const { mixins, extends: extendsOptions } = base;2619 const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;2620 const cached = cache.get(base);2621 let resolved;2622 if (cached) {2623 resolved = cached;2624 }2625 else if (!globalMixins.length && !mixins && !extendsOptions) {2626 {2627 resolved = base;2628 }2629 }2630 else {2631 resolved = {};2632 if (globalMixins.length) {2633 globalMixins.forEach(m => mergeOptions(resolved, m, optionMergeStrategies, true));2634 }2635 mergeOptions(resolved, base, optionMergeStrategies);2636 }2637 cache.set(base, resolved);2638 return resolved;2639}2640function mergeOptions(to, from, strats, asMixin = false) {2641 const { mixins, extends: extendsOptions } = from;2642 if (extendsOptions) {2643 mergeOptions(to, extendsOptions, strats, true);2644 }2645 if (mixins) {2646 mixins.forEach((m) => mergeOptions(to, m, strats, true));2647 }2648 for (const key in from) {2649 if (asMixin && key === 'expose') ;2650 else {2651 const strat = internalOptionMergeStrats[key] || (strats && strats[key]);2652 to[key] = strat ? strat(to[key], from[key]) : from[key];2653 }2654 }2655 return to;2656}2657const internalOptionMergeStrats = {2658 data: mergeDataFn,2659 props: mergeObjectOptions,2660 emits: mergeObjectOptions,2661 // objects2662 methods: mergeObjectOptions,2663 computed: mergeObjectOptions,2664 // lifecycle2665 beforeCreate: mergeAsArray,2666 created: mergeAsArray,2667 beforeMount: mergeAsArray,2668 mounted: mergeAsArray,2669 beforeUpdate: mergeAsArray,2670 updated: mergeAsArray,2671 beforeDestroy: mergeAsArray,2672 beforeUnmount: mergeAsArray,2673 destroyed: mergeAsArray,2674 unmounted: mergeAsArray,2675 activated: mergeAsArray,2676 deactivated: mergeAsArray,2677 errorCaptured: mergeAsArray,2678 serverPrefetch: mergeAsArray,2679 // assets2680 components: mergeObjectOptions,2681 directives: mergeObjectOptions,2682 // watch2683 watch: mergeWatchOptions,2684 // provide / inject2685 provide: mergeDataFn,2686 inject: mergeInject2687};2688function mergeDataFn(to, from) {2689 if (!from) {2690 return to;2691 }2692 if (!to) {2693 return from;2694 }2695 return function mergedDataFn() {2696 return (extend)(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);2697 };2698}2699function mergeInject(to, from) {2700 return mergeObjectOptions(normalizeInject(to), normalizeInject(from));2701}2702function normalizeInject(raw) {2703 if (isArray(raw)) {2704 const res = {};2705 for (let i = 0; i < raw.length; i++) {2706 res[raw[i]] = raw[i];2707 }2708 return res;2709 }2710 return raw;2711}2712function mergeAsArray(to, from) {2713 return to ? [...new Set([].concat(to, from))] : from;2714}2715function mergeObjectOptions(to, from) {2716 return to ? extend(extend(Object.create(null), to), from) : from;2717}2718function mergeWatchOptions(to, from) {2719 if (!to)2720 return from;2721 if (!from)2722 return to;2723 const merged = extend(Object.create(null), to);2724 for (const key in from) {2725 merged[key] = mergeAsArray(to[key], from[key]);2726 }2727 return merged;2728}2729function initProps(instance, rawProps, isStateful, // result of bitwise flag comparison2730isSSR = false) {2731 const props = {};2732 const attrs = {};2733 def(attrs, InternalObjectKey, 1);2734 instance.propsDefaults = Object.create(null);2735 setFullProps(instance, rawProps, props, attrs);2736 // ensure all declared prop keys are present2737 for (const key in instance.propsOptions[0]) {2738 if (!(key in props)) {2739 props[key] = undefined;2740 }2741 }2742 if (isStateful) {2743 // stateful2744 instance.props = isSSR ? props : shallowReactive(props);2745 }2746 else {2747 if (!instance.type.props) {2748 // functional w/ optional props, props === attrs2749 instance.props = attrs;2750 }2751 else {2752 // functional w/ declared props2753 instance.props = props;2754 }2755 }2756 instance.attrs = attrs;2757}2758function updateProps(instance, rawProps, rawPrevProps, optimized) {2759 const { props, attrs, vnode: { patchFlag } } = instance;2760 const rawCurrentProps = toRaw(props);2761 const [options] = instance.propsOptions;2762 let hasAttrsChanged = false;2763 if (2764 // always force full diff in dev2765 // - #1942 if hmr is enabled with sfc component2766 // - vite#872 non-sfc component used by sfc component2767 (optimized || patchFlag > 0) &&2768 !(patchFlag & 16 /* FULL_PROPS */)) {2769 if (patchFlag & 8 /* PROPS */) {2770 // Compiler-generated props & no keys change, just set the updated2771 // the props.2772 const propsToUpdate = instance.vnode.dynamicProps;2773 for (let i = 0; i < propsToUpdate.length; i++) {2774 let key = propsToUpdate[i];2775 // PROPS flag guarantees rawProps to be non-null2776 const value = rawProps[key];2777 if (options) {2778 // attr / props separation was done on init and will be consistent2779 // in this code path, so just check if attrs have it.2780 if (hasOwn(attrs, key)) {2781 if (value !== attrs[key]) {2782 attrs[key] = value;2783 hasAttrsChanged = true;2784 }2785 }2786 else {2787 const camelizedKey = camelize(key);2788 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false /* isAbsent */);2789 }2790 }2791 else {2792 if (value !== attrs[key]) {2793 attrs[key] = value;2794 hasAttrsChanged = true;2795 }2796 }2797 }2798 }2799 }2800 else {2801 // full props update.2802 if (setFullProps(instance, rawProps, props, attrs)) {2803 hasAttrsChanged = true;2804 }2805 // in case of dynamic props, check if we need to delete keys from2806 // the props object2807 let kebabKey;2808 for (const key in rawCurrentProps) {2809 if (!rawProps ||2810 // for camelCase2811 (!hasOwn(rawProps, key) &&2812 // it's possible the original props was passed in as kebab-case2813 // and converted to camelCase (#955)2814 ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey)))) {2815 if (options) {2816 if (rawPrevProps &&2817 // for camelCase2818 (rawPrevProps[key] !== undefined ||2819 // for kebab-case2820 rawPrevProps[kebabKey] !== undefined)) {2821 props[key] = resolvePropValue(options, rawCurrentProps, key, undefined, instance, true /* isAbsent */);2822 }2823 }2824 else {2825 delete props[key];2826 }2827 }2828 }2829 // in the case of functional component w/o props declaration, props and2830 // attrs point to the same object so it should already have been updated.2831 if (attrs !== rawCurrentProps) {2832 for (const key in attrs) {2833 if (!rawProps ||2834 (!hasOwn(rawProps, key) &&2835 (!false ))) {2836 delete attrs[key];2837 hasAttrsChanged = true;2838 }2839 }2840 }2841 }2842 // trigger updates for $attrs in case it's used in component slots2843 if (hasAttrsChanged) {2844 trigger(instance, "set" /* SET */, '$attrs');2845 }2846}2847function setFullProps(instance, rawProps, props, attrs) {2848 const [options, needCastKeys] = instance.propsOptions;2849 let hasAttrsChanged = false;2850 let rawCastValues;2851 if (rawProps) {2852 for (let key in rawProps) {2853 // key, ref are reserved and never passed down2854 if (isReservedProp(key)) {2855 continue;2856 }2857 const value = rawProps[key];2858 // prop option names are camelized during normalization, so to support2859 // kebab -> camel conversion here we need to camelize the key.2860 let camelKey;2861 if (options && hasOwn(options, (camelKey = camelize(key)))) {2862 if (!needCastKeys || !needCastKeys.includes(camelKey)) {2863 props[camelKey] = value;2864 }2865 else {2866 (rawCastValues || (rawCastValues = {}))[camelKey] = value;2867 }2868 }2869 else if (!isEmitListener(instance.emitsOptions, key)) {2870 if (!(key in attrs) || value !== attrs[key]) {2871 attrs[key] = value;2872 hasAttrsChanged = true;2873 }2874 }2875 }2876 }2877 if (needCastKeys) {2878 const rawCurrentProps = toRaw(props);2879 const castValues = rawCastValues || EMPTY_OBJ;2880 for (let i = 0; i < needCastKeys.length; i++) {2881 const key = needCastKeys[i];2882 props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));2883 }2884 }2885 return hasAttrsChanged;2886}2887function resolvePropValue(options, props, key, value, instance, isAbsent) {2888 const opt = options[key];2889 if (opt != null) {2890 const hasDefault = hasOwn(opt, 'default');2891 // default values2892 if (hasDefault && value === undefined) {2893 const defaultValue = opt.default;2894 if (opt.type !== Function && isFunction(defaultValue)) {2895 const { propsDefaults } = instance;2896 if (key in propsDefaults) {2897 value = propsDefaults[key];2898 }2899 else {2900 setCurrentInstance(instance);2901 value = propsDefaults[key] = defaultValue.call(null, props);2902 unsetCurrentInstance();2903 }2904 }2905 else {2906 value = defaultValue;2907 }2908 }2909 // boolean casting2910 if (opt[0 /* shouldCast */]) {2911 if (isAbsent && !hasDefault) {2912 value = false;2913 }2914 else if (opt[1 /* shouldCastTrue */] &&2915 (value === '' || value === hyphenate(key))) {2916 value = true;2917 }2918 }2919 }2920 return value;2921}2922function normalizePropsOptions(comp, appContext, asMixin = false) {2923 const cache = appContext.propsCache;2924 const cached = cache.get(comp);2925 if (cached) {2926 return cached;2927 }2928 const raw = comp.props;2929 const normalized = {};2930 const needCastKeys = [];2931 // apply mixin/extends props2932 let hasExtends = false;2933 if (__VUE_OPTIONS_API__ && !isFunction(comp)) {2934 const extendProps = (raw) => {2935 hasExtends = true;2936 const [props, keys] = normalizePropsOptions(raw, appContext, true);2937 extend(normalized, props);2938 if (keys)2939 needCastKeys.push(...keys);2940 };2941 if (!asMixin && appContext.mixins.length) {2942 appContext.mixins.forEach(extendProps);2943 }2944 if (comp.extends) {2945 extendProps(comp.extends);2946 }2947 if (comp.mixins) {2948 comp.mixins.forEach(extendProps);2949 }2950 }2951 if (!raw && !hasExtends) {2952 cache.set(comp, EMPTY_ARR);2953 return EMPTY_ARR;2954 }2955 if (isArray(raw)) {2956 for (let i = 0; i < raw.length; i++) {2957 const normalizedKey = camelize(raw[i]);2958 if (validatePropName(normalizedKey)) {2959 normalized[normalizedKey] = EMPTY_OBJ;2960 }2961 }2962 }2963 else if (raw) {2964 for (const key in raw) {2965 const normalizedKey = camelize(key);2966 if (validatePropName(normalizedKey)) {2967 const opt = raw[key];2968 const prop = (normalized[normalizedKey] =2969 isArray(opt) || isFunction(opt) ? { type: opt } : opt);2970 if (prop) {2971 const booleanIndex = getTypeIndex(Boolean, prop.type);2972 const stringIndex = getTypeIndex(String, prop.type);2973 prop[0 /* shouldCast */] = booleanIndex > -1;2974 prop[1 /* shouldCastTrue */] =2975 stringIndex < 0 || booleanIndex < stringIndex;2976 // if the prop needs boolean casting or default value2977 if (booleanIndex > -1 || hasOwn(prop, 'default')) {2978 needCastKeys.push(normalizedKey);2979 }2980 }2981 }2982 }2983 }2984 const res = [normalized, needCastKeys];2985 cache.set(comp, res);2986 return res;2987}2988function validatePropName(key) {2989 if (key[0] !== '$') {2990 return true;2991 }2992 return false;2993}2994// use function string name to check type constructors2995// so that it works across vms / iframes.2996function getType(ctor) {2997 const match = ctor && ctor.toString().match(/^\s*function (\w+)/);2998 return match ? match[1] : ctor === null ? 'null' : '';2999}3000function isSameType(a, b) {3001 return getType(a) === getType(b);3002}3003function getTypeIndex(type, expectedTypes) {3004 if (isArray(expectedTypes)) {3005 return expectedTypes.findIndex(t => isSameType(t, type));3006 }3007 else if (isFunction(expectedTypes)) {3008 return isSameType(expectedTypes, type) ? 0 : -1;3009 }3010 return -1;3011}3012const isInternalKey = (key) => key[0] === '_' || key === '$stable';3013const normalizeSlotValue = (value) => isArray(value)3014 ? value.map(normalizeVNode)3015 : [normalizeVNode(value)];3016const normalizeSlot = (key, rawSlot, ctx) => {3017 const normalized = withCtx((...args) => {3018 return normalizeSlotValue(rawSlot(...args));3019 }, ctx);3020 normalized._c = false;3021 return normalized;3022};3023const normalizeObjectSlots = (rawSlots, slots, instance) => {3024 const ctx = rawSlots._ctx;3025 for (const key in rawSlots) {3026 if (isInternalKey(key))3027 continue;3028 const value = rawSlots[key];3029 if (isFunction(value)) {3030 slots[key] = normalizeSlot(key, value, ctx);3031 }3032 else if (value != null) {3033 const normalized = normalizeSlotValue(value);3034 slots[key] = () => normalized;3035 }3036 }3037};3038const normalizeVNodeSlots = (instance, children) => {3039 const normalized = normalizeSlotValue(children);3040 instance.slots.default = () => normalized;3041};3042const initSlots = (instance, children) => {3043 if (instance.vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {3044 const type = children._;3045 if (type) {3046 // users can get the shallow readonly version of the slots object through `this.$slots`,3047 // we should avoid the proxy object polluting the slots of the internal instance3048 instance.slots = toRaw(children);3049 // make compiler marker non-enumerable3050 def(children, '_', type);3051 }3052 else {3053 normalizeObjectSlots(children, (instance.slots = {}));3054 }3055 }3056 else {3057 instance.slots = {};3058 if (children) {3059 normalizeVNodeSlots(instance, children);3060 }3061 }3062 def(instance.slots, InternalObjectKey, 1);3063};3064const updateSlots = (instance, children, optimized) => {3065 const { vnode, slots } = instance;3066 let needDeletionCheck = true;3067 let deletionComparisonTarget = EMPTY_OBJ;3068 if (vnode.shapeFlag & 32 /* SLOTS_CHILDREN */) {3069 const type = children._;3070 if (type) {3071 // compiled slots.3072 if (optimized && type === 1 /* STABLE */) {3073 // compiled AND stable.3074 // no need to update, and skip stale slots removal.3075 needDeletionCheck = false;3076 }3077 else {3078 // compiled but dynamic (v-if/v-for on slots) - update slots, but skip3079 // normalization.3080 extend(slots, children);3081 // #28933082 // when rendering the optimized slots by manually written render function,3083 // we need to delete the `slots._` flag if necessary to make subsequent updates reliable,3084 // i.e. let the `renderSlot` create the bailed Fragment3085 if (!optimized && type === 1 /* STABLE */) {3086 delete slots._;3087 }3088 }3089 }3090 else {3091 needDeletionCheck = !children.$stable;3092 normalizeObjectSlots(children, slots);3093 }3094 deletionComparisonTarget = children;3095 }3096 else if (children) {3097 // non slot object children (direct value) passed to a component3098 normalizeVNodeSlots(instance, children);3099 deletionComparisonTarget = { default: 1 };3100 }3101 // delete stale slots3102 if (needDeletionCheck) {3103 for (const key in slots) {3104 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {3105 delete slots[key];3106 }3107 }3108 }3109};3110function invokeDirectiveHook(vnode, prevVNode, instance, name) {3111 const bindings = vnode.dirs;3112 const oldBindings = prevVNode && prevVNode.dirs;3113 for (let i = 0; i < bindings.length; i++) {3114 const binding = bindings[i];3115 if (oldBindings) {3116 binding.oldValue = oldBindings[i].value;3117 }3118 let hook = binding.dir[name];3119 if (hook) {3120 // disable tracking inside all lifecycle hooks3121 // since they can potentially be called inside effects.3122 pauseTracking();3123 callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [3124 vnode.el,3125 binding,3126 vnode,3127 prevVNode3128 ]);3129 resetTracking();3130 }3131 }3132}3133function createAppContext() {3134 return {3135 app: null,3136 config: {3137 isNativeTag: NO,3138 performance: false,3139 globalProperties: {},3140 optionMergeStrategies: {},3141 errorHandler: undefined,3142 warnHandler: undefined,3143 compilerOptions: {}3144 },3145 mixins: [],3146 components: {},3147 directives: {},3148 provides: Object.create(null),3149 optionsCache: new WeakMap(),3150 propsCache: new WeakMap(),3151 emitsCache: new WeakMap()3152 };3153}3154let uid = 0;3155function createAppAPI(render, hydrate) {3156 return function createApp(rootComponent, rootProps = null) {3157 if (rootProps != null && !isObject(rootProps)) {3158 rootProps = null;3159 }3160 const context = createAppContext();3161 const installedPlugins = new Set();3162 let isMounted = false;3163 const app = (context.app = {3164 _uid: uid++,3165 _component: rootComponent,3166 _props: rootProps,3167 _container: null,3168 _context: context,3169 _instance: null,3170 version,3171 get config() {3172 return context.config;3173 },3174 set config(v) {3175 },3176 use(plugin, ...options) {3177 if (installedPlugins.has(plugin)) ;3178 else if (plugin && isFunction(plugin.install)) {3179 installedPlugins.add(plugin);3180 plugin.install(app, ...options);3181 }3182 else if (isFunction(plugin)) {3183 installedPlugins.add(plugin);3184 plugin(app, ...options);3185 }3186 else ;3187 return app;3188 },3189 mixin(mixin) {3190 if (__VUE_OPTIONS_API__) {3191 if (!context.mixins.includes(mixin)) {3192 context.mixins.push(mixin);3193 }3194 }3195 return app;3196 },3197 component(name, component) {3198 if (!component) {3199 return context.components[name];3200 }3201 context.components[name] = component;3202 return app;3203 },3204 directive(name, directive) {3205 if (!directive) {3206 return context.directives[name];3207 }3208 context.directives[name] = directive;3209 return app;3210 },3211 mount(rootContainer, isHydrate, isSVG) {3212 if (!isMounted) {3213 const vnode = createVNode(rootComponent, rootProps);3214 // store app context on the root VNode.3215 // this will be set on the root instance on initial mount.3216 vnode.appContext = context;3217 if (isHydrate && hydrate) {3218 hydrate(vnode, rootContainer);3219 }3220 else {3221 render(vnode, rootContainer, isSVG);3222 }3223 isMounted = true;3224 app._container = rootContainer;3225 rootContainer.__vue_app__ = app;3226 if (__VUE_PROD_DEVTOOLS__) {3227 app._instance = vnode.component;3228 devtoolsInitApp(app, version);3229 }3230 return getExposeProxy(vnode.component) || vnode.component.proxy;3231 }3232 },3233 unmount() {3234 if (isMounted) {3235 render(null, app._container);3236 if (__VUE_PROD_DEVTOOLS__) {3237 app._instance = null;3238 devtoolsUnmountApp(app);3239 }3240 delete app._container.__vue_app__;3241 }3242 },3243 provide(key, value) {3244 // TypeScript doesn't allow symbols as index type3245 // https://github.com/Microsoft/TypeScript/issues/245873246 context.provides[key] = value;3247 return app;3248 }3249 });3250 return app;3251 };3252}...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...1629 Comment,1630 Static1631 });1632}1633function devtoolsUnmountApp(app) {1634 emit("app:unmount", app);1635}1636var devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added");1637var devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated");1638var devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook("component:removed");1639function createDevtoolsComponentHook(hook) {1640 return (component) => {1641 emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : void 0, component);1642 };1643}1644var devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:start");1645var devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook("perf:end");1646function createDevtoolsPerformanceHook(hook) {1647 return (component, type, time) => {1648 emit(hook, component.appContext.app, component.uid, component, type, time);1649 };1650}1651function devtoolsComponentEmit(component, event, params) {1652 emit("component:emit", component.appContext.app, component, event, params);1653}1654function emit$1(instance, event, ...rawArgs) {1655 const props = instance.vnode.props || EMPTY_OBJ;1656 if (true) {1657 const { emitsOptions, propsOptions: [propsOptions] } = instance;1658 if (emitsOptions) {1659 if (!(event in emitsOptions) && true) {1660 if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {1661 warn2(`Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`);1662 }1663 } else {1664 const validator = emitsOptions[event];1665 if (isFunction(validator)) {1666 const isValid = validator(...rawArgs);1667 if (!isValid) {1668 warn2(`Invalid event arguments: event validation failed for event "${event}".`);1669 }1670 }1671 }1672 }1673 }1674 let args = rawArgs;1675 const isModelListener2 = event.startsWith("update:");1676 const modelArg = isModelListener2 && event.slice(7);1677 if (modelArg && modelArg in props) {1678 const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;1679 const { number, trim } = props[modifiersKey] || EMPTY_OBJ;1680 if (trim) {1681 args = rawArgs.map((a) => a.trim());1682 } else if (number) {1683 args = rawArgs.map(toNumber);1684 }1685 }1686 if (true) {1687 devtoolsComponentEmit(instance, event, args);1688 }1689 if (true) {1690 const lowerCaseEvent = event.toLowerCase();1691 if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {1692 warn2(`Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(event)}" instead of "${event}".`);1693 }1694 }1695 let handlerName;1696 let handler = props[handlerName = toHandlerKey(event)] || props[handlerName = toHandlerKey(camelize(event))];1697 if (!handler && isModelListener2) {1698 handler = props[handlerName = toHandlerKey(hyphenate(event))];1699 }1700 if (handler) {1701 callWithAsyncErrorHandling(handler, instance, 6, args);1702 }1703 const onceHandler = props[handlerName + `Once`];1704 if (onceHandler) {1705 if (!instance.emitted) {1706 instance.emitted = {};1707 } else if (instance.emitted[handlerName]) {1708 return;1709 }1710 instance.emitted[handlerName] = true;1711 callWithAsyncErrorHandling(onceHandler, instance, 6, args);1712 }1713}1714function normalizeEmitsOptions(comp, appContext, asMixin = false) {1715 const cache = appContext.emitsCache;1716 const cached = cache.get(comp);1717 if (cached !== void 0) {1718 return cached;1719 }1720 const raw = comp.emits;1721 let normalized = {};1722 let hasExtends = false;1723 if (!isFunction(comp)) {1724 const extendEmits = (raw2) => {1725 const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);1726 if (normalizedFromExtend) {1727 hasExtends = true;1728 extend(normalized, normalizedFromExtend);1729 }1730 };1731 if (!asMixin && appContext.mixins.length) {1732 appContext.mixins.forEach(extendEmits);1733 }1734 if (comp.extends) {1735 extendEmits(comp.extends);1736 }1737 if (comp.mixins) {1738 comp.mixins.forEach(extendEmits);1739 }1740 }1741 if (!raw && !hasExtends) {1742 cache.set(comp, null);1743 return null;1744 }1745 if (isArray(raw)) {1746 raw.forEach((key) => normalized[key] = null);1747 } else {1748 extend(normalized, raw);1749 }1750 cache.set(comp, normalized);1751 return normalized;1752}1753function isEmitListener(options, key) {1754 if (!options || !isOn(key)) {1755 return false;1756 }1757 key = key.slice(2).replace(/Once$/, "");1758 return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);1759}1760var currentRenderingInstance = null;1761var currentScopeId = null;1762function setCurrentRenderingInstance(instance) {1763 const prev = currentRenderingInstance;1764 currentRenderingInstance = instance;1765 currentScopeId = instance && instance.type.__scopeId || null;1766 return prev;1767}1768function pushScopeId(id) {1769 currentScopeId = id;1770}1771function popScopeId() {1772 currentScopeId = null;1773}1774function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {1775 if (!ctx)1776 return fn;1777 if (fn._n) {1778 return fn;1779 }1780 const renderFnWithContext = (...args) => {1781 if (renderFnWithContext._d) {1782 setBlockTracking(-1);1783 }1784 const prevInstance = setCurrentRenderingInstance(ctx);1785 const res = fn(...args);1786 setCurrentRenderingInstance(prevInstance);1787 if (renderFnWithContext._d) {1788 setBlockTracking(1);1789 }1790 if (true) {1791 devtoolsComponentUpdated(ctx);1792 }1793 return res;1794 };1795 renderFnWithContext._n = true;1796 renderFnWithContext._c = true;1797 renderFnWithContext._d = true;1798 return renderFnWithContext;1799}1800var accessedAttrs = false;1801function markAttrsAccessed() {1802 accessedAttrs = true;1803}1804function renderComponentRoot(instance) {1805 const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit: emit2, render: render3, renderCache, data, setupState, ctx, inheritAttrs } = instance;1806 let result;1807 let fallthroughAttrs;1808 const prev = setCurrentRenderingInstance(instance);1809 if (true) {1810 accessedAttrs = false;1811 }1812 try {1813 if (vnode.shapeFlag & 4) {1814 const proxyToUse = withProxy || proxy;1815 result = normalizeVNode(render3.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));1816 fallthroughAttrs = attrs;1817 } else {1818 const render4 = Component;1819 if (attrs === props) {1820 markAttrsAccessed();1821 }1822 result = normalizeVNode(render4.length > 1 ? render4(props, true ? {1823 get attrs() {1824 markAttrsAccessed();1825 return attrs;1826 },1827 slots,1828 emit: emit21829 } : { attrs, slots, emit: emit2 }) : render4(props, null));1830 fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);1831 }1832 } catch (err) {1833 blockStack.length = 0;1834 handleError(err, instance, 1);1835 result = createVNode(Comment);1836 }1837 let root = result;1838 let setRoot = void 0;1839 if (result.patchFlag > 0 && result.patchFlag & 2048) {1840 [root, setRoot] = getChildRoot(result);1841 }1842 if (fallthroughAttrs && inheritAttrs !== false) {1843 const keys = Object.keys(fallthroughAttrs);1844 const { shapeFlag } = root;1845 if (keys.length) {1846 if (shapeFlag & (1 | 6)) {1847 if (propsOptions && keys.some(isModelListener)) {1848 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);1849 }1850 root = cloneVNode(root, fallthroughAttrs);1851 } else if (!accessedAttrs && root.type !== Comment) {1852 const allAttrs = Object.keys(attrs);1853 const eventAttrs = [];1854 const extraAttrs = [];1855 for (let i = 0, l = allAttrs.length; i < l; i++) {1856 const key = allAttrs[i];1857 if (isOn(key)) {1858 if (!isModelListener(key)) {1859 eventAttrs.push(key[2].toLowerCase() + key.slice(3));1860 }1861 } else {1862 extraAttrs.push(key);1863 }1864 }1865 if (extraAttrs.length) {1866 warn2(`Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`);1867 }1868 if (eventAttrs.length) {1869 warn2(`Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`);1870 }1871 }1872 }1873 }1874 if (vnode.dirs) {1875 if (!isElementRoot(root)) {1876 warn2(`Runtime directive used on component with non-element root node. The directives will not function as intended.`);1877 }1878 root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;1879 }1880 if (vnode.transition) {1881 if (!isElementRoot(root)) {1882 warn2(`Component inside <Transition> renders non-element root node that cannot be animated.`);1883 }1884 root.transition = vnode.transition;1885 }1886 if (setRoot) {1887 setRoot(root);1888 } else {1889 result = root;1890 }1891 setCurrentRenderingInstance(prev);1892 return result;1893}1894var getChildRoot = (vnode) => {1895 const rawChildren = vnode.children;1896 const dynamicChildren = vnode.dynamicChildren;1897 const childRoot = filterSingleRoot(rawChildren);1898 if (!childRoot) {1899 return [vnode, void 0];1900 }1901 const index = rawChildren.indexOf(childRoot);1902 const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;1903 const setRoot = (updatedRoot) => {1904 rawChildren[index] = updatedRoot;1905 if (dynamicChildren) {1906 if (dynamicIndex > -1) {1907 dynamicChildren[dynamicIndex] = updatedRoot;1908 } else if (updatedRoot.patchFlag > 0) {1909 vnode.dynamicChildren = [...dynamicChildren, updatedRoot];1910 }1911 }1912 };1913 return [normalizeVNode(childRoot), setRoot];1914};1915function filterSingleRoot(children) {1916 let singleRoot;1917 for (let i = 0; i < children.length; i++) {1918 const child = children[i];1919 if (isVNode(child)) {1920 if (child.type !== Comment || child.children === "v-if") {1921 if (singleRoot) {1922 return;1923 } else {1924 singleRoot = child;1925 }1926 }1927 } else {1928 return;1929 }1930 }1931 return singleRoot;1932}1933var getFunctionalFallthrough = (attrs) => {1934 let res;1935 for (const key in attrs) {1936 if (key === "class" || key === "style" || isOn(key)) {1937 (res || (res = {}))[key] = attrs[key];1938 }1939 }1940 return res;1941};1942var filterModelListeners = (attrs, props) => {1943 const res = {};1944 for (const key in attrs) {1945 if (!isModelListener(key) || !(key.slice(9) in props)) {1946 res[key] = attrs[key];1947 }1948 }1949 return res;1950};1951var isElementRoot = (vnode) => {1952 return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;1953};1954function shouldUpdateComponent(prevVNode, nextVNode, optimized) {1955 const { props: prevProps, children: prevChildren, component } = prevVNode;1956 const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;1957 const emits = component.emitsOptions;1958 if ((prevChildren || nextChildren) && isHmrUpdating) {1959 return true;1960 }1961 if (nextVNode.dirs || nextVNode.transition) {1962 return true;1963 }1964 if (optimized && patchFlag >= 0) {1965 if (patchFlag & 1024) {1966 return true;1967 }1968 if (patchFlag & 16) {1969 if (!prevProps) {1970 return !!nextProps;1971 }1972 return hasPropsChanged(prevProps, nextProps, emits);1973 } else if (patchFlag & 8) {1974 const dynamicProps = nextVNode.dynamicProps;1975 for (let i = 0; i < dynamicProps.length; i++) {1976 const key = dynamicProps[i];1977 if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {1978 return true;1979 }1980 }1981 }1982 } else {1983 if (prevChildren || nextChildren) {1984 if (!nextChildren || !nextChildren.$stable) {1985 return true;1986 }1987 }1988 if (prevProps === nextProps) {1989 return false;1990 }1991 if (!prevProps) {1992 return !!nextProps;1993 }1994 if (!nextProps) {1995 return true;1996 }1997 return hasPropsChanged(prevProps, nextProps, emits);1998 }1999 return false;2000}2001function hasPropsChanged(prevProps, nextProps, emitsOptions) {2002 const nextKeys = Object.keys(nextProps);2003 if (nextKeys.length !== Object.keys(prevProps).length) {2004 return true;2005 }2006 for (let i = 0; i < nextKeys.length; i++) {2007 const key = nextKeys[i];2008 if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {2009 return true;2010 }2011 }2012 return false;2013}2014function updateHOCHostEl({ vnode, parent }, el) {2015 while (parent && parent.subTree === vnode) {2016 (vnode = parent.vnode).el = el;2017 parent = parent.parent;2018 }2019}2020var isSuspense = (type) => type.__isSuspense;2021function queueEffectWithSuspense(fn, suspense) {2022 if (suspense && suspense.pendingBranch) {2023 if (isArray(fn)) {2024 suspense.effects.push(...fn);2025 } else {2026 suspense.effects.push(fn);2027 }2028 } else {2029 queuePostFlushCb(fn);2030 }2031}2032function provide(key, value) {2033 if (!currentInstance) {2034 if (true) {2035 warn2(`provide() can only be used inside setup().`);2036 }2037 } else {2038 let provides = currentInstance.provides;2039 const parentProvides = currentInstance.parent && currentInstance.parent.provides;2040 if (parentProvides === provides) {2041 provides = currentInstance.provides = Object.create(parentProvides);2042 }2043 provides[key] = value;2044 }2045}2046function inject(key, defaultValue, treatDefaultAsFactory = false) {2047 const instance = currentInstance || currentRenderingInstance;2048 if (instance) {2049 const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;2050 if (provides && key in provides) {2051 return provides[key];2052 } else if (arguments.length > 1) {2053 return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;2054 } else if (true) {2055 warn2(`injection "${String(key)}" not found.`);2056 }2057 } else if (true) {2058 warn2(`inject() can only be used inside setup() or functional components.`);2059 }2060}2061var INITIAL_WATCHER_VALUE = {};2062function watch(source, cb, options) {2063 if (!isFunction(cb)) {2064 warn2(`\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`);2065 }2066 return doWatch(source, cb, options);2067}2068function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {2069 if (!cb) {2070 if (immediate !== void 0) {2071 warn2(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`);2072 }2073 if (deep !== void 0) {2074 warn2(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`);2075 }2076 }2077 const warnInvalidSource = (s) => {2078 warn2(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`);2079 };2080 const instance = currentInstance;2081 let getter;2082 let forceTrigger = false;2083 let isMultiSource = false;2084 if (isRef(source)) {2085 getter = () => source.value;2086 forceTrigger = isShallow(source);2087 } else if (isReactive(source)) {2088 getter = () => source;2089 deep = true;2090 } else if (isArray(source)) {2091 isMultiSource = true;2092 forceTrigger = source.some(isReactive);2093 getter = () => source.map((s) => {2094 if (isRef(s)) {2095 return s.value;2096 } else if (isReactive(s)) {2097 return traverse(s);2098 } else if (isFunction(s)) {2099 return callWithErrorHandling(s, instance, 2);2100 } else {2101 warnInvalidSource(s);2102 }2103 });2104 } else if (isFunction(source)) {2105 if (cb) {2106 getter = () => callWithErrorHandling(source, instance, 2);2107 } else {2108 getter = () => {2109 if (instance && instance.isUnmounted) {2110 return;2111 }2112 if (cleanup) {2113 cleanup();2114 }2115 return callWithAsyncErrorHandling(source, instance, 3, [onCleanup]);2116 };2117 }2118 } else {2119 getter = NOOP;2120 warnInvalidSource(source);2121 }2122 if (cb && deep) {2123 const baseGetter = getter;2124 getter = () => traverse(baseGetter());2125 }2126 let cleanup;2127 let onCleanup = (fn) => {2128 cleanup = effect2.onStop = () => {2129 callWithErrorHandling(fn, instance, 4);2130 };2131 };2132 if (isInSSRComponentSetup) {2133 onCleanup = NOOP;2134 if (!cb) {2135 getter();2136 } else if (immediate) {2137 callWithAsyncErrorHandling(cb, instance, 3, [2138 getter(),2139 isMultiSource ? [] : void 0,2140 onCleanup2141 ]);2142 }2143 return NOOP;2144 }2145 let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;2146 const job = () => {2147 if (!effect2.active) {2148 return;2149 }2150 if (cb) {2151 const newValue = effect2.run();2152 if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {2153 if (cleanup) {2154 cleanup();2155 }2156 callWithAsyncErrorHandling(cb, instance, 3, [2157 newValue,2158 oldValue === INITIAL_WATCHER_VALUE ? void 0 : oldValue,2159 onCleanup2160 ]);2161 oldValue = newValue;2162 }2163 } else {2164 effect2.run();2165 }2166 };2167 job.allowRecurse = !!cb;2168 let scheduler;2169 if (flush === "sync") {2170 scheduler = job;2171 } else if (flush === "post") {2172 scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);2173 } else {2174 scheduler = () => {2175 if (!instance || instance.isMounted) {2176 queuePreFlushCb(job);2177 } else {2178 job();2179 }2180 };2181 }2182 const effect2 = new ReactiveEffect(getter, scheduler);2183 if (true) {2184 effect2.onTrack = onTrack;2185 effect2.onTrigger = onTrigger;2186 }2187 if (cb) {2188 if (immediate) {2189 job();2190 } else {2191 oldValue = effect2.run();2192 }2193 } else if (flush === "post") {2194 queuePostRenderEffect(effect2.run.bind(effect2), instance && instance.suspense);2195 } else {2196 effect2.run();2197 }2198 return () => {2199 effect2.stop();2200 if (instance && instance.scope) {2201 remove(instance.scope.effects, effect2);2202 }2203 };2204}2205function instanceWatch(source, value, options) {2206 const publicThis = this.proxy;2207 const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);2208 let cb;2209 if (isFunction(value)) {2210 cb = value;2211 } else {2212 cb = value.handler;2213 options = value;2214 }2215 const cur = currentInstance;2216 setCurrentInstance(this);2217 const res = doWatch(getter, cb.bind(publicThis), options);2218 if (cur) {2219 setCurrentInstance(cur);2220 } else {2221 unsetCurrentInstance();2222 }2223 return res;2224}2225function createPathGetter(ctx, path) {2226 const segments = path.split(".");2227 return () => {2228 let cur = ctx;2229 for (let i = 0; i < segments.length && cur; i++) {2230 cur = cur[segments[i]];2231 }2232 return cur;2233 };2234}2235function traverse(value, seen) {2236 if (!isObject(value) || value["__v_skip"]) {2237 return value;2238 }2239 seen = seen || new Set();2240 if (seen.has(value)) {2241 return value;2242 }2243 seen.add(value);2244 if (isRef(value)) {2245 traverse(value.value, seen);2246 } else if (isArray(value)) {2247 for (let i = 0; i < value.length; i++) {2248 traverse(value[i], seen);2249 }2250 } else if (isSet(value) || isMap(value)) {2251 value.forEach((v) => {2252 traverse(v, seen);2253 });2254 } else if (isPlainObject(value)) {2255 for (const key in value) {2256 traverse(value[key], seen);2257 }2258 }2259 return value;2260}2261function useTransitionState() {2262 const state = {2263 isMounted: false,2264 isLeaving: false,2265 isUnmounting: false,2266 leavingVNodes: new Map()2267 };2268 onMounted(() => {2269 state.isMounted = true;2270 });2271 onBeforeUnmount(() => {2272 state.isUnmounting = true;2273 });2274 return state;2275}2276var TransitionHookValidator = [Function, Array];2277var BaseTransitionImpl = {2278 name: `BaseTransition`,2279 props: {2280 mode: String,2281 appear: Boolean,2282 persisted: Boolean,2283 onBeforeEnter: TransitionHookValidator,2284 onEnter: TransitionHookValidator,2285 onAfterEnter: TransitionHookValidator,2286 onEnterCancelled: TransitionHookValidator,2287 onBeforeLeave: TransitionHookValidator,2288 onLeave: TransitionHookValidator,2289 onAfterLeave: TransitionHookValidator,2290 onLeaveCancelled: TransitionHookValidator,2291 onBeforeAppear: TransitionHookValidator,2292 onAppear: TransitionHookValidator,2293 onAfterAppear: TransitionHookValidator,2294 onAppearCancelled: TransitionHookValidator2295 },2296 setup(props, { slots }) {2297 const instance = getCurrentInstance();2298 const state = useTransitionState();2299 let prevTransitionKey;2300 return () => {2301 const children = slots.default && getTransitionRawChildren(slots.default(), true);2302 if (!children || !children.length) {2303 return;2304 }2305 if (children.length > 1) {2306 warn2("<transition> can only be used on a single element or component. Use <transition-group> for lists.");2307 }2308 const rawProps = toRaw(props);2309 const { mode } = rawProps;2310 if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {2311 warn2(`invalid <transition> mode: ${mode}`);2312 }2313 const child = children[0];2314 if (state.isLeaving) {2315 return emptyPlaceholder(child);2316 }2317 const innerChild = getKeepAliveChild(child);2318 if (!innerChild) {2319 return emptyPlaceholder(child);2320 }2321 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);2322 setTransitionHooks(innerChild, enterHooks);2323 const oldChild = instance.subTree;2324 const oldInnerChild = oldChild && getKeepAliveChild(oldChild);2325 let transitionKeyChanged = false;2326 const { getTransitionKey } = innerChild.type;2327 if (getTransitionKey) {2328 const key = getTransitionKey();2329 if (prevTransitionKey === void 0) {2330 prevTransitionKey = key;2331 } else if (key !== prevTransitionKey) {2332 prevTransitionKey = key;2333 transitionKeyChanged = true;2334 }2335 }2336 if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {2337 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);2338 setTransitionHooks(oldInnerChild, leavingHooks);2339 if (mode === "out-in") {2340 state.isLeaving = true;2341 leavingHooks.afterLeave = () => {2342 state.isLeaving = false;2343 instance.update();2344 };2345 return emptyPlaceholder(child);2346 } else if (mode === "in-out" && innerChild.type !== Comment) {2347 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {2348 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);2349 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;2350 el._leaveCb = () => {2351 earlyRemove();2352 el._leaveCb = void 0;2353 delete enterHooks.delayedLeave;2354 };2355 enterHooks.delayedLeave = delayedLeave;2356 };2357 }2358 }2359 return child;2360 };2361 }2362};2363var BaseTransition = BaseTransitionImpl;2364function getLeavingNodesForType(state, vnode) {2365 const { leavingVNodes } = state;2366 let leavingVNodesCache = leavingVNodes.get(vnode.type);2367 if (!leavingVNodesCache) {2368 leavingVNodesCache = Object.create(null);2369 leavingVNodes.set(vnode.type, leavingVNodesCache);2370 }2371 return leavingVNodesCache;2372}2373function resolveTransitionHooks(vnode, props, state, instance) {2374 const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;2375 const key = String(vnode.key);2376 const leavingVNodesCache = getLeavingNodesForType(state, vnode);2377 const callHook3 = (hook, args) => {2378 hook && callWithAsyncErrorHandling(hook, instance, 9, args);2379 };2380 const hooks = {2381 mode,2382 persisted,2383 beforeEnter(el) {2384 let hook = onBeforeEnter;2385 if (!state.isMounted) {2386 if (appear) {2387 hook = onBeforeAppear || onBeforeEnter;2388 } else {2389 return;2390 }2391 }2392 if (el._leaveCb) {2393 el._leaveCb(true);2394 }2395 const leavingVNode = leavingVNodesCache[key];2396 if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) {2397 leavingVNode.el._leaveCb();2398 }2399 callHook3(hook, [el]);2400 },2401 enter(el) {2402 let hook = onEnter;2403 let afterHook = onAfterEnter;2404 let cancelHook = onEnterCancelled;2405 if (!state.isMounted) {2406 if (appear) {2407 hook = onAppear || onEnter;2408 afterHook = onAfterAppear || onAfterEnter;2409 cancelHook = onAppearCancelled || onEnterCancelled;2410 } else {2411 return;2412 }2413 }2414 let called = false;2415 const done = el._enterCb = (cancelled) => {2416 if (called)2417 return;2418 called = true;2419 if (cancelled) {2420 callHook3(cancelHook, [el]);2421 } else {2422 callHook3(afterHook, [el]);2423 }2424 if (hooks.delayedLeave) {2425 hooks.delayedLeave();2426 }2427 el._enterCb = void 0;2428 };2429 if (hook) {2430 hook(el, done);2431 if (hook.length <= 1) {2432 done();2433 }2434 } else {2435 done();2436 }2437 },2438 leave(el, remove2) {2439 const key2 = String(vnode.key);2440 if (el._enterCb) {2441 el._enterCb(true);2442 }2443 if (state.isUnmounting) {2444 return remove2();2445 }2446 callHook3(onBeforeLeave, [el]);2447 let called = false;2448 const done = el._leaveCb = (cancelled) => {2449 if (called)2450 return;2451 called = true;2452 remove2();2453 if (cancelled) {2454 callHook3(onLeaveCancelled, [el]);2455 } else {2456 callHook3(onAfterLeave, [el]);2457 }2458 el._leaveCb = void 0;2459 if (leavingVNodesCache[key2] === vnode) {2460 delete leavingVNodesCache[key2];2461 }2462 };2463 leavingVNodesCache[key2] = vnode;2464 if (onLeave) {2465 onLeave(el, done);2466 if (onLeave.length <= 1) {2467 done();2468 }2469 } else {2470 done();2471 }2472 },2473 clone(vnode2) {2474 return resolveTransitionHooks(vnode2, props, state, instance);2475 }2476 };2477 return hooks;2478}2479function emptyPlaceholder(vnode) {2480 if (isKeepAlive(vnode)) {2481 vnode = cloneVNode(vnode);2482 vnode.children = null;2483 return vnode;2484 }2485}2486function getKeepAliveChild(vnode) {2487 return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;2488}2489function setTransitionHooks(vnode, hooks) {2490 if (vnode.shapeFlag & 6 && vnode.component) {2491 setTransitionHooks(vnode.component.subTree, hooks);2492 } else if (vnode.shapeFlag & 128) {2493 vnode.ssContent.transition = hooks.clone(vnode.ssContent);2494 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);2495 } else {2496 vnode.transition = hooks;2497 }2498}2499function getTransitionRawChildren(children, keepComment = false) {2500 let ret = [];2501 let keyedFragmentCount = 0;2502 for (let i = 0; i < children.length; i++) {2503 const child = children[i];2504 if (child.type === Fragment) {2505 if (child.patchFlag & 128)2506 keyedFragmentCount++;2507 ret = ret.concat(getTransitionRawChildren(child.children, keepComment));2508 } else if (keepComment || child.type !== Comment) {2509 ret.push(child);2510 }2511 }2512 if (keyedFragmentCount > 1) {2513 for (let i = 0; i < ret.length; i++) {2514 ret[i].patchFlag = -2;2515 }2516 }2517 return ret;2518}2519function defineComponent(options) {2520 return isFunction(options) ? { setup: options, name: options.name } : options;2521}2522var isAsyncWrapper = (i) => !!i.type.__asyncLoader;2523var isKeepAlive = (vnode) => vnode.type.__isKeepAlive;2524function onActivated(hook, target) {2525 registerKeepAliveHook(hook, "a", target);2526}2527function onDeactivated(hook, target) {2528 registerKeepAliveHook(hook, "da", target);2529}2530function registerKeepAliveHook(hook, type, target = currentInstance) {2531 const wrappedHook = hook.__wdc || (hook.__wdc = () => {2532 let current = target;2533 while (current) {2534 if (current.isDeactivated) {2535 return;2536 }2537 current = current.parent;2538 }2539 return hook();2540 });2541 injectHook(type, wrappedHook, target);2542 if (target) {2543 let current = target.parent;2544 while (current && current.parent) {2545 if (isKeepAlive(current.parent.vnode)) {2546 injectToKeepAliveRoot(wrappedHook, type, target, current);2547 }2548 current = current.parent;2549 }2550 }2551}2552function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {2553 const injected = injectHook(type, hook, keepAliveRoot, true);2554 onUnmounted(() => {2555 remove(keepAliveRoot[type], injected);2556 }, target);2557}2558function injectHook(type, hook, target = currentInstance, prepend = false) {2559 if (target) {2560 const hooks = target[type] || (target[type] = []);2561 const wrappedHook = hook.__weh || (hook.__weh = (...args) => {2562 if (target.isUnmounted) {2563 return;2564 }2565 pauseTracking();2566 setCurrentInstance(target);2567 const res = callWithAsyncErrorHandling(hook, target, type, args);2568 unsetCurrentInstance();2569 resetTracking();2570 return res;2571 });2572 if (prepend) {2573 hooks.unshift(wrappedHook);2574 } else {2575 hooks.push(wrappedHook);2576 }2577 return wrappedHook;2578 } else if (true) {2579 const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));2580 warn2(`${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.`);2581 }2582}2583var createHook = (lifecycle) => (hook, target = currentInstance) => (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, hook, target);2584var onBeforeMount = createHook("bm");2585var onMounted = createHook("m");2586var onBeforeUpdate = createHook("bu");2587var onUpdated = createHook("u");2588var onBeforeUnmount = createHook("bum");2589var onUnmounted = createHook("um");2590var onServerPrefetch = createHook("sp");2591var onRenderTriggered = createHook("rtg");2592var onRenderTracked = createHook("rtc");2593function onErrorCaptured(hook, target = currentInstance) {2594 injectHook("ec", hook, target);2595}2596function createDuplicateChecker() {2597 const cache = Object.create(null);2598 return (type, key) => {2599 if (cache[key]) {2600 warn2(`${type} property "${key}" is already defined in ${cache[key]}.`);2601 } else {2602 cache[key] = type;2603 }2604 };2605}2606var shouldCacheAccess = true;2607function applyOptions(instance) {2608 const options = resolveMergedOptions(instance);2609 const publicThis = instance.proxy;2610 const ctx = instance.ctx;2611 shouldCacheAccess = false;2612 if (options.beforeCreate) {2613 callHook(options.beforeCreate, instance, "bc");2614 }2615 const {2616 data: dataOptions,2617 computed: computedOptions,2618 methods,2619 watch: watchOptions,2620 provide: provideOptions,2621 inject: injectOptions,2622 created,2623 beforeMount,2624 mounted,2625 beforeUpdate,2626 updated,2627 activated,2628 deactivated,2629 beforeDestroy,2630 beforeUnmount,2631 destroyed,2632 unmounted,2633 render: render3,2634 renderTracked,2635 renderTriggered,2636 errorCaptured,2637 serverPrefetch,2638 expose,2639 inheritAttrs,2640 components,2641 directives,2642 filters2643 } = options;2644 const checkDuplicateProperties = true ? createDuplicateChecker() : null;2645 if (true) {2646 const [propsOptions] = instance.propsOptions;2647 if (propsOptions) {2648 for (const key in propsOptions) {2649 checkDuplicateProperties("Props", key);2650 }2651 }2652 }2653 if (injectOptions) {2654 resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);2655 }2656 if (methods) {2657 for (const key in methods) {2658 const methodHandler = methods[key];2659 if (isFunction(methodHandler)) {2660 if (true) {2661 Object.defineProperty(ctx, key, {2662 value: methodHandler.bind(publicThis),2663 configurable: true,2664 enumerable: true,2665 writable: true2666 });2667 } else {2668 ctx[key] = methodHandler.bind(publicThis);2669 }2670 if (true) {2671 checkDuplicateProperties("Methods", key);2672 }2673 } else if (true) {2674 warn2(`Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`);2675 }2676 }2677 }2678 if (dataOptions) {2679 if (!isFunction(dataOptions)) {2680 warn2(`The data option must be a function. Plain object usage is no longer supported.`);2681 }2682 const data = dataOptions.call(publicThis, publicThis);2683 if (isPromise(data)) {2684 warn2(`data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`);2685 }2686 if (!isObject(data)) {2687 warn2(`data() should return an object.`);2688 } else {2689 instance.data = reactive(data);2690 if (true) {2691 for (const key in data) {2692 checkDuplicateProperties("Data", key);2693 if (key[0] !== "$" && key[0] !== "_") {2694 Object.defineProperty(ctx, key, {2695 configurable: true,2696 enumerable: true,2697 get: () => data[key],2698 set: NOOP2699 });2700 }2701 }2702 }2703 }2704 }2705 shouldCacheAccess = true;2706 if (computedOptions) {2707 for (const key in computedOptions) {2708 const opt = computedOptions[key];2709 const get2 = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;2710 if (get2 === NOOP) {2711 warn2(`Computed property "${key}" has no getter.`);2712 }2713 const set2 = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : true ? () => {2714 warn2(`Write operation failed: computed property "${key}" is readonly.`);2715 } : NOOP;2716 const c = computed2({2717 get: get2,2718 set: set22719 });2720 Object.defineProperty(ctx, key, {2721 enumerable: true,2722 configurable: true,2723 get: () => c.value,2724 set: (v) => c.value = v2725 });2726 if (true) {2727 checkDuplicateProperties("Computed", key);2728 }2729 }2730 }2731 if (watchOptions) {2732 for (const key in watchOptions) {2733 createWatcher(watchOptions[key], ctx, publicThis, key);2734 }2735 }2736 if (provideOptions) {2737 const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;2738 Reflect.ownKeys(provides).forEach((key) => {2739 provide(key, provides[key]);2740 });2741 }2742 if (created) {2743 callHook(created, instance, "c");2744 }2745 function registerLifecycleHook(register, hook) {2746 if (isArray(hook)) {2747 hook.forEach((_hook) => register(_hook.bind(publicThis)));2748 } else if (hook) {2749 register(hook.bind(publicThis));2750 }2751 }2752 registerLifecycleHook(onBeforeMount, beforeMount);2753 registerLifecycleHook(onMounted, mounted);2754 registerLifecycleHook(onBeforeUpdate, beforeUpdate);2755 registerLifecycleHook(onUpdated, updated);2756 registerLifecycleHook(onActivated, activated);2757 registerLifecycleHook(onDeactivated, deactivated);2758 registerLifecycleHook(onErrorCaptured, errorCaptured);2759 registerLifecycleHook(onRenderTracked, renderTracked);2760 registerLifecycleHook(onRenderTriggered, renderTriggered);2761 registerLifecycleHook(onBeforeUnmount, beforeUnmount);2762 registerLifecycleHook(onUnmounted, unmounted);2763 registerLifecycleHook(onServerPrefetch, serverPrefetch);2764 if (isArray(expose)) {2765 if (expose.length) {2766 const exposed = instance.exposed || (instance.exposed = {});2767 expose.forEach((key) => {2768 Object.defineProperty(exposed, key, {2769 get: () => publicThis[key],2770 set: (val) => publicThis[key] = val2771 });2772 });2773 } else if (!instance.exposed) {2774 instance.exposed = {};2775 }2776 }2777 if (render3 && instance.render === NOOP) {2778 instance.render = render3;2779 }2780 if (inheritAttrs != null) {2781 instance.inheritAttrs = inheritAttrs;2782 }2783 if (components)2784 instance.components = components;2785 if (directives)2786 instance.directives = directives;2787}2788function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {2789 if (isArray(injectOptions)) {2790 injectOptions = normalizeInject(injectOptions);2791 }2792 for (const key in injectOptions) {2793 const opt = injectOptions[key];2794 let injected;2795 if (isObject(opt)) {2796 if ("default" in opt) {2797 injected = inject(opt.from || key, opt.default, true);2798 } else {2799 injected = inject(opt.from || key);2800 }2801 } else {2802 injected = inject(opt);2803 }2804 if (isRef(injected)) {2805 if (unwrapRef) {2806 Object.defineProperty(ctx, key, {2807 enumerable: true,2808 configurable: true,2809 get: () => injected.value,2810 set: (v) => injected.value = v2811 });2812 } else {2813 if (true) {2814 warn2(`injected property "${key}" is a ref and will be auto-unwrapped and no longer needs \`.value\` in the next minor release. To opt-in to the new behavior now, set \`app.config.unwrapInjectedRef = true\` (this config is temporary and will not be needed in the future.)`);2815 }2816 ctx[key] = injected;2817 }2818 } else {2819 ctx[key] = injected;2820 }2821 if (true) {2822 checkDuplicateProperties("Inject", key);2823 }2824 }2825}2826function callHook(hook, instance, type) {2827 callWithAsyncErrorHandling(isArray(hook) ? hook.map((h2) => h2.bind(instance.proxy)) : hook.bind(instance.proxy), instance, type);2828}2829function createWatcher(raw, ctx, publicThis, key) {2830 const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];2831 if (isString(raw)) {2832 const handler = ctx[raw];2833 if (isFunction(handler)) {2834 watch(getter, handler);2835 } else if (true) {2836 warn2(`Invalid watch handler specified by key "${raw}"`, handler);2837 }2838 } else if (isFunction(raw)) {2839 watch(getter, raw.bind(publicThis));2840 } else if (isObject(raw)) {2841 if (isArray(raw)) {2842 raw.forEach((r) => createWatcher(r, ctx, publicThis, key));2843 } else {2844 const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];2845 if (isFunction(handler)) {2846 watch(getter, handler, raw);2847 } else if (true) {2848 warn2(`Invalid watch handler specified by key "${raw.handler}"`, handler);2849 }2850 }2851 } else if (true) {2852 warn2(`Invalid watch option: "${key}"`, raw);2853 }2854}2855function resolveMergedOptions(instance) {2856 const base = instance.type;2857 const { mixins, extends: extendsOptions } = base;2858 const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;2859 const cached = cache.get(base);2860 let resolved;2861 if (cached) {2862 resolved = cached;2863 } else if (!globalMixins.length && !mixins && !extendsOptions) {2864 {2865 resolved = base;2866 }2867 } else {2868 resolved = {};2869 if (globalMixins.length) {2870 globalMixins.forEach((m) => mergeOptions(resolved, m, optionMergeStrategies, true));2871 }2872 mergeOptions(resolved, base, optionMergeStrategies);2873 }2874 cache.set(base, resolved);2875 return resolved;2876}2877function mergeOptions(to, from, strats, asMixin = false) {2878 const { mixins, extends: extendsOptions } = from;2879 if (extendsOptions) {2880 mergeOptions(to, extendsOptions, strats, true);2881 }2882 if (mixins) {2883 mixins.forEach((m) => mergeOptions(to, m, strats, true));2884 }2885 for (const key in from) {2886 if (asMixin && key === "expose") {2887 warn2(`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`);2888 } else {2889 const strat = internalOptionMergeStrats[key] || strats && strats[key];2890 to[key] = strat ? strat(to[key], from[key]) : from[key];2891 }2892 }2893 return to;2894}2895var internalOptionMergeStrats = {2896 data: mergeDataFn,2897 props: mergeObjectOptions,2898 emits: mergeObjectOptions,2899 methods: mergeObjectOptions,2900 computed: mergeObjectOptions,2901 beforeCreate: mergeAsArray,2902 created: mergeAsArray,2903 beforeMount: mergeAsArray,2904 mounted: mergeAsArray,2905 beforeUpdate: mergeAsArray,2906 updated: mergeAsArray,2907 beforeDestroy: mergeAsArray,2908 beforeUnmount: mergeAsArray,2909 destroyed: mergeAsArray,2910 unmounted: mergeAsArray,2911 activated: mergeAsArray,2912 deactivated: mergeAsArray,2913 errorCaptured: mergeAsArray,2914 serverPrefetch: mergeAsArray,2915 components: mergeObjectOptions,2916 directives: mergeObjectOptions,2917 watch: mergeWatchOptions,2918 provide: mergeDataFn,2919 inject: mergeInject2920};2921function mergeDataFn(to, from) {2922 if (!from) {2923 return to;2924 }2925 if (!to) {2926 return from;2927 }2928 return function mergedDataFn() {2929 return extend(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);2930 };2931}2932function mergeInject(to, from) {2933 return mergeObjectOptions(normalizeInject(to), normalizeInject(from));2934}2935function normalizeInject(raw) {2936 if (isArray(raw)) {2937 const res = {};2938 for (let i = 0; i < raw.length; i++) {2939 res[raw[i]] = raw[i];2940 }2941 return res;2942 }2943 return raw;2944}2945function mergeAsArray(to, from) {2946 return to ? [...new Set([].concat(to, from))] : from;2947}2948function mergeObjectOptions(to, from) {2949 return to ? extend(extend(Object.create(null), to), from) : from;2950}2951function mergeWatchOptions(to, from) {2952 if (!to)2953 return from;2954 if (!from)2955 return to;2956 const merged = extend(Object.create(null), to);2957 for (const key in from) {2958 merged[key] = mergeAsArray(to[key], from[key]);2959 }2960 return merged;2961}2962function initProps(instance, rawProps, isStateful, isSSR = false) {2963 const props = {};2964 const attrs = {};2965 def(attrs, InternalObjectKey, 1);2966 instance.propsDefaults = Object.create(null);2967 setFullProps(instance, rawProps, props, attrs);2968 for (const key in instance.propsOptions[0]) {2969 if (!(key in props)) {2970 props[key] = void 0;2971 }2972 }2973 if (true) {2974 validateProps(rawProps || {}, props, instance);2975 }2976 if (isStateful) {2977 instance.props = isSSR ? props : shallowReactive(props);2978 } else {2979 if (!instance.type.props) {2980 instance.props = attrs;2981 } else {2982 instance.props = props;2983 }2984 }2985 instance.attrs = attrs;2986}2987function updateProps(instance, rawProps, rawPrevProps, optimized) {2988 const { props, attrs, vnode: { patchFlag } } = instance;2989 const rawCurrentProps = toRaw(props);2990 const [options] = instance.propsOptions;2991 let hasAttrsChanged = false;2992 if (!(instance.type.__hmrId || instance.parent && instance.parent.type.__hmrId) && (optimized || patchFlag > 0) && !(patchFlag & 16)) {2993 if (patchFlag & 8) {2994 const propsToUpdate = instance.vnode.dynamicProps;2995 for (let i = 0; i < propsToUpdate.length; i++) {2996 let key = propsToUpdate[i];2997 const value = rawProps[key];2998 if (options) {2999 if (hasOwn(attrs, key)) {3000 if (value !== attrs[key]) {3001 attrs[key] = value;3002 hasAttrsChanged = true;3003 }3004 } else {3005 const camelizedKey = camelize(key);3006 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false);3007 }3008 } else {3009 if (value !== attrs[key]) {3010 attrs[key] = value;3011 hasAttrsChanged = true;3012 }3013 }3014 }3015 }3016 } else {3017 if (setFullProps(instance, rawProps, props, attrs)) {3018 hasAttrsChanged = true;3019 }3020 let kebabKey;3021 for (const key in rawCurrentProps) {3022 if (!rawProps || !hasOwn(rawProps, key) && ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {3023 if (options) {3024 if (rawPrevProps && (rawPrevProps[key] !== void 0 || rawPrevProps[kebabKey] !== void 0)) {3025 props[key] = resolvePropValue(options, rawCurrentProps, key, void 0, instance, true);3026 }3027 } else {3028 delete props[key];3029 }3030 }3031 }3032 if (attrs !== rawCurrentProps) {3033 for (const key in attrs) {3034 if (!rawProps || !hasOwn(rawProps, key) && true) {3035 delete attrs[key];3036 hasAttrsChanged = true;3037 }3038 }3039 }3040 }3041 if (hasAttrsChanged) {3042 trigger(instance, "set", "$attrs");3043 }3044 if (true) {3045 validateProps(rawProps || {}, props, instance);3046 }3047}3048function setFullProps(instance, rawProps, props, attrs) {3049 const [options, needCastKeys] = instance.propsOptions;3050 let hasAttrsChanged = false;3051 let rawCastValues;3052 if (rawProps) {3053 for (let key in rawProps) {3054 if (isReservedProp(key)) {3055 continue;3056 }3057 const value = rawProps[key];3058 let camelKey;3059 if (options && hasOwn(options, camelKey = camelize(key))) {3060 if (!needCastKeys || !needCastKeys.includes(camelKey)) {3061 props[camelKey] = value;3062 } else {3063 (rawCastValues || (rawCastValues = {}))[camelKey] = value;3064 }3065 } else if (!isEmitListener(instance.emitsOptions, key)) {3066 if (!(key in attrs) || value !== attrs[key]) {3067 attrs[key] = value;3068 hasAttrsChanged = true;3069 }3070 }3071 }3072 }3073 if (needCastKeys) {3074 const rawCurrentProps = toRaw(props);3075 const castValues = rawCastValues || EMPTY_OBJ;3076 for (let i = 0; i < needCastKeys.length; i++) {3077 const key = needCastKeys[i];3078 props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));3079 }3080 }3081 return hasAttrsChanged;3082}3083function resolvePropValue(options, props, key, value, instance, isAbsent) {3084 const opt = options[key];3085 if (opt != null) {3086 const hasDefault = hasOwn(opt, "default");3087 if (hasDefault && value === void 0) {3088 const defaultValue = opt.default;3089 if (opt.type !== Function && isFunction(defaultValue)) {3090 const { propsDefaults } = instance;3091 if (key in propsDefaults) {3092 value = propsDefaults[key];3093 } else {3094 setCurrentInstance(instance);3095 value = propsDefaults[key] = defaultValue.call(null, props);3096 unsetCurrentInstance();3097 }3098 } else {3099 value = defaultValue;3100 }3101 }3102 if (opt[0]) {3103 if (isAbsent && !hasDefault) {3104 value = false;3105 } else if (opt[1] && (value === "" || value === hyphenate(key))) {3106 value = true;3107 }3108 }3109 }3110 return value;3111}3112function normalizePropsOptions(comp, appContext, asMixin = false) {3113 const cache = appContext.propsCache;3114 const cached = cache.get(comp);3115 if (cached) {3116 return cached;3117 }3118 const raw = comp.props;3119 const normalized = {};3120 const needCastKeys = [];3121 let hasExtends = false;3122 if (!isFunction(comp)) {3123 const extendProps = (raw2) => {3124 hasExtends = true;3125 const [props, keys] = normalizePropsOptions(raw2, appContext, true);3126 extend(normalized, props);3127 if (keys)3128 needCastKeys.push(...keys);3129 };3130 if (!asMixin && appContext.mixins.length) {3131 appContext.mixins.forEach(extendProps);3132 }3133 if (comp.extends) {3134 extendProps(comp.extends);3135 }3136 if (comp.mixins) {3137 comp.mixins.forEach(extendProps);3138 }3139 }3140 if (!raw && !hasExtends) {3141 cache.set(comp, EMPTY_ARR);3142 return EMPTY_ARR;3143 }3144 if (isArray(raw)) {3145 for (let i = 0; i < raw.length; i++) {3146 if (!isString(raw[i])) {3147 warn2(`props must be strings when using array syntax.`, raw[i]);3148 }3149 const normalizedKey = camelize(raw[i]);3150 if (validatePropName(normalizedKey)) {3151 normalized[normalizedKey] = EMPTY_OBJ;3152 }3153 }3154 } else if (raw) {3155 if (!isObject(raw)) {3156 warn2(`invalid props options`, raw);3157 }3158 for (const key in raw) {3159 const normalizedKey = camelize(key);3160 if (validatePropName(normalizedKey)) {3161 const opt = raw[key];3162 const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : opt;3163 if (prop) {3164 const booleanIndex = getTypeIndex(Boolean, prop.type);3165 const stringIndex = getTypeIndex(String, prop.type);3166 prop[0] = booleanIndex > -1;3167 prop[1] = stringIndex < 0 || booleanIndex < stringIndex;3168 if (booleanIndex > -1 || hasOwn(prop, "default")) {3169 needCastKeys.push(normalizedKey);3170 }3171 }3172 }3173 }3174 }3175 const res = [normalized, needCastKeys];3176 cache.set(comp, res);3177 return res;3178}3179function validatePropName(key) {3180 if (key[0] !== "$") {3181 return true;3182 } else if (true) {3183 warn2(`Invalid prop name: "${key}" is a reserved property.`);3184 }3185 return false;3186}3187function getType(ctor) {3188 const match = ctor && ctor.toString().match(/^\s*function (\w+)/);3189 return match ? match[1] : ctor === null ? "null" : "";3190}3191function isSameType(a, b) {3192 return getType(a) === getType(b);3193}3194function getTypeIndex(type, expectedTypes) {3195 if (isArray(expectedTypes)) {3196 return expectedTypes.findIndex((t) => isSameType(t, type));3197 } else if (isFunction(expectedTypes)) {3198 return isSameType(expectedTypes, type) ? 0 : -1;3199 }3200 return -1;3201}3202function validateProps(rawProps, props, instance) {3203 const resolvedValues = toRaw(props);3204 const options = instance.propsOptions[0];3205 for (const key in options) {3206 let opt = options[key];3207 if (opt == null)3208 continue;3209 validateProp(key, resolvedValues[key], opt, !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)));3210 }3211}3212function validateProp(name, value, prop, isAbsent) {3213 const { type, required, validator } = prop;3214 if (required && isAbsent) {3215 warn2('Missing required prop: "' + name + '"');3216 return;3217 }3218 if (value == null && !prop.required) {3219 return;3220 }3221 if (type != null && type !== true) {3222 let isValid = false;3223 const types = isArray(type) ? type : [type];3224 const expectedTypes = [];3225 for (let i = 0; i < types.length && !isValid; i++) {3226 const { valid, expectedType } = assertType(value, types[i]);3227 expectedTypes.push(expectedType || "");3228 isValid = valid;3229 }3230 if (!isValid) {3231 warn2(getInvalidTypeMessage(name, value, expectedTypes));3232 return;3233 }3234 }3235 if (validator && !validator(value)) {3236 warn2('Invalid prop: custom validator check failed for prop "' + name + '".');3237 }3238}3239var isSimpleType = /* @__PURE__ */ makeMap("String,Number,Boolean,Function,Symbol,BigInt");3240function assertType(value, type) {3241 let valid;3242 const expectedType = getType(type);3243 if (isSimpleType(expectedType)) {3244 const t = typeof value;3245 valid = t === expectedType.toLowerCase();3246 if (!valid && t === "object") {3247 valid = value instanceof type;3248 }3249 } else if (expectedType === "Object") {3250 valid = isObject(value);3251 } else if (expectedType === "Array") {3252 valid = isArray(value);3253 } else if (expectedType === "null") {3254 valid = value === null;3255 } else {3256 valid = value instanceof type;3257 }3258 return {3259 valid,3260 expectedType3261 };3262}3263function getInvalidTypeMessage(name, value, expectedTypes) {3264 let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;3265 const expectedType = expectedTypes[0];3266 const receivedType = toRawType(value);3267 const expectedValue = styleValue(value, expectedType);3268 const receivedValue = styleValue(value, receivedType);3269 if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {3270 message += ` with value ${expectedValue}`;3271 }3272 message += `, got ${receivedType} `;3273 if (isExplicable(receivedType)) {3274 message += `with value ${receivedValue}.`;3275 }3276 return message;3277}3278function styleValue(value, type) {3279 if (type === "String") {3280 return `"${value}"`;3281 } else if (type === "Number") {3282 return `${Number(value)}`;3283 } else {3284 return `${value}`;3285 }3286}3287function isExplicable(type) {3288 const explicitTypes = ["string", "number", "boolean"];3289 return explicitTypes.some((elem) => type.toLowerCase() === elem);3290}3291function isBoolean(...args) {3292 return args.some((elem) => elem.toLowerCase() === "boolean");3293}3294var isInternalKey = (key) => key[0] === "_" || key === "$stable";3295var normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];3296var normalizeSlot = (key, rawSlot, ctx) => {3297 const normalized = withCtx((...args) => {3298 if (currentInstance) {3299 warn2(`Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`);3300 }3301 return normalizeSlotValue(rawSlot(...args));3302 }, ctx);3303 normalized._c = false;3304 return normalized;3305};3306var normalizeObjectSlots = (rawSlots, slots, instance) => {3307 const ctx = rawSlots._ctx;3308 for (const key in rawSlots) {3309 if (isInternalKey(key))3310 continue;3311 const value = rawSlots[key];3312 if (isFunction(value)) {3313 slots[key] = normalizeSlot(key, value, ctx);3314 } else if (value != null) {3315 if (true) {3316 warn2(`Non-function value encountered for slot "${key}". Prefer function slots for better performance.`);3317 }3318 const normalized = normalizeSlotValue(value);3319 slots[key] = () => normalized;3320 }3321 }3322};3323var normalizeVNodeSlots = (instance, children) => {3324 if (!isKeepAlive(instance.vnode) && true) {3325 warn2(`Non-function value encountered for default slot. Prefer function slots for better performance.`);3326 }3327 const normalized = normalizeSlotValue(children);3328 instance.slots.default = () => normalized;3329};3330var initSlots = (instance, children) => {3331 if (instance.vnode.shapeFlag & 32) {3332 const type = children._;3333 if (type) {3334 instance.slots = toRaw(children);3335 def(children, "_", type);3336 } else {3337 normalizeObjectSlots(children, instance.slots = {});3338 }3339 } else {3340 instance.slots = {};3341 if (children) {3342 normalizeVNodeSlots(instance, children);3343 }3344 }3345 def(instance.slots, InternalObjectKey, 1);3346};3347var updateSlots = (instance, children, optimized) => {3348 const { vnode, slots } = instance;3349 let needDeletionCheck = true;3350 let deletionComparisonTarget = EMPTY_OBJ;3351 if (vnode.shapeFlag & 32) {3352 const type = children._;3353 if (type) {3354 if (isHmrUpdating) {3355 extend(slots, children);3356 } else if (optimized && type === 1) {3357 needDeletionCheck = false;3358 } else {3359 extend(slots, children);3360 if (!optimized && type === 1) {3361 delete slots._;3362 }3363 }3364 } else {3365 needDeletionCheck = !children.$stable;3366 normalizeObjectSlots(children, slots);3367 }3368 deletionComparisonTarget = children;3369 } else if (children) {3370 normalizeVNodeSlots(instance, children);3371 deletionComparisonTarget = { default: 1 };3372 }3373 if (needDeletionCheck) {3374 for (const key in slots) {3375 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {3376 delete slots[key];3377 }3378 }3379 }3380};3381function validateDirectiveName(name) {3382 if (isBuiltInDirective(name)) {3383 warn2("Do not use built-in directive ids as custom directive id: " + name);3384 }3385}3386function invokeDirectiveHook(vnode, prevVNode, instance, name) {3387 const bindings = vnode.dirs;3388 const oldBindings = prevVNode && prevVNode.dirs;3389 for (let i = 0; i < bindings.length; i++) {3390 const binding = bindings[i];3391 if (oldBindings) {3392 binding.oldValue = oldBindings[i].value;3393 }3394 let hook = binding.dir[name];3395 if (hook) {3396 pauseTracking();3397 callWithAsyncErrorHandling(hook, instance, 8, [3398 vnode.el,3399 binding,3400 vnode,3401 prevVNode3402 ]);3403 resetTracking();3404 }3405 }3406}3407function createAppContext() {3408 return {3409 app: null,3410 config: {3411 isNativeTag: NO,3412 performance: false,3413 globalProperties: {},3414 optionMergeStrategies: {},3415 errorHandler: void 0,3416 warnHandler: void 0,3417 compilerOptions: {}3418 },3419 mixins: [],3420 components: {},3421 directives: {},3422 provides: Object.create(null),3423 optionsCache: new WeakMap(),3424 propsCache: new WeakMap(),3425 emitsCache: new WeakMap()3426 };3427}3428var uid = 0;3429function createAppAPI(render3, hydrate) {3430 return function createApp2(rootComponent, rootProps = null) {3431 if (rootProps != null && !isObject(rootProps)) {3432 warn2(`root props passed to app.mount() must be an object.`);3433 rootProps = null;3434 }3435 const context = createAppContext();3436 const installedPlugins = new Set();3437 let isMounted = false;3438 const app = context.app = {3439 _uid: uid++,3440 _component: rootComponent,3441 _props: rootProps,3442 _container: null,3443 _context: context,3444 _instance: null,3445 version,3446 get config() {3447 return context.config;3448 },3449 set config(v) {3450 if (true) {3451 warn2(`app.config cannot be replaced. Modify individual options instead.`);3452 }3453 },3454 use(plugin, ...options) {3455 if (installedPlugins.has(plugin)) {3456 warn2(`Plugin has already been applied to target app.`);3457 } else if (plugin && isFunction(plugin.install)) {3458 installedPlugins.add(plugin);3459 plugin.install(app, ...options);3460 } else if (isFunction(plugin)) {3461 installedPlugins.add(plugin);3462 plugin(app, ...options);3463 } else if (true) {3464 warn2(`A plugin must either be a function or an object with an "install" function.`);3465 }3466 return app;3467 },3468 mixin(mixin) {3469 if (true) {3470 if (!context.mixins.includes(mixin)) {3471 context.mixins.push(mixin);3472 } else if (true) {3473 warn2("Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : ""));3474 }3475 } else if (true) {3476 warn2("Mixins are only available in builds supporting Options API");3477 }3478 return app;3479 },3480 component(name, component) {3481 if (true) {3482 validateComponentName(name, context.config);3483 }3484 if (!component) {3485 return context.components[name];3486 }3487 if (context.components[name]) {3488 warn2(`Component "${name}" has already been registered in target app.`);3489 }3490 context.components[name] = component;3491 return app;3492 },3493 directive(name, directive) {3494 if (true) {3495 validateDirectiveName(name);3496 }3497 if (!directive) {3498 return context.directives[name];3499 }3500 if (context.directives[name]) {3501 warn2(`Directive "${name}" has already been registered in target app.`);3502 }3503 context.directives[name] = directive;3504 return app;3505 },3506 mount(rootContainer, isHydrate, isSVG) {3507 if (!isMounted) {3508 const vnode = createVNode(rootComponent, rootProps);3509 vnode.appContext = context;3510 if (true) {3511 context.reload = () => {3512 render3(cloneVNode(vnode), rootContainer, isSVG);3513 };3514 }3515 if (isHydrate && hydrate) {3516 hydrate(vnode, rootContainer);3517 } else {3518 render3(vnode, rootContainer, isSVG);3519 }3520 isMounted = true;3521 app._container = rootContainer;3522 rootContainer.__vue_app__ = app;3523 if (true) {3524 app._instance = vnode.component;3525 devtoolsInitApp(app, version);3526 }3527 return getExposeProxy(vnode.component) || vnode.component.proxy;3528 } else if (true) {3529 warn2(`App has already been mounted.3530If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``);3531 }3532 },3533 unmount() {3534 if (isMounted) {3535 render3(null, app._container);3536 if (true) {3537 app._instance = null;3538 devtoolsUnmountApp(app);3539 }3540 delete app._container.__vue_app__;3541 } else if (true) {3542 warn2(`Cannot unmount an app that is not mounted.`);3543 }3544 },3545 provide(key, value) {3546 if (key in context.provides) {3547 warn2(`App already provides property with key "${String(key)}". It will be overwritten with the new value.`);3548 }3549 context.provides[key] = value;3550 return app;3551 }3552 };...

Full Screen

Full Screen

vue3.js

Source:vue3.js Github

copy

Full Screen

...1698 Comment,1699 Static1700 });1701 }1702 function devtoolsUnmountApp(app) {1703 if (!exports.devtools)1704 return;1705 exports.devtools.emit("app:unmount" /* APP_UNMOUNT */, app);1706 }1707 const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);1708 const devtoolsComponentUpdated = /*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */);1709 const devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);1710 function createDevtoolsComponentHook(hook) {1711 return (component) => {1712 if (!exports.devtools)1713 return;1714 exports.devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined);1715 };1716 } ...

Full Screen

Full Screen

vendor.30f85827.js

Source:vendor.30f85827.js Github

copy

Full Screen

...1194 Comment,1195 Static1196 });1197}1198function devtoolsUnmountApp(app) {1199 emit("app:unmount", app);1200}1201const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook("component:added");1202const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook("component:updated");1203const devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook("component:removed");1204function createDevtoolsComponentHook(hook) {1205 return (component) => {1206 emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : void 0, component);1207 };1208}1209function devtoolsComponentEmit(component, event, params) {1210 emit("component:emit", component.appContext.app, component, event, params);1211}1212function emit$1(instance, event, ...rawArgs) {1213 const props = instance.vnode.props || EMPTY_OBJ;1214 let args = rawArgs;1215 const isModelListener2 = event.startsWith("update:");1216 const modelArg = isModelListener2 && event.slice(7);1217 if (modelArg && modelArg in props) {1218 const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;1219 const { number, trim } = props[modifiersKey] || EMPTY_OBJ;1220 if (trim) {1221 args = rawArgs.map((a) => a.trim());1222 } else if (number) {1223 args = rawArgs.map(toNumber);1224 }1225 }1226 {1227 devtoolsComponentEmit(instance, event, args);1228 }1229 let handlerName;1230 let handler = props[handlerName = toHandlerKey(event)] || props[handlerName = toHandlerKey(camelize(event))];1231 if (!handler && isModelListener2) {1232 handler = props[handlerName = toHandlerKey(hyphenate(event))];1233 }1234 if (handler) {1235 callWithAsyncErrorHandling(handler, instance, 6, args);1236 }1237 const onceHandler = props[handlerName + `Once`];1238 if (onceHandler) {1239 if (!instance.emitted) {1240 instance.emitted = {};1241 } else if (instance.emitted[handlerName]) {1242 return;1243 }1244 instance.emitted[handlerName] = true;1245 callWithAsyncErrorHandling(onceHandler, instance, 6, args);1246 }1247}1248function normalizeEmitsOptions(comp, appContext, asMixin = false) {1249 const cache = appContext.emitsCache;1250 const cached = cache.get(comp);1251 if (cached !== void 0) {1252 return cached;1253 }1254 const raw = comp.emits;1255 let normalized = {};1256 let hasExtends = false;1257 if (!isFunction(comp)) {1258 const extendEmits = (raw2) => {1259 const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);1260 if (normalizedFromExtend) {1261 hasExtends = true;1262 extend(normalized, normalizedFromExtend);1263 }1264 };1265 if (!asMixin && appContext.mixins.length) {1266 appContext.mixins.forEach(extendEmits);1267 }1268 if (comp.extends) {1269 extendEmits(comp.extends);1270 }1271 if (comp.mixins) {1272 comp.mixins.forEach(extendEmits);1273 }1274 }1275 if (!raw && !hasExtends) {1276 cache.set(comp, null);1277 return null;1278 }1279 if (isArray(raw)) {1280 raw.forEach((key) => normalized[key] = null);1281 } else {1282 extend(normalized, raw);1283 }1284 cache.set(comp, normalized);1285 return normalized;1286}1287function isEmitListener(options, key) {1288 if (!options || !isOn(key)) {1289 return false;1290 }1291 key = key.slice(2).replace(/Once$/, "");1292 return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);1293}1294let currentRenderingInstance = null;1295let currentScopeId = null;1296function setCurrentRenderingInstance(instance) {1297 const prev = currentRenderingInstance;1298 currentRenderingInstance = instance;1299 currentScopeId = instance && instance.type.__scopeId || null;1300 return prev;1301}1302function pushScopeId(id) {1303 currentScopeId = id;1304}1305function popScopeId() {1306 currentScopeId = null;1307}1308function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) {1309 if (!ctx)1310 return fn;1311 if (fn._n) {1312 return fn;1313 }1314 const renderFnWithContext = (...args) => {1315 if (renderFnWithContext._d) {1316 setBlockTracking(-1);1317 }1318 const prevInstance = setCurrentRenderingInstance(ctx);1319 const res = fn(...args);1320 setCurrentRenderingInstance(prevInstance);1321 if (renderFnWithContext._d) {1322 setBlockTracking(1);1323 }1324 {1325 devtoolsComponentUpdated(ctx);1326 }1327 return res;1328 };1329 renderFnWithContext._n = true;1330 renderFnWithContext._c = true;1331 renderFnWithContext._d = true;1332 return renderFnWithContext;1333}1334function markAttrsAccessed() {1335}1336function renderComponentRoot(instance) {1337 const { type: Component, vnode, proxy, withProxy, props, propsOptions: [propsOptions], slots, attrs, emit: emit2, render, renderCache, data, setupState, ctx, inheritAttrs } = instance;1338 let result;1339 let fallthroughAttrs;1340 const prev = setCurrentRenderingInstance(instance);1341 try {1342 if (vnode.shapeFlag & 4) {1343 const proxyToUse = withProxy || proxy;1344 result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));1345 fallthroughAttrs = attrs;1346 } else {1347 const render2 = Component;1348 if (false)1349 ;1350 result = normalizeVNode(render2.length > 1 ? render2(props, false ? {1351 get attrs() {1352 markAttrsAccessed();1353 return attrs;1354 },1355 slots,1356 emit: emit21357 } : { attrs, slots, emit: emit2 }) : render2(props, null));1358 fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);1359 }1360 } catch (err) {1361 blockStack.length = 0;1362 handleError(err, instance, 1);1363 result = createVNode(Comment);1364 }1365 let root = result;1366 if (fallthroughAttrs && inheritAttrs !== false) {1367 const keys = Object.keys(fallthroughAttrs);1368 const { shapeFlag } = root;1369 if (keys.length) {1370 if (shapeFlag & (1 | 6)) {1371 if (propsOptions && keys.some(isModelListener)) {1372 fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);1373 }1374 root = cloneVNode(root, fallthroughAttrs);1375 }1376 }1377 }1378 if (vnode.dirs) {1379 root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;1380 }1381 if (vnode.transition) {1382 root.transition = vnode.transition;1383 }1384 {1385 result = root;1386 }1387 setCurrentRenderingInstance(prev);1388 return result;1389}1390const getFunctionalFallthrough = (attrs) => {1391 let res;1392 for (const key in attrs) {1393 if (key === "class" || key === "style" || isOn(key)) {1394 (res || (res = {}))[key] = attrs[key];1395 }1396 }1397 return res;1398};1399const filterModelListeners = (attrs, props) => {1400 const res = {};1401 for (const key in attrs) {1402 if (!isModelListener(key) || !(key.slice(9) in props)) {1403 res[key] = attrs[key];1404 }1405 }1406 return res;1407};1408function shouldUpdateComponent(prevVNode, nextVNode, optimized) {1409 const { props: prevProps, children: prevChildren, component } = prevVNode;1410 const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;1411 const emits = component.emitsOptions;1412 if (nextVNode.dirs || nextVNode.transition) {1413 return true;1414 }1415 if (optimized && patchFlag >= 0) {1416 if (patchFlag & 1024) {1417 return true;1418 }1419 if (patchFlag & 16) {1420 if (!prevProps) {1421 return !!nextProps;1422 }1423 return hasPropsChanged(prevProps, nextProps, emits);1424 } else if (patchFlag & 8) {1425 const dynamicProps = nextVNode.dynamicProps;1426 for (let i = 0; i < dynamicProps.length; i++) {1427 const key = dynamicProps[i];1428 if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {1429 return true;1430 }1431 }1432 }1433 } else {1434 if (prevChildren || nextChildren) {1435 if (!nextChildren || !nextChildren.$stable) {1436 return true;1437 }1438 }1439 if (prevProps === nextProps) {1440 return false;1441 }1442 if (!prevProps) {1443 return !!nextProps;1444 }1445 if (!nextProps) {1446 return true;1447 }1448 return hasPropsChanged(prevProps, nextProps, emits);1449 }1450 return false;1451}1452function hasPropsChanged(prevProps, nextProps, emitsOptions) {1453 const nextKeys = Object.keys(nextProps);1454 if (nextKeys.length !== Object.keys(prevProps).length) {1455 return true;1456 }1457 for (let i = 0; i < nextKeys.length; i++) {1458 const key = nextKeys[i];1459 if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {1460 return true;1461 }1462 }1463 return false;1464}1465function updateHOCHostEl({ vnode, parent }, el) {1466 while (parent && parent.subTree === vnode) {1467 (vnode = parent.vnode).el = el;1468 parent = parent.parent;1469 }1470}1471const isSuspense = (type) => type.__isSuspense;1472function queueEffectWithSuspense(fn, suspense) {1473 if (suspense && suspense.pendingBranch) {1474 if (isArray(fn)) {1475 suspense.effects.push(...fn);1476 } else {1477 suspense.effects.push(fn);1478 }1479 } else {1480 queuePostFlushCb(fn);1481 }1482}1483function provide(key, value) {1484 if (!currentInstance)1485 ;1486 else {1487 let provides = currentInstance.provides;1488 const parentProvides = currentInstance.parent && currentInstance.parent.provides;1489 if (parentProvides === provides) {1490 provides = currentInstance.provides = Object.create(parentProvides);1491 }1492 provides[key] = value;1493 }1494}1495function inject(key, defaultValue, treatDefaultAsFactory = false) {1496 const instance = currentInstance || currentRenderingInstance;1497 if (instance) {1498 const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides;1499 if (provides && key in provides) {1500 return provides[key];1501 } else if (arguments.length > 1) {1502 return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue;1503 } else1504 ;1505 }1506}1507const INITIAL_WATCHER_VALUE = {};1508function watch(source, cb, options) {1509 return doWatch(source, cb, options);1510}1511function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) {1512 const instance = currentInstance;1513 let getter;1514 let forceTrigger = false;1515 let isMultiSource = false;1516 if (isRef(source)) {1517 getter = () => source.value;1518 forceTrigger = isShallow(source);1519 } else if (isReactive(source)) {1520 getter = () => source;1521 deep = true;1522 } else if (isArray(source)) {1523 isMultiSource = true;1524 forceTrigger = source.some(isReactive);1525 getter = () => source.map((s) => {1526 if (isRef(s)) {1527 return s.value;1528 } else if (isReactive(s)) {1529 return traverse(s);1530 } else if (isFunction(s)) {1531 return callWithErrorHandling(s, instance, 2);1532 } else1533 ;1534 });1535 } else if (isFunction(source)) {1536 if (cb) {1537 getter = () => callWithErrorHandling(source, instance, 2);1538 } else {1539 getter = () => {1540 if (instance && instance.isUnmounted) {1541 return;1542 }1543 if (cleanup) {1544 cleanup();1545 }1546 return callWithAsyncErrorHandling(source, instance, 3, [onCleanup]);1547 };1548 }1549 } else {1550 getter = NOOP;1551 }1552 if (cb && deep) {1553 const baseGetter = getter;1554 getter = () => traverse(baseGetter());1555 }1556 let cleanup;1557 let onCleanup = (fn) => {1558 cleanup = effect.onStop = () => {1559 callWithErrorHandling(fn, instance, 4);1560 };1561 };1562 if (isInSSRComponentSetup) {1563 onCleanup = NOOP;1564 if (!cb) {1565 getter();1566 } else if (immediate) {1567 callWithAsyncErrorHandling(cb, instance, 3, [1568 getter(),1569 isMultiSource ? [] : void 0,1570 onCleanup1571 ]);1572 }1573 return NOOP;1574 }1575 let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;1576 const job = () => {1577 if (!effect.active) {1578 return;1579 }1580 if (cb) {1581 const newValue = effect.run();1582 if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) {1583 if (cleanup) {1584 cleanup();1585 }1586 callWithAsyncErrorHandling(cb, instance, 3, [1587 newValue,1588 oldValue === INITIAL_WATCHER_VALUE ? void 0 : oldValue,1589 onCleanup1590 ]);1591 oldValue = newValue;1592 }1593 } else {1594 effect.run();1595 }1596 };1597 job.allowRecurse = !!cb;1598 let scheduler;1599 if (flush === "sync") {1600 scheduler = job;1601 } else if (flush === "post") {1602 scheduler = () => queuePostRenderEffect(job, instance && instance.suspense);1603 } else {1604 scheduler = () => {1605 if (!instance || instance.isMounted) {1606 queuePreFlushCb(job);1607 } else {1608 job();1609 }1610 };1611 }1612 const effect = new ReactiveEffect(getter, scheduler);1613 if (cb) {1614 if (immediate) {1615 job();1616 } else {1617 oldValue = effect.run();1618 }1619 } else if (flush === "post") {1620 queuePostRenderEffect(effect.run.bind(effect), instance && instance.suspense);1621 } else {1622 effect.run();1623 }1624 return () => {1625 effect.stop();1626 if (instance && instance.scope) {1627 remove(instance.scope.effects, effect);1628 }1629 };1630}1631function instanceWatch(source, value, options) {1632 const publicThis = this.proxy;1633 const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);1634 let cb;1635 if (isFunction(value)) {1636 cb = value;1637 } else {1638 cb = value.handler;1639 options = value;1640 }1641 const cur = currentInstance;1642 setCurrentInstance(this);1643 const res = doWatch(getter, cb.bind(publicThis), options);1644 if (cur) {1645 setCurrentInstance(cur);1646 } else {1647 unsetCurrentInstance();1648 }1649 return res;1650}1651function createPathGetter(ctx, path) {1652 const segments = path.split(".");1653 return () => {1654 let cur = ctx;1655 for (let i = 0; i < segments.length && cur; i++) {1656 cur = cur[segments[i]];1657 }1658 return cur;1659 };1660}1661function traverse(value, seen) {1662 if (!isObject(value) || value["__v_skip"]) {1663 return value;1664 }1665 seen = seen || /* @__PURE__ */ new Set();1666 if (seen.has(value)) {1667 return value;1668 }1669 seen.add(value);1670 if (isRef(value)) {1671 traverse(value.value, seen);1672 } else if (isArray(value)) {1673 for (let i = 0; i < value.length; i++) {1674 traverse(value[i], seen);1675 }1676 } else if (isSet(value) || isMap(value)) {1677 value.forEach((v) => {1678 traverse(v, seen);1679 });1680 } else if (isPlainObject(value)) {1681 for (const key in value) {1682 traverse(value[key], seen);1683 }1684 }1685 return value;1686}1687function useTransitionState() {1688 const state = {1689 isMounted: false,1690 isLeaving: false,1691 isUnmounting: false,1692 leavingVNodes: /* @__PURE__ */ new Map()1693 };1694 onMounted(() => {1695 state.isMounted = true;1696 });1697 onBeforeUnmount(() => {1698 state.isUnmounting = true;1699 });1700 return state;1701}1702const TransitionHookValidator = [Function, Array];1703const BaseTransitionImpl = {1704 name: `BaseTransition`,1705 props: {1706 mode: String,1707 appear: Boolean,1708 persisted: Boolean,1709 onBeforeEnter: TransitionHookValidator,1710 onEnter: TransitionHookValidator,1711 onAfterEnter: TransitionHookValidator,1712 onEnterCancelled: TransitionHookValidator,1713 onBeforeLeave: TransitionHookValidator,1714 onLeave: TransitionHookValidator,1715 onAfterLeave: TransitionHookValidator,1716 onLeaveCancelled: TransitionHookValidator,1717 onBeforeAppear: TransitionHookValidator,1718 onAppear: TransitionHookValidator,1719 onAfterAppear: TransitionHookValidator,1720 onAppearCancelled: TransitionHookValidator1721 },1722 setup(props, { slots }) {1723 const instance = getCurrentInstance();1724 const state = useTransitionState();1725 let prevTransitionKey;1726 return () => {1727 const children = slots.default && getTransitionRawChildren(slots.default(), true);1728 if (!children || !children.length) {1729 return;1730 }1731 const rawProps = toRaw(props);1732 const { mode } = rawProps;1733 const child = children[0];1734 if (state.isLeaving) {1735 return emptyPlaceholder(child);1736 }1737 const innerChild = getKeepAliveChild(child);1738 if (!innerChild) {1739 return emptyPlaceholder(child);1740 }1741 const enterHooks = resolveTransitionHooks(innerChild, rawProps, state, instance);1742 setTransitionHooks(innerChild, enterHooks);1743 const oldChild = instance.subTree;1744 const oldInnerChild = oldChild && getKeepAliveChild(oldChild);1745 let transitionKeyChanged = false;1746 const { getTransitionKey } = innerChild.type;1747 if (getTransitionKey) {1748 const key = getTransitionKey();1749 if (prevTransitionKey === void 0) {1750 prevTransitionKey = key;1751 } else if (key !== prevTransitionKey) {1752 prevTransitionKey = key;1753 transitionKeyChanged = true;1754 }1755 }1756 if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {1757 const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance);1758 setTransitionHooks(oldInnerChild, leavingHooks);1759 if (mode === "out-in") {1760 state.isLeaving = true;1761 leavingHooks.afterLeave = () => {1762 state.isLeaving = false;1763 instance.update();1764 };1765 return emptyPlaceholder(child);1766 } else if (mode === "in-out" && innerChild.type !== Comment) {1767 leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {1768 const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild);1769 leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;1770 el._leaveCb = () => {1771 earlyRemove();1772 el._leaveCb = void 0;1773 delete enterHooks.delayedLeave;1774 };1775 enterHooks.delayedLeave = delayedLeave;1776 };1777 }1778 }1779 return child;1780 };1781 }1782};1783const BaseTransition = BaseTransitionImpl;1784function getLeavingNodesForType(state, vnode) {1785 const { leavingVNodes } = state;1786 let leavingVNodesCache = leavingVNodes.get(vnode.type);1787 if (!leavingVNodesCache) {1788 leavingVNodesCache = /* @__PURE__ */ Object.create(null);1789 leavingVNodes.set(vnode.type, leavingVNodesCache);1790 }1791 return leavingVNodesCache;1792}1793function resolveTransitionHooks(vnode, props, state, instance) {1794 const { appear, mode, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled } = props;1795 const key = String(vnode.key);1796 const leavingVNodesCache = getLeavingNodesForType(state, vnode);1797 const callHook2 = (hook, args) => {1798 hook && callWithAsyncErrorHandling(hook, instance, 9, args);1799 };1800 const hooks = {1801 mode,1802 persisted,1803 beforeEnter(el) {1804 let hook = onBeforeEnter;1805 if (!state.isMounted) {1806 if (appear) {1807 hook = onBeforeAppear || onBeforeEnter;1808 } else {1809 return;1810 }1811 }1812 if (el._leaveCb) {1813 el._leaveCb(true);1814 }1815 const leavingVNode = leavingVNodesCache[key];1816 if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el._leaveCb) {1817 leavingVNode.el._leaveCb();1818 }1819 callHook2(hook, [el]);1820 },1821 enter(el) {1822 let hook = onEnter;1823 let afterHook = onAfterEnter;1824 let cancelHook = onEnterCancelled;1825 if (!state.isMounted) {1826 if (appear) {1827 hook = onAppear || onEnter;1828 afterHook = onAfterAppear || onAfterEnter;1829 cancelHook = onAppearCancelled || onEnterCancelled;1830 } else {1831 return;1832 }1833 }1834 let called = false;1835 const done = el._enterCb = (cancelled) => {1836 if (called)1837 return;1838 called = true;1839 if (cancelled) {1840 callHook2(cancelHook, [el]);1841 } else {1842 callHook2(afterHook, [el]);1843 }1844 if (hooks.delayedLeave) {1845 hooks.delayedLeave();1846 }1847 el._enterCb = void 0;1848 };1849 if (hook) {1850 hook(el, done);1851 if (hook.length <= 1) {1852 done();1853 }1854 } else {1855 done();1856 }1857 },1858 leave(el, remove2) {1859 const key2 = String(vnode.key);1860 if (el._enterCb) {1861 el._enterCb(true);1862 }1863 if (state.isUnmounting) {1864 return remove2();1865 }1866 callHook2(onBeforeLeave, [el]);1867 let called = false;1868 const done = el._leaveCb = (cancelled) => {1869 if (called)1870 return;1871 called = true;1872 remove2();1873 if (cancelled) {1874 callHook2(onLeaveCancelled, [el]);1875 } else {1876 callHook2(onAfterLeave, [el]);1877 }1878 el._leaveCb = void 0;1879 if (leavingVNodesCache[key2] === vnode) {1880 delete leavingVNodesCache[key2];1881 }1882 };1883 leavingVNodesCache[key2] = vnode;1884 if (onLeave) {1885 onLeave(el, done);1886 if (onLeave.length <= 1) {1887 done();1888 }1889 } else {1890 done();1891 }1892 },1893 clone(vnode2) {1894 return resolveTransitionHooks(vnode2, props, state, instance);1895 }1896 };1897 return hooks;1898}1899function emptyPlaceholder(vnode) {1900 if (isKeepAlive(vnode)) {1901 vnode = cloneVNode(vnode);1902 vnode.children = null;1903 return vnode;1904 }1905}1906function getKeepAliveChild(vnode) {1907 return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;1908}1909function setTransitionHooks(vnode, hooks) {1910 if (vnode.shapeFlag & 6 && vnode.component) {1911 setTransitionHooks(vnode.component.subTree, hooks);1912 } else if (vnode.shapeFlag & 128) {1913 vnode.ssContent.transition = hooks.clone(vnode.ssContent);1914 vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);1915 } else {1916 vnode.transition = hooks;1917 }1918}1919function getTransitionRawChildren(children, keepComment = false) {1920 let ret = [];1921 let keyedFragmentCount = 0;1922 for (let i = 0; i < children.length; i++) {1923 const child = children[i];1924 if (child.type === Fragment) {1925 if (child.patchFlag & 128)1926 keyedFragmentCount++;1927 ret = ret.concat(getTransitionRawChildren(child.children, keepComment));1928 } else if (keepComment || child.type !== Comment) {1929 ret.push(child);1930 }1931 }1932 if (keyedFragmentCount > 1) {1933 for (let i = 0; i < ret.length; i++) {1934 ret[i].patchFlag = -2;1935 }1936 }1937 return ret;1938}1939const isAsyncWrapper = (i) => !!i.type.__asyncLoader;1940const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;1941function onActivated(hook, target) {1942 registerKeepAliveHook(hook, "a", target);1943}1944function onDeactivated(hook, target) {1945 registerKeepAliveHook(hook, "da", target);1946}1947function registerKeepAliveHook(hook, type, target = currentInstance) {1948 const wrappedHook = hook.__wdc || (hook.__wdc = () => {1949 let current = target;1950 while (current) {1951 if (current.isDeactivated) {1952 return;1953 }1954 current = current.parent;1955 }1956 return hook();1957 });1958 injectHook(type, wrappedHook, target);1959 if (target) {1960 let current = target.parent;1961 while (current && current.parent) {1962 if (isKeepAlive(current.parent.vnode)) {1963 injectToKeepAliveRoot(wrappedHook, type, target, current);1964 }1965 current = current.parent;1966 }1967 }1968}1969function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {1970 const injected = injectHook(type, hook, keepAliveRoot, true);1971 onUnmounted(() => {1972 remove(keepAliveRoot[type], injected);1973 }, target);1974}1975function injectHook(type, hook, target = currentInstance, prepend = false) {1976 if (target) {1977 const hooks = target[type] || (target[type] = []);1978 const wrappedHook = hook.__weh || (hook.__weh = (...args) => {1979 if (target.isUnmounted) {1980 return;1981 }1982 pauseTracking();1983 setCurrentInstance(target);1984 const res = callWithAsyncErrorHandling(hook, target, type, args);1985 unsetCurrentInstance();1986 resetTracking();1987 return res;1988 });1989 if (prepend) {1990 hooks.unshift(wrappedHook);1991 } else {1992 hooks.push(wrappedHook);1993 }1994 return wrappedHook;1995 }1996}1997const createHook = (lifecycle) => (hook, target = currentInstance) => (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, hook, target);1998const onBeforeMount = createHook("bm");1999const onMounted = createHook("m");2000const onBeforeUpdate = createHook("bu");2001const onUpdated = createHook("u");2002const onBeforeUnmount = createHook("bum");2003const onUnmounted = createHook("um");2004const onServerPrefetch = createHook("sp");2005const onRenderTriggered = createHook("rtg");2006const onRenderTracked = createHook("rtc");2007function onErrorCaptured(hook, target = currentInstance) {2008 injectHook("ec", hook, target);2009}2010let shouldCacheAccess = true;2011function applyOptions(instance) {2012 const options = resolveMergedOptions(instance);2013 const publicThis = instance.proxy;2014 const ctx = instance.ctx;2015 shouldCacheAccess = false;2016 if (options.beforeCreate) {2017 callHook(options.beforeCreate, instance, "bc");2018 }2019 const {2020 data: dataOptions,2021 computed: computedOptions,2022 methods,2023 watch: watchOptions,2024 provide: provideOptions,2025 inject: injectOptions,2026 created,2027 beforeMount,2028 mounted,2029 beforeUpdate,2030 updated,2031 activated,2032 deactivated,2033 beforeDestroy,2034 beforeUnmount,2035 destroyed,2036 unmounted,2037 render,2038 renderTracked,2039 renderTriggered,2040 errorCaptured,2041 serverPrefetch,2042 expose,2043 inheritAttrs,2044 components,2045 directives,2046 filters2047 } = options;2048 const checkDuplicateProperties = null;2049 if (injectOptions) {2050 resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef);2051 }2052 if (methods) {2053 for (const key in methods) {2054 const methodHandler = methods[key];2055 if (isFunction(methodHandler)) {2056 {2057 ctx[key] = methodHandler.bind(publicThis);2058 }2059 }2060 }2061 }2062 if (dataOptions) {2063 const data = dataOptions.call(publicThis, publicThis);2064 if (!isObject(data))2065 ;2066 else {2067 instance.data = reactive(data);2068 }2069 }2070 shouldCacheAccess = true;2071 if (computedOptions) {2072 for (const key in computedOptions) {2073 const opt = computedOptions[key];2074 const get2 = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;2075 const set2 = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : NOOP;2076 const c = computed({2077 get: get2,2078 set: set22079 });2080 Object.defineProperty(ctx, key, {2081 enumerable: true,2082 configurable: true,2083 get: () => c.value,2084 set: (v) => c.value = v2085 });2086 }2087 }2088 if (watchOptions) {2089 for (const key in watchOptions) {2090 createWatcher(watchOptions[key], ctx, publicThis, key);2091 }2092 }2093 if (provideOptions) {2094 const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions;2095 Reflect.ownKeys(provides).forEach((key) => {2096 provide(key, provides[key]);2097 });2098 }2099 if (created) {2100 callHook(created, instance, "c");2101 }2102 function registerLifecycleHook(register, hook) {2103 if (isArray(hook)) {2104 hook.forEach((_hook) => register(_hook.bind(publicThis)));2105 } else if (hook) {2106 register(hook.bind(publicThis));2107 }2108 }2109 registerLifecycleHook(onBeforeMount, beforeMount);2110 registerLifecycleHook(onMounted, mounted);2111 registerLifecycleHook(onBeforeUpdate, beforeUpdate);2112 registerLifecycleHook(onUpdated, updated);2113 registerLifecycleHook(onActivated, activated);2114 registerLifecycleHook(onDeactivated, deactivated);2115 registerLifecycleHook(onErrorCaptured, errorCaptured);2116 registerLifecycleHook(onRenderTracked, renderTracked);2117 registerLifecycleHook(onRenderTriggered, renderTriggered);2118 registerLifecycleHook(onBeforeUnmount, beforeUnmount);2119 registerLifecycleHook(onUnmounted, unmounted);2120 registerLifecycleHook(onServerPrefetch, serverPrefetch);2121 if (isArray(expose)) {2122 if (expose.length) {2123 const exposed = instance.exposed || (instance.exposed = {});2124 expose.forEach((key) => {2125 Object.defineProperty(exposed, key, {2126 get: () => publicThis[key],2127 set: (val) => publicThis[key] = val2128 });2129 });2130 } else if (!instance.exposed) {2131 instance.exposed = {};2132 }2133 }2134 if (render && instance.render === NOOP) {2135 instance.render = render;2136 }2137 if (inheritAttrs != null) {2138 instance.inheritAttrs = inheritAttrs;2139 }2140 if (components)2141 instance.components = components;2142 if (directives)2143 instance.directives = directives;2144}2145function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP, unwrapRef = false) {2146 if (isArray(injectOptions)) {2147 injectOptions = normalizeInject(injectOptions);2148 }2149 for (const key in injectOptions) {2150 const opt = injectOptions[key];2151 let injected;2152 if (isObject(opt)) {2153 if ("default" in opt) {2154 injected = inject(opt.from || key, opt.default, true);2155 } else {2156 injected = inject(opt.from || key);2157 }2158 } else {2159 injected = inject(opt);2160 }2161 if (isRef(injected)) {2162 if (unwrapRef) {2163 Object.defineProperty(ctx, key, {2164 enumerable: true,2165 configurable: true,2166 get: () => injected.value,2167 set: (v) => injected.value = v2168 });2169 } else {2170 ctx[key] = injected;2171 }2172 } else {2173 ctx[key] = injected;2174 }2175 }2176}2177function callHook(hook, instance, type) {2178 callWithAsyncErrorHandling(isArray(hook) ? hook.map((h) => h.bind(instance.proxy)) : hook.bind(instance.proxy), instance, type);2179}2180function createWatcher(raw, ctx, publicThis, key) {2181 const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];2182 if (isString(raw)) {2183 const handler = ctx[raw];2184 if (isFunction(handler)) {2185 watch(getter, handler);2186 }2187 } else if (isFunction(raw)) {2188 watch(getter, raw.bind(publicThis));2189 } else if (isObject(raw)) {2190 if (isArray(raw)) {2191 raw.forEach((r) => createWatcher(r, ctx, publicThis, key));2192 } else {2193 const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];2194 if (isFunction(handler)) {2195 watch(getter, handler, raw);2196 }2197 }2198 } else2199 ;2200}2201function resolveMergedOptions(instance) {2202 const base = instance.type;2203 const { mixins, extends: extendsOptions } = base;2204 const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext;2205 const cached = cache.get(base);2206 let resolved;2207 if (cached) {2208 resolved = cached;2209 } else if (!globalMixins.length && !mixins && !extendsOptions) {2210 {2211 resolved = base;2212 }2213 } else {2214 resolved = {};2215 if (globalMixins.length) {2216 globalMixins.forEach((m) => mergeOptions(resolved, m, optionMergeStrategies, true));2217 }2218 mergeOptions(resolved, base, optionMergeStrategies);2219 }2220 cache.set(base, resolved);2221 return resolved;2222}2223function mergeOptions(to, from, strats, asMixin = false) {2224 const { mixins, extends: extendsOptions } = from;2225 if (extendsOptions) {2226 mergeOptions(to, extendsOptions, strats, true);2227 }2228 if (mixins) {2229 mixins.forEach((m) => mergeOptions(to, m, strats, true));2230 }2231 for (const key in from) {2232 if (asMixin && key === "expose")2233 ;2234 else {2235 const strat = internalOptionMergeStrats[key] || strats && strats[key];2236 to[key] = strat ? strat(to[key], from[key]) : from[key];2237 }2238 }2239 return to;2240}2241const internalOptionMergeStrats = {2242 data: mergeDataFn,2243 props: mergeObjectOptions,2244 emits: mergeObjectOptions,2245 methods: mergeObjectOptions,2246 computed: mergeObjectOptions,2247 beforeCreate: mergeAsArray,2248 created: mergeAsArray,2249 beforeMount: mergeAsArray,2250 mounted: mergeAsArray,2251 beforeUpdate: mergeAsArray,2252 updated: mergeAsArray,2253 beforeDestroy: mergeAsArray,2254 beforeUnmount: mergeAsArray,2255 destroyed: mergeAsArray,2256 unmounted: mergeAsArray,2257 activated: mergeAsArray,2258 deactivated: mergeAsArray,2259 errorCaptured: mergeAsArray,2260 serverPrefetch: mergeAsArray,2261 components: mergeObjectOptions,2262 directives: mergeObjectOptions,2263 watch: mergeWatchOptions,2264 provide: mergeDataFn,2265 inject: mergeInject2266};2267function mergeDataFn(to, from) {2268 if (!from) {2269 return to;2270 }2271 if (!to) {2272 return from;2273 }2274 return function mergedDataFn() {2275 return extend(isFunction(to) ? to.call(this, this) : to, isFunction(from) ? from.call(this, this) : from);2276 };2277}2278function mergeInject(to, from) {2279 return mergeObjectOptions(normalizeInject(to), normalizeInject(from));2280}2281function normalizeInject(raw) {2282 if (isArray(raw)) {2283 const res = {};2284 for (let i = 0; i < raw.length; i++) {2285 res[raw[i]] = raw[i];2286 }2287 return res;2288 }2289 return raw;2290}2291function mergeAsArray(to, from) {2292 return to ? [...new Set([].concat(to, from))] : from;2293}2294function mergeObjectOptions(to, from) {2295 return to ? extend(extend(/* @__PURE__ */ Object.create(null), to), from) : from;2296}2297function mergeWatchOptions(to, from) {2298 if (!to)2299 return from;2300 if (!from)2301 return to;2302 const merged = extend(/* @__PURE__ */ Object.create(null), to);2303 for (const key in from) {2304 merged[key] = mergeAsArray(to[key], from[key]);2305 }2306 return merged;2307}2308function initProps(instance, rawProps, isStateful, isSSR = false) {2309 const props = {};2310 const attrs = {};2311 def(attrs, InternalObjectKey, 1);2312 instance.propsDefaults = /* @__PURE__ */ Object.create(null);2313 setFullProps(instance, rawProps, props, attrs);2314 for (const key in instance.propsOptions[0]) {2315 if (!(key in props)) {2316 props[key] = void 0;2317 }2318 }2319 if (isStateful) {2320 instance.props = isSSR ? props : shallowReactive(props);2321 } else {2322 if (!instance.type.props) {2323 instance.props = attrs;2324 } else {2325 instance.props = props;2326 }2327 }2328 instance.attrs = attrs;2329}2330function updateProps(instance, rawProps, rawPrevProps, optimized) {2331 const { props, attrs, vnode: { patchFlag } } = instance;2332 const rawCurrentProps = toRaw(props);2333 const [options] = instance.propsOptions;2334 let hasAttrsChanged = false;2335 if ((optimized || patchFlag > 0) && !(patchFlag & 16)) {2336 if (patchFlag & 8) {2337 const propsToUpdate = instance.vnode.dynamicProps;2338 for (let i = 0; i < propsToUpdate.length; i++) {2339 let key = propsToUpdate[i];2340 const value = rawProps[key];2341 if (options) {2342 if (hasOwn(attrs, key)) {2343 if (value !== attrs[key]) {2344 attrs[key] = value;2345 hasAttrsChanged = true;2346 }2347 } else {2348 const camelizedKey = camelize(key);2349 props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false);2350 }2351 } else {2352 if (value !== attrs[key]) {2353 attrs[key] = value;2354 hasAttrsChanged = true;2355 }2356 }2357 }2358 }2359 } else {2360 if (setFullProps(instance, rawProps, props, attrs)) {2361 hasAttrsChanged = true;2362 }2363 let kebabKey;2364 for (const key in rawCurrentProps) {2365 if (!rawProps || !hasOwn(rawProps, key) && ((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {2366 if (options) {2367 if (rawPrevProps && (rawPrevProps[key] !== void 0 || rawPrevProps[kebabKey] !== void 0)) {2368 props[key] = resolvePropValue(options, rawCurrentProps, key, void 0, instance, true);2369 }2370 } else {2371 delete props[key];2372 }2373 }2374 }2375 if (attrs !== rawCurrentProps) {2376 for (const key in attrs) {2377 if (!rawProps || !hasOwn(rawProps, key) && true) {2378 delete attrs[key];2379 hasAttrsChanged = true;2380 }2381 }2382 }2383 }2384 if (hasAttrsChanged) {2385 trigger$1(instance, "set", "$attrs");2386 }2387}2388function setFullProps(instance, rawProps, props, attrs) {2389 const [options, needCastKeys] = instance.propsOptions;2390 let hasAttrsChanged = false;2391 let rawCastValues;2392 if (rawProps) {2393 for (let key in rawProps) {2394 if (isReservedProp(key)) {2395 continue;2396 }2397 const value = rawProps[key];2398 let camelKey;2399 if (options && hasOwn(options, camelKey = camelize(key))) {2400 if (!needCastKeys || !needCastKeys.includes(camelKey)) {2401 props[camelKey] = value;2402 } else {2403 (rawCastValues || (rawCastValues = {}))[camelKey] = value;2404 }2405 } else if (!isEmitListener(instance.emitsOptions, key)) {2406 if (!(key in attrs) || value !== attrs[key]) {2407 attrs[key] = value;2408 hasAttrsChanged = true;2409 }2410 }2411 }2412 }2413 if (needCastKeys) {2414 const rawCurrentProps = toRaw(props);2415 const castValues = rawCastValues || EMPTY_OBJ;2416 for (let i = 0; i < needCastKeys.length; i++) {2417 const key = needCastKeys[i];2418 props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn(castValues, key));2419 }2420 }2421 return hasAttrsChanged;2422}2423function resolvePropValue(options, props, key, value, instance, isAbsent) {2424 const opt = options[key];2425 if (opt != null) {2426 const hasDefault = hasOwn(opt, "default");2427 if (hasDefault && value === void 0) {2428 const defaultValue = opt.default;2429 if (opt.type !== Function && isFunction(defaultValue)) {2430 const { propsDefaults } = instance;2431 if (key in propsDefaults) {2432 value = propsDefaults[key];2433 } else {2434 setCurrentInstance(instance);2435 value = propsDefaults[key] = defaultValue.call(null, props);2436 unsetCurrentInstance();2437 }2438 } else {2439 value = defaultValue;2440 }2441 }2442 if (opt[0]) {2443 if (isAbsent && !hasDefault) {2444 value = false;2445 } else if (opt[1] && (value === "" || value === hyphenate(key))) {2446 value = true;2447 }2448 }2449 }2450 return value;2451}2452function normalizePropsOptions(comp, appContext, asMixin = false) {2453 const cache = appContext.propsCache;2454 const cached = cache.get(comp);2455 if (cached) {2456 return cached;2457 }2458 const raw = comp.props;2459 const normalized = {};2460 const needCastKeys = [];2461 let hasExtends = false;2462 if (!isFunction(comp)) {2463 const extendProps = (raw2) => {2464 hasExtends = true;2465 const [props, keys] = normalizePropsOptions(raw2, appContext, true);2466 extend(normalized, props);2467 if (keys)2468 needCastKeys.push(...keys);2469 };2470 if (!asMixin && appContext.mixins.length) {2471 appContext.mixins.forEach(extendProps);2472 }2473 if (comp.extends) {2474 extendProps(comp.extends);2475 }2476 if (comp.mixins) {2477 comp.mixins.forEach(extendProps);2478 }2479 }2480 if (!raw && !hasExtends) {2481 cache.set(comp, EMPTY_ARR);2482 return EMPTY_ARR;2483 }2484 if (isArray(raw)) {2485 for (let i = 0; i < raw.length; i++) {2486 const normalizedKey = camelize(raw[i]);2487 if (validatePropName(normalizedKey)) {2488 normalized[normalizedKey] = EMPTY_OBJ;2489 }2490 }2491 } else if (raw) {2492 for (const key in raw) {2493 const normalizedKey = camelize(key);2494 if (validatePropName(normalizedKey)) {2495 const opt = raw[key];2496 const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : opt;2497 if (prop) {2498 const booleanIndex = getTypeIndex(Boolean, prop.type);2499 const stringIndex = getTypeIndex(String, prop.type);2500 prop[0] = booleanIndex > -1;2501 prop[1] = stringIndex < 0 || booleanIndex < stringIndex;2502 if (booleanIndex > -1 || hasOwn(prop, "default")) {2503 needCastKeys.push(normalizedKey);2504 }2505 }2506 }2507 }2508 }2509 const res = [normalized, needCastKeys];2510 cache.set(comp, res);2511 return res;2512}2513function validatePropName(key) {2514 if (key[0] !== "$") {2515 return true;2516 }2517 return false;2518}2519function getType(ctor) {2520 const match = ctor && ctor.toString().match(/^\s*function (\w+)/);2521 return match ? match[1] : ctor === null ? "null" : "";2522}2523function isSameType(a, b) {2524 return getType(a) === getType(b);2525}2526function getTypeIndex(type, expectedTypes) {2527 if (isArray(expectedTypes)) {2528 return expectedTypes.findIndex((t) => isSameType(t, type));2529 } else if (isFunction(expectedTypes)) {2530 return isSameType(expectedTypes, type) ? 0 : -1;2531 }2532 return -1;2533}2534const isInternalKey = (key) => key[0] === "_" || key === "$stable";2535const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];2536const normalizeSlot = (key, rawSlot, ctx) => {2537 const normalized = withCtx((...args) => {2538 return normalizeSlotValue(rawSlot(...args));2539 }, ctx);2540 normalized._c = false;2541 return normalized;2542};2543const normalizeObjectSlots = (rawSlots, slots, instance) => {2544 const ctx = rawSlots._ctx;2545 for (const key in rawSlots) {2546 if (isInternalKey(key))2547 continue;2548 const value = rawSlots[key];2549 if (isFunction(value)) {2550 slots[key] = normalizeSlot(key, value, ctx);2551 } else if (value != null) {2552 const normalized = normalizeSlotValue(value);2553 slots[key] = () => normalized;2554 }2555 }2556};2557const normalizeVNodeSlots = (instance, children) => {2558 const normalized = normalizeSlotValue(children);2559 instance.slots.default = () => normalized;2560};2561const initSlots = (instance, children) => {2562 if (instance.vnode.shapeFlag & 32) {2563 const type = children._;2564 if (type) {2565 instance.slots = toRaw(children);2566 def(children, "_", type);2567 } else {2568 normalizeObjectSlots(children, instance.slots = {});2569 }2570 } else {2571 instance.slots = {};2572 if (children) {2573 normalizeVNodeSlots(instance, children);2574 }2575 }2576 def(instance.slots, InternalObjectKey, 1);2577};2578const updateSlots = (instance, children, optimized) => {2579 const { vnode, slots } = instance;2580 let needDeletionCheck = true;2581 let deletionComparisonTarget = EMPTY_OBJ;2582 if (vnode.shapeFlag & 32) {2583 const type = children._;2584 if (type) {2585 if (optimized && type === 1) {2586 needDeletionCheck = false;2587 } else {2588 extend(slots, children);2589 if (!optimized && type === 1) {2590 delete slots._;2591 }2592 }2593 } else {2594 needDeletionCheck = !children.$stable;2595 normalizeObjectSlots(children, slots);2596 }2597 deletionComparisonTarget = children;2598 } else if (children) {2599 normalizeVNodeSlots(instance, children);2600 deletionComparisonTarget = { default: 1 };2601 }2602 if (needDeletionCheck) {2603 for (const key in slots) {2604 if (!isInternalKey(key) && !(key in deletionComparisonTarget)) {2605 delete slots[key];2606 }2607 }2608 }2609};2610function withDirectives(vnode, directives) {2611 const internalInstance = currentRenderingInstance;2612 if (internalInstance === null) {2613 return vnode;2614 }2615 const instance = internalInstance.proxy;2616 const bindings = vnode.dirs || (vnode.dirs = []);2617 for (let i = 0; i < directives.length; i++) {2618 let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];2619 if (isFunction(dir)) {2620 dir = {2621 mounted: dir,2622 updated: dir2623 };2624 }2625 if (dir.deep) {2626 traverse(value);2627 }2628 bindings.push({2629 dir,2630 instance,2631 value,2632 oldValue: void 0,2633 arg,2634 modifiers2635 });2636 }2637 return vnode;2638}2639function invokeDirectiveHook(vnode, prevVNode, instance, name) {2640 const bindings = vnode.dirs;2641 const oldBindings = prevVNode && prevVNode.dirs;2642 for (let i = 0; i < bindings.length; i++) {2643 const binding = bindings[i];2644 if (oldBindings) {2645 binding.oldValue = oldBindings[i].value;2646 }2647 let hook = binding.dir[name];2648 if (hook) {2649 pauseTracking();2650 callWithAsyncErrorHandling(hook, instance, 8, [2651 vnode.el,2652 binding,2653 vnode,2654 prevVNode2655 ]);2656 resetTracking();2657 }2658 }2659}2660function createAppContext() {2661 return {2662 app: null,2663 config: {2664 isNativeTag: NO,2665 performance: false,2666 globalProperties: {},2667 optionMergeStrategies: {},2668 errorHandler: void 0,2669 warnHandler: void 0,2670 compilerOptions: {}2671 },2672 mixins: [],2673 components: {},2674 directives: {},2675 provides: /* @__PURE__ */ Object.create(null),2676 optionsCache: /* @__PURE__ */ new WeakMap(),2677 propsCache: /* @__PURE__ */ new WeakMap(),2678 emitsCache: /* @__PURE__ */ new WeakMap()2679 };2680}2681let uid = 0;2682function createAppAPI(render, hydrate) {2683 return function createApp2(rootComponent, rootProps = null) {2684 if (rootProps != null && !isObject(rootProps)) {2685 rootProps = null;2686 }2687 const context = createAppContext();2688 const installedPlugins = /* @__PURE__ */ new Set();2689 let isMounted = false;2690 const app = context.app = {2691 _uid: uid++,2692 _component: rootComponent,2693 _props: rootProps,2694 _container: null,2695 _context: context,2696 _instance: null,2697 version,2698 get config() {2699 return context.config;2700 },2701 set config(v) {2702 },2703 use(plugin, ...options) {2704 if (installedPlugins.has(plugin))2705 ;2706 else if (plugin && isFunction(plugin.install)) {2707 installedPlugins.add(plugin);2708 plugin.install(app, ...options);2709 } else if (isFunction(plugin)) {2710 installedPlugins.add(plugin);2711 plugin(app, ...options);2712 } else2713 ;2714 return app;2715 },2716 mixin(mixin) {2717 {2718 if (!context.mixins.includes(mixin)) {2719 context.mixins.push(mixin);2720 }2721 }2722 return app;2723 },2724 component(name, component) {2725 if (!component) {2726 return context.components[name];2727 }2728 context.components[name] = component;2729 return app;2730 },2731 directive(name, directive) {2732 if (!directive) {2733 return context.directives[name];2734 }2735 context.directives[name] = directive;2736 return app;2737 },2738 mount(rootContainer, isHydrate, isSVG) {2739 if (!isMounted) {2740 const vnode = createVNode(rootComponent, rootProps);2741 vnode.appContext = context;2742 if (isHydrate && hydrate) {2743 hydrate(vnode, rootContainer);2744 } else {2745 render(vnode, rootContainer, isSVG);2746 }2747 isMounted = true;2748 app._container = rootContainer;2749 rootContainer.__vue_app__ = app;2750 {2751 app._instance = vnode.component;2752 devtoolsInitApp(app, version);2753 }2754 return getExposeProxy(vnode.component) || vnode.component.proxy;2755 }2756 },2757 unmount() {2758 if (isMounted) {2759 render(null, app._container);2760 {2761 app._instance = null;2762 devtoolsUnmountApp(app);2763 }2764 delete app._container.__vue_app__;2765 }2766 },2767 provide(key, value) {2768 context.provides[key] = value;2769 return app;2770 }2771 };2772 return app;2773 };2774}2775function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {2776 if (isArray(rawRef)) {...

Full Screen

Full Screen

render.js

Source:render.js Github

copy

Full Screen

...138 unmount() {139 if (isMounted) {140 render(null, app._container);141 {142 devtoolsUnmountApp(app);143 }144 }145 else {146 warn(`Cannot unmount an app that is not mounted.`);147 }148 },149 provide(key, value) {150 if ( key in context.provides) {151 warn(`App already provides property with key "${String(key)}". ` +152 `It will be overwritten with the new value.`);153 }154 // TypeScript doesn't allow symbols as index type155 // https://github.com/Microsoft/TypeScript/issues/24587156 context.provides[key] = value;...

Full Screen

Full Screen

note.js

Source:note.js Github

copy

Full Screen

...114 unmount() {115 if (isMounted) {116 render(null, app._container);117 {118 devtoolsUnmountApp(app);119 }120 }121 else {122 warn(`Cannot unmount an app that is not mounted.`);123 }124 },125 provide(key, value) {126 if ( key in context.provides) {127 warn(`App already provides property with key "${String(key)}". ` +128 `It will be overwritten with the new value.`);129 }130 // TypeScript doesn't allow symbols as index type131 // https://github.com/Microsoft/TypeScript/issues/24587132 context.provides[key] = value;...

Full Screen

Full Screen

createApp.js

Source:createApp.js Github

copy

Full Screen

...172 unmount() {173 if (isMounted) {174 render(null, app._container);175 {176 devtoolsUnmountApp(app);177 }178 }179 else {180 warn(`Cannot unmount an app that is not mounted.`);181 }182 },183 provide(key, value) {184 if ( key in context.provides) {185 warn(`App already provides property with key "${String(key)}". ` +186 `It will be overwritten with the new value.`);187 }188 // TypeScript doesn't allow symbols as index type189 // https://github.com/Microsoft/TypeScript/issues/24587190 context.provides[key] = value;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.evaluate(() => {7 window['playwrightInternal'].devtoolsUnmountApp();8 });9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { devtools } = chromium;3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await devtools(devtools => devtools.unmountApp());8 await browser.close();9})();10const { chromium } = require('playwright');11const { devtools } = chromium;12(async () => {13 const browser = await chromium.launch();14 const context = await browser.newContext();15 const page = await context.newPage();16 await devtools(devtools => devtools.mountApp());17 await browser.close();18})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { devtoolsUnmountApp } = require('playwright/lib/server/inspector');2const { devtoolsMountApp } = require('playwright/lib/server/inspector');3devtoolsUnmountApp('test', { port: 9222, headless: false });4devtoolsUnmountApp('test1', { port: 9222, headless: false });5devtoolsUnmountApp('test2', { port: 9222, headless: false });6devtoolsUnmountApp('test3', { port: 9222, headless: false });

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { devtoolsUnmountApp } = require('playwright/lib/server/chromium/crApp');3(async () => {4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await devtoolsUnmountApp(page);8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const {devtoolsUnmountApp} = require('playwright/lib/server/chromium/crConnection');2devtoolsUnmountApp(appId);3const { chromium } = require('playwright');4const browser = await chromium.launch({ headless: false });5const context = await browser.newContext();6const page = await context.newPage();7const appId = await page.evaluate(() => {8 const app = document.createElement('my-app');9 document.body.appendChild(app);10 return app.appId;11});12await page.unmountApp(appId);13const { chromium } = require('playwright');14const browser = await chromium.launch({ headless: false });15const context = await browser.newContext();16const page = await context.newPage();17const appId = await page.evaluate(() => {18 const app = document.createElement('my-app');19 document.body.appendChild(app);20 return app.appId;21});22await page.unmountApp(appId);

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful