@tanstack/router-generator 1.120.5 → 1.121.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/cjs/config.cjs +14 -14
  2. package/dist/cjs/config.cjs.map +1 -1
  3. package/dist/cjs/config.d.cts +68 -31
  4. package/dist/cjs/filesystem/physical/getRouteNodes.cjs +1 -5
  5. package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +1 -1
  6. package/dist/cjs/filesystem/physical/getRouteNodes.d.cts +2 -2
  7. package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +1 -1
  8. package/dist/cjs/filesystem/virtual/getRouteNodes.d.cts +2 -2
  9. package/dist/cjs/generator.cjs +160 -172
  10. package/dist/cjs/generator.cjs.map +1 -1
  11. package/dist/cjs/generator.d.cts +0 -59
  12. package/dist/cjs/index.cjs +23 -2
  13. package/dist/cjs/index.cjs.map +1 -1
  14. package/dist/cjs/index.d.cts +8 -4
  15. package/dist/cjs/template.cjs +4 -12
  16. package/dist/cjs/template.cjs.map +1 -1
  17. package/dist/cjs/template.d.cts +0 -1
  18. package/dist/cjs/types.d.cts +1 -1
  19. package/dist/cjs/utils.cjs +64 -5
  20. package/dist/cjs/utils.cjs.map +1 -1
  21. package/dist/cjs/utils.d.cts +11 -2
  22. package/dist/esm/config.d.ts +68 -31
  23. package/dist/esm/config.js +14 -14
  24. package/dist/esm/config.js.map +1 -1
  25. package/dist/esm/filesystem/physical/getRouteNodes.d.ts +2 -2
  26. package/dist/esm/filesystem/physical/getRouteNodes.js +2 -6
  27. package/dist/esm/filesystem/physical/getRouteNodes.js.map +1 -1
  28. package/dist/esm/filesystem/virtual/getRouteNodes.d.ts +2 -2
  29. package/dist/esm/filesystem/virtual/getRouteNodes.js.map +1 -1
  30. package/dist/esm/generator.d.ts +0 -59
  31. package/dist/esm/generator.js +163 -175
  32. package/dist/esm/generator.js.map +1 -1
  33. package/dist/esm/index.d.ts +8 -4
  34. package/dist/esm/index.js +25 -4
  35. package/dist/esm/index.js.map +1 -1
  36. package/dist/esm/template.d.ts +0 -1
  37. package/dist/esm/template.js +4 -12
  38. package/dist/esm/template.js.map +1 -1
  39. package/dist/esm/types.d.ts +1 -1
  40. package/dist/esm/utils.d.ts +11 -2
  41. package/dist/esm/utils.js +63 -4
  42. package/dist/esm/utils.js.map +1 -1
  43. package/package.json +3 -3
  44. package/src/config.ts +14 -11
  45. package/src/filesystem/physical/getRouteNodes.ts +13 -14
  46. package/src/filesystem/virtual/getRouteNodes.ts +18 -3
  47. package/src/generator.ts +242 -221
  48. package/src/index.ts +32 -7
  49. package/src/template.ts +4 -15
  50. package/src/types.ts +0 -1
  51. package/src/utils.ts +102 -6
@@ -26,10 +26,7 @@ function _interopNamespaceDefault(e) {
26
26
  }
27
27
  const fs__namespace = /* @__PURE__ */ _interopNamespaceDefault(fs);
28
28
  const fsp__namespace = /* @__PURE__ */ _interopNamespaceDefault(fsp);
29
- const CONSTANTS = {
30
- // When changing this, you'll want to update the import in `start-api-routes/src/index.ts#defaultAPIFileRouteHandler`
31
- APIRouteExportVariable: "APIRoute"
32
- };
29
+ const rootRouteId = "__root__";
33
30
  let latestTask = 0;
34
31
  const routeGroupPatternRegex = /\(.+\)/g;
35
32
  const possiblyNestedRouteGroupPatternRegex = /\([^/]+\)\/?/g;
@@ -58,7 +55,6 @@ async function generator(config, root) {
58
55
  };
59
56
  const start = Date.now();
60
57
  const TYPES_DISABLED = config.disableTypes;
