@tanstack/router-generator 1.20.5 → 1.22.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"config.cjs","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync, existsSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routeFileIgnorePattern: z.string().optional(),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":["z","existsSync","readFileSync"],"mappings":";;;;;AAIa,MAAA,eAAeA,MAAE,OAAO;AAAA,EACnC,iBAAiBA,IAAA,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,wBAAwBA,IAAA,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5C,iBAAiBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAYA,IAAAA,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAcA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAeA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EACnD,gBAAgBA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AACtD,CAAC;AAID,eAAsB,UACpB,eAAgC,CAAC,GACjC,iBACiB;AACjB,MAAI,oBAAoB,QAAW;AACjC,sBAAkB,QAAQ;EAC5B;AACA,QAAM,qBAAqB,KAAK,QAAQ,iBAAiB,iBAAiB;AACpE,QAAA,SAASC,cAAW,kBAAkB;AAExC,MAAA;AAEJ,MAAI,QAAQ;AACV,aAAS,aAAa,MAAM;AAAA,MAC1B,GAAG,KAAK,MAAMC,GAAa,aAAA,oBAAoB,OAAO,CAAC;AAAA,MACvD,GAAG;AAAA,IAAA,CACJ;AAAA,EAAA,OACI;AACI,aAAA,aAAa,MAAM,YAAY;AAAA,EAC1C;AAGA,MAAI,OAAO,cAAc;AAChB,WAAA,qBAAqB,OAAO,mBAAmB;AAAA,MACpD;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;;;"}
1
+ {"version":3,"file":"config.cjs","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { existsSync, readFileSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routeFileIgnorePattern: z.string().optional(),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":["z","existsSync","readFileSync"],"mappings":";;;;;AAIa,MAAA,eAAeA,MAAE,OAAO;AAAA,EACnC,iBAAiBA,IAAA,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,wBAAwBA,IAAA,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5C,iBAAiBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoBA,IAAE,EAAA,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAYA,IAAAA,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAcA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAeA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EACnD,gBAAgBA,IAAE,EAAA,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AACtD,CAAC;AAID,eAAsB,UACpB,eAAgC,CAAC,GACjC,iBACiB;AACjB,MAAI,oBAAoB,QAAW;AACjC,sBAAkB,QAAQ;EAC5B;AACA,QAAM,qBAAqB,KAAK,QAAQ,iBAAiB,iBAAiB;AACpE,QAAA,SAASC,cAAW,kBAAkB;AAExC,MAAA;AAEJ,MAAI,QAAQ;AACV,aAAS,aAAa,MAAM;AAAA,MAC1B,GAAG,KAAK,MAAMC,GAAa,aAAA,oBAAoB,OAAO,CAAC;AAAA,MACvD,GAAG;AAAA,IAAA,CACJ;AAAA,EAAA,OACI;AACI,aAAA,aAAa,MAAM,YAAY;AAAA,EAC1C;AAGA,MAAI,OAAO,cAAc;AAChB,WAAA,qBAAqB,OAAO,mBAAmB;AAAA,MACpD;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;;;"}
@@ -31,7 +31,7 @@ async function getRouteNodes(config) {
31
31
  const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } = config;
32
32
  const logger = utils.logging({ disabled: config.disableLogging });
33
33
  const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? "", "g");
34
- let routeNodes = [];
34
+ const routeNodes = [];
35
35
  async function recurse(dir) {
36
36
  const fullDir = path.resolve(config.routesDirectory, dir);
37
37
  let dirList = await fsp__namespace.readdir(fullDir, { withFileTypes: true });
@@ -62,17 +62,17 @@ async function getRouteNodes(config) {
62
62
  routePath = routePath.replaceAll(routeFilePrefix, "");
63
63
  }
64
64
  const variableName = routePathToVariable(routePath);
65
- let isLazy = routePath == null ? void 0 : routePath.endsWith("/lazy");
65
+ const isLazy = routePath.endsWith("/lazy");
66
66
  if (isLazy) {
67
- routePath = routePath == null ? void 0 : routePath.replace(/\/lazy$/, "");
67
+ routePath = routePath.replace(/\/lazy$/, "");
68
68
  }
69
- let isRoute = routePath == null ? void 0 : routePath.endsWith("/route");
70
- let isComponent = routePath == null ? void 0 : routePath.endsWith("/component");
71
- let isErrorComponent = routePath == null ? void 0 : routePath.endsWith("/errorComponent");
72
- let isPendingComponent = routePath == null ? void 0 : routePath.endsWith("/pendingComponent");
73
- let isLoader = routePath == null ? void 0 : routePath.endsWith("/loader");
74
- const segments = (routePath ?? "").split("/");
75
- let isLayout = ((_a = segments[segments.length - 1]) == null ? void 0 : _a.startsWith("_")) || false;
69
+ const isRoute = routePath.endsWith("/route");
70
+ const isComponent = routePath.endsWith("/component");
71
+ const isErrorComponent = routePath.endsWith("/errorComponent");
72
+ const isPendingComponent = routePath.endsWith("/pendingComponent");
73
+ const isLoader = routePath.endsWith("/loader");
74
+ const segments = routePath.split("/");
75
+ const isLayout = ((_a = segments[segments.length - 1]) == null ? void 0 : _a.startsWith("_")) || false;
76
76
  [
77
77
  [isComponent, "component"],
78
78
  [isErrorComponent, "errorComponent"],
@@ -85,7 +85,7 @@ async function getRouteNodes(config) {
85
85
  );
86
86
  }
87
87
  });
