Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/.vite/deps/react-router-dom.js
rd565449 r0c6b92a 1 1 import { 2 2 require_react_dom 3 } from "./chunk- 6VWAHX6D.js";3 } from "./chunk-GKJBSOWT.js"; 4 4 import { 5 5 require_react … … 1077 1077 let inFlightDataRoutes; 1078 1078 let basename = init.basename || "/"; 1079 let dataStrategyImpl = init. unstable_dataStrategy || defaultDataStrategy;1080 let patchRoutesOn MissImpl = init.unstable_patchRoutesOnMiss;1079 let dataStrategyImpl = init.dataStrategy || defaultDataStrategy; 1080 let patchRoutesOnNavigationImpl = init.patchRoutesOnNavigation; 1081 1081 let future = _extends({ 1082 1082 v7_fetcherPersist: false, … … 1095 1095 let initialMatches = matchRoutes(dataRoutes, init.history.location, basename); 1096 1096 let initialErrors = null; 1097 if (initialMatches == null && !patchRoutesOn MissImpl) {1097 if (initialMatches == null && !patchRoutesOnNavigationImpl) { 1098 1098 let error = getInternalRouterError(404, { 1099 1099 pathname: init.history.location.pathname … … 1131 1131 let loaderData = init.hydrationData ? init.hydrationData.loaderData : null; 1132 1132 let errors = init.hydrationData ? init.hydrationData.errors : null; 1133 let isRouteInitialized = (m) => {1134 if (!m.route.loader) {1135 return true;1136 }1137 if (typeof m.route.loader === "function" && m.route.loader.hydrate === true) {1138 return false;1139 }1140 return loaderData && loaderData[m.route.id] !== void 0 || errors && errors[m.route.id] !== void 0;1141 };1142 1133 if (errors) { 1143 1134 let idx = initialMatches.findIndex((m) => errors[m.route.id] !== void 0); 1144 initialized = initialMatches.slice(0, idx + 1).every( isRouteInitialized);1135 initialized = initialMatches.slice(0, idx + 1).every((m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)); 1145 1136 } else { 1146 initialized = initialMatches.every( isRouteInitialized);1137 initialized = initialMatches.every((m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)); 1147 1138 } 1148 1139 } else { … … 1186 1177 let activeDeferreds = /* @__PURE__ */ new Map(); 1187 1178 let blockerFunctions = /* @__PURE__ */ new Map(); 1188 let pendingPatchRoutes = /* @__PURE__ */ new Map(); 1189 let ignoreNextHistoryUpdate = false; 1179 let unblockBlockerHistoryUpdate = void 0; 1190 1180 function initialize() { 1191 1181 unlistenHistory = init.history.listen((_ref) => { … … 1195 1185 delta 1196 1186 } = _ref; 1197 if (ignoreNextHistoryUpdate) { 1198 ignoreNextHistoryUpdate = false; 1187 if (unblockBlockerHistoryUpdate) { 1188 unblockBlockerHistoryUpdate(); 1189 unblockBlockerHistoryUpdate = void 0; 1199 1190 return; 1200 1191 } … … 1206 1197 }); 1207 1198 if (blockerKey && delta != null) { 1208 ignoreNextHistoryUpdate = true; 1199 let nextHistoryUpdatePromise = new Promise((resolve) => { 1200 unblockBlockerHistoryUpdate = resolve; 1201 }); 1209 1202 init.history.go(delta * -1); 1210 1203 updateBlocker(blockerKey, { … … 1218 1211 location 1219 1212 }); 1220 init.history.go(delta);1213 nextHistoryUpdatePromise.then(() => init.history.go(delta)); 1221 1214 }, 1222 1215 reset() { … … 1281 1274 [...subscribers].forEach((subscriber) => subscriber(state, { 1282 1275 deletedFetchers: deletedFetchersKeys, 1283 unstable_viewTransitionOpts: opts.viewTransitionOpts,1284 unstable_flushSync: opts.flushSync === true1276 viewTransitionOpts: opts.viewTransitionOpts, 1277 flushSync: opts.flushSync === true 1285 1278 })); 1286 1279 if (future.v7_fetcherPersist) { … … 1397 1390 } 1398 1391 let preventScrollReset = opts && "preventScrollReset" in opts ? opts.preventScrollReset === true : void 0; 1399 let flushSync = (opts && opts. unstable_flushSync) === true;1392 let flushSync = (opts && opts.flushSync) === true; 1400 1393 let blockerKey = shouldBlockNavigation({ 1401 1394 currentLocation, … … 1433 1426 preventScrollReset, 1434 1427 replace: opts && opts.replace, 1435 enableViewTransition: opts && opts. unstable_viewTransition,1428 enableViewTransition: opts && opts.viewTransition, 1436 1429 flushSync 1437 1430 }); … … 1452 1445 } 1453 1446 startNavigation(pendingAction || state.historyAction, state.navigation.location, { 1454 overrideNavigation: state.navigation 1447 overrideNavigation: state.navigation, 1448 // Proxy through any rending view transition 1449 enableViewTransition: pendingViewTransitionEnabled === true 1455 1450 }); 1456 1451 } … … 1568 1563 }; 1569 1564 } else if (discoverResult.type === "error") { 1570 let { 1571 boundaryId, 1572 error 1573 } = handleDiscoverRouteError(location.pathname, discoverResult); 1565 let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id; 1574 1566 return { 1575 1567 matches: discoverResult.partialMatches, 1576 1568 pendingActionResult: [boundaryId, { 1577 1569 type: ResultType.error, 1578 error 1570 error: discoverResult.error 1579 1571 }] 1580 1572 }; … … 1608 1600 }; 1609 1601 } else { 1610 let results = await callDataStrategy("action", request, [actionMatch], matches);1611 result = results[ 0];1602 let results = await callDataStrategy("action", state, request, [actionMatch], matches, null); 1603 result = results[actionMatch.route.id]; 1612 1604 if (request.signal.aborted) { 1613 1605 return { … … 1624 1616 replace2 = location2 === state.location.pathname + state.location.search; 1625 1617 } 1626 await startRedirectNavigation(request, result, {1618 await startRedirectNavigation(request, result, true, { 1627 1619 submission, 1628 1620 replace: replace2 … … 1673 1665 }; 1674 1666 } else if (discoverResult.type === "error") { 1675 let { 1676 boundaryId, 1677 error 1678 } = handleDiscoverRouteError(location.pathname, discoverResult); 1667 let boundaryId = findNearestBoundary(discoverResult.partialMatches).route.id; 1679 1668 return { 1680 1669 matches: discoverResult.partialMatches, 1681 1670 loaderData: {}, 1682 1671 errors: { 1683 [boundaryId]: error1672 [boundaryId]: discoverResult.error 1684 1673 } 1685 1674 }; … … 1740 1729 } 1741 1730 revalidatingFetchers.forEach((rf) => { 1742 if (fetchControllers.has(rf.key)) { 1743 abortFetcher(rf.key); 1744 } 1731 abortFetcher(rf.key); 1745 1732 if (rf.controller) { 1746 1733 fetchControllers.set(rf.key, rf.controller); … … 1754 1741 loaderResults, 1755 1742 fetcherResults 1756 } = await callLoadersAndMaybeResolveData(state .matches, matches, matchesToLoad, revalidatingFetchers, request);1743 } = await callLoadersAndMaybeResolveData(state, matches, matchesToLoad, revalidatingFetchers, request); 1757 1744 if (request.signal.aborted) { 1758 1745 return { … … 1764 1751 } 1765 1752 revalidatingFetchers.forEach((rf) => fetchControllers.delete(rf.key)); 1766 let redirect3 = findRedirect( [...loaderResults, ...fetcherResults]);1753 let redirect3 = findRedirect(loaderResults); 1767 1754 if (redirect3) { 1768 if (redirect3.idx >= matchesToLoad.length) { 1769 let fetcherKey = revalidatingFetchers[redirect3.idx - matchesToLoad.length].key; 1770 fetchRedirectIds.add(fetcherKey); 1771 } 1772 await startRedirectNavigation(request, redirect3.result, { 1755 await startRedirectNavigation(request, redirect3.result, true, { 1773 1756 replace: replace2 1774 1757 }); … … 1777 1760 }; 1778 1761 } 1762 redirect3 = findRedirect(fetcherResults); 1763 if (redirect3) { 1764 fetchRedirectIds.add(redirect3.key); 1765 await startRedirectNavigation(request, redirect3.result, true, { 1766 replace: replace2 1767 }); 1768 return { 1769 shortCircuited: true 1770 }; 1771 } 1779 1772 let { 1780 1773 loaderData, 1781 1774 errors 1782 } = processLoaderData(state, matches, matchesToLoad,loaderResults, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds);1775 } = processLoaderData(state, matches, loaderResults, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds); 1783 1776 activeDeferreds.forEach((deferredData, routeId) => { 1784 1777 deferredData.subscribe((aborted) => { … … 1789 1782 }); 1790 1783 if (future.v7_partialHydration && initialHydration && state.errors) { 1791 Object.entries(state.errors).filter((_ref2) => { 1792 let [id] = _ref2; 1793 return !matchesToLoad.some((m) => m.route.id === id); 1794 }).forEach((_ref3) => { 1795 let [routeId, error] = _ref3; 1796 errors = Object.assign(errors || {}, { 1797 [routeId]: error 1798 }); 1799 }); 1784 errors = _extends({}, state.errors, errors); 1800 1785 } 1801 1786 let updatedFetchers = markFetchRedirectsDone(); … … 1835 1820 throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback."); 1836 1821 } 1837 if (fetchControllers.has(key))abortFetcher(key);1838 let flushSync = (opts && opts. unstable_flushSync) === true;1822 abortFetcher(key); 1823 let flushSync = (opts && opts.flushSync) === true; 1839 1824 let routesToUse = inFlightDataRoutes || dataRoutes; 1840 1825 let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, href, future.v7_relativeSplatPath, routeId, opts == null ? void 0 : opts.relative); … … 1864 1849 } 1865 1850 let match = getTargetMatch(matches, path); 1866 pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;1851 let preventScrollReset = (opts && opts.preventScrollReset) === true; 1867 1852 if (submission && isMutationMethod(submission.formMethod)) { 1868 handleFetcherAction(key, routeId, path, match, matches, fogOfWar.active, flushSync, submission);1853 handleFetcherAction(key, routeId, path, match, matches, fogOfWar.active, flushSync, preventScrollReset, submission); 1869 1854 return; 1870 1855 } … … 1873 1858 path 1874 1859 }); 1875 handleFetcherLoader(key, routeId, path, match, matches, fogOfWar.active, flushSync, submission);1876 } 1877 async function handleFetcherAction(key, routeId, path, match, requestMatches, isFogOfWar, flushSync, submission) {1860 handleFetcherLoader(key, routeId, path, match, matches, fogOfWar.active, flushSync, preventScrollReset, submission); 1861 } 1862 async function handleFetcherAction(key, routeId, path, match, requestMatches, isFogOfWar, flushSync, preventScrollReset, submission) { 1878 1863 interruptActiveLoads(); 1879 1864 fetchLoadMatches.delete(key); … … 1906 1891 return; 1907 1892 } else if (discoverResult.type === "error") { 1908 let { 1909 error 1910 } = handleDiscoverRouteError(path, discoverResult); 1911 setFetcherError(key, routeId, error, { 1893 setFetcherError(key, routeId, discoverResult.error, { 1912 1894 flushSync 1913 1895 }); … … 1930 1912 fetchControllers.set(key, abortController); 1931 1913 let originatingLoadId = incrementingLoadId; 1932 let actionResults = await callDataStrategy("action", fetchRequest, [match], requestMatches);1933 let actionResult = actionResults[ 0];1914 let actionResults = await callDataStrategy("action", state, fetchRequest, [match], requestMatches, key); 1915 let actionResult = actionResults[match.route.id]; 1934 1916 if (fetchRequest.signal.aborted) { 1935 1917 if (fetchControllers.get(key) === abortController) { … … 1952 1934 fetchRedirectIds.add(key); 1953 1935 updateFetcherState(key, getLoadingFetcher(submission)); 1954 return startRedirectNavigation(fetchRequest, actionResult, { 1955 fetcherSubmission: submission 1936 return startRedirectNavigation(fetchRequest, actionResult, false, { 1937 fetcherSubmission: submission, 1938 preventScrollReset 1956 1939 }); 1957 1940 } … … 1982 1965 let revalidatingFetcher = getLoadingFetcher(void 0, existingFetcher2 ? existingFetcher2.data : void 0); 1983 1966 state.fetchers.set(staleKey, revalidatingFetcher); 1984 if (fetchControllers.has(staleKey)) { 1985 abortFetcher(staleKey); 1986 } 1967 abortFetcher(staleKey); 1987 1968 if (rf.controller) { 1988 1969 fetchControllers.set(staleKey, rf.controller); … … 1997 1978 loaderResults, 1998 1979 fetcherResults 1999 } = await callLoadersAndMaybeResolveData(state .matches, matches, matchesToLoad, revalidatingFetchers, revalidationRequest);1980 } = await callLoadersAndMaybeResolveData(state, matches, matchesToLoad, revalidatingFetchers, revalidationRequest); 2000 1981 if (abortController.signal.aborted) { 2001 1982 return; … … 2005 1986 fetchControllers.delete(key); 2006 1987 revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key)); 2007 let redirect3 = findRedirect( [...loaderResults, ...fetcherResults]);1988 let redirect3 = findRedirect(loaderResults); 2008 1989 if (redirect3) { 2009 if (redirect3.idx >= matchesToLoad.length) { 2010 let fetcherKey = revalidatingFetchers[redirect3.idx - matchesToLoad.length].key; 2011 fetchRedirectIds.add(fetcherKey); 2012 } 2013 return startRedirectNavigation(revalidationRequest, redirect3.result); 1990 return startRedirectNavigation(revalidationRequest, redirect3.result, false, { 1991 preventScrollReset 1992 }); 1993 } 1994 redirect3 = findRedirect(fetcherResults); 1995 if (redirect3) { 1996 fetchRedirectIds.add(redirect3.key); 1997 return startRedirectNavigation(revalidationRequest, redirect3.result, false, { 1998 preventScrollReset 1999 }); 2014 2000 } 2015 2001 let { 2016 2002 loaderData, 2017 2003 errors 2018 } = processLoaderData(state, state.matches, matchesToLoad, loaderResults, void 0, revalidatingFetchers, fetcherResults, activeDeferreds);2004 } = processLoaderData(state, matches, loaderResults, void 0, revalidatingFetchers, fetcherResults, activeDeferreds); 2019 2005 if (state.fetchers.has(key)) { 2020 2006 let doneFetcher = getDoneFetcher(actionResult.data); … … 2040 2026 } 2041 2027 } 2042 async function handleFetcherLoader(key, routeId, path, match, matches, isFogOfWar, flushSync, submission) {2028 async function handleFetcherLoader(key, routeId, path, match, matches, isFogOfWar, flushSync, preventScrollReset, submission) { 2043 2029 let existingFetcher = state.fetchers.get(key); 2044 2030 updateFetcherState(key, getLoadingFetcher(submission, existingFetcher ? existingFetcher.data : void 0), { … … 2052 2038 return; 2053 2039 } else if (discoverResult.type === "error") { 2054 let { 2055 error 2056 } = handleDiscoverRouteError(path, discoverResult); 2057 setFetcherError(key, routeId, error, { 2040 setFetcherError(key, routeId, discoverResult.error, { 2058 2041 flushSync 2059 2042 }); … … 2073 2056 fetchControllers.set(key, abortController); 2074 2057 let originatingLoadId = incrementingLoadId; 2075 let results = await callDataStrategy("loader", fetchRequest, [match], matches);2076 let result = results[ 0];2058 let results = await callDataStrategy("loader", state, fetchRequest, [match], matches, key); 2059 let result = results[match.route.id]; 2077 2060 if (isDeferredResult(result)) { 2078 2061 result = await resolveDeferredData(result, fetchRequest.signal, true) || result; … … 2094 2077 } else { 2095 2078 fetchRedirectIds.add(key); 2096 await startRedirectNavigation(fetchRequest, result); 2079 await startRedirectNavigation(fetchRequest, result, false, { 2080 preventScrollReset 2081 }); 2097 2082 return; 2098 2083 } … … 2105 2090 updateFetcherState(key, getDoneFetcher(result.data)); 2106 2091 } 2107 async function startRedirectNavigation(request, redirect3, _temp2) {2092 async function startRedirectNavigation(request, redirect3, isNavigation, _temp2) { 2108 2093 let { 2109 2094 submission, 2110 2095 fetcherSubmission, 2096 preventScrollReset, 2111 2097 replace: replace2 2112 2098 } = _temp2 === void 0 ? {} : _temp2; … … 2155 2141 formAction: location 2156 2142 }), 2157 // Preserve this flag across redirects 2158 preventScrollReset: pendingPreventScrollReset 2143 // Preserve these flags across redirects 2144 preventScrollReset: preventScrollReset || pendingPreventScrollReset, 2145 enableViewTransition: isNavigation ? pendingViewTransitionEnabled : void 0 2159 2146 }); 2160 2147 } else { … … 2164 2151 // Send fetcher submissions through for shouldRevalidate 2165 2152 fetcherSubmission, 2166 // Preserve this flag across redirects 2167 preventScrollReset: pendingPreventScrollReset 2168 }); 2169 } 2170 } 2171 async function callDataStrategy(type, request, matchesToLoad, matches) { 2153 // Preserve these flags across redirects 2154 preventScrollReset: preventScrollReset || pendingPreventScrollReset, 2155 enableViewTransition: isNavigation ? pendingViewTransitionEnabled : void 0 2156 }); 2157 } 2158 } 2159 async function callDataStrategy(type, state2, request, matchesToLoad, matches, fetcherKey) { 2160 let results; 2161 let dataResults = {}; 2172 2162 try { 2173 let results = await callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, manifest, mapRouteProperties2); 2174 return await Promise.all(results.map((result, i) => { 2175 if (isRedirectHandlerResult(result)) { 2176 let response = result.result; 2177 return { 2178 type: ResultType.redirect, 2179 response: normalizeRelativeRoutingRedirectResponse(response, request, matchesToLoad[i].route.id, matches, basename, future.v7_relativeSplatPath) 2180 }; 2181 } 2182 return convertHandlerResultToDataResult(result); 2183 })); 2163 results = await callDataStrategyImpl(dataStrategyImpl, type, state2, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2); 2184 2164 } catch (e) { 2185 return matchesToLoad.map(() => ({ 2186 type: ResultType.error, 2187 error: e 2188 })); 2189 } 2190 } 2191 async function callLoadersAndMaybeResolveData(currentMatches, matches, matchesToLoad, fetchersToLoad, request) { 2192 let [loaderResults, ...fetcherResults] = await Promise.all([matchesToLoad.length ? callDataStrategy("loader", request, matchesToLoad, matches) : [], ...fetchersToLoad.map((f) => { 2165 matchesToLoad.forEach((m) => { 2166 dataResults[m.route.id] = { 2167 type: ResultType.error, 2168 error: e 2169 }; 2170 }); 2171 return dataResults; 2172 } 2173 for (let [routeId, result] of Object.entries(results)) { 2174 if (isRedirectDataStrategyResultResult(result)) { 2175 let response = result.result; 2176 dataResults[routeId] = { 2177 type: ResultType.redirect, 2178 response: normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename, future.v7_relativeSplatPath) 2179 }; 2180 } else { 2181 dataResults[routeId] = await convertDataStrategyResultToDataResult(result); 2182 } 2183 } 2184 return dataResults; 2185 } 2186 async function callLoadersAndMaybeResolveData(state2, matches, matchesToLoad, fetchersToLoad, request) { 2187 let currentMatches = state2.matches; 2188 let loaderResultsPromise = callDataStrategy("loader", state2, request, matchesToLoad, matches, null); 2189 let fetcherResultsPromise = Promise.all(fetchersToLoad.map(async (f) => { 2193 2190 if (f.matches && f.match && f.controller) { 2194 let fetcherRequest = createClientSideRequest(init.history, f.path, f.controller.signal); 2195 return callDataStrategy("loader", fetcherRequest, [f.match], f.matches).then((r) => r[0]); 2191 let results = await callDataStrategy("loader", state2, createClientSideRequest(init.history, f.path, f.controller.signal), [f.match], f.matches, f.key); 2192 let result = results[f.match.route.id]; 2193 return { 2194 [f.key]: result 2195 }; 2196 2196 } else { 2197 2197 return Promise.resolve({ 2198 type: ResultType.error, 2199 error: getInternalRouterError(404, { 2200 pathname: f.path 2201 }) 2198 [f.key]: { 2199 type: ResultType.error, 2200 error: getInternalRouterError(404, { 2201 pathname: f.path 2202 }) 2203 } 2202 2204 }); 2203 2205 } 2204 })]); 2205 await Promise.all([resolveDeferredResults(currentMatches, matchesToLoad, loaderResults, loaderResults.map(() => request.signal), false, state.loaderData), resolveDeferredResults(currentMatches, fetchersToLoad.map((f) => f.match), fetcherResults, fetchersToLoad.map((f) => f.controller ? f.controller.signal : null), true)]); 2206 })); 2207 let loaderResults = await loaderResultsPromise; 2208 let fetcherResults = (await fetcherResultsPromise).reduce((acc, r) => Object.assign(acc, r), {}); 2209 await Promise.all([resolveNavigationDeferredResults(matches, loaderResults, request.signal, currentMatches, state2.loaderData), resolveFetcherDeferredResults(matches, fetcherResults, fetchersToLoad)]); 2206 2210 return { 2207 2211 loaderResults, … … 2215 2219 if (fetchControllers.has(key)) { 2216 2220 cancelledFetcherLoads.add(key); 2217 abortFetcher(key);2218 }2221 } 2222 abortFetcher(key); 2219 2223 }); 2220 2224 } … … 2284 2288 function abortFetcher(key) { 2285 2289 let controller = fetchControllers.get(key); 2286 invariant(controller, "Expected fetch controller: " + key); 2287 controller.abort(); 2288 fetchControllers.delete(key); 2290 if (controller) { 2291 controller.abort(); 2292 fetchControllers.delete(key); 2293 } 2289 2294 } 2290 2295 function markFetchersDone(keys) { … … 2346 2351 }); 2347 2352 } 2348 function shouldBlockNavigation(_ref 4) {2353 function shouldBlockNavigation(_ref2) { 2349 2354 let { 2350 2355 currentLocation, 2351 2356 nextLocation, 2352 2357 historyAction 2353 } = _ref 4;2358 } = _ref2; 2354 2359 if (blockerFunctions.size === 0) { 2355 2360 return; … … 2388 2393 }; 2389 2394 } 2390 function handleDiscoverRouteError(pathname, discoverResult) {2391 return {2392 boundaryId: findNearestBoundary(discoverResult.partialMatches).route.id,2393 error: getInternalRouterError(400, {2394 type: "route-discovery",2395 pathname,2396 message: discoverResult.error != null && "message" in discoverResult.error ? discoverResult.error : String(discoverResult.error)2397 })2398 };2399 }2400 2395 function cancelActiveDeferreds(predicate) { 2401 2396 let cancelledRouteIds = []; … … 2452 2447 } 2453 2448 function checkFogOfWar(matches, routesToUse, pathname) { 2454 if (patchRoutesOn MissImpl) {2449 if (patchRoutesOnNavigationImpl) { 2455 2450 if (!matches) { 2456 2451 let fogMatches = matchRoutesImpl(routesToUse, pathname, basename, true); … … 2460 2455 }; 2461 2456 } else { 2462 let leafRoute = matches[matches.length - 1].route; 2463 if (leafRoute.path && (leafRoute.path === "*" || leafRoute.path.endsWith("/*"))) { 2457 if (Object.keys(matches[0].params).length > 0) { 2464 2458 let partialMatches = matchRoutesImpl(routesToUse, pathname, basename, true); 2465 2459 return { … … 2476 2470 } 2477 2471 async function discoverRoutes(matches, pathname, signal) { 2472 if (!patchRoutesOnNavigationImpl) { 2473 return { 2474 type: "success", 2475 matches 2476 }; 2477 } 2478 2478 let partialMatches = matches; 2479 let route = partialMatches.length > 0 ? partialMatches[partialMatches.length - 1].route : null;2480 2479 while (true) { 2481 2480 let isNonHMR = inFlightDataRoutes == null; 2482 2481 let routesToUse = inFlightDataRoutes || dataRoutes; 2482 let localManifest = manifest; 2483 2483 try { 2484 await loadLazyRouteChildren(patchRoutesOnMissImpl, pathname, partialMatches, routesToUse, manifest, mapRouteProperties2, pendingPatchRoutes, signal); 2484 await patchRoutesOnNavigationImpl({ 2485 path: pathname, 2486 matches: partialMatches, 2487 patch: (routeId, children) => { 2488 if (signal.aborted) return; 2489 patchRoutesImpl(routeId, children, routesToUse, localManifest, mapRouteProperties2); 2490 } 2491 }); 2485 2492 } catch (e) { 2486 2493 return { … … 2490 2497 }; 2491 2498 } finally { 2492 if (isNonHMR ) {2499 if (isNonHMR && !signal.aborted) { 2493 2500 dataRoutes = [...dataRoutes]; 2494 2501 } … … 2500 2507 } 2501 2508 let newMatches = matchRoutes(routesToUse, pathname, basename); 2502 let matchedSplat = false;2503 2509 if (newMatches) { 2504 let leafRoute = newMatches[newMatches.length - 1].route;2505 if (leafRoute.index) {2506 return {2507 type: "success",2508 matches: newMatches2509 };2510 }2511 if (leafRoute.path && leafRoute.path.length > 0) {2512 if (leafRoute.path === "*") {2513 matchedSplat = true;2514 } else {2515 return {2516 type: "success",2517 matches: newMatches2518 };2519 }2520 }2521 }2522 let newPartialMatches = matchRoutesImpl(routesToUse, pathname, basename, true);2523 if (!newPartialMatches || partialMatches.map((m) => m.route.id).join("-") === newPartialMatches.map((m) => m.route.id).join("-")) {2524 2510 return { 2525 2511 type: "success", 2526 matches: matchedSplat ? newMatches : null2512 matches: newMatches 2527 2513 }; 2528 2514 } 2529 partialMatches = newPartialMatches; 2530 route = partialMatches[partialMatches.length - 1].route; 2531 if (route.path === "*") { 2515 let newPartialMatches = matchRoutesImpl(routesToUse, pathname, basename, true); 2516 if (!newPartialMatches || partialMatches.length === newPartialMatches.length && partialMatches.every((m, i) => m.route.id === newPartialMatches[i].route.id)) { 2532 2517 return { 2533 2518 type: "success", 2534 matches: partialMatches2519 matches: null 2535 2520 }; 2536 2521 } 2522 partialMatches = newPartialMatches; 2537 2523 } 2538 2524 } … … 2615 2601 path.hash = location.hash; 2616 2602 } 2617 if ((to == null || to === "" || to === ".") && activeRouteMatch && activeRouteMatch.route.index && !hasNakedIndexQuery(path.search)) { 2618 path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index"; 2603 if ((to == null || to === "" || to === ".") && activeRouteMatch) { 2604 let nakedIndex = hasNakedIndexQuery(path.search); 2605 if (activeRouteMatch.route.index && !nakedIndex) { 2606 path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index"; 2607 } else if (!activeRouteMatch.route.index && nakedIndex) { 2608 let params = new URLSearchParams(path.search); 2609 let indexValues = params.getAll("index"); 2610 params.delete("index"); 2611 indexValues.filter((v) => v).forEach((v) => params.append("index", v)); 2612 let qs = params.toString(); 2613 path.search = qs ? "?" + qs : ""; 2614 } 2619 2615 } 2620 2616 if (prependBasename && basename !== "/") { … … 2653 2649 let text = typeof opts.body === "string" ? opts.body : opts.body instanceof FormData || opts.body instanceof URLSearchParams ? ( 2654 2650 // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data 2655 Array.from(opts.body.entries()).reduce((acc, _ref 5) => {2656 let [name, value] = _ref 5;2651 Array.from(opts.body.entries()).reduce((acc, _ref3) => { 2652 let [name, value] = _ref3; 2657 2653 return "" + acc + name + "=" + value + "\n"; 2658 2654 }, "") … … 2738 2734 }; 2739 2735 } 2740 function getLoaderMatchesUntilBoundary(matches, boundaryId ) {2741 let boundaryMatches = matches;2742 if (boundaryId) {2743 let index = matches.findIndex((m) => m.route.id === boundaryId);2744 if (index >= 0) {2745 boundaryMatches = matches.slice(0, index);2746 }2747 } 2748 return boundaryMatches;2749 } 2750 function getMatchesToLoad(history, state, matches, submission, location, i sInitialLoad, skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {2736 function getLoaderMatchesUntilBoundary(matches, boundaryId, includeBoundary) { 2737 if (includeBoundary === void 0) { 2738 includeBoundary = false; 2739 } 2740 let index = matches.findIndex((m) => m.route.id === boundaryId); 2741 if (index >= 0) { 2742 return matches.slice(0, includeBoundary ? index + 1 : index); 2743 } 2744 return matches; 2745 } 2746 function getMatchesToLoad(history, state, matches, submission, location, initialHydration, skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) { 2751 2747 let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0; 2752 2748 let currentUrl = history.createURL(state.location); 2753 2749 let nextUrl = history.createURL(location); 2754 let boundaryId = pendingActionResult && isErrorResult(pendingActionResult[1]) ? pendingActionResult[0] : void 0; 2755 let boundaryMatches = boundaryId ? getLoaderMatchesUntilBoundary(matches, boundaryId) : matches; 2750 let boundaryMatches = matches; 2751 if (initialHydration && state.errors) { 2752 boundaryMatches = getLoaderMatchesUntilBoundary(matches, Object.keys(state.errors)[0], true); 2753 } else if (pendingActionResult && isErrorResult(pendingActionResult[1])) { 2754 boundaryMatches = getLoaderMatchesUntilBoundary(matches, pendingActionResult[0]); 2755 } 2756 2756 let actionStatus = pendingActionResult ? pendingActionResult[1].statusCode : void 0; 2757 2757 let shouldSkipRevalidation = skipActionErrorRevalidation && actionStatus && actionStatus >= 400; … … 2766 2766 return false; 2767 2767 } 2768 if (isInitialLoad) { 2769 if (typeof route.loader !== "function" || route.loader.hydrate) { 2770 return true; 2771 } 2772 return state.loaderData[route.id] === void 0 && // Don't re-run if the loader ran and threw an error 2773 (!state.errors || state.errors[route.id] === void 0); 2768 if (initialHydration) { 2769 return shouldLoadRouteOnHydration(route, state.loaderData, state.errors); 2774 2770 } 2775 2771 if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some((id) => id === match.route.id)) { … … 2795 2791 let revalidatingFetchers = []; 2796 2792 fetchLoadMatches.forEach((f, key) => { 2797 if (i sInitialLoad|| !matches.some((m) => m.route.id === f.routeId) || deletedFetchers.has(key)) {2793 if (initialHydration || !matches.some((m) => m.route.id === f.routeId) || deletedFetchers.has(key)) { 2798 2794 return; 2799 2795 } … … 2845 2841 return [navigationMatches, revalidatingFetchers]; 2846 2842 } 2843 function shouldLoadRouteOnHydration(route, loaderData, errors) { 2844 if (route.lazy) { 2845 return true; 2846 } 2847 if (!route.loader) { 2848 return false; 2849 } 2850 let hasData = loaderData != null && loaderData[route.id] !== void 0; 2851 let hasError = errors != null && errors[route.id] !== void 0; 2852 if (!hasData && hasError) { 2853 return false; 2854 } 2855 if (typeof route.loader === "function" && route.loader.hydrate === true) { 2856 return true; 2857 } 2858 return !hasData && !hasError; 2859 } 2847 2860 function isNewLoader(currentLoaderData, currentMatch, match) { 2848 2861 let isNew = ( … … 2872 2885 return arg.defaultShouldRevalidate; 2873 2886 } 2874 async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, routes, manifest, mapRouteProperties2, pendingRouteChildren, signal) {2875 let key = [path, ...matches.map((m) => m.route.id)].join("-");2876 try {2877 let pending = pendingRouteChildren.get(key);2878 if (!pending) {2879 pending = patchRoutesOnMissImpl({2880 path,2881 matches,2882 patch: (routeId, children) => {2883 if (!signal.aborted) {2884 patchRoutesImpl(routeId, children, routes, manifest, mapRouteProperties2);2885 }2886 }2887 });2888 pendingRouteChildren.set(key, pending);2889 }2890 if (pending && isPromise(pending)) {2891 await pending;2892 }2893 } finally {2894 pendingRouteChildren.delete(key);2895 }2896 }2897 2887 function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) { 2888 var _childrenToPatch; 2889 let childrenToPatch; 2898 2890 if (routeId) { 2899 var _route$children;2900 2891 let route = manifest[routeId]; 2901 2892 invariant(route, "No route found to patch children into: routeId = " + routeId); 2902 let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties2, [routeId, "patch", String(((_route$children = route.children) == null ? void 0 : _route$children.length) || "0")], manifest); 2903 if (route.children) { 2904 route.children.push(...dataChildren); 2905 } else { 2906 route.children = dataChildren; 2907 } 2893 if (!route.children) { 2894 route.children = []; 2895 } 2896 childrenToPatch = route.children; 2908 2897 } else { 2909 let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties2, ["patch", String(routesToUse.length || "0")], manifest); 2910 routesToUse.push(...dataChildren); 2911 } 2898 childrenToPatch = routesToUse; 2899 } 2900 let uniqueChildren = children.filter((newRoute) => !childrenToPatch.some((existingRoute) => isSameRoute(newRoute, existingRoute))); 2901 let newRoutes = convertRoutesToDataRoutes(uniqueChildren, mapRouteProperties2, [routeId || "_", "patch", String(((_childrenToPatch = childrenToPatch) == null ? void 0 : _childrenToPatch.length) || "0")], manifest); 2902 childrenToPatch.push(...newRoutes); 2903 } 2904 function isSameRoute(newRoute, existingRoute) { 2905 if ("id" in newRoute && "id" in existingRoute && newRoute.id === existingRoute.id) { 2906 return true; 2907 } 2908 if (!(newRoute.index === existingRoute.index && newRoute.path === existingRoute.path && newRoute.caseSensitive === existingRoute.caseSensitive)) { 2909 return false; 2910 } 2911 if ((!newRoute.children || newRoute.children.length === 0) && (!existingRoute.children || existingRoute.children.length === 0)) { 2912 return true; 2913 } 2914 return newRoute.children.every((aChild, i) => { 2915 var _existingRoute$childr; 2916 return (_existingRoute$childr = existingRoute.children) == null ? void 0 : _existingRoute$childr.some((bChild) => isSameRoute(aChild, bChild)); 2917 }); 2912 2918 } 2913 2919 async function loadLazyRouteModule(route, mapRouteProperties2, manifest) { … … 2937 2943 })); 2938 2944 } 2939 function defaultDataStrategy(opts) { 2940 return Promise.all(opts.matches.map((m) => m.resolve())); 2941 } 2942 async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, manifest, mapRouteProperties2, requestContext) { 2943 let routeIdsToLoad = matchesToLoad.reduce((acc, m) => acc.add(m.route.id), /* @__PURE__ */ new Set()); 2944 let loadedMatches = /* @__PURE__ */ new Set(); 2945 async function defaultDataStrategy(_ref4) { 2946 let { 2947 matches 2948 } = _ref4; 2949 let matchesToLoad = matches.filter((m) => m.shouldLoad); 2950 let results = await Promise.all(matchesToLoad.map((m) => m.resolve())); 2951 return results.reduce((acc, result, i) => Object.assign(acc, { 2952 [matchesToLoad[i].route.id]: result 2953 }), {}); 2954 } 2955 async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, requestContext) { 2956 let loadRouteDefinitionsPromises = matches.map((m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties2, manifest) : void 0); 2957 let dsMatches = matches.map((match, i) => { 2958 let loadRoutePromise = loadRouteDefinitionsPromises[i]; 2959 let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id); 2960 let resolve = async (handlerOverride) => { 2961 if (handlerOverride && request.method === "GET" && (match.route.lazy || match.route.loader)) { 2962 shouldLoad = true; 2963 } 2964 return shouldLoad ? callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, requestContext) : Promise.resolve({ 2965 type: ResultType.data, 2966 result: void 0 2967 }); 2968 }; 2969 return _extends({}, match, { 2970 shouldLoad, 2971 resolve 2972 }); 2973 }); 2945 2974 let results = await dataStrategyImpl({ 2946 matches: matches.map((match) => { 2947 let shouldLoad = routeIdsToLoad.has(match.route.id); 2948 let resolve = (handlerOverride) => { 2949 loadedMatches.add(match.route.id); 2950 return shouldLoad ? callLoaderOrAction(type, request, match, manifest, mapRouteProperties2, handlerOverride, requestContext) : Promise.resolve({ 2951 type: ResultType.data, 2952 result: void 0 2953 }); 2954 }; 2955 return _extends({}, match, { 2956 shouldLoad, 2957 resolve 2958 }); 2959 }), 2975 matches: dsMatches, 2960 2976 request, 2961 2977 params: matches[0].params, 2978 fetcherKey, 2962 2979 context: requestContext 2963 2980 }); 2964 matches.forEach((m) => invariant(loadedMatches.has(m.route.id), '`match.resolve()` was not called for route id "' + m.route.id + '". You must call `match.resolve()` on every match passed to `dataStrategy` to ensure all routes are properly loaded.')); 2965 return results.filter((_, i) => routeIdsToLoad.has(matches[i].route.id)); 2966 } 2967 async function callLoaderOrAction(type, request, match, manifest, mapRouteProperties2, handlerOverride, staticContext) { 2981 try { 2982 await Promise.all(loadRouteDefinitionsPromises); 2983 } catch (e) { 2984 } 2985 return results; 2986 } 2987 async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, staticContext) { 2968 2988 let result; 2969 2989 let onReject; … … 2983 3003 }, ...ctx !== void 0 ? [ctx] : []); 2984 3004 }; 2985 let handlerPromise; 2986 if (handlerOverride) { 2987 handlerPromise = handlerOverride((ctx) => actualHandler(ctx)); 2988 } else { 2989 handlerPromise = (async () => { 2990 try { 2991 let val = await actualHandler(); 2992 return { 2993 type: "data", 2994 result: val 2995 }; 2996 } catch (e) { 2997 return { 2998 type: "error", 2999 result: e 3000 }; 3001 } 3002 })(); 3003 } 3005 let handlerPromise = (async () => { 3006 try { 3007 let val = await (handlerOverride ? handlerOverride((ctx) => actualHandler(ctx)) : actualHandler()); 3008 return { 3009 type: "data", 3010 result: val 3011 }; 3012 } catch (e) { 3013 return { 3014 type: "error", 3015 result: e 3016 }; 3017 } 3018 })(); 3004 3019 return Promise.race([handlerPromise, abortPromise]); 3005 3020 }; 3006 3021 try { 3007 3022 let handler = match.route[type]; 3008 if ( match.route.lazy) {3023 if (loadRoutePromise) { 3009 3024 if (handler) { 3010 3025 let handlerError; … … 3016 3031 handlerError = e; 3017 3032 }), 3018 load LazyRouteModule(match.route, mapRouteProperties2, manifest)3033 loadRoutePromise 3019 3034 ]); 3020 3035 if (handlerError !== void 0) { … … 3023 3038 result = value; 3024 3039 } else { 3025 await load LazyRouteModule(match.route, mapRouteProperties2, manifest);3040 await loadRoutePromise; 3026 3041 handler = match.route[type]; 3027 3042 if (handler) { … … 3064 3079 return result; 3065 3080 } 3066 async function convert HandlerResultToDataResult(handlerResult) {3081 async function convertDataStrategyResultToDataResult(dataStrategyResult) { 3067 3082 let { 3068 3083 result, 3069 3084 type 3070 } = handlerResult;3085 } = dataStrategyResult; 3071 3086 if (isResponse(result)) { 3072 3087 let data; … … 3206 3221 return formData; 3207 3222 } 3208 function processRouteLoaderData(matches, matchesToLoad,results, pendingActionResult, activeDeferreds, skipLoaderErrorBubbling) {3223 function processRouteLoaderData(matches, results, pendingActionResult, activeDeferreds, skipLoaderErrorBubbling) { 3209 3224 let loaderData = {}; 3210 3225 let errors = null; … … 3213 3228 let loaderHeaders = {}; 3214 3229 let pendingError = pendingActionResult && isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : void 0; 3215 results.forEach((result, index) => { 3216 let id = matchesToLoad[index].route.id; 3230 matches.forEach((match) => { 3231 if (!(match.route.id in results)) { 3232 return; 3233 } 3234 let id = match.route.id; 3235 let result = results[id]; 3217 3236 invariant(!isRedirectResult(result), "Cannot handle redirect results in processLoaderData"); 3218 3237 if (isErrorResult(result)) { … … 3273 3292 }; 3274 3293 } 3275 function processLoaderData(state, matches, matchesToLoad,results, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds) {3294 function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds) { 3276 3295 let { 3277 3296 loaderData, … … 3279 3298 } = processRouteLoaderData( 3280 3299 matches, 3281 matchesToLoad,3282 3300 results, 3283 3301 pendingActionResult, … … 3286 3304 // This method is only called client side so we always want to bubble 3287 3305 ); 3288 for (let index = 0; index < revalidatingFetchers.length; index++){3306 revalidatingFetchers.forEach((rf) => { 3289 3307 let { 3290 3308 key, 3291 3309 match, 3292 3310 controller 3293 } = r evalidatingFetchers[index];3294 invariant(fetcherResults !== void 0 && fetcherResults[index] !== void 0, "Did not find corresponding fetcher result");3295 let result = fetcherResults[index];3311 } = rf; 3312 let result = fetcherResults[key]; 3313 invariant(result, "Did not find corresponding fetcher result"); 3296 3314 if (controller && controller.signal.aborted) { 3297 continue;3315 return; 3298 3316 } else if (isErrorResult(result)) { 3299 3317 let boundaryMatch = findNearestBoundary(state.matches, match == null ? void 0 : match.route.id); … … 3312 3330 state.fetchers.set(key, doneFetcher); 3313 3331 } 3314 } 3332 }); 3315 3333 return { 3316 3334 loaderData, … … 3378 3396 if (status === 400) { 3379 3397 statusText = "Bad Request"; 3380 if (type === "route-discovery") { 3381 errorMessage = 'Unable to match URL "' + pathname + '" - the `unstable_patchRoutesOnMiss()` ' + ("function threw the following error:\n" + message); 3382 } else if (method && pathname && routeId) { 3398 if (method && pathname && routeId) { 3383 3399 errorMessage = "You made a " + method + ' request to "' + pathname + '" but ' + ('did not provide a `loader` for route "' + routeId + '", ') + "so there is no way to handle the request."; 3384 3400 } else if (type === "defer-action") { … … 3404 3420 } 3405 3421 function findRedirect(results) { 3406 for (let i = results.length - 1; i >= 0; i--) { 3407 let result = results[i]; 3422 let entries = Object.entries(results); 3423 for (let i = entries.length - 1; i >= 0; i--) { 3424 let [key, result] = entries[i]; 3408 3425 if (isRedirectResult(result)) { 3409 3426 return { 3410 result,3411 idx: i3427 key, 3428 result 3412 3429 }; 3413 3430 } … … 3433 3450 return false; 3434 3451 } 3435 function isPromise(val) { 3436 return typeof val === "object" && val != null && "then" in val; 3437 } 3438 function isRedirectHandlerResult(result) { 3452 function isRedirectDataStrategyResultResult(result) { 3439 3453 return isResponse(result.result) && redirectStatusCodes.has(result.result.status); 3440 3454 } … … 3464 3478 return validMutationMethods.has(method.toLowerCase()); 3465 3479 } 3466 async function resolveDeferredResults(currentMatches, matchesToLoad, results, signals, isFetcher, currentLoaderData) { 3467 for (let index = 0; index < results.length; index++) { 3468 let result = results[index]; 3469 let match = matchesToLoad[index]; 3480 async function resolveNavigationDeferredResults(matches, results, signal, currentMatches, currentLoaderData) { 3481 let entries = Object.entries(results); 3482 for (let index = 0; index < entries.length; index++) { 3483 let [routeId, result] = entries[index]; 3484 let match = matches.find((m) => (m == null ? void 0 : m.route.id) === routeId); 3470 3485 if (!match) { 3471 3486 continue; … … 3473 3488 let currentMatch = currentMatches.find((m) => m.route.id === match.route.id); 3474 3489 let isRevalidatingLoader = currentMatch != null && !isNewRouteInstance(currentMatch, match) && (currentLoaderData && currentLoaderData[match.route.id]) !== void 0; 3475 if (isDeferredResult(result) && (isFetcher || isRevalidatingLoader)) { 3476 let signal = signals[index]; 3477 invariant(signal, "Expected an AbortSignal for revalidating fetcher deferred result"); 3478 await resolveDeferredData(result, signal, isFetcher).then((result2) => { 3490 if (isDeferredResult(result) && isRevalidatingLoader) { 3491 await resolveDeferredData(result, signal, false).then((result2) => { 3479 3492 if (result2) { 3480 results[index] = result2 || results[index]; 3493 results[routeId] = result2; 3494 } 3495 }); 3496 } 3497 } 3498 } 3499 async function resolveFetcherDeferredResults(matches, results, revalidatingFetchers) { 3500 for (let index = 0; index < revalidatingFetchers.length; index++) { 3501 let { 3502 key, 3503 routeId, 3504 controller 3505 } = revalidatingFetchers[index]; 3506 let result = results[key]; 3507 let match = matches.find((m) => (m == null ? void 0 : m.route.id) === routeId); 3508 if (!match) { 3509 continue; 3510 } 3511 if (isDeferredResult(result)) { 3512 invariant(controller, "Expected an AbortController for revalidating fetcher deferred result"); 3513 await resolveDeferredData(result, controller.signal, true).then((result2) => { 3514 if (result2) { 3515 results[key] = result2; 3481 3516 } 3482 3517 }); … … 4178 4213 }(DataRouterStateHook || {}); 4179 4214 function getDataRouterConsoleError(hookName) { 4180 return hookName + " must be used within a data router. See https://reactrouter.com/ routers/picking-a-router.";4215 return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router."; 4181 4216 } 4182 4217 function useDataRouterContext(hookName) { … … 4326 4361 return navigate; 4327 4362 } 4363 var alreadyWarned$1 = {}; 4364 function warningOnce(key, cond, message) { 4365 if (!cond && !alreadyWarned$1[key]) { 4366 alreadyWarned$1[key] = true; 4367 true ? warning(false, message) : void 0; 4368 } 4369 } 4328 4370 var alreadyWarned = {}; 4329 function warningOnce(key, cond, message) { 4330 if (!cond && !alreadyWarned[key]) { 4331 alreadyWarned[key] = true; 4332 true ? warning(false, message) : void 0; 4371 function warnOnce(key, message) { 4372 if (!alreadyWarned[message]) { 4373 alreadyWarned[message] = true; 4374 console.warn(message); 4375 } 4376 } 4377 var logDeprecation = (flag, msg, link) => warnOnce(flag, "⚠️ React Router Future Flag Warning: " + msg + ". " + ("You can use the `" + flag + "` future flag to opt-in early. ") + ("For more information, see " + link + ".")); 4378 function logV6DeprecationWarnings(renderFuture, routerFuture) { 4379 if (!(renderFuture != null && renderFuture.v7_startTransition)) { 4380 logDeprecation("v7_startTransition", "React Router will begin wrapping state updates in `React.startTransition` in v7", "https://reactrouter.com/v6/upgrading/future#v7_starttransition"); 4381 } 4382 if (!(renderFuture != null && renderFuture.v7_relativeSplatPath) && (!routerFuture || !routerFuture.v7_relativeSplatPath)) { 4383 logDeprecation("v7_relativeSplatPath", "Relative route resolution within Splat routes is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath"); 4384 } 4385 if (routerFuture) { 4386 if (!routerFuture.v7_fetcherPersist) { 4387 logDeprecation("v7_fetcherPersist", "The persistence behavior of fetchers is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist"); 4388 } 4389 if (!routerFuture.v7_normalizeFormMethod) { 4390 logDeprecation("v7_normalizeFormMethod", "Casing of `formMethod` fields is being normalized to uppercase in v7", "https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod"); 4391 } 4392 if (!routerFuture.v7_partialHydration) { 4393 logDeprecation("v7_partialHydration", "`RouterProvider` hydration behavior is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_partialhydration"); 4394 } 4395 if (!routerFuture.v7_skipActionErrorRevalidation) { 4396 logDeprecation("v7_skipActionErrorRevalidation", "The revalidation behavior after 4xx/5xx `action` responses is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation"); 4397 } 4333 4398 } 4334 4399 } … … 4363 4428 }, [setStateImpl, v7_startTransition]); 4364 4429 React.useLayoutEffect(() => history.listen(setState), [history, setState]); 4430 React.useEffect(() => logV6DeprecationWarnings(future), [future]); 4365 4431 return React.createElement(Router, { 4366 4432 basename, … … 4677 4743 routes, 4678 4744 mapRouteProperties, 4679 unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,4680 unstable_patchRoutesOnMiss: opts == null ? void 0 : opts.unstable_patchRoutesOnMiss4745 dataStrategy: opts == null ? void 0 : opts.dataStrategy, 4746 patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation 4681 4747 }).initialize(); 4682 4748 } … … 4833 4899 }; 4834 4900 } 4835 var _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", " unstable_viewTransition"];4836 var _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", " unstable_viewTransition", "children"];4837 var _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", " unstable_viewTransition"];4901 var _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"]; 4902 var _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"]; 4903 var _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"]; 4838 4904 var REACT_ROUTER_VERSION = "6"; 4839 4905 try { … … 4853 4919 routes, 4854 4920 mapRouteProperties, 4855 unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,4856 unstable_patchRoutesOnMiss: opts == null ? void 0 : opts.unstable_patchRoutesOnMiss,4921 dataStrategy: opts == null ? void 0 : opts.dataStrategy, 4922 patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation, 4857 4923 window: opts == null ? void 0 : opts.window 4858 4924 }).initialize(); … … 4870 4936 routes, 4871 4937 mapRouteProperties, 4872 unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,4873 unstable_patchRoutesOnMiss: opts == null ? void 0 : opts.unstable_patchRoutesOnMiss,4938 dataStrategy: opts == null ? void 0 : opts.dataStrategy, 4939 patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation, 4874 4940 window: opts == null ? void 0 : opts.window 4875 4941 }).initialize(); … … 4992 5058 let { 4993 5059 deletedFetchers, 4994 unstable_flushSync:flushSync,4995 unstable_viewTransitionOpts:viewTransitionOpts5060 flushSync, 5061 viewTransitionOpts 4996 5062 } = _ref2; 4997 5063 deletedFetchers.forEach((key) => fetcherData.current.delete(key)); … … 5128 5194 v7_relativeSplatPath: router.future.v7_relativeSplatPath 5129 5195 }), [router.future.v7_relativeSplatPath]); 5196 React2.useEffect(() => logV6DeprecationWarnings(future, router.future), [future, router.future]); 5130 5197 return React2.createElement(React2.Fragment, null, React2.createElement(DataRouterContext.Provider, { 5131 5198 value: dataRouterContext … … 5183 5250 }, [setStateImpl, v7_startTransition]); 5184 5251 React2.useLayoutEffect(() => history.listen(setState), [history, setState]); 5252 React2.useEffect(() => logV6DeprecationWarnings(future), [future]); 5185 5253 return React2.createElement(Router, { 5186 5254 basename, … … 5218 5286 }, [setStateImpl, v7_startTransition]); 5219 5287 React2.useLayoutEffect(() => history.listen(setState), [history, setState]); 5288 React2.useEffect(() => logV6DeprecationWarnings(future), [future]); 5220 5289 return React2.createElement(Router, { 5221 5290 basename, … … 5245 5314 }, [setStateImpl, v7_startTransition]); 5246 5315 React2.useLayoutEffect(() => history.listen(setState), [history, setState]); 5316 React2.useEffect(() => logV6DeprecationWarnings(future), [future]); 5247 5317 return React2.createElement(Router, { 5248 5318 basename, … … 5269 5339 to, 5270 5340 preventScrollReset, 5271 unstable_viewTransition5341 viewTransition 5272 5342 } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded); 5273 5343 let { … … 5302 5372 preventScrollReset, 5303 5373 relative, 5304 unstable_viewTransition5374 viewTransition 5305 5375 }); 5306 5376 function handleClick(event) { … … 5331 5401 style: styleProp, 5332 5402 to, 5333 unstable_viewTransition,5403 viewTransition, 5334 5404 children 5335 5405 } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2); … … 5345 5415 let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static 5346 5416 // eslint-disable-next-line react-hooks/rules-of-hooks 5347 useViewTransitionState(path) && unstable_viewTransition === true;5417 useViewTransitionState(path) && viewTransition === true; 5348 5418 let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname; 5349 5419 let locationPathname = location.pathname; … … 5379 5449 style, 5380 5450 to, 5381 unstable_viewTransition5451 viewTransition 5382 5452 }), typeof children === "function" ? children(renderProps) : children); 5383 5453 }); … … 5397 5467 relative, 5398 5468 preventScrollReset, 5399 unstable_viewTransition5469 viewTransition 5400 5470 } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3); 5401 5471 let submit = useSubmit(); … … 5418 5488 relative, 5419 5489 preventScrollReset, 5420 unstable_viewTransition5490 viewTransition 5421 5491 }); 5422 5492 }; … … 5460 5530 })(DataRouterStateHook2 || (DataRouterStateHook2 = {})); 5461 5531 function getDataRouterConsoleError2(hookName) { 5462 return hookName + " must be used within a data router. See https://reactrouter.com/ routers/picking-a-router.";5532 return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router."; 5463 5533 } 5464 5534 function useDataRouterContext2(hookName) { … … 5479 5549 preventScrollReset, 5480 5550 relative, 5481 unstable_viewTransition5551 viewTransition 5482 5552 } = _temp === void 0 ? {} : _temp; 5483 5553 let navigate = useNavigate(); … … 5495 5565 preventScrollReset, 5496 5566 relative, 5497 unstable_viewTransition5498 }); 5499 } 5500 }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, unstable_viewTransition]);5567 viewTransition 5568 }); 5569 } 5570 }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]); 5501 5571 } 5502 5572 function useSearchParams(defaultInit) { … … 5554 5624 formMethod: options.method || method, 5555 5625 formEncType: options.encType || encType, 5556 unstable_flushSync: options.unstable_flushSync5626 flushSync: options.flushSync 5557 5627 }); 5558 5628 } else { … … 5566 5636 state: options.state, 5567 5637 fromRouteId: currentRouteId, 5568 unstable_flushSync: options.unstable_flushSync,5569 unstable_viewTransition: options.unstable_viewTransition5638 flushSync: options.flushSync, 5639 viewTransition: options.viewTransition 5570 5640 }); 5571 5641 } … … 5589 5659 path.search = location.search; 5590 5660 let params = new URLSearchParams(path.search); 5591 if (params.has("index") && params.get("index") === "") { 5661 let indexValues = params.getAll("index"); 5662 let hasNakedIndexParam = indexValues.some((v) => v === ""); 5663 if (hasNakedIndexParam) { 5592 5664 params.delete("index"); 5593 path.search = params.toString() ? "?" + params.toString() : ""; 5665 indexValues.filter((v) => v).forEach((v) => params.append("index", v)); 5666 let qs = params.toString(); 5667 path.search = qs ? "?" + qs : ""; 5594 5668 } 5595 5669 } … … 5810 5884 } 5811 5885 let vtContext = React2.useContext(ViewTransitionContext); 5812 !(vtContext != null) ? true ? invariant(false, "`u nstable_useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;5886 !(vtContext != null) ? true ? invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0; 5813 5887 let { 5814 5888 basename … … 5872 5946 HistoryRouter as unstable_HistoryRouter, 5873 5947 usePrompt as unstable_usePrompt, 5874 useViewTransitionState as unstable_useViewTransitionState,5875 5948 useActionData, 5876 5949 useAsyncError, … … 5900 5973 useRoutes, 5901 5974 useSearchParams, 5902 useSubmit 5975 useSubmit, 5976 useViewTransitionState 5903 5977 }; 5904 5978 /*! Bundled license information: … … 5906 5980 @remix-run/router/dist/router.js: 5907 5981 (** 5908 * @remix-run/router v1. 19.05982 * @remix-run/router v1.21.0 5909 5983 * 5910 5984 * Copyright (c) Remix Software Inc. … … 5918 5992 react-router/dist/index.js: 5919 5993 (** 5920 * React Router v6.2 6.05994 * React Router v6.28.0 5921 5995 * 5922 5996 * Copyright (c) Remix Software Inc. … … 5930 6004 react-router-dom/dist/index.js: 5931 6005 (** 5932 * React Router DOM v6.2 6.06006 * React Router DOM v6.28.0 5933 6007 * 5934 6008 * Copyright (c) Remix Software Inc.
Note:
See TracChangeset
for help on using the changeset viewer.