react-router 7.9.6 → 7.10.0-pre.1
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 +75 -10
- package/dist/development/{browser-BbBXFHbO.d.ts → browser-BpxEZgZC.d.ts} +1 -1
- package/dist/development/{browser-C07r42Tt.d.mts → browser-C5z6FZmz.d.mts} +1 -1
- package/dist/development/{chunk-4WY6JWTD.mjs → chunk-GIMUO62I.mjs} +208 -221
- package/dist/development/{chunk-AMVS5XVJ.js → chunk-KQLPIZ7E.js} +201 -258
- package/dist/development/{chunk-PZWDWJAY.js → chunk-RHWHYDYZ.js} +7 -7
- package/dist/development/{chunk-G3INQAYP.mjs → chunk-V5RTLP6E.mjs} +15 -5
- package/dist/development/{chunk-O4JVZSOY.js → chunk-XHWAND4X.js} +167 -123
- package/dist/development/dom-export.d.mts +29 -10
- package/dist/development/dom-export.d.ts +29 -10
- package/dist/development/dom-export.js +158 -103
- package/dist/development/dom-export.mjs +133 -79
- package/dist/{production/index-react-server-client-Da3kmxNd.d.ts → development/index-react-server-client-CCjKYJTH.d.ts} +75 -180
- package/dist/development/{index-react-server-client-rcoGPJhU.d.mts → index-react-server-client-CipGfVBI.d.mts} +75 -180
- package/dist/development/index-react-server-client.d.mts +2 -2
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +19 -4
- package/dist/development/index-react-server.d.ts +19 -4
- package/dist/development/index-react-server.js +30 -24
- package/dist/development/index-react-server.mjs +30 -24
- package/dist/development/index.d.mts +19 -15
- package/dist/development/index.d.ts +19 -15
- package/dist/development/index.js +92 -82
- package/dist/development/index.mjs +3 -3
- package/dist/{production/instrumentation-Unc20tLk.d.ts → development/instrumentation-BB0wRuqz.d.ts} +93 -11
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +2 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{register-QkB3HGjm.d.mts → register-C1RwVJAt.d.mts} +1 -1
- package/dist/development/{register-BpU9rFBJ.d.ts → register-ODDAAYlf.d.ts} +1 -1
- package/dist/development/{router-CAvh_Drx.d.mts → router-CwNp5l9u.d.mts} +93 -11
- package/dist/production/{browser-BbBXFHbO.d.ts → browser-BpxEZgZC.d.ts} +1 -1
- package/dist/production/{browser-C07r42Tt.d.mts → browser-C5z6FZmz.d.mts} +1 -1
- package/dist/production/{chunk-QN64DHI4.js → chunk-3MVZKESN.js} +167 -123
- package/dist/production/{chunk-FUSXQSWG.mjs → chunk-7F5XUDXM.mjs} +208 -221
- package/dist/production/{chunk-EAIF67OW.js → chunk-C7S4I3K5.js} +201 -258
- package/dist/production/{chunk-FDUMZGKM.mjs → chunk-ISOIFGFA.mjs} +15 -5
- package/dist/production/{chunk-G5A35OQU.js → chunk-YU3WNS3T.js} +7 -7
- package/dist/production/dom-export.d.mts +29 -10
- package/dist/production/dom-export.d.ts +29 -10
- package/dist/production/dom-export.js +158 -103
- package/dist/production/dom-export.mjs +133 -79
- package/dist/{development/index-react-server-client-Da3kmxNd.d.ts → production/index-react-server-client-CCjKYJTH.d.ts} +75 -180
- package/dist/production/{index-react-server-client-rcoGPJhU.d.mts → index-react-server-client-CipGfVBI.d.mts} +75 -180
- package/dist/production/index-react-server-client.d.mts +2 -2
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +19 -4
- package/dist/production/index-react-server.d.ts +19 -4
- package/dist/production/index-react-server.js +30 -24
- package/dist/production/index-react-server.mjs +30 -24
- package/dist/production/index.d.mts +19 -15
- package/dist/production/index.d.ts +19 -15
- package/dist/production/index.js +92 -82
- package/dist/production/index.mjs +3 -3
- package/dist/{development/instrumentation-Unc20tLk.d.ts → production/instrumentation-BB0wRuqz.d.ts} +93 -11
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +2 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{register-QkB3HGjm.d.mts → register-C1RwVJAt.d.mts} +1 -1
- package/dist/production/{register-BpU9rFBJ.d.ts → register-ODDAAYlf.d.ts} +1 -1
- package/dist/production/{router-CAvh_Drx.d.mts → router-CwNp5l9u.d.mts} +93 -11
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { f as RouterProviderProps$1, e as RouterInit, u as unstable_ClientInstrumentation, g as unstable_ClientOnErrorFunction } from './router-
|
|
3
|
-
export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-
|
|
2
|
+
import { f as RouterProviderProps$1, e as RouterInit, u as unstable_ClientInstrumentation, g as unstable_ClientOnErrorFunction } from './router-CwNp5l9u.mjs';
|
|
3
|
+
export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-C5z6FZmz.mjs';
|
|
4
4
|
|
|
5
5
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
6
6
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
@@ -25,16 +25,9 @@ interface HydratedRouterProps {
|
|
|
25
25
|
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
26
26
|
* mostly useful for observability such as wrapping navigations, fetches,
|
|
27
27
|
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
28
|
-
* tracing.
|
|
28
|
+
* tracing. See the [docs](../../how-to/instrumentation) for more information.
|
|
29
29
|
*
|
|
30
30
|
* ```tsx
|
|
31
|
-
* startTransition(() => {
|
|
32
|
-
* hydrateRoot(
|
|
33
|
-
* document,
|
|
34
|
-
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
35
|
-
* );
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
31
|
* const logging = {
|
|
39
32
|
* router({ instrument }) {
|
|
40
33
|
* instrument({
|
|
@@ -67,6 +60,13 @@ interface HydratedRouterProps {
|
|
|
67
60
|
* let duration = Math.round(performance.now() - start);
|
|
68
61
|
* console.log(`end ${label} (${duration}ms)`);
|
|
69
62
|
* }
|
|
63
|
+
*
|
|
64
|
+
* startTransition(() => {
|
|
65
|
+
* hydrateRoot(
|
|
66
|
+
* document,
|
|
67
|
+
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
68
|
+
* );
|
|
69
|
+
* });
|
|
70
70
|
* ```
|
|
71
71
|
*/
|
|
72
72
|
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
@@ -88,6 +88,25 @@ interface HydratedRouterProps {
|
|
|
88
88
|
* ```
|
|
89
89
|
*/
|
|
90
90
|
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
91
|
+
/**
|
|
92
|
+
* Control whether router state updates are internally wrapped in
|
|
93
|
+
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
|
94
|
+
*
|
|
95
|
+
* - When left `undefined`, all state updates are wrapped in
|
|
96
|
+
* `React.startTransition`
|
|
97
|
+
* - This can lead to buggy behaviors if you are wrapping your own
|
|
98
|
+
* navigations/fetchers in `startTransition`.
|
|
99
|
+
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
|
100
|
+
* in `React.startTransition` and router state changes will be wrapped in
|
|
101
|
+
* `React.startTransition` and also sent through
|
|
102
|
+
* [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
|
|
103
|
+
* surface mid-navigation router state changes to the UI.
|
|
104
|
+
* - When set to `false`, the router will not leverage `React.startTransition` or
|
|
105
|
+
* `React.useOptimistic` on any navigations or state changes.
|
|
106
|
+
*
|
|
107
|
+
* For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
|
|
108
|
+
*/
|
|
109
|
+
unstable_useTransitions?: boolean;
|
|
91
110
|
}
|
|
92
111
|
/**
|
|
93
112
|
* Framework-mode router component to be used to hydrate a router from a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RouterProviderProps as RouterProviderProps$1, RouterInit, unstable_ClientOnErrorFunction } from 'react-router';
|
|
3
|
-
import { u as unstable_ClientInstrumentation } from './instrumentation-
|
|
4
|
-
export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-
|
|
3
|
+
import { u as unstable_ClientInstrumentation } from './instrumentation-BB0wRuqz.js';
|
|
4
|
+
export { D as unstable_DecodeActionFunction, a as unstable_DecodeFormStateFunction, b as unstable_DecodeReplyFunction, R as unstable_RSCHydratedRouter, d as unstable_RSCManifestPayload, e as unstable_RSCPayload, f as unstable_RSCRenderPayload, c as unstable_createCallServer } from './browser-BpxEZgZC.js';
|
|
5
5
|
|
|
6
6
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
7
7
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
@@ -26,16 +26,9 @@ interface HydratedRouterProps {
|
|
|
26
26
|
* added routes via `route.lazy` or `patchRoutesOnNavigation`). This is
|
|
27
27
|
* mostly useful for observability such as wrapping navigations, fetches,
|
|
28
28
|
* as well as route loaders/actions/middlewares with logging and/or performance
|
|
29
|
-
* tracing.
|
|
29
|
+
* tracing. See the [docs](../../how-to/instrumentation) for more information.
|
|
30
30
|
*
|
|
31
31
|
* ```tsx
|
|
32
|
-
* startTransition(() => {
|
|
33
|
-
* hydrateRoot(
|
|
34
|
-
* document,
|
|
35
|
-
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
36
|
-
* );
|
|
37
|
-
* });
|
|
38
|
-
*
|
|
39
32
|
* const logging = {
|
|
40
33
|
* router({ instrument }) {
|
|
41
34
|
* instrument({
|
|
@@ -68,6 +61,13 @@ interface HydratedRouterProps {
|
|
|
68
61
|
* let duration = Math.round(performance.now() - start);
|
|
69
62
|
* console.log(`end ${label} (${duration}ms)`);
|
|
70
63
|
* }
|
|
64
|
+
*
|
|
65
|
+
* startTransition(() => {
|
|
66
|
+
* hydrateRoot(
|
|
67
|
+
* document,
|
|
68
|
+
* <HydratedRouter unstable_instrumentations={[logging]} />
|
|
69
|
+
* );
|
|
70
|
+
* });
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
unstable_instrumentations?: unstable_ClientInstrumentation[];
|
|
@@ -89,6 +89,25 @@ interface HydratedRouterProps {
|
|
|
89
89
|
* ```
|
|
90
90
|
*/
|
|
91
91
|
unstable_onError?: unstable_ClientOnErrorFunction;
|
|
92
|
+
/**
|
|
93
|
+
* Control whether router state updates are internally wrapped in
|
|
94
|
+
* [`React.startTransition`](https://react.dev/reference/react/startTransition).
|
|
95
|
+
*
|
|
96
|
+
* - When left `undefined`, all state updates are wrapped in
|
|
97
|
+
* `React.startTransition`
|
|
98
|
+
* - This can lead to buggy behaviors if you are wrapping your own
|
|
99
|
+
* navigations/fetchers in `startTransition`.
|
|
100
|
+
* - When set to `true`, {@link Link} and {@link Form} navigations will be wrapped
|
|
101
|
+
* in `React.startTransition` and router state changes will be wrapped in
|
|
102
|
+
* `React.startTransition` and also sent through
|
|
103
|
+
* [`useOptimistic`](https://react.dev/reference/react/useOptimistic) to
|
|
104
|
+
* surface mid-navigation router state changes to the UI.
|
|
105
|
+
* - When set to `false`, the router will not leverage `React.startTransition` or
|
|
106
|
+
* `React.useOptimistic` on any navigations or state changes.
|
|
107
|
+
*
|
|
108
|
+
* For more information, please see the [docs](https://reactrouter.com/explanation/react-transitions).
|
|
109
|
+
*/
|
|
110
|
+
unstable_useTransitions?: boolean;
|
|
92
111
|
}
|
|
93
112
|
/**
|
|
94
113
|
* Framework-mode router component to be used to hydrate a router from a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.10.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkRHWHYDYZjs = require('./chunk-RHWHYDYZ.js');
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -32,13 +32,13 @@ var _chunkPZWDWJAYjs = require('./chunk-PZWDWJAY.js');
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var _chunkKQLPIZ7Ejs = require('./chunk-KQLPIZ7E.js');
|
|
36
36
|
|
|
37
37
|
// lib/dom-export/dom-router-provider.tsx
|
|
38
38
|
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);
|
|
39
39
|
var _reactdom = require('react-dom'); var ReactDOM = _interopRequireWildcard(_reactdom); var ReactDOM2 = _interopRequireWildcard(_reactdom);
|
|
40
40
|
var _reactrouter = require('react-router');
|
|
41
|
-
function
|
|
41
|
+
function RouterProvider2(props) {
|
|
42
42
|
return /* @__PURE__ */ React.createElement(_reactrouter.RouterProvider, { flushSync: ReactDOM.flushSync, ...props });
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -204,7 +204,7 @@ function HydratedRouter(props) {
|
|
|
204
204
|
}, []);
|
|
205
205
|
React2.useEffect(() => {
|
|
206
206
|
if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
|
|
207
|
-
document.querySelectorAll(`[${
|
|
207
|
+
document.querySelectorAll(`[${_chunkKQLPIZ7Ejs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
|
|
208
208
|
}
|
|
209
209
|
}, [criticalCss]);
|
|
210
210
|
let [location2, setLocation] = React2.useState(router.state.location);
|
|
@@ -249,9 +249,10 @@ function HydratedRouter(props) {
|
|
|
249
249
|
}
|
|
250
250
|
},
|
|
251
251
|
/* @__PURE__ */ React2.createElement(_reactrouter.UNSAFE_RemixErrorBoundary, { location: location2 }, /* @__PURE__ */ React2.createElement(
|
|
252
|
-
|
|
252
|
+
RouterProvider2,
|
|
253
253
|
{
|
|
254
254
|
router,
|
|
255
|
+
unstable_useTransitions: props.unstable_useTransitions,
|
|
255
256
|
unstable_onError: props.unstable_onError
|
|
256
257
|
}
|
|
257
258
|
))
|
|
@@ -290,66 +291,68 @@ function createCallServer({
|
|
|
290
291
|
temporaryReferences
|
|
291
292
|
});
|
|
292
293
|
});
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
return () => {
|
|
302
|
-
globalVar.__reactRouterDataRouter.navigate(payload.location, {
|
|
303
|
-
replace: payload.replace
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
if (payload.type !== "action") {
|
|
308
|
-
throw new Error("Unexpected payload type");
|
|
309
|
-
}
|
|
310
|
-
const rerender = await payload.rerender;
|
|
311
|
-
if (rerender && landedActionId < actionId && globalVar.__routerActionID <= actionId) {
|
|
312
|
-
if (rerender.type === "redirect") {
|
|
313
|
-
if (rerender.reload || isExternalLocation(rerender.location)) {
|
|
314
|
-
window.location.href = rerender.location;
|
|
294
|
+
React3.startTransition(
|
|
295
|
+
() => (
|
|
296
|
+
// @ts-expect-error - Needs React 19 types
|
|
297
|
+
Promise.resolve(payloadPromise).then(async (payload) => {
|
|
298
|
+
if (payload.type === "redirect") {
|
|
299
|
+
if (payload.reload || isExternalLocation(payload.location)) {
|
|
300
|
+
window.location.href = payload.location;
|
|
315
301
|
return;
|
|
316
302
|
}
|
|
317
|
-
|
|
318
|
-
globalVar.__reactRouterDataRouter.navigate(
|
|
319
|
-
replace:
|
|
303
|
+
React3.startTransition(() => {
|
|
304
|
+
globalVar.__reactRouterDataRouter.navigate(payload.location, {
|
|
305
|
+
replace: payload.replace
|
|
320
306
|
});
|
|
321
|
-
};
|
|
307
|
+
});
|
|
308
|
+
return;
|
|
322
309
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
310
|
+
if (payload.type !== "action") {
|
|
311
|
+
throw new Error("Unexpected payload type");
|
|
312
|
+
}
|
|
313
|
+
const rerender = await payload.rerender;
|
|
314
|
+
if (rerender && landedActionId < actionId && globalVar.__routerActionID <= actionId) {
|
|
315
|
+
if (rerender.type === "redirect") {
|
|
316
|
+
if (rerender.reload || isExternalLocation(rerender.location)) {
|
|
317
|
+
window.location.href = rerender.location;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
React3.startTransition(() => {
|
|
321
|
+
globalVar.__reactRouterDataRouter.navigate(rerender.location, {
|
|
322
|
+
replace: rerender.replace
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
return;
|
|
332
326
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
globalVar.__reactRouterDataRouter.state.errors,
|
|
343
|
-
rerender.errors
|
|
344
|
-
) : null
|
|
327
|
+
React3.startTransition(() => {
|
|
328
|
+
let lastMatch;
|
|
329
|
+
for (const match of rerender.matches) {
|
|
330
|
+
globalVar.__reactRouterDataRouter.patchRoutes(
|
|
331
|
+
_nullishCoalesce(_optionalChain([lastMatch, 'optionalAccess', _21 => _21.id]), () => ( null)),
|
|
332
|
+
[createRouteFromServerManifest(match)],
|
|
333
|
+
true
|
|
334
|
+
);
|
|
335
|
+
lastMatch = match;
|
|
345
336
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
337
|
+
window.__reactRouterDataRouter._internalSetStateDoNotUseOrYouWillBreakYourApp(
|
|
338
|
+
{
|
|
339
|
+
loaderData: Object.assign(
|
|
340
|
+
{},
|
|
341
|
+
globalVar.__reactRouterDataRouter.state.loaderData,
|
|
342
|
+
rerender.loaderData
|
|
343
|
+
),
|
|
344
|
+
errors: rerender.errors ? Object.assign(
|
|
345
|
+
{},
|
|
346
|
+
globalVar.__reactRouterDataRouter.state.errors,
|
|
347
|
+
rerender.errors
|
|
348
|
+
) : null
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}).catch(() => {
|
|
354
|
+
})
|
|
355
|
+
)
|
|
353
356
|
);
|
|
354
357
|
return payloadPromise.then((payload) => {
|
|
355
358
|
if (payload.type !== "action" && payload.type !== "redirect") {
|
|
@@ -373,10 +376,10 @@ function createRouterFromPayload({
|
|
|
373
376
|
};
|
|
374
377
|
if (payload.type !== "render") throw new Error("Invalid payload type");
|
|
375
378
|
globalVar.__reactRouterRouteModules = _nullishCoalesce(globalVar.__reactRouterRouteModules, () => ( {}));
|
|
376
|
-
|
|
379
|
+
_chunkRHWHYDYZjs.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
|
|
377
380
|
let patches = /* @__PURE__ */ new Map();
|
|
378
381
|
_optionalChain([payload, 'access', _22 => _22.patches, 'optionalAccess', _23 => _23.forEach, 'call', _24 => _24((patch) => {
|
|
379
|
-
|
|
382
|
+
_chunkKQLPIZ7Ejs.invariant.call(void 0, patch.parentId, "Invalid patch parentId");
|
|
380
383
|
if (!patches.has(patch.parentId)) {
|
|
381
384
|
patches.set(patch.parentId, []);
|
|
382
385
|
}
|
|
@@ -398,12 +401,12 @@ function createRouterFromPayload({
|
|
|
398
401
|
}
|
|
399
402
|
return [route];
|
|
400
403
|
}, []);
|
|
401
|
-
globalVar.__reactRouterDataRouter =
|
|
404
|
+
globalVar.__reactRouterDataRouter = _chunkKQLPIZ7Ejs.createRouter.call(void 0, {
|
|
402
405
|
routes,
|
|
403
406
|
getContext,
|
|
404
407
|
basename: payload.basename,
|
|
405
|
-
history:
|
|
406
|
-
hydrationData:
|
|
408
|
+
history: _chunkKQLPIZ7Ejs.createBrowserHistory.call(void 0, ),
|
|
409
|
+
hydrationData: _chunkRHWHYDYZjs.getHydrationData.call(void 0, {
|
|
407
410
|
state: {
|
|
408
411
|
loaderData: payload.loaderData,
|
|
409
412
|
actionData: payload.actionData,
|
|
@@ -412,7 +415,7 @@ function createRouterFromPayload({
|
|
|
412
415
|
routes,
|
|
413
416
|
getRouteInfo: (routeId) => {
|
|
414
417
|
let match = payload.matches.find((m) => m.id === routeId);
|
|
415
|
-
|
|
418
|
+
_chunkKQLPIZ7Ejs.invariant.call(void 0, match, "Route not found in payload");
|
|
416
419
|
return {
|
|
417
420
|
clientLoader: match.clientLoader,
|
|
418
421
|
hasLoader: match.hasLoader,
|
|
@@ -510,9 +513,9 @@ function createRouterFromPayload({
|
|
|
510
513
|
routeModules: globalVar.__reactRouterRouteModules
|
|
511
514
|
};
|
|
512
515
|
}
|
|
513
|
-
var renderedRoutesContext =
|
|
516
|
+
var renderedRoutesContext = _chunkKQLPIZ7Ejs.createContext.call(void 0, );
|
|
514
517
|
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
|
|
515
|
-
let dataStrategy =
|
|
518
|
+
let dataStrategy = _chunkKQLPIZ7Ejs.getSingleFetchDataStrategyImpl.call(void 0,
|
|
516
519
|
getRouter,
|
|
517
520
|
(match) => {
|
|
518
521
|
let M = match;
|
|
@@ -548,38 +551,40 @@ function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReada
|
|
|
548
551
|
}
|
|
549
552
|
renderedRoutesById.get(route.id).push(route);
|
|
550
553
|
}
|
|
551
|
-
|
|
552
|
-
const
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
554
|
+
React3.startTransition(() => {
|
|
555
|
+
for (const match of args.matches) {
|
|
556
|
+
const renderedRoutes = renderedRoutesById.get(match.route.id);
|
|
557
|
+
if (renderedRoutes) {
|
|
558
|
+
for (const rendered of renderedRoutes) {
|
|
559
|
+
window.__reactRouterDataRouter.patchRoutes(
|
|
560
|
+
_nullishCoalesce(rendered.parentId, () => ( null)),
|
|
561
|
+
[createRouteFromServerManifest(rendered)],
|
|
562
|
+
true
|
|
563
|
+
);
|
|
564
|
+
}
|
|
560
565
|
}
|
|
561
566
|
}
|
|
562
|
-
}
|
|
567
|
+
});
|
|
563
568
|
return results;
|
|
564
569
|
});
|
|
565
570
|
}
|
|
566
571
|
function getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation) {
|
|
567
572
|
return async (args, basename, targetRoutes) => {
|
|
568
573
|
let { request, context } = args;
|
|
569
|
-
let url =
|
|
574
|
+
let url = _chunkKQLPIZ7Ejs.singleFetchUrl.call(void 0, request.url, basename, "rsc");
|
|
570
575
|
if (request.method === "GET") {
|
|
571
|
-
url =
|
|
576
|
+
url = _chunkKQLPIZ7Ejs.stripIndexParam.call(void 0, url);
|
|
572
577
|
if (targetRoutes) {
|
|
573
578
|
url.searchParams.set("_routes", targetRoutes.join(","));
|
|
574
579
|
}
|
|
575
580
|
}
|
|
576
581
|
let res = await fetchImplementation(
|
|
577
|
-
new Request(url, await
|
|
582
|
+
new Request(url, await _chunkKQLPIZ7Ejs.createRequestInit.call(void 0, request))
|
|
578
583
|
);
|
|
579
584
|
if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
|
|
580
|
-
throw new (0,
|
|
585
|
+
throw new (0, _chunkKQLPIZ7Ejs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
|
|
581
586
|
}
|
|
582
|
-
|
|
587
|
+
_chunkKQLPIZ7Ejs.invariant.call(void 0, res.body, "No response body to decode");
|
|
583
588
|
try {
|
|
584
589
|
const payload = await createFromReadableStream(res.body, {
|
|
585
590
|
temporaryReferences: void 0
|
|
@@ -603,7 +608,7 @@ function getFetchAndDecodeViaRSC(createFromReadableStream, fetchImplementation)
|
|
|
603
608
|
}
|
|
604
609
|
context.get(renderedRoutesContext).push(...payload.matches);
|
|
605
610
|
let results = { routes: {} };
|
|
606
|
-
const dataKey =
|
|
611
|
+
const dataKey = _chunkKQLPIZ7Ejs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
|
|
607
612
|
for (let [routeId, data] of Object.entries(payload[dataKey] || {})) {
|
|
608
613
|
results.routes[routeId] = { data };
|
|
609
614
|
}
|
|
@@ -636,7 +641,7 @@ function RSCHydratedRouter({
|
|
|
636
641
|
[createFromReadableStream, payload, fetchImplementation, getContext]
|
|
637
642
|
);
|
|
638
643
|
React3.useEffect(() => {
|
|
639
|
-
|
|
644
|
+
_chunkKQLPIZ7Ejs.setIsHydrated.call(void 0, );
|
|
640
645
|
}, []);
|
|
641
646
|
React3.useLayoutEffect(() => {
|
|
642
647
|
const globalVar = window;
|
|
@@ -645,14 +650,29 @@ function RSCHydratedRouter({
|
|
|
645
650
|
globalVar.__reactRouterDataRouter.initialize();
|
|
646
651
|
}
|
|
647
652
|
}, []);
|
|
648
|
-
let [
|
|
653
|
+
let [{ routes, state }, setState] = React3.useState(() => ({
|
|
654
|
+
routes: cloneRoutes(router2.routes),
|
|
655
|
+
state: router2.state
|
|
656
|
+
}));
|
|
649
657
|
React3.useLayoutEffect(
|
|
650
658
|
() => router2.subscribe((newState) => {
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
|
|
659
|
+
if (diffRoutes(router2.routes, routes))
|
|
660
|
+
React3.startTransition(() => {
|
|
661
|
+
setState({
|
|
662
|
+
routes: cloneRoutes(router2.routes),
|
|
663
|
+
state: newState
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
}),
|
|
667
|
+
[router2.subscribe, routes, router2]
|
|
668
|
+
);
|
|
669
|
+
const transitionEnabledRouter = React3.useMemo(
|
|
670
|
+
() => ({
|
|
671
|
+
...router2,
|
|
672
|
+
state,
|
|
673
|
+
routes
|
|
654
674
|
}),
|
|
655
|
-
[router2,
|
|
675
|
+
[router2, routes, state]
|
|
656
676
|
);
|
|
657
677
|
React3.useEffect(() => {
|
|
658
678
|
if (routeDiscovery === "lazy" || // @ts-expect-error - TS doesn't know about this yet
|
|
@@ -723,7 +743,14 @@ function RSCHydratedRouter({
|
|
|
723
743
|
routeDiscovery: { mode: "lazy", manifestPath: "/__manifest" },
|
|
724
744
|
routeModules
|
|
725
745
|
};
|
|
726
|
-
return /* @__PURE__ */ React3.createElement(
|
|
746
|
+
return /* @__PURE__ */ React3.createElement(_chunkKQLPIZ7Ejs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunkRHWHYDYZjs.RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(_chunkKQLPIZ7Ejs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
|
|
747
|
+
_chunkKQLPIZ7Ejs.RouterProvider,
|
|
748
|
+
{
|
|
749
|
+
router: transitionEnabledRouter,
|
|
750
|
+
flushSync: ReactDOM2.flushSync,
|
|
751
|
+
unstable_useTransitions: true
|
|
752
|
+
}
|
|
753
|
+
))));
|
|
727
754
|
}
|
|
728
755
|
function createRouteFromServerManifest(match, payload) {
|
|
729
756
|
let hasInitialData = payload && match.id in payload.loaderData;
|
|
@@ -734,8 +761,8 @@ function createRouteFromServerManifest(match, payload) {
|
|
|
734
761
|
// the server loader flow regardless of whether the client loader calls
|
|
735
762
|
// `serverLoader` or not, otherwise we'll have nothing to render.
|
|
736
763
|
match.hasComponent && !match.element;
|
|
737
|
-
|
|
738
|
-
|
|
764
|
+
_chunkKQLPIZ7Ejs.invariant.call(void 0, window.__reactRouterRouteModules);
|
|
765
|
+
_chunkRHWHYDYZjs.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
|
|
739
766
|
let dataRoute = {
|
|
740
767
|
id: match.id,
|
|
741
768
|
element: match.element,
|
|
@@ -785,7 +812,7 @@ function createRouteFromServerManifest(match, payload) {
|
|
|
785
812
|
return await callSingleFetch(singleFetch);
|
|
786
813
|
}
|
|
787
814
|
}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : () => {
|
|
788
|
-
throw
|
|
815
|
+
throw _chunkKQLPIZ7Ejs.noActionDefinedError.call(void 0, "action", match.id);
|
|
789
816
|
},
|
|
790
817
|
path: match.path,
|
|
791
818
|
shouldRevalidate: match.shouldRevalidate,
|
|
@@ -798,7 +825,7 @@ function createRouteFromServerManifest(match, payload) {
|
|
|
798
825
|
hasShouldRevalidate: match.shouldRevalidate != null
|
|
799
826
|
};
|
|
800
827
|
if (typeof dataRoute.loader === "function") {
|
|
801
|
-
dataRoute.loader.hydrate =
|
|
828
|
+
dataRoute.loader.hydrate = _chunkKQLPIZ7Ejs.shouldHydrateRouteLoader.call(void 0,
|
|
802
829
|
match.id,
|
|
803
830
|
match.clientLoader,
|
|
804
831
|
match.hasLoader,
|
|
@@ -808,7 +835,7 @@ function createRouteFromServerManifest(match, payload) {
|
|
|
808
835
|
return dataRoute;
|
|
809
836
|
}
|
|
810
837
|
function callSingleFetch(singleFetch) {
|
|
811
|
-
|
|
838
|
+
_chunkKQLPIZ7Ejs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
|
|
812
839
|
return singleFetch();
|
|
813
840
|
}
|
|
814
841
|
function preventInvalidServerHandlerCall(type, routeId, hasHandler) {
|
|
@@ -816,7 +843,7 @@ function preventInvalidServerHandlerCall(type, routeId, hasHandler) {
|
|
|
816
843
|
let fn = type === "action" ? "serverAction()" : "serverLoader()";
|
|
817
844
|
let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${routeId}")`;
|
|
818
845
|
console.error(msg);
|
|
819
|
-
throw new (0,
|
|
846
|
+
throw new (0, _chunkKQLPIZ7Ejs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
|
|
820
847
|
}
|
|
821
848
|
}
|
|
822
849
|
var nextPaths = /* @__PURE__ */ new Set();
|
|
@@ -859,11 +886,13 @@ async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fet
|
|
|
859
886
|
throw new Error("Failed to patch routes");
|
|
860
887
|
}
|
|
861
888
|
paths.forEach((p) => addToFifoQueue(p, discoveredPaths));
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
889
|
+
React3.startTransition(() => {
|
|
890
|
+
payload.patches.forEach((p) => {
|
|
891
|
+
window.__reactRouterDataRouter.patchRoutes(
|
|
892
|
+
_nullishCoalesce(p.parentId, () => ( null)),
|
|
893
|
+
[createRouteFromServerManifest(p)]
|
|
894
|
+
);
|
|
895
|
+
});
|
|
867
896
|
});
|
|
868
897
|
}
|
|
869
898
|
function addToFifoQueue(path, queue) {
|
|
@@ -884,6 +913,32 @@ function isExternalLocation(location2) {
|
|
|
884
913
|
const newLocation = new URL(location2, window.location.href);
|
|
885
914
|
return newLocation.origin !== window.location.origin;
|
|
886
915
|
}
|
|
916
|
+
function cloneRoutes(routes) {
|
|
917
|
+
if (!routes) return void 0;
|
|
918
|
+
return routes.map((route) => ({
|
|
919
|
+
...route,
|
|
920
|
+
children: cloneRoutes(route.children)
|
|
921
|
+
}));
|
|
922
|
+
}
|
|
923
|
+
function diffRoutes(a, b) {
|
|
924
|
+
if (a.length !== b.length) return true;
|
|
925
|
+
return a.some((route, index) => {
|
|
926
|
+
if (route.element !== b[index].element) return true;
|
|
927
|
+
if (route.errorElement !== b[index].errorElement)
|
|
928
|
+
return true;
|
|
929
|
+
if (route.hydrateFallbackElement !== b[index].hydrateFallbackElement)
|
|
930
|
+
return true;
|
|
931
|
+
if (route.hasErrorBoundary !== b[index].hasErrorBoundary)
|
|
932
|
+
return true;
|
|
933
|
+
if (route.hasLoader !== b[index].hasLoader) return true;
|
|
934
|
+
if (route.hasClientLoader !== b[index].hasClientLoader)
|
|
935
|
+
return true;
|
|
936
|
+
if (route.hasAction !== b[index].hasAction) return true;
|
|
937
|
+
if (route.hasClientAction !== b[index].hasClientAction)
|
|
938
|
+
return true;
|
|
939
|
+
return diffRoutes(route.children || [], b[index].children || []);
|
|
940
|
+
});
|
|
941
|
+
}
|
|
887
942
|
|
|
888
943
|
// lib/rsc/html-stream/browser.ts
|
|
889
944
|
function getRSCStream() {
|
|
@@ -925,4 +980,4 @@ function getRSCStream() {
|
|
|
925
980
|
|
|
926
981
|
|
|
927
982
|
|
|
928
|
-
exports.HydratedRouter = HydratedRouter; exports.RouterProvider =
|
|
983
|
+
exports.HydratedRouter = HydratedRouter; exports.RouterProvider = RouterProvider2; exports.unstable_RSCHydratedRouter = RSCHydratedRouter; exports.unstable_createCallServer = createCallServer; exports.unstable_getRSCStream = getRSCStream;
|