react-router 8.3.1 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/development/dom-export.js +1 -1
- package/dist/development/index-react-server-client.js +1 -1
- package/dist/development/index-react-server.d.ts +42 -48
- package/dist/development/index-react-server.js +75 -31
- package/dist/development/index.d.ts +2 -2
- package/dist/development/index.js +3 -3
- package/dist/development/lib/actions.js +1 -1
- package/dist/development/lib/components.js +45 -8
- package/dist/development/lib/context.d.ts +13 -5
- package/dist/development/lib/context.js +11 -3
- package/dist/development/lib/dom/dom.js +1 -1
- package/dist/development/lib/dom/lib.js +14 -32
- package/dist/development/lib/dom/server.d.ts +6 -1
- package/dist/development/lib/dom/server.js +40 -14
- package/dist/development/lib/dom/ssr/components.js +15 -23
- package/dist/development/lib/dom/ssr/data.js +1 -1
- package/dist/development/lib/dom/ssr/entry.d.ts +4 -0
- 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.js +33 -12
- package/dist/development/lib/dom/ssr/hydration.d.ts +3 -1
- package/dist/development/lib/dom/ssr/hydration.js +6 -4
- 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 +5 -2
- package/dist/development/lib/dom/ssr/routeModules.js +1 -1
- package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/development/lib/dom/ssr/routes.js +1 -1
- package/dist/development/lib/dom/ssr/server.js +2 -2
- package/dist/development/lib/dom/ssr/single-fetch.js +10 -19
- package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/development/lib/dom-export/hydrated-router.js +2 -1
- package/dist/development/lib/errors.js +1 -1
- package/dist/development/lib/hooks.js +49 -44
- 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.d.ts +2 -0
- package/dist/development/lib/router/matcher-route-pattern.js +216 -0
- package/dist/development/lib/router/matcher-route-pattern.preload.d.ts +20 -0
- package/dist/development/lib/router/matcher-route-pattern.preload.js +36 -0
- package/dist/development/lib/router/matcher.d.ts +2 -0
- package/dist/development/lib/router/matcher.js +29 -0
- package/dist/development/lib/router/navigation.js +1 -1
- package/dist/development/lib/router/router.d.ts +13 -7
- package/dist/development/lib/router/router.js +81 -66
- package/dist/development/lib/router/url.js +1 -1
- package/dist/development/lib/router/utils.d.ts +6 -1
- package/dist/development/lib/router/utils.js +6 -4
- package/dist/development/lib/rsc/browser.js +2 -1
- 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 +2 -4
- package/dist/development/lib/rsc/route-modules.js +1 -1
- package/dist/development/lib/rsc/server.rsc.d.ts +7 -0
- package/dist/development/lib/rsc/server.ssr.js +25 -21
- 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 +3 -4
- package/dist/development/lib/server-runtime/routes.js +1 -1
- package/dist/development/lib/server-runtime/server.js +7 -6
- 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 +1 -1
- 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/route-pattern.d.ts +3 -0
- package/dist/development/route-pattern.js +12 -0
- 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 +1 -1
- package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
- package/dist/production/dom-export.js +1 -1
- package/dist/production/index-react-server-client.js +1 -1
- package/dist/production/index-react-server.d.ts +42 -48
- package/dist/production/index-react-server.js +75 -31
- package/dist/production/index.d.ts +2 -2
- package/dist/production/index.js +3 -3
- package/dist/production/lib/actions.js +1 -1
- package/dist/production/lib/components.js +45 -8
- package/dist/production/lib/context.d.ts +13 -5
- package/dist/production/lib/context.js +11 -3
- package/dist/production/lib/dom/dom.js +1 -1
- package/dist/production/lib/dom/lib.js +14 -32
- package/dist/production/lib/dom/server.d.ts +6 -1
- package/dist/production/lib/dom/server.js +40 -14
- package/dist/production/lib/dom/ssr/components.js +15 -23
- package/dist/production/lib/dom/ssr/data.js +1 -1
- package/dist/production/lib/dom/ssr/entry.d.ts +4 -0
- 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.js +33 -12
- package/dist/production/lib/dom/ssr/hydration.d.ts +3 -1
- package/dist/production/lib/dom/ssr/hydration.js +6 -4
- 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 +5 -2
- package/dist/production/lib/dom/ssr/routeModules.js +1 -1
- package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
- package/dist/production/lib/dom/ssr/routes.js +1 -1
- package/dist/production/lib/dom/ssr/server.js +2 -2
- package/dist/production/lib/dom/ssr/single-fetch.js +10 -19
- package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
- package/dist/production/lib/dom-export/hydrated-router.js +2 -1
- package/dist/production/lib/errors.js +1 -1
- package/dist/production/lib/hooks.js +49 -44
- 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.d.ts +2 -0
- package/dist/production/lib/router/matcher-route-pattern.js +216 -0
- package/dist/production/lib/router/matcher-route-pattern.preload.d.ts +20 -0
- package/dist/production/lib/router/matcher-route-pattern.preload.js +36 -0
- package/dist/production/lib/router/matcher.d.ts +2 -0
- package/dist/production/lib/router/matcher.js +29 -0
- package/dist/production/lib/router/navigation.js +1 -1
- package/dist/production/lib/router/router.d.ts +13 -7
- package/dist/production/lib/router/router.js +81 -66
- package/dist/production/lib/router/url.js +1 -1
- package/dist/production/lib/router/utils.d.ts +6 -1
- package/dist/production/lib/router/utils.js +6 -4
- package/dist/production/lib/rsc/browser.js +2 -1
- 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 +2 -4
- package/dist/production/lib/rsc/route-modules.js +1 -1
- package/dist/production/lib/rsc/server.rsc.d.ts +7 -0
- package/dist/production/lib/rsc/server.ssr.js +25 -21
- 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 +3 -4
- package/dist/production/lib/server-runtime/routes.js +1 -1
- package/dist/production/lib/server-runtime/server.js +7 -6
- 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 +1 -1
- 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/route-pattern.d.ts +3 -0
- package/dist/production/route-pattern.js +12 -0
- 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 +1 -1
- package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
- package/docs/how-to/fetchers.md +6 -1
- package/docs/how-to/middleware.md +3 -1
- package/docs/how-to/optimize-revalidation.md +178 -5
- package/docs/how-to/react-server-components.md +26 -3
- package/docs/how-to/resource-routes.md +3 -0
- package/docs/start/data/actions.md +2 -1
- package/docs/start/data/route-object.md +21 -6
- package/docs/start/framework/actions.md +4 -2
- package/docs/start/framework/route-module.md +32 -5
- package/docs/upgrading/future.md +68 -0
- package/package.json +11 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import { isRouteErrorResponse } from "../router/utils.js";
|
|
12
|
-
import { hasInvalidProtocol } from "../router/router.js";
|
|
12
|
+
import { createDataRouteMatcher, hasInvalidProtocol } from "../router/router.js";
|
|
13
13
|
import { RSCRouterContext } from "../context.js";
|
|
14
14
|
import { decodeRedirectErrorDigest, decodeRouteErrorResponseDigest } from "../errors.js";
|
|
15
|
-
import {
|
|
15
|
+
import { escapeAttribute } from "../dom/ssr/markup.js";
|
|
16
16
|
import { shouldHydrateRouteLoader } from "../dom/ssr/routes.js";
|
|
17
17
|
import { FrameworkContext } from "../dom/ssr/components.js";
|
|
18
18
|
import { StaticRouterProvider, createStaticRouter } from "../dom/server.js";
|
|
@@ -179,7 +179,7 @@ async function routeRSCServerRequest({ request, serverResponse, createFromReadab
|
|
|
179
179
|
const redirectTransform = new TransformStream({ flush(controller) {
|
|
180
180
|
if (renderRedirect) {
|
|
181
181
|
if (hasInvalidProtocol(renderRedirect.location)) return;
|
|
182
|
-
controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${
|
|
182
|
+
controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeAttribute(renderRedirect.location)}"/>`));
|
|
183
183
|
}
|
|
184
184
|
} });
|
|
185
185
|
if (!hydrate) return new Response(html.pipeThrough(redirectTransform), {
|
|
@@ -258,7 +258,7 @@ async function routeRSCServerRequest({ request, serverResponse, createFromReadab
|
|
|
258
258
|
const retryRedirectTransform = new TransformStream({ flush(controller) {
|
|
259
259
|
if (retryRedirect) {
|
|
260
260
|
if (hasInvalidProtocol(retryRedirect.location)) return;
|
|
261
|
-
controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${
|
|
261
|
+
controller.enqueue(new TextEncoder().encode(`<meta http-equiv="refresh" content="0;url=${escapeAttribute(retryRedirect.location)}"/>`));
|
|
262
262
|
}
|
|
263
263
|
} });
|
|
264
264
|
if (!hydrate) return new Response(html.pipeThrough(retryRedirectTransform), {
|
|
@@ -333,6 +333,24 @@ function RSCStaticRouter({ getPayload, nonce }) {
|
|
|
333
333
|
if (payload.type !== "render") return null;
|
|
334
334
|
let patchedLoaderData = { ...payload.loaderData };
|
|
335
335
|
for (const match of payload.matches) if (shouldHydrateRouteLoader(match.id, match.clientLoader, match.hasLoader, false) && (match.hydrateFallbackElement || !match.hasLoader)) delete patchedLoaderData[match.id];
|
|
336
|
+
const routes = payload.matches.reduceRight((previous, match) => {
|
|
337
|
+
const route = {
|
|
338
|
+
id: match.id,
|
|
339
|
+
action: match.hasAction || !!match.clientAction,
|
|
340
|
+
element: match.element,
|
|
341
|
+
errorElement: match.errorElement,
|
|
342
|
+
handle: match.handle,
|
|
343
|
+
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
344
|
+
index: match.index,
|
|
345
|
+
loader: match.hasLoader || !!match.clientLoader,
|
|
346
|
+
path: match.path,
|
|
347
|
+
shouldRevalidate: match.shouldRevalidate
|
|
348
|
+
};
|
|
349
|
+
if (previous.length > 0) route.children = previous;
|
|
350
|
+
return [route];
|
|
351
|
+
}, []);
|
|
352
|
+
const dataRouteMatcher = createDataRouteMatcher({}, payload.basename || "/");
|
|
353
|
+
dataRouteMatcher.update(routes);
|
|
336
354
|
const context = {
|
|
337
355
|
get _deepestRenderedBoundaryId() {
|
|
338
356
|
return decoded._deepestRenderedBoundaryId ?? null;
|
|
@@ -348,6 +366,7 @@ function RSCStaticRouter({ getPayload, nonce }) {
|
|
|
348
366
|
loaderHeaders: {},
|
|
349
367
|
location: payload.location,
|
|
350
368
|
statusCode: 200,
|
|
369
|
+
_match: (locationArg) => dataRouteMatcher.match(locationArg),
|
|
351
370
|
matches: payload.matches.map((match) => ({
|
|
352
371
|
params: match.params,
|
|
353
372
|
pathname: match.pathname,
|
|
@@ -363,22 +382,7 @@ function RSCStaticRouter({ getPayload, nonce }) {
|
|
|
363
382
|
}
|
|
364
383
|
}))
|
|
365
384
|
};
|
|
366
|
-
const router = createStaticRouter(
|
|
367
|
-
const route = {
|
|
368
|
-
id: match.id,
|
|
369
|
-
action: match.hasAction || !!match.clientAction,
|
|
370
|
-
element: match.element,
|
|
371
|
-
errorElement: match.errorElement,
|
|
372
|
-
handle: match.handle,
|
|
373
|
-
hydrateFallbackElement: match.hydrateFallbackElement,
|
|
374
|
-
index: match.index,
|
|
375
|
-
loader: match.hasLoader || !!match.clientLoader,
|
|
376
|
-
path: match.path,
|
|
377
|
-
shouldRevalidate: match.shouldRevalidate
|
|
378
|
-
};
|
|
379
|
-
if (previous.length > 0) route.children = previous;
|
|
380
|
-
return [route];
|
|
381
|
-
}, []), context);
|
|
385
|
+
const router = createStaticRouter(routes, context);
|
|
382
386
|
const frameworkContext = {
|
|
383
387
|
future: {},
|
|
384
388
|
isSpaMode: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import { matchRoutesImpl } from "../router/utils.js";
|
|
12
11
|
import invariant from "./invariant.js";
|
|
13
12
|
//#region lib/server-runtime/routeMatching.ts
|
|
14
|
-
function matchServerRoutes(manifest,
|
|
15
|
-
let matches =
|
|
13
|
+
function matchServerRoutes(manifest, staticHandler, pathname) {
|
|
14
|
+
let matches = staticHandler.match(pathname);
|
|
16
15
|
if (!matches) return null;
|
|
17
16
|
return matches.map((match) => {
|
|
18
17
|
let route = manifest[match.route.id];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v8.
|
|
2
|
+
* react-router v8.4.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -90,12 +90,12 @@ function derive(build, mode) {
|
|
|
90
90
|
}
|
|
91
91
|
let manifestUrl = getManifestPath(build.routeDiscovery.manifestPath, build.basename);
|
|
92
92
|
if (build.routeDiscovery.mode === "lazy" && requestUrl.pathname === manifestUrl) try {
|
|
93
|
-
return await handleManifestRequest(build, staticHandler
|
|
93
|
+
return await handleManifestRequest(build, staticHandler, requestUrl);
|
|
94
94
|
} catch (e) {
|
|
95
95
|
handleError(e);
|
|
96
96
|
return new Response("Unknown Server Error", { status: 500 });
|
|
97
97
|
}
|
|
98
|
-
let matches = matchServerRoutes(build.routes, staticHandler
|
|
98
|
+
let matches = matchServerRoutes(build.routes, staticHandler, normalizedPathname);
|
|
99
99
|
if (matches && matches.length > 0) Object.assign(params, matches[0].params);
|
|
100
100
|
if (requestHandlerInstrumentations?.length) loadContext.set(instrumentationResultMetaContext, {
|
|
101
101
|
url: createDataFunctionUrl(request, normalizedPath),
|
|
@@ -173,7 +173,7 @@ const createRequestHandler = (build, mode) => {
|
|
|
173
173
|
return _requestHandler(request, initialContext);
|
|
174
174
|
};
|
|
175
175
|
};
|
|
176
|
-
async function handleManifestRequest(build,
|
|
176
|
+
async function handleManifestRequest(build, staticHandler, url) {
|
|
177
177
|
if (url.toString().length > 7680) return new Response(null, {
|
|
178
178
|
statusText: "Bad Request",
|
|
179
179
|
status: 400
|
|
@@ -188,7 +188,7 @@ async function handleManifestRequest(build, dataRoutes, branches, url) {
|
|
|
188
188
|
let paths = new Set(pathParam.split(",").filter(Boolean));
|
|
189
189
|
for (let path of paths) {
|
|
190
190
|
if (!path.startsWith("/")) path = `/${path}`;
|
|
191
|
-
let matches = matchServerRoutes(build.routes,
|
|
191
|
+
let matches = matchServerRoutes(build.routes, staticHandler, path);
|
|
192
192
|
if (matches) for (let match of matches) {
|
|
193
193
|
let routeId = match.route.id;
|
|
194
194
|
let route = build.assets.routes[routeId];
|
|
@@ -256,7 +256,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
256
256
|
};
|
|
257
257
|
let entryContext = {
|
|
258
258
|
manifest: build.assets,
|
|
259
|
-
branches:
|
|
259
|
+
branches: [],
|
|
260
260
|
routeModules: createEntryRouteModules(build.routes),
|
|
261
261
|
staticHandlerContext: context,
|
|
262
262
|
criticalCss,
|
|
@@ -291,6 +291,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
291
291
|
};
|
|
292
292
|
entryContext = {
|
|
293
293
|
...entryContext,
|
|
294
|
+
branches: [],
|
|
294
295
|
staticHandlerContext: context,
|
|
295
296
|
serverHandoffString: createServerHandoffString(baseServerHandoff),
|
|
296
297
|
serverHandoffStream: encodeViaTurboStream(state, request.signal, build.entry.module.streamTimeout, serverMode),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* react-router v8.4.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import { unstable_preloadRoutePattern } from "./lib/router/matcher-route-pattern.preload.js";
|
|
12
|
+
export { unstable_preloadRoutePattern };
|
|
@@ -50,7 +50,7 @@ interface Path {
|
|
|
50
50
|
* An entry in a history stack. A location contains information about the
|
|
51
51
|
* URL path, as well as possibly some arbitrary state and a key.
|
|
52
52
|
*/
|
|
53
|
-
interface Location<State = any> extends Path {
|
|
53
|
+
interface Location$1<State = any> extends Path {
|
|
54
54
|
/**
|
|
55
55
|
* A value of arbitrary data associated with this location.
|
|
56
56
|
*/
|
|
@@ -79,7 +79,7 @@ interface Update {
|
|
|
79
79
|
/**
|
|
80
80
|
* The new location.
|
|
81
81
|
*/
|
|
82
|
-
location: Location;
|
|
82
|
+
location: Location$1;
|
|
83
83
|
/**
|
|
84
84
|
* The delta between this location and the former location in the history stack
|
|
85
85
|
*/
|
|
@@ -113,7 +113,7 @@ interface History {
|
|
|
113
113
|
/**
|
|
114
114
|
* The current location. This value is mutable.
|
|
115
115
|
*/
|
|
116
|
-
readonly location: Location;
|
|
116
|
+
readonly location: Location$1;
|
|
117
117
|
/**
|
|
118
118
|
* Returns a valid href for the given `to` value that may be used as
|
|
119
119
|
* the value of an <a href> attribute.
|
|
@@ -597,7 +597,7 @@ interface MapRoutePropertiesFunction {
|
|
|
597
597
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
598
598
|
* ignored.
|
|
599
599
|
*/
|
|
600
|
-
type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
|
|
600
|
+
type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children" | "unstable_validateParams";
|
|
601
601
|
/**
|
|
602
602
|
* Keys we cannot change from within a lazy() function. We spread all other keys
|
|
603
603
|
* onto the route. Either they're meaningful to the router, or they'll get
|
|
@@ -655,6 +655,11 @@ type BaseRouteObject = {
|
|
|
655
655
|
* See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
|
|
656
656
|
*/
|
|
657
657
|
shouldRevalidate?: ShouldRevalidateFunction;
|
|
658
|
+
/**
|
|
659
|
+
* A map of route param names to regular expressions used to validate params
|
|
660
|
+
* after a route-pattern match.
|
|
661
|
+
*/
|
|
662
|
+
unstable_validateParams?: Record<string, RegExp>;
|
|
658
663
|
/**
|
|
659
664
|
* The route handle.
|
|
660
665
|
*/
|
|
@@ -791,7 +796,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
|
|
|
791
796
|
* Defaults to `/`.
|
|
792
797
|
* @returns An array of matched routes, or `null` if no matches were found.
|
|
793
798
|
*/
|
|
794
|
-
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
|
|
799
|
+
declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location$1> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
|
|
795
800
|
interface UIMatch<Data = unknown, Handle = unknown> {
|
|
796
801
|
id: string;
|
|
797
802
|
pathname: string;
|
|
@@ -811,30 +816,6 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
811
816
|
*/
|
|
812
817
|
handle: Handle;
|
|
813
818
|
}
|
|
814
|
-
interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
|
|
815
|
-
relativePath: string;
|
|
816
|
-
caseSensitive: boolean;
|
|
817
|
-
childrenIndex: number;
|
|
818
|
-
route: RouteObjectType;
|
|
819
|
-
matcher?: RegExp;
|
|
820
|
-
compiledParams?: CompiledPathParam[];
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* @private
|
|
824
|
-
* PRIVATE - DO NOT USE
|
|
825
|
-
*
|
|
826
|
-
* A "branch" of routes that match a given route pattern.
|
|
827
|
-
* This is an internal interface not intended for direct external usage.
|
|
828
|
-
*/
|
|
829
|
-
interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
|
|
830
|
-
path: string;
|
|
831
|
-
score: number;
|
|
832
|
-
routesMeta: RouteMeta<RouteObjectType>[];
|
|
833
|
-
}
|
|
834
|
-
type CompiledPathParam = {
|
|
835
|
-
paramName: string;
|
|
836
|
-
isOptional?: boolean;
|
|
837
|
-
};
|
|
838
819
|
declare class DataWithResponseInit<D> {
|
|
839
820
|
type: string;
|
|
840
821
|
data: D;
|
|
@@ -1143,9 +1124,10 @@ interface Router$1 {
|
|
|
1143
1124
|
* @private
|
|
1144
1125
|
* PRIVATE - DO NOT USE
|
|
1145
1126
|
*
|
|
1146
|
-
*
|
|
1127
|
+
* Match routes against a location using the router's configured route
|
|
1128
|
+
* matching implementation.
|
|
1147
1129
|
*/
|
|
1148
|
-
|
|
1130
|
+
match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
|
|
1149
1131
|
/**
|
|
1150
1132
|
* @private
|
|
1151
1133
|
* PRIVATE - DO NOT USE
|
|
@@ -1230,7 +1212,7 @@ interface Router$1 {
|
|
|
1230
1212
|
* Utility function to create an href for the given location
|
|
1231
1213
|
* @param location
|
|
1232
1214
|
*/
|
|
1233
|
-
createHref(location: Location | URL): string;
|
|
1215
|
+
createHref(location: Location$1 | URL): string;
|
|
1234
1216
|
/**
|
|
1235
1217
|
* @private
|
|
1236
1218
|
* PRIVATE - DO NOT USE
|
|
@@ -1346,7 +1328,7 @@ interface RouterState {
|
|
|
1346
1328
|
/**
|
|
1347
1329
|
* The current location reflected by the router
|
|
1348
1330
|
*/
|
|
1349
|
-
location: Location;
|
|
1331
|
+
location: Location$1;
|
|
1350
1332
|
/**
|
|
1351
1333
|
* The current set of route matches
|
|
1352
1334
|
*/
|
|
@@ -1407,7 +1389,10 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
|
|
|
1407
1389
|
/**
|
|
1408
1390
|
* Future flags to toggle new feature behavior
|
|
1409
1391
|
*/
|
|
1410
|
-
interface FutureConfig {
|
|
1392
|
+
interface FutureConfig {
|
|
1393
|
+
/** Enables route-pattern matching after calling `unstable_preloadRoutePattern()`. */
|
|
1394
|
+
unstable_routePatternMatching?: boolean;
|
|
1395
|
+
}
|
|
1411
1396
|
/**
|
|
1412
1397
|
* Initialization options for createRouter
|
|
1413
1398
|
*/
|
|
@@ -1439,6 +1424,8 @@ interface StaticHandlerContext {
|
|
|
1439
1424
|
loaderHeaders: Record<string, Headers>;
|
|
1440
1425
|
actionHeaders: Record<string, Headers>;
|
|
1441
1426
|
_deepestRenderedBoundaryId?: string | null;
|
|
1427
|
+
/** @private */
|
|
1428
|
+
_match: StaticHandler["match"];
|
|
1442
1429
|
}
|
|
1443
1430
|
/**
|
|
1444
1431
|
* A StaticHandler instance manages a singular SSR navigation/fetch event
|
|
@@ -1452,10 +1439,10 @@ interface StaticHandler {
|
|
|
1452
1439
|
* @private
|
|
1453
1440
|
* PRIVATE - DO NOT USE
|
|
1454
1441
|
*
|
|
1455
|
-
*
|
|
1456
|
-
* matching
|
|
1442
|
+
* Match routes against a location using the handler's configured route
|
|
1443
|
+
* matching implementation.
|
|
1457
1444
|
*/
|
|
1458
|
-
|
|
1445
|
+
match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
|
|
1459
1446
|
/**
|
|
1460
1447
|
* Perform a query for a given request - executing all matched route
|
|
1461
1448
|
* loaders/actions. Used for document requests.
|
|
@@ -1503,8 +1490,8 @@ interface StaticHandler {
|
|
|
1503
1490
|
}): Promise<any>;
|
|
1504
1491
|
}
|
|
1505
1492
|
type ViewTransitionOpts = {
|
|
1506
|
-
currentLocation: Location;
|
|
1507
|
-
nextLocation: Location;
|
|
1493
|
+
currentLocation: Location$1;
|
|
1494
|
+
nextLocation: Location$1;
|
|
1508
1495
|
};
|
|
1509
1496
|
/**
|
|
1510
1497
|
* Subscriber function signature for changes to router state
|
|
@@ -1522,7 +1509,7 @@ interface RouterSubscriber {
|
|
|
1522
1509
|
* for a given location
|
|
1523
1510
|
*/
|
|
1524
1511
|
interface GetScrollRestorationKeyFunction {
|
|
1525
|
-
(location: Location, matches: UIMatch[]): string | null;
|
|
1512
|
+
(location: Location$1, matches: UIMatch[]): string | null;
|
|
1526
1513
|
}
|
|
1527
1514
|
/**
|
|
1528
1515
|
* Function signature for determining the current scroll position
|
|
@@ -1604,7 +1591,7 @@ type NavigationStates = {
|
|
|
1604
1591
|
};
|
|
1605
1592
|
Loading: {
|
|
1606
1593
|
state: "loading";
|
|
1607
|
-
location: Location;
|
|
1594
|
+
location: Location$1;
|
|
1608
1595
|
matches: DataRouteMatch[];
|
|
1609
1596
|
historyAction: Action;
|
|
1610
1597
|
formMethod: Submission["formMethod"] | undefined;
|
|
@@ -1616,7 +1603,7 @@ type NavigationStates = {
|
|
|
1616
1603
|
};
|
|
1617
1604
|
Submitting: {
|
|
1618
1605
|
state: "submitting";
|
|
1619
|
-
location: Location;
|
|
1606
|
+
location: Location$1;
|
|
1620
1607
|
matches: DataRouteMatch[];
|
|
1621
1608
|
historyAction: Action;
|
|
1622
1609
|
formMethod: Submission["formMethod"];
|
|
@@ -1706,7 +1693,7 @@ interface BlockerBlocked {
|
|
|
1706
1693
|
state: "blocked";
|
|
1707
1694
|
reset: () => void;
|
|
1708
1695
|
proceed: () => void;
|
|
1709
|
-
location: Location;
|
|
1696
|
+
location: Location$1;
|
|
1710
1697
|
}
|
|
1711
1698
|
interface BlockerUnblocked {
|
|
1712
1699
|
state: "unblocked";
|
|
@@ -1718,12 +1705,12 @@ interface BlockerProceeding {
|
|
|
1718
1705
|
state: "proceeding";
|
|
1719
1706
|
reset: undefined;
|
|
1720
1707
|
proceed: undefined;
|
|
1721
|
-
location: Location;
|
|
1708
|
+
location: Location$1;
|
|
1722
1709
|
}
|
|
1723
1710
|
type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
|
|
1724
1711
|
type BlockerFunction = (args: {
|
|
1725
|
-
currentLocation: Location;
|
|
1726
|
-
nextLocation: Location;
|
|
1712
|
+
currentLocation: Location$1;
|
|
1713
|
+
nextLocation: Location$1;
|
|
1727
1714
|
historyAction: Action;
|
|
1728
1715
|
}) => boolean;
|
|
1729
1716
|
interface CreateStaticHandlerOptions {
|
|
@@ -2008,7 +1995,7 @@ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoad
|
|
|
2008
1995
|
interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
|
|
2009
1996
|
loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
|
|
2010
1997
|
params: Params;
|
|
2011
|
-
location: Location;
|
|
1998
|
+
location: Location$1;
|
|
2012
1999
|
matches: MetaMatches<MatchLoaders>;
|
|
2013
2000
|
error?: unknown;
|
|
2014
2001
|
}
|
|
@@ -2329,7 +2316,7 @@ type RSCRenderPayload = {
|
|
|
2329
2316
|
clientVersion?: string;
|
|
2330
2317
|
errors: Record<string, any> | null;
|
|
2331
2318
|
loaderData: Record<string, any>;
|
|
2332
|
-
location: Location;
|
|
2319
|
+
location: Location$1;
|
|
2333
2320
|
routeDiscovery: RouteDiscovery;
|
|
2334
2321
|
matches: RSCRouteMatch[];
|
|
2335
2322
|
patches?: Promise<RSCRouteManifest[]>;
|
|
@@ -2377,6 +2364,13 @@ type RouteDiscovery = {
|
|
|
2377
2364
|
* encoding an {@link unstable_RSCPayload} for consumption by an [RSC](https://react.dev/reference/rsc/server-components)
|
|
2378
2365
|
* enabled client router.
|
|
2379
2366
|
*
|
|
2367
|
+
* Treat every React Server Function as a public endpoint. Server Functions are
|
|
2368
|
+
* not inherently associated with a route. Any route middleware that runs is
|
|
2369
|
+
* selected from the URL used to call a Server Function, but the client controls
|
|
2370
|
+
* both the Server Function identifier and the URL. Perform all access control
|
|
2371
|
+
* checks within each Server Function, or use a route action for
|
|
2372
|
+
* middleware-driven access control.
|
|
2373
|
+
*
|
|
2380
2374
|
* @example
|
|
2381
2375
|
* import {
|
|
2382
2376
|
* createTemporaryReferenceSet,
|