react-router 0.0.0-experimental-e067e5e52 → 0.0.0-experimental-567b27f71

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/dist/development/{browser-Cloic07w.d.ts → browser-BUb__T3u.d.mts} +2 -1
  3. package/dist/{production/browser-Cloic07w.d.ts → development/browser-Bfn3xw9E.d.ts} +2 -1
  4. package/dist/development/{chunk-5UECWI5A.js → chunk-3KQWMVH5.js} +106 -109
  5. package/dist/{production/chunk-KMR3DDYK.js → development/chunk-FITK2GBN.js} +7 -7
  6. package/dist/development/{chunk-EZE2A5EE.mjs → chunk-MFSTD5J4.mjs} +305 -191
  7. package/dist/development/{chunk-SWPURLNP.mjs → chunk-T2TDL4ZI.mjs} +86 -50
  8. package/dist/development/{chunk-NQI6347W.js → chunk-XLC5DWBP.js} +361 -244
  9. package/dist/development/context-kw54iBKW.d.mts +1713 -0
  10. package/dist/development/dom-export.d.mts +3 -2
  11. package/dist/development/dom-export.d.ts +3 -2
  12. package/dist/development/dom-export.js +38 -29
  13. package/dist/development/dom-export.mjs +14 -5
  14. package/dist/{production/index-react-server-client-CFThihEp.d.mts → development/index-react-server-client-CmqQRyrG.d.mts} +51 -49
  15. package/dist/development/{index-react-server-client-CtMh0QTM.d.ts → index-react-server-client-CtQKvWuW.d.ts} +1114 -57
  16. package/dist/development/index-react-server-client.d.mts +3 -2
  17. package/dist/development/index-react-server-client.d.ts +3 -2
  18. package/dist/development/index-react-server-client.js +4 -4
  19. package/dist/development/index-react-server-client.mjs +2 -2
  20. package/dist/development/index-react-server.d.mts +297 -246
  21. package/dist/development/index-react-server.d.ts +297 -246
  22. package/dist/development/index-react-server.js +97 -21
  23. package/dist/development/index-react-server.mjs +97 -21
  24. package/dist/development/index.d.mts +12 -10
  25. package/dist/development/index.d.ts +12 -10
  26. package/dist/development/index.js +179 -143
  27. package/dist/development/index.mjs +3 -3
  28. package/dist/development/instrumentation-BYr6ff5D.d.ts +657 -0
  29. package/dist/development/lib/types/internal.d.mts +4 -4
  30. package/dist/development/lib/types/internal.d.ts +4 -4
  31. package/dist/development/lib/types/internal.js +1 -1
  32. package/dist/development/lib/types/internal.mjs +1 -1
  33. package/dist/development/{register-B86pZKib.d.ts → register-CTxsJBKQ.d.mts} +1 -1
  34. package/dist/development/{register-DA0Mb5jF.d.mts → register-CkcGwv27.d.ts} +1 -1
  35. package/dist/development/routeModules-BRrCYrSL.d.mts +1693 -0
  36. package/dist/development/routeModules-CA7kSxJJ.d.ts +1693 -0
  37. package/dist/{development/browser-JuMzyCK4.d.mts → production/browser-BUb__T3u.d.mts} +2 -1
  38. package/dist/production/{browser-JuMzyCK4.d.mts → browser-Bfn3xw9E.d.ts} +2 -1
  39. package/dist/production/{chunk-DMRAUID3.js → chunk-7CRO7VK3.js} +361 -244
  40. package/dist/production/{chunk-T33PNRK2.mjs → chunk-JCFT2HBB.mjs} +305 -191
  41. package/dist/{development/chunk-DGNRX45Q.js → production/chunk-ONKPUZLV.js} +7 -7
  42. package/dist/production/{chunk-T4I6FMSB.mjs → chunk-OZOQN5MO.mjs} +86 -50
  43. package/dist/production/{chunk-AHQTEAQI.js → chunk-Y4BW72NR.js} +106 -109
  44. package/dist/production/context-kw54iBKW.d.mts +1713 -0
  45. package/dist/production/dom-export.d.mts +3 -2
  46. package/dist/production/dom-export.d.ts +3 -2
  47. package/dist/production/dom-export.js +38 -29
  48. package/dist/production/dom-export.mjs +14 -5
  49. package/dist/{development/index-react-server-client-CFThihEp.d.mts → production/index-react-server-client-CmqQRyrG.d.mts} +51 -49
  50. package/dist/production/{index-react-server-client-CtMh0QTM.d.ts → index-react-server-client-CtQKvWuW.d.ts} +1114 -57
  51. package/dist/production/index-react-server-client.d.mts +3 -2
  52. package/dist/production/index-react-server-client.d.ts +3 -2
  53. package/dist/production/index-react-server-client.js +4 -4
  54. package/dist/production/index-react-server-client.mjs +2 -2
  55. package/dist/production/index-react-server.d.mts +297 -246
  56. package/dist/production/index-react-server.d.ts +297 -246
  57. package/dist/production/index-react-server.js +97 -21
  58. package/dist/production/index-react-server.mjs +97 -21
  59. package/dist/production/index.d.mts +12 -10
  60. package/dist/production/index.d.ts +12 -10
  61. package/dist/production/index.js +179 -143
  62. package/dist/production/index.mjs +3 -3
  63. package/dist/production/instrumentation-BYr6ff5D.d.ts +657 -0
  64. package/dist/production/lib/types/internal.d.mts +4 -4
  65. package/dist/production/lib/types/internal.d.ts +4 -4
  66. package/dist/production/lib/types/internal.js +1 -1
  67. package/dist/production/lib/types/internal.mjs +1 -1
  68. package/dist/production/{register-B86pZKib.d.ts → register-CTxsJBKQ.d.mts} +1 -1
  69. package/dist/production/{register-DA0Mb5jF.d.mts → register-CkcGwv27.d.ts} +1 -1
  70. package/dist/production/routeModules-BRrCYrSL.d.mts +1693 -0
  71. package/dist/production/routeModules-CA7kSxJJ.d.ts +1693 -0
  72. package/package.json +1 -1
  73. package/dist/development/instrumentation-C7Lh_MjH.d.ts +0 -3340
  74. package/dist/development/router-CFkT48p_.d.mts +0 -3340
  75. package/dist/production/instrumentation-C7Lh_MjH.d.ts +0 -3340
  76. package/dist/production/router-CFkT48p_.d.mts +0 -3340
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-e067e5e52
2
+ * react-router v0.0.0-experimental-567b27f71
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -126,15 +126,15 @@ function createMemoryHistory(options = {}) {
126
126
  }
