@remix-run/router 0.0.0-experimental-0f2dd78c → 0.0.0-experimental-cec61865

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @remix-run/router v0.0.0-experimental-0f2dd78c
2
+ * @remix-run/router v0.0.0-experimental-cec61865
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1975,7 +1975,7 @@ function createRouter(init) {
1975
1975
  shortCircuited,
1976
1976
  loaderData,
1977
1977
  errors
1978
- } = await handleLoaders(request, location, matches, loadingNavigation, opts && opts.submission, opts && opts.replace, pendingActionData, pendingError);
1978
+ } = await handleLoaders(request, location, matches, loadingNavigation, opts && opts.submission, opts && opts.fetcherSubmission, opts && opts.replace, pendingActionData, pendingError);
1979
1979
 
1980
1980
  if (shortCircuited) {
1981
1981
  return;
@@ -2088,7 +2088,7 @@ function createRouter(init) {
2088
2088
  // errors, etc.
2089
2089
 
2090
2090
 
2091
- async function handleLoaders(request, location, matches, overrideNavigation, submission, replace, pendingActionData, pendingError) {
2091
+ async function handleLoaders(request, location, matches, overrideNavigation, submission, fetcherSubmission, replace, pendingActionData, pendingError) {
2092
2092
  // Figure out the right navigation we want to use for data loading
2093
2093
  let loadingNavigation = overrideNavigation;
2094
2094
 
@@ -2107,7 +2107,7 @@ function createRouter(init) {
2107
2107
  // we have it on the loading navigation so use that if available
2108
2108
 
2109
2109
 
2110
- let activeSubmission = submission ? submission : loadingNavigation.formMethod && loadingNavigation.formAction && loadingNavigation.formData && loadingNavigation.formEncType ? {
2110
+ let activeSubmission = submission || fetcherSubmission ? submission || fetcherSubmission : loadingNavigation.formMethod && loadingNavigation.formAction && loadingNavigation.formData && loadingNavigation.formEncType ? {
2111
2111
  formMethod: loadingNavigation.formMethod,
2112
2112
  formAction: loadingNavigation.formAction,
2113
2113
  formData: loadingNavigation.formData,
@@ -2147,7 +2147,8 @@ function createRouter(init) {
2147
2147
  formMethod: undefined,
2148
2148
  formAction: undefined,
2149
2149
  formEncType: undefined,
2150
- formData: undefined
2150
+ formData: undefined,
2151
+ " _hasFetcherDoneAnything ": true
2151
2152
  };
2152
2153
  state.fetchers.set(rf.key, revalidatingFetcher);
2153
2154
  });
@@ -2283,7 +2284,8 @@ function createRouter(init) {
2283
2284
  let fetcher = _extends({
2284
2285
  state: "submitting"
2285
2286
  }, submission, {
2286
- data: existingFetcher && existingFetcher.data
2287
+ data: existingFetcher && existingFetcher.data,
2288
+ " _hasFetcherDoneAnything ": true
2287
2289
  });
2288
2290
 
2289
2291
  state.fetchers.set(key, fetcher);
@@ -2313,7 +2315,8 @@ function createRouter(init) {
2313
2315
  let loadingFetcher = _extends({
2314
2316
  state: "loading"
2315
2317
  }, submission, {
2316
- data: undefined
2318
+ data: undefined,
2319
+ " _hasFetcherDoneAnything ": true
2317
2320
  });
2318
2321
 
2319
2322
  state.fetchers.set(key, loadingFetcher);
@@ -2321,7 +2324,8 @@ function createRouter(init) {
2321
2324
  fetchers: new Map(state.fetchers)
2322
2325
  });
2323
2326
  return startRedirectNavigation(state, actionResult, {
2324
- submission
2327
+ submission,
2328
+ isFetchActionRedirect: true
2325
2329
  });
2326
2330
  } // Process any non-redirect errors thrown
2327
2331
 
@@ -2350,7 +2354,9 @@ function createRouter(init) {
2350
2354
  let loadFetcher = _extends({
2351
2355
  state: "loading",
2352
2356
  data: actionResult.data
2353
- }, submission);
2357
+ }, submission, {
2358
+ " _hasFetcherDoneAnything ": true
2359
+ });
2354
2360
 
2355
2361
  state.fetchers.set(key, loadFetcher);
2356
2362
  let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, fetchLoadMatches, routesToUse, init.basename, {
@@ -2369,7 +2375,8 @@ function createRouter(init) {
2369
2375
  formMethod: undefined,
2370
2376
  formAction: undefined,
2371
2377
  formEncType: undefined,
2372
- formData: undefined
2378
+ formData: undefined,
2379
+ " _hasFetcherDoneAnything ": true
2373
2380
  };
2374
2381
  state.fetchers.set(staleKey, revalidatingFetcher);
2375
2382
  fetchControllers.set(staleKey, abortController);
@@ -2407,7 +2414,8 @@ function createRouter(init) {
2407
2414
  formMethod: undefined,
2408
2415
  formAction: undefined,
2409
2416
  formEncType: undefined,
2410
- formData: undefined
2417
+ formData: undefined,
2418
+ " _hasFetcherDoneAnything ": true
2411
2419
  };
2412
2420
  state.fetchers.set(key, doneFetcher);
2413
2421
  let didAbortFetchLoads = abortStaleFetchLoads(loadId); // If we are currently in a navigation loading state and this fetcher is
@@ -2448,7 +2456,8 @@ function createRouter(init) {
2448
2456
  formEncType: undefined,
2449
2457
  formData: undefined
2450
2458
  }, submission, {
2451
- data: existingFetcher && existingFetcher.data
2459
+ data: existingFetcher && existingFetcher.data,
2460
+ " _hasFetcherDoneAnything ": true
2452
2461
  });
2453
2462
 
2454
2463
  state.fetchers.set(key, loadingFetcher);
@@ -2508,7 +2517,8 @@ function createRouter(init) {
2508
2517
  formMethod: undefined,
2509
2518
  formAction: undefined,
2510
2519
  formEncType: undefined,
2511
- formData: undefined
2520
+ formData: undefined,
2521
+ " _hasFetcherDoneAnything ": true
2512
2522
  };
2513
2523
  state.fetchers.set(key, doneFetcher);
2514
2524
  updateState({
@@ -2541,16 +2551,20 @@ function createRouter(init) {
2541
2551
 
2542
2552
  let {
2543
2553
  submission,
2544
- replace
2554
+ replace,
2555
+ isFetchActionRedirect
2545
2556
  } = _temp === void 0 ? {} : _temp;
2546
2557
 
2547
2558
  if (redirect.revalidate) {
2548
2559
  isRevalidationRequired = true;
2549
2560
  }
2550
2561
 
2551
- let redirectLocation = createLocation(state.location, redirect.location, {
2562
+ let redirectLocation = createLocation(state.location, redirect.location, // TODO: This can be removed once we get rid of useTransition in Remix v2
2563
+ _extends({
2552
2564
  _isRedirect: true
2553
- });
2565
+ }, isFetchActionRedirect ? {
2566
+ _isFetchActionRedirect: true
2567
+ } : {}));
2554
2568
  invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an absolute external redirect that goes to a new origin
2555
2569
 
2556
2570
  if (ABSOLUTE_URL_REGEX.test(redirect.location) && isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
@@ -2601,6 +2615,22 @@ function createRouter(init) {
2601
2615
  // Preserve this flag across redirects
2602
2616
  preventScrollReset: pendingPreventScrollReset
2603
2617
  });
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
+ });
2604
2634
  } else {
2605
2635
  // Otherwise, we kick off a new loading navigation, preserving the
2606
2636
  // submission info for the duration of this navigation
@@ -2696,7 +2726,8 @@ function createRouter(init) {
2696
2726
  formMethod: undefined,
2697
2727
  formAction: undefined,
2698
2728
  formEncType: undefined,
2699
- formData: undefined
2729
+ formData: undefined,
2730
+ " _hasFetcherDoneAnything ": true
2700
2731
  };
2701
2732
  state.fetchers.set(key, doneFetcher);
2702
2733
  }
@@ -3942,7 +3973,8 @@ function processLoaderData(state, matches, matchesToLoad, results, pendingError,
3942
3973
  formMethod: undefined,
3943
3974
  formAction: undefined,
3944
3975
  formEncType: undefined,
3945
- formData: undefined
3976
+ formData: undefined,
3977
+ " _hasFetcherDoneAnything ": true
3946
3978
  };
3947
3979
  state.fetchers.set(key, doneFetcher);
3948
3980
  }