@tanstack/router-generator 1.166.9 → 1.166.10

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 (58) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  2. package/dist/cjs/config.cjs +111 -147
  3. package/dist/cjs/config.cjs.map +1 -1
  4. package/dist/cjs/filesystem/physical/getRouteNodes.cjs +224 -303
  5. package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +1 -1
  6. package/dist/cjs/filesystem/physical/rootPathId.cjs +5 -4
  7. package/dist/cjs/filesystem/physical/rootPathId.cjs.map +1 -1
  8. package/dist/cjs/filesystem/virtual/config.cjs +32 -30
  9. package/dist/cjs/filesystem/virtual/config.cjs.map +1 -1
  10. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs +164 -209
  11. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +1 -1
  12. package/dist/cjs/filesystem/virtual/loadConfigFile.cjs +9 -8
  13. package/dist/cjs/filesystem/virtual/loadConfigFile.cjs.map +1 -1
  14. package/dist/cjs/generator.cjs +766 -1106
  15. package/dist/cjs/generator.cjs.map +1 -1
  16. package/dist/cjs/index.cjs +32 -34
  17. package/dist/cjs/logger.cjs +28 -34
  18. package/dist/cjs/logger.cjs.map +1 -1
  19. package/dist/cjs/template.cjs +144 -151
  20. package/dist/cjs/template.cjs.map +1 -1
  21. package/dist/cjs/transform/transform.cjs +287 -426
  22. package/dist/cjs/transform/transform.cjs.map +1 -1
  23. package/dist/cjs/transform/utils.cjs +31 -33
  24. package/dist/cjs/transform/utils.cjs.map +1 -1
  25. package/dist/cjs/utils.cjs +534 -544
  26. package/dist/cjs/utils.cjs.map +1 -1
  27. package/dist/cjs/validate-route-params.cjs +66 -51
  28. package/dist/cjs/validate-route-params.cjs.map +1 -1
  29. package/dist/esm/config.js +106 -147
  30. package/dist/esm/config.js.map +1 -1
  31. package/dist/esm/filesystem/physical/getRouteNodes.js +220 -286
  32. package/dist/esm/filesystem/physical/getRouteNodes.js.map +1 -1
  33. package/dist/esm/filesystem/physical/rootPathId.js +6 -5
  34. package/dist/esm/filesystem/physical/rootPathId.js.map +1 -1
  35. package/dist/esm/filesystem/virtual/config.js +31 -30
  36. package/dist/esm/filesystem/virtual/config.js.map +1 -1
  37. package/dist/esm/filesystem/virtual/getRouteNodes.js +161 -208
  38. package/dist/esm/filesystem/virtual/getRouteNodes.js.map +1 -1
  39. package/dist/esm/filesystem/virtual/loadConfigFile.js +7 -7
  40. package/dist/esm/filesystem/virtual/loadConfigFile.js.map +1 -1
  41. package/dist/esm/generator.js +756 -1083
  42. package/dist/esm/generator.js.map +1 -1
  43. package/dist/esm/index.js +4 -31
  44. package/dist/esm/logger.js +29 -35
  45. package/dist/esm/logger.js.map +1 -1
  46. package/dist/esm/template.js +144 -152
  47. package/dist/esm/template.js.map +1 -1
  48. package/dist/esm/transform/transform.js +285 -425
  49. package/dist/esm/transform/transform.js.map +1 -1
  50. package/dist/esm/transform/utils.js +31 -33
  51. package/dist/esm/transform/utils.js.map +1 -1
  52. package/dist/esm/utils.js +529 -564
  53. package/dist/esm/utils.js.map +1 -1
  54. package/dist/esm/validate-route-params.js +67 -52
  55. package/dist/esm/validate-route-params.js.map +1 -1
  56. package/package.json +5 -5
  57. package/dist/cjs/index.cjs.map +0 -1
  58. package/dist/esm/index.js.map +0 -1
