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,4 +1,4 @@
|
|
|
1
|
-
import { R as Router$1, I as InitialEntry, T as To, a as RelativeRoutingType, N as NonIndexRouteObject, L as LazyRouteFunction, b as IndexRouteObject, c as Location, A as Action, d as Navigator, e as RouterInit, F as FutureConfig, H as HydrationState, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, f as RouteObject, g as RouteMatch, h as Params, U as UIMatch } from './context-
|
|
1
|
+
import { R as Router$1, I as InitialEntry, T as To, a as RelativeRoutingType, N as NonIndexRouteObject, L as LazyRouteFunction, b as IndexRouteObject, c as Location, A as Action, d as Navigator, e as RouterInit, F as FutureConfig, H as HydrationState, D as DataStrategyFunction, P as PatchRoutesOnNavigationFunction, f as RouteObject, g as RouteMatch, h as Params, U as UIMatch } from './context-CphUWOpx.mjs';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
|
|
@@ -32,7 +32,7 @@ interface MemoryRouterOpts {
|
|
|
32
32
|
*/
|
|
33
33
|
initialEntries?: InitialEntry[];
|
|
34
34
|
/**
|
|
35
|
-
* Index of
|
|
35
|
+
* Index of `initialEntries` the application should initialize to
|
|
36
36
|
*/
|
|
37
37
|
initialIndex?: number;
|
|
38
38
|
/**
|
|
@@ -133,7 +133,7 @@ interface MemoryRouterProps {
|
|
|
133
133
|
*/
|
|
134
134
|
initialEntries?: InitialEntry[];
|
|
135
135
|
/**
|
|
136
|
-
* Index of
|
|
136
|
+
* Index of `initialEntries` the application should initialize to
|
|
137
137
|
*/
|
|
138
138
|
initialIndex?: number;
|
|
139
139
|
}
|
|
@@ -170,7 +170,7 @@ interface NavigateProps {
|
|
|
170
170
|
*/
|
|
171
171
|
state?: any;
|
|
172
172
|
/**
|
|
173
|
-
* How to interpret relative routing in the
|
|
173
|
+
* How to interpret relative routing in the `to` prop.
|
|
174
174
|
* See {@link RelativeRoutingType}.
|
|
175
175
|
*/
|
|
176
176
|
relative?: RelativeRoutingType;
|
|
@@ -288,32 +288,32 @@ interface PathRouteProps {
|
|
|
288
288
|
children?: React.ReactNode;
|
|
289
289
|
/**
|
|
290
290
|
* The React element to render when this Route matches.
|
|
291
|
-
* Mutually exclusive with
|
|
291
|
+
* Mutually exclusive with `Component`.
|
|
292
292
|
*/
|
|
293
293
|
element?: React.ReactNode | null;
|
|
294
294
|
/**
|
|
295
295
|
* The React element to render while this router is loading data.
|
|
296
|
-
* Mutually exclusive with
|
|
296
|
+
* Mutually exclusive with `HydrateFallback`.
|
|
297
297
|
*/
|
|
298
298
|
hydrateFallbackElement?: React.ReactNode | null;
|
|
299
299
|
/**
|
|
300
300
|
* The React element to render at this route if an error occurs.
|
|
301
|
-
* Mutually exclusive with
|
|
301
|
+
* Mutually exclusive with `ErrorBoundary`.
|
|
302
302
|
*/
|
|
303
303
|
errorElement?: React.ReactNode | null;
|
|
304
304
|
/**
|
|
305
305
|
* The React Component to render when this route matches.
|
|
306
|
-
* Mutually exclusive with
|
|
306
|
+
* Mutually exclusive with `element`.
|
|
307
307
|
*/
|
|
308
308
|
Component?: React.ComponentType | null;
|
|
309
309
|
/**
|
|
310
310
|
* The React Component to render while this router is loading data.
|
|
311
|
-
* Mutually exclusive with
|
|
311
|
+
* Mutually exclusive with `hydrateFallbackElement`.
|
|
312
312
|
*/
|
|
313
313
|
HydrateFallback?: React.ComponentType | null;
|
|
314
314
|
/**
|
|
315
315
|
* The React Component to render at this route if an error occurs.
|
|
316
|
-
* Mutually exclusive with
|
|
316
|
+
* Mutually exclusive with `errorElement`.
|
|
317
317
|
*/
|
|
318
318
|
ErrorBoundary?: React.ComponentType | null;
|
|
319
319
|
}
|
|
@@ -375,32 +375,32 @@ interface IndexRouteProps {
|
|
|
375
375
|
children?: undefined;
|
|
376
376
|
/**
|
|
377
377
|
* The React element to render when this Route matches.
|
|
378
|
-
* Mutually exclusive with
|
|
378
|
+
* Mutually exclusive with `Component`.
|
|
379
379
|
*/
|
|
380
380
|
element?: React.ReactNode | null;
|
|
381
381
|
/**
|
|
382
382
|
* The React element to render while this router is loading data.
|
|
383
|
-
* Mutually exclusive with
|
|
383
|
+
* Mutually exclusive with `HydrateFallback`.
|
|
384
384
|
*/
|
|
385
385
|
hydrateFallbackElement?: React.ReactNode | null;
|
|
386
386
|
/**
|
|
387
387
|
* The React element to render at this route if an error occurs.
|
|
388
|
-
* Mutually exclusive with
|
|
388
|
+
* Mutually exclusive with `ErrorBoundary`.
|
|
389
389
|
*/
|
|
390
390
|
errorElement?: React.ReactNode | null;
|
|
391
391
|
/**
|
|
392
392
|
* The React Component to render when this route matches.
|
|
393
|
-
* Mutually exclusive with
|
|
393
|
+
* Mutually exclusive with `element`.
|
|
394
394
|
*/
|
|
395
395
|
Component?: React.ComponentType | null;
|
|
396
396
|
/**
|
|
397
397
|
* The React Component to render while this router is loading data.
|
|
398
|
-
* Mutually exclusive with
|
|
398
|
+
* Mutually exclusive with `hydrateFallbackElement`.
|
|
399
399
|
*/
|
|
400
400
|
HydrateFallback?: React.ComponentType | null;
|
|
401
401
|
/**
|
|
402
402
|
* The React Component to render at this route if an error occurs.
|
|
403
|
-
* Mutually exclusive with
|
|
403
|
+
* Mutually exclusive with `errorElement`.
|
|
404
404
|
*/
|
|
405
405
|
ErrorBoundary?: React.ComponentType | null;
|
|
406
406
|
}
|
|
@@ -270,27 +270,117 @@ type Submission = {
|
|
|
270
270
|
json: undefined;
|
|
271
271
|
text: string;
|
|
272
272
|
};
|
|
273
|
+
/**
|
|
274
|
+
* A context instance used as the key for the `get`/`set` methods of a
|
|
275
|
+
* {@link unstable_RouterContextProvider}. Accepts an optional default
|
|
276
|
+
* value to be returned if no value has been set.
|
|
277
|
+
*/
|
|
273
278
|
interface unstable_RouterContext<T = unknown> {
|
|
274
279
|
defaultValue?: T;
|
|
275
280
|
}
|
|
276
281
|
/**
|
|
277
|
-
* Creates a context object that
|
|
282
|
+
* Creates a type-safe context object that can be used to store and retrieve
|
|
283
|
+
* values in middleware, [loaders](../../start/framework/route-module#loader),
|
|
284
|
+
* and [actions](../../start/framework/route-module#action). Similar to React's
|
|
285
|
+
* [`createContext`](https://react.dev/reference/react/createContext), but
|
|
286
|
+
* designed for React Router's request/response lifecycle.
|
|
287
|
+
*
|
|
288
|
+
* If a `defaultValue` is provided, it will be returned from `context.get()` when
|
|
289
|
+
* no value has been set for the context. Otherwise reading this context when no
|
|
290
|
+
* value has been set will throw an error.
|
|
291
|
+
*
|
|
292
|
+
* ```tsx filename=app/context.ts
|
|
293
|
+
* import { unstable_createContext } from "react-router";
|
|
294
|
+
*
|
|
295
|
+
* // Create a context for user data
|
|
296
|
+
* export const userContext =
|
|
297
|
+
* unstable_createContext<User | null>(null);
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* ```tsx filename=app/middleware/auth.ts
|
|
301
|
+
* import { userContext } from "~/context";
|
|
302
|
+
* import { getUserFromSession } from "~/auth.server";
|
|
278
303
|
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
*
|
|
304
|
+
* export const authMiddleware = async ({
|
|
305
|
+
* request,
|
|
306
|
+
* context,
|
|
307
|
+
* }) => {
|
|
308
|
+
* const user = await getUserFromSession(request);
|
|
309
|
+
* context.set(userContext, user);
|
|
310
|
+
* };
|
|
311
|
+
* ```
|
|
282
312
|
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
313
|
+
* ```tsx filename=app/routes/profile.tsx
|
|
314
|
+
* import { userContext } from "~/context";
|
|
315
|
+
*
|
|
316
|
+
* export async function loader({
|
|
317
|
+
* context,
|
|
318
|
+
* }: Route.LoaderArgs) {
|
|
319
|
+
* const user = context.get(userContext);
|
|
320
|
+
*
|
|
321
|
+
* if (!user) {
|
|
322
|
+
* throw new Response("Unauthorized", { status: 401 });
|
|
323
|
+
* }
|
|
324
|
+
*
|
|
325
|
+
* return { user };
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @public
|
|
330
|
+
* @category Utils
|
|
331
|
+
* @mode framework
|
|
332
|
+
* @mode data
|
|
333
|
+
* @param defaultValue An optional default value for the context. This value will
|
|
334
|
+
* be returned if no value has been set for this context.
|
|
335
|
+
* @returns A {@link unstable_RouterContext} object that can be used with
|
|
336
|
+
* `context.get()` and `context.set()` in middleware, loaders, and actions.
|
|
285
337
|
*/
|
|
286
338
|
declare function unstable_createContext<T>(defaultValue?: T): unstable_RouterContext<T>;
|
|
287
339
|
/**
|
|
288
|
-
* Provides methods for writing/reading values in application context in a
|
|
340
|
+
* Provides methods for writing/reading values in application context in a
|
|
341
|
+
* type-safe way. Primarily for usage with [Middleware](../../how-to/middleware).
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* import {
|
|
345
|
+
* unstable_createContext,
|
|
346
|
+
* unstable_RouterContextProvider
|
|
347
|
+
* } from "react-router";
|
|
348
|
+
*
|
|
349
|
+
* const userContext = unstable_createContext<User | null>(null);
|
|
350
|
+
* const contextProvider = new unstable_RouterContextProvider();
|
|
351
|
+
* contextProvider.set(userContext, getUser());
|
|
352
|
+
* const user = contextProvider.get(userContext);
|
|
353
|
+
* // ^ User
|
|
354
|
+
*
|
|
355
|
+
* @public
|
|
356
|
+
* @category Utils
|
|
357
|
+
* @mode framework
|
|
358
|
+
* @mode data
|
|
289
359
|
*/
|
|
290
360
|
declare class unstable_RouterContextProvider {
|
|
291
361
|
#private;
|
|
362
|
+
/**
|
|
363
|
+
* Create a new `unstable_RouterContextProvider` instance
|
|
364
|
+
* @param init An optional initial context map to populate the provider with
|
|
365
|
+
*/
|
|
292
366
|
constructor(init?: Map<unstable_RouterContext, unknown>);
|
|
367
|
+
/**
|
|
368
|
+
* Access a value from the context. If no value has been set for the
|
|
369
|
+
* context, it will return the context's `defaultValue` if provided, or throw an
|
|
370
|
+
* error if no `defaultValue` was set.
|
|
371
|
+
* @param context The context to get the value for
|
|
372
|
+
* @returns The value for the context, or the contexts `defaultValue` if no
|
|
373
|
+
* value was set
|
|
374
|
+
*/
|
|
293
375
|
get<T>(context: unstable_RouterContext<T>): T;
|
|
376
|
+
/**
|
|
377
|
+
* Set a value for the context. If the context already has a value set,
|
|
378
|
+
* this will overwrite it.
|
|
379
|
+
*
|
|
380
|
+
* @param context The context to set the value for
|
|
381
|
+
* @param value The value to set for the context
|
|
382
|
+
* @returns {void}
|
|
383
|
+
*/
|
|
294
384
|
set<C extends unstable_RouterContext>(context: C, value: C extends unstable_RouterContext<infer T> ? T : never): void;
|
|
295
385
|
}
|
|
296
386
|
type DefaultContext = MiddlewareEnabled extends true ? Readonly<unstable_RouterContextProvider> : any;
|
|
@@ -315,7 +405,7 @@ interface DataFunctionArgs<Context> {
|
|
|
315
405
|
* params.teamId;
|
|
316
406
|
* // ^ string
|
|
317
407
|
* }
|
|
318
|
-
|
|
408
|
+
*/
|
|
319
409
|
params: Params;
|
|
320
410
|
/**
|
|
321
411
|
* This is the context passed in to your server adapter's getLoadContext() function.
|
|
@@ -642,7 +732,27 @@ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticData
|
|
|
642
732
|
/**
|
|
643
733
|
* Matches the given routes to a location and returns the match data.
|
|
644
734
|
*
|
|
735
|
+
* @example
|
|
736
|
+
* import { matchRoutes } from "react-router";
|
|
737
|
+
*
|
|
738
|
+
* let routes = [{
|
|
739
|
+
* path: "/",
|
|
740
|
+
* Component: Root,
|
|
741
|
+
* children: [{
|
|
742
|
+
* path: "dashboard",
|
|
743
|
+
* Component: Dashboard,
|
|
744
|
+
* }]
|
|
745
|
+
* }];
|
|
746
|
+
*
|
|
747
|
+
* matchRoutes(routes, "/dashboard"); // [rootMatch, dashboardMatch]
|
|
748
|
+
*
|
|
749
|
+
* @public
|
|
645
750
|
* @category Utils
|
|
751
|
+
* @param routes The array of route objects to match against.
|
|
752
|
+
* @param locationArg The location to match against, either a string path or a
|
|
753
|
+
* partial {@link Location} object
|
|
754
|
+
* @param basename Optional base path to strip from the location before matching.
|
|
755
|
+
* @returns An array of matched routes, or `null` if no matches were found.
|
|
646
756
|
*/
|
|
647
757
|
declare function matchRoutes<RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): AgnosticRouteMatch<string, RouteObjectType>[] | null;
|
|
648
758
|
interface UIMatch<Data = unknown, Handle = unknown> {
|
|
@@ -650,7 +760,7 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
650
760
|
pathname: string;
|
|
651
761
|
/**
|
|
652
762
|
* {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the matched route.
|
|
653
|
-
|
|
763
|
+
*/
|
|
654
764
|
params: AgnosticRouteMatch["params"];
|
|
655
765
|
/**
|
|
656
766
|
* The return value from the matched route's loader or clientLoader
|
|
@@ -666,7 +776,16 @@ interface UIMatch<Data = unknown, Handle = unknown> {
|
|
|
666
776
|
/**
|
|
667
777
|
* Returns a path with params interpolated.
|
|
668
778
|
*
|
|
779
|
+
* @example
|
|
780
|
+
* import { generatePath } from "react-router";
|
|
781
|
+
*
|
|
782
|
+
* generatePath("/users/:id", { id: "123" }); // "/users/123"
|
|
783
|
+
*
|
|
784
|
+
* @public
|
|
669
785
|
* @category Utils
|
|
786
|
+
* @param originalPath The original path to generate.
|
|
787
|
+
* @param params The parameters to interpolate into the path.
|
|
788
|
+
* @returns The generated path with parameters interpolated.
|
|
670
789
|
*/
|
|
671
790
|
declare function generatePath<Path extends string>(originalPath: Path, params?: {
|
|
672
791
|
[key in PathParam<Path>]: string | null;
|
|
@@ -716,13 +835,25 @@ interface PathMatch<ParamKey extends string = string> {
|
|
|
716
835
|
* Performs pattern matching on a URL pathname and returns information about
|
|
717
836
|
* the match.
|
|
718
837
|
*
|
|
838
|
+
* @public
|
|
719
839
|
* @category Utils
|
|
840
|
+
* @param pattern The pattern to match against the URL pathname. This can be a
|
|
841
|
+
* string or a {@link PathPattern} object. If a string is provided, it will
|
|
842
|
+
* be treated as a pattern with `caseSensitive` set to `false` and `end
|
|
843
|
+
* set to `true`.
|
|
844
|
+
* @param pathname The URL pathname to match against the pattern.
|
|
845
|
+
* @returns A path match object if the pattern matches the pathname,
|
|
846
|
+
* or `null` if it does not match.
|
|
720
847
|
*/
|
|
721
848
|
declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
|
|
722
849
|
/**
|
|
723
850
|
* Returns a resolved path object relative to the given pathname.
|
|
724
851
|
*
|
|
852
|
+
* @public
|
|
725
853
|
* @category Utils
|
|
854
|
+
* @param to The path to resolve, either a string or a partial {@link Path} object.
|
|
855
|
+
* @param fromPathname The pathname to resolve the path from. Defaults to `/`.
|
|
856
|
+
* @returns A {@link Path} object with the resolved pathname, search, and hash.
|
|
726
857
|
*/
|
|
727
858
|
declare function resolvePath(to: To, fromPathname?: string): Path;
|
|
728
859
|
declare class DataWithResponseInit<D> {
|
|
@@ -733,9 +864,29 @@ declare class DataWithResponseInit<D> {
|
|
|
733
864
|
}
|
|
734
865
|
/**
|
|
735
866
|
* Create "responses" that contain `status`/`headers` without forcing
|
|
736
|
-
* serialization into an actual `Response`
|
|
867
|
+
* serialization into an actual `Response`
|
|
737
868
|
*
|
|
869
|
+
* @example
|
|
870
|
+
* import { data } from "react-router";
|
|
871
|
+
*
|
|
872
|
+
* export async function action({ request }) {
|
|
873
|
+
* let formData = await request.formData();
|
|
874
|
+
* let item = await createItem(formData);
|
|
875
|
+
* return data(item, {
|
|
876
|
+
* status: 201,
|
|
877
|
+
* headers: { "X-Custom-Header": "value" }
|
|
878
|
+
* });
|
|
879
|
+
* }
|
|
880
|
+
*
|
|
881
|
+
* @public
|
|
738
882
|
* @category Utils
|
|
883
|
+
* @mode framework
|
|
884
|
+
* @mode data
|
|
885
|
+
* @param data The data to be included in the response.
|
|
886
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
887
|
+
* response.
|
|
888
|
+
* @returns A `DataWithResponseInit` instance containing the data and response
|
|
889
|
+
* init.
|
|
739
890
|
*/
|
|
740
891
|
declare function data<D>(data: D, init?: number | ResponseInit): DataWithResponseInit<D>;
|
|
741
892
|
type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
|
@@ -743,7 +894,25 @@ type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
|
|
743
894
|
* A redirect response. Sets the status code and the `Location` header.
|
|
744
895
|
* Defaults to "302 Found".
|
|
745
896
|
*
|
|
897
|
+
* @example
|
|
898
|
+
* import { redirect } from "react-router";
|
|
899
|
+
*
|
|
900
|
+
* export function loader({ request }) {
|
|
901
|
+
* if (!isLoggedIn(request))
|
|
902
|
+
* throw redirect("/login");
|
|
903
|
+
* }
|
|
904
|
+
*
|
|
905
|
+
* // ...
|
|
906
|
+
* }
|
|
907
|
+
*
|
|
908
|
+
* @public
|
|
746
909
|
* @category Utils
|
|
910
|
+
* @mode framework
|
|
911
|
+
* @mode data
|
|
912
|
+
* @param url The URL to redirect to.
|
|
913
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
914
|
+
* response.
|
|
915
|
+
* @returns A `Response` object with the redirect status and `Location` header.
|
|
747
916
|
*/
|
|
748
917
|
declare const redirect: RedirectFunction;
|
|
749
918
|
/**
|
|
@@ -751,7 +920,26 @@ declare const redirect: RedirectFunction;
|
|
|
751
920
|
* Sets the status code and the `Location` header.
|
|
752
921
|
* Defaults to "302 Found".
|
|
753
922
|
*
|
|
923
|
+
* @example
|
|
924
|
+
* // routes/logout.tsx
|
|
925
|
+
* import { redirectDocument } from "react-router";
|
|
926
|
+
* import { destroySession } from "../sessions.server";
|
|
927
|
+
*
|
|
928
|
+
* export async function action({ request }) {
|
|
929
|
+
* let session = await getSession(request.headers.get("Cookie"));
|
|
930
|
+
* return redirectDocument("/", {
|
|
931
|
+
* headers: { "Set-Cookie": await destroySession(session) }
|
|
932
|
+
* });
|
|
933
|
+
* }
|
|
934
|
+
*
|
|
935
|
+
* @public
|
|
754
936
|
* @category Utils
|
|
937
|
+
* @mode framework
|
|
938
|
+
* @mode data
|
|
939
|
+
* @param url The URL to redirect to.
|
|
940
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
941
|
+
* response.
|
|
942
|
+
* @returns A `Response` object with the redirect status and `Location` header.
|
|
755
943
|
*/
|
|
756
944
|
declare const redirectDocument: RedirectFunction;
|
|
757
945
|
/**
|
|
@@ -760,7 +948,21 @@ declare const redirectDocument: RedirectFunction;
|
|
|
760
948
|
* Sets the status code and the `Location` header.
|
|
761
949
|
* Defaults to "302 Found".
|
|
762
950
|
*
|
|
951
|
+
* @example
|
|
952
|
+
* import { replace } from "react-router";
|
|
953
|
+
*
|
|
954
|
+
* export function loader() {
|
|
955
|
+
* return replace("/new-location");
|
|
956
|
+
* }
|
|
957
|
+
*
|
|
958
|
+
* @public
|
|
763
959
|
* @category Utils
|
|
960
|
+
* @mode framework
|
|
961
|
+
* @mode data
|
|
962
|
+
* @param url The URL to redirect to.
|
|
963
|
+
* @param init The status code or a `ResponseInit` object to be included in the
|
|
964
|
+
* response.
|
|
965
|
+
* @returns A `Response` object with the redirect status and `Location` header.
|
|
764
966
|
*/
|
|
765
967
|
declare const replace: RedirectFunction;
|
|
766
968
|
type ErrorResponse = {
|
|
@@ -768,14 +970,6 @@ type ErrorResponse = {
|
|
|
768
970
|
statusText: string;
|
|
769
971
|
data: any;
|
|
770
972
|
};
|
|
771
|
-
/**
|
|
772
|
-
* @private
|
|
773
|
-
* Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
|
|
774
|
-
*
|
|
775
|
-
* We don't export the class for public use since it's an implementation
|
|
776
|
-
* detail, but we export the interface above so folks can build their own
|
|
777
|
-
* abstractions around instances via isRouteErrorResponse()
|
|
778
|
-
*/
|
|
779
973
|
declare class ErrorResponseImpl implements ErrorResponse {
|
|
780
974
|
status: number;
|
|
781
975
|
statusText: string;
|
|
@@ -788,7 +982,31 @@ declare class ErrorResponseImpl implements ErrorResponse {
|
|
|
788
982
|
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
|
|
789
983
|
* Response thrown from an action/loader
|
|
790
984
|
*
|
|
985
|
+
* @example
|
|
986
|
+
* import { isRouteErrorResponse } from "react-router";
|
|
987
|
+
*
|
|
988
|
+
* export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
|
|
989
|
+
* if (isRouteErrorResponse(error)) {
|
|
990
|
+
* return (
|
|
991
|
+
* <>
|
|
992
|
+
* <p>Error: {{error.status}: {error.statusText}}</p>
|
|
993
|
+
* <p>{error.data}</p>
|
|
994
|
+
* </>
|
|
995
|
+
* );
|
|
996
|
+
* }
|
|
997
|
+
*
|
|
998
|
+
* return (
|
|
999
|
+
* <p>Error: {error instanceof Error ? error.message : "Unknown Error"}</p>
|
|
1000
|
+
* );
|
|
1001
|
+
* }
|
|
1002
|
+
*
|
|
1003
|
+
* @public
|
|
791
1004
|
* @category Utils
|
|
1005
|
+
* @mode framework
|
|
1006
|
+
* @mode data
|
|
1007
|
+
* @param error The error to check.
|
|
1008
|
+
* @returns `true` if the error is an `ErrorResponse`, `false` otherwise.
|
|
1009
|
+
*
|
|
792
1010
|
*/
|
|
793
1011
|
declare function isRouteErrorResponse(error: any): error is ErrorResponse;
|
|
794
1012
|
|
|
@@ -1101,15 +1319,13 @@ interface StaticHandler {
|
|
|
1101
1319
|
skipLoaderErrorBubbling?: boolean;
|
|
1102
1320
|
skipRevalidation?: boolean;
|
|
1103
1321
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1104
|
-
|
|
1105
|
-
unstable_stream?: (context: unstable_RouterContextProvider, query: (r: Request) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1322
|
+
unstable_generateMiddlewareResponse?: (query: (r: Request) => Promise<StaticHandlerContext | Response>) => MaybePromise<Response>;
|
|
1106
1323
|
}): Promise<StaticHandlerContext | Response>;
|
|
1107
1324
|
queryRoute(request: Request, opts?: {
|
|
1108
1325
|
routeId?: string;
|
|
1109
1326
|
requestContext?: unknown;
|
|
1110
1327
|
dataStrategy?: DataStrategyFunction<unknown>;
|
|
1111
|
-
|
|
1112
|
-
unstable_stream?: (context: unstable_RouterContextProvider, queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1328
|
+
unstable_generateMiddlewareResponse?: (queryRoute: (r: Request) => Promise<Response>) => MaybePromise<Response>;
|
|
1113
1329
|
}): Promise<any>;
|
|
1114
1330
|
}
|
|
1115
1331
|
type ViewTransitionOpts = {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { R as RouterProviderProps$1 } from './components-
|
|
2
|
+
import { R as RouterProviderProps$1 } from './components-BkK38HPd.mjs';
|
|
3
3
|
import './browser-z32v5KVN.mjs';
|
|
4
|
-
import { e as RouterInit } from './context-
|
|
4
|
+
import { e as RouterInit } from './context-CphUWOpx.mjs';
|
|
5
5
|
|
|
6
6
|
type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
7
7
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Props for the {@link HydratedRouter} component.
|
|
10
|
+
* Props for the {@link dom.HydratedRouter} component.
|
|
11
11
|
*
|
|
12
12
|
* @category Types
|
|
13
13
|
*/
|
|
@@ -5,7 +5,7 @@ type RouterProviderProps = Omit<RouterProviderProps$1, "flushSync">;
|
|
|
5
5
|
declare function RouterProvider(props: Omit<RouterProviderProps, "flushSync">): React.JSX.Element;
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Props for the {@link HydratedRouter} component.
|
|
8
|
+
* Props for the {@link dom.HydratedRouter} component.
|
|
9
9
|
*
|
|
10
10
|
* @category Types
|
|
11
11
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e89ad3012
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"use client";
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkNFNPXIQEjs = require('./chunk-NFNPXIQE.js');
|
|
15
15
|
|
|
16
16
|
// lib/dom-export/dom-router-provider.tsx
|
|
17
17
|
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
|
|
@@ -180,7 +180,7 @@ function HydratedRouter(props) {
|
|
|
180
180
|
}, []);
|
|
181
181
|
React2.useEffect(() => {
|
|
182
182
|
if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
|
|
183
|
-
document.querySelectorAll(`[${
|
|
183
|
+
document.querySelectorAll(`[${_chunkNFNPXIQEjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
|
|
184
184
|
}
|
|
185
185
|
}, [criticalCss]);
|
|
186
186
|
let [location, setLocation] = React2.useState(router.state.location);
|
|
@@ -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
|
*
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import {
|
|
13
13
|
deserializeErrors,
|
|
14
14
|
getHydrationData
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-J6PLTU3O.mjs";
|
|
16
16
|
import {
|
|
17
17
|
CRITICAL_CSS_DATA_ATTRIBUTE,
|
|
18
18
|
FrameworkContext,
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
invariant,
|
|
30
30
|
mapRouteProperties,
|
|
31
31
|
useFogOFWarDiscovery
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-QI3NR5VQ.mjs";
|
|
33
33
|
|
|
34
34
|
// lib/dom-export/dom-router-provider.tsx
|
|
35
35
|
import * as React from "react";
|