@meng-xi/vite-plugin 0.0.4 → 0.0.6
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/README-en.md +249 -70
- package/README.md +343 -143
- package/dist/common/index.cjs +1 -1
- package/dist/common/index.d.cts +84 -1
- package/dist/common/index.d.mts +84 -1
- package/dist/common/index.d.ts +84 -1
- package/dist/common/index.mjs +1 -1
- package/dist/factory/index.cjs +1 -1
- package/dist/factory/index.d.cts +71 -6
- package/dist/factory/index.d.mts +71 -6
- package/dist/factory/index.d.ts +71 -6
- package/dist/factory/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -5
- package/dist/index.d.mts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.mjs +1 -1
- package/dist/logger/index.cjs +1 -1
- package/dist/logger/index.d.cts +1 -1
- package/dist/logger/index.d.mts +1 -1
- package/dist/logger/index.d.ts +1 -1
- package/dist/logger/index.mjs +1 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +213 -8
- package/dist/plugins/index.d.mts +213 -8
- package/dist/plugins/index.d.ts +213 -8
- package/dist/plugins/index.mjs +1 -1
- package/dist/shared/vite-plugin.B5wW4CiL.mjs +36 -0
- package/dist/shared/vite-plugin.Ba9646wL.cjs +1 -0
- package/dist/shared/vite-plugin.C3ejdBNf.mjs +1 -0
- package/dist/shared/{vite-plugin.B3PARlU9.d.cts → vite-plugin.CLr0ttuO.d.cts} +16 -0
- package/dist/shared/{vite-plugin.B3PARlU9.d.mts → vite-plugin.CLr0ttuO.d.mts} +16 -0
- package/dist/shared/{vite-plugin.B3PARlU9.d.ts → vite-plugin.CLr0ttuO.d.ts} +16 -0
- package/dist/shared/vite-plugin.CXlzkIgT.cjs +36 -0
- package/dist/shared/vite-plugin.CawoITTT.cjs +1 -0
- package/dist/shared/vite-plugin.DSb6XzBn.mjs +1 -0
- package/package.json +72 -72
- package/dist/shared/vite-plugin.C7isVPKg.mjs +0 -1
- package/dist/shared/vite-plugin.D6NYITpX.cjs +0 -1
- package/dist/shared/vite-plugin.D8HTI0Ni.cjs +0 -2
- package/dist/shared/vite-plugin.Dd2ogbSe.mjs +0 -2
- package/dist/shared/vite-plugin.DqWt65U-.cjs +0 -1
- package/dist/shared/vite-plugin.HZb-1B5l.mjs +0 -1
- package/dist/shared/vite-plugin.UkE7CdSe.d.cts +0 -43
- package/dist/shared/vite-plugin.UkE7CdSe.d.mts +0 -43
- package/dist/shared/vite-plugin.UkE7CdSe.d.ts +0 -43
package/dist/common/index.d.mts
CHANGED
|
@@ -84,6 +84,38 @@ declare function readDirRecursive(dirPath: string, recursive: boolean): Promise<
|
|
|
84
84
|
* @returns 是否需要更新
|
|
85
85
|
*/
|
|
86
86
|
declare function shouldUpdateFile(sourceFile: string, targetFile: string): Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* 检查文件是否存在
|
|
89
|
+
* @param filePath 文件路径
|
|
90
|
+
* @returns 是否存在
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* if (await fileExists('/path/to/file')) {
|
|
95
|
+
* console.log('文件存在')
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare function fileExists(filePath: string): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* 带并发限制的批量执行
|
|
102
|
+
*
|
|
103
|
+
* @param items 待处理项
|
|
104
|
+
* @param handler 处理函数
|
|
105
|
+
* @param concurrency 并发数
|
|
106
|
+
* @returns 处理结果数组,顺序与输入项对应
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5']
|
|
111
|
+
* const results = await runWithConcurrency(
|
|
112
|
+
* urls,
|
|
113
|
+
* async (url) => fetch(url),
|
|
114
|
+
* 3 // 最多同时处理3个请求
|
|
115
|
+
* )
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare function runWithConcurrency<T, R>(items: T[], handler: (item: T) => Promise<R>, concurrency: number): Promise<R[]>;
|
|
87
119
|
/**
|
|
88
120
|
* 执行文件复制操作(优化版:并行IO)
|
|
89
121
|
* @param sourcePath 源文件或目录路径
|
|
@@ -100,11 +132,19 @@ declare function copySourceToTarget(sourcePath: string, targetPath: string, opti
|
|
|
100
132
|
* @throws 当写入过程中出现错误时抛出异常
|
|
101
133
|
*/
|
|
102
134
|
declare function writeFileContent(filePath: string, content: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* 读取文件内容
|
|
137
|
+
* @param filePath 文件路径
|
|
138
|
+
* @returns 文件内容字符串
|
|
139
|
+
* @throws 当读取过程中出现错误时抛出异常
|
|
140
|
+
*/
|
|
141
|
+
declare function readFileContent(filePath: string): Promise<string>;
|
|
103
142
|
/**
|
|
104
143
|
* 同步读取文件内容
|
|
105
144
|
* @param filePath 文件路径
|
|
106
145
|
* @returns 文件内容字符串
|
|
107
146
|
* @throws 当读取过程中出现错误时抛出异常
|
|
147
|
+
* @deprecated 请使用异步版本 readFileContent
|
|
108
148
|
*/
|
|
109
149
|
declare function readFileSync(filePath: string): string;
|
|
110
150
|
|
|
@@ -201,6 +241,49 @@ declare function formatDate(date: Date, format: string): string;
|
|
|
201
241
|
* ```
|
|
202
242
|
*/
|
|
203
243
|
declare function parseTemplate(template: string, values: Record<string, string>): string;
|
|
244
|
+
/**
|
|
245
|
+
* 将字符串转换为驼峰命名(camelCase)
|
|
246
|
+
*
|
|
247
|
+
* @param str 输入字符串
|
|
248
|
+
* @param separators 分隔符正则,默认为斜杠和横线
|
|
249
|
+
* @returns 驼峰命名字符串
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* toCamelCase('pages/user/profile') // 'pagesUserProfile'
|
|
254
|
+
* toCamelCase('user-profile-page') // 'userProfilePage'
|
|
255
|
+
* toCamelCase('/pages/index') // 'pagesIndex'
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare function toCamelCase(str: string, separators?: RegExp): string;
|
|
259
|
+
/**
|
|
260
|
+
* 将字符串转换为帕斯卡命名(PascalCase)
|
|
261
|
+
*
|
|
262
|
+
* @param str 输入字符串
|
|
263
|
+
* @param separators 分隔符正则,默认为斜杠和横线
|
|
264
|
+
* @returns 帕斯卡命名字符串
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* toPascalCase('pages/user/profile') // 'PagesUserProfile'
|
|
269
|
+
* toPascalCase('user-profile-page') // 'UserProfilePage'
|
|
270
|
+
* toPascalCase('/pages/index') // 'PagesIndex'
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
declare function toPascalCase(str: string, separators?: RegExp): string;
|
|
274
|
+
/**
|
|
275
|
+
* 移除 JSON 字符串中的注释
|
|
276
|
+
*
|
|
277
|
+
* @param jsonString 包含注释的 JSON 字符串
|
|
278
|
+
* @returns 移除注释后的 JSON 字符串
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* stripJsonComments('{\n // comment\n "name": "test"\n}')
|
|
283
|
+
* // '{\n "name": "test"\n}'
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
declare function stripJsonComments(jsonString: string): string;
|
|
204
287
|
|
|
205
288
|
/**
|
|
206
289
|
* 深度合并对象
|
|
@@ -231,5 +314,5 @@ declare function parseTemplate(template: string, values: Record<string, string>)
|
|
|
231
314
|
*/
|
|
232
315
|
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
233
316
|
|
|
234
|
-
export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileSync, shouldUpdateFile, writeFileContent };
|
|
317
|
+
export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, writeFileContent };
|
|
235
318
|
export type { DateFormatOptions };
|
package/dist/common/index.d.ts
CHANGED
|
@@ -84,6 +84,38 @@ declare function readDirRecursive(dirPath: string, recursive: boolean): Promise<
|
|
|
84
84
|
* @returns 是否需要更新
|
|
85
85
|
*/
|
|
86
86
|
declare function shouldUpdateFile(sourceFile: string, targetFile: string): Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* 检查文件是否存在
|
|
89
|
+
* @param filePath 文件路径
|
|
90
|
+
* @returns 是否存在
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* if (await fileExists('/path/to/file')) {
|
|
95
|
+
* console.log('文件存在')
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
declare function fileExists(filePath: string): Promise<boolean>;
|
|
100
|
+
/**
|
|
101
|
+
* 带并发限制的批量执行
|
|
102
|
+
*
|
|
103
|
+
* @param items 待处理项
|
|
104
|
+
* @param handler 处理函数
|
|
105
|
+
* @param concurrency 并发数
|
|
106
|
+
* @returns 处理结果数组,顺序与输入项对应
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const urls = ['url1', 'url2', 'url3', 'url4', 'url5']
|
|
111
|
+
* const results = await runWithConcurrency(
|
|
112
|
+
* urls,
|
|
113
|
+
* async (url) => fetch(url),
|
|
114
|
+
* 3 // 最多同时处理3个请求
|
|
115
|
+
* )
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare function runWithConcurrency<T, R>(items: T[], handler: (item: T) => Promise<R>, concurrency: number): Promise<R[]>;
|
|
87
119
|
/**
|
|
88
120
|
* 执行文件复制操作(优化版:并行IO)
|
|
89
121
|
* @param sourcePath 源文件或目录路径
|
|
@@ -100,11 +132,19 @@ declare function copySourceToTarget(sourcePath: string, targetPath: string, opti
|
|
|
100
132
|
* @throws 当写入过程中出现错误时抛出异常
|
|
101
133
|
*/
|
|
102
134
|
declare function writeFileContent(filePath: string, content: string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* 读取文件内容
|
|
137
|
+
* @param filePath 文件路径
|
|
138
|
+
* @returns 文件内容字符串
|
|
139
|
+
* @throws 当读取过程中出现错误时抛出异常
|
|
140
|
+
*/
|
|
141
|
+
declare function readFileContent(filePath: string): Promise<string>;
|
|
103
142
|
/**
|
|
104
143
|
* 同步读取文件内容
|
|
105
144
|
* @param filePath 文件路径
|
|
106
145
|
* @returns 文件内容字符串
|
|
107
146
|
* @throws 当读取过程中出现错误时抛出异常
|
|
147
|
+
* @deprecated 请使用异步版本 readFileContent
|
|
108
148
|
*/
|
|
109
149
|
declare function readFileSync(filePath: string): string;
|
|
110
150
|
|
|
@@ -201,6 +241,49 @@ declare function formatDate(date: Date, format: string): string;
|
|
|
201
241
|
* ```
|
|
202
242
|
*/
|
|
203
243
|
declare function parseTemplate(template: string, values: Record<string, string>): string;
|
|
244
|
+
/**
|
|
245
|
+
* 将字符串转换为驼峰命名(camelCase)
|
|
246
|
+
*
|
|
247
|
+
* @param str 输入字符串
|
|
248
|
+
* @param separators 分隔符正则,默认为斜杠和横线
|
|
249
|
+
* @returns 驼峰命名字符串
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* toCamelCase('pages/user/profile') // 'pagesUserProfile'
|
|
254
|
+
* toCamelCase('user-profile-page') // 'userProfilePage'
|
|
255
|
+
* toCamelCase('/pages/index') // 'pagesIndex'
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare function toCamelCase(str: string, separators?: RegExp): string;
|
|
259
|
+
/**
|
|
260
|
+
* 将字符串转换为帕斯卡命名(PascalCase)
|
|
261
|
+
*
|
|
262
|
+
* @param str 输入字符串
|
|
263
|
+
* @param separators 分隔符正则,默认为斜杠和横线
|
|
264
|
+
* @returns 帕斯卡命名字符串
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* ```typescript
|
|
268
|
+
* toPascalCase('pages/user/profile') // 'PagesUserProfile'
|
|
269
|
+
* toPascalCase('user-profile-page') // 'UserProfilePage'
|
|
270
|
+
* toPascalCase('/pages/index') // 'PagesIndex'
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
declare function toPascalCase(str: string, separators?: RegExp): string;
|
|
274
|
+
/**
|
|
275
|
+
* 移除 JSON 字符串中的注释
|
|
276
|
+
*
|
|
277
|
+
* @param jsonString 包含注释的 JSON 字符串
|
|
278
|
+
* @returns 移除注释后的 JSON 字符串
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* stripJsonComments('{\n // comment\n "name": "test"\n}')
|
|
283
|
+
* // '{\n "name": "test"\n}'
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
declare function stripJsonComments(jsonString: string): string;
|
|
204
287
|
|
|
205
288
|
/**
|
|
206
289
|
* 深度合并对象
|
|
@@ -231,5 +314,5 @@ declare function parseTemplate(template: string, values: Record<string, string>)
|
|
|
231
314
|
*/
|
|
232
315
|
declare function deepMerge<T extends Record<string, any>>(...sources: Partial<T>[]): T;
|
|
233
316
|
|
|
234
|
-
export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileSync, shouldUpdateFile, writeFileContent };
|
|
317
|
+
export { checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, writeFileContent };
|
|
235
318
|
export type { DateFormatOptions };
|
package/dist/common/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as checkSourceExists,a as copySourceToTarget,e as ensureTargetDir,f as formatDate,g as generateRandomHash,
|
|
1
|
+
export{c as checkSourceExists,a as copySourceToTarget,e as ensureTargetDir,f as fileExists,b as formatDate,g as generateRandomHash,d as getDateFormatParams,p as padNumber,h as parseTemplate,r as readDirRecursive,i as readFileContent,j as readFileSync,k as runWithConcurrency,s as shouldUpdateFile,l as stripJsonComments,t as toCamelCase,m as toPascalCase,w as writeFileContent}from"../shared/vite-plugin.C3ejdBNf.mjs";export{V as Validator,d as deepMerge}from"../shared/vite-plugin.B88RyRN8.mjs";import"fs";import"path";import"crypto";
|
package/dist/factory/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const index=require("../shared/vite-plugin.
|
|
1
|
+
"use strict";const index=require("../shared/vite-plugin.CawoITTT.cjs");require("../logger/index.cjs"),require("fs"),require("path"),require("crypto"),require("../shared/vite-plugin.IGZeStMa.cjs"),exports.BasePlugin=index.BasePlugin,exports.createPluginFactory=index.createPluginFactory;
|
package/dist/factory/index.d.cts
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.B3PARlU9.cjs';
|
|
1
|
+
import { Plugin, ResolvedConfig } from 'vite';
|
|
2
|
+
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.CLr0ttuO.cjs';
|
|
4
3
|
import { V as Validator } from '../shared/vite-plugin.CiHfwMiN.cjs';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 带插件实例引用的 Vite 插件类型
|
|
7
|
+
*
|
|
8
|
+
* @template T 插件配置类型
|
|
9
|
+
*/
|
|
10
|
+
interface PluginWithInstance<T extends BasePluginOptions = BasePluginOptions> extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* 原始插件实例的引用,方便外部访问插件内部状态
|
|
13
|
+
*/
|
|
14
|
+
pluginInstance?: BasePlugin<T>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 基础插件配置
|
|
18
|
+
*
|
|
19
|
+
* @interface BasePluginOptions
|
|
20
|
+
*/
|
|
21
|
+
interface BasePluginOptions {
|
|
22
|
+
/**
|
|
23
|
+
* 是否启用插件
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 是否启用日志
|
|
30
|
+
*
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
verbose?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 错误处理策略
|
|
36
|
+
*
|
|
37
|
+
* @default 'throw'
|
|
38
|
+
*/
|
|
39
|
+
errorStrategy?: 'throw' | 'log' | 'ignore';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 插件选项标准化器类型
|
|
43
|
+
*
|
|
44
|
+
* @template T 目标选项类型
|
|
45
|
+
* @template R 原始选项类型
|
|
46
|
+
*/
|
|
47
|
+
type OptionsNormalizer<T, R = any> = (raw?: R) => T;
|
|
48
|
+
/**
|
|
49
|
+
* 插件工厂函数类型
|
|
50
|
+
*
|
|
51
|
+
* @template T 插件配置类型,默认继承自 BasePluginOptions
|
|
52
|
+
* @template R 原始配置类型,默认与 T 相同
|
|
53
|
+
*/
|
|
54
|
+
type PluginFactory<T extends BasePluginOptions = BasePluginOptions, R = T> = (options?: R) => PluginWithInstance<T>;
|
|
55
|
+
|
|
6
56
|
/**
|
|
7
57
|
* 基础插件抽象类,提供插件开发的核心功能和生命周期管理
|
|
8
58
|
*
|
|
@@ -66,11 +116,10 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
66
116
|
* 获取插件的默认配置选项
|
|
67
117
|
*
|
|
68
118
|
* @protected
|
|
69
|
-
* @abstract
|
|
70
119
|
* @returns {Partial<T>} 插件特定的默认配置
|
|
71
|
-
* @description
|
|
120
|
+
* @description 子类可以重写此方法,以提供插件特定的默认配置值。默认返回空对象
|
|
72
121
|
*/
|
|
73
|
-
protected
|
|
122
|
+
protected getDefaultOptions(): Partial<T>;
|
|
74
123
|
/**
|
|
75
124
|
* 合并插件配置,将用户提供的配置与默认配置合并
|
|
76
125
|
*
|
|
@@ -142,6 +191,21 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
142
191
|
* @description 处理 Vite 配置解析完成事件,将解析后的配置存储到插件实例中
|
|
143
192
|
*/
|
|
144
193
|
protected onConfigResolved(config: ResolvedConfig): void;
|
|
194
|
+
/**
|
|
195
|
+
* 插件销毁生命周期
|
|
196
|
+
*
|
|
197
|
+
* @protected
|
|
198
|
+
* @virtual
|
|
199
|
+
* @description 插件销毁时调用的清理方法。基类会注销日志配置,子类可重写此方法添加自定义清理逻辑
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* protected destroy(): void {
|
|
203
|
+
* super.destroy()
|
|
204
|
+
* this.stopWatching()
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
protected destroy(): void;
|
|
145
209
|
/**
|
|
146
210
|
* 添加插件钩子到 Vite 插件对象
|
|
147
211
|
*
|
|
@@ -258,3 +322,4 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
258
322
|
declare function createPluginFactory<T extends BasePluginOptions, P extends BasePlugin<T>, R = T>(PluginClass: new (options: T, loggerConfig?: LoggerOptions) => P, normalizer?: OptionsNormalizer<T, R>): PluginFactory<T, R>;
|
|
259
323
|
|
|
260
324
|
export { BasePlugin, createPluginFactory };
|
|
325
|
+
export type { BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance };
|
package/dist/factory/index.d.mts
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.B3PARlU9.mjs';
|
|
1
|
+
import { Plugin, ResolvedConfig } from 'vite';
|
|
2
|
+
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.CLr0ttuO.mjs';
|
|
4
3
|
import { V as Validator } from '../shared/vite-plugin.CiHfwMiN.mjs';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 带插件实例引用的 Vite 插件类型
|
|
7
|
+
*
|
|
8
|
+
* @template T 插件配置类型
|
|
9
|
+
*/
|
|
10
|
+
interface PluginWithInstance<T extends BasePluginOptions = BasePluginOptions> extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* 原始插件实例的引用,方便外部访问插件内部状态
|
|
13
|
+
*/
|
|
14
|
+
pluginInstance?: BasePlugin<T>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 基础插件配置
|
|
18
|
+
*
|
|
19
|
+
* @interface BasePluginOptions
|
|
20
|
+
*/
|
|
21
|
+
interface BasePluginOptions {
|
|
22
|
+
/**
|
|
23
|
+
* 是否启用插件
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 是否启用日志
|
|
30
|
+
*
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
verbose?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 错误处理策略
|
|
36
|
+
*
|
|
37
|
+
* @default 'throw'
|
|
38
|
+
*/
|
|
39
|
+
errorStrategy?: 'throw' | 'log' | 'ignore';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 插件选项标准化器类型
|
|
43
|
+
*
|
|
44
|
+
* @template T 目标选项类型
|
|
45
|
+
* @template R 原始选项类型
|
|
46
|
+
*/
|
|
47
|
+
type OptionsNormalizer<T, R = any> = (raw?: R) => T;
|
|
48
|
+
/**
|
|
49
|
+
* 插件工厂函数类型
|
|
50
|
+
*
|
|
51
|
+
* @template T 插件配置类型,默认继承自 BasePluginOptions
|
|
52
|
+
* @template R 原始配置类型,默认与 T 相同
|
|
53
|
+
*/
|
|
54
|
+
type PluginFactory<T extends BasePluginOptions = BasePluginOptions, R = T> = (options?: R) => PluginWithInstance<T>;
|
|
55
|
+
|
|
6
56
|
/**
|
|
7
57
|
* 基础插件抽象类,提供插件开发的核心功能和生命周期管理
|
|
8
58
|
*
|
|
@@ -66,11 +116,10 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
66
116
|
* 获取插件的默认配置选项
|
|
67
117
|
*
|
|
68
118
|
* @protected
|
|
69
|
-
* @abstract
|
|
70
119
|
* @returns {Partial<T>} 插件特定的默认配置
|
|
71
|
-
* @description
|
|
120
|
+
* @description 子类可以重写此方法,以提供插件特定的默认配置值。默认返回空对象
|
|
72
121
|
*/
|
|
73
|
-
protected
|
|
122
|
+
protected getDefaultOptions(): Partial<T>;
|
|
74
123
|
/**
|
|
75
124
|
* 合并插件配置,将用户提供的配置与默认配置合并
|
|
76
125
|
*
|
|
@@ -142,6 +191,21 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
142
191
|
* @description 处理 Vite 配置解析完成事件,将解析后的配置存储到插件实例中
|
|
143
192
|
*/
|
|
144
193
|
protected onConfigResolved(config: ResolvedConfig): void;
|
|
194
|
+
/**
|
|
195
|
+
* 插件销毁生命周期
|
|
196
|
+
*
|
|
197
|
+
* @protected
|
|
198
|
+
* @virtual
|
|
199
|
+
* @description 插件销毁时调用的清理方法。基类会注销日志配置,子类可重写此方法添加自定义清理逻辑
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* protected destroy(): void {
|
|
203
|
+
* super.destroy()
|
|
204
|
+
* this.stopWatching()
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
protected destroy(): void;
|
|
145
209
|
/**
|
|
146
210
|
* 添加插件钩子到 Vite 插件对象
|
|
147
211
|
*
|
|
@@ -258,3 +322,4 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
258
322
|
declare function createPluginFactory<T extends BasePluginOptions, P extends BasePlugin<T>, R = T>(PluginClass: new (options: T, loggerConfig?: LoggerOptions) => P, normalizer?: OptionsNormalizer<T, R>): PluginFactory<T, R>;
|
|
259
323
|
|
|
260
324
|
export { BasePlugin, createPluginFactory };
|
|
325
|
+
export type { BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance };
|
package/dist/factory/index.d.ts
CHANGED
|
@@ -1,8 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.B3PARlU9.js';
|
|
1
|
+
import { Plugin, ResolvedConfig } from 'vite';
|
|
2
|
+
import { P as PluginLogger, a as LoggerOptions } from '../shared/vite-plugin.CLr0ttuO.js';
|
|
4
3
|
import { V as Validator } from '../shared/vite-plugin.CiHfwMiN.js';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 带插件实例引用的 Vite 插件类型
|
|
7
|
+
*
|
|
8
|
+
* @template T 插件配置类型
|
|
9
|
+
*/
|
|
10
|
+
interface PluginWithInstance<T extends BasePluginOptions = BasePluginOptions> extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* 原始插件实例的引用,方便外部访问插件内部状态
|
|
13
|
+
*/
|
|
14
|
+
pluginInstance?: BasePlugin<T>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 基础插件配置
|
|
18
|
+
*
|
|
19
|
+
* @interface BasePluginOptions
|
|
20
|
+
*/
|
|
21
|
+
interface BasePluginOptions {
|
|
22
|
+
/**
|
|
23
|
+
* 是否启用插件
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 是否启用日志
|
|
30
|
+
*
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
verbose?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 错误处理策略
|
|
36
|
+
*
|
|
37
|
+
* @default 'throw'
|
|
38
|
+
*/
|
|
39
|
+
errorStrategy?: 'throw' | 'log' | 'ignore';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 插件选项标准化器类型
|
|
43
|
+
*
|
|
44
|
+
* @template T 目标选项类型
|
|
45
|
+
* @template R 原始选项类型
|
|
46
|
+
*/
|
|
47
|
+
type OptionsNormalizer<T, R = any> = (raw?: R) => T;
|
|
48
|
+
/**
|
|
49
|
+
* 插件工厂函数类型
|
|
50
|
+
*
|
|
51
|
+
* @template T 插件配置类型,默认继承自 BasePluginOptions
|
|
52
|
+
* @template R 原始配置类型,默认与 T 相同
|
|
53
|
+
*/
|
|
54
|
+
type PluginFactory<T extends BasePluginOptions = BasePluginOptions, R = T> = (options?: R) => PluginWithInstance<T>;
|
|
55
|
+
|
|
6
56
|
/**
|
|
7
57
|
* 基础插件抽象类,提供插件开发的核心功能和生命周期管理
|
|
8
58
|
*
|
|
@@ -66,11 +116,10 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
66
116
|
* 获取插件的默认配置选项
|
|
67
117
|
*
|
|
68
118
|
* @protected
|
|
69
|
-
* @abstract
|
|
70
119
|
* @returns {Partial<T>} 插件特定的默认配置
|
|
71
|
-
* @description
|
|
120
|
+
* @description 子类可以重写此方法,以提供插件特定的默认配置值。默认返回空对象
|
|
72
121
|
*/
|
|
73
|
-
protected
|
|
122
|
+
protected getDefaultOptions(): Partial<T>;
|
|
74
123
|
/**
|
|
75
124
|
* 合并插件配置,将用户提供的配置与默认配置合并
|
|
76
125
|
*
|
|
@@ -142,6 +191,21 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
142
191
|
* @description 处理 Vite 配置解析完成事件,将解析后的配置存储到插件实例中
|
|
143
192
|
*/
|
|
144
193
|
protected onConfigResolved(config: ResolvedConfig): void;
|
|
194
|
+
/**
|
|
195
|
+
* 插件销毁生命周期
|
|
196
|
+
*
|
|
197
|
+
* @protected
|
|
198
|
+
* @virtual
|
|
199
|
+
* @description 插件销毁时调用的清理方法。基类会注销日志配置,子类可重写此方法添加自定义清理逻辑
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* protected destroy(): void {
|
|
203
|
+
* super.destroy()
|
|
204
|
+
* this.stopWatching()
|
|
205
|
+
* }
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
protected destroy(): void;
|
|
145
209
|
/**
|
|
146
210
|
* 添加插件钩子到 Vite 插件对象
|
|
147
211
|
*
|
|
@@ -258,3 +322,4 @@ declare abstract class BasePlugin<T extends BasePluginOptions = BasePluginOption
|
|
|
258
322
|
declare function createPluginFactory<T extends BasePluginOptions, P extends BasePlugin<T>, R = T>(PluginClass: new (options: T, loggerConfig?: LoggerOptions) => P, normalizer?: OptionsNormalizer<T, R>): PluginFactory<T, R>;
|
|
259
323
|
|
|
260
324
|
export { BasePlugin, createPluginFactory };
|
|
325
|
+
export type { BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance };
|
package/dist/factory/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{B as BasePlugin,c as createPluginFactory}from"../shared/vite-plugin.
|
|
1
|
+
export{B as BasePlugin,c as createPluginFactory}from"../shared/vite-plugin.DSb6XzBn.mjs";import"../logger/index.mjs";import"fs";import"path";import"crypto";import"../shared/vite-plugin.B88RyRN8.mjs";
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const format=require("./shared/vite-plugin.
|
|
1
|
+
"use strict";const format=require("./shared/vite-plugin.Ba9646wL.cjs"),validation=require("./shared/vite-plugin.IGZeStMa.cjs"),index=require("./shared/vite-plugin.CawoITTT.cjs"),logger_index=require("./logger/index.cjs"),index$1=require("./shared/vite-plugin.CXlzkIgT.cjs");require("fs"),require("path"),require("crypto"),exports.checkSourceExists=format.checkSourceExists,exports.copySourceToTarget=format.copySourceToTarget,exports.ensureTargetDir=format.ensureTargetDir,exports.fileExists=format.fileExists,exports.formatDate=format.formatDate,exports.generateRandomHash=format.generateRandomHash,exports.getDateFormatParams=format.getDateFormatParams,exports.padNumber=format.padNumber,exports.parseTemplate=format.parseTemplate,exports.readDirRecursive=format.readDirRecursive,exports.readFileContent=format.readFileContent,exports.readFileSync=format.readFileSync,exports.runWithConcurrency=format.runWithConcurrency,exports.shouldUpdateFile=format.shouldUpdateFile,exports.stripJsonComments=format.stripJsonComments,exports.toCamelCase=format.toCamelCase,exports.toPascalCase=format.toPascalCase,exports.writeFileContent=format.writeFileContent,exports.Validator=validation.Validator,exports.deepMerge=validation.deepMerge,exports.BasePlugin=index.BasePlugin,exports.createPluginFactory=index.createPluginFactory,exports.Logger=logger_index.Logger,exports.copyFile=index$1.copyFile,exports.generateRouter=index$1.generateRouter,exports.generateVersion=index$1.generateVersion,exports.injectIco=index$1.injectIco;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { DateFormatOptions, checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileSync, shouldUpdateFile, writeFileContent } from './common/index.cjs';
|
|
1
|
+
export { DateFormatOptions, checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, writeFileContent } from './common/index.cjs';
|
|
2
2
|
export { V as Validator } from './shared/vite-plugin.CiHfwMiN.cjs';
|
|
3
|
-
export { BasePlugin, createPluginFactory } from './factory/index.cjs';
|
|
4
|
-
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.
|
|
5
|
-
export { copyFile, generateVersion, injectIco } from './plugins/index.cjs';
|
|
3
|
+
export { BasePlugin, BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance, createPluginFactory } from './factory/index.cjs';
|
|
4
|
+
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.CLr0ttuO.cjs';
|
|
5
|
+
export { CopyFileOptions, GenerateRouterOptions, GenerateVersionOptions, Icon, InjectIcoOptions, NameStrategy, OutputFormat, OutputType, RouteConfig, RouteMeta, UniAppPageConfig, UniAppPagesJson, UniAppTabBarConfig, VersionFormat, copyFile, generateRouter, generateVersion, injectIco } from './plugins/index.cjs';
|
|
6
6
|
import 'vite';
|
|
7
|
-
import './shared/vite-plugin.UkE7CdSe.cjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { DateFormatOptions, checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileSync, shouldUpdateFile, writeFileContent } from './common/index.mjs';
|
|
1
|
+
export { DateFormatOptions, checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, writeFileContent } from './common/index.mjs';
|
|
2
2
|
export { V as Validator } from './shared/vite-plugin.CiHfwMiN.mjs';
|
|
3
|
-
export { BasePlugin, createPluginFactory } from './factory/index.mjs';
|
|
4
|
-
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.
|
|
5
|
-
export { copyFile, generateVersion, injectIco } from './plugins/index.mjs';
|
|
3
|
+
export { BasePlugin, BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance, createPluginFactory } from './factory/index.mjs';
|
|
4
|
+
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.CLr0ttuO.mjs';
|
|
5
|
+
export { CopyFileOptions, GenerateRouterOptions, GenerateVersionOptions, Icon, InjectIcoOptions, NameStrategy, OutputFormat, OutputType, RouteConfig, RouteMeta, UniAppPageConfig, UniAppPagesJson, UniAppTabBarConfig, VersionFormat, copyFile, generateRouter, generateVersion, injectIco } from './plugins/index.mjs';
|
|
6
6
|
import 'vite';
|
|
7
|
-
import './shared/vite-plugin.UkE7CdSe.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { DateFormatOptions, checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileSync, shouldUpdateFile, writeFileContent } from './common/index.js';
|
|
1
|
+
export { DateFormatOptions, checkSourceExists, copySourceToTarget, deepMerge, ensureTargetDir, fileExists, formatDate, generateRandomHash, getDateFormatParams, padNumber, parseTemplate, readDirRecursive, readFileContent, readFileSync, runWithConcurrency, shouldUpdateFile, stripJsonComments, toCamelCase, toPascalCase, writeFileContent } from './common/index.js';
|
|
2
2
|
export { V as Validator } from './shared/vite-plugin.CiHfwMiN.js';
|
|
3
|
-
export { BasePlugin, createPluginFactory } from './factory/index.js';
|
|
4
|
-
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.
|
|
5
|
-
export { copyFile, generateVersion, injectIco } from './plugins/index.js';
|
|
3
|
+
export { BasePlugin, BasePluginOptions, OptionsNormalizer, PluginFactory, PluginWithInstance, createPluginFactory } from './factory/index.js';
|
|
4
|
+
export { L as Logger, P as PluginLogger } from './shared/vite-plugin.CLr0ttuO.js';
|
|
5
|
+
export { CopyFileOptions, GenerateRouterOptions, GenerateVersionOptions, Icon, InjectIcoOptions, NameStrategy, OutputFormat, OutputType, RouteConfig, RouteMeta, UniAppPageConfig, UniAppPagesJson, UniAppTabBarConfig, VersionFormat, copyFile, generateRouter, generateVersion, injectIco } from './plugins/index.js';
|
|
6
6
|
import 'vite';
|
|
7
|
-
import './shared/vite-plugin.UkE7CdSe.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{c as checkSourceExists,a as copySourceToTarget,e as ensureTargetDir,f as formatDate,g as generateRandomHash,
|
|
1
|
+
export{c as checkSourceExists,a as copySourceToTarget,e as ensureTargetDir,f as fileExists,b as formatDate,g as generateRandomHash,d as getDateFormatParams,p as padNumber,h as parseTemplate,r as readDirRecursive,i as readFileContent,j as readFileSync,k as runWithConcurrency,s as shouldUpdateFile,l as stripJsonComments,t as toCamelCase,m as toPascalCase,w as writeFileContent}from"./shared/vite-plugin.C3ejdBNf.mjs";export{V as Validator,d as deepMerge}from"./shared/vite-plugin.B88RyRN8.mjs";export{B as BasePlugin,c as createPluginFactory}from"./shared/vite-plugin.DSb6XzBn.mjs";export{Logger}from"./logger/index.mjs";export{c as copyFile,g as generateRouter,a as generateVersion,i as injectIco}from"./shared/vite-plugin.B5wW4CiL.mjs";import"fs";import"path";import"crypto";
|
package/dist/logger/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";class Logger{static instance=null;libName="@meng-xi/vite-plugin";pluginConfigs=new Map;logTypes={info:{method:console.log,icon:"\u2139\uFE0F",color:"\x1B[36m",reset:"\x1B[0m"},success:{method:console.log,icon:"\u2705",color:"\x1B[32m",reset:"\x1B[0m"},warn:{method:console.warn,icon:"\u26A0\uFE0F",color:"\x1B[33m",reset:"\x1B[0m"},error:{method:console.error,icon:"\u274C",color:"\x1B[31m",reset:"\x1B[0m"}};constructor(){}static getInstance(){return Logger.instance||(Logger.instance=new Logger),Logger.instance}static create(e){const
|
|
1
|
+
"use strict";class Logger{static instance=null;libName="@meng-xi/vite-plugin";pluginConfigs=new Map;logTypes={info:{method:console.log,icon:"\u2139\uFE0F",color:"\x1B[36m",reset:"\x1B[0m"},success:{method:console.log,icon:"\u2705",color:"\x1B[32m",reset:"\x1B[0m"},warn:{method:console.warn,icon:"\u26A0\uFE0F",color:"\x1B[33m",reset:"\x1B[0m"},error:{method:console.error,icon:"\u274C",color:"\x1B[31m",reset:"\x1B[0m"}};constructor(){}static getInstance(){return Logger.instance||(Logger.instance=new Logger),Logger.instance}static create(e){const t=Logger.getInstance();return t.registerPlugin(e.name,e.enabled??!0),t}registerPlugin(e,t){this.pluginConfigs.set(e,t)}unregisterPlugin(e){this.pluginConfigs.delete(e)}static unregister(e){Logger.instance&&Logger.instance.unregisterPlugin(e)}static destroy(){Logger.instance&&(Logger.instance.pluginConfigs.clear(),Logger.instance=null)}formatPrefix(e){return`[${this.libName}:${e}]`}isPluginEnabled(e){return this.pluginConfigs.get(e)??!0}log(e,t,n,r){if(!this.isPluginEnabled(e))return;const l=this.formatPrefix(e),u=this.logTypes[t],{method:o,icon:a,color:s,reset:i}=u,c=`${a} ${l}`;r!=null?o(s+c+i,s+n+i,r):o(s+c+i,s+n+i)}createPluginLogger(e){return{success:(t,n)=>this.log(e,"success",t,n),info:(t,n)=>this.log(e,"info",t,n),warn:(t,n)=>this.log(e,"warn",t,n),error:(t,n)=>this.log(e,"error",t,n)}}}exports.Logger=Logger;
|
package/dist/logger/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { L as Logger, P as PluginLogger } from '../shared/vite-plugin.
|
|
1
|
+
export { L as Logger, P as PluginLogger } from '../shared/vite-plugin.CLr0ttuO.cjs';
|
package/dist/logger/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { L as Logger, P as PluginLogger } from '../shared/vite-plugin.
|
|
1
|
+
export { L as Logger, P as PluginLogger } from '../shared/vite-plugin.CLr0ttuO.mjs';
|
package/dist/logger/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { L as Logger, P as PluginLogger } from '../shared/vite-plugin.
|
|
1
|
+
export { L as Logger, P as PluginLogger } from '../shared/vite-plugin.CLr0ttuO.js';
|
package/dist/logger/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class
|
|
1
|
+
class t{static instance=null;libName="@meng-xi/vite-plugin";pluginConfigs=new Map;logTypes={info:{method:console.log,icon:"\u2139\uFE0F",color:"\x1B[36m",reset:"\x1B[0m"},success:{method:console.log,icon:"\u2705",color:"\x1B[32m",reset:"\x1B[0m"},warn:{method:console.warn,icon:"\u26A0\uFE0F",color:"\x1B[33m",reset:"\x1B[0m"},error:{method:console.error,icon:"\u274C",color:"\x1B[31m",reset:"\x1B[0m"}};constructor(){}static getInstance(){return t.instance||(t.instance=new t),t.instance}static create(e){const n=t.getInstance();return n.registerPlugin(e.name,e.enabled??!0),n}registerPlugin(e,n){this.pluginConfigs.set(e,n)}unregisterPlugin(e){this.pluginConfigs.delete(e)}static unregister(e){t.instance&&t.instance.unregisterPlugin(e)}static destroy(){t.instance&&(t.instance.pluginConfigs.clear(),t.instance=null)}formatPrefix(e){return`[${this.libName}:${e}]`}isPluginEnabled(e){return this.pluginConfigs.get(e)??!0}log(e,n,s,o){if(!this.isPluginEnabled(e))return;const u=this.formatPrefix(e),a=this.logTypes[n],{method:l,icon:g,color:i,reset:r}=a,c=`${g} ${u}`;o!=null?l(i+c+r,i+s+r,o):l(i+c+r,i+s+r)}createPluginLogger(e){return{success:(n,s)=>this.log(e,"success",n,s),info:(n,s)=>this.log(e,"info",n,s),warn:(n,s)=>this.log(e,"warn",n,s),error:(n,s)=>this.log(e,"error",n,s)}}}export{t as Logger};
|
package/dist/plugins/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const index=require("../shared/vite-plugin.
|
|
1
|
+
"use strict";const index=require("../shared/vite-plugin.CXlzkIgT.cjs");require("../shared/vite-plugin.CawoITTT.cjs"),require("../logger/index.cjs"),require("fs"),require("path"),require("crypto"),require("../shared/vite-plugin.IGZeStMa.cjs"),require("../shared/vite-plugin.Ba9646wL.cjs"),exports.copyFile=index.copyFile,exports.generateRouter=index.generateRouter,exports.generateVersion=index.generateVersion,exports.injectIco=index.injectIco;
|