@depup/tanstack__react-router 1.167.1-depup.0 → 1.167.3-depup.0

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 (195) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/Asset.cjs +115 -174
  3. package/dist/cjs/Asset.cjs.map +1 -1
  4. package/dist/cjs/CatchBoundary.cjs +92 -108
  5. package/dist/cjs/CatchBoundary.cjs.map +1 -1
  6. package/dist/cjs/ClientOnly.cjs +47 -13
  7. package/dist/cjs/ClientOnly.cjs.map +1 -1
  8. package/dist/cjs/HeadContent.cjs +23 -12
  9. package/dist/cjs/HeadContent.cjs.map +1 -1
  10. package/dist/cjs/HeadContent.dev.cjs +33 -38
  11. package/dist/cjs/HeadContent.dev.cjs.map +1 -1
  12. package/dist/cjs/Match.cjs +190 -247
  13. package/dist/cjs/Match.cjs.map +1 -1
  14. package/dist/cjs/Matches.cjs +131 -118
  15. package/dist/cjs/Matches.cjs.map +1 -1
  16. package/dist/cjs/RouterProvider.cjs +43 -27
  17. package/dist/cjs/RouterProvider.cjs.map +1 -1
  18. package/dist/cjs/SafeFragment.cjs +9 -5
  19. package/dist/cjs/SafeFragment.cjs.map +1 -1
  20. package/dist/cjs/ScriptOnce.cjs +17 -19
  21. package/dist/cjs/ScriptOnce.cjs.map +1 -1
  22. package/dist/cjs/Scripts.cjs +56 -54
  23. package/dist/cjs/Scripts.cjs.map +1 -1
  24. package/dist/cjs/ScrollRestoration.cjs +26 -30
  25. package/dist/cjs/ScrollRestoration.cjs.map +1 -1
  26. package/dist/cjs/Transitioner.cjs +109 -116
  27. package/dist/cjs/Transitioner.cjs.map +1 -1
  28. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  29. package/dist/cjs/awaited.cjs +28 -43
  30. package/dist/cjs/awaited.cjs.map +1 -1
  31. package/dist/cjs/fileRoute.cjs +133 -95
  32. package/dist/cjs/fileRoute.cjs.map +1 -1
  33. package/dist/cjs/headContentUtils.cjs +144 -181
  34. package/dist/cjs/headContentUtils.cjs.map +1 -1
  35. package/dist/cjs/index.cjs +249 -178
  36. package/dist/cjs/index.dev.cjs +249 -178
  37. package/dist/cjs/lazyRouteComponent.cjs +52 -67
  38. package/dist/cjs/lazyRouteComponent.cjs.map +1 -1
  39. package/dist/cjs/link.cjs +462 -556
  40. package/dist/cjs/link.cjs.map +1 -1
  41. package/dist/cjs/matchContext.cjs +9 -25
  42. package/dist/cjs/matchContext.cjs.map +1 -1
  43. package/dist/cjs/not-found.cjs +25 -32
  44. package/dist/cjs/not-found.cjs.map +1 -1
  45. package/dist/cjs/renderRouteNotFound.cjs +25 -19
  46. package/dist/cjs/renderRouteNotFound.cjs.map +1 -1
  47. package/dist/cjs/route.cjs +258 -178
  48. package/dist/cjs/route.cjs.map +1 -1
  49. package/dist/cjs/router.cjs +29 -16
  50. package/dist/cjs/router.cjs.map +1 -1
  51. package/dist/cjs/routerContext.cjs +8 -22
  52. package/dist/cjs/routerContext.cjs.map +1 -1
  53. package/dist/cjs/scroll-restoration.cjs +23 -36
  54. package/dist/cjs/scroll-restoration.cjs.map +1 -1
  55. package/dist/cjs/ssr/RouterClient.cjs +16 -22
  56. package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
  57. package/dist/cjs/ssr/RouterServer.cjs +10 -6
  58. package/dist/cjs/ssr/RouterServer.cjs.map +1 -1
  59. package/dist/cjs/ssr/client.cjs +10 -10
  60. package/dist/cjs/ssr/defaultRenderHandler.cjs +13 -14
  61. package/dist/cjs/ssr/defaultRenderHandler.cjs.map +1 -1
  62. package/dist/cjs/ssr/defaultStreamHandler.cjs +14 -15
  63. package/dist/cjs/ssr/defaultStreamHandler.cjs.map +1 -1
  64. package/dist/cjs/ssr/renderRouterToStream.cjs +51 -71
  65. package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
  66. package/dist/cjs/ssr/renderRouterToString.cjs +26 -29
  67. package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
  68. package/dist/cjs/ssr/server.cjs +18 -18
  69. package/dist/cjs/useBlocker.cjs +126 -162
  70. package/dist/cjs/useBlocker.cjs.map +1 -1
  71. package/dist/cjs/useCanGoBack.cjs +6 -5
  72. package/dist/cjs/useCanGoBack.cjs.map +1 -1
  73. package/dist/cjs/useLoaderData.cjs +24 -12
  74. package/dist/cjs/useLoaderData.cjs.map +1 -1
  75. package/dist/cjs/useLoaderDeps.cjs +23 -11
  76. package/dist/cjs/useLoaderDeps.cjs.map +1 -1
  77. package/dist/cjs/useLocation.cjs +17 -7
  78. package/dist/cjs/useLocation.cjs.map +1 -1
  79. package/dist/cjs/useMatch.cjs +25 -44
  80. package/dist/cjs/useMatch.cjs.map +1 -1
  81. package/dist/cjs/useNavigate.cjs +53 -43
  82. package/dist/cjs/useNavigate.cjs.map +1 -1
  83. package/dist/cjs/useParams.cjs +27 -14
  84. package/dist/cjs/useParams.cjs.map +1 -1
  85. package/dist/cjs/useRouteContext.cjs +9 -8
  86. package/dist/cjs/useRouteContext.cjs.map +1 -1
  87. package/dist/cjs/useRouter.cjs +23 -29
  88. package/dist/cjs/useRouter.cjs.map +1 -1
  89. package/dist/cjs/useRouterState.cjs +40 -35
  90. package/dist/cjs/useRouterState.cjs.map +1 -1
  91. package/dist/cjs/useSearch.cjs +26 -13
  92. package/dist/cjs/useSearch.cjs.map +1 -1
  93. package/dist/cjs/utils.cjs +81 -51
  94. package/dist/cjs/utils.cjs.map +1 -1
  95. package/dist/esm/Asset.js +112 -156
  96. package/dist/esm/Asset.js.map +1 -1
  97. package/dist/esm/CatchBoundary.js +90 -92
  98. package/dist/esm/CatchBoundary.js.map +1 -1
  99. package/dist/esm/ClientOnly.js +45 -14
  100. package/dist/esm/ClientOnly.js.map +1 -1
  101. package/dist/esm/HeadContent.dev.js +31 -21
  102. package/dist/esm/HeadContent.dev.js.map +1 -1
  103. package/dist/esm/HeadContent.js +20 -11
  104. package/dist/esm/HeadContent.js.map +1 -1
  105. package/dist/esm/Match.js +181 -226
  106. package/dist/esm/Match.js.map +1 -1
  107. package/dist/esm/Matches.js +125 -103
  108. package/dist/esm/Matches.js.map +1 -1
  109. package/dist/esm/RouterProvider.js +41 -28
  110. package/dist/esm/RouterProvider.js.map +1 -1
  111. package/dist/esm/SafeFragment.js +8 -6
  112. package/dist/esm/SafeFragment.js.map +1 -1
  113. package/dist/esm/ScriptOnce.js +15 -18
  114. package/dist/esm/ScriptOnce.js.map +1 -1
  115. package/dist/esm/Scripts.js +55 -54
  116. package/dist/esm/Scripts.js.map +1 -1
  117. package/dist/esm/ScrollRestoration.js +25 -31
  118. package/dist/esm/ScrollRestoration.js.map +1 -1
  119. package/dist/esm/Transitioner.js +106 -98
  120. package/dist/esm/Transitioner.js.map +1 -1
  121. package/dist/esm/awaited.js +26 -27
  122. package/dist/esm/awaited.js.map +1 -1
  123. package/dist/esm/fileRoute.js +127 -96
  124. package/dist/esm/fileRoute.js.map +1 -1
  125. package/dist/esm/headContentUtils.js +141 -163
  126. package/dist/esm/headContentUtils.js.map +1 -1
  127. package/dist/esm/index.dev.js +16 -117
  128. package/dist/esm/index.js +18 -118
  129. package/dist/esm/lazyRouteComponent.js +50 -50
  130. package/dist/esm/lazyRouteComponent.js.map +1 -1
  131. package/dist/esm/link.js +459 -541
  132. package/dist/esm/link.js.map +1 -1
  133. package/dist/esm/matchContext.js +8 -10
  134. package/dist/esm/matchContext.js.map +1 -1
  135. package/dist/esm/not-found.js +22 -32
  136. package/dist/esm/not-found.js.map +1 -1
  137. package/dist/esm/renderRouteNotFound.js +21 -18
  138. package/dist/esm/renderRouteNotFound.js.map +1 -1
  139. package/dist/esm/route.js +249 -180
  140. package/dist/esm/route.js.map +1 -1
  141. package/dist/esm/router.js +28 -17
  142. package/dist/esm/router.js.map +1 -1
  143. package/dist/esm/routerContext.js +7 -6
  144. package/dist/esm/routerContext.js.map +1 -1
  145. package/dist/esm/scroll-restoration.js +21 -35
  146. package/dist/esm/scroll-restoration.js.map +1 -1
  147. package/dist/esm/ssr/RouterClient.js +14 -21
  148. package/dist/esm/ssr/RouterClient.js.map +1 -1
  149. package/dist/esm/ssr/RouterServer.js +8 -6
  150. package/dist/esm/ssr/RouterServer.js.map +1 -1
  151. package/dist/esm/ssr/client.js +1 -4
  152. package/dist/esm/ssr/defaultRenderHandler.js +12 -13
  153. package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
  154. package/dist/esm/ssr/defaultStreamHandler.js +13 -14
  155. package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
  156. package/dist/esm/ssr/renderRouterToStream.js +48 -70
  157. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  158. package/dist/esm/ssr/renderRouterToString.js +24 -29
  159. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  160. package/dist/esm/ssr/server.js +3 -10
  161. package/dist/esm/useBlocker.js +124 -146
  162. package/dist/esm/useBlocker.js.map +1 -1
  163. package/dist/esm/useCanGoBack.js +6 -5
  164. package/dist/esm/useCanGoBack.js.map +1 -1
  165. package/dist/esm/useLoaderData.js +24 -12
  166. package/dist/esm/useLoaderData.js.map +1 -1
  167. package/dist/esm/useLoaderDeps.js +23 -11
  168. package/dist/esm/useLoaderDeps.js.map +1 -1
  169. package/dist/esm/useLocation.js +17 -7
  170. package/dist/esm/useLocation.js.map +1 -1
  171. package/dist/esm/useMatch.js +21 -26
  172. package/dist/esm/useMatch.js.map +1 -1
  173. package/dist/esm/useNavigate.js +50 -26
  174. package/dist/esm/useNavigate.js.map +1 -1
  175. package/dist/esm/useParams.js +27 -14
  176. package/dist/esm/useParams.js.map +1 -1
  177. package/dist/esm/useRouteContext.js +9 -8
  178. package/dist/esm/useRouteContext.js.map +1 -1
  179. package/dist/esm/useRouter.js +20 -12
  180. package/dist/esm/useRouter.js.map +1 -1
  181. package/dist/esm/useRouterState.js +38 -34
  182. package/dist/esm/useRouterState.js.map +1 -1
  183. package/dist/esm/useSearch.js +26 -13
  184. package/dist/esm/useSearch.js.map +1 -1
  185. package/dist/esm/utils.js +80 -39
  186. package/dist/esm/utils.js.map +1 -1
  187. package/package.json +5 -5
  188. package/dist/cjs/index.cjs.map +0 -1
  189. package/dist/cjs/index.dev.cjs.map +0 -1
  190. package/dist/cjs/ssr/client.cjs.map +0 -1
  191. package/dist/cjs/ssr/server.cjs.map +0 -1
  192. package/dist/esm/index.dev.js.map +0 -1
  193. package/dist/esm/index.js.map +0 -1
  194. package/dist/esm/ssr/client.js.map +0 -1
  195. package/dist/esm/ssr/server.js.map +0 -1