127
127
  function createBrowserHistory(options = {}) {
128
128
  function createBrowserLocation(window2, globalHistory) {
129
- let maskFrom = globalHistory.state?.unstable_maskFrom;
130
- let { pathname, search, hash } = maskFrom || window2.location;
129
+ let maskedLocation = globalHistory.state?.masked;
130
+ let { pathname, search, hash } = maskedLocation || window2.location;
131
131
  return createLocation(
132
132
  "",
133
133
  { pathname, search, hash },
134
134
  // state defaults to `null` because `window.history.state` does
135
135
  globalHistory.state && globalHistory.state.usr || null,
136
136
  globalHistory.state && globalHistory.state.key || "default",
137
- maskFrom ? {
137
+ maskedLocation ? {
138
138
  pathname: window2.location.pathname,
139
139
  search: window2.location.search,
140
140
  hash: window2.location.hash
@@ -216,7 +216,7 @@ function getHistoryState(location, index) {
216
216
  usr: location.state,
217
217
  key: location.key,
218
218
  idx: index,
219
- unstable_maskFrom: location.unstable_mask ? {
219
+ masked: location.unstable_mask ? {
220
220
  pathname: location.pathname,
221
221
  search: location.search,
222
222
  hash: location.hash
@@ -1380,6 +1380,7 @@ function createRouter(init) {
1380
1380
  }
1381
1381
  let dataStrategyImpl = init.dataStrategy || defaultDataStrategyWithMiddleware;
1382
1382
  let future = {
1383
+ unstable_passThroughRequests: false,
1383
1384
  ...init.future
1384
1385
  };
1385
1386
  let unlistenHistory = null;
@@ -1392,12 +1393,14 @@ function createRouter(init) {
1392
1393
  let initialMatchesIsFOW = false;
1393
1394
  let initialErrors = null;
1394
1395
  let initialized;
1396
+ let renderFallback;
1395
1397
  if (initialMatches == null && !init.patchRoutesOnNavigation) {
1396
1398
  let error = getInternalRouterError(404, {
1397
1399
  pathname: init.history.location.pathname
1398
1400
  });
1399
1401
  let { matches, route } = getShortCircuitMatches(dataRoutes);
1400
1402
  initialized = true;
1403
+ renderFallback = !initialized;
1401
1404
  initialMatches = matches;
1402
1405
  initialErrors = { [route.id]: error };
1403
1406
  } else {
@@ -1413,6 +1416,7 @@ function createRouter(init) {
1413
1416
  }
1414
1417
  if (!initialMatches) {
1415
1418
  initialized = false;
1419
+ renderFallback = !initialized;
1416
1420
  initialMatches = [];
1417
1421
  let fogOfWar = checkFogOfWar(
1418
1422
  null,
@@ -1425,23 +1429,27 @@ function createRouter(init) {
1425
1429
  }
1426
1430
  } else if (initialMatches.some((m) => m.route.lazy)) {
1427
1431
  initialized = false;
1432
+ renderFallback = !initialized;
1428
1433
  } else if (!initialMatches.some((m) => routeHasLoaderOrMiddleware(m.route))) {
1429
1434
  initialized = true;
1435
+ renderFallback = !initialized;
1430
1436
  } else {
1431
1437
  let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
1432
1438
  let errors = init.hydrationData ? init.hydrationData.errors : null;
1439
+ let relevantMatches = initialMatches;
1433
1440
  if (errors) {
1434
1441
  let idx = initialMatches.findIndex(
1435
1442
  (m) => errors[m.route.id] !== void 0
1436
1443
  );
1437
- initialized = initialMatches.slice(0, idx + 1).every(
1438
- (m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
1439
- );
1440
- } else {
1441
- initialized = initialMatches.every(
1442
- (m) => !shouldLoadRouteOnHydration(m.route, loaderData, errors)
1443
- );
1444
+ relevantMatches = relevantMatches.slice(0, idx + 1);
1444
1445
  }
1446
+ renderFallback = false;
1447
+ initialized = true;
1448
+ relevantMatches.forEach((m) => {
1449
+ let status = getRouteHydrationStatus(m.route, loaderData, errors);
1450
+ renderFallback = renderFallback || status.renderFallback;
1451
+ initialized = initialized && !status.shouldLoad;
1452
+ });
1445
1453
  }
1446
1454
  }
1447
1455
  let router;
@@ -1450,6 +1458,7 @@ function createRouter(init) {
1450
1458
  location: init.history.location,
1451
1459
  matches: initialMatches,
1452
1460
  initialized,
1461
+ renderFallback,
1453
1462
  navigation: IDLE_NAVIGATION,
1454
1463
  // Don't restore on initial updateState() if we were SSR'd
1455
1464
  restoreScrollPosition: init.hydrationData != null ? false : null,
@@ -1677,6 +1686,7 @@ function createRouter(init) {
1677
1686
  historyAction: pendingAction,
1678
1687
  location,
1679
1688
  initialized: true,
1689
+ renderFallback: false,
1680
1690
  navigation: IDLE_NAVIGATION,
1681
1691
  revalidation: "idle",
1682
1692
  restoreScrollPosition,
@@ -2017,6 +2027,7 @@ function createRouter(init) {
2017
2027
  mapRouteProperties2,
2018
2028
  manifest,
2019
2029
  request,
2030
+ location,
2020
2031
  matches,
2021
2032
  actionMatch,
2022
2033
  initialHydration ? [] : hydrationRouteProperties2,
@@ -2024,6 +2035,7 @@ function createRouter(init) {
2024
2035
  );
2025
2036
  let results = await callDataStrategy(
2026
2037
  request,
2038
+ location,
2027
2039
  dsMatches,
2028
2040
  scopedContext,
2029
2041
  null
@@ -2211,6 +2223,7 @@ function createRouter(init) {
2211
2223
  dsMatches,
2212
2224
  revalidatingFetchers,
2213
2225
  request,
2226
+ location,
2214
2227
  scopedContext
2215
2228
  );
2216
2229
  if (request.signal.aborted) {
@@ -2402,6 +2415,7 @@ function createRouter(init) {
2402
2415
  mapRouteProperties2,
2403
2416
  manifest,
2404
2417
  fetchRequest,
2418
+ path,
2405
2419
  requestMatches,
2406
2420
  match,
2407
2421
  hydrationRouteProperties2,
@@ -2409,6 +2423,7 @@ function createRouter(init) {
2409
2423
  );
2410
2424
  let actionResults = await callDataStrategy(
2411
2425
  fetchRequest,
2426
+ path,
2412
2427
  fetchMatches,
2413
2428
  scopedContext,
2414
2429
  key
@@ -2512,6 +2527,7 @@ function createRouter(init) {
2512
2527
  dsMatches,
2513
2528
  revalidatingFetchers,
2514
2529
  revalidationRequest,
2530
+ nextLocation,
2515
2531
  scopedContext
2516
2532
  );
2517
2533
  if (abortController.signal.aborted) {
@@ -2626,6 +2642,7 @@ function createRouter(init) {
2626
2642
  mapRouteProperties2,
2627
2643
  manifest,
2628
2644
  fetchRequest,
2645
+ path,
2629
2646
  matches,
2630
2647
  match,
2631
2648
  hydrationRouteProperties2,
@@ -2633,6 +2650,7 @@ function createRouter(init) {
2633
2650
  );
2634
2651
  let results = await callDataStrategy(
2635
2652
  fetchRequest,
2653
+ path,
2636
2654
  dsMatches,
2637
2655
  scopedContext,
2638
2656
  key
@@ -2741,13 +2759,14 @@ function createRouter(init) {
2741
2759
  });
2742
2760
  }
2743
2761
  }
2744
- async function callDataStrategy(request, matches, scopedContext, fetcherKey) {
2762
+ async function callDataStrategy(request, path, matches, scopedContext, fetcherKey) {
2745
2763
  let results;
2746
2764
  let dataResults = {};
2747
2765
  try {
2748
2766
  results = await callDataStrategyImpl(
2749
2767
  dataStrategyImpl,
2750
2768
  request,
2769
+ path,
2751
2770
  matches,
2752
2771
  fetcherKey,
2753
2772
  scopedContext,
@@ -2799,9 +2818,10 @@ function createRouter(init) {
2799
2818
  }
2800
2819
  return dataResults;
2801
2820
  }
2802
- async function callLoadersAndMaybeResolveData(matches, fetchersToLoad, request, scopedContext) {
2821
+ async function callLoadersAndMaybeResolveData(matches, fetchersToLoad, request, location, scopedContext) {
2803
2822
  let loaderResultsPromise = callDataStrategy(
2804
2823
  request,
2824
+ location,
2805
2825
  matches,
2806
2826
  scopedContext,
2807
2827
  null
@@ -2811,6 +2831,7 @@ function createRouter(init) {
2811
2831
  if (f.matches && f.match && f.request && f.controller) {
2812
2832
  let results = await callDataStrategy(
2813
2833
  f.request,
2834
+ f.path,
2814
2835
  f.matches,
2815
2836
  scopedContext,
2816
2837
  f.key
@@ -3219,6 +3240,11 @@ function createStaticHandler(routes, opts) {
3219
3240
  let basename = (opts ? opts.basename : null) || "/";
3220
3241
  let _mapRouteProperties = opts?.mapRouteProperties || defaultMapRouteProperties;
3221
3242
  let mapRouteProperties2 = _mapRouteProperties;
3243
+ let future = {
3244
+ unstable_passThroughRequests: false,
3245
+ // unused in static handler
3246
+ ...opts?.future
3247
+ };
3222
3248
  if (opts?.unstable_instrumentations) {
3223
3249
  let instrumentations = opts.unstable_instrumentations;
3224
3250
  mapRouteProperties2 = (route) => {
@@ -3243,11 +3269,12 @@ function createStaticHandler(routes, opts) {
3243
3269
  skipLoaderErrorBubbling,
3244
3270
  skipRevalidation,
3245
3271
  dataStrategy,
3246
- generateMiddlewareResponse
3272
+ generateMiddlewareResponse,
3273
+ unstable_normalizePath
3247
3274
  } = {}) {
3248
- let url = new URL(request.url);
3275
+ let normalizePath = unstable_normalizePath || defaultNormalizePath;
3249
3276
  let method = request.method;
3250
- let location = createLocation("", createPath(url), null, "default");
3277
+ let location = createLocation("", normalizePath(request), null, "default");
3251
3278
  let matches = matchRoutes(dataRoutes, location, basename);
3252
3279
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
3253
3280
  if (!isValidMethod(method) && method !== "HEAD") {
@@ -3300,6 +3327,7 @@ function createStaticHandler(routes, opts) {
3300
3327
  let response = await runServerMiddlewarePipeline(
3301
3328
  {
3302
3329
  request,
3330
+ unstable_url: createDataFunctionUrl(request, location),
3303
3331
  unstable_pattern: getRoutePattern(matches),
3304
3332
  matches,
3305
3333
  params: matches[0].params,
@@ -3416,11 +3444,12 @@ function createStaticHandler(routes, opts) {
3416
3444
  routeId,
3417
3445
  requestContext,
3418
3446
  dataStrategy,
3419
- generateMiddlewareResponse
3447
+ generateMiddlewareResponse,
3448
+ unstable_normalizePath
3420
3449
  } = {}) {
3421
- let url = new URL(request.url);
3450
+ let normalizePath = unstable_normalizePath || defaultNormalizePath;
3422
3451
  let method = request.method;
3423
- let location = createLocation("", createPath(url), null, "default");
3452
+ let location = createLocation("", normalizePath(request), null, "default");
3424
3453
  let matches = matchRoutes(dataRoutes, location, basename);
3425
3454
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
3426
3455
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
@@ -3446,6 +3475,7 @@ function createStaticHandler(routes, opts) {
3446
3475
  let response = await runServerMiddlewarePipeline(
3447
3476
  {
3448
3477
  request,
3478
+ unstable_url: createDataFunctionUrl(request, location),
3449
3479
  unstable_pattern: getRoutePattern(matches),
3450
3480
  matches,
3451
3481
  params: matches[0].params,
@@ -3523,6 +3553,7 @@ function createStaticHandler(routes, opts) {
3523
3553
  if (isMutationMethod(request.method)) {
3524
3554
  let result2 = await submit(
3525
3555
  request,
3556
+ location,
3526
3557
  matches,
3527
3558
  routeMatch || getTargetMatch(matches, location),
3528
3559
  requestContext,
@@ -3536,6 +3567,7 @@ function createStaticHandler(routes, opts) {
3536
3567
  }
3537
3568
  let result = await loadRouteData(
3538
3569
  request,
3570
+ location,
3539
3571
  matches,
3540
3572
  requestContext,
3541
3573
  dataStrategy,
@@ -3561,7 +3593,7 @@ function createStaticHandler(routes, opts) {
3561
3593
  throw e;
3562
3594
  }
3563
3595
  }
3564
- async function submit(request, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest, filterMatchesToLoad, skipRevalidation) {
3596
+ async function submit(request, location, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest, filterMatchesToLoad, skipRevalidation) {
3565
3597
  let result;
3566
3598
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
3567
3599
  let error = getInternalRouterError(405, {
@@ -3581,6 +3613,7 @@ function createStaticHandler(routes, opts) {
3581
3613
  mapRouteProperties2,
3582
3614
  manifest,
3583
3615
  request,
3616
+ location,
3584
3617
  matches,
3585
3618
  actionMatch,
3586
3619
  [],
@@ -3588,6 +3621,7 @@ function createStaticHandler(routes, opts) {
3588
3621
  );
3589
3622
  let results = await callDataStrategy(
3590
3623
  request,
3624
+ location,
3591
3625
  dsMatches,
3592
3626
  isRouteRequest,
3593
3627
  requestContext,
@@ -3661,6 +3695,7 @@ function createStaticHandler(routes, opts) {
3661
3695
  let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id);
3662
3696
  let handlerContext2 = await loadRouteData(
3663
3697
  loaderRequest,
3698
+ location,
3664
3699
  matches,
3665
3700
  requestContext,
3666
3701
  dataStrategy,
@@ -3680,6 +3715,7 @@ function createStaticHandler(routes, opts) {
3680
3715
  }
3681
3716
  let handlerContext = await loadRouteData(
3682
3717
  loaderRequest,
3718
+ location,
3683
3719
  matches,
3684
3720
  requestContext,
3685
3721
  dataStrategy,
@@ -3697,7 +3733,7 @@ function createStaticHandler(routes, opts) {
3697
3733
  actionHeaders: result.headers ? { [actionMatch.route.id]: result.headers } : {}
3698
3734
  };
3699
3735
  }
3700
- async function loadRouteData(request, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
3736
+ async function loadRouteData(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
3701
3737
  let isRouteRequest = routeMatch != null;
3702
3738
  if (isRouteRequest && !routeMatch?.route.loader && !routeMatch?.route.lazy) {
3703
3739
  throw getInternalRouterError(400, {
@@ -3712,6 +3748,7 @@ function createStaticHandler(routes, opts) {
3712
3748
  mapRouteProperties2,
3713
3749
  manifest,
3714
3750
  request,
3751
+ location,
3715
3752
  matches,
3716
3753
  routeMatch,
3717
3754
  [],
@@ -3729,6 +3766,7 @@ function createStaticHandler(routes, opts) {
3729
3766
  mapRouteProperties2,
3730
3767
  manifest,
3731
3768
  request,
3769
+ location,
3732
3770
  pattern,
3733
3771
  match,
3734
3772
  [],
@@ -3740,6 +3778,7 @@ function createStaticHandler(routes, opts) {
3740
3778
  mapRouteProperties2,
3741
3779
  manifest,
3742
3780
  request,
3781
+ location,
3743
3782
  pattern,
3744
3783
  match,
3745
3784
  [],
@@ -3761,6 +3800,7 @@ function createStaticHandler(routes, opts) {
3761
3800
  }
3762
3801
  let results = await callDataStrategy(
3763
3802
  request,
3803
+ location,
3764
3804
  dsMatches,
3765
3805
  isRouteRequest,
3766
3806
  requestContext,
@@ -3781,10 +3821,11 @@ function createStaticHandler(routes, opts) {
3781
3821
  matches
3782
3822
  };
3783
3823
  }
3784
- async function callDataStrategy(request, matches, isRouteRequest, requestContext, dataStrategy) {
3824
+ async function callDataStrategy(request, location, matches, isRouteRequest, requestContext, dataStrategy) {
3785
3825
  let results = await callDataStrategyImpl(
3786
3826
  dataStrategy || defaultDataStrategy,
3787
3827
  request,
3828
+ location,
3788
3829
  matches,
3789
3830
  null,
3790
3831
  requestContext,
@@ -3847,6 +3888,14 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
3847
3888
  function isSubmissionNavigation(opts) {
3848
3889
  return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
3849
3890
  }
3891
+ function defaultNormalizePath(request) {
3892
+ let url = new URL(request.url);
3893
+ return {
3894
+ pathname: url.pathname,
3895
+ search: url.search,
3896
+ hash: url.hash
3897
+ };
3898
+ }
3850
3899
  function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
3851
3900
  let contextualMatches;
3852
3901
  let activeRouteMatch;
@@ -4032,11 +4081,12 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4032
4081
  } else if (!routeHasLoaderOrMiddleware(route)) {
4033
4082
  forceShouldLoad = false;
4034
4083
  } else if (initialHydration) {
4035
- forceShouldLoad = shouldLoadRouteOnHydration(
4084
+ let { shouldLoad: shouldLoad2 } = getRouteHydrationStatus(
4036
4085
  route,
4037
4086
  state.loaderData,
4038
4087
  state.errors
4039
4088
  );
4089
+ forceShouldLoad = shouldLoad2;
4040
4090
  } else if (isNewLoader(state.loaderData, state.matches[index], match)) {
4041
4091
  forceShouldLoad = true;
4042
4092
  }
@@ -4045,6 +4095,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4045
4095
  mapRouteProperties2,
4046
4096
  manifest,
4047
4097
  request,
4098
+ location,
4048
4099
  pattern,
4049
4100
  match,
4050
4101
  lazyRoutePropertiesToSkip,
@@ -4075,6 +4126,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4075
4126
  mapRouteProperties2,
4076
4127
  manifest,
4077
4128
  request,
4129
+ location,
4078
4130
  pattern,
4079
4131
  match,
4080
4132
  lazyRoutePropertiesToSkip,
@@ -4124,6 +4176,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4124
4176
  mapRouteProperties2,
4125
4177
  manifest,
4126
4178
  fetchRequest,
4179
+ f.path,
4127
4180
  fetcherMatches,
4128
4181
  fetcherMatch,
4129
4182
  lazyRoutePropertiesToSkip,
@@ -4135,6 +4188,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4135
4188
  mapRouteProperties2,
4136
4189
  manifest,
4137
4190
  fetchRequest,
4191
+ f.path,
4138
4192
  fetcherMatches,
4139
4193
  fetcherMatch,
4140
4194
  lazyRoutePropertiesToSkip,
@@ -4159,6 +4213,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4159
4213
  mapRouteProperties2,
4160
4214
  manifest,
4161
4215
  fetchRequest,
4216
+ f.path,
4162
4217
  fetcherMatches,
4163
4218
  fetcherMatch,
4164
4219
  lazyRoutePropertiesToSkip,
@@ -4184,22 +4239,23 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4184
4239
  function routeHasLoaderOrMiddleware(route) {
4185
4240
  return route.loader != null || route.middleware != null && route.middleware.length > 0;
4186
4241
  }
4187
- function shouldLoadRouteOnHydration(route, loaderData, errors) {
4242
+ function getRouteHydrationStatus(route, loaderData, errors) {
4188
4243
  if (route.lazy) {
4189
- return true;
4244
+ return { shouldLoad: true, renderFallback: true };
4190
4245
  }
4191
4246
  if (!routeHasLoaderOrMiddleware(route)) {
4192
- return false;
4247
+ return { shouldLoad: false, renderFallback: false };
4193
4248
  }
4194
4249
  let hasData = loaderData != null && route.id in loaderData;
4195
4250
  let hasError = errors != null && errors[route.id] !== void 0;
4196
4251
  if (!hasData && hasError) {
4197
- return false;
4252
+ return { shouldLoad: false, renderFallback: false };
4198
4253
  }
4199
4254
  if (typeof route.loader === "function" && route.loader.hydrate === true) {
4200
- return true;
4255
+ return { shouldLoad: true, renderFallback: !hasData };
4201
4256
  }
4202
- return !hasData && !hasError;
4257
+ let shouldLoad = !hasData && !hasError;
4258
+ return { shouldLoad, renderFallback: shouldLoad };
4203
4259
  }
4204
4260
  function isNewLoader(currentLoaderData, currentMatch, match) {
4205
4261
  let isNew = (
@@ -4542,17 +4598,12 @@ function runClientMiddlewarePipeline(args, handler) {
4542
4598
  }
4543
4599
  }
4544
4600
  async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
4545
- let { matches, request, params, context, unstable_pattern } = args;
4601
+ let { matches, ...dataFnArgs } = args;
4546
4602
  let tuples = matches.flatMap(
4547
4603
  (m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
4548
4604
  );
4549
4605
  let result = await callRouteMiddleware(
4550
- {
4551
- request,
4552
- params,
4553
- context,
4554
- unstable_pattern
4555
- },
4606
+ dataFnArgs,
4556
4607
  tuples,
4557
4608
  handler,
4558
4609
  processResult,
@@ -4630,7 +4681,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
4630
4681
  handler: lazyRoutePromises.lazyHandlerPromise
4631
4682
  };
4632
4683
  }
4633
- function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
4684
+ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
4634
4685
  let isUsingNewApi = false;
4635
4686
  let _lazyPromises = getDataStrategyMatchLazyPromises(
4636
4687
  mapRouteProperties2,
@@ -4670,6 +4721,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
4670
4721
  if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) {
4671
4722
  return callLoaderOrAction({
4672
4723
  request,
4724
+ path,
4673
4725
  unstable_pattern,
4674
4726
  match,
4675
4727
  lazyHandlerPromise: _lazyPromises?.handler,
@@ -4682,7 +4734,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
4682
4734
  }
4683
4735
  };
4684
4736
  }
4685
- function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
4737
+ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, path, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
4686
4738
  return matches.map((match) => {
4687
4739
  if (match.route.id !== targetMatch.route.id) {
4688
4740
  return {
@@ -4704,6 +4756,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
4704
4756
  mapRouteProperties2,
4705
4757
  manifest,
4706
4758
  request,
4759
+ path,
4707
4760
  getRoutePattern(matches),
4708
4761
  match,
4709
4762
  lazyRoutePropertiesToSkip,
@@ -4713,12 +4766,13 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
4713
4766
  );
4714
4767
  });
4715
4768
  }
4716
- async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherKey, scopedContext, isStaticHandler) {
4769
+ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fetcherKey, scopedContext, isStaticHandler) {
4717
4770
  if (matches.some((m) => m._lazyPromises?.middleware)) {
4718
4771
  await Promise.all(matches.map((m) => m._lazyPromises?.middleware));
4719
4772
  }
4720
4773
  let dataStrategyArgs = {
4721
4774
  request,
4775
+ unstable_url: createDataFunctionUrl(request, path),
4722
4776
  unstable_pattern: getRoutePattern(matches),
4723
4777
  params: matches[0].params,
4724
4778
  context: scopedContext,
@@ -4760,6 +4814,7 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
4760
4814
  }
4761
4815
  async function callLoaderOrAction({
4762
4816
  request,
4817
+ path,
4763
4818
  unstable_pattern,
4764
4819
  match,
4765
4820
  lazyHandlerPromise,
@@ -4787,6 +4842,7 @@ async function callLoaderOrAction({
4787
4842
  return handler(
4788
4843
  {
4789
4844
  request,
4845
+ unstable_url: createDataFunctionUrl(request, path),
4790
4846
  unstable_pattern,
4791
4847
  params: match.params,
4792
4848
  context: scopedContext
@@ -4997,6 +5053,24 @@ function createClientSideRequest(history, location, signal, submission) {
4997
5053
  }
4998
5054
  return new Request(url, init);
4999
5055
  }
5056
+ function createDataFunctionUrl(request, path) {
5057
+ let url = new URL(request.url);
5058
+ let parsed = typeof path === "string" ? parsePath(path) : path;
5059
+ url.pathname = parsed.pathname || "/";
5060
+ if (parsed.search) {
5061
+ let searchParams = new URLSearchParams(parsed.search);
5062
+ let indexValues = searchParams.getAll("index");
5063
+ searchParams.delete("index");
5064
+ for (let value of indexValues.filter(Boolean)) {
5065
+ searchParams.append("index", value);
5066
+ }
5067
+ url.search = searchParams.size ? `?${searchParams.toString()}` : "";
5068
+ } else {
5069
+ url.search = "";
5070
+ }
5071
+ url.hash = parsed.hash || "";
5072
+ return url;
5073
+ }
5000
5074
  function convertFormDataToSearchParams(formData) {
5001
5075
  let searchParams = new URLSearchParams();
5002
5076
  for (let [key, value] of formData.entries()) {
@@ -5677,7 +5751,7 @@ function useResolvedPath(to, { relative } = {}) {
5677
5751
  function useRoutes(routes, locationArg) {
5678
5752
  return useRoutesImpl(routes, locationArg);
5679
5753
  }
5680
- function useRoutesImpl(routes, locationArg, dataRouterState, onError, future) {
5754
+ function useRoutesImpl(routes, locationArg, dataRouterOpts) {
5681
5755
  invariant(
5682
5756
  useInRouterContext(),
5683
5757
  // TODO: This error is probably because they somehow have 2 versions of the
@@ -5758,9 +5832,7 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5758
5832
  })
5759
5833
  ),
5760
5834
  parentMatches,
5761
- dataRouterState,
5762
- onError,
5763
- future
5835
+ dataRouterOpts
5764
5836
  );
5765
5837
  if (locationArg && renderedMatches) {
5766
5838
  return /* @__PURE__ */ React2.createElement(
@@ -5901,7 +5973,8 @@ function RenderedRoute({ routeContext, match, children }) {
5901
5973
  }
5902
5974
  return /* @__PURE__ */ React2.createElement(RouteContext.Provider, { value: routeContext }, children);
5903
5975
  }
5904
- function _renderMatches(matches, parentMatches = [], dataRouterState = null, onErrorHandler = null, future = null) {
5976
+ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
5977
+ let dataRouterState = dataRouterOpts?.state;
5905
5978
  if (matches == null) {
5906
5979
  if (!dataRouterState) {
5907
5980
  return null;
@@ -5933,7 +6006,8 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, onE
5933
6006
  }
5934
6007
  let renderFallback = false;
5935
6008
  let fallbackIndex = -1;
5936
- if (dataRouterState) {
6009
+ if (dataRouterOpts && dataRouterState) {
6010
+ renderFallback = dataRouterState.renderFallback;
5937
6011
  for (let i = 0; i < renderedMatches.length; i++) {
5938
6012
  let match = renderedMatches[i];
5939
6013
  if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
@@ -5943,7 +6017,9 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, onE
5943
6017
  let { loaderData, errors: errors2 } = dataRouterState;
5944
6018
  let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
5945
6019
  if (match.route.lazy || needsToRunLoader) {
5946
- renderFallback = true;
6020
+ if (dataRouterOpts.isStatic) {
6021
+ renderFallback = true;
6022
+ }
5947
6023
  if (fallbackIndex >= 0) {
5948
6024
  renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
5949
6025
  } else {
@@ -5954,6 +6030,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterState = null, onE
5954
6030
  }
5955
6031
  }
5956
6032
  }
6033
+ let onErrorHandler = dataRouterOpts?.onError;
5957
6034
  let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
5958
6035
  onErrorHandler(error, {
5959
6036
  location: dataRouterState.location,
@@ -6522,6 +6599,7 @@ function RouterProvider({
6522
6599
  routes: router.routes,
6523
6600
  future: router.future,
6524
6601
  state,
6602
+ isStatic: false,
6525
6603
  onError
6526
6604
  }
6527
6605
  )
@@ -6546,9 +6624,10 @@ function DataRoutes({
6546
6624
  routes,
6547
6625
  future,
6548
6626
  state,
6627
+ isStatic,
6549
6628
  onError
6550
6629
  }) {
6551
- return useRoutesImpl(routes, void 0, state, onError, future);
6630
+ return useRoutesImpl(routes, void 0, { state, isStatic, onError, future });
6552
6631
  }
6553
6632
  function MemoryRouter({
6554
6633
  basename,
@@ -7102,7 +7181,10 @@ function createLineSplittingTransform() {
7102
7181
  }
7103
7182
 
7104
7183
  // vendor/turbo-stream-v2/flatten.ts
7105
- function flatten(input) {
7184
+ var TIME_LIMIT_MS = 1;
7185
+ var getNow = () => Date.now();
7186
+ var yieldToMain = () => new Promise((resolve) => setTimeout(resolve, 0));
7187
+ async function flatten(input) {
7106
7188
  const { indices } = this;
7107
7189
  const existing = indices.get(input);
7108
7190
  if (existing) return [existing];
@@ -7114,55 +7196,76 @@ function flatten(input) {
7114
7196
  if (input === 0 && 1 / input < 0) return NEGATIVE_ZERO;
7115
7197
  const index = this.index++;
7116
7198
  indices.set(input, index);
7117
- stringify.call(this, input, index);
7199
+ const stack = [[input, index]];
7200
+ await stringify.call(this, stack);
7118
7201
  return index;
7119
7202
  }
7120
- function stringify(input, index) {
7121
- const { deferred, plugins, postPlugins } = this;
7203
+ async function stringify(stack) {
7204
+ const { deferred, indices, plugins, postPlugins } = this;
7122
7205
  const str = this.stringified;
7123
- const stack = [[input, index]];
7206
+ let lastYieldTime = getNow();
7207
+ const flattenValue = (value) => {
7208
+ const existing = indices.get(value);
7209
+ if (existing) return [existing];
7210
+ if (value === void 0) return UNDEFINED;
7211
+ if (value === null) return NULL;
7212
+ if (Number.isNaN(value)) return NAN;
7213
+ if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY;
7214
+ if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY;
7215
+ if (value === 0 && 1 / value < 0) return NEGATIVE_ZERO;
7216
+ const index = this.index++;
7217
+ indices.set(value, index);
7218
+ stack.push([value, index]);
7219
+ return index;
7220
+ };
7221
+ let i = 0;
7124
7222
  while (stack.length > 0) {
7125
- const [input2, index2] = stack.pop();
7126
- const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
7223
+ const now = getNow();
7224
+ if (++i % 6e3 === 0 && now - lastYieldTime >= TIME_LIMIT_MS) {
7225
+ await yieldToMain();
7226
+ lastYieldTime = getNow();
7227
+ }
7228
+ const [input, index] = stack.pop();
7229
+ const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flattenValue(k)}":${flattenValue(obj[k])}`).join(",");
7127
7230
  let error = null;
7128
- switch (typeof input2) {
7231
+ switch (typeof input) {
7129
7232
  case "boolean":
7130
7233
  case "number":
7131
7234
  case "string":
7132
- str[index2] = JSON.stringify(input2);
7235
+ str[index] = JSON.stringify(input);
7133
7236
  break;
7134
7237
  case "bigint":
7135
- str[index2] = `["${TYPE_BIGINT}","${input2}"]`;
7238
+ str[index] = `["${TYPE_BIGINT}","${input}"]`;
7136
7239
  break;
7137
7240
  case "symbol": {
7138
- const keyFor = Symbol.keyFor(input2);
7241
+ const keyFor = Symbol.keyFor(input);
7139
7242
  if (!keyFor) {
7140
7243
  error = new Error(
7141
7244
  "Cannot encode symbol unless created with Symbol.for()"
7142
7245
  );
7143
7246
  } else {
7144
- str[index2] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
7247
+ str[index] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
7145
7248
  }
7146
7249
  break;
7147
7250
  }
7148
7251
  case "object": {
7149
- if (!input2) {
7150
- str[index2] = `${NULL}`;
7252
+ if (!input) {
7253
+ str[index] = `${NULL}`;
7151
7254
  break;
7152
7255
  }
7153
- const isArray = Array.isArray(input2);
7256
+ const isArray = Array.isArray(input);
7154
7257
  let pluginHandled = false;
7155
7258
  if (!isArray && plugins) {
7156
7259
  for (const plugin of plugins) {
7157
- const pluginResult = plugin(input2);
7260
+ const pluginResult = plugin(input);
7158
7261
  if (Array.isArray(pluginResult)) {
7159
7262
  pluginHandled = true;
7160
7263
  const [pluginIdentifier, ...rest] = pluginResult;
7161
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
7264
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
7162
7265
  if (rest.length > 0) {
7163
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
7266
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
7164
7267
  }
7165
- str[index2] += "]";
7268
+ str[index] += "]";
7166
7269
  break;
7167
7270
  }
7168
7271
  }
@@ -7170,46 +7273,43 @@ function stringify(input, index) {
7170
7273
  if (!pluginHandled) {
7171
7274
  let result = isArray ? "[" : "{";
7172
7275
  if (isArray) {
7173
- for (let i = 0; i < input2.length; i++)
7174
- result += (i ? "," : "") + (i in input2 ? flatten.call(this, input2[i]) : HOLE);
7175
- str[index2] = `${result}]`;
7176
- } else if (input2 instanceof Date) {
7177
- const dateTime = input2.getTime();
7178
- str[index2] = `["${TYPE_DATE}",${Number.isNaN(dateTime) ? JSON.stringify("invalid") : dateTime}]`;
7179
- } else if (input2 instanceof URL) {
7180
- str[index2] = `["${TYPE_URL}",${JSON.stringify(input2.href)}]`;
7181
- } else if (input2 instanceof RegExp) {
7182
- str[index2] = `["${TYPE_REGEXP}",${JSON.stringify(
7183
- input2.source
7184
- )},${JSON.stringify(input2.flags)}]`;
7185
- } else if (input2 instanceof Set) {
7186
- if (input2.size > 0) {
7187
- str[index2] = `["${TYPE_SET}",${[...input2].map((val) => flatten.call(this, val)).join(",")}]`;
7276
+ for (let i2 = 0; i2 < input.length; i2++)
7277
+ result += (i2 ? "," : "") + (i2 in input ? flattenValue(input[i2]) : HOLE);
7278
+ str[index] = `${result}]`;
7279
+ } else if (input instanceof Date) {
7280
+ const dateTime = input.getTime();
7281
+ str[index] = `["${TYPE_DATE}",${Number.isNaN(dateTime) ? JSON.stringify("invalid") : dateTime}]`;
7282
+ } else if (input instanceof URL) {
7283
+ str[index] = `["${TYPE_URL}",${JSON.stringify(input.href)}]`;
7284
+ } else if (input instanceof RegExp) {
7285
+ str[index] = `["${TYPE_REGEXP}",${JSON.stringify(
7286
+ input.source
7287
+ )},${JSON.stringify(input.flags)}]`;
7288
+ } else if (input instanceof Set) {
7289
+ if (input.size > 0) {
7290
+ str[index] = `["${TYPE_SET}",${[...input].map((val) => flattenValue(val)).join(",")}]`;
7188
7291
  } else {
7189
- str[index2] = `["${TYPE_SET}"]`;
7292
+ str[index] = `["${TYPE_SET}"]`;
7190
7293
  }
7191
- } else if (input2 instanceof Map) {
7192
- if (input2.size > 0) {
7193
- str[index2] = `["${TYPE_MAP}",${[...input2].flatMap(([k, v]) => [
7194
- flatten.call(this, k),
7195
- flatten.call(this, v)
7196
- ]).join(",")}]`;
7294
+ } else if (input instanceof Map) {
7295
+ if (input.size > 0) {
7296
+ str[index] = `["${TYPE_MAP}",${[...input].flatMap(([k, v]) => [flattenValue(k), flattenValue(v)]).join(",")}]`;
7197
7297
  } else {
7198
- str[index2] = `["${TYPE_MAP}"]`;
7298
+ str[index] = `["${TYPE_MAP}"]`;
7199
7299
  }
7200
- } else if (input2 instanceof Promise) {
7201
- str[index2] = `["${TYPE_PROMISE}",${index2}]`;
7202
- deferred[index2] = input2;
7203
- } else if (input2 instanceof Error) {
7204
- str[index2] = `["${TYPE_ERROR}",${JSON.stringify(input2.message)}`;
7205
- if (input2.name !== "Error") {
7206
- str[index2] += `,${JSON.stringify(input2.name)}`;
7300
+ } else if (input instanceof Promise) {
7301
+ str[index] = `["${TYPE_PROMISE}",${index}]`;
7302
+ deferred[index] = input;
7303
+ } else if (input instanceof Error) {
7304
+ str[index] = `["${TYPE_ERROR}",${JSON.stringify(input.message)}`;
7305
+ if (input.name !== "Error") {
7306
+ str[index] += `,${JSON.stringify(input.name)}`;
7207
7307
  }
7208
- str[index2] += "]";
7209
- } else if (Object.getPrototypeOf(input2) === null) {
7210
- str[index2] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input2)}}]`;
7211
- } else if (isPlainObject2(input2)) {
7212
- str[index2] = `{${partsForObj(input2)}}`;
7308
+ str[index] += "]";
7309
+ } else if (Object.getPrototypeOf(input) === null) {
7310
+ str[index] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input)}}]`;
7311
+ } else if (isPlainObject2(input)) {
7312
+ str[index] = `{${partsForObj(input)}}`;
7213
7313
  } else {
7214
7314
  error = new Error("Cannot encode object with prototype");
7215
7315
  }
@@ -7217,19 +7317,19 @@ function stringify(input, index) {
7217
7317
  break;
7218
7318
  }
7219
7319
  default: {
7220
- const isArray = Array.isArray(input2);
7320
+ const isArray = Array.isArray(input);
7221
7321
  let pluginHandled = false;
7222
7322
  if (!isArray && plugins) {
7223
7323
  for (const plugin of plugins) {
7224
- const pluginResult = plugin(input2);
7324
+ const pluginResult = plugin(input);
7225
7325
  if (Array.isArray(pluginResult)) {
7226
7326
  pluginHandled = true;
7227
7327
  const [pluginIdentifier, ...rest] = pluginResult;
7228
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
7328
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
7229
7329
  if (rest.length > 0) {
7230
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
7330
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
7231
7331
  }
7232
- str[index2] += "]";
7332
+ str[index] += "]";
7233
7333
  break;
7234
7334
  }
7235
7335
  }
@@ -7243,15 +7343,15 @@ function stringify(input, index) {
7243
7343
  let pluginHandled = false;
7244
7344
  if (postPlugins) {
7245
7345
  for (const plugin of postPlugins) {
7246
- const pluginResult = plugin(input2);
7346
+ const pluginResult = plugin(input);
7247
7347
  if (Array.isArray(pluginResult)) {
7248
7348
  pluginHandled = true;
7249
7349
  const [pluginIdentifier, ...rest] = pluginResult;
7250
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
7350
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
7251
7351
  if (rest.length > 0) {
7252
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
7352
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
7253
7353
  }
7254
- str[index2] += "]";
7354
+ str[index] += "]";
7255
7355
  break;
7256
7356
  }
7257
7357
  }
@@ -7588,7 +7688,7 @@ async function decodeDeferred(reader) {
7588
7688
  }
7589
7689
  }
7590
7690
  function encode(input, options) {
7591
- const { plugins, postPlugins, signal } = options ?? {};
7691
+ const { onComplete, plugins, postPlugins, signal } = options ?? {};
7592
7692
  const encoder = {
7593
7693
  deferred: {},
7594
7694
  index: 0,
@@ -7602,7 +7702,7 @@ function encode(input, options) {
7602
7702
  let lastSentIndex = 0;
7603
7703
  const readable = new ReadableStream({
7604
7704
  async start(controller) {
7605
- const id = flatten.call(encoder, input);
7705
+ const id = await flatten.call(encoder, input);
7606
7706
  if (Array.isArray(id)) {
7607
7707
  throw new Error("This should never happen");
7608
7708
  }
@@ -7617,6 +7717,7 @@ function encode(input, options) {
7617
7717
  lastSentIndex = encoder.stringified.length - 1;
7618
7718
  }
7619
7719
  const seenPromises = /* @__PURE__ */ new WeakSet();
7720
+ let processingChain = Promise.resolve();
7620
7721
  if (Object.keys(encoder.deferred).length) {
7621
7722
  let raceDone;
7622
7723
  const racePromise = new Promise((resolve, reject) => {
@@ -7644,65 +7745,71 @@ function encode(input, options) {
7644
7745
  deferred
7645
7746
  ]).then(
7646
7747
  (resolved) => {
7647
- const id2 = flatten.call(encoder, resolved);
7648
- if (Array.isArray(id2)) {
7649
- controller.enqueue(
7650
- textEncoder.encode(
7651
- `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
7748
+ processingChain = processingChain.then(async () => {
7749
+ const id2 = await flatten.call(encoder, resolved);
7750
+ if (Array.isArray(id2)) {
7751
+ controller.enqueue(
7752
+ textEncoder.encode(
7753
+ `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
7652
7754
  `
7653
- )
7654
- );
7655
- encoder.index++;
7656
- lastSentIndex++;
7657
- } else if (id2 < 0) {
7658
- controller.enqueue(
7659
- textEncoder.encode(
7660
- `${TYPE_PROMISE}${deferredId}:${id2}
7755
+ )
7756
+ );
7757
+ encoder.index++;
7758
+ lastSentIndex++;
7759
+ } else if (id2 < 0) {
7760
+ controller.enqueue(
7761
+ textEncoder.encode(
7762
+ `${TYPE_PROMISE}${deferredId}:${id2}
7661
7763
  `
7662
- )
7663
- );
7664
- } else {
7665
- const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
7666
- controller.enqueue(
7667
- textEncoder.encode(
7668
- `${TYPE_PROMISE}${deferredId}:[${values}]
7764
+ )
7765
+ );
7766
+ } else {
7767
+ const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
7768
+ controller.enqueue(
7769
+ textEncoder.encode(
7770
+ `${TYPE_PROMISE}${deferredId}:[${values}]
7669
7771
  `
7670
- )
7671
- );
7672
- lastSentIndex = encoder.stringified.length - 1;
7673
- }
7772
+ )
7773
+ );
7774
+ lastSentIndex = encoder.stringified.length - 1;
7775
+ }
7776
+ });
7777
+ return processingChain;
7674
7778
  },
7675
7779
  (reason) => {
7676
- if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
7677
- reason = new Error("An unknown error occurred");
7678
- }
7679
- const id2 = flatten.call(encoder, reason);
7680
- if (Array.isArray(id2)) {
7681
- controller.enqueue(
7682
- textEncoder.encode(
7683
- `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
7780
+ processingChain = processingChain.then(async () => {
7781
+ if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
7782
+ reason = new Error("An unknown error occurred");
7783
+ }
7784
+ const id2 = await flatten.call(encoder, reason);
7785
+ if (Array.isArray(id2)) {
7786
+ controller.enqueue(
7787
+ textEncoder.encode(
7788
+ `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
7684
7789
  `
7685
- )
7686
- );
7687
- encoder.index++;
7688
- lastSentIndex++;
7689
- } else if (id2 < 0) {
7690
- controller.enqueue(
7691
- textEncoder.encode(
7692
- `${TYPE_ERROR}${deferredId}:${id2}
7790
+ )
7791
+ );
7792
+ encoder.index++;
7793
+ lastSentIndex++;
7794
+ } else if (id2 < 0) {
7795
+ controller.enqueue(
7796
+ textEncoder.encode(
7797
+ `${TYPE_ERROR}${deferredId}:${id2}
7693
7798
  `
7694
- )
7695
- );
7696
- } else {
7697
- const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
7698
- controller.enqueue(
7699
- textEncoder.encode(
7700
- `${TYPE_ERROR}${deferredId}:[${values}]
7799
+ )
7800
+ );
7801
+ } else {
7802
+ const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
7803
+ controller.enqueue(
7804
+ textEncoder.encode(
7805
+ `${TYPE_ERROR}${deferredId}:[${values}]
7701
7806
  `
7702
- )
7703
- );
7704
- lastSentIndex = encoder.stringified.length - 1;
7705
- }
7807
+ )
7808
+ );
7809
+ lastSentIndex = encoder.stringified.length - 1;
7810
+ }
7811
+ });
7812
+ return processingChain;
7706
7813
  }
7707
7814
  ).finally(() => {
7708
7815
  delete encoder.deferred[Number(deferredId)];
@@ -7714,7 +7821,9 @@ function encode(input, options) {
7714
7821
  raceDone();
7715
7822
  }
7716
7823
  await Promise.all(Object.values(encoder.deferred));
7824
+ await processingChain;
7717
7825
  controller.close();
7826
+ onComplete?.();
7718
7827
  }
7719
7828
  });
7720
7829
  return readable;
@@ -8705,7 +8814,13 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
8705
8814
  let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
8706
8815
  let initialError = hasInitialError ? initialState?.errors?.[route.id] : void 0;
8707
8816
  let isHydrationRequest = needsRevalidation == null && (routeModule.clientLoader?.hydrate === true || !route.hasLoader);
8708
- dataRoute.loader = async ({ request, params, context, unstable_pattern }, singleFetch) => {
8817
+ dataRoute.loader = async ({
8818
+ request,
8819
+ params,
8820
+ context,
8821
+ unstable_pattern,
8822
+ unstable_url
8823
+ }, singleFetch) => {
8709
8824
  try {
8710
8825
  let result = await prefetchStylesAndCallHandler(async () => {
8711
8826
  invariant2(
@@ -8720,6 +8835,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
8720
8835
  params,
8721
8836
  context,
8722
8837
  unstable_pattern,
8838
+ unstable_url,
8723
8839
  async serverLoader() {
8724
8840
  preventInvalidServerHandlerCall("loader", route);
8725
8841
  if (isHydrationRequest) {
@@ -8745,7 +8861,13 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
8745
8861
  route.hasLoader,
8746
8862
  isSpaMode
8747
8863
  );
8748
- dataRoute.action = ({ request, params, context, unstable_pattern }, singleFetch) => {
8864
+ dataRoute.action = ({
8865
+ request,
8866
+ params,
8867
+ context,
8868
+ unstable_pattern,
8869
+ unstable_url
8870
+ }, singleFetch) => {
8749
8871
  return prefetchStylesAndCallHandler(async () => {
8750
8872
  invariant2(
8751
8873
  routeModule,
@@ -8762,6 +8884,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
8762
8884
  params,
8763
8885
  context,
8764
8886
  unstable_pattern,
8887
+ unstable_url,
8765
8888
  async serverAction() {
8766
8889
  preventInvalidServerHandlerCall("action", route);
8767
8890
  return fetchServerAction(singleFetch);
@@ -8971,7 +9094,7 @@ function getPartialManifest({ sri, ...manifest }, router) {
8971
9094
  sri: sri ? true : void 0
8972
9095
  };
8973
9096
  }
8974
- function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename) {
9097
+ function getPatchRoutesOnNavigationFunction(getRouter, manifest, routeModules, ssr, routeDiscovery, isSpaMode, basename) {
8975
9098
  if (!isFogOfWarEnabled(routeDiscovery, ssr)) {
8976
9099
  return void 0;
8977
9100
  }
@@ -8979,9 +9102,12 @@ function getPatchRoutesOnNavigationFunction(manifest, routeModules, ssr, routeDi
8979
9102
  if (discoveredPaths.has(path)) {
8980
9103
  return;
8981
9104
  }
9105
+ let { state } = getRouter();
8982
9106
  await fetchAndApplyManifestPatches(
8983
9107
  [path],
8984
- fetcherKey ? window.location.href : path,
9108
+ // If we're patching for a fetcher call, reload the current location
9109
+ // Otherwise prefer any ongoing navigation location
9110
+ fetcherKey ? window.location.href : createPath(state.navigation.location || state.location),
8985
9111
  manifest,
8986
9112
  routeModules,
8987
9113
  ssr,
@@ -9467,7 +9593,7 @@ function Meta() {
9467
9593
  routeMeta = routeMeta || [];
9468
9594
  if (!Array.isArray(routeMeta)) {
9469
9595
  throw new Error(
9470
- "The route at " + _match.route.path + " returns an invalid value. All route meta functions must return an array of meta objects.\n\nTo reference the meta function API, see https://remix.run/route/meta"
9596
+ "The route at " + _match.route.path + " returns an invalid value. All route meta functions must return an array of meta objects.\n\nTo reference the meta function API, see https://reactrouter.com/start/framework/route-module#meta"
9471
9597
  );
9472
9598
  }
9473
9599
  match.meta = routeMeta;
@@ -9549,17 +9675,8 @@ function Scripts(scriptProps) {
9549
9675
  if (isRSCRouterContext) {
9550
9676
  return null;
9551
9677
  }
9552
- let maskScript = ssr ? [
9553
- "if (window.history.state && window.history.state.unstable_maskFrom) {",
9554
- "window.history.replaceState({ ...window.history.state, unstable_maskFrom: undefined }, null);",
9555
- "}"
9556
- ].join("") : "";
9557
9678
  let streamScript = "window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());";
9558
- let contextScript = staticContext ? [
9559
- `window.__reactRouterContext = ${serverHandoffString};`,
9560
- maskScript,
9561
- streamScript
9562
- ].join("\n") : " ";
9679
+ let contextScript = staticContext ? `window.__reactRouterContext = ${serverHandoffString};${streamScript}` : " ";
9563
9680
  let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}${!enableFogOfWar ? `import ${JSON.stringify(manifest.url)}` : ""};
9564
9681
  ${matches.map((match, routeIndex) => {
9565
9682
  let routeVarName = `route${routeIndex}`;
@@ -9809,7 +9926,7 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
9809
9926
  try {
9810
9927
  if (isBrowser2) {
9811
9928
  window.__reactRouterVersion = // @ts-expect-error
9812
- "0.0.0-experimental-e067e5e52";
9929
+ "0.0.0-experimental-567b27f71";
9813
9930
  }
9814
9931
  } catch (e) {
9815
9932
  }
@@ -10058,6 +10175,7 @@ var Link = React10.forwardRef(
10058
10175
  internalOnClick(event);
10059
10176
  }
10060
10177
  }
10178
+ let isSpaLink = !(parsed.isExternal || reloadDocument);
10061
10179
  let link = (
10062
10180
  // eslint-disable-next-line jsx-a11y/anchor-has-content
10063
10181
  /* @__PURE__ */ React10.createElement(
@@ -10065,8 +10183,8 @@ var Link = React10.forwardRef(
10065
10183
  {
10066
10184
  ...rest,
10067
10185
  ...prefetchHandlers,
10068
- href: (!(parsed.isExternal || reloadDocument) ? maskedHref : void 0) || parsed.absoluteURL || href,
10069
- onClick: parsed.isExternal || reloadDocument ? onClick : handleClick,
10186
+ href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
10187
+ onClick: isSpaLink ? handleClick : onClick,
10070
10188
  ref: mergeRefs(forwardedRef, prefetchRef),
10071
10189
  target,
10072
10190
  "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
@@ -10752,11 +10870,12 @@ function StaticRouterProvider({
10752
10870
  unstable_useTransitions: false
10753
10871
  },
10754
10872
  /* @__PURE__ */ React11.createElement(
10755
- DataRoutes2,
10873
+ DataRoutes,
10756
10874
  {
10757
10875
  routes: router.routes,
10758
10876
  future: router.future,
10759
- state
10877
+ state,
10878
+ isStatic: true
10760
10879
  }
10761
10880
  )
10762
10881
  ))))), hydrateScript ? /* @__PURE__ */ React11.createElement(
@@ -10768,13 +10887,6 @@ function StaticRouterProvider({
10768
10887
  }
10769
10888
  ) : null);
10770
10889
  }
10771
- function DataRoutes2({
10772
- routes,
10773
- future,
10774
- state
10775
- }) {
10776
- return useRoutesImpl(routes, void 0, state, void 0, future);
10777
- }
10778
10890
  function serializeErrors(errors) {
10779
10891
  if (!errors) return null;
10780
10892
  let entries = Object.entries(errors);
@@ -10858,6 +10970,7 @@ function createStaticRouter(routes, context, opts = {}) {
10858
10970
  get future() {
10859
10971
  return {
10860
10972
  v8_middleware: false,
10973
+ unstable_passThroughRequests: false,
10861
10974
  ...opts?.future
10862
10975
  };
10863
10976
  },
@@ -10870,6 +10983,7 @@ function createStaticRouter(routes, context, opts = {}) {
10870
10983
  actionData: context.actionData,
10871
10984
  errors: context.errors,
10872
10985
  initialized: true,
10986
+ renderFallback: false,
10873
10987
  navigation: IDLE_NAVIGATION,
10874
10988
  restoreScrollPosition: null,
10875
10989
  preventScrollReset: false,