@remix-run/router 0.0.0-experimental-9463fb5e → 0.0.0-experimental-8bb3ffdf
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 +181 -0
- package/dist/router.cjs.js +42 -47
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +0 -1
- package/dist/router.js +42 -45
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +42 -47
- 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 +49 -60
package/dist/router.d.ts
CHANGED
|
@@ -487,7 +487,6 @@ export declare const UNSAFE_DEFERRED_SYMBOL: unique symbol;
|
|
|
487
487
|
*/
|
|
488
488
|
export interface StaticHandlerFutureConfig {
|
|
489
489
|
v7_relativeSplatPath: boolean;
|
|
490
|
-
v7_throwAbortReason: boolean;
|
|
491
490
|
}
|
|
492
491
|
export interface CreateStaticHandlerOptions {
|
|
493
492
|
basename?: string;
|
package/dist/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-8bb3ffdf
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1366,17 +1366,28 @@ function createRouter(init) {
|
|
|
1366
1366
|
[route.id]: error
|
|
1367
1367
|
};
|
|
1368
1368
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1369
|
+
let initialized;
|
|
1370
|
+
let hasLazyRoutes = initialMatches.some(m => m.route.lazy);
|
|
1371
|
+
let hasLoaders = initialMatches.some(m => m.route.loader);
|
|
1372
|
+
if (hasLazyRoutes) {
|
|
1373
|
+
// All initialMatches need to be loaded before we're ready. If we have lazy
|
|
1374
|
+
// functions around still then we'll need to run them in initialize()
|
|
1375
|
+
initialized = false;
|
|
1376
|
+
} else if (!hasLoaders) {
|
|
1377
|
+
// If we've got no loaders to run, then we're good to go
|
|
1378
|
+
initialized = true;
|
|
1379
|
+
} else if (future.v7_partialHydration) {
|
|
1380
|
+
// If partial hydration is enabled, we're initialized so long as we were
|
|
1381
|
+
// provided with hydrationData for every route with a loader, and no loaders
|
|
1382
|
+
// were marked for explicit hydration
|
|
1383
|
+
let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
|
|
1384
|
+
let errors = init.hydrationData ? init.hydrationData.errors : null;
|
|
1385
|
+
initialized = initialMatches.every(m => m.route.loader && m.route.loader.hydrate !== true && (loaderData && loaderData[m.route.id] !== undefined || errors && errors[m.route.id] !== undefined));
|
|
1386
|
+
} else {
|
|
1387
|
+
// Without partial hydration - we're initialized if we were provided any
|
|
1388
|
+
// hydrationData - which is expected to be complete
|
|
1389
|
+
initialized = init.hydrationData != null;
|
|
1390
|
+
}
|
|
1380
1391
|
let router;
|
|
1381
1392
|
let state = {
|
|
1382
1393
|
historyAction: init.history.action,
|
|
@@ -1519,7 +1530,7 @@ function createRouter(init) {
|
|
|
1519
1530
|
// in the normal navigation flow. For SSR it's expected that lazy modules are
|
|
1520
1531
|
// resolved prior to router creation since we can't go into a fallbackElement
|
|
1521
1532
|
// UI for SSR'd apps
|
|
1522
|
-
if (!state.initialized
|
|
1533
|
+
if (!state.initialized) {
|
|
1523
1534
|
startNavigation(Action.Pop, state.location, {
|
|
1524
1535
|
initialHydration: true
|
|
1525
1536
|
});
|
|
@@ -2811,8 +2822,7 @@ function createStaticHandler(routes, opts) {
|
|
|
2811
2822
|
}
|
|
2812
2823
|
// Config driven behavior flags
|
|
2813
2824
|
let future = _extends({
|
|
2814
|
-
v7_relativeSplatPath: false
|
|
2815
|
-
v7_throwAbortReason: false
|
|
2825
|
+
v7_relativeSplatPath: false
|
|
2816
2826
|
}, opts ? opts.future : null);
|
|
2817
2827
|
let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, undefined, manifest);
|
|
2818
2828
|
/**
|
|
@@ -3029,7 +3039,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3029
3039
|
requestContext
|
|
3030
3040
|
});
|
|
3031
3041
|
if (request.signal.aborted) {
|
|
3032
|
-
|
|
3042
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3043
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3033
3044
|
}
|
|
3034
3045
|
}
|
|
3035
3046
|
if (isRedirectResult(result)) {
|
|
@@ -3143,7 +3154,8 @@ function createStaticHandler(routes, opts) {
|
|
|
3143
3154
|
requestContext
|
|
3144
3155
|
}))]);
|
|
3145
3156
|
if (request.signal.aborted) {
|
|
3146
|
-
|
|
3157
|
+
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3158
|
+
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3147
3159
|
}
|
|
3148
3160
|
// Process and commit output from loaders
|
|
3149
3161
|
let activeDeferreds = new Map();
|
|
@@ -3183,14 +3195,6 @@ function getStaticContextFromError(routes, context, error) {
|
|
|
3183
3195
|
});
|
|
3184
3196
|
return newContext;
|
|
3185
3197
|
}
|
|
3186
|
-
function throwStaticHandlerAbortedError(request, isRouteRequest, future) {
|
|
3187
|
-
let method = isRouteRequest ? "queryRoute" : "query";
|
|
3188
|
-
if (future.v7_throwAbortReason && request.signal.reason !== undefined) {
|
|
3189
|
-
throw request.signal.reason;
|
|
3190
|
-
} else {
|
|
3191
|
-
throw new Error(method + "() call aborted: " + request.method + " " + request.url);
|
|
3192
|
-
}
|
|
3193
|
-
}
|
|
3194
3198
|
function isSubmissionNavigation(opts) {
|
|
3195
3199
|
return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== undefined);
|
|
3196
3200
|
}
|
|
@@ -3378,18 +3382,24 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
|
|
|
3378
3382
|
let boundaryId = pendingError ? Object.keys(pendingError)[0] : undefined;
|
|
3379
3383
|
let boundaryMatches = getLoaderMatchesUntilBoundary(matches, boundaryId);
|
|
3380
3384
|
let navigationMatches = boundaryMatches.filter((match, index) => {
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
}
|
|
3386
|
-
if (match.route.lazy) {
|
|
3385
|
+
let {
|
|
3386
|
+
route
|
|
3387
|
+
} = match;
|
|
3388
|
+
if (route.lazy) {
|
|
3387
3389
|
// We haven't loaded this route yet so we don't know if it's got a loader!
|
|
3388
3390
|
return true;
|
|
3389
3391
|
}
|
|
3390
|
-
if (
|
|
3392
|
+
if (route.loader == null) {
|
|
3391
3393
|
return false;
|
|
3392
3394
|
}
|
|
3395
|
+
if (isInitialLoad) {
|
|
3396
|
+
if (route.loader.hydrate) {
|
|
3397
|
+
return true;
|
|
3398
|
+
}
|
|
3399
|
+
return state.loaderData[route.id] === undefined && (
|
|
3400
|
+
// Don't re-run if the loader ran and threw an error
|
|
3401
|
+
!state.errors || state.errors[route.id] === undefined);
|
|
3402
|
+
}
|
|
3393
3403
|
// Always call the loader on new route instances and pending defer cancellations
|
|
3394
3404
|
if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some(id => id === match.route.id)) {
|
|
3395
3405
|
return true;
|
|
@@ -3486,19 +3496,6 @@ function getMatchesToLoad(history, state, matches, submission, location, isIniti
|
|
|
3486
3496
|
});
|
|
3487
3497
|
return [navigationMatches, revalidatingFetchers];
|
|
3488
3498
|
}
|
|
3489
|
-
// Is this route unhydrated (when v7_partialHydration=true) such that we need
|
|
3490
|
-
// to call it's loader on the initial router creation
|
|
3491
|
-
function isUnhydratedRoute(state, route) {
|
|
3492
|
-
if (!route.loader) {
|
|
3493
|
-
return false;
|
|
3494
|
-
}
|
|
3495
|
-
if (route.loader.hydrate) {
|
|
3496
|
-
return true;
|
|
3497
|
-
}
|
|
3498
|
-
return state.loaderData[route.id] === undefined && (!state.errors ||
|
|
3499
|
-
// Loader ran but errored - don't re-run
|
|
3500
|
-
state.errors[route.id] === undefined);
|
|
3501
|
-
}
|
|
3502
3499
|
function isNewLoader(currentLoaderData, currentMatch, match) {
|
|
3503
3500
|
let isNew =
|
|
3504
3501
|
// [a] -> [a, b]
|