Skip to content

Commit 02fccde

Browse files
cleanup
1 parent bd91a2c commit 02fccde

1 file changed

Lines changed: 5 additions & 27 deletions

File tree

‎packages/router-generator/src/utils.ts‎

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type { ImportDeclaration, RouteNode } from './types'
1313
*/
1414
export class RoutePrefixMap {
1515
private prefixToRoute: Map<string, RouteNode> = new Map()
16-
private layoutRoutes: Array<RouteNode> = []
1716

1817
constructor(routes: Array<RouteNode>) {
1918
for (const route of routes) {
@@ -34,20 +33,7 @@ export class RoutePrefixMap {
3433

3534
// Index by exact path for direct lookups
3635
this.prefixToRoute.set(route.routePath, route)
37-
38-
if (
39-
route._fsRouteType === 'pathless_layout' ||
40-
route._fsRouteType === 'layout' ||
41-
route._fsRouteType === '__root'
42-
) {
43-
this.layoutRoutes.push(route)
44-
}
4536
}
46-
47-
// Sort by path length descending for longest-match-first
48-
this.layoutRoutes.sort(
49-
(a, b) => (b.routePath?.length ?? 0) - (a.routePath?.length ?? 0),
50-
)
5137
}
5238

5339
/**
@@ -482,7 +468,7 @@ export function createTokenRegex(
482468
}
483469
}
484470

485-
export function isBracketWrappedSegment(segment: string): boolean {
471+
function isBracketWrappedSegment(segment: string): boolean {
486472
return segment.startsWith('[') && segment.endsWith(']')
487473
}
488474

@@ -688,7 +674,7 @@ export const getResolvedRouteNodeVariableName = (
688674
/**
689675
* Infers the path for use by TS
690676
*/
691-
export const inferPath = (routeNode: RouteNode): string => {
677+
const inferPath = (routeNode: RouteNode): string => {
692678
if (routeNode.cleanedPath === '/') {
693679
return routeNode.cleanedPath ?? ''
694680
}
@@ -795,7 +781,7 @@ export const createRouteNodesById = (
795781
/**
796782
* Infers to path
797783
*/
798-
export const inferTo = (routeNode: RouteNode): string => {
784+
const inferTo = (routeNode: RouteNode): string => {
799785
const fullPath = inferFullPath(routeNode)
800786

801787
if (fullPath === '/') return fullPath
@@ -806,7 +792,7 @@ export const inferTo = (routeNode: RouteNode): string => {
806792
/**
807793
* Dedupes branches and index routes
808794
*/
809-
export const dedupeBranchesAndIndexRoutes = (
795+
const dedupeBranchesAndIndexRoutes = (
810796
routes: Array<RouteNode>,
811797
): Array<RouteNode> => {
812798
return routes.filter((route) => {
@@ -928,14 +914,6 @@ export function buildImportString(
928914
: ''
929915
}
930916

931-
export function lowerCaseFirstChar(value: string) {
932-
if (!value[0]) {
933-
return value
934-
}
935-
936-
return value[0].toLowerCase() + value.slice(1)
937-
}
938-
939917
export function mergeImportDeclarations(
940918
imports: Array<ImportDeclaration>,
941919
): Array<ImportDeclaration> {
@@ -1006,7 +984,7 @@ export function buildFileRoutesByPathInterface(opts: {
1006984
}`
1007985
}
1008986

1009-
export function getImportPath(
987+
function getImportPath(
1010988
node: RouteNode,
1011989
config: Config,
1012990
generatedRouteTreePath: string,

0 commit comments

Comments
 (0)