file-lane 2.0.2 → 2.0.3-beta.10
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/lib/FileLane.d.ts +46 -8
- package/lib/FileLane.js +509 -411
- package/lib/FileLaneCompilation.d.ts +14 -1
- package/lib/FileLaneCompilation.js +24 -12
- package/lib/enum/FileLaneTriggerType.d.ts +8 -0
- package/lib/enum/FileLaneTriggerType.js +15 -0
- package/lib/event/CompilationEvent.js +13 -11
- package/lib/event/FileEvent.js +11 -9
- package/lib/event/IEventDispatcher.js +4 -1
- package/lib/event/asyncEvent/AsyncEventDispatcher.js +57 -64
- package/lib/event/asyncEvent/DataEvent.js +10 -6
- package/lib/index.js +70 -10
- package/lib/interface/IChangedFile.js +10 -7
- package/lib/interface/IFileLaneConfig.d.ts +1 -0
- package/lib/interface/IFileLaneConfig.js +1 -2
- package/lib/interface/IFileLaneContext.js +1 -2
- package/lib/interface/IFileLaneEvents.d.ts +57 -0
- package/lib/interface/IFileLaneEvents.js +1 -0
- package/lib/interface/IFileParam.js +1 -2
- package/lib/interface/ILoader.d.ts +7 -0
- package/lib/interface/ILoader.js +1 -2
- package/lib/interface/IPlugin.js +1 -2
- package/lib/utils/FileLaneUtil.js +54 -49
- package/package.json +3 -3
package/lib/FileLane.d.ts
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import IFileLaneConfig from './interface/IFileLaneConfig';
|
|
2
|
+
import FileLaneTriggerType from './enum/FileLaneTriggerType';
|
|
3
|
+
import IFileLaneEvents from './interface/IFileLaneEvents';
|
|
4
|
+
export interface IBuilderParam {
|
|
5
|
+
fileList: string[];
|
|
6
|
+
trigger: FileLaneTriggerType;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
9
|
* FileLane
|
|
4
10
|
*
|
|
5
11
|
* 文件车道,用于将文件进行对应转换,支持1对1、1对N、N对1
|
|
6
12
|
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* new FileLane<IJavascriptCompileOption>(
|
|
16
|
+
* fileLaneConfig,
|
|
17
|
+
* projectPath,
|
|
18
|
+
* compilerOption,
|
|
19
|
+
* {
|
|
20
|
+
* onBuildSuccess: (data) => {},
|
|
21
|
+
* onBuildError: (data) => {},
|
|
22
|
+
* onLog: (logs) => {}
|
|
23
|
+
* }).start()
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
7
26
|
* @description
|
|
8
27
|
*/
|
|
9
28
|
declare class FileLane<O = any> {
|
|
@@ -12,19 +31,23 @@ declare class FileLane<O = any> {
|
|
|
12
31
|
private readonly events?;
|
|
13
32
|
private context;
|
|
14
33
|
private watcher?;
|
|
34
|
+
/**
|
|
35
|
+
* 每次编译的数据对象
|
|
36
|
+
*/
|
|
15
37
|
private compilation?;
|
|
16
38
|
private changeFileList;
|
|
39
|
+
private triggerCount;
|
|
40
|
+
private building;
|
|
41
|
+
private nextBuildParam;
|
|
17
42
|
/**
|
|
18
43
|
* 实例化FileLane
|
|
19
44
|
* @param config fileLane 配置
|
|
20
45
|
* @param projectPath 项目路径
|
|
21
46
|
* @param compilerOption 编译参数,不同语言的项目具有的参数不同,即使同一项目开发者也会设置不同的参数
|
|
47
|
+
* @param events 事件监听器
|
|
22
48
|
*/
|
|
23
|
-
constructor(config: IFileLaneConfig<O>, projectPath?: string, compilerOption?: O | undefined, events?:
|
|
24
|
-
|
|
25
|
-
costTime: number;
|
|
26
|
-
}) => void;
|
|
27
|
-
} | undefined);
|
|
49
|
+
constructor(config: IFileLaneConfig<O>, projectPath?: string, compilerOption?: O | undefined, events?: IFileLaneEvents | undefined);
|
|
50
|
+
private addProcessListener;
|
|
28
51
|
/**
|
|
29
52
|
* 运行
|
|
30
53
|
* @param params
|
|
@@ -39,10 +62,16 @@ declare class FileLane<O = any> {
|
|
|
39
62
|
watch?: boolean;
|
|
40
63
|
}): Promise<void>;
|
|
41
64
|
private validateConfig;
|
|
42
|
-
private
|
|
65
|
+
private processBeforeExitHandler;
|
|
43
66
|
private sigintHandler;
|
|
44
|
-
|
|
45
|
-
|
|
67
|
+
dispose(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* 触发编译
|
|
70
|
+
*
|
|
71
|
+
* 如果:在编译过程中,则记录统参数,待本次 build 完成后,开始下一次
|
|
72
|
+
* 否则:直接触发编译
|
|
73
|
+
*/
|
|
74
|
+
private triggerBuild;
|
|
46
75
|
/**
|
|
47
76
|
*
|
|
48
77
|
* @param fileList 原始文件列表
|
|
@@ -51,6 +80,15 @@ declare class FileLane<O = any> {
|
|
|
51
80
|
private initCompilation;
|
|
52
81
|
private buildFile;
|
|
53
82
|
private runLoaders;
|
|
83
|
+
/**
|
|
84
|
+
* 处理日志
|
|
85
|
+
* 1. 触发onLog事件
|
|
86
|
+
* 2. 如果有错误日志,则抛出错误
|
|
87
|
+
* @param logs
|
|
88
|
+
* @param onError
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
private handlerLogs;
|
|
54
92
|
private writeFiles;
|
|
55
93
|
private runLoader;
|
|
56
94
|
/**
|