@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "1.16.0-pre.0",
3
+ "version": "1.16.0",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",
package/router.ts CHANGED
@@ -405,9 +405,7 @@ export interface StaticHandler {
405
405
  query(
406
406
  request: Request,
407
407
  opts?: {
408
- loadRouteIds?: string[];
409
408
  requestContext?: unknown;
410
- skipLoaders?: boolean;
411
409
  skipLoaderErrorBubbling?: boolean;
412
410
  unstable_dataStrategy?: DataStrategyFunction;
413
411
  }
@@ -2988,30 +2986,22 @@ export function createStaticHandler(
2988
2986
  * propagate that out and return the raw Response so the HTTP server can
2989
2987
  * return it directly.
2990
2988
  *
2991
- * - `opts.loadRouteIds` is an optional array of routeIds to run only a subset of
2992
- * loaders during a query() call
2993
2989
  * - `opts.requestContext` is an optional server context that will be passed
2994
2990
  * to actions/loaders in the `context` parameter
2995
2991
  * - `opts.skipLoaderErrorBubbling` is an optional parameter that will prevent
2996
2992
  * the bubbling of errors which allows single-fetch-type implementations
2997
2993
  * where the client will handle the bubbling and we may need to return data
2998
2994
  * for the handling route
2999
- * - `opts.skipLoaders` is an optional parameter that will prevent loaders
3000
- * from running after an action
3001
2995
  */
3002
2996
  async function query(
3003
2997
  request: Request,
3004
2998
  {
3005
- loadRouteIds,
3006
2999
  requestContext,
3007
3000
  skipLoaderErrorBubbling,
3008
- skipLoaders,
3009
3001
  unstable_dataStrategy,
3010
3002
  }: {
3011
- loadRouteIds?: string[];
3012
3003
  requestContext?: unknown;
3013
3004
  skipLoaderErrorBubbling?: boolean;
3014
- skipLoaders?: boolean;
3015
3005
  unstable_dataStrategy?: DataStrategyFunction;
3016
3006
  } = {}
3017
3007
  ): Promise<StaticHandlerContext | Response> {
@@ -3065,9 +3055,7 @@ export function createStaticHandler(
3065
3055
  matches,
3066
3056
  requestContext,
3067
3057
  unstable_dataStrategy || null,
3068
- loadRouteIds || null,
3069
3058
  skipLoaderErrorBubbling === true,
3070
- skipLoaders === true,
3071
3059
  null
3072
3060
  );
3073
3061
  if (isResponse(result)) {
@@ -3145,11 +3133,10 @@ export function createStaticHandler(
3145
3133
  matches,
3146
3134
  requestContext,
3147
3135
  null,
3148
- null,
3149
- false,
3150
3136
  false,
3151
3137
  match
3152
3138
  );
3139
+
3153
3140
  if (isResponse(result)) {
3154
3141
  return result;
3155
3142
  }
@@ -3185,9 +3172,7 @@ export function createStaticHandler(
3185
3172
  matches: AgnosticDataRouteMatch[],
3186
3173
  requestContext: unknown,
3187
3174
  unstable_dataStrategy: DataStrategyFunction | null,
3188
- loadRouteIds: string[] | null,
3189
3175
  skipLoaderErrorBubbling: boolean,
3190
- skipLoaders: boolean,
3191
3176
  routeMatch: AgnosticDataRouteMatch | null
3192
3177
  ): Promise<Omit<StaticHandlerContext, "location" | "basename"> | Response> {
3193
3178
  invariant(
@@ -3203,9 +3188,7 @@ export function createStaticHandler(
3203
3188
  routeMatch || getTargetMatch(matches, location),
3204
3189
  requestContext,
3205
3190
  unstable_dataStrategy,
3206
- loadRouteIds,
3207
3191
  skipLoaderErrorBubbling,
3208
- skipLoaders,
3209
3192
  routeMatch != null
3210
3193
  );
3211
3194
  return result;
@@ -3216,7 +3199,6 @@ export function createStaticHandler(
3216
3199
  matches,
3217
3200
  requestContext,
3218
3201
  unstable_dataStrategy,
3219
- loadRouteIds,
3220
3202
  skipLoaderErrorBubbling,
3221
3203
  routeMatch
3222
3204
  );
@@ -3252,9 +3234,7 @@ export function createStaticHandler(
3252
3234
  actionMatch: AgnosticDataRouteMatch,
3253
3235
  requestContext: unknown,
3254
3236
  unstable_dataStrategy: DataStrategyFunction | null,
3255
- loadRouteIds: string[] | null,
3256
3237
  skipLoaderErrorBubbling: boolean,
3257
- skipLoaders: boolean,
3258
3238
  isRouteRequest: boolean
3259
3239
  ): Promise<Omit<StaticHandlerContext, "location" | "basename"> | Response> {
3260
3240
  let result: DataResult;
@@ -3347,36 +3327,12 @@ export function createStaticHandler(
3347
3327
  let boundaryMatch = skipLoaderErrorBubbling
3348
3328
  ? actionMatch
3349
3329
  : findNearestBoundary(matches, actionMatch.route.id);
3350
- let statusCode = isRouteErrorResponse(result.error)
3351
- ? result.error.status
3352
- : result.statusCode != null
3353
- ? result.statusCode
3354
- : 500;
3355
- let actionHeaders = {
3356
- ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}),
3357
- };
3358
-
3359
- if (skipLoaders) {
3360
- return {
3361
- matches,
3362
- loaderData: {},
3363
- actionData: {},
3364
- errors: {
3365
- [boundaryMatch.route.id]: result.error,
3366
- },
3367
- statusCode,
3368
- loaderHeaders: {},
3369
- actionHeaders,
3370
- activeDeferreds: null,
3371
- };
3372
- }
3373
3330
 
3374
3331
  let context = await loadRouteData(
3375
3332
  loaderRequest,
3376
3333
  matches,
3377
3334
  requestContext,
3378
3335
  unstable_dataStrategy,
3379
- loadRouteIds,
3380
3336
  skipLoaderErrorBubbling,
3381
3337
  null,
3382
3338
  [boundaryMatch.route.id, result]
@@ -3385,28 +3341,15 @@ export function createStaticHandler(
3385
3341
  // action status codes take precedence over loader status codes
3386
3342
  return {
3387
3343
  ...context,
3388
- statusCode,
3344
+ statusCode: isRouteErrorResponse(result.error)
3345
+ ? result.error.status
3346
+ : result.statusCode != null
3347
+ ? result.statusCode
3348
+ : 500,
3389
3349
  actionData: null,
3390
- actionHeaders,
3391
- };
3392
- }
3393
-
3394
- let actionHeaders = result.headers
3395
- ? { [actionMatch.route.id]: result.headers }
3396
- : {};
3397
-
3398
- if (skipLoaders) {
3399
- return {
3400
- matches,
3401
- loaderData: {},
3402
- actionData: {
3403
- [actionMatch.route.id]: result.data,
3350
+ actionHeaders: {
3351
+ ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}),
3404
3352
  },
3405
- errors: null,
3406
- statusCode: result.statusCode || 200,
3407
- loaderHeaders: {},
3408
- actionHeaders,
3409
- activeDeferreds: null,
3410
3353
  };
3411
3354
  }
3412
3355
 
@@ -3415,7 +3358,6 @@ export function createStaticHandler(
3415
3358
  matches,
3416
3359
  requestContext,
3417
3360
  unstable_dataStrategy,
3418
- loadRouteIds,
3419
3361
  skipLoaderErrorBubbling,
3420
3362
  null
3421
3363
  );
@@ -3438,7 +3380,6 @@ export function createStaticHandler(
3438
3380
  matches: AgnosticDataRouteMatch[],
3439
3381
  requestContext: unknown,
3440
3382
  unstable_dataStrategy: DataStrategyFunction | null,
3441
- loadRouteIds: string[] | null,
3442
3383
  skipLoaderErrorBubbling: boolean,
3443
3384
  routeMatch: AgnosticDataRouteMatch | null,
3444
3385
  pendingActionResult?: PendingActionResult
@@ -3473,12 +3414,6 @@ export function createStaticHandler(
3473
3414
  (m) => m.route.loader || m.route.lazy
3474
3415
  );
3475
3416
 
3476
- if (loadRouteIds) {
3477
- matchesToLoad = matchesToLoad.filter((m) =>
3478
- loadRouteIds.includes(m.route.id)
3479
- );
3480
- }
3481
-
3482
3417
  // Short circuit if we have no loaders to run (query())
3483
3418
  if (matchesToLoad.length === 0) {
3484
3419
  return {