react-router 7.7.1 → 7.8.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +87 -5
- package/dist/development/browser-z32v5KVN.d.mts +46 -0
- package/dist/development/{chunk-R73PQUJU.js → chunk-4EVDZJGM.js} +130 -130
- package/dist/{production/chunk-K3SBCRK4.mjs → development/chunk-I22FVTOY.mjs} +177 -134
- package/dist/development/{chunk-K7YFBME3.js → chunk-NGF2R4G7.js} +285 -189
- package/dist/development/{chunk-C37GKA54.mjs → chunk-XFFANEXU.mjs} +266 -170
- package/dist/development/{components-CjQijYga.d.mts → components-CuPfnyiZ.d.mts} +33 -21
- package/dist/{production/route-data-CqEmXQub.d.mts → development/context-DohQKLID.d.mts} +312 -525
- package/dist/development/dom-export.d.mts +16 -12
- package/dist/development/dom-export.d.ts +13 -8
- package/dist/development/dom-export.js +3 -3
- package/dist/development/dom-export.mjs +3 -3
- package/dist/development/{index-react-server-client-Bi_fx8qz.d.ts → index-react-server-client-BzBbJLAD.d.ts} +357 -219
- package/dist/{production/index-react-server-client-KLg-U4nr.d.mts → development/index-react-server-client-CuajY2vy.d.mts} +327 -200
- package/dist/development/index-react-server-client.d.mts +4 -3
- 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 +291 -71
- package/dist/development/index-react-server.d.ts +291 -71
- package/dist/development/index-react-server.js +209 -182
- package/dist/development/index-react-server.mjs +209 -182
- package/dist/development/index.d.mts +294 -86
- package/dist/development/index.d.ts +136 -105
- package/dist/development/index.js +258 -215
- package/dist/development/index.mjs +3 -3
- package/dist/development/lib/types/internal.d.mts +13 -2
- package/dist/development/lib/types/internal.d.ts +12 -2
- package/dist/development/lib/types/internal.js +1 -1
- package/dist/development/lib/types/internal.mjs +1 -1
- package/dist/development/route-data-CpB5xtMm.d.mts +473 -0
- package/dist/{production/routeModules-BR2FO0ix.d.ts → development/routeModules-qBivMBjd.d.ts} +325 -68
- package/dist/production/browser-z32v5KVN.d.mts +46 -0
- package/dist/production/{chunk-4DGLNKXF.js → chunk-4PESVXQ2.js} +130 -130
- package/dist/{development/chunk-KIUJAIYX.mjs → production/chunk-JJOMWYJ4.mjs} +177 -134
- package/dist/production/{chunk-IZ57JD2V.mjs → chunk-P2ZJHOXZ.mjs} +266 -170
- package/dist/production/{chunk-7OQROU2D.js → chunk-RLJ23MYZ.js} +285 -189
- package/dist/production/{components-CjQijYga.d.mts → components-CuPfnyiZ.d.mts} +33 -21
- package/dist/{development/route-data-CqEmXQub.d.mts → production/context-DohQKLID.d.mts} +312 -525
- package/dist/production/dom-export.d.mts +16 -12
- package/dist/production/dom-export.d.ts +13 -8
- package/dist/production/dom-export.js +3 -3
- package/dist/production/dom-export.mjs +3 -3
- package/dist/production/{index-react-server-client-Bi_fx8qz.d.ts → index-react-server-client-BzBbJLAD.d.ts} +357 -219
- package/dist/{development/index-react-server-client-KLg-U4nr.d.mts → production/index-react-server-client-CuajY2vy.d.mts} +327 -200
- package/dist/production/index-react-server-client.d.mts +4 -3
- 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 +291 -71
- package/dist/production/index-react-server.d.ts +291 -71
- package/dist/production/index-react-server.js +209 -182
- package/dist/production/index-react-server.mjs +209 -182
- package/dist/production/index.d.mts +294 -86
- package/dist/production/index.d.ts +136 -105
- package/dist/production/index.js +258 -215
- package/dist/production/index.mjs +3 -3
- package/dist/production/lib/types/internal.d.mts +13 -2
- package/dist/production/lib/types/internal.d.ts +12 -2
- package/dist/production/lib/types/internal.js +1 -1
- package/dist/production/lib/types/internal.mjs +1 -1
- package/dist/production/route-data-CpB5xtMm.d.mts +473 -0
- package/dist/{development/routeModules-BR2FO0ix.d.ts → production/routeModules-qBivMBjd.d.ts} +325 -68
- package/package.json +1 -1
- package/dist/development/browser-7LYX59NK.d.mts +0 -226
- package/dist/production/browser-7LYX59NK.d.mts +0 -226
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v7.
|
|
2
|
+
* react-router v7.8.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -367,6 +367,10 @@ function unstable_createContext(defaultValue) {
|
|
|
367
367
|
}
|
|
368
368
|
var _map;
|
|
369
369
|
var unstable_RouterContextProvider = class {
|
|
370
|
+
/**
|
|
371
|
+
* Create a new `unstable_RouterContextProvider` instance
|
|
372
|
+
* @param init An optional initial context map to populate the provider with
|
|
373
|
+
*/
|
|
370
374
|
constructor(init) {
|
|
371
375
|
__privateAdd(this, _map, /* @__PURE__ */ new Map());
|
|
372
376
|
if (init) {
|
|
@@ -375,6 +379,14 @@ var unstable_RouterContextProvider = class {
|
|
|
375
379
|
}
|
|
376
380
|
}
|
|
377
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Access a value from the context. If no value has been set for the context,
|
|
384
|
+
* it will return the context's `defaultValue` if provided, or throw an error
|
|
385
|
+
* if no `defaultValue` was set.
|
|
386
|
+
* @param context The context to get the value for
|
|
387
|
+
* @returns The value for the context, or the context's `defaultValue` if no
|
|
388
|
+
* value was set
|
|
389
|
+
*/
|
|
378
390
|
get(context) {
|
|
379
391
|
if (__privateGet(this, _map).has(context)) {
|
|
380
392
|
return __privateGet(this, _map).get(context);
|
|
@@ -384,6 +396,14 @@ var unstable_RouterContextProvider = class {
|
|
|
384
396
|
}
|
|
385
397
|
throw new Error("No value found for context");
|
|
386
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Set a value for the context. If the context already has a value set, this
|
|
401
|
+
* will overwrite it.
|
|
402
|
+
*
|
|
403
|
+
* @param context The context to set the value for
|
|
404
|
+
* @param value The value to set for the context
|
|
405
|
+
* @returns {void}
|
|
406
|
+
*/
|
|
387
407
|
set(context, value) {
|
|
388
408
|
__privateGet(this, _map).set(context, value);
|
|
389
409
|
}
|
|
@@ -489,6 +509,7 @@ function convertRouteMatchToUiMatch(match, loaderData) {
|
|
|
489
509
|
pathname,
|
|
490
510
|
params,
|
|
491
511
|
data: loaderData[route.id],
|
|
512
|
+
loaderData: loaderData[route.id],
|
|
492
513
|
handle: route.handle
|
|
493
514
|
};
|
|
494
515
|
}
|
|
@@ -1434,9 +1455,7 @@ function createRouter(init) {
|
|
|
1434
1455
|
pendingNavigationController.signal,
|
|
1435
1456
|
opts && opts.submission
|
|
1436
1457
|
);
|
|
1437
|
-
let scopedContext = new unstable_RouterContextProvider(
|
|
1438
|
-
init.unstable_getContext ? await init.unstable_getContext() : void 0
|
|
1439
|
-
);
|
|
1458
|
+
let scopedContext = init.unstable_getContext ? await init.unstable_getContext() : new unstable_RouterContextProvider();
|
|
1440
1459
|
let pendingActionResult;
|
|
1441
1460
|
if (opts && opts.pendingError) {
|
|
1442
1461
|
pendingActionResult = [
|
|
@@ -1703,7 +1722,7 @@ function createRouter(init) {
|
|
|
1703
1722
|
pendingActionResult
|
|
1704
1723
|
);
|
|
1705
1724
|
pendingNavigationLoadId = ++incrementingLoadId;
|
|
1706
|
-
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && revalidatingFetchers.length === 0) {
|
|
1725
|
+
if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some((m) => m.route.unstable_middleware) && revalidatingFetchers.length === 0) {
|
|
1707
1726
|
let updatedFetchers2 = markFetchRedirectsDone();
|
|
1708
1727
|
completeNavigation(
|
|
1709
1728
|
location,
|
|
@@ -1857,9 +1876,7 @@ function createRouter(init) {
|
|
|
1857
1876
|
setFetcherError(key, routeId, error, { flushSync });
|
|
1858
1877
|
return;
|
|
1859
1878
|
}
|
|
1860
|
-
let scopedContext = new unstable_RouterContextProvider(
|
|
1861
|
-
init.unstable_getContext ? await init.unstable_getContext() : void 0
|
|
1862
|
-
);
|
|
1879
|
+
let scopedContext = init.unstable_getContext ? await init.unstable_getContext() : new unstable_RouterContextProvider();
|
|
1863
1880
|
let preventScrollReset = (opts && opts.preventScrollReset) === true;
|
|
1864
1881
|
if (submission && isMutationMethod(submission.formMethod)) {
|
|
1865
1882
|
await handleFetcherAction(
|
|
@@ -2710,20 +2727,13 @@ function createStaticHandler(routes, opts) {
|
|
|
2710
2727
|
skipLoaderErrorBubbling,
|
|
2711
2728
|
skipRevalidation,
|
|
2712
2729
|
dataStrategy,
|
|
2713
|
-
|
|
2714
|
-
unstable_respond: respond
|
|
2730
|
+
unstable_generateMiddlewareResponse: generateMiddlewareResponse
|
|
2715
2731
|
} = {}) {
|
|
2716
2732
|
let url = new URL(request.url);
|
|
2717
2733
|
let method = request.method;
|
|
2718
2734
|
let location = createLocation("", createPath(url), null, "default");
|
|
2719
2735
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
2720
2736
|
requestContext = requestContext != null ? requestContext : new unstable_RouterContextProvider();
|
|
2721
|
-
let respondOrStreamStaticContext = (ctx) => {
|
|
2722
|
-
return stream ? stream(
|
|
2723
|
-
requestContext,
|
|
2724
|
-
() => Promise.resolve(ctx)
|
|
2725
|
-
) : respond ? respond(ctx) : ctx;
|
|
2726
|
-
};
|
|
2727
2737
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2728
2738
|
let error = getInternalRouterError(405, { method });
|
|
2729
2739
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
@@ -2740,7 +2750,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2740
2750
|
loaderHeaders: {},
|
|
2741
2751
|
actionHeaders: {}
|
|
2742
2752
|
};
|
|
2743
|
-
return
|
|
2753
|
+
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
2744
2754
|
} else if (!matches) {
|
|
2745
2755
|
let error = getInternalRouterError(404, { pathname: location.pathname });
|
|
2746
2756
|
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
@@ -2757,11 +2767,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2757
2767
|
loaderHeaders: {},
|
|
2758
2768
|
actionHeaders: {}
|
|
2759
2769
|
};
|
|
2760
|
-
return
|
|
2770
|
+
return generateMiddlewareResponse ? generateMiddlewareResponse(() => Promise.resolve(staticContext)) : staticContext;
|
|
2761
2771
|
}
|
|
2762
|
-
if (
|
|
2763
|
-
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
2764
|
-
)) {
|
|
2772
|
+
if (generateMiddlewareResponse) {
|
|
2765
2773
|
invariant(
|
|
2766
2774
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2767
2775
|
"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
@@ -2773,7 +2781,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2773
2781
|
mapRouteProperties2
|
|
2774
2782
|
);
|
|
2775
2783
|
let renderedStaticContext;
|
|
2776
|
-
let response = await
|
|
2784
|
+
let response = await runServerMiddlewarePipeline(
|
|
2777
2785
|
{
|
|
2778
2786
|
request,
|
|
2779
2787
|
matches,
|
|
@@ -2782,45 +2790,27 @@ function createStaticHandler(routes, opts) {
|
|
|
2782
2790
|
// this to the proper type knowing it's not an `AppLoadContext`
|
|
2783
2791
|
context: requestContext
|
|
2784
2792
|
},
|
|
2785
|
-
true,
|
|
2786
2793
|
async () => {
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
return isResponse(result3) ? result3 : { location, basename, ...result3 };
|
|
2794
|
+
let res = await generateMiddlewareResponse(
|
|
2795
|
+
async (revalidationRequest) => {
|
|
2796
|
+
let result2 = await queryImpl(
|
|
2797
|
+
revalidationRequest,
|
|
2798
|
+
location,
|
|
2799
|
+
matches,
|
|
2800
|
+
requestContext,
|
|
2801
|
+
dataStrategy || null,
|
|
2802
|
+
skipLoaderErrorBubbling === true,
|
|
2803
|
+
null,
|
|
2804
|
+
filterMatchesToLoad || null,
|
|
2805
|
+
skipRevalidation === true
|
|
2806
|
+
);
|
|
2807
|
+
if (isResponse(result2)) {
|
|
2808
|
+
return result2;
|
|
2803
2809
|
}
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
invariant(respond, "Expected respond to be defined");
|
|
2808
|
-
let result2 = await queryImpl(
|
|
2809
|
-
request,
|
|
2810
|
-
location,
|
|
2811
|
-
matches,
|
|
2812
|
-
requestContext,
|
|
2813
|
-
dataStrategy || null,
|
|
2814
|
-
skipLoaderErrorBubbling === true,
|
|
2815
|
-
null,
|
|
2816
|
-
filterMatchesToLoad || null,
|
|
2817
|
-
skipRevalidation === true
|
|
2810
|
+
renderedStaticContext = { location, basename, ...result2 };
|
|
2811
|
+
return renderedStaticContext;
|
|
2812
|
+
}
|
|
2818
2813
|
);
|
|
2819
|
-
if (isResponse(result2)) {
|
|
2820
|
-
return result2;
|
|
2821
|
-
}
|
|
2822
|
-
renderedStaticContext = { location, basename, ...result2 };
|
|
2823
|
-
let res = await respond(renderedStaticContext);
|
|
2824
2814
|
return res;
|
|
2825
2815
|
},
|
|
2826
2816
|
async (error, routeId) => {
|
|
@@ -2837,7 +2827,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2837
2827
|
error,
|
|
2838
2828
|
skipLoaderErrorBubbling ? routeId : findNearestBoundary(matches, routeId).route.id
|
|
2839
2829
|
);
|
|
2840
|
-
return
|
|
2830
|
+
return generateMiddlewareResponse(
|
|
2831
|
+
() => Promise.resolve(staticContext)
|
|
2832
|
+
);
|
|
2841
2833
|
} else {
|
|
2842
2834
|
let boundaryRouteId = skipLoaderErrorBubbling ? routeId : findNearestBoundary(
|
|
2843
2835
|
matches,
|
|
@@ -2858,7 +2850,9 @@ function createStaticHandler(routes, opts) {
|
|
|
2858
2850
|
actionHeaders: {},
|
|
2859
2851
|
loaderHeaders: {}
|
|
2860
2852
|
};
|
|
2861
|
-
return
|
|
2853
|
+
return generateMiddlewareResponse(
|
|
2854
|
+
() => Promise.resolve(staticContext)
|
|
2855
|
+
);
|
|
2862
2856
|
}
|
|
2863
2857
|
}
|
|
2864
2858
|
);
|
|
@@ -2891,7 +2885,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2891
2885
|
routeId,
|
|
2892
2886
|
requestContext,
|
|
2893
2887
|
dataStrategy,
|
|
2894
|
-
|
|
2888
|
+
unstable_generateMiddlewareResponse: generateMiddlewareResponse
|
|
2895
2889
|
} = {}) {
|
|
2896
2890
|
let url = new URL(request.url);
|
|
2897
2891
|
let method = request.method;
|
|
@@ -2912,15 +2906,13 @@ function createStaticHandler(routes, opts) {
|
|
|
2912
2906
|
} else if (!match) {
|
|
2913
2907
|
throw getInternalRouterError(404, { pathname: location.pathname });
|
|
2914
2908
|
}
|
|
2915
|
-
if (
|
|
2916
|
-
(m) => m.route.unstable_middleware || typeof m.route.lazy === "object" && m.route.lazy.unstable_middleware
|
|
2917
|
-
)) {
|
|
2909
|
+
if (generateMiddlewareResponse) {
|
|
2918
2910
|
invariant(
|
|
2919
2911
|
requestContext instanceof unstable_RouterContextProvider,
|
|
2920
2912
|
"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `unstable_RouterContextProvider`"
|
|
2921
2913
|
);
|
|
2922
2914
|
await loadLazyMiddlewareForMatches(matches, manifest, mapRouteProperties2);
|
|
2923
|
-
let response = await
|
|
2915
|
+
let response = await runServerMiddlewarePipeline(
|
|
2924
2916
|
{
|
|
2925
2917
|
request,
|
|
2926
2918
|
matches,
|
|
@@ -2929,37 +2921,34 @@ function createStaticHandler(routes, opts) {
|
|
|
2929
2921
|
// this to the proper type knowing it's not an `AppLoadContext`
|
|
2930
2922
|
context: requestContext
|
|
2931
2923
|
},
|
|
2932
|
-
true,
|
|
2933
2924
|
async () => {
|
|
2934
|
-
let
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2925
|
+
let res = await generateMiddlewareResponse(
|
|
2926
|
+
async (innerRequest) => {
|
|
2927
|
+
let result2 = await queryImpl(
|
|
2928
|
+
innerRequest,
|
|
2929
|
+
location,
|
|
2930
|
+
matches,
|
|
2931
|
+
requestContext,
|
|
2932
|
+
dataStrategy || null,
|
|
2933
|
+
false,
|
|
2934
|
+
match,
|
|
2935
|
+
null,
|
|
2936
|
+
false
|
|
2937
|
+
);
|
|
2938
|
+
let processed = handleQueryResult(result2);
|
|
2939
|
+
return isResponse(processed) ? processed : typeof processed === "string" ? new Response(processed) : Response.json(processed);
|
|
2940
|
+
}
|
|
2944
2941
|
);
|
|
2945
|
-
|
|
2946
|
-
return respond(result2);
|
|
2947
|
-
}
|
|
2948
|
-
let error2 = result2.errors ? Object.values(result2.errors)[0] : void 0;
|
|
2949
|
-
if (error2 !== void 0) {
|
|
2950
|
-
throw error2;
|
|
2951
|
-
}
|
|
2952
|
-
let value = result2.actionData ? Object.values(result2.actionData)[0] : Object.values(result2.loaderData)[0];
|
|
2953
|
-
return typeof value === "string" ? new Response(value) : Response.json(value);
|
|
2942
|
+
return res;
|
|
2954
2943
|
},
|
|
2955
|
-
(
|
|
2956
|
-
if (
|
|
2957
|
-
return
|
|
2944
|
+
(error) => {
|
|
2945
|
+
if (isRouteErrorResponse(error)) {
|
|
2946
|
+
return Promise.resolve(errorResponseToResponse(error));
|
|
2958
2947
|
}
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2948
|
+
if (isResponse(error)) {
|
|
2949
|
+
return Promise.resolve(error);
|
|
2950
|
+
}
|
|
2951
|
+
throw error;
|
|
2963
2952
|
}
|
|
2964
2953
|
);
|
|
2965
2954
|
return response;
|
|
@@ -2975,20 +2964,23 @@ function createStaticHandler(routes, opts) {
|
|
|
2975
2964
|
null,
|
|
2976
2965
|
false
|
|
2977
2966
|
);
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2967
|
+
return handleQueryResult(result);
|
|
2968
|
+
function handleQueryResult(result2) {
|
|
2969
|
+
if (isResponse(result2)) {
|
|
2970
|
+
return result2;
|
|
2971
|
+
}
|
|
2972
|
+
let error = result2.errors ? Object.values(result2.errors)[0] : void 0;
|
|
2973
|
+
if (error !== void 0) {
|
|
2974
|
+
throw error;
|
|
2975
|
+
}
|
|
2976
|
+
if (result2.actionData) {
|
|
2977
|
+
return Object.values(result2.actionData)[0];
|
|
2978
|
+
}
|
|
2979
|
+
if (result2.loaderData) {
|
|
2980
|
+
return Object.values(result2.loaderData)[0];
|
|
2981
|
+
}
|
|
2982
|
+
return void 0;
|
|
2990
2983
|
}
|
|
2991
|
-
return void 0;
|
|
2992
2984
|
}
|
|
2993
2985
|
async function queryImpl(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, skipRevalidation) {
|
|
2994
2986
|
invariant(
|
|
@@ -3928,45 +3920,118 @@ async function defaultDataStrategyWithMiddleware(args) {
|
|
|
3928
3920
|
if (!args.matches.some((m) => m.route.unstable_middleware)) {
|
|
3929
3921
|
return defaultDataStrategy(args);
|
|
3930
3922
|
}
|
|
3931
|
-
return
|
|
3923
|
+
return runClientMiddlewarePipeline(
|
|
3932
3924
|
args,
|
|
3933
|
-
false,
|
|
3934
3925
|
() => defaultDataStrategy(args),
|
|
3935
3926
|
(error, routeId) => ({ [routeId]: { type: "error", result: error } })
|
|
3936
3927
|
);
|
|
3937
3928
|
}
|
|
3938
|
-
async function
|
|
3929
|
+
async function runServerMiddlewarePipeline(args, handler, errorHandler) {
|
|
3939
3930
|
let { matches, request, params, context } = args;
|
|
3940
|
-
let
|
|
3941
|
-
|
|
3931
|
+
let tuples = matches.flatMap(
|
|
3932
|
+
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
3933
|
+
);
|
|
3934
|
+
let result = await callServerRouteMiddleware(
|
|
3935
|
+
{ request, params, context },
|
|
3936
|
+
tuples,
|
|
3937
|
+
handler,
|
|
3938
|
+
errorHandler
|
|
3939
|
+
);
|
|
3940
|
+
if (isResponse(result)) {
|
|
3941
|
+
return result;
|
|
3942
|
+
}
|
|
3943
|
+
invariant(false, `Expected a Response to be returned from route middleware`);
|
|
3944
|
+
}
|
|
3945
|
+
async function callServerRouteMiddleware(args, middlewares, handler, errorHandler, idx = 0) {
|
|
3946
|
+
let { request } = args;
|
|
3947
|
+
if (request.signal.aborted) {
|
|
3948
|
+
if (request.signal.reason) {
|
|
3949
|
+
throw request.signal.reason;
|
|
3950
|
+
}
|
|
3951
|
+
throw new Error(
|
|
3952
|
+
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
3953
|
+
);
|
|
3954
|
+
}
|
|
3955
|
+
let tuple = middlewares[idx];
|
|
3956
|
+
if (!tuple) {
|
|
3957
|
+
let result = await handler();
|
|
3958
|
+
return result;
|
|
3959
|
+
}
|
|
3960
|
+
let [routeId, middleware] = tuple;
|
|
3961
|
+
let nextCalled = false;
|
|
3962
|
+
let nextResult = void 0;
|
|
3963
|
+
let next = async () => {
|
|
3964
|
+
if (nextCalled) {
|
|
3965
|
+
throw new Error("You may only call `next()` once per middleware");
|
|
3966
|
+
}
|
|
3967
|
+
nextCalled = true;
|
|
3968
|
+
try {
|
|
3969
|
+
let result = await callServerRouteMiddleware(
|
|
3970
|
+
args,
|
|
3971
|
+
middlewares,
|
|
3972
|
+
handler,
|
|
3973
|
+
errorHandler,
|
|
3974
|
+
idx + 1
|
|
3975
|
+
);
|
|
3976
|
+
if (isDataWithResponseInit(result)) {
|
|
3977
|
+
result = dataWithResponseInitToResponse(result);
|
|
3978
|
+
}
|
|
3979
|
+
nextResult = result;
|
|
3980
|
+
return nextResult;
|
|
3981
|
+
} catch (e) {
|
|
3982
|
+
nextResult = await errorHandler(
|
|
3983
|
+
// Convert thrown data() values to ErrorResponses
|
|
3984
|
+
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
3985
|
+
routeId
|
|
3986
|
+
);
|
|
3987
|
+
return nextResult;
|
|
3988
|
+
}
|
|
3942
3989
|
};
|
|
3943
3990
|
try {
|
|
3944
|
-
let
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
middlewareState,
|
|
3952
|
-
handler
|
|
3991
|
+
let result = await middleware(
|
|
3992
|
+
{
|
|
3993
|
+
request: args.request,
|
|
3994
|
+
params: args.params,
|
|
3995
|
+
context: args.context
|
|
3996
|
+
},
|
|
3997
|
+
next
|
|
3953
3998
|
);
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
if (!middlewareState.middlewareError) {
|
|
3957
|
-
throw e;
|
|
3999
|
+
if (isDataWithResponseInit(result)) {
|
|
4000
|
+
result = dataWithResponseInitToResponse(result);
|
|
3958
4001
|
}
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
);
|
|
3963
|
-
if (propagateResult || !middlewareState.handlerResult) {
|
|
4002
|
+
if (nextCalled) {
|
|
4003
|
+
return typeof result === "undefined" ? nextResult : result;
|
|
4004
|
+
} else if (isResponse(result)) {
|
|
3964
4005
|
return result;
|
|
4006
|
+
} else {
|
|
4007
|
+
nextResult = await next();
|
|
4008
|
+
return nextResult;
|
|
3965
4009
|
}
|
|
3966
|
-
|
|
4010
|
+
} catch (e) {
|
|
4011
|
+
let response = await errorHandler(
|
|
4012
|
+
// Convert thrown data() values to ErrorResponses
|
|
4013
|
+
isDataWithResponseInit(e) ? dataWithResponseInitToErrorResponse(e) : e,
|
|
4014
|
+
routeId
|
|
4015
|
+
);
|
|
4016
|
+
return response;
|
|
3967
4017
|
}
|
|
3968
4018
|
}
|
|
3969
|
-
async function
|
|
4019
|
+
async function runClientMiddlewarePipeline(args, handler, errorHandler) {
|
|
4020
|
+
let { matches, request, params, context } = args;
|
|
4021
|
+
let tuples = matches.flatMap(
|
|
4022
|
+
(m) => m.route.unstable_middleware ? m.route.unstable_middleware.map((fn) => [m.route.id, fn]) : []
|
|
4023
|
+
);
|
|
4024
|
+
let handlerResult = {};
|
|
4025
|
+
await callClientRouteMiddleware(
|
|
4026
|
+
{ request, params, context },
|
|
4027
|
+
tuples,
|
|
4028
|
+
handler,
|
|
4029
|
+
errorHandler,
|
|
4030
|
+
handlerResult
|
|
4031
|
+
);
|
|
4032
|
+
return handlerResult;
|
|
4033
|
+
}
|
|
4034
|
+
async function callClientRouteMiddleware(args, middlewares, handler, errorHandler, handlerResult = {}, idx = 0) {
|
|
3970
4035
|
let { request } = args;
|
|
3971
4036
|
if (request.signal.aborted) {
|
|
3972
4037
|
if (request.signal.reason) {
|
|
@@ -3978,28 +4043,30 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
3978
4043
|
}
|
|
3979
4044
|
let tuple = middlewares[idx];
|
|
3980
4045
|
if (!tuple) {
|
|
3981
|
-
|
|
3982
|
-
|
|
4046
|
+
let result = await handler();
|
|
4047
|
+
Object.assign(handlerResult, result);
|
|
4048
|
+
return;
|
|
3983
4049
|
}
|
|
3984
4050
|
let [routeId, middleware] = tuple;
|
|
3985
4051
|
let nextCalled = false;
|
|
3986
|
-
let nextResult = void 0;
|
|
3987
4052
|
let next = async () => {
|
|
3988
4053
|
if (nextCalled) {
|
|
3989
4054
|
throw new Error("You may only call `next()` once per middleware");
|
|
3990
4055
|
}
|
|
3991
4056
|
nextCalled = true;
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4057
|
+
try {
|
|
4058
|
+
let result = await callClientRouteMiddleware(
|
|
4059
|
+
args,
|
|
4060
|
+
middlewares,
|
|
4061
|
+
handler,
|
|
4062
|
+
errorHandler,
|
|
4063
|
+
handlerResult,
|
|
4064
|
+
idx + 1
|
|
4065
|
+
);
|
|
4066
|
+
Object.assign(handlerResult, result);
|
|
4067
|
+
} catch (e) {
|
|
4068
|
+
let result = await errorHandler(e, routeId);
|
|
4069
|
+
Object.assign(handlerResult, result);
|
|
4003
4070
|
}
|
|
4004
4071
|
};
|
|
4005
4072
|
try {
|
|
@@ -4011,22 +4078,18 @@ async function callRouteMiddleware(args, middlewares, propagateResult, middlewar
|
|
|
4011
4078
|
},
|
|
4012
4079
|
next
|
|
4013
4080
|
);
|
|
4014
|
-
if (
|
|
4015
|
-
|
|
4016
|
-
return
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
}
|
|
4020
|
-
} else {
|
|
4021
|
-
return next();
|
|
4081
|
+
if (typeof result !== "undefined") {
|
|
4082
|
+
console.warn(
|
|
4083
|
+
"client middlewares are not intended to return values, the value will be ignored",
|
|
4084
|
+
result
|
|
4085
|
+
);
|
|
4022
4086
|
}
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
middlewareState.middlewareError = { routeId, error };
|
|
4026
|
-
} else if (middlewareState.middlewareError.error !== error) {
|
|
4027
|
-
middlewareState.middlewareError = { routeId, error };
|
|
4087
|
+
if (!nextCalled) {
|
|
4088
|
+
await next();
|
|
4028
4089
|
}
|
|
4029
|
-
|
|
4090
|
+
} catch (error) {
|
|
4091
|
+
let result = await errorHandler(error, routeId);
|
|
4092
|
+
Object.assign(handlerResult, result);
|
|
4030
4093
|
}
|
|
4031
4094
|
}
|
|
4032
4095
|
function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request, match, lazyRoutePropertiesToSkip) {
|
|
@@ -4137,9 +4200,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
|
|
|
4137
4200
|
);
|
|
4138
4201
|
} : (cb) => {
|
|
4139
4202
|
let typedDataStrategyArgs = dataStrategyArgs;
|
|
4140
|
-
return
|
|
4203
|
+
return runClientMiddlewarePipeline(
|
|
4141
4204
|
typedDataStrategyArgs,
|
|
4142
|
-
false,
|
|
4143
4205
|
() => cb({
|
|
4144
4206
|
...typedDataStrategyArgs,
|
|
4145
4207
|
fetcherKey,
|
|
@@ -4477,11 +4539,12 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
|
|
|
4477
4539
|
);
|
|
4478
4540
|
revalidatingFetchers.filter((f) => !f.matches || f.matches.some((m) => m.shouldLoad)).forEach((rf) => {
|
|
4479
4541
|
let { key, match, controller } = rf;
|
|
4480
|
-
let result = fetcherResults[key];
|
|
4481
|
-
invariant(result, "Did not find corresponding fetcher result");
|
|
4482
4542
|
if (controller && controller.signal.aborted) {
|
|
4483
4543
|
return;
|
|
4484
|
-
}
|
|
4544
|
+
}
|
|
4545
|
+
let result = fetcherResults[key];
|
|
4546
|
+
invariant(result, "Did not find corresponding fetcher result");
|
|
4547
|
+
if (isErrorResult(result)) {
|
|
4485
4548
|
let boundaryMatch = findNearestBoundary(state.matches, match?.route.id);
|
|
4486
4549
|
if (!(errors && errors[boundaryMatch.route.id])) {
|
|
4487
4550
|
errors = {
|
|
@@ -4611,6 +4674,28 @@ function isHashChangeOnly(a, b) {
|
|
|
4611
4674
|
}
|
|
4612
4675
|
return false;
|
|
4613
4676
|
}
|
|
4677
|
+
function dataWithResponseInitToResponse(data2) {
|
|
4678
|
+
return new Response(
|
|
4679
|
+
typeof data2.data === "string" ? data2.data : JSON.stringify(data2.data),
|
|
4680
|
+
data2.init || void 0
|
|
4681
|
+
);
|
|
4682
|
+
}
|
|
4683
|
+
function dataWithResponseInitToErrorResponse(data2) {
|
|
4684
|
+
return new ErrorResponseImpl(
|
|
4685
|
+
data2.init?.status ?? 500,
|
|
4686
|
+
data2.init?.statusText ?? "Internal Server Error",
|
|
4687
|
+
data2.data
|
|
4688
|
+
);
|
|
4689
|
+
}
|
|
4690
|
+
function errorResponseToResponse(error) {
|
|
4691
|
+
return new Response(
|
|
4692
|
+
typeof error.data === "string" ? error.data : JSON.stringify(error.data),
|
|
4693
|
+
{
|
|
4694
|
+
status: error.status,
|
|
4695
|
+
statusText: error.statusText
|
|
4696
|
+
}
|
|
4697
|
+
);
|
|
4698
|
+
}
|
|
4614
4699
|
function isDataStrategyResult(result) {
|
|
4615
4700
|
return result != null && typeof result === "object" && "type" in result && "result" in result && (result.type === "data" /* data */ || result.type === "error" /* error */);
|
|
4616
4701
|
}
|
|
@@ -7147,6 +7232,12 @@ async function bubbleMiddlewareErrors(singleFetchPromise, matches, routesParams,
|
|
|
7147
7232
|
let routeResult = fetchedData.routes[match.route.id];
|
|
7148
7233
|
if ("error" in routeResult) {
|
|
7149
7234
|
middlewareError = routeResult.error;
|
|
7235
|
+
if (results[match.route.id]?.result == null) {
|
|
7236
|
+
results[match.route.id] = {
|
|
7237
|
+
type: "error",
|
|
7238
|
+
result: middlewareError
|
|
7239
|
+
};
|
|
7240
|
+
}
|
|
7150
7241
|
break;
|
|
7151
7242
|
}
|
|
7152
7243
|
}
|
|
@@ -8150,12 +8241,14 @@ function getManifestPath(_manifestPath, basename) {
|
|
|
8150
8241
|
}
|
|
8151
8242
|
var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
|
|
8152
8243
|
async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
|
|
8244
|
+
const searchParams = new URLSearchParams();
|
|
8245
|
+
paths.sort().forEach((path) => searchParams.append("p", path));
|
|
8246
|
+
searchParams.set("version", manifest.version);
|
|
8153
8247
|
let url = new URL(
|
|
8154
8248
|
getManifestPath(manifestPath, basename),
|
|
8155
8249
|
window.location.origin
|
|
8156
8250
|
);
|
|
8157
|
-
|
|
8158
|
-
url.searchParams.set("version", manifest.version);
|
|
8251
|
+
url.search = searchParams.toString();
|
|
8159
8252
|
if (url.toString().length > URL_LIMIT) {
|
|
8160
8253
|
nextPaths.clear();
|
|
8161
8254
|
return;
|
|
@@ -8333,7 +8426,7 @@ function getActiveMatches(matches, errors, isSpaMode) {
|
|
|
8333
8426
|
return matches;
|
|
8334
8427
|
}
|
|
8335
8428
|
var CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
|
|
8336
|
-
function Links() {
|
|
8429
|
+
function Links({ nonce }) {
|
|
8337
8430
|
let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext();
|
|
8338
8431
|
let { errors, matches: routerMatches } = useDataRouterStateContext();
|
|
8339
8432
|
let matches = getActiveMatches(routerMatches, errors, isSpaMode);
|
|
@@ -8352,10 +8445,11 @@ function Links() {
|
|
|
8352
8445
|
{
|
|
8353
8446
|
...{ [CRITICAL_CSS_DATA_ATTRIBUTE]: "" },
|
|
8354
8447
|
rel: "stylesheet",
|
|
8355
|
-
href: criticalCss.href
|
|
8448
|
+
href: criticalCss.href,
|
|
8449
|
+
nonce
|
|
8356
8450
|
}
|
|
8357
8451
|
) : null, keyedLinks.map(
|
|
8358
|
-
({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React8.createElement(PrefetchPageLinks, { key, ...link }) : /* @__PURE__ */ React8.createElement("link", { key, ...link })
|
|
8452
|
+
({ key, link }) => isPageLinkDescriptor(link) ? /* @__PURE__ */ React8.createElement(PrefetchPageLinks, { key, nonce, ...link }) : /* @__PURE__ */ React8.createElement("link", { key, nonce, ...link })
|
|
8359
8453
|
));
|
|
8360
8454
|
}
|
|
8361
8455
|
function PrefetchPageLinks({ page, ...linkProps }) {
|
|
@@ -8466,7 +8560,7 @@ function PrefetchPageLinksImpl({
|
|
|
8466
8560
|
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React8.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React8.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
|
|
8467
8561
|
// these don't spread `linkProps` because they are full link descriptors
|
|
8468
8562
|
// already with their own props
|
|
8469
|
-
/* @__PURE__ */ React8.createElement("link", { key, ...link })
|
|
8563
|
+
/* @__PURE__ */ React8.createElement("link", { key, nonce: linkProps.nonce, ...link })
|
|
8470
8564
|
)));
|
|
8471
8565
|
}
|
|
8472
8566
|
function Meta() {
|
|
@@ -8495,6 +8589,7 @@ function Meta() {
|
|
|
8495
8589
|
let match = {
|
|
8496
8590
|
id: routeId,
|
|
8497
8591
|
data: data2,
|
|
8592
|
+
loaderData: data2,
|
|
8498
8593
|
meta: [],
|
|
8499
8594
|
params: _match.params,
|
|
8500
8595
|
pathname: _match.pathname,
|
|
@@ -8505,6 +8600,7 @@ function Meta() {
|
|
|
8505
8600
|
if (routeModule?.meta) {
|
|
8506
8601
|
routeMeta = typeof routeModule.meta === "function" ? routeModule.meta({
|
|
8507
8602
|
data: data2,
|
|
8603
|
+
loaderData: data2,
|
|
8508
8604
|
params,
|
|
8509
8605
|
location,
|
|
8510
8606
|
matches,
|
|
@@ -8845,7 +8941,7 @@ var isBrowser = typeof window !== "undefined" && typeof window.document !== "und
|
|
|
8845
8941
|
try {
|
|
8846
8942
|
if (isBrowser) {
|
|
8847
8943
|
window.__reactRouterVersion = // @ts-expect-error
|
|
8848
|
-
"7.
|
|
8944
|
+
"7.8.0-pre.1";
|
|
8849
8945
|
}
|
|
8850
8946
|
} catch (e) {
|
|
8851
8947
|
}
|