@@ -1 +1 @@
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 hasEscapedLeadingUnderscore,\n removeExt,\n replaceBackslash,\n routePathToVariable,\n unwrapBracketWrappedSegment,\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\n/**\n * Pre-compiled segment regexes for matching token patterns against route segments.\n * These are created once (in Generator constructor) and passed through to avoid\n * repeated regex compilation during route crawling.\n */\nexport interface TokenRegexBundle {\n indexTokenSegmentRegex: RegExp\n routeTokenSegmentRegex: RegExp\n}\n\nconst disallowedRouteGroupConfiguration = /\\(([^)]+)\\).(ts|js|tsx|jsx|vue)/\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 tokenRegexes: TokenRegexBundle,\n): Promise<GetRouteNodesResult> {\n const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } =\n config\n\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 if (routeFileIgnorePattern) {\n return (\n d.name.startsWith(routeFilePrefix) &&\n !d.name.match(routeFileIgnoreRegExp)\n )\n }\n\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 tokenRegexes,\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 // Keep originalRoutePath aligned with routePath for escape detection\n if (node.originalRoutePath) {\n node.originalRoutePath = `/${dir}${node.originalRoutePath}`\n }\n node.filePath = filePath\n // Virtual subtree nodes (from __virtual.ts) are embedded in a\n // physical directory tree. They should use path-based parent\n // inference, not the explicit virtual parent tracking. Clear any\n // _virtualParentRoutePath that was set at construction time.\n delete node._virtualParentRoutePath\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|vue)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n const {\n routePath: initialRoutePath,\n originalRoutePath: initialOriginalRoutePath,\n } = determineInitialRoutePath(filePathNoExt)\n\n let routePath = initialRoutePath\n let originalRoutePath = initialOriginalRoutePath\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n originalRoutePath = originalRoutePath.replaceAll(\n routeFilePrefix,\n '',\n )\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, originalRoutePath, tokenRegexes)\n const variableName = meta.variableName\n let routeType: FsRouteType = meta.fsRouteType\n\n if (routeType === 'lazy') {\n routePath = routePath.replace(/\\/lazy$/, '')\n originalRoutePath = originalRoutePath.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 (\n isValidPathlessLayoutRoute(\n routePath,\n originalRoutePath,\n routeType,\n tokenRegexes,\n )\n ) {\n routeType = 'pathless_layout'\n }\n\n // Only show deprecation warning for .tsx/.ts files, not .vue files\n // Vue files using .component.vue is the Vue-native way\n const isVueFile = filePath.endsWith('.vue')\n if (!isVueFile) {\n ;(\n [\n ['component', 'component'],\n ['errorComponent', 'errorComponent'],\n ['notFoundComponent', 'notFoundComponent'],\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\n // Get the last segment of originalRoutePath to check for escaping\n const originalSegments = originalRoutePath.split('/').filter(Boolean)\n const lastOriginalSegmentForSuffix =\n originalSegments[originalSegments.length - 1] || ''\n\n const { routeTokenSegmentRegex, indexTokenSegmentRegex } =\n tokenRegexes\n\n // List of special suffixes that can be escaped\n const specialSuffixes = [\n 'component',\n 'errorComponent',\n 'notFoundComponent',\n 'pendingComponent',\n 'loader',\n 'lazy',\n ]\n\n const routePathSegments = routePath.split('/').filter(Boolean)\n const lastRouteSegment =\n routePathSegments[routePathSegments.length - 1] || ''\n\n const suffixToStrip = specialSuffixes.find((suffix) => {\n const endsWithSuffix = routePath.endsWith(`/${suffix}`)\n // A suffix is escaped if wrapped in brackets in the original: [lazy] means literal \"lazy\"\n const isEscaped =\n lastOriginalSegmentForSuffix.startsWith('[') &&\n lastOriginalSegmentForSuffix.endsWith(']') &&\n unwrapBracketWrappedSegment(lastOriginalSegmentForSuffix) ===\n suffix\n return endsWithSuffix && !isEscaped\n })\n\n const routeTokenCandidate = unwrapBracketWrappedSegment(\n lastOriginalSegmentForSuffix,\n )\n const isRouteTokenEscaped =\n lastOriginalSegmentForSuffix !== routeTokenCandidate &&\n routeTokenSegmentRegex.test(routeTokenCandidate)\n\n const shouldStripRouteToken =\n routeTokenSegmentRegex.test(lastRouteSegment) &&\n !isRouteTokenEscaped\n\n if (suffixToStrip || shouldStripRouteToken) {\n const stripSegment = suffixToStrip ?? lastRouteSegment\n routePath = routePath.replace(new RegExp(`/${stripSegment}$`), '')\n originalRoutePath = originalRoutePath.replace(\n new RegExp(`/${stripSegment}$`),\n '',\n )\n }\n\n // Check if the index token should be treated specially or as a literal path\n // Escaping stays literal-only: if the last original segment is bracket-wrapped,\n // treat it as literal even if it matches the token regex.\n const lastOriginalSegment =\n originalRoutePath.split('/').filter(Boolean).pop() || ''\n\n const indexTokenCandidate =\n unwrapBracketWrappedSegment(lastOriginalSegment)\n const isIndexEscaped =\n lastOriginalSegment !== indexTokenCandidate &&\n indexTokenSegmentRegex.test(indexTokenCandidate)\n\n if (!isIndexEscaped) {\n const updatedRouteSegments = routePath.split('/').filter(Boolean)\n const updatedLastRouteSegment =\n updatedRouteSegments[updatedRouteSegments.length - 1] || ''\n\n if (indexTokenSegmentRegex.test(updatedLastRouteSegment)) {\n if (routePathSegments.length === 1) {\n routePath = '/'\n }\n\n if (lastOriginalSegment === updatedLastRouteSegment) {\n originalRoutePath = '/'\n }\n\n // For layout routes, don't use '/' fallback - an empty path means\n // \"layout for the parent path\" which is important for physical() mounts\n // where route.tsx at root should have empty path, not '/'\n const isLayoutRoute = routeType === 'layout'\n\n routePath =\n routePath.replace(\n new RegExp(`/${updatedLastRouteSegment}$`),\n '/',\n ) || (isLayoutRoute ? '' : '/')\n\n originalRoutePath =\n originalRoutePath.replace(\n new RegExp(`/${indexTokenCandidate}$`),\n '/',\n ) || (isLayoutRoute ? '' : '/')\n }\n }\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n _fsRouteType: routeType,\n originalRoutePath,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n // Find the root route node - prefer the actual route file over component/loader files\n const rootRouteNode =\n routeNodes.find(\n (d) =>\n d.routePath === `/${rootPathId}` &&\n ![\n 'component',\n 'errorComponent',\n 'notFoundComponent',\n 'pendingComponent',\n 'loader',\n 'lazy',\n ].includes(d._fsRouteType),\n ) ?? 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 (with brackets removed).\n * @param originalRoutePath - The original route path (may contain brackets for escaped content).\n * @param tokenRegexes - Pre-compiled token regexes for matching.\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 originalRoutePath: string,\n tokenRegexes: TokenRegexBundle,\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 | 'notFoundComponent'\n >\n variableName: string\n} {\n let fsRouteType: FsRouteType = 'static'\n\n // Get the last segment from the original path to check for escaping\n const originalSegments = originalRoutePath.split('/').filter(Boolean)\n const lastOriginalSegment =\n originalSegments[originalSegments.length - 1] || ''\n\n const { routeTokenSegmentRegex } = tokenRegexes\n\n // Helper to check if a specific suffix is escaped (literal-only)\n // A suffix is escaped if the original segment is wrapped in brackets: [lazy] means literal \"lazy\"\n const isSuffixEscaped = (suffix: string): boolean => {\n return (\n lastOriginalSegment.startsWith('[') &&\n lastOriginalSegment.endsWith(']') &&\n unwrapBracketWrappedSegment(lastOriginalSegment) === suffix\n )\n }\n\n const routeSegments = routePath.split('/').filter(Boolean)\n const lastRouteSegment = routeSegments[routeSegments.length - 1] || ''\n\n const routeTokenCandidate = unwrapBracketWrappedSegment(lastOriginalSegment)\n const isRouteTokenEscaped =\n lastOriginalSegment !== routeTokenCandidate &&\n routeTokenSegmentRegex.test(routeTokenCandidate)\n\n if (routeTokenSegmentRegex.test(lastRouteSegment) && !isRouteTokenEscaped) {\n // layout routes, i.e `/foo/route.tsx` or `/foo/_layout/route.tsx`\n fsRouteType = 'layout'\n } else if (routePath.endsWith('/lazy') && !isSuffixEscaped('lazy')) {\n // lazy routes, i.e. `/foo.lazy.tsx`\n fsRouteType = 'lazy'\n } else if (routePath.endsWith('/loader') && !isSuffixEscaped('loader')) {\n // loader routes, i.e. `/foo.loader.tsx`\n fsRouteType = 'loader'\n } else if (\n routePath.endsWith('/component') &&\n !isSuffixEscaped('component')\n ) {\n // component routes, i.e. `/foo.component.tsx`\n fsRouteType = 'component'\n } else if (\n routePath.endsWith('/pendingComponent') &&\n !isSuffixEscaped('pendingComponent')\n ) {\n // pending component routes, i.e. `/foo.pendingComponent.tsx`\n fsRouteType = 'pendingComponent'\n } else if (\n routePath.endsWith('/errorComponent') &&\n !isSuffixEscaped('errorComponent')\n ) {\n // error component routes, i.e. `/foo.errorComponent.tsx`\n fsRouteType = 'errorComponent'\n } else if (\n routePath.endsWith('/notFoundComponent') &&\n !isSuffixEscaped('notFoundComponent')\n ) {\n // not found component routes, i.e. `/foo.notFoundComponent.tsx`\n fsRouteType = 'notFoundComponent'\n }\n\n // Use originalRoutePath for variable name when any segment is fully\n // bracket-wrapped (e.g. [index], [route], [_]auth) to avoid collisions\n // with their non-escaped counterparts that get special token treatment\n const hasFullyEscapedSegment = originalSegments.some(\n (seg) =>\n seg.startsWith('[') &&\n seg.endsWith(']') &&\n !seg.slice(1, -1).includes('[') &&\n !seg.slice(1, -1).includes(']'),\n )\n const variableName = routePathToVariable(\n hasFullyEscapedSegment ? originalRoutePath : routePath,\n )\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 originalRoutePath Original route path with brackets for escaped content\n * @param routeType The route type determined from file extension\n * @param tokenRegexes Pre-compiled token regexes for matching\n * @returns Boolean indicating if the route is a pathless layout route\n */\nfunction isValidPathlessLayoutRoute(\n normalizedRoutePath: string,\n originalRoutePath: string,\n routeType: FsRouteType,\n tokenRegexes: TokenRegexBundle,\n): boolean {\n if (routeType === 'lazy') {\n return false\n }\n\n const segments = normalizedRoutePath.split('/').filter(Boolean)\n const originalSegments = originalRoutePath.split('/').filter(Boolean)\n\n if (segments.length === 0) {\n return false\n }\n\n const lastRouteSegment = segments[segments.length - 1]!\n const lastOriginalSegment =\n originalSegments[originalSegments.length - 1] || ''\n const secondToLastRouteSegment = segments[segments.length - 2]\n const secondToLastOriginalSegment =\n originalSegments[originalSegments.length - 2]\n\n // If segment === __root, then exit as false\n if (lastRouteSegment === rootPathId) {\n return false\n }\n\n const { routeTokenSegmentRegex, indexTokenSegmentRegex } = tokenRegexes\n\n // If segment matches 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 // But if the underscore is escaped, it's not a pathless layout\n if (\n routeTokenSegmentRegex.test(lastRouteSegment) &&\n typeof secondToLastRouteSegment === 'string' &&\n typeof secondToLastOriginalSegment === 'string'\n ) {\n // Check if the underscore is escaped\n if (hasEscapedLeadingUnderscore(secondToLastOriginalSegment)) {\n return false\n }\n return secondToLastRouteSegment.startsWith('_')\n }\n\n // Segment starts with _ but check if it's escaped\n // If the original segment has [_] at the start, the underscore is escaped and it's not a pathless layout\n if (hasEscapedLeadingUnderscore(lastOriginalSegment)) {\n return false\n }\n\n return (\n !indexTokenSegmentRegex.test(lastRouteSegment) &&\n !routeTokenSegmentRegex.test(lastRouteSegment) &&\n lastRouteSegment.startsWith('_')\n )\n}\n"],"names":["getRouteNodesVirtual"],"mappings":";;;;;;;AA+BA,MAAM,oCAAoC;AAE1C,MAAM,0BAA0B;AACzB,SAAS,oBAAoB,UAA2B;AAC7D,SAAO,wBAAwB,KAAK,QAAQ;AAC9C;AAEA,eAAsB,cACpB,QAUA,MACA,cAC8B;AAC9B,QAAM,EAAE,iBAAiB,uBAAuB,uBAAA,IAC9C;AAEF,QAAM,SAAS,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,QAAM,wBAAwB,IAAI,OAAO,0BAA0B,IAAI,GAAG;AAE1E,QAAM,aAA+B,CAAA;AACrC,QAAM,yBAAwC,CAAA;AAE9C,iBAAe,QAAQ,KAAa;AAClC,UAAM,UAAU,KAAK,QAAQ,OAAO,iBAAiB,GAAG;AACxD,QAAI,UAAU,MAAM,IAAI,QAAQ,SAAS,EAAE,eAAe,MAAM;AAEhE,cAAU,QAAQ,OAAO,CAAC,MAAM;AAC9B,UACE,EAAE,KAAK,WAAW,GAAG,KACpB,yBAAyB,EAAE,KAAK,WAAW,qBAAqB,GACjE;AACA,eAAO;AAAA,MACT;AAEA,UAAI,iBAAiB;AACnB,YAAI,wBAAw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IA,MAAI,4BAA4B,mBAAmB,GAAG;AACpD,WAAO;AAAA,EACT;AAEA,SACE,CAAC,uBAAuB,KAAK,gBAAgB,KAC7C,CAAC,uBAAuB,KAAK,gBAAgB,KAC7C,iBAAiB,WAAW,GAAG;AAEnC;"}
1
+ {"version":3,"file":"getRouteNodes.js","names":[],"sources":["../../../../src/filesystem/physical/getRouteNodes.ts"],"sourcesContent":["import path from 'node:path'\nimport * as fsp from 'node:fs/promises'\nimport {\n determineInitialRoutePath,\n hasEscapedLeadingUnderscore,\n removeExt,\n replaceBackslash,\n routePathToVariable,\n unwrapBracketWrappedSegment,\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\n/**\n * Pre-compiled segment regexes for matching token patterns against route segments.\n * These are created once (in Generator constructor) and passed through to avoid\n * repeated regex compilation during route crawling.\n */\nexport interface TokenRegexBundle {\n indexTokenSegmentRegex: RegExp\n routeTokenSegmentRegex: RegExp\n}\n\nconst disallowedRouteGroupConfiguration = /\\(([^)]+)\\).(ts|js|tsx|jsx|vue)/\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 tokenRegexes: TokenRegexBundle,\n): Promise<GetRouteNodesResult> {\n const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } =\n config\n\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 if (routeFileIgnorePattern) {\n return (\n d.name.startsWith(routeFilePrefix) &&\n !d.name.match(routeFileIgnoreRegExp)\n )\n }\n\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 tokenRegexes,\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 // Keep originalRoutePath aligned with routePath for escape detection\n if (node.originalRoutePath) {\n node.originalRoutePath = `/${dir}${node.originalRoutePath}`\n }\n node.filePath = filePath\n // Virtual subtree nodes (from __virtual.ts) are embedded in a\n // physical directory tree. They should use path-based parent\n // inference, not the explicit virtual parent tracking. Clear any\n // _virtualParentRoutePath that was set at construction time.\n delete node._virtualParentRoutePath\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|vue)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n const {\n routePath: initialRoutePath,\n originalRoutePath: initialOriginalRoutePath,\n } = determineInitialRoutePath(filePathNoExt)\n\n let routePath = initialRoutePath\n let originalRoutePath = initialOriginalRoutePath\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n originalRoutePath = originalRoutePath.replaceAll(\n routeFilePrefix,\n '',\n )\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, originalRoutePath, tokenRegexes)\n const variableName = meta.variableName\n let routeType: FsRouteType = meta.fsRouteType\n\n if (routeType === 'lazy') {\n routePath = routePath.replace(/\\/lazy$/, '')\n originalRoutePath = originalRoutePath.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 (\n isValidPathlessLayoutRoute(\n routePath,\n originalRoutePath,\n routeType,\n tokenRegexes,\n )\n ) {\n routeType = 'pathless_layout'\n }\n\n // Only show deprecation warning for .tsx/.ts files, not .vue files\n // Vue files using .component.vue is the Vue-native way\n const isVueFile = filePath.endsWith('.vue')\n if (!isVueFile) {\n ;(\n [\n ['component', 'component'],\n ['errorComponent', 'errorComponent'],\n ['notFoundComponent', 'notFoundComponent'],\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\n // Get the last segment of originalRoutePath to check for escaping\n const originalSegments = originalRoutePath.split('/').filter(Boolean)\n const lastOriginalSegmentForSuffix =\n originalSegments[originalSegments.length - 1] || ''\n\n const { routeTokenSegmentRegex, indexTokenSegmentRegex } =\n tokenRegexes\n\n // List of special suffixes that can be escaped\n const specialSuffixes = [\n 'component',\n 'errorComponent',\n 'notFoundComponent',\n 'pendingComponent',\n 'loader',\n 'lazy',\n ]\n\n const routePathSegments = routePath.split('/').filter(Boolean)\n const lastRouteSegment =\n routePathSegments[routePathSegments.length - 1] || ''\n\n const suffixToStrip = specialSuffixes.find((suffix) => {\n const endsWithSuffix = routePath.endsWith(`/${suffix}`)\n // A suffix is escaped if wrapped in brackets in the original: [lazy] means literal \"lazy\"\n const isEscaped =\n lastOriginalSegmentForSuffix.startsWith('[') &&\n lastOriginalSegmentForSuffix.endsWith(']') &&\n unwrapBracketWrappedSegment(lastOriginalSegmentForSuffix) ===\n suffix\n return endsWithSuffix && !isEscaped\n })\n\n const routeTokenCandidate = unwrapBracketWrappedSegment(\n lastOriginalSegmentForSuffix,\n )\n const isRouteTokenEscaped =\n lastOriginalSegmentForSuffix !== routeTokenCandidate &&\n routeTokenSegmentRegex.test(routeTokenCandidate)\n\n const shouldStripRouteToken =\n routeTokenSegmentRegex.test(lastRouteSegment) &&\n !isRouteTokenEscaped\n\n if (suffixToStrip || shouldStripRouteToken) {\n const stripSegment = suffixToStrip ?? lastRouteSegment\n routePath = routePath.replace(new RegExp(`/${stripSegment}$`), '')\n originalRoutePath = originalRoutePath.replace(\n new RegExp(`/${stripSegment}$`),\n '',\n )\n }\n\n // Check if the index token should be treated specially or as a literal path\n // Escaping stays literal-only: if the last original segment is bracket-wrapped,\n // treat it as literal even if it matches the token regex.\n const lastOriginalSegment =\n originalRoutePath.split('/').filter(Boolean).pop() || ''\n\n const indexTokenCandidate =\n unwrapBracketWrappedSegment(lastOriginalSegment)\n const isIndexEscaped =\n lastOriginalSegment !== indexTokenCandidate &&\n indexTokenSegmentRegex.test(indexTokenCandidate)\n\n if (!isIndexEscaped) {\n const updatedRouteSegments = routePath.split('/').filter(Boolean)\n const updatedLastRouteSegment =\n updatedRouteSegments[updatedRouteSegments.length - 1] || ''\n\n if (indexTokenSegmentRegex.test(updatedLastRouteSegment)) {\n if (routePathSegments.length === 1) {\n routePath = '/'\n }\n\n if (lastOriginalSegment === updatedLastRouteSegment) {\n originalRoutePath = '/'\n }\n\n // For layout routes, don't use '/' fallback - an empty path means\n // \"layout for the parent path\" which is important for physical() mounts\n // where route.tsx at root should have empty path, not '/'\n const isLayoutRoute = routeType === 'layout'\n\n routePath =\n routePath.replace(\n new RegExp(`/${updatedLastRouteSegment}$`),\n '/',\n ) || (isLayoutRoute ? '' : '/')\n\n originalRoutePath =\n originalRoutePath.replace(\n new RegExp(`/${indexTokenCandidate}$`),\n '/',\n ) || (isLayoutRoute ? '' : '/')\n }\n }\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n _fsRouteType: routeType,\n originalRoutePath,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n // Find the root route node - prefer the actual route file over component/loader files\n const rootRouteNode =\n routeNodes.find(\n (d) =>\n d.routePath === `/${rootPathId}` &&\n ![\n 'component',\n 'errorComponent',\n 'notFoundComponent',\n 'pendingComponent',\n 'loader',\n 'lazy',\n ].includes(d._fsRouteType),\n ) ?? 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 (with brackets removed).\n * @param originalRoutePath - The original route path (may contain brackets for escaped content).\n * @param tokenRegexes - Pre-compiled token regexes for matching.\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 originalRoutePath: string,\n tokenRegexes: TokenRegexBundle,\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 | 'notFoundComponent'\n >\n variableName: string\n} {\n let fsRouteType: FsRouteType = 'static'\n\n // Get the last segment from the original path to check for escaping\n const originalSegments = originalRoutePath.split('/').filter(Boolean)\n const lastOriginalSegment =\n originalSegments[originalSegments.length - 1] || ''\n\n const { routeTokenSegmentRegex } = tokenRegexes\n\n // Helper to check if a specific suffix is escaped (literal-only)\n // A suffix is escaped if the original segment is wrapped in brackets: [lazy] means literal \"lazy\"\n const isSuffixEscaped = (suffix: string): boolean => {\n return (\n lastOriginalSegment.startsWith('[') &&\n lastOriginalSegment.endsWith(']') &&\n unwrapBracketWrappedSegment(lastOriginalSegment) === suffix\n )\n }\n\n const routeSegments = routePath.split('/').filter(Boolean)\n const lastRouteSegment = routeSegments[routeSegments.length - 1] || ''\n\n const routeTokenCandidate = unwrapBracketWrappedSegment(lastOriginalSegment)\n const isRouteTokenEscaped =\n lastOriginalSegment !== routeTokenCandidate &&\n routeTokenSegmentRegex.test(routeTokenCandidate)\n\n if (routeTokenSegmentRegex.test(lastRouteSegment) && !isRouteTokenEscaped) {\n // layout routes, i.e `/foo/route.tsx` or `/foo/_layout/route.tsx`\n fsRouteType = 'layout'\n } else if (routePath.endsWith('/lazy') && !isSuffixEscaped('lazy')) {\n // lazy routes, i.e. `/foo.lazy.tsx`\n fsRouteType = 'lazy'\n } else if (routePath.endsWith('/loader') && !isSuffixEscaped('loader')) {\n // loader routes, i.e. `/foo.loader.tsx`\n fsRouteType = 'loader'\n } else if (\n routePath.endsWith('/component') &&\n !isSuffixEscaped('component')\n ) {\n // component routes, i.e. `/foo.component.tsx`\n fsRouteType = 'component'\n } else if (\n routePath.endsWith('/pendingComponent') &&\n !isSuffixEscaped('pendingComponent')\n ) {\n // pending component routes, i.e. `/foo.pendingComponent.tsx`\n fsRouteType = 'pendingComponent'\n } else if (\n routePath.endsWith('/errorComponent') &&\n !isSuffixEscaped('errorComponent')\n ) {\n // error component routes, i.e. `/foo.errorComponent.tsx`\n fsRouteType = 'errorComponent'\n } else if (\n routePath.endsWith('/notFoundComponent') &&\n !isSuffixEscaped('notFoundComponent')\n ) {\n // not found component routes, i.e. `/foo.notFoundComponent.tsx`\n fsRouteType = 'notFoundComponent'\n }\n\n // Use originalRoutePath for variable name when any segment is fully\n // bracket-wrapped (e.g. [index], [route], [_]auth) to avoid collisions\n // with their non-escaped counterparts that get special token treatment\n const hasFullyEscapedSegment = originalSegments.some(\n (seg) =>\n seg.startsWith('[') &&\n seg.endsWith(']') &&\n !seg.slice(1, -1).includes('[') &&\n !seg.slice(1, -1).includes(']'),\n )\n const variableName = routePathToVariable(\n hasFullyEscapedSegment ? originalRoutePath : routePath,\n )\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 originalRoutePath Original route path with brackets for escaped content\n * @param routeType The route type determined from file extension\n * @param tokenRegexes Pre-compiled token regexes for matching\n * @returns Boolean indicating if the route is a pathless layout route\n */\nfunction isValidPathlessLayoutRoute(\n normalizedRoutePath: string,\n originalRoutePath: string,\n routeType: FsRouteType,\n tokenRegexes: TokenRegexBundle,\n): boolean {\n if (routeType === 'lazy') {\n return false\n }\n\n const segments = normalizedRoutePath.split('/').filter(Boolean)\n const originalSegments = originalRoutePath.split('/').filter(Boolean)\n\n if (segments.length === 0) {\n return false\n }\n\n const lastRouteSegment = segments[segments.length - 1]!\n const lastOriginalSegment =\n originalSegments[originalSegments.length - 1] || ''\n const secondToLastRouteSegment = segments[segments.length - 2]\n const secondToLastOriginalSegment =\n originalSegments[originalSegments.length - 2]\n\n // If segment === __root, then exit as false\n if (lastRouteSegment === rootPathId) {\n return false\n }\n\n const { routeTokenSegmentRegex, indexTokenSegmentRegex } = tokenRegexes\n\n // If segment matches 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 // But if the underscore is escaped, it's not a pathless layout\n if (\n routeTokenSegmentRegex.test(lastRouteSegment) &&\n typeof secondToLastRouteSegment === 'string' &&\n typeof secondToLastOriginalSegment === 'string'\n ) {\n // Check if the underscore is escaped\n if (hasEscapedLeadingUnderscore(secondToLastOriginalSegment)) {\n return false\n }\n return secondToLastRouteSegment.startsWith('_')\n }\n\n // Segment starts with _ but check if it's escaped\n // If the original segment has [_] at the start, the underscore is escaped and it's not a pathless layout\n if (hasEscapedLeadingUnderscore(lastOriginalSegment)) {\n return false\n }\n\n return (\n !indexTokenSegmentRegex.test(lastRouteSegment) &&\n !routeTokenSegmentRegex.test(lastRouteSegment) &&\n lastRouteSegment.startsWith('_')\n )\n}\n"],"mappings":";;;;;;;;AA+BA,IAAM,oCAAoC;AAE1C,IAAM,0BAA0B;AAChC,SAAgB,oBAAoB,UAA2B;AAC7D,QAAO,wBAAwB,KAAK,SAAS;;AAG/C,eAAsB,cACpB,QAUA,MACA,cAC8B;CAC9B,MAAM,EAAE,iBAA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AiB,SAAS,MAAM;CACnD,MAAM,2BAA2B,SAAS,SAAS,SAAS;CAC5D,MAAM,8BACJ,iBAAiB,iBAAiB,SAAS;AAG7C,KAAI,qBAAA,SACF,QAAO;CAGT,MAAM,EAAE,wBAAwB,2BAA2B;AAM3D,KACE,uBAAuB,KAAK,iBAAiB,IAC7C,OAAO,6BAA6B,YACpC,OAAO,gCAAgC,UACvC;AAEA,MAAI,4BAA4B,4BAA4B,CAC1D,QAAO;AAET,SAAO,yBAAyB,WAAW,IAAI;;AAKjD,KAAI,4BAA4B,oBAAoB,CAClD,QAAO;AAGT,QACE,CAAC,uBAAuB,KAAK,iBAAiB,IAC9C,CAAC,uBAAuB,KAAK,iBAAiB,IAC9C,iBAAiB,WAAW,IAAI"}
@@ -1,5 +1,6 @@
1
- const rootPathId = "__root";
2
- export {
3
- rootPathId
4
- };
5
- //# sourceMappingURL=rootPathId.js.map
1
+ //#region src/filesystem/physical/rootPathId.ts
2
+ var rootPathId = "__root";
3
+ //#endregion
4
+ export { rootPathId };
5
+
6
+ //# sourceMappingURL=rootPathId.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rootPathId.js","sources":["../../../../src/filesystem/physical/rootPathId.ts"],"sourcesContent":["export const rootPathId = '__root'\n"],"names":[],"mappings":"AAAO,MAAM,aAAa;"}
1
+ {"version":3,"file":"rootPathId.js","names":[],"sources":["../../../../src/filesystem/physical/rootPathId.ts"],"sourcesContent":["export const rootPathId = '__root'\n"],"mappings":";AAAA,IAAa,aAAa"}
@@ -1,37 +1,38 @@
1
1
  import { z } from "zod";