61
- const ENABLED_API_ROUTES_GENERATION = config.__enableAPIRoutesGeneration ?? false;
62
58
  let getRouteNodesResult;
63
59
  if (config.virtualRouteConfig) {
64
60
  getRouteNodesResult = await getRouteNodes.getRouteNodes(config, root);
@@ -94,23 +90,6 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
94
90
  ]).filter((d) => ![`/${rootPathId.rootPathId}`].includes(d.routePath || ""));
95
91
  const routeTree = [];
96
92
  const routePiecesByPath = {};
97
- const onlyAPIRouteNodes = preRouteNodes.filter((d) => {
98
- if (!ENABLED_API_ROUTES_GENERATION) {
99
- return false;
100
- }
101
- if (d._fsRouteType !== "api") {
102
- return false;
103
- }
104
- return true;
105
- });
106
- const onlyGeneratorRouteNodes = preRouteNodes.filter((d) => {
107
- if (ENABLED_API_ROUTES_GENERATION) {
108
- if (d._fsRouteType === "api") {
109
- return false;
110
- }
111
- }
112
- return true;
113
- });
114
93
  const routeNodes = [];
115
94
  const handleRootNode = async (node) => {
116
95
  if (!node) {
@@ -175,7 +154,7 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
175
154
  (((_c = config.customScaffolding) == null ? void 0 : _c.lazyRouteTemplate) || ((_d = config.customScaffolding) == null ? void 0 : _d.routeTemplate)) ?? tLazyRouteTemplate.template(),
176
155
  {
177
156
  tsrImports: tLazyRouteTemplate.imports.tsrImports(),
178
- tsrPath: escapedRoutePath,
157
+ tsrPath: escapedRoutePath.replaceAll(/\{(.+)\}/gm, "$1"),
179
158
  tsrExportStart: tLazyRouteTemplate.imports.tsrExportStart(escapedRoutePath),
180
159
  tsrExportEnd: tLazyRouteTemplate.imports.tsrExportEnd()
181
160
  }
@@ -196,16 +175,66 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
196
175
  ((_e = config.customScaffolding) == null ? void 0 : _e.routeTemplate) ?? tRouteTemplate.template(),
197
176
  {
198
177
  tsrImports: tRouteTemplate.imports.tsrImports(),
199
- tsrPath: escapedRoutePath,
178
+ tsrPath: escapedRoutePath.replaceAll(/\{(.+)\}/gm, "$1"),
200
179
  tsrExportStart: tRouteTemplate.imports.tsrExportStart(escapedRoutePath),
201
180
  tsrExportEnd: tRouteTemplate.imports.tsrExportEnd()
202
181
  }
203
182
  );
204
183
  }
