@tanstack/router-generator 1.121.16 → 1.121.18

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 (97) hide show
  1. package/package.json +5 -5
  2. package/dist/cjs/config.cjs +0 -140
  3. package/dist/cjs/config.cjs.map +0 -1
  4. package/dist/cjs/config.d.cts +0 -155
  5. package/dist/cjs/filesystem/physical/getRouteNodes.cjs +0 -204
  6. package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +0 -1
  7. package/dist/cjs/filesystem/physical/getRouteNodes.d.cts +0 -15
  8. package/dist/cjs/filesystem/physical/rootPathId.cjs +0 -5
  9. package/dist/cjs/filesystem/physical/rootPathId.cjs.map +0 -1
  10. package/dist/cjs/filesystem/physical/rootPathId.d.cts +0 -1
  11. package/dist/cjs/filesystem/virtual/config.cjs +0 -37
  12. package/dist/cjs/filesystem/virtual/config.cjs.map +0 -1
  13. package/dist/cjs/filesystem/virtual/config.d.cts +0 -3
  14. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs +0 -192
  15. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +0 -1
  16. package/dist/cjs/filesystem/virtual/getRouteNodes.d.cts +0 -8
  17. package/dist/cjs/filesystem/virtual/loadConfigFile.cjs +0 -11
  18. package/dist/cjs/filesystem/virtual/loadConfigFile.cjs.map +0 -1
  19. package/dist/cjs/filesystem/virtual/loadConfigFile.d.cts +0 -1
  20. package/dist/cjs/generator.cjs +0 -970
  21. package/dist/cjs/generator.cjs.map +0 -1
  22. package/dist/cjs/generator.d.cts +0 -76
  23. package/dist/cjs/index.cjs +0 -35
  24. package/dist/cjs/index.cjs.map +0 -1
  25. package/dist/cjs/index.d.cts +0 -12
  26. package/dist/cjs/logger.cjs +0 -37
  27. package/dist/cjs/logger.cjs.map +0 -1
  28. package/dist/cjs/logger.d.cts +0 -10
  29. package/dist/cjs/plugin/default-generator-plugin.cjs +0 -101
  30. package/dist/cjs/plugin/default-generator-plugin.cjs.map +0 -1
  31. package/dist/cjs/plugin/default-generator-plugin.d.cts +0 -2
  32. package/dist/cjs/plugin/types.d.cts +0 -46
  33. package/dist/cjs/template.cjs +0 -110
  34. package/dist/cjs/template.cjs.map +0 -1
  35. package/dist/cjs/template.d.cts +0 -33
  36. package/dist/cjs/transform/default-transform-plugin.cjs +0 -95
  37. package/dist/cjs/transform/default-transform-plugin.cjs.map +0 -1
  38. package/dist/cjs/transform/default-transform-plugin.d.cts +0 -2
  39. package/dist/cjs/transform/transform.cjs +0 -374
  40. package/dist/cjs/transform/transform.cjs.map +0 -1
  41. package/dist/cjs/transform/transform.d.cts +0 -4
  42. package/dist/cjs/transform/types.d.cts +0 -43
  43. package/dist/cjs/transform/utils.cjs +0 -36
  44. package/dist/cjs/transform/utils.cjs.map +0 -1
  45. package/dist/cjs/transform/utils.d.cts +0 -2
  46. package/dist/cjs/types.d.cts +0 -47
  47. package/dist/cjs/utils.cjs +0 -438
  48. package/dist/cjs/utils.cjs.map +0 -1
  49. package/dist/cjs/utils.d.cts +0 -133
  50. package/dist/esm/config.d.ts +0 -155
  51. package/dist/esm/config.js +0 -140
  52. package/dist/esm/config.js.map +0 -1
  53. package/dist/esm/filesystem/physical/getRouteNodes.d.ts +0 -15
  54. package/dist/esm/filesystem/physical/getRouteNodes.js +0 -187
  55. package/dist/esm/filesystem/physical/getRouteNodes.js.map +0 -1
  56. package/dist/esm/filesystem/physical/rootPathId.d.ts +0 -1
  57. package/dist/esm/filesystem/physical/rootPathId.js +0 -5
  58. package/dist/esm/filesystem/physical/rootPathId.js.map +0 -1
  59. package/dist/esm/filesystem/virtual/config.d.ts +0 -3
  60. package/dist/esm/filesystem/virtual/config.js +0 -37
  61. package/dist/esm/filesystem/virtual/config.js.map +0 -1
  62. package/dist/esm/filesystem/virtual/getRouteNodes.d.ts +0 -8
  63. package/dist/esm/filesystem/virtual/getRouteNodes.js +0 -192
  64. package/dist/esm/filesystem/virtual/getRouteNodes.js.map +0 -1
  65. package/dist/esm/filesystem/virtual/loadConfigFile.d.ts +0 -1
  66. package/dist/esm/filesystem/virtual/loadConfigFile.js +0 -11
  67. package/dist/esm/filesystem/virtual/loadConfigFile.js.map +0 -1
  68. package/dist/esm/generator.d.ts +0 -76
  69. package/dist/esm/generator.js +0 -953
  70. package/dist/esm/generator.js.map +0 -1
  71. package/dist/esm/index.d.ts +0 -12
  72. package/dist/esm/index.js +0 -35
  73. package/dist/esm/index.js.map +0 -1
  74. package/dist/esm/logger.d.ts +0 -10
  75. package/dist/esm/logger.js +0 -37
  76. package/dist/esm/logger.js.map +0 -1
  77. package/dist/esm/plugin/default-generator-plugin.d.ts +0 -2
  78. package/dist/esm/plugin/default-generator-plugin.js +0 -101
  79. package/dist/esm/plugin/default-generator-plugin.js.map +0 -1
  80. package/dist/esm/plugin/types.d.ts +0 -46
  81. package/dist/esm/template.d.ts +0 -33
  82. package/dist/esm/template.js +0 -110
  83. package/dist/esm/template.js.map +0 -1
  84. package/dist/esm/transform/default-transform-plugin.d.ts +0 -2
  85. package/dist/esm/transform/default-transform-plugin.js +0 -95
  86. package/dist/esm/transform/default-transform-plugin.js.map +0 -1
  87. package/dist/esm/transform/transform.d.ts +0 -4
  88. package/dist/esm/transform/transform.js +0 -374
  89. package/dist/esm/transform/transform.js.map +0 -1
  90. package/dist/esm/transform/types.d.ts +0 -43
  91. package/dist/esm/transform/utils.d.ts +0 -2
  92. package/dist/esm/transform/utils.js +0 -36
  93. package/dist/esm/transform/utils.js.map +0 -1
  94. package/dist/esm/types.d.ts +0 -47
  95. package/dist/esm/utils.d.ts +0 -133
  96. package/dist/esm/utils.js +0 -420
  97. package/dist/esm/utils.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"getRouteNodes.js","sources":["../../../../src/filesystem/physical/getRouteNodes.ts"],"sourcesContent":["import path from 'node:path'\nimport * as fsp from 'node:fs/promises'\nimport {\n determineInitialRoutePath,\n removeExt,\n replaceBackslash,\n routePathToVariable,\n} from '../../utils'\nimport { getRouteNodes as getRouteNodesVirtual } from '../virtual/getRouteNodes'\nimport { loadConfigFile } from '../virtual/loadConfigFile'\nimport { logging } from '../../logger'\nimport { rootPathId } from './rootPathId'\nimport type {\n VirtualRootRoute,\n VirtualRouteSubtreeConfig,\n} from '@tanstack/virtual-file-routes'\nimport type { FsRouteType, GetRouteNodesResult, RouteNode } from '../../types'\nimport type { Config } from '../../config'\n\nconst disallowedRouteGroupConfiguration = /\\(([^)]+)\\).(ts|js|tsx|jsx)/\n\nconst virtualConfigFileRegExp = /__virtual\\.[mc]?[jt]s$/\nexport function isVirtualConfigFile(fileName: string): boolean {\n return virtualConfigFileRegExp.test(fileName)\n}\n\nexport async function getRouteNodes(\n config: Pick<\n Config,\n | 'routesDirectory'\n | 'routeFilePrefix'\n | 'routeFileIgnorePrefix'\n | 'routeFileIgnorePattern'\n | 'disableLogging'\n | 'routeToken'\n | 'indexToken'\n >,\n root: string,\n): Promise<GetRouteNodesResult> {\n const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } =\n config\n const logger = logging({ disabled: config.disableLogging })\n const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? '', 'g')\n\n const routeNodes: Array<RouteNode> = []\n const allPhysicalDirectories: Array<string> = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fsp.readdir(fullDir, { withFileTypes: true })\n\n dirList = dirList.filter((d) => {\n if (\n d.name.startsWith('.') ||\n (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.name.startsWith(routeFilePrefix)\n }\n\n if (routeFileIgnorePattern) {\n return !d.name.match(routeFileIgnoreRegExp)\n }\n\n return true\n })\n\n const virtualConfigFile = dirList.find((dirent) => {\n return dirent.isFile() && isVirtualConfigFile(dirent.name)\n })\n\n if (virtualConfigFile !== undefined) {\n const virtualRouteConfigExport = await loadConfigFile(\n path.resolve(fullDir, virtualConfigFile.name),\n )\n let virtualRouteSubtreeConfig: VirtualRouteSubtreeConfig\n if (typeof virtualRouteConfigExport.default === 'function') {\n virtualRouteSubtreeConfig = await virtualRouteConfigExport.default()\n } else {\n virtualRouteSubtreeConfig = virtualRouteConfigExport.default\n }\n const dummyRoot: VirtualRootRoute = {\n type: 'root',\n file: '',\n children: virtualRouteSubtreeConfig,\n }\n const { routeNodes: virtualRouteNodes, physicalDirectories } =\n await getRouteNodesVirtual(\n {\n ...config,\n routesDirectory: fullDir,\n virtualRouteConfig: dummyRoot,\n },\n root,\n )\n allPhysicalDirectories.push(...physicalDirectories)\n virtualRouteNodes.forEach((node) => {\n const filePath = replaceBackslash(path.join(dir, node.filePath))\n const routePath = `/${dir}${node.routePath}`\n\n node.variableName = routePathToVariable(\n `${dir}/${removeExt(node.filePath)}`,\n )\n node.routePath = routePath\n node.filePath = filePath\n })\n\n routeNodes.push(...virtualRouteNodes)\n\n return\n }\n\n await Promise.all(\n dirList.map(async (dirent) => {\n const fullPath = replaceBackslash(path.join(fullDir, dirent.name))\n const relativePath = path.posix.join(dir, dirent.name)\n\n if (dirent.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n let routePath = determineInitialRoutePath(filePathNoExt)\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n }\n\n if (disallowedRouteGroupConfiguration.test(dirent.name)) {\n 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?`\n logger.error(`ERROR: ${errorMessage}`)\n throw new Error(errorMessage)\n }\n\n const meta = getRouteMeta(routePath, config)\n const variableName = meta.variableName\n let routeType: FsRouteType = meta.fsRouteType\n\n if (routeType === 'lazy') {\n routePath = routePath.replace(/\\/lazy$/, '')\n }\n\n // this check needs to happen after the lazy route has been cleaned up\n // since the routePath is used to determine if a route is pathless\n if (isValidPathlessLayoutRoute(routePath, routeType, config)) {\n routeType = 'pathless_layout'\n }\n\n ;(\n [\n ['component', 'component'],\n ['errorComponent', 'errorComponent'],\n ['pendingComponent', 'pendingComponent'],\n ['loader', 'loader'],\n ] satisfies Array<[FsRouteType, string]>\n ).forEach(([matcher, type]) => {\n if (routeType === matcher) {\n logger.warn(\n `WARNING: The \\`.${type}.tsx\\` suffix used for the ${filePath} file is deprecated. Use the new \\`.lazy.tsx\\` suffix instead.`,\n )\n }\n })\n\n routePath = routePath.replace(\n new RegExp(\n `/(component|errorComponent|pendingComponent|loader|${config.routeToken}|lazy)$`,\n ),\n '',\n )\n\n if (routePath === config.indexToken) {\n routePath = '/'\n }\n\n routePath =\n routePath.replace(new RegExp(`/${config.indexToken}$`), '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n _fsRouteType: routeType,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n const rootRouteNode = routeNodes.find((d) => d.routePath === `/${rootPathId}`)\n if (rootRouteNode) {\n rootRouteNode._fsRouteType = '__root'\n rootRouteNode.variableName = 'root'\n }\n\n return {\n rootRouteNode,\n routeNodes,\n physicalDirectories: allPhysicalDirectories,\n }\n}\n\n/**\n * Determines the metadata for a given route path based on the provided configuration.\n *\n * @param routePath - The determined initial routePath.\n * @param config - The user configuration object.\n * @returns An object containing the type of the route and the variable name derived from the route path.\n */\nexport function getRouteMeta(\n routePath: string,\n config: Pick<Config, 'routeToken' | 'indexToken'>,\n): {\n // `__root` is can be more easily determined by filtering down to routePath === /${rootPathId}\n // `pathless` is needs to determined after `lazy` has been cleaned up from the routePath\n fsRouteType: Extract<\n FsRouteType,\n | 'static'\n | 'layout'\n | 'api'\n | 'lazy'\n | 'loader'\n | 'component'\n | 'pendingComponent'\n | 'errorComponent'\n >\n variableName: string\n} {\n let fsRouteType: FsRouteType = 'static'\n\n if (routePath.endsWith(`/${config.routeToken}`)) {\n // layout routes, i.e `/foo/route.tsx` or `/foo/_layout/route.tsx`\n fsRouteType = 'layout'\n } else if (routePath.endsWith('/lazy')) {\n // lazy routes, i.e. `/foo.lazy.tsx`\n fsRouteType = 'lazy'\n } else if (routePath.endsWith('/loader')) {\n // loader routes, i.e. `/foo.loader.tsx`\n fsRouteType = 'loader'\n } else if (routePath.endsWith('/component')) {\n // component routes, i.e. `/foo.component.tsx`\n fsRouteType = 'component'\n } else if (routePath.endsWith('/pendingComponent')) {\n // pending component routes, i.e. `/foo.pendingComponent.tsx`\n fsRouteType = 'pendingComponent'\n } else if (routePath.endsWith('/errorComponent')) {\n // error component routes, i.e. `/foo.errorComponent.tsx`\n fsRouteType = 'errorComponent'\n }\n\n const variableName = routePathToVariable(routePath)\n\n return { fsRouteType, variableName }\n}\n\n/**\n * Used to validate if a route is a pathless layout route\n * @param normalizedRoutePath Normalized route path, i.e `/foo/_layout/route.tsx` and `/foo._layout.route.tsx` to `/foo/_layout/route`\n * @param config The `router-generator` configuration object\n * @returns Boolean indicating if the route is a pathless layout route\n */\nfunction isValidPathlessLayoutRoute(\n normalizedRoutePath: string,\n routeType: FsRouteType,\n config: Pick<Config, 'routeToken' | 'indexToken'>,\n): boolean {\n if (routeType === 'lazy') {\n return false\n }\n\n const segments = normalizedRoutePath.split('/').filter(Boolean)\n\n if (segments.length === 0) {\n return false\n }\n\n const lastRouteSegment = segments[segments.length - 1]!\n const secondToLastRouteSegment = segments[segments.length - 2]\n\n // If segment === __root, then exit as false\n if (lastRouteSegment === rootPathId) {\n return false\n }\n\n // If segment === config.routeToken and secondToLastSegment is a string that starts with _, then exit as true\n // Since the route is actually a configuration route for a layout/pathless route\n // i.e. /foo/_layout/route.tsx === /foo/_layout.tsx\n if (\n lastRouteSegment === config.routeToken &&\n typeof secondToLastRouteSegment === 'string'\n ) {\n return secondToLastRouteSegment.startsWith('_')\n }\n\n // Segment starts with _\n return (\n lastRouteSegment !== config.indexToken &&\n lastRouteSegment !== config.routeToken &&\n lastRou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,WACA,QAgBA;AACA,MAAI,cAA2B;AAE/B,MAAI,UAAU,SAAS,IAAI,OAAO,UAAU,EAAE,GAAG;AAEjC,kBAAA;AAAA,EACL,WAAA,UAAU,SAAS,OAAO,GAAG;AAExB,kBAAA;AAAA,EACL,WAAA,UAAU,SAAS,SAAS,GAAG;AAE1B,kBAAA;AAAA,EACL,WAAA,UAAU,SAAS,YAAY,GAAG;AAE7B,kBAAA;AAAA,EACL,WAAA,UAAU,SAAS,mBAAmB,GAAG;AAEpC,kBAAA;AAAA,EACL,WAAA,UAAU,SAAS,iBAAiB,GAAG;AAElC,kBAAA;AAAA,EAAA;AAGV,QAAA,eAAe,oBAAoB,SAAS;AAE3C,SAAA,EAAE,aAAa,aAAa;AACrC;AAQA,SAAS,2BACP,qBACA,WACA,QACS;AACT,MAAI,cAAc,QAAQ;AACjB,WAAA;AAAA,EAAA;AAGT,QAAM,WAAW,oBAAoB,MAAM,GAAG,EAAE,OAAO,OAAO;AAE1D,MAAA,SAAS,WAAW,GAAG;AAClB,WAAA;AAAA,EAAA;AAGT,QAAM,mBAAmB,SAAS,SAAS,SAAS,CAAC;AACrD,QAAM,2BAA2B,SAAS,SAAS,SAAS,CAAC;AAG7D,MAAI,qBAAqB,YAAY;AAC5B,WAAA;AAAA,EAAA;AAMT,MACE,qBAAqB,OAAO,cAC5B,OAAO,6BAA6B,UACpC;AACO,WAAA,yBAAyB,WAAW,GAAG;AAAA,EAAA;AAK9C,SAAA,qBAAqB,OAAO,cAC5B,qBAAqB,OAAO,cAC5B,iBAAiB,WAAW,GAAG;AAEnC;"}
