react-router 0.0.0-experimental-917e6fdc0 → 0.0.0-experimental-7aea711dd

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 (155) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/development/dom-export.js +1 -1
  3. package/dist/development/index-react-server-client.js +1 -1
  4. package/dist/development/index-react-server.d.ts +34 -48
  5. package/dist/development/index-react-server.js +269 -34
  6. package/dist/development/index.d.ts +2 -2
  7. package/dist/development/index.js +3 -3
  8. package/dist/development/lib/actions.js +1 -1
  9. package/dist/development/lib/components.js +45 -8
  10. package/dist/development/lib/context.d.ts +13 -5
  11. package/dist/development/lib/context.js +11 -3
  12. package/dist/development/lib/dom/dom.js +1 -1
  13. package/dist/development/lib/dom/lib.js +14 -32
  14. package/dist/development/lib/dom/server.d.ts +6 -1
  15. package/dist/development/lib/dom/server.js +40 -14
  16. package/dist/development/lib/dom/ssr/components.js +15 -23
  17. package/dist/development/lib/dom/ssr/data.js +1 -1
  18. package/dist/development/lib/dom/ssr/entry.d.ts +4 -0
  19. package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
  20. package/dist/development/lib/dom/ssr/fallback.js +1 -1
  21. package/dist/development/lib/dom/ssr/fog-of-war.js +3 -3
  22. package/dist/development/lib/dom/ssr/hydration.d.ts +3 -1
  23. package/dist/development/lib/dom/ssr/hydration.js +6 -4
  24. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  25. package/dist/development/lib/dom/ssr/links.js +1 -1
  26. package/dist/development/lib/dom/ssr/markup.js +1 -1
  27. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  28. package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
  29. package/dist/development/lib/dom/ssr/routes.js +1 -1
  30. package/dist/development/lib/dom/ssr/server.js +2 -2
  31. package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
  32. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  33. package/dist/development/lib/dom-export/hydrated-router.js +2 -1
  34. package/dist/development/lib/errors.js +1 -1
  35. package/dist/development/lib/hooks.js +49 -44
  36. package/dist/development/lib/href.js +1 -1
  37. package/dist/development/lib/router/history.js +1 -1
  38. package/dist/development/lib/router/instrumentation.js +1 -1
  39. package/dist/development/lib/router/matcher-route-pattern.js +216 -0
  40. package/dist/development/lib/router/matcher.d.ts +2 -0
  41. package/dist/development/lib/router/matcher.js +29 -0
  42. package/dist/development/lib/router/navigation.js +1 -1
  43. package/dist/development/lib/router/router.d.ts +12 -7
  44. package/dist/development/lib/router/router.js +61 -56
  45. package/dist/development/lib/router/url.js +1 -1
  46. package/dist/development/lib/router/utils.d.ts +6 -1
  47. package/dist/development/lib/router/utils.js +6 -4
  48. package/dist/development/lib/rsc/browser.js +2 -1
  49. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  50. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  51. package/dist/development/lib/rsc/html-stream/server.js +1 -1
  52. package/dist/development/lib/rsc/route-modules.js +1 -1
  53. package/dist/development/lib/rsc/server.ssr.js +22 -18
  54. package/dist/development/lib/server-runtime/cookies.js +1 -1
  55. package/dist/development/lib/server-runtime/crypto.js +1 -1
  56. package/dist/development/lib/server-runtime/data.js +1 -1
  57. package/dist/development/lib/server-runtime/dev.js +1 -1
  58. package/dist/development/lib/server-runtime/entry.js +1 -1
  59. package/dist/development/lib/server-runtime/errors.js +1 -1
  60. package/dist/development/lib/server-runtime/headers.js +1 -1
  61. package/dist/development/lib/server-runtime/invariant.js +1 -1
  62. package/dist/development/lib/server-runtime/mode.js +1 -1
  63. package/dist/development/lib/server-runtime/routeMatching.js +3 -4
  64. package/dist/development/lib/server-runtime/routes.js +1 -1
  65. package/dist/development/lib/server-runtime/server.js +7 -6
  66. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  67. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
  68. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  69. package/dist/development/lib/server-runtime/sessions.js +1 -1
  70. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  71. package/dist/development/lib/server-runtime/urls.js +1 -1
  72. package/dist/development/lib/server-runtime/warnings.js +1 -1
  73. package/dist/development/lib/types/internal.js +1 -1
  74. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  75. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  76. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  77. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  78. package/dist/production/dom-export.js +1 -1
  79. package/dist/production/index-react-server-client.js +1 -1
  80. package/dist/production/index-react-server.d.ts +34 -48
  81. package/dist/production/index-react-server.js +269 -34
  82. package/dist/production/index.d.ts +2 -2
  83. package/dist/production/index.js +3 -3
  84. package/dist/production/lib/actions.js +1 -1
  85. package/dist/production/lib/components.js +45 -8
  86. package/dist/production/lib/context.d.ts +13 -5
  87. package/dist/production/lib/context.js +11 -3
  88. package/dist/production/lib/dom/dom.js +1 -1
  89. package/dist/production/lib/dom/lib.js +14 -32
  90. package/dist/production/lib/dom/server.d.ts +6 -1
  91. package/dist/production/lib/dom/server.js +40 -14
  92. package/dist/production/lib/dom/ssr/components.js +15 -23
  93. package/dist/production/lib/dom/ssr/data.js +1 -1
  94. package/dist/production/lib/dom/ssr/entry.d.ts +4 -0
  95. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  96. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  97. package/dist/production/lib/dom/ssr/fog-of-war.js +3 -3
  98. package/dist/production/lib/dom/ssr/hydration.d.ts +3 -1
  99. package/dist/production/lib/dom/ssr/hydration.js +6 -4
  100. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  101. package/dist/production/lib/dom/ssr/links.js +1 -1
  102. package/dist/production/lib/dom/ssr/markup.js +1 -1
  103. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  104. package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
  105. package/dist/production/lib/dom/ssr/routes.js +1 -1
  106. package/dist/production/lib/dom/ssr/server.js +2 -2
  107. package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
  108. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  109. package/dist/production/lib/dom-export/hydrated-router.js +2 -1
  110. package/dist/production/lib/errors.js +1 -1
  111. package/dist/production/lib/hooks.js +49 -44
  112. package/dist/production/lib/href.js +1 -1
  113. package/dist/production/lib/router/history.js +1 -1
  114. package/dist/production/lib/router/instrumentation.js +1 -1
  115. package/dist/production/lib/router/matcher-route-pattern.js +216 -0
  116. package/dist/production/lib/router/matcher.d.ts +2 -0
  117. package/dist/production/lib/router/matcher.js +29 -0
  118. package/dist/production/lib/router/navigation.js +1 -1
  119. package/dist/production/lib/router/router.d.ts +12 -7
  120. package/dist/production/lib/router/router.js +61 -56
  121. package/dist/production/lib/router/url.js +1 -1
  122. package/dist/production/lib/router/utils.d.ts +6 -1
  123. package/dist/production/lib/router/utils.js +6 -4
  124. package/dist/production/lib/rsc/browser.js +2 -1
  125. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  126. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  127. package/dist/production/lib/rsc/html-stream/server.js +1 -1
  128. package/dist/production/lib/rsc/route-modules.js +1 -1
  129. package/dist/production/lib/rsc/server.ssr.js +22 -18
  130. package/dist/production/lib/server-runtime/cookies.js +1 -1
  131. package/dist/production/lib/server-runtime/crypto.js +1 -1
  132. package/dist/production/lib/server-runtime/data.js +1 -1
  133. package/dist/production/lib/server-runtime/dev.js +1 -1
  134. package/dist/production/lib/server-runtime/entry.js +1 -1
  135. package/dist/production/lib/server-runtime/errors.js +1 -1
  136. package/dist/production/lib/server-runtime/headers.js +1 -1
  137. package/dist/production/lib/server-runtime/invariant.js +1 -1
  138. package/dist/production/lib/server-runtime/mode.js +1 -1
  139. package/dist/production/lib/server-runtime/routeMatching.js +3 -4
  140. package/dist/production/lib/server-runtime/routes.js +1 -1
  141. package/dist/production/lib/server-runtime/server.js +7 -6
  142. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  143. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
  144. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  145. package/dist/production/lib/server-runtime/sessions.js +1 -1
  146. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  147. package/dist/production/lib/server-runtime/urls.js +1 -1
  148. package/dist/production/lib/server-runtime/warnings.js +1 -1
  149. package/dist/production/lib/types/internal.js +1 -1
  150. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  151. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  152. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  153. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  154. package/docs/upgrading/future.md +47 -0
  155. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # `react-router`