2
- const indexRouteSchema = z.object({
3
- type: z.literal("index"),
4
- file: z.string()
2
+ //#region src/filesystem/virtual/config.ts
3
+ var indexRouteSchema = z.object({
4
+ type: z.literal("index"),
5
+ file: z.string()
5
6
  });
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()
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()
11
12
  });
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()
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()
17
18
  });
18
- const physicalSubTreeSchema = z.object({
19
- type: z.literal("physical"),
20
- directory: z.string(),
21
- pathPrefix: z.string()
19
+ var physicalSubTreeSchema = z.object({
20
+ type: z.literal("physical"),
21
+ directory: z.string(),
22
+ pathPrefix: z.string()
22
23
  });
23
- const virtualRouteNodeSchema = z.union([
24
- indexRouteSchema,
25
- layoutRouteSchema,
26
- routeSchema,
27
- physicalSubTreeSchema
24
+ var virtualRouteNodeSchema = z.union([
25
+ indexRouteSchema,
26
+ layoutRouteSchema,
27
+ routeSchema,
28
+ physicalSubTreeSchema
28
29
  ]);
29
- const virtualRootRouteSchema = z.object({
30
- type: z.literal("root"),
31
- file: z.string(),
32
- children: z.array(virtualRouteNodeSchema).optional()
30
+ var virtualRootRouteSchema = z.object({
31
+ type: z.literal("root"),
32
+ file: z.string(),
33
+ children: z.array(virtualRouteNodeSchema).optional()
33
34
  });
34
- export {
35
- virtualRootRouteSchema
36
- };
37
- //# sourceMappingURL=config.js.map
35
+ //#endregion
36
+ export { virtualRootRouteSchema };
37
+
38
+ //# sourceMappingURL=config.js.map
@@ -1 +1 @@
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,OAAA;AACV,CAAC;AAED,MAAM,oBAA4C,EAAE,OAAO;AAAA,EACzD,MAAM,EAAE,QAAQ,QAAQ;AAAA,EACxB,IAAI,EAAE,OAAA,EAAS,SAAA;AAAA,EACf,MAAM,EAAE,OAAA;AAAA,EACR,UAAU,EAAE,MAAM,EAAE,KAAK,MAAM,sBAAsB,CAAC,EAAE,SAAA;AAC1D,CAAC;AAED,MAAM,cAAgC,EAAE,OAAO;AAAA,EAC7C,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,MAAM,EAAE,OAAA,EAAS,SAAA;AAAA,EACjB,MAAM,EAAE,OAAA;AAAA,EACR,UAAU,EAAE,MAAM,EAAE,KAAK,MAAM,sBAAsB,CAAC,EAAE,SAAA;AAC1D,CAAC;AAED,MAAM,wBAAoD,EAAE,OAAO;AAAA,EACjE,MAAM,EAAE,QAAQ,UAAU;AAAA,EAC1B,WAAW,EAAE,OAAA;AAAA,EACb,YAAY,EAAE,OAAA;AAChB,CAAC;AAED,MAAM,yBAAyB,EAAE,MAAM;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,MAAM,yBAAsD,EAAE,OAAO;AAAA,EAC1E,MAAM,EAAE,QAAQ,MAAM;AAAA,EACtB,MAAM,EAAE,OAAA;AAAA,EACR,UAAU,EAAE,MAAM,sBAAsB,EAAE,SAAA;AAC5C,CAAC;"}
1
+ {"version":3,"file":"config.js","names":[],"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"],"mappings":";;AAQA,IAAM,mBAAmB,EAAE,OAAO;CAChC,MAAM,EAAE,QAAQ,QAAQ;CACxB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,IAAM,oBAA4C,EAAE,OAAO;CACzD,MAAM,EAAE,QAAQ,SAAS;CACzB,IAAI,EAAE,QAAQ,CAAC,UAAU;CACzB,MAAM,EAAE,QAAQ;CAChB,UAAU,EAAE,MAAM,EAAE,WAAW,uBAAuB,CAAC,CAAC,UAAU;CACnE,CAAC;AAEF,IAAM,cAAgC,EAAE,OAAO;CAC7C,MAAM,EAAE,QAAQ,QAAQ;CACxB,MAAM,EAAE,QAAQ,CAAC,UAAU;CAC3B,MAAM,EAAE,QAAQ;CAChB,UAAU,EAAE,MAAM,EAAE,WAAW,uBAAuB,CAAC,CAAC,UAAU;CACnE,CAAC;AAEF,IAAM,wBAAoD,EAAE,OAAO;CACjE,MAAM,EAAE,QAAQ,WAAW;CAC3B,WAAW,EAAE,QAAQ;CACrB,YAAY,EAAE,QAAQ;CACvB,CAAC;AAEF,IAAM,yBAAyB,EAAE,MAAM;CACrC;CACA;CACA;CACA;CACD,CAAC;AAEF,IAAa,yBAAsD,EAAE,OAAO;CAC1E,MAAM,EAAE,QAAQ,OAAO;CACvB,MAAM,EAAE,QAAQ;CAChB,UAAU,EAAE,MAAM,uBAAuB,CAAC,UAAU;CACrD,CAAC"}
@@ -1,220 +1,173 @@
1
- import path, { resolve, join } from "node:path";
2
- import { replaceBackslash, routePathToVariable, removeExt, removeTrailingSlash, determineInitialRoutePath, removeLeadingSlash } from "../../utils.js";
3
- import { getRouteNodes as getRouteNodes$1 } from "../physical/getRouteNodes.js";
4
- import { rootPathId } from "../physical/rootPathId.js";
5
1
  import { virtualRootRouteSchema } from "./config.js";
2
+ import { rootPathId } from "../physical/rootPathId.js";
3
+ import { determineInitialRoutePath, removeExt, removeLeadingSlash, removeTrailingSlash, replaceBackslash, routePathToVariable } from "../../utils.js";
6
4
  import { loadConfigFile } from "./loadConfigFile.js";
5
+ import { getRouteNodes as getRouteNodes$1 } from "../physical/getRouteNodes.js";
6
+ import path, { join, resolve } from "node:path";
7
+ //#region src/filesystem/virtual/getRouteNodes.ts
7
8
  function ensureLeadingUnderScore(id) {
8
- if (id.startsWith("_")) {
9
- return id;
10
- }
11
- return `_${id}`;
9
+ if (id.startsWith("_")) return id;
10
+ return `_${id}`;
12
11
  }
13
12
  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;
13
+ const result = [node];
14
+ if (node.children) for (const child of node.children) result.push(...flattenTree(child));
15
+ delete node.children;
16
+ return result;
22
17
  }
23
18
  async function getRouteNodes(tsrConfig, root, tokenRegexes) {
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
- tokenRegexes
43
- );
44
- const allNodes = flattenTree({
45
- children,
46
- filePath: virtualRouteConfig.file,
47
- fullPath: replaceBackslash(join(fullDir, virtualRouteConfig.file)),
48
- variableName: "root",
49
- routePath: `/${rootPathId}`,
50
- _fsRouteType: "__root"
51
- });
52
- const rootRouteNode = allNodes[0];
53
- const routeNodes = allNodes.slice(1);
54
- return { rootRouteNode, routeNodes, physicalDirectories };
19
+ const fullDir = resolve(tsrConfig.routesDirectory);
20
+ if (tsrConfig.virtualRouteConfig === void 0) throw new Error(`virtualRouteConfig is undefined`);
21
+ let virtualRouteConfig;
22
+ if (typeof tsrConfig.virtualRouteConfig === "string") virtualRouteConfig = await getVirtualRouteConfigFromFileExport(tsrConfig, root);
23
+ else virtualRouteConfig = tsrConfig.virtualRouteConfig;
24
+ const { children, physicalDirectories } = await getRouteNodesRecursive(tsrConfig, root, fullDir, virtualRouteConfig.children, tokenRegexes);
25
+ const allNodes = flattenTree({
26
+ children,
27
+ filePath: virtualRouteConfig.file,
28
+ fullPath: replaceBackslash(join(fullDir, virtualRouteConfig.file)),
29
+ variableName: "root",
30
+ routePath: `/${rootPathId}`,
31
+ _fsRouteType: "__root"
32
+ });
33
+ return {
34
+ rootRouteNode: allNodes[0],
35
+ routeNodes: allNodes.slice(1),
36
+ physicalDirectories
37
+ };
55
38
  }
39
+ /**
40
+ * Get the virtual route config from a file export
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * // routes.ts
45
+ * import { rootRoute } from '@tanstack/virtual-file-routes'
46
+ *
47
+ * export const routes = rootRoute({ ... })
48
+ * // or
49
+ * export default rootRoute({ ... })
50
+ * ```
51
+ *
52
+ */
56
53
  async function getVirtualRouteConfigFromFileExport(tsrConfig, root) {
57
- if (tsrConfig.virtualRouteConfig === void 0 || typeof tsrConfig.virtualRouteConfig !== "string" || tsrConfig.virtualRouteConfig === "") {
58
- throw new Error(`virtualRouteConfig is undefined or empty`);
59
- }
60
- const exports$1 = await loadConfigFile(join(root, tsrConfig.virtualRouteConfig));
61
- if (!("routes" in exports$1) && !("default" in exports$1)) {
62
- throw new Error(
63
- `routes not found in ${tsrConfig.virtualRouteConfig}. The routes export must be named like 'export const routes = ...' or done using 'export default ...'`
64
- );
65
- }
66
- const virtualRouteConfig = "routes" in exports$1 ? exports$1.routes : exports$1.default;
67
- return virtualRootRouteSchema.parse(virtualRouteConfig);
54
+ if (tsrConfig.virtualRouteConfig === void 0 || typeof tsrConfig.virtualRouteConfig !== "string" || tsrConfig.virtualRouteConfig === "") throw new Error(`virtualRouteConfig is undefined or empty`);
55
+ const exports = await loadConfigFile(join(root, tsrConfig.virtualRouteConfig));
56
+ if (!("routes" in exports) && !("default" in exports)) throw new Error(`routes not found in ${tsrConfig.virtualRouteConfig}. The routes export must be named like 'export const routes = ...' or done using 'export default ...'`);
57
+ const virtualRouteConfig = "routes" in exports ? exports.routes : exports.default;
58
+ return virtualRootRouteSchema.parse(virtualRouteConfig);
68
59
  }
69
60
  async function getRouteNodesRecursive(tsrConfig, root, fullDir, nodes, tokenRegexes, parent) {
70
- if (nodes === void 0) {
71
- return { children: [], physicalDirectories: [] };
72
- }
73
- const allPhysicalDirectories = [];
74
- const children = await Promise.all(
75
- nodes.map(async (node) => {
76
- if (node.type === "physical") {
77
- const { routeNodes, physicalDirectories } = await getRouteNodes$1(
78
- {
79
- ...tsrConfig,
80
- routesDirectory: resolve(fullDir, node.directory)
81
- },
82
- root,
83
- tokenRegexes
84
- );
85
- allPhysicalDirectories.push(
86
- resolve(fullDir, node.directory),
87
- ...physicalDirectories
88
- );
89
- routeNodes.forEach((subtreeNode) => {
90
- subtreeNode.variableName = routePathToVariable(
91
- `${node.pathPrefix}/${removeExt(subtreeNode.filePath)}`
92
- );
93
- subtreeNode.routePath = `${parent?.routePath ?? ""}${node.pathPrefix}${subtreeNode.routePath}`;
94
- if (subtreeNode.originalRoutePath) {
95
- subtreeNode.originalRoutePath = `${parent?.routePath ?? ""}${node.pathPrefix}${subtreeNode.originalRoutePath}`;
96
- }
97
- subtreeNode.filePath = `${node.directory}/${subtreeNode.filePath}`;
98
- });
99
- return routeNodes;
100
- }
101
- function getFile(file) {
102
- const filePath = file;
103
- const variableName = routePathToVariable(removeExt(filePath));
104
- const fullPath = replaceBackslash(join(fullDir, filePath));
105
- return { filePath, variableName, fullPath };
106
- }
107
- const parentRoutePath = removeTrailingSlash(parent?.routePath ?? "/");
108
- const virtualParentRoutePath = parent?.routePath ?? `/${rootPathId}`;
109
- switch (node.type) {
110
- case "index": {
111
- const { filePath, variableName, fullPath } = getFile(node.file);
112
- const routePath = `${parentRoutePath}/`;
113
- return {
114
- filePath,
115
- fullPath,
116
- variableName,
117
- routePath,
118
- _fsRouteType: "static",
119
- _virtualParentRoutePath: virtualParentRoutePath
120
- };
121
- }
122
- case "route": {
123
- const lastSegment = node.path;
124
- let routeNode;
125
- const {
126
- routePath: escapedSegment,
127
- originalRoutePath: originalSegment
128
- } = determineInitialRoutePath(removeLeadingSlash(lastSegment));
129
- const routePath = `${parentRoutePath}${escapedSegment}`;
130
- const originalRoutePath = `${parentRoutePath}${originalSegment}`;
131
- if (node.file) {
132
- const { filePath, variableName, fullPath } = getFile(node.file);
133
- routeNode = {
134
- filePath,
135
- fullPath,
136
- variableName,
137
- routePath,
138
- originalRoutePath,
139
- _fsRouteType: "static",
140
- _virtualParentRoutePath: virtualParentRoutePath
141
- };
142
- } else {
143
- routeNode = {
144
- filePath: "",
145
- fullPath: "",
146
- variableName: routePathToVariable(routePath),
147
- routePath,
148
- originalRoutePath,
149
- isVirtual: true,
150
- _fsRouteType: "static",
151
- _virtualParentRoutePath: virtualParentRoutePath
152
- };
153
- }
154
- if (node.children !== void 0) {
155
- const { children: children2, physicalDirectories } = await getRouteNodesRecursive(
156
- tsrConfig,
157
- root,
158
- fullDir,
159
- node.children,
160
- tokenRegexes,
161
- routeNode
162
- );
163
- routeNode.children = children2;
164
- allPhysicalDirectories.push(...physicalDirectories);
165
- routeNode._fsRouteType = "layout";
166
- }
167
- return routeNode;
168
- }
169
- case "layout": {
170
- const { filePath, variableName, fullPath } = getFile(node.file);
171
- if (node.id !== void 0) {
172
- node.id = ensureLeadingUnderScore(node.id);
173
- } else {
174
- const baseName = path.basename(filePath);
175
- const fileNameWithoutExt = path.parse(baseName).name;
176
- node.id = ensureLeadingUnderScore(fileNameWithoutExt);
177
- }
178
- const lastSegment = node.id;
179
- const {
180
- routePath: escapedSegment,
181
- originalRoutePath: originalSegment
182
- } = determineInitialRoutePath(removeLeadingSlash(lastSegment));
183
- const routePath = `${parentRoutePath}${escapedSegment}`;
184
- const originalRoutePath = `${parentRoutePath}${originalSegment}`;
185
- const routeNode = {
186
- fullPath,
187
- filePath,
188
- variableName,
189
- routePath,
190
- originalRoutePath,
191
- _fsRouteType: "pathless_layout",
192
- _virtualParentRoutePath: virtualParentRoutePath
193
- };
194
- if (node.children !== void 0) {
195
- const { children: children2, physicalDirectories } = await getRouteNodesRecursive(
196
- tsrConfig,
197
- root,
198
- fullDir,
199
- node.children,
200
- tokenRegexes,
201
- routeNode
202
- );
203
- routeNode.children = children2;
204
- allPhysicalDirectories.push(...physicalDirectories);
205
- }
206
- return routeNode;
207
- }
208
- }
209
- })
210
- );
211
- return {
212
- children: children.flat(),
213
- physicalDirectories: allPhysicalDirectories
214
- };
61
+ if (nodes === void 0) return {
62
+ children: [],
63
+ physicalDirectories: []
64
+ };
65
+ const allPhysicalDirectories = [];
66
+ return {
67
+ children: (await Promise.all(nodes.map(async (node) => {
68
+ if (node.type === "physical") {
69
+ const { routeNodes, physicalDirectories } = await getRouteNodes$1({
70
+ ...tsrConfig,
71
+ routesDirectory: resolve(fullDir, node.directory)
72
+ }, root, tokenRegexes);
73
+ allPhysicalDirectories.push(resolve(fullDir, node.directory), ...physicalDirectories);
74
+ routeNodes.forEach((subtreeNode) => {
75
+ subtreeNode.variableName = routePathToVariable(`${node.pathPrefix}/${removeExt(subtreeNode.filePath)}`);
76
+ subtreeNode.routePath = `${parent?.routePath ?? ""}${node.pathPrefix}${subtreeNode.routePath}`;
77
+ if (subtreeNode.originalRoutePath) subtreeNode.originalRoutePath = `${parent?.routePath ?? ""}${node.pathPrefix}${subtreeNode.originalRoutePath}`;
78
+ subtreeNode.filePath = `${node.directory}/${subtreeNode.filePath}`;
79
+ });
80
+ return routeNodes;
81
+ }
82
+ function getFile(file) {
83
+ const filePath = file;
84
+ return {
85
+ filePath,
86
+ variableName: routePathToVariable(removeExt(filePath)),
87
+ fullPath: replaceBackslash(join(fullDir, filePath))
88
+ };
89
+ }
90
+ const parentRoutePath = removeTrailingSlash(parent?.routePath ?? "/");
91
+ const virtualParentRoutePath = parent?.routePath ?? `/__root`;
92
+ switch (node.type) {
93
+ case "index": {
94
+ const { filePath, variableName, fullPath } = getFile(node.file);
95
+ return {
96
+ filePath,
97
+ fullPath,
98
+ variableName,
99
+ routePath: `${parentRoutePath}/`,
100
+ _fsRouteType: "static",
101
+ _virtualParentRoutePath: virtualParentRoutePath
102
+ };
103
+ }
104
+ case "route": {
105
+ const lastSegment = node.path;
106
+ let routeNode;
107
+ const { routePath: escapedSegment, originalRoutePath: originalSegment } = determineInitialRoutePath(removeLeadingSlash(lastSegment));
108
+ const routePath = `${parentRoutePath}${escapedSegment}`;
109
+ const originalRoutePath = `${parentRoutePath}${originalSegment}`;
110
+ if (node.file) {
111
+ const { filePath, variableName, fullPath } = getFile(node.file);
112
+ routeNode = {
113
+ filePath,
114
+ fullPath,
115
+ variableName,
116
+ routePath,
117
+ originalRoutePath,
118
+ _fsRouteType: "static",
119
+ _virtualParentRoutePath: virtualParentRoutePath
120
+ };
121
+ } else routeNode = {
122
+ filePath: "",
123
+ fullPath: "",
124
+ variableName: routePathToVariable(routePath),
125
+ routePath,
126
+ originalRoutePath,
127
+ isVirtual: true,
128
+ _fsRouteType: "static",
129
+ _virtualParentRoutePath: virtualParentRoutePath
130
+ };
131
+ if (node.children !== void 0) {
132
+ const { children, physicalDirectories } = await getRouteNodesRecursive(tsrConfig, root, fullDir, node.children, tokenRegexes, routeNode);
133
+ routeNode.children = children;
134
+ allPhysicalDirectories.push(...physicalDirectories);
135
+ routeNode._fsRouteType = "layout";
136
+ }
137
+ return routeNode;
138
+ }
139
+ case "layout": {
140
+ const { filePath, variableName, fullPath } = getFile(node.file);
141
+ if (node.id !== void 0) node.id = ensureLeadingUnderScore(node.id);
142
+ else {
143
+ const baseName = path.basename(filePath);
144
+ const fileNameWithoutExt = path.parse(baseName).name;
145
+ node.id = ensureLeadingUnderScore(fileNameWithoutExt);
146
+ }
147
+ const lastSegment = node.id;
148
+ const { routePath: escapedSegment, originalRoutePath: originalSegment } = determineInitialRoutePath(removeLeadingSlash(lastSegment));
149
+ const routeNode = {
150
+ fullPath,
151
+ filePath,
152
+ variableName,
153
+ routePath: `${parentRoutePath}${escapedSegment}`,
154
+ originalRoutePath: `${parentRoutePath}${originalSegment}`,
155
+ _fsRouteType: "pathless_layout",
156
+ _virtualParentRoutePath: virtualParentRoutePath
157
+ };
158
+ if (node.children !== void 0) {
159
+ const { children, physicalDirectories } = await getRouteNodesRecursive(tsrConfig, root, fullDir, node.children, tokenRegexes, routeNode);
160
+ routeNode.children = children;
161
+ allPhysicalDirectories.push(...physicalDirectories);
162
+ }
163
+ return routeNode;
164
+ }
165
+ }
166
+ }))).flat(),
167
+ physicalDirectories: allPhysicalDirectories
168
+ };
215
169
  }
216
- export {
217
- getRouteNodes,
218
- getRouteNodesRecursive
219
- };
220
- //# sourceMappingURL=getRouteNodes.js.map
170
+ //#endregion
171
+ export { getRouteNodes };
172
+
173
+ //# sourceMappingURL=getRouteNodes.js.map