@octanejs/tanstack-start 0.1.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 (266) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +52 -0
  3. package/THIRD_PARTY_NOTICES.md +11 -0
  4. package/package.json +149 -0
  5. package/src/client-only.d.ts +1 -0
  6. package/src/client-only.js +0 -0
  7. package/src/client-rpc.d.ts +1 -0
  8. package/src/client-rpc.js +1 -0
  9. package/src/client.d.ts +3 -0
  10. package/src/client.js +2 -0
  11. package/src/default-entry/client.js +12 -0
  12. package/src/default-entry/server.js +13 -0
  13. package/src/default-entry/start.js +1 -0
  14. package/src/default-entry-paths.d.ts +5 -0
  15. package/src/default-entry-paths.js +11 -0
  16. package/src/index.d.ts +11 -0
  17. package/src/index.js +22 -0
  18. package/src/internal/README.md +15 -0
  19. package/src/internal/router-generator/config.d.ts +255 -0
  20. package/src/internal/router-generator/config.js +134 -0
  21. package/src/internal/router-generator/filesystem/physical/getRouteNodes.d.ts +53 -0
  22. package/src/internal/router-generator/filesystem/physical/getRouteNodes.js +335 -0
  23. package/src/internal/router-generator/filesystem/physical/rootPathId.d.ts +1 -0
  24. package/src/internal/router-generator/filesystem/physical/rootPathId.js +4 -0
  25. package/src/internal/router-generator/filesystem/virtual/config.d.ts +3 -0
  26. package/src/internal/router-generator/filesystem/virtual/config.js +36 -0
  27. package/src/internal/router-generator/filesystem/virtual/getRouteNodes.d.ts +31 -0
  28. package/src/internal/router-generator/filesystem/virtual/getRouteNodes.js +272 -0
  29. package/src/internal/router-generator/filesystem/virtual/loadConfigFile.d.ts +1 -0
  30. package/src/internal/router-generator/filesystem/virtual/loadConfigFile.js +10 -0
  31. package/src/internal/router-generator/generator.d.ts +119 -0
  32. package/src/internal/router-generator/generator.js +1080 -0
  33. package/src/internal/router-generator/index.d.ts +40 -0
  34. package/src/internal/router-generator/index.js +49 -0
  35. package/src/internal/router-generator/logger.d.ts +8 -0
  36. package/src/internal/router-generator/logger.js +30 -0
  37. package/src/internal/router-generator/plugin/types.d.ts +37 -0
  38. package/src/internal/router-generator/template.d.ts +38 -0
  39. package/src/internal/router-generator/template.js +220 -0
  40. package/src/internal/router-generator/transform/transform.d.ts +8 -0
  41. package/src/internal/router-generator/transform/transform.js +385 -0
  42. package/src/internal/router-generator/transform/types.d.ts +34 -0
  43. package/src/internal/router-generator/types.d.ts +73 -0
  44. package/src/internal/router-generator/utils.d.ts +270 -0
  45. package/src/internal/router-generator/utils.js +864 -0
  46. package/src/internal/router-generator/validate-route-params.d.ts +13 -0
  47. package/src/internal/router-generator/validate-route-params.js +75 -0
  48. package/src/internal/router-plugin/context.d.ts +2 -0
  49. package/src/internal/router-plugin/context.js +2 -0
  50. package/src/internal/router-plugin/core/code-splitter/compilers.d.ts +69 -0
  51. package/src/internal/router-plugin/core/code-splitter/compilers.js +1042 -0
  52. package/src/internal/router-plugin/core/code-splitter/framework-options.d.ts +11 -0
  53. package/src/internal/router-plugin/core/code-splitter/framework-options.js +41 -0
  54. package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.d.ts +12 -0
  55. package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.js +35 -0
  56. package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.d.ts +5 -0
  57. package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.js +106 -0
  58. package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.d.ts +8 -0
  59. package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.js +85 -0
  60. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.d.ts +2 -0
  61. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.js +55 -0
  62. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.d.ts +2 -0
  63. package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.js +50 -0
  64. package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.ts +5 -0
  65. package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.js +54 -0
  66. package/src/internal/router-plugin/core/code-splitter/plugins.d.ts +62 -0
  67. package/src/internal/router-plugin/core/code-splitter/types.d.ts +9 -0
  68. package/src/internal/router-plugin/core/config.d.ts +294 -0
  69. package/src/internal/router-plugin/core/config.js +56 -0
  70. package/src/internal/router-plugin/core/constants.d.ts +12 -0
  71. package/src/internal/router-plugin/core/constants.js +13 -0
  72. package/src/internal/router-plugin/core/framework-plugin-order.d.ts +8 -0
  73. package/src/internal/router-plugin/core/framework-plugin-order.js +78 -0
  74. package/src/internal/router-plugin/core/hmr/handle-route-update.d.ts +1 -0
  75. package/src/internal/router-plugin/core/hmr/handle-route-update.js +126 -0
  76. package/src/internal/router-plugin/core/hmr/index.d.ts +5 -0
  77. package/src/internal/router-plugin/core/hmr/select-adapter.d.ts +17 -0
  78. package/src/internal/router-plugin/core/hmr/select-adapter.js +24 -0
  79. package/src/internal/router-plugin/core/hmr/vite-adapter.d.ts +18 -0
  80. package/src/internal/router-plugin/core/hmr/vite-adapter.js +73 -0
  81. package/src/internal/router-plugin/core/hmr/webpack-adapter.d.ts +22 -0
  82. package/src/internal/router-plugin/core/hmr/webpack-adapter.js +78 -0
  83. package/src/internal/router-plugin/core/router-code-splitter-plugin.d.ts +10 -0
  84. package/src/internal/router-plugin/core/router-code-splitter-plugin.js +244 -0
  85. package/src/internal/router-plugin/core/router-composed-plugin.d.ts +5 -0
  86. package/src/internal/router-plugin/core/router-composed-plugin.js +62 -0
  87. package/src/internal/router-plugin/core/router-generator-plugin.d.ts +10 -0
  88. package/src/internal/router-plugin/core/router-generator-plugin.js +125 -0
  89. package/src/internal/router-plugin/core/router-hmr-plugin.d.ts +13 -0
  90. package/src/internal/router-plugin/core/router-hmr-plugin.js +101 -0
  91. package/src/internal/router-plugin/core/router-plugin-context.d.ts +5 -0
  92. package/src/internal/router-plugin/core/router-plugin-context.js +6 -0
  93. package/src/internal/router-plugin/core/utils.d.ts +17 -0
  94. package/src/internal/router-plugin/core/utils.js +47 -0
  95. package/src/internal/router-plugin/esbuild.d.ts +197 -0
  96. package/src/internal/router-plugin/esbuild.js +58 -0
  97. package/src/internal/router-plugin/index.d.ts +19 -0
  98. package/src/internal/router-plugin/index.js +17 -0
  99. package/src/internal/router-plugin/rspack.d.ts +61 -0
  100. package/src/internal/router-plugin/rspack.js +92 -0
  101. package/src/internal/router-plugin/vite.d.ts +201 -0
  102. package/src/internal/router-plugin/vite.js +62 -0
  103. package/src/internal/router-plugin/webpack.d.ts +50 -0
  104. package/src/internal/router-plugin/webpack.js +77 -0
  105. package/src/internal/start-plugin-core/build-sitemap.d.ts +34 -0
  106. package/src/internal/start-plugin-core/build-sitemap.js +125 -0
  107. package/src/internal/start-plugin-core/config-context.d.ts +30 -0
  108. package/src/internal/start-plugin-core/config-context.js +89 -0
  109. package/src/internal/start-plugin-core/constants.d.ts +20 -0
  110. package/src/internal/start-plugin-core/constants.js +24 -0
  111. package/src/internal/start-plugin-core/debug.d.ts +1 -0
  112. package/src/internal/start-plugin-core/hydrate-when-transform.d.ts +5 -0
  113. package/src/internal/start-plugin-core/hydrate-when-transform.js +661 -0
  114. package/src/internal/start-plugin-core/hydration-constants.d.ts +1 -0
  115. package/src/internal/start-plugin-core/hydration-constants.js +4 -0
  116. package/src/internal/start-plugin-core/import-protection/adapterUtils.d.ts +40 -0
  117. package/src/internal/start-plugin-core/import-protection/adapterUtils.js +42 -0
  118. package/src/internal/start-plugin-core/import-protection/analysis.d.ts +63 -0
  119. package/src/internal/start-plugin-core/import-protection/analysis.js +533 -0
  120. package/src/internal/start-plugin-core/import-protection/constants.d.ts +11 -0
  121. package/src/internal/start-plugin-core/import-protection/constants.js +39 -0
  122. package/src/internal/start-plugin-core/import-protection/defaults.d.ts +19 -0
  123. package/src/internal/start-plugin-core/import-protection/defaults.js +34 -0
  124. package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.d.ts +22 -0
  125. package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.js +94 -0
  126. package/src/internal/start-plugin-core/import-protection/matchers.d.ts +18 -0
  127. package/src/internal/start-plugin-core/import-protection/matchers.js +39 -0
  128. package/src/internal/start-plugin-core/import-protection/rewrite.d.ts +29 -0
  129. package/src/internal/start-plugin-core/import-protection/rewrite.js +184 -0
  130. package/src/internal/start-plugin-core/import-protection/sourceLocation.d.ts +170 -0
  131. package/src/internal/start-plugin-core/import-protection/sourceLocation.js +376 -0
  132. package/src/internal/start-plugin-core/import-protection/trace.d.ts +89 -0
  133. package/src/internal/start-plugin-core/import-protection/trace.js +186 -0
  134. package/src/internal/start-plugin-core/import-protection/utils.d.ts +78 -0
  135. package/src/internal/start-plugin-core/import-protection/utils.js +171 -0
  136. package/src/internal/start-plugin-core/import-protection/virtualModules.d.ts +38 -0
  137. package/src/internal/start-plugin-core/import-protection/virtualModules.js +241 -0
  138. package/src/internal/start-plugin-core/index.d.ts +8 -0
  139. package/src/internal/start-plugin-core/index.js +2 -0
  140. package/src/internal/start-plugin-core/planning.d.ts +44 -0
  141. package/src/internal/start-plugin-core/planning.js +98 -0
  142. package/src/internal/start-plugin-core/post-build.d.ts +12 -0
  143. package/src/internal/start-plugin-core/post-build.js +40 -0
  144. package/src/internal/start-plugin-core/prerender.d.ts +17 -0
  145. package/src/internal/start-plugin-core/prerender.js +172 -0
  146. package/src/internal/start-plugin-core/queue.d.ts +37 -0
  147. package/src/internal/start-plugin-core/queue.js +118 -0
  148. package/src/internal/start-plugin-core/resolve-entries.d.ts +10 -0
  149. package/src/internal/start-plugin-core/resolve-entries.js +32 -0
  150. package/src/internal/start-plugin-core/schema.d.ts +1799 -0
  151. package/src/internal/start-plugin-core/schema.js +252 -0
  152. package/src/internal/start-plugin-core/serialization-adapters-module.d.ts +18 -0
  153. package/src/internal/start-plugin-core/serialization-adapters-module.js +37 -0
  154. package/src/internal/start-plugin-core/start-compiler/compiler.d.ts +181 -0
  155. package/src/internal/start-plugin-core/start-compiler/compiler.js +1078 -0
  156. package/src/internal/start-plugin-core/start-compiler/config.d.ts +20 -0
  157. package/src/internal/start-plugin-core/start-compiler/config.js +84 -0
  158. package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.d.ts +24 -0
  159. package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.js +25 -0
  160. package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.d.ts +11 -0
  161. package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.js +24 -0
  162. package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.d.ts +11 -0
  163. package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.js +35 -0
  164. package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.d.ts +22 -0
  165. package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.js +292 -0
  166. package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.d.ts +14 -0
  167. package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.js +41 -0
  168. package/src/internal/start-plugin-core/start-compiler/host.d.ts +44 -0
  169. package/src/internal/start-plugin-core/start-compiler/host.js +75 -0
  170. package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.d.ts +10 -0
  171. package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.js +87 -0
  172. package/src/internal/start-plugin-core/start-compiler/types.d.ts +119 -0
  173. package/src/internal/start-plugin-core/start-compiler/utils.d.ts +27 -0
  174. package/src/internal/start-plugin-core/start-compiler/utils.js +36 -0
  175. package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.d.ts +16 -0
  176. package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.js +131 -0
  177. package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.d.ts +64 -0
  178. package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.js +441 -0
  179. package/src/internal/start-plugin-core/start-router-plugin/constants.d.ts +1 -0
  180. package/src/internal/start-plugin-core/start-router-plugin/constants.js +4 -0
  181. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.d.ts +6 -0
  182. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.js +6 -0
  183. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.d.ts +6 -0
  184. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.js +27 -0
  185. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.d.ts +6 -0
  186. package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.js +34 -0
  187. package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.d.ts +11 -0
  188. package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.js +42 -0
  189. package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.d.ts +6 -0
  190. package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.js +59 -0
  191. package/src/internal/start-plugin-core/types.d.ts +135 -0
  192. package/src/internal/start-plugin-core/types.js +4 -0
  193. package/src/internal/start-plugin-core/utils.d.ts +13 -0
  194. package/src/internal/start-plugin-core/utils.js +42 -0
  195. package/src/internal/start-plugin-core/vite/createVirtualModule.d.ts +15 -0
  196. package/src/internal/start-plugin-core/vite/createVirtualModule.js +27 -0
  197. package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.d.ts +26 -0
  198. package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.js +165 -0
  199. package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.d.ts +11 -0
  200. package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.js +170 -0
  201. package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.d.ts +4 -0
  202. package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.js +1553 -0
  203. package/src/internal/start-plugin-core/vite/import-protection-plugin/types.d.ts +103 -0
  204. package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.d.ts +40 -0
  205. package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.js +68 -0
  206. package/src/internal/start-plugin-core/vite/index.d.ts +13 -0
  207. package/src/internal/start-plugin-core/vite/index.js +4 -0
  208. package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.d.ts +2 -0
  209. package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.js +13 -0
  210. package/src/internal/start-plugin-core/vite/output-directory.d.ts +7 -0
  211. package/src/internal/start-plugin-core/vite/output-directory.js +18 -0
  212. package/src/internal/start-plugin-core/vite/planning.d.ts +112 -0
  213. package/src/internal/start-plugin-core/vite/planning.js +152 -0
  214. package/src/internal/start-plugin-core/vite/plugin.d.ts +7 -0
  215. package/src/internal/start-plugin-core/vite/plugin.js +208 -0
  216. package/src/internal/start-plugin-core/vite/plugins.d.ts +17 -0
  217. package/src/internal/start-plugin-core/vite/plugins.js +72 -0
  218. package/src/internal/start-plugin-core/vite/post-server-build.d.ts +9 -0
  219. package/src/internal/start-plugin-core/vite/post-server-build.js +22 -0
  220. package/src/internal/start-plugin-core/vite/prerender.d.ts +9 -0
  221. package/src/internal/start-plugin-core/vite/prerender.js +52 -0
  222. package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.d.ts +2 -0
  223. package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.js +54 -0
  224. package/src/internal/start-plugin-core/vite/schema.d.ts +2423 -0
  225. package/src/internal/start-plugin-core/vite/schema.js +17 -0
  226. package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.d.ts +5 -0
  227. package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.js +63 -0
  228. package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.d.ts +5 -0
  229. package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.js +14 -0
  230. package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.d.ts +5 -0
  231. package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.js +25 -0
  232. package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.d.ts +29 -0
  233. package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.js +380 -0
  234. package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.d.ts +11 -0
  235. package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.js +114 -0
  236. package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.d.ts +3 -0
  237. package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.js +103 -0
  238. package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.d.ts +9 -0
  239. package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.js +143 -0
  240. package/src/internal/start-plugin-core/vite/types.d.ts +17 -0
  241. package/src/package-names.js +10 -0
  242. package/src/plugin-vite.d.ts +23 -0
  243. package/src/plugin-vite.js +62 -0
  244. package/src/runtime/client/StartClient.d.ts +11 -0
  245. package/src/runtime/client/StartClient.js +16 -0
  246. package/src/runtime/client/hydrateStart.d.ts +4 -0
  247. package/src/runtime/client/hydrateStart.js +30 -0
  248. package/src/runtime/server/StartServer.d.ts +10 -0
  249. package/src/runtime/server/StartServer.js +6 -0
  250. package/src/runtime/server/defaultRenderHandler.d.ts +3 -0
  251. package/src/runtime/server/defaultRenderHandler.js +11 -0
  252. package/src/runtime/server/defaultStreamHandler.d.ts +3 -0
  253. package/src/runtime/server/defaultStreamHandler.js +13 -0
  254. package/src/server-entry.d.ts +11 -0
  255. package/src/server-entry.js +13 -0
  256. package/src/server-only.d.ts +1 -0
  257. package/src/server-only.js +0 -0
  258. package/src/server-rpc.d.ts +1 -0
  259. package/src/server-rpc.js +1 -0
  260. package/src/server.d.ts +6 -0
  261. package/src/server.js +4 -0
  262. package/src/ssr-rpc.d.ts +1 -0
  263. package/src/ssr-rpc.js +1 -0
  264. package/src/use-server-fn.d.ts +3 -0
  265. package/src/use-server-fn.js +18 -0
  266. package/src/validate-options.js +7 -0
