@chuckcchen/vite-plugin 0.0.3 → 1.0.0
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/bundler.d.ts +27 -27
- package/dist/bundler.js +89 -89
- package/dist/bundler.js.map +1 -1
- package/dist/core.d.ts +14 -14
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +179 -150
- package/dist/core.js.map +1 -1
- package/dist/factory.d.ts +124 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +264 -0
- package/dist/factory.js.map +1 -0
- package/dist/helpers.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +113 -113
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/dist/utils.d.ts +56 -56
- package/dist/utils.js +68 -68
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,265 +1,265 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EdgeOne Vite Plugin Adapter -
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Type Definitions
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This file defines all core types for the adapter plugin system,
|
|
5
|
+
* including route info, meta config, build context, hook functions, etc.
|
|
6
6
|
*/
|
|
7
7
|
import type { Plugin, ResolvedConfig } from "vite";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Route information interface
|
|
10
|
+
* Describes route configuration for deployment
|
|
11
11
|
*/
|
|
12
12
|
export interface RouteInfo {
|
|
13
|
-
/**
|
|
13
|
+
/** Route path pattern, e.g. "/" or "/about" or "/*" */
|
|
14
14
|
path: string;
|
|
15
|
-
/**
|
|
15
|
+
/** Whether this is a static content route (true = static, false = requires SSR) */
|
|
16
16
|
isStatic: boolean;
|
|
17
|
-
/**
|
|
17
|
+
/** Source route pattern for dynamic route mapping */
|
|
18
18
|
srcRoute?: string;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* EdgeOne
|
|
22
|
-
*
|
|
21
|
+
* EdgeOne deployment metadata configuration interface
|
|
22
|
+
* Structure of the generated meta.json file
|
|
23
23
|
*/
|
|
24
24
|
export interface MetaConfig {
|
|
25
|
-
/**
|
|
25
|
+
/** Configuration object */
|
|
26
26
|
conf: {
|
|
27
|
-
/** HTTP
|
|
27
|
+
/** HTTP response header rules list */
|
|
28
28
|
headers: HeaderRule[];
|
|
29
|
-
/**
|
|
29
|
+
/** Redirect rules list */
|
|
30
30
|
redirects: RedirectRule[];
|
|
31
|
-
/** URL
|
|
31
|
+
/** URL rewrite rules list */
|
|
32
32
|
rewrites: RewriteRule[];
|
|
33
|
-
/**
|
|
33
|
+
/** Cache rules list */
|
|
34
34
|
caches: CacheRule[];
|
|
35
|
-
/**
|
|
35
|
+
/** Whether a custom 404 page exists */
|
|
36
36
|
has404: boolean;
|
|
37
|
-
/** 404
|
|
37
|
+
/** Whether 404 page uses SSR rendering */
|
|
38
38
|
ssr404: boolean;
|
|
39
39
|
};
|
|
40
|
-
/**
|
|
40
|
+
/** Whether a custom 404 page exists (top-level field) */
|
|
41
41
|
has404: boolean;
|
|
42
|
-
/**
|
|
42
|
+
/** Framework routes list */
|
|
43
43
|
frameworkRoutes: RouteInfo[];
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* HTTP
|
|
47
|
-
*
|
|
46
|
+
* HTTP response header rule configuration
|
|
47
|
+
* Used to add custom HTTP response headers for specific paths
|
|
48
48
|
*/
|
|
49
49
|
export interface HeaderRule {
|
|
50
|
-
/**
|
|
50
|
+
/** Source path pattern to match */
|
|
51
51
|
source: string;
|
|
52
|
-
/**
|
|
52
|
+
/** Response header key-value pairs to add */
|
|
53
53
|
headers: Record<string, string>;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
56
|
+
* Redirect rule configuration
|
|
57
|
+
* Used to configure URL redirects
|
|
58
58
|
*/
|
|
59
59
|
export interface RedirectRule {
|
|
60
|
-
/**
|
|
60
|
+
/** Source path pattern to match */
|
|
61
61
|
source: string;
|
|
62
|
-
/**
|
|
62
|
+
/** Destination URL for redirect */
|
|
63
63
|
destination: string;
|
|
64
|
-
/**
|
|
64
|
+
/** Whether this is a permanent redirect (301), otherwise temporary (302) */
|
|
65
65
|
permanent?: boolean;
|
|
66
|
-
/**
|
|
66
|
+
/** Custom HTTP status code */
|
|
67
67
|
statusCode?: number;
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
|
-
* URL
|
|
71
|
-
*
|
|
70
|
+
* URL rewrite rule configuration
|
|
71
|
+
* Used to rewrite request paths without changing browser URL
|
|
72
72
|
*/
|
|
73
73
|
export interface RewriteRule {
|
|
74
|
-
/**
|
|
74
|
+
/** Source path pattern to match */
|
|
75
75
|
source: string;
|
|
76
|
-
/**
|
|
76
|
+
/** Destination path to rewrite to */
|
|
77
77
|
destination: string;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
80
|
+
* Cache rule configuration
|
|
81
|
+
* Used to configure caching strategy for specific paths
|
|
82
82
|
*/
|
|
83
83
|
export interface CacheRule {
|
|
84
|
-
/**
|
|
84
|
+
/** Source path pattern to match */
|
|
85
85
|
source: string;
|
|
86
|
-
/**
|
|
86
|
+
/** Maximum cache time in seconds */
|
|
87
87
|
maxAge?: number;
|
|
88
|
-
/**
|
|
88
|
+
/** Grace period for revalidation after expiry in seconds */
|
|
89
89
|
staleWhileRevalidate?: number;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* Build context interface
|
|
93
|
+
* Context information passed to hook functions
|
|
94
94
|
*/
|
|
95
95
|
export interface BuildContext {
|
|
96
|
-
/**
|
|
96
|
+
/** Absolute path to project root directory */
|
|
97
97
|
projectRoot: string;
|
|
98
|
-
/**
|
|
98
|
+
/** Output directory name (default: .edgeone) */
|
|
99
99
|
outputDir: string;
|
|
100
|
-
/**
|
|
100
|
+
/** Whether SSR mode is enabled */
|
|
101
101
|
isSSR: boolean;
|
|
102
|
-
/** Vite
|
|
102
|
+
/** Vite resolved configuration object */
|
|
103
103
|
viteConfig: ResolvedConfig;
|
|
104
|
-
/**
|
|
104
|
+
/** Logger utility instance */
|
|
105
105
|
logger: Logger;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
108
|
+
* Logger interface
|
|
109
|
+
* Provides unified logging methods
|
|
110
110
|
*/
|
|
111
111
|
export interface Logger {
|
|
112
|
-
/**
|
|
112
|
+
/** Normal log output */
|
|
113
113
|
log: (message: string, ...args: unknown[]) => void;
|
|
114
|
-
/**
|
|
114
|
+
/** Verbose log output (only shown in verbose mode) */
|
|
115
115
|
verbose: (message: string, ...args: unknown[]) => void;
|
|
116
|
-
/**
|
|
116
|
+
/** Warning log output */
|
|
117
117
|
warn: (message: string, ...args: unknown[]) => void;
|
|
118
|
-
/**
|
|
118
|
+
/** Error log output */
|
|
119
119
|
error: (message: string, ...args: unknown[]) => void;
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
122
|
+
* Build artifacts information interface
|
|
123
|
+
* Describes paths of generated files after build
|
|
124
124
|
*/
|
|
125
125
|
export interface BuildArtifacts {
|
|
126
|
-
/**
|
|
126
|
+
/** Client build directory path (e.g. dist/client) */
|
|
127
127
|
clientDir: string | null;
|
|
128
|
-
/**
|
|
128
|
+
/** Server build directory path (e.g. dist/server) */
|
|
129
129
|
serverDir: string | null;
|
|
130
|
-
/**
|
|
130
|
+
/** Server entry file path (e.g. dist/server/index.js) */
|
|
131
131
|
serverEntry: string | null;
|
|
132
|
-
/**
|
|
132
|
+
/** Static assets directory path */
|
|
133
133
|
assetsDir: string | null;
|
|
134
134
|
}
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
136
|
+
* Server wrapper configuration interface
|
|
137
|
+
* Used for generating server code wrapper
|
|
138
138
|
*/
|
|
139
139
|
export interface ServerWrapperConfig {
|
|
140
|
-
/**
|
|
140
|
+
/** Path to server build entry file */
|
|
141
141
|
serverEntryPath: string;
|
|
142
|
-
/**
|
|
142
|
+
/** Custom wrapper code template (optional) */
|
|
143
143
|
wrapperTemplate?: string;
|
|
144
|
-
/**
|
|
144
|
+
/** List of variables to export from server build */
|
|
145
145
|
exports?: string[];
|
|
146
|
-
/**
|
|
146
|
+
/** Extra code to add at the beginning of wrapper */
|
|
147
147
|
banner?: string;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
* esbuild
|
|
151
|
-
*
|
|
150
|
+
* esbuild bundle configuration interface
|
|
151
|
+
* Used to configure server code bundling options
|
|
152
152
|
*/
|
|
153
153
|
export interface ServerBundleConfig {
|
|
154
|
-
/**
|
|
154
|
+
/** Bundle entry point file list */
|
|
155
155
|
entryPoints: string[];
|
|
156
|
-
/**
|
|
156
|
+
/** Output file path */
|
|
157
157
|
outfile: string;
|
|
158
|
-
/**
|
|
158
|
+
/** External modules list (not bundled) */
|
|
159
159
|
external?: string[];
|
|
160
|
-
/**
|
|
160
|
+
/** Additional esbuild configuration options */
|
|
161
161
|
esbuildOptions?: Record<string, unknown>;
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
164
|
+
* Hook function type definitions
|
|
165
|
+
* These types define function signatures for lifecycle hooks
|
|
166
166
|
*/
|
|
167
|
-
/**
|
|
167
|
+
/** Hook called before build starts */
|
|
168
168
|
export type BeforeBuildHook = (context: BuildContext) => Promise<void> | void;
|
|
169
|
-
/**
|
|
169
|
+
/** Hook called after build artifacts are detected */
|
|
170
170
|
export type AfterBuildHook = (context: BuildContext, artifacts: BuildArtifacts) => Promise<void> | void;
|
|
171
|
-
/**
|
|
171
|
+
/** Hook called before server code bundling, can modify bundle config */
|
|
172
172
|
export type BeforeBundleHook = (context: BuildContext, config: ServerBundleConfig) => Promise<ServerBundleConfig> | ServerBundleConfig;
|
|
173
|
-
/**
|
|
173
|
+
/** Hook called after server code bundling */
|
|
174
174
|
export type AfterBundleHook = (context: BuildContext, outputPath: string) => Promise<void> | void;
|
|
175
|
-
/**
|
|
175
|
+
/** Hook for generating route information */
|
|
176
176
|
export type GenerateRoutesHook = (context: BuildContext) => Promise<RouteInfo[]> | RouteInfo[];
|
|
177
|
-
/**
|
|
177
|
+
/** Hook for generating metadata configuration */
|
|
178
178
|
export type GenerateMetaHook = (context: BuildContext, routes: RouteInfo[]) => Promise<MetaConfig> | MetaConfig;
|
|
179
|
-
/**
|
|
179
|
+
/** Hook for generating server wrapper code */
|
|
180
180
|
export type GenerateServerWrapperHook = (context: BuildContext, config: ServerWrapperConfig) => Promise<string> | string;
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
182
|
+
* Adapter hooks configuration interface
|
|
183
|
+
* Defines all hook functions available to adapters
|
|
184
184
|
*/
|
|
185
185
|
export interface AdapterHooks {
|
|
186
|
-
/**
|
|
186
|
+
/** Called before build processing starts */
|
|
187
187
|
beforeBuild?: BeforeBuildHook;
|
|
188
|
-
/**
|
|
188
|
+
/** Called after build artifacts detection completes */
|
|
189
189
|
afterBuild?: AfterBuildHook;
|
|
190
|
-
/**
|
|
190
|
+
/** Called before server code bundling, can modify bundle config */
|
|
191
191
|
beforeBundle?: BeforeBundleHook;
|
|
192
|
-
/**
|
|
192
|
+
/** Called after server code bundling completes */
|
|
193
193
|
afterBundle?: AfterBundleHook;
|
|
194
|
-
/**
|
|
194
|
+
/** Called when generating route information */
|
|
195
195
|
generateRoutes?: GenerateRoutesHook;
|
|
196
|
-
/**
|
|
196
|
+
/** Called when generating meta.json configuration */
|
|
197
197
|
generateMeta?: GenerateMetaHook;
|
|
198
|
-
/**
|
|
198
|
+
/** Called when generating server wrapper code */
|
|
199
199
|
generateServerWrapper?: GenerateServerWrapperHook;
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
202
|
+
* Framework adapter interface
|
|
203
|
+
* Framework-specific adapters (e.g. React Router, TanStack Start) must implement this interface
|
|
204
204
|
*/
|
|
205
205
|
export interface FrameworkAdapter {
|
|
206
|
-
/**
|
|
206
|
+
/** Adapter name for logging and debugging */
|
|
207
207
|
name: string;
|
|
208
|
-
/**
|
|
208
|
+
/** Detect whether current project should use this adapter */
|
|
209
209
|
detect: (context: BuildContext) => Promise<boolean> | boolean;
|
|
210
|
-
/**
|
|
210
|
+
/** Get build artifacts path information */
|
|
211
211
|
getBuildArtifacts: (context: BuildContext) => Promise<BuildArtifacts> | BuildArtifacts;
|
|
212
|
-
/**
|
|
212
|
+
/** Adapter-specific hook functions */
|
|
213
213
|
hooks?: AdapterHooks;
|
|
214
214
|
}
|
|
215
215
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
216
|
+
* Core adapter plugin options interface
|
|
217
|
+
* Base configuration options for all adapters
|
|
218
218
|
*/
|
|
219
219
|
export interface CoreAdapterOptions {
|
|
220
|
-
/**
|
|
220
|
+
/** Enable verbose logging output (default: false) */
|
|
221
221
|
verbose?: boolean;
|
|
222
|
-
/**
|
|
222
|
+
/** Output directory name (default: .edgeone) */
|
|
223
223
|
outputDir?: string;
|
|
224
|
-
/**
|
|
224
|
+
/** Clean output directory before build (default: true) */
|
|
225
225
|
cleanOutput?: boolean;
|
|
226
|
-
/**
|
|
226
|
+
/** Framework adapter instance to use */
|
|
227
227
|
adapter?: FrameworkAdapter;
|
|
228
|
-
/**
|
|
228
|
+
/** Custom hook functions */
|
|
229
229
|
hooks?: AdapterHooks;
|
|
230
|
-
/**
|
|
230
|
+
/** Enable SSR (auto-detected if not specified) */
|
|
231
231
|
ssr?: boolean;
|
|
232
232
|
}
|
|
233
233
|
/**
|
|
234
|
-
* Vite
|
|
235
|
-
*
|
|
234
|
+
* Vite adapter plugin options interface
|
|
235
|
+
* For generic Vite projects (SPA and custom SSR)
|
|
236
236
|
*/
|
|
237
237
|
export interface ViteAdapterOptions extends CoreAdapterOptions {
|
|
238
|
-
/**
|
|
238
|
+
/** Client build directory (default: dist) */
|
|
239
239
|
clientBuildDir?: string;
|
|
240
|
-
/**
|
|
240
|
+
/** Server build directory (default: dist/server) */
|
|
241
241
|
serverBuildDir?: string;
|
|
242
|
-
/**
|
|
242
|
+
/** Server entry file path (default: server/index.js) */
|
|
243
243
|
serverEntry?: string;
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
246
|
-
* React Router
|
|
247
|
-
*
|
|
246
|
+
* React Router adapter options interface
|
|
247
|
+
* For React Router v7 framework projects
|
|
248
248
|
*
|
|
249
|
-
*
|
|
249
|
+
* Note: SSR and prerender config follows framework's react-router.config.ts
|
|
250
250
|
*/
|
|
251
251
|
export interface ReactRouterAdapterOptions extends CoreAdapterOptions {
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
|
-
* TanStack Start
|
|
255
|
-
*
|
|
254
|
+
* TanStack Start adapter options interface
|
|
255
|
+
* For TanStack Start framework projects
|
|
256
256
|
*/
|
|
257
257
|
export interface TanStackStartAdapterOptions extends CoreAdapterOptions {
|
|
258
|
-
/**
|
|
258
|
+
/** Server preset (default: node-server) */
|
|
259
259
|
preset?: string;
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
262
|
-
*
|
|
262
|
+
* Factory function type for creating adapter plugins
|
|
263
263
|
*/
|
|
264
264
|
export type CreateAdapterPlugin = (options?: CoreAdapterOptions) => Plugin;
|
|
265
265
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEnD;;;GAG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BAAkB;IACjC,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,4BAA4B;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,kDAAkD;IAClD,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;CAAG;AAExE;;;GAGG;AACH,MAAM,WAAW,2BAA4B,SAAQ,kBAAkB;IACrE,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,MAAM,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EdgeOne Vite Plugin Adapter -
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Type Definitions
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This file defines all core types for the adapter plugin system,
|
|
5
|
+
* including route info, meta config, build context, hook functions, etc.
|
|
6
6
|
*/
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=types.js.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EdgeOne Vite Plugin Adapter -
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Utility Functions Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides a set of general utility functions, including:
|
|
5
|
+
* - Logging
|
|
6
|
+
* - File system operations (read, write, copy, delete, etc.)
|
|
7
|
+
* - Path detection
|
|
8
|
+
* - File size formatting
|
|
9
|
+
* - Conditional waiting, etc.
|
|
10
10
|
*/
|
|
11
11
|
import type { Logger } from "./types.js";
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Create logger instance
|
|
14
14
|
*
|
|
15
|
-
* @param verbose -
|
|
16
|
-
* @returns
|
|
15
|
+
* @param verbose - Enable verbose logging mode, default is false
|
|
16
|
+
* @returns Logger object with log, verbose, warn, error methods
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* const logger = createLogger(true);
|
|
20
|
-
* logger.verbose("
|
|
21
|
-
* logger.warn("
|
|
20
|
+
* logger.verbose("This message only shows in verbose mode");
|
|
21
|
+
* logger.warn("This is a warning message");
|
|
22
22
|
*/
|
|
23
23
|
export declare function createLogger(verbose?: boolean): Logger;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Check if specified path exists
|
|
26
26
|
*
|
|
27
|
-
* @param filePath -
|
|
28
|
-
* @returns
|
|
27
|
+
* @param filePath - File or directory path to check
|
|
28
|
+
* @returns True if path exists, false otherwise
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
31
|
* if (await pathExists('/path/to/file')) {
|
|
32
|
-
* console.log('
|
|
32
|
+
* console.log('File exists');
|
|
33
33
|
* }
|
|
34
34
|
*/
|
|
35
35
|
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Find first existing path from candidate list
|
|
38
38
|
*
|
|
39
|
-
* @param candidates -
|
|
40
|
-
* @returns
|
|
39
|
+
* @param candidates - Candidate paths array, sorted by priority
|
|
40
|
+
* @returns First existing path, or null if none exist
|
|
41
41
|
*
|
|
42
42
|
* @example
|
|
43
43
|
* const buildDir = await findExistingPath([
|
|
@@ -48,71 +48,71 @@ export declare function pathExists(filePath: string): Promise<boolean>;
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function findExistingPath(candidates: string[]): Promise<string | null>;
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* Recursively copy directory
|
|
52
|
+
* Copy all contents from source directory to destination directory
|
|
53
53
|
*
|
|
54
|
-
* @param src -
|
|
55
|
-
* @param dest -
|
|
54
|
+
* @param src - Source directory path
|
|
55
|
+
* @param dest - Destination directory path
|
|
56
56
|
*
|
|
57
57
|
* @example
|
|
58
58
|
* await copyDirectory('dist/client', '.edgeone/assets');
|
|
59
59
|
*/
|
|
60
60
|
export declare function copyDirectory(src: string, dest: string): Promise<void>;
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
62
|
+
* Clean directory (delete and recreate)
|
|
63
|
+
* Used to ensure directory is in a clean empty state
|
|
64
64
|
*
|
|
65
|
-
* @param dir -
|
|
65
|
+
* @param dir - Directory path to clean
|
|
66
66
|
*
|
|
67
67
|
* @example
|
|
68
68
|
* await cleanDirectory('.edgeone');
|
|
69
69
|
*/
|
|
70
70
|
export declare function cleanDirectory(dir: string): Promise<void>;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
73
|
-
*
|
|
72
|
+
* Ensure directory exists
|
|
73
|
+
* Recursively create if directory doesn't exist
|
|
74
74
|
*
|
|
75
|
-
* @param dir -
|
|
75
|
+
* @param dir - Directory path
|
|
76
76
|
*
|
|
77
77
|
* @example
|
|
78
78
|
* await ensureDirectory('.edgeone/server-handler');
|
|
79
79
|
*/
|
|
80
80
|
export declare function ensureDirectory(dir: string): Promise<void>;
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
82
|
+
* Read file content as string
|
|
83
83
|
*
|
|
84
|
-
* @param filePath -
|
|
85
|
-
* @returns
|
|
84
|
+
* @param filePath - File path
|
|
85
|
+
* @returns File content string (UTF-8 encoded)
|
|
86
86
|
*
|
|
87
87
|
* @example
|
|
88
88
|
* const content = await readFile('dist/server/index.js');
|
|
89
89
|
*/
|
|
90
90
|
export declare function readFile(filePath: string): Promise<string>;
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* Write content to file
|
|
93
|
+
* Automatically creates parent directory if it doesn't exist
|
|
94
94
|
*
|
|
95
|
-
* @param filePath -
|
|
96
|
-
* @param content -
|
|
95
|
+
* @param filePath - File path
|
|
96
|
+
* @param content - Content to write
|
|
97
97
|
*
|
|
98
98
|
* @example
|
|
99
99
|
* await writeFile('.edgeone/meta.json', JSON.stringify(config));
|
|
100
100
|
*/
|
|
101
101
|
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
103
|
+
* Delete file
|
|
104
104
|
*
|
|
105
|
-
* @param filePath -
|
|
105
|
+
* @param filePath - File path to delete
|
|
106
106
|
*
|
|
107
107
|
* @example
|
|
108
108
|
* await deleteFile('server-wrapper.temp.js');
|
|
109
109
|
*/
|
|
110
110
|
export declare function deleteFile(filePath: string): Promise<void>;
|
|
111
111
|
/**
|
|
112
|
-
*
|
|
112
|
+
* Format file size to human-readable string
|
|
113
113
|
*
|
|
114
|
-
* @param bytes -
|
|
115
|
-
* @returns
|
|
114
|
+
* @param bytes - Number of bytes
|
|
115
|
+
* @returns Formatted string, e.g. "1.5 KB", "2.3 MB"
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
118
|
* formatSize(1536); // "1.5 KB"
|
|
@@ -120,14 +120,14 @@ export declare function deleteFile(filePath: string): Promise<void>;
|
|
|
120
120
|
*/
|
|
121
121
|
export declare function formatSize(bytes: number): string;
|
|
122
122
|
/**
|
|
123
|
-
*
|
|
124
|
-
*
|
|
123
|
+
* Wait for condition to be met (with retry mechanism)
|
|
124
|
+
* Used to wait for async operations to complete, like file writes
|
|
125
125
|
*
|
|
126
|
-
* @param condition -
|
|
127
|
-
* @param options -
|
|
128
|
-
* @param options.maxRetries -
|
|
129
|
-
* @param options.delay -
|
|
130
|
-
* @returns
|
|
126
|
+
* @param condition - Async condition function returning boolean
|
|
127
|
+
* @param options - Configuration options
|
|
128
|
+
* @param options.maxRetries - Maximum retry count, default 15
|
|
129
|
+
* @param options.delay - Delay between retries in milliseconds, default 300ms
|
|
130
|
+
* @returns True if condition met, false if timeout
|
|
131
131
|
*
|
|
132
132
|
* @example
|
|
133
133
|
* const ready = await waitFor(
|
|
@@ -140,10 +140,10 @@ export declare function waitFor(condition: () => Promise<boolean>, options?: {
|
|
|
140
140
|
delay?: number;
|
|
141
141
|
}): Promise<boolean>;
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* List files and subdirectory names in directory
|
|
144
144
|
*
|
|
145
|
-
* @param dir -
|
|
146
|
-
* @returns
|
|
145
|
+
* @param dir - Directory path
|
|
146
|
+
* @returns Array of file and directory names, empty array if directory doesn't exist
|
|
147
147
|
*
|
|
148
148
|
* @example
|
|
149
149
|
* const files = await listFiles('dist/client');
|
|
@@ -151,14 +151,14 @@ export declare function waitFor(condition: () => Promise<boolean>, options?: {
|
|
|
151
151
|
*/
|
|
152
152
|
export declare function listFiles(dir: string): Promise<string[]>;
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
154
|
+
* Recursively count files in directory
|
|
155
155
|
*
|
|
156
|
-
* @param dir -
|
|
157
|
-
* @returns
|
|
156
|
+
* @param dir - Directory path
|
|
157
|
+
* @returns Total file count (excluding directories)
|
|
158
158
|
*
|
|
159
159
|
* @example
|
|
160
160
|
* const count = await countFiles('dist');
|
|
161
|
-
* console.log(
|
|
161
|
+
* console.log(`Build artifacts contain ${count} files`);
|
|
162
162
|
*/
|
|
163
163
|
export declare function countFiles(dir: string): Promise<number>;
|
|
164
164
|
//# sourceMappingURL=utils.d.ts.map
|