react-router 0.0.0-experimental-01a3132e6 → 0.0.0-experimental-e41ede670
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 +0 -10
- package/dist/development/{chunk-IMLGQ7TF.mjs → chunk-H3OBLXFX.mjs} +558 -300
- package/dist/development/dom-export.d.mts +13 -3
- package/dist/development/dom-export.d.ts +13 -3
- package/dist/development/dom-export.js +205 -38
- package/dist/development/dom-export.mjs +9 -6
- package/dist/{production/fog-of-war-CcF9dOvO.d.ts → development/fog-of-war-Bt7PejVF.d.ts} +87 -8
- package/dist/development/{fog-of-war-D5Q4Ix4U.d.mts → fog-of-war-Dz4n-TU-.d.mts} +87 -8
- package/dist/development/index.d.mts +10 -11
- package/dist/development/index.d.ts +10 -11
- package/dist/development/index.js +558 -300
- package/dist/development/index.mjs +2 -2
- package/dist/development/lib/types/route-module.d.mts +6 -2
- package/dist/development/lib/types/route-module.d.ts +6 -2
- package/dist/development/lib/types/route-module.js +1 -1
- package/dist/development/lib/types/route-module.mjs +1 -1
- package/dist/development/{route-data-JFOfNyPS.d.ts → route-data-C96IyGKo.d.mts} +37 -15
- package/dist/{production/route-data-JFOfNyPS.d.mts → development/route-data-C96IyGKo.d.ts} +37 -15
- package/dist/production/{chunk-3NLLFLDL.mjs → chunk-YBZNESR7.mjs} +558 -300
- package/dist/production/dom-export.d.mts +13 -3
- package/dist/production/dom-export.d.ts +13 -3
- package/dist/production/dom-export.js +205 -38
- package/dist/production/dom-export.mjs +9 -6
- package/dist/{development/fog-of-war-CcF9dOvO.d.ts → production/fog-of-war-Bt7PejVF.d.ts} +87 -8
- package/dist/production/{fog-of-war-D5Q4Ix4U.d.mts → fog-of-war-Dz4n-TU-.d.mts} +87 -8
- package/dist/production/index.d.mts +10 -11
- package/dist/production/index.d.ts +10 -11
- package/dist/production/index.js +558 -300
- package/dist/production/index.mjs +2 -2
- package/dist/production/lib/types/route-module.d.mts +6 -2
- package/dist/production/lib/types/route-module.d.ts +6 -2
- package/dist/production/lib/types/route-module.js +1 -1
- package/dist/production/lib/types/route-module.mjs +1 -1
- package/dist/production/{route-data-JFOfNyPS.d.ts → route-data-C96IyGKo.d.mts} +37 -15
- package/dist/{development/route-data-JFOfNyPS.d.mts → production/route-data-C96IyGKo.d.ts} +37 -15
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* react-router v0.0.0-experimental-
|
|
2
|
+
* react-router v0.0.0-experimental-e41ede670
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -812,7 +812,10 @@ var redirect = (url, init = 302) => {
|
|
|
812
812
|
}
|
|
813
813
|
let headers = new Headers(responseInit.headers);
|
|
814
814
|
headers.set("Location", url);
|
|
815
|
-
return new Response(null, {
|
|
815
|
+
return new Response(null, {
|
|
816
|
+
...responseInit,
|
|
817
|
+
headers
|
|
818
|
+
});
|
|
816
819
|
};
|
|
817
820
|
var redirectDocument = (url, init) => {
|
|
818
821
|
let response = redirect(url, init);
|
|
@@ -907,6 +910,7 @@ function createRouter(init) {
|
|
|
907
910
|
);
|
|
908
911
|
let inFlightDataRoutes;
|
|
909
912
|
let basename = init.basename || "/";
|
|
913
|
+
let routerContext = typeof init.context !== "undefined" ? init.context : {};
|
|
910
914
|
let dataStrategyImpl = init.dataStrategy || defaultDataStrategy;
|
|
911
915
|
let patchRoutesOnNavigationImpl = init.patchRoutesOnNavigation;
|
|
912
916
|
let future = {
|
|
@@ -1095,11 +1099,6 @@ function createRouter(init) {
|
|
|
1095
1099
|
}
|
|
1096
1100
|
}
|
|
1097
1101
|
});
|
|
1098
|
-
fetchersQueuedForDeletion.forEach((key) => {
|
|
1099
|
-
if (!state.fetchers.has(key) && !fetchControllers.has(key)) {
|
|
1100
|
-
unmountedFetchers.push(key);
|
|
1101
|
-
}
|
|
1102
|
-
});
|
|
1103
1102
|
[...subscribers].forEach(
|
|
1104
1103
|
(subscriber) => subscriber(state, {
|
|
1105
1104
|
deletedFetchers: unmountedFetchers,
|
|
@@ -1482,6 +1481,14 @@ function createRouter(init) {
|
|
|
1482
1481
|
null
|
|
1483
1482
|
);
|
|
1484
1483
|
result = results[actionMatch.route.id];
|
|
1484
|
+
if (!result) {
|
|
1485
|
+
for (let match of matches) {
|
|
1486
|
+
if (results[match.route.id]) {
|
|
1487
|
+
result = results[match.route.id];
|
|
1488
|
+
break;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1485
1492
|
if (request.signal.aborted) {
|
|
1486
1493
|
return { shortCircuited: true };
|
|
1487
1494
|
}
|
|
@@ -2143,13 +2150,13 @@ function createRouter(init) {
|
|
|
2143
2150
|
results = await callDataStrategyImpl(
|
|
2144
2151
|
dataStrategyImpl,
|
|
2145
2152
|
type,
|
|
2146
|
-
state2,
|
|
2147
2153
|
request,
|
|
2148
2154
|
matchesToLoad,
|
|
2149
2155
|
matches,
|
|
2150
2156
|
fetcherKey,
|
|
2151
2157
|
manifest,
|
|
2152
|
-
mapRouteProperties2
|
|
2158
|
+
mapRouteProperties2,
|
|
2159
|
+
routerContext
|
|
2153
2160
|
);
|
|
2154
2161
|
} catch (e) {
|
|
2155
2162
|
matchesToLoad.forEach((m) => {
|
|
@@ -2575,16 +2582,18 @@ function createStaticHandler(routes, opts) {
|
|
|
2575
2582
|
async function query(request, {
|
|
2576
2583
|
requestContext,
|
|
2577
2584
|
skipLoaderErrorBubbling,
|
|
2578
|
-
dataStrategy
|
|
2585
|
+
dataStrategy,
|
|
2586
|
+
respond
|
|
2579
2587
|
} = {}) {
|
|
2580
2588
|
let url = new URL(request.url);
|
|
2581
2589
|
let method = request.method;
|
|
2582
2590
|
let location = createLocation("", createPath(url), null, "default");
|
|
2583
2591
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
2592
|
+
let staticContext;
|
|
2584
2593
|
if (!isValidMethod(method) && method !== "HEAD") {
|
|
2585
2594
|
let error = getInternalRouterError(405, { method });
|
|
2586
2595
|
let { matches: methodNotAllowedMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2587
|
-
|
|
2596
|
+
staticContext = {
|
|
2588
2597
|
basename,
|
|
2589
2598
|
location,
|
|
2590
2599
|
matches: methodNotAllowedMatches,
|
|
@@ -2600,7 +2609,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2600
2609
|
} else if (!matches) {
|
|
2601
2610
|
let error = getInternalRouterError(404, { pathname: location.pathname });
|
|
2602
2611
|
let { matches: notFoundMatches, route } = getShortCircuitMatches(dataRoutes);
|
|
2603
|
-
|
|
2612
|
+
staticContext = {
|
|
2604
2613
|
basename,
|
|
2605
2614
|
location,
|
|
2606
2615
|
matches: notFoundMatches,
|
|
@@ -2613,25 +2622,76 @@ function createStaticHandler(routes, opts) {
|
|
|
2613
2622
|
loaderHeaders: {},
|
|
2614
2623
|
actionHeaders: {}
|
|
2615
2624
|
};
|
|
2625
|
+
} else if (respond) {
|
|
2626
|
+
try {
|
|
2627
|
+
let response = await runMiddlewarePipeline(
|
|
2628
|
+
{
|
|
2629
|
+
request,
|
|
2630
|
+
matches,
|
|
2631
|
+
params: matches[0].params,
|
|
2632
|
+
context: requestContext
|
|
2633
|
+
},
|
|
2634
|
+
matches.length - 1,
|
|
2635
|
+
true,
|
|
2636
|
+
async () => {
|
|
2637
|
+
let result = await callQueryHandlers(
|
|
2638
|
+
request,
|
|
2639
|
+
location,
|
|
2640
|
+
matches,
|
|
2641
|
+
requestContext,
|
|
2642
|
+
dataStrategy || defaultDataStrategyWithoutMiddleware,
|
|
2643
|
+
skipLoaderErrorBubbling === true,
|
|
2644
|
+
null
|
|
2645
|
+
);
|
|
2646
|
+
if (isResponse(result)) {
|
|
2647
|
+
return result;
|
|
2648
|
+
}
|
|
2649
|
+
let res = await respond({
|
|
2650
|
+
location,
|
|
2651
|
+
basename,
|
|
2652
|
+
...result
|
|
2653
|
+
});
|
|
2654
|
+
return res;
|
|
2655
|
+
}
|
|
2656
|
+
);
|
|
2657
|
+
invariant(isResponse(response), "Expected a response in query()");
|
|
2658
|
+
return response;
|
|
2659
|
+
} catch (e) {
|
|
2660
|
+
if (isResponse(e)) {
|
|
2661
|
+
return e;
|
|
2662
|
+
}
|
|
2663
|
+
throw e;
|
|
2664
|
+
}
|
|
2665
|
+
} else {
|
|
2666
|
+
let result = await callQueryHandlers(
|
|
2667
|
+
request,
|
|
2668
|
+
location,
|
|
2669
|
+
matches,
|
|
2670
|
+
requestContext,
|
|
2671
|
+
dataStrategy || null,
|
|
2672
|
+
skipLoaderErrorBubbling === true,
|
|
2673
|
+
null
|
|
2674
|
+
);
|
|
2675
|
+
if (isResponse(result)) {
|
|
2676
|
+
return result;
|
|
2677
|
+
}
|
|
2678
|
+
staticContext = {
|
|
2679
|
+
location,
|
|
2680
|
+
basename,
|
|
2681
|
+
...result
|
|
2682
|
+
};
|
|
2616
2683
|
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
matches,
|
|
2621
|
-
requestContext,
|
|
2622
|
-
dataStrategy || null,
|
|
2623
|
-
skipLoaderErrorBubbling === true,
|
|
2624
|
-
null
|
|
2625
|
-
);
|
|
2626
|
-
if (isResponse(result)) {
|
|
2627
|
-
return result;
|
|
2684
|
+
if (respond) {
|
|
2685
|
+
let res = await respond(staticContext);
|
|
2686
|
+
return res;
|
|
2628
2687
|
}
|
|
2629
|
-
return
|
|
2688
|
+
return staticContext;
|
|
2630
2689
|
}
|
|
2631
2690
|
async function queryRoute(request, {
|
|
2632
2691
|
routeId,
|
|
2633
2692
|
requestContext,
|
|
2634
|
-
dataStrategy
|
|
2693
|
+
dataStrategy,
|
|
2694
|
+
respond
|
|
2635
2695
|
} = {}) {
|
|
2636
2696
|
let url = new URL(request.url);
|
|
2637
2697
|
let method = request.method;
|
|
@@ -2651,31 +2711,64 @@ function createStaticHandler(routes, opts) {
|
|
|
2651
2711
|
} else if (!match) {
|
|
2652
2712
|
throw getInternalRouterError(404, { pathname: location.pathname });
|
|
2653
2713
|
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2714
|
+
if (respond) {
|
|
2715
|
+
let response = await runMiddlewarePipeline(
|
|
2716
|
+
{
|
|
2717
|
+
request,
|
|
2718
|
+
matches,
|
|
2719
|
+
params: matches[0].params,
|
|
2720
|
+
context: requestContext
|
|
2721
|
+
},
|
|
2722
|
+
matches.length - 1,
|
|
2723
|
+
true,
|
|
2724
|
+
async () => {
|
|
2725
|
+
let result = await callQueryHandlers(
|
|
2726
|
+
request,
|
|
2727
|
+
location,
|
|
2728
|
+
matches,
|
|
2729
|
+
requestContext,
|
|
2730
|
+
dataStrategy || defaultDataStrategyWithoutMiddleware,
|
|
2731
|
+
false,
|
|
2732
|
+
match
|
|
2733
|
+
);
|
|
2734
|
+
if (isResponse(result)) {
|
|
2735
|
+
return result;
|
|
2736
|
+
}
|
|
2737
|
+
let error = result.errors ? Object.values(result.errors)[0] : void 0;
|
|
2738
|
+
if (error !== void 0) {
|
|
2739
|
+
throw error;
|
|
2740
|
+
}
|
|
2741
|
+
throw new Error("Expected a response from queryRoute");
|
|
2742
|
+
}
|
|
2743
|
+
);
|
|
2744
|
+
return response;
|
|
2745
|
+
} else {
|
|
2746
|
+
let result = await callQueryHandlers(
|
|
2747
|
+
request,
|
|
2748
|
+
location,
|
|
2749
|
+
matches,
|
|
2750
|
+
requestContext,
|
|
2751
|
+
dataStrategy || null,
|
|
2752
|
+
false,
|
|
2753
|
+
match
|
|
2754
|
+
);
|
|
2755
|
+
if (isResponse(result)) {
|
|
2756
|
+
return result;
|
|
2757
|
+
}
|
|
2758
|
+
let error = result.errors ? Object.values(result.errors)[0] : void 0;
|
|
2759
|
+
if (error !== void 0) {
|
|
2760
|
+
throw error;
|
|
2761
|
+
}
|
|
2762
|
+
if (result.actionData) {
|
|
2763
|
+
return Object.values(result.actionData)[0];
|
|
2764
|
+
}
|
|
2765
|
+
if (result.loaderData) {
|
|
2766
|
+
return Object.values(result.loaderData)[0];
|
|
2767
|
+
}
|
|
2768
|
+
return void 0;
|
|
2675
2769
|
}
|
|
2676
|
-
return void 0;
|
|
2677
2770
|
}
|
|
2678
|
-
async function
|
|
2771
|
+
async function callQueryHandlers(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch) {
|
|
2679
2772
|
invariant(
|
|
2680
2773
|
request.signal,
|
|
2681
2774
|
"query()/queryRoute() requests must contain an AbortController signal"
|
|
@@ -2780,7 +2873,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2780
2873
|
});
|
|
2781
2874
|
if (isErrorResult(result)) {
|
|
2782
2875
|
let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id);
|
|
2783
|
-
let
|
|
2876
|
+
let handlerContext2 = await loadRouteData(
|
|
2784
2877
|
loaderRequest,
|
|
2785
2878
|
matches,
|
|
2786
2879
|
requestContext,
|
|
@@ -2790,7 +2883,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2790
2883
|
[boundaryMatch.route.id, result]
|
|
2791
2884
|
);
|
|
2792
2885
|
return {
|
|
2793
|
-
...
|
|
2886
|
+
...handlerContext2,
|
|
2794
2887
|
statusCode: isRouteErrorResponse(result.error) ? result.error.status : result.statusCode != null ? result.statusCode : 500,
|
|
2795
2888
|
actionData: null,
|
|
2796
2889
|
actionHeaders: {
|
|
@@ -2798,7 +2891,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2798
2891
|
}
|
|
2799
2892
|
};
|
|
2800
2893
|
}
|
|
2801
|
-
let
|
|
2894
|
+
let handlerContext = await loadRouteData(
|
|
2802
2895
|
loaderRequest,
|
|
2803
2896
|
matches,
|
|
2804
2897
|
requestContext,
|
|
@@ -2807,7 +2900,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2807
2900
|
null
|
|
2808
2901
|
);
|
|
2809
2902
|
return {
|
|
2810
|
-
...
|
|
2903
|
+
...handlerContext,
|
|
2811
2904
|
actionData: {
|
|
2812
2905
|
[actionMatch.route.id]: result.data
|
|
2813
2906
|
},
|
|
@@ -2856,7 +2949,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2856
2949
|
if (request.signal.aborted) {
|
|
2857
2950
|
throwStaticHandlerAbortedError(request, isRouteRequest);
|
|
2858
2951
|
}
|
|
2859
|
-
let
|
|
2952
|
+
let handlerContext = processRouteLoaderData(
|
|
2860
2953
|
matches,
|
|
2861
2954
|
results,
|
|
2862
2955
|
pendingActionResult,
|
|
@@ -2868,26 +2961,25 @@ function createStaticHandler(routes, opts) {
|
|
|
2868
2961
|
);
|
|
2869
2962
|
matches.forEach((match) => {
|
|
2870
2963
|
if (!executedLoaders.has(match.route.id)) {
|
|
2871
|
-
|
|
2964
|
+
handlerContext.loaderData[match.route.id] = null;
|
|
2872
2965
|
}
|
|
2873
2966
|
});
|
|
2874
2967
|
return {
|
|
2875
|
-
...
|
|
2968
|
+
...handlerContext,
|
|
2876
2969
|
matches
|
|
2877
2970
|
};
|
|
2878
2971
|
}
|
|
2879
|
-
async function callDataStrategy(type, request, matchesToLoad, matches, isRouteRequest,
|
|
2972
|
+
async function callDataStrategy(type, request, matchesToLoad, matches, isRouteRequest, routerContext, dataStrategy) {
|
|
2880
2973
|
let results = await callDataStrategyImpl(
|
|
2881
2974
|
dataStrategy || defaultDataStrategy,
|
|
2882
2975
|
type,
|
|
2883
|
-
null,
|
|
2884
2976
|
request,
|
|
2885
2977
|
matchesToLoad,
|
|
2886
2978
|
matches,
|
|
2887
2979
|
null,
|
|
2888
2980
|
manifest,
|
|
2889
2981
|
mapRouteProperties2,
|
|
2890
|
-
|
|
2982
|
+
routerContext
|
|
2891
2983
|
);
|
|
2892
2984
|
let dataResults = {};
|
|
2893
2985
|
await Promise.all(
|
|
@@ -2920,15 +3012,14 @@ function createStaticHandler(routes, opts) {
|
|
|
2920
3012
|
queryRoute
|
|
2921
3013
|
};
|
|
2922
3014
|
}
|
|
2923
|
-
function getStaticContextFromError(routes,
|
|
2924
|
-
|
|
2925
|
-
...
|
|
3015
|
+
function getStaticContextFromError(routes, handlerContext, error) {
|
|
3016
|
+
return {
|
|
3017
|
+
...handlerContext,
|
|
2926
3018
|
statusCode: isRouteErrorResponse(error) ? error.status : 500,
|
|
2927
3019
|
errors: {
|
|
2928
|
-
[
|
|
3020
|
+
[handlerContext._deepestRenderedBoundaryId || routes[0].id]: error
|
|
2929
3021
|
}
|
|
2930
3022
|
};
|
|
2931
|
-
return newContext;
|
|
2932
3023
|
}
|
|
2933
3024
|
function throwStaticHandlerAbortedError(request, isRouteRequest) {
|
|
2934
3025
|
if (request.signal.reason !== void 0) {
|
|
@@ -3321,20 +3412,133 @@ async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
|
|
|
3321
3412
|
lazy: void 0
|
|
3322
3413
|
});
|
|
3323
3414
|
}
|
|
3324
|
-
async function
|
|
3325
|
-
matches
|
|
3326
|
-
|
|
3327
|
-
let matchesToLoad = matches.filter((m) => m.shouldLoad);
|
|
3415
|
+
async function defaultDataStrategyWithoutMiddleware(args) {
|
|
3416
|
+
let matchesToLoad = args.matches.filter((m) => m.shouldLoad);
|
|
3417
|
+
let keyedResults = {};
|
|
3328
3418
|
let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3419
|
+
results.forEach((result, i) => {
|
|
3420
|
+
keyedResults[matchesToLoad[i].route.id] = result;
|
|
3421
|
+
});
|
|
3422
|
+
return keyedResults;
|
|
3423
|
+
}
|
|
3424
|
+
async function defaultDataStrategy(args) {
|
|
3425
|
+
let matchesToLoad = args.matches.filter((m) => m.shouldLoad);
|
|
3426
|
+
let lastIndex = args.matches.length - 1;
|
|
3427
|
+
for (let i = lastIndex; i >= 0; i--) {
|
|
3428
|
+
if (args.matches[i].shouldLoad) {
|
|
3429
|
+
lastIndex = i;
|
|
3430
|
+
break;
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
let results = await runMiddlewarePipeline(
|
|
3434
|
+
args,
|
|
3435
|
+
lastIndex,
|
|
3436
|
+
false,
|
|
3437
|
+
async (keyedResults) => {
|
|
3438
|
+
let results2 = await Promise.all(matchesToLoad.map((m) => m.resolve()));
|
|
3439
|
+
results2.forEach((result, i) => {
|
|
3440
|
+
keyedResults[matchesToLoad[i].route.id] = result;
|
|
3441
|
+
});
|
|
3442
|
+
}
|
|
3332
3443
|
);
|
|
3444
|
+
return results;
|
|
3445
|
+
}
|
|
3446
|
+
async function runMiddlewarePipeline({
|
|
3447
|
+
request,
|
|
3448
|
+
params,
|
|
3449
|
+
context,
|
|
3450
|
+
matches
|
|
3451
|
+
}, lastIndex, propagateResult, handler) {
|
|
3452
|
+
let keyedResults = {};
|
|
3453
|
+
try {
|
|
3454
|
+
let result = await callRouteMiddleware(
|
|
3455
|
+
matches.slice(0, lastIndex + 1).flatMap(
|
|
3456
|
+
(m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
|
|
3457
|
+
),
|
|
3458
|
+
0,
|
|
3459
|
+
{ request, params, context },
|
|
3460
|
+
keyedResults,
|
|
3461
|
+
propagateResult,
|
|
3462
|
+
handler
|
|
3463
|
+
);
|
|
3464
|
+
return propagateResult ? result : keyedResults;
|
|
3465
|
+
} catch (e) {
|
|
3466
|
+
if (!(e instanceof MiddlewareError)) {
|
|
3467
|
+
throw e;
|
|
3468
|
+
}
|
|
3469
|
+
if (propagateResult && isResponse(e.error)) {
|
|
3470
|
+
throw e.error;
|
|
3471
|
+
}
|
|
3472
|
+
return {
|
|
3473
|
+
...keyedResults,
|
|
3474
|
+
[e.routeId]: { type: "error", result: e.error }
|
|
3475
|
+
};
|
|
3476
|
+
}
|
|
3333
3477
|
}
|
|
3334
|
-
|
|
3478
|
+
var MiddlewareError = class {
|
|
3479
|
+
constructor(routeId, error) {
|
|
3480
|
+
this.routeId = routeId;
|
|
3481
|
+
this.error = error;
|
|
3482
|
+
}
|
|
3483
|
+
};
|
|
3484
|
+
async function callRouteMiddleware(middlewares, idx, args, keyedResults, propagateResult, handler) {
|
|
3485
|
+
let { request } = args;
|
|
3486
|
+
if (request.signal.aborted) {
|
|
3487
|
+
if (request.signal.reason) {
|
|
3488
|
+
throw request.signal.reason;
|
|
3489
|
+
}
|
|
3490
|
+
throw new Error(
|
|
3491
|
+
`Request aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
|
|
3492
|
+
);
|
|
3493
|
+
}
|
|
3494
|
+
let tuple = middlewares[idx];
|
|
3495
|
+
if (!tuple) {
|
|
3496
|
+
let result = await handler(keyedResults);
|
|
3497
|
+
return result;
|
|
3498
|
+
}
|
|
3499
|
+
let [routeId, middleware] = tuple;
|
|
3500
|
+
let nextCalled = false;
|
|
3501
|
+
let next = async () => {
|
|
3502
|
+
if (nextCalled) {
|
|
3503
|
+
throw new Error("You may only call `next()` once per middleware");
|
|
3504
|
+
}
|
|
3505
|
+
nextCalled = true;
|
|
3506
|
+
let result = await callRouteMiddleware(
|
|
3507
|
+
middlewares,
|
|
3508
|
+
idx + 1,
|
|
3509
|
+
args,
|
|
3510
|
+
keyedResults,
|
|
3511
|
+
propagateResult,
|
|
3512
|
+
handler
|
|
3513
|
+
);
|
|
3514
|
+
return propagateResult ? result : void 0;
|
|
3515
|
+
};
|
|
3516
|
+
try {
|
|
3517
|
+
let result = await middleware(args, next);
|
|
3518
|
+
if (!nextCalled) {
|
|
3519
|
+
result = await next();
|
|
3520
|
+
}
|
|
3521
|
+
return result;
|
|
3522
|
+
} catch (e) {
|
|
3523
|
+
if (e instanceof MiddlewareError) {
|
|
3524
|
+
throw e;
|
|
3525
|
+
}
|
|
3526
|
+
throw new MiddlewareError(routeId, e);
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, fetcherKey, manifest, mapRouteProperties2, routerContext) {
|
|
3335
3530
|
let loadRouteDefinitionsPromises = matches.map(
|
|
3336
3531
|
(m) => m.route.lazy ? loadLazyRouteModule(m.route, mapRouteProperties2, manifest) : void 0
|
|
3337
3532
|
);
|
|
3533
|
+
let lazyMiddlewarePromises = matches.map(
|
|
3534
|
+
(m, i) => m.route.lazy && !("middleware" in m.route) ? (
|
|
3535
|
+
// Swallow the error here, let it bubble up from resolve()
|
|
3536
|
+
loadRouteDefinitionsPromises[i].catch((e) => e)
|
|
3537
|
+
) : null
|
|
3538
|
+
).filter((p) => p != null);
|
|
3539
|
+
if (lazyMiddlewarePromises.length > 0) {
|
|
3540
|
+
await Promise.all(lazyMiddlewarePromises);
|
|
3541
|
+
}
|
|
3338
3542
|
let dsMatches = matches.map((match, i) => {
|
|
3339
3543
|
let loadRoutePromise = loadRouteDefinitionsPromises[i];
|
|
3340
3544
|
let shouldLoad = matchesToLoad.some((m) => m.route.id === match.route.id);
|
|
@@ -3348,7 +3552,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matc
|
|
|
3348
3552
|
match,
|
|
3349
3553
|
loadRoutePromise,
|
|
3350
3554
|
handlerOverride,
|
|
3351
|
-
|
|
3555
|
+
routerContext
|
|
3352
3556
|
) : Promise.resolve({ type: "data" /* data */, result: void 0 });
|
|
3353
3557
|
};
|
|
3354
3558
|
return {
|
|
@@ -3362,7 +3566,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matc
|
|
|
3362
3566
|
request,
|
|
3363
3567
|
params: matches[0].params,
|
|
3364
3568
|
fetcherKey,
|
|
3365
|
-
context:
|
|
3569
|
+
context: routerContext
|
|
3366
3570
|
});
|
|
3367
3571
|
try {
|
|
3368
3572
|
await Promise.all(loadRouteDefinitionsPromises);
|
|
@@ -3370,7 +3574,7 @@ async function callDataStrategyImpl(dataStrategyImpl, type, state, request, matc
|
|
|
3370
3574
|
}
|
|
3371
3575
|
return results;
|
|
3372
3576
|
}
|
|
3373
|
-
async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride,
|
|
3577
|
+
async function callLoaderOrAction(type, request, match, loadRoutePromise, handlerOverride, routerContext) {
|
|
3374
3578
|
let result;
|
|
3375
3579
|
let onReject;
|
|
3376
3580
|
let runHandler = (handler) => {
|
|
@@ -3390,7 +3594,7 @@ async function callLoaderOrAction(type, request, match, loadRoutePromise, handle
|
|
|
3390
3594
|
{
|
|
3391
3595
|
request,
|
|
3392
3596
|
params: match.params,
|
|
3393
|
-
context:
|
|
3597
|
+
context: routerContext
|
|
3394
3598
|
},
|
|
3395
3599
|
...ctx !== void 0 ? [ctx] : []
|
|
3396
3600
|
);
|
|
@@ -4697,6 +4901,7 @@ function mapRouteProperties(route) {
|
|
|
4697
4901
|
function createMemoryRouter(routes, opts) {
|
|
4698
4902
|
return createRouter({
|
|
4699
4903
|
basename: opts?.basename,
|
|
4904
|
+
context: opts?.context,
|
|
4700
4905
|
future: opts?.future,
|
|
4701
4906
|
history: createMemoryHistory({
|
|
4702
4907
|
initialEntries: opts?.initialEntries,
|
|
@@ -4743,12 +4948,12 @@ function RouterProvider({
|
|
|
4743
4948
|
let fetcherData = React3.useRef(/* @__PURE__ */ new Map());
|
|
4744
4949
|
let setState = React3.useCallback(
|
|
4745
4950
|
(newState, { deletedFetchers, flushSync, viewTransitionOpts }) => {
|
|
4951
|
+
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
4746
4952
|
newState.fetchers.forEach((fetcher, key) => {
|
|
4747
4953
|
if (fetcher.data !== void 0) {
|
|
4748
4954
|
fetcherData.current.set(key, fetcher.data);
|
|
4749
4955
|
}
|
|
4750
4956
|
});
|
|
4751
|
-
deletedFetchers.forEach((key) => fetcherData.current.delete(key));
|
|
4752
4957
|
warnOnce(
|
|
4753
4958
|
flushSync === false || reactDomFlushSyncImpl != null,
|
|
4754
4959
|
'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.'
|
|
@@ -5646,20 +5851,54 @@ function StreamTransfer({
|
|
|
5646
5851
|
}
|
|
5647
5852
|
}
|
|
5648
5853
|
function getSingleFetchDataStrategy(manifest, routeModules, getRouter) {
|
|
5649
|
-
return async (
|
|
5854
|
+
return async (args) => {
|
|
5855
|
+
let { request, matches, fetcherKey } = args;
|
|
5650
5856
|
if (request.method !== "GET") {
|
|
5651
|
-
return
|
|
5857
|
+
return runMiddlewarePipeline(
|
|
5858
|
+
args,
|
|
5859
|
+
matches.findIndex((m) => m.shouldLoad),
|
|
5860
|
+
false,
|
|
5861
|
+
async (keyedResults) => {
|
|
5862
|
+
let results = await singleFetchActionStrategy(request, matches);
|
|
5863
|
+
Object.assign(keyedResults, results);
|
|
5864
|
+
}
|
|
5865
|
+
);
|
|
5652
5866
|
}
|
|
5653
5867
|
if (fetcherKey) {
|
|
5654
|
-
return
|
|
5868
|
+
return runMiddlewarePipeline(
|
|
5869
|
+
args,
|
|
5870
|
+
matches.findIndex((m) => m.shouldLoad),
|
|
5871
|
+
false,
|
|
5872
|
+
async (keyedResults) => {
|
|
5873
|
+
let results = await singleFetchLoaderFetcherStrategy(
|
|
5874
|
+
request,
|
|
5875
|
+
matches
|
|
5876
|
+
);
|
|
5877
|
+
Object.assign(keyedResults, results);
|
|
5878
|
+
}
|
|
5879
|
+
);
|
|
5655
5880
|
}
|
|
5656
|
-
|
|
5881
|
+
let lowestLoadingIndex = getLowestLoadingIndex(
|
|
5657
5882
|
manifest,
|
|
5658
5883
|
routeModules,
|
|
5659
5884
|
getRouter(),
|
|
5660
|
-
request,
|
|
5661
5885
|
matches
|
|
5662
5886
|
);
|
|
5887
|
+
return runMiddlewarePipeline(
|
|
5888
|
+
args,
|
|
5889
|
+
lowestLoadingIndex,
|
|
5890
|
+
false,
|
|
5891
|
+
async (keyedResults) => {
|
|
5892
|
+
let results = await singleFetchLoaderNavigationStrategy(
|
|
5893
|
+
manifest,
|
|
5894
|
+
routeModules,
|
|
5895
|
+
getRouter(),
|
|
5896
|
+
request,
|
|
5897
|
+
matches
|
|
5898
|
+
);
|
|
5899
|
+
Object.assign(keyedResults, results);
|
|
5900
|
+
}
|
|
5901
|
+
);
|
|
5663
5902
|
};
|
|
5664
5903
|
}
|
|
5665
5904
|
async function singleFetchActionStrategy(request, matches) {
|
|
@@ -5689,6 +5928,20 @@ async function singleFetchActionStrategy(request, matches) {
|
|
|
5689
5928
|
}
|
|
5690
5929
|
};
|
|
5691
5930
|
}
|
|
5931
|
+
function isOptedOut(manifestRoute, routeModule, match, router) {
|
|
5932
|
+
return match.route.id in router.state.loaderData && manifestRoute && manifestRoute.hasLoader && routeModule && routeModule.shouldRevalidate;
|
|
5933
|
+
}
|
|
5934
|
+
function getLowestLoadingIndex(manifest, routeModules, router, matches) {
|
|
5935
|
+
let tailIdx = [...matches].reverse().findIndex(
|
|
5936
|
+
(m) => m.shouldLoad || !isOptedOut(
|
|
5937
|
+
manifest.routes[m.route.id],
|
|
5938
|
+
routeModules[m.route.id],
|
|
5939
|
+
m,
|
|
5940
|
+
router
|
|
5941
|
+
)
|
|
5942
|
+
);
|
|
5943
|
+
return tailIdx < 0 ? 0 : matches.length - 1 - tailIdx;
|
|
5944
|
+
}
|
|
5692
5945
|
async function singleFetchLoaderNavigationStrategy(manifest, routeModules, router, request, matches) {
|
|
5693
5946
|
let routesParams = /* @__PURE__ */ new Set();
|
|
5694
5947
|
let foundOptOutRoute = false;
|
|
@@ -5707,7 +5960,7 @@ async function singleFetchLoaderNavigationStrategy(manifest, routeModules, route
|
|
|
5707
5960
|
if (!router.state.initialized) {
|
|
5708
5961
|
return;
|
|
5709
5962
|
}
|
|
5710
|
-
if (
|
|
5963
|
+
if (isOptedOut(manifestRoute, routeModules[m.route.id], m, router)) {
|
|
5711
5964
|
foundOptOutRoute = true;
|
|
5712
5965
|
return;
|
|
5713
5966
|
}
|
|
@@ -5883,7 +6136,7 @@ function unwrapSingleFetchResult(result, routeId) {
|
|
|
5883
6136
|
if (result.replace) {
|
|
5884
6137
|
headers["X-Remix-Replace"] = "yes";
|
|
5885
6138
|
}
|
|
5886
|
-
|
|
6139
|
+
return redirect(result.redirect, { status: result.status, headers });
|
|
5887
6140
|
} else if ("data" in result) {
|
|
5888
6141
|
return result.data;
|
|
5889
6142
|
} else {
|
|
@@ -6099,8 +6352,8 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
|
|
|
6099
6352
|
// render, so just give it a no-op function so we can render down to the
|
|
6100
6353
|
// proper fallback
|
|
6101
6354
|
loader: route.hasLoader || route.hasClientLoader ? () => null : void 0
|
|
6102
|
-
// We don't need action/shouldRevalidate on these routes since
|
|
6103
|
-
// for a static render
|
|
6355
|
+
// We don't need middleware/action/shouldRevalidate on these routes since
|
|
6356
|
+
// they're for a static render
|
|
6104
6357
|
};
|
|
6105
6358
|
let children = createServerRoutes(
|
|
6106
6359
|
manifest,
|
|
@@ -6184,6 +6437,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6184
6437
|
Object.assign(dataRoute, {
|
|
6185
6438
|
...dataRoute,
|
|
6186
6439
|
...getRouteComponents(route, routeModule, isSpaMode),
|
|
6440
|
+
middleware: routeModule.clientMiddleware,
|
|
6187
6441
|
handle: routeModule.handle,
|
|
6188
6442
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6189
6443
|
routeModule,
|
|
@@ -6196,7 +6450,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6196
6450
|
let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
|
|
6197
6451
|
let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
|
|
6198
6452
|
let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
|
|
6199
|
-
dataRoute.loader = async ({ request, params }, singleFetch) => {
|
|
6453
|
+
dataRoute.loader = async ({ request, params, context }, singleFetch) => {
|
|
6200
6454
|
try {
|
|
6201
6455
|
let result = await prefetchStylesAndCallHandler(async () => {
|
|
6202
6456
|
invariant2(
|
|
@@ -6210,6 +6464,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6210
6464
|
return routeModule.clientLoader({
|
|
6211
6465
|
request,
|
|
6212
6466
|
params,
|
|
6467
|
+
context,
|
|
6213
6468
|
async serverLoader() {
|
|
6214
6469
|
preventInvalidServerHandlerCall("loader", route, isSpaMode);
|
|
6215
6470
|
if (isHydrationRequest) {
|
|
@@ -6234,7 +6489,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6234
6489
|
routeModule,
|
|
6235
6490
|
isSpaMode
|
|
6236
6491
|
);
|
|
6237
|
-
dataRoute.action = ({ request, params }, singleFetch) => {
|
|
6492
|
+
dataRoute.action = ({ request, params, context }, singleFetch) => {
|
|
6238
6493
|
return prefetchStylesAndCallHandler(async () => {
|
|
6239
6494
|
invariant2(
|
|
6240
6495
|
routeModule,
|
|
@@ -6249,6 +6504,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6249
6504
|
return routeModule.clientAction({
|
|
6250
6505
|
request,
|
|
6251
6506
|
params,
|
|
6507
|
+
context,
|
|
6252
6508
|
async serverAction() {
|
|
6253
6509
|
preventInvalidServerHandlerCall("action", route, isSpaMode);
|
|
6254
6510
|
return fetchServerAction(singleFetch);
|
|
@@ -6258,13 +6514,13 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6258
6514
|
};
|
|
6259
6515
|
} else {
|
|
6260
6516
|
if (!route.hasClientLoader) {
|
|
6261
|
-
dataRoute.loader = (
|
|
6517
|
+
dataRoute.loader = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
6262
6518
|
if (isSpaMode) return Promise.resolve(null);
|
|
6263
6519
|
return fetchServerLoader(singleFetch);
|
|
6264
6520
|
});
|
|
6265
6521
|
}
|
|
6266
6522
|
if (!route.hasClientAction) {
|
|
6267
|
-
dataRoute.action = (
|
|
6523
|
+
dataRoute.action = (_, singleFetch) => prefetchStylesAndCallHandler(() => {
|
|
6268
6524
|
if (isSpaMode) {
|
|
6269
6525
|
throw noActionDefinedError("clientAction", route.id);
|
|
6270
6526
|
}
|
|
@@ -6300,6 +6556,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, isSpaMode
|
|
|
6300
6556
|
return {
|
|
6301
6557
|
...lazyRoute.loader ? { loader: lazyRoute.loader } : {},
|
|
6302
6558
|
...lazyRoute.action ? { action: lazyRoute.action } : {},
|
|
6559
|
+
middleware: mod.clientMiddleware,
|
|
6303
6560
|
hasErrorBoundary: lazyRoute.hasErrorBoundary,
|
|
6304
6561
|
shouldRevalidate: getShouldRevalidateFunction(
|
|
6305
6562
|
lazyRoute,
|
|
@@ -6357,6 +6614,7 @@ async function loadRouteModuleWithBlockingLinks(route, routeModules) {
|
|
|
6357
6614
|
return {
|
|
6358
6615
|
Component: getRouteModuleComponent(routeModule),
|
|
6359
6616
|
ErrorBoundary: routeModule.ErrorBoundary,
|
|
6617
|
+
clientMiddleware: routeModule.clientMiddleware,
|
|
6360
6618
|
clientAction: routeModule.clientAction,
|
|
6361
6619
|
clientLoader: routeModule.clientLoader,
|
|
6362
6620
|
handle: routeModule.handle,
|
|
@@ -6982,13 +7240,14 @@ function mergeRefs(...refs) {
|
|
|
6982
7240
|
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
6983
7241
|
try {
|
|
6984
7242
|
if (isBrowser) {
|
|
6985
|
-
window.__reactRouterVersion = "0.0.0-experimental-
|
|
7243
|
+
window.__reactRouterVersion = "0.0.0-experimental-e41ede670";
|
|
6986
7244
|
}
|
|
6987
7245
|
} catch (e) {
|
|
6988
7246
|
}
|
|
6989
7247
|
function createBrowserRouter(routes, opts) {
|
|
6990
7248
|
return createRouter({
|
|
6991
7249
|
basename: opts?.basename,
|
|
7250
|
+
context: opts?.context,
|
|
6992
7251
|
future: opts?.future,
|
|
6993
7252
|
history: createBrowserHistory({ window: opts?.window }),
|
|
6994
7253
|
hydrationData: opts?.hydrationData || parseHydrationData(),
|
|
@@ -7002,6 +7261,7 @@ function createBrowserRouter(routes, opts) {
|
|
|
7002
7261
|
function createHashRouter(routes, opts) {
|
|
7003
7262
|
return createRouter({
|
|
7004
7263
|
basename: opts?.basename,
|
|
7264
|
+
context: opts?.context,
|
|
7005
7265
|
future: opts?.future,
|
|
7006
7266
|
history: createHashHistory({ window: opts?.window }),
|
|
7007
7267
|
hydrationData: opts?.hydrationData || parseHydrationData(),
|
|
@@ -8143,13 +8403,14 @@ function createRoutesStub(routes, context = {}) {
|
|
|
8143
8403
|
isSpaMode: false
|
|
8144
8404
|
};
|
|
8145
8405
|
let patched = processRoutes(
|
|
8146
|
-
// @ts-expect-error
|
|
8406
|
+
// @ts-expect-error `StubRouteObject` is stricter about `loader`/`action`
|
|
8407
|
+
// types compared to `AgnosticRouteObject`
|
|
8147
8408
|
convertRoutesToDataRoutes(routes, (r) => r),
|
|
8148
|
-
context,
|
|
8149
8409
|
remixContextRef.current.manifest,
|
|
8150
8410
|
remixContextRef.current.routeModules
|
|
8151
8411
|
);
|
|
8152
8412
|
routerRef.current = createMemoryRouter(patched, {
|
|
8413
|
+
context,
|
|
8153
8414
|
initialEntries,
|
|
8154
8415
|
initialIndex,
|
|
8155
8416
|
hydrationData
|
|
@@ -8158,14 +8419,13 @@ function createRoutesStub(routes, context = {}) {
|
|
|
8158
8419
|
return /* @__PURE__ */ React13.createElement(FrameworkContext.Provider, { value: remixContextRef.current }, /* @__PURE__ */ React13.createElement(RouterProvider, { router: routerRef.current }));
|
|
8159
8420
|
};
|
|
8160
8421
|
}
|
|
8161
|
-
function processRoutes(routes,
|
|
8422
|
+
function processRoutes(routes, manifest, routeModules, parentId) {
|
|
8162
8423
|
return routes.map((route) => {
|
|
8163
8424
|
if (!route.id) {
|
|
8164
8425
|
throw new Error(
|
|
8165
8426
|
"Expected a route.id in @remix-run/testing processRoutes() function"
|
|
8166
8427
|
);
|
|
8167
8428
|
}
|
|
8168
|
-
let { loader, action } = route;
|
|
8169
8429
|
let newRoute = {
|
|
8170
8430
|
id: route.id,
|
|
8171
8431
|
path: route.path,
|
|
@@ -8173,8 +8433,8 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
|
|
|
8173
8433
|
Component: route.Component,
|
|
8174
8434
|
HydrateFallback: route.HydrateFallback,
|
|
8175
8435
|
ErrorBoundary: route.ErrorBoundary,
|
|
8176
|
-
action: action
|
|
8177
|
-
loader: loader
|
|
8436
|
+
action: route.action,
|
|
8437
|
+
loader: route.loader,
|
|
8178
8438
|
handle: route.handle,
|
|
8179
8439
|
shouldRevalidate: route.shouldRevalidate
|
|
8180
8440
|
};
|
|
@@ -8206,7 +8466,6 @@ function processRoutes(routes, context, manifest, routeModules, parentId) {
|
|
|
8206
8466
|
if (route.children) {
|
|
8207
8467
|
newRoute.children = processRoutes(
|
|
8208
8468
|
route.children,
|
|
8209
|
-
context,
|
|
8210
8469
|
manifest,
|
|
8211
8470
|
routeModules,
|
|
8212
8471
|
newRoute.id
|
|
@@ -8567,6 +8826,7 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
|
|
|
8567
8826
|
hasErrorBoundary: route.id === "root" || route.module.ErrorBoundary != null,
|
|
8568
8827
|
id: route.id,
|
|
8569
8828
|
path: route.path,
|
|
8829
|
+
middleware: route.module.middleware,
|
|
8570
8830
|
// Need to use RR's version in the param typed here to permit the optional
|
|
8571
8831
|
// context even though we know it'll always be provided in remix
|
|
8572
8832
|
loader: route.module.loader ? async (args) => {
|
|
@@ -8710,24 +8970,6 @@ function prependCookies(parentHeaders, childHeaders) {
|
|
|
8710
8970
|
|
|
8711
8971
|
// lib/server-runtime/single-fetch.ts
|
|
8712
8972
|
var SINGLE_FETCH_REDIRECT_STATUS = 202;
|
|
8713
|
-
function getSingleFetchDataStrategy2({
|
|
8714
|
-
isActionDataRequest,
|
|
8715
|
-
loadRouteIds
|
|
8716
|
-
} = {}) {
|
|
8717
|
-
return async ({ request, matches }) => {
|
|
8718
|
-
if (isActionDataRequest && request.method === "GET") {
|
|
8719
|
-
return {};
|
|
8720
|
-
}
|
|
8721
|
-
let matchesToLoad = loadRouteIds ? matches.filter((m) => loadRouteIds.includes(m.route.id)) : matches;
|
|
8722
|
-
let results = await Promise.all(
|
|
8723
|
-
matchesToLoad.map((match) => match.resolve())
|
|
8724
|
-
);
|
|
8725
|
-
return results.reduce(
|
|
8726
|
-
(acc, result, i) => Object.assign(acc, { [matchesToLoad[i].route.id]: result }),
|
|
8727
|
-
{}
|
|
8728
|
-
);
|
|
8729
|
-
};
|
|
8730
|
-
}
|
|
8731
8973
|
async function singleFetchAction(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
8732
8974
|
try {
|
|
8733
8975
|
let handlerRequest = new Request(handlerUrl, {
|
|
@@ -8740,12 +8982,45 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
8740
8982
|
let result = await staticHandler.query(handlerRequest, {
|
|
8741
8983
|
requestContext: loadContext,
|
|
8742
8984
|
skipLoaderErrorBubbling: true,
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8985
|
+
async respond(context) {
|
|
8986
|
+
let headers = getDocumentHeaders(build, context);
|
|
8987
|
+
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
8988
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
8989
|
+
result: getSingleFetchRedirect(
|
|
8990
|
+
context.statusCode,
|
|
8991
|
+
headers,
|
|
8992
|
+
build.basename
|
|
8993
|
+
),
|
|
8994
|
+
headers,
|
|
8995
|
+
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
8996
|
+
});
|
|
8997
|
+
}
|
|
8998
|
+
if (context.errors) {
|
|
8999
|
+
Object.values(context.errors).forEach((err) => {
|
|
9000
|
+
if (!isRouteErrorResponse(err) || err.error) {
|
|
9001
|
+
handleError(err);
|
|
9002
|
+
}
|
|
9003
|
+
});
|
|
9004
|
+
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
9005
|
+
}
|
|
9006
|
+
let singleFetchResult;
|
|
9007
|
+
if (context.errors) {
|
|
9008
|
+
singleFetchResult = { error: Object.values(context.errors)[0] };
|
|
9009
|
+
} else {
|
|
9010
|
+
singleFetchResult = {
|
|
9011
|
+
data: Object.values(context.actionData || {})[0]
|
|
9012
|
+
};
|
|
9013
|
+
}
|
|
9014
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9015
|
+
result: singleFetchResult,
|
|
9016
|
+
headers,
|
|
9017
|
+
status: context.statusCode
|
|
9018
|
+
});
|
|
9019
|
+
}
|
|
8746
9020
|
});
|
|
8747
|
-
|
|
8748
|
-
|
|
9021
|
+
invariant3(isResponse(result), " Expected a Response from query()");
|
|
9022
|
+
if (isRedirectResponse(result)) {
|
|
9023
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
8749
9024
|
result: getSingleFetchRedirect(
|
|
8750
9025
|
result.status,
|
|
8751
9026
|
result.headers,
|
|
@@ -8753,47 +9028,16 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
|
|
|
8753
9028
|
),
|
|
8754
9029
|
headers: result.headers,
|
|
8755
9030
|
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
8756
|
-
};
|
|
8757
|
-
}
|
|
8758
|
-
let context = result;
|
|
8759
|
-
let headers = getDocumentHeaders(build, context);
|
|
8760
|
-
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
8761
|
-
return {
|
|
8762
|
-
result: getSingleFetchRedirect(
|
|
8763
|
-
context.statusCode,
|
|
8764
|
-
headers,
|
|
8765
|
-
build.basename
|
|
8766
|
-
),
|
|
8767
|
-
headers,
|
|
8768
|
-
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
8769
|
-
};
|
|
8770
|
-
}
|
|
8771
|
-
if (context.errors) {
|
|
8772
|
-
Object.values(context.errors).forEach((err) => {
|
|
8773
|
-
if (!isRouteErrorResponse(err) || err.error) {
|
|
8774
|
-
handleError(err);
|
|
8775
|
-
}
|
|
8776
9031
|
});
|
|
8777
|
-
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
8778
9032
|
}
|
|
8779
|
-
|
|
8780
|
-
if (context.errors) {
|
|
8781
|
-
singleFetchResult = { error: Object.values(context.errors)[0] };
|
|
8782
|
-
} else {
|
|
8783
|
-
singleFetchResult = { data: Object.values(context.actionData || {})[0] };
|
|
8784
|
-
}
|
|
8785
|
-
return {
|
|
8786
|
-
result: singleFetchResult,
|
|
8787
|
-
headers,
|
|
8788
|
-
status: context.statusCode
|
|
8789
|
-
};
|
|
9033
|
+
return result;
|
|
8790
9034
|
} catch (error) {
|
|
8791
9035
|
handleError(error);
|
|
8792
|
-
return {
|
|
9036
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
8793
9037
|
result: { error },
|
|
8794
9038
|
headers: new Headers(),
|
|
8795
9039
|
status: 500
|
|
8796
|
-
};
|
|
9040
|
+
});
|
|
8797
9041
|
}
|
|
8798
9042
|
}
|
|
8799
9043
|
async function singleFetchLoaders(build, serverMode, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
@@ -8806,12 +9050,51 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
|
|
|
8806
9050
|
let result = await staticHandler.query(handlerRequest, {
|
|
8807
9051
|
requestContext: loadContext,
|
|
8808
9052
|
skipLoaderErrorBubbling: true,
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
9053
|
+
async respond(context) {
|
|
9054
|
+
let headers = getDocumentHeaders(build, context);
|
|
9055
|
+
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
9056
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9057
|
+
result: {
|
|
9058
|
+
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(
|
|
9059
|
+
context.statusCode,
|
|
9060
|
+
headers,
|
|
9061
|
+
build.basename
|
|
9062
|
+
)
|
|
9063
|
+
},
|
|
9064
|
+
headers,
|
|
9065
|
+
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
9066
|
+
});
|
|
9067
|
+
}
|
|
9068
|
+
if (context.errors) {
|
|
9069
|
+
Object.values(context.errors).forEach((err) => {
|
|
9070
|
+
if (!isRouteErrorResponse(err) || err.error) {
|
|
9071
|
+
handleError(err);
|
|
9072
|
+
}
|
|
9073
|
+
});
|
|
9074
|
+
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
9075
|
+
}
|
|
9076
|
+
let results = {};
|
|
9077
|
+
let loadedMatches = loadRouteIds ? context.matches.filter(
|
|
9078
|
+
(m) => m.route.loader && loadRouteIds.includes(m.route.id)
|
|
9079
|
+
) : context.matches;
|
|
9080
|
+
loadedMatches.forEach((m) => {
|
|
9081
|
+
let { id } = m.route;
|
|
9082
|
+
if (context.errors && context.errors.hasOwnProperty(id)) {
|
|
9083
|
+
results[id] = { error: context.errors[id] };
|
|
9084
|
+
} else if (context.loaderData.hasOwnProperty(id)) {
|
|
9085
|
+
results[id] = { data: context.loaderData[id] };
|
|
9086
|
+
}
|
|
9087
|
+
});
|
|
9088
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
9089
|
+
result: results,
|
|
9090
|
+
headers,
|
|
9091
|
+
status: context.statusCode
|
|
9092
|
+
});
|
|
9093
|
+
}
|
|
8812
9094
|
});
|
|
8813
|
-
|
|
8814
|
-
|
|
9095
|
+
invariant3(isResponse(result), " Expected a Response from query()");
|
|
9096
|
+
if (isRedirectResponse(result)) {
|
|
9097
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
8815
9098
|
result: {
|
|
8816
9099
|
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(
|
|
8817
9100
|
result.status,
|
|
@@ -8821,57 +9104,42 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
|
|
|
8821
9104
|
},
|
|
8822
9105
|
headers: result.headers,
|
|
8823
9106
|
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
8824
|
-
};
|
|
8825
|
-
}
|
|
8826
|
-
let context = result;
|
|
8827
|
-
let headers = getDocumentHeaders(build, context);
|
|
8828
|
-
if (isRedirectStatusCode(context.statusCode) && headers.has("Location")) {
|
|
8829
|
-
return {
|
|
8830
|
-
result: {
|
|
8831
|
-
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(
|
|
8832
|
-
context.statusCode,
|
|
8833
|
-
headers,
|
|
8834
|
-
build.basename
|
|
8835
|
-
)
|
|
8836
|
-
},
|
|
8837
|
-
headers,
|
|
8838
|
-
status: SINGLE_FETCH_REDIRECT_STATUS
|
|
8839
|
-
};
|
|
8840
|
-
}
|
|
8841
|
-
if (context.errors) {
|
|
8842
|
-
Object.values(context.errors).forEach((err) => {
|
|
8843
|
-
if (!isRouteErrorResponse(err) || err.error) {
|
|
8844
|
-
handleError(err);
|
|
8845
|
-
}
|
|
8846
9107
|
});
|
|
8847
|
-
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
8848
9108
|
}
|
|
8849
|
-
|
|
8850
|
-
let loadedMatches = loadRouteIds ? context.matches.filter(
|
|
8851
|
-
(m) => m.route.loader && loadRouteIds.includes(m.route.id)
|
|
8852
|
-
) : context.matches;
|
|
8853
|
-
loadedMatches.forEach((m) => {
|
|
8854
|
-
let { id } = m.route;
|
|
8855
|
-
if (context.errors && context.errors.hasOwnProperty(id)) {
|
|
8856
|
-
results[id] = { error: context.errors[id] };
|
|
8857
|
-
} else if (context.loaderData.hasOwnProperty(id)) {
|
|
8858
|
-
results[id] = { data: context.loaderData[id] };
|
|
8859
|
-
}
|
|
8860
|
-
});
|
|
8861
|
-
return {
|
|
8862
|
-
result: results,
|
|
8863
|
-
headers,
|
|
8864
|
-
status: context.statusCode
|
|
8865
|
-
};
|
|
9109
|
+
return result;
|
|
8866
9110
|
} catch (error) {
|
|
8867
9111
|
handleError(error);
|
|
8868
|
-
return {
|
|
9112
|
+
return generateSingleFetchResponse(request, build, serverMode, {
|
|
8869
9113
|
result: { root: { error } },
|
|
8870
9114
|
headers: new Headers(),
|
|
8871
9115
|
status: 500
|
|
8872
|
-
};
|
|
9116
|
+
});
|
|
8873
9117
|
}
|
|
8874
9118
|
}
|
|
9119
|
+
function generateSingleFetchResponse(request, build, serverMode, {
|
|
9120
|
+
result,
|
|
9121
|
+
headers,
|
|
9122
|
+
status
|
|
9123
|
+
}) {
|
|
9124
|
+
let resultHeaders = new Headers(headers);
|
|
9125
|
+
resultHeaders.set("X-Remix-Response", "yes");
|
|
9126
|
+
if (status === 304) {
|
|
9127
|
+
return new Response(null, { status: 304, headers: resultHeaders });
|
|
9128
|
+
}
|
|
9129
|
+
resultHeaders.set("Content-Type", "text/x-script");
|
|
9130
|
+
return new Response(
|
|
9131
|
+
encodeViaTurboStream(
|
|
9132
|
+
result,
|
|
9133
|
+
request.signal,
|
|
9134
|
+
build.entry.module.streamTimeout,
|
|
9135
|
+
serverMode
|
|
9136
|
+
),
|
|
9137
|
+
{
|
|
9138
|
+
status: status || 200,
|
|
9139
|
+
headers: resultHeaders
|
|
9140
|
+
}
|
|
9141
|
+
);
|
|
9142
|
+
}
|
|
8875
9143
|
function getSingleFetchRedirect(status, headers, basename) {
|
|
8876
9144
|
let redirect2 = headers.get("Location");
|
|
8877
9145
|
if (basename) {
|
|
@@ -9112,7 +9380,7 @@ async function handleManifestRequest(build, routes, url) {
|
|
|
9112
9380
|
return new Response("Invalid Request", { status: 400 });
|
|
9113
9381
|
}
|
|
9114
9382
|
async function handleSingleFetchRequest(serverMode, build, staticHandler, request, handlerUrl, loadContext, handleError) {
|
|
9115
|
-
let
|
|
9383
|
+
let response = request.method !== "GET" ? await singleFetchAction(
|
|
9116
9384
|
build,
|
|
9117
9385
|
serverMode,
|
|
9118
9386
|
staticHandler,
|
|
@@ -9129,129 +9397,67 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
|
|
|
9129
9397
|
loadContext,
|
|
9130
9398
|
handleError
|
|
9131
9399
|
);
|
|
9132
|
-
|
|
9133
|
-
resultHeaders.set("X-Remix-Response", "yes");
|
|
9134
|
-
if (status === 304) {
|
|
9135
|
-
return new Response(null, { status: 304, headers: resultHeaders });
|
|
9136
|
-
}
|
|
9137
|
-
resultHeaders.set("Content-Type", "text/x-script");
|
|
9138
|
-
return new Response(
|
|
9139
|
-
encodeViaTurboStream(
|
|
9140
|
-
result,
|
|
9141
|
-
request.signal,
|
|
9142
|
-
build.entry.module.streamTimeout,
|
|
9143
|
-
serverMode
|
|
9144
|
-
),
|
|
9145
|
-
{
|
|
9146
|
-
status: status || 200,
|
|
9147
|
-
headers: resultHeaders
|
|
9148
|
-
}
|
|
9149
|
-
);
|
|
9400
|
+
return response;
|
|
9150
9401
|
}
|
|
9151
9402
|
async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, criticalCss) {
|
|
9152
|
-
let context;
|
|
9153
9403
|
try {
|
|
9154
|
-
|
|
9155
|
-
requestContext: loadContext
|
|
9404
|
+
let response = await staticHandler.query(request, {
|
|
9405
|
+
requestContext: loadContext,
|
|
9406
|
+
respond: renderHtml
|
|
9156
9407
|
});
|
|
9408
|
+
invariant3(
|
|
9409
|
+
isResponse(response),
|
|
9410
|
+
"Expected a Response to be returned from query"
|
|
9411
|
+
);
|
|
9412
|
+
return response;
|
|
9157
9413
|
} catch (error) {
|
|
9158
9414
|
handleError(error);
|
|
9159
9415
|
return new Response(null, { status: 500 });
|
|
9160
9416
|
}
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
if (context.errors) {
|
|
9169
|
-
Object.values(context.errors).forEach((err) => {
|
|
9170
|
-
if (!isRouteErrorResponse(err) || err.error) {
|
|
9171
|
-
handleError(err);
|
|
9172
|
-
}
|
|
9173
|
-
});
|
|
9174
|
-
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
9175
|
-
}
|
|
9176
|
-
let state = {
|
|
9177
|
-
loaderData: context.loaderData,
|
|
9178
|
-
actionData: context.actionData,
|
|
9179
|
-
errors: serializeErrors2(context.errors, serverMode)
|
|
9180
|
-
};
|
|
9181
|
-
let entryContext = {
|
|
9182
|
-
manifest: build.assets,
|
|
9183
|
-
routeModules: createEntryRouteModules(build.routes),
|
|
9184
|
-
staticHandlerContext: context,
|
|
9185
|
-
criticalCss,
|
|
9186
|
-
serverHandoffString: createServerHandoffString({
|
|
9187
|
-
basename: build.basename,
|
|
9188
|
-
criticalCss,
|
|
9189
|
-
future: build.future,
|
|
9190
|
-
isSpaMode: build.isSpaMode
|
|
9191
|
-
}),
|
|
9192
|
-
serverHandoffStream: encodeViaTurboStream(
|
|
9193
|
-
state,
|
|
9194
|
-
request.signal,
|
|
9195
|
-
build.entry.module.streamTimeout,
|
|
9196
|
-
serverMode
|
|
9197
|
-
),
|
|
9198
|
-
renderMeta: {},
|
|
9199
|
-
future: build.future,
|
|
9200
|
-
isSpaMode: build.isSpaMode,
|
|
9201
|
-
serializeError: (err) => serializeError(err, serverMode)
|
|
9202
|
-
};
|
|
9203
|
-
let handleDocumentRequestFunction = build.entry.module.default;
|
|
9204
|
-
try {
|
|
9205
|
-
return await handleDocumentRequestFunction(
|
|
9206
|
-
request,
|
|
9207
|
-
context.statusCode,
|
|
9208
|
-
headers,
|
|
9209
|
-
entryContext,
|
|
9210
|
-
loadContext
|
|
9211
|
-
);
|
|
9212
|
-
} catch (error) {
|
|
9213
|
-
handleError(error);
|
|
9214
|
-
let errorForSecondRender = error;
|
|
9215
|
-
if (isResponse(error)) {
|
|
9216
|
-
try {
|
|
9217
|
-
let data2 = await unwrapResponse(error);
|
|
9218
|
-
errorForSecondRender = new ErrorResponseImpl(
|
|
9219
|
-
error.status,
|
|
9220
|
-
error.statusText,
|
|
9221
|
-
data2
|
|
9222
|
-
);
|
|
9223
|
-
} catch (e) {
|
|
9224
|
-
}
|
|
9417
|
+
async function renderHtml(context) {
|
|
9418
|
+
if (isResponse(context)) {
|
|
9419
|
+
return context;
|
|
9420
|
+
}
|
|
9421
|
+
let headers = getDocumentHeaders(build, context);
|
|
9422
|
+
if (context.statusCode === 304) {
|
|
9423
|
+
return new Response(null, { status: 304, headers });
|
|
9225
9424
|
}
|
|
9226
|
-
context = getStaticContextFromError(
|
|
9227
|
-
staticHandler.dataRoutes,
|
|
9228
|
-
context,
|
|
9229
|
-
errorForSecondRender
|
|
9230
|
-
);
|
|
9231
9425
|
if (context.errors) {
|
|
9426
|
+
Object.values(context.errors).forEach((err) => {
|
|
9427
|
+
if (!isRouteErrorResponse(err) || err.error) {
|
|
9428
|
+
handleError(err);
|
|
9429
|
+
}
|
|
9430
|
+
});
|
|
9232
9431
|
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
9233
9432
|
}
|
|
9234
|
-
let
|
|
9433
|
+
let state = {
|
|
9235
9434
|
loaderData: context.loaderData,
|
|
9236
9435
|
actionData: context.actionData,
|
|
9237
9436
|
errors: serializeErrors2(context.errors, serverMode)
|
|
9238
9437
|
};
|
|
9239
|
-
entryContext = {
|
|
9240
|
-
|
|
9438
|
+
let entryContext = {
|
|
9439
|
+
manifest: build.assets,
|
|
9440
|
+
routeModules: createEntryRouteModules(build.routes),
|
|
9241
9441
|
staticHandlerContext: context,
|
|
9442
|
+
criticalCss,
|
|
9242
9443
|
serverHandoffString: createServerHandoffString({
|
|
9243
9444
|
basename: build.basename,
|
|
9445
|
+
criticalCss,
|
|
9244
9446
|
future: build.future,
|
|
9245
9447
|
isSpaMode: build.isSpaMode
|
|
9246
9448
|
}),
|
|
9247
9449
|
serverHandoffStream: encodeViaTurboStream(
|
|
9248
|
-
|
|
9450
|
+
state,
|
|
9249
9451
|
request.signal,
|
|
9250
9452
|
build.entry.module.streamTimeout,
|
|
9251
9453
|
serverMode
|
|
9252
9454
|
),
|
|
9253
|
-
renderMeta: {}
|
|
9455
|
+
renderMeta: {},
|
|
9456
|
+
future: build.future,
|
|
9457
|
+
isSpaMode: build.isSpaMode,
|
|
9458
|
+
serializeError: (err) => serializeError(err, serverMode)
|
|
9254
9459
|
};
|
|
9460
|
+
let handleDocumentRequestFunction = build.entry.module.default;
|
|
9255
9461
|
try {
|
|
9256
9462
|
return await handleDocumentRequestFunction(
|
|
9257
9463
|
request,
|
|
@@ -9260,9 +9466,61 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
|
|
|
9260
9466
|
entryContext,
|
|
9261
9467
|
loadContext
|
|
9262
9468
|
);
|
|
9263
|
-
} catch (
|
|
9264
|
-
handleError(
|
|
9265
|
-
|
|
9469
|
+
} catch (error) {
|
|
9470
|
+
handleError(error);
|
|
9471
|
+
let errorForSecondRender = error;
|
|
9472
|
+
if (isResponse(error)) {
|
|
9473
|
+
try {
|
|
9474
|
+
let data2 = await unwrapResponse(error);
|
|
9475
|
+
errorForSecondRender = new ErrorResponseImpl(
|
|
9476
|
+
error.status,
|
|
9477
|
+
error.statusText,
|
|
9478
|
+
data2
|
|
9479
|
+
);
|
|
9480
|
+
} catch (e) {
|
|
9481
|
+
}
|
|
9482
|
+
}
|
|
9483
|
+
context = getStaticContextFromError(
|
|
9484
|
+
staticHandler.dataRoutes,
|
|
9485
|
+
context,
|
|
9486
|
+
errorForSecondRender
|
|
9487
|
+
);
|
|
9488
|
+
if (context.errors) {
|
|
9489
|
+
context.errors = sanitizeErrors(context.errors, serverMode);
|
|
9490
|
+
}
|
|
9491
|
+
let state2 = {
|
|
9492
|
+
loaderData: context.loaderData,
|
|
9493
|
+
actionData: context.actionData,
|
|
9494
|
+
errors: serializeErrors2(context.errors, serverMode)
|
|
9495
|
+
};
|
|
9496
|
+
entryContext = {
|
|
9497
|
+
...entryContext,
|
|
9498
|
+
staticHandlerContext: context,
|
|
9499
|
+
serverHandoffString: createServerHandoffString({
|
|
9500
|
+
basename: build.basename,
|
|
9501
|
+
future: build.future,
|
|
9502
|
+
isSpaMode: build.isSpaMode
|
|
9503
|
+
}),
|
|
9504
|
+
serverHandoffStream: encodeViaTurboStream(
|
|
9505
|
+
state2,
|
|
9506
|
+
request.signal,
|
|
9507
|
+
build.entry.module.streamTimeout,
|
|
9508
|
+
serverMode
|
|
9509
|
+
),
|
|
9510
|
+
renderMeta: {}
|
|
9511
|
+
};
|
|
9512
|
+
try {
|
|
9513
|
+
return await handleDocumentRequestFunction(
|
|
9514
|
+
request,
|
|
9515
|
+
context.statusCode,
|
|
9516
|
+
headers,
|
|
9517
|
+
entryContext,
|
|
9518
|
+
loadContext
|
|
9519
|
+
);
|
|
9520
|
+
} catch (error2) {
|
|
9521
|
+
handleError(error2);
|
|
9522
|
+
return returnLastResortErrorResponse(error2, serverMode);
|
|
9523
|
+
}
|
|
9266
9524
|
}
|
|
9267
9525
|
}
|
|
9268
9526
|
}
|