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
|
-
import { Location, Path, To } from "./history.js";
|
|
2
|
+
import { Action, Location, Path, To } from "./history.js";
|
|
3
3
|
import * as React$1 from "react";
|
|
4
4
|
|
|
5
5
|
//#region lib/router/utils.d.ts
|
|
@@ -185,6 +185,13 @@ interface DataFunctionArgs<Context> {
|
|
|
185
185
|
* In Framework mode, this is a normalized URL with React-Router-specific
|
|
186
186
|
* implementation details removed (`.data` suffixes, `index`/`_routes` search
|
|
187
187
|
* params). For the raw incoming URL, use `request.url`.
|
|
188
|
+
*
|
|
189
|
+
* This normalization preserves standard URL pathname encoding and casing.
|
|
190
|
+
* For example, a request to `/%61dmin.data` produces a `url.pathname` of
|
|
191
|
+
* `/%61dmin`. This is not a canonical representation of the matched route.
|
|
192
|
+
* For authorization, attach {@link https://reactrouter.com/how-to/middleware#authentication server middleware}
|
|
193
|
+
* to the protected route or a common ancestor instead of relying on literal
|
|
194
|
+
* pathname-prefix comparisons.
|
|
188
195
|
*/
|
|
189
196
|
url: URL;
|
|
190
197
|
/**
|
|
@@ -389,6 +396,11 @@ interface DataStrategyMatch extends RouteMatch<string, DataRouteObject> {
|
|
|
389
396
|
*/
|
|
390
397
|
resolve: (handlerOverride?: (handler: (ctx?: unknown) => DataFunctionReturnValue) => DataFunctionReturnValue) => Promise<DataStrategyResult>;
|
|
391
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* The operation that initiated a data strategy execution. Static handler
|
|
401
|
+
* executions use `"static"`.
|
|
402
|
+
*/
|
|
403
|
+
type DataStrategyInitiator = "initialization" | "navigation" | "fetcher" | "revalidation" | "static";
|
|
392
404
|
interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctionArgs<Context> {
|
|
393
405
|
/**
|
|
394
406
|
* Matches for this route extended with Data strategy APIs
|
|
@@ -396,8 +408,23 @@ interface DataStrategyFunctionArgs<Context = DefaultContext> extends DataFunctio
|
|
|
396
408
|
matches: DataStrategyMatch[];
|
|
397
409
|
runClientMiddleware: (cb: DataStrategyFunction<Context>) => Promise<Record<string, DataStrategyResult>>;
|
|
398
410
|
/**
|
|
399
|
-
* The
|
|
400
|
-
*
|
|
411
|
+
* The operation that initiated this data strategy execution
|
|
412
|
+
*
|
|
413
|
+
* This field is experimental and subject to breaking changes.
|
|
414
|
+
*/
|
|
415
|
+
unstable_initiator: DataStrategyInitiator;
|
|
416
|
+
/**
|
|
417
|
+
* The history action (`"PUSH"`, `"REPLACE"`, or `"POP"`) for a navigation-
|
|
418
|
+
* initiated execution, including fetchers reloaded by that navigation.
|
|
419
|
+
* `null` for initialization, fetcher, revalidation, and static executions.
|
|
420
|
+
*
|
|
421
|
+
* This field is experimental and subject to breaking changes.
|
|
422
|
+
*/
|
|
423
|
+
unstable_navigationType: Action | null;
|
|
424
|
+
/**
|
|
425
|
+
* The key of the fetcher targeted by this data strategy execution, otherwise
|
|
426
|
+
* `null`. Fetchers reloaded during a navigation or revalidation retain that
|
|
427
|
+
* `unstable_initiator` while providing their key here.
|
|
401
428
|
*/
|
|
402
429
|
fetcherKey: string | null;
|
|
403
430
|
}
|
|
@@ -962,4 +989,4 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
962
989
|
*/
|
|
963
990
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
964
991
|
//#endregion
|
|
965
|
-
export { ActionFunction, ActionFunctionArgs, BaseRouteObject, DataRouteMatch, DataRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, DataStrategyResult, DataWithResponseInit, ErrorResponse, ErrorResponseImpl, FormEncType, FormMethod, HTMLFormMethod, IndexRouteObject, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, MapRoutePropertiesFunction, MaybePromise, MiddlewareFunction, MiddlewareNextFunction, NonIndexRouteObject, ParamParseKey, Params, PatchRoutesOnNavigationFunction, PatchRoutesOnNavigationFunctionArgs, PathMatch, PathParam, PathPattern, RedirectFunction, RouteBranch, RouteData, RouteManifest, RouteMatch, RouteObject, RouterContext, RouterContextProvider, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, Submission, TrackedPromise, UIMatch, createContext, data, defaultMapRouteProperties, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath };
|
|
992
|
+
export { ActionFunction, ActionFunctionArgs, BaseRouteObject, DataRouteMatch, DataRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyInitiator, DataStrategyMatch, DataStrategyResult, DataWithResponseInit, ErrorResponse, ErrorResponseImpl, FormEncType, FormMethod, HTMLFormMethod, IndexRouteObject, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, MapRoutePropertiesFunction, MaybePromise, MiddlewareFunction, MiddlewareNextFunction, NonIndexRouteObject, ParamParseKey, Params, PatchRoutesOnNavigationFunction, PatchRoutesOnNavigationFunctionArgs, PathMatch, PathParam, PathPattern, RedirectFunction, RouteBranch, RouteData, RouteManifest, RouteMatch, RouteObject, RouterContext, RouterContextProvider, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, Submission, TrackedPromise, UIMatch, createContext, data, defaultMapRouteProperties, generatePath, isRouteErrorResponse, matchPath, matchRoutes, redirect, redirectDocument, replace, resolvePath };
|
|
@@ -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
|
*
|
|
@@ -129,6 +129,7 @@ var RouterContextProvider = class {
|
|
|
129
129
|
this.#map.set(context, value);
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
|
+
var DiscoveryCancelledError = class extends Error {};
|
|
132
133
|
const unsupportedLazyRouteObjectKeys = new Set([
|
|
133
134
|
"lazy",
|
|
134
135
|
"caseSensitive",
|
|
@@ -514,7 +515,7 @@ function compilePath(path, caseSensitive = false, end = true) {
|
|
|
514
515
|
return "(?:/([^\\/]*))?";
|
|
515
516
|
}
|
|
516
517
|
return "/([^\\/]+)";
|
|
517
|
-
}).replace(/\/([\
|
|
518
|
+
}).replace(/\/((?:[^/?()[\]*^\\]|\\.)+)\?(?=\/|$|\()/g, "(?:/$1)?");
|
|
518
519
|
if (path.endsWith("*")) {
|
|
519
520
|
params.push({ paramName: "*" });
|
|
520
521
|
regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
|
|
@@ -875,4 +876,4 @@ function parseToInfo(_to, basename) {
|
|
|
875
876
|
};
|
|
876
877
|
}
|
|
877
878
|
//#endregion
|
|
878
|
-
export { ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, createDataFunctionUrl, data, decodePath, defaultMapRouteProperties, encodePathParam, explodeOptionalSegments, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, normalizePathname, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename };
|
|
879
|
+
export { DiscoveryCancelledError, ErrorResponseImpl, RouterContextProvider, SUPPORTED_ERROR_TYPES, compilePath, convertRouteMatchToUiMatch, convertRoutesToDataRoutes, createContext, createDataFunctionUrl, data, decodePath, defaultMapRouteProperties, encodePathParam, explodeOptionalSegments, flattenAndRankRoutes, generatePath, getPathContributingMatches, getResolveToMatches, getRoutePattern, isAbsoluteUrl, isBrowser, isRouteErrorResponse, isUnsupportedLazyRouteFunctionKey, isUnsupportedLazyRouteObjectKey, joinPaths, matchPath, matchRoutes, matchRoutesImpl, normalizePathname, parseToInfo, prependBasename, redirect, redirectDocument, removeDoubleSlashes, removeTrailingSlash, replace, resolvePath, resolveTo, stripBasename };
|
|
@@ -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,12 +14,12 @@ import { ErrorResponseImpl, createContext, resolvePath } from "../router/utils.j
|
|
|
14
14
|
import { validateNavigationTarget } from "../router/navigation.js";
|
|
15
15
|
import { createRouter, hasInvalidProtocol, isMutationMethod } from "../router/router.js";
|
|
16
16
|
import { RSCRouterContext } from "../context.js";
|
|
17
|
-
import { RouterProvider } from "../components.js";
|
|
18
17
|
import { createRequestInit } from "../dom/ssr/data.js";
|
|
19
18
|
import { getSingleFetchDataStrategyImpl, singleFetchUrl, stripIndexParam } from "../dom/ssr/single-fetch.js";
|
|
20
19
|
import { noActionDefinedError, shouldHydrateRouteLoader } from "../dom/ssr/routes.js";
|
|
21
|
-
import { getPathsWithAncestors, handleClientVersionMismatch } from "../dom/ssr/fog-of-war.js";
|
|
20
|
+
import { getManifestPathsParam, getPathsWithAncestors, handleClientVersionMismatch } from "../dom/ssr/fog-of-war.js";
|
|
22
21
|
import { FrameworkContext, setIsHydrated } from "../dom/ssr/components.js";
|
|
22
|
+
import { RouterProvider } from "../components.js";
|
|
23
23
|
import { RSCRouterGlobalErrorBoundary } from "./errorBoundaries.js";
|
|
24
24
|
import { populateRSCRouteModules } from "./route-modules.js";
|
|
25
25
|
import { getHydrationData } from "../dom/ssr/hydration.js";
|
|
@@ -539,7 +539,7 @@ function getManifestUrl(paths, clientVersion) {
|
|
|
539
539
|
else {
|
|
540
540
|
let basename = (window.__reactRouterDataRouter.basename ?? "").replace(/^\/|\/$/g, "");
|
|
541
541
|
url = new URL(`${basename}/.manifest`, window.location.origin);
|
|
542
|
-
url.searchParams.set("paths", paths
|
|
542
|
+
url.searchParams.set("paths", getManifestPathsParam(paths));
|
|
543
543
|
}
|
|
544
544
|
if (clientVersion !== void 0) url.searchParams.set("version", clientVersion);
|
|
545
545
|
return url;
|
|
@@ -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
|
*
|
|
@@ -21,11 +21,31 @@ function injectRSCPayload(rscStream, { nonce } = {}) {
|
|
|
21
21
|
let rscReader = null;
|
|
22
22
|
let buffered = [];
|
|
23
23
|
let timeout = null;
|
|
24
|
+
async function stop(reason) {
|
|
25
|
+
cancelled = true;
|
|
26
|
+
if (timeout) {
|
|
27
|
+
clearTimeout(timeout);
|
|
28
|
+
timeout = null;
|
|
29
|
+
}
|
|
30
|
+
buffered.length = 0;
|
|
31
|
+
resolveFlightDataPromise();
|
|
32
|
+
if (rscReader && rscStream.locked) await rscReader.cancel(reason).catch(() => {});
|
|
33
|
+
else await rscStream.cancel(reason).catch(() => {});
|
|
34
|
+
}
|
|
35
|
+
function tryEnqueue(controller, chunk) {
|
|
36
|
+
try {
|
|
37
|
+
controller.enqueue(chunk);
|
|
38
|
+
return true;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
stop(error);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
function flushBufferedChunks(controller) {
|
|
25
45
|
for (let chunk of buffered) {
|
|
26
46
|
let buf = decoder.decode(chunk, { stream: true });
|
|
27
47
|
if (buf.endsWith(trailer)) buf = buf.slice(0, -14);
|
|
28
|
-
controller
|
|
48
|
+
if (!tryEnqueue(controller, encoder.encode(buf))) return;
|
|
29
49
|
}
|
|
30
50
|
buffered.length = 0;
|
|
31
51
|
timeout = null;
|
|
@@ -50,18 +70,10 @@ function injectRSCPayload(rscStream, { nonce } = {}) {
|
|
|
50
70
|
clearTimeout(timeout);
|
|
51
71
|
flushBufferedChunks(controller);
|
|
52
72
|
}
|
|
53
|
-
controller
|
|
73
|
+
tryEnqueue(controller, encoder.encode("</body></html>"));
|
|
54
74
|
},
|
|
55
75
|
async cancel(reason) {
|
|
56
|
-
|
|
57
|
-
if (timeout) {
|
|
58
|
-
clearTimeout(timeout);
|
|
59
|
-
timeout = null;
|
|
60
|
-
}
|
|
61
|
-
buffered.length = 0;
|
|
62
|
-
if (rscReader) await rscReader.cancel(reason).catch(() => {});
|
|
63
|
-
else await rscStream.cancel(reason).catch(() => {});
|
|
64
|
-
resolveFlightDataPromise();
|
|
76
|
+
await stop(reason);
|
|
65
77
|
}
|
|
66
78
|
});
|
|
67
79
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { Location } from "../router/history.js";
|
|
3
|
-
import { ActionFunction, LoaderFunction, Params, RouterContextProvider, ShouldRevalidateFunction } from "../router/utils.js";
|
|
3
|
+
import { ActionFunction, LoaderFunction, MiddlewareFunction, Params, RouterContextProvider, ShouldRevalidateFunction } from "../router/utils.js";
|
|
4
4
|
import { ClientActionFunction, ClientLoaderFunction, HeadersFunction, LinksFunction, MetaFunction } from "../dom/ssr/routeModules.js";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
6
|
import { ReactFormState } from "react-dom/client";
|
|
@@ -19,6 +19,7 @@ type RSCRouteConfigEntryBase = {
|
|
|
19
19
|
links?: LinksFunction;
|
|
20
20
|
loader?: LoaderFunction;
|
|
21
21
|
meta?: MetaFunction;
|
|
22
|
+
middleware?: MiddlewareFunction<any>[];
|
|
22
23
|
shouldRevalidate?: ShouldRevalidateFunction;
|
|
23
24
|
};
|
|
24
25
|
type RSCRouteConfigEntry = RSCRouteConfigEntryBase & {
|
|
@@ -204,7 +205,7 @@ declare function matchRSCServerRequest({
|
|
|
204
205
|
onError,
|
|
205
206
|
request,
|
|
206
207
|
routes,
|
|
207
|
-
generateResponse
|
|
208
|
+
generateResponse: encodeResponse
|
|
208
209
|
}: {
|
|
209
210
|
allowedActionOrigins?: string[];
|
|
210
211
|
createTemporaryReferenceSet: () => unknown;
|
|
@@ -19,7 +19,21 @@ interface ServerBuild {
|
|
|
19
19
|
publicPath: string;
|
|
20
20
|
assetsBuildDirectory: string;
|
|
21
21
|
future: FutureConfig;
|
|
22
|
+
/**
|
|
23
|
+
* Whether runtime server requests are supported, including API-only builds.
|
|
24
|
+
*/
|
|
22
25
|
ssr: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The origin to use for server requests in API-only mode.
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
unstable_apiServerOrigin?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether production document rendering is disabled while data and route
|
|
33
|
+
* discovery requests remain supported.
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
unstable_apiOnly?: boolean;
|
|
23
37
|
unstable_getCriticalCss?: (args: {
|
|
24
38
|
pathname: string;
|
|
25
39
|
}) => OptionalCriticalCss | Promise<OptionalCriticalCss>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { RouteManifest } from "../router/utils.js";
|
|
3
|
-
import { ServerRouteModule } from "../dom/ssr/routeModules.js";
|
|
4
3
|
import { Route } from "../dom/ssr/routes.js";
|
|
4
|
+
import { ServerRouteModule } from "../dom/ssr/routeModules.js";
|
|
5
5
|
|
|
6
6
|
//#region lib/server-runtime/routes.d.ts
|
|
7
7
|
type ServerRouteManifest = RouteManifest<Omit<ServerRoute, "children">>;
|
|
@@ -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,7 +11,7 @@
|
|
|
11
11
|
import { ErrorResponseImpl, RouterContextProvider, createDataFunctionUrl, defaultMapRouteProperties, getRoutePattern, isRouteErrorResponse, removeTrailingSlash, stripBasename } from "../router/utils.js";
|
|
12
12
|
import { instrumentHandler, instrumentationResultMetaContext } from "../router/instrumentation.js";
|
|
13
13
|
import { createStaticHandler, getStaticContextFromError, isMutationMethod, isRedirectResponse, isResponse } from "../router/router.js";
|
|
14
|
-
import { getManifestPath } from "../dom/ssr/fog-of-war.js";
|
|
14
|
+
import { getManifestPath, isFogOfWarEnabled, shouldUseInitialRouteDiscovery } from "../dom/ssr/fog-of-war.js";
|
|
15
15
|
import { createEntryRouteModules } from "./entry.js";
|
|
16
16
|
import { isServerMode } from "./mode.js";
|
|
17
17
|
import { sanitizeErrors, serializeError } from "./errors.js";
|
|
@@ -58,8 +58,11 @@ function derive(build, mode) {
|
|
|
58
58
|
let normalizedPath = getNormalizedPath(request);
|
|
59
59
|
let normalizedPathname = normalizedPath.pathname;
|
|
60
60
|
let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
|
|
61
|
-
if (!build.ssr) {
|
|
62
|
-
let decodedPath =
|
|
61
|
+
if (!build.ssr || build.unstable_apiOnly) {
|
|
62
|
+
let decodedPath = normalizedPathname;
|
|
63
|
+
try {
|
|
64
|
+
decodedPath = decodeURI(normalizedPathname);
|
|
65
|
+
} catch {}
|
|
63
66
|
if (build.basename && build.basename !== "/") {
|
|
64
67
|
let strippedPath = stripBasename(decodedPath, build.basename);
|
|
65
68
|
if (strippedPath == null) {
|
|
@@ -76,7 +79,7 @@ function derive(build, mode) {
|
|
|
76
79
|
decodedPath = strippedPath;
|
|
77
80
|
}
|
|
78
81
|
if (build.prerender.length === 0) isSpaMode = true;
|
|
79
|
-
else if (!build.prerender.some((p) => removeTrailingSlash(p) === removeTrailingSlash(decodedPath))) if (requestUrl.pathname.endsWith(".data")) {
|
|
82
|
+
else if (!build.prerender.some((p) => removeTrailingSlash(p) === removeTrailingSlash(decodedPath))) if (requestUrl.pathname.endsWith(".data") && !build.unstable_apiOnly) {
|
|
80
83
|
errorHandler(new ErrorResponseImpl(404, "Not Found", `Refusing to SSR the path \`${decodedPath}\` because \`ssr:false\` is set and the path is not included in the \`prerender\` config, so in production the path will be a 404.`), {
|
|
81
84
|
context: loadContext,
|
|
82
85
|
params,
|
|
@@ -95,6 +98,10 @@ function derive(build, mode) {
|
|
|
95
98
|
handleError(e);
|
|
96
99
|
return new Response("Unknown Server Error", { status: 500 });
|
|
97
100
|
}
|
|
101
|
+
if (build.unstable_apiOnly && serverMode !== "development" && !requestUrl.pathname.endsWith(".data") && getBuildTimeHeader(request, "X-React-Router-SPA-Mode") !== "yes" && getBuildTimeHeader(request, "X-React-Router-Prerender") !== "yes") return new Response(null, {
|
|
102
|
+
status: 404,
|
|
103
|
+
statusText: "Not Found"
|
|
104
|
+
});
|
|
98
105
|
let matches = matchServerRoutes(build.routes, staticHandler, normalizedPathname);
|
|
99
106
|
if (matches && matches.length > 0) Object.assign(params, matches[0].params);
|
|
100
107
|
if (requestHandlerInstrumentations?.length) loadContext.set(instrumentationResultMetaContext, {
|
|
@@ -247,12 +254,19 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
247
254
|
actionData: context.actionData,
|
|
248
255
|
errors: context.errors
|
|
249
256
|
};
|
|
257
|
+
let routeDiscovery = build.routeDiscovery;
|
|
258
|
+
if (isFogOfWarEnabled(routeDiscovery, build.ssr) && shouldUseInitialRouteDiscovery(context.location.pathname, staticHandler._matchCost)) routeDiscovery = {
|
|
259
|
+
...routeDiscovery,
|
|
260
|
+
mode: "initial"
|
|
261
|
+
};
|
|
250
262
|
let baseServerHandoff = {
|
|
251
263
|
basename: build.basename,
|
|
252
264
|
future: build.future,
|
|
253
|
-
routeDiscovery
|
|
265
|
+
routeDiscovery,
|
|
254
266
|
ssr: build.ssr,
|
|
255
|
-
isSpaMode
|
|
267
|
+
isSpaMode,
|
|
268
|
+
unstable_apiOnly: build.unstable_apiOnly,
|
|
269
|
+
unstable_apiServerOrigin: build.unstable_apiServerOrigin
|
|
256
270
|
};
|
|
257
271
|
let entryContext = {
|
|
258
272
|
manifest: build.assets,
|
|
@@ -268,8 +282,10 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
268
282
|
renderMeta: {},
|
|
269
283
|
future: build.future,
|
|
270
284
|
ssr: build.ssr,
|
|
271
|
-
routeDiscovery
|
|
285
|
+
routeDiscovery,
|
|
272
286
|
isSpaMode,
|
|
287
|
+
unstable_apiOnly: build.unstable_apiOnly,
|
|
288
|
+
unstable_apiServerOrigin: build.unstable_apiServerOrigin,
|
|
273
289
|
serializeError: (err) => serializeError(err, serverMode)
|
|
274
290
|
};
|
|
275
291
|
let handleDocumentRequestFunction = build.entry.module.default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { CriticalCss, FutureConfig } from "../dom/ssr/entry.js";
|
|
3
|
+
import { ServerBuild } from "./build.js";
|
|
4
|
+
|
|
5
|
+
//#region lib/server-runtime/serverHandoff.d.ts
|
|
6
|
+
type ServerHandoff = {
|
|
7
|
+
criticalCss?: CriticalCss;
|
|
8
|
+
basename: string | undefined;
|
|
9
|
+
future: FutureConfig;
|
|
10
|
+
ssr: boolean;
|
|
11
|
+
isSpaMode: boolean;
|
|
12
|
+
unstable_apiOnly?: boolean;
|
|
13
|
+
unstable_apiServerOrigin?: string;
|
|
14
|
+
routeDiscovery: ServerBuild["routeDiscovery"];
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { ServerHandoff };
|
|
@@ -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
|
*
|
|
@@ -99,7 +99,7 @@ function createSessionStorage({ cookie: cookieArg, createData, readData, updateD
|
|
|
99
99
|
return cookie.serialize(id, options);
|
|
100
100
|
},
|
|
101
101
|
async destroySession(session, options) {
|
|
102
|
-
await deleteData(session.id);
|
|
102
|
+
if (session.id) await deleteData(session.id);
|
|
103
103
|
return cookie.serialize("", {
|
|
104
104
|
...options,
|
|
105
105
|
maxAge: void 0,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
import { DataWithResponseInit, RouterContextProvider } from "../router/utils.js";
|
|
3
|
+
import { ClientActionFunctionArgs, ClientLoaderFunctionArgs } from "../dom/ssr/routeModules.js";
|
|
4
|
+
import { Serializable } from "../server-runtime/single-fetch.js";
|
|
3
5
|
import { Equal, Func, IsAny } from "./utils.js";
|
|
4
6
|
import { RouteModule } from "./route-module.js";
|
|
5
7
|
import { unstable_SerializesTo } from "./serializes-to.js";
|
|
6
|
-
import { Serializable } from "../server-runtime/single-fetch.js";
|
|
7
|
-
import { ClientActionFunctionArgs, ClientLoaderFunctionArgs } from "../dom/ssr/routeModules.js";
|
|
8
8
|
|
|
9
9
|
//#region lib/types/route-data.d.ts
|
|
10
10
|
type Serialize<T> = T extends unstable_SerializesTo<infer To> ? To : T extends Serializable ? T : T extends ((...args: any[]) => unknown) ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends ReadonlySet<infer U> ? ReadonlySet<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? { [K in keyof T]: Serialize<T[K]> } : undefined;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { Location } from "../router/history.js";
|
|
3
3
|
import { DataStrategyResult, MiddlewareNextFunction } from "../router/utils.js";
|
|
4
4
|
import { LinkDescriptor } from "../router/links.js";
|
|
5
|
+
import { MetaDescriptor } from "../dom/ssr/routeModules.js";
|
|
5
6
|
import { Func, Pretty } from "./utils.js";
|
|
6
7
|
import { RouteModule } from "./route-module.js";
|
|
7
8
|
import { ClientDataFunctionArgs, GetLoaderData, ServerDataFrom, ServerDataFunctionArgs } from "./route-data.js";
|
|
8
|
-
import { MetaDescriptor } from "../dom/ssr/routeModules.js";
|
|
9
9
|
|
|
10
10
|
//#region lib/types/route-module-annotations.d.ts
|
|
11
11
|
type MaybePromise<T> = T | Promise<T>;
|