react-router 8.4.0 → 8.5.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 +94 -1
- package/dist/development/dom-export.d.ts +2 -1
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +2 -2
- package/dist/development/index-react-server.d.ts +237 -165
- package/dist/development/index-react-server.js +69 -33
- package/dist/development/index.d.ts +9 -8
- package/dist/development/index.js +5 -4
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/await.js +58 -0
- package/dist/development/lib/components.d.ts +41 -5
- package/dist/development/lib/components.js +82 -5
- package/dist/development/lib/context.d.ts +8 -3
- package/dist/development/lib/context.js +1 -1
- package/dist/development/lib/dom/dom.d.ts +3 -0
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.d.ts +34 -9
- package/dist/development/lib/dom/lib.js +17 -6
- package/dist/development/lib/dom/server.js +2 -2
- package/dist/development/lib/dom/ssr/components.js +12 -9
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/entry.d.ts +9 -2
- package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/development/lib/dom/ssr/fallback.js +1 -1
- package/dist/development/lib/dom/ssr/fog-of-war.d.ts +3 -2
- package/dist/development/lib/dom/ssr/fog-of-war.js +25 -13
- package/dist/development/lib/dom/ssr/hydration.js +1 -1
- package/dist/development/lib/dom/ssr/invariant.js +1 -1
- package/dist/development/lib/dom/ssr/links.js +1 -1
- package/dist/development/lib/dom/ssr/markup.js +1 -1
- package/dist/development/lib/dom/ssr/route-discovery.d.ts +120 -0
- package/dist/development/lib/dom/ssr/route-discovery.js +415 -0
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +2 -2
- package/dist/development/lib/dom/ssr/routes.d.ts +2 -2
- package/dist/development/lib/dom/ssr/routes.js +8 -8
- package/dist/development/lib/dom/ssr/server.js +3 -1
- package/dist/development/lib/dom/ssr/single-fetch.d.ts +28 -2
- package/dist/development/lib/dom/ssr/single-fetch.js +73 -55
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.d.ts +28 -0
- package/dist/development/lib/dom-export/hydrated-router.js +32 -12
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.d.ts +3 -6
- package/dist/development/lib/hooks.js +8 -9
- package/dist/development/lib/href.js +1 -1
- package/dist/development/lib/router/history.js +1 -1
- package/dist/development/lib/router/instrumentation.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.js +1 -1
- package/dist/development/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/development/lib/router/matcher.js +6 -1
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.d.ts +8 -0
- package/dist/development/lib/router/router.js +213 -91
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +31 -4
- package/dist/development/lib/router/utils.js +4 -3
- package/dist/development/lib/rsc/browser.js +4 -4
- package/dist/development/lib/rsc/errorBoundaries.js +1 -1
- package/dist/development/lib/rsc/html-stream/browser.js +1 -1
- package/dist/development/lib/rsc/html-stream/server.js +24 -12
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +3 -2
- package/dist/development/lib/rsc/server.ssr.js +1 -1
- package/dist/development/lib/server-runtime/build.d.ts +14 -0
- package/dist/development/lib/server-runtime/cookies.js +1 -1
- package/dist/development/lib/server-runtime/crypto.js +1 -1
- package/dist/development/lib/server-runtime/data.js +1 -1
- package/dist/development/lib/server-runtime/dev.js +1 -1
- package/dist/development/lib/server-runtime/entry.js +1 -1
- package/dist/development/lib/server-runtime/errors.js +1 -1
- package/dist/development/lib/server-runtime/headers.js +1 -1
- package/dist/development/lib/server-runtime/invariant.js +1 -1
- package/dist/development/lib/server-runtime/mode.js +1 -1
- package/dist/development/lib/server-runtime/routeMatching.js +1 -1
- package/dist/development/lib/server-runtime/routes.d.ts +1 -1
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +24 -8
- package/dist/development/lib/server-runtime/serverHandoff.d.ts +17 -0
- package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/development/lib/server-runtime/sessions.js +2 -2
- package/dist/development/lib/server-runtime/single-fetch.js +1 -1
- package/dist/development/lib/server-runtime/urls.js +1 -1
- package/dist/development/lib/server-runtime/warnings.js +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/route-data.d.ts +2 -2
- package/dist/development/lib/types/route-module-annotations.d.ts +1 -1
- package/dist/development/route-pattern.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/development/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.d.ts +2 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +2 -2
- package/dist/production/index-react-server.d.ts +237 -165
- package/dist/production/index-react-server.js +69 -33
- package/dist/production/index.d.ts +9 -8
- package/dist/production/index.js +5 -4
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/await.js +58 -0
- package/dist/production/lib/components.d.ts +41 -5
- package/dist/production/lib/components.js +82 -5
- package/dist/production/lib/context.d.ts +8 -3
- package/dist/production/lib/context.js +1 -1
- package/dist/production/lib/dom/dom.d.ts +3 -0
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.d.ts +34 -9
- package/dist/production/lib/dom/lib.js +17 -6
- package/dist/production/lib/dom/server.js +2 -2
- package/dist/production/lib/dom/ssr/components.js +12 -9
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/entry.d.ts +9 -2
- package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
- package/dist/production/lib/dom/ssr/fallback.js +1 -1
- package/dist/production/lib/dom/ssr/fog-of-war.d.ts +3 -2
- package/dist/production/lib/dom/ssr/fog-of-war.js +25 -13
- package/dist/production/lib/dom/ssr/hydration.js +1 -1
- package/dist/production/lib/dom/ssr/invariant.js +1 -1
- package/dist/production/lib/dom/ssr/links.js +1 -1
- package/dist/production/lib/dom/ssr/markup.js +1 -1
- package/dist/production/lib/dom/ssr/route-discovery.d.ts +120 -0
- package/dist/production/lib/dom/ssr/route-discovery.js +415 -0
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +2 -2
- package/dist/production/lib/dom/ssr/routes.d.ts +2 -2
- package/dist/production/lib/dom/ssr/routes.js +8 -8
- package/dist/production/lib/dom/ssr/server.js +3 -1
- package/dist/production/lib/dom/ssr/single-fetch.d.ts +28 -2
- package/dist/production/lib/dom/ssr/single-fetch.js +73 -55
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.d.ts +28 -0
- package/dist/production/lib/dom-export/hydrated-router.js +32 -12
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.d.ts +3 -6
- package/dist/production/lib/hooks.js +7 -8
- package/dist/production/lib/href.js +1 -1
- package/dist/production/lib/router/history.js +1 -1
- package/dist/production/lib/router/instrumentation.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.js +1 -1
- package/dist/production/lib/router/matcher-route-pattern.preload.js +1 -1
- package/dist/production/lib/router/matcher.js +6 -1
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.d.ts +8 -0
- package/dist/production/lib/router/router.js +213 -91
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +31 -4
- package/dist/production/lib/router/utils.js +4 -3
- package/dist/production/lib/rsc/browser.js +4 -4
- package/dist/production/lib/rsc/errorBoundaries.js +1 -1
- package/dist/production/lib/rsc/html-stream/browser.js +1 -1
- package/dist/production/lib/rsc/html-stream/server.js +24 -12
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +3 -2
- package/dist/production/lib/rsc/server.ssr.js +1 -1
- package/dist/production/lib/server-runtime/build.d.ts +14 -0
- package/dist/production/lib/server-runtime/cookies.js +1 -1
- package/dist/production/lib/server-runtime/crypto.js +1 -1
- package/dist/production/lib/server-runtime/data.js +1 -1
- package/dist/production/lib/server-runtime/dev.js +1 -1
- package/dist/production/lib/server-runtime/entry.js +1 -1
- package/dist/production/lib/server-runtime/errors.js +1 -1
- package/dist/production/lib/server-runtime/headers.js +1 -1
- package/dist/production/lib/server-runtime/invariant.js +1 -1
- package/dist/production/lib/server-runtime/mode.js +1 -1
- package/dist/production/lib/server-runtime/routeMatching.js +1 -1
- package/dist/production/lib/server-runtime/routes.d.ts +1 -1
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +24 -8
- package/dist/production/lib/server-runtime/serverHandoff.d.ts +17 -0
- package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
- package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
- package/dist/production/lib/server-runtime/sessions.js +2 -2
- package/dist/production/lib/server-runtime/single-fetch.js +1 -1
- package/dist/production/lib/server-runtime/urls.js +1 -1
- package/dist/production/lib/server-runtime/warnings.js +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/route-data.d.ts +2 -2
- package/dist/production/lib/types/route-module-annotations.d.ts +1 -1
- package/dist/production/route-pattern.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
- package/dist/production/vendor/turbo-stream-v2/unflatten.js +23 -3
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/explanation/backend-for-frontend.md +0 -3
- package/docs/explanation/code-splitting.md +0 -3
- package/docs/explanation/concurrency.md +0 -3
- package/docs/explanation/hot-module-replacement.md +0 -3
- package/docs/explanation/lazy-route-discovery.md +4 -3
- package/docs/explanation/progressive-enhancement.md +0 -3
- package/docs/explanation/race-conditions.md +0 -3
- package/docs/explanation/react-transitions.md +0 -3
- package/docs/explanation/sessions-and-cookies.md +109 -5
- package/docs/explanation/state-management.md +0 -3
- package/docs/explanation/styling.md +0 -3
- package/docs/explanation/type-safety.md +0 -3
- package/docs/how-to/accessibility.md +0 -6
- package/docs/how-to/client-data.md +0 -3
- package/docs/how-to/custom-fetch.md +218 -0
- package/docs/how-to/data-strategy.md +23 -4
- package/docs/how-to/error-boundary.md +0 -3
- package/docs/how-to/error-reporting.md +0 -3
- package/docs/how-to/fetchers.md +0 -3
- package/docs/how-to/file-route-conventions.md +0 -3
- package/docs/how-to/file-uploads.md +0 -3
- package/docs/how-to/form-validation.md +0 -3
- package/docs/how-to/headers.md +0 -3
- package/docs/how-to/instrumentation.md +0 -3
- package/docs/how-to/middleware.md +7 -3
- package/docs/how-to/navigation-blocking.md +0 -3
- package/docs/how-to/optimize-revalidation.md +2 -5
- package/docs/how-to/pre-rendering.md +23 -4
- package/docs/how-to/presets.md +0 -3
- package/docs/how-to/react-server-components.md +0 -3
- package/docs/how-to/resource-routes.md +0 -3
- package/docs/how-to/route-discovery.md +147 -0
- package/docs/how-to/route-module-type-safety.md +0 -3
- package/docs/how-to/security.md +0 -3
- package/docs/how-to/server-bundles.md +0 -3
- package/docs/how-to/spa.md +2 -3
- package/docs/how-to/status.md +0 -3
- package/docs/how-to/suspense.md +22 -6
- package/docs/how-to/using-handle.md +0 -3
- package/docs/how-to/view-transitions.md +79 -15
- package/docs/start/framework/data-loading.md +9 -0
- package/docs/start/framework/navigating.md +5 -9
- package/docs/start/framework/rendering.md +37 -0
- package/docs/upgrading/future.md +0 -12
- package/docs/upgrading/v7.md +3 -33
- package/package.json +9 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
import { createMemoryHistory, createPath, invariant, parsePath, warning } from "./router/history.js";
|
|
12
12
|
import { defaultMapRouteProperties, getResolveToMatches, getRoutePattern, resolveTo, stripBasename } from "./router/utils.js";
|
|
13
13
|
import { getNavigatorCurrentUrl, validateNavigationTarget } from "./router/navigation.js";
|
|
14
|
-
import { createRouter } from "./router/router.js";
|
|
14
|
+
import { clientErrors, createRouter } from "./router/router.js";
|
|
15
15
|
import { AwaitContext, DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, LocationContext, NavigationContext, RouteContext, ViewTransitionContext, useIsRSCRouterContext } from "./context.js";
|
|
16
|
+
import { getAwaitPromise, getPromiseResult } from "./await.js";
|
|
16
17
|
import { _renderMatches, useActionData, useAsyncValue, useInRouterContext, useLoaderData, useLocation, useMatches, useNavigate, useOutlet, useParams, useRouteError, useRoutes, useRoutesImpl } from "./hooks.js";
|
|
17
18
|
import { warnOnce } from "./server-runtime/warnings.js";
|
|
19
|
+
import { FrameworkContext } from "./dom/ssr/components.js";
|
|
18
20
|
import * as React$1 from "react";
|
|
19
21
|
import { useOptimistic } from "react";
|
|
20
22
|
//#region lib/components.tsx
|
|
@@ -84,6 +86,11 @@ var Deferred = class {
|
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
};
|
|
89
|
+
function handleSkippedViewTransition(transition, document) {
|
|
90
|
+
transition.ready.catch((reason) => {
|
|
91
|
+
if (!(document.visibilityState === "hidden" || typeof reason === "object" && reason !== null && "name" in reason && reason.name === "AbortError")) throw reason;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
87
94
|
/**
|
|
88
95
|
* Render the UI for the given {@link DataRouter}. This component should
|
|
89
96
|
* typically be at the top of an app's element tree. The router prop should
|
|
@@ -122,13 +129,18 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
122
129
|
useTransitions = useIsRSCRouterContext() || useTransitions;
|
|
123
130
|
let [_state, setStateImpl] = React$1.useState(router.state);
|
|
124
131
|
let [state, setOptimisticState] = useOptimistic(_state);
|
|
132
|
+
let lastState = React$1.useRef(state);
|
|
125
133
|
let [pendingState, setPendingState] = React$1.useState();
|
|
126
134
|
let [vtContext, setVtContext] = React$1.useState({ isTransitioning: false });
|
|
127
135
|
let [renderDfd, setRenderDfd] = React$1.useState();
|
|
128
136
|
let [transition, setTransition] = React$1.useState();
|
|
129
137
|
let [interruption, setInterruption] = React$1.useState();
|
|
130
138
|
let fetcherData = React$1.useRef(/* @__PURE__ */ new Map());
|
|
139
|
+
let handledErrors = React$1.useRef(/* @__PURE__ */ new WeakSet());
|
|
131
140
|
let setState = React$1.useCallback((newState, { deletedFetchers, newErrors, flushSync, viewTransitionOpts }) => {
|
|
141
|
+
lastState.current = newState;
|
|
142
|
+
if (newErrors && newState.errors && clientErrors.has(newState.errors)) if (handledErrors.current.has(newState.errors)) newErrors = null;
|
|
143
|
+
else handledErrors.current.add(newState.errors);
|
|
132
144
|
if (newErrors && onError) Object.values(newErrors).forEach((error) => onError(error, {
|
|
133
145
|
location: newState.location,
|
|
134
146
|
params: newState.matches[0]?.params ?? {},
|
|
@@ -166,6 +178,7 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
166
178
|
let t = router.window.document.startViewTransition(() => {
|
|
167
179
|
reactDomFlushSyncImpl(() => setStateImpl(newState));
|
|
168
180
|
});
|
|
181
|
+
handleSkippedViewTransition(t, router.window.document);
|
|
169
182
|
t.finished.finally(() => {
|
|
170
183
|
reactDomFlushSyncImpl(() => {
|
|
171
184
|
setRenderDfd(void 0);
|
|
@@ -204,6 +217,15 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
204
217
|
onError
|
|
205
218
|
]);
|
|
206
219
|
React$1.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
|
|
220
|
+
React$1.useLayoutEffect(() => {
|
|
221
|
+
let errors = router.state.errors;
|
|
222
|
+
let newErrors = errors ? clientErrors.get(errors) : null;
|
|
223
|
+
if (lastState.current !== router.state || errors && newErrors && !handledErrors.current.has(errors)) setState(router.state, {
|
|
224
|
+
deletedFetchers: [],
|
|
225
|
+
flushSync: false,
|
|
226
|
+
newErrors: newErrors ?? null
|
|
227
|
+
});
|
|
228
|
+
}, [router, setState]);
|
|
207
229
|
React$1.useEffect(() => {
|
|
208
230
|
if (vtContext.isTransitioning && !vtContext.flushSync) setRenderDfd(new Deferred());
|
|
209
231
|
}, [vtContext]);
|
|
@@ -219,6 +241,7 @@ function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, onError, use
|
|
|
219
241
|
});
|
|
220
242
|
await renderPromise;
|
|
221
243
|
});
|
|
244
|
+
handleSkippedViewTransition(transition, router.window.document);
|
|
222
245
|
transition.finished.finally(() => {
|
|
223
246
|
setRenderDfd(void 0);
|
|
224
247
|
setTransition(void 0);
|
|
@@ -347,6 +370,10 @@ const MemoizedDataRoutes = React$1.memo(DataRoutes);
|
|
|
347
370
|
function DataRoutes({ routes, manifest, state, isStatic, onError }) {
|
|
348
371
|
let dataRouterContext = React$1.useContext(DataRouterContext);
|
|
349
372
|
invariant(dataRouterContext, "You must render this element inside a <DataRouterContext.Provider> element");
|
|
373
|
+
let discoveryRuntime = React$1.useContext(FrameworkContext)?.routeDiscoveryRuntime;
|
|
374
|
+
React$1.useEffect(() => {
|
|
375
|
+
if (state.initialized) discoveryRuntime?.markReady();
|
|
376
|
+
}, [state.initialized, discoveryRuntime]);
|
|
350
377
|
return useRoutesImpl(routes, void 0, {
|
|
351
378
|
router: dataRouterContext.router,
|
|
352
379
|
manifest,
|
|
@@ -624,6 +651,21 @@ function Routes({ children, location }) {
|
|
|
624
651
|
*
|
|
625
652
|
* **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
|
|
626
653
|
*
|
|
654
|
+
* Pass `unstable_promise` instead of `resolve` to opt into React's
|
|
655
|
+
* [`use()`](https://react.dev/reference/react/use) implementation. With
|
|
656
|
+
* `unstable_promise`, `errorElement` handles promise rejections, while errors
|
|
657
|
+
* thrown by children bubble to the nearest React error boundary.
|
|
658
|
+
*
|
|
659
|
+
* In React Server Components, `resolve` already has this error-handling behavior:
|
|
660
|
+
* `errorElement` handles only input rejections, while child render errors
|
|
661
|
+
* propagate to the surrounding error boundary. Both props accept promise-like
|
|
662
|
+
* values without modifying the source promise. Both props treat a falsy
|
|
663
|
+
* `errorElement` as absent and propagate the rejection. Pass an empty fragment
|
|
664
|
+
* to handle a rejection without rendering any content.
|
|
665
|
+
*
|
|
666
|
+
* <docs-warning>The `unstable_promise` prop is experimental and may change in
|
|
667
|
+
* minor or patch releases.</docs-warning>
|
|
668
|
+
*
|
|
627
669
|
* @example
|
|
628
670
|
* import { Await, useLoaderData } from "react-router";
|
|
629
671
|
*
|
|
@@ -664,9 +706,14 @@ function Routes({ children, location }) {
|
|
|
664
706
|
* @param {AwaitProps.children} props.children n/a
|
|
665
707
|
* @param {AwaitProps.errorElement} props.errorElement n/a
|
|
666
708
|
* @param {AwaitProps.resolve} props.resolve n/a
|
|
709
|
+
* @param props.unstable_promise A promise (or value) to read using React's `use()`
|
|
710
|
+
* API in client components. Accepts promise-like values without modifying the
|
|
711
|
+
* source promise. Pass exactly one of `unstable_promise` or `resolve`.
|
|
667
712
|
* @returns React element for the rendered awaited value
|
|
668
713
|
*/
|
|
669
|
-
function Await(
|
|
714
|
+
function Await(props) {
|
|
715
|
+
invariant("resolve" in props !== "unstable_promise" in props, "<Await> requires exactly one of `resolve` or `unstable_promise`");
|
|
716
|
+
let { children, errorElement } = props;
|
|
670
717
|
let dataRouterContext = React$1.useContext(DataRouterContext);
|
|
671
718
|
let dataRouterStateContext = React$1.useContext(DataRouterStateContext);
|
|
672
719
|
let onError = React$1.useCallback((error, errorInfo) => {
|
|
@@ -677,12 +724,25 @@ function Await({ children, errorElement, resolve }) {
|
|
|
677
724
|
errorInfo
|
|
678
725
|
});
|
|
679
726
|
}, [dataRouterContext, dataRouterStateContext]);
|
|
727
|
+
if ("unstable_promise" in props) return /* @__PURE__ */ React$1.createElement(AwaitPromise, {
|
|
728
|
+
value: props.unstable_promise,
|
|
729
|
+
errorElement,
|
|
730
|
+
onError
|
|
731
|
+
}, children);
|
|
680
732
|
return /* @__PURE__ */ React$1.createElement(AwaitErrorBoundary, {
|
|
681
|
-
resolve,
|
|
733
|
+
resolve: props.resolve,
|
|
682
734
|
errorElement,
|
|
683
735
|
onError
|
|
684
736
|
}, /* @__PURE__ */ React$1.createElement(ResolveAwait, null, children));
|
|
685
737
|
}
|
|
738
|
+
function AwaitPromise({ value, children, errorElement, onError }) {
|
|
739
|
+
let result = value != null && (typeof value === "object" || typeof value === "function") && "then" in value && typeof value.then === "function" ? React$1.use(getAwaitPromise(value, onError)) : {
|
|
740
|
+
status: "fulfilled",
|
|
741
|
+
value
|
|
742
|
+
};
|
|
743
|
+
if (result.status === "rejected" && !errorElement) throw result.reason;
|
|
744
|
+
return /* @__PURE__ */ React$1.createElement(AwaitContext.Provider, { value: result }, result.status === "rejected" ? errorElement : /* @__PURE__ */ React$1.createElement(ResolveAwait, null, children));
|
|
745
|
+
}
|
|
686
746
|
var AwaitErrorBoundary = class extends React$1.Component {
|
|
687
747
|
constructor(props) {
|
|
688
748
|
super(props);
|
|
@@ -716,7 +776,24 @@ var AwaitErrorBoundary = class extends React$1.Component {
|
|
|
716
776
|
} else {
|
|
717
777
|
status = 0;
|
|
718
778
|
Object.defineProperty(resolve, "_tracked", { get: () => true });
|
|
719
|
-
|
|
779
|
+
let result = getPromiseResult(resolve);
|
|
780
|
+
if (result) {
|
|
781
|
+
promise = resolve;
|
|
782
|
+
if (result.status === "fulfilled") {
|
|
783
|
+
status = 1;
|
|
784
|
+
Object.defineProperty(resolve, "_data", { get: () => result.value });
|
|
785
|
+
} else {
|
|
786
|
+
status = 2;
|
|
787
|
+
Object.defineProperty(resolve, "_error", { get: () => result.reason });
|
|
788
|
+
Promise.resolve(resolve).catch((reason) => {
|
|
789
|
+
try {
|
|
790
|
+
this.props.onError?.(reason);
|
|
791
|
+
} catch (error) {
|
|
792
|
+
console.error("<Await> caught the following error in onError", error);
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
} else promise = Promise.resolve(resolve).then((data) => Object.defineProperty(resolve, "_data", { get: () => data }), (error) => {
|
|
720
797
|
this.props.onError?.(error);
|
|
721
798
|
Object.defineProperty(resolve, "_error", { get: () => error });
|
|
722
799
|
});
|
|
@@ -32,8 +32,8 @@ type FetchersContextObject = {
|
|
|
32
32
|
fetcherData: Map<string, any>;
|
|
33
33
|
};
|
|
34
34
|
declare const FetchersContext: React$1.Context<FetchersContextObject | null>;
|
|
35
|
-
declare const AwaitContext: React$1.Context<TrackedPromise | null>;
|
|
36
|
-
declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | null>>;
|
|
35
|
+
declare const AwaitContext: React$1.Context<TrackedPromise | PromiseSettledResult<unknown> | null>;
|
|
36
|
+
declare const AwaitContextProvider: (props: React$1.ComponentProps<typeof AwaitContext.Provider>) => React$1.FunctionComponentElement<React$1.ProviderProps<TrackedPromise | PromiseSettledResult<unknown> | null>>;
|
|
37
37
|
interface NavigateOptions {
|
|
38
38
|
/** Replace the current entry in the history stack instead of pushing a new one */
|
|
39
39
|
replace?: boolean;
|
|
@@ -47,7 +47,12 @@ interface NavigateOptions {
|
|
|
47
47
|
relative?: RelativeRoutingType;
|
|
48
48
|
/** Wraps the initial state update for this navigation in a {@link https://react.dev/reference/react-dom/flushSync ReactDOM.flushSync} call instead of the default {@link https://react.dev/reference/react/startTransition React.startTransition} */
|
|
49
49
|
flushSync?: boolean;
|
|
50
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Enables a view transition for this navigation.
|
|
52
|
+
*
|
|
53
|
+
* @deprecated Use React's `<ViewTransition>` component instead. See the
|
|
54
|
+
* [migration guide](https://reactrouter.com/how-to/view-transitions).
|
|
55
|
+
*/
|
|
51
56
|
viewTransition?: boolean;
|
|
52
57
|
/** Specifies the default revalidation behavior after this submission */
|
|
53
58
|
defaultShouldRevalidate?: boolean;
|
|
@@ -112,6 +112,9 @@ interface SubmitOptions extends FetcherSubmitOptions {
|
|
|
112
112
|
navigate?: boolean;
|
|
113
113
|
/**
|
|
114
114
|
* Enable view transitions on this submission navigation
|
|
115
|
+
*
|
|
116
|
+
* @deprecated Use React's `<ViewTransition>` component instead. See the
|
|
117
|
+
* [migration guide](https://reactrouter.com/how-to/view-transitions).
|
|
115
118
|
*/
|
|
116
119
|
viewTransition?: boolean;
|
|
117
120
|
}
|
|
@@ -3,9 +3,9 @@ import { History, To } from "../router/history.js";
|
|
|
3
3
|
import { DataStrategyFunction, HTMLFormMethod, PatchRoutesOnNavigationFunction, RouteObject } from "../router/utils.js";
|
|
4
4
|
import { BlockerFunction, Fetcher, FutureConfig, GetScrollRestorationKeyFunction, HydrationState, RelativeRoutingType, Router, RouterInit } from "../router/router.js";
|
|
5
5
|
import { NavigateOptions } from "../context.js";
|
|
6
|
+
import { SerializeFrom } from "../types/route-data.js";
|
|
6
7
|
import { FetcherSubmitOptions, SubmitOptions, SubmitTarget, URLSearchParamsInit } from "./dom.js";
|
|
7
8
|
import { DiscoverBehavior, PrefetchBehavior, ScriptsProps } from "./ssr/components.js";
|
|
8
|
-
import { SerializeFrom } from "../types/route-data.js";
|
|
9
9
|
import { ClientInstrumentation } from "../router/instrumentation.js";
|
|
10
10
|
import * as React$1 from "react";
|
|
11
11
|
|
|
@@ -863,6 +863,9 @@ interface LinkProps extends Omit<React$1.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
|
863
863
|
*/
|
|
864
864
|
to: To;
|
|
865
865
|
/**
|
|
866
|
+
* **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
|
|
867
|
+
* component instead. See the [migration guide](../../how-to/view-transitions).
|
|
868
|
+
*
|
|
866
869
|
* Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
867
870
|
* for this navigation.
|
|
868
871
|
*
|
|
@@ -873,6 +876,8 @@ interface LinkProps extends Omit<React$1.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
|
873
876
|
* ```
|
|
874
877
|
*
|
|
875
878
|
* To apply specific styles for the transition, see {@link useViewTransitionState}
|
|
879
|
+
*
|
|
880
|
+
* @deprecated Use React's `<ViewTransition>` component instead.
|
|
876
881
|
*/
|
|
877
882
|
viewTransition?: boolean;
|
|
878
883
|
/**
|
|
@@ -1020,6 +1025,10 @@ type NavLinkRenderProps = {
|
|
|
1020
1025
|
/**
|
|
1021
1026
|
* Indicates if a view transition to the link's URL is in progress.
|
|
1022
1027
|
* See {@link useViewTransitionState}
|
|
1028
|
+
*
|
|
1029
|
+
* @deprecated Only tracks React Router's deprecated view transitions. Use
|
|
1030
|
+
* React's `<ViewTransition>` component to style transitions instead. See the
|
|
1031
|
+
* [migration guide](https://reactrouter.com/how-to/view-transitions).
|
|
1023
1032
|
*/
|
|
1024
1033
|
isTransitioning: boolean;
|
|
1025
1034
|
};
|
|
@@ -1059,9 +1068,6 @@ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children
|
|
|
1059
1068
|
* a.pending {
|
|
1060
1069
|
* color: blue;
|
|
1061
1070
|
* }
|
|
1062
|
-
* a.transitioning {
|
|
1063
|
-
* view-transition-name: my-transition;
|
|
1064
|
-
* }
|
|
1065
1071
|
* ```
|
|
1066
1072
|
*
|
|
1067
1073
|
* Or you can specify a function that receives {@link NavLinkRenderProps} and
|
|
@@ -1074,6 +1080,10 @@ interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children
|
|
|
1074
1080
|
* ""
|
|
1075
1081
|
* )} />
|
|
1076
1082
|
* ```
|
|
1083
|
+
*
|
|
1084
|
+
* The `transitioning` class is deprecated and only tracks React Router's
|
|
1085
|
+
* legacy view transitions. Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
|
|
1086
|
+
* component instead. See the [migration guide](../../how-to/view-transitions).
|
|
1077
1087
|
*/
|
|
1078
1088
|
className?: string | ((props: NavLinkRenderProps) => string | undefined);
|
|
1079
1089
|
/**
|
|
@@ -1257,9 +1267,14 @@ interface FormProps extends SharedFormProps {
|
|
|
1257
1267
|
*/
|
|
1258
1268
|
state?: any;
|
|
1259
1269
|
/**
|
|
1270
|
+
* **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
|
|
1271
|
+
* component instead. See the [migration guide](../../how-to/view-transitions).
|
|
1272
|
+
*
|
|
1260
1273
|
* Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
1261
1274
|
* for this navigation. To apply specific styles during the transition, see
|
|
1262
1275
|
* {@link useViewTransitionState}.
|
|
1276
|
+
*
|
|
1277
|
+
* @deprecated Use React's `<ViewTransition>` component instead.
|
|
1263
1278
|
*/
|
|
1264
1279
|
viewTransition?: boolean;
|
|
1265
1280
|
}
|
|
@@ -1405,9 +1420,9 @@ declare namespace ScrollRestoration {
|
|
|
1405
1420
|
* @param options.state The state to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
|
1406
1421
|
* entry for this navigation. Defaults to `undefined`.
|
|
1407
1422
|
* @param options.target The target attribute for the link. Defaults to `undefined`.
|
|
1408
|
-
* @param options.viewTransition
|
|
1409
|
-
*
|
|
1410
|
-
*
|
|
1423
|
+
* @param options.viewTransition **Deprecated.** Use React's
|
|
1424
|
+
* [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
|
|
1425
|
+
* instead. See the [migration guide](../../how-to/view-transitions).
|
|
1411
1426
|
* @param options.defaultShouldRevalidate Specify the default revalidation
|
|
1412
1427
|
* behavior for the navigation. When not specified, loaders revalidate
|
|
1413
1428
|
* according to the router's standard revalidation behavior.
|
|
@@ -1435,10 +1450,9 @@ declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to:
|
|
|
1435
1450
|
state?: any;
|
|
1436
1451
|
preventScrollReset?: boolean;
|
|
1437
1452
|
relative?: RelativeRoutingType;
|
|
1438
|
-
viewTransition?: boolean;
|
|
1439
1453
|
defaultShouldRevalidate?: boolean;
|
|
1440
1454
|
useTransitions?: boolean;
|
|
1441
|
-
}): (event: React$1.MouseEvent<E, MouseEvent>) => void;
|
|
1455
|
+
} & Pick<NavigateOptions, "viewTransition">): (event: React$1.MouseEvent<E, MouseEvent>) => void;
|
|
1442
1456
|
/**
|
|
1443
1457
|
* Returns a tuple of the current URL's [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
|
|
1444
1458
|
* and a function to update them. Setting the search params causes a navigation.
|
|
@@ -1662,6 +1676,10 @@ interface FetcherSubmitFunction {
|
|
|
1662
1676
|
* The imperative version of {@link Form | `<Form>`} that lets you submit a form
|
|
1663
1677
|
* from code instead of a user interaction.
|
|
1664
1678
|
*
|
|
1679
|
+
* The `viewTransition` submission option is deprecated. Use React's
|
|
1680
|
+
* [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
|
|
1681
|
+
* instead. See the [migration guide](../../how-to/view-transitions).
|
|
1682
|
+
*
|
|
1665
1683
|
* @example
|
|
1666
1684
|
* import { useSubmit } from "react-router";
|
|
1667
1685
|
*
|
|
@@ -2025,6 +2043,11 @@ declare function usePrompt({
|
|
|
2025
2043
|
message: string;
|
|
2026
2044
|
}): void;
|
|
2027
2045
|
/**
|
|
2046
|
+
* **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
|
|
2047
|
+
* component to style transitions instead. This hook only tracks React Router's
|
|
2048
|
+
* legacy view transitions, not transitions started by React. See the
|
|
2049
|
+
* [migration guide](../../how-to/view-transitions).
|
|
2050
|
+
*
|
|
2028
2051
|
* This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
2029
2052
|
* and the specified location matches either side of the navigation (the URL you are
|
|
2030
2053
|
* navigating **to** or the URL you are navigating **from**). This can be used to apply finer-grained styles to
|
|
@@ -2044,6 +2067,8 @@ declare function usePrompt({
|
|
|
2044
2067
|
* more details.
|
|
2045
2068
|
* @returns `true` if there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
2046
2069
|
* and the resolved path matches the transition's destination or source pathname, otherwise `false`.
|
|
2070
|
+
*
|
|
2071
|
+
* @deprecated Use React's `<ViewTransition>` component instead.
|
|
2047
2072
|
*/
|
|
2048
2073
|
declare function useViewTransitionState(to: To, {
|
|
2049
2074
|
relative
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -14,10 +14,10 @@ import { ErrorResponseImpl, SUPPORTED_ERROR_TYPES, defaultMapRouteProperties, jo
|
|
|
14
14
|
import { IDLE_FETCHER, createRouter } from "../router/router.js";
|
|
15
15
|
import { DataRouterNavigationContext, NavigationContext, RouteContext, ViewTransitionContext } from "../context.js";
|
|
16
16
|
import { useBlocker, useCurrentRouteId, useDataRouterContext, useDataRouterFetchers, useDataRouterState, useHref, useLocation, useMatches, useNavigate, useNavigation, useResolvedPath } from "../hooks.js";
|
|
17
|
-
import { Router, hydrationRouteProperties } from "../components.js";
|
|
18
|
-
import { createSearchParams, getFormSubmissionInfo, getSearchParamsForLocation, shouldProcessLinkClick } from "./dom.js";
|
|
19
17
|
import { escapeHtml } from "./ssr/markup.js";
|
|
20
18
|
import { FrameworkContext, PrefetchPageLinks, mergeRefs, usePrefetchBehavior } from "./ssr/components.js";
|
|
19
|
+
import { Router, hydrationRouteProperties } from "../components.js";
|
|
20
|
+
import { createSearchParams, getFormSubmissionInfo, getSearchParamsForLocation, shouldProcessLinkClick } from "./dom.js";
|
|
21
21
|
import * as React$1 from "react";
|
|
22
22
|
//#region lib/dom/lib.tsx
|
|
23
23
|
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
@@ -592,9 +592,9 @@ ScrollRestoration.displayName = "ScrollRestoration";
|
|
|
592
592
|
* @param options.state The state to add to the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
|
|
593
593
|
* entry for this navigation. Defaults to `undefined`.
|
|
594
594
|
* @param options.target The target attribute for the link. Defaults to `undefined`.
|
|
595
|
-
* @param options.viewTransition
|
|
596
|
-
*
|
|
597
|
-
*
|
|
595
|
+
* @param options.viewTransition **Deprecated.** Use React's
|
|
596
|
+
* [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
|
|
597
|
+
* instead. See the [migration guide](../../how-to/view-transitions).
|
|
598
598
|
* @param options.defaultShouldRevalidate Specify the default revalidation
|
|
599
599
|
* behavior for the navigation. When not specified, loaders revalidate
|
|
600
600
|
* according to the router's standard revalidation behavior.
|
|
@@ -756,6 +756,10 @@ let getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
|
|
|
756
756
|
* The imperative version of {@link Form | `<Form>`} that lets you submit a form
|
|
757
757
|
* from code instead of a user interaction.
|
|
758
758
|
*
|
|
759
|
+
* The `viewTransition` submission option is deprecated. Use React's
|
|
760
|
+
* [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition) component
|
|
761
|
+
* instead. See the [migration guide](../../how-to/view-transitions).
|
|
762
|
+
*
|
|
759
763
|
* @example
|
|
760
764
|
* import { useSubmit } from "react-router";
|
|
761
765
|
*
|
|
@@ -1235,6 +1239,11 @@ function usePrompt({ when, message }) {
|
|
|
1235
1239
|
}, [blocker, when]);
|
|
1236
1240
|
}
|
|
1237
1241
|
/**
|
|
1242
|
+
* **Deprecated.** Use React's [`<ViewTransition>`](https://react.dev/reference/react/ViewTransition)
|
|
1243
|
+
* component to style transitions instead. This hook only tracks React Router's
|
|
1244
|
+
* legacy view transitions, not transitions started by React. See the
|
|
1245
|
+
* [migration guide](../../how-to/view-transitions).
|
|
1246
|
+
*
|
|
1238
1247
|
* This hook returns `true` when there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
1239
1248
|
* and the specified location matches either side of the navigation (the URL you are
|
|
1240
1249
|
* navigating **to** or the URL you are navigating **from**). This can be used to apply finer-grained styles to
|
|
@@ -1254,6 +1263,8 @@ function usePrompt({ when, message }) {
|
|
|
1254
1263
|
* more details.
|
|
1255
1264
|
* @returns `true` if there is an active [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
|
|
1256
1265
|
* and the resolved path matches the transition's destination or source pathname, otherwise `false`.
|
|
1266
|
+
*
|
|
1267
|
+
* @deprecated Use React's `<ViewTransition>` component instead.
|
|
1257
1268
|
*/
|
|
1258
1269
|
function useViewTransitionState(to, { relative } = {}) {
|
|
1259
1270
|
let vtContext = React$1.useContext(ViewTransitionContext);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -13,8 +13,8 @@ import { createPath, invariant, parsePath, warning } from "../router/history.js"
|
|
|
13
13
|
import { convertRoutesToDataRoutes, isRouteErrorResponse } from "../router/utils.js";
|
|
14
14
|
import { IDLE_BLOCKER, IDLE_FETCHER, IDLE_NAVIGATION } from "../router/router.js";
|
|
15
15
|
import { DataRouterContext, DataRouterDataContext, DataRouterNavigationContext, DataRouterStateContext, FetchersContext, ViewTransitionContext } from "../context.js";
|
|
16
|
-
import { DataRoutes, Router } from "../components.js";
|
|
17
16
|
import { escapeHtml } from "./ssr/markup.js";
|
|
17
|
+
import { DataRoutes, Router } from "../components.js";
|
|
18
18
|
import * as React$1 from "react";
|
|
19
19
|
//#region lib/dom/server.tsx
|
|
20
20
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.5.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { useIsRSCRouterContext } from "../../context.js";
|
|
12
12
|
import { useDataRouterContext, useDataRouterData, useDataRouterState, useLocation } from "../../hooks.js";
|
|
13
|
-
import { warnOnce } from "../../server-runtime/warnings.js";
|
|
14
13
|
import invariant from "./invariant.js";
|
|
15
14
|
import { getKeyedLinksForMatches, getKeyedPrefetchLinks, getModuleLinkHrefs, getNewMatchesForLinks, isPageLinkDescriptor } from "./links.js";
|
|
16
15
|
import { escapeHtml } from "./markup.js";
|
|
17
16
|
import { singleFetchUrl } from "./single-fetch.js";
|
|
17
|
+
import { warnOnce } from "../../server-runtime/warnings.js";
|
|
18
18
|
import { getPartialManifest, isFogOfWarEnabled } from "./fog-of-war.js";
|
|
19
19
|
import * as React$1 from "react";
|
|
20
20
|
//#region lib/dom/ssr/components.tsx
|
|
@@ -234,19 +234,21 @@ function useKeyedPrefetchLinks(matches) {
|
|
|
234
234
|
}
|
|
235
235
|
function RSCPrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps }) {
|
|
236
236
|
let location = useLocation();
|
|
237
|
+
let { unstable_apiServerOrigin } = useFrameworkContext();
|
|
237
238
|
let dataHrefs = React$1.useMemo(() => {
|
|
238
239
|
if (page === location.pathname + location.search + location.hash) return [];
|
|
239
|
-
let url = singleFetchUrl(page, "rsc");
|
|
240
|
+
let url = singleFetchUrl(page, "rsc", unstable_apiServerOrigin);
|
|
240
241
|
let hasSomeRoutesWithShouldRevalidate = false;
|
|
241
242
|
let targetRoutes = [];
|
|
242
243
|
for (let match of nextMatches) if (typeof match.route.shouldRevalidate === "function") hasSomeRoutesWithShouldRevalidate = true;
|
|
243
244
|
else targetRoutes.push(match.route.id);
|
|
244
245
|
if (hasSomeRoutesWithShouldRevalidate && targetRoutes.length > 0) url.searchParams.set("_routes", targetRoutes.join(","));
|
|
245
|
-
return [url.pathname + url.search];
|
|
246
|
+
return [unstable_apiServerOrigin ? url.toString() : url.pathname + url.search];
|
|
246
247
|
}, [
|
|
247
248
|
page,
|
|
248
249
|
location,
|
|
249
|
-
nextMatches
|
|
250
|
+
nextMatches,
|
|
251
|
+
unstable_apiServerOrigin
|
|
250
252
|
]);
|
|
251
253
|
return /* @__PURE__ */ React$1.createElement(React$1.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React$1.createElement("link", {
|
|
252
254
|
key: href,
|
|
@@ -258,7 +260,7 @@ function RSCPrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps })
|
|
|
258
260
|
}
|
|
259
261
|
function PrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps }) {
|
|
260
262
|
let location = useLocation();
|
|
261
|
-
let { manifest, routeModules } = useFrameworkContext();
|
|
263
|
+
let { manifest, routeModules, unstable_apiServerOrigin } = useFrameworkContext();
|
|
262
264
|
let { matches } = useDataRouterState("PrefetchPageLinks");
|
|
263
265
|
let { loaderData } = useDataRouterData("PrefetchPageLinks");
|
|
264
266
|
let newMatchesForData = React$1.useMemo(() => getNewMatchesForLinks(page, nextMatches, matches, manifest, location, "data"), [
|
|
@@ -287,9 +289,9 @@ function PrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps }) {
|
|
|
287
289
|
else routesParams.add(m.route.id);
|
|
288
290
|
});
|
|
289
291
|
if (routesParams.size === 0) return [];
|
|
290
|
-
let url = singleFetchUrl(page, "data");
|
|
292
|
+
let url = singleFetchUrl(page, "data", unstable_apiServerOrigin);
|
|
291
293
|
if (foundOptOutRoute && routesParams.size > 0) url.searchParams.set("_routes", nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(","));
|
|
292
|
-
return [url.pathname + url.search];
|
|
294
|
+
return [unstable_apiServerOrigin ? url.toString() : url.pathname + url.search];
|
|
293
295
|
}, [
|
|
294
296
|
loaderData,
|
|
295
297
|
location,
|
|
@@ -297,7 +299,8 @@ function PrefetchPageLinksImpl({ page, matches: nextMatches, ...linkProps }) {
|
|
|
297
299
|
newMatchesForData,
|
|
298
300
|
nextMatches,
|
|
299
301
|
page,
|
|
300
|
-
routeModules
|
|
302
|
+
routeModules,
|
|
303
|
+
unstable_apiServerOrigin
|
|
301
304
|
]);
|
|
302
305
|
let moduleHrefs = React$1.useMemo(() => getModuleLinkHrefs(newMatchesForAssets, manifest), [newMatchesForAssets, manifest]);
|
|
303
306
|
let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import { DataRouteObject, RouteBranch, RouteManifest } from "../../router/utils.js";
|
|
3
3
|
import { StaticHandlerContext } from "../../router/router.js";
|
|
4
|
-
import { RouteModules } from "./routeModules.js";
|
|
5
4
|
import { EntryRoute } from "./routes.js";
|
|
5
|
+
import { RouteModules } from "./routeModules.js";
|
|
6
|
+
import { DiscoveryState, RouteDiscoveryRuntime } from "./route-discovery.js";
|
|
6
7
|
import { ServerBuild } from "../../server-runtime/build.js";
|
|
7
8
|
|
|
8
9
|
//#region lib/dom/ssr/entry.d.ts
|
|
@@ -11,6 +12,8 @@ type SerializedError = {
|
|
|
11
12
|
stack?: string;
|
|
12
13
|
};
|
|
13
14
|
interface FrameworkContextObject {
|
|
15
|
+
routeDiscoveryRuntime?: RouteDiscoveryRuntime;
|
|
16
|
+
routeDiscoveryState?: DiscoveryState;
|
|
14
17
|
manifest: AssetsManifest;
|
|
15
18
|
routeModules: RouteModules;
|
|
16
19
|
criticalCss?: CriticalCss;
|
|
@@ -18,6 +21,8 @@ interface FrameworkContextObject {
|
|
|
18
21
|
future: FutureConfig;
|
|
19
22
|
ssr: boolean;
|
|
20
23
|
isSpaMode: boolean;
|
|
24
|
+
unstable_apiOnly?: boolean;
|
|
25
|
+
unstable_apiServerOrigin?: string;
|
|
21
26
|
routeDiscovery: ServerBuild["routeDiscovery"];
|
|
22
27
|
nonce?: string;
|
|
23
28
|
serializeError?(error: Error): SerializedError;
|
|
@@ -41,7 +46,9 @@ interface EntryContext extends FrameworkContextObject {
|
|
|
41
46
|
staticHandlerContext: StaticHandlerContext;
|
|
42
47
|
serverHandoffStream?: ReadableStream<Uint8Array>;
|
|
43
48
|
}
|
|
44
|
-
|
|
49
|
+
interface FutureConfig {
|
|
50
|
+
unstable_customRouteDiscovery?: boolean;
|
|
51
|
+
}
|
|
45
52
|
type CriticalCss = string | {
|
|
46
53
|
rel: "stylesheet";
|
|
47
54
|
href: string;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { PatchRoutesOnNavigationFunction } from "../../router/utils.js";
|
|
3
3
|
import { Router } from "../../router/router.js";
|
|
4
4
|
import { RouteModules } from "./routeModules.js";
|
|
5
|
+
import { RouterFetch } from "./single-fetch.js";
|
|
5
6
|
import { AssetsManifest } from "./entry.js";
|
|
6
7
|
import { ServerBuild } from "../../server-runtime/build.js";
|
|
7
8
|
|
|
8
9
|
//#region lib/dom/ssr/fog-of-war.d.ts
|
|
9
|
-
declare function getPatchRoutesOnNavigationFunction(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined): PatchRoutesOnNavigationFunction | undefined;
|
|
10
|
-
declare function useFogOFWarDiscovery(router: Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean): void;
|
|
10
|
+
declare function getPatchRoutesOnNavigationFunction(getRouter: () => Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, basename: string | undefined, fetchImplementation?: RouterFetch, serverOrigin?: string, isApiOnly?: boolean): PatchRoutesOnNavigationFunction | undefined;
|
|
11
|
+
declare function useFogOFWarDiscovery(router: Router, manifest: AssetsManifest, routeModules: RouteModules, ssr: boolean, routeDiscovery: ServerBuild["routeDiscovery"], isSpaMode: boolean, fetchImplementation?: RouterFetch, serverOrigin?: string, isApiOnly?: boolean): void;
|
|
11
12
|
//#endregion
|
|
12
13
|
export { getPatchRoutesOnNavigationFunction, useFogOFWarDiscovery };
|