@tanstack/router-generator 1.121.16 → 1.121.17
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.
- package/package.json +4 -4
- package/dist/cjs/config.cjs +0 -140
- package/dist/cjs/config.cjs.map +0 -1
- package/dist/cjs/config.d.cts +0 -155
- package/dist/cjs/filesystem/physical/getRouteNodes.cjs +0 -204
- package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +0 -1
- package/dist/cjs/filesystem/physical/getRouteNodes.d.cts +0 -15
- package/dist/cjs/filesystem/physical/rootPathId.cjs +0 -5
- package/dist/cjs/filesystem/physical/rootPathId.cjs.map +0 -1
- package/dist/cjs/filesystem/physical/rootPathId.d.cts +0 -1
- package/dist/cjs/filesystem/virtual/config.cjs +0 -37
- package/dist/cjs/filesystem/virtual/config.cjs.map +0 -1
- package/dist/cjs/filesystem/virtual/config.d.cts +0 -3
- package/dist/cjs/filesystem/virtual/getRouteNodes.cjs +0 -192
- package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +0 -1
- package/dist/cjs/filesystem/virtual/getRouteNodes.d.cts +0 -8
- package/dist/cjs/filesystem/virtual/loadConfigFile.cjs +0 -11
- package/dist/cjs/filesystem/virtual/loadConfigFile.cjs.map +0 -1
- package/dist/cjs/filesystem/virtual/loadConfigFile.d.cts +0 -1
- package/dist/cjs/generator.cjs +0 -970
- package/dist/cjs/generator.cjs.map +0 -1
- package/dist/cjs/generator.d.cts +0 -76
- package/dist/cjs/index.cjs +0 -35
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/index.d.cts +0 -12
- package/dist/cjs/logger.cjs +0 -37
- package/dist/cjs/logger.cjs.map +0 -1
- package/dist/cjs/logger.d.cts +0 -10
- package/dist/cjs/plugin/default-generator-plugin.cjs +0 -101
- package/dist/cjs/plugin/default-generator-plugin.cjs.map +0 -1
- package/dist/cjs/plugin/default-generator-plugin.d.cts +0 -2
- package/dist/cjs/plugin/types.d.cts +0 -46
- package/dist/cjs/template.cjs +0 -110
- package/dist/cjs/template.cjs.map +0 -1
- package/dist/cjs/template.d.cts +0 -33
- package/dist/cjs/transform/default-transform-plugin.cjs +0 -95
- package/dist/cjs/transform/default-transform-plugin.cjs.map +0 -1
- package/dist/cjs/transform/default-transform-plugin.d.cts +0 -2
- package/dist/cjs/transform/transform.cjs +0 -374
- package/dist/cjs/transform/transform.cjs.map +0 -1
- package/dist/cjs/transform/transform.d.cts +0 -4
- package/dist/cjs/transform/types.d.cts +0 -43
- package/dist/cjs/transform/utils.cjs +0 -36
- package/dist/cjs/transform/utils.cjs.map +0 -1
- package/dist/cjs/transform/utils.d.cts +0 -2
- package/dist/cjs/types.d.cts +0 -47
- package/dist/cjs/utils.cjs +0 -438
- package/dist/cjs/utils.cjs.map +0 -1
- package/dist/cjs/utils.d.cts +0 -133
- package/dist/esm/config.d.ts +0 -155
- package/dist/esm/config.js +0 -140
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/filesystem/physical/getRouteNodes.d.ts +0 -15
- package/dist/esm/filesystem/physical/getRouteNodes.js +0 -187
- package/dist/esm/filesystem/physical/getRouteNodes.js.map +0 -1
- package/dist/esm/filesystem/physical/rootPathId.d.ts +0 -1
- package/dist/esm/filesystem/physical/rootPathId.js +0 -5
- package/dist/esm/filesystem/physical/rootPathId.js.map +0 -1
- package/dist/esm/filesystem/virtual/config.d.ts +0 -3
- package/dist/esm/filesystem/virtual/config.js +0 -37
- package/dist/esm/filesystem/virtual/config.js.map +0 -1
- package/dist/esm/filesystem/virtual/getRouteNodes.d.ts +0 -8
- package/dist/esm/filesystem/virtual/getRouteNodes.js +0 -192
- package/dist/esm/filesystem/virtual/getRouteNodes.js.map +0 -1
- package/dist/esm/filesystem/virtual/loadConfigFile.d.ts +0 -1
- package/dist/esm/filesystem/virtual/loadConfigFile.js +0 -11
- package/dist/esm/filesystem/virtual/loadConfigFile.js.map +0 -1
- package/dist/esm/generator.d.ts +0 -76
- package/dist/esm/generator.js +0 -953
- package/dist/esm/generator.js.map +0 -1
- package/dist/esm/index.d.ts +0 -12
- package/dist/esm/index.js +0 -35
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/logger.d.ts +0 -10
- package/dist/esm/logger.js +0 -37
- package/dist/esm/logger.js.map +0 -1
- package/dist/esm/plugin/default-generator-plugin.d.ts +0 -2
- package/dist/esm/plugin/default-generator-plugin.js +0 -101
- package/dist/esm/plugin/default-generator-plugin.js.map +0 -1
- package/dist/esm/plugin/types.d.ts +0 -46
- package/dist/esm/template.d.ts +0 -33
- package/dist/esm/template.js +0 -110
- package/dist/esm/template.js.map +0 -1
- package/dist/esm/transform/default-transform-plugin.d.ts +0 -2
- package/dist/esm/transform/default-transform-plugin.js +0 -95
- package/dist/esm/transform/default-transform-plugin.js.map +0 -1
- package/dist/esm/transform/transform.d.ts +0 -4
- package/dist/esm/transform/transform.js +0 -374
- package/dist/esm/transform/transform.js.map +0 -1
- package/dist/esm/transform/types.d.ts +0 -43
- package/dist/esm/transform/utils.d.ts +0 -2
- package/dist/esm/transform/utils.js +0 -36
- package/dist/esm/transform/utils.js.map +0 -1
- package/dist/esm/types.d.ts +0 -47
- package/dist/esm/utils.d.ts +0 -133
- package/dist/esm/utils.js +0 -420
- package/dist/esm/utils.js.map +0 -1
package/dist/cjs/utils.d.cts
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { Config } from './config.cjs';
|
|
2
|
-
import { ImportDeclaration, RouteNode } from './types.cjs';
|
|
3
|
-
export declare function multiSortBy<T>(arr: Array<T>, accessors?: Array<(item: T) => any>): Array<T>;
|
|
4
|
-
export declare function cleanPath(path: string): string;
|
|
5
|
-
export declare function trimPathLeft(path: string): string;
|
|
6
|
-
export declare function removeLeadingSlash(path: string): string;
|
|
7
|
-
export declare function removeTrailingSlash(s: string): string;
|
|
8
|
-
export declare function determineInitialRoutePath(routePath: string): string;
|
|
9
|
-
export declare function replaceBackslash(s: string): string;
|
|
10
|
-
export declare function routePathToVariable(routePath: string): string;
|
|
11
|
-
export declare function removeUnderscores(s?: string): string | undefined;
|
|
12
|
-
export declare function capitalize(s: string): string;
|
|
13
|
-
export declare function removeExt(d: string, keepExtension?: boolean): string;
|
|
14
|
-
/**
|
|
15
|
-
* This function writes to a file if the content is different.
|
|
16
|
-
*
|
|
17
|
-
* @param filepath The path to the file
|
|
18
|
-
* @param content Original content
|
|
19
|
-
* @param incomingContent New content
|
|
20
|
-
* @param callbacks Callbacks to run before and after writing
|
|
21
|
-
* @returns Whether the file was written
|
|
22
|
-
*/
|
|
23
|
-
export declare function writeIfDifferent(filepath: string, content: string, incomingContent: string, callbacks?: {
|
|
24
|
-
beforeWrite?: () => void;
|
|
25
|
-
afterWrite?: () => void;
|
|
26
|
-
}): Promise<boolean>;
|
|
27
|
-
/**
|
|
28
|
-
* This function formats the source code using the default formatter (Prettier).
|
|
29
|
-
*
|
|
30
|
-
* @param source The content to format
|
|
31
|
-
* @param config The configuration object
|
|
32
|
-
* @returns The formatted content
|
|
33
|
-
*/
|
|
34
|
-
export declare function format(source: string, config: {
|
|
35
|
-
quoteStyle: 'single' | 'double';
|
|
36
|
-
semicolons: boolean;
|
|
37
|
-
}): Promise<string>;
|
|
38
|
-
/**
|
|
39
|
-
* This function resets the regex index to 0 so that it can be reused
|
|
40
|
-
* without having to create a new regex object or worry about the last
|
|
41
|
-
* state when using the global flag.
|
|
42
|
-
*
|
|
43
|
-
* @param regex The regex object to reset
|
|
44
|
-
* @returns
|
|
45
|
-
*/
|
|
46
|
-
export declare function resetRegex(regex: RegExp): void;
|
|
47
|
-
/**
|
|
48
|
-
* This function checks if a file exists.
|
|
49
|
-
*
|
|
50
|
-
* @param file The path to the file
|
|
51
|
-
* @returns Whether the file exists
|
|
52
|
-
*/
|
|
53
|
-
export declare function checkFileExists(file: string): Promise<boolean>;
|
|
54
|
-
export declare function removeGroups(s: string): string;
|
|
55
|
-
/**
|
|
56
|
-
* Removes all segments from a given path that start with an underscore ('_').
|
|
57
|
-
*
|
|
58
|
-
* @param {string} routePath - The path from which to remove segments. Defaults to '/'.
|
|
59
|
-
* @returns {string} The path with all underscore-prefixed segments removed.
|
|
60
|
-
* @example
|
|
61
|
-
* removeLayoutSegments('/workspace/_auth/foo') // '/workspace/foo'
|
|
62
|
-
*/
|
|
63
|
-
export declare function removeLayoutSegments(routePath?: string): string;
|
|
64
|
-
/**
|
|
65
|
-
* The `node.path` is used as the `id` in the route definition.
|
|
66
|
-
* This function checks if the given node has a parent and if so, it determines the correct path for the given node.
|
|
67
|
-
* @param node - The node to determine the path for.
|
|
68
|
-
* @returns The correct path for the given node.
|
|
69
|
-
*/
|
|
70
|
-
export declare function determineNodePath(node: RouteNode): string | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Removes the last segment from a given path. Segments are considered to be separated by a '/'.
|
|
73
|
-
*
|
|
74
|
-
* @param {string} routePath - The path from which to remove the last segment. Defaults to '/'.
|
|
75
|
-
* @returns {string} The path with the last segment removed.
|
|
76
|
-
* @example
|
|
77
|
-
* removeLastSegmentFromPath('/workspace/_auth/foo') // '/workspace/_auth'
|
|
78
|
-
*/
|
|
79
|
-
export declare function removeLastSegmentFromPath(routePath?: string): string;
|
|
80
|
-
export declare function hasParentRoute(routes: Array<RouteNode>, node: RouteNode, routePathToCheck: string | undefined): RouteNode | null;
|
|
81
|
-
/**
|
|
82
|
-
* Gets the final variable name for a route
|
|
83
|
-
*/
|
|
84
|
-
export declare const getResolvedRouteNodeVariableName: (routeNode: RouteNode, variableNameSuffix: string) => string;
|
|
85
|
-
/**
|
|
86
|
-
* Checks if a given RouteNode is valid for augmenting it with typing based on conditions.
|
|
87
|
-
* Also asserts that the RouteNode is defined.
|
|
88
|
-
*
|
|
89
|
-
* @param routeNode - The RouteNode to check.
|
|
90
|
-
* @returns A boolean indicating whether the RouteNode is defined.
|
|
91
|
-
*/
|
|
92
|
-
export declare function isRouteNodeValidForAugmentation(routeNode?: RouteNode): routeNode is RouteNode;
|
|
93
|
-
/**
|
|
94
|
-
* Infers the path for use by TS
|
|
95
|
-
*/
|
|
96
|
-
export declare const inferPath: (routeNode: RouteNode) => string;
|
|
97
|
-
/**
|
|
98
|
-
* Infers the full path for use by TS
|
|
99
|
-
*/
|
|
100
|
-
export declare const inferFullPath: (routeNode: RouteNode) => string;
|
|
101
|
-
/**
|
|
102
|
-
* Creates a map from fullPath to routeNode
|
|
103
|
-
*/
|
|
104
|
-
export declare const createRouteNodesByFullPath: (routeNodes: Array<RouteNode>) => Map<string, RouteNode>;
|
|
105
|
-
/**
|
|
106
|
-
* Create a map from 'to' to a routeNode
|
|
107
|
-
*/
|
|
108
|
-
export declare const createRouteNodesByTo: (routeNodes: Array<RouteNode>) => Map<string, RouteNode>;
|
|
109
|
-
/**
|
|
110
|
-
* Create a map from 'id' to a routeNode
|
|
111
|
-
*/
|
|
112
|
-
export declare const createRouteNodesById: (routeNodes: Array<RouteNode>) => Map<string, RouteNode>;
|
|
113
|
-
/**
|
|
114
|
-
* Infers to path
|
|
115
|
-
*/
|
|
116
|
-
export declare const inferTo: (routeNode: RouteNode) => string;
|
|
117
|
-
/**
|
|
118
|
-
* Dedupes branches and index routes
|
|
119
|
-
*/
|
|
120
|
-
export declare const dedupeBranchesAndIndexRoutes: (routes: Array<RouteNode>) => Array<RouteNode>;
|
|
121
|
-
export declare function checkRouteFullPathUniqueness(_routes: Array<RouteNode>, config: Config): void;
|
|
122
|
-
export declare function buildRouteTreeConfig(nodes: Array<RouteNode>, exportName: string, disableTypes: boolean, depth?: number): Array<string>;
|
|
123
|
-
export declare function buildImportString(importDeclaration: ImportDeclaration): string;
|
|
124
|
-
export declare function lowerCaseFirstChar(value: string): string;
|
|
125
|
-
export declare function mergeImportDeclarations(imports: Array<ImportDeclaration>): Array<ImportDeclaration>;
|
|
126
|
-
export declare function hasChildWithExport(node: RouteNode, exportName: string): boolean;
|
|
127
|
-
export declare const findParent: (node: RouteNode | undefined, exportName: string) => string;
|
|
128
|
-
export declare function buildFileRoutesByPathInterface(opts: {
|
|
129
|
-
routeNodes: Array<RouteNode>;
|
|
130
|
-
module: string;
|
|
131
|
-
interfaceName: string;
|
|
132
|
-
exportName: string;
|
|
133
|
-
}): string;
|
package/dist/esm/config.d.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { GeneratorPlugin } from './plugin/types.js';
|
|
3
|
-
export declare const baseConfigSchema: z.ZodObject<{
|
|
4
|
-
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<["react", "solid"]>>>;
|
|
5
|
-
virtualRouteConfig: z.ZodOptional<z.ZodUnion<[z.ZodType<import('@tanstack/virtual-file-routes').VirtualRootRoute, z.ZodTypeDef, import('@tanstack/virtual-file-routes').VirtualRootRoute>, z.ZodString]>>;
|
|
6
|
-
routeFilePrefix: z.ZodOptional<z.ZodString>;
|
|
7
|
-
routeFileIgnorePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
8
|
-
routeFileIgnorePattern: z.ZodOptional<z.ZodString>;
|
|
9
|
-
routesDirectory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
10
|
-
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<["single", "double"]>>>;
|
|
11
|
-
semicolons: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
12
|
-
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
13
|
-
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
14
|
-
indexToken: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
15
|
-
routeToken: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
16
|
-
pathParamsAllowedCharacters: z.ZodOptional<z.ZodArray<z.ZodEnum<[";", ":", "@", "&", "=", "+", "$", ","]>, "many">>;
|
|
17
|
-
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
target: "react" | "solid";
|
|
19
|
-
routeFileIgnorePrefix: string;
|
|
20
|
-
routesDirectory: string;
|
|
21
|
-
quoteStyle: "single" | "double";
|
|
22
|
-
semicolons: boolean;
|
|
23
|
-
disableLogging: boolean;
|
|
24
|
-
routeTreeFileHeader: string[];
|
|
25
|
-
indexToken: string;
|
|
26
|
-
routeToken: string;
|
|
27
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
28
|
-
routeFilePrefix?: string | undefined;
|
|
29
|
-
routeFileIgnorePattern?: string | undefined;
|
|
30
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
31
|
-
}, {
|
|
32
|
-
target?: "react" | "solid" | undefined;
|
|
33
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
34
|
-
routeFilePrefix?: string | undefined;
|
|
35
|
-
routeFileIgnorePrefix?: string | undefined;
|
|
36
|
-
routeFileIgnorePattern?: string | undefined;
|
|
37
|
-
routesDirectory?: string | undefined;
|
|
38
|
-
quoteStyle?: "single" | "double" | undefined;
|
|
39
|
-
semicolons?: boolean | undefined;
|
|
40
|
-
disableLogging?: boolean | undefined;
|
|
41
|
-
routeTreeFileHeader?: string[] | undefined;
|
|
42
|
-
indexToken?: string | undefined;
|
|
43
|
-
routeToken?: string | undefined;
|
|
44
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
45
|
-
}>;
|
|
46
|
-
export type BaseConfig = z.infer<typeof baseConfigSchema>;
|
|
47
|
-
export declare const configSchema: z.ZodObject<{
|
|
48
|
-
target: z.ZodDefault<z.ZodOptional<z.ZodEnum<["react", "solid"]>>>;
|
|
49
|
-
virtualRouteConfig: z.ZodOptional<z.ZodUnion<[z.ZodType<import('@tanstack/virtual-file-routes').VirtualRootRoute, z.ZodTypeDef, import('@tanstack/virtual-file-routes').VirtualRootRoute>, z.ZodString]>>;
|
|
50
|
-
routeFilePrefix: z.ZodOptional<z.ZodString>;
|
|
51
|
-
routeFileIgnorePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
52
|
-
routeFileIgnorePattern: z.ZodOptional<z.ZodString>;
|
|
53
|
-
routesDirectory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
54
|
-
quoteStyle: z.ZodDefault<z.ZodOptional<z.ZodEnum<["single", "double"]>>>;
|
|
55
|
-
semicolons: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
56
|
-
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
57
|
-
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
58
|
-
indexToken: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
59
|
-
routeToken: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
60
|
-
pathParamsAllowedCharacters: z.ZodOptional<z.ZodArray<z.ZodEnum<[";", ":", "@", "&", "=", "+", "$", ","]>, "many">>;
|
|
61
|
-
} & {
|
|
62
|
-
generatedRouteTree: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
63
|
-
disableTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
64
|
-
verboseFileRoutes: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
-
addExtensions: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
66
|
-
enableRouteTreeFormatting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
67
|
-
routeTreeFileFooter: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
68
|
-
autoCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
-
customScaffolding: z.ZodOptional<z.ZodObject<{
|
|
70
|
-
routeTemplate: z.ZodOptional<z.ZodString>;
|
|
71
|
-
lazyRouteTemplate: z.ZodOptional<z.ZodString>;
|
|
72
|
-
}, "strip", z.ZodTypeAny, {
|
|
73
|
-
routeTemplate?: string | undefined;
|
|
74
|
-
lazyRouteTemplate?: string | undefined;
|
|
75
|
-
}, {
|
|
76
|
-
routeTemplate?: string | undefined;
|
|
77
|
-
lazyRouteTemplate?: string | undefined;
|
|
78
|
-
}>>;
|
|
79
|
-
experimental: z.ZodOptional<z.ZodObject<{
|
|
80
|
-
enableCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
-
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
enableCodeSplitting?: boolean | undefined;
|
|
83
|
-
}, {
|
|
84
|
-
enableCodeSplitting?: boolean | undefined;
|
|
85
|
-
}>>;
|
|
86
|
-
plugins: z.ZodOptional<z.ZodArray<z.ZodType<GeneratorPlugin, z.ZodTypeDef, GeneratorPlugin>, "many">>;
|
|
87
|
-
tmpDir: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
88
|
-
}, "strip", z.ZodTypeAny, {
|
|
89
|
-
target: "react" | "solid";
|
|
90
|
-
routeFileIgnorePrefix: string;
|
|
91
|
-
routesDirectory: string;
|
|
92
|
-
quoteStyle: "single" | "double";
|
|
93
|
-
semicolons: boolean;
|
|
94
|
-
disableLogging: boolean;
|
|
95
|
-
routeTreeFileHeader: string[];
|
|
96
|
-
indexToken: string;
|
|
97
|
-
routeToken: string;
|
|
98
|
-
generatedRouteTree: string;
|
|
99
|
-
disableTypes: boolean;
|
|
100
|
-
addExtensions: boolean;
|
|
101
|
-
enableRouteTreeFormatting: boolean;
|
|
102
|
-
routeTreeFileFooter: string[];
|
|
103
|
-
tmpDir: string;
|
|
104
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
105
|
-
routeFilePrefix?: string | undefined;
|
|
106
|
-
routeFileIgnorePattern?: string | undefined;
|
|
107
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
108
|
-
verboseFileRoutes?: boolean | undefined;
|
|
109
|
-
autoCodeSplitting?: boolean | undefined;
|
|
110
|
-
customScaffolding?: {
|
|
111
|
-
routeTemplate?: string | undefined;
|
|
112
|
-
lazyRouteTemplate?: string | undefined;
|
|
113
|
-
} | undefined;
|
|
114
|
-
experimental?: {
|
|
115
|
-
enableCodeSplitting?: boolean | undefined;
|
|
116
|
-
} | undefined;
|
|
117
|
-
plugins?: GeneratorPlugin[] | undefined;
|
|
118
|
-
}, {
|
|
119
|
-
target?: "react" | "solid" | undefined;
|
|
120
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
121
|
-
routeFilePrefix?: string | undefined;
|
|
122
|
-
routeFileIgnorePrefix?: string | undefined;
|
|
123
|
-
routeFileIgnorePattern?: string | undefined;
|
|
124
|
-
routesDirectory?: string | undefined;
|
|
125
|
-
quoteStyle?: "single" | "double" | undefined;
|
|
126
|
-
semicolons?: boolean | undefined;
|
|
127
|
-
disableLogging?: boolean | undefined;
|
|
128
|
-
routeTreeFileHeader?: string[] | undefined;
|
|
129
|
-
indexToken?: string | undefined;
|
|
130
|
-
routeToken?: string | undefined;
|
|
131
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
132
|
-
generatedRouteTree?: string | undefined;
|
|
133
|
-
disableTypes?: boolean | undefined;
|
|
134
|
-
verboseFileRoutes?: boolean | undefined;
|
|
135
|
-
addExtensions?: boolean | undefined;
|
|
136
|
-
enableRouteTreeFormatting?: boolean | undefined;
|
|
137
|
-
routeTreeFileFooter?: string[] | undefined;
|
|
138
|
-
autoCodeSplitting?: boolean | undefined;
|
|
139
|
-
customScaffolding?: {
|
|
140
|
-
routeTemplate?: string | undefined;
|
|
141
|
-
lazyRouteTemplate?: string | undefined;
|
|
142
|
-
} | undefined;
|
|
143
|
-
experimental?: {
|
|
144
|
-
enableCodeSplitting?: boolean | undefined;
|
|
145
|
-
} | undefined;
|
|
146
|
-
plugins?: GeneratorPlugin[] | undefined;
|
|
147
|
-
tmpDir?: string | undefined;
|
|
148
|
-
}>;
|
|
149
|
-
export type Config = z.infer<typeof configSchema>;
|
|
150
|
-
type ResolveParams = {
|
|
151
|
-
configDirectory: string;
|
|
152
|
-
};
|
|
153
|
-
export declare function resolveConfigPath({ configDirectory }: ResolveParams): string;
|
|
154
|
-
export declare function getConfig(inlineConfig?: Partial<Config>, configDirectory?: string): Config;
|
|
155
|
-
export {};
|
package/dist/esm/config.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { existsSync, readFileSync, mkdirSync } from "node:fs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { virtualRootRouteSchema } from "./filesystem/virtual/config.js";
|
|
5
|
-
const baseConfigSchema = z.object({
|
|
6
|
-
target: z.enum(["react", "solid"]).optional().default("react"),
|
|
7
|
-
virtualRouteConfig: virtualRootRouteSchema.or(z.string()).optional(),
|
|
8
|
-
routeFilePrefix: z.string().optional(),
|
|
9
|
-
routeFileIgnorePrefix: z.string().optional().default("-"),
|
|
10
|
-
routeFileIgnorePattern: z.string().optional(),
|
|
11
|
-
routesDirectory: z.string().optional().default("./src/routes"),
|
|
12
|
-
quoteStyle: z.enum(["single", "double"]).optional().default("single"),
|
|
13
|
-
semicolons: z.boolean().optional().default(false),
|
|
14
|
-
disableLogging: z.boolean().optional().default(false),
|
|
15
|
-
routeTreeFileHeader: z.array(z.string()).optional().default([
|
|
16
|
-
"/* eslint-disable */",
|
|
17
|
-
"// @ts-nocheck",
|
|
18
|
-
"// noinspection JSUnusedGlobalSymbols"
|
|
19
|
-
]),
|
|
20
|
-
indexToken: z.string().optional().default("index"),
|
|
21
|
-
routeToken: z.string().optional().default("route"),
|
|
22
|
-
pathParamsAllowedCharacters: z.array(z.enum([";", ":", "@", "&", "=", "+", "$", ","])).optional()
|
|
23
|
-
});
|
|
24
|
-
const configSchema = baseConfigSchema.extend({
|
|
25
|
-
generatedRouteTree: z.string().optional().default("./src/routeTree.gen.ts"),
|
|
26
|
-
disableTypes: z.boolean().optional().default(false),
|
|
27
|
-
verboseFileRoutes: z.boolean().optional(),
|
|
28
|
-
addExtensions: z.boolean().optional().default(false),
|
|
29
|
-
enableRouteTreeFormatting: z.boolean().optional().default(true),
|
|
30
|
-
routeTreeFileFooter: z.array(z.string()).optional().default([]),
|
|
31
|
-
autoCodeSplitting: z.boolean().optional(),
|
|
32
|
-
customScaffolding: z.object({
|
|
33
|
-
routeTemplate: z.string().optional(),
|
|
34
|
-
lazyRouteTemplate: z.string().optional()
|
|
35
|
-
}).optional(),
|
|
36
|
-
experimental: z.object({
|
|
37
|
-
// TODO: This has been made stable and is now "autoCodeSplitting". Remove in next major version.
|
|
38
|
-
enableCodeSplitting: z.boolean().optional()
|
|
39
|
-
}).optional(),
|
|
40
|
-
plugins: z.array(z.custom()).optional(),
|
|
41
|
-
tmpDir: z.string().optional().default("")
|
|
42
|
-
});
|
|
43
|
-
function resolveConfigPath({ configDirectory }) {
|
|
44
|
-
return path.resolve(configDirectory, "tsr.config.json");
|
|
45
|
-
}
|
|
46
|
-
function getConfig(inlineConfig = {}, configDirectory) {
|
|
47
|
-
if (configDirectory === void 0) {
|
|
48
|
-
configDirectory = process.cwd();
|
|
49
|
-
}
|
|
50
|
-
const configFilePathJson = resolveConfigPath({ configDirectory });
|
|
51
|
-
const exists = existsSync(configFilePathJson);
|
|
52
|
-
let config;
|
|
53
|
-
if (exists) {
|
|
54
|
-
config = configSchema.parse({
|
|
55
|
-
...JSON.parse(readFileSync(configFilePathJson, "utf-8")),
|
|
56
|
-
...inlineConfig
|
|
57
|
-
});
|
|
58
|
-
} else {
|
|
59
|
-
config = configSchema.parse(inlineConfig);
|
|
60
|
-
}
|
|
61
|
-
if (config.disableTypes) {
|
|
62
|
-
config.generatedRouteTree = config.generatedRouteTree.replace(
|
|
63
|
-
/\.(ts|tsx)$/,
|
|
64
|
-
".js"
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
if (configDirectory) {
|
|
68
|
-
if (path.isAbsolute(configDirectory)) {
|
|
69
|
-
config.routesDirectory = path.resolve(
|
|
70
|
-
configDirectory,
|
|
71
|
-
config.routesDirectory
|
|
72
|
-
);
|
|
73
|
-
config.generatedRouteTree = path.resolve(
|
|
74
|
-
configDirectory,
|
|
75
|
-
config.generatedRouteTree
|
|
76
|
-
);
|
|
77
|
-
} else {
|
|
78
|
-
config.routesDirectory = path.resolve(
|
|
79
|
-
process.cwd(),
|
|
80
|
-
configDirectory,
|
|
81
|
-
config.routesDirectory
|
|
82
|
-
);
|
|
83
|
-
config.generatedRouteTree = path.resolve(
|
|
84
|
-
process.cwd(),
|
|
85
|
-
configDirectory,
|
|
86
|
-
config.generatedRouteTree
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const resolveTmpDir = (dir) => {
|
|
91
|
-
if (Array.isArray(dir)) {
|
|
92
|
-
dir = path.join(...dir);
|
|
93
|
-
}
|
|
94
|
-
if (!path.isAbsolute(dir)) {
|
|
95
|
-
dir = path.resolve(process.cwd(), dir);
|
|
96
|
-
}
|
|
97
|
-
mkdirSync(dir, { recursive: true });
|
|
98
|
-
return dir;
|
|
99
|
-
};
|
|
100
|
-
if (config.tmpDir) {
|
|
101
|
-
config.tmpDir = resolveTmpDir(config.tmpDir);
|
|
102
|
-
} else if (process.env.TSR_TMP_DIR) {
|
|
103
|
-
config.tmpDir = resolveTmpDir(process.env.TSR_TMP_DIR);
|
|
104
|
-
} else {
|
|
105
|
-
config.tmpDir = resolveTmpDir([".tanstack", "tmp"]);
|
|
106
|
-
}
|
|
107
|
-
validateConfig(config);
|
|
108
|
-
return config;
|
|
109
|
-
}
|
|
110
|
-
function validateConfig(config) {
|
|
111
|
-
var _a;
|
|
112
|
-
if (typeof ((_a = config.experimental) == null ? void 0 : _a.enableCodeSplitting) !== "undefined") {
|
|
113
|
-
const message = `
|
|
114
|
-
------
|
|
115
|
-
⚠️ ⚠️ ⚠️
|
|
116
|
-
ERROR: The "experimental.enableCodeSplitting" flag has been made stable and is now "autoCodeSplitting". Please update your configuration file to use "autoCodeSplitting" instead of "experimental.enableCodeSplitting".
|
|
117
|
-
------
|
|
118
|
-
`;
|
|
119
|
-
console.error(message);
|
|
120
|
-
throw new Error(message);
|
|
121
|
-
}
|
|
122
|
-
if (config.indexToken === config.routeToken) {
|
|
123
|
-
throw new Error(
|
|
124
|
-
`The "indexToken" and "routeToken" options must be different.`
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
if (config.routeFileIgnorePrefix && config.routeFileIgnorePrefix.trim() === "_") {
|
|
128
|
-
throw new Error(
|
|
129
|
-
`The "routeFileIgnorePrefix" cannot be an underscore ("_"). This is a reserved character used to denote a pathless route. Please use a different prefix.`
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
return config;
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
baseConfigSchema,
|
|
136
|
-
configSchema,
|
|
137
|
-
getConfig,
|
|
138
|
-
resolveConfigPath
|
|
139
|
-
};
|
|
140
|
-
//# sourceMappingURL=config.js.map
|
package/dist/esm/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import path from 'node:path'\nimport { existsSync, mkdirSync, readFileSync } from 'node:fs'\nimport { z } from 'zod'\nimport { virtualRootRouteSchema } from './filesystem/virtual/config'\nimport type { GeneratorPlugin } from './plugin/types'\n\nexport const baseConfigSchema = z.object({\n target: z.enum(['react', 'solid']).optional().default('react'),\n virtualRouteConfig: virtualRootRouteSchema.or(z.string()).optional(),\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 quoteStyle: z.enum(['single', 'double']).optional().default('single'),\n semicolons: z.boolean().optional().default(false),\n disableLogging: z.boolean().optional().default(false),\n routeTreeFileHeader: z\n .array(z.string())\n .optional()\n .default([\n '/* eslint-disable */',\n '// @ts-nocheck',\n '// noinspection JSUnusedGlobalSymbols',\n ]),\n indexToken: z.string().optional().default('index'),\n routeToken: z.string().optional().default('route'),\n pathParamsAllowedCharacters: z\n .array(z.enum([';', ':', '@', '&', '=', '+', '$', ',']))\n .optional(),\n})\n\nexport type BaseConfig = z.infer<typeof baseConfigSchema>\n\nexport const configSchema = baseConfigSchema.extend({\n generatedRouteTree: z.string().optional().default('./src/routeTree.gen.ts'),\n disableTypes: z.boolean().optional().default(false),\n verboseFileRoutes: z.boolean().optional(),\n addExtensions: z.boolean().optional().default(false),\n enableRouteTreeFormatting: z.boolean().optional().default(true),\n routeTreeFileFooter: z.array(z.string()).optional().default([]),\n autoCodeSplitting: z.boolean().optional(),\n customScaffolding: z\n .object({\n routeTemplate: z.string().optional(),\n lazyRouteTemplate: z.string().optional(),\n })\n .optional(),\n experimental: z\n .object({\n // TODO: This has been made stable and is now \"autoCodeSplitting\". Remove in next major version.\n enableCodeSplitting: z.boolean().optional(),\n })\n .optional(),\n plugins: z.array(z.custom<GeneratorPlugin>()).optional(),\n tmpDir: z.string().optional().default(''),\n})\n\nexport type Config = z.infer<typeof configSchema>\n\ntype ResolveParams = {\n configDirectory: string\n}\n\nexport function resolveConfigPath({ configDirectory }: ResolveParams) {\n return path.resolve(configDirectory, 'tsr.config.json')\n}\n\nexport function getConfig(\n inlineConfig: Partial<Config> = {},\n configDirectory?: string,\n): Config {\n if (configDirectory === undefined) {\n configDirectory = process.cwd()\n }\n const configFilePathJson = resolveConfigPath({ configDirectory })\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 // if a configDirectory is used, paths should be relative to that directory\n if (configDirectory) {\n // if absolute configDirectory is provided, use it as the root\n if (path.isAbsolute(configDirectory)) {\n config.routesDirectory = path.resolve(\n configDirectory,\n config.routesDirectory,\n )\n config.generatedRouteTree = path.resolve(\n configDirectory,\n config.generatedRouteTree,\n )\n } else {\n config.routesDirectory = path.resolve(\n process.cwd(),\n configDirectory,\n config.routesDirectory,\n )\n config.generatedRouteTree = path.resolve(\n process.cwd(),\n configDirectory,\n config.generatedRouteTree,\n )\n }\n }\n\n const resolveTmpDir = (dir: string | Array<string>) => {\n if (Array.isArray(dir)) {\n dir = path.join(...dir)\n }\n if (!path.isAbsolute(dir)) {\n dir = path.resolve(process.cwd(), dir)\n }\n mkdirSync(dir, { recursive: true })\n return dir\n }\n\n if (config.tmpDir) {\n config.tmpDir = resolveTmpDir(config.tmpDir)\n } else if (process.env.TSR_TMP_DIR) {\n config.tmpDir = resolveTmpDir(process.env.TSR_TMP_DIR)\n } else {\n config.tmpDir = resolveTmpDir(['.tanstack', 'tmp'])\n }\n\n validateConfig(config)\n return config\n}\n\nfunction validateConfig(config: Config) {\n if (typeof config.experimental?.enableCodeSplitting !== 'undefined') {\n const message = `\n------\n⚠️ ⚠️ ⚠️\nERROR: The \"experimental.enableCodeSplitting\" flag has been made stable and is now \"autoCodeSplitting\". Please update your configuration file to use \"autoCodeSplitting\" instead of \"experimental.enableCodeSplitting\".\n------\n`\n console.error(message)\n throw new Error(message)\n }\n\n if (config.indexToken === config.routeToken) {\n throw new Error(\n `The \"indexToken\" and \"routeToken\" options must be different.`,\n )\n }\n\n if (\n config.routeFileIgnorePrefix &&\n config.routeFileIgnorePrefix.trim() === '_'\n ) {\n throw new Error(\n `The \"routeFileIgnorePrefix\" cannot be an underscore (\"_\"). This is a reserved character used to denote a pathless route. Please use a different prefix.`,\n )\n }\n\n return config\n}\n"],"names":[],"mappings":";;;;AAMa,MAAA,mBAAmB,EAAE,OAAO;A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A,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGK,SAAA;AACT;"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { FsRouteType, GetRouteNodesResult } from '../../types.js';
|
|
2
|
-
import { Config } from '../../config.js';
|
|
3
|
-
export declare function isVirtualConfigFile(fileName: string): boolean;
|
|
4
|
-
export declare function getRouteNodes(config: Pick<Config, 'routesDirectory' | 'routeFilePrefix' | 'routeFileIgnorePrefix' | 'routeFileIgnorePattern' | 'disableLogging' | 'routeToken' | 'indexToken'>, root: string): Promise<GetRouteNodesResult>;
|
|
5
|
-
/**
|
|
6
|
-
* Determines the metadata for a given route path based on the provided configuration.
|
|
7
|
-
*
|
|
8
|
-
* @param routePath - The determined initial routePath.
|
|
9
|
-
* @param config - The user configuration object.
|
|
10
|
-
* @returns An object containing the type of the route and the variable name derived from the route path.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getRouteMeta(routePath: string, config: Pick<Config, 'routeToken' | 'indexToken'>): {
|
|
13
|
-
fsRouteType: Extract<FsRouteType, 'static' | 'layout' | 'api' | 'lazy' | 'loader' | 'component' | 'pendingComponent' | 'errorComponent'>;
|
|
14
|
-
variableName: string;
|
|
15
|
-
};
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import * as fsp from "node:fs/promises";
|
|
3
|
-
import { replaceBackslash, routePathToVariable, removeExt, determineInitialRoutePath } from "../../utils.js";
|
|
4
|
-
import { getRouteNodes as getRouteNodes$1 } from "../virtual/getRouteNodes.js";
|
|
5
|
-
import { loadConfigFile } from "../virtual/loadConfigFile.js";
|
|
6
|
-
import { logging } from "../../logger.js";
|
|
7
|
-
import { rootPathId } from "./rootPathId.js";
|
|
8
|
-
const disallowedRouteGroupConfiguration = /\(([^)]+)\).(ts|js|tsx|jsx)/;
|
|
9
|
-
const virtualConfigFileRegExp = /__virtual\.[mc]?[jt]s$/;
|
|
10
|
-
function isVirtualConfigFile(fileName) {
|
|
11
|
-
return virtualConfigFileRegExp.test(fileName);
|
|
12
|
-
}
|
|
13
|
-
async function getRouteNodes(config, root) {
|
|
14
|
-
const { routeFilePrefix, routeFileIgnorePrefix, routeFileIgnorePattern } = config;
|
|
15
|
-
const logger = logging({ disabled: config.disableLogging });
|
|
16
|
-
const routeFileIgnoreRegExp = new RegExp(routeFileIgnorePattern ?? "", "g");
|
|
17
|
-
const routeNodes = [];
|
|
18
|
-
const allPhysicalDirectories = [];
|
|
19
|
-
async function recurse(dir) {
|
|
20
|
-
const fullDir = path.resolve(config.routesDirectory, dir);
|
|
21
|
-
let dirList = await fsp.readdir(fullDir, { withFileTypes: true });
|
|
22
|
-
dirList = dirList.filter((d) => {
|
|
23
|
-
if (d.name.startsWith(".") || routeFileIgnorePrefix && d.name.startsWith(routeFileIgnorePrefix)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if (routeFilePrefix) {
|
|
27
|
-
return d.name.startsWith(routeFilePrefix);
|
|
28
|
-
}
|
|
29
|
-
if (routeFileIgnorePattern) {
|
|
30
|
-
return !d.name.match(routeFileIgnoreRegExp);
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
});
|
|
34
|
-
const virtualConfigFile = dirList.find((dirent) => {
|
|
35
|
-
return dirent.isFile() && isVirtualConfigFile(dirent.name);
|
|
36
|
-
});
|
|
37
|
-
if (virtualConfigFile !== void 0) {
|
|
38
|
-
const virtualRouteConfigExport = await loadConfigFile(
|
|
39
|
-
path.resolve(fullDir, virtualConfigFile.name)
|
|
40
|
-
);
|
|
41
|
-
let virtualRouteSubtreeConfig;
|
|
42
|
-
if (typeof virtualRouteConfigExport.default === "function") {
|
|
43
|
-
virtualRouteSubtreeConfig = await virtualRouteConfigExport.default();
|
|
44
|
-
} else {
|
|
45
|
-
virtualRouteSubtreeConfig = virtualRouteConfigExport.default;
|
|
46
|
-
}
|
|
47
|
-
const dummyRoot = {
|
|
48
|
-
type: "root",
|
|
49
|
-
file: "",
|
|
50
|
-
children: virtualRouteSubtreeConfig
|
|
51
|
-
};
|
|
52
|
-
const { routeNodes: virtualRouteNodes, physicalDirectories } = await getRouteNodes$1(
|
|
53
|
-
{
|
|
54
|
-
...config,
|
|
55
|
-
routesDirectory: fullDir,
|
|
56
|
-
virtualRouteConfig: dummyRoot
|
|
57
|
-
},
|
|
58
|
-
root
|
|
59
|
-
);
|
|
60
|
-
allPhysicalDirectories.push(...physicalDirectories);
|
|
61
|
-
virtualRouteNodes.forEach((node) => {
|
|
62
|
-
const filePath = replaceBackslash(path.join(dir, node.filePath));
|
|
63
|
-
const routePath = `/${dir}${node.routePath}`;
|
|
64
|
-
node.variableName = routePathToVariable(
|
|
65
|
-
`${dir}/${removeExt(node.filePath)}`
|
|
66
|
-
);
|
|
67
|
-
node.routePath = routePath;
|
|
68
|
-
node.filePath = filePath;
|
|
69
|
-
});
|
|
70
|
-
routeNodes.push(...virtualRouteNodes);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
await Promise.all(
|
|
74
|
-
dirList.map(async (dirent) => {
|
|
75
|
-
const fullPath = replaceBackslash(path.join(fullDir, dirent.name));
|
|
76
|
-
const relativePath = path.posix.join(dir, dirent.name);
|
|
77
|
-
if (dirent.isDirectory()) {
|
|
78
|
-
await recurse(relativePath);
|
|
79
|
-
} else if (fullPath.match(/\.(tsx|ts|jsx|js)$/)) {
|
|
80
|
-
const filePath = replaceBackslash(path.join(dir, dirent.name));
|
|
81
|
-
const filePathNoExt = removeExt(filePath);
|
|
82
|
-
let routePath = determineInitialRoutePath(filePathNoExt);
|
|
83
|
-
if (routeFilePrefix) {
|
|
84
|
-
routePath = routePath.replaceAll(routeFilePrefix, "");
|
|
85
|
-
}
|
|
86
|
-
if (disallowedRouteGroupConfiguration.test(dirent.name)) {
|
|
87
|
-
const errorMessage = `A route configuration for a route group was found at \`${filePath}\`. This is not supported. Did you mean to use a layout/pathless route instead?`;
|
|
88
|
-
logger.error(`ERROR: ${errorMessage}`);
|
|
89
|
-
throw new Error(errorMessage);
|
|
90
|
-
}
|
|
91
|
-
const meta = getRouteMeta(routePath, config);
|
|
92
|
-
const variableName = meta.variableName;
|
|
93
|
-
let routeType = meta.fsRouteType;
|
|
94
|
-
if (routeType === "lazy") {
|
|
95
|
-
routePath = routePath.replace(/\/lazy$/, "");
|
|
96
|
-
}
|
|
97
|
-
if (isValidPathlessLayoutRoute(routePath, routeType, config)) {
|
|
98
|
-
routeType = "pathless_layout";
|
|
99
|
-
}
|
|
100
|
-
[
|
|
101
|
-
["component", "component"],
|
|
102
|
-
["errorComponent", "errorComponent"],
|
|
103
|
-
["pendingComponent", "pendingComponent"],
|
|
104
|
-
["loader", "loader"]
|
|
105
|
-
].forEach(([matcher, type]) => {
|
|
106
|
-
if (routeType === matcher) {
|
|
107
|
-
logger.warn(
|
|
108
|
-
`WARNING: The \`.${type}.tsx\` suffix used for the ${filePath} file is deprecated. Use the new \`.lazy.tsx\` suffix instead.`
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
routePath = routePath.replace(
|
|
113
|
-
new RegExp(
|
|
114
|
-
`/(component|errorComponent|pendingComponent|loader|${config.routeToken}|lazy)$`
|
|
115
|
-
),
|
|
116
|
-
""
|
|
117
|
-
);
|
|
118
|
-
if (routePath === config.indexToken) {
|
|
119
|
-
routePath = "/";
|
|
120
|
-
}
|
|
121
|
-
routePath = routePath.replace(new RegExp(`/${config.indexToken}$`), "/") || "/";
|
|
122
|
-
routeNodes.push({
|
|
123
|
-
filePath,
|
|
124
|
-
fullPath,
|
|
125
|
-
routePath,
|
|
126
|
-
variableName,
|
|
127
|
-
_fsRouteType: routeType
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
return routeNodes;
|
|
133
|
-
}
|
|
134
|
-
await recurse("./");
|
|
135
|
-
const rootRouteNode = routeNodes.find((d) => d.routePath === `/${rootPathId}`);
|
|
136
|
-
if (rootRouteNode) {
|
|
137
|
-
rootRouteNode._fsRouteType = "__root";
|
|
138
|
-
rootRouteNode.variableName = "root";
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
rootRouteNode,
|
|
142
|
-
routeNodes,
|
|
143
|
-
physicalDirectories: allPhysicalDirectories
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function getRouteMeta(routePath, config) {
|
|
147
|
-
let fsRouteType = "static";
|
|
148
|
-
if (routePath.endsWith(`/${config.routeToken}`)) {
|
|
149
|
-
fsRouteType = "layout";
|
|
150
|
-
} else if (routePath.endsWith("/lazy")) {
|
|
151
|
-
fsRouteType = "lazy";
|
|
152
|
-
} else if (routePath.endsWith("/loader")) {
|
|
153
|
-
fsRouteType = "loader";
|
|
154
|
-
} else if (routePath.endsWith("/component")) {
|
|
155
|
-
fsRouteType = "component";
|
|
156
|
-
} else if (routePath.endsWith("/pendingComponent")) {
|
|
157
|
-
fsRouteType = "pendingComponent";
|
|
158
|
-
} else if (routePath.endsWith("/errorComponent")) {
|
|
159
|
-
fsRouteType = "errorComponent";
|
|
160
|
-
}
|
|
161
|
-
const variableName = routePathToVariable(routePath);
|
|
162
|
-
return { fsRouteType, variableName };
|
|
163
|
-
}
|
|
164
|
-
function isValidPathlessLayoutRoute(normalizedRoutePath, routeType, config) {
|
|
165
|
-
if (routeType === "lazy") {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
const segments = normalizedRoutePath.split("/").filter(Boolean);
|
|
169
|
-
if (segments.length === 0) {
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
const lastRouteSegment = segments[segments.length - 1];
|
|
173
|
-
const secondToLastRouteSegment = segments[segments.length - 2];
|
|
174
|
-
if (lastRouteSegment === rootPathId) {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
if (lastRouteSegment === config.routeToken && typeof secondToLastRouteSegment === "string") {
|
|
178
|
-
return secondToLastRouteSegment.startsWith("_");
|
|
179
|
-
}
|
|
180
|
-
return lastRouteSegment !== config.indexToken && lastRouteSegment !== config.routeToken && lastRouteSegment.startsWith("_");
|
|
181
|
-
}
|
|
182
|
-
export {
|
|
183
|
-
getRouteMeta,
|
|
184
|
-
getRouteNodes,
|
|
185
|
-
isVirtualConfigFile
|
|
186
|
-
};
|
|
187
|
-
//# sourceMappingURL=getRouteNodes.js.map
|