@@ -1,109 +1,140 @@
1
- import warning from "tiny-warning";
2
- import { createRoute } from "./route.js";
1
+ import { useRouter } from "./useRouter.js";
3
2
  import { useMatch } from "./useMatch.js";
4
- import { useLoaderDeps } from "./useLoaderDeps.js";
5
3
  import { useLoaderData } from "./useLoaderData.js";
6
- import { useSearch } from "./useSearch.js";
4
+ import { useLoaderDeps } from "./useLoaderDeps.js";
7
5
  import { useParams } from "./useParams.js";
6
+ import { useSearch } from "./useSearch.js";
8
7
  import { useNavigate } from "./useNavigate.js";
9
- import { useRouter } from "./useRouter.js";
10
8
  import { useRouteContext } from "./useRouteContext.js";
9
+ import { createRoute } from "./route.js";
10
+ import warning from "tiny-warning";
11
+ //#region src/fileRoute.ts
12
+ /**
13
+ * Creates a file-based Route factory for a given path.
14
+ *
15
+ * Used by TanStack Router's file-based routing to associate a file with a
16
+ * route. The returned function accepts standard route options. In normal usage
17
+ * the `path` string is inserted and maintained by the `tsr` generator.
18
+ *
19
+ * @param path File path literal for the route (usually auto-generated).
20
+ * @returns A function that accepts Route options and returns a Route instance.
21
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
22
+ */
11
23
  function createFileRoute(path) {
12
- if (typeof path === "object") {
13
- return new FileRoute(path, {
14
- silent: true
15
- }).createRoute(path);
16
- }
17
- return new FileRoute(path, {
18
- silent: true
19
- }).createRoute;
20
- }
21
- class FileRoute {
22
- constructor(path, _opts) {
23
- this.path = path;
24
- this.createRoute = (options) => {
25
- if (process.env.NODE_ENV !== "production") {
26
- warning(
27
- this.silent,
28
- "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
29
- );
30
- }
31
- const route = createRoute(options);
32
- route.isRoot = false;
33
- return route;
34
- };
35
- this.silent = _opts?.silent;
36
- }
24
+ if (typeof path === "object") return new FileRoute(path, { silent: true }).createRoute(path);
25
+ return new FileRoute(path, { silent: true }).createRoute;
37
26
  }
27
+ /**
28
+ @deprecated It's no longer recommended to use the `FileRoute` class directly.
29
+ Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
30
+ */
31
+ var FileRoute = class {
32
+ constructor(path, _opts) {
33
+ this.path = path;
34
+ this.createRoute = (options) => {
35
+ if (process.env.NODE_ENV !== "production") warning(this.silent, "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.");
36
+ const route = createRoute(options);
37
+ route.isRoot = false;
38
+ return route;
39
+ };
40
+ this.silent = _opts?.silent;
41
+ }
42
+ };
43
+ /**
44
+ @deprecated It's recommended not to split loaders into separate files.
45
+ Instead, place the loader function in the main route file via `createFileRoute`.
46
+ */
38
47
  function FileRouteLoader(_path) {
39
- if (process.env.NODE_ENV !== "production") {
40
- warning(
41
- false,
42
- `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`
43
- );
44
- }
45
- return (loaderFn) => loaderFn;
46
- }
47
- class LazyRoute {
48
- constructor(opts) {
49
- this.useMatch = (opts2) => {
50
- return useMatch({
51
- select: opts2?.select,
52
- from: this.options.id,
53
- structuralSharing: opts2?.structuralSharing
54
- });
55
- };
56
- this.useRouteContext = (opts2) => {
57
- return useRouteContext({ ...opts2, from: this.options.id });
58
- };
59
- this.useSearch = (opts2) => {
60
- return useSearch({
61
- select: opts2?.select,
62
- structuralSharing: opts2?.structuralSharing,
63
- from: this.options.id
64
- });
65
- };
66
- this.useParams = (opts2) => {
67
- return useParams({
68
- select: opts2?.select,
69
- structuralSharing: opts2?.structuralSharing,
70
- from: this.options.id
71
- });
72
- };
73
- this.useLoaderDeps = (opts2) => {
74
- return useLoaderDeps({ ...opts2, from: this.options.id });
75
- };
76
- this.useLoaderData = (opts2) => {
77
- return useLoaderData({ ...opts2, from: this.options.id });
78
- };
79
- this.useNavigate = () => {
80
- const router = useRouter();
81
- return useNavigate({ from: router.routesById[this.options.id].fullPath });
82
- };
83
- this.options = opts;
84
- this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
85
- }
48
+ if (process.env.NODE_ENV !== "production") warning(false, `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`);
49
+ return (loaderFn) => loaderFn;
86
50
  }
