@chuckcchen/vite-plugin 0.0.2 → 0.0.4

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.
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Adapter Factory - Simplifies the creation of framework adapters
3
+ *
4
+ * Provides factory functions and preset configurations to reduce boilerplate code in adapter development
5
+ */
6
+ import type { BuildContext, FrameworkAdapter, AdapterHooks } from "./types.js";
7
+ /**
8
+ * Server wrapper preset configuration
9
+ */
10
+ export interface ServerWrapperPreset {
11
+ /** Additional import statements */
12
+ imports?: string;
13
+ /** Handler initialization code */
14
+ handlerSetup: string;
15
+ /** Handler call expression */
16
+ handlerCall: string;
17
+ }
18
+ /**
19
+ * Built-in server wrapper presets
20
+ */
21
+ export declare const SERVER_WRAPPER_PRESETS: {
22
+ /** Generic handler - detects default or handler export */
23
+ readonly generic: {
24
+ readonly handlerSetup: string;
25
+ readonly handlerCall: "handler(webRequest, ...args)";
26
+ };
27
+ /** Hono style - supports app.fetch */
28
+ readonly hono: {
29
+ readonly handlerSetup: string;
30
+ readonly handlerCall: "serverHandler(webRequest, ...args)";
31
+ };
32
+ /** React Router - uses createRequestHandler */
33
+ readonly reactRouter: {
34
+ readonly imports: "import { createRequestHandler } from \"react-router\";";
35
+ readonly handlerSetup: string;
36
+ readonly handlerCall: "requestHandler(webRequest, ...args)";
37
+ };
38
+ };
39
+ /**
40
+ * Build directory configuration
41
+ */
42
+ export interface BuildDirConfig {
43
+ /** Client directory candidates */
44
+ client: string[];
45
+ /** Server directory candidates (SSR mode) */
46
+ server?: string[];
47
+ }
48
+ /**
49
+ * Adapter factory configuration
50
+ */
51
+ export interface AdapterFactoryConfig {
52
+ /** Adapter name */
53
+ name: string;
54
+ /** Config file detection list */
55
+ configFiles: string[];
56
+ /** Build directory candidates configuration */
57
+ buildDirs: BuildDirConfig;
58
+ /** Server entry file candidates */
59
+ serverEntryFiles?: string[];
60
+ /** Server wrapper configuration (use preset name or custom config) */
61
+ serverWrapper?: keyof typeof SERVER_WRAPPER_PRESETS | ServerWrapperPreset;
62
+ /** Default routes list */
63
+ defaultRoutes?: string[];
64
+ /** Extra routes for SSR mode */
65
+ ssrExtraRoutes?: string[];
66
+ /** Custom ssr404 handling */
67
+ ssr404?: boolean | ((isSSR: boolean) => boolean);
68
+ }
69
+ /**
70
+ * Adapter factory runtime options
71
+ */
72
+ export interface AdapterFactoryOptions {
73
+ /** User-specified client directory */
74
+ clientBuildDir?: string;
75
+ /** User-specified server directory */
76
+ serverBuildDir?: string;
77
+ /** User-specified server entry */
78
+ serverEntry?: string;
79
+ /** User-specified routes */
80
+ routes?: string[];
81
+ }
82
+ /**
83
+ * Create a framework adapter
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const adapter = createFrameworkAdapter({
88
+ * name: "my-framework",
89
+ * configFiles: ["my-framework.config.ts", "my-framework.config.js"],
90
+ * buildDirs: {
91
+ * client: ["dist/client", "dist"],
92
+ * server: ["dist/server"],
93
+ * },
94
+ * serverWrapper: "generic",
95
+ * });
96
+ * ```
97
+ */
98
+ export declare function createFrameworkAdapter(config: AdapterFactoryConfig, options?: AdapterFactoryOptions, overrides?: Partial<FrameworkAdapter>): FrameworkAdapter;
99
+ /**
100
+ * Create a stateful adapter
101
+ * Used for complex adapters that need to share state between different hooks
102
+ */
103
+ export declare function createStatefulAdapter<TState extends object>(initialState: TState, factory: (state: TState) => FrameworkAdapter): FrameworkAdapter;
104
+ /**
105
+ * Compose multiple hooks
106
+ */
107
+ export declare function composeHooks(...hooksList: (AdapterHooks | undefined)[]): AdapterHooks;
108
+ /**
109
+ * Create a detector function - based on config files
110
+ */
111
+ export declare function createConfigDetector(configFiles: string[]): (context: BuildContext) => Promise<boolean>;
112
+ /**
113
+ * Create a detector function - based on build directories
114
+ */
115
+ export declare function createBuildDirDetector(buildDirs: string[]): (context: BuildContext) => Promise<boolean>;
116
+ /**
117
+ * Create a detector function - based on package.json dependencies
118
+ */
119
+ export declare function createDependencyDetector(dependencies: string[]): (context: BuildContext) => Promise<boolean>;
120
+ /**
121
+ * Combine multiple detector functions (returns true if any matches)
122
+ */
123
+ export declare function combineDetectors(...detectors: ((context: BuildContext) => Promise<boolean> | boolean)[]): (context: BuildContext) => Promise<boolean>;
124
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,YAAY,EAIZ,gBAAgB,EAChB,YAAY,EAEb,MAAM,YAAY,CAAC;AAWpB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB;IACjC,0DAA0D;;;;;IAa1D,sCAAsC;;;;;IAatC,+CAA+C;;;;;;CAoBvC,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,kCAAkC;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,+CAA+C;IAC/C,SAAS,EAAE,cAAc,CAAC;IAC1B,mCAAmC;IACnC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,OAAO,sBAAsB,GAAG,mBAAmB,CAAC;IAC1E,0BAA0B;IAC1B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,gCAAgC;IAChC,cAAc,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B,gBAAgB,CAC9B,GAAG,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,EAAE,IAEzD,SAAS,YAAY,KAAG,OAAO,CAAC,OAAO,CAAC,CAQvD"}
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Adapter Factory - Simplifies the creation of framework adapters
3
+ *
4
+ * Provides factory functions and preset configurations to reduce boilerplate code in adapter development
5
+ */
6
+ import path from "path";
7
+ import { detectConfigFile, detectBuildDir, detectServerEntry, generateServerWrapperCode, createDefaultMeta, logBuildArtifacts, } from "./helpers.js";
8
+ import { pathExists } from "./utils.js";
9
+ /**
10
+ * Built-in server wrapper presets
11
+ */
12
+ export const SERVER_WRAPPER_PRESETS = {
13
+ /** Generic handler - detects default or handler export */
14
+ generic: {
15
+ handlerSetup: `
16
+ const handler = typeof module.default === 'function'
17
+ ? module.default
18
+ : (typeof module.handler === 'function' ? module.handler : null);
19
+
20
+ if (!handler) {
21
+ throw new Error('No handler found in server build');
22
+ }`.trim(),
23
+ handlerCall: "handler(webRequest, ...args)",
24
+ },
25
+ /** Hono style - supports app.fetch */
26
+ hono: {
27
+ handlerSetup: `
28
+ const getHandler = () => {
29
+ if (typeof handler === 'function') return handler;
30
+ if (typeof fetch === 'function') return fetch;
31
+ if (typeof app === 'object' && typeof app.fetch === 'function') return app.fetch.bind(app);
32
+ throw new Error('No handler found in server build');
33
+ };
34
+ const serverHandler = getHandler();`.trim(),
35
+ handlerCall: "serverHandler(webRequest, ...args)",
36
+ },
37
+ /** React Router - uses createRequestHandler */
38
+ reactRouter: {
39
+ imports: `import { createRequestHandler } from "react-router";`,
40
+ handlerSetup: `
41
+ const buildConfig = {
42
+ assets: serverManifest,
43
+ assetsBuildDirectory,
44
+ basename,
45
+ entry,
46
+ future,
47
+ isSpaMode,
48
+ publicPath,
49
+ routes,
50
+ routeDiscovery,
51
+ ssr
52
+ };
53
+
54
+ const requestHandler = createRequestHandler(buildConfig);`.trim(),
55
+ handlerCall: "requestHandler(webRequest, ...args)",
56
+ },
57
+ };
58
+ /**
59
+ * Create a framework adapter
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const adapter = createFrameworkAdapter({
64
+ * name: "my-framework",
65
+ * configFiles: ["my-framework.config.ts", "my-framework.config.js"],
66
+ * buildDirs: {
67
+ * client: ["dist/client", "dist"],
68
+ * server: ["dist/server"],
69
+ * },
70
+ * serverWrapper: "generic",
71
+ * });
72
+ * ```
73
+ */
74
+ export function createFrameworkAdapter(config, options = {}, overrides) {
75
+ const { name, configFiles, buildDirs, serverEntryFiles = ["index.js", "index.mjs", "entry.js", "main.js"], serverWrapper = "generic", defaultRoutes = ["/"], ssrExtraRoutes = [], ssr404, } = config;
76
+ const { clientBuildDir, serverBuildDir, serverEntry, routes = defaultRoutes, } = options;
77
+ // Resolve server wrapper configuration
78
+ const wrapperConfig = typeof serverWrapper === "string"
79
+ ? SERVER_WRAPPER_PRESETS[serverWrapper]
80
+ : serverWrapper;
81
+ const baseAdapter = {
82
+ name,
83
+ async detect(context) {
84
+ const configPath = await detectConfigFile(context.projectRoot, configFiles);
85
+ return configPath !== null;
86
+ },
87
+ async getBuildArtifacts(context) {
88
+ const { projectRoot, isSSR, logger } = context;
89
+ // Detect client directory
90
+ let clientDir = null;
91
+ if (clientBuildDir) {
92
+ clientDir = path.join(projectRoot, clientBuildDir);
93
+ }
94
+ else {
95
+ const candidates = isSSR && buildDirs.server
96
+ ? buildDirs.client
97
+ : buildDirs.client;
98
+ clientDir = await detectBuildDir(projectRoot, candidates);
99
+ }
100
+ // Detect server directory and entry
101
+ let serverDir = null;
102
+ let serverEntryPath = null;
103
+ if (isSSR && buildDirs.server) {
104
+ if (serverBuildDir) {
105
+ serverDir = path.join(projectRoot, serverBuildDir);
106
+ }
107
+ else {
108
+ serverDir = await detectBuildDir(projectRoot, buildDirs.server);
109
+ }
110
+ if (serverEntry) {
111
+ serverEntryPath = path.join(projectRoot, serverEntry);
112
+ }
113
+ else if (serverDir) {
114
+ serverEntryPath = await detectServerEntry(serverDir, serverEntryFiles);
115
+ }
116
+ }
117
+ logBuildArtifacts(logger, name, {
118
+ clientDir,
119
+ serverDir,
120
+ serverEntry: serverEntryPath,
121
+ });
122
+ return {
123
+ clientDir,
124
+ serverDir,
125
+ serverEntry: serverEntryPath,
126
+ assetsDir: clientDir,
127
+ };
128
+ },
129
+ hooks: {
130
+ async generateRoutes(context) {
131
+ const routeList = routes.map((route) => ({
132
+ path: route,
133
+ isStatic: !context.isSSR,
134
+ srcRoute: route,
135
+ }));
136
+ // Add extra routes for SSR mode
137
+ if (context.isSSR && ssrExtraRoutes.length > 0) {
138
+ ssrExtraRoutes.forEach((route) => {
139
+ routeList.push({ path: route, isStatic: false, srcRoute: route });
140
+ });
141
+ }
142
+ return routeList;
143
+ },
144
+ async generateMeta(context, routeList) {
145
+ const meta = createDefaultMeta(routeList, { isSSR: context.isSSR });
146
+ // Custom ssr404 handling
147
+ if (ssr404 !== undefined) {
148
+ meta.conf.ssr404 = typeof ssr404 === "function"
149
+ ? ssr404(context.isSSR)
150
+ : ssr404;
151
+ }
152
+ return meta;
153
+ },
154
+ async generateServerWrapper(_context, config) {
155
+ return generateServerWrapperCode({
156
+ serverEntryPath: config.serverEntryPath,
157
+ imports: wrapperConfig.imports,
158
+ handlerSetup: wrapperConfig.handlerSetup,
159
+ handlerCall: wrapperConfig.handlerCall,
160
+ });
161
+ },
162
+ },
163
+ };
164
+ // Merge user overrides
165
+ if (overrides) {
166
+ return mergeAdapter(baseAdapter, overrides);
167
+ }
168
+ return baseAdapter;
169
+ }
170
+ /**
171
+ * Merge adapter configurations
172
+ */
173
+ function mergeAdapter(base, overrides) {
174
+ const merged = {
175
+ ...base,
176
+ ...overrides,
177
+ name: overrides.name || base.name,
178
+ };
179
+ // Merge hooks
180
+ if (base.hooks || overrides.hooks) {
181
+ merged.hooks = {
182
+ ...base.hooks,
183
+ ...overrides.hooks,
184
+ };
185
+ }
186
+ return merged;
187
+ }
188
+ /**
189
+ * Create a stateful adapter
190
+ * Used for complex adapters that need to share state between different hooks
191
+ */
192
+ export function createStatefulAdapter(initialState, factory) {
193
+ const state = { ...initialState };
194
+ return factory(state);
195
+ }
196
+ /**
197
+ * Compose multiple hooks
198
+ */
199
+ export function composeHooks(...hooksList) {
200
+ const result = {};
201
+ for (const hooks of hooksList) {
202
+ if (!hooks)
203
+ continue;
204
+ Object.assign(result, hooks);
205
+ }
206
+ return result;
207
+ }
208
+ /**
209
+ * Create a detector function - based on config files
210
+ */
211
+ export function createConfigDetector(configFiles) {
212
+ return async (context) => {
213
+ const configPath = await detectConfigFile(context.projectRoot, configFiles);
214
+ return configPath !== null;
215
+ };
216
+ }
217
+ /**
218
+ * Create a detector function - based on build directories
219
+ */
220
+ export function createBuildDirDetector(buildDirs) {
221
+ return async (context) => {
222
+ for (const dir of buildDirs) {
223
+ if (await pathExists(path.join(context.projectRoot, dir))) {
224
+ return true;
225
+ }
226
+ }
227
+ return false;
228
+ };
229
+ }
230
+ /**
231
+ * Create a detector function - based on package.json dependencies
232
+ */
233
+ export function createDependencyDetector(dependencies) {
234
+ return async (context) => {
235
+ const packageJsonPath = path.join(context.projectRoot, "package.json");
236
+ if (!await pathExists(packageJsonPath)) {
237
+ return false;
238
+ }
239
+ try {
240
+ const { readFile } = await import("./utils.js");
241
+ const content = await readFile(packageJsonPath);
242
+ const packageJson = JSON.parse(content);
243
+ const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
244
+ return dependencies.some((dep) => dep in deps);
245
+ }
246
+ catch {
247
+ return false;
248
+ }
249
+ };
250
+ }
251
+ /**
252
+ * Combine multiple detector functions (returns true if any matches)
253
+ */
254
+ export function combineDetectors(...detectors) {
255
+ return async (context) => {
256
+ for (const detector of detectors) {
257
+ if (await detector(context)) {
258
+ return true;
259
+ }
260
+ }
261
+ return false;
262
+ };
263
+ }
264
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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AAM,OAAO,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,CAAC;YAChD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,MAAM,IAAI,GAAG,EAAE,GAAG,WAAW,CAAC,YAAY,EAAE,GAAG,WAAW,CAAC,eAAe,EAAE,CAAC;YAE7E,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACjD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAG,SAAoE;IAEvE,OAAO,KAAK,EAAE,OAAqB,EAAoB,EAAE;QACvD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,IAAI,MAAM,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC5B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Shared helper functions for EdgeOne adapters
3
+ */
4
+ import type { RouteInfo, MetaConfig, Logger } from "./types.js";
5
+ /** Detect config file from candidate list */
6
+ export declare function detectConfigFile(projectRoot: string, patterns: string[]): Promise<string | null>;
7
+ /** Dynamically import config file */
8
+ export declare function loadConfigFile<T = unknown>(configPath: string): Promise<T | null>;
9
+ /** Create default meta configuration */
10
+ export declare function createDefaultMeta(routes: RouteInfo[], options?: {
11
+ isSSR?: boolean;
12
+ has404?: boolean;
13
+ }): MetaConfig;
14
+ /** Node.js IncomingMessage to Web Request converter code */
15
+ export declare const NODE_REQUEST_CONVERTER_CODE: string;
16
+ /** Server wrapper generator options */
17
+ export interface ServerWrapperGeneratorOptions {
18
+ serverEntryPath: string;
19
+ handlerSetup?: string;
20
+ handlerCall: string;
21
+ imports?: string;
22
+ needsNodeRequestConversion?: boolean;
23
+ }
24
+ /** Generate server wrapper code */
25
+ export declare function generateServerWrapperCode(options: ServerWrapperGeneratorOptions): Promise<string>;
26
+ /** Normalize route path */
27
+ export declare function normalizeRoutePath(routePath: string): string;
28
+ /** Convert route path to regex format */
29
+ export declare function routePathToRegex(routePath: string): string;
30
+ /** Detect server entry file */
31
+ export declare function detectServerEntry(serverDir: string, candidates?: string[]): Promise<string | null>;
32
+ /** Detect build directory */
33
+ export declare function detectBuildDir(projectRoot: string, candidates: string[]): Promise<string | null>;
34
+ /** Log build artifacts info */
35
+ export declare function logBuildArtifacts(logger: Logger, adapterName: string, artifacts: {
36
+ clientDir?: string | null;
37
+ serverDir?: string | null;
38
+ serverEntry?: string | null;
39
+ }): void;
40
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGhE,6CAA6C;AAC7C,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAAE,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAED,qCAAqC;AACrC,wBAAsB,cAAc,CAAC,CAAC,GAAG,OAAO,EAC9C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAQnB;AAED,wCAAwC;AACxC,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EAAE,EACnB,OAAO,GAAE;IACP,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CACb,GACL,UAAU,CAeZ;AAED,4DAA4D;AAC5D,eAAO,MAAM,2BAA2B,QA8BhC,CAAC;AAET,uCAAuC;AACvC,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,mCAAmC;AACnC,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,MAAM,CAAC,CA+CjB;AAED,2BAA2B;AAC3B,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAY5D;AAED,yCAAyC;AACzC,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAc1D;AAED,+BAA+B;AAC/B,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EACjB,UAAU,GAAE,MAAM,EAAqD,GACtE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAED,6BAA6B;AAC7B,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQxB;AAED,+BAA+B;AAC/B,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE;IACT,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GACA,IAAI,CAON"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Shared helper functions for EdgeOne adapters
3
+ */
4
+ import path from "path";
5
+ import { pathToFileURL } from "url";
6
+ import { pathExists, readFile } from "./utils.js";
7
+ /** Detect config file from candidate list */
8
+ export async function detectConfigFile(projectRoot, patterns) {
9
+ for (const pattern of patterns) {
10
+ const fullPath = path.join(projectRoot, pattern);
11
+ if (await pathExists(fullPath)) {
12
+ return fullPath;
13
+ }
14
+ }
15
+ return null;
16
+ }
17
+ /** Dynamically import config file */
18
+ export async function loadConfigFile(configPath) {
19
+ try {
20
+ const fileUrl = pathToFileURL(configPath).href;
21
+ const module = await import(`${fileUrl}?t=${Date.now()}`);
22
+ return module.default;
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ }
28
+ /** Create default meta configuration */
29
+ export function createDefaultMeta(routes, options = {}) {
30
+ const { isSSR = false, has404 = false } = options;
31
+ return {
32
+ conf: {
33
+ headers: [],
34
+ redirects: [],
35
+ rewrites: [],
36
+ caches: [],
37
+ has404,
38
+ ssr404: isSSR && !has404,
39
+ },
40
+ has404,
41
+ frameworkRoutes: routes,
42
+ };
43
+ }
44
+ /** Node.js IncomingMessage to Web Request converter code */
45
+ export const NODE_REQUEST_CONVERTER_CODE = `
46
+ function nodeRequestToWebRequest(nodeReq) {
47
+ const protocol = nodeReq.connection?.encrypted ? 'https' : 'http';
48
+ const host = nodeReq.headers.host || 'localhost';
49
+ const url = \`\${protocol}://\${host}\${nodeReq.url}\`;
50
+
51
+ // Convert request headers
52
+ const headers = new Headers();
53
+ for (const [key, value] of Object.entries(nodeReq.headers)) {
54
+ if (value) {
55
+ if (Array.isArray(value)) {
56
+ value.forEach(v => headers.append(key, v));
57
+ } else {
58
+ headers.set(key, value);
59
+ }
60
+ }
61
+ }
62
+
63
+ const init = {
64
+ method: nodeReq.method,
65
+ headers: headers,
66
+ };
67
+
68
+ // Add request body for non-GET/HEAD requests
69
+ if (nodeReq.method !== 'GET' && nodeReq.method !== 'HEAD') {
70
+ init.body = nodeReq;
71
+ }
72
+
73
+ return new Request(url, init);
74
+ }
75
+ `.trim();
76
+ /** Generate server wrapper code */
77
+ export async function generateServerWrapperCode(options) {
78
+ const { serverEntryPath, handlerSetup = "", handlerCall, imports = "", needsNodeRequestConversion = true, } = options;
79
+ const serverBuildContent = await readFile(serverEntryPath);
80
+ const parts = [
81
+ `// Server build content`,
82
+ serverBuildContent,
83
+ ``,
84
+ `// HTTP server wrapper`,
85
+ ];
86
+ // 添加额外导入
87
+ if (imports) {
88
+ parts.push(imports);
89
+ parts.push(``);
90
+ }
91
+ // 添加 handler 初始化代码
92
+ if (handlerSetup) {
93
+ parts.push(handlerSetup);
94
+ parts.push(``);
95
+ }
96
+ // 添加请求转换函数
97
+ if (needsNodeRequestConversion) {
98
+ parts.push(NODE_REQUEST_CONVERTER_CODE);
99
+ parts.push(``);
100
+ }
101
+ // Add request handler
102
+ parts.push(`
103
+ async function nodeRequestHandler(nodeReq, ...args) {
104
+ const webRequest = nodeRequestToWebRequest(nodeReq);
105
+ return ${handlerCall};
106
+ }
107
+
108
+ export default nodeRequestHandler;
109
+ `.trim());
110
+ return parts.join("\n");
111
+ }
112
+ /** Normalize route path */
113
+ export function normalizeRoutePath(routePath) {
114
+ let normalized = routePath.replace(/\/+/g, "/");
115
+ if (!normalized.startsWith("/")) {
116
+ normalized = "/" + normalized;
117
+ }
118
+ if (normalized !== "/" && normalized.endsWith("/")) {
119
+ normalized = normalized.slice(0, -1);
120
+ }
121
+ return normalized;
122
+ }
123
+ /** Convert route path to regex format */
124
+ export function routePathToRegex(routePath) {
125
+ let result = normalizeRoutePath(routePath);
126
+ if (result.includes("*")) {
127
+ result = result.replace(/[.+?^${}|[\]\\]/g, "\\$&");
128
+ if (result.endsWith("/*")) {
129
+ result = result.slice(0, -2) + "/?.*";
130
+ }
131
+ else {
132
+ result = result.replace(/\*/g, ".*");
133
+ }
134
+ }
135
+ return result;
136
+ }
137
+ /** Detect server entry file */
138
+ export async function detectServerEntry(serverDir, candidates = ["index.js", "index.mjs", "entry.js", "main.js"]) {
139
+ for (const candidate of candidates) {
140
+ const entryPath = path.join(serverDir, candidate);
141
+ if (await pathExists(entryPath)) {
142
+ return entryPath;
143
+ }
144
+ }
145
+ return null;
146
+ }
147
+ /** Detect build directory */
148
+ export async function detectBuildDir(projectRoot, candidates) {
149
+ for (const candidate of candidates) {
150
+ const dirPath = path.join(projectRoot, candidate);
151
+ if (await pathExists(dirPath)) {
152
+ return dirPath;
153
+ }
154
+ }
155
+ return null;
156
+ }
157
+ /** Log build artifacts info */
158
+ export function logBuildArtifacts(logger, adapterName, artifacts) {
159
+ logger.verbose(`${adapterName} build artifacts:`);
160
+ logger.verbose(` Client: ${artifacts.clientDir || "not found"}`);
161
+ logger.verbose(` Server: ${artifacts.serverDir || "not found"}`);
162
+ if (artifacts.serverEntry) {
163
+ logger.verbose(` Server entry: ${artifacts.serverEntry}`);
164
+ }
165
+ }
166
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAElD,6CAA6C;AAC7C,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,QAAkB;IAElB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACjD,IAAI,MAAM,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAkB;IAElB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,OAAO,MAAM,IAAI,CAAC,GAAG,EAAE,EAAE,CAA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