react-router
Advanced tools
Comparing version 0.0.0-nightly-e3c67ede3-20240815 to 0.0.0-nightly-e85f691d1-20240816
# `react-router` | ||
## 6.26.1 | ||
### Patch Changes | ||
- Rename `unstable_patchRoutesOnMiss` to `unstable_patchRoutesOnNavigation` to match new behavior ([#11888](https://github.com/remix-run/react-router/pull/11888)) | ||
- Updated dependencies: | ||
- `@remix-run/router@1.19.1` | ||
## 6.26.0 | ||
@@ -18,6 +26,4 @@ | ||
### Patch Changes | ||
No significant changes to this package were made in this release. [See the repo `CHANGELOG.md`](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md) for an overview of all changes in v6.25.1. | ||
- Memoize some `RouterProvider` internals to reduce unnecessary re-renders ([#11803](https://github.com/remix-run/react-router/pull/11803)) | ||
## 6.25.0 | ||
@@ -24,0 +30,0 @@ |
@@ -8,3 +8,3 @@ export type { InitialEntry, Location, Path, To } from "./lib/router/history"; | ||
export type { DataRouteMatch, DataRouteObject, IndexRouteObject, NavigateOptions, Navigator, NonIndexRouteObject, RouteMatch, RouteObject, } from "./lib/context"; | ||
export type { AwaitProps, IndexRouteProps, LayoutRouteProps, MemoryRouterProps, NavigateProps, OutletProps, PathRouteProps, RouteProps, RouterProps, RouterProviderProps, RoutesProps, PatchRoutesOnMissFunction as unstable_PatchRoutesOnMissFunction, } from "./lib/components"; | ||
export type { AwaitProps, IndexRouteProps, LayoutRouteProps, MemoryRouterProps, NavigateProps, OutletProps, PathRouteProps, RouteProps, RouterProps, RouterProviderProps, RoutesProps, PatchRoutesOnNavigationFunction as unstable_PatchRoutesOnNavigationFunction, } from "./lib/components"; | ||
export type { NavigateFunction } from "./lib/hooks"; | ||
@@ -72,3 +72,3 @@ export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, } from "./lib/components"; | ||
/** @internal */ | ||
export { initFogOfWar as UNSAFE_initFogOfWar, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, } from "./lib/dom/ssr/fog-of-war"; | ||
export { getPatchRoutesOnNavigationFunction as UNSAFE_getPatchRoutesOnNavigationFunction, useFogOFWarDiscovery as UNSAFE_useFogOFWarDiscovery, } from "./lib/dom/ssr/fog-of-war"; | ||
/** @internal */ | ||
@@ -75,0 +75,0 @@ export type { RouteModules as UNSAFE_RouteModules } from "./lib/dom/ssr/routeModules"; |
@@ -5,3 +5,3 @@ import * as React from "react"; | ||
import type { FutureConfig, HydrationState, RelativeRoutingType, Router as RemixRouter } from "./router/router"; | ||
import type { AgnosticPatchRoutesOnMissFunction, DataStrategyFunction, LazyRouteFunction, TrackedPromise } from "./router/utils"; | ||
import type { AgnosticPatchRoutesOnNavigationFunction, DataStrategyFunction, LazyRouteFunction, TrackedPromise } from "./router/utils"; | ||
import type { IndexRouteObject, Navigator, NonIndexRouteObject, RouteMatch, RouteObject } from "./context"; | ||
@@ -14,3 +14,3 @@ /** | ||
}; | ||
export interface PatchRoutesOnMissFunction extends AgnosticPatchRoutesOnMissFunction<RouteMatch> { | ||
export interface PatchRoutesOnNavigationFunction extends AgnosticPatchRoutesOnNavigationFunction<RouteMatch> { | ||
} | ||
@@ -27,3 +27,3 @@ /** | ||
unstable_dataStrategy?: DataStrategyFunction; | ||
unstable_patchRoutesOnMiss?: PatchRoutesOnMissFunction; | ||
unstable_patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction; | ||
}): RemixRouter; | ||
@@ -30,0 +30,0 @@ export interface RouterProviderProps { |
@@ -5,3 +5,3 @@ import type { HydrationState, Router as RemixRouter } from "../router/router"; | ||
export type WindowRemixContext = { | ||
ssrMatches: string[]; | ||
url: string; | ||
basename?: string; | ||
@@ -8,0 +8,0 @@ state: HydrationState; |
@@ -8,3 +8,3 @@ import * as React from "react"; | ||
import type { DiscoverBehavior, PrefetchBehavior, ScriptsProps } from "./ssr/components"; | ||
import type { PatchRoutesOnMissFunction } from "../components"; | ||
import type { PatchRoutesOnNavigationFunction } from "../components"; | ||
import type { RouteObject, NavigateOptions } from "../context"; | ||
@@ -16,3 +16,3 @@ interface DOMRouterOpts { | ||
unstable_dataStrategy?: DataStrategyFunction; | ||
unstable_patchRoutesOnMiss?: PatchRoutesOnMissFunction; | ||
unstable_patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction; | ||
window?: Window; | ||
@@ -19,0 +19,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import type { PatchRoutesOnMissFunction } from "../../components"; | ||
import type { PatchRoutesOnNavigationFunction } from "../../components"; | ||
import type { Router as RemixRouter } from "../../router/router"; | ||
@@ -12,7 +12,2 @@ import type { AssetsManifest } from "./entry"; | ||
} | ||
type FogOfWarInfo = { | ||
nextPaths: Set<string>; | ||
knownGoodPaths: Set<string>; | ||
known404Paths: Set<string>; | ||
}; | ||
export declare function isFogOfWarEnabled(isSpaMode: boolean): boolean; | ||
@@ -32,8 +27,4 @@ export declare function getPartialManifest(manifest: AssetsManifest, router: RemixRouter): { | ||
}; | ||
export declare function initFogOfWar(manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined): { | ||
enabled: boolean; | ||
patchRoutesOnMiss?: PatchRoutesOnMissFunction; | ||
}; | ||
export declare function getPatchRoutesOnNavigationFunction(manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined; | ||
export declare function useFogOFWarDiscovery(router: RemixRouter, manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean): void; | ||
export declare function fetchAndApplyManifestPatches(paths: string[], _fogOfWar: FogOfWarInfo, manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined, patchRoutes: RemixRouter["patchRoutes"]): Promise<void>; | ||
export {}; | ||
export declare function fetchAndApplyManifestPatches(paths: string[], manifest: AssetsManifest, routeModules: RouteModules, isSpaMode: boolean, basename: string | undefined, patchRoutes: RemixRouter["patchRoutes"]): Promise<void>; |
import type { History, Location, Path, To } from "./history"; | ||
import { Action as NavigationType } from "./history"; | ||
import type { AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticRouteObject, DataStrategyFunction, FormEncType, HTMLFormMethod, MapRoutePropertiesFunction, RouteData, Submission, UIMatch, AgnosticPatchRoutesOnMissFunction, DataWithResponseInit } from "./utils"; | ||
import type { AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticRouteObject, DataStrategyFunction, FormEncType, HTMLFormMethod, MapRoutePropertiesFunction, RouteData, Submission, UIMatch, AgnosticPatchRoutesOnNavigationFunction, DataWithResponseInit } from "./utils"; | ||
/** | ||
@@ -271,3 +271,3 @@ * A Router instance manages all navigation and data loading/mutations | ||
window?: Window; | ||
unstable_patchRoutesOnMiss?: AgnosticPatchRoutesOnMissFunction; | ||
unstable_patchRoutesOnNavigation?: AgnosticPatchRoutesOnNavigationFunction; | ||
unstable_dataStrategy?: DataStrategyFunction; | ||
@@ -274,0 +274,0 @@ } |
@@ -177,3 +177,3 @@ import type { Location, Path, To } from "./history"; | ||
} | ||
export interface AgnosticPatchRoutesOnMissFunction<M extends AgnosticRouteMatch = AgnosticRouteMatch> { | ||
export interface AgnosticPatchRoutesOnNavigationFunction<M extends AgnosticRouteMatch = AgnosticRouteMatch> { | ||
(opts: { | ||
@@ -180,0 +180,0 @@ path: string; |
@@ -7,3 +7,3 @@ import type { HydrationState } from "../router/router"; | ||
criticalCss?: string; | ||
ssrMatches: string[]; | ||
url: string; | ||
basename: string | undefined; | ||
@@ -10,0 +10,0 @@ future: FutureConfig; |
import type { StaticHandler } from "../router/router"; | ||
import type { DataStrategyFunction } from "../router/utils"; | ||
import { type SingleFetchRedirectResult, type SingleFetchResult, type SingleFetchResults, SingleFetchRedirectSymbol } from "../dom/ssr/single-fetch"; | ||
import type { SingleFetchRedirectResult, SingleFetchResult, SingleFetchResults } from "../dom/ssr/single-fetch"; | ||
import { SingleFetchRedirectSymbol } from "../dom/ssr/single-fetch"; | ||
import type { AppLoadContext } from "./data"; | ||
@@ -24,3 +25,3 @@ import { ServerMode } from "./mode"; | ||
}>; | ||
export declare function getSingleFetchRedirect(status: number, headers: Headers): SingleFetchRedirectResult; | ||
export declare function getSingleFetchRedirect(status: number, headers: Headers, basename: string | undefined): SingleFetchRedirectResult; | ||
type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | { | ||
@@ -27,0 +28,0 @@ [key: PropertyKey]: Serializable; |
/** | ||
* React Router v0.0.0-nightly-e3c67ede3-20240815 | ||
* React Router v0.0.0-nightly-e85f691d1-20240816 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* React Router v0.0.0-nightly-e3c67ede3-20240815 | ||
* React Router v0.0.0-nightly-e85f691d1-20240816 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* React Router v0.0.0-nightly-e3c67ede3-20240815 | ||
* React Router v0.0.0-nightly-e85f691d1-20240816 | ||
* | ||
@@ -13,3 +13,3 @@ * Copyright (c) Remix Software Inc. | ||
import * as ReactDOM from 'react-dom'; | ||
import { UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery, UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_decodeViaTurboStream, UNSAFE_createClientRoutes, matchRoutes, UNSAFE_shouldHydrateRouteLoader, UNSAFE_deserializeErrors, UNSAFE_initFogOfWar, UNSAFE_createRouter, UNSAFE_createBrowserHistory, UNSAFE_mapRouteProperties, UNSAFE_getSingleFetchDataStrategy, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, RouterProvider as RouterProvider$1 } from 'react-router'; | ||
import { UNSAFE_invariant, UNSAFE_useFogOFWarDiscovery, UNSAFE_FrameworkContext, UNSAFE_RemixErrorBoundary, UNSAFE_decodeViaTurboStream, UNSAFE_createClientRoutes, matchRoutes, UNSAFE_shouldHydrateRouteLoader, UNSAFE_deserializeErrors, UNSAFE_createRouter, UNSAFE_createBrowserHistory, UNSAFE_mapRouteProperties, UNSAFE_getSingleFetchDataStrategy, UNSAFE_getPatchRoutesOnNavigationFunction, UNSAFE_createClientRoutesWithHMRRevalidationOptOut, RouterProvider as RouterProvider$1 } from 'react-router'; | ||
@@ -36,2 +36,18 @@ let ssrInfo = null; | ||
// Hard reload if the path we tried to load is not the current path. | ||
// This is usually the result of 2 rapid back/forward clicks from an | ||
// external site into a Remix app, where we initially start the load for | ||
// one URL and while the JS chunks are loading a second forward click moves | ||
// us to a new URL. Avoid comparing search params because of CDNs which | ||
// can be configured to ignore certain params and only pathname is relevant | ||
// towards determining the route matches. | ||
let initialPathname = ssrInfo.context.url; | ||
let hydratedPathname = window.location.pathname; | ||
if (initialPathname !== hydratedPathname && !ssrInfo.context.isSpaMode) { | ||
let errorMsg = `Initial URL (${initialPathname}) does not match URL at time of hydration ` + `(${hydratedPathname}), reloading page...`; | ||
console.error(errorMsg); | ||
window.location.reload(); | ||
throw new Error("SSR/Client mismatch - reloading current URL"); | ||
} | ||
// We need to suspend until the initial state snapshot is decoded into | ||
@@ -77,21 +93,2 @@ // window.__remixContext.state | ||
let initialMatches = matchRoutes(routes, window.location, window.__remixContext?.basename); | ||
// Hard reload if the matches we rendered on the server aren't the matches | ||
// we matched in the client, otherwise we'll try to hydrate without the | ||
// right modules and throw a hydration error, which can put React into an | ||
// infinite hydration loop when hydrating the full `<html>` document. | ||
// This is usually the result of 2 rapid back/forward clicks from an | ||
// external site into a Remix app, where we initially start the load for | ||
// one URL and while the JS chunks are loading a second forward click moves | ||
// us to a new URL. | ||
let ssrMatches = ssrInfo.context.ssrMatches; | ||
let hasDifferentSSRMatches = (initialMatches || []).length !== ssrMatches.length || !(initialMatches || []).every((m, i) => ssrMatches[i] === m.route.id); | ||
if (hasDifferentSSRMatches && !ssrInfo.context.isSpaMode) { | ||
let ssr = ssrMatches.join(","); | ||
let client = (initialMatches || []).map(m => m.route.id).join(","); | ||
let errorMsg = `SSR Matches (${ssr}) do not match client matches (${client}) at ` + `time of hydration , reloading page...`; | ||
console.error(errorMsg); | ||
window.location.reload(); | ||
throw new Error("SSR/Client mismatch - reloading current URL"); | ||
} | ||
if (initialMatches) { | ||
@@ -124,6 +121,2 @@ for (let match of initialMatches) { | ||
} | ||
let { | ||
enabled: isFogOfWarEnabled, | ||
patchRoutesOnMiss | ||
} = UNSAFE_initFogOfWar(ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode, ssrInfo.context.basename); | ||
@@ -139,5 +132,3 @@ // We don't use createBrowserRouter here because we need fine-grained control | ||
unstable_dataStrategy: UNSAFE_getSingleFetchDataStrategy(ssrInfo.manifest, ssrInfo.routeModules), | ||
...(isFogOfWarEnabled ? { | ||
unstable_patchRoutesOnMiss: patchRoutesOnMiss | ||
} : {}) | ||
unstable_patchRoutesOnNavigation: UNSAFE_getPatchRoutesOnNavigationFunction(ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode, ssrInfo.context.basename) | ||
}); | ||
@@ -144,0 +135,0 @@ ssrInfo.router = router; |
/** | ||
* React Router v0.0.0-nightly-e3c67ede3-20240815 | ||
* React Router v0.0.0-nightly-e85f691d1-20240816 | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
import*as e from"react";import*as t from"react-dom";import{UNSAFE_invariant as o,UNSAFE_useFogOFWarDiscovery as r,UNSAFE_FrameworkContext as i,UNSAFE_RemixErrorBoundary as a,UNSAFE_decodeViaTurboStream as n,UNSAFE_createClientRoutes as s,matchRoutes as u,UNSAFE_shouldHydrateRouteLoader as l,UNSAFE_deserializeErrors as d,UNSAFE_initFogOfWar as c,UNSAFE_createRouter as m,UNSAFE_createBrowserHistory as f,UNSAFE_mapRouteProperties as x,UNSAFE_getSingleFetchDataStrategy as w,UNSAFE_createClientRoutesWithHMRRevalidationOptOut as M,RouterProvider as h}from"react-router";let p=null,g=null;function S(){if(!p&&window.__remixContext&&window.__remixManifest&&window.__remixRouteModules&&(p={context:window.__remixContext,manifest:window.__remixManifest,routeModules:window.__remixRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!p)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=p;if(!p.stateDecodingPromise){let t=p.context.stream;t||o(!1),p.context.stream=void 0,p.stateDecodingPromise=n(t,window).then((t=>{p.context.state=t.value,e.stateDecodingPromise.value=!0})).catch((t=>{e.stateDecodingPromise.error=t}))}if(p.stateDecodingPromise.error)throw p.stateDecodingPromise.error;if(!p.stateDecodingPromise.value)throw p.stateDecodingPromise;let t,r=s(p.manifest.routes,p.routeModules,p.context.state,p.context.isSpaMode);if(!p.context.isSpaMode){t={...p.context.state,loaderData:{...p.context.state.loaderData}};let e=u(r,window.location,window.__remixContext?.basename),o=p.context.ssrMatches;if(((e||[]).length!==o.length||!(e||[]).every(((e,t)=>o[t]===e.route.id)))&&!p.context.isSpaMode){let t=`SSR Matches (${o.join(",")}) do not match client matches (${(e||[]).map((e=>e.route.id)).join(",")}) at time of hydration , reloading page...`;throw console.error(t),window.location.reload(),new Error("SSR/Client mismatch - reloading current URL")}if(e)for(let r of e){let e=r.route.id,o=p.routeModules[e],i=p.manifest.routes[e];o&&l(i,o,p.context.isSpaMode)&&(o.HydrateFallback||!i.hasLoader)?t.loaderData[e]=void 0:i&&!i.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=d(t.errors))}let{enabled:i,patchRoutesOnMiss:a}=c(p.manifest,p.routeModules,p.context.isSpaMode,p.context.basename),h=m({routes:r,history:f(),basename:p.context.basename,hydrationData:t,mapRouteProperties:x,unstable_dataStrategy:w(p.manifest,p.routeModules),...i?{unstable_patchRoutesOnMiss:a}:{}});return p.router=h,h.state.initialized&&(p.routerInitialized=!0,h.initialize()),h.createRoutesForHMR=M,window.__remixRouter=h,h}function _(){g||(g=S());let[t,n]=e.useState(void 0),[s,u]=e.useState(g.state.location);return e.useLayoutEffect((()=>{p&&p.router&&!p.routerInitialized&&(p.routerInitialized=!0,p.router.initialize())}),[]),e.useLayoutEffect((()=>{if(p&&p.router)return p.router.subscribe((e=>{e.location!==s&&u(e.location)}))}),[s]),p||o(!1),r(g,p.manifest,p.routeModules,p.context.isSpaMode),e.createElement(e.Fragment,null,e.createElement(i.Provider,{value:{manifest:p.manifest,routeModules:p.routeModules,future:p.context.future,criticalCss:t,isSpaMode:p.context.isSpaMode}},e.createElement(a,{location:s},e.createElement(R,{router:g}))),e.createElement(e.Fragment,null))}function R(o){return e.createElement(h,Object.assign({flushSync:t.flushSync},o))}export{_ as HydratedRouter,R as RouterProvider}; | ||
import*as e from"react";import*as t from"react-dom";import{UNSAFE_invariant as o,UNSAFE_useFogOFWarDiscovery as r,UNSAFE_FrameworkContext as i,UNSAFE_RemixErrorBoundary as a,UNSAFE_decodeViaTurboStream as n,UNSAFE_createClientRoutes as s,matchRoutes as u,UNSAFE_shouldHydrateRouteLoader as l,UNSAFE_deserializeErrors as d,UNSAFE_createRouter as c,UNSAFE_createBrowserHistory as m,UNSAFE_mapRouteProperties as f,UNSAFE_getSingleFetchDataStrategy as w,UNSAFE_getPatchRoutesOnNavigationFunction as x,UNSAFE_createClientRoutesWithHMRRevalidationOptOut as p,RouterProvider as M}from"react-router";let g=null,h=null;function _(){if(!g&&window.__remixContext&&window.__remixManifest&&window.__remixRouteModules&&(g={context:window.__remixContext,manifest:window.__remixManifest,routeModules:window.__remixRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!g)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=g.context.url,t=window.location.pathname;if(e!==t&&!g.context.isSpaMode){let o=`Initial URL (${e}) does not match URL at time of hydration (${t}), reloading page...`;throw console.error(o),window.location.reload(),new Error("SSR/Client mismatch - reloading current URL")}let r=g;if(!g.stateDecodingPromise){let e=g.context.stream;e||o(!1),g.context.stream=void 0,g.stateDecodingPromise=n(e,window).then((e=>{g.context.state=e.value,r.stateDecodingPromise.value=!0})).catch((e=>{r.stateDecodingPromise.error=e}))}if(g.stateDecodingPromise.error)throw g.stateDecodingPromise.error;if(!g.stateDecodingPromise.value)throw g.stateDecodingPromise;let i,a=s(g.manifest.routes,g.routeModules,g.context.state,g.context.isSpaMode);if(!g.context.isSpaMode){i={...g.context.state,loaderData:{...g.context.state.loaderData}};let e=u(a,window.location,window.__remixContext?.basename);if(e)for(let t of e){let e=t.route.id,o=g.routeModules[e],r=g.manifest.routes[e];o&&l(r,o,g.context.isSpaMode)&&(o.HydrateFallback||!r.hasLoader)?i.loaderData[e]=void 0:r&&!r.hasLoader&&(i.loaderData[e]=null)}i&&i.errors&&(i.errors=d(i.errors))}let M=c({routes:a,history:m(),basename:g.context.basename,hydrationData:i,mapRouteProperties:f,unstable_dataStrategy:w(g.manifest,g.routeModules),unstable_patchRoutesOnNavigation:x(g.manifest,g.routeModules,g.context.isSpaMode,g.context.basename)});return g.router=M,M.state.initialized&&(g.routerInitialized=!0,M.initialize()),M.createRoutesForHMR=p,window.__remixRouter=M,M}function S(){h||(h=_());let[t,n]=e.useState(void 0),[s,u]=e.useState(h.state.location);return e.useLayoutEffect((()=>{g&&g.router&&!g.routerInitialized&&(g.routerInitialized=!0,g.router.initialize())}),[]),e.useLayoutEffect((()=>{if(g&&g.router)return g.router.subscribe((e=>{e.location!==s&&u(e.location)}))}),[s]),g||o(!1),r(h,g.manifest,g.routeModules,g.context.isSpaMode),e.createElement(e.Fragment,null,e.createElement(i.Provider,{value:{manifest:g.manifest,routeModules:g.routeModules,future:g.context.future,criticalCss:t,isSpaMode:g.context.isSpaMode}},e.createElement(a,{location:s},e.createElement(R,{router:h}))),e.createElement(e.Fragment,null))}function R(o){return e.createElement(M,Object.assign({flushSync:t.flushSync},o))}export{S as HydratedRouter,R as RouterProvider}; | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
/** | ||
* React Router v0.0.0-nightly-e3c67ede3-20240815 | ||
* React Router v0.0.0-nightly-e85f691d1-20240816 | ||
* | ||
@@ -73,2 +73,18 @@ * Copyright (c) Remix Software Inc. | ||
// Hard reload if the path we tried to load is not the current path. | ||
// This is usually the result of 2 rapid back/forward clicks from an | ||
// external site into a Remix app, where we initially start the load for | ||
// one URL and while the JS chunks are loading a second forward click moves | ||
// us to a new URL. Avoid comparing search params because of CDNs which | ||
// can be configured to ignore certain params and only pathname is relevant | ||
// towards determining the route matches. | ||
let initialPathname = ssrInfo.context.url; | ||
let hydratedPathname = window.location.pathname; | ||
if (initialPathname !== hydratedPathname && !ssrInfo.context.isSpaMode) { | ||
let errorMsg = "Initial URL (" + initialPathname + ") does not match URL at time of hydration " + ("(" + hydratedPathname + "), reloading page..."); | ||
console.error(errorMsg); | ||
window.location.reload(); | ||
throw new Error("SSR/Client mismatch - reloading current URL"); | ||
} | ||
// We need to suspend until the initial state snapshot is decoded into | ||
@@ -112,21 +128,2 @@ // window.__remixContext.state | ||
let initialMatches = reactRouter.matchRoutes(routes, window.location, (_window$__remixContex = window.__remixContext) == null ? void 0 : _window$__remixContex.basename); | ||
// Hard reload if the matches we rendered on the server aren't the matches | ||
// we matched in the client, otherwise we'll try to hydrate without the | ||
// right modules and throw a hydration error, which can put React into an | ||
// infinite hydration loop when hydrating the full `<html>` document. | ||
// This is usually the result of 2 rapid back/forward clicks from an | ||
// external site into a Remix app, where we initially start the load for | ||
// one URL and while the JS chunks are loading a second forward click moves | ||
// us to a new URL. | ||
let ssrMatches = ssrInfo.context.ssrMatches; | ||
let hasDifferentSSRMatches = (initialMatches || []).length !== ssrMatches.length || !(initialMatches || []).every((m, i) => ssrMatches[i] === m.route.id); | ||
if (hasDifferentSSRMatches && !ssrInfo.context.isSpaMode) { | ||
let ssr = ssrMatches.join(","); | ||
let client = (initialMatches || []).map(m => m.route.id).join(","); | ||
let errorMsg = "SSR Matches (" + ssr + ") do not match client matches (" + client + ") at " + "time of hydration , reloading page..."; | ||
console.error(errorMsg); | ||
window.location.reload(); | ||
throw new Error("SSR/Client mismatch - reloading current URL"); | ||
} | ||
if (initialMatches) { | ||
@@ -159,10 +156,6 @@ for (let match of initialMatches) { | ||
} | ||
let { | ||
enabled: isFogOfWarEnabled, | ||
patchRoutesOnMiss | ||
} = reactRouter.UNSAFE_initFogOfWar(ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode, ssrInfo.context.basename); | ||
// We don't use createBrowserRouter here because we need fine-grained control | ||
// over initialization to support synchronous `clientLoader` flows. | ||
let router = reactRouter.UNSAFE_createRouter(_extends({ | ||
let router = reactRouter.UNSAFE_createRouter({ | ||
routes, | ||
@@ -173,6 +166,5 @@ history: reactRouter.UNSAFE_createBrowserHistory(), | ||
mapRouteProperties: reactRouter.UNSAFE_mapRouteProperties, | ||
unstable_dataStrategy: reactRouter.UNSAFE_getSingleFetchDataStrategy(ssrInfo.manifest, ssrInfo.routeModules) | ||
}, isFogOfWarEnabled ? { | ||
unstable_patchRoutesOnMiss: patchRoutesOnMiss | ||
} : {})); | ||
unstable_dataStrategy: reactRouter.UNSAFE_getSingleFetchDataStrategy(ssrInfo.manifest, ssrInfo.routeModules), | ||
unstable_patchRoutesOnNavigation: reactRouter.UNSAFE_getPatchRoutesOnNavigationFunction(ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode, ssrInfo.context.basename) | ||
}); | ||
ssrInfo.router = router; | ||
@@ -179,0 +171,0 @@ |
/** | ||
* React Router v0.0.0-nightly-e3c67ede3-20240815 | ||
* React Router v0.0.0-nightly-e85f691d1-20240816 | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","react-router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDomExport={},e.React,e.ReactDOM,e.ReactRouter)}(this,(function(e,t,r,o){"use strict";function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=i(t),n=i(r);function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},s.apply(this,arguments)}let u=null,c=null;function d(){if(!u&&window.__remixContext&&window.__remixManifest&&window.__remixRouteModules&&(u={context:window.__remixContext,manifest:window.__remixManifest,routeModules:window.__remixRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!u)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=u;if(!u.stateDecodingPromise){let t=u.context.stream;t||o.UNSAFE_invariant(!1),u.context.stream=void 0,u.stateDecodingPromise=o.UNSAFE_decodeViaTurboStream(t,window).then((t=>{u.context.state=t.value,e.stateDecodingPromise.value=!0})).catch((t=>{e.stateDecodingPromise.error=t}))}if(u.stateDecodingPromise.error)throw u.stateDecodingPromise.error;if(!u.stateDecodingPromise.value)throw u.stateDecodingPromise;let t,r=o.UNSAFE_createClientRoutes(u.manifest.routes,u.routeModules,u.context.state,u.context.isSpaMode);if(!u.context.isSpaMode){var i;t=s({},u.context.state,{loaderData:s({},u.context.state.loaderData)});let e=o.matchRoutes(r,window.location,null==(i=window.__remixContext)?void 0:i.basename),a=u.context.ssrMatches;if(((e||[]).length!==a.length||!(e||[]).every(((e,t)=>a[t]===e.route.id)))&&!u.context.isSpaMode){let t="SSR Matches ("+a.join(",")+") do not match client matches ("+(e||[]).map((e=>e.route.id)).join(",")+") at time of hydration , reloading page...";throw console.error(t),window.location.reload(),new Error("SSR/Client mismatch - reloading current URL")}if(e)for(let r of e){let e=r.route.id,i=u.routeModules[e],a=u.manifest.routes[e];i&&o.UNSAFE_shouldHydrateRouteLoader(a,i,u.context.isSpaMode)&&(i.HydrateFallback||!a.hasLoader)?t.loaderData[e]=void 0:a&&!a.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=o.UNSAFE_deserializeErrors(t.errors))}let{enabled:a,patchRoutesOnMiss:n}=o.UNSAFE_initFogOfWar(u.manifest,u.routeModules,u.context.isSpaMode,u.context.basename),c=o.UNSAFE_createRouter(s({routes:r,history:o.UNSAFE_createBrowserHistory(),basename:u.context.basename,hydrationData:t,mapRouteProperties:o.UNSAFE_mapRouteProperties,unstable_dataStrategy:o.UNSAFE_getSingleFetchDataStrategy(u.manifest,u.routeModules)},a?{unstable_patchRoutesOnMiss:n}:{}));return u.router=c,c.state.initialized&&(u.routerInitialized=!0,c.initialize()),c.createRoutesForHMR=o.UNSAFE_createClientRoutesWithHMRRevalidationOptOut,window.__remixRouter=c,c}function l(e){return a.createElement(o.RouterProvider,s({flushSync:n.flushSync},e))}e.HydratedRouter=function(){c||(c=d());let[e,t]=a.useState(void 0),[r,i]=a.useState(c.state.location);return a.useLayoutEffect((()=>{u&&u.router&&!u.routerInitialized&&(u.routerInitialized=!0,u.router.initialize())}),[]),a.useLayoutEffect((()=>{if(u&&u.router)return u.router.subscribe((e=>{e.location!==r&&i(e.location)}))}),[r]),u||o.UNSAFE_invariant(!1),o.UNSAFE_useFogOFWarDiscovery(c,u.manifest,u.routeModules,u.context.isSpaMode),a.createElement(a.Fragment,null,a.createElement(o.UNSAFE_FrameworkContext.Provider,{value:{manifest:u.manifest,routeModules:u.routeModules,future:u.context.future,criticalCss:e,isSpaMode:u.context.isSpaMode}},a.createElement(o.UNSAFE_RemixErrorBoundary,{location:r},a.createElement(l,{router:c}))),a.createElement(a.Fragment,null))},e.RouterProvider=l,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("react-router")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","react-router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDomExport={},e.React,e.ReactDOM,e.ReactRouter)}(this,(function(e,t,o,r){"use strict";function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var i=a(t),n=a(o);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},u.apply(this,arguments)}let s=null,c=null;function l(){if(!s&&window.__remixContext&&window.__remixManifest&&window.__remixRouteModules&&(s={context:window.__remixContext,manifest:window.__remixManifest,routeModules:window.__remixRouteModules,stateDecodingPromise:void 0,router:void 0,routerInitialized:!1}),!s)throw new Error("You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`");let e=s.context.url,t=window.location.pathname;if(e!==t&&!s.context.isSpaMode){let o="Initial URL ("+e+") does not match URL at time of hydration ("+t+"), reloading page...";throw console.error(o),window.location.reload(),new Error("SSR/Client mismatch - reloading current URL")}let o=s;if(!s.stateDecodingPromise){let e=s.context.stream;e||r.UNSAFE_invariant(!1),s.context.stream=void 0,s.stateDecodingPromise=r.UNSAFE_decodeViaTurboStream(e,window).then((e=>{s.context.state=e.value,o.stateDecodingPromise.value=!0})).catch((e=>{o.stateDecodingPromise.error=e}))}if(s.stateDecodingPromise.error)throw s.stateDecodingPromise.error;if(!s.stateDecodingPromise.value)throw s.stateDecodingPromise;let a,i=r.UNSAFE_createClientRoutes(s.manifest.routes,s.routeModules,s.context.state,s.context.isSpaMode);if(!s.context.isSpaMode){var n;a=u({},s.context.state,{loaderData:u({},s.context.state.loaderData)});let e=r.matchRoutes(i,window.location,null==(n=window.__remixContext)?void 0:n.basename);if(e)for(let t of e){let e=t.route.id,o=s.routeModules[e],i=s.manifest.routes[e];o&&r.UNSAFE_shouldHydrateRouteLoader(i,o,s.context.isSpaMode)&&(o.HydrateFallback||!i.hasLoader)?a.loaderData[e]=void 0:i&&!i.hasLoader&&(a.loaderData[e]=null)}a&&a.errors&&(a.errors=r.UNSAFE_deserializeErrors(a.errors))}let c=r.UNSAFE_createRouter({routes:i,history:r.UNSAFE_createBrowserHistory(),basename:s.context.basename,hydrationData:a,mapRouteProperties:r.UNSAFE_mapRouteProperties,unstable_dataStrategy:r.UNSAFE_getSingleFetchDataStrategy(s.manifest,s.routeModules),unstable_patchRoutesOnNavigation:r.UNSAFE_getPatchRoutesOnNavigationFunction(s.manifest,s.routeModules,s.context.isSpaMode,s.context.basename)});return s.router=c,c.state.initialized&&(s.routerInitialized=!0,c.initialize()),c.createRoutesForHMR=r.UNSAFE_createClientRoutesWithHMRRevalidationOptOut,window.__remixRouter=c,c}function d(e){return i.createElement(r.RouterProvider,u({flushSync:n.flushSync},e))}e.HydratedRouter=function(){c||(c=l());let[e,t]=i.useState(void 0),[o,a]=i.useState(c.state.location);return i.useLayoutEffect((()=>{s&&s.router&&!s.routerInitialized&&(s.routerInitialized=!0,s.router.initialize())}),[]),i.useLayoutEffect((()=>{if(s&&s.router)return s.router.subscribe((e=>{e.location!==o&&a(e.location)}))}),[o]),s||r.UNSAFE_invariant(!1),r.UNSAFE_useFogOFWarDiscovery(c,s.manifest,s.routeModules,s.context.isSpaMode),i.createElement(i.Fragment,null,i.createElement(r.UNSAFE_FrameworkContext.Provider,{value:{manifest:s.manifest,routeModules:s.routeModules,future:s.context.future,criticalCss:e,isSpaMode:s.context.isSpaMode}},i.createElement(r.UNSAFE_RemixErrorBoundary,{location:o},i.createElement(d,{router:c}))),i.createElement(i.Fragment,null))},e.RouterProvider=d,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
{ | ||
"name": "react-router", | ||
"version": "0.0.0-nightly-e3c67ede3-20240815", | ||
"version": "0.0.0-nightly-e85f691d1-20240816", | ||
"description": "Declarative routing for React", | ||
@@ -44,4 +44,4 @@ "keywords": [ | ||
"source-map": "^0.7.3", | ||
"turbo-stream": "^2.2.0", | ||
"react-router": "0.0.0-nightly-e3c67ede3-20240815" | ||
"turbo-stream": "2.3.0", | ||
"react-router": "0.0.0-nightly-e85f691d1-20240816" | ||
}, | ||
@@ -48,0 +48,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6497511
41551
+ Addedturbo-stream@2.3.0(transitive)
- Removedturbo-stream@2.4.1(transitive)
Updatedturbo-stream@2.3.0