@chuckcchen/vite-plugin 1.0.19 → 1.0.21
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 -18
- package/dist/bundler.d.ts.map +1 -1
- package/dist/bundler.js +43 -30
- package/dist/bundler.js.map +1 -1
- package/dist/core.d.ts +2 -18
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +125 -248
- package/dist/core.js.map +1 -1
- package/dist/factory/detectors.d.ts +5 -15
- package/dist/factory/detectors.d.ts.map +1 -1
- package/dist/factory/detectors.js +8 -22
- package/dist/factory/detectors.js.map +1 -1
- package/dist/factory/hooks.d.ts +4 -59
- package/dist/factory/hooks.d.ts.map +1 -1
- package/dist/factory/hooks.js +18 -117
- package/dist/factory/hooks.js.map +1 -1
- package/dist/factory/index.d.ts +7 -51
- package/dist/factory/index.d.ts.map +1 -1
- package/dist/factory/index.js +10 -55
- package/dist/factory/index.js.map +1 -1
- package/dist/factory/presets.d.ts +16 -121
- package/dist/factory/presets.d.ts.map +1 -1
- package/dist/factory/presets.js +143 -174
- package/dist/factory/presets.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -35
- package/dist/index.js.map +1 -1
- package/dist/route/index.d.ts +1 -1
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/index.js +1 -3
- package/dist/route/index.js.map +1 -1
- package/dist/route/parser.d.ts +0 -37
- package/dist/route/parser.d.ts.map +1 -1
- package/dist/route/parser.js +11 -124
- package/dist/route/parser.js.map +1 -1
- package/dist/route/regex.d.ts +15 -80
- package/dist/route/regex.d.ts.map +1 -1
- package/dist/route/regex.js +65 -169
- package/dist/route/regex.js.map +1 -1
- package/dist/route/regex.test.d.ts +7 -0
- package/dist/route/regex.test.d.ts.map +1 -0
- package/dist/route/regex.test.js +662 -0
- package/dist/route/regex.test.js.map +1 -0
- package/dist/route/types.d.ts +0 -58
- package/dist/route/types.d.ts.map +1 -1
- package/dist/types.d.ts +36 -147
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -3
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +1 -78
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +11 -144
- package/dist/utils.js.map +1 -1
- package/dist/vite-config-parser.d.ts +4 -141
- package/dist/vite-config-parser.d.ts.map +1 -1
- package/dist/vite-config-parser.js +25 -235
- package/dist/vite-config-parser.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,iCAAiC,EACjC,wBAAwB,EACxB,sBAAsB,EACtB,+BAA+B,EAC/B,sBAAsB,GAIvB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GAGnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAuBxB,MAAM,UAAU,sBAAsB,CACpC,MAA4B,EAC5B,UAAiC,EAAE,EACnC,SAAqC;IAErC,MAAM,EACJ,IAAI,EACJ,WAAW,EACX,SAAS,EACT,gBAAgB,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,EACnE,aAAa,GAAG,YAAY,EAC5B,WAAW,EACX,aAAa,GAAG,CAAC,GAAG,CAAC,EACrB,cAAc,G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KAAK,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE;SACpD,CAAC;IACJ,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,YAAoB,EACpB,OAA4C;IAE5C,OAAO,OAAO,CAAC,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,132 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Handler detection path configuration
|
|
17
|
-
*
|
|
18
|
-
* Supported path formats:
|
|
19
|
-
* - "default" - Check if default export is a function
|
|
20
|
-
* - "default.fetch" - Check if default export has a fetch method
|
|
21
|
-
* - "handler" - Check serverExports.handler
|
|
22
|
-
* - "app.fetch" - Check serverExports.app.fetch (Hono style)
|
|
23
|
-
* - "server.fetch" - Check serverExports.server.fetch (TanStack Start)
|
|
24
|
-
*/
|
|
25
|
-
export type HandlerDetectPath = string;
|
|
26
|
-
/**
|
|
27
|
-
* Default handler detection paths for webHandler preset
|
|
28
|
-
*/
|
|
29
|
-
export declare const DEFAULT_HANDLER_DETECT_PATHS: HandlerDetectPath[];
|
|
30
|
-
/**
|
|
31
|
-
* Create a webHandler preset with custom detection paths
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* // TanStack Start - only check server.fetch
|
|
36
|
-
* const preset = createWebHandlerPreset(["default.fetch", "server.fetch"]);
|
|
37
|
-
*
|
|
38
|
-
* // Custom framework
|
|
39
|
-
* const preset = createWebHandlerPreset(["default", "myHandler", "app.handle"]);
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function createWebHandlerPreset(detectPaths?: HandlerDetectPath[]): ServerWrapperPreset;
|
|
43
|
-
/**
|
|
44
|
-
* Built-in server wrapper presets (generic, framework-agnostic)
|
|
45
|
-
*
|
|
46
|
-
* Note: All presets use `serverBuild` (namespace import) and `serverExports` (rest exports)
|
|
47
|
-
* which are automatically provided by generateServerWrapperCode()
|
|
48
|
-
*
|
|
49
|
-
* Framework-specific presets should be defined in their respective adapter packages.
|
|
50
|
-
*/
|
|
1
|
+
import type { ServerWrapperPreset, EsbuildConfig, HandlerMode } from "../types.js";
|
|
2
|
+
export type { ServerWrapperPreset, EsbuildConfig, HandlerMode };
|
|
3
|
+
export declare const WEB_HANDLER_EXPORTS: readonly ["default", "default.fetch", "handler", "fetch", "app.fetch", "server.fetch"];
|
|
4
|
+
export declare const SSR_RENDER_EXPORTS: readonly ["render", "ssr", "default"];
|
|
5
|
+
export declare function resolvePreset(preset: ServerWrapperPreset): {
|
|
6
|
+
imports: string;
|
|
7
|
+
setup: string;
|
|
8
|
+
invoke: string;
|
|
9
|
+
esbuildConfig?: EsbuildConfig;
|
|
10
|
+
};
|
|
11
|
+
export declare function createWebHandlerPreset(exportPaths?: string[]): ServerWrapperPreset;
|
|
12
|
+
export declare function createSSRRenderPreset(exportPaths?: string[]): ServerWrapperPreset;
|
|
13
|
+
export declare function createAutoDetectPreset(): ServerWrapperPreset;
|
|
51
14
|
export declare const SERVER_WRAPPER_PRESETS: {
|
|
52
|
-
|
|
53
|
-
* Web Handler - Request/Response pattern
|
|
54
|
-
*
|
|
55
|
-
* Supports multiple export patterns (configurable via createWebHandlerPreset):
|
|
56
|
-
* - default export function
|
|
57
|
-
* - default.fetch (app object with fetch method)
|
|
58
|
-
* - named `handler` export
|
|
59
|
-
* - named `fetch` export
|
|
60
|
-
* - `app.fetch` pattern (Hono style)
|
|
61
|
-
* - `server.fetch` pattern (TanStack Start)
|
|
62
|
-
*/
|
|
15
|
+
readonly autoDetect: ServerWrapperPreset;
|
|
63
16
|
readonly webHandler: ServerWrapperPreset;
|
|
64
|
-
|
|
65
|
-
* HTML Render - render function returning {head, html}
|
|
66
|
-
*
|
|
67
|
-
* Standard Vite SSR pattern where render(url) returns HTML fragments
|
|
68
|
-
* that are injected into the HTML template.
|
|
69
|
-
*/
|
|
70
|
-
readonly htmlRender: {
|
|
71
|
-
readonly requiresHtmlTemplate: true;
|
|
72
|
-
readonly handlerSetup: string;
|
|
73
|
-
readonly handlerCall: "handleSSRRequest(webRequest)";
|
|
74
|
-
};
|
|
17
|
+
readonly ssrRender: ServerWrapperPreset;
|
|
75
18
|
};
|
|
76
|
-
|
|
77
|
-
* Result of extending server wrapper presets
|
|
78
|
-
*/
|
|
19
|
+
export type PresetName = keyof typeof SERVER_WRAPPER_PRESETS;
|
|
79
20
|
export interface ExtendedPresetsResult<TCustom extends Record<string, ServerWrapperPreset>> {
|
|
80
|
-
/** Extended presets object (core + custom) */
|
|
81
21
|
presets: typeof SERVER_WRAPPER_PRESETS & TCustom;
|
|
82
|
-
/** Type-safe preset resolver function */
|
|
83
22
|
resolvePreset: (preset: keyof (typeof SERVER_WRAPPER_PRESETS & TCustom) | ServerWrapperPreset) => ServerWrapperPreset;
|
|
84
|
-
/** Get all available preset names */
|
|
85
23
|
getPresetNames: () => (keyof (typeof SERVER_WRAPPER_PRESETS & TCustom))[];
|
|
86
24
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Create a server wrapper preset
|
|
89
|
-
*
|
|
90
|
-
* Helper function to create a properly typed preset with validation and normalization.
|
|
91
|
-
* Automatically trims handlerSetup and validates required fields.
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* const myPreset = createServerWrapperPreset({
|
|
96
|
-
* imports: `import { handler } from 'my-framework';`,
|
|
97
|
-
* handlerSetup: `const requestHandler = handler(serverExports);`,
|
|
98
|
-
* handlerCall: "requestHandler(webRequest)",
|
|
99
|
-
* });
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
25
|
export declare function createServerWrapperPreset(config: ServerWrapperPreset): ServerWrapperPreset;
|
|
103
|
-
/**
|
|
104
|
-
* Extend core server wrapper presets with custom presets
|
|
105
|
-
*
|
|
106
|
-
* This utility provides a standardized way for adapters to:
|
|
107
|
-
* 1. Add framework-specific presets while keeping core presets
|
|
108
|
-
* 2. Get a type-safe resolver function
|
|
109
|
-
* 3. Export extended presets for external use
|
|
110
|
-
*
|
|
111
|
-
* Custom presets are automatically validated and normalized using createServerWrapperPreset().
|
|
112
|
-
*
|
|
113
|
-
* @example
|
|
114
|
-
* ```ts
|
|
115
|
-
* // In vite-adapter - can pass raw config, will be validated automatically
|
|
116
|
-
* const { presets, resolvePreset } = extendServerWrapperPresets({
|
|
117
|
-
* vike: {
|
|
118
|
-
* imports: `import { renderPage } from 'vike/server';`,
|
|
119
|
-
* handlerSetup: `...`,
|
|
120
|
-
* handlerCall: "handleVikeRequest(webRequest)",
|
|
121
|
-
* },
|
|
122
|
-
* });
|
|
123
|
-
*
|
|
124
|
-
* export const SERVER_WRAPPER_PRESETS = presets;
|
|
125
|
-
* export type ServerWrapperPresetName = keyof typeof presets;
|
|
126
|
-
*
|
|
127
|
-
* // Use in adapter
|
|
128
|
-
* const resolved = resolvePreset(options.serverWrapper || "htmlRender");
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
26
|
export declare function extendServerWrapperPresets<TCustom extends Record<string, ServerWrapperPreset>>(customPresets: TCustom): ExtendedPresetsResult<TCustom>;
|
|
132
27
|
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/factory/presets.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/factory/presets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,WAAW,EACZ,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,C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4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export const DEFAULT_HANDLER_DETECT_PATHS = [
|
|
10
|
-
"default", // export default handler
|
|
11
|
-
"default.fetch", // export default { fetch } (app object)
|
|
12
|
-
"handler", // export { handler }
|
|
13
|
-
"fetch", // export { fetch }
|
|
14
|
-
"app.fetch", // export { app } (Hono)
|
|
15
|
-
"server.fetch", // export { server } (TanStack Start)
|
|
1
|
+
export const WEB_HANDLER_EXPORTS = [
|
|
2
|
+
"default",
|
|
3
|
+
"default.fetch",
|
|
4
|
+
"handler",
|
|
5
|
+
"fetch",
|
|
6
|
+
"app.fetch",
|
|
7
|
+
"server.fetch",
|
|
16
8
|
];
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
export const SSR_RENDER_EXPORTS = ["render", "ssr", "default"];
|
|
10
|
+
const RESPONSE_PARSER_CODE = `
|
|
11
|
+
function __parseResponse(result) {
|
|
12
|
+
if (result instanceof Response) return result;
|
|
13
|
+
|
|
14
|
+
if (typeof result === 'string') {
|
|
15
|
+
const isFullHtml = result.trim().toLowerCase().startsWith('<!doctype') ||
|
|
16
|
+
result.trim().toLowerCase().startsWith('<html');
|
|
17
|
+
return new Response(result, {
|
|
18
|
+
status: 200,
|
|
19
|
+
headers: { 'Content-Type': isFullHtml ? 'text/html; charset=utf-8' : 'text/plain; charset=utf-8' }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (result === null || result === undefined) {
|
|
24
|
+
return new Response('Not Found', {
|
|
25
|
+
status: 404,
|
|
26
|
+
headers: { 'Content-Type': 'text/plain; charset=utf-8' }
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return new Response(JSON.stringify(result), {
|
|
31
|
+
status: 200,
|
|
32
|
+
headers: { 'Content-Type': 'application/json; charset=utf-8' }
|
|
33
|
+
});
|
|
34
|
+
}`.trim();
|
|
35
|
+
function generateExportCheck(exportPath) {
|
|
36
|
+
if (exportPath === "default") {
|
|
37
|
+
return `if (typeof defaultExport === 'function') return defaultExport;`;
|
|
23
38
|
}
|
|
24
|
-
if (
|
|
25
|
-
return `
|
|
39
|
+
if (exportPath === "default.fetch") {
|
|
40
|
+
return `if (typeof defaultExport === 'object' && defaultExport !== null && typeof defaultExport.fetch === 'function') return defaultExport.fetch.bind(defaultExport);`;
|
|
26
41
|
}
|
|
27
|
-
if (
|
|
28
|
-
const [obj, method] =
|
|
29
|
-
return `
|
|
42
|
+
if (exportPath.includes(".")) {
|
|
43
|
+
const [obj, method] = exportPath.split(".");
|
|
44
|
+
return `if (typeof serverExports.${obj} === 'object' && serverExports.${obj} !== null && typeof serverExports.${obj}.${method} === 'function') return serverExports.${obj}.${method}.bind(serverExports.${obj});`;
|
|
30
45
|
}
|
|
31
|
-
return `
|
|
46
|
+
return `if (typeof serverExports.${exportPath} === 'function') return serverExports.${exportPath};`;
|
|
32
47
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const expectedList = detectPaths.join(", ");
|
|
48
|
+
function generateHandlerDetection(exportPaths) {
|
|
49
|
+
const checks = exportPaths
|
|
50
|
+
.map((p) => ` ${generateExportCheck(p)}`)
|
|
51
|
+
.join("\n");
|
|
52
|
+
const expectedList = exportPaths.join(", ");
|
|
39
53
|
return `
|
|
40
|
-
const
|
|
54
|
+
const __getHandler = () => {
|
|
41
55
|
${checks}
|
|
42
|
-
throw new Error('No handler found. Expected: ${expectedList}');
|
|
56
|
+
throw new Error('No handler found. Expected exports: ${expectedList}');
|
|
43
57
|
};
|
|
44
|
-
const
|
|
58
|
+
const __handler = __getHandler();`.trim();
|
|
45
59
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
60
|
+
function generateInvokeCode(mode) {
|
|
61
|
+
if (mode === "web") {
|
|
62
|
+
return `
|
|
63
|
+
async function __handleRequest(request) {
|
|
64
|
+
const result = await __handler(request);
|
|
65
|
+
return __parseResponse(result);
|
|
66
|
+
}`.trim();
|
|
67
|
+
}
|
|
68
|
+
if (mode === "ssr") {
|
|
69
|
+
return `
|
|
70
|
+
async function __handleRequest(request) {
|
|
71
|
+
const url = new URL(request.url);
|
|
72
|
+
const fullUrl = url.pathname + url.search;
|
|
73
|
+
const result = await __handler(fullUrl, request);
|
|
74
|
+
return __parseResponse(result);
|
|
75
|
+
}`.trim();
|
|
76
|
+
}
|
|
77
|
+
return `
|
|
78
|
+
async function __handleRequest(request) {
|
|
79
|
+
const url = new URL(request.url);
|
|
80
|
+
const fullUrl = url.pathname + url.search;
|
|
81
|
+
let result;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
result = await __handler(request);
|
|
85
|
+
if (result === undefined) {
|
|
86
|
+
result = await __handler(fullUrl, request);
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
result = await __handler(fullUrl, request);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return __parseResponse(result);
|
|
93
|
+
}`.trim();
|
|
94
|
+
}
|
|
95
|
+
function normalizeExports(exports) {
|
|
96
|
+
if (!exports)
|
|
97
|
+
return [];
|
|
98
|
+
return Array.isArray(exports) ? exports : [exports];
|
|
99
|
+
}
|
|
100
|
+
export function resolvePreset(preset) {
|
|
101
|
+
if (preset.setup && preset.invoke) {
|
|
102
|
+
return {
|
|
103
|
+
imports: preset.imports ?? "",
|
|
104
|
+
setup: preset.setup.trim(),
|
|
105
|
+
invoke: preset.invoke,
|
|
106
|
+
esbuildConfig: preset.esbuildConfig,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const exportPaths = normalizeExports(preset.exports);
|
|
110
|
+
const mode = preset.mode ?? "auto";
|
|
111
|
+
if (exportPaths.length === 0) {
|
|
112
|
+
throw new Error("ServerWrapperPreset must specify either 'exports' or 'setup'+'invoke'");
|
|
113
|
+
}
|
|
114
|
+
const handlerDetection = generateHandlerDetection(exportPaths);
|
|
115
|
+
const invokeCode = generateInvokeCode(mode);
|
|
116
|
+
const generatedSetup = `
|
|
117
|
+
${RESPONSE_PARSER_CODE}
|
|
118
|
+
|
|
119
|
+
${handlerDetection}
|
|
120
|
+
|
|
121
|
+
${invokeCode}`.trim();
|
|
122
|
+
return {
|
|
123
|
+
imports: preset.imports ?? "",
|
|
124
|
+
setup: generatedSetup,
|
|
125
|
+
invoke: "__handleRequest(webRequest)",
|
|
126
|
+
esbuildConfig: preset.esbuildConfig,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export function createWebHandlerPreset(exportPaths = [...WEB_HANDLER_EXPORTS]) {
|
|
130
|
+
return { exports: exportPaths, mode: "web" };
|
|
131
|
+
}
|
|
132
|
+
export function createSSRRenderPreset(exportPaths = [...SSR_RENDER_EXPORTS]) {
|
|
133
|
+
return { exports: exportPaths, mode: "ssr" };
|
|
134
|
+
}
|
|
135
|
+
export function createAutoDetectPreset() {
|
|
59
136
|
return {
|
|
60
|
-
|
|
61
|
-
|
|
137
|
+
exports: ["default", "default.fetch", "handler", "fetch", "render", "ssr"],
|
|
138
|
+
mode: "auto",
|
|
62
139
|
};
|
|
63
140
|
}
|
|
64
|
-
// ============================================================================
|
|
65
|
-
// Built-in Presets
|
|
66
|
-
// ============================================================================
|
|
67
|
-
/**
|
|
68
|
-
* Built-in server wrapper presets (generic, framework-agnostic)
|
|
69
|
-
*
|
|
70
|
-
* Note: All presets use `serverBuild` (namespace import) and `serverExports` (rest exports)
|
|
71
|
-
* which are automatically provided by generateServerWrapperCode()
|
|
72
|
-
*
|
|
73
|
-
* Framework-specific presets should be defined in their respective adapter packages.
|
|
74
|
-
*/
|
|
75
141
|
export const SERVER_WRAPPER_PRESETS = {
|
|
76
|
-
|
|
77
|
-
* Web Handler - Request/Response pattern
|
|
78
|
-
*
|
|
79
|
-
* Supports multiple export patterns (configurable via createWebHandlerPreset):
|
|
80
|
-
* - default export function
|
|
81
|
-
* - default.fetch (app object with fetch method)
|
|
82
|
-
* - named `handler` export
|
|
83
|
-
* - named `fetch` export
|
|
84
|
-
* - `app.fetch` pattern (Hono style)
|
|
85
|
-
* - `server.fetch` pattern (TanStack Start)
|
|
86
|
-
*/
|
|
142
|
+
autoDetect: createAutoDetectPreset(),
|
|
87
143
|
webHandler: createWebHandlerPreset(),
|
|
88
|
-
|
|
89
|
-
* HTML Render - render function returning {head, html}
|
|
90
|
-
*
|
|
91
|
-
* Standard Vite SSR pattern where render(url) returns HTML fragments
|
|
92
|
-
* that are injected into the HTML template.
|
|
93
|
-
*/
|
|
94
|
-
htmlRender: {
|
|
95
|
-
requiresHtmlTemplate: true,
|
|
96
|
-
handlerSetup: `
|
|
97
|
-
const renderFn = typeof serverExports.render === 'function'
|
|
98
|
-
? serverExports.render
|
|
99
|
-
: (typeof defaultExport === 'function' ? defaultExport : null);
|
|
100
|
-
|
|
101
|
-
if (!renderFn) {
|
|
102
|
-
throw new Error('No render function found in server build. Expected export: render(url)');
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async function handleSSRRequest(request) {
|
|
106
|
-
const url = new URL(request.url);
|
|
107
|
-
const pathname = url.pathname;
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
const rendered = await renderFn(pathname);
|
|
111
|
-
let html = __HTML_TEMPLATE__
|
|
112
|
-
.replace('<!--app-head-->', rendered.head ?? '')
|
|
113
|
-
.replace('<!--app-html-->', rendered.html ?? '');
|
|
114
|
-
|
|
115
|
-
return new Response(html, {
|
|
116
|
-
status: 200,
|
|
117
|
-
headers: { 'Content-Type': 'text/html; charset=utf-8' }
|
|
118
|
-
});
|
|
119
|
-
} catch (error) {
|
|
120
|
-
console.error('SSR render error:', error);
|
|
121
|
-
return new Response('Internal Server Error: ' + error.message, {
|
|
122
|
-
status: 500,
|
|
123
|
-
headers: { 'Content-Type': 'text/plain' }
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}`.trim(),
|
|
127
|
-
handlerCall: "handleSSRRequest(webRequest)",
|
|
128
|
-
},
|
|
144
|
+
ssrRender: createSSRRenderPreset(),
|
|
129
145
|
};
|
|
130
|
-
/**
|
|
131
|
-
* Create a server wrapper preset
|
|
132
|
-
*
|
|
133
|
-
* Helper function to create a properly typed preset with validation and normalization.
|
|
134
|
-
* Automatically trims handlerSetup and validates required fields.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* const myPreset = createServerWrapperPreset({
|
|
139
|
-
* imports: `import { handler } from 'my-framework';`,
|
|
140
|
-
* handlerSetup: `const requestHandler = handler(serverExports);`,
|
|
141
|
-
* handlerCall: "requestHandler(webRequest)",
|
|
142
|
-
* });
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
146
|
export function createServerWrapperPreset(config) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
throw new Error("Server wrapper preset must have handlerCall");
|
|
147
|
+
const hasDeclarative = config.exports !== undefined;
|
|
148
|
+
const hasCustomCode = config.setup && config.invoke;
|
|
149
|
+
if (!hasDeclarative && !hasCustomCode) {
|
|
150
|
+
throw new Error("ServerWrapperPreset must specify either 'exports' or 'setup'+'invoke'");
|
|
151
151
|
}
|
|
152
152
|
return {
|
|
153
|
+
exports: config.exports,
|
|
154
|
+
mode: config.mode,
|
|
153
155
|
imports: config.imports,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
setup: config.setup,
|
|
157
|
+
invoke: config.invoke,
|
|
158
|
+
esbuildConfig: config.esbuildConfig,
|
|
157
159
|
};
|
|
158
160
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Extend core server wrapper presets with custom presets
|
|
161
|
-
*
|
|
162
|
-
* This utility provides a standardized way for adapters to:
|
|
163
|
-
* 1. Add framework-specific presets while keeping core presets
|
|
164
|
-
* 2. Get a type-safe resolver function
|
|
165
|
-
* 3. Export extended presets for external use
|
|
166
|
-
*
|
|
167
|
-
* Custom presets are automatically validated and normalized using createServerWrapperPreset().
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```ts
|
|
171
|
-
* // In vite-adapter - can pass raw config, will be validated automatically
|
|
172
|
-
* const { presets, resolvePreset } = extendServerWrapperPresets({
|
|
173
|
-
* vike: {
|
|
174
|
-
* imports: `import { renderPage } from 'vike/server';`,
|
|
175
|
-
* handlerSetup: `...`,
|
|
176
|
-
* handlerCall: "handleVikeRequest(webRequest)",
|
|
177
|
-
* },
|
|
178
|
-
* });
|
|
179
|
-
*
|
|
180
|
-
* export const SERVER_WRAPPER_PRESETS = presets;
|
|
181
|
-
* export type ServerWrapperPresetName = keyof typeof presets;
|
|
182
|
-
*
|
|
183
|
-
* // Use in adapter
|
|
184
|
-
* const resolved = resolvePreset(options.serverWrapper || "htmlRender");
|
|
185
|
-
* ```
|
|
186
|
-
*/
|
|
187
161
|
export function extendServerWrapperPresets(customPresets) {
|
|
188
|
-
// Validate and normalize all custom presets
|
|
189
162
|
const normalizedCustomPresets = {};
|
|
190
163
|
for (const [key, preset] of Object.entries(customPresets)) {
|
|
191
164
|
normalizedCustomPresets[key] = createServerWrapperPreset(preset);
|
|
@@ -194,24 +167,20 @@ export function extendServerWrapperPresets(customPresets) {
|
|
|
194
167
|
...SERVER_WRAPPER_PRESETS,
|
|
195
168
|
...normalizedCustomPresets,
|
|
196
169
|
};
|
|
197
|
-
function
|
|
170
|
+
function resolvePresetByName(preset) {
|
|
198
171
|
if (typeof preset === "string") {
|
|
199
172
|
const resolved = extendedPresets[preset];
|
|
200
173
|
if (!resolved) {
|
|
201
|
-
throw new Error(`Unknown
|
|
174
|
+
throw new Error(`Unknown preset: "${preset}". Available: ${Object.keys(extendedPresets).join(", ")}`);
|
|
202
175
|
}
|
|
203
176
|
return resolved;
|
|
204
177
|
}
|
|
205
|
-
// Validate and normalize inline preset
|
|
206
178
|
return createServerWrapperPreset(preset);
|
|
207
179
|
}
|
|
208
|
-
function getPresetNames() {
|
|
209
|
-
return Object.keys(extendedPresets);
|
|
210
|
-
}
|
|
211
180
|
return {
|
|
212
181
|
presets: extendedPresets,
|
|
213
|
-
resolvePreset,
|
|
214
|
-
getPresetNames,
|
|
182
|
+
resolvePreset: resolvePresetByName,
|
|
183
|
+
getPresetNames: () => Object.keys(extendedPresets),
|
|
215
184
|
};
|
|
216
185
|
}
|
|
217
186
|
//# sourceMappingURL=presets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../src/factory/presets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../../src/factory/presets.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,SAAS;IACT,eAAe;IACf,SAAS;IACT,OAAO;IACP,WAAW;IACX,cAAc;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAU,CAAC;AAExE,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;EAwB3B,CAAC,IAAI,EAAE,CAAC;AAEV,SAAS,mBAAmB,CAAC,UAAkB;IAC7C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,gEAAgE,CAAC;IAC1E,CAAC;IACD,IAAI,UAAU,KAAK,eAAe,EAAE,CAAC;QACnC,OAAO,+JAA+J,CAAC;IACzK,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,4BA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I,KAAK,CACb,oBAAoB,MAAM,iBAAiB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrF,CAAC;YACJ,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,yBAAyB,CAAC,MAA6B,CAAC,CAAC;IAClE,CAAC;IAED,OAAO;QACL,OAAO,EAAE,eAAe;QACxB,aAAa,EAAE,mBAAmB;QAClC,cAAc,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAyB;KAC3E,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Core adapter plugin for EdgeOne platform
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Core exports
|
|
4
3
|
*/
|
|
5
4
|
export { createCoreAdapter, default } from "./core.js";
|
|
6
|
-
export { bundleServerCode, createServerWrapper, cleanupWrapper, } from "./bundler.js";
|
|
5
|
+
export { bundleServerCode, createServerWrapper, cleanupWrapper, createEsmInteropPlugin, } from "./bundler.js";
|
|
6
|
+
export type { EsmInteropPluginOptions } from "./bundler.js";
|
|
7
7
|
export { ViteConfigParser, createViteConfigParser, parseViteConfig, getOutputDirFromViteConfig, getServerDirFromViteConfig, getServerEntryFromViteConfig, } from "./vite-config-parser.js";
|
|
8
8
|
export { createLogger, logBuildArtifacts, pathExists, copyDirectory, ensureDirectory, readFile, writeFile, deleteFile, listFiles, detectConfigFile, detectBuildDir, detectServerEntry, loadConfigFile, normalizeRoutePath, createDefaultMeta, NODE_REQUEST_CONVERTER_CODE, generateServerWrapperCode, } from "./utils.js";
|
|
9
|
-
export { createFrameworkAdapter, createStatefulAdapter, combineDetectors, createConfigDetector, createBuildDirDetector, createDependencyDetector, SERVER_WRAPPER_PRESETS, extendServerWrapperPresets, createServerWrapperPreset, createWebHandlerPreset,
|
|
9
|
+
export { createFrameworkAdapter, createStatefulAdapter, combineDetectors, createConfigDetector, createBuildDirDetector, createDependencyDetector, SERVER_WRAPPER_PRESETS, extendServerWrapperPresets, createServerWrapperPreset, resolvePreset, createWebHandlerPreset, createSSRRenderPreset, createAutoDetectPreset, WEB_HANDLER_EXPORTS, SSR_RENDER_EXPORTS, } from "./factory/index.js";
|
|
10
10
|
export { isDynamicRoute, routeToRegex, addRegexToRoutes, convertRoutesToMetaFormat, parseRouteTreeContent, parseRouteTreeFile, scanRoutesDirectory, scanRoutesFromDirectories, loadServerBuildRoutes, flattenRouteTree, parseRoutesFromSources, toRouteInfo, toRouteInfoArray, } from "./route/index.js";
|
|
11
|
-
export type { RouteInfo, MetaRouteInfo, MetaConfig, HeaderRule, RedirectRule, RewriteRule, CacheRule, BuildContext, Logger, BuildArtifacts, ServerWrapperConfig, ServerBundleConfig, BeforeBuildHook, AfterBuildHook, BeforeBundleHook, AfterBundleHook, GenerateRoutesHook, GenerateMetaHook, GenerateServerWrapperHook, AdapterHooks, FrameworkAdapter, CoreAdapterOptions, ViteAdapterOptions, ReactRouterAdapterOptions, TanStackStartAdapterOptions, CreateAdapterPlugin, } from "./types.js";
|
|
11
|
+
export type { RouteInfo, MetaRouteInfo, MetaConfig, HeaderRule, RedirectRule, RewriteRule, CacheRule, BuildContext, Logger, BuildArtifacts, ServerWrapperConfig, ServerBundleConfig, EsbuildConfig, ServerWrapperPreset, HandlerMode, BeforeBuildHook, AfterBuildHook, BeforeBundleHook, AfterBundleHook, GenerateRoutesHook, GenerateMetaHook, GenerateServerWrapperHook, AdapterHooks, FrameworkAdapter, CoreAdapterOptions, ViteAdapterOptions, ReactRouterAdapterOptions, TanStackStartAdapterOptions, CreateAdapterPlugin, } from "./types.js";
|
|
12
12
|
export type { ServerWrapperGeneratorOptions } from "./utils.js";
|
|
13
13
|
export type { ViteConfigInfo, ViteConfigParserOptions, } from "./vite-config-parser.js";
|
|
14
|
-
export type {
|
|
14
|
+
export type { PresetName, BuildDirConfig, AdapterFactoryConfig, AdapterFactoryOptions, RouteSourceConfig, ExtendedPresetsResult, } from "./factory/index.js";
|
|
15
15
|
export type { RouteNode, RouteParserConfig, RouteTreeParserOptions, ServerBuildRouteSource, RouteTreeFileSource, DirectoryScanSource, RouteSource, InternalRouteInfo, FlattenRouteTreeOptions, RouteSyntax, RouteToRegexOptions, } from "./route/index.js";
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EAEf,0BAA0B,EAC1B,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,eAAe,EACf,QAAQ,EACR,SAAS,EACT,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,aAAa,EACb,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EACV,SAAS,EACT,aAAa,EACb,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,YAAY,EACZ,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,EACzB,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAEhE,YAAY,EACV,cAAc,EACd,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,EACX,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Core adapter plugin for EdgeOne platform
|
|
2
|
+
* EdgeOne Vite Plugin Adapter - Core exports
|
|
4
3
|
*/
|
|
5
|
-
// Core
|
|
6
4
|
export { createCoreAdapter, default } from "./core.js";
|
|
7
|
-
|
|
8
|
-
export { bundleServerCode, createServerWrapper, cleanupWrapper, } from "./bundler.js";
|
|
9
|
-
// Vite Config Parser
|
|
5
|
+
export { bundleServerCode, createServerWrapper, cleanupWrapper, createEsmInteropPlugin, } from "./bundler.js";
|
|
10
6
|
export { ViteConfigParser, createViteConfigParser, parseViteConfig,
|
|
11
|
-
//
|
|
7
|
+
// @deprecated Use ViteConfigParser instead
|
|
12
8
|
getOutputDirFromViteConfig, getServerDirFromViteConfig, getServerEntryFromViteConfig, } from "./vite-config-parser.js";
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
|
|
16
|
-
createLogger, logBuildArtifacts,
|
|
17
|
-
// File system
|
|
18
|
-
pathExists, copyDirectory, ensureDirectory, readFile, writeFile, deleteFile, listFiles,
|
|
19
|
-
// Detection
|
|
20
|
-
detectConfigFile, detectBuildDir, detectServerEntry, loadConfigFile,
|
|
21
|
-
// Route helpers
|
|
22
|
-
normalizeRoutePath,
|
|
23
|
-
// Meta
|
|
24
|
-
createDefaultMeta,
|
|
25
|
-
// Server wrapper
|
|
26
|
-
NODE_REQUEST_CONVERTER_CODE, generateServerWrapperCode, } from "./utils.js";
|
|
27
|
-
// Factory
|
|
28
|
-
export { createFrameworkAdapter, createStatefulAdapter, combineDetectors, createConfigDetector, createBuildDirDetector, createDependencyDetector, SERVER_WRAPPER_PRESETS,
|
|
29
|
-
// Preset extension utilities
|
|
30
|
-
extendServerWrapperPresets, createServerWrapperPreset,
|
|
31
|
-
// Web handler preset factory
|
|
32
|
-
createWebHandlerPreset, DEFAULT_HANDLER_DETECT_PATHS, } from "./factory/index.js";
|
|
33
|
-
// Route Module
|
|
34
|
-
export {
|
|
35
|
-
// Dynamic route to regex conversion
|
|
36
|
-
isDynamicRoute, routeToRegex, addRegexToRoutes, convertRoutesToMetaFormat,
|
|
37
|
-
// Parsing functions
|
|
38
|
-
parseRouteTreeContent, parseRouteTreeFile, scanRoutesDirectory, scanRoutesFromDirectories, loadServerBuildRoutes, flattenRouteTree, parseRoutesFromSources,
|
|
39
|
-
// Type conversion utilities
|
|
40
|
-
toRouteInfo, toRouteInfoArray, } from "./route/index.js";
|
|
9
|
+
export { createLogger, logBuildArtifacts, pathExists, copyDirectory, ensureDirectory, readFile, writeFile, deleteFile, listFiles, detectConfigFile, detectBuildDir, detectServerEntry, loadConfigFile, normalizeRoutePath, createDefaultMeta, NODE_REQUEST_CONVERTER_CODE, generateServerWrapperCode, } from "./utils.js";
|
|
10
|
+
export { createFrameworkAdapter, createStatefulAdapter, combineDetectors, createConfigDetector, createBuildDirDetector, createDependencyDetector, SERVER_WRAPPER_PRESETS, extendServerWrapperPresets, createServerWrapperPreset, resolvePreset, createWebHandlerPreset, createSSRRenderPreset, createAutoDetectPreset, WEB_HANDLER_EXPORTS, SSR_RENDER_EXPORTS, } from "./factory/index.js";
|
|
11
|
+
export { isDynamicRoute, routeToRegex, addRegexToRoutes, convertRoutesToMetaFormat, parseRouteTreeContent, parseRouteTreeFile, scanRoutesDirectory, scanRoutesFromDirectories, loadServerBuildRoutes, flattenRouteTree, parseRoutesFromSources, toRouteInfo, toRouteInfoArray, } from "./route/index.js";
|
|
41
12
|
//# sourceMappingURL=index.js.map
|