51
+ var LazyRoute = class {
52
+ constructor(opts) {
53
+ this.useMatch = (opts) => {
54
+ return useMatch({
55
+ select: opts?.select,
56
+ from: this.options.id,
57
+ structuralSharing: opts?.structuralSharing
58
+ });
59
+ };
60
+ this.useRouteContext = (opts) => {
61
+ return useRouteContext({
62
+ ...opts,
63
+ from: this.options.id
64
+ });
65
+ };
66
+ this.useSearch = (opts) => {
67
+ return useSearch({
68
+ select: opts?.select,
69
+ structuralSharing: opts?.structuralSharing,
70
+ from: this.options.id
71
+ });
72
+ };
73
+ this.useParams = (opts) => {
74
+ return useParams({
75
+ select: opts?.select,
76
+ structuralSharing: opts?.structuralSharing,
77
+ from: this.options.id
78
+ });
79
+ };
80
+ this.useLoaderDeps = (opts) => {
81
+ return useLoaderDeps({
82
+ ...opts,
83
+ from: this.options.id
84
+ });
85
+ };
86
+ this.useLoaderData = (opts) => {
87
+ return useLoaderData({
88
+ ...opts,
89
+ from: this.options.id
90
+ });
91
+ };
92
+ this.useNavigate = () => {
93
+ return useNavigate({ from: useRouter().routesById[this.options.id].fullPath });
94
+ };
95
+ this.options = opts;
96
+ this.$$typeof = Symbol.for("react.memo");
97
+ }
98
+ };
99
+ /**
100
+ * Creates a lazily-configurable code-based route stub by ID.
101
+ *
102
+ * Use this for code-splitting with code-based routes. The returned function
103
+ * accepts only non-critical route options like `component`, `pendingComponent`,
104
+ * `errorComponent`, and `notFoundComponent` which are applied when the route
105
+ * is matched.
106
+ *
107
+ * @param id Route ID string literal to associate with the lazy route.
108
+ * @returns A function that accepts lazy route options and returns a `LazyRoute`.
109
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
110
+ */
87
111
  function createLazyRoute(id) {
88
- return (opts) => {
89
- return new LazyRoute({
90
- id,
91
- ...opts
92
- });
93
- };
112
+ return (opts) => {
113
+ return new LazyRoute({
114
+ id,
115
+ ...opts
116
+ });
117
+ };
94
118
  }
