react-router 6.26.2 → 7.0.0-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +307 -0
- package/README.md +1 -14
- package/dist/dom-export.d.ts +3 -0
- package/dist/dom-export.mjs +205 -0
- package/dist/dom-export.mjs.map +1 -0
- package/dist/index.d.ts +74 -29
- package/dist/index.mjs +11551 -0
- package/dist/index.mjs.map +1 -0
- package/dist/lib/components.d.ts +250 -35
- package/dist/lib/context.d.ts +20 -7
- package/dist/lib/dom/dom.d.ts +123 -0
- package/dist/lib/dom/global.d.ts +40 -0
- package/dist/lib/dom/lib.d.ts +940 -0
- package/dist/lib/dom/server.d.ts +41 -0
- package/dist/lib/dom/ssr/components.d.ts +123 -0
- package/dist/lib/dom/ssr/data.d.ts +7 -0
- package/dist/lib/dom/ssr/entry.d.ts +47 -0
- package/dist/lib/dom/ssr/errorBoundaries.d.ts +36 -0
- package/dist/lib/dom/ssr/errors.d.ts +2 -0
- package/dist/lib/dom/ssr/fallback.d.ts +2 -0
- package/dist/lib/dom/ssr/fog-of-war.d.ts +28 -0
- package/dist/lib/dom/ssr/invariant.d.ts +2 -0
- package/dist/lib/dom/ssr/links.d.ts +25 -0
- package/dist/lib/dom/ssr/markup.d.ts +5 -0
- package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
- package/dist/lib/dom/ssr/routes-test-stub.d.ts +59 -0
- package/dist/lib/dom/ssr/routes.d.ts +32 -0
- package/dist/lib/dom/ssr/server.d.ts +16 -0
- package/dist/lib/dom/ssr/single-fetch.d.ts +37 -0
- package/dist/lib/dom-export/dom-router-provider.d.ts +5 -0
- package/dist/lib/dom-export/hydrated-router.d.ts +5 -0
- package/dist/lib/dom-export.d.ts +3 -0
- package/dist/lib/hooks.d.ts +286 -57
- package/dist/lib/router/history.d.ts +253 -0
- package/dist/lib/router/links.d.ts +104 -0
- package/dist/lib/router/router.d.ts +540 -0
- package/dist/lib/router/utils.d.ts +505 -0
- package/dist/lib/server-runtime/build.d.ts +38 -0
- package/dist/lib/server-runtime/cookies.d.ts +62 -0
- package/dist/lib/server-runtime/crypto.d.ts +2 -0
- package/dist/lib/server-runtime/data.d.ts +15 -0
- package/dist/lib/server-runtime/dev.d.ts +8 -0
- package/dist/lib/server-runtime/entry.d.ts +3 -0
- package/dist/lib/server-runtime/errors.d.ts +51 -0
- package/dist/lib/server-runtime/headers.d.ts +3 -0
- package/dist/lib/server-runtime/invariant.d.ts +2 -0
- package/dist/lib/server-runtime/jsonify.d.ts +33 -0
- package/dist/lib/server-runtime/markup.d.ts +1 -0
- package/dist/lib/server-runtime/mode.d.ts +9 -0
- package/dist/lib/server-runtime/responses.d.ts +37 -0
- package/dist/lib/server-runtime/routeMatching.d.ts +8 -0
- package/dist/lib/server-runtime/routeModules.d.ts +212 -0
- package/dist/lib/server-runtime/routes.d.ts +31 -0
- package/dist/lib/server-runtime/server.d.ts +5 -0
- package/dist/lib/server-runtime/serverHandoff.d.ts +11 -0
- package/dist/lib/server-runtime/sessions/cookieStorage.d.ts +19 -0
- package/dist/lib/server-runtime/sessions/memoryStorage.d.ts +17 -0
- package/dist/lib/server-runtime/sessions.d.ts +140 -0
- package/dist/lib/server-runtime/single-fetch.d.ts +30 -0
- package/dist/lib/server-runtime/typecheck.d.ts +4 -0
- package/dist/lib/server-runtime/warnings.d.ts +1 -0
- package/dist/lib/types.d.ts +71 -0
- package/dist/lib/types.mjs +10 -0
- package/dist/main-dom-export.js +19 -0
- package/dist/main.js +1 -1
- package/dist/react-router-dom.development.js +199 -0
- package/dist/react-router-dom.development.js.map +1 -0
- package/dist/react-router-dom.production.min.js +12 -0
- package/dist/react-router-dom.production.min.js.map +1 -0
- package/dist/react-router.development.js +12271 -1129
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router-dom.development.js +241 -0
- package/dist/umd/react-router-dom.development.js.map +1 -0
- package/dist/umd/react-router-dom.production.min.js +12 -0
- package/dist/umd/react-router-dom.production.min.js.map +1 -0
- package/dist/umd/react-router.development.js +12459 -1224
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +35 -6
- package/dist/index.js +0 -1467
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Router v7.0.0-pre.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
(function (global, factory) {
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('react-router')) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', 'react-router'], factory) :
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRouterDOMExport = {}, global.React, global.ReactDOM, global.ReactRouter));
|
|
15
|
+
})(this, (function (exports, React, ReactDOM, reactRouter) { 'use strict';
|
|
16
|
+
|
|
17
|
+
function _interopNamespace(e) {
|
|
18
|
+
if (e && e.__esModule) return e;
|
|
19
|
+
var n = Object.create(null);
|
|
20
|
+
if (e) {
|
|
21
|
+
Object.keys(e).forEach(function (k) {
|
|
22
|
+
if (k !== 'default') {
|
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return e[k]; }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
n["default"] = e;
|
|
32
|
+
return Object.freeze(n);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
|
+
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
37
|
+
|
|
38
|
+
function _extends() {
|
|
39
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
40
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
41
|
+
var source = arguments[i];
|
|
42
|
+
for (var key in source) {
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44
|
+
target[key] = source[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return target;
|
|
49
|
+
};
|
|
50
|
+
return _extends.apply(this, arguments);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let ssrInfo = null;
|
|
54
|
+
let router = null;
|
|
55
|
+
function initSsrInfo() {
|
|
56
|
+
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
|
57
|
+
ssrInfo = {
|
|
58
|
+
context: window.__reactRouterContext,
|
|
59
|
+
manifest: window.__reactRouterManifest,
|
|
60
|
+
routeModules: window.__reactRouterRouteModules,
|
|
61
|
+
stateDecodingPromise: undefined,
|
|
62
|
+
router: undefined,
|
|
63
|
+
routerInitialized: false
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function createHydratedRouter() {
|
|
68
|
+
initSsrInfo();
|
|
69
|
+
if (!ssrInfo) {
|
|
70
|
+
throw new Error("You must be using the SSR features of React Router in order to skip " + "passing a `router` prop to `<RouterProvider>`");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// We need to suspend until the initial state snapshot is decoded into
|
|
74
|
+
// window.__reactRouterContext.state
|
|
75
|
+
|
|
76
|
+
let localSsrInfo = ssrInfo;
|
|
77
|
+
// Note: `stateDecodingPromise` is not coupled to `router` - we'll reach this
|
|
78
|
+
// code potentially many times waiting for our state to arrive, but we'll
|
|
79
|
+
// then only get past here and create the `router` one time
|
|
80
|
+
if (!ssrInfo.stateDecodingPromise) {
|
|
81
|
+
let stream = ssrInfo.context.stream;
|
|
82
|
+
!stream ? reactRouter.UNSAFE_invariant(false, "No stream found for single fetch decoding") : void 0;
|
|
83
|
+
ssrInfo.context.stream = undefined;
|
|
84
|
+
ssrInfo.stateDecodingPromise = reactRouter.UNSAFE_decodeViaTurboStream(stream, window).then(value => {
|
|
85
|
+
ssrInfo.context.state = value.value;
|
|
86
|
+
localSsrInfo.stateDecodingPromise.value = true;
|
|
87
|
+
}).catch(e => {
|
|
88
|
+
localSsrInfo.stateDecodingPromise.error = e;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (ssrInfo.stateDecodingPromise.error) {
|
|
92
|
+
throw ssrInfo.stateDecodingPromise.error;
|
|
93
|
+
}
|
|
94
|
+
if (!ssrInfo.stateDecodingPromise.value) {
|
|
95
|
+
throw ssrInfo.stateDecodingPromise;
|
|
96
|
+
}
|
|
97
|
+
let routes = reactRouter.UNSAFE_createClientRoutes(ssrInfo.manifest.routes, ssrInfo.routeModules, ssrInfo.context.state, ssrInfo.context.isSpaMode);
|
|
98
|
+
let hydrationData = undefined;
|
|
99
|
+
if (!ssrInfo.context.isSpaMode) {
|
|
100
|
+
var _window$__reactRouter;
|
|
101
|
+
// Create a shallow clone of `loaderData` we can mutate for partial hydration.
|
|
102
|
+
// When a route exports a `clientLoader` and a `HydrateFallback`, the SSR will
|
|
103
|
+
// render the fallback so we need the client to do the same for hydration.
|
|
104
|
+
// The server loader data has already been exposed to these route `clientLoader`'s
|
|
105
|
+
// in `createClientRoutes` above, so we need to clear out the version we pass to
|
|
106
|
+
// `createBrowserRouter` so it initializes and runs the client loaders.
|
|
107
|
+
hydrationData = _extends({}, ssrInfo.context.state, {
|
|
108
|
+
loaderData: _extends({}, ssrInfo.context.state.loaderData)
|
|
109
|
+
});
|
|
110
|
+
let initialMatches = reactRouter.matchRoutes(routes, window.location, (_window$__reactRouter = window.__reactRouterContext) == null ? void 0 : _window$__reactRouter.basename);
|
|
111
|
+
if (initialMatches) {
|
|
112
|
+
for (let match of initialMatches) {
|
|
113
|
+
let routeId = match.route.id;
|
|
114
|
+
let route = ssrInfo.routeModules[routeId];
|
|
115
|
+
let manifestRoute = ssrInfo.manifest.routes[routeId];
|
|
116
|
+
// Clear out the loaderData to avoid rendering the route component when the
|
|
117
|
+
// route opted into clientLoader hydration and either:
|
|
118
|
+
// * gave us a HydrateFallback
|
|
119
|
+
// * or doesn't have a server loader and we have no data to render
|
|
120
|
+
if (route && reactRouter.UNSAFE_shouldHydrateRouteLoader(manifestRoute, route, ssrInfo.context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) {
|
|
121
|
+
delete hydrationData.loaderData[routeId];
|
|
122
|
+
} else if (manifestRoute && !manifestRoute.hasLoader) {
|
|
123
|
+
// Since every Remix route gets a `loader` on the client side to load
|
|
124
|
+
// the route JS module, we need to add a `null` value to `loaderData`
|
|
125
|
+
// for any routes that don't have server loaders so our partial
|
|
126
|
+
// hydration logic doesn't kick off the route module loaders during
|
|
127
|
+
// hydration
|
|
128
|
+
hydrationData.loaderData[routeId] = null;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (hydrationData && hydrationData.errors) {
|
|
133
|
+
// TODO: De-dup this or remove entirely in v7 where single fetch is the
|
|
134
|
+
// only approach and we have already serialized or deserialized on the server
|
|
135
|
+
hydrationData.errors = reactRouter.UNSAFE_deserializeErrors(hydrationData.errors);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// We don't use createBrowserRouter here because we need fine-grained control
|
|
140
|
+
// over initialization to support synchronous `clientLoader` flows.
|
|
141
|
+
let router = reactRouter.UNSAFE_createRouter({
|
|
142
|
+
routes,
|
|
143
|
+
history: reactRouter.UNSAFE_createBrowserHistory(),
|
|
144
|
+
basename: ssrInfo.context.basename,
|
|
145
|
+
hydrationData,
|
|
146
|
+
mapRouteProperties: reactRouter.UNSAFE_mapRouteProperties,
|
|
147
|
+
dataStrategy: reactRouter.UNSAFE_getSingleFetchDataStrategy(ssrInfo.manifest, ssrInfo.routeModules, () => router),
|
|
148
|
+
patchRoutesOnNavigation: reactRouter.UNSAFE_getPatchRoutesOnNavigationFunction(ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode, ssrInfo.context.basename)
|
|
149
|
+
});
|
|
150
|
+
ssrInfo.router = router;
|
|
151
|
+
|
|
152
|
+
// We can call initialize() immediately if the router doesn't have any
|
|
153
|
+
// loaders to run on hydration
|
|
154
|
+
if (router.state.initialized) {
|
|
155
|
+
ssrInfo.routerInitialized = true;
|
|
156
|
+
router.initialize();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
router.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
|
161
|
+
reactRouter.UNSAFE_createClientRoutesWithHMRRevalidationOptOut;
|
|
162
|
+
window.__reactRouterInstance = router;
|
|
163
|
+
return router;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @category Router Components
|
|
168
|
+
*/
|
|
169
|
+
function HydratedRouter() {
|
|
170
|
+
var _ssrInfo;
|
|
171
|
+
if (!router) {
|
|
172
|
+
router = createHydratedRouter();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Critical CSS can become stale after code changes, e.g. styles might be
|
|
176
|
+
// removed from a component, but the styles will still be present in the
|
|
177
|
+
// server HTML. This allows our HMR logic to clear the critical CSS state.
|
|
178
|
+
let [criticalCss, setCriticalCss] = React__namespace.useState((_ssrInfo = ssrInfo) == null ? void 0 : _ssrInfo.context.criticalCss );
|
|
179
|
+
{
|
|
180
|
+
if (ssrInfo) {
|
|
181
|
+
window.__reactRouterClearCriticalCss = () => setCriticalCss(undefined);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
let [location, setLocation] = React__namespace.useState(router.state.location);
|
|
185
|
+
React__namespace.useLayoutEffect(() => {
|
|
186
|
+
// If we had to run clientLoaders on hydration, we delay initialization until
|
|
187
|
+
// after we've hydrated to avoid hydration issues from synchronous client loaders
|
|
188
|
+
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
|
189
|
+
ssrInfo.routerInitialized = true;
|
|
190
|
+
ssrInfo.router.initialize();
|
|
191
|
+
}
|
|
192
|
+
}, []);
|
|
193
|
+
React__namespace.useLayoutEffect(() => {
|
|
194
|
+
if (ssrInfo && ssrInfo.router) {
|
|
195
|
+
return ssrInfo.router.subscribe(newState => {
|
|
196
|
+
if (newState.location !== location) {
|
|
197
|
+
setLocation(newState.location);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}, [location]);
|
|
202
|
+
!ssrInfo ? reactRouter.UNSAFE_invariant(false, "ssrInfo unavailable for HydratedRouter") : void 0;
|
|
203
|
+
reactRouter.UNSAFE_useFogOFWarDiscovery(router, ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode);
|
|
204
|
+
|
|
205
|
+
// We need to include a wrapper RemixErrorBoundary here in case the root error
|
|
206
|
+
// boundary also throws and we need to bubble up outside of the router entirely.
|
|
207
|
+
// Then we need a stateful location here so the user can back-button navigate
|
|
208
|
+
// out of there
|
|
209
|
+
return (
|
|
210
|
+
/*#__PURE__*/
|
|
211
|
+
// This fragment is important to ensure we match the <ServerRouter> JSX
|
|
212
|
+
// structure so that useId values hydrate correctly
|
|
213
|
+
React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(reactRouter.UNSAFE_FrameworkContext.Provider, {
|
|
214
|
+
value: {
|
|
215
|
+
manifest: ssrInfo.manifest,
|
|
216
|
+
routeModules: ssrInfo.routeModules,
|
|
217
|
+
future: ssrInfo.context.future,
|
|
218
|
+
criticalCss,
|
|
219
|
+
isSpaMode: ssrInfo.context.isSpaMode
|
|
220
|
+
}
|
|
221
|
+
}, /*#__PURE__*/React__namespace.createElement(reactRouter.UNSAFE_RemixErrorBoundary, {
|
|
222
|
+
location: location
|
|
223
|
+
}, /*#__PURE__*/React__namespace.createElement(RouterProvider, {
|
|
224
|
+
router: router
|
|
225
|
+
}))), /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null))
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function RouterProvider(props) {
|
|
230
|
+
return /*#__PURE__*/React__namespace.createElement(reactRouter.RouterProvider, _extends({
|
|
231
|
+
flushSync: ReactDOM__namespace.flushSync
|
|
232
|
+
}, props));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
exports.HydratedRouter = HydratedRouter;
|
|
236
|
+
exports.RouterProvider = RouterProvider;
|
|
237
|
+
|
|
238
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
239
|
+
|
|
240
|
+
}));
|
|
241
|
+
//# sourceMappingURL=react-router-dom.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router-dom.development.js","sources":["../../lib/dom-export/hydrated-router.tsx","../../lib/dom-export/dom-router-provider.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n UNSAFE_AssetsManifest as AssetsManifest,\n UNSAFE_RouteModules as RouteModules,\n DataRouter,\n HydrationState,\n} from \"react-router\";\nimport {\n UNSAFE_invariant as invariant,\n UNSAFE_FrameworkContext as FrameworkContext,\n UNSAFE_decodeViaTurboStream as decodeViaTurboStream,\n UNSAFE_RemixErrorBoundary as RemixErrorBoundary,\n UNSAFE_createBrowserHistory as createBrowserHistory,\n UNSAFE_createClientRoutes as createClientRoutes,\n UNSAFE_createRouter as createRouter,\n UNSAFE_deserializeErrors as deserializeErrors,\n UNSAFE_getSingleFetchDataStrategy as getSingleFetchDataStrategy,\n UNSAFE_getPatchRoutesOnNavigationFunction as getPatchRoutesOnNavigationFunction,\n UNSAFE_shouldHydrateRouteLoader as shouldHydrateRouteLoader,\n UNSAFE_useFogOFWarDiscovery as useFogOFWarDiscovery,\n UNSAFE_mapRouteProperties as mapRouteProperties,\n UNSAFE_createClientRoutesWithHMRRevalidationOptOut as createClientRoutesWithHMRRevalidationOptOut,\n matchRoutes,\n} from \"react-router\";\nimport { RouterProvider } from \"./dom-router-provider\";\n\ntype SSRInfo = {\n context: NonNullable<(typeof window)[\"__reactRouterContext\"]>;\n routeModules: RouteModules;\n manifest: AssetsManifest;\n stateDecodingPromise:\n | (Promise<void> & {\n value?: unknown;\n error?: unknown;\n })\n | undefined;\n router: DataRouter | undefined;\n routerInitialized: boolean;\n};\n\nlet ssrInfo: SSRInfo | null = null;\nlet router: DataRouter | null = null;\n\nfunction initSsrInfo(): void {\n if (\n !ssrInfo &&\n window.__reactRouterContext &&\n window.__reactRouterManifest &&\n window.__reactRouterRouteModules\n ) {\n ssrInfo = {\n context: window.__reactRouterContext,\n manifest: window.__reactRouterManifest,\n routeModules: window.__reactRouterRouteModules,\n stateDecodingPromise: undefined,\n router: undefined,\n routerInitialized: false,\n };\n }\n}\n\nfunction createHydratedRouter(): DataRouter {\n initSsrInfo();\n\n if (!ssrInfo) {\n throw new Error(\n \"You must be using the SSR features of React Router in order to skip \" +\n \"passing a `router` prop to `<RouterProvider>`\"\n );\n }\n\n // We need to suspend until the initial state snapshot is decoded into\n // window.__reactRouterContext.state\n\n let localSsrInfo = ssrInfo;\n // Note: `stateDecodingPromise` is not coupled to `router` - we'll reach this\n // code potentially many times waiting for our state to arrive, but we'll\n // then only get past here and create the `router` one time\n if (!ssrInfo.stateDecodingPromise) {\n let stream = ssrInfo.context.stream;\n invariant(stream, \"No stream found for single fetch decoding\");\n ssrInfo.context.stream = undefined;\n ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window)\n .then((value) => {\n ssrInfo!.context.state =\n value.value as typeof localSsrInfo.context.state;\n localSsrInfo.stateDecodingPromise!.value = true;\n })\n .catch((e) => {\n localSsrInfo.stateDecodingPromise!.error = e;\n });\n }\n if (ssrInfo.stateDecodingPromise.error) {\n throw ssrInfo.stateDecodingPromise.error;\n }\n if (!ssrInfo.stateDecodingPromise.value) {\n throw ssrInfo.stateDecodingPromise;\n }\n\n let routes = createClientRoutes(\n ssrInfo.manifest.routes,\n ssrInfo.routeModules,\n ssrInfo.context.state,\n ssrInfo.context.isSpaMode\n );\n\n let hydrationData: HydrationState | undefined = undefined;\n if (!ssrInfo.context.isSpaMode) {\n // Create a shallow clone of `loaderData` we can mutate for partial hydration.\n // When a route exports a `clientLoader` and a `HydrateFallback`, the SSR will\n // render the fallback so we need the client to do the same for hydration.\n // The server loader data has already been exposed to these route `clientLoader`'s\n // in `createClientRoutes` above, so we need to clear out the version we pass to\n // `createBrowserRouter` so it initializes and runs the client loaders.\n hydrationData = {\n ...ssrInfo.context.state,\n loaderData: { ...ssrInfo.context.state.loaderData },\n };\n let initialMatches = matchRoutes(\n routes,\n window.location,\n window.__reactRouterContext?.basename\n );\n if (initialMatches) {\n for (let match of initialMatches) {\n let routeId = match.route.id;\n let route = ssrInfo.routeModules[routeId];\n let manifestRoute = ssrInfo.manifest.routes[routeId];\n // Clear out the loaderData to avoid rendering the route component when the\n // route opted into clientLoader hydration and either:\n // * gave us a HydrateFallback\n // * or doesn't have a server loader and we have no data to render\n if (\n route &&\n shouldHydrateRouteLoader(\n manifestRoute,\n route,\n ssrInfo.context.isSpaMode\n ) &&\n (route.HydrateFallback || !manifestRoute.hasLoader)\n ) {\n delete hydrationData.loaderData![routeId];\n } else if (manifestRoute && !manifestRoute.hasLoader) {\n // Since every Remix route gets a `loader` on the client side to load\n // the route JS module, we need to add a `null` value to `loaderData`\n // for any routes that don't have server loaders so our partial\n // hydration logic doesn't kick off the route module loaders during\n // hydration\n hydrationData.loaderData![routeId] = null;\n }\n }\n }\n\n if (hydrationData && hydrationData.errors) {\n // TODO: De-dup this or remove entirely in v7 where single fetch is the\n // only approach and we have already serialized or deserialized on the server\n hydrationData.errors = deserializeErrors(hydrationData.errors);\n }\n }\n\n // We don't use createBrowserRouter here because we need fine-grained control\n // over initialization to support synchronous `clientLoader` flows.\n let router = createRouter({\n routes,\n history: createBrowserHistory(),\n basename: ssrInfo.context.basename,\n hydrationData,\n mapRouteProperties,\n dataStrategy: getSingleFetchDataStrategy(\n ssrInfo.manifest,\n ssrInfo.routeModules,\n () => router\n ),\n patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(\n ssrInfo.manifest,\n ssrInfo.routeModules,\n ssrInfo.context.isSpaMode,\n ssrInfo.context.basename\n ),\n });\n ssrInfo.router = router;\n\n // We can call initialize() immediately if the router doesn't have any\n // loaders to run on hydration\n if (router.state.initialized) {\n ssrInfo.routerInitialized = true;\n router.initialize();\n }\n\n // @ts-ignore\n router.createRoutesForHMR =\n /* spacer so ts-ignore does not affect the right hand of the assignment */\n createClientRoutesWithHMRRevalidationOptOut;\n window.__reactRouterInstance = router;\n\n return router;\n}\n\n/**\n * @category Router Components\n */\nexport function HydratedRouter() {\n if (!router) {\n router = createHydratedRouter();\n }\n\n // Critical CSS can become stale after code changes, e.g. styles might be\n // removed from a component, but the styles will still be present in the\n // server HTML. This allows our HMR logic to clear the critical CSS state.\n let [criticalCss, setCriticalCss] = React.useState(\n process.env.NODE_ENV === \"development\"\n ? ssrInfo?.context.criticalCss\n : undefined\n );\n if (process.env.NODE_ENV === \"development\") {\n if (ssrInfo) {\n window.__reactRouterClearCriticalCss = () => setCriticalCss(undefined);\n }\n }\n\n let [location, setLocation] = React.useState(router.state.location);\n\n React.useLayoutEffect(() => {\n // If we had to run clientLoaders on hydration, we delay initialization until\n // after we've hydrated to avoid hydration issues from synchronous client loaders\n if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {\n ssrInfo.routerInitialized = true;\n ssrInfo.router.initialize();\n }\n }, []);\n\n React.useLayoutEffect(() => {\n if (ssrInfo && ssrInfo.router) {\n return ssrInfo.router.subscribe((newState) => {\n if (newState.location !== location) {\n setLocation(newState.location);\n }\n });\n }\n }, [location]);\n\n invariant(ssrInfo, \"ssrInfo unavailable for HydratedRouter\");\n\n useFogOFWarDiscovery(\n router,\n ssrInfo.manifest,\n ssrInfo.routeModules,\n ssrInfo.context.isSpaMode\n );\n\n // We need to include a wrapper RemixErrorBoundary here in case the root error\n // boundary also throws and we need to bubble up outside of the router entirely.\n // Then we need a stateful location here so the user can back-button navigate\n // out of there\n return (\n // This fragment is important to ensure we match the <ServerRouter> JSX\n // structure so that useId values hydrate correctly\n <>\n <FrameworkContext.Provider\n value={{\n manifest: ssrInfo.manifest,\n routeModules: ssrInfo.routeModules,\n future: ssrInfo.context.future,\n criticalCss,\n isSpaMode: ssrInfo.context.isSpaMode,\n }}\n >\n <RemixErrorBoundary location={location}>\n <RouterProvider router={router} />\n </RemixErrorBoundary>\n </FrameworkContext.Provider>\n {/*\n This fragment is important to ensure we match the <ServerRouter> JSX\n structure so that useId values hydrate correctly\n */}\n <></>\n </>\n );\n}\n","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\n\nimport type { RouterProviderProps as BaseRouterProviderProps } from \"react-router\";\nimport { RouterProvider as BaseRouterProvider } from \"react-router\";\n\nexport { HydratedRouter } from \"./hydrated-router\";\n\nexport type RouterProviderProps = Omit<BaseRouterProviderProps, \"flushSync\">;\n\nexport function RouterProvider(props: Omit<RouterProviderProps, \"flushSync\">) {\n return <BaseRouterProvider flushSync={ReactDOM.flushSync} {...props} />;\n}\n"],"names":["ssrInfo","router","initSsrInfo","window","__reactRouterContext","__reactRouterManifest","__reactRouterRouteModules","context","manifest","routeModules","stateDecodingPromise","undefined","routerInitialized","createHydratedRouter","Error","localSsrInfo","stream","invariant","decodeViaTurboStream","then","value","state","catch","e","error","routes","createClientRoutes","isSpaMode","hydrationData","_window$__reactRouter","_extends","loaderData","initialMatches","matchRoutes","location","basename","match","routeId","route","id","manifestRoute","shouldHydrateRouteLoader","HydrateFallback","hasLoader","errors","deserializeErrors","createRouter","history","createBrowserHistory","mapRouteProperties","dataStrategy","getSingleFetchDataStrategy","patchRoutesOnNavigation","getPatchRoutesOnNavigationFunction","initialized","initialize","createRoutesForHMR","createClientRoutesWithHMRRevalidationOptOut","__reactRouterInstance","HydratedRouter","_ssrInfo","criticalCss","setCriticalCss","React","useState","__reactRouterClearCriticalCss","setLocation","useLayoutEffect","subscribe","newState","useFogOFWarDiscovery","createElement","Fragment","FrameworkContext","Provider","future","RemixErrorBoundary","RouterProvider","props","BaseRouterProvider","flushSync","ReactDOM"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,IAAIA,OAAuB,GAAG,IAAI,CAAA;EAClC,IAAIC,MAAyB,GAAG,IAAI,CAAA;EAEpC,SAASC,WAAWA,GAAS;EAC3B,EAAA,IACE,CAACF,OAAO,IACRG,MAAM,CAACC,oBAAoB,IAC3BD,MAAM,CAACE,qBAAqB,IAC5BF,MAAM,CAACG,yBAAyB,EAChC;EACAN,IAAAA,OAAO,GAAG;QACRO,OAAO,EAAEJ,MAAM,CAACC,oBAAoB;QACpCI,QAAQ,EAAEL,MAAM,CAACE,qBAAqB;QACtCI,YAAY,EAAEN,MAAM,CAACG,yBAAyB;EAC9CI,MAAAA,oBAAoB,EAAEC,SAAS;EAC/BV,MAAAA,MAAM,EAAEU,SAAS;EACjBC,MAAAA,iBAAiB,EAAE,KAAA;OACpB,CAAA;EACH,GAAA;EACF,CAAA;EAEA,SAASC,oBAAoBA,GAAe;EAC1CX,EAAAA,WAAW,EAAE,CAAA;IAEb,IAAI,CAACF,OAAO,EAAE;EACZ,IAAA,MAAM,IAAIc,KAAK,CACb,sEAAsE,GACpE,+CACJ,CAAC,CAAA;EACH,GAAA;;EAEA;EACA;;IAEA,IAAIC,YAAY,GAAGf,OAAO,CAAA;EAC1B;EACA;EACA;EACA,EAAA,IAAI,CAACA,OAAO,CAACU,oBAAoB,EAAE;EACjC,IAAA,IAAIM,MAAM,GAAGhB,OAAO,CAACO,OAAO,CAACS,MAAM,CAAA;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A;;EAED;EACA;EACA;EACA;EACA,EAAA;EAAA;EACE;EACA;EACAoC,IAAAA,gBAAA,CAAAQ,aAAA,CAAAR,gBAAA,CAAAS,QAAA,EACET,IAAAA,eAAAA,gBAAA,CAAAQ,aAAA,CAACE,mCAAgB,CAACC,QAAQ,EAAA;EACxBtD,MAAAA,KAAK,EAAE;UACLZ,QAAQ,EAAER,OAAO,CAACQ,QAAQ;UAC1BC,YAAY,EAAET,OAAO,CAACS,YAAY;EAClCkE,QAAAA,MAAM,EAAE3E,OAAO,CAACO,OAAO,CAACoE,MAAM;UAC9Bd,WAAW;EACXlC,QAAAA,SAAS,EAAE3B,OAAO,CAACO,OAAO,CAACoB,SAAAA;EAC7B,OAAA;EAAE,KAAA,eAEFoC,gBAAA,CAAAQ,aAAA,CAACK,qCAAkB,EAAA;EAAC1C,MAAAA,QAAQ,EAAEA,QAAAA;EAAS,KAAA,eACrC6B,gBAAA,CAAAQ,aAAA,CAACM,cAAc,EAAA;EAAC5E,MAAAA,MAAM,EAAEA,MAAAA;EAAO,KAAE,CACf,CACK,CAAC,eAK5B8D,gBAAA,CAAAQ,aAAA,CAAAR,gBAAA,CAAAS,QAAA,EAAA,IAAI,CACJ,CAAA;EAAC,IAAA;EAEP;;EC7QO,SAASK,cAAcA,CAACC,KAA6C,EAAE;EAC5E,EAAA,oBAAOf,gBAAA,CAAAQ,aAAA,CAACQ,0BAAkB,EAAAjD,QAAA,CAAA;MAACkD,SAAS,EAAEC,mBAAQ,CAACD,SAAAA;KAAeF,EAAAA,KAAK,CAAG,CAAC,CAAA;EACzE;;;;;;;;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Router v7.0.0-pre.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
!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 a(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 i=a(t),n=a(r);function u(){return u=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},u.apply(this,arguments)}let s=null,c=null;function d(){if(!s&&window.__reactRouterContext&&window.__reactRouterManifest&&window.__reactRouterRouteModules&&(s={context:window.__reactRouterContext,manifest:window.__reactRouterManifest,routeModules:window.__reactRouterRouteModules,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;if(!s.stateDecodingPromise){let t=s.context.stream;t||o.UNSAFE_invariant(!1),s.context.stream=void 0,s.stateDecodingPromise=o.UNSAFE_decodeViaTurboStream(t,window).then((t=>{s.context.state=t.value,e.stateDecodingPromise.value=!0})).catch((t=>{e.stateDecodingPromise.error=t}))}if(s.stateDecodingPromise.error)throw s.stateDecodingPromise.error;if(!s.stateDecodingPromise.value)throw s.stateDecodingPromise;let t,r=o.UNSAFE_createClientRoutes(s.manifest.routes,s.routeModules,s.context.state,s.context.isSpaMode);if(!s.context.isSpaMode){var a;t=u({},s.context.state,{loaderData:u({},s.context.state.loaderData)});let e=o.matchRoutes(r,window.location,null==(a=window.__reactRouterContext)?void 0:a.basename);if(e)for(let r of e){let e=r.route.id,a=s.routeModules[e],i=s.manifest.routes[e];a&&o.UNSAFE_shouldHydrateRouteLoader(i,a,s.context.isSpaMode)&&(a.HydrateFallback||!i.hasLoader)?delete t.loaderData[e]:i&&!i.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=o.UNSAFE_deserializeErrors(t.errors))}let i=o.UNSAFE_createRouter({routes:r,history:o.UNSAFE_createBrowserHistory(),basename:s.context.basename,hydrationData:t,mapRouteProperties:o.UNSAFE_mapRouteProperties,dataStrategy:o.UNSAFE_getSingleFetchDataStrategy(s.manifest,s.routeModules,(()=>i)),patchRoutesOnNavigation:o.UNSAFE_getPatchRoutesOnNavigationFunction(s.manifest,s.routeModules,s.context.isSpaMode,s.context.basename)});return s.router=i,i.state.initialized&&(s.routerInitialized=!0,i.initialize()),i.createRoutesForHMR=o.UNSAFE_createClientRoutesWithHMRRevalidationOptOut,window.__reactRouterInstance=i,i}function l(e){return i.createElement(o.RouterProvider,u({flushSync:n.flushSync},e))}e.HydratedRouter=function(){c||(c=d());let[e,t]=i.useState(void 0),[r,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!==r&&a(e.location)}))}),[r]),s||o.UNSAFE_invariant(!1),o.UNSAFE_useFogOFWarDiscovery(c,s.manifest,s.routeModules,s.context.isSpaMode),i.createElement(i.Fragment,null,i.createElement(o.UNSAFE_FrameworkContext.Provider,{value:{manifest:s.manifest,routeModules:s.routeModules,future:s.context.future,criticalCss:e,isSpaMode:s.context.isSpaMode}},i.createElement(o.UNSAFE_RemixErrorBoundary,{location:r},i.createElement(l,{router:c}))),i.createElement(i.Fragment,null))},e.RouterProvider=l,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
12
|
+
//# sourceMappingURL=react-router-dom.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-router-dom.production.min.js","sources":["../../lib/dom-export/hydrated-router.tsx","../../lib/dom-export/dom-router-provider.tsx"],"sourcesContent":["import * as React from \"react\";\n\nimport type {\n UNSAFE_AssetsManifest as AssetsManifest,\n UNSAFE_RouteModules as RouteModules,\n DataRouter,\n HydrationState,\n} from \"react-router\";\nimport {\n UNSAFE_invariant as invariant,\n UNSAFE_FrameworkContext as FrameworkContext,\n UNSAFE_decodeViaTurboStream as decodeViaTurboStream,\n UNSAFE_RemixErrorBoundary as RemixErrorBoundary,\n UNSAFE_createBrowserHistory as createBrowserHistory,\n UNSAFE_createClientRoutes as createClientRoutes,\n UNSAFE_createRouter as createRouter,\n UNSAFE_deserializeErrors as deserializeErrors,\n UNSAFE_getSingleFetchDataStrategy as getSingleFetchDataStrategy,\n UNSAFE_getPatchRoutesOnNavigationFunction as getPatchRoutesOnNavigationFunction,\n UNSAFE_shouldHydrateRouteLoader as shouldHydrateRouteLoader,\n UNSAFE_useFogOFWarDiscovery as useFogOFWarDiscovery,\n UNSAFE_mapRouteProperties as mapRouteProperties,\n UNSAFE_createClientRoutesWithHMRRevalidationOptOut as createClientRoutesWithHMRRevalidationOptOut,\n matchRoutes,\n} from \"react-router\";\nimport { RouterProvider } from \"./dom-router-provider\";\n\ntype SSRInfo = {\n context: NonNullable<(typeof window)[\"__reactRouterContext\"]>;\n routeModules: RouteModules;\n manifest: AssetsManifest;\n stateDecodingPromise:\n | (Promise<void> & {\n value?: unknown;\n error?: unknown;\n })\n | undefined;\n router: DataRouter | undefined;\n routerInitialized: boolean;\n};\n\nlet ssrInfo: SSRInfo | null = null;\nlet router: DataRouter | null = null;\n\nfunction initSsrInfo(): void {\n if (\n !ssrInfo &&\n window.__reactRouterContext &&\n window.__reactRouterManifest &&\n window.__reactRouterRouteModules\n ) {\n ssrInfo = {\n context: window.__reactRouterContext,\n manifest: window.__reactRouterManifest,\n routeModules: window.__reactRouterRouteModules,\n stateDecodingPromise: undefined,\n router: undefined,\n routerInitialized: false,\n };\n }\n}\n\nfunction createHydratedRouter(): DataRouter {\n initSsrInfo();\n\n if (!ssrInfo) {\n throw new Error(\n \"You must be using the SSR features of React Router in order to skip \" +\n \"passing a `router` prop to `<RouterProvider>`\"\n );\n }\n\n // We need to suspend until the initial state snapshot is decoded into\n // window.__reactRouterContext.state\n\n let localSsrInfo = ssrInfo;\n // Note: `stateDecodingPromise` is not coupled to `router` - we'll reach this\n // code potentially many times waiting for our state to arrive, but we'll\n // then only get past here and create the `router` one time\n if (!ssrInfo.stateDecodingPromise) {\n let stream = ssrInfo.context.stream;\n invariant(stream, \"No stream found for single fetch decoding\");\n ssrInfo.context.stream = undefined;\n ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window)\n .then((value) => {\n ssrInfo!.context.state =\n value.value as typeof localSsrInfo.context.state;\n localSsrInfo.stateDecodingPromise!.value = true;\n })\n .catch((e) => {\n localSsrInfo.stateDecodingPromise!.error = e;\n });\n }\n if (ssrInfo.stateDecodingPromise.error) {\n throw ssrInfo.stateDecodingPromise.error;\n }\n if (!ssrInfo.stateDecodingPromise.value) {\n throw ssrInfo.stateDecodingPromise;\n }\n\n let routes = createClientRoutes(\n ssrInfo.manifest.routes,\n ssrInfo.routeModules,\n ssrInfo.context.state,\n ssrInfo.context.isSpaMode\n );\n\n let hydrationData: HydrationState | undefined = undefined;\n if (!ssrInfo.context.isSpaMode) {\n // Create a shallow clone of `loaderData` we can mutate for partial hydration.\n // When a route exports a `clientLoader` and a `HydrateFallback`, the SSR will\n // render the fallback so we need the client to do the same for hydration.\n // The server loader data has already been exposed to these route `clientLoader`'s\n // in `createClientRoutes` above, so we need to clear out the version we pass to\n // `createBrowserRouter` so it initializes and runs the client loaders.\n hydrationData = {\n ...ssrInfo.context.state,\n loaderData: { ...ssrInfo.context.state.loaderData },\n };\n let initialMatches = matchRoutes(\n routes,\n window.location,\n window.__reactRouterContext?.basename\n );\n if (initialMatches) {\n for (let match of initialMatches) {\n let routeId = match.route.id;\n let route = ssrInfo.routeModules[routeId];\n let manifestRoute = ssrInfo.manifest.routes[routeId];\n // Clear out the loaderData to avoid rendering the route component when the\n // route opted into clientLoader hydration and either:\n // * gave us a HydrateFallback\n // * or doesn't have a server loader and we have no data to render\n if (\n route &&\n shouldHydrateRouteLoader(\n manifestRoute,\n route,\n ssrInfo.context.isSpaMode\n ) &&\n (route.HydrateFallback || !manifestRoute.hasLoader)\n ) {\n delete hydrationData.loaderData![routeId];\n } else if (manifestRoute && !manifestRoute.hasLoader) {\n // Since every Remix route gets a `loader` on the client side to load\n // the route JS module, we need to add a `null` value to `loaderData`\n // for any routes that don't have server loaders so our partial\n // hydration logic doesn't kick off the route module loaders during\n // hydration\n hydrationData.loaderData![routeId] = null;\n }\n }\n }\n\n if (hydrationData && hydrationData.errors) {\n // TODO: De-dup this or remove entirely in v7 where single fetch is the\n // only approach and we have already serialized or deserialized on the server\n hydrationData.errors = deserializeErrors(hydrationData.errors);\n }\n }\n\n // We don't use createBrowserRouter here because we need fine-grained control\n // over initialization to support synchronous `clientLoader` flows.\n let router = createRouter({\n routes,\n history: createBrowserHistory(),\n basename: ssrInfo.context.basename,\n hydrationData,\n mapRouteProperties,\n dataStrategy: getSingleFetchDataStrategy(\n ssrInfo.manifest,\n ssrInfo.routeModules,\n () => router\n ),\n patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(\n ssrInfo.manifest,\n ssrInfo.routeModules,\n ssrInfo.context.isSpaMode,\n ssrInfo.context.basename\n ),\n });\n ssrInfo.router = router;\n\n // We can call initialize() immediately if the router doesn't have any\n // loaders to run on hydration\n if (router.state.initialized) {\n ssrInfo.routerInitialized = true;\n router.initialize();\n }\n\n // @ts-ignore\n router.createRoutesForHMR =\n /* spacer so ts-ignore does not affect the right hand of the assignment */\n createClientRoutesWithHMRRevalidationOptOut;\n window.__reactRouterInstance = router;\n\n return router;\n}\n\n/**\n * @category Router Components\n */\nexport function HydratedRouter() {\n if (!router) {\n router = createHydratedRouter();\n }\n\n // Critical CSS can become stale after code changes, e.g. styles might be\n // removed from a component, but the styles will still be present in the\n // server HTML. This allows our HMR logic to clear the critical CSS state.\n let [criticalCss, setCriticalCss] = React.useState(\n process.env.NODE_ENV === \"development\"\n ? ssrInfo?.context.criticalCss\n : undefined\n );\n if (process.env.NODE_ENV === \"development\") {\n if (ssrInfo) {\n window.__reactRouterClearCriticalCss = () => setCriticalCss(undefined);\n }\n }\n\n let [location, setLocation] = React.useState(router.state.location);\n\n React.useLayoutEffect(() => {\n // If we had to run clientLoaders on hydration, we delay initialization until\n // after we've hydrated to avoid hydration issues from synchronous client loaders\n if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {\n ssrInfo.routerInitialized = true;\n ssrInfo.router.initialize();\n }\n }, []);\n\n React.useLayoutEffect(() => {\n if (ssrInfo && ssrInfo.router) {\n return ssrInfo.router.subscribe((newState) => {\n if (newState.location !== location) {\n setLocation(newState.location);\n }\n });\n }\n }, [location]);\n\n invariant(ssrInfo, \"ssrInfo unavailable for HydratedRouter\");\n\n useFogOFWarDiscovery(\n router,\n ssrInfo.manifest,\n ssrInfo.routeModules,\n ssrInfo.context.isSpaMode\n );\n\n // We need to include a wrapper RemixErrorBoundary here in case the root error\n // boundary also throws and we need to bubble up outside of the router entirely.\n // Then we need a stateful location here so the user can back-button navigate\n // out of there\n return (\n // This fragment is important to ensure we match the <ServerRouter> JSX\n // structure so that useId values hydrate correctly\n <>\n <FrameworkContext.Provider\n value={{\n manifest: ssrInfo.manifest,\n routeModules: ssrInfo.routeModules,\n future: ssrInfo.context.future,\n criticalCss,\n isSpaMode: ssrInfo.context.isSpaMode,\n }}\n >\n <RemixErrorBoundary location={location}>\n <RouterProvider router={router} />\n </RemixErrorBoundary>\n </FrameworkContext.Provider>\n {/*\n This fragment is important to ensure we match the <ServerRouter> JSX\n structure so that useId values hydrate correctly\n */}\n <></>\n </>\n );\n}\n","import * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\n\nimport type { RouterProviderProps as BaseRouterProviderProps } from \"react-router\";\nimport { RouterProvider as BaseRouterProvider } from \"react-router\";\n\nexport { HydratedRouter } from \"./hydrated-router\";\n\nexport type RouterProviderProps = Omit<BaseRouterProviderProps, \"flushSync\">;\n\nexport function RouterProvider(props: Omit<RouterProviderProps, \"flushSync\">) {\n return <BaseRouterProvider flushSync={ReactDOM.flushSync} {...props} />;\n}\n"],"names":["ssrInfo","router","createHydratedRouter","window","__reactRouterContext","__reactRouterManifest","__reactRouterRouteModules","context","manifest","routeModules","stateDecodingPromise","undefined","routerInitialized","Error","localSsrInfo","stream","invariant","UNSAFE_invariant","decodeViaTurboStream","then","value","state","catch","e","error","hydrationData","routes","createClientRoutes","UNSAFE_createClientRoutes","isSpaMode","_window$__reactRouter","_extends","loaderData","initialMatches","matchRoutes","location","basename","match","routeId","route","id","manifestRoute","shouldHydrateRouteLoader","UNSAFE_shouldHydrateRouteLoader","HydrateFallback","hasLoader","errors","deserializeErrors","createRouter","history","createBrowserHistory","mapRouteProperties","UNSAFE_mapRouteProperties","dataStrategy","getSingleFetchDataStrategy","UNSAFE_getSingleFetchDataStrategy","patchRoutesOnNavigation","getPatchRoutesOnNavigationFunction","UNSAFE_getPatchRoutesOnNavigationFunction","initialized","initialize","createRoutesForHMR","createClientRoutesWithHMRRevalidationOptOut","__reactRouterInstance","RouterProvider","props","React","createElement","BaseRouterProvider","flushSync","ReactDOM","criticalCss","setCriticalCss","useState","setLocation","useLayoutEffect","subscribe","newState","useFogOFWarDiscovery","Fragment","FrameworkContext","UNSAFE_FrameworkContext","Provider","future","RemixErrorBoundary"],"mappings":";;;;;;;;;;y5BAyCA,IAAIA,EAA0B,KAC1BC,EAA4B,KAoBhC,SAASC,IAGP,IAnBGF,GACDG,OAAOC,sBACPD,OAAOE,uBACPF,OAAOG,4BAEPN,EAAU,CACRO,QAASJ,OAAOC,qBAChBI,SAAUL,OAAOE,sBACjBI,aAAcN,OAAOG,0BACrBI,0BAAsBC,EACtBV,YAAQU,EACRC,mBA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