2
2
 
3
+ ## v8.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix `Expected fetcher: <key>` error thrown on navigation when a fetcher is aborted during its post-action revalidation ([#15365](https://github.com/remix-run/react-router/pull/15365))
8
+ - Fix lazy route discovery caching a path as discovered when the triggering navigation was aborted after the manifest response settled but before the route tree was patched, which permanently (for the session) shadowed the real route behind a catch-all or produced 404s on every subsequent visit ([#15399](https://github.com/remix-run/react-router/pull/15399))
9
+ - Improve route matching performance for long paths ([#15417](https://github.com/remix-run/react-router/pull/15417))
10
+ - Improve validation of action request origins ([#15419](https://github.com/remix-run/react-router/pull/15419))
11
+ - Fix `<ScrollRestoration>` leaving `history.scrollRestoration` set to `"auto"` after a bfcache restore, which let the browser restore scroll on subsequent history traversals before the destination route had rendered ([#15397](https://github.com/remix-run/react-router/pull/15397))
12
+ - Properly respect the `relative` option in `useSubmit`/`fetcher.submit` when resolivng the `action` path ([#15400](https://github.com/remix-run/react-router/pull/15400))
13
+ - Add additional URL validation on client side navigations/redirects ([#15445](https://github.com/remix-run/react-router/pull/15445))
14
+
3
15
  ## v8.3.0
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-917e6fdc0
2
+ * react-router v0.0.0-experimental-7aea711dd
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-917e6fdc0
2
+ * react-router v0.0.0-experimental-7aea711dd
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -50,7 +50,7 @@ interface Path {
50
50
  * An entry in a history stack. A location contains information about the
51
51
  * URL path, as well as possibly some arbitrary state and a key.
52
52
  */
53
- interface Location<State = any> extends Path {
53
+ interface Location$1<State = any> extends Path {
54
54
  /**
55
55
  * A value of arbitrary data associated with this location.
56
56
  */
@@ -79,7 +79,7 @@ interface Update {
79
79
  /**
80
80
  * The new location.
81
81
  */
82
- location: Location;
82
+ location: Location$1;
83
83
  /**
84
84
  * The delta between this location and the former location in the history stack
85
85
  */
@@ -113,7 +113,7 @@ interface History {
113
113
  /**
114
114
  * The current location. This value is mutable.
115
115
  */
116
- readonly location: Location;
116
+ readonly location: Location$1;
117
117
  /**
118
118
  * Returns a valid href for the given `to` value that may be used as
119
119
  * the value of an <a href> attribute.
@@ -597,7 +597,7 @@ interface MapRoutePropertiesFunction {
597
597
  * onto the route. Either they're meaningful to the router, or they'll get
598
598
  * ignored.
599
599
  */
600
- type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
600
+ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children" | "unstable_validateParams";
601
601
  /**
602
602
  * Keys we cannot change from within a lazy() function. We spread all other keys
603
603
  * onto the route. Either they're meaningful to the router, or they'll get
@@ -655,6 +655,11 @@ type BaseRouteObject = {
655
655
  * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
656
656
  */
657
657
  shouldRevalidate?: ShouldRevalidateFunction;
658
+ /**
659
+ * A map of route param names to regular expressions used to validate params
660
+ * after a route-pattern match.
661
+ */
662
+ unstable_validateParams?: Record<string, RegExp>;
658
663
  /**
659
664
  * The route handle.
660
665
  */
@@ -791,7 +796,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
791
796
  * Defaults to `/`.
792
797
  * @returns An array of matched routes, or `null` if no matches were found.
793
798
  */
794
- declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
799
+ declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location$1> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
795
800
  interface UIMatch<Data = unknown, Handle = unknown> {
796
801
  id: string;
797
802
  pathname: string;
@@ -811,30 +816,6 @@ interface UIMatch<Data = unknown, Handle = unknown> {
811
816
  */
812
817
  handle: Handle;
813
818
  }
814
- interface RouteMeta<RouteObjectType extends RouteObject = RouteObject> {
815
- relativePath: string;
816
- caseSensitive: boolean;
817
- childrenIndex: number;
818
- route: RouteObjectType;
819
- matcher?: RegExp;
820
- compiledParams?: CompiledPathParam[];
821
- }
822
- /**
823
- * @private
824
- * PRIVATE - DO NOT USE
825
- *
826
- * A "branch" of routes that match a given route pattern.
827
- * This is an internal interface not intended for direct external usage.
828
- */
829
- interface RouteBranch<RouteObjectType extends RouteObject = RouteObject> {
830
- path: string;
831
- score: number;
832
- routesMeta: RouteMeta<RouteObjectType>[];
833
- }
834
- type CompiledPathParam = {
835
- paramName: string;
836
- isOptional?: boolean;
837
- };
838
819
  declare class DataWithResponseInit<D> {
839
820
  type: string;
840
821
  data: D;
@@ -1143,9 +1124,10 @@ interface Router$1 {
1143
1124
  * @private
1144
1125
  * PRIVATE - DO NOT USE
1145
1126
  *
1146
- * Return the route branches for this router instance
1127
+ * Match routes against a location using the router's configured route
1128
+ * matching implementation.
1147
1129
  */
1148
- get branches(): RouteBranch<DataRouteObject>[] | undefined;
1130
+ match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
1149
1131
  /**
1150
1132
  * @private
1151
1133
  * PRIVATE - DO NOT USE
@@ -1230,7 +1212,7 @@ interface Router$1 {
1230
1212
  * Utility function to create an href for the given location
1231
1213
  * @param location
1232
1214
  */
1233
- createHref(location: Location | URL): string;
1215
+ createHref(location: Location$1 | URL): string;
1234
1216
  /**
1235
1217
  * @private
1236
1218
  * PRIVATE - DO NOT USE
@@ -1346,7 +1328,7 @@ interface RouterState {
1346
1328
  /**
1347
1329
  * The current location reflected by the router
1348
1330
  */
1349
- location: Location;
1331
+ location: Location$1;
1350
1332
  /**
1351
1333
  * The current set of route matches
1352
1334
  */
@@ -1407,7 +1389,9 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
1407
1389
  /**
1408
1390
  * Future flags to toggle new feature behavior
1409
1391
  */
1410
- interface FutureConfig {}
1392
+ interface FutureConfig {
1393
+ unstable_routePatternMatching?: boolean;
1394
+ }
1411
1395
  /**
1412
1396
  * Initialization options for createRouter
1413
1397
  */
@@ -1439,6 +1423,8 @@ interface StaticHandlerContext {
1439
1423
  loaderHeaders: Record<string, Headers>;
1440
1424
  actionHeaders: Record<string, Headers>;
1441
1425
  _deepestRenderedBoundaryId?: string | null;
1426
+ /** @private */
1427
+ _match: StaticHandler["match"];
1442
1428
  }
1443
1429
  /**
1444
1430
  * A StaticHandler instance manages a singular SSR navigation/fetch event
@@ -1452,10 +1438,10 @@ interface StaticHandler {
1452
1438
  * @private
1453
1439
  * PRIVATE - DO NOT USE
1454
1440
  *
1455
- * The route branches derived from the data routes, used for internal route
1456
- * matching in Framework Mode
1441
+ * Match routes against a location using the handler's configured route
1442
+ * matching implementation.
1457
1443
  */
1458
- _internalRouteBranches: RouteBranch<DataRouteObject>[];
1444
+ match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
1459
1445
  /**
1460
1446
  * Perform a query for a given request - executing all matched route
1461
1447
  * loaders/actions. Used for document requests.
@@ -1503,8 +1489,8 @@ interface StaticHandler {
1503
1489
  }): Promise<any>;
1504
1490
  }
1505
1491
  type ViewTransitionOpts = {
1506
- currentLocation: Location;
1507
- nextLocation: Location;
1492
+ currentLocation: Location$1;
1493
+ nextLocation: Location$1;
1508
1494
  };
1509
1495
  /**
1510
1496
  * Subscriber function signature for changes to router state
@@ -1522,7 +1508,7 @@ interface RouterSubscriber {
1522
1508
  * for a given location
1523
1509
  */
1524
1510
  interface GetScrollRestorationKeyFunction {
1525
- (location: Location, matches: UIMatch[]): string | null;
1511
+ (location: Location$1, matches: UIMatch[]): string | null;
1526
1512
  }
1527
1513
  /**
1528
1514
  * Function signature for determining the current scroll position
@@ -1604,7 +1590,7 @@ type NavigationStates = {
1604
1590
  };
1605
1591
  Loading: {
1606
1592
  state: "loading";
1607
- location: Location;
1593
+ location: Location$1;
1608
1594
  matches: DataRouteMatch[];
1609
1595
  historyAction: Action;
1610
1596
  formMethod: Submission["formMethod"] | undefined;
@@ -1616,7 +1602,7 @@ type NavigationStates = {
1616
1602
  };
1617
1603
  Submitting: {
1618
1604
  state: "submitting";
1619
- location: Location;
1605
+ location: Location$1;
1620
1606
  matches: DataRouteMatch[];
1621
1607
  historyAction: Action;
1622
1608
  formMethod: Submission["formMethod"];
@@ -1706,7 +1692,7 @@ interface BlockerBlocked {
1706
1692
  state: "blocked";
1707
1693
  reset: () => void;
1708
1694
  proceed: () => void;
1709
- location: Location;
1695
+ location: Location$1;
1710
1696
  }
1711
1697
  interface BlockerUnblocked {
1712
1698
  state: "unblocked";
@@ -1718,12 +1704,12 @@ interface BlockerProceeding {
1718
1704
  state: "proceeding";
1719
1705
  reset: undefined;
1720
1706
  proceed: undefined;
1721
- location: Location;
1707
+ location: Location$1;
1722
1708
  }
1723
1709
  type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1724
1710
  type BlockerFunction = (args: {
1725
- currentLocation: Location;
1726
- nextLocation: Location;
1711
+ currentLocation: Location$1;
1712
+ nextLocation: Location$1;
1727
1713
  historyAction: Action;
1728
1714
  }) => boolean;
1729
1715
  interface CreateStaticHandlerOptions {
@@ -2008,7 +1994,7 @@ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoad
2008
1994
  interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2009
1995
  loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
2010
1996
  params: Params;
2011
- location: Location;
1997
+ location: Location$1;
2012
1998
  matches: MetaMatches<MatchLoaders>;
2013
1999
  error?: unknown;
2014
2000
  }
@@ -2329,7 +2315,7 @@ type RSCRenderPayload = {
2329
2315
  clientVersion?: string;
2330
2316
  errors: Record<string, any> | null;
2331
2317
  loaderData: Record<string, any>;
2332
- location: Location;
2318
+ location: Location$1;
2333
2319
  routeDiscovery: RouteDiscovery;
2334
2320
  matches: RSCRouteMatch[];
2335
2321
  patches?: Promise<RSCRouteManifest[]>;