184
+ } else if (config.verboseFileRoutes === false) {
185
+ if (!routeCode.split("\n").some((line) => line.trim().startsWith("export const Route"))) {
186
+ return;
187
+ }
188
+ replaced = routeCode.replace(
189
+ /(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
190
+ (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`
191
+ ).replace(
192
+ new RegExp(
193
+ `(import\\s*\\{)(.*)(create(Lazy)?FileRoute)(.*)(\\}\\s*from\\s*['"]@tanstack\\/${ROUTE_TEMPLATE.subPkg}['"])`,
194
+ "gs"
195
+ ),
196
+ (_, p1, p2, ___, ____, p5, p6) => {
197
+ const beforeCreateFileRoute = () => {
198
+ if (!p2) return "";
199
+ let trimmed = p2.trim();
200
+ if (trimmed.endsWith(",")) {
201
+ trimmed = trimmed.slice(0, -1);
202
+ }
203
+ return trimmed;
204
+ };
205
+ const afterCreateFileRoute = () => {
206
+ if (!p5) return "";
207
+ let trimmed = p5.trim();
208
+ if (trimmed.startsWith(",")) {
209
+ trimmed = trimmed.slice(1);
210
+ }
211
+ return trimmed;
212
+ };
213
+ const newImport = () => {
214
+ const before = beforeCreateFileRoute();
215
+ const after = afterCreateFileRoute();
216
+ if (!before) return after;
217
+ if (!after) return before;
218
+ return `${before},${after}`;
219
+ };
220
+ const middle = newImport();
221
+ if (middle === "") return "";
222
+ return `${p1} ${newImport()} ${p6}`;
223
+ }
224
+ ).replace(
225
+ /create(Lazy)?FileRoute(\(\s*['"])([^\s]*)(['"],?\s*\))/g,
226
+ (_, __, p2, ___, p4) => `${node._fsRouteType === "lazy" ? "createLazyFileRoute" : "createFileRoute"}`
227
+ );
205
228
  } else {
229
+ if (!routeCode.split("\n").some((line) => line.trim().startsWith("export const Route"))) {
230
+ return;
231
+ }
206
232
  replaced = routeCode.replace(
207
233
  /(FileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
208
234
  (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`
235
+ ).replace(
236
+ /((FileRoute)(\s*)(\({))/g,
237
+ (_, __, p2, p3, p4) => `${p2}('${escapedRoutePath}')${p3}${p4}`
209
238
  ).replace(
210
239
  new RegExp(
211
240
  `(import\\s*\\{.*)(create(Lazy)?FileRoute)(.*\\}\\s*from\\s*['"]@tanstack\\/${ROUTE_TEMPLATE.subPkg}['"])`,
@@ -216,6 +245,16 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
216
245
  /create(Lazy)?FileRoute(\(\s*['"])([^\s]*)(['"],?\s*\))/g,
217
246
  (_, __, p2, ___, p4) => `${node._fsRouteType === "lazy" ? "createLazyFileRoute" : "createFileRoute"}${p2}${escapedRoutePath}${p4}`
218
247
  );
248
+ const regex = new RegExp(
249
+ `(import\\s*\\{.*)(create(Lazy)?FileRoute)(.*\\}\\s*from\\s*['"]@tanstack\\/${ROUTE_TEMPLATE.subPkg}['"])`,
250
+ "gm"
251
+ );
252
+ if (!replaced.match(regex)) {
253
+ replaced = [
254
+ `import { ${node._fsRouteType === "lazy" ? "createLazyFileRoute" : "createFileRoute"} } from '@tanstack/${ROUTE_TEMPLATE.subPkg}'`,
255
+ ...replaced.split("\n")
256
+ ].join("\n");
257
+ }
219
258
  }
220
259
  await utils.writeIfDifferent(node.fullPath, routeCode, replaced, {
221
260
  beforeWrite: () => {
@@ -288,68 +327,15 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
288
327
  }
289
328
  routeNodes.push(node);
290
329
  };
291
- for (const node of onlyGeneratorRouteNodes) {
330
+ for (const node of preRouteNodes) {
292
331
  await handleNode(node);
293
332
  }
294
333
  checkRouteFullPathUniqueness(
295
334
  preRouteNodes.filter(
296
- (d) => d.children === void 0 && ["api", "lazy"].every(
297
- (type) => type !== d._fsRouteType
298
- )
335
+ (d) => d.children === void 0 && "lazy" !== d._fsRouteType
299
336
  ),
300
337
  config
301
338
  );
302
- const startAPIRouteNodes = checkStartAPIRoutes(
303
- onlyAPIRouteNodes,
304
- config
305
- );
306
- const handleAPINode = async (node) => {
307
- var _a, _b;
308
- const routeCode = fs__namespace.readFileSync(node.fullPath, "utf-8");
309
- const escapedRoutePath = ((_a = node.routePath) == null ? void 0 : _a.replaceAll("$", "$$")) ?? "";
310
- if (!routeCode) {
311
- const replaced = await template.fillTemplate(
312
- config,
313
- ((_b = config.customScaffolding) == null ? void 0 : _b.apiTemplate) ?? template.defaultAPIRouteTemplate,
314
- {
315
- tsrImports: "import { createAPIFileRoute } from '@tanstack/react-start/api';",
316
- tsrPath: escapedRoutePath,
317
- tsrExportStart: `export const ${CONSTANTS.APIRouteExportVariable} = createAPIFileRoute('${escapedRoutePath}')(`,
318
- tsrExportEnd: ");"
319
- }
320
- );
321
- await utils.writeIfDifferent(
322
- node.fullPath,
323
- "",
324
- // Empty string because the file doesn't exist yet
325
- replaced,
326
- {
327
- beforeWrite: () => {
328
- logger.log(`🟡 Creating ${node.fullPath}`);
329
- }
330
- }
331
- );
332
- } else {
333
- await utils.writeIfDifferent(
334
- node.fullPath,
335
- routeCode,
336
- routeCode.replace(
337
- /(createAPIFileRoute\(\s*['"])([^\s]*)(['"],?\s*\))/g,
338
- (_, p1, __, p3) => `${p1}${escapedRoutePath}${p3}`
339
- ),
340
- {
341
- beforeWrite: () => {
342
- logger.log(`🟡 Updating ${node.fullPath}`);
343
- }
344
- }
345
- );
346
- }
347
- };
348
- if (ENABLED_API_ROUTES_GENERATION) {
349
- for (const node of startAPIRouteNodes) {
350
- await handleAPINode(node);
351
- }
352
- }
353
339
  function buildRouteTreeConfig(nodes, depth = 1) {
354
340
  const children = nodes.map((node) => {
355
341
  var _a, _b;
@@ -396,6 +382,21 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
396
382
  },
397
383
  (d) => d
398
384
  ]);
385
+ const typeImports = Object.entries({
386
+ // Used for augmentation of regular routes
387
+ CreateFileRoute: config.verboseFileRoutes === false && sortedRouteNodes.some(
388
+ (d) => isRouteNodeValidForAugmentation(d) && d._fsRouteType !== "lazy"
389
+ ),
390
+ // Used for augmentation of lazy (`.lazy`) routes
391
+ CreateLazyFileRoute: config.verboseFileRoutes === false && sortedRouteNodes.some(
392
+ (node) => {
393
+ var _a;
394
+ return ((_a = routePiecesByPath[node.routePath]) == null ? void 0 : _a.lazy) && isRouteNodeValidForAugmentation(node);
395
+ }
396
+ ),
397
+ // Used in the process of augmenting the routes
398
+ FileRoutesByPath: config.verboseFileRoutes === false && sortedRouteNodes.some((d) => isRouteNodeValidForAugmentation(d))
399
+ }).filter((d) => d[1]).map((d) => d[0]).sort((a, b) => a.localeCompare(b));
399
400
  const imports = Object.entries({
400
401
  createFileRoute: sortedRouteNodes.some((d) => d.isVirtual),
401
402
  lazyFn: sortedRouteNodes.some(
@@ -428,18 +429,20 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
428
429
  `// This file was automatically generated by TanStack Router.
429
430
  // You should NOT make any changes in this file as it will be overwritten.
430
431
  // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.`,
431
- imports.length ? `import { ${imports.join(", ")} } from '${ROUTE_TEMPLATE.fullPkg}'
432
- ` : "",
432
+ [
433
+ imports.length ? `import { ${imports.join(", ")} } from '${ROUTE_TEMPLATE.fullPkg}'` : "",
434
+ !TYPES_DISABLED && typeImports.length ? `import type { ${typeImports.join(", ")} } from '${ROUTE_TEMPLATE.fullPkg}'` : ""
435
+ ].filter(Boolean).join("\n"),
433
436
  "// Import Routes",
434
437
  [
435
438
  `import { Route as rootRoute } from './${getImportPath(rootRouteNode)}'`,
436
439
  ...sortedRouteNodes.filter((d) => !d.isVirtual).map((node) => {
437
- return `import { Route as ${node.variableName}Import } from './${getImportPath(node)}'`;
440
+ return `import { Route as ${node.variableName}RouteImport } from './${getImportPath(node)}'`;
438
441
  })
439
442
  ].join("\n"),
440
443
  virtualRouteNodes.length ? "// Create Virtual Routes" : "",
441
444
  virtualRouteNodes.map((node) => {
442
- return `const ${node.variableName}Import = createFileRoute('${node.routePath}')()`;
445
+ return `const ${node.variableName}RouteImport = createFileRoute('${node.routePath}')()`;
443
446
  }).join("\n"),
444
447
  "// Create/Update Routes",
445
448
  sortedRouteNodes.map((node) => {
@@ -450,52 +453,54 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
450
453
  const pendingComponentNode = (_d = routePiecesByPath[node.routePath]) == null ? void 0 : _d.pendingComponent;
451
454
  const lazyComponentNode = (_e = routePiecesByPath[node.routePath]) == null ? void 0 : _e.lazy;
452
455
  return [
453
- `const ${node.variableName}Route = ${node.variableName}Import.update({
456
+ [
457
+ `const ${node.variableName}Route = ${node.variableName}RouteImport.update({
454
458
  ${[
455
- `id: '${node.path}'`,
456
- !node.isNonPath ? `path: '${node.cleanedPath}'` : void 0,
457
- `getParentRoute: () => ${((_f = node.parent) == null ? void 0 : _f.variableName) ?? "root"}Route`
458
- ].filter(Boolean).join(",")}
459
+ `id: '${node.path}'`,
460
+ !node.isNonPath ? `path: '${node.cleanedPath}'` : void 0,
461
+ `getParentRoute: () => ${((_f = node.parent) == null ? void 0 : _f.variableName) ?? "root"}Route`
462
+ ].filter(Boolean).join(",")}
459
463
  }${TYPES_DISABLED ? "" : "as any"})`,
460
- loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${utils.replaceBackslash(
461
- utils.removeExt(
462
- path.relative(
463
- path.dirname(config.generatedRouteTree),
464
- path.resolve(config.routesDirectory, loaderNode.filePath)
465
- ),
466
- config.addExtensions
467
- )
468
- )}'), 'loader') })` : "",
469
- componentNode || errorComponentNode || pendingComponentNode ? `.update({
470
- ${[
471
- ["component", componentNode],
472
- ["errorComponent", errorComponentNode],
473
- ["pendingComponent", pendingComponentNode]
474
- ].filter((d) => d[1]).map((d) => {
475
- return `${d[0]}: lazyRouteComponent(() => import('./${utils.replaceBackslash(
464
+ loaderNode ? `.updateLoader({ loader: lazyFn(() => import('./${utils.replaceBackslash(
476
465
  utils.removeExt(
477
466
  path.relative(
478
467
  path.dirname(config.generatedRouteTree),
479
- path.resolve(config.routesDirectory, d[1].filePath)
468
+ path.resolve(config.routesDirectory, loaderNode.filePath)
480
469
  ),
481
470
  config.addExtensions
482
471
  )
483
- )}'), '${d[0]}')`;
484
- }).join("\n,")}
485
- })` : "",
486
- lazyComponentNode ? `.lazy(() => import('./${utils.replaceBackslash(
487
- utils.removeExt(
488
- path.relative(
489
- path.dirname(config.generatedRouteTree),
490
- path.resolve(
491
- config.routesDirectory,
492
- lazyComponentNode.filePath
472
+ )}'), 'loader') })` : "",
473
+ componentNode || errorComponentNode || pendingComponentNode ? `.update({
474
+ ${[
475
+ ["component", componentNode],
476
+ ["errorComponent", errorComponentNode],
477
+ ["pendingComponent", pendingComponentNode]
478
+ ].filter((d) => d[1]).map((d) => {
479
+ return `${d[0]}: lazyRouteComponent(() => import('./${utils.replaceBackslash(
480
+ utils.removeExt(
481
+ path.relative(
482
+ path.dirname(config.generatedRouteTree),
483
+ path.resolve(config.routesDirectory, d[1].filePath)
484
+ ),
485
+ config.addExtensions
493
486
  )
494
- ),
495
- config.addExtensions
496
- )
497
- )}').then((d) => d.Route))` : ""
498
- ].join("");
487
+ )}'), '${d[0]}')`;
488
+ }).join("\n,")}
489
+ })` : "",
490
+ lazyComponentNode ? `.lazy(() => import('./${utils.replaceBackslash(
491
+ utils.removeExt(
492
+ path.relative(
493
+ path.dirname(config.generatedRouteTree),
494
+ path.resolve(
495
+ config.routesDirectory,
496
+ lazyComponentNode.filePath
497
+ )
498
+ ),
499
+ config.addExtensions
500
+ )
501
+ )}').then((d) => d.Route))` : ""
502
+ ].join("")
503
+ ].join("\n\n");
499
504
  }).join("\n\n"),
500
505
  ...TYPES_DISABLED ? [] : [
501
506
  "// Populate the FileRoutesByPath interface",
@@ -508,13 +513,36 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
508
513
  id: '${filePathId}'
509
514
  path: '${inferPath(routeNode)}'
510
515
  fullPath: '${inferFullPath(routeNode)}'
511
- preLoaderRoute: typeof ${routeNode.variableName}Import
512
- 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"}
516
+ preLoaderRoute: typeof ${routeNode.variableName}RouteImport
517
+ parentRoute: typeof ${routeNode.isVirtualParentRequired ? `${(_a = routeNode.parent) == null ? void 0 : _a.variableName}Route` : ((_b = routeNode.parent) == null ? void 0 : _b.variableName) ? `${routeNode.parent.variableName}RouteImport` : "rootRoute"}
513
518
  }`;
514
519
  }).join("\n")}
515
520
  }
516
521
  }`
517
522
  ],
523
+ ...TYPES_DISABLED ? [] : config.verboseFileRoutes !== false ? [] : [
524
+ `// Add type-safety to the createFileRoute function across the route tree`,
525
+ routeNodes.map((routeNode) => {
526
+ var _a;
527
+ function getModuleDeclaration(routeNode2) {
528
+ if (!isRouteNodeValidForAugmentation(routeNode2)) {
529
+ return "";
530
+ }
531
+ return `declare module './${getImportPath(routeNode2)}' {
532
+ const ${routeNode2._fsRouteType === "lazy" ? "createLazyFileRoute" : "createFileRoute"}: ${routeNode2._fsRouteType === "lazy" ? `CreateLazyFileRoute<FileRoutesByPath['${routeNode2.routePath}']['preLoaderRoute']>}` : `CreateFileRoute<
533
+ '${routeNode2.routePath}',
534
+ FileRoutesByPath['${routeNode2.routePath}']['parentRoute'],
535
+ FileRoutesByPath['${routeNode2.routePath}']['id'],
536
+ FileRoutesByPath['${routeNode2.routePath}']['path'],
537
+ FileRoutesByPath['${routeNode2.routePath}']['fullPath']
538
+ >
539
+ }`}`;
540
+ }
541
+ return getModuleDeclaration(routeNode) + getModuleDeclaration(
542
+ (_a = routePiecesByPath[routeNode.routePath]) == null ? void 0 : _a.lazy
543
+ );
544
+ }).join("\n")
545
+ ],
518
546
  "// Create and export the route tree",
519
547
  routeConfigChildrenText,
520
548
  ...TYPES_DISABLED ? [] : [
@@ -531,7 +559,7 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
531
559
  })}
532
560
  }`,
533
561
  `export interface FileRoutesById {
534
- '__root__': typeof rootRoute,
562
+ '${rootRouteId}': typeof rootRoute,
535
563
  ${[...createRouteNodesById(routeNodes).entries()].map(([id, routeNode]) => {
536
564
  return `'${id}': typeof ${getResolvedRouteNodeVariableName(routeNode)}`;
537
565
  })}
@@ -541,7 +569,7 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
541
569
  fullPaths: ${routeNodes.length > 0 ? [...createRouteNodesByFullPath(routeNodes).keys()].map((fullPath) => `'${fullPath}'`).join("|") : "never"}
542
570
  fileRoutesByTo: FileRoutesByTo
543
571
  to: ${routeNodes.length > 0 ? [...createRouteNodesByTo(routeNodes).keys()].map((to) => `'${to}'`).join("|") : "never"}
544
- id: ${[`'__root__'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join("|")}
572
+ id: ${[`'${rootRouteId}'`, ...[...createRouteNodesById(routeNodes).keys()].map((id) => `'${id}'`)].join("|")}
545
573
  fileRoutesById: FileRoutesById
546
574
  }`,
547
575
  `export interface RootRouteChildren {
@@ -556,7 +584,7 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
556
584
  ].filter(Boolean).join("\n\n");
557
585
  const createRouteManifest = () => {
558
586
  const routesManifest = {
559
- __root__: {
587
+ [rootRouteId]: {
560
588
  filePath: rootRouteNode.filePath,
561
589
  children: routeTree.map((d) => d.routePath)
562
590
  },
@@ -623,6 +651,12 @@ Add the file in: "${config.routesDirectory}/${rootPathId.rootPathId}.${config.di
623
651
  function removeGroups(s) {
624
652
  return s.replace(possiblyNestedRouteGroupPatternRegex, "");
625
653
  }
654
+ function isRouteNodeValidForAugmentation(routeNode) {
655
+ if (!routeNode || routeNode.isVirtual) {
656
+ return false;
657
+ }
658
+ return true;
659
+ }
626
660
  function determineNodePath(node) {
627
661
  var _a;
628
662
  return node.path = node.parent ? ((_a = node.routePath) == null ? void 0 : _a.replace(node.parent.routePath ?? "", "")) || "/" : node.routePath;
@@ -723,58 +757,12 @@ function checkRouteFullPathUniqueness(_routes, config) {
723
757
  const conflictingFiles = checkUnique(routes, "inferredFullPath");
724
758
  if (conflictingFiles !== void 0) {
725
759
  const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? "s" : ""}: ${conflictingFiles.map((p) => `"${p.inferredFullPath}"`).join(", ")}.
726
- Please ensure each route has a unique full path.
727
- Conflicting files:
728
- ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join("\n ")}
729
- `;
730
- throw new Error(errorMessage);
731
- }
732
- }
733
- function checkStartAPIRoutes(_routes, config) {
734
- if (_routes.length === 0) {
735
- return [];
736
- }
737
- const routes = _routes.map((d) => {
738
- const routePath = utils.removeTrailingSlash(d.routePath ?? "");
739
- return { ...d, routePath };
740
- });
741
- const conflictingFiles = checkUnique(routes, "routePath");
742
- if (conflictingFiles !== void 0) {
743
- const errorMessage = `Conflicting configuration paths were found for the following API route${conflictingFiles.length > 1 ? "s" : ""}: ${conflictingFiles.map((p) => `"${p}"`).join(", ")}.
744
- Please ensure each API route has a unique route path.
760
+ Please ensure each Route has a unique full path.
745
761
  Conflicting files:
746
762
  ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join("\n ")}
747
763
  `;
748
764
  throw new Error(errorMessage);
749
765
  }
750
- return routes;
751
- }
752
- function startAPIRouteSegmentsFromTSRFilePath(src, config) {
753
- const routePath = utils.determineInitialRoutePath(src);
754
- const parts = routePath.replaceAll(".", "/").split("/").filter((p) => !!p && p !== config.indexToken);
755
- const segments = parts.map((part) => {
756
- if (part.startsWith("$")) {
757
- if (part === "$") {
758
- return { value: part, type: "splat" };
759
- }
760
- part.replaceAll("$", "");
761
- return { value: part, type: "param" };
762
- }
763
- return { value: part, type: "path" };
764
- });
765
- return segments;
766
766
  }
767
- exports.CONSTANTS = CONSTANTS;
768
- exports.createRouteNodesByFullPath = createRouteNodesByFullPath;
769
- exports.createRouteNodesById = createRouteNodesById;
770
- exports.createRouteNodesByTo = createRouteNodesByTo;
771
- exports.dedupeBranchesAndIndexRoutes = dedupeBranchesAndIndexRoutes;
772
767
  exports.generator = generator;
773
- exports.getResolvedRouteNodeVariableName = getResolvedRouteNodeVariableName;
774
- exports.hasParentRoute = hasParentRoute;
775
- exports.inferFullPath = inferFullPath;
776
- exports.inferPath = inferPath;
777
- exports.inferTo = inferTo;
778
- exports.removeLastSegmentFromPath = removeLastSegmentFromPath;
779
- exports.startAPIRouteSegmentsFromTSRFilePath = startAPIRouteSegmentsFromTSRFilePath;
780
768
  //# sourceMappingURL=generator.cjs.map