119
+ /**
120
+ * Creates a lazily-configurable file-based route stub by file path.
121
+ *
122
+ * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
123
+ * The returned function accepts only non-critical route options like
124
+ * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
125
+ *
126
+ * @param id File path literal for the route file.
127
+ * @returns A function that accepts lazy route options and returns a `LazyRoute`.
128
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
129
+ */
95
130
  function createLazyFileRoute(id) {
96
- if (typeof id === "object") {
97
- return new LazyRoute(id);
98
- }
99
- return (opts) => new LazyRoute({ id, ...opts });
131
+ if (typeof id === "object") return new LazyRoute(id);
132
+ return (opts) => new LazyRoute({
133
+ id,
134
+ ...opts
135
+ });
100
136
  }
101
- export {
102
- FileRoute,
103
- FileRouteLoader,
104
- LazyRoute,
105
- createFileRoute,
106
- createLazyFileRoute,
107
- createLazyRoute
108
- };
109
- //# sourceMappingURL=fileRoute.js.map
137
+ //#endregion
138
+ export { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileRoute, createLazyRoute };
139
+
140
+ //# sourceMappingURL=fileRoute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport { useRouteContext } from './useRouteContext'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderEntry,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\n */\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister = Register,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TMiddlewares,\n THandlers\n > => {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n }\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/**\n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the main route file via `createFileRoute`.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderEntry<\n Register,\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n }\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.options.id })\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\n */\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\n\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\n */\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"names":["opts"],"mappings":";;;;;;;;;;AAiDO,SAAS,gBAQd,MAC0E;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EACrB;AACA,SAAO,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EAAA,CACT,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAaZ,YAgDG;AACH,UAAI,QAAQ,IAAI,aAAa,cAAc;AACzC;AAAA,UACE,KAAK;AAAA,UACL;AAAA,QAAA;AAAA,MAEJ;AACA,YAAM,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AACzB,aAAO;AAAA,IACT;AA1EE,SAAK,SAAS,OAAO;AAAA,EACvB;AA0EF;AAMO,SAAS,gBAId,OAea;AACb,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC;AAAA,MACE;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YACE,MAGA;AAKF,SAAA,WAAwC,CAACA,UAAS;AAChD,aAAO,SAAS;AAAA,QACd,QAAQA,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,mBAAmBA,OAAM;AAAA,MAAA,CACnB;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,aAAO,gBAAgB,EAAE,GAAIA,OAAc,MAAM,KAAK,QAAQ,IAAI;AAAA,IACpE;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAO,UAAU;AAAA,QACf,QAAQA,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAO,cAAc,EAAE,GAAGA,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAAS,UAAA;AACf,aAAO,YAAY,EAAE,MAAM,OAAO,WAAW,KAAK,QAAQ,EAAE,EAAE,UAAU;AAAA,IAC1E;AA7CE,SAAK,UAAU;AACb,SAAa,WAAW,uBAAO,IAAI,YAAY;AAAA,EACnD;AA4CF;AAcO,SAAS,gBAId,IAA2D;AAC3D,SAAO,CAAC,SAA2B;AACjC,WAAO,IAAI,UAAkB;AAAA,MAC3B;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,EACH;AACF;AAaO,SAAS,oBAGd,IAA8D;AAC9D,MAAI,OAAO,OAAO,UAAU;AAC1B,WAAO,IAAI,UAAkB,EAAE;AAAA,EACjC;AAEA,SAAO,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;"}
1
+ {"version":3,"file":"fileRoute.js","names":[],"sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport { useRouteContext } from './useRouteContext'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderEntry,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\n/**\n * Creates a file-based Route factory for a given path.\n *\n * Used by TanStack Router's file-based routing to associate a file with a\n * route. The returned function accepts standard route options. In normal usage\n * the `path` string is inserted and maintained by the `tsr` generator.\n *\n * @param path File path literal for the route (usually auto-generated).\n * @returns A function that accepts Route options and returns a Route instance.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction\n */\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends RouteConstraints['TFullPath'] =\n FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister = Register,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TMiddlewares,\n THandlers\n > => {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n }\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/**\n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the main route file via `createFileRoute`.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderEntry<\n Register,\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n if (process.env.NODE_ENV !== 'production') {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n }\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n ;(this as any).$$typeof = Symbol.for('react.memo')\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n structuralSharing: opts?.structuralSharing,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useRouteContext({ ...(opts as any), from: this.options.id })\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useSearch({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return useParams({\n select: opts?.select,\n structuralSharing: opts?.structuralSharing,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\n/**\n * Creates a lazily-configurable code-based route stub by ID.\n *\n * Use this for code-splitting with code-based routes. The returned function\n * accepts only non-critical route options like `component`, `pendingComponent`,\n * `errorComponent`, and `notFoundComponent` which are applied when the route\n * is matched.\n *\n * @param id Route ID string literal to associate with the lazy route.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction\n */\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\n\n/**\n * Creates a lazily-configurable file-based route stub by file path.\n *\n * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).\n * The returned function accepts only non-critical route options like\n * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.\n *\n * @param id File path literal for the route file.\n * @returns A function that accepts lazy route options and returns a `LazyRoute`.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction\n */\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,gBAQd,MAC0E;AAC1E,KAAI,OAAO,SAAS,SAClB,QAAO,IAAI,UAA0D,MAAM,EACzE,QAAQ,MACT,CAAC,CAAC,YAAY,KAAK;AAEtB,QAAO,IAAI,UAA0D,MAAM,EACzE,QAAQ,MACT,CAAC,CAAC;;;;;;AAOL,IAAa,YAAb,MAOE;CAGA,YACE,MACA,OACA;AAFO,OAAA,OAAA;sBAmBP,YAgDG;AACH,OAAA,QAAA,IAAA,aAA6B,aAC3B,SACE,KAAK,QACL,kIACD;GAEH,MAAM,QAAQ,YAAY,QAAe;AACvC,SAAc,SAAS;AACzB,UAAO;;AAzEP,OAAK,SAAS,OAAO;;;;;;;AAiFzB,SAAgB,gBAId,OAea;AACb,KAAA,QAAA,IAAA,aAA6B,aAC3B,SACE,OACA,6MACD;AAEH,SAAQ,aAAa;;AAevB,IAAa,YAAb,MAAgD;CAK9C,YACE,MAGA;mBAKuC,SAAS;AAChD,UAAO,SAAS;IACd,QAAQ,MAAM;IACd,MAAM,KAAK,QAAQ;IACnB,mBAAmB,MAAM;IAC1B,CAAQ;;0BAG4C,SAAS;AAC9D,UAAO,gBAAgB;IAAE,GAAI;IAAc,MAAM,KAAK,QAAQ;IAAI,CAAC;;oBAG1B,SAAS;AAElD,UAAO,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK,QAAQ;IACpB,CAAQ;;oBAGgC,SAAS;AAElD,UAAO,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK,QAAQ;IACpB,CAAQ;;wBAGwC,SAAS;AAC1D,UAAO,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK,QAAQ;IAAI,CAAQ;;wBAGd,SAAS;AAC1D,UAAO,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK,QAAQ;IAAI,CAAQ;;2BAGN;AAEzD,UAAO,YAAY,EAAE,MADN,WAAW,CACQ,WAAW,KAAK,QAAQ,IAAI,UAAU,CAAC;;AA5CzE,OAAK,UAAU;AACb,OAAa,WAAW,OAAO,IAAI,aAAa;;;;;;;;;;;;;;;AA2DtD,SAAgB,gBAId,IAA2D;AAC3D,SAAQ,SAA2B;AACjC,SAAO,IAAI,UAAkB;GACvB;GACJ,GAAG;GACJ,CAAC;;;;;;;;;;;;;;AAeN,SAAgB,oBAGd,IAA8D;AAC9D,KAAI,OAAO,OAAO,SAChB,QAAO,IAAI,UAAkB,GAAG;AAGlC,SAAQ,SAA2B,IAAI,UAAkB;EAAE;EAAI,GAAG;EAAM,CAAC"}
@@ -1,168 +1,146 @@
1
- import * as React from "react";
2
- import { escapeHtml } from "@tanstack/router-core";
3
1
  import { useRouter } from "./useRouter.js";
