@depup/tanstack__react-router 1.167.0-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 (197) 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/dist/llms/rules/guide.d.ts +1 -1
  188. package/dist/llms/rules/guide.js +2 -2
  189. package/package.json +5 -5
  190. package/dist/cjs/index.cjs.map +0 -1
  191. package/dist/cjs/index.dev.cjs.map +0 -1
  192. package/dist/cjs/ssr/client.cjs.map +0 -1
  193. package/dist/cjs/ssr/server.cjs.map +0 -1
  194. package/dist/esm/index.dev.js.map +0 -1
  195. package/dist/esm/index.js.map +0 -1
  196. package/dist/esm/ssr/client.js.map +0 -1
  197. package/dist/esm/ssr/server.js.map +0 -1
@@ -1,109 +1,147 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const warning = require("tiny-warning");
4
- const route = require("./route.cjs");
5
- const useMatch = require("./useMatch.cjs");
6
- const useLoaderDeps = require("./useLoaderDeps.cjs");
7
- const useLoaderData = require("./useLoaderData.cjs");
8
- const useSearch = require("./useSearch.cjs");
9
- const useParams = require("./useParams.cjs");
10
- const useNavigate = require("./useNavigate.cjs");
11
- const useRouter = require("./useRouter.cjs");
12
- const useRouteContext = require("./useRouteContext.cjs");
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_useRouter = require("./useRouter.cjs");
3
+ const require_useMatch = require("./useMatch.cjs");
4
+ const require_useLoaderData = require("./useLoaderData.cjs");
5
+ const require_useLoaderDeps = require("./useLoaderDeps.cjs");
6
+ const require_useParams = require("./useParams.cjs");
7
+ const require_useSearch = require("./useSearch.cjs");
8
+ const require_useNavigate = require("./useNavigate.cjs");
9
+ const require_useRouteContext = require("./useRouteContext.cjs");
10
+ const require_route = require("./route.cjs");
11
+ let tiny_warning = require("tiny-warning");
12
+ tiny_warning = require_runtime.__toESM(tiny_warning);
13
+ //#region src/fileRoute.ts
14
+ /**
15
+ * Creates a file-based Route factory for a given path.
16
+ *
17
+ * Used by TanStack Router's file-based routing to associate a file with a
18
+ * route. The returned function accepts standard route options. In normal usage
19
+ * the `path` string is inserted and maintained by the `tsr` generator.
20
+ *
21
+ * @param path File path literal for the route (usually auto-generated).
22
+ * @returns A function that accepts Route options and returns a Route instance.
23
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createFileRouteFunction
24
+ */
13
25
  function createFileRoute(path) {
14
- if (typeof path === "object") {
15
- return new FileRoute(path, {
16
- silent: true
17
- }).createRoute(path);
18
- }
19
- return new FileRoute(path, {
20
- silent: true
21
- }).createRoute;
22
- }
23
- class FileRoute {
24
- constructor(path, _opts) {
25
- this.path = path;
26
- this.createRoute = (options) => {
27
- if (process.env.NODE_ENV !== "production") {
28
- warning(
29
- this.silent,
30
- "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
31
- );
32
- }
33
- const route$1 = route.createRoute(options);
34
- route$1.isRoot = false;
35
- return route$1;
36
- };
37
- this.silent = _opts?.silent;
38
- }
26
+ if (typeof path === "object") return new FileRoute(path, { silent: true }).createRoute(path);
27
+ return new FileRoute(path, { silent: true }).createRoute;
39
28
  }