88
- routePath = routePath == null ? void 0 : routePath.replace(
88
+ routePath = routePath.replace(
89
89
  /\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,
90
90
  ""
91
91
  );
@@ -114,14 +114,14 @@ async function getRouteNodes(config) {
114
114
  await recurse("./");
115
115
  return routeNodes;
116
116
  }
117
- let first = false;
117
+ let isFirst = false;
118
118
  let skipMessage = false;
119
119
  async function generator(config) {
120
120
  const logger = utils.logging({ disabled: config.disableLogging });
121
121
  logger.log("");
122
- if (!first) {
122
+ if (!isFirst) {
123
123
  logger.log("♻️ Generating routes...");
124
- first = true;
124
+ isFirst = true;
125
125
  } else if (skipMessage) {
126
126
  skipMessage = false;
127
127
  } else {
@@ -148,20 +148,11 @@ async function generator(config) {
148
148
  var _a;
149
149
  return (_a = d.routePath) == null ? void 0 : _a.split("/").length;
150
150
  },
151
- (d) => {
152
- var _a;
153
- return ((_a = d.filePath) == null ? void 0 : _a.match(/[./]index[.]/)) ? 1 : -1;
154
- },
155
- (d) => {
156
- var _a;
157
- return ((_a = d.filePath) == null ? void 0 : _a.match(
158
- /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/
159
- )) ? 1 : -1;
160
- },
161
- (d) => {
162
- var _a;
163
- return ((_a = d.filePath) == null ? void 0 : _a.match(/[./]route[.]/)) ? -1 : 1;
164
- },
151
+ (d) => d.filePath.match(/[./]index[.]/) ? 1 : -1,
152
+ (d) => d.filePath.match(
153
+ /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/
154
+ ) ? 1 : -1,
155
+ (d) => d.filePath.match(/[./]route[.]/) ? -1 : 1,
165
156
  (d) => {
166
157
  var _a;
167
158
  return ((_a = d.routePath) == null ? void 0 : _a.endsWith("/")) ? -1 : 1;
@@ -170,7 +161,7 @@ async function generator(config) {
170
161
  ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ""));
171
162
  const routeTree = [];
172
163
  const routePiecesByPath = {};
173
- let routeNodes = [];
164
+ const routeNodes = [];
174
165
  const handleNode = async (node) => {
175
166
  var _a, _b;
176
167
  let parentRoute = hasParentRoute(routeNodes, node, node.routePath);
@@ -188,11 +179,11 @@ async function generator(config) {
188
179
  node.parent = parentRoute;
189
180
  node.path = determineNodePath(node);
190
181
  const trimmedPath = utils.trimPathLeft(node.path ?? "");
191
- const split = (trimmedPath == null ? void 0 : trimmedPath.split("/")) ?? [];
192
- let first2 = split[0] ?? trimmedPath ?? "";
193
- const lastRouteSegment = split[split.length - 1] ?? trimmedPath ?? "";
182
+ const split = trimmedPath.split("/");
183
+ const first = split[0] ?? trimmedPath;
184
+ const lastRouteSegment = split[split.length - 1] ?? trimmedPath;
194
185
  node.isNonPath = lastRouteSegment.startsWith("_");
195
- node.isNonLayout = first2.endsWith("_");
186
+ node.isNonLayout = first.endsWith("_");
196
187
  node.cleanedPath = removeGroups(
197
188
  removeUnderscores(removeLayoutSegments(node.path)) ?? ""
198
189
  );
@@ -447,10 +438,10 @@ async function generator(config) {
447
438
  `declare module '@tanstack/react-router' {
448
439
  interface FileRoutesByPath {
449
440
  ${routeNodes.map((routeNode) => {
450
- var _a, _b, _c;
441
+ var _a, _b;
451
442
  return `'${removeTrailingUnderscores(routeNode.routePath)}': {
452
443
  preLoaderRoute: typeof ${routeNode.variableName}Import
453
- parentRoute: typeof ${routeNode.isVirtualParentRequired ? `${(_a = routeNode.parent) == null ? void 0 : _a.variableName}Route` : ((_b = routeNode.parent) == null ? void 0 : _b.variableName) ? `${(_c = routeNode.parent) == null ? void 0 : _c.variableName}Import` : "rootRoute"}
444
+ parentRoute: typeof ${routeNode.isVirtualParentRequired ? `${(_a = routeNode.parent) == null ? void 0 : _a.variableName}Route` : ((_b = routeNode.parent) == null ? void 0 : _b.variableName) ? `${routeNode.parent.variableName}Import` : "rootRoute"}
454
445
  }`;
455
446
  }).join("\n")}
456
447
  }
@@ -488,9 +479,9 @@ async function generator(config) {
488
479
  `✅ Processed ${routeNodes.length === 1 ? "route" : "routes"} in ${Date.now() - start}ms`
489
480
  );
490
481
  }
491
- function routePathToVariable(d) {
492
- var _a, _b, _c, _d;
493
- return ((_d = (_c = (_b = (_a = removeUnderscores(d)) == null ? void 0 : _a.replace(/\/\$\//g, "/splat/")) == null ? void 0 : _b.replace(/\$$/g, "splat")) == null ? void 0 : _c.replace(/\$/g, "")) == null ? void 0 : _d.split(/[/-]/g).map((d2, i) => i > 0 ? capitalize(d2) : d2).join("").replace(/([^a-zA-Z0-9]|[\.])/gm, "").replace(/^(\d)/g, "R$1")) ?? "";
482
+ function routePathToVariable(routePath) {
483
+ var _a;
484
+ return ((_a = removeUnderscores(routePath)) == null ? void 0 : _a.replace(/\/\$\//g, "/splat/").replace(/\$$/g, "splat").replace(/\$/g, "").split(/[/-]/g).map((d, i) => i > 0 ? capitalize(d) : d).join("").replace(/([^a-zA-Z0-9]|[.])/gm, "").replace(/^(\d)/g, "R$1")) ?? "";
494
485
  }
495
486
  function removeExt(d, keepExtension = false) {
496
487
  return keepExtension ? d : d.substring(0, d.lastIndexOf(".")) || d;
@@ -538,13 +529,13 @@ function determineNodePath(node) {
538
529
  var _a;
539
530
  return node.path = node.parent ? ((_a = node.routePath) == null ? void 0 : _a.replace(node.parent.routePath, "")) || "/" : node.routePath;
540
531
  }
541
- function removeLastSegmentFromPath(path2 = "/") {
542
- const segments = path2.split("/");
532
+ function removeLastSegmentFromPath(routePath = "/") {
533
+ const segments = routePath.split("/");
543
534
  segments.pop();
544
535
  return segments.join("/");
545
536
  }
546
- function removeLayoutSegments(path2 = "/") {
547
- const segments = path2.split("/");
537
+ function removeLayoutSegments(routePath = "/") {
538
+ const segments = routePath.split("/");
548
539
  const newSegments = segments.filter((segment) => !segment.startsWith("_"));
549
540
  return newSegments.join("/");
550
541
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generator.cjs","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs'\nimport * as fsp from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, logging, trimPathLeft } from './utils'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isLayout?: boolean\n isVirtualParentRequired?: boolean\n isVirtualParentRoute?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isLazy?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } =\n config\n const logger = logging({ disabled: config.disableLogging })\n const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? '', 'g')\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fsp.readdir(fullDir, { withFileTypes: true })\n\n dirList = dirList.filter((d) => {\n if (\n d.name.startsWith('.') ||\n (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.name.startsWith(routeFilePrefix)\n }\n\n if (routeFileIgnorePattern) {\n return !d.name.match(routeFileIgnoreRegExp)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (dirent) => {\n const fullPath = path.join(fullDir, dirent.name)\n const relativePath = path.join(dir, dirent.name)\n\n if (dirent.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n }\n\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n let isLazy = routePath?.endsWith('/lazy')\n\n if (isLazy) {\n routePath = routePath?.replace(/\\/lazy$/, '')\n }\n\n let isRoute = routePath?.endsWith('/route')\n let isComponent = routePath?.endsWith('/component')\n let isErrorComponent = routePath?.endsWith('/errorComponent')\n let isPendingComponent = routePath?.endsWith('/pendingComponent')\n let isLoader = routePath?.endsWith('/loader')\n\n const segments = (routePath ?? '').split('/')\n let isLayout = segments[segments.length - 1]?.startsWith('_') || false\n\n ;(\n [\n [isComponent, 'component'],\n [isErrorComponent, 'errorComponent'],\n [isPendingComponent, 'pendingComponent'],\n [isLoader, 'loader'],\n ] as const\n ).forEach(([isType, type]) => {\n if (isType) {\n logger.warn(\n `WARNING: The \\`.${type}.tsx\\` suffix used for the ${filePath} file is deprecated. Use the new \\`.lazy.tsx\\` suffix instead.`,\n )\n }\n })\n\n routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n isLazy,\n isLayout,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = 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) {\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!first) {\n logger.log('♻️ Generating routes...')\n first = 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 const routePathIdPrefix = config.routeFilePrefix ?? ''\n const beforeRouteNodes = await getRouteNodes(config)\n const rootRouteNode = beforeRouteNodes.find(\n (d) => d.routePath === `/${rootPathId}`,\n )\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath?.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: 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 let routeNodes: RouteNode[] = []\n\n const handleNode = async (node: RouteNode) => {\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 let first = split[0] ?? trimmedPath ?? ''\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath ?? ''\n\n node.isNonPath = lastRouteSegment.startsWith('_')\n node.isNonLayout = first.endsWith('_')\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\n if (!node.isVirtualParentRoute) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$') ?? '',\n )\n\n let replaced = routeCode\n\n if (!routeCode) {\n if (node.isLazy) {\n replaced = [\n `import { createLazyFileRoute } from '@tanstack/react-router'`,\n `export const Route = createLazyFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n } else if (\n node.isRoute ||\n (!node.isComponent &&\n !node.isErrorComponent &&\n !node.isPendingComponent &&\n !node.isLoader)\n ) {\n replaced = [\n `import { createFileRoute } from '@tanstack/react-router'`,\n `export const Route = createFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n }\n } else {\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createLazyFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n }\n\n if (replaced !== routeCode) {\n logger.log(`🟡 Updating ${node.fullPath}`)\n await fsp.writeFile(node.fullPath, replaced)\n }\n }\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent ||\n node.isLazy)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLazy\n ? 'lazy'\n : node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\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 isLazy: false,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n node.isVirtualParentRequired = node.isLayout ? !cleanedPathIsEmpty : false\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 = {\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 isLayout: false,\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.isLayout) {\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 function buildRouteConfig(nodes: RouteNode[], depth = 1): string {\n const children = nodes.map((node) => {\n if (node.isRoot) {\n return\n }\n\n if (node.isLayout && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return children.filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = buildRouteConfig(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(\"index'\") ? -1 : 1),\n (d) => d,\n ])\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 const rootPathIdExtension =\n config.addExtensions && rootRouteNode\n ? path.extname(rootRouteNode.filePath)\n : ''\n\n const routeImports = [\n '/* prettier-ignore-start */',\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n '// This file is auto-generated by TanStack Router',\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${replaceBackslash(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n `${routePathIdPrefix}${rootPathId}${rootPathIdExtension}`,\n ),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${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 ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }Import = createFileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}')()`\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 `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${config.disableTypes ? '' : '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 })\n .join('\\n\\n'),\n ...(config.disableTypes\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n '// Create and export the route tree',\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n '/* prettier-ignore-end */',\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fsp.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\nfunction routePathToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\/\\$\\//g, '/splat/')\n ?.replace(/\\$$/g, 'splat')\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '')\n .replace(/^(\\d)/g, 'R$1') ?? ''\n )\n}\n\nexport function removeExt(d: string, keepExtension: boolean = false) {\n return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replaceAll(/(^_|_$)/gi, '').replaceAll(/(\\/_|_\\/)/gi, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replaceAll(/\\\\/gi, '/')\n}\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\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} path - 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 */\nexport function removeLastSegmentFromPath(path: string = '/'): string {\n const segments = path.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} path - 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(path: string = '/'): string {\n const segments = path.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nexport function hasParentRoute(\n routes: 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"],"names":["logging","fsp","cleanPath","trimPathLeft","first","fs","prettier","d","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAI,aAAa;AACV,MAAM,aAAa;AAC1B,MAAM,yBAAyB;AA0B/B,eAAe,cAAc,QAAgB;AAC3C,QAAM,EAAE,iBAAiB,uBAAuB,uBAAA,IAC9C;AACF,QAAM,SAASA,MAAAA,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,QAAM,wBAAwB,IAAI,OAAO,0BAA0B,IAAI,GAAG;AAE1E,MAAI,aAA0B,CAAA;AAE9B,iBAAe,QAAQ,KAAa;AAClC,UAAM,UAAU,KAAK,QAAQ,OAAO,iBAAiB,GAAG;AACpD,QAAA,UAAU,MAAMC,eAAI,QAAQ,SAAS,EAAE,eAAe,MAAM;AAEtD,cAAA,QAAQ,OAAO,CAAC,MAAM;AAE5B,UAAA,EAAE,KAAK,WAAW,GAAG,KACpB,yBAAyB,EAAE,KAAK,WAAW,qBAAqB,GACjE;AACO,eAAA;AAAA,MACT;AAEA,UAAI,iBAAiB;AACZ,eAAA,EAAE,KAAK,WAAW,eAAe;AAAA,MAC1C;AAEA,UAAI,wBAAwB;AAC1B,eAAO,CAAC,EAAE,KAAK,MAAM,qBAAqB;AAAA,MAC5C;AAEO,aAAA;AAAA,IAAA,CACR;AAED,UAAM,QAAQ;AAAA,MACZ,QAAQ,IAAI,OAAO,WAAW;;AAC5B,cAAM,WAAW,KAAK,KAAK,SAAS,OAAO,IAAI;AAC/C,cAAM,eAAe,KAAK,KAAK,KAAK,OAAO,IAAI;AAE3C,YAAA,OAAO,eAAe;AACxB,gBAAM,QAAQ,YAAY;AAAA,QACjB,WAAA,SAAS,MAAM,oBAAoB,GAAG;AAC/C,gBAAM,WAAW,iBAAiB,KAAK,KAAK,KAAK,OAAO,IAAI,CAAC;AACvD,gBAAA,gBAAgB,UAAU,QAAQ;AACpC,c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AAU,EAAE;AAEjD,aAAW,SAAS,aAAa;AAC/B,QAAI,MAAM,cAAc;AAAK;AAG3B,QAAA,iBAAiB,WAAW,GAAG,MAAM,SAAS,GAAG,KACjD,MAAM,cAAc,kBACpB;AACO,aAAA;AAAA,IACT;AAAA,EACF;AAEM,QAAA,WAAW,iBAAiB,MAAM,GAAG;AAC3C,WAAS,IAAI;AACP,QAAA,kBAAkB,SAAS,KAAK,GAAG;AAElC,SAAA,eAAe,QAAQ,MAAM,eAAe;AACrD;;;;;;;"}
1
+ {"version":3,"file":"generator.cjs","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs'\nimport * as fsp from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { cleanPath, logging, trimPathLeft } from './utils'\nimport type { Config } from './config'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isLayout?: boolean\n isVirtualParentRequired?: boolean\n isVirtualParentRoute?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isLazy?: boolean\n isRoot?: boolean\n children?: Array<RouteNode>\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } =\n config\n const logger = logging({ disabled: config.disableLogging })\n const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? '', 'g')\n\n const routeNodes: Array<RouteNode> = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fsp.readdir(fullDir, { withFileTypes: true })\n\n dirList = dirList.filter((d) => {\n if (\n d.name.startsWith('.') ||\n (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.name.startsWith(routeFilePrefix)\n }\n\n if (routeFileIgnorePattern) {\n return !d.name.match(routeFileIgnoreRegExp)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (dirent) => {\n const fullPath = path.join(fullDir, dirent.name)\n const relativePath = path.join(dir, dirent.name)\n\n if (dirent.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n }\n\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n const isLazy = routePath.endsWith('/lazy')\n\n if (isLazy) {\n routePath = routePath.replace(/\\/lazy$/, '')\n }\n\n const isRoute = routePath.endsWith('/route')\n const isComponent = routePath.endsWith('/component')\n const isErrorComponent = routePath.endsWith('/errorComponent')\n const isPendingComponent = routePath.endsWith('/pendingComponent')\n const isLoader = routePath.endsWith('/loader')\n\n const segments = routePath.split('/')\n const isLayout =\n segments[segments.length - 1]?.startsWith('_') || false\n\n ;(\n [\n [isComponent, 'component'],\n [isErrorComponent, 'errorComponent'],\n [isPendingComponent, 'pendingComponent'],\n [isLoader, 'loader'],\n ] as const\n ).forEach(([isType, type]) => {\n if (isType) {\n logger.warn(\n `WARNING: The \\`.${type}.tsx\\` suffix used for the ${filePath} file is deprecated. Use the new \\`.lazy.tsx\\` suffix instead.`,\n )\n }\n })\n\n routePath = routePath.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n isLazy,\n isLayout,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\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) {\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 const routePathIdPrefix = config.routeFilePrefix ?? ''\n const beforeRouteNodes = await getRouteNodes(config)\n const rootRouteNode = beforeRouteNodes.find(\n (d) => d.routePath === `/${rootPathId}`,\n )\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath.match(/[./]route[.]/) ? -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 const handleNode = async (node: RouteNode) => {\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 first = split[0] ?? trimmedPath\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath = lastRouteSegment.startsWith('_')\n node.isNonLayout = first.endsWith('_')\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\n if (!node.isVirtualParentRoute) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$') ?? '',\n )\n\n let replaced = routeCode\n\n if (!routeCode) {\n if (node.isLazy) {\n replaced = [\n `import { createLazyFileRoute } from '@tanstack/react-router'`,\n `export const Route = createLazyFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n } else if (\n node.isRoute ||\n (!node.isComponent &&\n !node.isErrorComponent &&\n !node.isPendingComponent &&\n !node.isLoader)\n ) {\n replaced = [\n `import { createFileRoute } from '@tanstack/react-router'`,\n `export const Route = createFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n }\n } else {\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createLazyFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n }\n\n if (replaced !== routeCode) {\n logger.log(`🟡 Updating ${node.fullPath}`)\n await fsp.writeFile(node.fullPath, replaced)\n }\n }\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent ||\n node.isLazy)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLazy\n ? 'lazy'\n : node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\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 isLazy: false,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n node.isVirtualParentRequired = node.isLayout ? !cleanedPathIsEmpty : false\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 = {\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 isLayout: false,\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.isLayout) {\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 function buildRouteConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node.isRoot) {\n return\n }\n\n if (node.isLayout && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return children.filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = buildRouteConfig(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(\"index'\") ? -1 : 1),\n (d) => d,\n ])\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 const rootPathIdExtension =\n config.addExtensions && rootRouteNode\n ? path.extname(rootRouteNode.filePath)\n : ''\n\n const routeImports = [\n '/* prettier-ignore-start */',\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n '// This file is auto-generated by TanStack Router',\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${replaceBackslash(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n `${routePathIdPrefix}${rootPathId}${rootPathIdExtension}`,\n ),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${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 ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }Import = createFileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}')()`\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 `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${config.disableTypes ? '' : '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 })\n .join('\\n\\n'),\n ...(config.disableTypes\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n '// Create and export the route tree',\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n '/* prettier-ignore-end */',\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fsp.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\nfunction routePathToVariable(routePath: string): string {\n return (\n removeUnderscores(routePath)\n ?.replace(/\\/\\$\\//g, '/splat/')\n .replace(/\\$$/g, 'splat')\n .replace(/\\$/g, '')\n .split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[.])/gm, '')\n .replace(/^(\\d)/g, 'R$1') ?? ''\n )\n}\n\nexport function removeExt(d: string, keepExtension: boolean = false) {\n return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: Array<T>,\n accessors: Array<(item: T) => any> = [(d) => d],\n): Array<T> {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replaceAll(/(^_|_$)/gi, '').replaceAll(/(\\/_|_\\/)/gi, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replaceAll(/\\\\/gi, '/')\n}\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\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 */\nexport function 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\nexport function 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"],"names":["logging","fsp","cleanPath","trimPathLeft","fs","prettier"],"mappings":";;;;;;;;;;;;;;;;;;;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AW,iBAAiB,MAAM,GAAG;AAC3C,WAAS,IAAI;AACP,QAAA,kBAAkB,SAAS,KAAK,GAAG;AAElC,SAAA,eAAe,QAAQ,MAAM,eAAe;AACrD;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { Config } from './config.cjs';
1
+ import type { Config } from './config.cjs';
2
2
  export declare const rootPathId = "__root";
3
3
  export type RouteNode = {
4
4
  filePath: string;
@@ -20,19 +20,19 @@ export type RouteNode = {
20
20
  isVirtual?: boolean;
21
21
  isLazy?: boolean;
22
22
  isRoot?: boolean;
23
- children?: RouteNode[];
23
+ children?: Array<RouteNode>;
24
24
  parent?: RouteNode;
25
25
  };
26
26
  export declare function generator(config: Config): Promise<void>;
27
27
  export declare function removeExt(d: string, keepExtension?: boolean): string;
28
- export declare function multiSortBy<T>(arr: T[], accessors?: ((item: T) => any)[]): T[];
28
+ export declare function multiSortBy<T>(arr: Array<T>, accessors?: Array<(item: T) => any>): Array<T>;
29
29
  /**
30
30
  * Removes the last segment from a given path. Segments are considered to be separated by a '/'.
31
31
  *
32
- * @param {string} path - The path from which to remove the last segment. Defaults to '/'.
32
+ * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.
33
33
  * @returns {string} The path with the last segment removed.
34
34
  * @example
35
35
  * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'
36
36
  */
37
- export declare function removeLastSegmentFromPath(path?: string): string;
38
- export declare function hasParentRoute(routes: RouteNode[], node: RouteNode, routePathToCheck: string | undefined): RouteNode | null;
37
+ export declare function removeLastSegmentFromPath(routePath?: string): string;
38
+ export declare function hasParentRoute(routes: Array<RouteNode>, node: RouteNode, routePathToCheck: string | undefined): RouteNode | null;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["export function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function logging(config: { disabled: boolean }) {\n return {\n log: (...args: any[]) => {\n if (!config.disabled) console.log(...args)\n },\n debug: (...args: any[]) => {\n if (!config.disabled) console.debug(...args)\n },\n info: (...args: any[]) => {\n if (!config.disabled) console.info(...args)\n },\n warn: (...args: any[]) => {\n if (!config.disabled) console.warn(...args)\n },\n error: (...args: any[]) => {\n if (!config.disabled) console.error(...args)\n },\n }\n}\n"],"names":[],"mappings":";;AAAO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,QAAQ,QAA+B;AAC9C,SAAA;AAAA,IACL,KAAK,IAAI,SAAgB;AACvB,UAAI,CAAC,OAAO;AAAkB,gBAAA,IAAI,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,OAAO,IAAI,SAAgB;AACzB,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,IACA,MAAM,IAAI,SAAgB;AACxB,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,MAAM,IAAI,SAAgB;AACxB,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,OAAO,IAAI,SAAgB;AACzB,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,EAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["export function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function logging(config: { disabled: boolean }) {\n return {\n log: (...args: Array<any>) => {\n if (!config.disabled) console.log(...args)\n },\n debug: (...args: Array<any>) => {\n if (!config.disabled) console.debug(...args)\n },\n info: (...args: Array<any>) => {\n if (!config.disabled) console.info(...args)\n },\n warn: (...args: Array<any>) => {\n if (!config.disabled) console.warn(...args)\n },\n error: (...args: Array<any>) => {\n if (!config.disabled) console.error(...args)\n },\n }\n}\n"],"names":[],"mappings":";;AAAO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,QAAQ,QAA+B;AAC9C,SAAA;AAAA,IACL,KAAK,IAAI,SAAqB;AAC5B,UAAI,CAAC,OAAO;AAAkB,gBAAA,IAAI,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,OAAO,IAAI,SAAqB;AAC9B,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,IACA,MAAM,IAAI,SAAqB;AAC7B,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,MAAM,IAAI,SAAqB;AAC7B,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,OAAO,IAAI,SAAqB;AAC9B,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,EAAA;AAEJ;;;;"}
@@ -3,9 +3,9 @@ export declare function trimPathLeft(path: string): string;
3
3
  export declare function logging(config: {
4
4
  disabled: boolean;
5
5
  }): {
6
- log: (...args: any[]) => void;
7
- debug: (...args: any[]) => void;
8
- info: (...args: any[]) => void;
9
- warn: (...args: any[]) => void;
10
- error: (...args: any[]) => void;
6
+ log: (...args: Array<any>) => void;
7
+ debug: (...args: Array<any>) => void;
8
+ info: (...args: Array<any>) => void;
9
+ warn: (...args: Array<any>) => void;
10
+ error: (...args: Array<any>) => void;
11
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { readFileSync, existsSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routeFileIgnorePattern: z.string().optional(),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,eAAe,EAAE,OAAO;AAAA,EACnC,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,wBAAwB,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5C,iBAAiB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAY,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAc,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAe,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EACnD,gBAAgB,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AACtD,CAAC;AAID,eAAsB,UACpB,eAAgC,CAAC,GACjC,iBACiB;AACjB,MAAI,oBAAoB,QAAW;AACjC,sBAAkB,QAAQ;EAC5B;AACA,QAAM,qBAAqB,KAAK,QAAQ,iBAAiB,iBAAiB;AACpE,QAAA,SAAS,WAAW,kBAAkB;AAExC,MAAA;AAEJ,MAAI,QAAQ;AACV,aAAS,aAAa,MAAM;AAAA,MAC1B,GAAG,KAAK,MAAM,aAAa,oBAAoB,OAAO,CAAC;AAAA,MACvD,GAAG;AAAA,IAAA,CACJ;AAAA,EAAA,OACI;AACI,aAAA,aAAa,MAAM,YAAY;AAAA,EAC1C;AAGA,MAAI,OAAO,cAAc;AAChB,WAAA,qBAAqB,OAAO,mBAAmB;AAAA,MACpD;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import path from 'path'\nimport { existsSync, readFileSync } from 'fs'\nimport { z } from 'zod'\n\nexport const configSchema = z.object({\n routeFilePrefix: z.string().optional(),\n routeFileIgnorePrefix: z.string().optional().default('-'),\n routeFileIgnorePattern: z.string().optional(),\n routesDirectory: z.string().optional().default('./src/routes'),\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n disableTypes: z.boolean().optional().default(false),\n addExtensions: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\nexport async function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Promise<Config> {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = path.resolve(configDirectory, 'tsr.config.json')\n const exists = existsSync(configFilePathJson)\n\n let config: Config\n\n if (exists) {\n config = configSchema.parse({\n ...JSON.parse(readFileSync(configFilePathJson, 'utf-8')),\n ...inlineConfig,\n })\n } else {\n config = configSchema.parse(inlineConfig)\n }\n\n // If typescript is disabled, make sure the generated route tree is a .js file\n if (config.disableTypes) {\n config.generatedRouteTree = config.generatedRouteTree.replace(\n /\\.(ts|tsx)$/,\n '.js',\n )\n }\n\n return config\n}\n"],"names":[],"mappings":";;;AAIa,MAAA,eAAe,EAAE,OAAO;AAAA,EACnC,iBAAiB,EAAE,OAAO,EAAE,SAAS;AAAA,EACrC,uBAAuB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,GAAG;AAAA,EACxD,wBAAwB,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5C,iBAAiB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,cAAc;AAAA,EAC7D,oBAAoB,EAAE,OAAA,EAAS,SAAS,EAAE,QAAQ,wBAAwB;AAAA,EAC1E,YAAY,EAAE,KAAK,CAAC,UAAU,QAAQ,CAAC,EAAE,SAAA,EAAW,QAAQ,QAAQ;AAAA,EACpE,cAAc,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EAClD,eAAe,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AAAA,EACnD,gBAAgB,EAAE,QAAA,EAAU,SAAS,EAAE,QAAQ,KAAK;AACtD,CAAC;AAID,eAAsB,UACpB,eAAgC,CAAC,GACjC,iBACiB;AACjB,MAAI,oBAAoB,QAAW;AACjC,sBAAkB,QAAQ;EAC5B;AACA,QAAM,qBAAqB,KAAK,QAAQ,iBAAiB,iBAAiB;AACpE,QAAA,SAAS,WAAW,kBAAkB;AAExC,MAAA;AAEJ,MAAI,QAAQ;AACV,aAAS,aAAa,MAAM;AAAA,MAC1B,GAAG,KAAK,MAAM,aAAa,oBAAoB,OAAO,CAAC;AAAA,MACvD,GAAG;AAAA,IAAA,CACJ;AAAA,EAAA,OACI;AACI,aAAA,aAAa,MAAM,YAAY;AAAA,EAC1C;AAGA,MAAI,OAAO,cAAc;AAChB,WAAA,qBAAqB,OAAO,mBAAmB;AAAA,MACpD;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAEO,SAAA;AACT;"}
@@ -1,4 +1,4 @@
1
- import { Config } from './config.js';
1
+ import type { Config } from './config.js';
2
2
  export declare const rootPathId = "__root";
3
3
  export type RouteNode = {
4
4
  filePath: string;
@@ -20,19 +20,19 @@ export type RouteNode = {
20
20
  isVirtual?: boolean;
21
21
  isLazy?: boolean;
22
22
  isRoot?: boolean;
23
- children?: RouteNode[];
23
+ children?: Array<RouteNode>;
24
24
  parent?: RouteNode;
25
25
  };
26
26
  export declare function generator(config: Config): Promise<void>;
27
27
  export declare function removeExt(d: string, keepExtension?: boolean): string;
28
- export declare function multiSortBy<T>(arr: T[], accessors?: ((item: T) => any)[]): T[];
28
+ export declare function multiSortBy<T>(arr: Array<T>, accessors?: Array<(item: T) => any>): Array<T>;
29
29
  /**
30
30
  * Removes the last segment from a given path. Segments are considered to be separated by a '/'.
31
31
  *
32
- * @param {string} path - The path from which to remove the last segment. Defaults to '/'.
32
+ * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.
33
33
  * @returns {string} The path with the last segment removed.
34
34
  * @example
35
35
  * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'
36
36
  */
37
- export declare function removeLastSegmentFromPath(path?: string): string;
38
- export declare function hasParentRoute(routes: RouteNode[], node: RouteNode, routePathToCheck: string | undefined): RouteNode | null;
37
+ export declare function removeLastSegmentFromPath(routePath?: string): string;
38
+ export declare function hasParentRoute(routes: Array<RouteNode>, node: RouteNode, routePathToCheck: string | undefined): RouteNode | null;
@@ -10,7 +10,7 @@ async function getRouteNodes(config) {
10
10
  const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } = config;
11
11
  const logger = logging({ disabled: config.disableLogging });
12
12
  const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? "", "g");
13
- let routeNodes = [];
13
+ const routeNodes = [];
14
14
  async function recurse(dir) {
15
15
  const fullDir = path.resolve(config.routesDirectory, dir);
16
16
  let dirList = await fsp.readdir(fullDir, { withFileTypes: true });
@@ -41,17 +41,17 @@ async function getRouteNodes(config) {
41
41
  routePath = routePath.replaceAll(routeFilePrefix, "");
42
42
  }
43
43
  const variableName = routePathToVariable(routePath);
44
- let isLazy = routePath == null ? void 0 : routePath.endsWith("/lazy");
44
+ const isLazy = routePath.endsWith("/lazy");
45
45
  if (isLazy) {
46
- routePath = routePath == null ? void 0 : routePath.replace(/\/lazy$/, "");
46
+ routePath = routePath.replace(/\/lazy$/, "");
47
47
  }
48
- let isRoute = routePath == null ? void 0 : routePath.endsWith("/route");
49
- let isComponent = routePath == null ? void 0 : routePath.endsWith("/component");
50
- let isErrorComponent = routePath == null ? void 0 : routePath.endsWith("/errorComponent");
51
- let isPendingComponent = routePath == null ? void 0 : routePath.endsWith("/pendingComponent");
52
- let isLoader = routePath == null ? void 0 : routePath.endsWith("/loader");
53
- const segments = (routePath ?? "").split("/");
54
- let isLayout = ((_a = segments[segments.length - 1]) == null ? void 0 : _a.startsWith("_")) || false;
48
+ const isRoute = routePath.endsWith("/route");
49
+ const isComponent = routePath.endsWith("/component");
50
+ const isErrorComponent = routePath.endsWith("/errorComponent");
51
+ const isPendingComponent = routePath.endsWith("/pendingComponent");
52
+ const isLoader = routePath.endsWith("/loader");
53
+ const segments = routePath.split("/");
54
+ const isLayout = ((_a = segments[segments.length - 1]) == null ? void 0 : _a.startsWith("_")) || false;
55
55
  [
56
56
  [isComponent, "component"],
57
57
  [isErrorComponent, "errorComponent"],
@@ -64,7 +64,7 @@ async function getRouteNodes(config) {
64
64
  );
65
65
  }
66
66
  });
67
- routePath = routePath == null ? void 0 : routePath.replace(
67
+ routePath = routePath.replace(
68
68
  /\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,
69
69
  ""
70
70
  );
@@ -93,14 +93,14 @@ async function getRouteNodes(config) {
93
93
  await recurse("./");
94
94
  return routeNodes;
95
95
  }
96
- let first = false;
96
+ let isFirst = false;
97
97
  let skipMessage = false;
98
98
  async function generator(config) {
99
99
  const logger = logging({ disabled: config.disableLogging });
100
100
  logger.log("");
101
- if (!first) {
101
+ if (!isFirst) {
102
102
  logger.log("♻️ Generating routes...");
103
- first = true;
103
+ isFirst = true;
104
104
  } else if (skipMessage) {
105
105
  skipMessage = false;
106
106
  } else {
@@ -127,20 +127,11 @@ async function generator(config) {
127
127
  var _a;
128
128
  return (_a = d.routePath) == null ? void 0 : _a.split("/").length;
129
129
  },
130
- (d) => {
131
- var _a;
132
- return ((_a = d.filePath) == null ? void 0 : _a.match(/[./]index[.]/)) ? 1 : -1;
133
- },
134
- (d) => {
135
- var _a;
136
- return ((_a = d.filePath) == null ? void 0 : _a.match(
137
- /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/
138
- )) ? 1 : -1;
139
- },
140
- (d) => {
141
- var _a;
142
- return ((_a = d.filePath) == null ? void 0 : _a.match(/[./]route[.]/)) ? -1 : 1;
143
- },
130
+ (d) => d.filePath.match(/[./]index[.]/) ? 1 : -1,
131
+ (d) => d.filePath.match(
132
+ /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/
133
+ ) ? 1 : -1,
134
+ (d) => d.filePath.match(/[./]route[.]/) ? -1 : 1,
144
135
  (d) => {
145
136
  var _a;
146
137
  return ((_a = d.routePath) == null ? void 0 : _a.endsWith("/")) ? -1 : 1;
@@ -149,7 +140,7 @@ async function generator(config) {
149
140
  ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ""));
150
141
  const routeTree = [];
151
142
  const routePiecesByPath = {};
152
- let routeNodes = [];
143
+ const routeNodes = [];
153
144
  const handleNode = async (node) => {
154
145
  var _a, _b;
155
146
  let parentRoute = hasParentRoute(routeNodes, node, node.routePath);
@@ -167,11 +158,11 @@ async function generator(config) {
167
158
  node.parent = parentRoute;
168
159
  node.path = determineNodePath(node);
169
160
  const trimmedPath = trimPathLeft(node.path ?? "");
170
- const split = (trimmedPath == null ? void 0 : trimmedPath.split("/")) ?? [];
171
- let first2 = split[0] ?? trimmedPath ?? "";
172
- const lastRouteSegment = split[split.length - 1] ?? trimmedPath ?? "";
161
+ const split = trimmedPath.split("/");
162
+ const first = split[0] ?? trimmedPath;
163
+ const lastRouteSegment = split[split.length - 1] ?? trimmedPath;
173
164
  node.isNonPath = lastRouteSegment.startsWith("_");
174
- node.isNonLayout = first2.endsWith("_");
165
+ node.isNonLayout = first.endsWith("_");
175
166
  node.cleanedPath = removeGroups(
176
167
  removeUnderscores(removeLayoutSegments(node.path)) ?? ""
177
168
  );
@@ -426,10 +417,10 @@ async function generator(config) {
426
417
  `declare module '@tanstack/react-router' {
427
418
  interface FileRoutesByPath {
428
419
  ${routeNodes.map((routeNode) => {
429
- var _a, _b, _c;
420
+ var _a, _b;
430
421
  return `'${removeTrailingUnderscores(routeNode.routePath)}': {
431
422
  preLoaderRoute: typeof ${routeNode.variableName}Import
432
- parentRoute: typeof ${routeNode.isVirtualParentRequired ? `${(_a = routeNode.parent) == null ? void 0 : _a.variableName}Route` : ((_b = routeNode.parent) == null ? void 0 : _b.variableName) ? `${(_c = routeNode.parent) == null ? void 0 : _c.variableName}Import` : "rootRoute"}
423
+ parentRoute: typeof ${routeNode.isVirtualParentRequired ? `${(_a = routeNode.parent) == null ? void 0 : _a.variableName}Route` : ((_b = routeNode.parent) == null ? void 0 : _b.variableName) ? `${routeNode.parent.variableName}Import` : "rootRoute"}
433
424
  }`;
434
425
  }).join("\n")}
435
426
  }
@@ -467,9 +458,9 @@ async function generator(config) {
467
458
  `✅ Processed ${routeNodes.length === 1 ? "route" : "routes"} in ${Date.now() - start}ms`
468
459
  );
469
460
  }
470
- function routePathToVariable(d) {
471
- var _a, _b, _c, _d;
472
- return ((_d = (_c = (_b = (_a = removeUnderscores(d)) == null ? void 0 : _a.replace(/\/\$\//g, "/splat/")) == null ? void 0 : _b.replace(/\$$/g, "splat")) == null ? void 0 : _c.replace(/\$/g, "")) == null ? void 0 : _d.split(/[/-]/g).map((d2, i) => i > 0 ? capitalize(d2) : d2).join("").replace(/([^a-zA-Z0-9]|[\.])/gm, "").replace(/^(\d)/g, "R$1")) ?? "";
461
+ function routePathToVariable(routePath) {
462
+ var _a;
463
+ return ((_a = removeUnderscores(routePath)) == null ? void 0 : _a.replace(/\/\$\//g, "/splat/").replace(/\$$/g, "splat").replace(/\$/g, "").split(/[/-]/g).map((d, i) => i > 0 ? capitalize(d) : d).join("").replace(/([^a-zA-Z0-9]|[.])/gm, "").replace(/^(\d)/g, "R$1")) ?? "";
473
464
  }
474
465
  function removeExt(d, keepExtension = false) {
475
466
  return keepExtension ? d : d.substring(0, d.lastIndexOf(".")) || d;
@@ -517,13 +508,13 @@ function determineNodePath(node) {
517
508
  var _a;
518
509
  return node.path = node.parent ? ((_a = node.routePath) == null ? void 0 : _a.replace(node.parent.routePath, "")) || "/" : node.routePath;
519
510
  }
520
- function removeLastSegmentFromPath(path2 = "/") {
521
- const segments = path2.split("/");
511
+ function removeLastSegmentFromPath(routePath = "/") {
512
+ const segments = routePath.split("/");
522
513
  segments.pop();
523
514
  return segments.join("/");
524
515
  }
525
- function removeLayoutSegments(path2 = "/") {
526
- const segments = path2.split("/");
516
+ function removeLayoutSegments(routePath = "/") {
517
+ const segments = routePath.split("/");
527
518
  const newSegments = segments.filter((segment) => !segment.startsWith("_"));
528
519
  return newSegments.join("/");
529
520
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs'\nimport * as fsp from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { Config } from './config'\nimport { cleanPath, logging, trimPathLeft } from './utils'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isLayout?: boolean\n isVirtualParentRequired?: boolean\n isVirtualParentRoute?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isLazy?: boolean\n isRoot?: boolean\n children?: RouteNode[]\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } =\n config\n const logger = logging({ disabled: config.disableLogging })\n const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? '', 'g')\n\n let routeNodes: RouteNode[] = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fsp.readdir(fullDir, { withFileTypes: true })\n\n dirList = dirList.filter((d) => {\n if (\n d.name.startsWith('.') ||\n (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.name.startsWith(routeFilePrefix)\n }\n\n if (routeFileIgnorePattern) {\n return !d.name.match(routeFileIgnoreRegExp)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (dirent) => {\n const fullPath = path.join(fullDir, dirent.name)\n const relativePath = path.join(dir, dirent.name)\n\n if (dirent.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n }\n\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n let isLazy = routePath?.endsWith('/lazy')\n\n if (isLazy) {\n routePath = routePath?.replace(/\\/lazy$/, '')\n }\n\n let isRoute = routePath?.endsWith('/route')\n let isComponent = routePath?.endsWith('/component')\n let isErrorComponent = routePath?.endsWith('/errorComponent')\n let isPendingComponent = routePath?.endsWith('/pendingComponent')\n let isLoader = routePath?.endsWith('/loader')\n\n const segments = (routePath ?? '').split('/')\n let isLayout = segments[segments.length - 1]?.startsWith('_') || false\n\n ;(\n [\n [isComponent, 'component'],\n [isErrorComponent, 'errorComponent'],\n [isPendingComponent, 'pendingComponent'],\n [isLoader, 'loader'],\n ] as const\n ).forEach(([isType, type]) => {\n if (isType) {\n logger.warn(\n `WARNING: The \\`.${type}.tsx\\` suffix used for the ${filePath} file is deprecated. Use the new \\`.lazy.tsx\\` suffix instead.`,\n )\n }\n })\n\n routePath = routePath?.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n isLazy,\n isLayout,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\n\nlet first = 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) {\n const logger = logging({ disabled: config.disableLogging })\n logger.log('')\n\n if (!first) {\n logger.log('♻️ Generating routes...')\n first = 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 const routePathIdPrefix = config.routeFilePrefix ?? ''\n const beforeRouteNodes = await getRouteNodes(config)\n const rootRouteNode = beforeRouteNodes.find(\n (d) => d.routePath === `/${rootPathId}`,\n )\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath?.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),\n (d) => (d.routePath?.endsWith('/') ? -1 : 1),\n (d) => d.routePath,\n ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))\n\n const routeTree: 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 let routeNodes: RouteNode[] = []\n\n const handleNode = async (node: RouteNode) => {\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 let first = split[0] ?? trimmedPath ?? ''\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath ?? ''\n\n node.isNonPath = lastRouteSegment.startsWith('_')\n node.isNonLayout = first.endsWith('_')\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\n if (!node.isVirtualParentRoute) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$') ?? '',\n )\n\n let replaced = routeCode\n\n if (!routeCode) {\n if (node.isLazy) {\n replaced = [\n `import { createLazyFileRoute } from '@tanstack/react-router'`,\n `export const Route = createLazyFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n } else if (\n node.isRoute ||\n (!node.isComponent &&\n !node.isErrorComponent &&\n !node.isPendingComponent &&\n !node.isLoader)\n ) {\n replaced = [\n `import { createFileRoute } from '@tanstack/react-router'`,\n `export const Route = createFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n }\n } else {\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createLazyFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n }\n\n if (replaced !== routeCode) {\n logger.log(`🟡 Updating ${node.fullPath}`)\n await fsp.writeFile(node.fullPath, replaced)\n }\n }\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent ||\n node.isLazy)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLazy\n ? 'lazy'\n : node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\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 isLazy: false,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n node.isVirtualParentRequired = node.isLayout ? !cleanedPathIsEmpty : false\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 = {\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 isLayout: false,\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.isLayout) {\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 function buildRouteConfig(nodes: RouteNode[], depth = 1): string {\n const children = nodes.map((node) => {\n if (node.isRoot) {\n return\n }\n\n if (node.isLayout && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return children.filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = buildRouteConfig(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(\"index'\") ? -1 : 1),\n (d) => d,\n ])\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 const rootPathIdExtension =\n config.addExtensions && rootRouteNode\n ? path.extname(rootRouteNode.filePath)\n : ''\n\n const routeImports = [\n '/* prettier-ignore-start */',\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n '// This file is auto-generated by TanStack Router',\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${replaceBackslash(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n `${routePathIdPrefix}${rootPathId}${rootPathIdExtension}`,\n ),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${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 ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }Import = createFileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}')()`\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 `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${config.disableTypes ? '' : '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 })\n .join('\\n\\n'),\n ...(config.disableTypes\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent?.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n '// Create and export the route tree',\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n '/* prettier-ignore-end */',\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fsp.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\nfunction routePathToVariable(d: string): string {\n return (\n removeUnderscores(d)\n ?.replace(/\\/\\$\\//g, '/splat/')\n ?.replace(/\\$$/g, 'splat')\n ?.replace(/\\$/g, '')\n ?.split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[\\.])/gm, '')\n .replace(/^(\\d)/g, 'R$1') ?? ''\n )\n}\n\nexport function removeExt(d: string, keepExtension: boolean = false) {\n return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: T[],\n accessors: ((item: T) => any)[] = [(d) => d],\n): T[] {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replaceAll(/(^_|_$)/gi, '').replaceAll(/(\\/_|_\\/)/gi, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replaceAll(/\\\\/gi, '/')\n}\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\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} path - 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 */\nexport function removeLastSegmentFromPath(path: string = '/'): string {\n const segments = path.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} path - 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(path: string = '/'): string {\n const segments = path.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\n}\n\nexport function hasParentRoute(\n routes: 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"],"names":["first","d","path"],"mappings":";;;;;AAOA,IAAI,aAAa;AACV,MAAM,aAAa;AAC1B,MAAM,yBAAyB;AA0B/B,eAAe,cAAc,QAAgB;AAC3C,QAAM,EAAE,iBAAiB,uBAAuB,uBAAA,IAC9C;AACF,QAAM,SAAS,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,QAAM,wBAAwB,IAAI,OAAO,0BAA0B,IAAI,GAAG;AAE1E,MAAI,aAA0B,CAAA;AAE9B,iBAAe,QAAQ,KAAa;AAClC,UAAM,UAAU,KAAK,QAAQ,OAAO,iBAAiB,GAAG;AACpD,QAAA,UAAU,MAAM,IAAI,QAAQ,SAAS,EAAE,eAAe,MAAM;AAEtD,cAAA,QAAQ,OAAO,CAAC,MAAM;AAE5B,UAAA,EAAE,KAAK,WAAW,GAAG,KACpB,yBAAyB,EAAE,KAAK,WAAW,qBAAqB,GACjE;AACO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AAWA,MAAK,MAAM,GAAG;AAC/B,WAAS,IAAI;AACN,SAAA,SAAS,KAAK,GAAG;AAC1B;AAUA,SAAS,qBAAqBA,QAAe,KAAa;AAClD,QAAA,WAAWA,MAAK,MAAM,GAAG;AACzB,QAAA,cAAc,SAAS,OAAO,CAAC,YAAY,CAAC,QAAQ,WAAW,GAAG,CAAC;AAClE,SAAA,YAAY,KAAK,GAAG;AAC7B;AAEgB,SAAA,eACd,QACA,MACA,kBACkB;AACd,MAAA,CAAC,oBAAoB,qBAAqB,KAAK;AAC1C,WAAA;AAAA,EACT;AAEM,QAAA,cAAc,YAAY,QAAQ;AAAA,IACtC,CAAC,MAAM,EAAE,UAAW,SAAS;AAAA,IAC7B,CAAC,MAAM,EAAE;AAAA,EAAA,CACV,EAAE,OAAO,CAAC,MAAM,EAAE,cAAc,IAAI,UAAU,EAAE;AAEjD,aAAW,SAAS,aAAa;AAC/B,QAAI,MAAM,cAAc;AAAK;AAG3B,QAAA,iBAAiB,WAAW,GAAG,MAAM,SAAS,GAAG,KACjD,MAAM,cAAc,kBACpB;AACO,aAAA;AAAA,IACT;AAAA,EACF;AAEM,QAAA,WAAW,iBAAiB,MAAM,GAAG;AAC3C,WAAS,IAAI;AACP,QAAA,kBAAkB,SAAS,KAAK,GAAG;AAElC,SAAA,eAAe,QAAQ,MAAM,eAAe;AACrD;"}
1
+ {"version":3,"file":"generator.js","sources":["../../src/generator.ts"],"sourcesContent":["import path from 'path'\nimport * as fs from 'fs'\nimport * as fsp from 'fs/promises'\nimport * as prettier from 'prettier'\nimport { cleanPath, logging, trimPathLeft } from './utils'\nimport type { Config } from './config'\n\nlet latestTask = 0\nexport const rootPathId = '__root'\nconst routeGroupPatternRegex = /\\(.+\\)/g\n\nexport type RouteNode = {\n filePath: string\n fullPath: string\n variableName: string\n routePath?: string\n cleanedPath?: string\n path?: string\n isNonPath?: boolean\n isNonLayout?: boolean\n isLayout?: boolean\n isVirtualParentRequired?: boolean\n isVirtualParentRoute?: boolean\n isRoute?: boolean\n isLoader?: boolean\n isComponent?: boolean\n isErrorComponent?: boolean\n isPendingComponent?: boolean\n isVirtual?: boolean\n isLazy?: boolean\n isRoot?: boolean\n children?: Array<RouteNode>\n parent?: RouteNode\n}\n\nasync function getRouteNodes(config: Config) {\n const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } =\n config\n const logger = logging({ disabled: config.disableLogging })\n const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? '', 'g')\n\n const routeNodes: Array<RouteNode> = []\n\n async function recurse(dir: string) {\n const fullDir = path.resolve(config.routesDirectory, dir)\n let dirList = await fsp.readdir(fullDir, { withFileTypes: true })\n\n dirList = dirList.filter((d) => {\n if (\n d.name.startsWith('.') ||\n (routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix))\n ) {\n return false\n }\n\n if (routeFilePrefix) {\n return d.name.startsWith(routeFilePrefix)\n }\n\n if (routeFileIgnorePattern) {\n return !d.name.match(routeFileIgnoreRegExp)\n }\n\n return true\n })\n\n await Promise.all(\n dirList.map(async (dirent) => {\n const fullPath = path.join(fullDir, dirent.name)\n const relativePath = path.join(dir, dirent.name)\n\n if (dirent.isDirectory()) {\n await recurse(relativePath)\n } else if (fullPath.match(/\\.(tsx|ts|jsx|js)$/)) {\n const filePath = replaceBackslash(path.join(dir, dirent.name))\n const filePathNoExt = removeExt(filePath)\n let routePath =\n cleanPath(`/${filePathNoExt.split('.').join('/')}`) || ''\n\n if (routeFilePrefix) {\n routePath = routePath.replaceAll(routeFilePrefix, '')\n }\n\n const variableName = routePathToVariable(routePath)\n\n // Remove the index from the route path and\n // if the route path is empty, use `/'\n\n const isLazy = routePath.endsWith('/lazy')\n\n if (isLazy) {\n routePath = routePath.replace(/\\/lazy$/, '')\n }\n\n const isRoute = routePath.endsWith('/route')\n const isComponent = routePath.endsWith('/component')\n const isErrorComponent = routePath.endsWith('/errorComponent')\n const isPendingComponent = routePath.endsWith('/pendingComponent')\n const isLoader = routePath.endsWith('/loader')\n\n const segments = routePath.split('/')\n const isLayout =\n segments[segments.length - 1]?.startsWith('_') || false\n\n ;(\n [\n [isComponent, 'component'],\n [isErrorComponent, 'errorComponent'],\n [isPendingComponent, 'pendingComponent'],\n [isLoader, 'loader'],\n ] as const\n ).forEach(([isType, type]) => {\n if (isType) {\n logger.warn(\n `WARNING: The \\`.${type}.tsx\\` suffix used for the ${filePath} file is deprecated. Use the new \\`.lazy.tsx\\` suffix instead.`,\n )\n }\n })\n\n routePath = routePath.replace(\n /\\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,\n '',\n )\n\n if (routePath === 'index') {\n routePath = '/'\n }\n\n routePath = routePath.replace(/\\/index$/, '/') || '/'\n\n routeNodes.push({\n filePath,\n fullPath,\n routePath,\n variableName,\n isRoute,\n isComponent,\n isErrorComponent,\n isPendingComponent,\n isLoader,\n isLazy,\n isLayout,\n })\n }\n }),\n )\n\n return routeNodes\n }\n\n await recurse('./')\n\n return routeNodes\n}\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) {\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 const routePathIdPrefix = config.routeFilePrefix ?? ''\n const beforeRouteNodes = await getRouteNodes(config)\n const rootRouteNode = beforeRouteNodes.find(\n (d) => d.routePath === `/${rootPathId}`,\n )\n\n const preRouteNodes = multiSortBy(beforeRouteNodes, [\n (d) => (d.routePath === '/' ? -1 : 1),\n (d) => d.routePath?.split('/').length,\n (d) => (d.filePath.match(/[./]index[.]/) ? 1 : -1),\n (d) =>\n d.filePath.match(\n /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,\n )\n ? 1\n : -1,\n (d) => (d.filePath.match(/[./]route[.]/) ? -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 const handleNode = async (node: RouteNode) => {\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 first = split[0] ?? trimmedPath\n const lastRouteSegment = split[split.length - 1] ?? trimmedPath\n\n node.isNonPath = lastRouteSegment.startsWith('_')\n node.isNonLayout = first.endsWith('_')\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\n if (!node.isVirtualParentRoute) {\n const routeCode = fs.readFileSync(node.fullPath, 'utf-8')\n\n const escapedRoutePath = removeTrailingUnderscores(\n node.routePath?.replaceAll('$', '$$') ?? '',\n )\n\n let replaced = routeCode\n\n if (!routeCode) {\n if (node.isLazy) {\n replaced = [\n `import { createLazyFileRoute } from '@tanstack/react-router'`,\n `export const Route = createLazyFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n } else if (\n node.isRoute ||\n (!node.isComponent &&\n !node.isErrorComponent &&\n !node.isPendingComponent &&\n !node.isLoader)\n ) {\n replaced = [\n `import { createFileRoute } from '@tanstack/react-router'`,\n `export const Route = createFileRoute('${escapedRoutePath}')({\n component: () => <div>Hello ${escapedRoutePath}!</div>\n})`,\n ].join('\\n\\n')\n }\n } else {\n replaced = routeCode\n .replace(\n /(FileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n .replace(\n /(createLazyFileRoute\\(\\s*['\"])([^\\s]*)(['\"],?\\s*\\))/g,\n (match, p1, p2, p3) => `${p1}${escapedRoutePath}${p3}`,\n )\n }\n\n if (replaced !== routeCode) {\n logger.log(`🟡 Updating ${node.fullPath}`)\n await fsp.writeFile(node.fullPath, replaced)\n }\n }\n\n if (\n !node.isVirtual &&\n (node.isLoader ||\n node.isComponent ||\n node.isErrorComponent ||\n node.isPendingComponent ||\n node.isLazy)\n ) {\n routePiecesByPath[node.routePath!] =\n routePiecesByPath[node.routePath!] || {}\n\n routePiecesByPath[node.routePath!]![\n node.isLazy\n ? 'lazy'\n : node.isLoader\n ? 'loader'\n : node.isErrorComponent\n ? 'errorComponent'\n : node.isPendingComponent\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 isLazy: false,\n isLoader: false,\n isComponent: false,\n isErrorComponent: false,\n isPendingComponent: false,\n })\n }\n return\n }\n\n const cleanedPathIsEmpty = (node.cleanedPath || '').length === 0\n node.isVirtualParentRequired = node.isLayout ? !cleanedPathIsEmpty : false\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 = {\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 isLayout: false,\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.isLayout) {\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 function buildRouteConfig(nodes: Array<RouteNode>, depth = 1): string {\n const children = nodes.map((node) => {\n if (node.isRoot) {\n return\n }\n\n if (node.isLayout && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}Route`\n\n if (node.children?.length) {\n const childConfigs = buildRouteConfig(node.children, depth + 1)\n return `${route}.addChildren([${spaces(depth * 4)}${childConfigs}])`\n }\n\n return route\n })\n\n return children.filter(Boolean).join(`,`)\n }\n\n const routeConfigChildrenText = buildRouteConfig(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(\"index'\") ? -1 : 1),\n (d) => d,\n ])\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 const rootPathIdExtension =\n config.addExtensions && rootRouteNode\n ? path.extname(rootRouteNode.filePath)\n : ''\n\n const routeImports = [\n '/* prettier-ignore-start */',\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n '// This file is auto-generated by TanStack Router',\n imports.length\n ? `import { ${imports.join(', ')} } from '@tanstack/react-router'\\n`\n : '',\n '// Import Routes',\n [\n `import { Route as rootRoute } from './${replaceBackslash(\n path.relative(\n path.dirname(config.generatedRouteTree),\n path.resolve(\n config.routesDirectory,\n `${routePathIdPrefix}${rootPathId}${rootPathIdExtension}`,\n ),\n ),\n )}'`,\n ...sortedRouteNodes\n .filter((d) => !d.isVirtual)\n .map((node) => {\n return `import { Route as ${\n node.variableName\n }Import } from './${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 ].join('\\n'),\n virtualRouteNodes.length ? '// Create Virtual Routes' : '',\n virtualRouteNodes\n .map((node) => {\n return `const ${\n node.variableName\n }Import = createFileRoute('${removeTrailingUnderscores(\n node.routePath,\n )}')()`\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 `const ${node.variableName}Route = ${node.variableName}Import.update({\n ${[\n node.isNonPath\n ? `id: '${node.path}'`\n : `path: '${node.cleanedPath}'`,\n `getParentRoute: () => ${node.parent?.variableName ?? 'root'}Route`,\n ]\n .filter(Boolean)\n .join(',')}\n }${config.disableTypes ? '' : '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 })\n .join('\\n\\n'),\n ...(config.disableTypes\n ? []\n : [\n '// Populate the FileRoutesByPath interface',\n `declare module '@tanstack/react-router' {\n interface FileRoutesByPath {\n ${routeNodes\n .map((routeNode) => {\n return `'${removeTrailingUnderscores(routeNode.routePath)}': {\n preLoaderRoute: typeof ${routeNode.variableName}Import\n parentRoute: typeof ${\n routeNode.isVirtualParentRequired\n ? `${routeNode.parent?.variableName}Route`\n : routeNode.parent?.variableName\n ? `${routeNode.parent.variableName}Import`\n : 'rootRoute'\n }\n }`\n })\n .join('\\n')}\n }\n}`,\n ]),\n '// Create and export the route tree',\n `export const routeTree = rootRoute.addChildren([${routeConfigChildrenText}])`,\n '/* prettier-ignore-end */',\n ]\n .filter(Boolean)\n .join('\\n\\n')\n\n const routeConfigFileContent = await prettier.format(routeImports, {\n semi: false,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n })\n\n const routeTreeContent = await fsp\n .readFile(path.resolve(config.generatedRouteTree), 'utf-8')\n .catch((err: any) => {\n if (err.code === 'ENOENT') {\n return undefined\n }\n throw err\n })\n\n if (!checkLatest()) return\n\n if (routeTreeContent !== routeConfigFileContent) {\n await fsp.mkdir(path.dirname(path.resolve(config.generatedRouteTree)), {\n recursive: true,\n })\n if (!checkLatest()) return\n await fsp.writeFile(\n path.resolve(config.generatedRouteTree),\n routeConfigFileContent,\n )\n }\n\n logger.log(\n `✅ Processed ${routeNodes.length === 1 ? 'route' : 'routes'} in ${\n Date.now() - start\n }ms`,\n )\n}\n\nfunction routePathToVariable(routePath: string): string {\n return (\n removeUnderscores(routePath)\n ?.replace(/\\/\\$\\//g, '/splat/')\n .replace(/\\$$/g, 'splat')\n .replace(/\\$/g, '')\n .split(/[/-]/g)\n .map((d, i) => (i > 0 ? capitalize(d) : d))\n .join('')\n .replace(/([^a-zA-Z0-9]|[.])/gm, '')\n .replace(/^(\\d)/g, 'R$1') ?? ''\n )\n}\n\nexport function removeExt(d: string, keepExtension: boolean = false) {\n return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d\n}\n\nfunction spaces(d: number): string {\n return Array.from({ length: d })\n .map(() => ' ')\n .join('')\n}\n\nexport function multiSortBy<T>(\n arr: Array<T>,\n accessors: Array<(item: T) => any> = [(d) => d],\n): Array<T> {\n return arr\n .map((d, i) => [d, i] as const)\n .sort(([a, ai], [b, bi]) => {\n for (const accessor of accessors) {\n const ao = accessor(a)\n const bo = accessor(b)\n\n if (typeof ao === 'undefined') {\n if (typeof bo === 'undefined') {\n continue\n }\n return 1\n }\n\n if (ao === bo) {\n continue\n }\n\n return ao > bo ? 1 : -1\n }\n\n return ai - bi\n })\n .map(([d]) => d)\n}\n\nfunction capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nfunction removeUnderscores(s?: string) {\n return s?.replaceAll(/(^_|_$)/gi, '').replaceAll(/(\\/_|_\\/)/gi, '/')\n}\n\nfunction removeTrailingUnderscores(s?: string) {\n return s?.replaceAll(/(_$)/gi, '').replaceAll(/(_\\/)/gi, '/')\n}\n\nfunction replaceBackslash(s: string) {\n return s.replaceAll(/\\\\/gi, '/')\n}\n\nfunction removeGroups(s: string) {\n return s.replaceAll(routeGroupPatternRegex, '').replaceAll('//', '/')\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 */\nexport function 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\nexport function 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"],"names":[],"mappings":";;;;;AAOA,IAAI,aAAa;AACV,MAAM,aAAa;AAC1B,MAAM,yBAAyB;AA0B/B,eAAe,cAAc,QAAgB;AAC3C,QAAM,EAAE,iBAAiB,uBAAuB,uBAAA,IAC9C;AACF,QAAM,SAAS,QAAQ,EAAE,UAAU,OAAO,gBAAgB;AAC1D,QAAM,wBAAwB,IAAI,OAAO,0BAA0B,IAAI,GAAG;AAE1E,QAAM,aAA+B,CAAA;AAErC,iBAAe,QAAQ,KAAa;AAClC,UAAM,UAAU,KAAK,QAAQ,OAAO,iBAAiB,GAAG;AACpD,QAAA,UAAU,MAAM,IAAI,QAAQ,SAAS,EAAE,eAAe,MAAM;AAEtD,cAAA,QAAQ,OAAO,CAAC,MAAM;AAE5B,UAAA,EAAE,KAAK,WAAW,GAAG,KACpB,yBAAyB,EAAE,KAAK,WAAW,qBAAqB,GACjE;AACO,eAAA;AAAA,MACT;AAEA,UAAI,iBAAiB;AACZ,eAAA,EAAE,KAAK,WAAW,eAAe;AAAA,MAC1C;AAEA,UAAI,wBAAwB;AAC1B,eAAO,CAAC,EAAE,KAAK,MAAM,qBAAqB;AAAA,MAC5C;AAEO,aAAA;AAAA,IAAA,CACR;AAED,UAAM,QAAQ;AAAA,MACZ,QAAQ,IA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,MAAA,CAAC,oBAAoB,qBAAqB,KAAK;AAC1C,WAAA;AAAA,EACT;AAEM,QAAA,cAAc,YAAY,QAAQ;AAAA,IACtC,CAAC,MAAM,EAAE,UAAW,SAAS;AAAA,IAC7B,CAAC,MAAM,EAAE;AAAA,EAAA,CACV,EAAE,OAAO,CAAC,MAAM,EAAE,cAAc,IAAI,UAAU,EAAE;AAEjD,aAAW,SAAS,aAAa;AAC/B,QAAI,MAAM,cAAc;AAAK;AAG3B,QAAA,iBAAiB,WAAW,GAAG,MAAM,SAAS,GAAG,KACjD,MAAM,cAAc,kBACpB;AACO,aAAA;AAAA,IACT;AAAA,EACF;AAEM,QAAA,WAAW,iBAAiB,MAAM,GAAG;AAC3C,WAAS,IAAI;AACP,QAAA,kBAAkB,SAAS,KAAK,GAAG;AAElC,SAAA,eAAe,QAAQ,MAAM,eAAe;AACrD;"}
@@ -3,9 +3,9 @@ export declare function trimPathLeft(path: string): string;
3
3
  export declare function logging(config: {
4
4
  disabled: boolean;
5
5
  }): {
6
- log: (...args: any[]) => void;
7
- debug: (...args: any[]) => void;
8
- info: (...args: any[]) => void;
9
- warn: (...args: any[]) => void;
10
- error: (...args: any[]) => void;
6
+ log: (...args: Array<any>) => void;
7
+ debug: (...args: Array<any>) => void;
8
+ info: (...args: Array<any>) => void;
9
+ warn: (...args: Array<any>) => void;
10
+ error: (...args: Array<any>) => void;
11
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["export function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function logging(config: { disabled: boolean }) {\n return {\n log: (...args: any[]) => {\n if (!config.disabled) console.log(...args)\n },\n debug: (...args: any[]) => {\n if (!config.disabled) console.debug(...args)\n },\n info: (...args: any[]) => {\n if (!config.disabled) console.info(...args)\n },\n warn: (...args: any[]) => {\n if (!config.disabled) console.warn(...args)\n },\n error: (...args: any[]) => {\n if (!config.disabled) console.error(...args)\n },\n }\n}\n"],"names":[],"mappings":"AAAO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,QAAQ,QAA+B;AAC9C,SAAA;AAAA,IACL,KAAK,IAAI,SAAgB;AACvB,UAAI,CAAC,OAAO;AAAkB,gBAAA,IAAI,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,OAAO,IAAI,SAAgB;AACzB,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,IACA,MAAM,IAAI,SAAgB;AACxB,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,MAAM,IAAI,SAAgB;AACxB,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,OAAO,IAAI,SAAgB;AACzB,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["export function cleanPath(path: string) {\n // remove double slashes\n return path.replace(/\\/{2,}/g, '/')\n}\n\nexport function trimPathLeft(path: string) {\n return path === '/' ? path : path.replace(/^\\/{1,}/, '')\n}\n\nexport function logging(config: { disabled: boolean }) {\n return {\n log: (...args: Array<any>) => {\n if (!config.disabled) console.log(...args)\n },\n debug: (...args: Array<any>) => {\n if (!config.disabled) console.debug(...args)\n },\n info: (...args: Array<any>) => {\n if (!config.disabled) console.info(...args)\n },\n warn: (...args: Array<any>) => {\n if (!config.disabled) console.warn(...args)\n },\n error: (...args: Array<any>) => {\n if (!config.disabled) console.error(...args)\n },\n }\n}\n"],"names":[],"mappings":"AAAO,SAAS,UAAU,MAAc;AAE/B,SAAA,KAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAa,MAAc;AACzC,SAAO,SAAS,MAAM,OAAO,KAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,QAAQ,QAA+B;AAC9C,SAAA;AAAA,IACL,KAAK,IAAI,SAAqB;AAC5B,UAAI,CAAC,OAAO;AAAkB,gBAAA,IAAI,GAAG,IAAI;AAAA,IAC3C;AAAA,IACA,OAAO,IAAI,SAAqB;AAC9B,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,IACA,MAAM,IAAI,SAAqB;AAC7B,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,MAAM,IAAI,SAAqB;AAC7B,UAAI,CAAC,OAAO;AAAkB,gBAAA,KAAK,GAAG,IAAI;AAAA,IAC5C;AAAA,IACA,OAAO,IAAI,SAAqB;AAC9B,UAAI,CAAC,OAAO;AAAkB,gBAAA,MAAM,GAAG,IAAI;AAAA,IAC7C;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-generator",
3
- "version": "1.20.5",
3
+ "version": "1.22.6",
4
4
  "description": "",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -54,6 +54,7 @@
54
54
  },
55
55
  "scripts": {
56
56
  "clean": "rimraf ./dist && rimraf ./coverage",
57
+ "test:eslint": "eslint --ext .ts,.tsx ./src",
57
58
  "test:types": "tsc",
58
59
  "test:lib": "vitest",
59
60
  "test:build": "publint --strict",
package/src/config.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import path from 'path'
2
- import { readFileSync, existsSync } from 'fs'
2
+ import { existsSync, readFileSync } from 'fs'
3
3
  import { z } from 'zod'
4
4
 
5
5
  export const configSchema = z.object({
package/src/generator.ts CHANGED
@@ -2,8 +2,8 @@ import path from 'path'
2
2
  import * as fs from 'fs'
3
3
  import * as fsp from 'fs/promises'
4
4
  import * as prettier from 'prettier'
5
- import { Config } from './config'
6
5
  import { cleanPath, logging, trimPathLeft } from './utils'
6
+ import type { Config } from './config'
7
7
 
8
8
  let latestTask = 0
9
9
  export const rootPathId = '__root'
@@ -29,7 +29,7 @@ export type RouteNode = {
29
29
  isVirtual?: boolean
30
30
  isLazy?: boolean
31
31
  isRoot?: boolean
32
- children?: RouteNode[]
32
+ children?: Array<RouteNode>
33
33
  parent?: RouteNode
34
34
  }
35
35
 
@@ -39,7 +39,7 @@ async function getRouteNodes(config: Config) {
39
39
  const logger = logging({ disabled: config.disableLogging })
40
40
  const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? '', 'g')
41
41
 
42
- let routeNodes: RouteNode[] = []
42
+ const routeNodes: Array<RouteNode> = []
43
43
 
44
44
  async function recurse(dir: string) {
45
45
  const fullDir = path.resolve(config.routesDirectory, dir)
@@ -86,20 +86,21 @@ async function getRouteNodes(config: Config) {
86
86
  // Remove the index from the route path and
87
87
  // if the route path is empty, use `/'
88
88
 
89
- let isLazy = routePath?.endsWith('/lazy')
89
+ const isLazy = routePath.endsWith('/lazy')
90
90
 
91
91
  if (isLazy) {
92
- routePath = routePath?.replace(/\/lazy$/, '')
92
+ routePath = routePath.replace(/\/lazy$/, '')
93
93
  }
94
94
 
95
- let isRoute = routePath?.endsWith('/route')
96
- let isComponent = routePath?.endsWith('/component')
97
- let isErrorComponent = routePath?.endsWith('/errorComponent')
98
- let isPendingComponent = routePath?.endsWith('/pendingComponent')
99
- let isLoader = routePath?.endsWith('/loader')
95
+ const isRoute = routePath.endsWith('/route')
96
+ const isComponent = routePath.endsWith('/component')
97
+ const isErrorComponent = routePath.endsWith('/errorComponent')
98
+ const isPendingComponent = routePath.endsWith('/pendingComponent')
99
+ const isLoader = routePath.endsWith('/loader')
100
100
 
101
- const segments = (routePath ?? '').split('/')
102
- let isLayout = segments[segments.length - 1]?.startsWith('_') || false
101
+ const segments = routePath.split('/')
102
+ const isLayout =
103
+ segments[segments.length - 1]?.startsWith('_') || false
103
104
 
104
105
  ;(
105
106
  [
@@ -116,7 +117,7 @@ async function getRouteNodes(config: Config) {
116
117
  }
117
118
  })
118
119
 
119
- routePath = routePath?.replace(
120
+ routePath = routePath.replace(
120
121
  /\/(component|errorComponent|pendingComponent|loader|route|lazy)$/,
121
122
  '',
122
123
  )
@@ -152,7 +153,7 @@ async function getRouteNodes(config: Config) {
152
153
  return routeNodes
153
154
  }
154
155
 
155
- let first = false
156
+ let isFirst = false
156
157
  let skipMessage = false
157
158
 
158
159
  type RouteSubNode = {
@@ -167,9 +168,9 @@ export async function generator(config: Config) {
167
168
  const logger = logging({ disabled: config.disableLogging })
168
169
  logger.log('')
169
170
 
170
- if (!first) {
171
+ if (!isFirst) {
171
172
  logger.log('♻️ Generating routes...')
172
- first = true
173
+ isFirst = true
173
174
  } else if (skipMessage) {
174
175
  skipMessage = false
175
176
  } else {
@@ -198,24 +199,24 @@ export async function generator(config: Config) {
198
199
  const preRouteNodes = multiSortBy(beforeRouteNodes, [
199
200
  (d) => (d.routePath === '/' ? -1 : 1),
200
201
  (d) => d.routePath?.split('/').length,
201
- (d) => (d.filePath?.match(/[./]index[.]/) ? 1 : -1),
202
+ (d) => (d.filePath.match(/[./]index[.]/) ? 1 : -1),
202
203
  (d) =>
203
- d.filePath?.match(
204
+ d.filePath.match(
204
205
  /[./](component|errorComponent|pendingComponent|loader|lazy)[.]/,
205
206
  )
206
207
  ? 1
207
208
  : -1,
208
- (d) => (d.filePath?.match(/[./]route[.]/) ? -1 : 1),
209
+ (d) => (d.filePath.match(/[./]route[.]/) ? -1 : 1),
209
210
  (d) => (d.routePath?.endsWith('/') ? -1 : 1),
210
211
  (d) => d.routePath,
211
212
  ]).filter((d) => ![`/${rootPathId}`].includes(d.routePath || ''))
212
213
 
213
- const routeTree: RouteNode[] = []
214
+ const routeTree: Array<RouteNode> = []
214
215
  const routePiecesByPath: Record<string, RouteSubNode> = {}
215
216
 
216
217
  // Loop over the flat list of routeNodes and
217
218
  // build up a tree based on the routeNodes' routePath
218
- let routeNodes: RouteNode[] = []
219
+ const routeNodes: Array<RouteNode> = []
219
220
 
220
221
  const handleNode = async (node: RouteNode) => {
221
222
  let parentRoute = hasParentRoute(routeNodes, node, node.routePath)
@@ -239,9 +240,9 @@ export async function generator(config: Config) {
239
240
 
240
241
  const trimmedPath = trimPathLeft(node.path ?? '')
241
242
 
242
- const split = trimmedPath?.split('/') ?? []
243
- let first = split[0] ?? trimmedPath ?? ''
244
- const lastRouteSegment = split[split.length - 1] ?? trimmedPath ?? ''
243
+ const split = trimmedPath.split('/')
244
+ const first = split[0] ?? trimmedPath
245
+ const lastRouteSegment = split[split.length - 1] ?? trimmedPath
245
246
 
246
247
  node.isNonPath = lastRouteSegment.startsWith('_')
247
248
  node.isNonLayout = first.endsWith('_')
@@ -402,7 +403,7 @@ export async function generator(config: Config) {
402
403
  await handleNode(node)
403
404
  }
404
405
 
405
- function buildRouteConfig(nodes: RouteNode[], depth = 1): string {
406
+ function buildRouteConfig(nodes: Array<RouteNode>, depth = 1): string {
406
407
  const children = nodes.map((node) => {
407
408
  if (node.isRoot) {
408
409
  return
@@ -567,7 +568,7 @@ export async function generator(config: Config) {
567
568
  path.dirname(config.generatedRouteTree),
568
569
  path.resolve(
569
570
  config.routesDirectory,
570
- lazyComponentNode!.filePath,
571
+ lazyComponentNode.filePath,
571
572
  ),
572
573
  ),
573
574
  config.addExtensions,
@@ -591,7 +592,7 @@ export async function generator(config: Config) {
591
592
  routeNode.isVirtualParentRequired
592
593
  ? `${routeNode.parent?.variableName}Route`
593
594
  : routeNode.parent?.variableName
594
- ? `${routeNode.parent?.variableName}Import`
595
+ ? `${routeNode.parent.variableName}Import`
595
596
  : 'rootRoute'
596
597
  }
597
598
  }`
@@ -642,16 +643,16 @@ export async function generator(config: Config) {
642
643
  )
643
644
  }
644
645
 
645
- function routePathToVariable(d: string): string {
646
+ function routePathToVariable(routePath: string): string {
646
647
  return (
647
- removeUnderscores(d)
648
+ removeUnderscores(routePath)
648
649
  ?.replace(/\/\$\//g, '/splat/')
649
- ?.replace(/\$$/g, 'splat')
650
- ?.replace(/\$/g, '')
651
- ?.split(/[/-]/g)
650
+ .replace(/\$$/g, 'splat')
651
+ .replace(/\$/g, '')
652
+ .split(/[/-]/g)
652
653
  .map((d, i) => (i > 0 ? capitalize(d) : d))
653
654
  .join('')
654
- .replace(/([^a-zA-Z0-9]|[\.])/gm, '')
655
+ .replace(/([^a-zA-Z0-9]|[.])/gm, '')
655
656
  .replace(/^(\d)/g, 'R$1') ?? ''
656
657
  )
657
658
  }
@@ -667,9 +668,9 @@ function spaces(d: number): string {
667
668
  }
668
669
 
669
670
  export function multiSortBy<T>(
670
- arr: T[],
671
- accessors: ((item: T) => any)[] = [(d) => d],
672
- ): T[] {
671
+ arr: Array<T>,
672
+ accessors: Array<(item: T) => any> = [(d) => d],
673
+ ): Array<T> {
673
674
  return arr
674
675
  .map((d, i) => [d, i] as const)
675
676
  .sort(([a, ai], [b, bi]) => {
@@ -732,13 +733,13 @@ function determineNodePath(node: RouteNode) {
732
733
  /**
733
734
  * Removes the last segment from a given path. Segments are considered to be separated by a '/'.
734
735
  *
735
- * @param {string} path - The path from which to remove the last segment. Defaults to '/'.
736
+ * @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.
736
737
  * @returns {string} The path with the last segment removed.
737
738
  * @example
738
739
  * removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'
739
740
  */
740
- export function removeLastSegmentFromPath(path: string = '/'): string {
741
- const segments = path.split('/')
741
+ export function removeLastSegmentFromPath(routePath: string = '/'): string {
742
+ const segments = routePath.split('/')
742
743
  segments.pop() // Remove the last segment
743
744
  return segments.join('/')
744
745
  }
@@ -746,19 +747,19 @@ export function removeLastSegmentFromPath(path: string = '/'): string {
746
747
  /**
747
748
  * Removes all segments from a given path that start with an underscore ('_').
748
749
  *
749
- * @param {string} path - The path from which to remove segments. Defaults to '/'.
750
+ * @param {string} routePath - The path from which to remove segments. Defaults to '/'.
750
751
  * @returns {string} The path with all underscore-prefixed segments removed.
751
752
  * @example
752
753
  * removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'
753
754
  */
754
- function removeLayoutSegments(path: string = '/'): string {
755
- const segments = path.split('/')
755
+ function removeLayoutSegments(routePath: string = '/'): string {
756
+ const segments = routePath.split('/')
756
757
  const newSegments = segments.filter((segment) => !segment.startsWith('_'))
757
758
  return newSegments.join('/')
758
759
  }
759
760
 
760
761
  export function hasParentRoute(
761
- routes: RouteNode[],
762
+ routes: Array<RouteNode>,
762
763
  node: RouteNode,
763
764
  routePathToCheck: string | undefined,
764
765
  ): RouteNode | null {
package/src/utils.ts CHANGED
@@ -9,19 +9,19 @@ export function trimPathLeft(path: string) {
9
9
 
10
10
  export function logging(config: { disabled: boolean }) {
11
11
  return {
12
- log: (...args: any[]) => {
12
+ log: (...args: Array<any>) => {
13
13
  if (!config.disabled) console.log(...args)
14
14
  },
15
- debug: (...args: any[]) => {
15
+ debug: (...args: Array<any>) => {
16
16
  if (!config.disabled) console.debug(...args)
17
17
  },
18
- info: (...args: any[]) => {
18
+ info: (...args: Array<any>) => {
19
19
  if (!config.disabled) console.info(...args)
20
20
  },
21
- warn: (...args: any[]) => {
21
+ warn: (...args: Array<any>) => {
22
22
  if (!config.disabled) console.warn(...args)
23
23
  },
24
- error: (...args: any[]) => {
24
+ error: (...args: Array<any>) => {
25
25
  if (!config.disabled) console.error(...args)
26
26
  },
27
27
  }