@gylautorun/dev-proxy-cookie 1.0.1 → 1.0.2
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/index.d.mts +281 -68
- package/dist/index.d.ts +281 -68
- package/dist/index.js +269 -156
- package/dist/index.min.js +4 -4
- package/dist/index.min.mjs +4 -4
- package/dist/index.mjs +268 -151
- package/package.json +1 -1
- package/src/index.ts +13 -0
- package/src/proxy/apply-dev-cookie-header.ts +35 -5
- package/src/proxy/core.ts +179 -10
- package/src/proxy/index.ts +8 -3
- package/src/proxy/vite-middleware-plugin.ts +158 -0
- package/src/proxy/vue-proxy-config.ts +64 -2
- package/src/utils/cookie-reader.ts +74 -3
- package/src/utils/cookie-watcher.ts +50 -1
- package/src/utils/env-detector.ts +9 -2
- package/src/utils/index.ts +7 -0
- package/src/proxy/vite-adapter.ts +0 -98
- package/src/proxy/vite-cookie-plugin.ts +0 -94
- package/src/proxy/vite-plugin.ts +0 -66
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import * as net from 'net';
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
-
import { ViteDevServer
|
|
3
|
+
import { ViteDevServer } from 'vite';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 错误回调函数类型
|
|
7
|
+
* @param err - 错误对象
|
|
8
|
+
* @param req - 请求对象
|
|
9
|
+
* @param res - 响应对象或 Socket
|
|
10
|
+
*/
|
|
5
11
|
type ErrorCallback = (err: Error, req: IncomingMessage, res: ServerResponse | net.Socket) => void;
|
|
6
12
|
interface ProxyHooks {
|
|
7
13
|
onProxyReq?: (proxyReq: any, req: IncomingMessage, res: ServerResponse) => void;
|
|
@@ -16,6 +22,12 @@ interface AutoProxyCookieOptions {
|
|
|
16
22
|
autoRestart?: boolean;
|
|
17
23
|
restartMarkerFile?: string;
|
|
18
24
|
proxyMap?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* 需要代理的路径前缀列表(默认代理到 target)
|
|
27
|
+
* 例如: ['/api', '/digital-platform']
|
|
28
|
+
* 如果请求路径匹配这些前缀之一,将被代理到 target
|
|
29
|
+
*/
|
|
30
|
+
proxyPaths?: string[];
|
|
19
31
|
ignorePaths?: string[];
|
|
20
32
|
ws?: boolean;
|
|
21
33
|
changeOrigin?: boolean;
|
|
@@ -34,6 +46,15 @@ interface AutoProxyCookieOptions {
|
|
|
34
46
|
[header: string]: string;
|
|
35
47
|
};
|
|
36
48
|
hooks?: ProxyHooks;
|
|
49
|
+
/**
|
|
50
|
+
* 是否启用文件监听
|
|
51
|
+
* - 'auto': 自动(如果 isDev 为 true,则启用监听)
|
|
52
|
+
* - true: 强制启用监听
|
|
53
|
+
* - false: 禁用监听
|
|
54
|
+
*
|
|
55
|
+
* 默认值: 'auto'
|
|
56
|
+
*/
|
|
57
|
+
watch?: 'auto' | boolean;
|
|
37
58
|
/**
|
|
38
59
|
* 是否为开发环境(优先级最高)
|
|
39
60
|
* 设置此参数后,将直接决定是否启用文件监听:
|
|
@@ -44,67 +65,154 @@ interface AutoProxyCookieOptions {
|
|
|
44
65
|
*/
|
|
45
66
|
isDev?: boolean;
|
|
46
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* 自动代理 Cookie 类
|
|
70
|
+
*
|
|
71
|
+
* 提供完整的开发环境代理解决方案,支持 HTTP 和 WebSocket 代理,
|
|
72
|
+
* 自动从文件读取 Cookie 并注入到代理请求中。
|
|
73
|
+
*/
|
|
47
74
|
declare class AutoProxyCookie {
|
|
75
|
+
/** 合并后的配置选项 */
|
|
48
76
|
private options;
|
|
77
|
+
/** 当前 Cookie 值 */
|
|
49
78
|
private currentCookie;
|
|
79
|
+
/** Vite 开发服务器实例 */
|
|
50
80
|
private server;
|
|
81
|
+
/** HTTP 代理服务器实例 */
|
|
51
82
|
private proxyServer;
|
|
83
|
+
/** Cookie 文件监听器 */
|
|
52
84
|
private watcher;
|
|
85
|
+
/** Cookie 文件读取器 */
|
|
53
86
|
private cookieReader;
|
|
87
|
+
/**
|
|
88
|
+
* 构造函数
|
|
89
|
+
* @param options - 配置选项
|
|
90
|
+
*/
|
|
54
91
|
constructor(options: AutoProxyCookieOptions);
|
|
92
|
+
/**
|
|
93
|
+
* Cookie 变化处理函数
|
|
94
|
+
* @param newCookie - 新的 Cookie 值
|
|
95
|
+
*/
|
|
55
96
|
private handleCookieChange;
|
|
97
|
+
/**
|
|
98
|
+
* 根据请求路径获取代理目标 URL
|
|
99
|
+
* @param req - HTTP 请求对象
|
|
100
|
+
* @returns 代理目标 URL
|
|
101
|
+
*/
|
|
56
102
|
private getProxyUrl;
|
|
103
|
+
/**
|
|
104
|
+
* 判断路径是否应该被忽略(不代理)
|
|
105
|
+
* @param pathname - 请求路径
|
|
106
|
+
* @returns 是否忽略
|
|
107
|
+
*/
|
|
57
108
|
private isIgnoredPath;
|
|
109
|
+
/**
|
|
110
|
+
* 日志输出函数
|
|
111
|
+
* @param level - 日志级别
|
|
112
|
+
* @param args - 日志参数
|
|
113
|
+
*/
|
|
58
114
|
private log;
|
|
115
|
+
/**
|
|
116
|
+
* 创建代理服务器配置选项
|
|
117
|
+
* @param target - 代理目标地址
|
|
118
|
+
* @returns 代理服务器配置
|
|
119
|
+
*/
|
|
59
120
|
private createProxyOptions;
|
|
121
|
+
/**
|
|
122
|
+
* 代理请求处理函数
|
|
123
|
+
* @param proxyReq - 代理请求对象
|
|
124
|
+
* @param req - 原始请求对象
|
|
125
|
+
* @param res - 响应对象
|
|
126
|
+
* @param _options - 服务器选项
|
|
127
|
+
*/
|
|
60
128
|
private handleOnProxyReq;
|
|
129
|
+
/**
|
|
130
|
+
* 代理响应处理函数
|
|
131
|
+
* @param proxyRes - 代理响应对象
|
|
132
|
+
* @param req - 原始请求对象
|
|
133
|
+
* @param res - 响应对象
|
|
134
|
+
*/
|
|
61
135
|
private handleOnProxyRes;
|
|
136
|
+
/**
|
|
137
|
+
* HTTP 代理错误处理函数
|
|
138
|
+
* @param err - 错误对象
|
|
139
|
+
* @param req - 请求对象
|
|
140
|
+
* @param res - 响应对象或 Socket
|
|
141
|
+
*/
|
|
62
142
|
private handleOnError;
|
|
143
|
+
/**
|
|
144
|
+
* WebSocket 代理错误处理函数
|
|
145
|
+
* @param err - 错误对象
|
|
146
|
+
* @param req - 请求对象
|
|
147
|
+
* @param socket - WebSocket 连接的 Socket
|
|
148
|
+
*/
|
|
63
149
|
private handleOnWsError;
|
|
150
|
+
/**
|
|
151
|
+
* 初始化代理中间件
|
|
152
|
+
* @param server - Vite 开发服务器实例
|
|
153
|
+
*/
|
|
64
154
|
setup(server: ViteDevServer): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* 启动 Cookie 文件监听
|
|
157
|
+
*/
|
|
65
158
|
private startFileWatch;
|
|
159
|
+
/**
|
|
160
|
+
* 停止代理服务
|
|
161
|
+
*/
|
|
66
162
|
stop(): void;
|
|
67
|
-
getCurrentCookie(): string;
|
|
68
|
-
}
|
|
69
|
-
declare function createAutoProxyCookie(options: AutoProxyCookieOptions): AutoProxyCookie;
|
|
70
|
-
|
|
71
|
-
interface ViteAutoProxyCookiePluginOptions extends AutoProxyCookieOptions {
|
|
72
|
-
name?: string;
|
|
73
163
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* - true: 启用监听(开发模式)
|
|
77
|
-
* - false: 禁用监听(生产模式)
|
|
78
|
-
*
|
|
79
|
-
* 使用示例: isDev: process.env.NODE_ENV === 'development'
|
|
164
|
+
* 获取当前 Cookie 值
|
|
165
|
+
* @returns 当前 Cookie 字符串
|
|
80
166
|
*/
|
|
81
|
-
|
|
167
|
+
getCurrentCookie(): string;
|
|
82
168
|
}
|
|
83
|
-
|
|
169
|
+
/**
|
|
170
|
+
* 创建 AutoProxyCookie 实例
|
|
171
|
+
* @param options - 配置选项
|
|
172
|
+
* @returns AutoProxyCookie 实例
|
|
173
|
+
*/
|
|
174
|
+
declare function createAutoProxyCookie(options: AutoProxyCookieOptions): AutoProxyCookie;
|
|
84
175
|
|
|
85
|
-
|
|
176
|
+
/**
|
|
177
|
+
* Vite 中间件代理 Cookie 插件配置选项
|
|
178
|
+
*/
|
|
179
|
+
interface ViteMiddlewareProxyOptions {
|
|
180
|
+
/** Cookie 文件路径 */
|
|
86
181
|
cookieFile: string;
|
|
182
|
+
/** 默认代理目标地址 */
|
|
183
|
+
target: string;
|
|
184
|
+
/** 是否启用调试日志 */
|
|
87
185
|
debug?: boolean;
|
|
88
|
-
onCookieChange?: (cookie: string) => void;
|
|
89
186
|
/**
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* - false: 从不监听
|
|
93
|
-
* - 'auto': 根据环境自动判断(默认)
|
|
94
|
-
* @default 'auto'
|
|
187
|
+
* 代理路径映射表
|
|
188
|
+
* 键:路径前缀,值:代理目标地址
|
|
95
189
|
*/
|
|
96
|
-
|
|
190
|
+
proxyMap?: Record<string, string>;
|
|
97
191
|
/**
|
|
98
|
-
*
|
|
99
|
-
* 设置此参数后,将直接决定是否启用文件监听:
|
|
100
|
-
* - true: 启用监听(开发模式)
|
|
101
|
-
* - false: 禁用监听(生产模式)
|
|
102
|
-
*
|
|
103
|
-
* 使用示例: isDev: process.env.NODE_ENV === 'development'
|
|
192
|
+
* 需要代理的路径前缀列表(使用默认 target)
|
|
104
193
|
*/
|
|
105
|
-
|
|
194
|
+
proxyPaths?: string[];
|
|
195
|
+
/**
|
|
196
|
+
* 需要忽略的路径前缀列表(不代理)
|
|
197
|
+
*/
|
|
198
|
+
ignorePaths?: string[];
|
|
106
199
|
}
|
|
107
|
-
|
|
200
|
+
/**
|
|
201
|
+
* 创建 Vite 中间件代理 Cookie 插件
|
|
202
|
+
*
|
|
203
|
+
* @param options - 插件配置选项
|
|
204
|
+
* @returns Vite 插件对象
|
|
205
|
+
*/
|
|
206
|
+
declare function viteMiddlewareProxy(options: ViteMiddlewareProxyOptions): any;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Vue CLI 代理配置模块
|
|
210
|
+
*
|
|
211
|
+
* 提供 Vue CLI 开发服务器的代理配置功能,支持从文件读取 Cookie 并注入代理请求。
|
|
212
|
+
* 核心函数包括 createFileCookieGetter 和 createVueProxyConfig。
|
|
213
|
+
*
|
|
214
|
+
* @module vue-proxy-config
|
|
215
|
+
*/
|
|
108
216
|
|
|
109
217
|
/** Options for {@link createFileCookieGetter}. */
|
|
110
218
|
interface CreateFileCookieGetterOptions {
|
|
@@ -136,105 +244,210 @@ interface CreateFileCookieGetterOptions {
|
|
|
136
244
|
*/
|
|
137
245
|
isDev?: boolean;
|
|
138
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Vue 代理配置选项
|
|
249
|
+
*/
|
|
139
250
|
interface VueProxyConfigOptions {
|
|
251
|
+
/** Cookie 获取函数 */
|
|
140
252
|
getCookie?: () => string;
|
|
253
|
+
/** 是否输出调试日志 */
|
|
141
254
|
debug?: boolean;
|
|
255
|
+
/** 自定义请求头 */
|
|
142
256
|
headers?: Record<string, string>;
|
|
257
|
+
/** 是否启用 WebSocket 代理 */
|
|
143
258
|
ws?: boolean;
|
|
259
|
+
/** 是否修改请求头中的 Origin */
|
|
144
260
|
changeOrigin?: boolean;
|
|
261
|
+
/** 是否验证 SSL 证书 */
|
|
145
262
|
secure?: boolean;
|
|
263
|
+
/** 错误回调函数 */
|
|
146
264
|
onError?: (err: Error) => void;
|
|
147
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Vue CLI 代理配置接口
|
|
268
|
+
*
|
|
269
|
+
* 符合 Vue CLI 代理配置格式的对象结构
|
|
270
|
+
*/
|
|
148
271
|
interface ProxyConfig {
|
|
272
|
+
/** 是否启用 WebSocket 代理 */
|
|
149
273
|
ws: boolean;
|
|
274
|
+
/** 代理目标地址 */
|
|
150
275
|
target: string;
|
|
276
|
+
/** 是否修改请求头中的 Origin */
|
|
151
277
|
changeOrigin: boolean;
|
|
278
|
+
/** 是否验证 SSL 证书 */
|
|
152
279
|
secure: boolean;
|
|
280
|
+
/** 代理请求前的回调函数 */
|
|
153
281
|
onProxyReq: (proxyReq: any, req: IncomingMessage) => void;
|
|
282
|
+
/** 代理响应后的回调函数(可选) */
|
|
154
283
|
onProxyRes?: (proxyRes: any, req: IncomingMessage) => void;
|
|
284
|
+
/** 错误处理回调函数 */
|
|
155
285
|
onError: (err: Error) => void;
|
|
286
|
+
/** 自定义请求头 */
|
|
156
287
|
headers?: Record<string, string>;
|
|
157
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* 创建 Vue CLI 代理配置
|
|
291
|
+
*
|
|
292
|
+
* @param target - 代理目标地址
|
|
293
|
+
* @param options - 配置选项
|
|
294
|
+
* @returns Vue CLI 代理配置对象
|
|
295
|
+
*/
|
|
158
296
|
declare function createVueProxyConfig(target: string, options?: VueProxyConfigOptions): ProxyConfig;
|
|
297
|
+
/**
|
|
298
|
+
* 创建文件 Cookie 获取器
|
|
299
|
+
*
|
|
300
|
+
* 从指定文件读取 Cookie 值,支持文件监听功能。
|
|
301
|
+
*
|
|
302
|
+
* @param cookieFile - Cookie 文件路径
|
|
303
|
+
* @param options - 配置选项
|
|
304
|
+
* @returns Cookie 获取函数
|
|
305
|
+
*/
|
|
159
306
|
declare function createFileCookieGetter(cookieFile: string, options?: CreateFileCookieGetterOptions): () => string;
|
|
307
|
+
/**
|
|
308
|
+
* 自动代理配置选项
|
|
309
|
+
*/
|
|
160
310
|
interface AutoProxyConfigOptions extends VueProxyConfigOptions {
|
|
311
|
+
/** 代理目标地址 */
|
|
161
312
|
target: string;
|
|
313
|
+
/** 忽略的路径列表(不代理这些路径) */
|
|
162
314
|
ignorePaths?: string[];
|
|
315
|
+
/** 包含的路径列表(只代理这些路径) */
|
|
163
316
|
includePaths?: string[];
|
|
317
|
+
/** 额外的代理配置 */
|
|
164
318
|
additionalProxies?: Record<string, string>;
|
|
165
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* 创建自动代理配置
|
|
322
|
+
*
|
|
323
|
+
* 根据配置自动生成 Vue CLI 代理配置对象,支持忽略路径和包含路径两种模式。
|
|
324
|
+
*
|
|
325
|
+
* @param options - 配置选项
|
|
326
|
+
* @returns Vue CLI 代理配置对象映射
|
|
327
|
+
*/
|
|
166
328
|
declare function createAutoProxyConfig(options: AutoProxyConfigOptions): Record<string, ProxyConfig>;
|
|
167
329
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
debug?: boolean;
|
|
172
|
-
autoRestart?: boolean;
|
|
173
|
-
restartMarkerFile?: string;
|
|
174
|
-
proxyMap?: Record<string, string>;
|
|
175
|
-
ignorePaths?: string[];
|
|
176
|
-
includePaths?: string[];
|
|
177
|
-
onCookieChange?: (cookie: string) => void;
|
|
178
|
-
mode?: 'auto' | 'proxy' | 'cookie';
|
|
179
|
-
/**
|
|
180
|
-
* 是否监听文件变化
|
|
181
|
-
* - true: 始终监听
|
|
182
|
-
* - false: 从不监听
|
|
183
|
-
* - 'auto': 根据环境自动判断(默认)
|
|
184
|
-
* @default 'auto'
|
|
185
|
-
*/
|
|
186
|
-
watch?: boolean | 'auto';
|
|
187
|
-
/**
|
|
188
|
-
* 是否为开发环境(优先级最高)
|
|
189
|
-
* 设置此参数后,将直接决定是否启用文件监听:
|
|
190
|
-
* - true: 启用监听(开发模式)
|
|
191
|
-
* - false: 禁用监听(生产模式)
|
|
192
|
-
*
|
|
193
|
-
* 使用示例: isDev: process.env.NODE_ENV === 'development'
|
|
194
|
-
*/
|
|
195
|
-
isDev?: boolean;
|
|
196
|
-
}
|
|
197
|
-
declare function createDevProxyCookie(options: UnifiedProxyCookieOptions): Plugin;
|
|
198
|
-
declare function getViteVersion(): string | null;
|
|
199
|
-
declare function getViteMajorVersion(): number;
|
|
200
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Cookie 读取器配置选项
|
|
332
|
+
*/
|
|
201
333
|
interface CookieReaderOptions {
|
|
202
334
|
cookieFile: string;
|
|
203
335
|
encoding?: BufferEncoding;
|
|
204
336
|
}
|
|
337
|
+
/**
|
|
338
|
+
* Cookie 文件读取器类
|
|
339
|
+
*
|
|
340
|
+
* 提供从文件读取 Cookie 的功能,支持注释过滤和自动文件创建。
|
|
341
|
+
*/
|
|
205
342
|
declare class CookieReader {
|
|
343
|
+
/** 配置选项 */
|
|
206
344
|
protected options: CookieReaderOptions;
|
|
207
|
-
|
|
345
|
+
/** 是否启用调试模式 */
|
|
346
|
+
protected debug: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* 构造函数
|
|
349
|
+
* @param options - 配置选项
|
|
350
|
+
* @param debug - 是否启用调试模式
|
|
351
|
+
*/
|
|
352
|
+
constructor(options: CookieReaderOptions, debug?: boolean);
|
|
353
|
+
/**
|
|
354
|
+
* 读取 Cookie 文件内容
|
|
355
|
+
*
|
|
356
|
+
* 支持过滤注释行(以 # 开头)和空行,将有效行用分号连接。
|
|
357
|
+
*
|
|
358
|
+
* @returns Cookie 字符串
|
|
359
|
+
*/
|
|
208
360
|
readCookie(): string;
|
|
361
|
+
/**
|
|
362
|
+
* 确保 Cookie 文件存在
|
|
363
|
+
*
|
|
364
|
+
* 如果文件不存在,会自动创建空文件。
|
|
365
|
+
* 如果父目录不存在,会自动创建目录。
|
|
366
|
+
*/
|
|
209
367
|
ensureCookieFile(): void;
|
|
210
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* 创建 Cookie 获取器函数
|
|
371
|
+
*
|
|
372
|
+
* 返回一个函数,每次调用时从文件读取最新的 Cookie 值。
|
|
373
|
+
*
|
|
374
|
+
* @param cookieFile - Cookie 文件路径
|
|
375
|
+
* @returns Cookie 获取函数
|
|
376
|
+
*/
|
|
211
377
|
declare function createCookieGetter(cookieFile: string): () => string;
|
|
212
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Cookie 监听器配置选项
|
|
381
|
+
*/
|
|
213
382
|
interface CookieWatcherOptions {
|
|
214
383
|
cookieFile: string;
|
|
215
384
|
onCookieChange: (cookie: string) => void;
|
|
216
385
|
onError?: (error: Error) => void;
|
|
217
386
|
autoCreateFile?: boolean;
|
|
218
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Cookie 文件监听器类
|
|
390
|
+
*
|
|
391
|
+
* 使用 chokidar 监听 Cookie 文件变化,当文件内容改变时触发回调。
|
|
392
|
+
* 支持自动创建文件和稳定性阈值配置。
|
|
393
|
+
*/
|
|
219
394
|
declare class CookieWatcher {
|
|
395
|
+
/** 文件监听器实例 */
|
|
220
396
|
private watcher;
|
|
397
|
+
/** 配置选项 */
|
|
221
398
|
private options;
|
|
399
|
+
/** Cookie 读取器 */
|
|
222
400
|
private cookieReader;
|
|
401
|
+
/** 上次读取的 Cookie 内容 */
|
|
223
402
|
private lastContent;
|
|
403
|
+
/**
|
|
404
|
+
* 构造函数
|
|
405
|
+
* @param options - 配置选项
|
|
406
|
+
*/
|
|
224
407
|
constructor(options: CookieWatcherOptions);
|
|
408
|
+
/**
|
|
409
|
+
* 文件变化处理函数
|
|
410
|
+
*
|
|
411
|
+
* 读取新的 Cookie 内容,如果与上次不同则触发回调。
|
|
412
|
+
*/
|
|
225
413
|
private handleChange;
|
|
414
|
+
/**
|
|
415
|
+
* 启动文件监听
|
|
416
|
+
*/
|
|
226
417
|
start(): void;
|
|
418
|
+
/**
|
|
419
|
+
* 停止文件监听
|
|
420
|
+
*/
|
|
227
421
|
stop(): void;
|
|
422
|
+
/**
|
|
423
|
+
* 获取当前 Cookie 值
|
|
424
|
+
* @returns 当前 Cookie 字符串
|
|
425
|
+
*/
|
|
228
426
|
getCurrentCookie(): string;
|
|
229
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* 创建并启动 Cookie 文件监听器
|
|
430
|
+
*
|
|
431
|
+
* @param cookieFile - Cookie 文件路径
|
|
432
|
+
* @param onCookieChange - Cookie 变化回调函数
|
|
433
|
+
* @param onError - 错误回调函数(可选)
|
|
434
|
+
* @returns CookieWatcher 实例
|
|
435
|
+
*/
|
|
230
436
|
declare function watchCookieFile(cookieFile: string, onCookieChange: (cookie: string) => void, onError?: (error: Error) => void): CookieWatcher;
|
|
231
437
|
|
|
232
438
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
439
|
+
* 环境检测工具模块
|
|
440
|
+
*
|
|
441
|
+
* 提供智能环境检测功能,用于判断当前是否为生产构建环境,
|
|
442
|
+
* 从而决定是否启用文件监听等开发环境特性。
|
|
443
|
+
*
|
|
444
|
+
* @module env-detector
|
|
235
445
|
*/
|
|
236
446
|
/**
|
|
237
447
|
* 判断环境变量值是否表示生产环境
|
|
448
|
+
*
|
|
449
|
+
* @param value - 环境变量值
|
|
450
|
+
* @returns 是否为生产环境值
|
|
238
451
|
*/
|
|
239
452
|
declare function isProductionValue(value: string): boolean;
|
|
240
453
|
/**
|
|
@@ -261,4 +474,4 @@ declare function detectProductionEnvironment(customEnvs?: string[], debug?: bool
|
|
|
261
474
|
*/
|
|
262
475
|
declare function shouldEnableWatch(watch: boolean | 'auto', customEnvs?: string[], debug?: boolean, loggerPrefix?: string): boolean;
|
|
263
476
|
|
|
264
|
-
export { type AutoProxyConfigOptions, AutoProxyCookie, type AutoProxyCookieOptions, CookieReader, type CookieReaderOptions, CookieWatcher, type CookieWatcherOptions, type CreateFileCookieGetterOptions, type ErrorCallback, type ProxyConfig, type ProxyHooks, type
|
|
477
|
+
export { type AutoProxyConfigOptions, AutoProxyCookie, type AutoProxyCookieOptions, CookieReader, type CookieReaderOptions, CookieWatcher, type CookieWatcherOptions, type CreateFileCookieGetterOptions, type ErrorCallback, type ProxyConfig, type ProxyHooks, type ViteMiddlewareProxyOptions, type VueProxyConfigOptions, createAutoProxyConfig, createAutoProxyCookie, createCookieGetter, createFileCookieGetter, createVueProxyConfig, detectProductionEnvironment, isProductionValue, shouldEnableWatch, viteMiddlewareProxy, watchCookieFile };
|