@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,40 @@
1
+ export { configSchema, getConfig, resolveConfigPath, baseConfigSchema } from './config.js';
2
+ export type { Config, BaseConfig } from './config.js';
3
+ export { Generator } from './generator.js';
4
+ export type { FileEventType, FileEvent, GeneratorEvent } from './generator.js';
5
+ export type {
6
+ FormatRouteOptions,
7
+ GeneratorPlugin,
8
+ TransformRouteSourceOptions,
9
+ } from './plugin/types.js';
10
+ export {
11
+ capitalize,
12
+ cleanPath,
13
+ trimPathLeft,
14
+ removeLeadingSlash,
15
+ removeTrailingSlash,
16
+ determineInitialRoutePath,
17
+ replaceBackslash,
18
+ routePathToVariable,
19
+ removeUnderscores,
20
+ resetRegex,
21
+ multiSortBy,
22
+ writeIfDifferent,
23
+ format,
24
+ removeExt,
25
+ checkRouteFullPathUniqueness,
26
+ inferFullPath,
27
+ } from './utils.js';
28
+ export type {
29
+ RouteNode,
30
+ GetRouteNodesResult,
31
+ GetRoutesByFileMapResult,
32
+ GetRoutesByFileMapResultValue,
33
+ ImportDeclaration,
34
+ ImportSpecifier,
35
+ HandleNodeAccumulator,
36
+ } from './types.js';
37
+ export { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes.js';
38
+ export { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes.js';
39
+ export { rootPathId } from './filesystem/physical/rootPathId.js';
40
+ export type { TransformContext, TransformOptions, TransformResult } from './transform/types.js';
@@ -0,0 +1,49 @@
1
+ import { baseConfigSchema, configSchema, getConfig, resolveConfigPath } from './config.js';
2
+ import { rootPathId } from './filesystem/physical/rootPathId.js';
3
+ import {
4
+ capitalize,
5
+ checkRouteFullPathUniqueness,
6
+ cleanPath,
7
+ determineInitialRoutePath,
8
+ format,
9
+ inferFullPath,
10
+ multiSortBy,
11
+ removeExt,
12
+ removeLeadingSlash,
13
+ removeTrailingSlash,
14
+ removeUnderscores,
15
+ replaceBackslash,
16
+ resetRegex,
17
+ routePathToVariable,
18
+ trimPathLeft,
19
+ writeIfDifferent,
20
+ } from './utils.js';
21
+ import { getRouteNodes as getRouteNodes$1 } from './filesystem/virtual/getRouteNodes.js';
22
+ import { getRouteNodes } from './filesystem/physical/getRouteNodes.js';
23
+ import { Generator } from './generator.js';
24
+ export {
25
+ Generator,
26
+ baseConfigSchema,
27
+ capitalize,
28
+ checkRouteFullPathUniqueness,
29
+ cleanPath,
30
+ configSchema,
31
+ determineInitialRoutePath,
32
+ format,
33
+ getConfig,
34
+ inferFullPath,
35
+ multiSortBy,
36
+ getRouteNodes as physicalGetRouteNodes,
37
+ removeExt,
38
+ removeLeadingSlash,
39
+ removeTrailingSlash,
40
+ removeUnderscores,
41
+ replaceBackslash,
42
+ resetRegex,
43
+ resolveConfigPath,
44
+ rootPathId,
45
+ routePathToVariable,
46
+ trimPathLeft,
47
+ getRouteNodes$1 as virtualGetRouteNodes,
48
+ writeIfDifferent,
49
+ };
@@ -0,0 +1,8 @@
1
+ export interface Logger {
2
+ log: (...args: Array<any>) => void;
3
+ debug: (...args: Array<any>) => void;
4
+ info: (...args: Array<any>) => void;
5
+ warn: (...args: Array<any>) => void;
6
+ error: (...args: Array<any>) => void;
7
+ }
8
+ export declare function logging(config: { disabled: boolean }): Logger;
@@ -0,0 +1,30 @@
1
+ //#region src/logger.ts
2
+ function logging(config) {
3
+ function stripEmojis(str) {
4
+ return str.replace(/[\p{Emoji_Presentation}\p{Extended_Pictographic}]/gu, '');
5
+ }
6
+ function formatLogArgs(args) {
7
+ if (process.env.CI)
8
+ return args.map((arg) => (typeof arg === 'string' ? stripEmojis(arg) : arg));
9
+ return args;
10
+ }
11
+ return {
12
+ log: (...args) => {
13
+ if (!config.disabled) console.log(...formatLogArgs(args));
14
+ },
15
+ debug: (...args) => {
16
+ if (!config.disabled) console.debug(...formatLogArgs(args));
17
+ },
18
+ info: (...args) => {
19
+ if (!config.disabled) console.info(...formatLogArgs(args));
20
+ },
21
+ warn: (...args) => {
22
+ if (!config.disabled) console.warn(...formatLogArgs(args));
23
+ },
24
+ error: (...args) => {
25
+ if (!config.disabled) console.error(...formatLogArgs(args));
26
+ },
27
+ };
28
+ }
29
+ //#endregion
30
+ export { logging };
@@ -0,0 +1,37 @@
1
+ import { HandleNodeAccumulator, RouteNode } from '../types.js';
2
+ import { Generator } from '../generator.js';
3
+ export interface TransformRouteSourceOptions {
4
+ source: string;
5
+ filename: string;
6
+ node: RouteNode;
7
+ }
8
+ export interface FormatRouteOptions {
9
+ source: string;
10
+ node: RouteNode;
11
+ }
12
+ export interface GeneratorPlugin {
13
+ name: string;
14
+ init?: (opts: { generator: Generator }) => void;
15
+ onRouteTreeChanged?: (opts: {
16
+ routeTree: Array<RouteNode>;
17
+ routeNodes: Array<RouteNode>;
18
+ rootRouteNode: RouteNode;
19
+ acc: HandleNodeAccumulator;
20
+ }) => void;
21
+ afterTransform?: (opts: { node: RouteNode; prevNode: RouteNode | undefined }) => void;
22
+ /**
23
+ * Converts framework-specific route syntax into position-preserving
24
+ * TypeScript/JSX for route analysis. Hooks run in plugin order and each
25
+ * returned value is passed to the next hook. The final source must have the
26
+ * same length as the authored source. It is never emitted.
27
+ */
28
+ transformRouteSource?: (
29
+ opts: TransformRouteSourceOptions,
30
+ ) => string | void | Promise<string | void>;
31
+ /**
32
+ * Formats a newly scaffolded route. Hooks run in plugin order and each
33
+ * returned value is passed to the next hook. The built-in TypeScript
34
+ * formatter is used only when no plugin handles the route.
35
+ */
36
+ formatRoute?: (opts: FormatRouteOptions) => string | void | Promise<string | void>;
37
+ }
@@ -0,0 +1,38 @@
1
+ import { Config } from './config.js';
2
+ type TemplateTag = 'tsrImports' | 'tsrPath' | 'tsrExportStart' | 'tsrExportEnd';
3
+ export declare function fillTemplate(
4
+ config: Config,
5
+ template: string,
6
+ values: Record<TemplateTag, string>,
7
+ formatter?: (source: string) => string | Promise<string>,
8
+ ): string | Promise<string>;
9
+ export type TargetTemplate = {
10
+ fullPkg: string;
11
+ subPkg: string;
12
+ rootRoute: {
13
+ template: () => string;
14
+ imports: {
15
+ tsrImports: () => string;
16
+ tsrExportStart: () => string;
17
+ tsrExportEnd: () => string;
18
+ };
19
+ };
20
+ route: {
21
+ template: () => string;
22
+ imports: {
23
+ tsrImports: () => string;
24
+ tsrExportStart: (routePath: string) => string;
25
+ tsrExportEnd: () => string;
26
+ };
27
+ };
28
+ lazyRoute: {
29
+ template: () => string;
30
+ imports: {
31
+ tsrImports: () => string;
32
+ tsrExportStart: (routePath: string) => string;
33
+ tsrExportEnd: () => string;
34
+ };
35
+ };
36
+ };
37
+ export declare function getTargetTemplate(config: Config): TargetTemplate;
38
+ export {};
@@ -0,0 +1,220 @@
1
+ import { format } from './utils.js';
2
+ import { OCTANE_ROUTER_PACKAGE } from '#tanstack-start/package-names';
3
+ //#region src/template.ts
4
+ function fillTemplate(config, template, values, formatter) {
5
+ const replaced = template.replace(/%%(\w+)%%/g, (_, key) => values[key] || '');
6
+ return formatter ? formatter(replaced) : format(replaced, config);
7
+ }
8
+ function serializeRoutePath(routePath) {
9
+ return JSON.stringify(routePath);
10
+ }
11
+ function getTargetTemplate(config) {
12
+ const target = config.target;
13
+ switch (target) {
14
+ case 'react':
15
+ return {
16
+ fullPkg: '@tanstack/react-router',
17
+ subPkg: 'react-router',
18
+ rootRoute: {
19
+ template: () =>
20
+ [
21
+ 'import * as React from "react"\n',
22
+ '%%tsrImports%%',
23
+ '\n\n',
24
+ '%%tsrExportStart%%{\n component: RootComponent\n }%%tsrExportEnd%%\n\n',
25
+ 'function RootComponent() { return (<React.Fragment><div>Hello "%%tsrPath%%"!</div><Outlet /></React.Fragment>) };\n',
26
+ ].join(''),
27
+ imports: {
28
+ tsrImports: () => "import { Outlet, createRootRoute } from '@tanstack/react-router';",
29
+ tsrExportStart: () => 'export const Route = createRootRoute(',
30
+ tsrExportEnd: () => ');',
31
+ },
32
+ },
33
+ route: {
34
+ template: () =>
35
+ [
36
+ '%%tsrImports%%',
37
+ '\n\n',
38
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
39
+ 'function RouteComponent() { return <div>Hello "%%tsrPath%%"!</div> };\n',
40
+ ].join(''),
41
+ imports: {
42
+ tsrImports: () => "import { createFileRoute } from '@tanstack/react-router';",
43
+ tsrExportStart: (routePath) =>
44
+ `export const Route = createFileRoute(${serializeRoutePath(routePath)})(`,
45
+ tsrExportEnd: () => ');',
46
+ },
47
+ },
48
+ lazyRoute: {
49
+ template: () =>
50
+ [
51
+ '%%tsrImports%%',
52
+ '\n\n',
53
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
54
+ 'function RouteComponent() { return <div>Hello "%%tsrPath%%"!</div> };\n',
55
+ ].join(''),
56
+ imports: {
57
+ tsrImports: () => "import { createLazyFileRoute } from '@tanstack/react-router';",
58
+ tsrExportStart: (routePath) =>
59
+ `export const Route = createLazyFileRoute(${serializeRoutePath(routePath)})(`,
60
+ tsrExportEnd: () => ');',
61
+ },
62
+ },
63
+ };
64
+ case 'solid':
65
+ return {
66
+ fullPkg: '@tanstack/solid-router',
67
+ subPkg: 'solid-router',
68
+ rootRoute: {
69
+ template: () =>
70
+ [
71
+ 'import * as Solid from "solid-js"\n',
72
+ '%%tsrImports%%',
73
+ '\n\n',
74
+ '%%tsrExportStart%%{\n component: RootComponent\n }%%tsrExportEnd%%\n\n',
75
+ 'function RootComponent() { return (<><div>Hello "%%tsrPath%%"!</div><Outlet /></>) };\n',
76
+ ].join(''),
77
+ imports: {
78
+ tsrImports: () => "import { Outlet, createRootRoute } from '@tanstack/solid-router';",
79
+ tsrExportStart: () => 'export const Route = createRootRoute(',
80
+ tsrExportEnd: () => ');',
81
+ },
82
+ },
83
+ route: {
84
+ template: () =>
85
+ [
86
+ '%%tsrImports%%',
87
+ '\n\n',
88
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
89
+ 'function RouteComponent() { return <div>Hello "%%tsrPath%%"!</div> };\n',
90
+ ].join(''),
91
+ imports: {
92
+ tsrImports: () => "import { createFileRoute } from '@tanstack/solid-router';",
93
+ tsrExportStart: (routePath) =>
94
+ `export const Route = createFileRoute(${serializeRoutePath(routePath)})(`,
95
+ tsrExportEnd: () => ');',
96
+ },
97
+ },
98
+ lazyRoute: {
99
+ template: () =>
100
+ [
101
+ '%%tsrImports%%',
102
+ '\n\n',
103
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
104
+ 'function RouteComponent() { return <div>Hello "%%tsrPath%%"!</div> };\n',
105
+ ].join(''),
106
+ imports: {
107
+ tsrImports: () => "import { createLazyFileRoute } from '@tanstack/solid-router';",
108
+ tsrExportStart: (routePath) =>
109
+ `export const Route = createLazyFileRoute(${serializeRoutePath(routePath)})(`,
110
+ tsrExportEnd: () => ');',
111
+ },
112
+ },
113
+ };
114
+ case 'vue':
115
+ return {
116
+ fullPkg: '@tanstack/vue-router',
117
+ subPkg: 'vue-router',
118
+ rootRoute: {
119
+ template: () =>
120
+ [
121
+ 'import { h } from "vue"\n',
122
+ '%%tsrImports%%',
123
+ '\n\n',
124
+ '%%tsrExportStart%%{\n component: RootComponent\n }%%tsrExportEnd%%\n\n',
125
+ 'function RootComponent() { return h("div", {}, ["Hello \\"%%tsrPath%%\\"!", h(Outlet)]) };\n',
126
+ ].join(''),
127
+ imports: {
128
+ tsrImports: () => "import { Outlet, createRootRoute } from '@tanstack/vue-router';",
129
+ tsrExportStart: () => 'export const Route = createRootRoute(',
130
+ tsrExportEnd: () => ');',
131
+ },
132
+ },
133
+ route: {
134
+ template: () =>
135
+ [
136
+ 'import { h } from "vue"\n',
137
+ '%%tsrImports%%',
138
+ '\n\n',
139
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
140
+ 'function RouteComponent() { return h("div", {}, "Hello \\"%%tsrPath%%\\"!") };\n',
141
+ ].join(''),
142
+ imports: {
143
+ tsrImports: () => "import { createFileRoute } from '@tanstack/vue-router';",
144
+ tsrExportStart: (routePath) =>
145
+ `export const Route = createFileRoute(${serializeRoutePath(routePath)})(`,
146
+ tsrExportEnd: () => ');',
147
+ },
148
+ },
149
+ lazyRoute: {
150
+ template: () =>
151
+ [
152
+ 'import { h } from "vue"\n',
153
+ '%%tsrImports%%',
154
+ '\n\n',
155
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
156
+ 'function RouteComponent() { return h("div", {}, "Hello \\"%%tsrPath%%\\"!") };\n',
157
+ ].join(''),
158
+ imports: {
159
+ tsrImports: () => "import { createLazyFileRoute } from '@tanstack/vue-router';",
160
+ tsrExportStart: (routePath) =>
161
+ `export const Route = createLazyFileRoute(${serializeRoutePath(routePath)})(`,
162
+ tsrExportEnd: () => ');',
163
+ },
164
+ },
165
+ };
166
+ case 'octane':
167
+ return {
168
+ fullPkg: OCTANE_ROUTER_PACKAGE,
169
+ subPkg: 'octane-router',
170
+ rootRoute: {
171
+ template: () =>
172
+ [
173
+ '%%tsrImports%%',
174
+ '\n\n',
175
+ '%%tsrExportStart%%{\n component: RootComponent\n }%%tsrExportEnd%%\n\n',
176
+ 'function RootComponent() @{\n <div>Hello "%%tsrPath%%"!<Outlet /></div>\n}\n',
177
+ ].join(''),
178
+ imports: {
179
+ tsrImports: () => `import { Outlet, createRootRoute } from '${OCTANE_ROUTER_PACKAGE}';`,
180
+ tsrExportStart: () => 'export const Route = createRootRoute(',
181
+ tsrExportEnd: () => ');',
182
+ },
183
+ },
184
+ route: {
185
+ template: () =>
186
+ [
187
+ '%%tsrImports%%',
188
+ '\n\n',
189
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
190
+ 'function RouteComponent() @{\n <div>Hello "%%tsrPath%%"!</div>\n}\n',
191
+ ].join(''),
192
+ imports: {
193
+ tsrImports: () => `import { createFileRoute } from '${OCTANE_ROUTER_PACKAGE}';`,
194
+ tsrExportStart: (routePath) =>
195
+ `export const Route = createFileRoute(${serializeRoutePath(routePath)})(`,
196
+ tsrExportEnd: () => ');',
197
+ },
198
+ },
199
+ lazyRoute: {
200
+ template: () =>
201
+ [
202
+ '%%tsrImports%%',
203
+ '\n\n',
204
+ '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n',
205
+ 'function RouteComponent() @{\n <div>Hello "%%tsrPath%%"!</div>\n}\n',
206
+ ].join(''),
207
+ imports: {
208
+ tsrImports: () => `import { createLazyFileRoute } from '${OCTANE_ROUTER_PACKAGE}';`,
209
+ tsrExportStart: (routePath) =>
210
+ `export const Route = createLazyFileRoute(${serializeRoutePath(routePath)})(`,
211
+ tsrExportEnd: () => ');',
212
+ },
213
+ },
214
+ };
215
+ default:
216
+ throw new Error(`router-generator: Unknown target type: ${target}`);
217
+ }
218
+ }
219
+ //#endregion
220
+ export { fillTemplate, getTargetTemplate };
@@ -0,0 +1,8 @@
1
+ import { TransformOptions, TransformResult } from './types.js';
2
+ export declare function transform({
3
+ ctx,
4
+ source,
5
+ parseSource,
6
+ filename,
7
+ node,
8
+ }: TransformOptions): TransformResult;