Builds the per-request context factory from React Router's
RouterContextProvider class.
React Router 8 checks initialContext instanceof RouterContextProvider and
answers a 500 Unexpected Server Error when it fails, so the class itself —
not a structural stand-in — has to reach the handler.
Extracted as a pure function so the branch is unit-testable without importing
react-router.
Builds the per-request context factory from React Router's
RouterContextProviderclass.React Router 8 checks
initialContext instanceof RouterContextProviderand answers a 500Unexpected Server Errorwhen it fails, so the class itself — not a structural stand-in — has to reach the handler.Extracted as a pure function so the branch is unit-testable without importing
react-router.