react-router 0.0.0-experimental-aecfb0db1 → 0.0.0-experimental-e6fb6e074
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 +18 -753
- package/README.md +14 -5
- package/dist/index.d.ts +30 -0
- package/dist/index.js +1501 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/components.d.ts +157 -0
- package/dist/lib/context.d.ts +102 -0
- package/dist/lib/deprecations.d.ts +4 -0
- package/dist/lib/hooks.d.ts +181 -0
- package/dist/main.js +19 -0
- package/dist/react-router.development.js +1397 -0
- package/dist/react-router.development.js.map +1 -0
- package/dist/react-router.production.min.js +12 -0
- package/dist/react-router.production.min.js.map +1 -0
- package/dist/umd/react-router.development.js +1624 -0
- package/dist/umd/react-router.development.js.map +1 -0
- package/dist/umd/react-router.production.min.js +12 -0
- package/dist/umd/react-router.production.min.js.map +1 -0
- package/package.json +9 -82
- package/dist/development/chunk-RXFCVJK2.mjs +0 -11495
- package/dist/development/dom-export.d.mts +0 -23
- package/dist/development/dom-export.d.ts +0 -22
- package/dist/development/dom-export.js +0 -246
- package/dist/development/dom-export.mjs +0 -225
- package/dist/development/index.d.mts +0 -800
- package/dist/development/index.d.ts +0 -2530
- package/dist/development/index.js +0 -11645
- package/dist/development/index.mjs +0 -246
- package/dist/development/lib/types/route-module.d.mts +0 -208
- package/dist/development/lib/types/route-module.d.ts +0 -208
- package/dist/development/lib/types/route-module.js +0 -28
- package/dist/development/lib/types/route-module.mjs +0 -10
- package/dist/development/lib-BJBhVBWN.d.mts +0 -1736
- package/dist/development/route-data-BmDen1H_.d.mts +0 -1749
- package/dist/development/route-data-fNWkI-4T.d.ts +0 -1749
- package/dist/production/chunk-TLRBG5AD.mjs +0 -11495
- package/dist/production/dom-export.d.mts +0 -23
- package/dist/production/dom-export.d.ts +0 -22
- package/dist/production/dom-export.js +0 -246
- package/dist/production/dom-export.mjs +0 -225
- package/dist/production/index.d.mts +0 -800
- package/dist/production/index.d.ts +0 -2530
- package/dist/production/index.js +0 -11645
- package/dist/production/index.mjs +0 -246
- package/dist/production/lib/types/route-module.d.mts +0 -208
- package/dist/production/lib/types/route-module.d.ts +0 -208
- package/dist/production/lib/types/route-module.js +0 -28
- package/dist/production/lib/types/route-module.mjs +0 -10
- package/dist/production/lib-BJBhVBWN.d.mts +0 -1736
- package/dist/production/route-data-BmDen1H_.d.mts +0 -1749
- package/dist/production/route-data-fNWkI-4T.d.ts +0 -1749
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { R as RouterProviderProps$1 } from './lib-BJBhVBWN.mjs';
|
|
3
|
-
import { R as RouterInit } from './route-data-BmDen1H_.mjs';
|
|
4
|
-
|
|
5
|
-
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
6
|
-
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
7
|
-
|
|
8
|
-
interface HydratedRouterProps {
|
|
9
|
-
/**
|
|
10
|
-
* Context object to passed through to `createBrowserRouter` and made available
|
|
11
|
-
* to `clientLoader`/`clientActon` functions
|
|
12
|
-
*/
|
|
13
|
-
unstable_getContext?: RouterInit["unstable_getContext"];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Framework-mode router component to be used in `entry.client.tsx` to hydrate a
|
|
17
|
-
* router from a `ServerRouter`
|
|
18
|
-
*
|
|
19
|
-
* @category Component Routers
|
|
20
|
-
*/
|
|
21
|
-
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
|
22
|
-
|
|
23
|
-
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { RouterProviderProps as RouterProviderProps$1, RouterInit } from 'react-router';
|
|
3
|
-
|
|
4
|
-
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
5
|
-
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
6
|
-
|
|
7
|
-
interface HydratedRouterProps {
|
|
8
|
-
/**
|
|
9
|
-
* Context object to passed through to `createBrowserRouter` and made available
|
|
10
|
-
* to `clientLoader`/`clientActon` functions
|
|
11
|
-
*/
|
|
12
|
-
unstable_getContext?: RouterInit["unstable_getContext"];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Framework-mode router component to be used in `entry.client.tsx` to hydrate a
|
|
16
|
-
* router from a `ServerRouter`
|
|
17
|
-
*
|
|
18
|
-
* @category Component Routers
|
|
19
|
-
*/
|
|
20
|
-
declare function HydratedRouter(props: HydratedRouterProps): React.JSX.Element;
|
|
21
|
-
|
|
22
|
-
export { HydratedRouter, RouterProvider, type RouterProviderProps };
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router v0.0.0-experimental-aecfb0db1
|
|
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
|
-
var __create = Object.create;
|
|
13
|
-
var __defProp = Object.defineProperty;
|
|
14
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
-
var __export = (target, all) => {
|
|
19
|
-
for (var name in all)
|
|
20
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
-
};
|
|
22
|
-
var __copyProps = (to, from, except, desc) => {
|
|
23
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
-
for (let key of __getOwnPropNames(from))
|
|
25
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
-
}
|
|
28
|
-
return to;
|
|
29
|
-
};
|
|
30
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
-
mod
|
|
37
|
-
));
|
|
38
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
-
|
|
40
|
-
// dom-export.ts
|
|
41
|
-
var dom_export_exports = {};
|
|
42
|
-
__export(dom_export_exports, {
|
|
43
|
-
HydratedRouter: () => HydratedRouter,
|
|
44
|
-
RouterProvider: () => RouterProvider
|
|
45
|
-
});
|
|
46
|
-
module.exports = __toCommonJS(dom_export_exports);
|
|
47
|
-
|
|
48
|
-
// lib/dom-export/dom-router-provider.tsx
|
|
49
|
-
var React = __toESM(require("react"));
|
|
50
|
-
var ReactDOM = __toESM(require("react-dom"));
|
|
51
|
-
var import_react_router = require("react-router");
|
|
52
|
-
function RouterProvider(props) {
|
|
53
|
-
return /* @__PURE__ */ React.createElement(import_react_router.RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// lib/dom-export/hydrated-router.tsx
|
|
57
|
-
var React2 = __toESM(require("react"));
|
|
58
|
-
var import_react_router2 = require("react-router");
|
|
59
|
-
var ssrInfo = null;
|
|
60
|
-
var router = null;
|
|
61
|
-
function initSsrInfo() {
|
|
62
|
-
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
|
63
|
-
if (window.__reactRouterManifest.sri === true) {
|
|
64
|
-
const importMap = document.querySelector("script[rr-importmap]");
|
|
65
|
-
if (importMap?.textContent) {
|
|
66
|
-
try {
|
|
67
|
-
window.__reactRouterManifest.sri = JSON.parse(
|
|
68
|
-
importMap.textContent
|
|
69
|
-
).integrity;
|
|
70
|
-
} catch (err) {
|
|
71
|
-
console.error("Failed to parse import map", err);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
ssrInfo = {
|
|
76
|
-
context: window.__reactRouterContext,
|
|
77
|
-
manifest: window.__reactRouterManifest,
|
|
78
|
-
routeModules: window.__reactRouterRouteModules,
|
|
79
|
-
stateDecodingPromise: void 0,
|
|
80
|
-
router: void 0,
|
|
81
|
-
routerInitialized: false
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function createHydratedRouter({
|
|
86
|
-
unstable_getContext
|
|
87
|
-
}) {
|
|
88
|
-
initSsrInfo();
|
|
89
|
-
if (!ssrInfo) {
|
|
90
|
-
throw new Error(
|
|
91
|
-
"You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
let localSsrInfo = ssrInfo;
|
|
95
|
-
if (!ssrInfo.stateDecodingPromise) {
|
|
96
|
-
let stream = ssrInfo.context.stream;
|
|
97
|
-
(0, import_react_router2.UNSAFE_invariant)(stream, "No stream found for single fetch decoding");
|
|
98
|
-
ssrInfo.context.stream = void 0;
|
|
99
|
-
ssrInfo.stateDecodingPromise = (0, import_react_router2.UNSAFE_decodeViaTurboStream)(stream, window).then((value) => {
|
|
100
|
-
ssrInfo.context.state = value.value;
|
|
101
|
-
localSsrInfo.stateDecodingPromise.value = true;
|
|
102
|
-
}).catch((e) => {
|
|
103
|
-
localSsrInfo.stateDecodingPromise.error = e;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
if (ssrInfo.stateDecodingPromise.error) {
|
|
107
|
-
throw ssrInfo.stateDecodingPromise.error;
|
|
108
|
-
}
|
|
109
|
-
if (!ssrInfo.stateDecodingPromise.value) {
|
|
110
|
-
throw ssrInfo.stateDecodingPromise;
|
|
111
|
-
}
|
|
112
|
-
let routes = (0, import_react_router2.UNSAFE_createClientRoutes)(
|
|
113
|
-
ssrInfo.manifest.routes,
|
|
114
|
-
ssrInfo.routeModules,
|
|
115
|
-
ssrInfo.context.state,
|
|
116
|
-
ssrInfo.context.ssr,
|
|
117
|
-
ssrInfo.context.isSpaMode
|
|
118
|
-
);
|
|
119
|
-
let hydrationData = void 0;
|
|
120
|
-
if (ssrInfo.context.isSpaMode) {
|
|
121
|
-
let { loaderData } = ssrInfo.context.state;
|
|
122
|
-
if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
|
|
123
|
-
hydrationData = {
|
|
124
|
-
loaderData: {
|
|
125
|
-
root: loaderData.root
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
hydrationData = (0, import_react_router2.UNSAFE_getHydrationData)(
|
|
131
|
-
ssrInfo.context.state,
|
|
132
|
-
routes,
|
|
133
|
-
(routeId) => ({
|
|
134
|
-
clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
|
|
135
|
-
hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
|
|
136
|
-
hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
|
|
137
|
-
}),
|
|
138
|
-
window.location,
|
|
139
|
-
window.__reactRouterContext?.basename,
|
|
140
|
-
ssrInfo.context.isSpaMode
|
|
141
|
-
);
|
|
142
|
-
if (hydrationData && hydrationData.errors) {
|
|
143
|
-
hydrationData.errors = (0, import_react_router2.UNSAFE_deserializeErrors)(hydrationData.errors);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
let router2 = (0, import_react_router2.UNSAFE_createRouter)({
|
|
147
|
-
routes,
|
|
148
|
-
history: (0, import_react_router2.UNSAFE_createBrowserHistory)(),
|
|
149
|
-
basename: ssrInfo.context.basename,
|
|
150
|
-
unstable_getContext,
|
|
151
|
-
hydrationData,
|
|
152
|
-
hydrationRouteProperties: import_react_router2.UNSAFE_hydrationRouteProperties,
|
|
153
|
-
mapRouteProperties: import_react_router2.UNSAFE_mapRouteProperties,
|
|
154
|
-
future: {
|
|
155
|
-
unstable_middleware: ssrInfo.context.future.unstable_middleware
|
|
156
|
-
},
|
|
157
|
-
dataStrategy: (0, import_react_router2.UNSAFE_getTurboStreamSingleFetchDataStrategy)(
|
|
158
|
-
() => router2,
|
|
159
|
-
ssrInfo.manifest,
|
|
160
|
-
ssrInfo.routeModules,
|
|
161
|
-
ssrInfo.context.ssr,
|
|
162
|
-
ssrInfo.context.basename
|
|
163
|
-
),
|
|
164
|
-
patchRoutesOnNavigation: (0, import_react_router2.UNSAFE_getPatchRoutesOnNavigationFunction)(
|
|
165
|
-
ssrInfo.manifest,
|
|
166
|
-
ssrInfo.routeModules,
|
|
167
|
-
ssrInfo.context.ssr,
|
|
168
|
-
ssrInfo.context.routeDiscovery,
|
|
169
|
-
ssrInfo.context.isSpaMode,
|
|
170
|
-
ssrInfo.context.basename
|
|
171
|
-
)
|
|
172
|
-
});
|
|
173
|
-
ssrInfo.router = router2;
|
|
174
|
-
if (router2.state.initialized) {
|
|
175
|
-
ssrInfo.routerInitialized = true;
|
|
176
|
-
router2.initialize();
|
|
177
|
-
}
|
|
178
|
-
router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
|
179
|
-
import_react_router2.UNSAFE_createClientRoutesWithHMRRevalidationOptOut;
|
|
180
|
-
window.__reactRouterDataRouter = router2;
|
|
181
|
-
return router2;
|
|
182
|
-
}
|
|
183
|
-
function HydratedRouter(props) {
|
|
184
|
-
if (!router) {
|
|
185
|
-
router = createHydratedRouter({
|
|
186
|
-
unstable_getContext: props.unstable_getContext
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
let [criticalCss, setCriticalCss] = React2.useState(
|
|
190
|
-
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
|
191
|
-
);
|
|
192
|
-
if (process.env.NODE_ENV === "development") {
|
|
193
|
-
if (ssrInfo) {
|
|
194
|
-
window.__reactRouterClearCriticalCss = () => setCriticalCss(void 0);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
let [location, setLocation] = React2.useState(router.state.location);
|
|
198
|
-
React2.useLayoutEffect(() => {
|
|
199
|
-
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
|
200
|
-
ssrInfo.routerInitialized = true;
|
|
201
|
-
ssrInfo.router.initialize();
|
|
202
|
-
}
|
|
203
|
-
}, []);
|
|
204
|
-
React2.useLayoutEffect(() => {
|
|
205
|
-
if (ssrInfo && ssrInfo.router) {
|
|
206
|
-
return ssrInfo.router.subscribe((newState) => {
|
|
207
|
-
if (newState.location !== location) {
|
|
208
|
-
setLocation(newState.location);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}, [location]);
|
|
213
|
-
(0, import_react_router2.UNSAFE_invariant)(ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
|
214
|
-
(0, import_react_router2.UNSAFE_useFogOFWarDiscovery)(
|
|
215
|
-
router,
|
|
216
|
-
ssrInfo.manifest,
|
|
217
|
-
ssrInfo.routeModules,
|
|
218
|
-
ssrInfo.context.ssr,
|
|
219
|
-
ssrInfo.context.routeDiscovery,
|
|
220
|
-
ssrInfo.context.isSpaMode
|
|
221
|
-
);
|
|
222
|
-
return (
|
|
223
|
-
// This fragment is important to ensure we match the <ServerRouter> JSX
|
|
224
|
-
// structure so that useId values hydrate correctly
|
|
225
|
-
/* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
226
|
-
import_react_router2.UNSAFE_FrameworkContext.Provider,
|
|
227
|
-
{
|
|
228
|
-
value: {
|
|
229
|
-
manifest: ssrInfo.manifest,
|
|
230
|
-
routeModules: ssrInfo.routeModules,
|
|
231
|
-
future: ssrInfo.context.future,
|
|
232
|
-
criticalCss,
|
|
233
|
-
ssr: ssrInfo.context.ssr,
|
|
234
|
-
isSpaMode: ssrInfo.context.isSpaMode,
|
|
235
|
-
routeDiscovery: ssrInfo.context.routeDiscovery
|
|
236
|
-
}
|
|
237
|
-
},
|
|
238
|
-
/* @__PURE__ */ React2.createElement(import_react_router2.UNSAFE_RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider, { router }))
|
|
239
|
-
), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
243
|
-
0 && (module.exports = {
|
|
244
|
-
HydratedRouter,
|
|
245
|
-
RouterProvider
|
|
246
|
-
});
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-router v0.0.0-experimental-aecfb0db1
|
|
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 {
|
|
12
|
-
FrameworkContext,
|
|
13
|
-
RemixErrorBoundary,
|
|
14
|
-
RouterProvider,
|
|
15
|
-
createBrowserHistory,
|
|
16
|
-
createClientRoutes,
|
|
17
|
-
createClientRoutesWithHMRRevalidationOptOut,
|
|
18
|
-
createRouter,
|
|
19
|
-
decodeViaTurboStream,
|
|
20
|
-
deserializeErrors,
|
|
21
|
-
getHydrationData,
|
|
22
|
-
getPatchRoutesOnNavigationFunction,
|
|
23
|
-
getTurboStreamSingleFetchDataStrategy,
|
|
24
|
-
hydrationRouteProperties,
|
|
25
|
-
invariant,
|
|
26
|
-
mapRouteProperties,
|
|
27
|
-
useFogOFWarDiscovery
|
|
28
|
-
} from "./chunk-RXFCVJK2.mjs";
|
|
29
|
-
|
|
30
|
-
// lib/dom-export/dom-router-provider.tsx
|
|
31
|
-
import * as React from "react";
|
|
32
|
-
import * as ReactDOM from "react-dom";
|
|
33
|
-
function RouterProvider2(props) {
|
|
34
|
-
return /* @__PURE__ */ React.createElement(RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// lib/dom-export/hydrated-router.tsx
|
|
38
|
-
import * as React2 from "react";
|
|
39
|
-
var ssrInfo = null;
|
|
40
|
-
var router = null;
|
|
41
|
-
function initSsrInfo() {
|
|
42
|
-
if (!ssrInfo && window.__reactRouterContext && window.__reactRouterManifest && window.__reactRouterRouteModules) {
|
|
43
|
-
if (window.__reactRouterManifest.sri === true) {
|
|
44
|
-
const importMap = document.querySelector("script[rr-importmap]");
|
|
45
|
-
if (importMap?.textContent) {
|
|
46
|
-
try {
|
|
47
|
-
window.__reactRouterManifest.sri = JSON.parse(
|
|
48
|
-
importMap.textContent
|
|
49
|
-
).integrity;
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.error("Failed to parse import map", err);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
ssrInfo = {
|
|
56
|
-
context: window.__reactRouterContext,
|
|
57
|
-
manifest: window.__reactRouterManifest,
|
|
58
|
-
routeModules: window.__reactRouterRouteModules,
|
|
59
|
-
stateDecodingPromise: void 0,
|
|
60
|
-
router: void 0,
|
|
61
|
-
routerInitialized: false
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function createHydratedRouter({
|
|
66
|
-
unstable_getContext
|
|
67
|
-
}) {
|
|
68
|
-
initSsrInfo();
|
|
69
|
-
if (!ssrInfo) {
|
|
70
|
-
throw new Error(
|
|
71
|
-
"You must be using the SSR features of React Router in order to skip passing a `router` prop to `<RouterProvider>`"
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
let localSsrInfo = ssrInfo;
|
|
75
|
-
if (!ssrInfo.stateDecodingPromise) {
|
|
76
|
-
let stream = ssrInfo.context.stream;
|
|
77
|
-
invariant(stream, "No stream found for single fetch decoding");
|
|
78
|
-
ssrInfo.context.stream = void 0;
|
|
79
|
-
ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then((value) => {
|
|
80
|
-
ssrInfo.context.state = value.value;
|
|
81
|
-
localSsrInfo.stateDecodingPromise.value = true;
|
|
82
|
-
}).catch((e) => {
|
|
83
|
-
localSsrInfo.stateDecodingPromise.error = e;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
if (ssrInfo.stateDecodingPromise.error) {
|
|
87
|
-
throw ssrInfo.stateDecodingPromise.error;
|
|
88
|
-
}
|
|
89
|
-
if (!ssrInfo.stateDecodingPromise.value) {
|
|
90
|
-
throw ssrInfo.stateDecodingPromise;
|
|
91
|
-
}
|
|
92
|
-
let routes = createClientRoutes(
|
|
93
|
-
ssrInfo.manifest.routes,
|
|
94
|
-
ssrInfo.routeModules,
|
|
95
|
-
ssrInfo.context.state,
|
|
96
|
-
ssrInfo.context.ssr,
|
|
97
|
-
ssrInfo.context.isSpaMode
|
|
98
|
-
);
|
|
99
|
-
let hydrationData = void 0;
|
|
100
|
-
if (ssrInfo.context.isSpaMode) {
|
|
101
|
-
let { loaderData } = ssrInfo.context.state;
|
|
102
|
-
if (ssrInfo.manifest.routes.root?.hasLoader && loaderData && "root" in loaderData) {
|
|
103
|
-
hydrationData = {
|
|
104
|
-
loaderData: {
|
|
105
|
-
root: loaderData.root
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
hydrationData = getHydrationData(
|
|
111
|
-
ssrInfo.context.state,
|
|
112
|
-
routes,
|
|
113
|
-
(routeId) => ({
|
|
114
|
-
clientLoader: ssrInfo.routeModules[routeId]?.clientLoader,
|
|
115
|
-
hasLoader: ssrInfo.manifest.routes[routeId]?.hasLoader === true,
|
|
116
|
-
hasHydrateFallback: ssrInfo.routeModules[routeId]?.HydrateFallback != null
|
|
117
|
-
}),
|
|
118
|
-
window.location,
|
|
119
|
-
window.__reactRouterContext?.basename,
|
|
120
|
-
ssrInfo.context.isSpaMode
|
|
121
|
-
);
|
|
122
|
-
if (hydrationData && hydrationData.errors) {
|
|
123
|
-
hydrationData.errors = deserializeErrors(hydrationData.errors);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
let router2 = createRouter({
|
|
127
|
-
routes,
|
|
128
|
-
history: createBrowserHistory(),
|
|
129
|
-
basename: ssrInfo.context.basename,
|
|
130
|
-
unstable_getContext,
|
|
131
|
-
hydrationData,
|
|
132
|
-
hydrationRouteProperties,
|
|
133
|
-
mapRouteProperties,
|
|
134
|
-
future: {
|
|
135
|
-
unstable_middleware: ssrInfo.context.future.unstable_middleware
|
|
136
|
-
},
|
|
137
|
-
dataStrategy: getTurboStreamSingleFetchDataStrategy(
|
|
138
|
-
() => router2,
|
|
139
|
-
ssrInfo.manifest,
|
|
140
|
-
ssrInfo.routeModules,
|
|
141
|
-
ssrInfo.context.ssr,
|
|
142
|
-
ssrInfo.context.basename
|
|
143
|
-
),
|
|
144
|
-
patchRoutesOnNavigation: getPatchRoutesOnNavigationFunction(
|
|
145
|
-
ssrInfo.manifest,
|
|
146
|
-
ssrInfo.routeModules,
|
|
147
|
-
ssrInfo.context.ssr,
|
|
148
|
-
ssrInfo.context.routeDiscovery,
|
|
149
|
-
ssrInfo.context.isSpaMode,
|
|
150
|
-
ssrInfo.context.basename
|
|
151
|
-
)
|
|
152
|
-
});
|
|
153
|
-
ssrInfo.router = router2;
|
|
154
|
-
if (router2.state.initialized) {
|
|
155
|
-
ssrInfo.routerInitialized = true;
|
|
156
|
-
router2.initialize();
|
|
157
|
-
}
|
|
158
|
-
router2.createRoutesForHMR = /* spacer so ts-ignore does not affect the right hand of the assignment */
|
|
159
|
-
createClientRoutesWithHMRRevalidationOptOut;
|
|
160
|
-
window.__reactRouterDataRouter = router2;
|
|
161
|
-
return router2;
|
|
162
|
-
}
|
|
163
|
-
function HydratedRouter(props) {
|
|
164
|
-
if (!router) {
|
|
165
|
-
router = createHydratedRouter({
|
|
166
|
-
unstable_getContext: props.unstable_getContext
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
let [criticalCss, setCriticalCss] = React2.useState(
|
|
170
|
-
process.env.NODE_ENV === "development" ? ssrInfo?.context.criticalCss : void 0
|
|
171
|
-
);
|
|
172
|
-
if (process.env.NODE_ENV === "development") {
|
|
173
|
-
if (ssrInfo) {
|
|
174
|
-
window.__reactRouterClearCriticalCss = () => setCriticalCss(void 0);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
let [location, setLocation] = React2.useState(router.state.location);
|
|
178
|
-
React2.useLayoutEffect(() => {
|
|
179
|
-
if (ssrInfo && ssrInfo.router && !ssrInfo.routerInitialized) {
|
|
180
|
-
ssrInfo.routerInitialized = true;
|
|
181
|
-
ssrInfo.router.initialize();
|
|
182
|
-
}
|
|
183
|
-
}, []);
|
|
184
|
-
React2.useLayoutEffect(() => {
|
|
185
|
-
if (ssrInfo && ssrInfo.router) {
|
|
186
|
-
return ssrInfo.router.subscribe((newState) => {
|
|
187
|
-
if (newState.location !== location) {
|
|
188
|
-
setLocation(newState.location);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}, [location]);
|
|
193
|
-
invariant(ssrInfo, "ssrInfo unavailable for HydratedRouter");
|
|
194
|
-
useFogOFWarDiscovery(
|
|
195
|
-
router,
|
|
196
|
-
ssrInfo.manifest,
|
|
197
|
-
ssrInfo.routeModules,
|
|
198
|
-
ssrInfo.context.ssr,
|
|
199
|
-
ssrInfo.context.routeDiscovery,
|
|
200
|
-
ssrInfo.context.isSpaMode
|
|
201
|
-
);
|
|
202
|
-
return (
|
|
203
|
-
// This fragment is important to ensure we match the <ServerRouter> JSX
|
|
204
|
-
// structure so that useId values hydrate correctly
|
|
205
|
-
/* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
206
|
-
FrameworkContext.Provider,
|
|
207
|
-
{
|
|
208
|
-
value: {
|
|
209
|
-
manifest: ssrInfo.manifest,
|
|
210
|
-
routeModules: ssrInfo.routeModules,
|
|
211
|
-
future: ssrInfo.context.future,
|
|
212
|
-
criticalCss,
|
|
213
|
-
ssr: ssrInfo.context.ssr,
|
|
214
|
-
isSpaMode: ssrInfo.context.isSpaMode,
|
|
215
|
-
routeDiscovery: ssrInfo.context.routeDiscovery
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
/* @__PURE__ */ React2.createElement(RemixErrorBoundary, { location }, /* @__PURE__ */ React2.createElement(RouterProvider2, { router }))
|
|
219
|
-
), /* @__PURE__ */ React2.createElement(React2.Fragment, null))
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
export {
|
|
223
|
-
HydratedRouter,
|
|
224
|
-
RouterProvider2 as RouterProvider
|
|
225
|
-
};
|