@remix-run/router 0.0.0-experimental-b8437806 → 0.0.0-experimental-7b1bbb00
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/dist/index.d.ts +3 -3
- package/dist/router.cjs.js +32 -45
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +0 -3
- package/dist/router.js +29 -45
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +32 -45
- 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/dist/utils.d.ts +4 -3
- package/index.ts +2 -1
- package/package.json +1 -1
- package/router.ts +28 -55
- package/utils.ts +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, FormEncType, FormMethod, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, V7_FormMethod, } from "./utils";
|
|
2
|
-
export { AbortedDeferredError,
|
|
1
|
+
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, ErrorResponse, FormEncType, FormMethod, HTMLFormMethod, JsonFunction, LazyRouteFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathPattern, RedirectFunction, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, TrackedPromise, V7_FormMethod, } from "./utils";
|
|
2
|
+
export { AbortedDeferredError, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, redirectDocument, resolvePath, resolveTo, stripBasename, } from "./utils";
|
|
3
3
|
export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history";
|
|
4
4
|
export { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath, } from "./history";
|
|
5
5
|
export * from "./router";
|
|
6
6
|
/** @internal */
|
|
7
7
|
export type { RouteManifest as UNSAFE_RouteManifest } from "./utils";
|
|
8
|
-
export { DeferredData as UNSAFE_DeferredData, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getPathContributingMatches as UNSAFE_getPathContributingMatches, } from "./utils";
|
|
8
|
+
export { DeferredData as UNSAFE_DeferredData, ErrorResponseImpl as UNSAFE_ErrorResponseImpl, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getPathContributingMatches as UNSAFE_getPathContributingMatches, } from "./utils";
|
|
9
9
|
export { invariant as UNSAFE_invariant, warning as UNSAFE_warning, } from "./history";
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-7b1bbb00
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -1469,7 +1469,7 @@ const redirectDocument = (url, init) => {
|
|
|
1469
1469
|
* @private
|
|
1470
1470
|
* Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies
|
|
1471
1471
|
*/
|
|
1472
|
-
class
|
|
1472
|
+
class ErrorResponseImpl {
|
|
1473
1473
|
constructor(status, statusText, data, internal) {
|
|
1474
1474
|
if (internal === void 0) {
|
|
1475
1475
|
internal = false;
|
|
@@ -1486,6 +1486,9 @@ class ErrorResponse {
|
|
|
1486
1486
|
}
|
|
1487
1487
|
}
|
|
1488
1488
|
|
|
1489
|
+
// We don't want the class exported since usage of it at runtime is an
|
|
1490
|
+
// implementation detail, but we do want to export the shape so folks can
|
|
1491
|
+
// build their own abstractions around instances via isRouteErrorResponse()
|
|
1489
1492
|
/**
|
|
1490
1493
|
* Check if the given error is an ErrorResponse generated from a 4xx/5xx
|
|
1491
1494
|
* Response thrown from an action/loader
|
|
@@ -1854,23 +1857,13 @@ function createRouter(init) {
|
|
|
1854
1857
|
state = _extends({}, state, newState);
|
|
1855
1858
|
subscribers.forEach(subscriber => subscriber(state));
|
|
1856
1859
|
}
|
|
1857
|
-
function completeNavigation(location, newState) {
|
|
1858
|
-
// @ts-expect-error
|
|
1859
|
-
if (typeof document !== "undefined" && document.startViewTransition) {
|
|
1860
|
-
// TODO: Do we need a flushSync here?
|
|
1861
|
-
// @ts-expect-error
|
|
1862
|
-
document.startViewTransition(() => completeNavigationForRealz(location, newState));
|
|
1863
|
-
} else {
|
|
1864
|
-
completeNavigationForRealz(location, newState);
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
1860
|
|
|
1868
1861
|
// Complete a navigation returning the state.navigation back to the IDLE_NAVIGATION
|
|
1869
1862
|
// and setting state.[historyAction/location/matches] to the new route.
|
|
1870
1863
|
// - Location is a required param
|
|
1871
1864
|
// - Navigation will always be set to IDLE_NAVIGATION
|
|
1872
1865
|
// - Can pass any other state in newState
|
|
1873
|
-
function
|
|
1866
|
+
function completeNavigation(location, newState) {
|
|
1874
1867
|
var _location$state, _location$state2;
|
|
1875
1868
|
// Deduce if we're in a loading/actionReload state:
|
|
1876
1869
|
// - We have committed actionData in the store
|
|
@@ -2480,8 +2473,7 @@ function createRouter(init) {
|
|
|
2480
2473
|
fetchers: new Map(state.fetchers)
|
|
2481
2474
|
});
|
|
2482
2475
|
return startRedirectNavigation(state, actionResult, {
|
|
2483
|
-
submission
|
|
2484
|
-
isFetchActionRedirect: true
|
|
2476
|
+
fetcherSubmission: submission
|
|
2485
2477
|
});
|
|
2486
2478
|
}
|
|
2487
2479
|
}
|
|
@@ -2696,18 +2688,15 @@ function createRouter(init) {
|
|
|
2696
2688
|
async function startRedirectNavigation(state, redirect, _temp) {
|
|
2697
2689
|
let {
|
|
2698
2690
|
submission,
|
|
2699
|
-
|
|
2700
|
-
|
|
2691
|
+
fetcherSubmission,
|
|
2692
|
+
replace
|
|
2701
2693
|
} = _temp === void 0 ? {} : _temp;
|
|
2702
2694
|
if (redirect.revalidate) {
|
|
2703
2695
|
isRevalidationRequired = true;
|
|
2704
2696
|
}
|
|
2705
|
-
let redirectLocation = createLocation(state.location, redirect.location,
|
|
2706
|
-
_extends({
|
|
2697
|
+
let redirectLocation = createLocation(state.location, redirect.location, {
|
|
2707
2698
|
_isRedirect: true
|
|
2708
|
-
}
|
|
2709
|
-
_isFetchActionRedirect: true
|
|
2710
|
-
} : {}));
|
|
2699
|
+
});
|
|
2711
2700
|
invariant(redirectLocation, "Expected a location on the redirect navigation");
|
|
2712
2701
|
if (isBrowser) {
|
|
2713
2702
|
let isDocumentReload = false;
|
|
@@ -2739,11 +2728,19 @@ function createRouter(init) {
|
|
|
2739
2728
|
|
|
2740
2729
|
// Use the incoming submission if provided, fallback on the active one in
|
|
2741
2730
|
// state.navigation
|
|
2742
|
-
let
|
|
2731
|
+
let {
|
|
2732
|
+
formMethod,
|
|
2733
|
+
formAction,
|
|
2734
|
+
formEncType
|
|
2735
|
+
} = state.navigation;
|
|
2736
|
+
if (!submission && !fetcherSubmission && formMethod && formAction && formEncType) {
|
|
2737
|
+
submission = getSubmissionFromNavigation(state.navigation);
|
|
2738
|
+
}
|
|
2743
2739
|
|
|
2744
2740
|
// If this was a 307/308 submission we want to preserve the HTTP method and
|
|
2745
2741
|
// re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the
|
|
2746
2742
|
// redirected location
|
|
2743
|
+
let activeSubmission = submission || fetcherSubmission;
|
|
2747
2744
|
if (redirectPreserveMethodStatusCodes.has(redirect.status) && activeSubmission && isMutationMethod(activeSubmission.formMethod)) {
|
|
2748
2745
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2749
2746
|
submission: _extends({}, activeSubmission, {
|
|
@@ -2752,20 +2749,14 @@ function createRouter(init) {
|
|
|
2752
2749
|
// Preserve this flag across redirects
|
|
2753
2750
|
preventScrollReset: pendingPreventScrollReset
|
|
2754
2751
|
});
|
|
2755
|
-
} else if (isFetchActionRedirect) {
|
|
2756
|
-
// For a fetch action redirect, we kick off a new loading navigation
|
|
2757
|
-
// without the fetcher submission, but we send it along for shouldRevalidate
|
|
2758
|
-
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2759
|
-
overrideNavigation: getLoadingNavigation(redirectLocation),
|
|
2760
|
-
fetcherSubmission: activeSubmission,
|
|
2761
|
-
// Preserve this flag across redirects
|
|
2762
|
-
preventScrollReset: pendingPreventScrollReset
|
|
2763
|
-
});
|
|
2764
2752
|
} else {
|
|
2765
|
-
// If we have a submission, we will preserve it through the
|
|
2766
|
-
|
|
2753
|
+
// If we have a navigation submission, we will preserve it through the
|
|
2754
|
+
// redirect navigation
|
|
2755
|
+
let overrideNavigation = getLoadingNavigation(redirectLocation, submission);
|
|
2767
2756
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2768
2757
|
overrideNavigation,
|
|
2758
|
+
// Send fetcher submissions through for shouldRevalidate
|
|
2759
|
+
fetcherSubmission,
|
|
2769
2760
|
// Preserve this flag across redirects
|
|
2770
2761
|
preventScrollReset: pendingPreventScrollReset
|
|
2771
2762
|
});
|
|
@@ -3978,7 +3969,7 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
|
|
|
3978
3969
|
if (resultType === ResultType.error) {
|
|
3979
3970
|
return {
|
|
3980
3971
|
type: resultType,
|
|
3981
|
-
error: new
|
|
3972
|
+
error: new ErrorResponseImpl(status, result.statusText, data),
|
|
3982
3973
|
headers: result.headers
|
|
3983
3974
|
};
|
|
3984
3975
|
}
|
|
@@ -4257,7 +4248,7 @@ function getInternalRouterError(status, _temp4) {
|
|
|
4257
4248
|
errorMessage = "Invalid request method \"" + method.toUpperCase() + "\"";
|
|
4258
4249
|
}
|
|
4259
4250
|
}
|
|
4260
|
-
return new
|
|
4251
|
+
return new ErrorResponseImpl(status || 500, statusText, new Error(errorMessage), true);
|
|
4261
4252
|
}
|
|
4262
4253
|
|
|
4263
4254
|
// Find any returned redirect errors, starting from the lowest match
|
|
@@ -4505,8 +4496,7 @@ function getLoadingFetcher(submission, data) {
|
|
|
4505
4496
|
formData: submission.formData,
|
|
4506
4497
|
json: submission.json,
|
|
4507
4498
|
text: submission.text,
|
|
4508
|
-
data
|
|
4509
|
-
" _hasFetcherDoneAnything ": true
|
|
4499
|
+
data
|
|
4510
4500
|
};
|
|
4511
4501
|
return fetcher;
|
|
4512
4502
|
} else {
|
|
@@ -4518,8 +4508,7 @@ function getLoadingFetcher(submission, data) {
|
|
|
4518
4508
|
formData: undefined,
|
|
4519
4509
|
json: undefined,
|
|
4520
4510
|
text: undefined,
|
|
4521
|
-
data
|
|
4522
|
-
" _hasFetcherDoneAnything ": true
|
|
4511
|
+
data
|
|
4523
4512
|
};
|
|
4524
4513
|
return fetcher;
|
|
4525
4514
|
}
|
|
@@ -4533,8 +4522,7 @@ function getSubmittingFetcher(submission, existingFetcher) {
|
|
|
4533
4522
|
formData: submission.formData,
|
|
4534
4523
|
json: submission.json,
|
|
4535
4524
|
text: submission.text,
|
|
4536
|
-
data: existingFetcher ? existingFetcher.data : undefined
|
|
4537
|
-
" _hasFetcherDoneAnything ": true
|
|
4525
|
+
data: existingFetcher ? existingFetcher.data : undefined
|
|
4538
4526
|
};
|
|
4539
4527
|
return fetcher;
|
|
4540
4528
|
}
|
|
@@ -4547,8 +4535,7 @@ function getDoneFetcher(data) {
|
|
|
4547
4535
|
formData: undefined,
|
|
4548
4536
|
json: undefined,
|
|
4549
4537
|
text: undefined,
|
|
4550
|
-
data
|
|
4551
|
-
" _hasFetcherDoneAnything ": true
|
|
4538
|
+
data
|
|
4552
4539
|
};
|
|
4553
4540
|
return fetcher;
|
|
4554
4541
|
}
|
|
@@ -4556,12 +4543,12 @@ function getDoneFetcher(data) {
|
|
|
4556
4543
|
|
|
4557
4544
|
exports.AbortedDeferredError = AbortedDeferredError;
|
|
4558
4545
|
exports.Action = Action;
|
|
4559
|
-
exports.ErrorResponse = ErrorResponse;
|
|
4560
4546
|
exports.IDLE_BLOCKER = IDLE_BLOCKER;
|
|
4561
4547
|
exports.IDLE_FETCHER = IDLE_FETCHER;
|
|
4562
4548
|
exports.IDLE_NAVIGATION = IDLE_NAVIGATION;
|
|
4563
4549
|
exports.UNSAFE_DEFERRED_SYMBOL = UNSAFE_DEFERRED_SYMBOL;
|
|
4564
4550
|
exports.UNSAFE_DeferredData = DeferredData;
|
|
4551
|
+
exports.UNSAFE_ErrorResponseImpl = ErrorResponseImpl;
|
|
4565
4552
|
exports.UNSAFE_convertRoutesToDataRoutes = convertRoutesToDataRoutes;
|
|
4566
4553
|
exports.UNSAFE_getPathContributingMatches = getPathContributingMatches;
|
|
4567
4554
|
exports.UNSAFE_invariant = invariant;
|