@chuckcchen/vite-plugin 1.0.3 → 1.0.5
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 +5 -45
- package/dist/bundler.d.ts.map +1 -1
- package/dist/bundler.js +30 -172
- package/dist/bundler.js.map +1 -1
- package/dist/core.d.ts +0 -8
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +15 -56
- package/dist/core.js.map +1 -1
- package/dist/factory.d.ts +51 -45
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +215 -184
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/dist/route-parser.d.ts +141 -0
- package/dist/route-parser.d.ts.map +1 -0
- package/dist/route-parser.js +293 -0
- package/dist/route-parser.js.map +1 -0
- package/dist/types.d.ts +0 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +64 -125
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +230 -168
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/utils.d.ts
CHANGED
|
@@ -1,164 +1,103 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EdgeOne Vite Plugin Adapter - Utility Functions Module
|
|
3
3
|
*
|
|
4
|
-
* This module provides
|
|
4
|
+
* This module provides utility functions for:
|
|
5
5
|
* - Logging
|
|
6
|
-
* - File system operations
|
|
6
|
+
* - File system operations
|
|
7
7
|
* - Path detection
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
8
|
+
* - Config file loading
|
|
9
|
+
* - Server wrapper generation
|
|
10
|
+
* - Meta configuration
|
|
10
11
|
*/
|
|
11
|
-
import type { Logger } from "./types.js";
|
|
12
|
+
import type { Logger, RouteInfo, MetaConfig } from "./types.js";
|
|
12
13
|
/**
|
|
13
14
|
* Create logger instance
|
|
14
|
-
*
|
|
15
|
-
* @param verbose - Enable verbose logging mode, default is false
|
|
16
|
-
* @returns Logger object with log, verbose, warn, error methods
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const logger = createLogger(true);
|
|
20
|
-
* logger.verbose("This message only shows in verbose mode");
|
|
21
|
-
* logger.warn("This is a warning message");
|
|
22
15
|
*/
|
|
23
16
|
export declare function createLogger(verbose?: boolean): Logger;
|
|
24
17
|
/**
|
|
25
18
|
* Check if specified path exists
|
|
26
|
-
*
|
|
27
|
-
* @param filePath - File or directory path to check
|
|
28
|
-
* @returns True if path exists, false otherwise
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* if (await pathExists('/path/to/file')) {
|
|
32
|
-
* console.log('File exists');
|
|
33
|
-
* }
|
|
34
19
|
*/
|
|
35
20
|
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
36
|
-
/**
|
|
37
|
-
* Find first existing path from candidate list
|
|
38
|
-
*
|
|
39
|
-
* @param candidates - Candidate paths array, sorted by priority
|
|
40
|
-
* @returns First existing path, or null if none exist
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* const buildDir = await findExistingPath([
|
|
44
|
-
* '/project/dist',
|
|
45
|
-
* '/project/build',
|
|
46
|
-
* '/project/output'
|
|
47
|
-
* ]);
|
|
48
|
-
*/
|
|
49
|
-
export declare function findExistingPath(candidates: string[]): Promise<string | null>;
|
|
50
21
|
/**
|
|
51
22
|
* Recursively copy directory
|
|
52
|
-
* Copy all contents from source directory to destination directory
|
|
53
|
-
*
|
|
54
|
-
* @param src - Source directory path
|
|
55
|
-
* @param dest - Destination directory path
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* await copyDirectory('dist/client', '.edgeone/assets');
|
|
59
23
|
*/
|
|
60
24
|
export declare function copyDirectory(src: string, dest: string): Promise<void>;
|
|
61
25
|
/**
|
|
62
|
-
*
|
|
63
|
-
* Used to ensure directory is in a clean empty state
|
|
64
|
-
*
|
|
65
|
-
* @param dir - Directory path to clean
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* await cleanDirectory('.edgeone');
|
|
69
|
-
*/
|
|
70
|
-
export declare function cleanDirectory(dir: string): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Ensure directory exists
|
|
73
|
-
* Recursively create if directory doesn't exist
|
|
74
|
-
*
|
|
75
|
-
* @param dir - Directory path
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* await ensureDirectory('.edgeone/server-handler');
|
|
26
|
+
* Ensure directory exists (creates recursively if needed)
|
|
79
27
|
*/
|
|
80
28
|
export declare function ensureDirectory(dir: string): Promise<void>;
|
|
81
29
|
/**
|
|
82
30
|
* Read file content as string
|
|
83
|
-
*
|
|
84
|
-
* @param filePath - File path
|
|
85
|
-
* @returns File content string (UTF-8 encoded)
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* const content = await readFile('dist/server/index.js');
|
|
89
31
|
*/
|
|
90
32
|
export declare function readFile(filePath: string): Promise<string>;
|
|
91
33
|
/**
|
|
92
|
-
* Write content to file
|
|
93
|
-
* Automatically creates parent directory if it doesn't exist
|
|
94
|
-
*
|
|
95
|
-
* @param filePath - File path
|
|
96
|
-
* @param content - Content to write
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* await writeFile('.edgeone/meta.json', JSON.stringify(config));
|
|
34
|
+
* Write content to file (auto-creates parent directory)
|
|
100
35
|
*/
|
|
101
36
|
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
102
37
|
/**
|
|
103
38
|
* Delete file
|
|
104
|
-
*
|
|
105
|
-
* @param filePath - File path to delete
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* await deleteFile('server-wrapper.temp.js');
|
|
109
39
|
*/
|
|
110
40
|
export declare function deleteFile(filePath: string): Promise<void>;
|
|
111
41
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
* @param
|
|
115
|
-
* @returns Formatted string, e.g. "1.5 KB", "2.3 MB"
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* formatSize(1536); // "1.5 KB"
|
|
119
|
-
* formatSize(2457600); // "2.34 MB"
|
|
42
|
+
* List files in directory
|
|
43
|
+
* @param dir - Directory path
|
|
44
|
+
* @param logger - Optional logger for verbose error reporting
|
|
120
45
|
*/
|
|
121
|
-
export declare function
|
|
46
|
+
export declare function listFiles(dir: string, logger?: Logger): Promise<string[]>;
|
|
122
47
|
/**
|
|
123
|
-
*
|
|
124
|
-
* Used to wait for async operations to complete, like file writes
|
|
125
|
-
*
|
|
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
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* const ready = await waitFor(
|
|
134
|
-
* async () => await pathExists('dist/index.html'),
|
|
135
|
-
* { maxRetries: 10, delay: 500 }
|
|
136
|
-
* );
|
|
137
|
-
*/
|
|
138
|
-
export declare function waitFor(condition: () => Promise<boolean>, options?: {
|
|
139
|
-
maxRetries?: number;
|
|
140
|
-
delay?: number;
|
|
141
|
-
}): Promise<boolean>;
|
|
142
|
-
/**
|
|
143
|
-
* List files and subdirectory names in directory
|
|
144
|
-
*
|
|
145
|
-
* @param dir - Directory path
|
|
146
|
-
* @returns Array of file and directory names, empty array if directory doesn't exist
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* const files = await listFiles('dist/client');
|
|
150
|
-
* // ['index.html', 'assets', 'favicon.ico']
|
|
48
|
+
* Detect config file from candidate list
|
|
151
49
|
*/
|
|
152
|
-
export declare function
|
|
50
|
+
export declare function detectConfigFile(projectRoot: string, patterns: string[]): Promise<string | null>;
|
|
153
51
|
/**
|
|
154
|
-
*
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
*
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
52
|
+
* Detect build directory from candidate list
|
|
53
|
+
*/
|
|
54
|
+
export declare function detectBuildDir(projectRoot: string, candidates: string[]): Promise<string | null>;
|
|
55
|
+
/**
|
|
56
|
+
* Detect server entry file from candidate list
|
|
57
|
+
*/
|
|
58
|
+
export declare function detectServerEntry(serverDir: string, candidates?: string[]): Promise<string | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Dynamically import config file
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* Dynamically import config file
|
|
64
|
+
* @param configPath - Path to config file
|
|
65
|
+
* @param logger - Optional logger for verbose error reporting
|
|
66
|
+
*/
|
|
67
|
+
export declare function loadConfigFile<T = unknown>(configPath: string, logger?: Logger): Promise<T | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Normalize route path
|
|
70
|
+
*/
|
|
71
|
+
export declare function normalizeRoutePath(routePath: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Create default meta configuration
|
|
74
|
+
*/
|
|
75
|
+
export declare function createDefaultMeta(routes: RouteInfo[], options?: {
|
|
76
|
+
isSSR?: boolean;
|
|
77
|
+
has404?: boolean;
|
|
78
|
+
}): MetaConfig;
|
|
79
|
+
/** Node.js IncomingMessage to Web Request converter code */
|
|
80
|
+
export declare const NODE_REQUEST_CONVERTER_CODE: string;
|
|
81
|
+
/** Server wrapper generator options */
|
|
82
|
+
export interface ServerWrapperGeneratorOptions {
|
|
83
|
+
serverEntryPath: string;
|
|
84
|
+
handlerSetup?: string;
|
|
85
|
+
handlerCall: string;
|
|
86
|
+
imports?: string;
|
|
87
|
+
needsNodeRequestConversion?: boolean;
|
|
88
|
+
mode?: "inline" | "import";
|
|
89
|
+
additionalExports?: string[];
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Generate server wrapper code
|
|
93
|
+
*/
|
|
94
|
+
export declare function generateServerWrapperCode(options: ServerWrapperGeneratorOptions): Promise<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Log build artifacts info
|
|
162
97
|
*/
|
|
163
|
-
export declare function
|
|
98
|
+
export declare function logBuildArtifacts(logger: Logger, adapterName: string, artifacts: {
|
|
99
|
+
clientDir?: string | null;
|
|
100
|
+
serverDir?: string | null;
|
|
101
|
+
serverEntry?: string | null;
|
|
102
|
+
}): void;
|
|
164
103
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAMhE;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,OAAe,GAAG,MAAM,CAiB7D;AAMD;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5E;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhF;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAA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