29
+ /**
30
+ @deprecated It's no longer recommended to use the `FileRoute` class directly.
31
+ Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.
32
+ */
33
+ var FileRoute = class {
34
+ constructor(path, _opts) {
35
+ this.path = path;
36
+ this.createRoute = (options) => {
37
+ if (process.env.NODE_ENV !== "production") (0, tiny_warning.default)(this.silent, "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.");
38
+ const route = require_route.createRoute(options);
39
+ route.isRoot = false;
40
+ return route;
41
+ };
42
+ this.silent = _opts?.silent;
43
+ }
44
+ };
45
+ /**
46
+ @deprecated It's recommended not to split loaders into separate files.
47
+ Instead, place the loader function in the main route file via `createFileRoute`.
48
+ */
40
49
  function FileRouteLoader(_path) {
41
- if (process.env.NODE_ENV !== "production") {
42
- warning(
43
- false,
44
- `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`
45
- );
46
- }
47
- return (loaderFn) => loaderFn;
48
- }
49
- class LazyRoute {
50
- constructor(opts) {
51
- this.useMatch = (opts2) => {
52
- return useMatch.useMatch({
53
- select: opts2?.select,
54
- from: this.options.id,
55
- structuralSharing: opts2?.structuralSharing
56
- });
57
- };
58
- this.useRouteContext = (opts2) => {
59
- return useRouteContext.useRouteContext({ ...opts2, from: this.options.id });
60
- };
61
- this.useSearch = (opts2) => {
62
- return useSearch.useSearch({
63
- select: opts2?.select,
64
- structuralSharing: opts2?.structuralSharing,
65
- from: this.options.id
66
- });
67
- };
68
- this.useParams = (opts2) => {
69
- return useParams.useParams({
70
- select: opts2?.select,
71
- structuralSharing: opts2?.structuralSharing,
72
- from: this.options.id
73
- });
74
- };
75
- this.useLoaderDeps = (opts2) => {
76
- return useLoaderDeps.useLoaderDeps({ ...opts2, from: this.options.id });
77
- };
78
- this.useLoaderData = (opts2) => {
79
- return useLoaderData.useLoaderData({ ...opts2, from: this.options.id });
80
- };
81
- this.useNavigate = () => {
82
- const router = useRouter.useRouter();
83
- return useNavigate.useNavigate({ from: router.routesById[this.options.id].fullPath });
84
- };
85
- this.options = opts;
86
- this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
87
- }
50
+ if (process.env.NODE_ENV !== "production") (0, tiny_warning.default)(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`);
51
+ return (loaderFn) => loaderFn;
88
52
  }
53
+ var LazyRoute = class {
54
+ constructor(opts) {
55
+ this.useMatch = (opts) => {
56
+ return require_useMatch.useMatch({
57
+ select: opts?.select,
58
+ from: this.options.id,
59
+ structuralSharing: opts?.structuralSharing
60
+ });
61
+ };
62
+ this.useRouteContext = (opts) => {
63
+ return require_useRouteContext.useRouteContext({
64
+ ...opts,
65
+ from: this.options.id
66
+ });
67
+ };
68
+ this.useSearch = (opts) => {
69
+ return require_useSearch.useSearch({
70
+ select: opts?.select,
71
+ structuralSharing: opts?.structuralSharing,
72
+ from: this.options.id
73
+ });
74
+ };
75
+ this.useParams = (opts) => {
76
+ return require_useParams.useParams({
77
+ select: opts?.select,
78
+ structuralSharing: opts?.structuralSharing,
79
+ from: this.options.id
80
+ });
81
+ };
82
+ this.useLoaderDeps = (opts) => {
83
+ return require_useLoaderDeps.useLoaderDeps({
84
+ ...opts,
85
+ from: this.options.id
86
+ });
87
+ };
88
+ this.useLoaderData = (opts) => {
89
+ return require_useLoaderData.useLoaderData({
90
+ ...opts,
91
+ from: this.options.id
92
+ });
93
+ };
94
+ this.useNavigate = () => {
95
+ return require_useNavigate.useNavigate({ from: require_useRouter.useRouter().routesById[this.options.id].fullPath });
96
+ };
97
+ this.options = opts;
98
+ this.$$typeof = Symbol.for("react.memo");
99
+ }
100
+ };
101
+ /**
102
+ * Creates a lazily-configurable code-based route stub by ID.
103
+ *
104
+ * Use this for code-splitting with code-based routes. The returned function
105
+ * accepts only non-critical route options like `component`, `pendingComponent`,
106
+ * `errorComponent`, and `notFoundComponent` which are applied when the route
107
+ * is matched.
108
+ *
109
+ * @param id Route ID string literal to associate with the lazy route.
110
+ * @returns A function that accepts lazy route options and returns a `LazyRoute`.
111
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyRouteFunction
112
+ */
89
113
  function createLazyRoute(id) {
90
- return (opts) => {
91
- return new LazyRoute({
92
- id,
93
- ...opts
94
- });
95
- };
114
+ return (opts) => {
115
+ return new LazyRoute({
116
+ id,
117
+ ...opts
118
+ });
119
+ };
96
120
  }
121
+ /**
122
+ * Creates a lazily-configurable file-based route stub by file path.
123
+ *
124
+ * Use this for code-splitting with file-based routes (eg. `.lazy.tsx` files).
125
+ * The returned function accepts only non-critical route options like
126
+ * `component`, `pendingComponent`, `errorComponent`, and `notFoundComponent`.
127
+ *
128
+ * @param id File path literal for the route file.
129
+ * @returns A function that accepts lazy route options and returns a `LazyRoute`.
130
+ * @link https://tanstack.com/router/latest/docs/framework/react/api/router/createLazyFileRouteFunction
131
+ */
97
132
  function createLazyFileRoute(id) {
98
- if (typeof id === "object") {
99
- return new LazyRoute(id);
100
- }
101
- return (opts) => new LazyRoute({ id, ...opts });
133
+ if (typeof id === "object") return new LazyRoute(id);
134
+ return (opts) => new LazyRoute({
135
+ id,
136
+ ...opts
137
+ });
102
138
  }
139
+ //#endregion
103
140
  exports.FileRoute = FileRoute;
104
141
  exports.FileRouteLoader = FileRouteLoader;
105
142
  exports.LazyRoute = LazyRoute;
106
143
  exports.createFileRoute = createFileRoute;
107
144
  exports.createLazyFileRoute = createLazyFileRoute;
108
145
  exports.createLazyRoute = createLazyRoute;
109
- //# sourceMappingURL=fileRoute.cjs.map
146
+
147
+ //# sourceMappingURL=fileRoute.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileRoute.cjs","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":["route","createRoute","opts","useMatch","useRouteContext","useSearch","useParams","useLoaderDeps","useLoaderData","useRouter","useNavigate"],"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,YAAMA,UAAQC,MAAAA,YAAY,OAAc;AACtCD,cAAc,SAAS;AACzB,aAAOA;AAAAA,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,CAACE,UAAS;AAChD,aAAOC,kBAAS;AAAA,QACd,QAAQD,OAAM;AAAA,QACd,MAAM,KAAK,QAAQ;AAAA,QACnB,mBAAmBA,OAAM;AAAA,MAAA,CACnB;AAAA,IACV;AAEA,SAAA,kBAAsD,CAACA,UAAS;AAC9D,aAAOE,gBAAAA,gBAAgB,EAAE,GAAIF,OAAc,MAAM,KAAK,QAAQ,IAAI;AAAA,IACpE;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAOG,oBAAU;AAAA,QACf,QAAQH,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,YAA0C,CAACA,UAAS;AAElD,aAAOI,oBAAU;AAAA,QACf,QAAQJ,OAAM;AAAA,QACd,mBAAmBA,OAAM;AAAA,QACzB,MAAM,KAAK,QAAQ;AAAA,MAAA,CACb;AAAA,IACV;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAOK,cAAAA,cAAc,EAAE,GAAGL,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,gBAAkD,CAACA,UAAS;AAC1D,aAAOM,cAAAA,cAAc,EAAE,GAAGN,OAAM,MAAM,KAAK,QAAQ,IAAW;AAAA,IAChE;AAEA,SAAA,cAAc,MAA6C;AACzD,YAAM,SAASO,UAAAA,UAAA;AACf,aAAOC,YAAAA,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.cjs","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,EAAA,GAAA,aAAA,SACE,KAAK,QACL,kIACD;GAEH,MAAM,QAAQ,cAAA,YAAY,QAAe;AACvC,SAAc,SAAS;AACzB,UAAO;;AAzEP,OAAK,SAAS,OAAO;;;;;;;AAiFzB,SAAgB,gBAId,OAea;AACb,KAAA,QAAA,IAAA,aAA6B,aAC3B,EAAA,GAAA,aAAA,SACE,OACA,6MACD;AAEH,SAAQ,aAAa;;AAevB,IAAa,YAAb,MAAgD;CAK9C,YACE,MAGA;mBAKuC,SAAS;AAChD,UAAO,iBAAA,SAAS;IACd,QAAQ,MAAM;IACd,MAAM,KAAK,QAAQ;IACnB,mBAAmB,MAAM;IAC1B,CAAQ;;0BAG4C,SAAS;AAC9D,UAAO,wBAAA,gBAAgB;IAAE,GAAI;IAAc,MAAM,KAAK,QAAQ;IAAI,CAAC;;oBAG1B,SAAS;AAElD,UAAO,kBAAA,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK,QAAQ;IACpB,CAAQ;;oBAGgC,SAAS;AAElD,UAAO,kBAAA,UAAU;IACf,QAAQ,MAAM;IACd,mBAAmB,MAAM;IACzB,MAAM,KAAK,QAAQ;IACpB,CAAQ;;wBAGwC,SAAS;AAC1D,UAAO,sBAAA,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK,QAAQ;IAAI,CAAQ;;wBAGd,SAAS;AAC1D,UAAO,sBAAA,cAAc;IAAE,GAAG;IAAM,MAAM,KAAK,QAAQ;IAAI,CAAQ;;2BAGN;AAEzD,UAAO,oBAAA,YAAY,EAAE,MADN,kBAAA,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,185 +1,148 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const React = require("react");
4
- const routerCore = require("@tanstack/router-core");
5
- const useRouter = require("./useRouter.cjs");
6
- const useRouterState = require("./useRouterState.cjs");
7
- function _interopNamespaceDefault(e) {
8
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
9
- if (e) {
10
- for (const k in e) {
11
- if (k !== "default") {
12
- const d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: () => e[k]
16
- });
17
- }
18
- }
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
- const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
24
- const useTags = () => {
25
- const router = useRouter.useRouter();
26
- const nonce = router.options.ssr?.nonce;
27
- const routeMeta = useRouterState.useRouterState({
28
- select: (state) => {
29
- return state.matches.map((match) => match.meta).filter(Boolean);
30
- }
31
- });
32
- const meta = React__namespace.useMemo(() => {
33
- const resultMeta = [];
34
- const metaByAttribute = {};
35
- let title;
36
- for (let i = routeMeta.length - 1; i >= 0; i--) {
37
- const metas = routeMeta[i];
38
- for (let j = metas.length - 1; j >= 0; j--) {
39
- const m = metas[j];
40
- if (!m) continue;
41
- if (m.title) {
42
- if (!title) {
43
- title = {
44
- tag: "title",
45
- children: m.title
46
- };
47
- }
48
- } else if ("script:ld+json" in m) {
49
- try {
50
- const json = JSON.stringify(m["script:ld+json"]);
51
- resultMeta.push({
52
- tag: "script",
53
- attrs: {
54
- type: "application/ld+json"
55
- },
56
- children: routerCore.escapeHtml(json)
57
- });
58
- } catch {
59
- }
60
- } else {
61
- const attribute = m.name ?? m.property;
62
- if (attribute) {
63
- if (metaByAttribute[attribute]) {
64
- continue;
65
- } else {
66
- metaByAttribute[attribute] = true;
67
- }
68
- }
69
- resultMeta.push({
70
- tag: "meta",
71
- attrs: {
72
- ...m,
73
- nonce
74
- }
75
- });
76
- }
77
- }
78
- }
79
- if (title) {
80
- resultMeta.push(title);
81
- }
82
- if (nonce) {
83
- resultMeta.push({
84
- tag: "meta",
85
- attrs: {
86
- property: "csp-nonce",
87
- content: nonce
88
- }
89
- });
90
- }
91
- resultMeta.reverse();
92
- return resultMeta;
93
- }, [routeMeta, nonce]);
94
- const links = useRouterState.useRouterState({
95
- select: (state) => {
96
- const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
97
- tag: "link",
98
- attrs: {
99
- ...link,
100
- nonce
101
- }
102
- }));
103
- const manifest = router.ssr?.manifest;
104
- const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
105
- (asset) => ({
106
- tag: "link",
107
- attrs: {
108
- ...asset.attrs,
109
- suppressHydrationWarning: true,
110
- nonce
111
- }
112
- })
113
- );
114
- return [...constructed, ...assets];
115
- },
116
- structuralSharing: true
117
- });
118
- const preloadLinks = useRouterState.useRouterState({
119
- select: (state) => {
120
- const preloadLinks2 = [];
121
- state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
122
- (route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
123
- preloadLinks2.push({
124
- tag: "link",
125
- attrs: {
126
- rel: "modulepreload",
127
- href: preload,
128
- nonce
129
- }
130
- });
131
- })
132
- );
133
- return preloadLinks2;
134
- },
135
- structuralSharing: true
136
- });
137
- const styles = useRouterState.useRouterState({
138
- select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
139
- tag: "style",
140
- attrs: {
141
- ...attrs,
142
- nonce
143
- },
144
- children
145
- })),
146
- structuralSharing: true
147
- });
148
- const headScripts = useRouterState.useRouterState({
149
- select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
150
- tag: "script",
151
- attrs: {
152
- ...script,
153
- nonce
154
- },
155
- children
156
- })),
157
- structuralSharing: true
158
- });
159
- return uniqBy(
160
- [
161
- ...meta,
162
- ...preloadLinks,
163
- ...links,
164
- ...styles,
165
- ...headScripts
166
- ],
167
- (d) => {
168
- return JSON.stringify(d);
169
- }
170
- );
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_useRouter = require("./useRouter.cjs");
3
+ const require_useRouterState = require("./useRouterState.cjs");
4
+ let _tanstack_router_core = require("@tanstack/router-core");
5
+ let react = require("react");
6
+ react = require_runtime.__toESM(react);
7
+ //#region src/headContentUtils.tsx
8
+ /**
9
+ * Build the list of head/link/meta/script tags to render for active matches.
10
+ * Used internally by `HeadContent`.
11
+ */
12
+ var useTags = () => {
13
+ const router = require_useRouter.useRouter();
14
+ const nonce = router.options.ssr?.nonce;
15
+ const routeMeta = require_useRouterState.useRouterState({ select: (state) => {
16
+ return state.matches.map((match) => match.meta).filter(Boolean);
17
+ } });
18
+ const meta = react.useMemo(() => {
19
+ const resultMeta = [];
20
+ const metaByAttribute = {};
21
+ let title;
22
+ for (let i = routeMeta.length - 1; i >= 0; i--) {
23
+ const metas = routeMeta[i];
24
+ for (let j = metas.length - 1; j >= 0; j--) {
25
+ const m = metas[j];
26
+ if (!m) continue;
27
+ if (m.title) {
28
+ if (!title) title = {
29
+ tag: "title",
30
+ children: m.title
31
+ };
32
+ } else if ("script:ld+json" in m) try {
33
+ const json = JSON.stringify(m["script:ld+json"]);
34
+ resultMeta.push({
35
+ tag: "script",
36
+ attrs: { type: "application/ld+json" },
37
+ children: (0, _tanstack_router_core.escapeHtml)(json)
38
+ });
39
+ } catch {}
40
+ else {
41
+ const attribute = m.name ?? m.property;
42
+ if (attribute) if (metaByAttribute[attribute]) continue;
43
+ else metaByAttribute[attribute] = true;
44
+ resultMeta.push({
45
+ tag: "meta",
46
+ attrs: {
47
+ ...m,
48
+ nonce
49
+ }
50
+ });
51
+ }
52
+ }
53
+ }
54
+ if (title) resultMeta.push(title);
55
+ if (nonce) resultMeta.push({
56
+ tag: "meta",
57
+ attrs: {
58
+ property: "csp-nonce",
59
+ content: nonce
60
+ }
61
+ });
62
+ resultMeta.reverse();
63
+ return resultMeta;
64
+ }, [routeMeta, nonce]);
65
+ const links = require_useRouterState.useRouterState({
66
+ select: (state) => {
67
+ const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
68
+ tag: "link",
69
+ attrs: {
70
+ ...link,
71
+ nonce
72
+ }
73
+ }));
74
+ const manifest = router.ssr?.manifest;
75
+ const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map((asset) => ({
76
+ tag: "link",
77
+ attrs: {
78
+ ...asset.attrs,
79
+ suppressHydrationWarning: true,
80
+ nonce
81
+ }
82
+ }));
83
+ return [...constructed, ...assets];
84
+ },
85
+ structuralSharing: true
86
+ });
87
+ const preloadLinks = require_useRouterState.useRouterState({
88
+ select: (state) => {
89
+ const preloadLinks = [];
90
+ state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach((route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
91
+ preloadLinks.push({
92
+ tag: "link",
93
+ attrs: {
94
+ rel: "modulepreload",
95
+ href: preload,
96
+ nonce
97
+ }
98
+ });
99
+ }));
100
+ return preloadLinks;
101
+ },
102
+ structuralSharing: true
103
+ });
104
+ const styles = require_useRouterState.useRouterState({
105
+ select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
106
+ tag: "style",
107
+ attrs: {
108
+ ...attrs,
109
+ nonce
110
+ },
111
+ children
112
+ })),
113
+ structuralSharing: true
114
+ });
115
+ const headScripts = require_useRouterState.useRouterState({
116
+ select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
117
+ tag: "script",
118
+ attrs: {
119
+ ...script,
120
+ nonce
121
+ },
122
+ children
123
+ })),
124
+ structuralSharing: true
125
+ });
126
+ return uniqBy([
127
+ ...meta,
128
+ ...preloadLinks,
129
+ ...links,
130
+ ...styles,
131
+ ...headScripts
132
+ ], (d) => {
133
+ return JSON.stringify(d);
134
+ });
171
135
  };
172
136
  function uniqBy(arr, fn) {
173
- const seen = /* @__PURE__ */ new Set();
174
- return arr.filter((item) => {
175
- const key = fn(item);
176
- if (seen.has(key)) {
177
- return false;
178
- }
179
- seen.add(key);
180
- return true;
181
- });
137
+ const seen = /* @__PURE__ */ new Set();
138
+ return arr.filter((item) => {
139
+ const key = fn(item);
140
+ if (seen.has(key)) return false;
141
+ seen.add(key);
142
+ return true;
143
+ });
182
144
  }
183
- exports.uniqBy = uniqBy;
145
+ //#endregion
184
146
  exports.useTags = useTags;
185
- //# sourceMappingURL=headContentUtils.cjs.map
147
+
148
+ //# sourceMappingURL=headContentUtils.cjs.map