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.
Files changed (84) hide show
  1. package/CHANGELOG.md +307 -0
  2. package/README.md +1 -14
  3. package/dist/dom-export.d.ts +3 -0
  4. package/dist/dom-export.mjs +205 -0
  5. package/dist/dom-export.mjs.map +1 -0
  6. package/dist/index.d.ts +74 -29
  7. package/dist/index.mjs +11551 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/lib/components.d.ts +250 -35
  10. package/dist/lib/context.d.ts +20 -7
  11. package/dist/lib/dom/dom.d.ts +123 -0
  12. package/dist/lib/dom/global.d.ts +40 -0
  13. package/dist/lib/dom/lib.d.ts +940 -0
  14. package/dist/lib/dom/server.d.ts +41 -0
  15. package/dist/lib/dom/ssr/components.d.ts +123 -0
  16. package/dist/lib/dom/ssr/data.d.ts +7 -0
  17. package/dist/lib/dom/ssr/entry.d.ts +47 -0
  18. package/dist/lib/dom/ssr/errorBoundaries.d.ts +36 -0
  19. package/dist/lib/dom/ssr/errors.d.ts +2 -0
  20. package/dist/lib/dom/ssr/fallback.d.ts +2 -0
  21. package/dist/lib/dom/ssr/fog-of-war.d.ts +28 -0
  22. package/dist/lib/dom/ssr/invariant.d.ts +2 -0
  23. package/dist/lib/dom/ssr/links.d.ts +25 -0
  24. package/dist/lib/dom/ssr/markup.d.ts +5 -0
  25. package/dist/lib/dom/ssr/routeModules.d.ts +141 -0
  26. package/dist/lib/dom/ssr/routes-test-stub.d.ts +59 -0
  27. package/dist/lib/dom/ssr/routes.d.ts +32 -0
  28. package/dist/lib/dom/ssr/server.d.ts +16 -0
  29. package/dist/lib/dom/ssr/single-fetch.d.ts +37 -0
  30. package/dist/lib/dom-export/dom-router-provider.d.ts +5 -0
  31. package/dist/lib/dom-export/hydrated-router.d.ts +5 -0
  32. package/dist/lib/dom-export.d.ts +3 -0
  33. package/dist/lib/hooks.d.ts +286 -57
  34. package/dist/lib/router/history.d.ts +253 -0
  35. package/dist/lib/router/links.d.ts +104 -0
  36. package/dist/lib/router/router.d.ts +540 -0
  37. package/dist/lib/router/utils.d.ts +505 -0
  38. package/dist/lib/server-runtime/build.d.ts +38 -0
  39. package/dist/lib/server-runtime/cookies.d.ts +62 -0
  40. package/dist/lib/server-runtime/crypto.d.ts +2 -0
  41. package/dist/lib/server-runtime/data.d.ts +15 -0
  42. package/dist/lib/server-runtime/dev.d.ts +8 -0
  43. package/dist/lib/server-runtime/entry.d.ts +3 -0
  44. package/dist/lib/server-runtime/errors.d.ts +51 -0
  45. package/dist/lib/server-runtime/headers.d.ts +3 -0
  46. package/dist/lib/server-runtime/invariant.d.ts +2 -0
  47. package/dist/lib/server-runtime/jsonify.d.ts +33 -0
  48. package/dist/lib/server-runtime/markup.d.ts +1 -0
  49. package/dist/lib/server-runtime/mode.d.ts +9 -0
  50. package/dist/lib/server-runtime/responses.d.ts +37 -0
  51. package/dist/lib/server-runtime/routeMatching.d.ts +8 -0
  52. package/dist/lib/server-runtime/routeModules.d.ts +212 -0
  53. package/dist/lib/server-runtime/routes.d.ts +31 -0
  54. package/dist/lib/server-runtime/server.d.ts +5 -0
  55. package/dist/lib/server-runtime/serverHandoff.d.ts +11 -0
  56. package/dist/lib/server-runtime/sessions/cookieStorage.d.ts +19 -0
  57. package/dist/lib/server-runtime/sessions/memoryStorage.d.ts +17 -0
  58. package/dist/lib/server-runtime/sessions.d.ts +140 -0
  59. package/dist/lib/server-runtime/single-fetch.d.ts +30 -0
  60. package/dist/lib/server-runtime/typecheck.d.ts +4 -0
  61. package/dist/lib/server-runtime/warnings.d.ts +1 -0
  62. package/dist/lib/types.d.ts +71 -0
  63. package/dist/lib/types.mjs +10 -0
  64. package/dist/main-dom-export.js +19 -0
  65. package/dist/main.js +1 -1
  66. package/dist/react-router-dom.development.js +199 -0
  67. package/dist/react-router-dom.development.js.map +1 -0
  68. package/dist/react-router-dom.production.min.js +12 -0
  69. package/dist/react-router-dom.production.min.js.map +1 -0
  70. package/dist/react-router.development.js +12271 -1129
  71. package/dist/react-router.development.js.map +1 -1
  72. package/dist/react-router.production.min.js +2 -2
  73. package/dist/react-router.production.min.js.map +1 -1
  74. package/dist/umd/react-router-dom.development.js +241 -0
  75. package/dist/umd/react-router-dom.development.js.map +1 -0
  76. package/dist/umd/react-router-dom.production.min.js +12 -0
  77. package/dist/umd/react-router-dom.production.min.js.map +1 -0
  78. package/dist/umd/react-router.development.js +12459 -1224
  79. package/dist/umd/react-router.development.js.map +1 -1
  80. package/dist/umd/react-router.production.min.js +2 -2
  81. package/dist/umd/react-router.production.min.js.map +1 -1
  82. package/package.json +35 -6
  83. package/dist/index.js +0 -1467
  84. package/dist/index.js.map +0 -1
