@chuckcchen/vite-plugin 1.0.16 → 1.0.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/dist/core.d.ts.map +1 -1
- package/dist/core.js +8 -4
- package/dist/core.js.map +1 -1
- package/dist/factory/hooks.d.ts +1 -1
- package/dist/factory/hooks.d.ts.map +1 -1
- package/dist/factory/hooks.js +4 -2
- package/dist/factory/hooks.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/route/index.d.ts +7 -0
- package/dist/route/index.d.ts.map +1 -0
- package/dist/route/index.js +8 -0
- package/dist/route/index.js.map +1 -0
- package/dist/route/parser.d.ts +55 -0
- package/dist/route/parser.d.ts.map +1 -0
- package/dist/route/parser.js +300 -0
- package/dist/route/parser.js.map +1 -0
- package/dist/route/regex.d.ts +96 -0
- package/dist/route/regex.d.ts.map +1 -0
- package/dist/route/regex.js +244 -0
- package/dist/route/regex.js.map +1 -0
- package/dist/route/types.d.ts +116 -0
- package/dist/route/types.d.ts.map +1 -0
- package/dist/route/types.js +5 -0
- package/dist/route/types.js.map +1 -0
- package/dist/route-parser.d.ts +4 -228
- package/dist/route-parser.d.ts.map +1 -1
- package/dist/route-parser.js +4 -481
- package/dist/route-parser.js.map +1 -1
- package/dist/types.d.ts +12 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/route-parser.d.ts
CHANGED
|
@@ -1,232 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Route Parser -
|
|
2
|
+
* Route Parser - Re-exports from route module
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* @deprecated Import from "./route/index.js" instead
|
|
5
|
+
* This file is kept for backward compatibility.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Framework route syntax types
|
|
10
|
-
*/
|
|
11
|
-
export type FrameworkSyntax = "react-router" | "tanstack-start" | "nextjs" | "auto";
|
|
12
|
-
/**
|
|
13
|
-
* Options for converting route path to regex
|
|
14
|
-
*/
|
|
15
|
-
export interface RouteToRegexOptions {
|
|
16
|
-
/** Framework syntax to use for parsing. Default: "auto" (auto-detect) */
|
|
17
|
-
syntax?: FrameworkSyntax;
|
|
18
|
-
/** Whether to make the trailing slash optional. Default: true */
|
|
19
|
-
trailingSlashOptional?: boolean;
|
|
20
|
-
/** Whether to anchor the regex at start and end. Default: true */
|
|
21
|
-
anchored?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Check if a route path contains dynamic segments
|
|
25
|
-
*
|
|
26
|
-
* Detects patterns from multiple frameworks:
|
|
27
|
-
* - React Router: :param, :param?, *
|
|
28
|
-
* - TanStack Start: $param, $
|
|
29
|
-
* - Next.js: [param], [[param]], [...param]
|
|
30
|
-
*/
|
|
31
|
-
export declare function isDynamicRoute(routePath: string): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Convert a route path to a regular expression pattern
|
|
34
|
-
*
|
|
35
|
-
* Supports multiple framework syntaxes:
|
|
36
|
-
*
|
|
37
|
-
* **React Router:**
|
|
38
|
-
* - `:slug` → `([^/]+)` - Required dynamic parameter
|
|
39
|
-
* - `:slug?` → `([^/]+)?` - Optional dynamic parameter
|
|
40
|
-
* - `*` → `(.*)` - Wildcard/splat (catches everything)
|
|
41
|
-
*
|
|
42
|
-
* **TanStack Start:**
|
|
43
|
-
* - `$slug` → `([^/]+)` - Required dynamic parameter
|
|
44
|
-
* - `$` (at end) → `(.*)` - Wildcard/splat
|
|
45
|
-
*
|
|
46
|
-
* **Next.js:**
|
|
47
|
-
* - `[slug]` → `([^/]+)` - Required dynamic parameter
|
|
48
|
-
* - `[[slug]]` → `([^/]+)?` - Optional dynamic parameter
|
|
49
|
-
* - `[...slug]` → `(.*)` - Catch-all
|
|
50
|
-
* - `[[...slug]]` → `(.*)?` - Optional catch-all
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* // React Router
|
|
54
|
-
* routeToRegex("/blog/:slug") // "^/blog/([^/]+)/?$"
|
|
55
|
-
* routeToRegex("/files/*") // "^/files(?:/(.*))?$"
|
|
56
|
-
*
|
|
57
|
-
* // TanStack Start
|
|
58
|
-
* routeToRegex("/blog/$slug") // "^/blog/([^/]+)/?$"
|
|
59
|
-
* routeToRegex("/files/$") // "^/files(?:/(.*))?$"
|
|
60
|
-
*
|
|
61
|
-
* // Next.js
|
|
62
|
-
* routeToRegex("/blog/[slug]") // "^/blog/([^/]+)/?$"
|
|
63
|
-
* routeToRegex("/files/[...path]") // "^/files(?:/(.*))?$"
|
|
64
|
-
*/
|
|
65
|
-
export declare function routeToRegex(routePath: string, options?: RouteToRegexOptions): string;
|
|
66
|
-
/**
|
|
67
|
-
* Add regex patterns to routes that contain dynamic segments
|
|
68
|
-
*
|
|
69
|
-
* This function processes an array of RouteInfo and adds the `regex` field
|
|
70
|
-
* to routes that contain dynamic parameters.
|
|
71
|
-
*
|
|
72
|
-
* @param routes - Array of route info objects
|
|
73
|
-
* @param options - Options for regex conversion
|
|
74
|
-
* @returns Routes with regex patterns added where applicable
|
|
75
|
-
*/
|
|
76
|
-
export declare function addRegexToRoutes(routes: RouteInfo[], options?: RouteToRegexOptions): RouteInfo[];
|
|
77
|
-
/**
|
|
78
|
-
* Generic route node structure
|
|
79
|
-
*/
|
|
80
|
-
export interface RouteNode {
|
|
81
|
-
id: string;
|
|
82
|
-
path?: string;
|
|
83
|
-
index?: boolean;
|
|
84
|
-
parentId?: string;
|
|
85
|
-
children?: RouteNode[];
|
|
86
|
-
hasLoader?: boolean;
|
|
87
|
-
hasAction?: boolean;
|
|
88
|
-
hasClientLoader?: boolean;
|
|
89
|
-
hasClientAction?: boolean;
|
|
90
|
-
[key: string]: unknown;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Route parser configuration
|
|
94
|
-
*/
|
|
95
|
-
export interface RouteParserConfig {
|
|
96
|
-
/** Convert file path patterns to route paths (e.g., $id -> :id) */
|
|
97
|
-
paramPattern?: RegExp;
|
|
98
|
-
/** Replacement for param pattern */
|
|
99
|
-
paramReplacement?: string;
|
|
100
|
-
/** Index route file names */
|
|
101
|
-
indexFiles?: string[];
|
|
102
|
-
/** Layout/root route file names to skip */
|
|
103
|
-
layoutFiles?: string[];
|
|
104
|
-
/** File extensions to include */
|
|
105
|
-
extensions?: string[];
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Route tree parser options
|
|
109
|
-
*/
|
|
110
|
-
export interface RouteTreeParserOptions {
|
|
111
|
-
/** Path pattern regex to extract routes */
|
|
112
|
-
pathPattern?: RegExp;
|
|
113
|
-
/** Full path pattern regex */
|
|
114
|
-
fullPathPattern?: RegExp;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Server build route source configuration
|
|
118
|
-
*/
|
|
119
|
-
export interface ServerBuildRouteSource {
|
|
120
|
-
type: "serverBuild";
|
|
121
|
-
/** Server entry path */
|
|
122
|
-
serverEntry: string;
|
|
123
|
-
/** Property path to routes object (e.g., "routes") */
|
|
124
|
-
routesProperty?: string;
|
|
125
|
-
/** Transform function for route nodes */
|
|
126
|
-
transform?: (routes: Record<string, RouteNode>) => RouteInfo[];
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Route tree file source configuration
|
|
130
|
-
*/
|
|
131
|
-
export interface RouteTreeFileSource {
|
|
132
|
-
type: "routeTree";
|
|
133
|
-
/** Candidate paths for route tree file */
|
|
134
|
-
paths: string[];
|
|
135
|
-
/** Parser options */
|
|
136
|
-
parserOptions?: RouteTreeParserOptions;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Directory scan source configuration
|
|
140
|
-
*/
|
|
141
|
-
export interface DirectoryScanSource {
|
|
142
|
-
type: "directory";
|
|
143
|
-
/** Candidate directories to scan */
|
|
144
|
-
paths: string[];
|
|
145
|
-
/** Parser configuration */
|
|
146
|
-
config?: RouteParserConfig;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Route source configuration union type
|
|
150
|
-
*/
|
|
151
|
-
export type RouteSource = ServerBuildRouteSource | RouteTreeFileSource | DirectoryScanSource;
|
|
152
|
-
/**
|
|
153
|
-
* Parse routes from route tree file content
|
|
154
|
-
*/
|
|
155
|
-
export declare function parseRouteTreeContent(content: string, options?: RouteTreeParserOptions): InternalRouteInfo[];
|
|
156
|
-
/**
|
|
157
|
-
* Load and parse route tree from file
|
|
158
|
-
*/
|
|
159
|
-
export declare function parseRouteTreeFile(projectRoot: string, candidatePaths: string[], options?: RouteTreeParserOptions, logger?: Logger): Promise<InternalRouteInfo[]>;
|
|
160
|
-
/**
|
|
161
|
-
* Scan directory for route files
|
|
162
|
-
*/
|
|
163
|
-
export declare function scanRoutesDirectory(dir: string, basePath?: string, config?: RouteParserConfig): Promise<InternalRouteInfo[]>;
|
|
164
|
-
/**
|
|
165
|
-
* Scan multiple candidate directories for routes
|
|
166
|
-
*/
|
|
167
|
-
export declare function scanRoutesFromDirectories(projectRoot: string, candidateDirs: string[], config?: RouteParserConfig, logger?: Logger): Promise<InternalRouteInfo[]>;
|
|
168
|
-
/**
|
|
169
|
-
* Load server build module and extract routes
|
|
170
|
-
*/
|
|
171
|
-
export declare function loadServerBuildRoutes<T = unknown>(serverEntryPath: string, logger?: Logger): Promise<T | null>;
|
|
172
|
-
/**
|
|
173
|
-
* Options for flattenRouteTree function
|
|
174
|
-
*/
|
|
175
|
-
export interface FlattenRouteTreeOptions {
|
|
176
|
-
/** Parent path prefix */
|
|
177
|
-
parentPath?: string;
|
|
178
|
-
/** Whether SSR mode is enabled */
|
|
179
|
-
isSSR?: boolean;
|
|
180
|
-
/** Whether SPA mode is enabled */
|
|
181
|
-
isSpaMode?: boolean;
|
|
182
|
-
/** Root route ID to skip (default: "root") */
|
|
183
|
-
skipRootId?: string;
|
|
184
|
-
/**
|
|
185
|
-
* Custom callback to generate additional routes for each route node.
|
|
186
|
-
* This allows framework-specific route generation (e.g., .data routes for React Router).
|
|
187
|
-
* Return an array of additional RouteInfo to add, or empty array for none.
|
|
188
|
-
*/
|
|
189
|
-
onRouteProcessed?: (route: RouteNode, routePath: string, isStatic: boolean) => RouteInfo[];
|
|
190
|
-
/**
|
|
191
|
-
* Custom callback to determine if a route should be static.
|
|
192
|
-
* If not provided, uses default logic based on isSSR, isSpaMode, and client loaders.
|
|
193
|
-
*/
|
|
194
|
-
isStaticRoute?: (route: RouteNode, isSSR: boolean, isSpaMode: boolean) => boolean;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Flatten nested route tree to flat route list
|
|
198
|
-
*
|
|
199
|
-
* This is a generic utility that works with any route tree structure.
|
|
200
|
-
* Framework-specific behavior (like generating .data routes) should be
|
|
201
|
-
* implemented via the onRouteProcessed callback.
|
|
202
|
-
*/
|
|
203
|
-
export declare function flattenRouteTree(routes: Record<string, RouteNode>, options?: FlattenRouteTreeOptions): RouteInfo[];
|
|
204
|
-
/**
|
|
205
|
-
* Parse routes from multiple sources with fallback
|
|
206
|
-
*/
|
|
207
|
-
export declare function parseRoutesFromSources(projectRoot: string, sources: RouteSource[], options?: {
|
|
208
|
-
isSSR?: boolean;
|
|
209
|
-
logger?: Logger;
|
|
210
|
-
}): Promise<RouteInfo[]>;
|
|
211
|
-
/**
|
|
212
|
-
* Internal route info with additional properties for parsing
|
|
213
|
-
* This extends RouteInfo with optional properties used during route parsing
|
|
214
|
-
*/
|
|
215
|
-
export interface InternalRouteInfo extends RouteInfo {
|
|
216
|
-
/** Route identifier */
|
|
217
|
-
id?: string;
|
|
218
|
-
/** Full path including parent paths */
|
|
219
|
-
fullPath?: string;
|
|
220
|
-
/** Source file path */
|
|
221
|
-
filePath?: string;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Convert internal route info to standard RouteInfo
|
|
225
|
-
* Strips internal-only properties
|
|
226
|
-
*/
|
|
227
|
-
export declare function toRouteInfo(internal: InternalRouteInfo): RouteInfo;
|
|
228
|
-
/**
|
|
229
|
-
* Convert array of internal route info to standard RouteInfo array
|
|
230
|
-
*/
|
|
231
|
-
export declare function toRouteInfoArray(internals: InternalRouteInfo[]): RouteInfo[];
|
|
7
|
+
export * from "./route/index.js";
|
|
232
8
|
//# sourceMappingURL=route-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-parser.d.ts","sourceRoot":"","sources":["../src/route-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"route-parser.d.ts","sourceRoot":"","sources":["../src/route-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,kBAAkB,CAAC"}
|