react-router 0.0.0-experimental-2a6c7bc → 0.0.0-experimental-e89ad3012
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/dist/development/{chunk-VEWXUMGM.mjs → chunk-3O4L5GVQ.mjs} +90 -125
- package/dist/development/{chunk-JRLTRGBE.js → chunk-JJHCVRDZ.js} +89 -124
- package/dist/development/{chunk-GSZ4XTPZ.js → chunk-ROJMZUUV.js} +130 -130
- package/dist/{production/chunk-ATNMTWNA.mjs → development/chunk-XKV32KFX.mjs} +157 -141
- package/dist/development/{components-CFzgj3gZ.d.mts → components-BkK38HPd.d.mts} +16 -16
- package/dist/development/{context-AvZz33Zq.d.mts → context-CphUWOpx.d.mts} +238 -22
- package/dist/development/dom-export.d.mts +3 -3
- package/dist/development/dom-export.d.ts +1 -1
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/{production/index-react-server-client-DIZWnqdE.d.ts → development/index-react-server-client-D-lyvxf_.d.ts} +25 -26
- package/dist/{production/index-react-server-client-BuCmY0hu.d.mts → development/index-react-server-client-pe1TAKAq.d.mts} +12 -13
- package/dist/development/index-react-server-client.d.mts +4 -4
- package/dist/development/index-react-server-client.d.ts +2 -2
- package/dist/development/index-react-server-client.js +4 -4
- package/dist/development/index-react-server-client.mjs +2 -2
- package/dist/development/index-react-server.d.mts +193 -14
- package/dist/development/index-react-server.d.ts +193 -14
- package/dist/development/index-react-server.js +115 -147
- package/dist/development/index-react-server.mjs +115 -147
- package/dist/development/index.d.mts +8 -8
- package/dist/development/index.d.ts +4 -4
- package/dist/development/index.js +240 -224
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +2 -2
- package/dist/development/lib/types/internal.d.ts +1 -1
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/{route-data-BnrIwdAP.d.mts → route-data-DJXZgnJq.d.mts} +1 -1
- package/dist/development/{routeModules-BbH0xTnc.d.ts → routeModules-DH3xUx4Z.d.ts} +238 -22
- package/dist/{development/chunk-M2KD4YIT.mjs → production/chunk-J6PLTU3O.mjs} +157 -141
- package/dist/production/{chunk-3UOGQQWX.js → chunk-NFNPXIQE.js} +89 -124
- package/dist/production/{chunk-P2JVUBYL.mjs → chunk-QI3NR5VQ.mjs} +90 -125
- package/dist/production/{chunk-ZIOZTUIH.js → chunk-X3M2F3OK.js} +130 -130
- package/dist/production/{components-CFzgj3gZ.d.mts → components-BkK38HPd.d.mts} +16 -16
- package/dist/production/{context-AvZz33Zq.d.mts → context-CphUWOpx.d.mts} +238 -22
- package/dist/production/dom-export.d.mts +3 -3
- package/dist/production/dom-export.d.ts +1 -1
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/{development/index-react-server-client-DIZWnqdE.d.ts → production/index-react-server-client-D-lyvxf_.d.ts} +25 -26
- package/dist/{development/index-react-server-client-BuCmY0hu.d.mts → production/index-react-server-client-pe1TAKAq.d.mts} +12 -13
- package/dist/production/index-react-server-client.d.mts +4 -4
- package/dist/production/index-react-server-client.d.ts +2 -2
- package/dist/production/index-react-server-client.js +4 -4
- package/dist/production/index-react-server-client.mjs +2 -2
- package/dist/production/index-react-server.d.mts +193 -14
- package/dist/production/index-react-server.d.ts +193 -14
- package/dist/production/index-react-server.js +115 -147
- package/dist/production/index-react-server.mjs +115 -147
- package/dist/production/index.d.mts +8 -8
- package/dist/production/index.d.ts +4 -4
- package/dist/production/index.js +240 -224
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +2 -2
- package/dist/production/lib/types/internal.d.ts +1 -1
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/{route-data-BnrIwdAP.d.mts → route-data-DJXZgnJq.d.mts} +1 -1
- package/dist/production/{routeModules-BbH0xTnc.d.ts → routeModules-DH3xUx4Z.d.ts} +238 -22
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e89ad3012
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
isSession,
|
|
32
32
|
routeRSCServerRequest,
|
|
33
33
|
setDevServerHooks
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-J6PLTU3O.mjs";
|
|
35
35
|
import {
|
|
36
36
|
Action,
|
|
37
37
|
Await,
|
|
@@ -140,7 +140,7 @@ import {
|
|
|
140
140
|
withComponentProps,
|
|
141
141
|
withErrorBoundaryProps,
|
|
142
142
|
withHydrateFallbackProps
|
|
143
|
-
} from "./chunk-
|
|
143
|
+
} from "./chunk-QI3NR5VQ.mjs";
|
|
144
144
|
export {
|
|
145
145
|
Await,
|
|
146
146
|
BrowserRouter,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RouteModule, L as LinkDescriptor, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, C as ClientDataFunctionArgs, a as ServerDataFrom, N as Normalize, b as GetActionData } from '../../route-data-
|
|
2
|
-
import { c as Location, u as unstable_MiddlewareNextFunction } from '../../context-
|
|
1
|
+
import { R as RouteModule, L as LinkDescriptor, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, C as ClientDataFunctionArgs, a as ServerDataFrom, N as Normalize, b as GetActionData } from '../../route-data-DJXZgnJq.mjs';
|
|
2
|
+
import { c as Location, u as unstable_MiddlewareNextFunction } from '../../context-CphUWOpx.mjs';
|
|
3
3
|
import { R as RouteFiles, P as Pages } from '../../register-DiOIlEq5.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RouteModule, L as LinkDescriptor, a as Location, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, u as unstable_MiddlewareNextFunction, C as ClientDataFunctionArgs, b as ServerDataFrom, N as Normalize, c as GetActionData } from '../../routeModules-
|
|
1
|
+
import { R as RouteModule, L as LinkDescriptor, a as Location, P as Pretty, M as MetaDescriptor, G as GetLoaderData, S as ServerDataFunctionArgs, u as unstable_MiddlewareNextFunction, C as ClientDataFunctionArgs, b as ServerDataFrom, N as Normalize, c as GetActionData } from '../../routeModules-DH3xUx4Z.js';
|
|
2
2
|
import { R as RouteFiles, P as Pages } from '../../register-DiOIlEq5.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentType, ReactElement } from 'react';
|
|
2
|
-
import { i as ActionFunctionArgs, j as LoaderFunctionArgs, k as ActionFunction, l as LoaderFunction, h as Params, c as Location, m as DataRouteMatch, n as unstable_MiddlewareFunction, S as ShouldRevalidateFunction, o as unstable_RouterContextProvider, p as DataWithResponseInit, M as MiddlewareEnabled } from './context-
|
|
2
|
+
import { i as ActionFunctionArgs, j as LoaderFunctionArgs, k as ActionFunction, l as LoaderFunction, h as Params, c as Location, m as DataRouteMatch, n as unstable_MiddlewareFunction, S as ShouldRevalidateFunction, o as unstable_RouterContextProvider, p as DataWithResponseInit, M as MiddlewareEnabled } from './context-CphUWOpx.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* An object of unknown type for route loaders and actions provided by the
|
|
@@ -271,27 +271,117 @@ type Submission = {
|
|
|
271
271
|
json: undefined;
|
|
272
272
|
text: string;
|
|
273
273
|
};
|
|
274
|
+
/**
|
|
275
|
+
* A context instance used as the key for the `get`/`set` methods of a
|
|
276
|
+
* {@link unstable_RouterContextProvider}. Accepts an optional default
|
|
277
|
+
* value to be returned if no value has been set.
|
|
278
|
+
*/
|
|
274
279
|
interface unstable_RouterContext<T = unknown> {
|
|
275
280
|
defaultValue?: T;
|
|
276
281
|
}
|
|
277
282
|
/**
|
|
278
|
-
* Creates a context object that
|
|
283
|
+
* Creates a type-safe context object that can be used to store and retrieve
|
|
284
|
+
* values in middleware, [loaders](../../start/framework/route-module#loader),
|
|
285
|
+
* and [actions](../../start/framework/route-module#action). Similar to React's
|
|
286
|
+
* [`createContext`](https://react.dev/reference/react/createContext), but
|
|
287
|
+
* designed for React Router's request/response lifecycle.
|
|
288
|
+
*
|
|
289
|
+
* If a `defaultValue` is provided, it will be returned from `context.get()` when
|
|
290
|
+
* no value has been set for the context. Otherwise reading this context when no
|
|
291
|
+
* value has been set will throw an error.
|
|
292
|
+
*
|
|
293
|
+
* ```tsx filename=app/context.ts
|
|
294
|
+
* import { unstable_createContext } from "react-router";
|
|
279
295
|
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
*
|
|
296
|
+
* // Create a context for user data
|
|
297
|
+
* export const userContext =
|
|
298
|
+
* unstable_createContext<User | null>(null);
|
|
299
|
+
* ```
|
|
300
|
+
*
|
|
301
|
+
* ```tsx filename=app/middleware/auth.ts
|
|
302
|
+
* import { userContext } from "~/context";
|
|
303
|
+
* import { getUserFromSession } from "~/auth.server";
|
|
304
|
+
*
|
|
305
|
+
* export const authMiddleware = async ({
|
|
306
|
+
* request,
|
|
307
|
+
* context,
|
|
308
|
+
* }) => {
|
|
309
|
+
* const user = await getUserFromSession(request);
|
|
310
|
+
* context.set(userContext, user);
|
|
311
|
+
* };
|
|
312
|
+
* ```
|
|
283
313
|
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
314
|
+
* ```tsx filename=app/routes/profile.tsx
|
|
315
|
+
* import { userContext } from "~/context";
|
|
316
|
+
*
|
|
317
|
+
* export async function loader({
|
|
318
|
+
* context,
|
|
319
|
+
* }: Route.LoaderArgs) {
|
|
320
|
+
* const user = context.get(userContext);
|
|
321
|
+
*
|
|
322
|
+
* if (!user) {
|
|
323
|
+
* throw new Response("Unauthorized", { status: 401 });
|
|
324
|
+
* }
|
|
325
|
+
*
|
|
326
|
+
* return { user };
|
|
327
|
+
* }
|
|
328
|
+
* ```
|
|
329
|
+
*
|
|
330
|
+
* @public
|
|
331
|
+
* @category Utils
|
|
332
|
+
* @mode framework
|
|
333
|
+
* @mode data
|
|
334
|
+
* @param defaultValue An optional default value for the context. This value will
|
|
335
|
+
* be returned if no value has been set for this context.
|
|
336
|
+
* @returns A {@link unstable_RouterContext} object that can be used with
|
|
337
|
+
* `context.get()` and `context.set()` in middleware, loaders, and actions.
|
|
286
338
|
*/
|
|
287
339
|
declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
|
|
288
340
|
/**
|
|
289
|
-
* Provides methods for writing/reading values in application context in a
|
|
341
|
+
* Provides methods for writing/reading values in application context in a
|
|
342
|
+
* type-safe way. Primarily for usage with [Middleware](../../how-to/middleware).
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* import {
|
|
346
|
+
* unstable_createContext,
|
|
347
|
+
* unstable_RouterContextProvider
|
|
348
|
+
* } from "react-router";
|
|
349
|
+
*
|
|
350
|
+
* const userContext = unstable_createContext<User | null>(null);
|
|
351
|
+
* const contextProvider = new unstable_RouterContextProvider();
|
|
352
|
+
* contextProvider.set(userContext, getUser());
|
|
353
|
+
* const user = contextProvider.get(userContext);
|
|
354
|
+
* // ^ User
|
|
355
|
+
*
|
|
356
|
+
* @public
|
|
357
|
+
* @category Utils
|
|
358
|
+
* @mode framework
|
|
359
|
+
* @mode data
|
|
290
360
|
*/
|
|
291
361
|
declare class unstable_RouterContextProvider {
|
|
292
362
|
#private;
|
|
363
|
+
/**
|
|
364
|
+
* Create a new `unstable_RouterContextProvider` instance
|
|
365
|
+
* @param init An optional initial context map to populate the provider with
|
|
366
|
+
*/
|
|
293
367
|
constructor(init?: Map<unstable_RouterContext, unknown>);
|
|
368
|
+
/**
|
|
369
|
+
* Access a value from the context. If no value has been set for the
|
|
370
|
+
* context, it will return the context's `defaultValue` if provided, or throw an
|
|
371
|
+
* error if no `defaultValue` was set.
|
|
372
|
+
* @param context The context to get the value for
|
|
373
|
+
* @returns The value for the context, or the contexts `defaultValue` if no
|
|
374
|
+
* value was set
|
|
375
|
+
*/
|
|
294
376
|
get<T>(context: unstable_RouterContext<T>): T;
|
|
377
|
+
/**
|
|
378
|
+
* Set a value for the context. If the context already has a value set,
|
|
379
|
+
* this will overwrite it.
|
|
380
|
+
*
|
|
381
|
+
* @param context The context to set the value for
|
|
382
|
+
* @param value The value to set for the context
|
|
383
|
+
* @returns {void}
|
|
384
|
+
*/
|
|
295
385
|
set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
|
|
296
386
|
}
|
|
297
387
|
type DefaultContext = MiddlewareEnabled extends true ? Readonly<unstable_RouterContextProvider> : any;
|
|
@@ -316,7 +406,7 @@ interface DataFunctionArgs<Context> {
|
|
|
316
406
|
* params.teamId;
|
|
317
407
|
* // ^ string
|
|
318
408
|
* }
|
|
319
|
-
|
|
409
|
+
*/
|
|
320
410
|
params: Params;
|
|
321
411
|
/**
|
|
322
412
|
* This is the context passed in to your server adapter's getLoadContext() function.
|
|
@@ -643,7 +733,27 @@ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticData
|
|
|
643
733
|
/**
|
|
644
734
|
* Matches the given routes to a location and returns the match data.
|
|
645
735
|
*
|
|
736
|
+
* @example
|
|
737
|
+
* import { matchRoutes } from "react-router";
|
|
738
|
+
*
|
|
739
|
+
* let routes = [{
|
|
740
|
+
* path: "/",
|
|
741
|
+
* Component: Root,
|
|
742
|
+
* children: [{
|
|
743
|
+
* path: "dashboard",
|
|
744
|
+
* Component: Dashboard,
|
|
745
|
+
* }]
|
|
746
|
+
* }];
|
|
747
|
+
*
|
|
748
|
+
* matchRoutes(routes, "/dashboard"); // [rootMatch, dashboardMatch]
|
|
749
|
+
*
|
|
750
|
+
* @public
|
|
646
751
|
* @category Utils
|
|
752
|
+
* @param routes The array of route objects to match against.
|
|
753
|
+
* @param locationArg The location to match against, either a string path or a
|
|
754
|
+
* partial {@link Location} object
|
|
755
|
+
* @param basename Optional base path to strip from the location before matching.
|
|
756
|
+
* @returns An array of matched routes, or `null` if no matches were found.
|
|
647
757
|
*/
|
|
648
758
|
declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
|
|
649
759
|
interface UIMatch<Data = unknown, Handle = unknown> {
|
|
@@ -651,7 +761,7 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
651
761
|
pathname: string;
|
|
652
762
|
/**
|
|
653
763
|
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
|
|
654
|
-
|
|
764
|
+
*/
|
|
655
765
|
params: AgnosticRouteMatch["params"];
|
|
656
766
|
/**
|
|
657
767
|
* The return value from the matched route's loader or clientLoader
|
|
@@ -667,7 +777,16 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
667
777
|
/**
|
|
668
778
|
* Returns a path with params interpolated.
|
|
669
779
|
*
|
|
780
|
+
* @example
|
|
781
|
+
* import { generatePath } from "react-router";
|
|
782
|
+
*
|
|
783
|
+
* generatePath("/users/:id", { id: "123" }); // "/users/123"
|
|
784
|
+
*
|
|
785
|
+
* @public
|
|
670
786
|
* @category Utils
|
|
787
|
+
* @param originalPath The original path to generate.
|
|
788
|
+
* @param params The parameters to interpolate into the path.
|
|
789
|
+
* @returns The generated path with parameters interpolated.
|
|
671
790
|
*/
|
|
672
791
|
declare function generatePath<Path extends string>(originalPath: Path, params?: {
|
|
673
792
|
[key in PathParam<Path>]: string | null;
|
|
@@ -717,13 +836,25 @@ interface PathMatch<ParamKey extends string = string> {
|
|
|
717
836
|
* Performs pattern matching on a URL pathname and returns information about
|
|
718
837
|
* the match.
|
|
719
838
|
*
|
|
839
|
+
* @public
|
|
720
840
|
* @category Utils
|
|
841
|
+
* @param pattern The pattern to match against the URL pathname. This can be a
|
|
842
|
+
* string or a {@link PathPattern} object. If a string is provided, it will
|
|
843
|
+
* be treated as a pattern with `caseSensitive` set to `false` and `end
|
|
844
|
+
* set to `true`.
|
|
845
|
+
* @param pathname The URL pathname to match against the pattern.
|
|
846
|
+
* @returns A path match object if the pattern matches the pathname,
|
|
847
|
+
* or `null` if it does not match.
|
|
721
848
|
*/
|
|
722
849
|
declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
|
|
723
850
|
/**
|
|
724
851
|
* Returns a resolved path object relative to the given pathname.
|
|
725
852
|
*
|
|
853
|
+
* @public
|
|
726
854
|
* @category Utils
|
|
855
|
+
* @param to The path to resolve, either a string or a partial {@link Path} object.
|
|
856
|
+
* @param fromPathname The pathname to resolve the path from. Defaults to `/`.
|
|
857
|
+
* @returns A {@link Path} object with the resolved pathname, search, and hash.
|
|
727
858
|
*/
|
|
728
859
|
declare function resolvePath(to: To, fromPathname?: string): Path;
|
|
729
860
|
declare class DataWithResponseInit<D> {
|
|
@@ -734,9 +865,29 @@ declare class DataWithResponseInit<D> {
|
|
|
734
865
|
}
|
|
735
866
|
/**
|
|
736
867
|
* Create "responses" that contain `status`/`headers` without forcing
|
|
737
|
-
* serialization into an actual `Response`
|
|
868
|
+
* serialization into an actual `Response`
|
|
869
|
+
*
|
|
870
|
+
* @example
|
|
871
|
+
* import { data } from "react-router";
|
|
738
872
|
*
|
|
873
|
+
* export async function action({ request }) {
|
|
874
|
+
* let formData = await request.formData();
|
|
875
|
+
* let item = await createItem(formData);
|
|
876
|
+
* return data(item, {
|
|
877
|
+
* status: 201,
|
|
878
|
+
* headers: { "X-Custom-Header": "value" }
|
|
879
|
+
* });
|
|
880
|
+
* }
|
|
881
|
+
*
|
|
882
|
+
* @public
|
|
739
883
|
* @category Utils
|
|
884
|
+
* @mode framework
|
|
885
|
+
* @mode data
|
|
886
|
+
* @param data The data to be included in the response.
|
|
887
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
888
|
+
* response.
|
|
889
|
+
* @returns A `DataWithResponseInit` instance containing the data and response
|
|
890
|
+
* init.
|
|
740
891
|
*/
|
|
741
892
|
declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
|
|
742
893
|
type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
|
@@ -744,7 +895,25 @@ type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
|
|
744
895
|
* A redirect response. Sets the status code and the `Location` header.
|
|
745
896
|
* Defaults to "302 Found".
|
|
746
897
|
*
|
|
898
|
+
* @example
|
|
899
|
+
* import { redirect } from "react-router";
|
|
900
|
+
*
|
|
901
|
+
* export function loader({ request }) {
|
|
902
|
+
* if (!isLoggedIn(request))
|
|
903
|
+
* throw redirect("/login");
|
|
904
|
+
* }
|
|
905
|
+
*
|
|
906
|
+
* // ...
|
|
907
|
+
* }
|
|
908
|
+
*
|
|
909
|
+
* @public
|
|
747
910
|
* @category Utils
|
|
911
|
+
* @mode framework
|
|
912
|
+
* @mode data
|
|
913
|
+
* @param url The URL to redirect to.
|
|
914
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
915
|
+
* response.
|
|
916
|
+
* @returns A `Response` object with the redirect status and `Location` header.
|
|
748
917
|
*/
|
|
749
918
|
declare const redirect: RedirectFunction;
|
|
750
919
|
/**
|
|
@@ -752,7 +921,26 @@ declare const redirect: RedirectFunction;
|
|
|
752
921
|
* Sets the status code and the `Location` header.
|
|
753
922
|
* Defaults to "302 Found".
|
|
754
923
|
*
|
|
924
|
+
* @example
|
|
925
|
+
* // routes/logout.tsx
|
|
926
|
+
* import { redirectDocument } from "react-router";
|
|
927
|
+
* import { destroySession } from "../sessions.server";
|
|
928
|
+
*
|
|
929
|
+
* export async function action({ request }) {
|
|
930
|
+
* let session = await getSession(request.headers.get("Cookie"));
|
|
931
|
+
* return redirectDocument("/", {
|
|
932
|
+
* headers: { "Set-Cookie": await destroySession(session) }
|
|
933
|
+
* });
|
|
934
|
+
* }
|
|
935
|
+
*
|
|
936
|
+
* @public
|
|
755
937
|
* @category Utils
|
|
938
|
+
* @mode framework
|
|
939
|
+
* @mode data
|
|
940
|
+
* @param url The URL to redirect to.
|
|
941
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
942
|
+
* response.
|
|
943
|
+
* @returns A `Response` object with the redirect status and `Location` header.
|
|
756
944
|
*/
|
|
757
945
|
declare const redirectDocument: RedirectFunction;
|
|
758
946
|
/**
|
|
@@ -761,7 +949,21 @@ declare const redirectDocument: RedirectFunction;
|
|
|
761
949
|
* Sets the status code and the `Location` header.
|
|
762
950
|
* Defaults to "302 Found".
|
|
763
951
|
*
|
|
952
|
+
* @example
|
|
953
|
+
* import { replace } from "react-router";
|
|
954
|
+
*
|
|
955
|
+
* export function loader() {
|
|
956
|
+
* return replace("/new-location");
|
|
957
|
+
* }
|
|
958
|
+
*
|
|
959
|
+
* @public
|
|
764
960
|
* @category Utils
|
|
961
|
+
* @mode framework
|
|
962
|
+
* @mode data
|
|
963
|
+
* @param url The URL to redirect to.
|
|
964
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
965
|
+
* response.
|
|
966
|
+
* @returns A `Response` object with the redirect status and `Location` header.
|
|
765
967
|
*/
|
|
766
968
|
declare const replace: RedirectFunction;
|
|
767
969
|
type ErrorResponse = {
|
|
@@ -769,14 +971,6 @@ type ErrorResponse = {
|
|
|
769
971
|
statusText: string;
|
|
770
972
|
data: any;
|
|
771
973
|
};
|
|
772
|
-
/**
|
|
773
|
-
* @private
|
|
774
|
-
* Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
|
|
775
|
-
*
|
|
776
|
-
* We don't export the class for public use since it's an implementation
|
|
777
|
-
* detail, but we export the interface above so folks can build their own
|
|
778
|
-
* abstractions around instances via isRouteErrorResponse()
|
|
779
|
-
*/
|
|
780
974
|
declare class ErrorResponseImpl implements ErrorResponse {
|
|
781
975
|
status: number;
|
|
782
976
|
statusText: string;
|
|
@@ -789,7 +983,31 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
789
983
|
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
|
|
790
984
|
* Response thrown from an action/loader
|
|
791
985
|
*
|
|
986
|
+
* @example
|
|
987
|
+
* import { isRouteErrorResponse } from "react-router";
|
|
988
|
+
*
|
|
989
|
+
* export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
|
|
990
|
+
* if (isRouteErrorResponse(error)) {
|
|
991
|
+
* return (
|
|
992
|
+
* <>
|
|
993
|
+
* <p>Error: {{error.status}: {error.statusText}}</p>
|
|
994
|
+
* <p>{error.data}</p>
|
|
995
|
+
* </>
|
|
996
|
+
* );
|
|
997
|
+
* }
|
|
998
|
+
*
|
|
999
|
+
* return (
|
|
1000
|
+
* <p>Error: {error instanceof Error ? error.message : "Unknown Error"}</p>
|
|
1001
|
+
* );
|
|
1002
|
+
* }
|
|
1003
|
+
*
|
|
1004
|
+
* @public
|
|
792
1005
|
* @category Utils
|
|
1006
|
+
* @mode framework
|
|
1007
|
+
* @mode data
|
|
1008
|
+
* @param error The error to check.
|
|
1009
|
+
* @returns `true` if the error is an `ErrorResponse`, `false` otherwise.
|
|
1010
|
+
*
|
|
793
1011
|
*/
|
|
794
1012
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
795
1013
|
|
|
@@ -1102,15 +1320,13 @@ interface StaticHandler {
|
|
|
1102
1320
|
skipLoaderErrorBubbling?: boolean;
|
|
1103
1321
|
skipRevalidation?: boolean;
|
|
1104
1322
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1105
|
-
|
|
1106
|
-
unstable_stream?: (context: unstable_RouterContextProvider, query: (r: Request) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1323
|
+
unstable_generateMiddlewareResponse?: (query: (r: Request) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1107
1324
|
}): Promise<StaticHandlerContext | Response>;
|
|
1108
1325
|
queryRoute(request: Request, opts?: {
|
|
1109
1326
|
routeId?: string;
|
|
1110
1327
|
requestContext?: unknown;
|
|
1111
1328
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1112
|
-
|
|
1113
|
-
unstable_stream?: (context: unstable_RouterContextProvider, queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1329
|
+
unstable_generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1114
1330
|
}): Promise<any>;
|
|
1115
1331
|
}
|
|
1116
1332
|
type ViewTransitionOpts = {
|