diff --git a/.changeset/shy-ducks-repeat.md b/.changeset/shy-ducks-repeat.md index f9d8173605b..f8db29a9e9d 100644 --- a/.changeset/shy-ducks-repeat.md +++ b/.changeset/shy-ducks-repeat.md @@ -3,5 +3,6 @@ "@remix-run/server-runtime": patch --- -Fog of War: Simplify implementation now that React Router handles slug/splat edge cases and tracks previously disscovered routes (see https://github.com/remix-run/react-router/pull/11883) +- Fog of War: Simplify implementation now that React Router handles slug/splat edge cases and tracks previously disscovered routes (see https://github.com/remix-run/react-router/pull/11883) - This changes the return signature of the internal `__manifest` endpoint since we no longer need the `notFoundPaths` field +- Fog of War: Update to use renamed `unstable_patchRoutesOnNavigation` function in RR (see https://github.com/remix-run/react-router/pull/11888) \ No newline at end of file diff --git a/integration/package.json b/integration/package.json index db7fd0982c0..5b6aac81978 100644 --- a/integration/package.json +++ b/integration/package.json @@ -14,7 +14,7 @@ "@remix-run/dev": "workspace:*", "@remix-run/express": "workspace:*", "@remix-run/node": "workspace:*", - "@remix-run/router": "0.0.0-experimental-dc307bdd5", + "@remix-run/router": "0.0.0-experimental-5a6545bf7", "@remix-run/server-runtime": "workspace:*", "@types/express": "^4.17.9", "@vanilla-extract/css": "^1.10.0", diff --git a/packages/remix-dev/package.json b/packages/remix-dev/package.json index eaf47ec78b7..abbcaf0a1e9 100644 --- a/packages/remix-dev/package.json +++ b/packages/remix-dev/package.json @@ -32,7 +32,7 @@ "@mdx-js/mdx": "^2.3.0", "@npmcli/package-json": "^4.0.1", "@remix-run/node": "workspace:*", - "@remix-run/router": "0.0.0-experimental-dc307bdd5", + "@remix-run/router": "0.0.0-experimental-5a6545bf7", "@remix-run/server-runtime": "workspace:*", "@types/mdx": "^2.0.5", "@vanilla-extract/integration": "^6.2.0", diff --git a/packages/remix-react/browser.tsx b/packages/remix-react/browser.tsx index c0014b1c1e1..b7b65cb6bf9 100644 --- a/packages/remix-react/browser.tsx +++ b/packages/remix-react/browser.tsx @@ -20,7 +20,10 @@ import { getSingleFetchDataStrategy, } from "./single-fetch"; import invariant from "./invariant"; -import { initFogOfWar, useFogOFWarDiscovery } from "./fog-of-war"; +import { + getPatchRoutesOnNavigationFunction, + useFogOFWarDiscovery, +} from "./fog-of-war"; /* eslint-disable prefer-let/prefer-let */ declare global { @@ -305,14 +308,6 @@ export function RemixBrowser(_props: RemixBrowserProps): ReactElement { } } - let { enabled: isFogOfWarEnabled, patchRoutesOnMiss } = initFogOfWar( - window.__remixManifest, - window.__remixRouteModules, - window.__remixContext.future, - window.__remixContext.isSpaMode, - window.__remixContext.basename - ); - // We don't use createBrowserRouter here because we need fine-grained control // over initialization to support synchronous `clientLoader` flows. router = createRouter({ @@ -337,9 +332,13 @@ export function RemixBrowser(_props: RemixBrowserProps): ReactElement { window.__remixRouteModules ) : undefined, - ...(isFogOfWarEnabled - ? { unstable_patchRoutesOnMiss: patchRoutesOnMiss } - : {}), + unstable_patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction( + window.__remixManifest, + window.__remixRouteModules, + window.__remixContext.future, + window.__remixContext.isSpaMode, + window.__remixContext.basename + ), }); // We can call initialize() immediately if the router doesn't have any diff --git a/packages/remix-react/fog-of-war.ts b/packages/remix-react/fog-of-war.ts index b8e609556b1..033d4624a09 100644 --- a/packages/remix-react/fog-of-war.ts +++ b/packages/remix-react/fog-of-war.ts @@ -1,7 +1,7 @@ import type { Router } from "@remix-run/router"; import { matchRoutes } from "@remix-run/router"; import * as React from "react"; -import type { unstable_PatchRoutesOnMissFunction } from "react-router"; +import type { unstable_PatchRoutesOnNavigationFunction } from "react-router"; import type { AssetsManifest, FutureConfig } from "./entry"; import type { RouteModules } from "./routeModules"; @@ -64,36 +64,29 @@ export function getPartialManifest(manifest: AssetsManifest, router: Router) { }; } -export function initFogOfWar( +export function getPatchRoutesOnNavigationFunction( manifest: AssetsManifest, routeModules: RouteModules, future: FutureConfig, isSpaMode: boolean, basename: string | undefined -): { - enabled: boolean; - patchRoutesOnMiss?: unstable_PatchRoutesOnMissFunction; -} { +): unstable_PatchRoutesOnNavigationFunction | undefined { if (!isFogOfWarEnabled(future, isSpaMode)) { - return { enabled: false }; + return undefined; } - - return { - enabled: true, - patchRoutesOnMiss: async ({ path, patch }) => { - if (discoveredPaths.has(path)) { - return; - } - await fetchAndApplyManifestPatches( - [path], - manifest, - routeModules, - future, - isSpaMode, - basename, - patch - ); - }, + return async ({ path, patch }) => { + if (discoveredPaths.has(path)) { + return; + } + await fetchAndApplyManifestPatches( + [path], + manifest, + routeModules, + future, + isSpaMode, + basename, + patch + ); }; } diff --git a/packages/remix-react/package.json b/packages/remix-react/package.json index fd6986c63e5..8ae187a55f7 100644 --- a/packages/remix-react/package.json +++ b/packages/remix-react/package.json @@ -19,10 +19,10 @@ "tsc": "tsc" }, "dependencies": { - "@remix-run/router": "0.0.0-experimental-dc307bdd5", + "@remix-run/router": "0.0.0-experimental-5a6545bf7", "@remix-run/server-runtime": "workspace:*", - "react-router": "0.0.0-experimental-dc307bdd5", - "react-router-dom": "0.0.0-experimental-dc307bdd5", + "react-router": "0.0.0-experimental-5a6545bf7", + "react-router-dom": "0.0.0-experimental-5a6545bf7", "turbo-stream": "2.3.0" }, "devDependencies": { diff --git a/packages/remix-server-runtime/package.json b/packages/remix-server-runtime/package.json index 70e65cf1e39..07ceb6156f0 100644 --- a/packages/remix-server-runtime/package.json +++ b/packages/remix-server-runtime/package.json @@ -19,7 +19,7 @@ "tsc": "tsc" }, "dependencies": { - "@remix-run/router": "0.0.0-experimental-dc307bdd5", + "@remix-run/router": "0.0.0-experimental-5a6545bf7", "@types/cookie": "^0.6.0", "@web3-storage/multipart-parser": "^1.0.0", "cookie": "^0.6.0", diff --git a/packages/remix-testing/package.json b/packages/remix-testing/package.json index 83d740bf9cb..a3df6276c4f 100644 --- a/packages/remix-testing/package.json +++ b/packages/remix-testing/package.json @@ -21,8 +21,8 @@ "dependencies": { "@remix-run/node": "workspace:*", "@remix-run/react": "workspace:*", - "@remix-run/router": "0.0.0-experimental-dc307bdd5", - "react-router-dom": "0.0.0-experimental-dc307bdd5" + "@remix-run/router": "0.0.0-experimental-5a6545bf7", + "react-router-dom": "0.0.0-experimental-5a6545bf7" }, "devDependencies": { "@remix-run/server-runtime": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 242b0d1b4a3..bf410d94482 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -323,8 +323,8 @@ importers: specifier: workspace:* version: link:../packages/remix-node '@remix-run/router': - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5 + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7 '@remix-run/server-runtime': specifier: workspace:* version: link:../packages/remix-server-runtime @@ -871,8 +871,8 @@ importers: specifier: ^2.11.1 version: link:../remix-react '@remix-run/router': - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5 + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7 '@remix-run/server-runtime': specifier: workspace:* version: link:../remix-server-runtime @@ -1217,17 +1217,17 @@ importers: packages/remix-react: dependencies: '@remix-run/router': - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5 + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7 '@remix-run/server-runtime': specifier: workspace:* version: link:../remix-server-runtime react-router: - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5(react@18.2.0) + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7(react@18.2.0) react-router-dom: - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7(react-dom@18.2.0)(react@18.2.0) turbo-stream: specifier: 2.3.0 version: 2.3.0 @@ -1303,8 +1303,8 @@ importers: packages/remix-server-runtime: dependencies: '@remix-run/router': - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5 + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7 '@types/cookie': specifier: ^0.6.0 version: 0.6.0 @@ -1340,11 +1340,11 @@ importers: specifier: workspace:* version: link:../remix-react '@remix-run/router': - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5 + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7 react-router-dom: - specifier: 0.0.0-experimental-dc307bdd5 - version: 0.0.0-experimental-dc307bdd5(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.0-experimental-5a6545bf7 + version: 0.0.0-experimental-5a6545bf7(react-dom@18.2.0)(react@18.2.0) devDependencies: '@remix-run/server-runtime': specifier: workspace:* @@ -4201,8 +4201,8 @@ packages: - encoding dev: false - /@remix-run/router@0.0.0-experimental-dc307bdd5: - resolution: {integrity: sha512-qrqUoZXI0DsswGM1sjQN0L+JMn5Xh4M4MhPvg4lHuAv060jniFkGyTfSRJg6C4FD7b9lXMYcwJCmFvL4ab1Oug==} + /@remix-run/router@0.0.0-experimental-5a6545bf7: + resolution: {integrity: sha512-xsFyd1dMF1kRAVwUWas7iYjhBL0z7//dQ8bVoQ3kXfgWgN7A/WX2M74PrYfa1Qe3xfgvw8h1yjbHRBvM7FA8QA==} engines: {node: '>=14.0.0'} dev: false @@ -12786,26 +12786,26 @@ packages: engines: {node: '>=0.10.0'} dev: false - /react-router-dom@0.0.0-experimental-dc307bdd5(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-ZMkgQpVXtsMOZuXy3y+ndfZJ74Fs8kSUzWNKDtYmHuvGvFItD10Dqr+zZYI3AbjmPZwcKlqyOnQ2lNHnCCot1g==} + /react-router-dom@0.0.0-experimental-5a6545bf7(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-fidHtQFuYr6KW2KwXfXrRQFY7jqmJba3h9CY+y7KGHNtt7UxG3tJh4hpm6zhfvHMMX9ONWtNkTYIHjazDh2JBg==} engines: {node: '>=14.0.0'} peerDependencies: react: '>=16.8' react-dom: '>=16.8' dependencies: - '@remix-run/router': 0.0.0-experimental-dc307bdd5 + '@remix-run/router': 0.0.0-experimental-5a6545bf7 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - react-router: 0.0.0-experimental-dc307bdd5(react@18.2.0) + react-router: 0.0.0-experimental-5a6545bf7(react@18.2.0) dev: false - /react-router@0.0.0-experimental-dc307bdd5(react@18.2.0): - resolution: {integrity: sha512-fpDYLE5QFWd7h3IUQx4MH5PbiNuXx+t/H4XTC1jwbKWczJdCj280K0NJcdf3YC0DnUJBsSN8lEtyFAox+/23IA==} + /react-router@0.0.0-experimental-5a6545bf7(react@18.2.0): + resolution: {integrity: sha512-88Ft7yZN0q99d+s4RMV6kaXWLjMMHvGZuOIcOXJ+yVgLOQXXiq8xFBD40D4pyaHYtuo7tR+NK9ti8rhhFx1poA==} engines: {node: '>=14.0.0'} peerDependencies: react: '>=16.8' dependencies: - '@remix-run/router': 0.0.0-experimental-dc307bdd5 + '@remix-run/router': 0.0.0-experimental-5a6545bf7 react: 18.2.0 dev: false