@remix-run/router 1.16.0-pre.0 → 1.16.0
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 +3 -11
- package/dist/router.cjs.js +14 -56
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +0 -2
- package/dist/router.js +14 -56
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +14 -56
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/router.ts +8 -73
package/dist/router.d.ts
CHANGED
|
@@ -299,9 +299,7 @@ export interface StaticHandlerContext {
|
|
|
299
299
|
export interface StaticHandler {
|
|
300
300
|
dataRoutes: AgnosticDataRouteObject[];
|
|
301
301
|
query(request: Request, opts?: {
|
|
302
|
-
loadRouteIds?: string[];
|
|
303
302
|
requestContext?: unknown;
|
|
304
|
-
skipLoaders?: boolean;
|
|
305
303
|
skipLoaderErrorBubbling?: boolean;
|
|
306
304
|
unstable_dataStrategy?: DataStrategyFunction;
|
|
307
305
|
}): Promise<StaticHandlerContext | Response>;
|
package/dist/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.16.0
|
|
2
|
+
* @remix-run/router v1.16.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -2893,23 +2893,17 @@ function createStaticHandler(routes, opts) {
|
|
|
2893
2893
|
* propagate that out and return the raw Response so the HTTP server can
|
|
2894
2894
|
* return it directly.
|
|
2895
2895
|
*
|
|
2896
|
-
* - `opts.loadRouteIds` is an optional array of routeIds to run only a subset of
|
|
2897
|
-
* loaders during a query() call
|
|
2898
2896
|
* - `opts.requestContext` is an optional server context that will be passed
|
|
2899
2897
|
* to actions/loaders in the `context` parameter
|
|
2900
2898
|
* - `opts.skipLoaderErrorBubbling` is an optional parameter that will prevent
|
|
2901
2899
|
* the bubbling of errors which allows single-fetch-type implementations
|
|
2902
2900
|
* where the client will handle the bubbling and we may need to return data
|
|
2903
2901
|
* for the handling route
|
|
2904
|
-
* - `opts.skipLoaders` is an optional parameter that will prevent loaders
|
|
2905
|
-
* from running after an action
|
|
2906
2902
|
*/
|
|
2907
2903
|
async function query(request, _temp3) {
|
|
2908
2904
|
let {
|
|
2909
|
-
loadRouteIds,
|
|
2910
2905
|
requestContext,
|
|
2911
2906
|
skipLoaderErrorBubbling,
|
|
2912
|
-
skipLoaders,
|
|
2913
2907
|
unstable_dataStrategy
|
|
2914
2908
|
} = _temp3 === void 0 ? {} : _temp3;
|
|
2915
2909
|
let url = new URL(request.url);
|
|
@@ -2962,7 +2956,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2962
2956
|
activeDeferreds: null
|
|
2963
2957
|
};
|
|
2964
2958
|
}
|
|
2965
|
-
let result = await queryImpl(request, location, matches, requestContext, unstable_dataStrategy || null,
|
|
2959
|
+
let result = await queryImpl(request, location, matches, requestContext, unstable_dataStrategy || null, skipLoaderErrorBubbling === true, null);
|
|
2966
2960
|
if (isResponse(result)) {
|
|
2967
2961
|
return result;
|
|
2968
2962
|
}
|
|
@@ -3031,7 +3025,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3031
3025
|
pathname: location.pathname
|
|
3032
3026
|
});
|
|
3033
3027
|
}
|
|
3034
|
-
let result = await queryImpl(request, location, matches, requestContext, null,
|
|
3028
|
+
let result = await queryImpl(request, location, matches, requestContext, null, false, match);
|
|
3035
3029
|
if (isResponse(result)) {
|
|
3036
3030
|
return result;
|
|
3037
3031
|
}
|
|
@@ -3057,14 +3051,14 @@ function createStaticHandler(routes, opts) {
|
|
|
3057
3051
|
}
|
|
3058
3052
|
return undefined;
|
|
3059
3053
|
}
|
|
3060
|
-
async function queryImpl(request, location, matches, requestContext, unstable_dataStrategy,
|
|
3054
|
+
async function queryImpl(request, location, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch) {
|
|
3061
3055
|
invariant(request.signal, "query()/queryRoute() requests must contain an AbortController signal");
|
|
3062
3056
|
try {
|
|
3063
3057
|
if (isMutationMethod(request.method.toLowerCase())) {
|
|
3064
|
-
let result = await submit(request, matches, routeMatch || getTargetMatch(matches, location), requestContext, unstable_dataStrategy,
|
|
3058
|
+
let result = await submit(request, matches, routeMatch || getTargetMatch(matches, location), requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch != null);
|
|
3065
3059
|
return result;
|
|
3066
3060
|
}
|
|
3067
|
-
let result = await loadRouteData(request, matches, requestContext, unstable_dataStrategy,
|
|
3061
|
+
let result = await loadRouteData(request, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch);
|
|
3068
3062
|
return isResponse(result) ? result : _extends({}, result, {
|
|
3069
3063
|
actionData: null,
|
|
3070
3064
|
actionHeaders: {}
|
|
@@ -3087,7 +3081,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3087
3081
|
throw e;
|
|
3088
3082
|
}
|
|
3089
3083
|
}
|
|
3090
|
-
async function submit(request, matches, actionMatch, requestContext, unstable_dataStrategy,
|
|
3084
|
+
async function submit(request, matches, actionMatch, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, isRouteRequest) {
|
|
3091
3085
|
let result;
|
|
3092
3086
|
if (!actionMatch.route.action && !actionMatch.route.lazy) {
|
|
3093
3087
|
let error = getInternalRouterError(405, {
|
|
@@ -3164,50 +3158,17 @@ function createStaticHandler(routes, opts) {
|
|
|
3164
3158
|
// Store off the pending error - we use it to determine which loaders
|
|
3165
3159
|
// to call and will commit it when we complete the navigation
|
|
3166
3160
|
let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id);
|
|
3167
|
-
let
|
|
3168
|
-
let actionHeaders = _extends({}, result.headers ? {
|
|
3169
|
-
[actionMatch.route.id]: result.headers
|
|
3170
|
-
} : {});
|
|
3171
|
-
if (skipLoaders) {
|
|
3172
|
-
return {
|
|
3173
|
-
matches,
|
|
3174
|
-
loaderData: {},
|
|
3175
|
-
actionData: {},
|
|
3176
|
-
errors: {
|
|
3177
|
-
[boundaryMatch.route.id]: result.error
|
|
3178
|
-
},
|
|
3179
|
-
statusCode,
|
|
3180
|
-
loaderHeaders: {},
|
|
3181
|
-
actionHeaders,
|
|
3182
|
-
activeDeferreds: null
|
|
3183
|
-
};
|
|
3184
|
-
}
|
|
3185
|
-
let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, null, [boundaryMatch.route.id, result]);
|
|
3161
|
+
let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, null, [boundaryMatch.route.id, result]);
|
|
3186
3162
|
// action status codes take precedence over loader status codes
|
|
3187
3163
|
return _extends({}, context, {
|
|
3188
|
-
statusCode,
|
|
3164
|
+
statusCode: isRouteErrorResponse(result.error) ? result.error.status : result.statusCode != null ? result.statusCode : 500,
|
|
3189
3165
|
actionData: null,
|
|
3190
|
-
actionHeaders
|
|
3166
|
+
actionHeaders: _extends({}, result.headers ? {
|
|
3167
|
+
[actionMatch.route.id]: result.headers
|
|
3168
|
+
} : {})
|
|
3191
3169
|
});
|
|
3192
3170
|
}
|
|
3193
|
-
let
|
|
3194
|
-
[actionMatch.route.id]: result.headers
|
|
3195
|
-
} : {};
|
|
3196
|
-
if (skipLoaders) {
|
|
3197
|
-
return {
|
|
3198
|
-
matches,
|
|
3199
|
-
loaderData: {},
|
|
3200
|
-
actionData: {
|
|
3201
|
-
[actionMatch.route.id]: result.data
|
|
3202
|
-
},
|
|
3203
|
-
errors: null,
|
|
3204
|
-
statusCode: result.statusCode || 200,
|
|
3205
|
-
loaderHeaders: {},
|
|
3206
|
-
actionHeaders,
|
|
3207
|
-
activeDeferreds: null
|
|
3208
|
-
};
|
|
3209
|
-
}
|
|
3210
|
-
let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, loadRouteIds, skipLoaderErrorBubbling, null);
|
|
3171
|
+
let context = await loadRouteData(loaderRequest, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, null);
|
|
3211
3172
|
return _extends({}, context, {
|
|
3212
3173
|
actionData: {
|
|
3213
3174
|
[actionMatch.route.id]: result.data
|
|
@@ -3220,7 +3181,7 @@ function createStaticHandler(routes, opts) {
|
|
|
3220
3181
|
} : {}
|
|
3221
3182
|
});
|
|
3222
3183
|
}
|
|
3223
|
-
async function loadRouteData(request, matches, requestContext, unstable_dataStrategy,
|
|
3184
|
+
async function loadRouteData(request, matches, requestContext, unstable_dataStrategy, skipLoaderErrorBubbling, routeMatch, pendingActionResult) {
|
|
3224
3185
|
let isRouteRequest = routeMatch != null;
|
|
3225
3186
|
// Short circuit if we have no loaders to run (queryRoute())
|
|
3226
3187
|
if (isRouteRequest && !(routeMatch != null && routeMatch.route.loader) && !(routeMatch != null && routeMatch.route.lazy)) {
|
|
@@ -3232,9 +3193,6 @@ function createStaticHandler(routes, opts) {
|
|
|
3232
3193
|
}
|
|
3233
3194
|
let requestMatches = routeMatch ? [routeMatch] : pendingActionResult && isErrorResult(pendingActionResult[1]) ? getLoaderMatchesUntilBoundary(matches, pendingActionResult[0]) : matches;
|
|
3234
3195
|
let matchesToLoad = requestMatches.filter(m => m.route.loader || m.route.lazy);
|
|
3235
|
-
if (loadRouteIds) {
|
|
3236
|
-
matchesToLoad = matchesToLoad.filter(m => loadRouteIds.includes(m.route.id));
|
|
3237
|
-
}
|
|
3238
3196
|
// Short circuit if we have no loaders to run (query())
|
|
3239
3197
|
if (matchesToLoad.length === 0) {
|
|
3240
3198
|
return {
|