@@ -0,0 +1,10 @@
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
+ */
@@ -0,0 +1,19 @@
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
+ 'use strict';
12
+
13
+ /* eslint-env node */
14
+
15
+ if (process.env.NODE_ENV === "production") {
16
+ module.exports = require("./umd/react-router-dom.production.min.js");
17
+ } else {
18
+ module.exports = require("./umd/react-router-dom.development.js");
19
+ }
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v6.26.2
2
+ * React Router v7.0.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -0,0 +1,199 @@
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
+ import * as React from 'react';
12
+ import * as ReactDOM from 'react-dom';
13
+ 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';
14
+
15
+ let ssrInfo = null;
16
+ let router = null;
17
+ function initSsrInfo() {
18
+ if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
19
+ ssrInfo = {
20
+ context: window.__reactRouterContext,
21
+ manifest: window.__reactRouterManifest,
22
+ routeModules: window.__reactRouterRouteModules,
23
+ stateDecodingPromise: undefined,
24
+ router: undefined,
25
+ routerInitialized: false
26
+ };
27
+ }
28
+ }
29
+ function createHydratedRouter() {
30
+ initSsrInfo();
31
+ if (!ssrInfo) {
32
+ throw new Error("You must be using the SSR features of React Router in order to skip " + "passing a `router` prop to `<RouterProvider>`");
33
+ }
34
+
35
+ // We need to suspend until the initial state snapshot is decoded into
36
+ // window.__reactRouterContext.state
37
+
38
+ let localSsrInfo = ssrInfo;
39
+ // Note: `stateDecodingPromise` is not coupled to `router` - we'll reach this
40
+ // code potentially many times waiting for our state to arrive, but we'll
41
+ // then only get past here and create the `router` one time
42
+ if (!ssrInfo.stateDecodingPromise) {
43
+ let stream = ssrInfo.context.stream;
44
+ !stream ? UNSAFE_invariant(false, "No stream found for single fetch decoding") : void 0;
45
+ ssrInfo.context.stream = undefined;
46
+ ssrInfo.stateDecodingPromise = UNSAFE_decodeViaTurboStream(stream, window).then(value => {
47
+ ssrInfo.context.state = value.value;
48
+ localSsrInfo.stateDecodingPromise.value = true;
49
+ }).catch(e => {
50
+ localSsrInfo.stateDecodingPromise.error = e;
51
+ });
52
+ }
53
+ if (ssrInfo.stateDecodingPromise.error) {
54
+ throw ssrInfo.stateDecodingPromise.error;
55
+ }
56
+ if (!ssrInfo.stateDecodingPromise.value) {
57
+ throw ssrInfo.stateDecodingPromise;
58
+ }
59
+ let routes = UNSAFE_createClientRoutes(ssrInfo.manifest.routes, ssrInfo.routeModules, ssrInfo.context.state, ssrInfo.context.isSpaMode);
60
+ let hydrationData = undefined;
61
+ if (!ssrInfo.context.isSpaMode) {
62
+ // Create a shallow clone of `loaderData` we can mutate for partial hydration.
63
+ // When a route exports a `clientLoader` and a `HydrateFallback`, the SSR will
64
+ // render the fallback so we need the client to do the same for hydration.
65
+ // The server loader data has already been exposed to these route `clientLoader`'s
66
+ // in `createClientRoutes` above, so we need to clear out the version we pass to
67
+ // `createBrowserRouter` so it initializes and runs the client loaders.
68
+ hydrationData = {
69
+ ...ssrInfo.context.state,
70
+ loaderData: {
71
+ ...ssrInfo.context.state.loaderData
72
+ }
73
+ };
74
+ let initialMatches = matchRoutes(routes, window.location, window.__reactRouterContext?.basename);
75
+ if (initialMatches) {
76
+ for (let match of initialMatches) {
77
+ let routeId = match.route.id;
78
+ let route = ssrInfo.routeModules[routeId];
79
+ let manifestRoute = ssrInfo.manifest.routes[routeId];
80
+ // Clear out the loaderData to avoid rendering the route component when the
81
+ // route opted into clientLoader hydration and either:
82
+ // * gave us a HydrateFallback
83
+ // * or doesn't have a server loader and we have no data to render
84
+ if (route && UNSAFE_shouldHydrateRouteLoader(manifestRoute, route, ssrInfo.context.isSpaMode) && (route.HydrateFallback || !manifestRoute.hasLoader)) {
85
+ delete hydrationData.loaderData[routeId];
86
+ } else if (manifestRoute && !manifestRoute.hasLoader) {
87
+ // Since every Remix route gets a `loader` on the client side to load
88
+ // the route JS module, we need to add a `null` value to `loaderData`
89
+ // for any routes that don't have server loaders so our partial
90
+ // hydration logic doesn't kick off the route module loaders during
91
+ // hydration
92
+ hydrationData.loaderData[routeId] = null;
93
+ }
94
+ }
95
+ }
96
+ if (hydrationData && hydrationData.errors) {
97
+ // TODO: De-dup this or remove entirely in v7 where single fetch is the
98
+ // only approach and we have already serialized or deserialized on the server
99
+ hydrationData.errors = UNSAFE_deserializeErrors(hydrationData.errors);
100
+ }
101
+ }
102
+
103
+ // We don't use createBrowserRouter here because we need fine-grained control
104
+ // over initialization to support synchronous `clientLoader` flows.
105
+ let router = UNSAFE_createRouter({
106
+ routes,
107
+ history: UNSAFE_createBrowserHistory(),
108
+ basename: ssrInfo.context.basename,
109
+ hydrationData,
110
+ mapRouteProperties: UNSAFE_mapRouteProperties,
111
+ dataStrategy: UNSAFE_getSingleFetchDataStrategy(ssrInfo.manifest, ssrInfo.routeModules, () => router),
112
+ patchRoutesOnNavigation: UNSAFE_getPatchRoutesOnNavigationFunction(ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode, ssrInfo.context.basename)
113
+ });
114
+ ssrInfo.router = router;
115
+
116
+ // We can call initialize() immediately if the router doesn't have any
117
+ // loaders to run on hydration
118
+ if (router.state.initialized) {
119
+ ssrInfo.routerInitialized = true;
120
+ router.initialize();
121
+ }
122
+
123
+ // @ts-ignore
124
+ router.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
125
+ UNSAFE_createClientRoutesWithHMRRevalidationOptOut;
126
+ window.__reactRouterInstance = router;
127
+ return router;
128
+ }
129
+
130
+ /**
131
+ * @category Router Components
132
+ */
133
+ function HydratedRouter() {
134
+ if (!router) {
135
+ router = createHydratedRouter();
136
+ }
137
+
138
+ // Critical CSS can become stale after code changes, e.g. styles might be
139
+ // removed from a component, but the styles will still be present in the
140
+ // server HTML. This allows our HMR logic to clear the critical CSS state.
141
+ let [criticalCss, setCriticalCss] = React.useState(ssrInfo?.context.criticalCss );
142
+ {
143
+ if (ssrInfo) {
144
+ window.__reactRouterClearCriticalCss = () => setCriticalCss(undefined);
145
+ }
146
+ }
147
+ let [location, setLocation] = React.useState(router.state.location);
148
+ React.useLayoutEffect(() => {
149
+ // If we had to run clientLoaders on hydration, we delay initialization until
150
+ // after we've hydrated to avoid hydration issues from synchronous client loaders
151
+ if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
152
+ ssrInfo.routerInitialized = true;
153
+ ssrInfo.router.initialize();
154
+ }
155
+ }, []);
156
+ React.useLayoutEffect(() => {
157
+ if (ssrInfo && ssrInfo.router) {
158
+ return ssrInfo.router.subscribe(newState => {
159
+ if (newState.location !== location) {
160
+ setLocation(newState.location);
161
+ }
162
+ });
163
+ }
164
+ }, [location]);
165
+ !ssrInfo ? UNSAFE_invariant(false, "ssrInfo unavailable for HydratedRouter") : void 0;
166
+ UNSAFE_useFogOFWarDiscovery(router, ssrInfo.manifest, ssrInfo.routeModules, ssrInfo.context.isSpaMode);
167
+
168
+ // We need to include a wrapper RemixErrorBoundary here in case the root error
169
+ // boundary also throws and we need to bubble up outside of the router entirely.
170
+ // Then we need a stateful location here so the user can back-button navigate
171
+ // out of there
172
+ return (
173
+ /*#__PURE__*/
174
+ // This fragment is important to ensure we match the <ServerRouter> JSX
175
+ // structure so that useId values hydrate correctly
176
+ React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UNSAFE_FrameworkContext.Provider, {
177
+ value: {
178
+ manifest: ssrInfo.manifest,
179
+ routeModules: ssrInfo.routeModules,
180
+ future: ssrInfo.context.future,
181
+ criticalCss,
182
+ isSpaMode: ssrInfo.context.isSpaMode
183
+ }
184
+ }, /*#__PURE__*/React.createElement(UNSAFE_RemixErrorBoundary, {
185
+ location: location
186
+ }, /*#__PURE__*/React.createElement(RouterProvider, {
187
+ router: router
188
+ }))), /*#__PURE__*/React.createElement(React.Fragment, null))
189
+ );
190
+ }
191
+
192
+ function RouterProvider(props) {
193
+ return /*#__PURE__*/React.createElement(RouterProvider$1, Object.assign({
194
+ flushSync: ReactDOM.flushSync
195
+ }, props));
196
+ }
197
+
198
+ export { HydratedRouter, RouterProvider };
199
+ //# 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","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","criticalCss","setCriticalCss","React","useState","__reactRouterClearCriticalCss","setLocation","useLayoutEffect","subscribe","newState","useFogOFWarDiscovery","createElement","Fragment","FrameworkContext","Provider","future","RemixErrorBoundary","RouterProvider","props","BaseRouterProvider","Object","assign","flushSync","ReactDOM"],"mappings":";;;;;;;;;;;;;;AAyCA,IAAIA,OAAuB,GAAG,IAAI,CAAA;AAClC,IAAIC,MAAyB,GAAG,IAAI,CAAA;AAEpC,SAASC,WAAWA,GAAS;AAC3B,EAAA,IACE,CAACF,OAAO,IACRG,MAAM,CAACC,oBAAoB,IAC3BD,MAAM,CAACE,qBAAqB,IAC5BF,MAAM,CAACG,yBAAyB,EAChC;AACAN,IAAAA,OAAO,GAAG;MACRO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AC5E,oBAAOf,KAAA,CAAAQ,aAAA,CAACQ,gBAAkB,EAAAC,MAAA,CAAAC,MAAA,CAAA;IAAAC,SAAA,EAAYC,QAAQ,CAACD,SAAAA;GAAeJ,EAAAA,KAAK,CAAG,CAAC,CAAA;AACzE;;;;"}
@@ -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
+ import*as e from"react";import*as t from"react-dom";import{UNSAFE_invariant as o,UNSAFE_useFogOFWarDiscovery as r,UNSAFE_FrameworkContext as a,UNSAFE_RemixErrorBoundary as i,UNSAFE_decodeViaTurboStream as n,UNSAFE_createClientRoutes as s,matchRoutes as u,UNSAFE_shouldHydrateRouteLoader as c,UNSAFE_deserializeErrors as d,UNSAFE_createRouter as l,UNSAFE_createBrowserHistory as m,UNSAFE_mapRouteProperties as f,UNSAFE_getSingleFetchDataStrategy as w,UNSAFE_getPatchRoutesOnNavigationFunction as x,UNSAFE_createClientRoutesWithHMRRevalidationOptOut as M,RouterProvider as R}from"react-router";let p=null,g=null;function _(){if(!p&&window.__reactRouterContext&&window.__reactRouterManifest&&window.__reactRouterRouteModules&&(p={context:window.__reactRouterContext,manifest:window.__reactRouterManifest,routeModules:window.__reactRouterRouteModules,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.__reactRouterContext?.basename);if(e)for(let o of e){let e=o.route.id,r=p.routeModules[e],a=p.manifest.routes[e];r&&c(a,r,p.context.isSpaMode)&&(r.HydrateFallback||!a.hasLoader)?delete t.loaderData[e]:a&&!a.hasLoader&&(t.loaderData[e]=null)}t&&t.errors&&(t.errors=d(t.errors))}let a=l({routes:r,history:m(),basename:p.context.basename,hydrationData:t,mapRouteProperties:f,dataStrategy:w(p.manifest,p.routeModules,(()=>a)),patchRoutesOnNavigation:x(p.manifest,p.routeModules,p.context.isSpaMode,p.context.basename)});return p.router=a,a.state.initialized&&(p.routerInitialized=!0,a.initialize()),a.createRoutesForHMR=M,window.__reactRouterInstance=a,a}function D(){g||(g=_());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(a.Provider,{value:{manifest:p.manifest,routeModules:p.routeModules,future:p.context.future,criticalCss:t,isSpaMode:p.context.isSpaMode}},e.createElement(i,{location:s},e.createElement(S,{router:g}))),e.createElement(e.Fragment,null))}function S(o){return e.createElement(R,Object.assign({flushSync:t.flushSync},o))}export{D as HydratedRouter,S as RouterProvider};
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","decodeViaTurboStream","then","value","state","catch","e","error","hydrationData","routes","createClientRoutes","isSpaMode","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","criticalCss","setCriticalCss","React","useState","setLocation","useLayoutEffect","subscribe","newState","useFogOFWarDiscovery","createElement","Fragment","FrameworkContext","Provider","future","RemixErrorBoundary","RouterProvider","props","BaseRouterProvider","Object","assign","flushSync","ReactDOM"],"mappings":";;;;;;;;;;glBAyCA,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,mBAAmB,KAQlBZ,EACH,MAAM,IAAIa,MACR,qHAQJ,IAAIC,EAAed,EAInB,IAAKA,EAAQU,qBAAsB,CACjC,IAAIK,EAASf,EAAQO,QAAQQ,OACnBA,GAAVC,GAAS,GACThB,EAAQO,QAAQQ,YAASJ,EACzBX,EAAQU,qBAAuBO,EAAqBF,EAAQZ,QACzDe,MAAMC,IACLnB,EAASO,QAAQa,MACfD,EAAMA,MACRL,EAAaJ,qBAAsBS,OAAQ,CAAI,IAEhDE,OAAOC,IACNR,EAAaJ,qBAAsBa,MAAQD,CAAC,GAElD,C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