4
2
  import { useRouterState } from "./useRouterState.js";
5
- const useTags = () => {
6
- const router = useRouter();
7
- const nonce = router.options.ssr?.nonce;
8
- const routeMeta = useRouterState({
9
- select: (state) => {
10
- return state.matches.map((match) => match.meta).filter(Boolean);
11
- }
12
- });
13
- const meta = React.useMemo(() => {
14
- const resultMeta = [];
15
- const metaByAttribute = {};
16
- let title;
17
- for (let i = routeMeta.length - 1; i >= 0; i--) {
18
- const metas = routeMeta[i];
19
- for (let j = metas.length - 1; j >= 0; j--) {
20
- const m = metas[j];
21
- if (!m) continue;
22
- if (m.title) {
23
- if (!title) {
24
- title = {
25
- tag: "title",
26
- children: m.title
27
- };
28
- }
29
- } else if ("script:ld+json" in m) {
30
- try {
31
- const json = JSON.stringify(m["script:ld+json"]);
32
- resultMeta.push({
33
- tag: "script",
34
- attrs: {
35
- type: "application/ld+json"
36
- },
37
- children: escapeHtml(json)
38
- });
39
- } catch {
40
- }
41
- } else {
42
- const attribute = m.name ?? m.property;
43
- if (attribute) {
44
- if (metaByAttribute[attribute]) {
45
- continue;
46
- } else {
47
- metaByAttribute[attribute] = true;
48
- }
49
- }
50
- resultMeta.push({
51
- tag: "meta",
52
- attrs: {
53
- ...m,
54
- nonce
55
- }
56
- });
57
- }
58
- }
59
- }
60
- if (title) {
61
- resultMeta.push(title);
62
- }
63
- if (nonce) {
64
- resultMeta.push({
65
- tag: "meta",
66
- attrs: {
67
- property: "csp-nonce",
68
- content: nonce
69
- }
70
- });
71
- }
72
- resultMeta.reverse();
73
- return resultMeta;
74
- }, [routeMeta, nonce]);
75
- const links = useRouterState({
76
- select: (state) => {
77
- const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
78
- tag: "link",
79
- attrs: {
80
- ...link,
81
- nonce
82
- }
83
- }));
84
- const manifest = router.ssr?.manifest;
85
- const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
86
- (asset) => ({
87
- tag: "link",
88
- attrs: {
89
- ...asset.attrs,
90
- suppressHydrationWarning: true,
91
- nonce
92
- }
93
- })
94
- );
95
- return [...constructed, ...assets];
96
- },
97
- structuralSharing: true
98
- });
99
- const preloadLinks = useRouterState({
100
- select: (state) => {
101
- const preloadLinks2 = [];
102
- state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
103
- (route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
104
- preloadLinks2.push({
105
- tag: "link",
106
- attrs: {
107
- rel: "modulepreload",
108
- href: preload,
109
- nonce
110
- }
111
- });
112
- })
113
- );
114
- return preloadLinks2;
115
- },
116
- structuralSharing: true
117
- });
118
- const styles = useRouterState({
119
- select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
120
- tag: "style",
121
- attrs: {
122
- ...attrs,
123
- nonce
124
- },
125
- children
126
- })),
127
- structuralSharing: true
128
- });
129
- const headScripts = useRouterState({
130
- select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
131
- tag: "script",
132
- attrs: {
133
- ...script,
134
- nonce
135
- },
136
- children
137
- })),
138
- structuralSharing: true
139
- });
140
- return uniqBy(
141
- [
142
- ...meta,
143
- ...preloadLinks,
144
- ...links,
145
- ...styles,
146
- ...headScripts
147
- ],
148
- (d) => {
149
- return JSON.stringify(d);
150
- }
151
- );
3
+ import { escapeHtml } from "@tanstack/router-core";
4
+ import * as React$1 from "react";
5
+ //#region src/headContentUtils.tsx
6
+ /**
7
+ * Build the list of head/link/meta/script tags to render for active matches.
8
+ * Used internally by `HeadContent`.
9
+ */
10
+ var useTags = () => {
11
+ const router = useRouter();
12
+ const nonce = router.options.ssr?.nonce;
13
+ const routeMeta = useRouterState({ select: (state) => {
14
+ return state.matches.map((match) => match.meta).filter(Boolean);
15
+ } });
16
+ const meta = React$1.useMemo(() => {
17
+ const resultMeta = [];
18
+ const metaByAttribute = {};
19
+ let title;
20
+ for (let i = routeMeta.length - 1; i >= 0; i--) {
21
+ const metas = routeMeta[i];
22
+ for (let j = metas.length - 1; j >= 0; j--) {
23
+ const m = metas[j];
24
+ if (!m) continue;
25
+ if (m.title) {
26
+ if (!title) title = {
27
+ tag: "title",
28
+ children: m.title
29
+ };
30
+ } else if ("script:ld+json" in m) try {
31
+ const json = JSON.stringify(m["script:ld+json"]);
32
+ resultMeta.push({
33
+ tag: "script",
34
+ attrs: { type: "application/ld+json" },
35
+ children: escapeHtml(json)
36
+ });
37
+ } catch {}
38
+ else {
39
+ const attribute = m.name ?? m.property;
40
+ if (attribute) if (metaByAttribute[attribute]) continue;
41
+ else metaByAttribute[attribute] = true;
42
+ resultMeta.push({
43
+ tag: "meta",
44
+ attrs: {
45
+ ...m,
46
+ nonce
47
+ }
48
+ });
49
+ }
50
+ }
51
+ }
52
+ if (title) resultMeta.push(title);
53
+ if (nonce) resultMeta.push({
54
+ tag: "meta",
55
+ attrs: {
56
+ property: "csp-nonce",
57
+ content: nonce
58
+ }
59
+ });
60
+ resultMeta.reverse();
61
+ return resultMeta;
62
+ }, [routeMeta, nonce]);
63
+ const links = useRouterState({
64
+ select: (state) => {
65
+ const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
66
+ tag: "link",
67
+ attrs: {
68
+ ...link,
69
+ nonce
70
+ }
71
+ }));
72
+ const manifest = router.ssr?.manifest;
73
+ const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map((asset) => ({
74
+ tag: "link",
75
+ attrs: {
76
+ ...asset.attrs,
77
+ suppressHydrationWarning: true,
78
+ nonce
79
+ }
80
+ }));
81
+ return [...constructed, ...assets];
82
+ },
83
+ structuralSharing: true
84
+ });
85
+ const preloadLinks = useRouterState({
86
+ select: (state) => {
87
+ const preloadLinks = [];
88
+ state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
89
+ preloadLinks.push({
90
+ tag: "link",
91
+ attrs: {
92
+ rel: "modulepreload",
93
+ href: preload,
94
+ nonce
95
+ }
96
+ });
97
+ }));
98
+ return preloadLinks;
99
+ },
100
+ structuralSharing: true
101
+ });
102
+ const styles = useRouterState({
103
+ select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
104
+ tag: "style",
105
+ attrs: {
106
+ ...attrs,
107
+ nonce
108
+ },
109
+ children
110
+ })),
111
+ structuralSharing: true
112
+ });
113
+ const headScripts = useRouterState({
114
+ select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
115
+ tag: "script",
116
+ attrs: {
117
+ ...script,
118
+ nonce
119
+ },
120
+ children
121
+ })),
122
+ structuralSharing: true
123
+ });
124
+ return uniqBy([
125
+ ...meta,
126
+ ...preloadLinks,
127
+ ...links,
128
+ ...styles,
129
+ ...headScripts
130
+ ], (d) => {
131
+ return JSON.stringify(d);
132
+ });
152
133
  };
153
134
  function uniqBy(arr, fn) {
154
- const seen = /* @__PURE__ */ new Set();
155
- return arr.filter((item) => {
156
- const key = fn(item);
157
- if (seen.has(key)) {
158
- return false;
159
- }
160
- seen.add(key);
161
- return true;
162
- });
135
+ const seen = /* @__PURE__ */ new Set();
136
+ return arr.filter((item) => {
137
+ const key = fn(item);
138
+ if (seen.has(key)) return false;
139
+ seen.add(key);
140
+ return true;
141
+ });
163
142
  }
164
- export {
165
- uniqBy,
166
- useTags
167
- };
168
- //# sourceMappingURL=headContentUtils.js.map
143
+ //#endregion
144
+ export { useTags };
145
+
146
+ //# sourceMappingURL=headContentUtils.js.map