@@ -1 +0,0 @@
1
- export declare const rootPathId = "__root";
@@ -1,5 +0,0 @@
1
- const rootPathId = "__root";
2
- export {
3
- rootPathId
4
- };
5
- //# sourceMappingURL=rootPathId.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rootPathId.js","sources":["../../../../src/filesystem/physical/rootPathId.ts"],"sourcesContent":["export const rootPathId = '__root'\n"],"names":[],"mappings":"AAAO,MAAM,aAAa;"}
@@ -1,3 +0,0 @@
1
- import { z } from 'zod';
2
- import { VirtualRootRoute } from '@tanstack/virtual-file-routes';
3
- export declare const virtualRootRouteSchema: z.ZodType<VirtualRootRoute>;
@@ -1,37 +0,0 @@
1
- import { z } from "zod";
2
- const indexRouteSchema = z.object({
3
- type: z.literal("index"),
4
- file: z.string()
5
- });
6
- const layoutRouteSchema = z.object({
7
- type: z.literal("layout"),
8
- id: z.string().optional(),
9
- file: z.string(),
10
- children: z.array(z.lazy(() => virtualRouteNodeSchema)).optional()
11
- });
12
- const routeSchema = z.object({
13
- type: z.literal("route"),
14
- file: z.string().optional(),
15
- path: z.string(),
16
- children: z.array(z.lazy(() => virtualRouteNodeSchema)).optional()
17
- });
18
- const physicalSubTreeSchema = z.object({
19
- type: z.literal("physical"),
20
- directory: z.string(),
21
- pathPrefix: z.string()
22
- });
23
- const virtualRouteNodeSchema = z.union([
24
- indexRouteSchema,
25
- layoutRouteSchema,
26
- routeSchema,
27
- physicalSubTreeSchema
28
- ]);
29
- const virtualRootRouteSchema = z.object({
30
- type: z.literal("root"),
31
- file: z.string(),
32
- children: z.array(virtualRouteNodeSchema).optional()
33
- });
34
- export {
35
- virtualRootRouteSchema
36
- };
37
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sources":["../../../../src/filesystem/virtual/config.ts"],"sourcesContent":["import { z } from 'zod'\nimport type {\n LayoutRoute,\n PhysicalSubtree,\n Route,\n VirtualRootRoute,\n} from '@tanstack/virtual-file-routes'\n\nconst indexRouteSchema = z.object({\n type: z.literal('index'),\n file: z.string(),\n})\n\nconst layoutRouteSchema: z.ZodType<LayoutRoute> = z.object({\n type: z.literal('layout'),\n id: z.string().optional(),\n file: z.string(),\n children: z.array(z.lazy(() => virtualRouteNodeSchema)).optional(),\n})\n\nconst routeSchema: z.ZodType<Route> = z.object({\n type: z.literal('route'),\n file: z.string().optional(),\n path: z.string(),\n children: z.array(z.lazy(() => virtualRouteNodeSchema)).optional(),\n})\n\nconst physicalSubTreeSchema: z.ZodType<PhysicalSubtree> = z.object({\n type: z.literal('physical'),\n directory: z.string(),\n pathPrefix: z.string(),\n})\n\nconst virtualRouteNodeSchema = z.union([\n indexRouteSchema,\n layoutRouteSchema,\n routeSchema,\n physicalSubTreeSchema,\n])\n\nexport const virtualRootRouteSchema: z.ZodType<VirtualRootRoute> = z.object({\n type: z.literal('root'),\n file: z.string(),\n children: z.array(virtualRouteNodeSchema).optional(),\n})\n"],"names":[],"mappings":";AAQA,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,MAAM,EAAE,OAAO;AACjB,CAAC;AAED,MAAM,oBAA4C,EAAE,OAAO;AAAA,EACzD,MAAM,EAAE,QAAQ,QAAQ;AAAA,EACxB,IAAI,EAAE,OAAO,EAAE,SAAS;AAAA,EACxB,MAAM,EAAE,OAAO;AAAA,EACf,UAAU,EAAE,MAAM,EAAE,KAAK,MAAM,sBAAsB,CAAC,EAAE,SAAS;AACnE,CAAC;AAED,MAAM,cAAgC,EAAE,OAAO;AAAA,EAC7C,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,MAAM,EAAE,OAAO;AAAA,EACf,UAAU,EAAE,MAAM,EAAE,KAAK,MAAM,sBAAsB,CAAC,EAAE,SAAS;AACnE,CAAC;AAED,MAAM,wBAAoD,EAAE,OAAO;AAAA,EACjE,MAAM,EAAE,QAAQ,UAAU;AAAA,EAC1B,WAAW,EAAE,OAAO;AAAA,EACpB,YAAY,EAAE,OAAO;AACvB,CAAC;AAED,MAAM,yBAAyB,EAAE,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEY,MAAA,yBAAsD,EAAE,OAAO;AAAA,EAC1E,MAAM,EAAE,QAAQ,MAAM;AAAA,EACtB,MAAM,EAAE,OAAO;AAAA,EACf,UAAU,EAAE,MAAM,sBAAsB,EAAE,SAAS;AACrD,CAAC;"}
@@ -1,8 +0,0 @@
1
- import { VirtualRouteNode } from '@tanstack/virtual-file-routes';
2
- import { GetRouteNodesResult, RouteNode } from '../../types.js';
3
- import { Config } from '../../config.js';
4
- export declare function getRouteNodes(tsrConfig: Pick<Config, 'routesDirectory' | 'virtualRouteConfig' | 'routeFileIgnorePrefix' | 'disableLogging' | 'indexToken' | 'routeToken'>, root: string): Promise<GetRouteNodesResult>;
5
- export declare function getRouteNodesRecursive(tsrConfig: Pick<Config, 'routesDirectory' | 'routeFileIgnorePrefix' | 'disableLogging' | 'indexToken' | 'routeToken'>, root: string, fullDir: string, nodes?: Array<VirtualRouteNode>, parent?: RouteNode): Promise<{
6
- children: Array<RouteNode>;
7
- physicalDirectories: Array<string>;
8
- }>;
@@ -1,192 +0,0 @@
1
- import path, { resolve, join } from "node:path";
2
- import { replaceBackslash, routePathToVariable, removeExt, removeTrailingSlash, removeLeadingSlash } from "../../utils.js";
3
- import { getRouteNodes as getRouteNodes$1 } from "../physical/getRouteNodes.js";
4
- import { rootPathId } from "../physical/rootPathId.js";
5
- import { virtualRootRouteSchema } from "./config.js";
6
- import { loadConfigFile } from "./loadConfigFile.js";
7
- function ensureLeadingUnderScore(id) {
8
- if (id.startsWith("_")) {
9
- return id;
10
- }
11
- return `_${id}`;
12
- }
13
- function flattenTree(node) {
14
- const result = [node];
15
- if (node.children) {
16
- for (const child of node.children) {
17
- result.push(...flattenTree(child));
18
- }
19
- }
20
- delete node.children;
21
- return result;
22
- }
23
- async function getRouteNodes(tsrConfig, root) {
24
- const fullDir = resolve(tsrConfig.routesDirectory);
25
- if (tsrConfig.virtualRouteConfig === void 0) {
26
- throw new Error(`virtualRouteConfig is undefined`);
27
- }
28
- let virtualRouteConfig;
29
- if (typeof tsrConfig.virtualRouteConfig === "string") {
30
- virtualRouteConfig = await getVirtualRouteConfigFromFileExport(
31
- tsrConfig,
32
- root
33
- );
34
- } else {
35
- virtualRouteConfig = tsrConfig.virtualRouteConfig;
36
- }
37
- const { children, physicalDirectories } = await getRouteNodesRecursive(
38
- tsrConfig,
39
- root,
40
- fullDir,
41
- virtualRouteConfig.children
42
- );
43
- const allNodes = flattenTree({
44
- children,
45
- filePath: virtualRouteConfig.file,
46
- fullPath: replaceBackslash(join(fullDir, virtualRouteConfig.file)),
47
- variableName: "root",
48
- routePath: `/${rootPathId}`,
49
- _fsRouteType: "__root"
50
- });
51
- const rootRouteNode = allNodes[0];
52
- const routeNodes = allNodes.slice(1);
53
- return { rootRouteNode, routeNodes, physicalDirectories };
54
- }
55
- async function getVirtualRouteConfigFromFileExport(tsrConfig, root) {
56
- if (tsrConfig.virtualRouteConfig === void 0 || typeof tsrConfig.virtualRouteConfig !== "string" || tsrConfig.virtualRouteConfig === "") {
57
- throw new Error(`virtualRouteConfig is undefined or empty`);
58
- }
59
- const exports = await loadConfigFile(join(root, tsrConfig.virtualRouteConfig));
60
- if (!("routes" in exports) && !("default" in exports)) {
61
- throw new Error(
62
- `routes not found in ${tsrConfig.virtualRouteConfig}. The routes export must be named like 'export const routes = ...' or done using 'export default ...'`
63
- );
64
- }
65
- const virtualRouteConfig = "routes" in exports ? exports.routes : exports.default;
66
- return virtualRootRouteSchema.parse(virtualRouteConfig);
67
- }
68
- async function getRouteNodesRecursive(tsrConfig, root, fullDir, nodes, parent) {
69
- if (nodes === void 0) {
70
- return { children: [], physicalDirectories: [] };
71
- }
72
- const allPhysicalDirectories = [];
73
- const children = await Promise.all(
74
- nodes.map(async (node) => {
75
- if (node.type === "physical") {
76
- const { routeNodes, physicalDirectories } = await getRouteNodes$1(
77
- {
78
- ...tsrConfig,
79
- routesDirectory: resolve(fullDir, node.directory)
80
- },
81
- root
82
- );
83
- allPhysicalDirectories.push(node.directory);
84
- routeNodes.forEach((subtreeNode) => {
85
- subtreeNode.variableName = routePathToVariable(
86
- `${node.pathPrefix}/${removeExt(subtreeNode.filePath)}`
87
- );
88
- subtreeNode.routePath = `${(parent == null ? void 0 : parent.routePath) ?? ""}${node.pathPrefix}${subtreeNode.routePath}`;
89
- subtreeNode.filePath = `${node.directory}/${subtreeNode.filePath}`;
90
- });
91
- return routeNodes;
92
- }
93
- function getFile(file) {
94
- const filePath = file;
95
- const variableName = routePathToVariable(removeExt(filePath));
96
- const fullPath = replaceBackslash(join(fullDir, filePath));
97
- return { filePath, variableName, fullPath };
98
- }
99
- const parentRoutePath = removeTrailingSlash((parent == null ? void 0 : parent.routePath) ?? "/");
100
- switch (node.type) {
101
- case "index": {
102
- const { filePath, variableName, fullPath } = getFile(node.file);
103
- const routePath = `${parentRoutePath}/`;
104
- return {
105
- filePath,
106
- fullPath,
107
- variableName,
108
- routePath,
109
- _fsRouteType: "static"
110
- };
111
- }
112
- case "route": {
113
- const lastSegment = node.path;
114
- let routeNode;
115
- const routePath = `${parentRoutePath}/${removeLeadingSlash(lastSegment)}`;
116
- if (node.file) {
117
- const { filePath, variableName, fullPath } = getFile(node.file);
118
- routeNode = {
119
- filePath,
120
- fullPath,
121
- variableName,
122
- routePath,
123
- _fsRouteType: "static"
124
- };
125
- } else {
126
- routeNode = {
127
- filePath: "",
128
- fullPath: "",
129
- variableName: routePathToVariable(routePath),
130
- routePath,
131
- isVirtual: true,
132
- _fsRouteType: "static"
133
- };
134
- }
135
- if (node.children !== void 0) {
136
- const { children: children2, physicalDirectories } = await getRouteNodesRecursive(
137
- tsrConfig,
138
- root,
139
- fullDir,
140
- node.children,
141
- routeNode
142
- );
143
- routeNode.children = children2;
144
- allPhysicalDirectories.push(...physicalDirectories);
145
- routeNode._fsRouteType = "layout";
146
- }
147
- return routeNode;
148
- }
149
- case "layout": {
150
- const { filePath, variableName, fullPath } = getFile(node.file);
151
- if (node.id !== void 0) {
152
- node.id = ensureLeadingUnderScore(node.id);
153
- } else {
154
- const baseName = path.basename(filePath);
155
- const fileNameWithoutExt = path.parse(baseName).name;
156
- node.id = ensureLeadingUnderScore(fileNameWithoutExt);
157
- }
158
- const lastSegment = node.id;
159
- const routePath = `${parentRoutePath}/${removeLeadingSlash(lastSegment)}`;
160
- const routeNode = {
161
- fullPath,
162
- filePath,
163
- variableName,
164
- routePath,
165
- _fsRouteType: "pathless_layout"
166
- };
167
- if (node.children !== void 0) {
168
- const { children: children2, physicalDirectories } = await getRouteNodesRecursive(
169
- tsrConfig,
170
- root,
171
- fullDir,
172
- node.children,
173
- routeNode
174
- );
175
- routeNode.children = children2;
176
- allPhysicalDirectories.push(...physicalDirectories);
177
- }
178
- return routeNode;
179
- }
180
- }
181
- })
182
- );
183
- return {
184
- children: children.flat(),
185
- physicalDirectories: allPhysicalDirectories
186
- };
187
- }
188
- export {
189
- getRouteNodes,
190
- getRouteNodesRecursive
191
- };
192
- //# sourceMappingURL=getRouteNodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getRouteNodes.js","sources":["../../../../src/filesystem/virtual/getRouteNodes.ts"],"sourcesContent":["import path, { join, resolve } from 'node:path'\nimport {\n removeExt,\n removeLeadingSlash,\n removeTrailingSlash,\n replaceBackslash,\n routePathToVariable,\n} from '../../utils'\nimport { getRouteNodes as getRouteNodesPhysical } from '../physical/getRouteNodes'\nimport { rootPathId } from '../physical/rootPathId'\nimport { virtualRootRouteSchema } from './config'\nimport { loadConfigFile } from './loadConfigFile'\nimport type {\n VirtualRootRoute,\n VirtualRouteNode,\n} from '@tanstack/virtual-file-routes'\nimport type { GetRouteNodesResult, RouteNode } from '../../types'\nimport type { Config } from '../../config'\n\nfunction ensureLeadingUnderScore(id: string) {\n if (id.startsWith('_')) {\n return id\n }\n return `_${id}`\n}\n\nfunction flattenTree(node: RouteNode): Array<RouteNode> {\n const result = [node]\n\n if (node.children) {\n for (const child of node.children) {\n result.push(...flattenTree(child))\n }\n }\n delete node.children\n\n return result\n}\n\nexport async function getRouteNodes(\n tsrConfig: Pick<\n Config,\n | 'routesDirectory'\n | 'virtualRouteConfig'\n | 'routeFileIgnorePrefix'\n | 'disableLogging'\n | 'indexToken'\n | 'routeToken'\n >,\n root: string,\n): Promise<GetRouteNodesResult> {\n const fullDir = resolve(tsrConfig.routesDirectory)\n if (tsrConfig.virtualRouteConfig === undefined) {\n throw new Error(`virtualRouteConfig is undefined`)\n }\n let virtualRouteConfig: VirtualRootRoute\n if (typeof tsrConfig.virtualRouteConfig === 'string') {\n virtualRouteConfig = await getVirtualRouteConfigFromFileExport(\n tsrConfig,\n root,\n )\n } else {\n virtualRouteConfig = tsrConfig.virtualRouteConfig\n }\n const { children, physicalDirectories } = await getRouteNodesRecursive(\n tsrConfig,\n root,\n fullDir,\n virtualRouteConfig.children,\n )\n const allNodes = flattenTree({\n children,\n filePath: virtualRouteConfig.file,\n fullPath: replaceBackslash(join(fullDir, virtualRouteConfig.file)),\n variableName: 'root',\n routePath: `/${rootPathId}`,\n _fsRouteType: '__root',\n })\n\n const rootRouteNode = allNodes[0]\n const routeNodes = allNodes.slice(1)\n\n return { rootRouteNode, routeNodes, physicalDirectories }\n}\n\n/**\n * Get the virtual route config from a file export\n *\n * @example\n * ```ts\n * // routes.ts\n * import { rootRoute } from '@tanstack/virtual-file-routes'\n *\n * export const routes = rootRoute({ ... })\n * // or\n * export default rootRoute({ ... })\n * ```\n *\n */\nasync function getVirtualRouteConfigFromFileExport(\n tsrConfig: Pick<Config, 'virtualRouteConfig'>,\n root: string,\n): Promise<VirtualRootRoute> {\n if (\n tsrConfig.virtualRouteConfig === undefined ||\n typeof tsrConfig.virtualRouteConfig !== 'string' ||\n tsrConfig.virtualRouteConfig === ''\n ) {\n throw new Error(`virtualRouteConfig is undefined or empty`)\n }\n const exports = await loadConfigFile(join(root, tsrConfig.virtualRouteConfig))\n\n if (!('routes' in exports) && !('default' in exports)) {\n throw new Error(\n `routes not found in ${tsrConfig.virtualRouteConfig}. The routes export must be named like 'export const routes = ...' or done using 'export default ...'`,\n )\n }\n\n const virtualRouteConfig =\n 'routes' in exports ? exports.routes : exports.default\n\n return virtualRootRouteSchema.parse(virtualRouteConfig)\n}\n\nexport async function getRouteNodesRecursive(\n tsrConfig: Pick<\n Config,\n | 'routesDirectory'\n | 'routeFileIgnorePrefix'\n | 'disableLogging'\n | 'indexToken'\n | 'routeToken'\n >,\n root: string,\n fullDir: string,\n nodes?: Array<VirtualRouteNode>,\n parent?: RouteNode,\n): Promise<{ children: Array<RouteNode>; physicalDirectories: Array<string> }> {\n if (nodes === undefined) {\n return { children: [], physicalDirectories: [] }\n }\n const allPhysicalDirectories: Array<string> = []\n const children = await Promise.all(\n nodes.map(async (node) => {\n if (node.type === 'physical') {\n const { routeNodes, physicalDirectories } = await getRouteNodesPhysical(\n {\n ...tsrConfig,\n routesDirectory: resolve(fullDir, node.directory),\n },\n root,\n )\n allPhysicalDirectories.push(node.directory)\n routeNodes.forEach((subtreeNode) => {\n subtreeNode.variableName = routePathToVariable(\n `${node.pathPrefix}/${removeExt(subtreeNode.filePath)}`,\n )\n subtreeNode.routePath = `${parent?.routePath ?? ''}${node.pathPrefix}${subtreeNode.routePath}`\n subtreeNode.filePath = `${node.directory}/${subtreeNode.filePath}`\n })\n return routeNodes\n }\n\n function getFile(file: string) {\n const filePath = file\n const variableName = routePathToVariable(removeExt(filePath))\n const fullPath = replaceBackslash(join(fullDir, filePath))\n return { filePath, variableName, fullPath }\n }\n const parentRoutePath = removeTrailingSlash(parent?.routePath ?? '/')\n\n switch (node.type) {\n case 'index': {\n const { filePath, variableName, fullPath } = getFile(node.file)\n const routePath = `${parentRoutePath}/`\n return {\n filePath,\n fullPath,\n variableName,\n routePath,\n _fsRouteType: 'static',\n } satisfies RouteNode\n }\n\n case 'route': {\n const lastSegment = node.path\n let routeNode: RouteNode\n\n const routePath = `${parentRoutePath}/${removeLeadingSlash(lastSegment)}`\n if (node.file) {\n const { filePath, variableName, fullPath } = getFile(node.file)\n routeNode = {\n filePath,\n fullPath,\n variableName,\n routePath,\n _fsRouteType: 'static',\n }\n } else {\n routeNode = {\n filePath: '',\n fullPath: '',\n variableName: routePathToVariable(routePath),\n routePath,\n isVirtual: true,\n _fsRouteType: 'static',\n }\n }\n\n if (node.children !== undefined) {\n const { children, physicalDirectories } =\n await getRouteNodesRecursive(\n tsrConfig,\n root,\n fullDir,\n node.children,\n routeNode,\n )\n routeNode.children = children\n allPhysicalDirectories.push(...physicalDirectories)\n\n // If the route has children, it should be a layout\n routeNode._fsRouteType = 'layout'\n }\n return routeNode\n }\n case 'layout': {\n const { filePath, variableName, fullPath } = getFile(node.file)\n\n if (node.id !== undefined) {\n node.id = ensureLeadingUnderScore(node.id)\n } else {\n const baseName = path.basename(filePath)\n const fileNameWithoutExt = path.parse(baseName).name\n node.id = ensureLeadingUnderScore(fileNameWithoutExt)\n }\n const lastSegment = node.id\n const routePath = `${parentRoutePath}/${removeLeadingSlash(lastSegment)}`\n\n const routeNode: RouteNode = {\n fullPath,\n filePath,\n variableName,\n routePath,\n _fsRouteType: 'pathless_layout',\n }\n\n if (node.children !== undefined) {\n const { children, physicalDirectories } =\n await getRouteNodesRecursive(\n tsrConfig,\n root,\n fullDir,\n node.children,\n routeNode,\n )\n routeNode.children = children\n allPhysicalDirectories.push(...physicalDirectories)\n }\n return routeNode\n }\n }\n }),\n )\n return {\n children: children.flat(),\n physicalDirectories: allPhysicalDirectories,\n }\n}\n"],"names":["getRouteNodesPhysical","children"],"mappings":";;;;;;AAmBA,SAAS,wBAAwB,IAAY;AACvC,MAAA,GAAG,WAAW,GAAG,GAAG;AACf,WAAA;AAAA,EAAA;AAET,SAAO,IAAI,EAAE;AACf;AAEA,SAAS,YAAY,MAAmC;AAChD,QAAA,SAAS,CAAC,IAAI;AAEpB,MAAI,KAAK,UAAU;AACN,eAAA,SAAS,KAAK,UAAU;AACjC,aAAO,KAAK,GAAG,YAAY,KAAK,CAAC;AAAA,IAAA;AAAA,EACnC;AAEF,SAAO,KAAK;AAEL,SAAA;AACT;AAEsB,eAAA,cACpB,WASA,MAC8B;AACxB,QAAA,UAAU,QAAQ,UAAU,eAAe;AAC7C,MAAA,UAAU,uBAAuB,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A;AACE,mCAAA,KAAK,GAAG,mBAAmB;AAAA,UAAA;AAE7C,iBAAA;AAAA,QAAA;AAAA,MACT;AAAA,IAEH,CAAA;AAAA,EACH;AACO,SAAA;AAAA,IACL,UAAU,SAAS,KAAK;AAAA,IACxB,qBAAqB;AAAA,EACvB;AACF;"}
@@ -1 +0,0 @@
1
- export declare function loadConfigFile(filePath: string): Promise<any>;
@@ -1,11 +0,0 @@
1
- import { pathToFileURL } from "node:url";
2
- import { tsImport } from "tsx/esm/api";
3
- async function loadConfigFile(filePath) {
4
- const fileURL = pathToFileURL(filePath).href;
5
- const loaded = await tsImport(fileURL, "./");
6
- return loaded;
7
- }
8
- export {
9
- loadConfigFile
10
- };
11
- //# sourceMappingURL=loadConfigFile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadConfigFile.js","sources":["../../../../src/filesystem/virtual/loadConfigFile.ts"],"sourcesContent":["import { pathToFileURL } from 'node:url'\nimport { tsImport } from 'tsx/esm/api'\n\nexport async function loadConfigFile(filePath: string) {\n const fileURL = pathToFileURL(filePath).href\n const loaded = await tsImport(fileURL, './')\n return loaded\n}\n"],"names":[],"mappings":";;AAGA,eAAsB,eAAe,UAAkB;AAC/C,QAAA,UAAU,cAAc,QAAQ,EAAE;AACxC,QAAM,SAAS,MAAM,SAAS,SAAS,IAAI;AACpC,SAAA;AACT;"}
@@ -1,76 +0,0 @@
1
- import { TargetTemplate } from './template.js';
2
- import { GetRoutesByFileMapResult } from './types.js';
3
- import { Config } from './config.js';
4
- interface fs {
5
- stat: (filePath: string) => Promise<{
6
- mtimeMs: bigint;
7
- }>;
8
- mkdtempSync: (prefix: string) => string;
9
- rename: (oldPath: string, newPath: string) => Promise<void>;
10
- writeFile: (filePath: string, content: string) => Promise<void>;
11
- readFile: (filePath: string) => Promise<{
12
- stat: {
13
- mtimeMs: bigint;
14
- };
15
- fileContent: string;
16
- } | 'file-not-existing'>;
17
- }
18
- export type FileEventType = 'create' | 'update' | 'delete';
19
- export type FileEvent = {
20
- type: FileEventType;
21
- path: string;
22
- };
23
- export type GeneratorEvent = FileEvent | {
24
- type: 'rerun';
25
- };
26
- export declare class Generator {
27
- /**
28
- * why do we have two caches for the route files?
29
- * During processing, we READ from the cache and WRITE to the shadow cache.
30
- *
31
- * After a route file is processed, we write to the shadow cache.
32
- * If during processing we bail out and re-run, we don't lose this modification
33
- * but still can track whether the file contributed changes and thus the route tree file needs to be regenerated.
34
- * After all files are processed, we swap the shadow cache with the main cache and initialize a new shadow cache.
35
- * That way we also ensure deleted/renamed files don't stay in the cache forever.
36
- */
37
- private routeNodeCache;
38
- private routeNodeShadowCache;
39
- private routeTreeFileCache;
40
- config: Config;
41
- targetTemplate: TargetTemplate;
42
- private root;
43
- private routesDirectoryPath;
44
- private tmpDir;
45
- private fs;
46
- private logger;
47
- private generatedRouteTreePath;
48
- private runPromise;
49
- private fileEventQueue;
50
- private plugins;
51
- private pluginsWithTransform;
52
- private transformPlugins;
53
- private routeGroupPatternRegex;
54
- private physicalDirectories;
55
- constructor(opts: {
56
- config: Config;
57
- root: string;
58
- fs?: fs;
59
- });
60
- private getRoutesDirectoryPath;
61
- getRoutesByFileMap(): GetRoutesByFileMapResult;
62
- run(event?: GeneratorEvent): Promise<void>;
63
- private generatorInternal;
64
- private buildRouteTreeFileContent;
65
- private getImportPath;
66
- private processRouteNodeFile;
67
- private didRouteFileChangeComparedToCache;
68
- private didFileChangeComparedToCache;
69
- private safeFileWrite;
70
- private getTempFileName;
71
- private isRouteFileCacheFresh;
72
- private handleRootNode;
73
- private handleNode;
74
- private isFileRelevantForRouteTreeGeneration;
75
- }
76
- export {};