@tanstack/router-generator 1.121.20 → 1.121.25
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/dist/cjs/config.cjs +140 -0
- package/dist/cjs/config.cjs.map +1 -0
- package/dist/cjs/config.d.cts +155 -0
- package/dist/cjs/filesystem/physical/getRouteNodes.cjs +204 -0
- package/dist/cjs/filesystem/physical/getRouteNodes.cjs.map +1 -0
- package/dist/cjs/filesystem/physical/getRouteNodes.d.cts +15 -0
- package/dist/cjs/filesystem/physical/rootPathId.cjs +5 -0
- package/dist/cjs/filesystem/physical/rootPathId.cjs.map +1 -0
- package/dist/cjs/filesystem/physical/rootPathId.d.cts +1 -0
- package/dist/cjs/filesystem/virtual/config.cjs +37 -0
- package/dist/cjs/filesystem/virtual/config.cjs.map +1 -0
- package/dist/cjs/filesystem/virtual/config.d.cts +3 -0
- package/dist/cjs/filesystem/virtual/getRouteNodes.cjs +192 -0
- package/dist/cjs/filesystem/virtual/getRouteNodes.cjs.map +1 -0
- package/dist/cjs/filesystem/virtual/getRouteNodes.d.cts +8 -0
- package/dist/cjs/filesystem/virtual/loadConfigFile.cjs +11 -0
- package/dist/cjs/filesystem/virtual/loadConfigFile.cjs.map +1 -0
- package/dist/cjs/filesystem/virtual/loadConfigFile.d.cts +1 -0
- package/dist/cjs/generator.cjs +974 -0
- package/dist/cjs/generator.cjs.map +1 -0
- package/dist/cjs/generator.d.cts +77 -0
- package/dist/cjs/index.cjs +35 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +12 -0
- package/dist/cjs/logger.cjs +37 -0
- package/dist/cjs/logger.cjs.map +1 -0
- package/dist/cjs/logger.d.cts +10 -0
- package/dist/cjs/plugin/default-generator-plugin.cjs +101 -0
- package/dist/cjs/plugin/default-generator-plugin.cjs.map +1 -0
- package/dist/cjs/plugin/default-generator-plugin.d.cts +2 -0
- package/dist/cjs/plugin/types.d.cts +46 -0
- package/dist/cjs/template.cjs +110 -0
- package/dist/cjs/template.cjs.map +1 -0
- package/dist/cjs/template.d.cts +33 -0
- package/dist/cjs/transform/default-transform-plugin.cjs +95 -0
- package/dist/cjs/transform/default-transform-plugin.cjs.map +1 -0
- package/dist/cjs/transform/default-transform-plugin.d.cts +2 -0
- package/dist/cjs/transform/transform.cjs +374 -0
- package/dist/cjs/transform/transform.cjs.map +1 -0
- package/dist/cjs/transform/transform.d.cts +4 -0
- package/dist/cjs/transform/types.d.cts +43 -0
- package/dist/cjs/transform/utils.cjs +36 -0
- package/dist/cjs/transform/utils.cjs.map +1 -0
- package/dist/cjs/transform/utils.d.cts +2 -0
- package/dist/cjs/types.d.cts +47 -0
- package/dist/cjs/utils.cjs +438 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +133 -0
- package/dist/esm/config.d.ts +155 -0
- package/dist/esm/config.js +140 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/filesystem/physical/getRouteNodes.d.ts +15 -0
- package/dist/esm/filesystem/physical/getRouteNodes.js +187 -0
- package/dist/esm/filesystem/physical/getRouteNodes.js.map +1 -0
- package/dist/esm/filesystem/physical/rootPathId.d.ts +1 -0
- package/dist/esm/filesystem/physical/rootPathId.js +5 -0
- package/dist/esm/filesystem/physical/rootPathId.js.map +1 -0
- package/dist/esm/filesystem/virtual/config.d.ts +3 -0
- package/dist/esm/filesystem/virtual/config.js +37 -0
- package/dist/esm/filesystem/virtual/config.js.map +1 -0
- package/dist/esm/filesystem/virtual/getRouteNodes.d.ts +8 -0
- package/dist/esm/filesystem/virtual/getRouteNodes.js +192 -0
- package/dist/esm/filesystem/virtual/getRouteNodes.js.map +1 -0
- package/dist/esm/filesystem/virtual/loadConfigFile.d.ts +1 -0
- package/dist/esm/filesystem/virtual/loadConfigFile.js +11 -0
- package/dist/esm/filesystem/virtual/loadConfigFile.js.map +1 -0
- package/dist/esm/generator.d.ts +77 -0
- package/dist/esm/generator.js +957 -0
- package/dist/esm/generator.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +35 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.d.ts +10 -0
- package/dist/esm/logger.js +37 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/plugin/default-generator-plugin.d.ts +2 -0
- package/dist/esm/plugin/default-generator-plugin.js +101 -0
- package/dist/esm/plugin/default-generator-plugin.js.map +1 -0
- package/dist/esm/plugin/types.d.ts +46 -0
- package/dist/esm/template.d.ts +33 -0
- package/dist/esm/template.js +110 -0
- package/dist/esm/template.js.map +1 -0
- package/dist/esm/transform/default-transform-plugin.d.ts +2 -0
- package/dist/esm/transform/default-transform-plugin.js +95 -0
- package/dist/esm/transform/default-transform-plugin.js.map +1 -0
- package/dist/esm/transform/transform.d.ts +4 -0
- package/dist/esm/transform/transform.js +374 -0
- package/dist/esm/transform/transform.js.map +1 -0
- package/dist/esm/transform/types.d.ts +43 -0
- package/dist/esm/transform/utils.d.ts +2 -0
- package/dist/esm/transform/utils.js +36 -0
- package/dist/esm/transform/utils.js.map +1 -0
- package/dist/esm/types.d.ts +47 -0
- package/dist/esm/utils.d.ts +133 -0
- package/dist/esm/utils.js +420 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +5 -5
- package/src/generator.ts +5 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Config } from './config.js';
|
|
2
|
+
import { ImportDeclaration, RouteNode } from './types.js';
|
|
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;
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import * as fsp from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import * as prettier from "prettier";
|
|
4
|
+
import { rootPathId } from "./filesystem/physical/rootPathId.js";
|
|
5
|
+
function multiSortBy(arr, accessors = [(d) => d]) {
|
|
6
|
+
return arr.map((d, i) => [d, i]).sort(([a, ai], [b, bi]) => {
|
|
7
|
+
for (const accessor of accessors) {
|
|
8
|
+
const ao = accessor(a);
|
|
9
|
+
const bo = accessor(b);
|
|
10
|
+
if (typeof ao === "undefined") {
|
|
11
|
+
if (typeof bo === "undefined") {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
if (ao === bo) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
return ao > bo ? 1 : -1;
|
|
20
|
+
}
|
|
21
|
+
return ai - bi;
|
|
22
|
+
}).map(([d]) => d);
|
|
23
|
+
}
|
|
24
|
+
function cleanPath(path2) {
|
|
25
|
+
return path2.replace(/\/{2,}/g, "/");
|
|
26
|
+
}
|
|
27
|
+
function trimPathLeft(path2) {
|
|
28
|
+
return path2 === "/" ? path2 : path2.replace(/^\/{1,}/, "");
|
|
29
|
+
}
|
|
30
|
+
function removeLeadingSlash(path2) {
|
|
31
|
+
return path2.replace(/^\//, "");
|
|
32
|
+
}
|
|
33
|
+
function removeTrailingSlash(s) {
|
|
34
|
+
return s.replace(/\/$/, "");
|
|
35
|
+
}
|
|
36
|
+
function determineInitialRoutePath(routePath) {
|
|
37
|
+
const DISALLOWED_ESCAPE_CHARS = /* @__PURE__ */ new Set([
|
|
38
|
+
"/",
|
|
39
|
+
"\\",
|
|
40
|
+
"?",
|
|
41
|
+
"#",
|
|
42
|
+
":",
|
|
43
|
+
"*",
|
|
44
|
+
"<",
|
|
45
|
+
">",
|
|
46
|
+
"|",
|
|
47
|
+
"!",
|
|
48
|
+
"$",
|
|
49
|
+
"%"
|
|
50
|
+
]);
|
|
51
|
+
const parts = routePath.split(new RegExp("(?<!\\[)\\.(?!\\])", "g"));
|
|
52
|
+
const escapedParts = parts.map((part) => {
|
|
53
|
+
const BRACKET_CONTENT_RE = /\[(.*?)\]/g;
|
|
54
|
+
let match;
|
|
55
|
+
while ((match = BRACKET_CONTENT_RE.exec(part)) !== null) {
|
|
56
|
+
const character = match[1];
|
|
57
|
+
if (character === void 0) continue;
|
|
58
|
+
if (DISALLOWED_ESCAPE_CHARS.has(character)) {
|
|
59
|
+
console.error(
|
|
60
|
+
`Error: Disallowed character "${character}" found in square brackets in route path "${routePath}".
|
|
61
|
+
You cannot use any of the following characters in square brackets: ${Array.from(
|
|
62
|
+
DISALLOWED_ESCAPE_CHARS
|
|
63
|
+
).join(", ")}
|
|
64
|
+
Please remove and/or replace them.`
|
|
65
|
+
);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return part.replace(/\[(.)\]/g, "$1");
|
|
70
|
+
});
|
|
71
|
+
const final = cleanPath(`/${escapedParts.join("/")}`) || "";
|
|
72
|
+
return final;
|
|
73
|
+
}
|
|
74
|
+
function replaceBackslash(s) {
|
|
75
|
+
return s.replaceAll(/\\/gi, "/");
|
|
76
|
+
}
|
|
77
|
+
function routePathToVariable(routePath) {
|
|
78
|
+
var _a;
|
|
79
|
+
const toVariableSafeChar = (char) => {
|
|
80
|
+
if (/[a-zA-Z0-9_]/.test(char)) {
|
|
81
|
+
return char;
|
|
82
|
+
}
|
|
83
|
+
switch (char) {
|
|
84
|
+
case ".":
|
|
85
|
+
return "Dot";
|
|
86
|
+
case "-":
|
|
87
|
+
return "Dash";
|
|
88
|
+
case "@":
|
|
89
|
+
return "At";
|
|
90
|
+
case "(":
|
|
91
|
+
return "";
|
|
92
|
+
// Removed since route groups use parentheses
|
|
93
|
+
case ")":
|
|
94
|
+
return "";
|
|
95
|
+
// Removed since route groups use parentheses
|
|
96
|
+
case " ":
|
|
97
|
+
return "";
|
|
98
|
+
// Remove spaces
|
|
99
|
+
default:
|
|
100
|
+
return `Char${char.charCodeAt(0)}`;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return ((_a = removeUnderscores(routePath)) == null ? void 0 : _a.replace(/\/\$\//g, "/splat/").replace(/\$$/g, "splat").replace(/\$\{\$\}/g, "splat").replace(/\$/g, "").split(/[/-]/g).map((d, i) => i > 0 ? capitalize(d) : d).join("").split("").map(toVariableSafeChar).join("").replace(/^(\d)/g, "R$1")) ?? "";
|
|
104
|
+
}
|
|
105
|
+
function removeUnderscores(s) {
|
|
106
|
+
return s == null ? void 0 : s.replaceAll(/(^_|_$)/gi, "").replaceAll(/(\/_|_\/)/gi, "/");
|
|
107
|
+
}
|
|
108
|
+
function capitalize(s) {
|
|
109
|
+
if (typeof s !== "string") return "";
|
|
110
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
111
|
+
}
|
|
112
|
+
function removeExt(d, keepExtension = false) {
|
|
113
|
+
return keepExtension ? d : d.substring(0, d.lastIndexOf(".")) || d;
|
|
114
|
+
}
|
|
115
|
+
async function writeIfDifferent(filepath, content, incomingContent, callbacks) {
|
|
116
|
+
var _a, _b;
|
|
117
|
+
if (content !== incomingContent) {
|
|
118
|
+
(_a = callbacks == null ? void 0 : callbacks.beforeWrite) == null ? void 0 : _a.call(callbacks);
|
|
119
|
+
await fsp.writeFile(filepath, incomingContent);
|
|
120
|
+
(_b = callbacks == null ? void 0 : callbacks.afterWrite) == null ? void 0 : _b.call(callbacks);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
async function format(source, config) {
|
|
126
|
+
const prettierOptions = {
|
|
127
|
+
semi: config.semicolons,
|
|
128
|
+
singleQuote: config.quoteStyle === "single",
|
|
129
|
+
parser: "typescript"
|
|
130
|
+
};
|
|
131
|
+
return prettier.format(source, prettierOptions);
|
|
132
|
+
}
|
|
133
|
+
function resetRegex(regex) {
|
|
134
|
+
regex.lastIndex = 0;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
async function checkFileExists(file) {
|
|
138
|
+
try {
|
|
139
|
+
await fsp.access(file, fsp.constants.F_OK);
|
|
140
|
+
return true;
|
|
141
|
+
} catch {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const possiblyNestedRouteGroupPatternRegex = /\([^/]+\)\/?/g;
|
|
146
|
+
function removeGroups(s) {
|
|
147
|
+
return s.replace(possiblyNestedRouteGroupPatternRegex, "");
|
|
148
|
+
}
|
|
149
|
+
function removeLayoutSegments(routePath = "/") {
|
|
150
|
+
const segments = routePath.split("/");
|
|
151
|
+
const newSegments = segments.filter((segment) => !segment.startsWith("_"));
|
|
152
|
+
return newSegments.join("/");
|
|
153
|
+
}
|
|
154
|
+
function determineNodePath(node) {
|
|
155
|
+
var _a;
|
|
156
|
+
return node.path = node.parent ? ((_a = node.routePath) == null ? void 0 : _a.replace(node.parent.routePath ?? "", "")) || "/" : node.routePath;
|
|
157
|
+
}
|
|
158
|
+
function removeLastSegmentFromPath(routePath = "/") {
|
|
159
|
+
const segments = routePath.split("/");
|
|
160
|
+
segments.pop();
|
|
161
|
+
return segments.join("/");
|
|
162
|
+
}
|
|
163
|
+
function hasParentRoute(routes, node, routePathToCheck) {
|
|
164
|
+
if (!routePathToCheck || routePathToCheck === "/") {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const sortedNodes = multiSortBy(routes, [
|
|
168
|
+
(d) => d.routePath.length * -1,
|
|
169
|
+
(d) => d.variableName
|
|
170
|
+
]).filter((d) => d.routePath !== `/${rootPathId}`);
|
|
171
|
+
for (const route of sortedNodes) {
|
|
172
|
+
if (route.routePath === "/") continue;
|
|
173
|
+
if (routePathToCheck.startsWith(`${route.routePath}/`) && route.routePath !== routePathToCheck) {
|
|
174
|
+
return route;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const segments = routePathToCheck.split("/");
|
|
178
|
+
segments.pop();
|
|
179
|
+
const parentRoutePath = segments.join("/");
|
|
180
|
+
return hasParentRoute(routes, node, parentRoutePath);
|
|
181
|
+
}
|
|
182
|
+
const getResolvedRouteNodeVariableName = (routeNode, variableNameSuffix) => {
|
|
183
|
+
var _a;
|
|
184
|
+
return ((_a = routeNode.children) == null ? void 0 : _a.length) ? `${routeNode.variableName}${variableNameSuffix}WithChildren` : `${routeNode.variableName}${variableNameSuffix}`;
|
|
185
|
+
};
|
|
186
|
+
function isRouteNodeValidForAugmentation(routeNode) {
|
|
187
|
+
if (!routeNode || routeNode.isVirtual) {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
const inferPath = (routeNode) => {
|
|
193
|
+
var _a;
|
|
194
|
+
return routeNode.cleanedPath === "/" ? routeNode.cleanedPath : ((_a = routeNode.cleanedPath) == null ? void 0 : _a.replace(/\/$/, "")) ?? "";
|
|
195
|
+
};
|
|
196
|
+
const inferFullPath = (routeNode) => {
|
|
197
|
+
const fullPath = removeGroups(
|
|
198
|
+
removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? ""
|
|
199
|
+
);
|
|
200
|
+
return routeNode.cleanedPath === "/" ? fullPath : fullPath.replace(/\/$/, "");
|
|
201
|
+
};
|
|
202
|
+
const createRouteNodesByFullPath = (routeNodes) => {
|
|
203
|
+
return new Map(
|
|
204
|
+
routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode])
|
|
205
|
+
);
|
|
206
|
+
};
|
|
207
|
+
const createRouteNodesByTo = (routeNodes) => {
|
|
208
|
+
return new Map(
|
|
209
|
+
dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [
|
|
210
|
+
inferTo(routeNode),
|
|
211
|
+
routeNode
|
|
212
|
+
])
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
const createRouteNodesById = (routeNodes) => {
|
|
216
|
+
return new Map(
|
|
217
|
+
routeNodes.map((routeNode) => {
|
|
218
|
+
const id = routeNode.routePath ?? "";
|
|
219
|
+
return [id, routeNode];
|
|
220
|
+
})
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
const inferTo = (routeNode) => {
|
|
224
|
+
const fullPath = inferFullPath(routeNode);
|
|
225
|
+
if (fullPath === "/") return fullPath;
|
|
226
|
+
return fullPath.replace(/\/$/, "");
|
|
227
|
+
};
|
|
228
|
+
const dedupeBranchesAndIndexRoutes = (routes) => {
|
|
229
|
+
return routes.filter((route) => {
|
|
230
|
+
var _a;
|
|
231
|
+
if ((_a = route.children) == null ? void 0 : _a.find((child) => child.cleanedPath === "/")) return false;
|
|
232
|
+
return true;
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
function checkUnique(routes, key) {
|
|
236
|
+
const keys = routes.map((d) => d[key]);
|
|
237
|
+
const uniqueKeys = new Set(keys);
|
|
238
|
+
if (keys.length !== uniqueKeys.size) {
|
|
239
|
+
const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i);
|
|
240
|
+
const conflictingFiles = routes.filter(
|
|
241
|
+
(d) => duplicateKeys.includes(d[key])
|
|
242
|
+
);
|
|
243
|
+
return conflictingFiles;
|
|
244
|
+
}
|
|
245
|
+
return void 0;
|
|
246
|
+
}
|
|
247
|
+
function checkRouteFullPathUniqueness(_routes, config) {
|
|
248
|
+
const routes = _routes.map((d) => {
|
|
249
|
+
const inferredFullPath = inferFullPath(d);
|
|
250
|
+
return { ...d, inferredFullPath };
|
|
251
|
+
});
|
|
252
|
+
const conflictingFiles = checkUnique(routes, "inferredFullPath");
|
|
253
|
+
if (conflictingFiles !== void 0) {
|
|
254
|
+
const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? "s" : ""}: ${conflictingFiles.map((p) => `"${p.inferredFullPath}"`).join(", ")}.
|
|
255
|
+
Please ensure each Route has a unique full path.
|
|
256
|
+
Conflicting files:
|
|
257
|
+
${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join("\n ")}
|
|
258
|
+
`;
|
|
259
|
+
throw new Error(errorMessage);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function buildRouteTreeConfig(nodes, exportName, disableTypes, depth = 1) {
|
|
263
|
+
const children = nodes.filter((n) => {
|
|
264
|
+
var _a;
|
|
265
|
+
return (_a = n.exports) == null ? void 0 : _a.includes(exportName);
|
|
266
|
+
}).map((node) => {
|
|
267
|
+
var _a, _b;
|
|
268
|
+
if (node._fsRouteType === "__root") {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (node._fsRouteType === "pathless_layout" && !((_a = node.children) == null ? void 0 : _a.length)) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const route = `${node.variableName}`;
|
|
275
|
+
if ((_b = node.children) == null ? void 0 : _b.length) {
|
|
276
|
+
const childConfigs = buildRouteTreeConfig(
|
|
277
|
+
node.children,
|
|
278
|
+
exportName,
|
|
279
|
+
disableTypes,
|
|
280
|
+
depth + 1
|
|
281
|
+
);
|
|
282
|
+
const childrenDeclaration = disableTypes ? "" : `interface ${route}${exportName}Children {
|
|
283
|
+
${node.children.filter((n) => {
|
|
284
|
+
var _a2;
|
|
285
|
+
return (_a2 = n.exports) == null ? void 0 : _a2.includes(exportName);
|
|
286
|
+
}).map(
|
|
287
|
+
(child) => `${child.variableName}${exportName}: typeof ${getResolvedRouteNodeVariableName(child, exportName)}`
|
|
288
|
+
).join(",")}
|
|
289
|
+
}`;
|
|
290
|
+
const children2 = `const ${route}${exportName}Children${disableTypes ? "" : `: ${route}${exportName}Children`} = {
|
|
291
|
+
${node.children.filter((n) => {
|
|
292
|
+
var _a2;
|
|
293
|
+
return (_a2 = n.exports) == null ? void 0 : _a2.includes(exportName);
|
|
294
|
+
}).map(
|
|
295
|
+
(child) => `${child.variableName}${exportName}: ${getResolvedRouteNodeVariableName(child, exportName)}`
|
|
296
|
+
).join(",")}
|
|
297
|
+
}`;
|
|
298
|
+
const routeWithChildren = `const ${route}${exportName}WithChildren = ${route}${exportName}._addFileChildren(${route}${exportName}Children)`;
|
|
299
|
+
return [
|
|
300
|
+
childConfigs.join("\n"),
|
|
301
|
+
childrenDeclaration,
|
|
302
|
+
children2,
|
|
303
|
+
routeWithChildren
|
|
304
|
+
].join("\n\n");
|
|
305
|
+
}
|
|
306
|
+
return void 0;
|
|
307
|
+
});
|
|
308
|
+
return children.filter((x) => x !== void 0);
|
|
309
|
+
}
|
|
310
|
+
function buildImportString(importDeclaration) {
|
|
311
|
+
const { source, specifiers, importKind } = importDeclaration;
|
|
312
|
+
return specifiers.length ? `import ${importKind === "type" ? "type " : ""}{ ${specifiers.map((s) => s.local ? `${s.imported} as ${s.local}` : s.imported).join(", ")} } from '${source}'` : "";
|
|
313
|
+
}
|
|
314
|
+
function lowerCaseFirstChar(value) {
|
|
315
|
+
if (!value[0]) {
|
|
316
|
+
return value;
|
|
317
|
+
}
|
|
318
|
+
return value[0].toLowerCase() + value.slice(1);
|
|
319
|
+
}
|
|
320
|
+
function mergeImportDeclarations(imports) {
|
|
321
|
+
const merged = {};
|
|
322
|
+
for (const imp of imports) {
|
|
323
|
+
const key = `${imp.source}-${imp.importKind}`;
|
|
324
|
+
if (!merged[key]) {
|
|
325
|
+
merged[key] = { ...imp, specifiers: [] };
|
|
326
|
+
}
|
|
327
|
+
for (const specifier of imp.specifiers) {
|
|
328
|
+
if (!merged[key].specifiers.some(
|
|
329
|
+
(existing) => existing.imported === specifier.imported && existing.local === specifier.local
|
|
330
|
+
)) {
|
|
331
|
+
merged[key].specifiers.push(specifier);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return Object.values(merged);
|
|
336
|
+
}
|
|
337
|
+
function hasChildWithExport(node, exportName) {
|
|
338
|
+
var _a;
|
|
339
|
+
return ((_a = node.children) == null ? void 0 : _a.some((child) => hasChildWithExport(child))) ?? false;
|
|
340
|
+
}
|
|
341
|
+
const findParent = (node, exportName) => {
|
|
342
|
+
var _a;
|
|
343
|
+
if (!node) {
|
|
344
|
+
return `root${exportName}Import`;
|
|
345
|
+
}
|
|
346
|
+
if (node.parent) {
|
|
347
|
+
if ((_a = node.parent.exports) == null ? void 0 : _a.includes(exportName)) {
|
|
348
|
+
if (node.isVirtualParentRequired) {
|
|
349
|
+
return `${node.parent.variableName}${exportName}`;
|
|
350
|
+
} else {
|
|
351
|
+
return `${node.parent.variableName}${exportName}`;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return findParent(node.parent, exportName);
|
|
356
|
+
};
|
|
357
|
+
function buildFileRoutesByPathInterface(opts) {
|
|
358
|
+
return `declare module '${opts.module}' {
|
|
359
|
+
interface ${opts.interfaceName} {
|
|
360
|
+
${opts.routeNodes.map((routeNode) => {
|
|
361
|
+
var _a;
|
|
362
|
+
const filePathId = routeNode.routePath;
|
|
363
|
+
let preloaderRoute = "";
|
|
364
|
+
if ((_a = routeNode.exports) == null ? void 0 : _a.includes(opts.exportName)) {
|
|
365
|
+
preloaderRoute = `typeof ${routeNode.variableName}${opts.exportName}Import`;
|
|
366
|
+
} else {
|
|
367
|
+
preloaderRoute = "unknown";
|
|
368
|
+
}
|
|
369
|
+
const parent = findParent(routeNode, opts.exportName);
|
|
370
|
+
return `'${filePathId}': {
|
|
371
|
+
id: '${filePathId}'
|
|
372
|
+
path: '${inferPath(routeNode)}'
|
|
373
|
+
fullPath: '${inferFullPath(routeNode)}'
|
|
374
|
+
preLoaderRoute: ${preloaderRoute}
|
|
375
|
+
parentRoute: typeof ${parent}
|
|
376
|
+
}`;
|
|
377
|
+
}).join("\n")}
|
|
378
|
+
}
|
|
379
|
+
}`;
|
|
380
|
+
}
|
|
381
|
+
export {
|
|
382
|
+
buildFileRoutesByPathInterface,
|
|
383
|
+
buildImportString,
|
|
384
|
+
buildRouteTreeConfig,
|
|
385
|
+
capitalize,
|
|
386
|
+
checkFileExists,
|
|
387
|
+
checkRouteFullPathUniqueness,
|
|
388
|
+
cleanPath,
|
|
389
|
+
createRouteNodesByFullPath,
|
|
390
|
+
createRouteNodesById,
|
|
391
|
+
createRouteNodesByTo,
|
|
392
|
+
dedupeBranchesAndIndexRoutes,
|
|
393
|
+
determineInitialRoutePath,
|
|
394
|
+
determineNodePath,
|
|
395
|
+
findParent,
|
|
396
|
+
format,
|
|
397
|
+
getResolvedRouteNodeVariableName,
|
|
398
|
+
hasChildWithExport,
|
|
399
|
+
hasParentRoute,
|
|
400
|
+
inferFullPath,
|
|
401
|
+
inferPath,
|
|
402
|
+
inferTo,
|
|
403
|
+
isRouteNodeValidForAugmentation,
|
|
404
|
+
lowerCaseFirstChar,
|
|
405
|
+
mergeImportDeclarations,
|
|
406
|
+
multiSortBy,
|
|
407
|
+
removeExt,
|
|
408
|
+
removeGroups,
|
|
409
|
+
removeLastSegmentFromPath,
|
|
410
|
+
removeLayoutSegments,
|
|
411
|
+
removeLeadingSlash,
|
|
412
|
+
removeTrailingSlash,
|
|
413
|
+
removeUnderscores,
|
|
414
|
+
replaceBackslash,
|
|
415
|
+
resetRegex,
|
|
416
|
+
routePathToVariable,
|
|
417
|
+
trimPathLeft,
|
|
418
|
+
writeIfDifferent
|
|
419
|
+
};
|
|
420
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/utils.ts"],"sourcesContent":["import * as fsp from 'node:fs/promises'\nimport path from 'node:path'\nimport * as prettier from 'prettier'\nimport { rootPathId } from './filesystem/physical/rootPathId'\nimport type { Config } from './config'\nimport type { ImportDeclaration, RouteNode } from './types'\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\nexport 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 removeLeadingSlash(path: string): string {\n return path.replace(/^\\//, '')\n}\n\nexport function removeTrailingSlash(s: string) {\n return s.replace(/\\/$/, '')\n}\n\nexport function determineInitialRoutePath(routePath: string) {\n const DISALLOWED_ESCAPE_CHARS = new Set([\n '/',\n '\\\\',\n '?',\n '#',\n ':',\n '*',\n '<',\n '>',\n '|',\n '!',\n '$',\n '%',\n ])\n\n const parts = routePath.split(/(?<!\\[)\\.(?!\\])/g)\n\n // Escape any characters that in square brackets\n const escapedParts = parts.map((part) => {\n // Check if any disallowed characters are used in brackets\n const BRACKET_CONTENT_RE = /\\[(.*?)\\]/g\n\n let match\n while ((match = BRACKET_CONTENT_RE.exec(part)) !== null) {\n const character = match[1]\n if (character === undefined) continue\n if (DISALLOWED_ESCAPE_CHARS.has(character)) {\n console.error(\n `Error: Disallowed character \"${character}\" found in square brackets in route path \"${routePath}\".\\nYou cannot use any of the following characters in square brackets: ${Array.from(\n DISALLOWED_ESCAPE_CHARS,\n ).join(', ')}\\nPlease remove and/or replace them.`,\n )\n process.exit(1)\n }\n }\n\n // Since this split segment is safe at this point, we can\n // remove the brackets and replace them with the content inside\n return part.replace(/\\[(.)\\]/g, '$1')\n })\n\n // If the syntax for prefix/suffix is different, from the path\n // matching internals of router-core, we'd perform those changes here\n // on the `escapedParts` array before it is joined back together in\n // `final`\n\n const final = cleanPath(`/${escapedParts.join('/')}`) || ''\n\n return final\n}\n\nexport function replaceBackslash(s: string) {\n return s.replaceAll(/\\\\/gi, '/')\n}\n\nexport function routePathToVariable(routePath: string): string {\n const toVariableSafeChar = (char: string): string => {\n if (/[a-zA-Z0-9_]/.test(char)) {\n return char // Keep alphanumeric characters and underscores as is\n }\n\n // Replace special characters with meaningful text equivalents\n switch (char) {\n case '.':\n return 'Dot'\n case '-':\n return 'Dash'\n case '@':\n return 'At'\n case '(':\n return '' // Removed since route groups use parentheses\n case ')':\n return '' // Removed since route groups use parentheses\n case ' ':\n return '' // Remove spaces\n default:\n return `Char${char.charCodeAt(0)}` // For any other characters\n }\n }\n\n return (\n removeUnderscores(routePath)\n ?.replace(/\\/\\$\\//g, '/splat/')\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 .split('')\n .map(toVariableSafeChar)\n .join('')\n // .replace(/([^a-zA-Z0-9]|[.])/gm, '')\n .replace(/^(\\d)/g, 'R$1') ?? ''\n )\n}\n\nexport function removeUnderscores(s?: string) {\n return s?.replaceAll(/(^_|_$)/gi, '').replaceAll(/(\\/_|_\\/)/gi, '/')\n}\n\nexport function capitalize(s: string) {\n if (typeof s !== 'string') return ''\n return s.charAt(0).toUpperCase() + s.slice(1)\n}\n\nexport function removeExt(d: string, keepExtension: boolean = false) {\n return keepExtension ? d : d.substring(0, d.lastIndexOf('.')) || d\n}\n\n/**\n * This function writes to a file if the content is different.\n *\n * @param filepath The path to the file\n * @param content Original content\n * @param incomingContent New content\n * @param callbacks Callbacks to run before and after writing\n * @returns Whether the file was written\n */\nexport async function writeIfDifferent(\n filepath: string,\n content: string,\n incomingContent: string,\n callbacks?: { beforeWrite?: () => void; afterWrite?: () => void },\n): Promise<boolean> {\n if (content !== incomingContent) {\n callbacks?.beforeWrite?.()\n await fsp.writeFile(filepath, incomingContent)\n callbacks?.afterWrite?.()\n return true\n }\n return false\n}\n\n/**\n * This function formats the source code using the default formatter (Prettier).\n *\n * @param source The content to format\n * @param config The configuration object\n * @returns The formatted content\n */\nexport async function format(\n source: string,\n config: {\n quoteStyle: 'single' | 'double'\n semicolons: boolean\n },\n): Promise<string> {\n const prettierOptions: prettier.Config = {\n semi: config.semicolons,\n singleQuote: config.quoteStyle === 'single',\n parser: 'typescript',\n }\n return prettier.format(source, prettierOptions)\n}\n\n/**\n * This function resets the regex index to 0 so that it can be reused\n * without having to create a new regex object or worry about the last\n * state when using the global flag.\n *\n * @param regex The regex object to reset\n * @returns\n */\nexport function resetRegex(regex: RegExp) {\n regex.lastIndex = 0\n return\n}\n\n/**\n * This function checks if a file exists.\n *\n * @param file The path to the file\n * @returns Whether the file exists\n */\nexport async function checkFileExists(file: string) {\n try {\n await fsp.access(file, fsp.constants.F_OK)\n return true\n } catch {\n return false\n }\n}\n\nconst possiblyNestedRouteGroupPatternRegex = /\\([^/]+\\)\\/?/g\nexport function removeGroups(s: string) {\n return s.replace(possiblyNestedRouteGroupPatternRegex, '')\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 */\nexport function removeLayoutSegments(routePath: string = '/'): string {\n const segments = routePath.split('/')\n const newSegments = segments.filter((segment) => !segment.startsWith('_'))\n return newSegments.join('/')\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 */\nexport function 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\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\n/**\n * Gets the final variable name for a route\n */\nexport const getResolvedRouteNodeVariableName = (\n routeNode: RouteNode,\n variableNameSuffix: string,\n): string => {\n return routeNode.children?.length\n ? `${routeNode.variableName}${variableNameSuffix}WithChildren`\n : `${routeNode.variableName}${variableNameSuffix}`\n}\n\n/**\n * Checks if a given RouteNode is valid for augmenting it with typing based on conditions.\n * Also asserts that the RouteNode is defined.\n *\n * @param routeNode - The RouteNode to check.\n * @returns A boolean indicating whether the RouteNode is defined.\n */\nexport function isRouteNodeValidForAugmentation(\n routeNode?: RouteNode,\n): routeNode is RouteNode {\n if (!routeNode || routeNode.isVirtual) {\n return false\n }\n return true\n}\n\n/**\n * Infers the path for use by TS\n */\nexport const inferPath = (routeNode: RouteNode): string => {\n return routeNode.cleanedPath === '/'\n ? routeNode.cleanedPath\n : (routeNode.cleanedPath?.replace(/\\/$/, '') ?? '')\n}\n\n/**\n * Infers the full path for use by TS\n */\nexport const inferFullPath = (routeNode: RouteNode): string => {\n const fullPath = removeGroups(\n removeUnderscores(removeLayoutSegments(routeNode.routePath)) ?? '',\n )\n\n return routeNode.cleanedPath === '/' ? fullPath : fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Creates a map from fullPath to routeNode\n */\nexport const createRouteNodesByFullPath = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => [inferFullPath(routeNode), routeNode]),\n )\n}\n\n/**\n * Create a map from 'to' to a routeNode\n */\nexport const createRouteNodesByTo = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n dedupeBranchesAndIndexRoutes(routeNodes).map((routeNode) => [\n inferTo(routeNode),\n routeNode,\n ]),\n )\n}\n\n/**\n * Create a map from 'id' to a routeNode\n */\nexport const createRouteNodesById = (\n routeNodes: Array<RouteNode>,\n): Map<string, RouteNode> => {\n return new Map(\n routeNodes.map((routeNode) => {\n const id = routeNode.routePath ?? ''\n return [id, routeNode]\n }),\n )\n}\n\n/**\n * Infers to path\n */\nexport const inferTo = (routeNode: RouteNode): string => {\n const fullPath = inferFullPath(routeNode)\n\n if (fullPath === '/') return fullPath\n\n return fullPath.replace(/\\/$/, '')\n}\n\n/**\n * Dedupes branches and index routes\n */\nexport const dedupeBranchesAndIndexRoutes = (\n routes: Array<RouteNode>,\n): Array<RouteNode> => {\n return routes.filter((route) => {\n if (route.children?.find((child) => child.cleanedPath === '/')) return false\n return true\n })\n}\n\nfunction checkUnique<TElement>(routes: Array<TElement>, key: keyof TElement) {\n // Check no two routes have the same `key`\n // if they do, throw an error with the conflicting filePaths\n const keys = routes.map((d) => d[key])\n const uniqueKeys = new Set(keys)\n if (keys.length !== uniqueKeys.size) {\n const duplicateKeys = keys.filter((d, i) => keys.indexOf(d) !== i)\n const conflictingFiles = routes.filter((d) =>\n duplicateKeys.includes(d[key]),\n )\n return conflictingFiles\n }\n return undefined\n}\n\nexport function checkRouteFullPathUniqueness(\n _routes: Array<RouteNode>,\n config: Config,\n) {\n const routes = _routes.map((d) => {\n const inferredFullPath = inferFullPath(d)\n return { ...d, inferredFullPath }\n })\n\n const conflictingFiles = checkUnique(routes, 'inferredFullPath')\n\n if (conflictingFiles !== undefined) {\n const errorMessage = `Conflicting configuration paths were found for the following route${conflictingFiles.length > 1 ? 's' : ''}: ${conflictingFiles\n .map((p) => `\"${p.inferredFullPath}\"`)\n .join(', ')}.\nPlease ensure each Route has a unique full path.\nConflicting files: \\n ${conflictingFiles.map((d) => path.resolve(config.routesDirectory, d.filePath)).join('\\n ')}\\n`\n throw new Error(errorMessage)\n }\n}\n\nexport function buildRouteTreeConfig(\n nodes: Array<RouteNode>,\n exportName: string,\n disableTypes: boolean,\n depth = 1,\n): Array<string> {\n const children = nodes\n .filter((n) => n.exports?.includes(exportName))\n .map((node) => {\n if (node._fsRouteType === '__root') {\n return\n }\n\n if (node._fsRouteType === 'pathless_layout' && !node.children?.length) {\n return\n }\n\n const route = `${node.variableName}`\n\n if (node.children?.length) {\n const childConfigs = buildRouteTreeConfig(\n node.children,\n exportName,\n disableTypes,\n depth + 1,\n )\n\n const childrenDeclaration = disableTypes\n ? ''\n : `interface ${route}${exportName}Children {\n ${node.children\n .filter((n) => n.exports?.includes(exportName))\n .map(\n (child) =>\n `${child.variableName}${exportName}: typeof ${getResolvedRouteNodeVariableName(child, exportName)}`,\n )\n .join(',')}\n}`\n\n const children = `const ${route}${exportName}Children${disableTypes ? '' : `: ${route}${exportName}Children`} = {\n ${node.children\n .filter((n) => n.exports?.includes(exportName))\n .map(\n (child) =>\n `${child.variableName}${exportName}: ${getResolvedRouteNodeVariableName(child, exportName)}`,\n )\n .join(',')}\n}`\n\n const routeWithChildren = `const ${route}${exportName}WithChildren = ${route}${exportName}._addFileChildren(${route}${exportName}Children)`\n\n return [\n childConfigs.join('\\n'),\n childrenDeclaration,\n children,\n routeWithChildren,\n ].join('\\n\\n')\n }\n\n return undefined\n })\n\n return children.filter((x) => x !== undefined)\n}\n\nexport function buildImportString(\n importDeclaration: ImportDeclaration,\n): string {\n const { source, specifiers, importKind } = importDeclaration\n return specifiers.length\n ? `import ${importKind === 'type' ? 'type ' : ''}{ ${specifiers.map((s) => (s.local ? `${s.imported} as ${s.local}` : s.imported)).join(', ')} } from '${source}'`\n : ''\n}\n\nexport function lowerCaseFirstChar(value: string) {\n if (!value[0]) {\n return value\n }\n\n return value[0].toLowerCase() + value.slice(1)\n}\n\nexport function mergeImportDeclarations(\n imports: Array<ImportDeclaration>,\n): Array<ImportDeclaration> {\n const merged: Record<string, ImportDeclaration> = {}\n\n for (const imp of imports) {\n const key = `${imp.source}-${imp.importKind}`\n if (!merged[key]) {\n merged[key] = { ...imp, specifiers: [] }\n }\n for (const specifier of imp.specifiers) {\n // check if the specifier already exists in the merged import\n if (\n !merged[key].specifiers.some(\n (existing) =>\n existing.imported === specifier.imported &&\n existing.local === specifier.local,\n )\n ) {\n merged[key].specifiers.push(specifier)\n }\n }\n }\n\n return Object.values(merged)\n}\n\nexport function hasChildWithExport(\n node: RouteNode,\n exportName: string,\n): boolean {\n return (\n node.children?.some((child) => hasChildWithExport(child, exportName)) ??\n false\n )\n}\n\nexport const findParent = (\n node: RouteNode | undefined,\n exportName: string,\n): string => {\n if (!node) {\n return `root${exportName}Import`\n }\n if (node.parent) {\n if (node.parent.exports?.includes(exportName)) {\n if (node.isVirtualParentRequired) {\n return `${node.parent.variableName}${exportName}`\n } else {\n return `${node.parent.variableName}${exportName}`\n }\n }\n }\n return findParent(node.parent, exportName)\n}\n\nexport function buildFileRoutesByPathInterface(opts: {\n routeNodes: Array<RouteNode>\n module: string\n interfaceName: string\n exportName: string\n}): string {\n return `declare module '${opts.module}' {\n interface ${opts.interfaceName} {\n ${opts.routeNodes\n .map((routeNode) => {\n const filePathId = routeNode.routePath\n let preloaderRoute = ''\n\n if (routeNode.exports?.includes(opts.exportName)) {\n preloaderRoute = `typeof ${routeNode.variableName}${opts.exportName}Import`\n } else {\n preloaderRoute = 'unknown'\n }\n\n const parent = findParent(routeNode, opts.exportName)\n\n return `'${filePathId}': {\n id: '${filePathId}'\n path: '${inferPath(routeNode)}'\n fullPath: '${inferFullPath(routeNode)}'\n preLoaderRoute: ${preloaderRoute}\n parentRoute: typeof ${parent}\n }`\n })\n .join('\\n')}\n }\n}`\n}\n"],"names":["path","_a","children"],"mappings":";;;;AAOO,SAAS,YACd,KACA,YAAqC,CAAC,CAAC,MAAM,CAAC,GACpC;AACV,SAAO,IACJ,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAU,EAC7B,KAAK,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM;AAC1B,eAAW,YAAY,WAAW;AAC1B,YAAA,KAAK,SAAS,CAAC;AACf,YAAA,KAAK,SAAS,CAAC;AAEjB,UAAA,OAAO,OAAO,aAAa;AACzB,YAAA,OAAO,OAAO,aAAa;AAC7B;AAAA,QAAA;AAEK,eAAA;AAAA,MAAA;AAGT,UAAI,OAAO,IAAI;AACb;AAAA,MAAA;AAGK,aAAA,KAAK,KAAK,IAAI;AAAA,IAAA;AAGvB,WAAO,KAAK;AAAA,EACb,CAAA,EACA,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;AACnB;AAEO,SAAS,UAAUA,OAAc;AAE/BA,SAAAA,MAAK,QAAQ,WAAW,GAAG;AACpC;AAEO,SAAS,aAAaA,OAAc;AACzC,SAAOA,UAAS,MAAMA,QAAOA,MAAK,QAAQ,WAAW,EAAE;AACzD;AAEO,SAAS,mBAAmBA,OAAsB;AAChDA,SAAAA,MAAK,QAAQ,OAAO,EAAE;AAC/B;AAEO,SAAS,oBAAoB,GAAW;AACtC,SAAA,EAAE,QAAQ,OAAO,EAAE;AAC5B;AAEO,SAAS,0BAA0B,WAAmB;AACrD,QAAA,8CAA8B,IAAI;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEK,QAAA,QAAQ,UAAU,MAAM,oCAAkB;AA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AErB,SAAI,eAAU,YAAV,mBAAmB,SAAS,KAAK,aAAa;AAChD,uBAAiB,UAAU,UAAU,YAAY,GAAG,KAAK,UAAU;AAAA,IAAA,OAC9D;AACY,uBAAA;AAAA,IAAA;AAGnB,UAAM,SAAS,WAAW,WAAW,KAAK,UAAU;AAEpD,WAAO,IAAI,UAAU;AAAA,iBACZ,UAAU;AAAA,mBACR,UAAU,SAAS,CAAC;AAAA,uBAChB,cAAc,SAAS,CAAC;AAAA,4BACnB,cAAc;AAAA,gCACV,MAAM;AAAA;AAAA,EAAA,CAE/B,EACA,KAAK,IAAI,CAAC;AAAA;AAAA;AAGjB;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/router-generator",
|
|
3
|
-
"version": "1.121.
|
|
3
|
+
"version": "1.121.25",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"source-map": "^0.7.4",
|
|
55
55
|
"tsx": "^4.19.2",
|
|
56
56
|
"zod": "^3.24.2",
|
|
57
|
-
"@tanstack/router-
|
|
58
|
-
"@tanstack/
|
|
59
|
-
"@tanstack/
|
|
57
|
+
"@tanstack/router-core": "^1.121.21",
|
|
58
|
+
"@tanstack/router-utils": "^1.121.21",
|
|
59
|
+
"@tanstack/virtual-file-routes": "^1.121.21"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@tanstack/react-router": "^1.121.
|
|
62
|
+
"@tanstack/react-router": "^1.121.24"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {}
|
|
65
65
|
}
|
package/src/generator.ts
CHANGED
|
@@ -424,6 +424,7 @@ export class Generator {
|
|
|
424
424
|
}
|
|
425
425
|
|
|
426
426
|
if (!writeRouteTreeFile) {
|
|
427
|
+
this.swapCaches()
|
|
427
428
|
return
|
|
428
429
|
}
|
|
429
430
|
|
|
@@ -473,7 +474,10 @@ export class Generator {
|
|
|
473
474
|
}
|
|
474
475
|
}
|
|
475
476
|
|
|
476
|
-
|
|
477
|
+
this.swapCaches()
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
private swapCaches() {
|
|
477
481
|
this.routeNodeCache = this.routeNodeShadowCache
|
|
478
482
|
this.routeNodeShadowCache = new Map()
|
|
479
483
|
}
|