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
|
@@ -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 _chunkJJHCVRDZjs = require('./chunk-JJHCVRDZ.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(`[${_chunkJJHCVRDZjs.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-XKV32KFX.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-3O4L5GVQ.mjs";
|
|
33
33
|
|
|
34
34
|
// lib/dom-export/dom-router-provider.tsx
|
|
35
35
|
import * as React from "react";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as InitialEntry, T as To, i as RelativeRoutingType, w as NonIndexRouteObject, af as LazyRouteFunction, q as IndexRouteObject, a as Location, A as Action, aC as Navigator, d as Router$1, Q as RouterInit, aY as FutureConfig$1, H as HydrationState, D as DataStrategyFunction, W as PatchRoutesOnNavigationFunction, p as RouteObject, aE as RouteMatch, o as Params, U as UIMatch, ae as HTMLFormMethod, ac as FormEncType, aZ as RouteManifest, a_ as ServerRouteModule, z as MiddlewareEnabled, y as unstable_RouterContextProvider, x as AppLoadContext, ag as LoaderFunctionArgs, a6 as ActionFunctionArgs, e as RouteModules, X as DataRouteObject, J as ClientLoaderFunction, $ as StaticHandlerContext, aJ as PageLinkDescriptor, a$ as History, _ as GetScrollRestorationKeyFunction, f as NavigateOptions, a0 as Fetcher, h as SerializeFrom, B as BlockerFunction, b0 as CreateStaticHandlerOptions$1, Y as StaticHandler } from './routeModules-
|
|
1
|
+
import { I as InitialEntry, T as To, i as RelativeRoutingType, w as NonIndexRouteObject, af as LazyRouteFunction, q as IndexRouteObject, a as Location, A as Action, aC as Navigator, d as Router$1, Q as RouterInit, aY as FutureConfig$1, H as HydrationState, D as DataStrategyFunction, W as PatchRoutesOnNavigationFunction, p as RouteObject, aE as RouteMatch, o as Params, U as UIMatch, ae as HTMLFormMethod, ac as FormEncType, aZ as RouteManifest, a_ as ServerRouteModule, z as MiddlewareEnabled, y as unstable_RouterContextProvider, x as AppLoadContext, ag as LoaderFunctionArgs, a6 as ActionFunctionArgs, e as RouteModules, X as DataRouteObject, J as ClientLoaderFunction, $ as StaticHandlerContext, aJ as PageLinkDescriptor, a$ as History, _ as GetScrollRestorationKeyFunction, f as NavigateOptions, a0 as Fetcher, h as SerializeFrom, B as BlockerFunction, b0 as CreateStaticHandlerOptions$1, Y as StaticHandler } from './routeModules-DH3xUx4Z.js';
|
|
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
|
}
|
|
@@ -1268,7 +1268,7 @@ interface DOMRouterOpts {
|
|
|
1268
1268
|
* [`clientLoader`](../../start/framework/route-module#clientLoader)), you may
|
|
1269
1269
|
* want to include `loaderData` for only some routes that were loaded/rendered
|
|
1270
1270
|
* on the server. This allows you to hydrate _some_ of the routes (such as the
|
|
1271
|
-
* app layout/shell) while showing a
|
|
1271
|
+
* app layout/shell) while showing a `HydrateFallback`
|
|
1272
1272
|
* component and running the [`loader`](../../start/data/route-object#loader)s
|
|
1273
1273
|
* for other routes during hydration.
|
|
1274
1274
|
*
|
|
@@ -1276,8 +1276,7 @@ interface DOMRouterOpts {
|
|
|
1276
1276
|
* hydration in two scenarios:
|
|
1277
1277
|
*
|
|
1278
1278
|
* 1. No hydration data is provided
|
|
1279
|
-
* In these cases the
|
|
1280
|
-
* component will render on initial hydration
|
|
1279
|
+
* In these cases the `HydrateFallback` component will render on initial hydration
|
|
1281
1280
|
* 2. The `loader.hydrate` property is set to `true`
|
|
1282
1281
|
* This allows you to run the [`loader`](../../start/data/route-object#loader)
|
|
1283
1282
|
* even if you did not render a fallback on initial hydration (i.e., to
|
|
@@ -1339,9 +1338,9 @@ interface DOMRouterOpts {
|
|
|
1339
1338
|
*
|
|
1340
1339
|
* The `dataStrategy` function should return a key/value-object of
|
|
1341
1340
|
* `routeId` -> {@link DataStrategyResult} and should include entries for any
|
|
1342
|
-
* routes where a handler was executed. A
|
|
1343
|
-
* if the handler was successful or not based on the
|
|
1344
|
-
* field. If the returned
|
|
1341
|
+
* routes where a handler was executed. A `DataStrategyResult` indicates
|
|
1342
|
+
* if the handler was successful or not based on the `DataStrategyResult.type`
|
|
1343
|
+
* field. If the returned `DataStrategyResult.result` is a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response),
|
|
1345
1344
|
* React Router will unwrap it for you (via [`res.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)
|
|
1346
1345
|
* or [`res.text`](https://developer.mozilla.org/en-US/docs/Web/API/Response/text)).
|
|
1347
1346
|
* If you need to do custom decoding of a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
@@ -1361,7 +1360,7 @@ interface DOMRouterOpts {
|
|
|
1361
1360
|
* let router = createBrowserRouter(routes, {
|
|
1362
1361
|
* async dataStrategy({ matches, request }) {
|
|
1363
1362
|
* const matchesToLoad = matches.filter((m) => m.shouldLoad);
|
|
1364
|
-
* const results = {};
|
|
1363
|
+
* const results: Record<string, DataStrategyResult> = {};
|
|
1365
1364
|
* await Promise.all(
|
|
1366
1365
|
* matchesToLoad.map(async (match) => {
|
|
1367
1366
|
* console.log(`Processing ${match.route.id}`);
|
|
@@ -1535,7 +1534,7 @@ interface DOMRouterOpts {
|
|
|
1535
1534
|
*
|
|
1536
1535
|
* `patchRoutesOnNavigation` will be called anytime React Router is unable to
|
|
1537
1536
|
* match a `path`. The arguments include the `path`, any partial
|
|
1538
|
-
*
|
|
1537
|
+
* `matches`, and a `patch` function you can call to patch
|
|
1539
1538
|
* new routes into the tree at a specific location. This method is executed
|
|
1540
1539
|
* during the `loading` portion of the navigation for `GET` requests and during
|
|
1541
1540
|
* the `submitting` portion of the navigation for non-`GET` requests.
|
|
@@ -1638,7 +1637,7 @@ interface DOMRouterOpts {
|
|
|
1638
1637
|
* **Co-locating route discovery with route definition**
|
|
1639
1638
|
*
|
|
1640
1639
|
* If you don't wish to perform your own pseudo-matching, you can leverage
|
|
1641
|
-
* the partial
|
|
1640
|
+
* the partial `matches` array and the [`handle`](../../start/data/route-object#handle)
|
|
1642
1641
|
* field on a route to keep the children definitions co-located:
|
|
1643
1642
|
*
|
|
1644
1643
|
* ```tsx
|
|
@@ -3289,4 +3288,4 @@ declare function createStaticRouter(routes: RouteObject[], context: StaticHandle
|
|
|
3289
3288
|
future?: Partial<FutureConfig$1>;
|
|
3290
3289
|
}): Router$1;
|
|
3291
3290
|
|
|
3292
|
-
export { ScrollRestoration as $, type AssetsManifest as A, type BrowserRouterProps as B, type ScrollRestorationProps as C, type DOMRouterOpts as D, type EntryContext as E, type FutureConfig as F, type SetURLSearchParams as G, type HydrateFallbackType as H, type IndexRouteProps as I, type SubmitFunction as J, type FetcherSubmitFunction as K, type LayoutRouteProps as L, type MemoryRouterOpts as M, type NavigateProps as N, type OutletProps as O, type PathRouteProps as P, type FetcherWithComponents as Q, type RouteComponentType as R, type ServerBuild as S, createBrowserRouter as T, createHashRouter as U, BrowserRouter as V, HashRouter as W, Link as X, HistoryRouter as Y, NavLink as Z, Form as _, type ErrorBoundaryType as a, useLinkClickHandler as a0, useSearchParams as a1, useSubmit as a2, useFormAction as a3, useFetcher as a4, useFetchers as a5, useBeforeUnload as a6, usePrompt as a7, useViewTransitionState as a8, type FetcherSubmitOptions as a9,
|
|
3291
|
+
export { ScrollRestoration as $, type AssetsManifest as A, type BrowserRouterProps as B, type ScrollRestorationProps as C, type DOMRouterOpts as D, type EntryContext as E, type FutureConfig as F, type SetURLSearchParams as G, type HydrateFallbackType as H, type IndexRouteProps as I, type SubmitFunction as J, type FetcherSubmitFunction as K, type LayoutRouteProps as L, type MemoryRouterOpts as M, type NavigateProps as N, type OutletProps as O, type PathRouteProps as P, type FetcherWithComponents as Q, type RouteComponentType as R, type ServerBuild as S, createBrowserRouter as T, createHashRouter as U, BrowserRouter as V, HashRouter as W, Link as X, HistoryRouter as Y, NavLink as Z, Form as _, type ErrorBoundaryType as a, useLinkClickHandler as a0, useSearchParams as a1, useSubmit as a2, useFormAction as a3, useFetcher as a4, useFetchers as a5, useBeforeUnload as a6, usePrompt as a7, useViewTransitionState as a8, type FetcherSubmitOptions as a9, withComponentProps as aA, WithHydrateFallbackProps as aB, withHydrateFallbackProps as aC, WithErrorBoundaryProps as aD, withErrorBoundaryProps as aE, FrameworkContext as aF, createClientRoutes as aG, createClientRoutesWithHMRRevalidationOptOut as aH, shouldHydrateRouteLoader as aI, useScrollRestoration as aJ, type ParamKeyValuePair as aa, type SubmitOptions as ab, type URLSearchParamsInit as ac, type SubmitTarget as ad, createSearchParams as ae, type StaticRouterProps as af, type StaticRouterProviderProps as ag, createStaticHandler as ah, createStaticRouter as ai, StaticRouter as aj, StaticRouterProvider as ak, Meta as al, Links as am, Scripts as an, PrefetchPageLinks as ao, type LinksProps as ap, type ScriptsProps as aq, type PrefetchBehavior as ar, type DiscoverBehavior as as, type HandleDataRequestFunction as at, type HandleDocumentRequestFunction as au, type HandleErrorFunction as av, type ServerEntryModule as aw, hydrationRouteProperties as ax, mapRouteProperties as ay, WithComponentProps as az, type AwaitProps as b, type MemoryRouterProps as c, type RouteProps as d, type RouterProps as e, type RouterProviderProps as f, type RoutesProps as g, Await as h, MemoryRouter as i, Navigate as j, Outlet as k, Route$1 as l, Router as m, RouterProvider as n, Routes as o, createMemoryRouter as p, createRoutesFromChildren as q, createRoutesFromElements as r, renderMatches as s, type HashRouterProps as t, type HistoryRouterProps as u, type LinkProps as v, type NavLinkProps as w, type NavLinkRenderProps as x, type FetcherFormProps as y, type FormProps as z };
|