react-router 0.0.0-experimental-2a01b6fd8 → 0.0.0-experimental-917e6fdc0

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 (149) hide show
  1. package/dist/development/dom-export.js +1 -1
  2. package/dist/development/index-react-server-client.js +1 -1
  3. package/dist/development/index-react-server.d.ts +29 -31
  4. package/dist/development/index-react-server.js +33 -258
  5. package/dist/development/index.js +1 -1
  6. package/dist/development/lib/actions.js +10 -5
  7. package/dist/development/lib/components.js +10 -8
  8. package/dist/development/lib/context.d.ts +1 -0
  9. package/dist/development/lib/context.js +1 -1
  10. package/dist/development/lib/dom/dom.js +1 -1
  11. package/dist/development/lib/dom/lib.js +16 -1
  12. package/dist/development/lib/dom/server.d.ts +1 -6
  13. package/dist/development/lib/dom/server.js +9 -13
  14. package/dist/development/lib/dom/ssr/components.js +5 -4
  15. package/dist/development/lib/dom/ssr/data.js +1 -1
  16. package/dist/development/lib/dom/ssr/errorBoundaries.js +1 -1
  17. package/dist/development/lib/dom/ssr/fallback.js +1 -1
  18. package/dist/development/lib/dom/ssr/fog-of-war.js +4 -3
  19. package/dist/development/lib/dom/ssr/hydration.d.ts +1 -3
  20. package/dist/development/lib/dom/ssr/hydration.js +4 -6
  21. package/dist/development/lib/dom/ssr/invariant.js +1 -1
  22. package/dist/development/lib/dom/ssr/links.js +1 -1
  23. package/dist/development/lib/dom/ssr/markup.js +1 -1
  24. package/dist/development/lib/dom/ssr/routeModules.js +1 -1
  25. package/dist/development/lib/dom/ssr/routes-test-stub.js +1 -1
  26. package/dist/development/lib/dom/ssr/routes.js +1 -1
  27. package/dist/development/lib/dom/ssr/server.js +2 -2
  28. package/dist/development/lib/dom/ssr/single-fetch.js +1 -1
  29. package/dist/development/lib/dom-export/dom-router-provider.js +1 -1
  30. package/dist/development/lib/dom-export/hydrated-router.js +1 -2
  31. package/dist/development/lib/errors.js +1 -1
  32. package/dist/development/lib/hooks.js +7 -7
  33. package/dist/development/lib/href.js +1 -1
  34. package/dist/development/lib/router/history.js +1 -1
  35. package/dist/development/lib/router/instrumentation.js +1 -1
  36. package/dist/development/lib/router/navigation.js +45 -0
  37. package/dist/development/lib/router/router.d.ts +11 -6
  38. package/dist/development/lib/router/router.js +67 -51
  39. package/dist/development/lib/router/url.js +1 -1
  40. package/dist/development/lib/router/utils.d.ts +1 -8
  41. package/dist/development/lib/router/utils.js +11 -9
  42. package/dist/development/lib/rsc/browser.js +4 -2
  43. package/dist/development/lib/rsc/errorBoundaries.js +1 -1
  44. package/dist/development/lib/rsc/html-stream/browser.js +1 -1
  45. package/dist/development/lib/rsc/html-stream/server.js +1 -1
  46. package/dist/development/lib/rsc/route-modules.js +1 -1
  47. package/dist/development/lib/rsc/server.ssr.js +1 -1
  48. package/dist/development/lib/server-runtime/cookies.js +1 -1
  49. package/dist/development/lib/server-runtime/crypto.js +1 -1
  50. package/dist/development/lib/server-runtime/data.js +1 -1
  51. package/dist/development/lib/server-runtime/dev.js +1 -1
  52. package/dist/development/lib/server-runtime/entry.js +1 -1
  53. package/dist/development/lib/server-runtime/errors.js +1 -1
  54. package/dist/development/lib/server-runtime/headers.js +1 -1
  55. package/dist/development/lib/server-runtime/invariant.js +1 -1
  56. package/dist/development/lib/server-runtime/mode.js +1 -1
  57. package/dist/development/lib/server-runtime/routeMatching.js +4 -3
  58. package/dist/development/lib/server-runtime/routes.js +1 -1
  59. package/dist/development/lib/server-runtime/server.js +6 -8
  60. package/dist/development/lib/server-runtime/serverHandoff.js +1 -1
  61. package/dist/development/lib/server-runtime/sessions/cookieStorage.js +1 -1
  62. package/dist/development/lib/server-runtime/sessions/memoryStorage.js +1 -1
  63. package/dist/development/lib/server-runtime/sessions.js +1 -1
  64. package/dist/development/lib/server-runtime/single-fetch.js +1 -1
  65. package/dist/development/lib/server-runtime/urls.js +1 -1
  66. package/dist/development/lib/server-runtime/warnings.js +1 -1
  67. package/dist/development/lib/types/internal.js +1 -1
  68. package/dist/development/vendor/turbo-stream-v2/flatten.js +1 -1
  69. package/dist/development/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  70. package/dist/development/vendor/turbo-stream-v2/unflatten.js +1 -1
  71. package/dist/development/vendor/turbo-stream-v2/utils.js +1 -1
  72. package/dist/production/dom-export.js +1 -1
  73. package/dist/production/index-react-server-client.js +1 -1
  74. package/dist/production/index-react-server.d.ts +29 -31
  75. package/dist/production/index-react-server.js +33 -258
  76. package/dist/production/index.js +1 -1
  77. package/dist/production/lib/actions.js +10 -5
  78. package/dist/production/lib/components.js +10 -8
  79. package/dist/production/lib/context.d.ts +1 -0
  80. package/dist/production/lib/context.js +1 -1
  81. package/dist/production/lib/dom/dom.js +1 -1
  82. package/dist/production/lib/dom/lib.js +16 -1
  83. package/dist/production/lib/dom/server.d.ts +1 -6
  84. package/dist/production/lib/dom/server.js +9 -13
  85. package/dist/production/lib/dom/ssr/components.js +5 -4
  86. package/dist/production/lib/dom/ssr/data.js +1 -1
  87. package/dist/production/lib/dom/ssr/errorBoundaries.js +1 -1
  88. package/dist/production/lib/dom/ssr/fallback.js +1 -1
  89. package/dist/production/lib/dom/ssr/fog-of-war.js +4 -3
  90. package/dist/production/lib/dom/ssr/hydration.d.ts +1 -3
  91. package/dist/production/lib/dom/ssr/hydration.js +4 -6
  92. package/dist/production/lib/dom/ssr/invariant.js +1 -1
  93. package/dist/production/lib/dom/ssr/links.js +1 -1
  94. package/dist/production/lib/dom/ssr/markup.js +1 -1
  95. package/dist/production/lib/dom/ssr/routeModules.js +1 -1
  96. package/dist/production/lib/dom/ssr/routes-test-stub.js +1 -1
  97. package/dist/production/lib/dom/ssr/routes.js +1 -1
  98. package/dist/production/lib/dom/ssr/server.js +2 -2
  99. package/dist/production/lib/dom/ssr/single-fetch.js +1 -1
  100. package/dist/production/lib/dom-export/dom-router-provider.js +1 -1
  101. package/dist/production/lib/dom-export/hydrated-router.js +1 -2
  102. package/dist/production/lib/errors.js +1 -1
  103. package/dist/production/lib/hooks.js +7 -7
  104. package/dist/production/lib/href.js +1 -1
  105. package/dist/production/lib/router/history.js +1 -1
  106. package/dist/production/lib/router/instrumentation.js +1 -1
  107. package/dist/production/lib/router/navigation.js +45 -0
  108. package/dist/production/lib/router/router.d.ts +11 -6
  109. package/dist/production/lib/router/router.js +67 -51
  110. package/dist/production/lib/router/url.js +1 -1
  111. package/dist/production/lib/router/utils.d.ts +1 -8
  112. package/dist/production/lib/router/utils.js +11 -9
  113. package/dist/production/lib/rsc/browser.js +4 -2
  114. package/dist/production/lib/rsc/errorBoundaries.js +1 -1
  115. package/dist/production/lib/rsc/html-stream/browser.js +1 -1
  116. package/dist/production/lib/rsc/html-stream/server.js +1 -1
  117. package/dist/production/lib/rsc/route-modules.js +1 -1
  118. package/dist/production/lib/rsc/server.ssr.js +1 -1
  119. package/dist/production/lib/server-runtime/cookies.js +1 -1
  120. package/dist/production/lib/server-runtime/crypto.js +1 -1
  121. package/dist/production/lib/server-runtime/data.js +1 -1
  122. package/dist/production/lib/server-runtime/dev.js +1 -1
  123. package/dist/production/lib/server-runtime/entry.js +1 -1
  124. package/dist/production/lib/server-runtime/errors.js +1 -1
  125. package/dist/production/lib/server-runtime/headers.js +1 -1
  126. package/dist/production/lib/server-runtime/invariant.js +1 -1
  127. package/dist/production/lib/server-runtime/mode.js +1 -1
  128. package/dist/production/lib/server-runtime/routeMatching.js +4 -3
  129. package/dist/production/lib/server-runtime/routes.js +1 -1
  130. package/dist/production/lib/server-runtime/server.js +6 -8
  131. package/dist/production/lib/server-runtime/serverHandoff.js +1 -1
  132. package/dist/production/lib/server-runtime/sessions/cookieStorage.js +1 -1
  133. package/dist/production/lib/server-runtime/sessions/memoryStorage.js +1 -1
  134. package/dist/production/lib/server-runtime/sessions.js +1 -1
  135. package/dist/production/lib/server-runtime/single-fetch.js +1 -1
  136. package/dist/production/lib/server-runtime/urls.js +1 -1
  137. package/dist/production/lib/server-runtime/warnings.js +1 -1
  138. package/dist/production/lib/types/internal.js +1 -1
  139. package/dist/production/vendor/turbo-stream-v2/flatten.js +1 -1
  140. package/dist/production/vendor/turbo-stream-v2/turbo-stream.js +1 -1
  141. package/dist/production/vendor/turbo-stream-v2/unflatten.js +1 -1
  142. package/dist/production/vendor/turbo-stream-v2/utils.js +1 -1
  143. package/package.json +1 -2
  144. package/dist/development/lib/router/matcher-route-pattern.js +0 -213
  145. package/dist/development/lib/router/matcher.d.ts +0 -2
  146. package/dist/development/lib/router/matcher.js +0 -30
  147. package/dist/production/lib/router/matcher-route-pattern.js +0 -213
  148. package/dist/production/lib/router/matcher.d.ts +0 -2
  149. package/dist/production/lib/router/matcher.js +0 -30
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-2a01b6fd8
2
+ * react-router v0.0.0-experimental-917e6fdc0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-2a01b6fd8
2
+ * react-router v0.0.0-experimental-917e6fdc0
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$1<State = any> extends Path {
53
+ interface Location<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$1;
82
+ location: Location;
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$1;
116
+ readonly location: Location;
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.
@@ -488,9 +488,6 @@ interface ShouldRevalidateFunctionArgs {
488
488
  interface ShouldRevalidateFunction {
489
489
  (args: ShouldRevalidateFunctionArgs): boolean;
490
490
  }
491
- interface UnstableValidateParamsFunction {
492
- (params: Params): boolean;
493
- }
494
491
  interface DataStrategyMatch extends RouteMatch<string, DataRouteObject> {
495
492
  /**
496
493
  * @private
@@ -600,7 +597,7 @@ interface MapRoutePropertiesFunction {
600
597
  * onto the route. Either they're meaningful to the router, or they'll get
601
598
  * ignored.
602
599
  */
603
- type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children" | "unstable_validateParams";
600
+ type UnsupportedLazyRouteObjectKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
604
601
  /**
605
602
  * Keys we cannot change from within a lazy() function. We spread all other keys
606
603
  * onto the route. Either they're meaningful to the router, or they'll get
@@ -658,10 +655,6 @@ type BaseRouteObject = {
658
655
  * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
659
656
  */
660
657
  shouldRevalidate?: ShouldRevalidateFunction;
661
- /**
662
- * Validate route params after a route-pattern match.
663
- */
664
- unstable_validateParams?: UnstableValidateParamsFunction;
665
658
  /**
666
659
  * The route handle.
667
660
  */
@@ -798,7 +791,7 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {}
798
791
  * Defaults to `/`.
799
792
  * @returns An array of matched routes, or `null` if no matches were found.
800
793
  */
801
- declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location$1> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
794
+ declare function matchRoutes<RouteObjectType extends RouteObject = RouteObject>(routes: RouteObjectType[], locationArg: Partial<Location> | string, basename?: string): RouteMatch<string, RouteObjectType>[] | null;
802
795
  interface UIMatch<Data = unknown, Handle = unknown> {
803
796
  id: string;
804
797
  pathname: string;
@@ -1150,10 +1143,9 @@ interface Router$1 {
1150
1143
  * @private
1151
1144
  * PRIVATE - DO NOT USE
1152
1145
  *
1153
- * Match routes against a location using the router's configured route
1154
- * matching implementation.
1146
+ * Return the route branches for this router instance
1155
1147
  */
1156
- match(locationArg: Partial<Location$1> | string): DataRouteMatch[] | null;
1148
+ get branches(): RouteBranch<DataRouteObject>[] | undefined;
1157
1149
  /**
1158
1150
  * @private
1159
1151
  * PRIVATE - DO NOT USE
@@ -1238,7 +1230,15 @@ interface Router$1 {
1238
1230
  * Utility function to create an href for the given location
1239
1231
  * @param location
1240
1232
  */
1241
- createHref(location: Location$1 | URL): string;
1233
+ createHref(location: Location | URL): string;
1234
+ /**
1235
+ * @private
1236
+ * PRIVATE - DO NOT USE
1237
+ *
1238
+ * Utility function to create a URL for the given location
1239
+ * @param location
1240
+ */
1241
+ createURL?(to: To): URL;
1242
1242
  /**
1243
1243
  * @private
1244
1244
  * PRIVATE - DO NOT USE
@@ -1346,7 +1346,7 @@ interface RouterState {
1346
1346
  /**
1347
1347
  * The current location reflected by the router
1348
1348
  */
1349
- location: Location$1;
1349
+ location: Location;
1350
1350
  /**
1351
1351
  * The current set of route matches
1352
1352
  */
@@ -1407,9 +1407,7 @@ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "e
1407
1407
  /**
1408
1408
  * Future flags to toggle new feature behavior
1409
1409
  */
1410
- interface FutureConfig {
1411
- unstable_routePatternMatching?: boolean;
1412
- }
1410
+ interface FutureConfig {}
1413
1411
  /**
1414
1412
  * Initialization options for createRouter
1415
1413
  */
@@ -1505,8 +1503,8 @@ interface StaticHandler {
1505
1503
  }): Promise<any>;
1506
1504
  }
1507
1505
  type ViewTransitionOpts = {
1508
- currentLocation: Location$1;
1509
- nextLocation: Location$1;
1506
+ currentLocation: Location;
1507
+ nextLocation: Location;
1510
1508
  };
1511
1509
  /**
1512
1510
  * Subscriber function signature for changes to router state
@@ -1524,7 +1522,7 @@ interface RouterSubscriber {
1524
1522
  * for a given location
1525
1523
  */
1526
1524
  interface GetScrollRestorationKeyFunction {
1527
- (location: Location$1, matches: UIMatch[]): string | null;
1525
+ (location: Location, matches: UIMatch[]): string | null;
1528
1526
  }
1529
1527
  /**
1530
1528
  * Function signature for determining the current scroll position
@@ -1606,7 +1604,7 @@ type NavigationStates = {
1606
1604
  };
1607
1605
  Loading: {
1608
1606
  state: "loading";
1609
- location: Location$1;
1607
+ location: Location;
1610
1608
  matches: DataRouteMatch[];
1611
1609
  historyAction: Action;
1612
1610
  formMethod: Submission["formMethod"] | undefined;
@@ -1618,7 +1616,7 @@ type NavigationStates = {
1618
1616
  };
1619
1617
  Submitting: {
1620
1618
  state: "submitting";
1621
- location: Location$1;
1619
+ location: Location;
1622
1620
  matches: DataRouteMatch[];
1623
1621
  historyAction: Action;
1624
1622
  formMethod: Submission["formMethod"];
@@ -1708,7 +1706,7 @@ interface BlockerBlocked {
1708
1706
  state: "blocked";
1709
1707
  reset: () => void;
1710
1708
  proceed: () => void;
1711
- location: Location$1;
1709
+ location: Location;
1712
1710
  }
1713
1711
  interface BlockerUnblocked {
1714
1712
  state: "unblocked";
@@ -1720,12 +1718,12 @@ interface BlockerProceeding {
1720
1718
  state: "proceeding";
1721
1719
  reset: undefined;
1722
1720
  proceed: undefined;
1723
- location: Location$1;
1721
+ location: Location;
1724
1722
  }
1725
1723
  type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1726
1724
  type BlockerFunction = (args: {
1727
- currentLocation: Location$1;
1728
- nextLocation: Location$1;
1725
+ currentLocation: Location;
1726
+ nextLocation: Location;
1729
1727
  historyAction: Action;
1730
1728
  }) => boolean;
1731
1729
  interface CreateStaticHandlerOptions {
@@ -2010,7 +2008,7 @@ type MetaMatches<MatchLoaders extends Record<string, LoaderFunction | ClientLoad
2010
2008
  interface MetaArgs<Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown, MatchLoaders extends Record<string, LoaderFunction | ClientLoaderFunction | unknown> = Record<string, unknown>> {
2011
2009
  loaderData: (Loader extends LoaderFunction | ClientLoaderFunction ? SerializeFrom<Loader> : unknown) | undefined;
2012
2010
  params: Params;
2013
- location: Location$1;
2011
+ location: Location;
2014
2012
  matches: MetaMatches<MatchLoaders>;
2015
2013
  error?: unknown;
2016
2014
  }
@@ -2331,7 +2329,7 @@ type RSCRenderPayload = {
2331
2329
  clientVersion?: string;
2332
2330
  errors: Record<string, any> | null;
2333
2331
  loaderData: Record<string, any>;
2334
- location: Location$1;
2332
+ location: Location;
2335
2333
  routeDiscovery: RouteDiscovery;
2336
2334
  matches: RSCRouteMatch[];
2337
2335
  patches?: Promise<RSCRouteManifest[]>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-2a01b6fd8
2
+ * react-router v0.0.0-experimental-917e6fdc0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -10,7 +10,6 @@
10
10
  */
11
11
  import { AsyncLocalStorage } from "node:async_hooks";
12
12
  import * as React from "react";
13
- import { createMultiMatcher } from "@remix-run/route-pattern/match";
14
13
  import { parse, serialize, splitSetCookieString } from "cookie-es";
15
14
  import { BrowserRouter, Form, HashRouter, Link, Links, MemoryRouter, Meta, NavLink, Navigate, Outlet, Outlet as Outlet$1, Route, Router, RouterProvider, Routes, ScrollRestoration, StaticRouter, StaticRouterProvider, UNSAFE_AwaitContextProvider, UNSAFE_WithComponentProps, UNSAFE_WithErrorBoundaryProps, UNSAFE_WithHydrateFallbackProps, unstable_HistoryRouter } from "react-router/internal/react-server-client";
16
15
  //#region lib/router/url.ts
@@ -208,8 +207,7 @@ const unsupportedLazyRouteObjectKeys = new Set([
208
207
  "path",
209
208
  "id",
210
209
  "index",
211
- "children",
212
- "unstable_validateParams"
210
+ "children"
213
211
  ]);
214
212
  function isUnsupportedLazyRouteObjectKey(key) {
215
213
  return unsupportedLazyRouteObjectKeys.has(key);
@@ -221,8 +219,7 @@ const unsupportedLazyRouteFunctionKeys = new Set([
221
219
  "id",
222
220
  "index",
223
221
  "middleware",
224
- "children",
225
- "unstable_validateParams"
222
+ "children"
226
223
  ]);
227
224
  function isUnsupportedLazyRouteFunctionKey(key) {
228
225
  return unsupportedLazyRouteFunctionKeys.has(key);
@@ -338,11 +335,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
338
335
  };
339
336
  }
340
337
  function flattenAndRankRoutes(routes) {
341
- let branches = flattenRoutes$1(routes);
338
+ let branches = flattenRoutes(routes);
342
339
  rankRouteBranches(branches);
343
340
  return branches;
344
341
  }
345
- function flattenRoutes$1(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
342
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
346
343
  let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
347
344
  let meta = {
348
345
  relativePath: relativePath === void 0 ? route.path || "" : relativePath,
@@ -359,7 +356,7 @@ function flattenRoutes$1(routes, branches = [], parentsMeta = [], parentPath = "
359
356
  let routesMeta = parentsMeta.concat(meta);
360
357
  if (route.children && route.children.length > 0) {
361
358
  invariant$1(route.index !== true, `Index routes must not have child routes. Please remove all child routes from route path "${path}".`);
362
- flattenRoutes$1(route.children, branches, routesMeta, path, hasParentOptionalSegments);
359
+ flattenRoutes(route.children, branches, routesMeta, path, hasParentOptionalSegments);
363
360
  }
364
361
  if (route.path == null && !route.index) return;
365
362
  branches.push({
@@ -518,13 +515,13 @@ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
518
515
  let match = pathname.match(matcher);
519
516
  if (!match) return null;
520
517
  let matchedPathname = match[0];
521
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
518
+ let pathnameBase = removeTrailingSlash(matchedPathname, 1);
522
519
  let captureGroups = match.slice(1);
523
520
  return {
524
521
  params: compiledParams.reduce((memo, { paramName, isOptional }, index) => {
525
522
  if (paramName === "*") {
526
523
  let splatValue = captureGroups[index] || "";
527
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
524
+ pathnameBase = removeTrailingSlash(matchedPathname.slice(0, matchedPathname.length - splatValue.length), 1);
528
525
  }
529
526
  const value = captureGroups[index];
530
527
  if (isOptional && !value) memo[paramName] = void 0;
@@ -593,7 +590,7 @@ function resolvePath(to, fromPathname = "/") {
593
590
  let pathname;
594
591
  if (toPathname) {
595
592
  toPathname = removeDoubleSlashes(toPathname);
596
- if (toPathname.startsWith("/")) pathname = resolvePathname(toPathname.substring(1), "/");
593
+ if (toPathname.startsWith("/") || toPathname.startsWith("\\")) pathname = resolvePathname(toPathname.substring(1), "/");
597
594
  else pathname = resolvePathname(toPathname, fromPathname);
598
595
  } else pathname = fromPathname;
599
596
  return {
@@ -654,7 +651,11 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
654
651
  }
655
652
  const removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
656
653
  const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
657
- const removeTrailingSlash = (path) => path.replace(/\/+$/, "");
654
+ function removeTrailingSlash(path, minLength = 0) {
655
+ let end = path.length;
656
+ while (end > minLength && path.charCodeAt(end - 1) === 47) end--;
657
+ return end === path.length ? path : path.slice(0, end);
658
+ }
658
659
  const normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
659
660
  const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
660
661
  const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
@@ -1039,223 +1040,6 @@ function getReadonlyContext(context) {
1039
1040
  return { get: (ctx) => context.get(ctx) };
1040
1041
  }
1041
1042
  //#endregion
1042
- //#region lib/router/matcher-route-pattern.ts
1043
- var RoutePatternDataRouteMatcher = class {
1044
- #state;
1045
- #basename;
1046
- constructor(basename) {
1047
- this.#basename = basename;
1048
- }
1049
- update(routes) {
1050
- let branches = flattenRoutes(routes);
1051
- let matcher = createMultiMatcher();
1052
- let partialMatcher = createMultiMatcher();
1053
- for (let branch of branches) {
1054
- let routePattern = convertReactRouterPathToRoutePattern(branch.path);
1055
- validateRoutePatternSplat(branch.path, routePattern);
1056
- routePattern = addOptionalTrailingSlash(routePattern);
1057
- matcher.add(routePattern, branch);
1058
- if (!branch.routesMeta[branch.routesMeta.length - 1].route.index) partialMatcher.add(routePattern === "/" ? `/*__rr_partial` : `${routePattern}(/*__rr_partial)`, branch);
1059
- }
1060
- this.#state = {
1061
- branches,
1062
- matcher,
1063
- partialMatcher
1064
- };
1065
- return branches;
1066
- }
1067
- match(locationArg, allowPartial = false) {
1068
- let pathname = stripBasename((typeof locationArg === "string" ? parsePath(locationArg) : locationArg).pathname || "/", this.#basename);
1069
- if (pathname == null) return null;
1070
- let decoded = decodePath(pathname);
1071
- let url = new URL(decoded, "http://reactrouter.local");
1072
- invariant$1(this.#state, "Route pattern routes must be initialized before matching.");
1073
- let matches = this.#state.matcher.matchAll(url);
1074
- if (allowPartial) matches.push(...this.#state.partialMatcher.matchAll(url));
1075
- for (let match of prioritizeValidatedMatches(matches)) {
1076
- let routeMatches = convertRoutePatternMatchToRouteMatches(match, pathname, allowPartial);
1077
- if (routeMatches && validateRouteMatchParams(routeMatches)) return routeMatches;
1078
- }
1079
- return null;
1080
- }
1081
- };
1082
- function validateRoutePatternSplat(routePath, routePattern) {
1083
- invariant$1(getRoutePatternSplatIndexes(routePattern).length <= 1 && isTerminalRoutePatternSplat(routePattern), `Route path "${routePath}" is not supported with \`future.unstable_routePatternMatching\` because React Router only supports a single splat at the end of a route path.`);
1084
- }
1085
- function getRoutePatternSplatIndexes(routePattern) {
1086
- let splatIndexes = [];
1087
- for (let i = 0; i < routePattern.length; i++) {
1088
- let char = routePattern[i];
1089
- if (char === "\\") {
1090
- i++;
1091
- continue;
1092
- }
1093
- if (char === "*") splatIndexes.push(i);
1094
- }
1095
- return splatIndexes;
1096
- }
1097
- function isTerminalRoutePatternSplat(routePattern) {
1098
- for (let i = 0; i < routePattern.length; i++) {
1099
- let char = routePattern[i];
1100
- if (char === "\\") {
1101
- i++;
1102
- continue;
1103
- }
1104
- if (char !== "*") continue;
1105
- let suffix = routePattern.slice(i + 1);
1106
- return /^[a-zA-Z_$][a-zA-Z_$0-9]*$/.test(suffix) || suffix === "";
1107
- }
1108
- return true;
1109
- }
1110
- function addOptionalTrailingSlash(routePattern) {
1111
- return routePattern === "/" ? routePattern : `${routePattern.replace(/\/+$/, "")}(/)`;
1112
- }
1113
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "") {
1114
- routes.forEach((route, index) => {
1115
- invariant$1(route.caseSensitive !== true, "`caseSensitive` routes are not supported with `future.unstable_routePatternMatching`.");
1116
- let meta = {
1117
- relativePath: route.path || "",
1118
- caseSensitive: false,
1119
- childrenIndex: index,
1120
- route
1121
- };
1122
- if (meta.relativePath.startsWith("/")) {
1123
- invariant$1(meta.relativePath.startsWith(parentPath), `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`);
1124
- meta.relativePath = meta.relativePath.slice(parentPath.length);
1125
- }
1126
- let routesMeta = parentsMeta.concat(meta);
1127
- let path = meta.relativePath ? joinPaths([parentPath, meta.relativePath]) : parentPath;
1128
- if (route.children && route.children.length > 0) {
1129
- invariant$1(route.index !== true, `Index routes must not have child routes. Please remove all child routes from route path "${path}".`);
1130
- flattenRoutes(route.children, branches, routesMeta, path);
1131
- if (route.children?.some((child) => child.index)) return;
1132
- }
1133
- if (route.path != null || route.index) branches.push({
1134
- path,
1135
- score: 0,
1136
- routesMeta
1137
- });
1138
- });
1139
- return branches;
1140
- }
1141
- function convertReactRouterPathToRoutePattern(path) {
1142
- warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`);
1143
- if (path.endsWith("*") && path !== "*" && !path.endsWith("/*")) path = path.replace(/\*$/, "/*");
1144
- path = path.replace(/^\/*/, "/");
1145
- if (path === "") return "/";
1146
- let segments = path.split("/");
1147
- let pattern = segments.shift() || "";
1148
- for (let i = 0; i < segments.length;) {
1149
- let optionalRun = [];
1150
- while (i < segments.length && isOptionalRouteSegment(segments[i])) {
1151
- optionalRun.push(convertRouteSegment(segments[i].slice(0, -1)));
1152
- i++;
1153
- }
1154
- if (optionalRun.length > 0) {
1155
- let nested = optionalRun.reduceRight((child, segment) => `/${segment}${child ? `(${child})` : ""}`, "");
1156
- pattern += `(${nested})`;
1157
- continue;
1158
- }
1159
- pattern += `/${convertRouteSegment(segments[i])}`;
1160
- i++;
1161
- }
1162
- return pattern || "/";
1163
- }
1164
- function isOptionalRouteSegment(segment) {
1165
- return segment.endsWith("?");
1166
- }
1167
- function convertRouteSegment(segment) {
1168
- if (segment === "*") return "*__rr_splat";
1169
- let paramMatch = segment.match(/^:([\w-]+)(\?)?(.*)$/);
1170
- if (paramMatch) {
1171
- let [, paramName, optional, suffix] = paramMatch;
1172
- let converted = `:${paramName}${escapeRoutePatternLiteral(suffix)}`;
1173
- return optional ? `(:${paramName})${escapeRoutePatternLiteral(suffix)}` : converted;
1174
- }
1175
- return escapeRoutePatternLiteral(segment);
1176
- }
1177
- function escapeRoutePatternLiteral(value) {
1178
- return value.replace(/[\\():*]/g, "\\$&");
1179
- }
1180
- function validateRouteMatchParams(matches) {
1181
- return matches.every(({ route, params }) => {
1182
- try {
1183
- return typeof route.unstable_validateParams !== "function" || route.unstable_validateParams(params) === true;
1184
- } catch (e) {
1185
- warning(false, `Route "${route.id || route.path}" failed param validation with the following error:\n` + (e instanceof Error ? e.message : String(e)));
1186
- }
1187
- });
1188
- }
1189
- function prioritizeValidatedMatches(matches) {
1190
- let validatedMatches = [];
1191
- let unvalidatedMatches = [];
1192
- for (let match of matches) if (match.data.routesMeta.some((meta) => typeof meta.route.unstable_validateParams === "function")) validatedMatches.push(match);
1193
- else unvalidatedMatches.push(match);
1194
- return validatedMatches.concat(unvalidatedMatches);
1195
- }
1196
- function convertRoutePatternMatchToRouteMatches(match, pathname, allowPartial) {
1197
- let pathSegments = pathname.replace(/^\//, "").split("/").filter(Boolean);
1198
- let splatParamName = match.paramsMeta.pathname.find((meta) => meta.type === "*")?.name;
1199
- let matchedParams = Object.entries(match.params).reduce((params, [key, value]) => {
1200
- if (key === "__rr_partial" || value === void 0) return params;
1201
- params[key === "__rr_splat" || key === splatParamName ? "*" : key] = value;
1202
- return params;
1203
- }, {});
1204
- let consumedSegments = 0;
1205
- let matches = [];
1206
- for (let i = 0; i < match.data.routesMeta.length; i++) {
1207
- let meta = match.data.routesMeta[i];
1208
- let splatBaseSegments = null;
1209
- let routeSegments = meta.relativePath.replace(/^\//, "").split("/").filter(Boolean);
1210
- for (let segment of routeSegments) {
1211
- if (segment === "*") {
1212
- splatBaseSegments = consumedSegments;
1213
- consumedSegments = pathSegments.length;
1214
- break;
1215
- }
1216
- if (segment.endsWith("?")) {
1217
- let routeSegment = segment.slice(0, -1);
1218
- if (routeSegment.startsWith(":")) {
1219
- if (matchedParams[routeSegment.slice(1)] !== void 0) consumedSegments++;
1220
- } else if (pathSegments[consumedSegments] === routeSegment) consumedSegments++;
1221
- continue;
1222
- }
1223
- consumedSegments++;
1224
- }
1225
- let routePathname = getRoutePatternMatchPathname(pathSegments, consumedSegments);
1226
- let pathnameBase = splatBaseSegments == null ? routePathname : getRoutePatternMatchPathname(pathSegments, splatBaseSegments);
1227
- matches.push({
1228
- params: matchedParams,
1229
- pathname: routePathname,
1230
- pathnameBase,
1231
- route: meta.route
1232
- });
1233
- }
1234
- if (!allowPartial && pathSegments.length > consumedSegments && !match.data.routesMeta[match.data.routesMeta.length - 1].route.index) return null;
1235
- return matches;
1236
- }
1237
- function getRoutePatternMatchPathname(pathSegments, consumedSegments) {
1238
- return consumedSegments === 0 ? "/" : `/${pathSegments.slice(0, consumedSegments).join("/")}`;
1239
- }
1240
- //#endregion
1241
- //#region lib/router/matcher.ts
1242
- var V6RegExMatcher = class {
1243
- #routes = [];
1244
- #branches = [];
1245
- #basename;
1246
- constructor(basename) {
1247
- this.#basename = basename;
1248
- }
1249
- update(routes) {
1250
- this.#routes = routes;
1251
- this.#branches = flattenAndRankRoutes(routes);
1252
- return this.#branches;
1253
- }
1254
- match(locationArg, allowPartial = false) {
1255
- return matchRoutesImpl(this.#routes, locationArg, this.#basename, allowPartial, this.#branches);
1256
- }
1257
- };
1258
- //#endregion
1259
1043
  //#region lib/router/router.ts
1260
1044
  const validMutationMethodsArr = [
1261
1045
  "POST",
@@ -1274,9 +1058,6 @@ const redirectStatusCodes = new Set([
1274
1058
  308
1275
1059
  ]);
1276
1060
  const ResetLoaderDataSymbol = Symbol("ResetLoaderData");
1277
- function createDataRouteMatcher(future, basename) {
1278
- return future.unstable_routePatternMatching ? new RoutePatternDataRouteMatcher(basename) : new V6RegExMatcher(basename);
1279
- }
1280
1061
  /**
1281
1062
  * Create a static handler to perform server-side data loading
1282
1063
  *
@@ -1313,7 +1094,7 @@ function createStaticHandler(routes, opts) {
1313
1094
  let basename = (opts ? opts.basename : null) || "/";
1314
1095
  let _mapRouteProperties = opts?.mapRouteProperties;
1315
1096
  let mapRouteProperties = _mapRouteProperties ? _mapRouteProperties : () => ({});
1316
- let dataRouteMatcher = createDataRouteMatcher({ ...opts?.future }, basename);
1097
+ ({ ...opts?.future });
1317
1098
  if (opts?.instrumentations) {
1318
1099
  let instrumentations = opts.instrumentations;
1319
1100
  mapRouteProperties = (route) => {
@@ -1324,7 +1105,7 @@ function createStaticHandler(routes, opts) {
1324
1105
  };
1325
1106
  }
1326
1107
  let dataRoutes = convertRoutesToDataRoutes(routes, mapRouteProperties, void 0, manifest);
1327
- let routeBranches = dataRouteMatcher.update(dataRoutes);
1108
+ let routeBranches = flattenAndRankRoutes(dataRoutes);
1328
1109
  /**
1329
1110
  * The query() method is intended for document requests, in which we want to
1330
1111
  * call an optional action and potentially multiple loaders for all nested
@@ -1355,7 +1136,7 @@ function createStaticHandler(routes, opts) {
1355
1136
  let normalizePathImpl = normalizePath || defaultNormalizePath;
1356
1137
  let method = request.method;
1357
1138
  let location = createLocation("", normalizePathImpl(request), null, "default");
1358
- let matches = dataRouteMatcher.match(location);
1139
+ let matches = matchRoutesImpl(dataRoutes, location, basename, false, routeBranches);
1359
1140
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
1360
1141
  if (!isValidMethod(method) && method !== "HEAD") {
1361
1142
  let error = getInternalRouterError(405, { method });
@@ -1483,7 +1264,7 @@ function createStaticHandler(routes, opts) {
1483
1264
  let normalizePathImpl = normalizePath || defaultNormalizePath;
1484
1265
  let method = request.method;
1485
1266
  let location = createLocation("", normalizePathImpl(request), null, "default");
1486
- let matches = dataRouteMatcher.match(location);
1267
+ let matches = matchRoutesImpl(dataRoutes, location, basename, false, routeBranches);
1487
1268
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
1488
1269
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") throw getInternalRouterError(405, { method });
1489
1270
  else if (!matches) throw getInternalRouterError(404, { pathname: location.pathname });
@@ -2440,14 +2221,19 @@ function getPathsWithAncestors(paths) {
2440
2221
  function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
2441
2222
  let originHeader = request.headers.get("origin");
2442
2223
  let originDomain = null;
2224
+ let originUrl = null;
2443
2225
  try {
2444
- originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
2226
+ if (typeof originHeader === "string" && originHeader !== "null") {
2227
+ originUrl = new URL(originHeader);
2228
+ originDomain = originUrl.host;
2229
+ } else originDomain = originHeader;
2445
2230
  } catch {
2446
2231
  throw new Error(`\`origin\` header is not a valid URL. Aborting the action.`);
2447
2232
  }
2448
- let host = new URL(request.url).host;
2449
- if (originDomain && originDomain !== host) {
2450
- if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` host does not match `origin` header from a forwarded action request. Aborting the action.");
2233
+ let requestUrl = new URL(request.url);
2234
+ let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
2235
+ if (originDomain && !originMatchesRequest) {
2236
+ if (!isAllowedOrigin(originDomain, allowedActionOrigins)) throw new Error("The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action.");
2451
2237
  }
2452
2238
  }
2453
2239
  function matchWildcardDomain(domain, pattern) {
@@ -2544,11 +2330,6 @@ const Await = (async ({ children, resolve, errorElement }) => {
2544
2330
  }
2545
2331
  });
2546
2332
  });
2547
- function createRSCDataRouteMatcher(routes, basename) {
2548
- let dataRouteMatcher = createDataRouteMatcher({}, basename ?? "/");
2549
- dataRouteMatcher.update(routes);
2550
- return dataRouteMatcher;
2551
- }
2552
2333
  /**
2553
2334
  * Matches the given routes to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
2554
2335
  * and returns an [RSC](https://react.dev/reference/rsc/server-components)
@@ -2643,7 +2424,7 @@ async function matchRSCServerRequest({ allowedActionOrigins, createTemporaryRefe
2643
2424
  const requestUrl = new URL(request.url);
2644
2425
  if (isManifestRequest(requestUrl)) return await generateManifestResponse(routes, basename, request, generateResponse, temporaryReferences, routeDiscovery, clientVersion);
2645
2426
  let isDataRequest = isReactServerRequest(requestUrl);
2646
- let matches = createRSCDataRouteMatcher(routes, basename).match(url.pathname);
2427
+ let matches = matchRoutes(routes, url.pathname, basename);
2647
2428
  if (matches) await Promise.all(matches.map((m) => explodeLazyRoute(m.route)));
2648
2429
  const leafMatch = matches?.[matches.length - 1];
2649
2430
  if (!isDataRequest && leafMatch && !leafMatch.route.Component && !leafMatch.route.ErrorBoundary) return generateResourceResponse(routerRequest, routes, basename, leafMatch.route.id, requestContext, onError);
@@ -2680,10 +2461,9 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2680
2461
  }
2681
2462
  let pathParam = url.searchParams.get("paths");
2682
2463
  let pathnames = pathParam ? pathParam.split(",").filter(Boolean) : [url.pathname.replace(/\.manifest$/, "")];
2683
- let dataRouteMatcher = createRSCDataRouteMatcher(routes, basename);
2684
2464
  let routeIds = /* @__PURE__ */ new Set();
2685
2465
  let matchedRoutes = pathnames.flatMap((pathname) => {
2686
- let pathnameMatches = dataRouteMatcher.match(pathname);
2466
+ let pathnameMatches = matchRoutes(routes, pathname, basename);
2687
2467
  return pathnameMatches?.map((m, i) => ({
2688
2468
  ...m.route,
2689
2469
  parentId: pathnameMatches[i - 1]?.route.id
@@ -2697,7 +2477,7 @@ async function generateManifestResponse(routes, basename, request, generateRespo
2697
2477
  });
2698
2478
  let payload = {
2699
2479
  type: "manifest",
2700
- patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), getAdditionalRoutePatches(pathnames, dataRouteMatcher, Array.from(routeIds))]).then((r) => r.flat(1))
2480
+ patches: Promise.all([...matchedRoutes.map((route) => getManifestRoute(route)), getAdditionalRoutePatches(pathnames, routes, basename, Array.from(routeIds))]).then((r) => r.flat(1))
2701
2481
  };
2702
2482
  return generateResponse({
2703
2483
  statusCode: 200,
@@ -2958,12 +2738,7 @@ async function getRenderPayload(baseRenderPayload, routes, basename, routeIdsToL
2958
2738
  parentId
2959
2739
  });
2960
2740
  }));
2961
- let patches;
2962
- if (routeDiscovery?.mode === "initial" && !isDataRequest) patches = getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id)));
2963
- else {
2964
- let dataRouteMatcher = createRSCDataRouteMatcher(routes, basename);
2965
- patches = getAdditionalRoutePatches(getPathsWithAncestors([staticContext.location.pathname]), dataRouteMatcher, staticContext.matches.map((m) => m.route.id));
2966
- }
2741
+ let patches = routeDiscovery?.mode === "initial" && !isDataRequest ? getAllRoutePatches(routes, basename).then((patches) => patches.filter((patch) => !staticContext.matches.some((m) => m.route.id === patch.id))) : getAdditionalRoutePatches(getPathsWithAncestors([staticContext.location.pathname]), routes, basename, staticContext.matches.map((m) => m.route.id));
2967
2742
  return {
2968
2743
  ...baseRenderPayload,
2969
2744
  matches: await matchesPromise,
@@ -3067,13 +2842,13 @@ async function getAllRoutePatches(routes, basename) {
3067
2842
  for (let route of routes) await traverse(route, void 0);
3068
2843
  return patches.filter((p) => !!p.parentId);
3069
2844
  }
3070
- async function getAdditionalRoutePatches(pathnames, dataRouteMatcher, matchedRouteIds) {
2845
+ async function getAdditionalRoutePatches(pathnames, routes, basename, matchedRouteIds) {
3071
2846
  let patchRouteMatches = /* @__PURE__ */ new Map();
3072
2847
  let matchedPaths = /* @__PURE__ */ new Set();
3073
2848
  for (const pathname of pathnames) {
3074
2849
  if (matchedPaths.has(pathname)) continue;
3075
2850
  matchedPaths.add(pathname);
3076
- let matches = dataRouteMatcher.match(pathname) || [];
2851
+ let matches = matchRoutes(routes, pathname, basename) || [];
3077
2852
  matches.forEach((m, i) => {
3078
2853
  if (patchRouteMatches.get(m.route.id)) return;
3079
2854
  patchRouteMatches.set(m.route.id, {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v0.0.0-experimental-2a01b6fd8
2
+ * react-router v0.0.0-experimental-917e6fdc0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *