@tanstack/router-generator 1.121.0-alpha.5 → 1.121.1

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 (90) hide show
  1. package/dist/cjs/config.cjs +23 -5
  2. package/dist/cjs/config.cjs.map +1 -1
  3. package/dist/cjs/config.d.cts +7 -3
  4. package/dist/cjs/filesystem/physical/getRouteNodes.cjs +5 -3
  5. package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +1 -1
  6. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs +1 -1
  7. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +1 -1
  8. package/dist/cjs/generator.cjs +836 -668
  9. package/dist/cjs/generator.cjs.map +1 -1
  10. package/dist/cjs/generator.d.cts +71 -1
  11. package/dist/cjs/index.cjs +5 -2
  12. package/dist/cjs/index.cjs.map +1 -1
  13. package/dist/cjs/index.d.cts +7 -3
  14. package/dist/cjs/logger.cjs +37 -0
  15. package/dist/cjs/logger.cjs.map +1 -0
  16. package/dist/cjs/logger.d.cts +10 -0
  17. package/dist/cjs/plugin/default-generator-plugin.cjs +88 -0
  18. package/dist/cjs/plugin/default-generator-plugin.cjs.map +1 -0
  19. package/dist/cjs/plugin/default-generator-plugin.d.cts +2 -0
  20. package/dist/cjs/plugin/types.d.cts +46 -0
  21. package/dist/cjs/template.cjs +10 -10
  22. package/dist/cjs/template.cjs.map +1 -1
  23. package/dist/cjs/template.d.cts +2 -2
  24. package/dist/cjs/transform/default-transform-plugin.cjs +95 -0
  25. package/dist/cjs/transform/default-transform-plugin.cjs.map +1 -0
  26. package/dist/cjs/transform/default-transform-plugin.d.cts +2 -0
  27. package/dist/cjs/transform/transform.cjs +351 -0
  28. package/dist/cjs/transform/transform.cjs.map +1 -0
  29. package/dist/cjs/transform/transform.d.cts +4 -0
  30. package/dist/cjs/transform/types.d.cts +43 -0
  31. package/dist/cjs/transform/utils.cjs +36 -0
  32. package/dist/cjs/transform/utils.cjs.map +1 -0
  33. package/dist/cjs/transform/utils.d.cts +2 -0
  34. package/dist/cjs/types.d.cts +22 -0
  35. package/dist/cjs/utils.cjs +262 -40
  36. package/dist/cjs/utils.cjs.map +1 -1
  37. package/dist/cjs/utils.d.cts +82 -9
  38. package/dist/esm/config.d.ts +7 -3
  39. package/dist/esm/config.js +21 -3
  40. package/dist/esm/config.js.map +1 -1
  41. package/dist/esm/filesystem/physical/getRouteNodes.js +3 -1
  42. package/dist/esm/filesystem/physical/getRouteNodes.js.map +1 -1
  43. package/dist/esm/filesystem/virtual/getRouteNodes.js +1 -1
  44. package/dist/esm/filesystem/virtual/getRouteNodes.js.map +1 -1
  45. package/dist/esm/generator.d.ts +71 -1
  46. package/dist/esm/generator.js +827 -658
  47. package/dist/esm/generator.js.map +1 -1
  48. package/dist/esm/index.d.ts +7 -3
  49. package/dist/esm/index.js +7 -4
  50. package/dist/esm/index.js.map +1 -1
  51. package/dist/esm/logger.d.ts +10 -0
  52. package/dist/esm/logger.js +37 -0
  53. package/dist/esm/logger.js.map +1 -0
  54. package/dist/esm/plugin/default-generator-plugin.d.ts +2 -0
  55. package/dist/esm/plugin/default-generator-plugin.js +88 -0
  56. package/dist/esm/plugin/default-generator-plugin.js.map +1 -0
  57. package/dist/esm/plugin/types.d.ts +46 -0
  58. package/dist/esm/template.d.ts +2 -2
  59. package/dist/esm/template.js +10 -10
  60. package/dist/esm/template.js.map +1 -1
  61. package/dist/esm/transform/default-transform-plugin.d.ts +2 -0
  62. package/dist/esm/transform/default-transform-plugin.js +95 -0
  63. package/dist/esm/transform/default-transform-plugin.js.map +1 -0
  64. package/dist/esm/transform/transform.d.ts +4 -0
  65. package/dist/esm/transform/transform.js +351 -0
  66. package/dist/esm/transform/transform.js.map +1 -0
  67. package/dist/esm/transform/types.d.ts +43 -0
  68. package/dist/esm/transform/utils.d.ts +2 -0
  69. package/dist/esm/transform/utils.js +36 -0
  70. package/dist/esm/transform/utils.js.map +1 -0
  71. package/dist/esm/types.d.ts +22 -0
  72. package/dist/esm/utils.d.ts +82 -9
  73. package/dist/esm/utils.js +262 -40
  74. package/dist/esm/utils.js.map +1 -1
  75. package/package.json +9 -10
  76. package/src/config.ts +23 -2
  77. package/src/filesystem/physical/getRouteNodes.ts +2 -1
  78. package/src/filesystem/virtual/getRouteNodes.ts +1 -1
  79. package/src/generator.ts +1123 -945
  80. package/src/index.ts +25 -3
  81. package/src/logger.ts +43 -0
  82. package/src/plugin/default-generator-plugin.ts +96 -0
  83. package/src/plugin/types.ts +51 -0
  84. package/src/template.ts +33 -12
  85. package/src/transform/default-transform-plugin.ts +103 -0
  86. package/src/transform/transform.ts +430 -0
  87. package/src/transform/types.ts +50 -0
  88. package/src/transform/utils.ts +42 -0
  89. package/src/types.ts +25 -0
  90. package/src/utils.ts +385 -36
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'node:path'\nimport * as fs from 'node:fs'\nimport * as fsp from 'node:fs/promises'\nimport {\n format,\n logging,\n multiSortBy,\n removeExt,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n routePathToVariable,\n trimPathLeft,\n writeIfDifferent,\n} from './utils'\nimport { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes'\nimport { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes'\nimport { rootPathId } from './filesystem/physical/rootPathId'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport type { FsRouteType, GetRouteNodesResult, RouteNode } from './types'\nimport type { Config } from './config'\n\n// Maybe import this from `@tanstack/router-core` in the future???\nconst rootRouteId = '__root__'\n\nlet latestTask = 0\nconst routeGroupPatternRegex = /\\(.+\\)/g\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\n\nlet isFirst = false\nlet skipMessage = false\n\ntype RouteSubNode = {\n component?: RouteNode\n errorComponent?: RouteNode\n pendingComponent?: RouteNode\n loader?: RouteNode\n lazy?: RouteNode\n}\n\nexport async function generator(config: Config, root: string) {\n const ROUTE_TEMPLATE = getTargetTemplate(config.target)\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!isFirst) {\n logger.log('♻️ Generating routes...')\n isFirst = true\n } else if (skipMessage) {\n skipMessage = false\n } else {\n logger.log('♻️ Regenerating routes...')\n }\n\n const taskId = latestTask + 1\n latestTask = taskId\n\n const checkLatest = () => {\n if (latestTask !== taskId) {\n skipMessage = true\n return false\n }\n\n return true\n }\n\n const start = Date.now()\n\n const TYPES_DISABLED = config.disableTypes\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(config, root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(config, root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\" file to your routes directory.\\nAdd the file in: \"${config.routesDirectory}/${rootPathId}.${config.disableTypes ? 'js' : 'tsx'}\"`\n }\n throw new Error(errorMessage)\n }\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.indexToken}[.]`)) ? 1 : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${config.routeToken}[.]`)) ? -1 : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: Array<RouteNode> = []\n const routePiecesByPath: Record<string, RouteSubNode> = {}\n\n // Loop over the flat list of routeNodes and\n // build up a tree based on the routeNodes' routePath\n const routeNodes: Array<RouteNode> = []\n\n // the handleRootNode function is not being collapsed into the handleNode function\n // because it requires only a subset of the logic that the handleNode function requires\n // and it's easier to read and maintain this way\n const handleRootNode = async (node?: RouteNode) => {\n if (!node) {\n // currently this is not being handled, but it could be in the future\n // for example to handle a virtual root route\n return\n }\n\n // from here on, we are only handling the root node that's present in the file system\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n if (!routeCode) {\n const _rootTemplate = ROUTE_TEMPLATE.rootRoute\n const replaced = await fillTemplate(config, _rootTemplate.template(), {\n tsrImports: _rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: _rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: _rootTemplate.imports.tsrExportEnd(),\n })\n\n await writeIfDifferent(\n node.fullPath,\n '', // Empty string because the file doesn't exist yet\n replaced,\n {\n beforeWrite: () => {\n logger.log(`🟡 Creating ${node.fullPath}`)\n },\n },\n )\n }\n }\n\n await handleRootNode(rootRouteNode)\n\n const handleNode = async (node: RouteNode) => {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n // Ensure the boilerplate for the route exists, which can be skipped for virtual parent routes and virtual routes\n if (!node.isVirtualParentRoute && !node.isVirtual) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n\n let replaced = routeCode\n\n const tRouteTemplate = ROUTE_TEMPLATE.route\n const tLazyRouteTemplate = ROUTE_TEMPLATE.lazyRoute\n\n if (!routeCode) {\n // Creating a new lazy route file\n if (node._fsRouteType === 'lazy') {\n // Check by default check if the user has a specific lazy route template\n // If not, check if the user has a route template and use that instead\n replaced = await fillTemplate(\n config,\n (config.customScaffolding?.lazyRouteTemplate ||\n config.customScaffolding?.routeTemplate) ??\n tLazyRouteTemplate.template(),\n {\n tsrImports: tLazyRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd(),\n },\n )\n } else if (\n // Creating a new normal route file\n (['layout', 'static'] satisfies Array<FsRouteType>).some(\n (d) => d === node._fsRouteType,\n ) ||\n (\n [\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'loader',\n ] satisfies Array<FsRouteType>\n ).every((d) => d !== node._fsRouteType)\n ) {\n replaced = await fillTemplate(\n config,\n config.customScaffolding?.routeTemplate ??\n tRouteTemplate.template(),\n {\n tsrImports: tRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tRouteTemplate.imports.tsrExportEnd(),\n },\n )\n }\n } else if (config.verboseFileRoutes === false) {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{)(.*)(create(Lazy)?FileRoute)(.*)(\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, p2, ___, ____, p5, p6) => {\n const beforeCreateFileRoute = () => {\n if (!p2) return ''\n\n let trimmed = p2.trim()\n\n if (trimmed.endsWith(',')) {\n trimmed = trimmed.slice(0, -1)\n }\n\n return trimmed\n }\n\n const afterCreateFileRoute = () => {\n if (!p5) return ''\n\n let trimmed = p5.trim()\n\n if (trimmed.startsWith(',')) {\n trimmed = trimmed.slice(1)\n }\n\n return trimmed\n }\n\n const newImport = () => {\n const before = beforeCreateFileRoute()\n const after = afterCreateFileRoute()\n\n if (!before) return after\n\n if (!after) return before\n\n return `${before},${after}`\n }\n\n const middle = newImport()\n\n if (middle === '') return ''\n\n return `${p1} ${newImport()} ${p6}`\n },\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}`,\n )\n } else {\n // Check if the route file has a Route export\n if (\n !routeCode\n .split('\\n')\n .some((line) => line.trim().startsWith('export const Route'))\n ) {\n return\n }\n\n // Update the existing route file\n replaced = routeCode\n // fix wrong ids\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n // fix missing ids\n .replace(\n /((FileRoute)(\\s*)(\\({))/g,\n (_, __, p2, p3, p4) => `${p2}('${escapedRoutePath}')${p3}${p4}`,\n )\n .replace(\n new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gs',\n ),\n (_, p1, __, ___, p4) =>\n `${p1}${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p4}`,\n )\n .replace(\n /create(Lazy)?FileRoute(\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (_, __, p2, ___, p4) =>\n `${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}${p2}${escapedRoutePath}${p4}`,\n )\n\n // check whether the import statement is already present\n const regex = new RegExp(\n `(import\\\\s*\\\\{.*)(create(Lazy)?FileRoute)(.*\\\\}\\\\s*from\\\\s*['\"]@tanstack\\\\/${ROUTE_TEMPLATE.subPkg}['\"])`,\n 'gm',\n )\n if (!replaced.match(regex)) {\n replaced = [\n `import { ${node._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'} } from '@tanstack/${ROUTE_TEMPLATE.subPkg}'`,\n ...replaced.split('\\n'),\n ].join('\\n')\n }\n }\n\n await writeIfDifferent(node.fullPath, routeCode, replaced, {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${node.fullPath}`)\n },\n })\n }\n\n if (\n !node.isVirtual &&\n (\n [\n 'lazy',\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n ] satisfies Array<FsRouteType>\n ).some((d) => d === node._fsRouteType)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node._fsRouteType === 'lazy'\n ? 'lazy'\n : node._fsRouteType === 'loader'\n ? 'loader'\n : node._fsRouteType === 'errorComponent'\n ? 'errorComponent'\n : node._fsRouteType === 'pendingComponent'\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = routeNodes.find((d) => d.routePath === node.routePath)\n\n if (!anchorRoute) {\n await handleNode({\n ...node,\n isVirtual: true,\n _fsRouteType: 'static',\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n await handleNode(parentNode)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n routeTree.push(node)\n }\n\n routeNodes.push(node)\n }\n\n for (const node of preRouteNodes) {\n await handleNode(node)\n }\n\n // This is run against the `preRouteNodes` array since it\n // has the flattened Route nodes and not the full tree\n // Since TSR allows multiple way of defining a route,\n // we need to ensure that a user hasn't defined the\n // same route in multiple ways (i.e. `flat`, `nested`, `virtual`)\n checkRouteFullPathUniqueness(\n preRouteNodes.filter(\n (d) => d.children === undefined && 'lazy' !== d._fsRouteType,\n ),\n config,\n )\n\n function buildRouteTreeConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(node.children, depth + 1)\n\n const childrenDeclaration = TYPES_DISABLED\n ? ''\n : `interface ${route}Children {\n ${node.children.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const children = `const ${route}Children${TYPES_DISABLED ? '' : `: ${route}Children`} = {\n ${node.children.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`\n\n const routeWithChildren = `const ${route}WithChildren = ${route}._addFileChildren(${route}Children)`\n\n return [\n childConfigs,\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter(Boolean).join('\\n\\n')\n }\n\n const routeConfigChildrenText = buildRouteTreeConfig(routeTree)\n\n const sortedRouteNodes = multiSortBy(routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const typeImports = Object.entries({\n // Used for augmentation of regular routes\n CreateFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (d) => isRouteNodeValidForAugmentation(d) && d._fsRouteType !== 'lazy',\n ),\n // Used for augmentation of lazy (`.lazy`) routes\n CreateLazyFileRoute:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.lazy &&\n isRouteNodeValidForAugmentation(node),\n ),\n // Used in the process of augmenting the routes\n FileRoutesByPath:\n config.verboseFileRoutes === false &&\n sortedRouteNodes.some((d) => isRouteNodeValidForAugmentation(d)),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n .sort((a, b) => a.localeCompare(b))\n\n const imports = Object.entries({\n createFileRoute: sortedRouteNodes.some((d) => d.isVirtual),\n lazyFn: sortedRouteNodes.some(\n (node) => routePiecesByPath[node.routePath!]?.loader,\n ),\n lazyRouteComponent: sortedRouteNodes.some(\n (node) =>\n routePiecesByPath[node.routePath!]?.component ||\n routePiecesByPath[node.routePath!]?.errorComponent ||\n routePiecesByPath[node.routePath!]?.pendingComponent,\n ),\n })\n .filter((d) => d[1])\n .map((d) => d[0])\n\n const virtualRouteNodes = sortedRouteNodes.filter((d) => d.isVirtual)\n\n function getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, node.filePath),\n ),\n config.addExtensions,\n ),\n )\n }\n\n const routeImports = [\n ...config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n [\n imports.length\n ? `import { ${imports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n !TYPES_DISABLED && typeImports.length\n ? `import type { ${typeImports.join(', ')} } from '${ROUTE_TEMPLATE.fullPkg}'`\n : '',\n ]\n .filter(Boolean)\n .join('\\n'),\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${getImportPath(rootRouteNode)}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }RouteImport } from './${getImportPath(node)}'`\n }),\n ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }RouteImport = createFileRoute('${node.routePath}')()`\n })\n .join('\\n'),\n '// Create/Update Routes',\n sortedRouteNodes\n .map((node) => {\n const loaderNode = routePiecesByPath[node.routePath!]?.loader\n const componentNode = routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n routePiecesByPath[node.routePath!]?.pendingComponent\n const lazyComponentNode = routePiecesByPath[node.routePath!]?.lazy\n\n return [\n [\n `const ${node.variableName}Route = ${node.variableName}RouteImport.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${TYPES_DISABLED ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, loaderNode.filePath),\n ),\n config.addExtensions,\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(config.routesDirectory, d[1]!.filePath),\n ),\n config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n lazyComponentNode.filePath,\n ),\n ),\n config.addExtensions,\n ),\n )}').then((d) => d.Route))`\n : '',\n ].join(''),\n ].join('\\n\\n')\n })\n .join('\\n\\n'),\n ...(TYPES_DISABLED\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '${ROUTE_TEMPLATE.fullPkg}' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: typeof ${routeNode.variableName}RouteImport\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}RouteImport`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n ...(TYPES_DISABLED\n ? []\n : config.verboseFileRoutes !== false\n ? []\n : [\n `// Add type-safety to the createFileRoute function across the route tree`,\n routeNodes\n .map((routeNode) => {\n function getModuleDeclaration(routeNode?: RouteNode) {\n if (!isRouteNodeValidForAugmentation(routeNode)) {\n return ''\n }\n return `declare module './${getImportPath(routeNode)}' {\n const ${routeNode._fsRouteType === 'lazy' ? 'createLazyFileRoute' : 'createFileRoute'}: ${\n routeNode._fsRouteType === 'lazy'\n ? `CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>}`\n : `CreateFileRoute<\n '${routeNode.routePath}',\n FileRoutesByPath['${routeNode.routePath}']['parentRoute'],\n FileRoutesByPath['${routeNode.routePath}']['id'],\n FileRoutesByPath['${routeNode.routePath}']['path'],\n FileRoutesByPath['${routeNode.routePath}']['fullPath']\n >\n }`\n }`\n }\n return (\n getModuleDeclaration(routeNode) +\n getModuleDeclaration(\n routePiecesByPath[routeNode.routePath!]?.lazy,\n )\n )\n })\n .join('\\n'),\n ]),\n '// Create and export the route tree',\n routeConfigChildrenText,\n ...(TYPES_DISABLED\n ? []\n : [\n `export interface FileRoutesByFullPath {\n ${[...createRouteNodesByFullPath(routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n },\n )}\n}`,\n `export interface FileRoutesByTo {\n ${[...createRouteNodesByTo(routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRoutesById {\n '${rootRouteId}': typeof rootRoute,\n ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`\n })}\n}`,\n `export interface FileRouteTypes {\n fileRoutesByFullPath: FileRoutesByFullPath\n fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\n fileRoutesByTo: FileRoutesByTo\n to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\n id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\n fileRoutesById: FileRoutesById\n}`,\n `export interface RootRouteChildren {\n ${routeTree.map((child) => `${child.variableName}Route: typeof ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n ]),\n `const rootRouteChildren${TYPES_DISABLED ? '' : ': RootRouteChildren'} = {\n ${routeTree.map((child) => `${child.variableName}Route: ${getResolvedRouteNodeVariableName(child)}`).join(',')}\n}`,\n `export const routeTree = rootRoute._addFileChildren(rootRouteChildren)${TYPES_DISABLED ? '' : '._addFileTypes<FileRouteTypes>()'}`,\n ...config.routeTreeFileFooter,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const createRouteManifest = () => {\n const routesManifest = {\n [rootRouteId]: {\n filePath: rootRouteNode.filePath,\n children: routeTree.map((d) => d.routePath),\n },\n ...Object.fromEntries(\n routeNodes.map((d) => {\n const filePathId = d.routePath\n\n return [\n filePathId,\n {\n filePath: d.filePath,\n parent: d.parent?.routePath ? d.parent.routePath : undefined,\n children: d.children?.map((childRoute) => childRoute.routePath),\n },\n ]\n }),\n ),\n }\n\n return JSON.stringify(\n {\n routes: routesManifest,\n },\n null,\n 2,\n )\n }\n\n const includeManifest = ['react', 'solid']\n const routeConfigFileContent =\n config.disableManifestGeneration || !includeManifest.includes(config.target)\n ? routeImports\n : [\n routeImports,\n '\\n',\n '/* ROUTE_MANIFEST_START',\n createRouteManifest(),\n 'ROUTE_MANIFEST_END */',\n ].join('\\n')\n\n if (!checkLatest()) return\n\n const existingRouteTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err) => {\n if (err.code === 'ENOENT') {\n return ''\n }\n\n throw err\n })\n\n if (!checkLatest()) return\n\n // Ensure the directory exists\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n\n if (!checkLatest()) return\n\n // Write the route tree file, if it has changed\n const routeTreeWriteResult = await writeIfDifferent(\n path.resolve(config.generatedRouteTree),\n config.enableRouteTreeFormatting\n ? await format(existingRouteTreeContent, config)\n : existingRouteTreeContent,\n config.enableRouteTreeFormatting\n ? await format(routeConfigFileContent, config)\n : routeConfigFileContent,\n {\n beforeWrite: () => {\n logger.log(`🟡 Updating ${config.generatedRouteTree}`)\n },\n },\n )\n if (routeTreeWriteResult && !checkLatest()) {\n return\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\n// function removeTrailingUnderscores(s?: string) {\n// return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n// }\n\nfunction removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\n}\n\n/**\n * Checks if a given RouteNode is valid for augmenting it with typing based on conditions.\n * Also asserts that the RouteNode is defined.\n *\n * @param routeNode - The RouteNode to check.\n * @returns A boolean indicating whether the RouteNode is defined.\n */\nfunction isRouteNodeValidForAugmentation(\n routeNode?: RouteNode,\n): routeNode is RouteNode {\n if (!routeNode || routeNode.isVirtual) {\n return false\n }\n return true\n}\n\n/**\n * The `node.path` is used as the `id` in the route definition.\n * This function checks if the given node has a parent and if so, it determines the correct path for the given node.\n * @param node - The node to determine the path for.\n * @returns The correct path for the given node.\n */\nfunction determineNodePath(node: RouteNode) {\n return (node.path = node.parent\n ? node.routePath?.replace(node.parent.routePath ?? '', '') || '/'\n : node.routePath)\n}\n\n/**\n * Removes the last segment from a given path. Segments are considered to be separated by a '/'.\n *\n * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.\n * @returns {string} The path with the last segment removed.\n * @example\n * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'\n */\nfunction removeLastSegmentFromPath(routePath: string = '/'): string {\n const segments = routePath.split('/')\n segments.pop() // Remove the last segment\n return segments.join('/')\n}\n\n/**\n * Removes all segments from a given path that start with an underscore ('_').\n *\n * @param {string} routePath - The path from which to remove segments. Defaults to '/'.\n * @returns {string} The path with all underscore-prefixed segments removed.\n * @example\n * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'\n */\nfunction removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nfunction hasParentRoute(\n routes: Array<RouteNode>,\n node: RouteNode,\n routePathToCheck: string | undefined,\n): RouteNode | null {\n if (!routePathToCheck || routePathToCheck === '/') {\n return null\n }\n\n const sortedNodes = multiSortBy(routes, [\n (d) => d.routePath!.length * -1,\n (d) => d.variableName,\n ]).filter((d) => d.routePath !== `/${rootPathId}`)\n\n for (const route of sortedNodes) {\n if (route.routePath === '/') continue\n\n if (\n routePathToCheck.startsWith(`${route.routePath}/`) &&\n route.routePath !== routePathToCheck\n ) {\n return route\n }\n }\n\n const segments = routePathToCheck.split('/')\n segments.pop() // Remove the last segment\n const parentRoutePath = segments.join('/')\n\n return hasParentRoute(routes, node, parentRoutePath)\n}\n\n/**\n * Gets the final variable name for a route\n */\nconst getResolvedRouteNodeVariableName = (routeNode: RouteNode): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}RouteWithChildren`\n : `${routeNode.variableName}Route`\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nconst createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nconst createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nconst createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers the full path for use by TS\n */\nconst inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Infers the path for use by TS\n */\nconst inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers to path\n */\nconst inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nconst dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nfunction checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n throw new Error(errorMessage)\n }\n}\n"],"names":["virtualGetRouteNodes","physicalGetRouteNodes","children","routeNode"],"mappings":";;;;;;;;AAuBA,MAAM,cAAc;AAEpB,IAAI,aAAa;AACjB,MAAM,yBAAyB;AAC/B,MAAM,uCAAuC;AAE7C,IAAI,UAAU;AACd,IAAI,cAAc;AAUI,eAAA,UAAU,QAAgB,MAAc;AACtD,QAAA,iBAAiB,kBAAkB,OAAO,MAAM;AACtD,QAAM,SAAS,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,SAAO,IAAI,EAAE;AAEb,MAAI,CAAC,SAAS;AACZ,WAAO,IAAI,0BAA0B;AAC3B,cAAA;AAAA,aACD,aAAa;AACR,kBAAA;AAAA,EAAA,OACT;AACL,WAAO,IAAI,4BAA4B;AAAA,EAAA;AAGzC,QAAM,SAAS,aAAa;AACf,eAAA;AAEb,QAAM,cAAc,MAAM;AACxB,QAAI,eAAe,QAAQ;AACX,oBAAA;AACP,aAAA;AAAA,IAAA;AAGF,WAAA;AAAA,EACT;AAEM,QAAA,QAAQ,KAAK,IAAI;AAEvB,QAAM,iBAAiB,OAAO;AA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C,UAAU;;AAC1B,SAAA,WAAM,aAAN,mBAAgB,KAAK,CAAC,UAAU,MAAM,gBAAgB,KAAa,QAAA;AAChE,WAAA;AAAA,EAAA,CACR;AACH;AAEA,SAAS,YAAsB,QAAyB,KAAqB;AAG3E,QAAM,OAAO,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC;AAC/B,QAAA,aAAa,IAAI,IAAI,IAAI;AAC3B,MAAA,KAAK,WAAW,WAAW,MAAM;AAC7B,UAAA,gBAAgB,KAAK,OAAO,CAAC,GAAG,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;AACjE,UAAM,mBAAmB,OAAO;AAAA,MAAO,CAAC,MACtC,cAAc,SAAS,EAAE,GAAG,CAAC;AAAA,IAC/B;AACO,WAAA;AAAA,EAAA;AAEF,SAAA;AACT;AAEA,SAAS,6BACP,SACA,QACA;AACA,QAAM,SAAS,QAAQ,IAAI,CAAC,MAAM;AAC1B,UAAA,mBAAmB,cAAc,CAAC;AACjC,WAAA,EAAE,GAAG,GAAG,iBAAiB;AAAA,EAAA,CACjC;AAEK,QAAA,mBAAmB,YAAY,QAAQ,kBAAkB;AAE/D,MAAI,qBAAqB,QAAW;AAClC,UAAM,eAAe,qEAAqE,iBAAiB,SAAS,IAAI,MAAM,EAAE,KAAK,iBAClI,IAAI,CAAC,MAAM,IAAI,EAAE,gBAAgB,GAAG,EACpC,KAAK,IAAI,CAAC;AAAA;AAAA;AAAA,GAEO,iBAAiB,IAAI,CAAC,MAAM,KAAK,QAAQ,OAAO,iBAAiB,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA;AACvG,UAAA,IAAI,MAAM,YAAY;AAAA,EAAA;AAEhC;"}
1
+ {"version":3,"file":"generator.js","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'node:path'\nimport * as fsp from 'node:fs/promises'\nimport { mkdtempSync } from 'node:fs'\nimport crypto from 'node:crypto'\nimport { deepEqual, rootRouteId } from '@tanstack/router-core'\nimport { logging } from './logger'\nimport { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes'\nimport { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes'\nimport { rootPathId } from './filesystem/physical/rootPathId'\nimport {\n buildFileRoutesByPathInterface,\n buildImportString,\n buildRouteTreeConfig,\n checkFileExists,\n createRouteNodesByFullPath,\n createRouteNodesById,\n createRouteNodesByTo,\n determineNodePath,\n findParent,\n format,\n getResolvedRouteNodeVariableName,\n hasParentRoute,\n isRouteNodeValidForAugmentation,\n lowerCaseFirstChar,\n mergeImportDeclarations,\n multiSortBy,\n removeExt,\n removeGroups,\n removeLastSegmentFromPath,\n removeLayoutSegments,\n removeUnderscores,\n replaceBackslash,\n resetRegex,\n routePathToVariable,\n trimPathLeft,\n} from './utils'\nimport { fillTemplate, getTargetTemplate } from './template'\nimport { transform } from './transform/transform'\nimport { defaultGeneratorPlugin } from './plugin/default-generator-plugin'\nimport type {\n GeneratorPlugin,\n GeneratorPluginWithTransform,\n} from './plugin/types'\nimport type { TargetTemplate } from './template'\nimport type {\n FsRouteType,\n GetRouteNodesResult,\n HandleNodeAccumulator,\n ImportDeclaration,\n RouteNode,\n} from './types'\nimport type { Config } from './config'\nimport type { Logger } from './logger'\nimport type { TransformPlugin } from './transform/types'\n\ninterface fs {\n stat: (filePath: string) => Promise<{ mtimeMs: bigint }>\n mkdtempSync: (prefix: string) => string\n rename: (oldPath: string, newPath: string) => Promise<void>\n writeFile: (filePath: string, content: string) => Promise<void>\n readFile: (\n filePath: string,\n ) => Promise<\n { stat: { mtimeMs: bigint }; fileContent: string } | 'file-not-existing'\n >\n}\n\nconst DefaultFileSystem: fs = {\n stat: (filePath) => fsp.stat(filePath, { bigint: true }),\n mkdtempSync: mkdtempSync,\n rename: (oldPath, newPath) => fsp.rename(oldPath, newPath),\n writeFile: (filePath, content) => fsp.writeFile(filePath, content),\n readFile: async (filePath: string) => {\n try {\n const fileHandle = await fsp.open(filePath, 'r')\n const stat = await fileHandle.stat({ bigint: true })\n const fileContent = (await fileHandle.readFile()).toString()\n await fileHandle.close()\n return { stat, fileContent }\n } catch (e: any) {\n if ('code' in e) {\n if (e.code === 'ENOENT') {\n return 'file-not-existing'\n }\n }\n throw e\n }\n },\n}\n\ninterface Rerun {\n rerun: true\n msg?: string\n event: GeneratorEvent\n}\nfunction rerun(opts: { msg?: string; event?: GeneratorEvent }): Rerun {\n const { event, ...rest } = opts\n return { rerun: true, event: event ?? { type: 'rerun' }, ...rest }\n}\n\nfunction isRerun(result: unknown): result is Rerun {\n return (\n typeof result === 'object' &&\n result !== null &&\n 'rerun' in result &&\n result.rerun === true\n )\n}\n\nexport type FileEventType = 'create' | 'update' | 'delete'\nexport type FileEvent = {\n type: FileEventType\n path: string\n}\nexport type GeneratorEvent = FileEvent | { type: 'rerun' }\n\ntype FileCacheChange<TCacheEntry extends GeneratorCacheEntry> =\n | {\n result: false\n cacheEntry: TCacheEntry\n }\n | { result: true; mtimeMs: bigint; cacheEntry: TCacheEntry }\n | {\n result: 'file-not-in-cache'\n }\n | {\n result: 'cannot-stat-file'\n }\n\ninterface GeneratorCacheEntry {\n mtimeMs: bigint\n fileContent: string\n}\n\ninterface RouteNodeCacheEntry extends GeneratorCacheEntry {\n exports: Array<string>\n}\n\ntype GeneratorRouteNodeCache = Map</** filePath **/ string, RouteNodeCacheEntry>\n\nexport class Generator {\n /**\n * why do we have two caches for the route files?\n * During processing, we READ from the cache and WRITE to the shadow cache.\n *\n * After a route file is processed, we write to the shadow cache.\n * If during processing we bail out and re-run, we don't lose this modification\n * but still can track whether the file contributed changes and thus the route tree file needs to be regenerated.\n * After all files are processed, we swap the shadow cache with the main cache and initialize a new shadow cache.\n * That way we also ensure deleted/renamed files don't stay in the cache forever.\n */\n private routeNodeCache: GeneratorRouteNodeCache = new Map()\n private routeNodeShadowCache: GeneratorRouteNodeCache = new Map()\n\n private routeTreeFileCache: GeneratorCacheEntry | undefined\n\n public config: Config\n public targetTemplate: TargetTemplate\n\n private root: string\n private routesDirectoryPath: string\n private tmpDir: string\n private fs: fs\n private logger: Logger\n private generatedRouteTreePath: string\n private runPromise: Promise<void> | undefined\n private fileEventQueue: Array<GeneratorEvent> = []\n private plugins: Array<GeneratorPlugin> = [defaultGeneratorPlugin()]\n private pluginsWithTransform: Array<GeneratorPluginWithTransform> = []\n // this is just a cache for the transform plugins since we need them for each route file that is to be processed\n private transformPlugins: Array<TransformPlugin> = []\n private routeGroupPatternRegex = /\\(.+\\)/g\n\n constructor(opts: { config: Config; root: string; fs?: fs }) {\n this.config = opts.config\n this.logger = logging({ disabled: this.config.disableLogging })\n this.root = opts.root\n this.fs = opts.fs || DefaultFileSystem\n this.tmpDir = this.fs.mkdtempSync(\n path.join(this.config.tmpDir, 'router-generator-'),\n )\n this.generatedRouteTreePath = path.resolve(this.config.generatedRouteTree)\n this.targetTemplate = getTargetTemplate(this.config)\n\n this.routesDirectoryPath = this.getRoutesDirectoryPath()\n this.plugins.push(...(opts.config.plugins || []))\n this.plugins.forEach((plugin) => {\n if ('transformPlugin' in plugin) {\n if (this.pluginsWithTransform.find((p) => p.name === plugin.name)) {\n throw new Error(\n `Plugin with name \"${plugin.name}\" is already registered for export ${plugin.transformPlugin.exportName}!`,\n )\n }\n this.pluginsWithTransform.push(plugin)\n this.transformPlugins.push(plugin.transformPlugin)\n }\n })\n }\n\n private getRoutesDirectoryPath() {\n return path.isAbsolute(this.config.routesDirectory)\n ? this.config.routesDirectory\n : path.resolve(this.root, this.config.routesDirectory)\n }\n\n public async run(event?: GeneratorEvent): Promise<void> {\n // we are only interested in FileEvents that affect either the generated route tree or files inside the routes folder\n if (event && event.type !== 'rerun') {\n if (\n !(\n event.path === this.generatedRouteTreePath ||\n event.path.startsWith(this.routesDirectoryPath)\n )\n ) {\n return\n }\n }\n this.fileEventQueue.push(event ?? { type: 'rerun' })\n // only allow a single run at a time\n if (this.runPromise) {\n return this.runPromise\n }\n\n this.runPromise = (async () => {\n do {\n // synchronously copy and clear the queue since we are going to iterate asynchronously over it\n // and while we do so, a new event could be put into the queue\n const tempQueue = this.fileEventQueue\n this.fileEventQueue = []\n // if we only have 'update' events in the queue\n // and we already have the affected files' latest state in our cache, we can exit early\n const remainingEvents = (\n await Promise.all(\n tempQueue.map(async (e) => {\n if (e.type === 'update') {\n let cacheEntry\n if (e.path === this.generatedRouteTreePath) {\n cacheEntry = this.routeTreeFileCache\n } else {\n // we only check the routeNodeCache here\n // if the file's state is only up-to-date in the shadow cache we need to re-run\n cacheEntry = this.routeNodeCache.get(e.path)\n }\n const change = await this.didFileChangeComparedToCache(\n { path: e.path },\n cacheEntry,\n )\n if (change.result === false) {\n return null\n }\n }\n return e\n }),\n )\n ).filter((e) => e !== null)\n\n if (remainingEvents.length === 0) {\n break\n }\n\n try {\n const start = performance.now()\n await this.generatorInternal()\n const end = performance.now()\n this.logger.info(\n `Generated route tree in ${Math.round(end - start)}ms`,\n )\n } catch (err) {\n const errArray = !Array.isArray(err) ? [err] : err\n\n const recoverableErrors = errArray.filter((e) => isRerun(e))\n if (recoverableErrors.length === errArray.length) {\n this.fileEventQueue.push(...recoverableErrors.map((e) => e.event))\n recoverableErrors.forEach((e) => {\n if (e.msg) {\n this.logger.info(e.msg)\n }\n })\n } else {\n const unrecoverableErrors = errArray.filter((e) => !isRerun(e))\n this.runPromise = undefined\n throw new Error(\n unrecoverableErrors.map((e) => (e as Error).message).join(),\n )\n }\n }\n } while (this.fileEventQueue.length)\n this.runPromise = undefined\n })()\n return this.runPromise\n }\n\n private async generatorInternal() {\n let writeRouteTreeFile: boolean | 'force' = false\n\n let getRouteNodesResult: GetRouteNodesResult\n\n if (this.config.virtualRouteConfig) {\n getRouteNodesResult = await virtualGetRouteNodes(this.config, this.root)\n } else {\n getRouteNodesResult = await physicalGetRouteNodes(this.config, this.root)\n }\n\n const { rootRouteNode, routeNodes: beforeRouteNodes } = getRouteNodesResult\n if (rootRouteNode === undefined) {\n let errorMessage = `rootRouteNode must not be undefined. Make sure you've added your root route into the route-tree.`\n if (!this.config.virtualRouteConfig) {\n errorMessage += `\\nMake sure that you add a \"${rootPathId}.${this.config.disableTypes ? 'js' : 'tsx'}\" file to your routes directory.\\nAdd the file in: \"${this.config.routesDirectory}/${rootPathId}.${this.config.disableTypes ? 'js' : 'tsx'}\"`\n }\n throw new Error(errorMessage)\n }\n\n writeRouteTreeFile = await this.handleRootNode(rootRouteNode)\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) =>\n d.filePath.match(new RegExp(`[./]${this.config.indexToken}[.]`))\n ? 1\n : -1,\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) =>\n d.filePath.match(new RegExp(`[./]${this.config.routeToken}[.]`))\n ? -1\n : 1,\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeFileAllResult = await Promise.allSettled(\n preRouteNodes\n // only process routes that are backed by an actual file\n .filter((n) => !n.isVirtualParentRoute && !n.isVirtual)\n .map((n) => this.processRouteNodeFile(n)),\n )\n\n const rejections = routeFileAllResult.filter(\n (result) => result.status === 'rejected',\n )\n if (rejections.length > 0) {\n throw rejections.map((e) => e.reason)\n }\n\n const routeFileResult = routeFileAllResult.flatMap((result) => {\n if (result.status === 'fulfilled' && result.value !== null) {\n return result.value\n }\n return []\n })\n\n routeFileResult.forEach((result) => {\n if (!result.node.exports?.length) {\n this.logger.warn(\n `Route file \"${result.cacheEntry.fileContent}\" does not export any route piece. This is likely a mistake.`,\n )\n }\n })\n if (routeFileResult.find((r) => r.shouldWriteTree)) {\n writeRouteTreeFile = true\n }\n\n // this is the first time the generator runs, so read in the route tree file if it exists yet\n if (!this.routeTreeFileCache) {\n const routeTreeFile = await this.fs.readFile(this.generatedRouteTreePath)\n if (routeTreeFile !== 'file-not-existing') {\n this.routeTreeFileCache = {\n fileContent: routeTreeFile.fileContent,\n mtimeMs: routeTreeFile.stat.mtimeMs,\n }\n }\n writeRouteTreeFile = true\n } else {\n const routeTreeFileChange = await this.didFileChangeComparedToCache(\n { path: this.generatedRouteTreePath },\n this.routeTreeFileCache,\n )\n if (routeTreeFileChange.result !== false) {\n writeRouteTreeFile = 'force'\n if (routeTreeFileChange.result === true) {\n const routeTreeFile = await this.fs.readFile(\n this.generatedRouteTreePath,\n )\n if (routeTreeFile !== 'file-not-existing') {\n this.routeTreeFileCache = {\n fileContent: routeTreeFile.fileContent,\n mtimeMs: routeTreeFile.stat.mtimeMs,\n }\n }\n }\n }\n }\n\n if (!writeRouteTreeFile) {\n // only needs to be done if no other changes have been detected yet\n // compare shadowCache and cache to identify deleted routes\n for (const fullPath of this.routeNodeCache.keys()) {\n if (!this.routeNodeShadowCache.has(fullPath)) {\n writeRouteTreeFile = true\n break\n }\n }\n }\n\n if (!writeRouteTreeFile) {\n return\n }\n\n let routeTreeContent = this.buildRouteTreeFileContent(\n rootRouteNode,\n preRouteNodes,\n routeFileResult,\n )\n routeTreeContent = this.config.enableRouteTreeFormatting\n ? await format(routeTreeContent, this.config)\n : routeTreeContent\n\n let newMtimeMs: bigint | undefined\n if (this.routeTreeFileCache) {\n if (\n writeRouteTreeFile !== 'force' &&\n this.routeTreeFileCache.fileContent === routeTreeContent\n ) {\n // existing route tree file is already up-to-date, don't write it\n // we should only get here in the initial run when the route cache is not filled yet\n } else {\n const newRouteTreeFileStat = await this.safeFileWrite({\n filePath: this.generatedRouteTreePath,\n newContent: routeTreeContent,\n strategy: {\n type: 'mtime',\n expectedMtimeMs: this.routeTreeFileCache.mtimeMs,\n },\n })\n newMtimeMs = newRouteTreeFileStat.mtimeMs\n }\n } else {\n const newRouteTreeFileStat = await this.safeFileWrite({\n filePath: this.generatedRouteTreePath,\n newContent: routeTreeContent,\n strategy: {\n type: 'new-file',\n },\n })\n newMtimeMs = newRouteTreeFileStat.mtimeMs\n }\n\n if (newMtimeMs !== undefined) {\n this.routeTreeFileCache = {\n fileContent: routeTreeContent,\n mtimeMs: newMtimeMs,\n }\n }\n\n // now that we have finished this run, we can finally swap the caches\n this.routeNodeCache = this.routeNodeShadowCache\n this.routeNodeShadowCache = new Map()\n }\n\n private buildRouteTreeFileContent(\n rootRouteNode: RouteNode,\n preRouteNodes: Array<RouteNode>,\n routeFileResult: Array<{\n cacheEntry: RouteNodeCacheEntry\n node: RouteNode\n }>,\n ) {\n const getImportForRouteNode = (node: RouteNode, exportName: string) => {\n if (node.exports?.includes(exportName)) {\n return {\n source: `./${this.getImportPath(node)}`,\n specifiers: [\n {\n imported: exportName,\n local: `${node.variableName}${exportName}Import`,\n },\n ],\n } satisfies ImportDeclaration\n }\n return undefined\n }\n\n const buildRouteTreeForExport = (plugin: GeneratorPluginWithTransform) => {\n const exportName = plugin.transformPlugin.exportName\n const acc: HandleNodeAccumulator = {\n routeTree: [],\n routeNodes: [],\n routePiecesByPath: {},\n }\n for (const node of preRouteNodes) {\n if (node.exports?.includes(plugin.transformPlugin.exportName)) {\n this.handleNode(node, acc)\n }\n }\n\n const sortedRouteNodes = multiSortBy(acc.routeNodes, [\n (d) => (d.routePath?.includes(`/${rootPathId}`) ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.routePath?.endsWith(this.config.indexToken) ? -1 : 1),\n (d) => d,\n ])\n\n const pluginConfig = plugin.config({\n generator: this,\n rootRouteNode,\n sortedRouteNodes,\n })\n\n const routeImports = sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .flatMap((node) => getImportForRouteNode(node, exportName) ?? [])\n\n const hasMatchingRouteFiles =\n acc.routeNodes.length > 0 || rootRouteNode.exports?.includes(exportName)\n\n const virtualRouteNodes = sortedRouteNodes\n .filter((d) => d.isVirtual)\n .map((node) => {\n return `const ${\n node.variableName\n }${exportName}Import = ${plugin.createVirtualRouteCode({ node })}`\n })\n if (\n !rootRouteNode.exports?.includes(exportName) &&\n pluginConfig.virtualRootRoute\n ) {\n virtualRouteNodes.unshift(\n `const ${rootRouteNode.variableName}${exportName}Import = ${plugin.createRootRouteCode()}`,\n )\n }\n\n const imports = plugin.imports({\n sortedRouteNodes,\n acc,\n generator: this,\n rootRouteNode,\n })\n\n const routeTreeConfig = buildRouteTreeConfig(\n acc.routeTree,\n exportName,\n this.config.disableTypes,\n )\n\n const createUpdateRoutes = sortedRouteNodes.map((node) => {\n const loaderNode = acc.routePiecesByPath[node.routePath!]?.loader\n const componentNode = acc.routePiecesByPath[node.routePath!]?.component\n const errorComponentNode =\n acc.routePiecesByPath[node.routePath!]?.errorComponent\n const pendingComponentNode =\n acc.routePiecesByPath[node.routePath!]?.pendingComponent\n const lazyComponentNode = acc.routePiecesByPath[node.routePath!]?.lazy\n\n return [\n [\n `const ${node.variableName}${exportName} = ${node.variableName}${exportName}Import.update({\n ${[\n `id: '${node.path}'`,\n !node.isNonPath ? `path: '${node.cleanedPath}'` : undefined,\n `getParentRoute: () => ${findParent(node, exportName)}`,\n ]\n .filter(Boolean)\n .join(',')}\n }${this.config.disableTypes ? '' : 'as any'})`,\n loaderNode\n ? `.updateLoader({ loader: lazyFn(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(this.config.generatedRouteTree),\n path.resolve(\n this.config.routesDirectory,\n loaderNode.filePath,\n ),\n ),\n this.config.addExtensions,\n ),\n )}'), 'loader') })`\n : '',\n componentNode || errorComponentNode || pendingComponentNode\n ? `.update({\n ${(\n [\n ['component', componentNode],\n ['errorComponent', errorComponentNode],\n ['pendingComponent', pendingComponentNode],\n ] as const\n )\n .filter((d) => d[1])\n .map((d) => {\n return `${\n d[0]\n }: lazyRouteComponent(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(this.config.generatedRouteTree),\n path.resolve(\n this.config.routesDirectory,\n d[1]!.filePath,\n ),\n ),\n this.config.addExtensions,\n ),\n )}'), '${d[0]}')`\n })\n .join('\\n,')}\n })`\n : '',\n lazyComponentNode\n ? `.lazy(() => import('./${replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(this.config.generatedRouteTree),\n path.resolve(\n this.config.routesDirectory,\n lazyComponentNode.filePath,\n ),\n ),\n this.config.addExtensions,\n ),\n )}').then((d) => d.${exportName}))`\n : '',\n ].join(''),\n ].join('\\n\\n')\n })\n\n let fileRoutesByPathInterfacePerPlugin = ''\n let fileRoutesByFullPathPerPlugin = ''\n\n if (!this.config.disableTypes && hasMatchingRouteFiles) {\n fileRoutesByFullPathPerPlugin = [\n `export interface File${exportName}sByFullPath {\n${[...createRouteNodesByFullPath(acc.routeNodes).entries()].map(\n ([fullPath, routeNode]) => {\n return `'${fullPath}': typeof ${getResolvedRouteNodeVariableName(routeNode, exportName)}`\n },\n)}\n}`,\n `export interface File${exportName}sByTo {\n${[...createRouteNodesByTo(acc.routeNodes).entries()].map(([to, routeNode]) => {\n return `'${to}': typeof ${getResolvedRouteNodeVariableName(routeNode, exportName)}`\n})}\n}`,\n `export interface File${exportName}sById {\n'${rootRouteId}': typeof root${exportName}Import,\n${[...createRouteNodesById(acc.routeNodes).entries()].map(([id, routeNode]) => {\n return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode, exportName)}`\n})}\n}`,\n `export interface File${exportName}Types {\nfile${exportName}sByFullPath: File${exportName}sByFullPath\nfullPaths: ${acc.routeNodes.length > 0 ? [...createRouteNodesByFullPath(acc.routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join('|') : 'never'}\nfile${exportName}sByTo: File${exportName}sByTo\nto: ${acc.routeNodes.length > 0 ? [...createRouteNodesByTo(acc.routeNodes).keys()].map((to) => `'${to}'`).join('|') : 'never'}\nid: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(acc.routeNodes).keys()].map((id) => `'${id}'`)].join('|')}\nfile${exportName}sById: File${exportName}sById\n}`,\n `export interface Root${exportName}Children {\n${acc.routeTree.map((child) => `${child.variableName}${exportName}: typeof ${getResolvedRouteNodeVariableName(child, exportName)}`).join(',')}\n}`,\n ].join('\\n')\n\n fileRoutesByPathInterfacePerPlugin = buildFileRoutesByPathInterface({\n ...plugin.moduleAugmentation({ generator: this }),\n routeNodes:\n this.config.verboseFileRoutes !== false\n ? sortedRouteNodes\n : [\n ...routeFileResult.map(({ node }) => node),\n ...sortedRouteNodes.filter((d) => d.isVirtual),\n ],\n exportName,\n })\n }\n\n let routeTree = ''\n if (hasMatchingRouteFiles) {\n routeTree = [\n `const root${exportName}Children${this.config.disableTypes ? '' : `: Root${exportName}Children`} = {\n ${acc.routeTree\n .map(\n (child) =>\n `${child.variableName}${exportName}: ${getResolvedRouteNodeVariableName(child, exportName)}`,\n )\n .join(',')}\n}`,\n `export const ${lowerCaseFirstChar(exportName)}Tree = root${exportName}Import._addFileChildren(root${exportName}Children)${this.config.disableTypes ? '' : `._addFileTypes<File${exportName}Types>()`}`,\n ].join('\\n')\n }\n\n return {\n routeImports,\n sortedRouteNodes,\n acc,\n virtualRouteNodes,\n routeTreeConfig,\n routeTree,\n imports,\n createUpdateRoutes,\n fileRoutesByFullPathPerPlugin,\n fileRoutesByPathInterfacePerPlugin,\n }\n }\n\n const routeTrees = this.pluginsWithTransform.map((plugin) => ({\n exportName: plugin.transformPlugin.exportName,\n ...buildRouteTreeForExport(plugin),\n }))\n\n this.plugins.map((plugin) => {\n return plugin.onRouteTreesChanged?.({\n routeTrees,\n rootRouteNode,\n generator: this,\n })\n })\n\n let mergedImports = mergeImportDeclarations(\n routeTrees.flatMap((d) => d.imports),\n )\n if (this.config.disableTypes) {\n mergedImports = mergedImports.filter((d) => d.importKind !== 'type')\n }\n\n const importStatements = mergedImports.map(buildImportString)\n\n let moduleAugmentation = ''\n if (this.config.verboseFileRoutes === false && !this.config.disableTypes) {\n moduleAugmentation = routeFileResult\n .map(({ node }) => {\n const getModuleDeclaration = (routeNode?: RouteNode) => {\n if (!isRouteNodeValidForAugmentation(routeNode)) {\n return ''\n }\n const moduleAugmentation = this.pluginsWithTransform\n .map((plugin) => {\n return plugin.routeModuleAugmentation({\n routeNode,\n })\n })\n .filter(Boolean)\n .join('\\n')\n\n return `declare module './${this.getImportPath(routeNode)}' {\n ${moduleAugmentation}\n }`\n }\n return getModuleDeclaration(node)\n })\n .join('\\n')\n }\n\n const routeImports = routeTrees.flatMap((t) => t.routeImports)\n const rootRouteImports = this.pluginsWithTransform.flatMap(\n (p) =>\n getImportForRouteNode(rootRouteNode, p.transformPlugin.exportName) ??\n [],\n )\n if (rootRouteImports.length > 0) {\n routeImports.unshift(...rootRouteImports)\n }\n const routeTreeContent = [\n ...this.config.routeTreeFileHeader,\n `// This file was automatically generated by TanStack Router.\n// You should NOT make any changes in this file as it will be overwritten.\n// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,\n [...importStatements].join('\\n'),\n mergeImportDeclarations(routeImports).map(buildImportString).join('\\n'),\n routeTrees.flatMap((t) => t.virtualRouteNodes).join('\\n'),\n routeTrees.flatMap((t) => t.createUpdateRoutes).join('\\n'),\n\n routeTrees.map((t) => t.fileRoutesByFullPathPerPlugin).join('\\n'),\n routeTrees.map((t) => t.fileRoutesByPathInterfacePerPlugin).join('\\n'),\n moduleAugmentation,\n routeTrees.flatMap((t) => t.routeTreeConfig).join('\\n'),\n routeTrees.map((t) => t.routeTree).join('\\n'),\n ...this.config.routeTreeFileFooter,\n ]\n .filter(Boolean)\n .join('\\n\\n')\n return routeTreeContent\n }\n\n private getImportPath(node: RouteNode) {\n return replaceBackslash(\n removeExt(\n path.relative(\n path.dirname(this.config.generatedRouteTree),\n path.resolve(this.config.routesDirectory, node.filePath),\n ),\n this.config.addExtensions,\n ),\n )\n }\n\n private async processRouteNodeFile(node: RouteNode): Promise<{\n shouldWriteTree: boolean\n cacheEntry: RouteNodeCacheEntry\n node: RouteNode\n } | null> {\n const result = await this.isRouteFileCacheFresh(node)\n\n if (result.status === 'fresh') {\n node.exports = result.cacheEntry.exports\n return {\n node,\n shouldWriteTree: result.exportsChanged,\n cacheEntry: result.cacheEntry,\n }\n }\n\n const existingRouteFile = await this.fs.readFile(node.fullPath)\n if (existingRouteFile === 'file-not-existing') {\n throw new Error(`⚠️ File ${node.fullPath} does not exist`)\n }\n\n const updatedCacheEntry: RouteNodeCacheEntry = {\n fileContent: existingRouteFile.fileContent,\n mtimeMs: existingRouteFile.stat.mtimeMs,\n exports: [],\n }\n\n const escapedRoutePath = node.routePath?.replaceAll('$', '$$') ?? ''\n\n let shouldWriteRouteFile = false\n // now we need to either scaffold the file or transform it\n if (!existingRouteFile.fileContent) {\n shouldWriteRouteFile = true\n // Creating a new lazy route file\n if (node._fsRouteType === 'lazy') {\n const tLazyRouteTemplate = this.targetTemplate.lazyRoute\n // Check by default check if the user has a specific lazy route template\n // If not, check if the user has a route template and use that instead\n updatedCacheEntry.fileContent = await fillTemplate(\n this.config,\n (this.config.customScaffolding?.lazyRouteTemplate ||\n this.config.customScaffolding?.routeTemplate) ??\n tLazyRouteTemplate.template(),\n {\n tsrImports: tLazyRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd(),\n },\n )\n updatedCacheEntry.exports = ['Route']\n } else if (\n // Creating a new normal route file\n (['layout', 'static'] satisfies Array<FsRouteType>).some(\n (d) => d === node._fsRouteType,\n ) ||\n (\n [\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'loader',\n ] satisfies Array<FsRouteType>\n ).every((d) => d !== node._fsRouteType)\n ) {\n const tRouteTemplate = this.targetTemplate.route\n updatedCacheEntry.fileContent = await fillTemplate(\n this.config,\n this.config.customScaffolding?.routeTemplate ??\n tRouteTemplate.template(),\n {\n tsrImports: tRouteTemplate.imports.tsrImports(),\n tsrPath: escapedRoutePath.replaceAll(/\\{(.+)\\}/gm, '$1'),\n tsrExportStart:\n tRouteTemplate.imports.tsrExportStart(escapedRoutePath),\n tsrExportEnd: tRouteTemplate.imports.tsrExportEnd(),\n },\n )\n updatedCacheEntry.exports = ['Route']\n } else {\n return null\n }\n } else {\n // transform the file\n const transformResult = await transform({\n source: updatedCacheEntry.fileContent,\n ctx: {\n target: this.config.target,\n routeId: escapedRoutePath,\n lazy: node._fsRouteType === 'lazy',\n verboseFileRoutes: !(this.config.verboseFileRoutes === false),\n },\n plugins: this.transformPlugins,\n })\n\n if (transformResult.result === 'error') {\n throw new Error(\n `Error transforming route file ${node.fullPath}: ${transformResult.error}`,\n )\n }\n updatedCacheEntry.exports = transformResult.exports\n if (transformResult.result === 'modified') {\n updatedCacheEntry.fileContent = transformResult.output\n shouldWriteRouteFile = true\n }\n }\n\n // file was changed\n if (shouldWriteRouteFile) {\n const stats = await this.safeFileWrite({\n filePath: node.fullPath,\n newContent: updatedCacheEntry.fileContent,\n strategy: {\n type: 'mtime',\n expectedMtimeMs: updatedCacheEntry.mtimeMs,\n },\n })\n updatedCacheEntry.mtimeMs = stats.mtimeMs\n }\n\n this.routeNodeShadowCache.set(node.fullPath, updatedCacheEntry)\n node.exports = updatedCacheEntry.exports\n const shouldWriteTree = !deepEqual(\n result.cacheEntry?.exports,\n updatedCacheEntry.exports,\n )\n return {\n node,\n shouldWriteTree,\n cacheEntry: updatedCacheEntry,\n }\n }\n\n private async didRouteFileChangeComparedToCache(\n file: {\n path: string\n mtimeMs?: bigint\n },\n cache: 'routeNodeCache' | 'routeNodeShadowCache',\n ): Promise<FileCacheChange<RouteNodeCacheEntry>> {\n const cacheEntry = this[cache].get(file.path)\n return this.didFileChangeComparedToCache(file, cacheEntry)\n }\n\n private async didFileChangeComparedToCache<\n TCacheEntry extends GeneratorCacheEntry,\n >(\n file: {\n path: string\n mtimeMs?: bigint\n },\n cacheEntry: TCacheEntry | undefined,\n ): Promise<FileCacheChange<TCacheEntry>> {\n // for now we rely on the modification time of the file\n // to determine if the file has changed\n // we could also compare the file content but this would be slower as we would have to read the file\n\n if (!cacheEntry) {\n return { result: 'file-not-in-cache' }\n }\n let mtimeMs = file.mtimeMs\n\n if (mtimeMs === undefined) {\n try {\n const currentStat = await this.fs.stat(file.path)\n mtimeMs = currentStat.mtimeMs\n } catch {\n return { result: 'cannot-stat-file' }\n }\n }\n return { result: mtimeMs !== cacheEntry.mtimeMs, mtimeMs, cacheEntry }\n }\n\n private async safeFileWrite(opts: {\n filePath: string\n newContent: string\n strategy:\n | {\n type: 'mtime'\n expectedMtimeMs: bigint\n }\n | {\n type: 'new-file'\n }\n }) {\n const tmpPath = this.getTempFileName(opts.filePath)\n await this.fs.writeFile(tmpPath, opts.newContent)\n\n if (opts.strategy.type === 'mtime') {\n const beforeStat = await this.fs.stat(opts.filePath)\n if (beforeStat.mtimeMs !== opts.strategy.expectedMtimeMs) {\n throw rerun({\n msg: `File ${opts.filePath} was modified by another process during processing.`,\n event: { type: 'update', path: opts.filePath },\n })\n }\n } else {\n if (await checkFileExists(opts.filePath)) {\n throw rerun({\n msg: `File ${opts.filePath} already exists. Cannot overwrite.`,\n event: { type: 'update', path: opts.filePath },\n })\n }\n }\n\n const stat = await this.fs.stat(tmpPath)\n\n await this.fs.rename(tmpPath, opts.filePath)\n\n return stat\n }\n\n private getTempFileName(filePath: string) {\n const absPath = path.resolve(filePath)\n const hash = crypto.createHash('md5').update(absPath).digest('hex')\n return path.join(this.tmpDir, hash)\n }\n\n private async isRouteFileCacheFresh(node: RouteNode): Promise<\n | {\n status: 'fresh'\n cacheEntry: RouteNodeCacheEntry\n exportsChanged: boolean\n }\n | { status: 'stale'; cacheEntry?: RouteNodeCacheEntry }\n > {\n const fileChangedCache = await this.didRouteFileChangeComparedToCache(\n { path: node.fullPath },\n 'routeNodeCache',\n )\n if (fileChangedCache.result === false) {\n this.routeNodeShadowCache.set(node.fullPath, fileChangedCache.cacheEntry)\n return {\n status: 'fresh',\n exportsChanged: false,\n cacheEntry: fileChangedCache.cacheEntry,\n }\n }\n if (fileChangedCache.result === 'cannot-stat-file') {\n throw new Error(`⚠️ expected route file to exist at ${node.fullPath}`)\n }\n const mtimeMs =\n fileChangedCache.result === true ? fileChangedCache.mtimeMs : undefined\n\n const shadowCacheFileChange = await this.didRouteFileChangeComparedToCache(\n { path: node.fullPath, mtimeMs },\n 'routeNodeShadowCache',\n )\n\n if (shadowCacheFileChange.result === 'cannot-stat-file') {\n throw new Error(`⚠️ expected route file to exist at ${node.fullPath}`)\n }\n\n if (shadowCacheFileChange.result === false) {\n // shadow cache has latest file state already\n // compare shadowCache against cache to determine whether exports changed\n // if they didn't, cache is fresh\n if (fileChangedCache.result === true) {\n if (\n deepEqual(\n fileChangedCache.cacheEntry.exports,\n shadowCacheFileChange.cacheEntry.exports,\n )\n ) {\n return {\n status: 'fresh',\n exportsChanged: false,\n cacheEntry: shadowCacheFileChange.cacheEntry,\n }\n }\n return {\n status: 'fresh',\n exportsChanged: true,\n cacheEntry: shadowCacheFileChange.cacheEntry,\n }\n }\n }\n\n if (fileChangedCache.result === 'file-not-in-cache') {\n return {\n status: 'stale',\n }\n }\n return { status: 'stale', cacheEntry: fileChangedCache.cacheEntry }\n }\n\n private async handleRootNode(node: RouteNode) {\n const result = await this.isRouteFileCacheFresh(node)\n\n if (result.status === 'fresh') {\n node.exports = result.cacheEntry.exports\n this.routeNodeShadowCache.set(node.fullPath, result.cacheEntry)\n return result.exportsChanged\n }\n const rootNodeFile = await this.fs.readFile(node.fullPath)\n if (rootNodeFile === 'file-not-existing') {\n throw new Error(`⚠️ expected root route to exist at ${node.fullPath}`)\n }\n\n const updatedCacheEntry: RouteNodeCacheEntry = {\n fileContent: rootNodeFile.fileContent,\n mtimeMs: rootNodeFile.stat.mtimeMs,\n exports: [],\n }\n\n // scaffold the root route\n if (!rootNodeFile.fileContent) {\n const rootTemplate = this.targetTemplate.rootRoute\n const rootRouteContent = await fillTemplate(\n this.config,\n rootTemplate.template(),\n {\n tsrImports: rootTemplate.imports.tsrImports(),\n tsrPath: rootPathId,\n tsrExportStart: rootTemplate.imports.tsrExportStart(),\n tsrExportEnd: rootTemplate.imports.tsrExportEnd(),\n },\n )\n\n this.logger.log(`🟡 Creating ${node.fullPath}`)\n const stats = await this.safeFileWrite({\n filePath: node.fullPath,\n newContent: rootRouteContent,\n strategy: {\n type: 'mtime',\n expectedMtimeMs: rootNodeFile.stat.mtimeMs,\n },\n })\n updatedCacheEntry.fileContent = rootRouteContent\n updatedCacheEntry.mtimeMs = stats.mtimeMs\n }\n\n const rootRouteExports: Array<string> = []\n for (const plugin of this.pluginsWithTransform) {\n const exportName = plugin.transformPlugin.exportName\n if (rootNodeFile.fileContent.includes(`export const ${exportName}`)) {\n rootRouteExports.push(exportName)\n }\n }\n\n updatedCacheEntry.exports = rootRouteExports\n node.exports = rootRouteExports\n this.routeNodeShadowCache.set(node.fullPath, updatedCacheEntry)\n\n const shouldWriteTree = !deepEqual(\n result.cacheEntry?.exports,\n rootRouteExports,\n )\n return shouldWriteTree\n }\n\n private handleNode(node: RouteNode, acc: HandleNodeAccumulator) {\n // Do not remove this as we need to set the lastIndex to 0 as it\n // is necessary to reset the regex's index when using the global flag\n // otherwise it might not match the next time it's used\n resetRegex(this.routeGroupPatternRegex)\n\n let parentRoute = hasParentRoute(acc.routeNodes, node, node.routePath)\n\n // if the parent route is a virtual parent route, we need to find the real parent route\n if (parentRoute?.isVirtualParentRoute && parentRoute.children?.length) {\n // only if this sub-parent route returns a valid parent route, we use it, if not leave it as it\n const possibleParentRoute = hasParentRoute(\n parentRoute.children,\n node,\n node.routePath,\n )\n if (possibleParentRoute) {\n parentRoute = possibleParentRoute\n }\n }\n\n if (parentRoute) node.parent = parentRoute\n\n node.path = determineNodePath(node)\n\n const trimmedPath = trimPathLeft(node.path ?? '')\n\n const split = trimmedPath.split('/')\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath =\n lastRouteSegment.startsWith('_') ||\n this.routeGroupPatternRegex.test(lastRouteSegment)\n\n node.cleanedPath = removeGroups(\n removeUnderscores(removeLayoutSegments(node.path)) ?? '',\n )\n\n if (\n !node.isVirtual &&\n (\n [\n 'lazy',\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n ] satisfies Array<FsRouteType>\n ).some((d) => d === node._fsRouteType)\n ) {\n acc.routePiecesByPath[node.routePath!] =\n acc.routePiecesByPath[node.routePath!] || {}\n\n acc.routePiecesByPath[node.routePath!]![\n node._fsRouteType === 'lazy'\n ? 'lazy'\n : node._fsRouteType === 'loader'\n ? 'loader'\n : node._fsRouteType === 'errorComponent'\n ? 'errorComponent'\n : node._fsRouteType === 'pendingComponent'\n ? 'pendingComponent'\n : 'component'\n ] = node\n\n const anchorRoute = acc.routeNodes.find(\n (d) => d.routePath === node.routePath,\n )\n\n if (!anchorRoute) {\n this.handleNode(\n {\n ...node,\n isVirtual: true,\n _fsRouteType: 'static',\n },\n acc,\n )\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n const nonPathRoute =\n node._fsRouteType === 'pathless_layout' && node.isNonPath\n\n node.isVirtualParentRequired =\n node._fsRouteType === 'pathless_layout' || nonPathRoute\n ? !cleanedPathIsEmpty\n : false\n\n if (!node.isVirtual && node.isVirtualParentRequired) {\n const parentRoutePath = removeLastSegmentFromPath(node.routePath) || '/'\n const parentVariableName = routePathToVariable(parentRoutePath)\n\n const anchorRoute = acc.routeNodes.find(\n (d) => d.routePath === parentRoutePath,\n )\n\n if (!anchorRoute) {\n const parentNode: RouteNode = {\n ...node,\n path: removeLastSegmentFromPath(node.path) || '/',\n filePath: removeLastSegmentFromPath(node.filePath) || '/',\n fullPath: removeLastSegmentFromPath(node.fullPath) || '/',\n routePath: parentRoutePath,\n variableName: parentVariableName,\n isVirtual: true,\n _fsRouteType: 'layout', // layout since this route will wrap other routes\n isVirtualParentRoute: true,\n isVirtualParentRequired: false,\n }\n\n parentNode.children = parentNode.children ?? []\n parentNode.children.push(node)\n\n node.parent = parentNode\n\n if (node._fsRouteType === 'pathless_layout') {\n // since `node.path` is used as the `id` on the route definition, we need to update it\n node.path = determineNodePath(node)\n }\n\n this.handleNode(parentNode, acc)\n } else {\n anchorRoute.children = anchorRoute.children ?? []\n anchorRoute.children.push(node)\n\n node.parent = anchorRoute\n }\n }\n\n if (node.parent) {\n if (!node.isVirtualParentRequired) {\n node.parent.children = node.parent.children ?? []\n node.parent.children.push(node)\n }\n } else {\n acc.routeTree.push(node)\n }\n\n acc.routeNodes.push(node)\n }\n}\n"],"names":["virtualGetRouteNodes","physicalGetRouteNodes","_a","routeImports","_b","_c","moduleAugmentation"],"mappings":";;;;;;;;;;;;;AAmEA,MAAM,oBAAwB;AAAA,EAC5B,MAAM,CAAC,aAAa,IAAI,KAAK,UAAU,EAAE,QAAQ,MAAM;AAAA,EACvD;AAAA,EACA,QAAQ,CAAC,SAAS,YAAY,IAAI,OAAO,SAAS,OAAO;AAAA,EACzD,WAAW,CAAC,UAAU,YAAY,IAAI,UAAU,UAAU,OAAO;AAAA,EACjE,UAAU,OAAO,aAAqB;AAChC,QAAA;AACF,YAAM,aAAa,MAAM,IAAI,KAAK,UAAU,GAAG;AAC/C,YAAM,OAAO,MAAM,WAAW,KAAK,EAAE,QAAQ,MAAM;AACnD,YAAM,eAAe,MAAM,WAAW,SAAA,GAAY,SAAS;AAC3D,YAAM,WAAW,MAAM;AAChB,aAAA,EAAE,MAAM,YAAY;AAAA,aACpB,GAAQ;AACf,UAAI,UAAU,GAAG;AACX,YAAA,EAAE,SAAS,UAAU;AAChB,iBAAA;AAAA,QAAA;AAAA,MACT;AAEI,YAAA;AAAA,IAAA;AAAA,EACR;AAEJ;AAOA,SAAS,MAAM,MAAuD;AACpE,QAAM,EAAE,OAAO,GAAG,KAAA,IAAS;AACpB,SAAA,EAAE,OAAO,MAAM,OAAO,SAAS,EAAE,MAAM,WAAW,GAAG,KAAK;AACnE;AAEA,SAAS,QAAQ,QAAkC;AAE/C,SAAA,OAAO,WAAW,YAClB,WAAW,QACX,WAAW,UACX,OAAO,UAAU;AAErB;AAiCO,MAA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qBACD;AAEN,QAAI,CAAC,KAAK,aAAa,KAAK,yBAAyB;AACnD,YAAM,kBAAkB,0BAA0B,KAAK,SAAS,KAAK;AAC/D,YAAA,qBAAqB,oBAAoB,eAAe;AAExD,YAAA,cAAc,IAAI,WAAW;AAAA,QACjC,CAAC,MAAM,EAAE,cAAc;AAAA,MACzB;AAEA,UAAI,CAAC,aAAa;AAChB,cAAM,aAAwB;AAAA,UAC5B,GAAG;AAAA,UACH,MAAM,0BAA0B,KAAK,IAAI,KAAK;AAAA,UAC9C,UAAU,0BAA0B,KAAK,QAAQ,KAAK;AAAA,UACtD,UAAU,0BAA0B,KAAK,QAAQ,KAAK;AAAA,UACtD,WAAW;AAAA,UACX,cAAc;AAAA,UACd,WAAW;AAAA,UACX,cAAc;AAAA;AAAA,UACd,sBAAsB;AAAA,UACtB,yBAAyB;AAAA,QAC3B;AAEW,mBAAA,WAAW,WAAW,YAAY,CAAC;AACnC,mBAAA,SAAS,KAAK,IAAI;AAE7B,aAAK,SAAS;AAEV,YAAA,KAAK,iBAAiB,mBAAmB;AAEtC,eAAA,OAAO,kBAAkB,IAAI;AAAA,QAAA;AAG/B,aAAA,WAAW,YAAY,GAAG;AAAA,MAAA,OAC1B;AACO,oBAAA,WAAW,YAAY,YAAY,CAAC;AACpC,oBAAA,SAAS,KAAK,IAAI;AAE9B,aAAK,SAAS;AAAA,MAAA;AAAA,IAChB;AAGF,QAAI,KAAK,QAAQ;AACX,UAAA,CAAC,KAAK,yBAAyB;AACjC,aAAK,OAAO,WAAW,KAAK,OAAO,YAAY,CAAC;AAC3C,aAAA,OAAO,SAAS,KAAK,IAAI;AAAA,MAAA;AAAA,IAChC,OACK;AACD,UAAA,UAAU,KAAK,IAAI;AAAA,IAAA;AAGrB,QAAA,WAAW,KAAK,IAAI;AAAA,EAAA;AAE5B;"}
@@ -1,8 +1,12 @@
1
1
  export { configSchema, getConfig, resolveConfigPath, baseConfigSchema, } from './config.js';
2
2
  export type { Config, BaseConfig } from './config.js';
3
- export { generator } from './generator.js';
4
- export { logging, capitalize, cleanPath, trimPathLeft, removeLeadingSlash, removeTrailingSlash, determineInitialRoutePath, replaceBackslash, routePathToVariable, removeUnderscores, resetRegex, multiSortBy, writeIfDifferent, format, removeExt, } from './utils.js';
5
- export type { RouteNode, GetRouteNodesResult } from './types.js';
3
+ export { Generator } from './generator.js';
4
+ export type { FileEventType, FileEvent, GeneratorEvent } from './generator.js';
5
+ export type { GeneratorPluginBase, GeneratorPlugin, GeneratorPluginWithTransform, } from './plugin/types.js';
6
+ export { capitalize, cleanPath, trimPathLeft, removeLeadingSlash, removeTrailingSlash, determineInitialRoutePath, replaceBackslash, routePathToVariable, removeUnderscores, resetRegex, multiSortBy, writeIfDifferent, format, removeExt, checkRouteFullPathUniqueness, hasChildWithExport, } from './utils.js';
7
+ export type { RouteNode, GetRouteNodesResult, ImportDeclaration, ImportSpecifier, } from './types.js';
6
8
  export { getRouteNodes as physicalGetRouteNodes } from './filesystem/physical/getRouteNodes.js';
7
9
  export { getRouteNodes as virtualGetRouteNodes } from './filesystem/virtual/getRouteNodes.js';
8
10
  export { rootPathId } from './filesystem/physical/rootPathId.js';
11
+ export { ensureStringArgument } from './transform/utils.js';
12
+ export type { TransformImportsConfig, TransformContext, TransformOptions, TransformPlugin, } from './transform/types.js';
package/dist/esm/index.js CHANGED
@@ -1,19 +1,22 @@
1
1
  import { baseConfigSchema, configSchema, getConfig, resolveConfigPath } from "./config.js";
2
- import { generator } from "./generator.js";
3
- import { capitalize, cleanPath, determineInitialRoutePath, format, logging, multiSortBy, removeExt, removeLeadingSlash, removeTrailingSlash, removeUnderscores, replaceBackslash, resetRegex, routePathToVariable, trimPathLeft, writeIfDifferent } from "./utils.js";
2
+ import { Generator } from "./generator.js";
3
+ import { capitalize, checkRouteFullPathUniqueness, cleanPath, determineInitialRoutePath, format, hasChildWithExport, multiSortBy, removeExt, removeLeadingSlash, removeTrailingSlash, removeUnderscores, replaceBackslash, resetRegex, routePathToVariable, trimPathLeft, writeIfDifferent } from "./utils.js";
4
4
  import { getRouteNodes } from "./filesystem/physical/getRouteNodes.js";
5
5
  import { getRouteNodes as getRouteNodes2 } from "./filesystem/virtual/getRouteNodes.js";
6
6
  import { rootPathId } from "./filesystem/physical/rootPathId.js";
7
+ import { ensureStringArgument } from "./transform/utils.js";
7
8
  export {
9
+ Generator,
8
10
  baseConfigSchema,
9
11
  capitalize,
12
+ checkRouteFullPathUniqueness,
10
13
  cleanPath,
11
14
  configSchema,
12
15
  determineInitialRoutePath,
16
+ ensureStringArgument,
13
17
  format,
14
- generator,
15
18
  getConfig,
16
- logging,
19
+ hasChildWithExport,
17
20
  multiSortBy,
18
21
  getRouteNodes as physicalGetRouteNodes,
19
22
  removeExt,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,10 @@
1
+ export interface Logger {
2
+ log: (...args: Array<any>) => void;
3
+ debug: (...args: Array<any>) => void;
4
+ info: (...args: Array<any>) => void;
5
+ warn: (...args: Array<any>) => void;
6
+ error: (...args: Array<any>) => void;
7
+ }
8
+ export declare function logging(config: {
9
+ disabled: boolean;
10
+ }): Logger;
@@ -0,0 +1,37 @@
1
+ function logging(config) {
2
+ function stripEmojis(str) {
3
+ return str.replace(
4
+ /[\p{Emoji_Presentation}\p{Extended_Pictographic}]/gu,
5
+ ""
6
+ );
7
+ }
8
+ function formatLogArgs(args) {
9
+ if (process.env.CI) {
10
+ return args.map(
11
+ (arg) => typeof arg === "string" ? stripEmojis(arg) : arg
12
+ );
13
+ }
14
+ return args;
15
+ }
16
+ return {
17
+ log: (...args) => {
18
+ if (!config.disabled) console.log(...formatLogArgs(args));
19
+ },
20
+ debug: (...args) => {
21
+ if (!config.disabled) console.debug(...formatLogArgs(args));
22
+ },
23
+ info: (...args) => {
24
+ if (!config.disabled) console.info(...formatLogArgs(args));
25
+ },
26
+ warn: (...args) => {
27
+ if (!config.disabled) console.warn(...formatLogArgs(args));
28
+ },
29
+ error: (...args) => {
30
+ if (!config.disabled) console.error(...formatLogArgs(args));
31
+ }
32
+ };
33
+ }
34
+ export {
35
+ logging
36
+ };
37
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sources":["../../src/logger.ts"],"sourcesContent":["export interface Logger {\n log: (...args: Array<any>) => void\n debug: (...args: Array<any>) => void\n info: (...args: Array<any>) => void\n warn: (...args: Array<any>) => void\n error: (...args: Array<any>) => void\n}\n\nexport function logging(config: { disabled: boolean }): Logger {\n function stripEmojis(str: string) {\n return str.replace(\n /[\\p{Emoji_Presentation}\\p{Extended_Pictographic}]/gu,\n '',\n )\n }\n\n function formatLogArgs(args: Array<any>): Array<any> {\n if (process.env.CI) {\n return args.map((arg) =>\n typeof arg === 'string' ? stripEmojis(arg) : arg,\n )\n }\n return args\n }\n\n return {\n log: (...args: Array<any>) => {\n if (!config.disabled) console.log(...formatLogArgs(args))\n },\n debug: (...args: Array<any>) => {\n if (!config.disabled) console.debug(...formatLogArgs(args))\n },\n info: (...args: Array<any>) => {\n if (!config.disabled) console.info(...formatLogArgs(args))\n },\n warn: (...args: Array<any>) => {\n if (!config.disabled) console.warn(...formatLogArgs(args))\n },\n error: (...args: Array<any>) => {\n if (!config.disabled) console.error(...formatLogArgs(args))\n },\n }\n}\n"],"names":[],"mappings":"AAQO,SAAS,QAAQ,QAAuC;AAC7D,WAAS,YAAY,KAAa;AAChC,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGF,WAAS,cAAc,MAA8B;AAC/C,QAAA,QAAQ,IAAI,IAAI;AAClB,aAAO,KAAK;AAAA,QAAI,CAAC,QACf,OAAO,QAAQ,WAAW,YAAY,GAAG,IAAI;AAAA,MAC/C;AAAA,IAAA;AAEK,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,KAAK,IAAI,SAAqB;AACxB,UAAA,CAAC,OAAO,SAAU,SAAQ,IAAI,GAAG,cAAc,IAAI,CAAC;AAAA,IAC1D;AAAA,IACA,OAAO,IAAI,SAAqB;AAC1B,UAAA,CAAC,OAAO,SAAU,SAAQ,MAAM,GAAG,cAAc,IAAI,CAAC;AAAA,IAC5D;AAAA,IACA,MAAM,IAAI,SAAqB;AACzB,UAAA,CAAC,OAAO,SAAU,SAAQ,KAAK,GAAG,cAAc,IAAI,CAAC;AAAA,IAC3D;AAAA,IACA,MAAM,IAAI,SAAqB;AACzB,UAAA,CAAC,OAAO,SAAU,SAAQ,KAAK,GAAG,cAAc,IAAI,CAAC;AAAA,IAC3D;AAAA,IACA,OAAO,IAAI,SAAqB;AAC1B,UAAA,CAAC,OAAO,SAAU,SAAQ,MAAM,GAAG,cAAc,IAAI,CAAC;AAAA,IAAA;AAAA,EAE9D;AACF;"}
@@ -0,0 +1,2 @@
1
+ import { GeneratorPluginWithTransform } from './types.js';
2
+ export declare function defaultGeneratorPlugin(): GeneratorPluginWithTransform;
@@ -0,0 +1,88 @@
1
+ import { defaultTransformPlugin } from "../transform/default-transform-plugin.js";
2
+ import { checkRouteFullPathUniqueness, isRouteNodeValidForAugmentation } from "../utils.js";
3
+ function defaultGeneratorPlugin() {
4
+ return {
5
+ name: "default",
6
+ transformPlugin: defaultTransformPlugin,
7
+ imports: (opts) => {
8
+ const imports = [];
9
+ if (opts.acc.routeNodes.some((n) => n.isVirtual)) {
10
+ imports.push({
11
+ specifiers: [{ imported: "createFileRoute" }],
12
+ source: opts.generator.targetTemplate.fullPkg
13
+ });
14
+ }
15
+ if (opts.generator.config.verboseFileRoutes === false) {
16
+ const typeImport = {
17
+ specifiers: [],
18
+ source: opts.generator.targetTemplate.fullPkg,
19
+ importKind: "type"
20
+ };
21
+ if (opts.sortedRouteNodes.some(
22
+ (d) => isRouteNodeValidForAugmentation(d) && d._fsRouteType !== "lazy"
23
+ )) {
24
+ typeImport.specifiers.push({ imported: "CreateFileRoute" });
25
+ }
26
+ if (opts.sortedRouteNodes.some(
27
+ (node) => {
28
+ var _a;
29
+ return ((_a = opts.acc.routePiecesByPath[node.routePath]) == null ? void 0 : _a.lazy) && isRouteNodeValidForAugmentation(node);
30
+ }
31
+ )) {
32
+ typeImport.specifiers.push({ imported: "CreateLazyFileRoute" });
33
+ }
34
+ if (typeImport.specifiers.length > 0) {
35
+ typeImport.specifiers.push({ imported: "FileRoutesByPath" });
36
+ imports.push(typeImport);
37
+ }
38
+ }
39
+ return imports;
40
+ },
41
+ moduleAugmentation: ({ generator }) => ({
42
+ module: generator.targetTemplate.fullPkg,
43
+ interfaceName: "FileRoutesByPath"
44
+ }),
45
+ onRouteTreesChanged: ({ routeTrees, generator }) => {
46
+ const routeTree = routeTrees.find((tree) => tree.exportName === "Route");
47
+ if (!routeTree) {
48
+ throw new Error(
49
+ 'No route tree found with export name "Route". Please ensure your routes are correctly defined.'
50
+ );
51
+ }
52
+ checkRouteFullPathUniqueness(
53
+ routeTree.sortedRouteNodes.filter(
54
+ (d) => {
55
+ var _a;
56
+ return d.children === void 0 && "lazy" !== d._fsRouteType && ((_a = d.exports) == null ? void 0 : _a.includes("Route"));
57
+ }
58
+ ),
59
+ generator.config
60
+ );
61
+ },
62
+ routeModuleAugmentation: ({ routeNode }) => {
63
+ if (routeNode._fsRouteType === "lazy") {
64
+ return `const createLazyFileRoute: CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>`;
65
+ } else {
66
+ return `const createFileRoute: CreateFileRoute<'${routeNode.routePath}',
67
+ FileRoutesByPath['${routeNode.routePath}']['parentRoute'],
68
+ FileRoutesByPath['${routeNode.routePath}']['id'],
69
+ FileRoutesByPath['${routeNode.routePath}']['path'],
70
+ FileRoutesByPath['${routeNode.routePath}']['fullPath']
71
+ >
72
+ `;
73
+ }
74
+ },
75
+ createRootRouteCode: () => `createRooRoute()`,
76
+ createVirtualRouteCode: ({ node }) => `createFileRoute('${node.routePath}')()`,
77
+ config: ({ sortedRouteNodes }) => {
78
+ const hasMatchingRouteFiles = sortedRouteNodes.length > 0;
79
+ return {
80
+ virtualRootRoute: hasMatchingRouteFiles
81
+ };
82
+ }
83
+ };
84
+ }
85
+ export {
86
+ defaultGeneratorPlugin
87
+ };
88
+ //# sourceMappingURL=default-generator-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-generator-plugin.js","sources":["../../../src/plugin/default-generator-plugin.ts"],"sourcesContent":["import { defaultTransformPlugin } from '../transform/default-transform-plugin'\nimport {\n checkRouteFullPathUniqueness,\n isRouteNodeValidForAugmentation,\n} from '../utils'\nimport type { ImportDeclaration } from '../types'\nimport type { GeneratorPluginWithTransform } from './types'\n\nexport function defaultGeneratorPlugin(): GeneratorPluginWithTransform {\n return {\n name: 'default',\n transformPlugin: defaultTransformPlugin,\n imports: (opts) => {\n const imports: Array<ImportDeclaration> = []\n if (opts.acc.routeNodes.some((n) => n.isVirtual)) {\n imports.push({\n specifiers: [{ imported: 'createFileRoute' }],\n source: opts.generator.targetTemplate.fullPkg,\n })\n }\n if (opts.generator.config.verboseFileRoutes === false) {\n const typeImport: ImportDeclaration = {\n specifiers: [],\n source: opts.generator.targetTemplate.fullPkg,\n importKind: 'type',\n }\n if (\n opts.sortedRouteNodes.some(\n (d) =>\n isRouteNodeValidForAugmentation(d) && d._fsRouteType !== 'lazy',\n )\n ) {\n typeImport.specifiers.push({ imported: 'CreateFileRoute' })\n }\n if (\n opts.sortedRouteNodes.some(\n (node) =>\n opts.acc.routePiecesByPath[node.routePath!]?.lazy &&\n isRouteNodeValidForAugmentation(node),\n )\n ) {\n typeImport.specifiers.push({ imported: 'CreateLazyFileRoute' })\n }\n\n if (typeImport.specifiers.length > 0) {\n typeImport.specifiers.push({ imported: 'FileRoutesByPath' })\n imports.push(typeImport)\n }\n }\n return imports\n },\n moduleAugmentation: ({ generator }) => ({\n module: generator.targetTemplate.fullPkg,\n interfaceName: 'FileRoutesByPath',\n }),\n onRouteTreesChanged: ({ routeTrees, generator }) => {\n const routeTree = routeTrees.find((tree) => tree.exportName === 'Route')\n if (!routeTree) {\n throw new Error(\n 'No route tree found with export name \"Route\". Please ensure your routes are correctly defined.',\n )\n }\n checkRouteFullPathUniqueness(\n routeTree.sortedRouteNodes.filter(\n (d) =>\n d.children === undefined &&\n 'lazy' !== d._fsRouteType &&\n d.exports?.includes('Route'),\n ),\n generator.config,\n )\n },\n routeModuleAugmentation: ({ routeNode }) => {\n if (routeNode._fsRouteType === 'lazy') {\n return `const createLazyFileRoute: CreateLazyFileRoute<FileRoutesByPath['${routeNode.routePath}']['preLoaderRoute']>`\n } else {\n return `const createFileRoute: CreateFileRoute<'${routeNode.routePath}',\n FileRoutesByPath['${routeNode.routePath}']['parentRoute'],\n FileRoutesByPath['${routeNode.routePath}']['id'],\n FileRoutesByPath['${routeNode.routePath}']['path'],\n FileRoutesByPath['${routeNode.routePath}']['fullPath']\n >\n `\n }\n },\n createRootRouteCode: () => `createRooRoute()`,\n createVirtualRouteCode: ({ node }) =>\n `createFileRoute('${node.routePath}')()`,\n config: ({ sortedRouteNodes }) => {\n const hasMatchingRouteFiles = sortedRouteNodes.length > 0\n return {\n virtualRootRoute: hasMatchingRouteFiles,\n }\n },\n }\n}\n"],"names":[],"mappings":";;AAQO,SAAS,yBAAuD;AAC9D,SAAA;AAAA,IACL,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,SAAS,CAAC,SAAS;AACjB,YAAM,UAAoC,CAAC;AACvC,UAAA,KAAK,IAAI,WAAW,KAAK,CAAC,MAAM,EAAE,SAAS,GAAG;AAChD,gBAAQ,KAAK;AAAA,UACX,YAAY,CAAC,EAAE,UAAU,mBAAmB;AAAA,UAC5C,QAAQ,KAAK,UAAU,eAAe;AAAA,QAAA,CACvC;AAAA,MAAA;AAEH,UAAI,KAAK,UAAU,OAAO,sBAAsB,OAAO;AACrD,cAAM,aAAgC;AAAA,UACpC,YAAY,CAAC;AAAA,UACb,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CACnB,UAAU,SAAS;AAAA,gCACnB,UAAU,SAAS;AAAA,gCACnB,UAAU,SAAS;AAAA;AAAA;AAAA,MAAA;AAAA,IAI/C;AAAA,IACA,qBAAqB,MAAM;AAAA,IAC3B,wBAAwB,CAAC,EAAE,KACzB,MAAA,oBAAoB,KAAK,SAAS;AAAA,IACpC,QAAQ,CAAC,EAAE,uBAAuB;AAC1B,YAAA,wBAAwB,iBAAiB,SAAS;AACjD,aAAA;AAAA,QACL,kBAAkB;AAAA,MACpB;AAAA,IAAA;AAAA,EAEJ;AACF;"}
@@ -0,0 +1,46 @@
1
+ import { TransformPlugin } from '../transform/types.js';
2
+ import { HandleNodeAccumulator, ImportDeclaration, RouteNode } from '../types.js';
3
+ import { Generator } from '../generator.js';
4
+ export type GeneratorPlugin = GeneratorPluginBase | GeneratorPluginWithTransform;
5
+ export interface GeneratorPluginBase {
6
+ name: string;
7
+ onRouteTreesChanged?: (opts: {
8
+ routeTrees: Array<{
9
+ sortedRouteNodes: Array<RouteNode>;
10
+ acc: HandleNodeAccumulator;
11
+ exportName: string;
12
+ }>;
13
+ rootRouteNode: RouteNode;
14
+ generator: Generator;
15
+ }) => void;
16
+ }
17
+ export interface GeneratorPluginWithTransform extends GeneratorPluginBase {
18
+ transformPlugin: TransformPlugin;
19
+ moduleAugmentation: (opts: {
20
+ generator: Generator;
21
+ }) => {
22
+ module: string;
23
+ interfaceName: string;
24
+ };
25
+ imports: (opts: {
26
+ rootRouteNode: RouteNode;
27
+ sortedRouteNodes: Array<RouteNode>;
28
+ acc: HandleNodeAccumulator;
29
+ generator: Generator;
30
+ }) => Array<ImportDeclaration>;
31
+ routeModuleAugmentation: (opts: {
32
+ routeNode: RouteNode;
33
+ }) => string | undefined;
34
+ createRootRouteCode: () => string;
35
+ createVirtualRouteCode: (opts: {
36
+ node: RouteNode;
37
+ }) => string;
38
+ config: (opts: {
39
+ generator: Generator;
40
+ rootRouteNode: RouteNode;
41
+ sortedRouteNodes: Array<RouteNode>;
42
+ }) => {
43
+ virtualRootRoute?: boolean;
44
+ };
45
+ }
46
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { Config } from './config.js';
2
2
  type TemplateTag = 'tsrImports' | 'tsrPath' | 'tsrExportStart' | 'tsrExportEnd';
3
3
  export declare function fillTemplate(config: Config, template: string, values: Record<TemplateTag, string>): Promise<string>;
4
- type TargetTemplate = {
4
+ export type TargetTemplate = {
5
5
  fullPkg: string;
6
6
  subPkg: string;
7
7
  rootRoute: {
@@ -29,5 +29,5 @@ type TargetTemplate = {
29
29
  };
30
30
  };
31
31
  };
32
- export declare function getTargetTemplate(target: Config['target']): TargetTemplate;
32
+ export declare function getTargetTemplate(config: Config): TargetTemplate;
33
33
  export {};