@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.
- 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.d.ts +40 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +166 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +8 -75
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -56
- 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 +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,80 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @edgeone/vite-plugin-adapter
|
|
3
|
-
*
|
|
4
|
-
* EdgeOne 平台的核心适配器插件
|
|
5
|
-
*
|
|
6
|
-
* 本包为构建框架特定适配器提供基础设施,主要功能包括:
|
|
7
|
-
* - 构建产物检测和处理
|
|
8
|
-
* - 使用 esbuild 打包服务端代码
|
|
9
|
-
* - 静态资源管理
|
|
10
|
-
* - 路由配置生成
|
|
11
|
-
* - 生成 EdgeOne 部署所需的 meta.json 配置文件
|
|
12
|
-
*
|
|
13
|
-
* 使用场景:
|
|
14
|
-
* 1. 直接使用核心适配器构建自定义适配器
|
|
15
|
-
* 2. 作为其他框架适配器(如 React Router、TanStack Start)的基础依赖
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* // 直接使用核心适配器创建自定义适配器
|
|
20
|
-
* import { createCoreAdapter } from '@edgeone/vite-plugin-adapter';
|
|
21
|
-
*
|
|
22
|
-
* export default defineConfig({
|
|
23
|
-
* plugins: [
|
|
24
|
-
* createCoreAdapter({
|
|
25
|
-
* verbose: true, // 启用详细日志
|
|
26
|
-
* hooks: {
|
|
27
|
-
* // 自定义路由生成逻辑
|
|
28
|
-
* generateRoutes: async (ctx) => [...],
|
|
29
|
-
* // 自定义服务端包装器生成逻辑
|
|
30
|
-
* generateServerWrapper: async (ctx, config) => '...',
|
|
31
|
-
* }
|
|
32
|
-
* })
|
|
33
|
-
* ]
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
3
|
+
* Core adapter plugin for EdgeOne platform
|
|
36
4
|
*/
|
|
37
5
|
export { createCoreAdapter, default } from "./core.js";
|
|
38
|
-
export { bundleServerCode,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
copyDirectory, // 递归复制目录
|
|
46
|
-
cleanDirectory, // 清理目录(删除后重建)
|
|
47
|
-
ensureDirectory, // 确保目录存在
|
|
48
|
-
readFile, // 读取文件内容
|
|
49
|
-
writeFile, // 写入文件内容
|
|
50
|
-
deleteFile, // 删除文件
|
|
51
|
-
formatSize, // 格式化文件大小
|
|
52
|
-
waitFor, // 等待条件满足(带重试)
|
|
53
|
-
listFiles, // 列出目录内容
|
|
54
|
-
countFiles, } from "./utils.js";
|
|
55
|
-
export type { RouteInfo, // 路由信息
|
|
56
|
-
MetaConfig, // 元数据配置
|
|
57
|
-
HeaderRule, // HTTP 响应头规则
|
|
58
|
-
RedirectRule, // 重定向规则
|
|
59
|
-
RewriteRule, // URL 重写规则
|
|
60
|
-
CacheRule, // 缓存规则
|
|
61
|
-
BuildContext, // 构建上下文
|
|
62
|
-
Logger, // 日志接口
|
|
63
|
-
BuildArtifacts, // 构建产物信息
|
|
64
|
-
ServerWrapperConfig, // 服务端包装器配置
|
|
65
|
-
ServerBundleConfig, // esbuild 打包配置
|
|
66
|
-
BeforeBuildHook, // 构建前钩子
|
|
67
|
-
AfterBuildHook, // 构建后钩子
|
|
68
|
-
BeforeBundleHook, // 打包前钩子
|
|
69
|
-
AfterBundleHook, // 打包后钩子
|
|
70
|
-
GenerateRoutesHook, // 路由生成钩子
|
|
71
|
-
GenerateMetaHook, // 元数据生成钩子
|
|
72
|
-
GenerateServerWrapperHook, // 服务端包装器生成钩子
|
|
73
|
-
AdapterHooks, // 适配器钩子集合
|
|
74
|
-
FrameworkAdapter, // 框架适配器接口
|
|
75
|
-
CoreAdapterOptions, // 核心适配器选项
|
|
76
|
-
ViteAdapterOptions, // Vite 适配器选项
|
|
77
|
-
ReactRouterAdapterOptions, // React Router 适配器选项
|
|
78
|
-
TanStackStartAdapterOptions, // TanStack Start 适配器选项
|
|
79
|
-
CreateAdapterPlugin, } from "./types.js";
|
|
6
|
+
export { bundleServerCode, createServerWrapper, cleanupWrapper, getBundleSize, } from "./bundler.js";
|
|
7
|
+
export { createLogger, pathExists, findExistingPath, copyDirectory, cleanDirectory, ensureDirectory, readFile, writeFile, deleteFile, formatSize, waitFor, listFiles, countFiles, } from "./utils.js";
|
|
8
|
+
export { detectConfigFile, loadConfigFile, createDefaultMeta, NODE_REQUEST_CONVERTER_CODE, generateServerWrapperCode, normalizeRoutePath, routePathToRegex, detectServerEntry, detectBuildDir, logBuildArtifacts, } from "./helpers.js";
|
|
9
|
+
export { createFrameworkAdapter, createStatefulAdapter, composeHooks, createConfigDetector, createBuildDirDetector, createDependencyDetector, combineDetectors, SERVER_WRAPPER_PRESETS, } from "./factory.js";
|
|
10
|
+
export type { RouteInfo, 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 { ServerWrapperGeneratorOptions } from "./helpers.js";
|
|
12
|
+
export type { ServerWrapperPreset, BuildDirConfig, AdapterFactoryConfig, AdapterFactoryOptions, } from "./factory.js";
|
|
80
13
|
//# 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;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGvD,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,eAAe,EACf,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,YAAY,EACZ,MAAM,EACN,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,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,cAAc,CAAC;AAElE,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,61 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @edgeone/vite-plugin-adapter
|
|
3
|
-
*
|
|
4
|
-
* EdgeOne 平台的核心适配器插件
|
|
5
|
-
*
|
|
6
|
-
* 本包为构建框架特定适配器提供基础设施,主要功能包括:
|
|
7
|
-
* - 构建产物检测和处理
|
|
8
|
-
* - 使用 esbuild 打包服务端代码
|
|
9
|
-
* - 静态资源管理
|
|
10
|
-
* - 路由配置生成
|
|
11
|
-
* - 生成 EdgeOne 部署所需的 meta.json 配置文件
|
|
12
|
-
*
|
|
13
|
-
* 使用场景:
|
|
14
|
-
* 1. 直接使用核心适配器构建自定义适配器
|
|
15
|
-
* 2. 作为其他框架适配器(如 React Router、TanStack Start)的基础依赖
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* // 直接使用核心适配器创建自定义适配器
|
|
20
|
-
* import { createCoreAdapter } from '@edgeone/vite-plugin-adapter';
|
|
21
|
-
*
|
|
22
|
-
* export default defineConfig({
|
|
23
|
-
* plugins: [
|
|
24
|
-
* createCoreAdapter({
|
|
25
|
-
* verbose: true, // 启用详细日志
|
|
26
|
-
* hooks: {
|
|
27
|
-
* // 自定义路由生成逻辑
|
|
28
|
-
* generateRoutes: async (ctx) => [...],
|
|
29
|
-
* // 自定义服务端包装器生成逻辑
|
|
30
|
-
* generateServerWrapper: async (ctx, config) => '...',
|
|
31
|
-
* }
|
|
32
|
-
* })
|
|
33
|
-
* ]
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
3
|
+
* Core adapter plugin for EdgeOne platform
|
|
36
4
|
*/
|
|
37
|
-
//
|
|
38
|
-
// createCoreAdapter: 创建核心适配器插件的工厂函数
|
|
5
|
+
// Core
|
|
39
6
|
export { createCoreAdapter, default } from "./core.js";
|
|
40
|
-
//
|
|
41
|
-
export { bundleServerCode,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
} from "./
|
|
46
|
-
//
|
|
47
|
-
export {
|
|
48
|
-
pathExists, // 检查路径是否存在
|
|
49
|
-
findExistingPath, // 从候选列表中找到第一个存在的路径
|
|
50
|
-
copyDirectory, // 递归复制目录
|
|
51
|
-
cleanDirectory, // 清理目录(删除后重建)
|
|
52
|
-
ensureDirectory, // 确保目录存在
|
|
53
|
-
readFile, // 读取文件内容
|
|
54
|
-
writeFile, // 写入文件内容
|
|
55
|
-
deleteFile, // 删除文件
|
|
56
|
-
formatSize, // 格式化文件大小
|
|
57
|
-
waitFor, // 等待条件满足(带重试)
|
|
58
|
-
listFiles, // 列出目录内容
|
|
59
|
-
countFiles, // 递归统计文件数量
|
|
60
|
-
} from "./utils.js";
|
|
7
|
+
// Bundler
|
|
8
|
+
export { bundleServerCode, createServerWrapper, cleanupWrapper, getBundleSize, } from "./bundler.js";
|
|
9
|
+
// Utils
|
|
10
|
+
export { createLogger, pathExists, findExistingPath, copyDirectory, cleanDirectory, ensureDirectory, readFile, writeFile, deleteFile, formatSize, waitFor, listFiles, countFiles, } from "./utils.js";
|
|
11
|
+
// Helpers
|
|
12
|
+
export { detectConfigFile, loadConfigFile, createDefaultMeta, NODE_REQUEST_CONVERTER_CODE, generateServerWrapperCode, normalizeRoutePath, routePathToRegex, detectServerEntry, detectBuildDir, logBuildArtifacts, } from "./helpers.js";
|
|
13
|
+
// Factory
|
|
14
|
+
export { createFrameworkAdapter, createStatefulAdapter, composeHooks, createConfigDetector, createBuildDirDetector, createDependencyDetector, combineDetectors, SERVER_WRAPPER_PRESETS, } from "./factory.js";
|
|
61
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO;AACP,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEvD,UAAU;AACV,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AAEtB,QAAQ;AACR,OAAO,EACL,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,eAAe,EACf,QAAQ,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,OAAO,EACP,SAAS,EACT,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,UAAU;AACV,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,2BAA2B,EAC3B,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,UAAU;AACV,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
|
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;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,
|
|
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;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,mFAAmF;IACnF,QAAQ,EAAE,OAAO,CAAC;IAClB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,2BAA2B;IAC3B,IAAI,EAAE;QACJ,sCAAsC;QACtC,OAAO,EAAE,UAAU,EAAE,CAAC;QACtB,0BAA0B;QAC1B,SAAS,EAAE,YAAY,EAAE,CAAC;QAC1B,6BAA6B;QAC7B,QAAQ,EAAE,WAAW,EAAE,CAAC;QACxB,uBAAuB;QACvB,MAAM,EAAE,SAAS,EAAE,CAAC;QACpB,uCAAuC;QACvC,MAAM,EAAE,OAAO,CAAC;QAChB,0CAA0C;QAC1C,MAAM,EAAE,OAAO,C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AAM,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
|