@@ -0,0 +1,134 @@
1
+ import { virtualRootRouteSchema } from './filesystem/virtual/config.js';
2
+ import path from 'node:path';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { z } from 'zod';
5
+ //#region src/config.ts
6
+ var tokenJsonRegexSchema = z.object({
7
+ regex: z.string(),
8
+ flags: z.string().optional(),
9
+ });
10
+ var tokenMatcherSchema = z.union([z.string(), z.instanceof(RegExp), tokenJsonRegexSchema]);
11
+ var baseConfigSchema = z.object({
12
+ target: z.enum(['react', 'solid', 'vue', 'octane']).optional().default('react'),
13
+ virtualRouteConfig: virtualRootRouteSchema.or(z.string()).optional(),
14
+ routeFilePrefix: z.string().optional(),
15
+ routeFileIgnorePrefix: z.string().optional().default('-'),
16
+ routeFileIgnorePattern: z.string().optional(),
17
+ routesDirectory: z.string().optional().default('./src/routes'),
18
+ quoteStyle: z.enum(['single', 'double']).optional().default('single'),
19
+ semicolons: z.boolean().optional().default(false),
20
+ disableLogging: z.boolean().optional().default(false),
21
+ routeTreeFileHeader: z
22
+ .array(z.string())
23
+ .optional()
24
+ .default(['/* eslint-disable */', '// @ts-nocheck', '// noinspection JSUnusedGlobalSymbols']),
25
+ indexToken: tokenMatcherSchema.optional().default('index'),
26
+ routeToken: tokenMatcherSchema.optional().default('route'),
27
+ pathParamsAllowedCharacters: z.array(z.enum([';', ':', '@', '&', '=', '+', '$', ','])).optional(),
28
+ });
29
+ var configSchema = baseConfigSchema.extend({
30
+ generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),
31
+ disableTypes: z.boolean().optional().default(false),
32
+ addExtensions: z
33
+ .union([z.boolean(), z.string()])
34
+ .optional()
35
+ .default(false)
36
+ .transform((v) => (typeof v === 'string' ? (v.startsWith('.') ? v : `.${v}`) : v)),
37
+ enableRouteTreeFormatting: z.boolean().optional().default(true),
38
+ routeTreeFileFooter: z
39
+ .union([
40
+ z.array(z.string()).optional().default([]),
41
+ z.custom((value) => typeof value === 'function'),
42
+ ])
43
+ .optional(),
44
+ autoCodeSplitting: z.boolean().optional(),
45
+ customScaffolding: z
46
+ .object({
47
+ routeTemplate: z.string().optional(),
48
+ lazyRouteTemplate: z.string().optional(),
49
+ })
50
+ .optional(),
51
+ experimental: z.object({ enableCodeSplitting: z.boolean().optional() }).optional(),
52
+ plugins: z.array(z.custom()).optional(),
53
+ tmpDir: z.string().optional().default(''),
54
+ importRoutesUsingAbsolutePaths: z.boolean().optional().default(false),
55
+ });
56
+ function resolveConfigPath({ configDirectory }) {
57
+ return path.resolve(configDirectory, 'tsr.config.json');
58
+ }
59
+ function getConfig(inlineConfig = {}, configDirectory) {
60
+ if (configDirectory === void 0) configDirectory = process.cwd();
61
+ const configFilePathJson = resolveConfigPath({ configDirectory });
62
+ const exists = existsSync(configFilePathJson);
63
+ let config;
64
+ let rawConfig;
65
+ if (exists) {
66
+ const merged = {
67
+ ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),
68
+ ...inlineConfig,
69
+ };
70
+ rawConfig = merged;
71
+ config = configSchema.parse(merged);
72
+ } else {
73
+ rawConfig = inlineConfig;
74
+ config = configSchema.parse(inlineConfig);
75
+ }
76
+ if (config.target === 'octane' && rawConfig.addExtensions === void 0) config.addExtensions = true;
77
+ if (config.disableTypes)
78
+ config.generatedRouteTree = config.generatedRouteTree.replace(/\.(ts|tsx)$/, '.js');
79
+ if (configDirectory)
80
+ if (path.isAbsolute(configDirectory)) {
81
+ config.routesDirectory = path.resolve(configDirectory, config.routesDirectory);
82
+ config.generatedRouteTree = path.resolve(configDirectory, config.generatedRouteTree);
83
+ } else {
84
+ config.routesDirectory = path.resolve(process.cwd(), configDirectory, config.routesDirectory);
85
+ config.generatedRouteTree = path.resolve(
86
+ process.cwd(),
87
+ configDirectory,
88
+ config.generatedRouteTree,
89
+ );
90
+ }
91
+ const resolveTmpDir = (dir) => {
92
+ if (Array.isArray(dir)) dir = path.join(...dir);
93
+ if (!path.isAbsolute(dir)) dir = path.resolve(process.cwd(), dir);
94
+ return dir;
95
+ };
96
+ if (config.tmpDir) config.tmpDir = resolveTmpDir(config.tmpDir);
97
+ else if (process.env.TSR_TMP_DIR) config.tmpDir = resolveTmpDir(process.env.TSR_TMP_DIR);
98
+ else config.tmpDir = resolveTmpDir(['.tanstack', 'tmp']);
99
+ validateConfig(config);
100
+ return config;
101
+ }
102
+ function validateConfig(config) {
103
+ if (typeof config.experimental?.enableCodeSplitting !== 'undefined') {
104
+ const message = `
105
+ ------
106
+ ⚠️ ⚠️ ⚠️
107
+ ERROR: The "experimental.enableCodeSplitting" flag has been made stable and is now "autoCodeSplitting". Please update your configuration file to use "autoCodeSplitting" instead of "experimental.enableCodeSplitting".
108
+ ------
109
+ `;
110
+ console.error(message);
111
+ throw new Error(message);
112
+ }
113
+ if (areTokensEqual(config.indexToken, config.routeToken))
114
+ throw new Error(`The "indexToken" and "routeToken" options must be different.`);
115
+ if (config.routeFileIgnorePrefix && config.routeFileIgnorePrefix.trim() === '_')
116
+ throw new Error(
117
+ `The "routeFileIgnorePrefix" cannot be an underscore ("_"). This is a reserved character used to denote a pathless route. Please use a different prefix.`,
118
+ );
119
+ return config;
120
+ }
121
+ /**
122
+ * Compares two token matchers for equality.
123
+ * Handles strings, RegExp instances, and JSON regex objects.
124
+ */
125
+ function areTokensEqual(a, b) {
126
+ if (typeof a === 'string' && typeof b === 'string') return a === b;
127
+ if (a instanceof RegExp && b instanceof RegExp)
128
+ return a.source === b.source && a.flags === b.flags;
129
+ if (typeof a === 'object' && 'regex' in a && typeof b === 'object' && 'regex' in b)
130
+ return a.regex === b.regex && (a.flags ?? '') === (b.flags ?? '');
131
+ return false;
132
+ }
133
+ //#endregion
134
+ export { baseConfigSchema, configSchema, getConfig, resolveConfigPath };
@@ -0,0 +1,53 @@
1
+ import { FsRouteType, GetRouteNodesResult } from '../../types.js';
2
+ import { Config } from '../../config.js';
3
+ /**
4
+ * Pre-compiled segment regexes for matching token patterns against route segments.
5
+ * These are created once (in Generator constructor) and passed through to avoid
6
+ * repeated regex compilation during route crawling.
7
+ */
8
+ export interface TokenRegexBundle {
9
+ indexTokenSegmentRegex: RegExp;
10
+ routeTokenSegmentRegex: RegExp;
11
+ }
12
+ export declare function isVirtualConfigFile(fileName: string): boolean;
13
+ export declare function getRouteNodes(
14
+ config: Pick<
15
+ Config,
16
+ | 'routesDirectory'
17
+ | 'routeFilePrefix'
18
+ | 'routeFileIgnorePrefix'
19
+ | 'routeFileIgnorePattern'
20
+ | 'disableLogging'
21
+ | 'routeToken'
22
+ | 'indexToken'
23
+ >,
24
+ root: string,
25
+ tokenRegexes: TokenRegexBundle,
26
+ ): Promise<GetRouteNodesResult>;
27
+ /**
28
+ * Determines the metadata for a given route path based on the provided configuration.
29
+ *
30
+ * @param routePath - The determined initial routePath (with brackets removed).
31
+ * @param originalRoutePath - The original route path (may contain brackets for escaped content).
32
+ * @param tokenRegexes - Pre-compiled token regexes for matching.
33
+ * @returns An object containing the type of the route and the variable name derived from the route path.
34
+ */
35
+ export declare function getRouteMeta(
36
+ routePath: string,
37
+ originalRoutePath: string,
38
+ tokenRegexes: TokenRegexBundle,
39
+ ): {
40
+ fsRouteType: Extract<
41
+ FsRouteType,
42
+ | 'static'
43
+ | 'layout'
44
+ | 'api'
45
+ | 'lazy'
46
+ | 'loader'
47
+ | 'component'
48
+ | 'pendingComponent'
49
+ | 'errorComponent'
50
+ | 'notFoundComponent'
51
+ >;
52
+ variableName: string;
53
+ };
@@ -0,0 +1,335 @@
1
+ import { logging } from '../../logger.js';
2
+ import './rootPathId.js';
3
+ import {
4
+ cleanPath,
5
+ createRoutePathSegmentMetadata,
6
+ determineInitialRoutePath,
7
+ escapeRegExp,
8
+ hasEscapedLeadingUnderscore,
9
+ joinRoutePathSegmentMetadata,
10
+ removeExt,
11
+ replaceBackslash,
12
+ routePathToVariable,
13
+ unwrapBracketWrappedSegment,
14
+ } from '../../utils.js';
15
+ import { loadConfigFile } from '../virtual/loadConfigFile.js';
16
+ import { getRouteNodes as getRouteNodes$1 } from '../virtual/getRouteNodes.js';
17
+ import path from 'node:path';
18
+ import * as fsp from 'node:fs/promises';
19
+ //#region src/filesystem/physical/getRouteNodes.ts
20
+ var disallowedRouteGroupConfiguration = /\(([^)]+)\)\.(ts|js|tsx|jsx|vue|tsrx)$/;
21
+ var virtualConfigFileRegExp = /__virtual\.[mc]?[jt]s$/;
22
+ function isVirtualConfigFile(fileName) {
23
+ return virtualConfigFileRegExp.test(fileName);
24
+ }
25
+ async function getRouteNodes(config, root, tokenRegexes) {
26
+ const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } = config;
27
+ const logger = logging({ disabled: config.disableLogging });
28
+ const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? '', 'g');
29
+ const routeNodes = [];
30
+ const allPhysicalDirectories = [];
31
+ async function recurse(dir) {
32
+ const fullDir = path.resolve(config.routesDirectory, dir);
33
+ let dirList = await fsp.readdir(fullDir, { withFileTypes: true });
34
+ dirList = dirList.filter((d) => {
35
+ if (
36
+ d.name.startsWith('.') ||
37
+ (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))
38
+ )
39
+ return false;
40
+ if (routeFilePrefix) {
41
+ if (routeFileIgnorePattern)
42
+ return d.name.startsWith(routeFilePrefix) && !d.name.match(routeFileIgnoreRegExp);
43
+ return d.name.startsWith(routeFilePrefix);
44
+ }
45
+ if (routeFileIgnorePattern) return !d.name.match(routeFileIgnoreRegExp);
46
+ return true;
47
+ });
48
+ const virtualConfigFile = dirList.find((dirent) => {
49
+ return dirent.isFile() && isVirtualConfigFile(dirent.name);
50
+ });
51
+ if (virtualConfigFile !== void 0) {
52
+ const virtualRouteConfigExport = await loadConfigFile(
53
+ path.resolve(fullDir, virtualConfigFile.name),
54
+ );
55
+ let virtualRouteSubtreeConfig;
56
+ if (typeof virtualRouteConfigExport.default === 'function')
57
+ virtualRouteSubtreeConfig = await virtualRouteConfigExport.default();
58
+ else virtualRouteSubtreeConfig = virtualRouteConfigExport.default;
59
+ const dummyRoot = {
60
+ type: 'root',
61
+ file: '',
62
+ children: virtualRouteSubtreeConfig,
63
+ };
64
+ const { routeNodes: virtualRouteNodes, physicalDirectories } = await getRouteNodes$1(
65
+ {
66
+ ...config,
67
+ routesDirectory: fullDir,
68
+ virtualRouteConfig: dummyRoot,
69
+ },
70
+ root,
71
+ tokenRegexes,
72
+ );
73
+ allPhysicalDirectories.push(...physicalDirectories);
74
+ virtualRouteNodes.forEach((node) => {
75
+ const normalizedDir = dir === './' ? '' : dir;
76
+ const filePath = replaceBackslash(path.join(normalizedDir, node.filePath));
77
+ const { routePath: prefixPath, originalRoutePath: originalPrefixPath } = normalizedDir
78
+ ? determineInitialRoutePath(normalizedDir)
79
+ : {
80
+ routePath: '',
81
+ originalRoutePath: '',
82
+ };
83
+ const routePath = cleanPath(`${prefixPath}${node.routePath}`);
84
+ node.variableName = routePathToVariable(
85
+ cleanPath(`${prefixPath}/${removeExt(node.filePath)}`),
86
+ );
87
+ node._routePathSegmentMetadata = joinRoutePathSegmentMetadata(
88
+ routePath,
89
+ prefixPath,
90
+ createRoutePathSegmentMetadata(prefixPath, originalPrefixPath),
91
+ node._routePathSegmentMetadata,
92
+ );
93
+ node.routePath = routePath;
94
+ if (node.originalRoutePath)
95
+ node.originalRoutePath = cleanPath(`${originalPrefixPath}${node.originalRoutePath}`);
96
+ node.filePath = filePath;
97
+ delete node._virtualParentRoutePath;
98
+ });
99
+ routeNodes.push(...virtualRouteNodes);
100
+ return;
101
+ }
102
+ await Promise.all(
103
+ dirList.map(async (dirent) => {
104
+ const fullPath = replaceBackslash(path.join(fullDir, dirent.name));
105
+ const relativePath = path.posix.join(dir, dirent.name);
106
+ if (dirent.isDirectory()) await recurse(relativePath);
107
+ else if (fullPath.match(/\.(tsx|ts|jsx|js|vue|tsrx)$/)) {
108
+ const filePath = replaceBackslash(path.join(dir, dirent.name));
109
+ const { routePath: initialRoutePath, originalRoutePath: initialOriginalRoutePath } =
110
+ determineInitialRoutePath(removeExt(filePath));
111
+ let routePath = initialRoutePath;
112
+ let originalRoutePath = initialOriginalRoutePath;
113
+ if (routeFilePrefix) {
114
+ routePath = routePath.replaceAll(routeFilePrefix, '');
115
+ originalRoutePath = originalRoutePath.replaceAll(routeFilePrefix, '');
116
+ }
117
+ if (disallowedRouteGroupConfiguration.test(dirent.name)) {
118
+ const errorMessage = `A route configuration for a route group was found at \`${filePath}\`. This is not supported. Did you mean to use a layout/pathless route instead?`;
119
+ logger.error(`ERROR: ${errorMessage}`);
120
+ throw new Error(errorMessage);
121
+ }
122
+ const meta = getRouteMeta(routePath, originalRoutePath, tokenRegexes);
123
+ const variableName = meta.variableName;
124
+ let routeType = meta.fsRouteType;
125
+ if (routeType === 'lazy') {
126
+ routePath = routePath.replace(/\/lazy$/, '');
127
+ originalRoutePath = originalRoutePath.replace(/\/lazy$/, '');
128
+ }
129
+ if (isValidPathlessLayoutRoute(routePath, originalRoutePath, routeType, tokenRegexes))
130
+ routeType = 'pathless_layout';
131
+ if (!filePath.endsWith('.vue')) {
132
+ const extension = path.extname(filePath);
133
+ [
134
+ ['component', 'component'],
135
+ ['errorComponent', 'errorComponent'],
136
+ ['notFoundComponent', 'notFoundComponent'],
137
+ ['pendingComponent', 'pendingComponent'],
138
+ ['loader', 'loader'],
139
+ ].forEach(([matcher, type]) => {
140
+ if (routeType === matcher)
141
+ logger.warn(
142
+ `WARNING: The \`.${type}${extension}\` suffix used for the ${filePath} file is deprecated. Use the new \`.lazy${extension}\` suffix instead.`,
143
+ );
144
+ });
145
+ }
146
+ const originalSegments = originalRoutePath.split('/').filter(Boolean);
147
+ const lastOriginalSegmentForSuffix = originalSegments[originalSegments.length - 1] || '';
148
+ const { routeTokenSegmentRegex, indexTokenSegmentRegex } = tokenRegexes;
149
+ const specialSuffixes = [
150
+ 'component',
151
+ 'errorComponent',
152
+ 'notFoundComponent',
153
+ 'pendingComponent',
154
+ 'loader',
155
+ 'lazy',
156
+ ];
157
+ const routePathSegments = routePath.split('/').filter(Boolean);
158
+ const lastRouteSegment = routePathSegments[routePathSegments.length - 1] || '';
159
+ const suffixToStrip = specialSuffixes.find((suffix) => {
160
+ const endsWithSuffix = routePath.endsWith(`/${suffix}`);
161
+ const isEscaped =
162
+ lastOriginalSegmentForSuffix.startsWith('[') &&
163
+ lastOriginalSegmentForSuffix.endsWith(']') &&
164
+ unwrapBracketWrappedSegment(lastOriginalSegmentForSuffix) === suffix;
165
+ return endsWithSuffix && !isEscaped;
166
+ });
167
+ const routeTokenCandidate = unwrapBracketWrappedSegment(lastOriginalSegmentForSuffix);
168
+ const isRouteTokenEscaped =
169
+ lastOriginalSegmentForSuffix !== routeTokenCandidate &&
170
+ routeTokenSegmentRegex.test(routeTokenCandidate);
171
+ const shouldStripRouteToken =
172
+ routeTokenSegmentRegex.test(lastRouteSegment) && !isRouteTokenEscaped;
173
+ if (suffixToStrip || shouldStripRouteToken) {
174
+ const stripSegment = suffixToStrip ?? lastRouteSegment;
175
+ routePath = routePath.replace(new RegExp(`/${escapeRegExp(stripSegment)}$`), '');
176
+ originalRoutePath = originalRoutePath.replace(
177
+ new RegExp(`/${escapeRegExp(stripSegment)}$`),
178
+ '',
179
+ );
180
+ }
181
+ const lastOriginalSegment = originalRoutePath.split('/').filter(Boolean).pop() || '';
182
+ const indexTokenCandidate = unwrapBracketWrappedSegment(lastOriginalSegment);
183
+ if (
184
+ !(
185
+ lastOriginalSegment !== indexTokenCandidate &&
186
+ indexTokenSegmentRegex.test(indexTokenCandidate)
187
+ )
188
+ ) {
189
+ const updatedRouteSegments = routePath.split('/').filter(Boolean);
190
+ const updatedLastRouteSegment =
191
+ updatedRouteSegments[updatedRouteSegments.length - 1] || '';
192
+ if (indexTokenSegmentRegex.test(updatedLastRouteSegment)) {
193
+ if (routePathSegments.length === 1) routePath = '/';
194
+ const isLayoutRoute = routeType === 'layout';
195
+ routePath =
196
+ routePath.replace(new RegExp(`/${escapeRegExp(updatedLastRouteSegment)}$`), '/') ||
197
+ (isLayoutRoute ? '' : '/');
198
+ originalRoutePath =
199
+ originalRoutePath.replace(
200
+ new RegExp(`/${escapeRegExp(indexTokenCandidate)}$`),
201
+ '/',
202
+ ) || (isLayoutRoute ? '' : '/');
203
+ }
204
+ }
205
+ routeNodes.push({
206
+ filePath,
207
+ fullPath,
208
+ routePath,
209
+ variableName,
210
+ _fsRouteType: routeType,
211
+ originalRoutePath,
212
+ _routePathSegmentMetadata: createRoutePathSegmentMetadata(routePath, originalRoutePath),
213
+ });
214
+ }
215
+ }),
216
+ );
217
+ return routeNodes;
218
+ }
219
+ await recurse('./');
220
+ const rootRouteNode =
221
+ routeNodes.find(
222
+ (d) =>
223
+ d.routePath === `/__root` &&
224
+ ![
225
+ 'component',
226
+ 'errorComponent',
227
+ 'notFoundComponent',
228
+ 'pendingComponent',
229
+ 'loader',
230
+ 'lazy',
231
+ ].includes(d._fsRouteType),
232
+ ) ?? routeNodes.find((d) => d.routePath === `/__root`);
233
+ if (rootRouteNode) {
234
+ rootRouteNode._fsRouteType = '__root';
235
+ rootRouteNode.variableName = 'root';
236
+ }
237
+ return {
238
+ rootRouteNode,
239
+ routeNodes,
240
+ physicalDirectories: allPhysicalDirectories,
241
+ };
242
+ }
243
+ /**
244
+ * Determines the metadata for a given route path based on the provided configuration.
245
+ *
246
+ * @param routePath - The determined initial routePath (with brackets removed).
247
+ * @param originalRoutePath - The original route path (may contain brackets for escaped content).
248
+ * @param tokenRegexes - Pre-compiled token regexes for matching.
249
+ * @returns An object containing the type of the route and the variable name derived from the route path.
250
+ */
251
+ function getRouteMeta(routePath, originalRoutePath, tokenRegexes) {
252
+ let fsRouteType = 'static';
253
+ const originalSegments = originalRoutePath.split('/').filter(Boolean);
254
+ const lastOriginalSegment = originalSegments[originalSegments.length - 1] || '';
255
+ const { routeTokenSegmentRegex } = tokenRegexes;
256
+ const isSuffixEscaped = (suffix) => {
257
+ return (
258
+ lastOriginalSegment.startsWith('[') &&
259
+ lastOriginalSegment.endsWith(']') &&
260
+ unwrapBracketWrappedSegment(lastOriginalSegment) === suffix
261
+ );
262
+ };
263
+ const routeSegments = routePath.split('/').filter(Boolean);
264
+ const lastRouteSegment = routeSegments[routeSegments.length - 1] || '';
265
+ const routeTokenCandidate = unwrapBracketWrappedSegment(lastOriginalSegment);
266
+ const isRouteTokenEscaped =
267
+ lastOriginalSegment !== routeTokenCandidate && routeTokenSegmentRegex.test(routeTokenCandidate);
268
+ if (routeTokenSegmentRegex.test(lastRouteSegment) && !isRouteTokenEscaped) fsRouteType = 'layout';
269
+ else if (routePath.endsWith('/lazy') && !isSuffixEscaped('lazy')) fsRouteType = 'lazy';
270
+ else if (routePath.endsWith('/loader') && !isSuffixEscaped('loader')) fsRouteType = 'loader';
271
+ else if (routePath.endsWith('/component') && !isSuffixEscaped('component'))
272
+ fsRouteType = 'component';
273
+ else if (routePath.endsWith('/pendingComponent') && !isSuffixEscaped('pendingComponent'))
274
+ fsRouteType = 'pendingComponent';
275
+ else if (routePath.endsWith('/errorComponent') && !isSuffixEscaped('errorComponent'))
276
+ fsRouteType = 'errorComponent';
277
+ else if (routePath.endsWith('/notFoundComponent') && !isSuffixEscaped('notFoundComponent'))
278
+ fsRouteType = 'notFoundComponent';
279
+ const variableName = routePathToVariable(
280
+ originalSegments.some(
281
+ (seg) =>
282
+ seg.startsWith('[') &&
283
+ seg.endsWith(']') &&
284
+ !seg.slice(1, -1).includes('[') &&
285
+ !seg.slice(1, -1).includes(']'),
286
+ )
287
+ ? originalRoutePath
288
+ : routePath,
289
+ );
290
+ return {
291
+ fsRouteType,
292
+ variableName,
293
+ };
294
+ }
295
+ /**
296
+ * Used to validate if a route is a pathless layout route
297
+ * @param normalizedRoutePath Normalized route path, i.e `/foo/_layout/route.tsx` and `/foo._layout.route.tsx` to `/foo/_layout/route`
298
+ * @param originalRoutePath Original route path with brackets for escaped content
299
+ * @param routeType The route type determined from file extension
300
+ * @param tokenRegexes Pre-compiled token regexes for matching
301
+ * @returns Boolean indicating if the route is a pathless layout route
302
+ */
303
+ function isValidPathlessLayoutRoute(
304
+ normalizedRoutePath,
305
+ originalRoutePath,
306
+ routeType,
307
+ tokenRegexes,
308
+ ) {
309
+ if (routeType === 'lazy') return false;
310
+ const segments = normalizedRoutePath.split('/').filter(Boolean);
311
+ const originalSegments = originalRoutePath.split('/').filter(Boolean);
312
+ if (segments.length === 0) return false;
313
+ const lastRouteSegment = segments[segments.length - 1];
314
+ const lastOriginalSegment = originalSegments[originalSegments.length - 1] || '';
315
+ const secondToLastRouteSegment = segments[segments.length - 2];
316
+ const secondToLastOriginalSegment = originalSegments[originalSegments.length - 2];
317
+ if (lastRouteSegment === '__root') return false;
318
+ const { routeTokenSegmentRegex, indexTokenSegmentRegex } = tokenRegexes;
319
+ if (
320
+ routeTokenSegmentRegex.test(lastRouteSegment) &&
321
+ typeof secondToLastRouteSegment === 'string' &&
322
+ typeof secondToLastOriginalSegment === 'string'
323
+ ) {
324
+ if (hasEscapedLeadingUnderscore(secondToLastOriginalSegment)) return false;
325
+ return secondToLastRouteSegment.startsWith('_');
326
+ }
327
+ if (hasEscapedLeadingUnderscore(lastOriginalSegment)) return false;
328
+ return (
329
+ !indexTokenSegmentRegex.test(lastRouteSegment) &&
330
+ !routeTokenSegmentRegex.test(lastRouteSegment) &&
331
+ lastRouteSegment.startsWith('_')
332
+ );
333
+ }
334
+ //#endregion
335
+ export { getRouteNodes, isVirtualConfigFile };
@@ -0,0 +1 @@
1
+ export declare const rootPathId = '__root';
@@ -0,0 +1,4 @@
1
+ //#region src/filesystem/physical/rootPathId.ts
2
+ var rootPathId = '__root';
3
+ //#endregion
4
+ export { rootPathId };
@@ -0,0 +1,3 @@
1
+ import { z } from 'zod';
2
+ import { VirtualRootRoute } from '@tanstack/virtual-file-routes';
3
+ export declare const virtualRootRouteSchema: z.ZodType<VirtualRootRoute>;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ //#region src/filesystem/virtual/config.ts
3
+ var indexRouteSchema = z.object({
4
+ type: z.literal('index'),
5
+ file: z.string(),
6
+ });
7
+ var layoutRouteSchema = z.object({
8
+ type: z.literal('layout'),
9
+ id: z.string().optional(),
10
+ file: z.string(),
11
+ children: z.array(z.lazy(() => virtualRouteNodeSchema)).optional(),
12
+ });
13
+ var routeSchema = z.object({
14
+ type: z.literal('route'),
15
+ file: z.string().optional(),
16
+ path: z.string(),
17
+ children: z.array(z.lazy(() => virtualRouteNodeSchema)).optional(),
18
+ });
19
+ var physicalSubTreeSchema = z.object({
20
+ type: z.literal('physical'),
21
+ directory: z.string(),
22
+ pathPrefix: z.string(),
23
+ });
24
+ var virtualRouteNodeSchema = z.union([
25
+ indexRouteSchema,
26
+ layoutRouteSchema,
27
+ routeSchema,
28
+ physicalSubTreeSchema,
29
+ ]);
30
+ var virtualRootRouteSchema = z.object({
31
+ type: z.literal('root'),
32
+ file: z.string(),
33
+ children: z.array(virtualRouteNodeSchema).optional(),
34
+ });
35
+ //#endregion
36
+ export { virtualRootRouteSchema };
@@ -0,0 +1,31 @@
1
+ import { VirtualRouteNode } from '@tanstack/virtual-file-routes';
2
+ import { GetRouteNodesResult, RouteNode } from '../../types.js';
3
+ import { Config } from '../../config.js';
4
+ import { TokenRegexBundle } from '../physical/getRouteNodes.js';
5
+ export declare function getRouteNodes(
6
+ tsrConfig: Pick<
7
+ Config,
8
+ | 'routesDirectory'
9
+ | 'virtualRouteConfig'
10
+ | 'routeFileIgnorePrefix'
11
+ | 'disableLogging'
12
+ | 'indexToken'
13
+ | 'routeToken'
14
+ >,
15
+ root: string,
16
+ tokenRegexes: TokenRegexBundle,
17
+ ): Promise<GetRouteNodesResult>;
18
+ export declare function getRouteNodesRecursive(
19
+ tsrConfig: Pick<
20
+ Config,
21
+ 'routesDirectory' | 'routeFileIgnorePrefix' | 'disableLogging' | 'indexToken' | 'routeToken'
22
+ >,
23
+ root: string,
24
+ fullDir: string,
25
+ nodes: Array<VirtualRouteNode> | undefined,
26
+ tokenRegexes: TokenRegexBundle,
27
+ parent?: RouteNode,
28
+ ): Promise<{
29
+ children: Array<RouteNode>;
30
+ physicalDirectories: Array<string>;
31
+ }>;