@remix-run/router 0.0.0-experimental-cec61865 → 0.0.0-experimental-0db28b07
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 +26 -1
- package/dist/router.cjs.js +31 -51
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +2 -5
- package/dist/router.js +31 -52
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +31 -51
- 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 +35 -48
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.5.0-pre.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Remove `instanceof` check for `DeferredData` to be resiliant to ESM/CJS boundaries in SSR bundling scenarios ([#10247](https://github.com/remix-run/react-router/pull/10247))
|
|
8
|
+
|
|
9
|
+
## 1.5.0-pre.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Added support for [**Future Flags**](https://reactrouter.com/en/main/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
|
|
14
|
+
|
|
15
|
+
- When `future.v7_normalizeFormMethod === false` (default v6 behavior),
|
|
16
|
+
- `useNavigation().formMethod` is lowercase
|
|
17
|
+
- `useFetcher().formMethod` is lowercase
|
|
18
|
+
- When `future.v7_normalizeFormMethod === true`:
|
|
19
|
+
- `useNavigation().formMethod` is uppercase
|
|
20
|
+
- `useFetcher().formMethod` is uppercase
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Provide fetcher submission to `shouldRevalidate` if the fetcher action redirects ([#10208](https://github.com/remix-run/react-router/pull/10208))
|
|
25
|
+
- Properly handle `lazy()` errors during router initialization ([#10201](https://github.com/remix-run/react-router/pull/10201))
|
|
26
|
+
- Update to latest `@remix-run/web-fetch@4.3.3` ([#10216](https://github.com/remix-run/react-router/pull/10216))
|
|
27
|
+
|
|
3
28
|
## 1.4.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
|
@@ -64,7 +89,7 @@
|
|
|
64
89
|
|
|
65
90
|
### Patch Changes
|
|
66
91
|
|
|
67
|
-
- Fix `generatePath` incorrectly applying parameters in some cases ([
|
|
92
|
+
- Fix `generatePath` incorrectly applying parameters in some cases ([#10078](https://github.com/remix-run/react-router/pull/10078))
|
|
68
93
|
|
|
69
94
|
## 1.3.3
|
|
70
95
|
|
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-0db28b07
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -2147,8 +2147,7 @@ function createRouter(init) {
|
|
|
2147
2147
|
formMethod: undefined,
|
|
2148
2148
|
formAction: undefined,
|
|
2149
2149
|
formEncType: undefined,
|
|
2150
|
-
formData: undefined
|
|
2151
|
-
" _hasFetcherDoneAnything ": true
|
|
2150
|
+
formData: undefined
|
|
2152
2151
|
};
|
|
2153
2152
|
state.fetchers.set(rf.key, revalidatingFetcher);
|
|
2154
2153
|
});
|
|
@@ -2284,8 +2283,7 @@ function createRouter(init) {
|
|
|
2284
2283
|
let fetcher = _extends({
|
|
2285
2284
|
state: "submitting"
|
|
2286
2285
|
}, submission, {
|
|
2287
|
-
data: existingFetcher && existingFetcher.data
|
|
2288
|
-
" _hasFetcherDoneAnything ": true
|
|
2286
|
+
data: existingFetcher && existingFetcher.data
|
|
2289
2287
|
});
|
|
2290
2288
|
|
|
2291
2289
|
state.fetchers.set(key, fetcher);
|
|
@@ -2315,8 +2313,7 @@ function createRouter(init) {
|
|
|
2315
2313
|
let loadingFetcher = _extends({
|
|
2316
2314
|
state: "loading"
|
|
2317
2315
|
}, submission, {
|
|
2318
|
-
data: undefined
|
|
2319
|
-
" _hasFetcherDoneAnything ": true
|
|
2316
|
+
data: undefined
|
|
2320
2317
|
});
|
|
2321
2318
|
|
|
2322
2319
|
state.fetchers.set(key, loadingFetcher);
|
|
@@ -2324,8 +2321,7 @@ function createRouter(init) {
|
|
|
2324
2321
|
fetchers: new Map(state.fetchers)
|
|
2325
2322
|
});
|
|
2326
2323
|
return startRedirectNavigation(state, actionResult, {
|
|
2327
|
-
submission
|
|
2328
|
-
isFetchActionRedirect: true
|
|
2324
|
+
fetcherSubmission: submission
|
|
2329
2325
|
});
|
|
2330
2326
|
} // Process any non-redirect errors thrown
|
|
2331
2327
|
|
|
@@ -2354,9 +2350,7 @@ function createRouter(init) {
|
|
|
2354
2350
|
let loadFetcher = _extends({
|
|
2355
2351
|
state: "loading",
|
|
2356
2352
|
data: actionResult.data
|
|
2357
|
-
}, submission
|
|
2358
|
-
" _hasFetcherDoneAnything ": true
|
|
2359
|
-
});
|
|
2353
|
+
}, submission);
|
|
2360
2354
|
|
|
2361
2355
|
state.fetchers.set(key, loadFetcher);
|
|
2362
2356
|
let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, fetchLoadMatches, routesToUse, init.basename, {
|
|
@@ -2375,8 +2369,7 @@ function createRouter(init) {
|
|
|
2375
2369
|
formMethod: undefined,
|
|
2376
2370
|
formAction: undefined,
|
|
2377
2371
|
formEncType: undefined,
|
|
2378
|
-
formData: undefined
|
|
2379
|
-
" _hasFetcherDoneAnything ": true
|
|
2372
|
+
formData: undefined
|
|
2380
2373
|
};
|
|
2381
2374
|
state.fetchers.set(staleKey, revalidatingFetcher);
|
|
2382
2375
|
fetchControllers.set(staleKey, abortController);
|
|
@@ -2414,8 +2407,7 @@ function createRouter(init) {
|
|
|
2414
2407
|
formMethod: undefined,
|
|
2415
2408
|
formAction: undefined,
|
|
2416
2409
|
formEncType: undefined,
|
|
2417
|
-
formData: undefined
|
|
2418
|
-
" _hasFetcherDoneAnything ": true
|
|
2410
|
+
formData: undefined
|
|
2419
2411
|
};
|
|
2420
2412
|
state.fetchers.set(key, doneFetcher);
|
|
2421
2413
|
let didAbortFetchLoads = abortStaleFetchLoads(loadId); // If we are currently in a navigation loading state and this fetcher is
|
|
@@ -2456,8 +2448,7 @@ function createRouter(init) {
|
|
|
2456
2448
|
formEncType: undefined,
|
|
2457
2449
|
formData: undefined
|
|
2458
2450
|
}, submission, {
|
|
2459
|
-
data: existingFetcher && existingFetcher.data
|
|
2460
|
-
" _hasFetcherDoneAnything ": true
|
|
2451
|
+
data: existingFetcher && existingFetcher.data
|
|
2461
2452
|
});
|
|
2462
2453
|
|
|
2463
2454
|
state.fetchers.set(key, loadingFetcher);
|
|
@@ -2517,8 +2508,7 @@ function createRouter(init) {
|
|
|
2517
2508
|
formMethod: undefined,
|
|
2518
2509
|
formAction: undefined,
|
|
2519
2510
|
formEncType: undefined,
|
|
2520
|
-
formData: undefined
|
|
2521
|
-
" _hasFetcherDoneAnything ": true
|
|
2511
|
+
formData: undefined
|
|
2522
2512
|
};
|
|
2523
2513
|
state.fetchers.set(key, doneFetcher);
|
|
2524
2514
|
updateState({
|
|
@@ -2551,20 +2541,17 @@ function createRouter(init) {
|
|
|
2551
2541
|
|
|
2552
2542
|
let {
|
|
2553
2543
|
submission,
|
|
2554
|
-
|
|
2555
|
-
|
|
2544
|
+
fetcherSubmission,
|
|
2545
|
+
replace
|
|
2556
2546
|
} = _temp === void 0 ? {} : _temp;
|
|
2557
2547
|
|
|
2558
2548
|
if (redirect.revalidate) {
|
|
2559
2549
|
isRevalidationRequired = true;
|
|
2560
2550
|
}
|
|
2561
2551
|
|
|
2562
|
-
let redirectLocation = createLocation(state.location, redirect.location,
|
|
2563
|
-
_extends({
|
|
2552
|
+
let redirectLocation = createLocation(state.location, redirect.location, {
|
|
2564
2553
|
_isRedirect: true
|
|
2565
|
-
}
|
|
2566
|
-
_isFetchActionRedirect: true
|
|
2567
|
-
} : {}));
|
|
2554
|
+
});
|
|
2568
2555
|
invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an absolute external redirect that goes to a new origin
|
|
2569
2556
|
|
|
2570
2557
|
if (ABSOLUTE_URL_REGEX.test(redirect.location) && isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
|
|
@@ -2595,7 +2582,7 @@ function createRouter(init) {
|
|
|
2595
2582
|
formData
|
|
2596
2583
|
} = state.navigation;
|
|
2597
2584
|
|
|
2598
|
-
if (!submission && formMethod && formAction && formData && formEncType) {
|
|
2585
|
+
if (!submission && !fetcherSubmission && formMethod && formAction && formData && formEncType) {
|
|
2599
2586
|
submission = {
|
|
2600
2587
|
formMethod,
|
|
2601
2588
|
formAction,
|
|
@@ -2607,30 +2594,16 @@ function createRouter(init) {
|
|
|
2607
2594
|
// redirected location
|
|
2608
2595
|
|
|
2609
2596
|
|
|
2610
|
-
|
|
2597
|
+
let activeSubmission = submission || fetcherSubmission;
|
|
2598
|
+
|
|
2599
|
+
if (redirectPreserveMethodStatusCodes.has(redirect.status) && activeSubmission && isMutationMethod(activeSubmission.formMethod)) {
|
|
2611
2600
|
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2612
|
-
submission: _extends({},
|
|
2601
|
+
submission: _extends({}, activeSubmission, {
|
|
2613
2602
|
formAction: redirect.location
|
|
2614
2603
|
}),
|
|
2615
2604
|
// Preserve this flag across redirects
|
|
2616
2605
|
preventScrollReset: pendingPreventScrollReset
|
|
2617
2606
|
});
|
|
2618
|
-
} else if (isFetchActionRedirect) {
|
|
2619
|
-
// For a fetch action redirect, we kick off a new loading navigation
|
|
2620
|
-
// without the fetcher submission, but we send it along for shouldRevalidate
|
|
2621
|
-
await startNavigation(redirectHistoryAction, redirectLocation, {
|
|
2622
|
-
overrideNavigation: {
|
|
2623
|
-
state: "loading",
|
|
2624
|
-
location: redirectLocation,
|
|
2625
|
-
formMethod: undefined,
|
|
2626
|
-
formAction: undefined,
|
|
2627
|
-
formEncType: undefined,
|
|
2628
|
-
formData: undefined
|
|
2629
|
-
},
|
|
2630
|
-
fetcherSubmission: submission,
|
|
2631
|
-
// Preserve this flag across redirects
|
|
2632
|
-
preventScrollReset: pendingPreventScrollReset
|
|
2633
|
-
});
|
|
2634
2607
|
} else {
|
|
2635
2608
|
// Otherwise, we kick off a new loading navigation, preserving the
|
|
2636
2609
|
// submission info for the duration of this navigation
|
|
@@ -2638,11 +2611,14 @@ function createRouter(init) {
|
|
|
2638
2611
|
overrideNavigation: {
|
|
2639
2612
|
state: "loading",
|
|
2640
2613
|
location: redirectLocation,
|
|
2614
|
+
// Only include navigational submissions on the navigation
|
|
2641
2615
|
formMethod: submission ? submission.formMethod : undefined,
|
|
2642
2616
|
formAction: submission ? submission.formAction : undefined,
|
|
2643
2617
|
formEncType: submission ? submission.formEncType : undefined,
|
|
2644
2618
|
formData: submission ? submission.formData : undefined
|
|
2645
2619
|
},
|
|
2620
|
+
// Send fetcher submissions through for shouldRevalidate
|
|
2621
|
+
fetcherSubmission,
|
|
2646
2622
|
// Preserve this flag across redirects
|
|
2647
2623
|
preventScrollReset: pendingPreventScrollReset
|
|
2648
2624
|
});
|
|
@@ -2726,8 +2702,7 @@ function createRouter(init) {
|
|
|
2726
2702
|
formMethod: undefined,
|
|
2727
2703
|
formAction: undefined,
|
|
2728
2704
|
formEncType: undefined,
|
|
2729
|
-
formData: undefined
|
|
2730
|
-
" _hasFetcherDoneAnything ": true
|
|
2705
|
+
formData: undefined
|
|
2731
2706
|
};
|
|
2732
2707
|
state.fetchers.set(key, doneFetcher);
|
|
2733
2708
|
}
|
|
@@ -3802,7 +3777,7 @@ async function callLoaderOrAction(type, request, match, matches, manifest, detec
|
|
|
3802
3777
|
};
|
|
3803
3778
|
}
|
|
3804
3779
|
|
|
3805
|
-
if (result
|
|
3780
|
+
if (isDeferredData(result)) {
|
|
3806
3781
|
var _result$init, _result$init2;
|
|
3807
3782
|
|
|
3808
3783
|
return {
|
|
@@ -3973,8 +3948,7 @@ function processLoaderData(state, matches, matchesToLoad, results, pendingError,
|
|
|
3973
3948
|
formMethod: undefined,
|
|
3974
3949
|
formAction: undefined,
|
|
3975
3950
|
formEncType: undefined,
|
|
3976
|
-
formData: undefined
|
|
3977
|
-
" _hasFetcherDoneAnything ": true
|
|
3951
|
+
formData: undefined
|
|
3978
3952
|
};
|
|
3979
3953
|
state.fetchers.set(key, doneFetcher);
|
|
3980
3954
|
}
|
|
@@ -4106,6 +4080,11 @@ function isRedirectResult(result) {
|
|
|
4106
4080
|
return (result && result.type) === ResultType.redirect;
|
|
4107
4081
|
}
|
|
4108
4082
|
|
|
4083
|
+
function isDeferredData(value) {
|
|
4084
|
+
let deferred = value;
|
|
4085
|
+
return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function";
|
|
4086
|
+
}
|
|
4087
|
+
|
|
4109
4088
|
function isResponse(value) {
|
|
4110
4089
|
return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
|
|
4111
4090
|
}
|
|
@@ -4247,6 +4226,7 @@ exports.defer = defer;
|
|
|
4247
4226
|
exports.generatePath = generatePath;
|
|
4248
4227
|
exports.getStaticContextFromError = getStaticContextFromError;
|
|
4249
4228
|
exports.getToPathname = getToPathname;
|
|
4229
|
+
exports.isDeferredData = isDeferredData;
|
|
4250
4230
|
exports.isRouteErrorResponse = isRouteErrorResponse;
|
|
4251
4231
|
exports.joinPaths = joinPaths;
|
|
4252
4232
|
exports.json = json;
|