miniprogram-ci 2.1.28 → 2.1.30
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/CHANGELOG.md +4 -0
- package/README.md +4 -0
- package/dist/@types/config/config.d.ts +1 -1
- package/dist/@types/modules/corecompiler/baseCompiler.d.ts +1 -0
- package/dist/@types/modules/corecompiler/originalCompiler.d.ts +1 -0
- package/dist/@types/modules/corecompiler/summer/graph/basegraph.d.ts +2 -0
- package/dist/@types/modules/corecompiler/summer/module.d.ts +8 -3
- package/dist/@types/modules/corecompiler/summer/pluginconfig.d.ts +1 -1
- package/dist/@types/modules/corecompiler/summer/plugins/base/es6module.d.ts +0 -17
- package/dist/@types/modules/corecompiler/summer/plugins/filetask/script.d.ts +28 -0
- package/dist/@types/modules/corecompiler/summer/plugins/index.d.ts +1 -1
- package/dist/@types/modules/corecompiler/summer/plugins/script_task/babel_script_task.d.ts +22 -0
- package/dist/@types/modules/corecompiler/summer/plugins/script_task/load_script_task.d.ts +7 -0
- package/dist/@types/modules/corecompiler/summer/plugins/script_task/minify_script_task.d.ts +5 -0
- package/dist/@types/modules/corecompiler/summer/plugins/script_task/swc_task.d.ts +22 -0
- package/dist/@types/modules/corecompiler/summerCompiler.d.ts +4 -0
- package/dist/@types/types/devtools.d.ts +9 -0
- package/dist/@types/types/summer.d.ts +7 -2
- package/dist/@types/utils/env.d.ts +1 -0
- package/dist/@types/utils/helper_util.d.ts +1 -1
- package/dist/@types/utils/packOptionsHelper.d.ts +1 -0
- package/dist/@types/utils/subprocess/processManager.d.ts +1 -1
- package/dist/ci/build-apk.js +1 -1
- package/dist/ci/miniapp/iosTheme.js +1 -1
- package/dist/config/config.js +1 -1
- package/dist/modules/corecompiler/original/json/game.js +1 -1
- package/dist/modules/corecompiler/originalCompiler.js +1 -1
- package/dist/modules/corecompiler/processHandler.js +1 -1
- package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
- package/dist/modules/corecompiler/summer/module.js +1 -1
- package/dist/modules/corecompiler/summer/pluginconfig.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/base/es6module.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/base/javascript.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/base/swc.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/enhance.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/filetask/script.js +1 -0
- package/dist/modules/corecompiler/summer/plugins/index.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/less.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/script_task/babel_script_task.js +1 -0
- package/dist/modules/corecompiler/summer/plugins/script_task/load_script_task.js +1 -0
- package/dist/modules/corecompiler/summer/plugins/script_task/minify_script_task.js +1 -0
- package/dist/modules/corecompiler/summer/plugins/script_task/swc_task.js +1 -0
- package/dist/modules/corecompiler/summer/plugins/terser.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/typescript.js +1 -1
- package/dist/modules/corecompiler/summer/summer.js +1 -1
- package/dist/modules/corecompiler/summerCompiler.js +1 -1
- package/dist/modules/createSummer.js +1 -1
- package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
- package/dist/utils/cosUpload.js +1 -1
- package/dist/utils/env.js +1 -1
- package/dist/utils/packOptionsHelper.js +1 -1
- package/dist/utils/subprocess/processManager.js +1 -1
- package/dist/utils/subprocess/processService.js +1 -1
- package/package.json +2 -3
- package/npm-shrinkwrap.json +0 -45371
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,6 +7,10 @@ miniprogram-ci 是从[微信开发者工具](https://developers.weixin.qq.com/mi
|
|
|
7
7
|
miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,调用方式与普通开发模式无异。[查看详情](#第三方平台开发)
|
|
8
8
|
|
|
9
9
|
## 最近变更
|
|
10
|
+
#### 2.1.30
|
|
11
|
+
- `new` 新增 允许 CI 构建多端 APK 时使用 beta 版本 SDK
|
|
12
|
+
#### 2.1.29
|
|
13
|
+
- `fix` 修复 多端 iOS 构建专业版水印去除失败
|
|
10
14
|
#### 2.1.27
|
|
11
15
|
- `new` 优化 cos 上传链路
|
|
12
16
|
#### 2.1.20
|
|
@@ -123,6 +123,7 @@ export declare abstract class BaseCoreCompiler {
|
|
|
123
123
|
componentFiles: string[];
|
|
124
124
|
otherFiles: string[];
|
|
125
125
|
}>;
|
|
126
|
+
abstract waitSubProcessReady(): Promise<void>;
|
|
126
127
|
abstract getAllPageAndComponent(): Promise<string[]>;
|
|
127
128
|
abstract getExtJSON(): Promise<ExtJSON.IExtJSON>;
|
|
128
129
|
abstract getAppJSON(): Promise<AppJSON.IAppJSON>;
|
|
@@ -3,6 +3,7 @@ import { BaseCoreCompiler } from './baseCompiler';
|
|
|
3
3
|
import { OriginalCompileManager } from './original';
|
|
4
4
|
import { FileInfo } from './summer/graph/basegraph';
|
|
5
5
|
export declare class OriginalCompiler extends BaseCoreCompiler {
|
|
6
|
+
waitSubProcessReady(): Promise<void>;
|
|
6
7
|
readonly isSummer = false;
|
|
7
8
|
compileManager: OriginalCompileManager | undefined;
|
|
8
9
|
constructor(project: MiniProgramCore.IPreCompileProject);
|
|
@@ -56,6 +56,7 @@ export declare abstract class BaseGraph {
|
|
|
56
56
|
private onFileChange;
|
|
57
57
|
private invalidateModules;
|
|
58
58
|
private loadModuleFromFile;
|
|
59
|
+
private loadSourceForModuleWithoutTransform;
|
|
59
60
|
private loadSourceForModule;
|
|
60
61
|
protected doCompileSingleCode(info: FileInfo, sourceCode?: string): Promise<MiniProgramDevtools.CodeFile>;
|
|
61
62
|
private getCodeFileTask;
|
|
@@ -66,6 +67,7 @@ export declare abstract class BaseGraph {
|
|
|
66
67
|
private readFile;
|
|
67
68
|
private tranform;
|
|
68
69
|
private generate;
|
|
70
|
+
private compileCode;
|
|
69
71
|
private optimize;
|
|
70
72
|
private compress;
|
|
71
73
|
compile(options: MiniProgramCore.ICompileOptions, recorder: Recorder): Promise<MiniProgramDevtools.ICompileResult>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MiniProgramSummer, MiniProgramDevtools, MiniProgramCore } from '../../../types';
|
|
2
2
|
import { CustomError } from '../../../utils/customError';
|
|
3
|
-
import {
|
|
3
|
+
import { FileType } from './graph/basegraph';
|
|
4
4
|
declare class JsTag {
|
|
5
5
|
isLargeFile: boolean;
|
|
6
6
|
isBabelIgnore: boolean;
|
|
@@ -17,7 +17,6 @@ declare class JsTag {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export default class Module {
|
|
20
|
-
private readonly graph;
|
|
21
20
|
readonly path: string;
|
|
22
21
|
readonly sourcePath: string;
|
|
23
22
|
fileType: FileType;
|
|
@@ -25,24 +24,30 @@ export default class Module {
|
|
|
25
24
|
private _error;
|
|
26
25
|
private loadResult?;
|
|
27
26
|
private generateResultPromise;
|
|
27
|
+
private compileResultPromise;
|
|
28
28
|
depFiles: string[];
|
|
29
29
|
independentRoot: string;
|
|
30
30
|
isBabelIgnore: boolean;
|
|
31
31
|
private generatedTS;
|
|
32
|
-
constructor(
|
|
32
|
+
constructor(path: string, sourcePath: string, fileType: FileType);
|
|
33
33
|
private transResultType;
|
|
34
34
|
getGeneratedTS(resultType: MiniProgramCore.IResultType): number;
|
|
35
35
|
setError(resultType: MiniProgramCore.IResultType, error: CustomError | Error): void;
|
|
36
36
|
getError(resultType: MiniProgramCore.IResultType): Error | CustomError | undefined;
|
|
37
37
|
getJsTag(): Promise<JsTag | undefined>;
|
|
38
|
+
getJsTag2(): Promise<JsTag | undefined>;
|
|
38
39
|
getSource(): Promise<MiniProgramSummer.SourceDescription>;
|
|
39
40
|
getMd5(): Promise<string>;
|
|
40
41
|
setLoadingPromise(promise: Promise<MiniProgramSummer.ILoadResult>): void;
|
|
42
|
+
clearUselessCache(): Promise<void>;
|
|
41
43
|
getLoadingPromise(): Promise<MiniProgramSummer.ILoadResult> | undefined;
|
|
42
44
|
setGeneratingPromise(resultType: MiniProgramCore.IResultType, promise: Promise<MiniProgramSummer.IGenerateResult>): void;
|
|
43
45
|
getGeneratingPromise(resultType: MiniProgramCore.IResultType): Promise<MiniProgramSummer.IGenerateResult> | undefined;
|
|
46
|
+
getCompilePromise(resultType: MiniProgramCore.IResultType): Promise<MiniProgramSummer.IGenerateResult> | undefined;
|
|
47
|
+
setCompilePromise(resultType: MiniProgramCore.IResultType, promise: Promise<MiniProgramSummer.IGenerateResult>): void;
|
|
44
48
|
getProcessInfo(resultType: MiniProgramCore.IResultType): Promise<MiniProgramSummer.IPluginProcessInfo[] | undefined>;
|
|
45
49
|
toCodeFile(resultType: MiniProgramCore.IResultType): Promise<MiniProgramDevtools.CodeFile | MiniProgramDevtools.CodeError>;
|
|
50
|
+
toCodeFile2(resultType: MiniProgramCore.IResultType): Promise<MiniProgramDevtools.CodeFile | MiniProgramDevtools.CodeError>;
|
|
46
51
|
toGenerateResult(resultType: MiniProgramCore.IResultType): Promise<MiniProgramSummer.IGenerateResult | MiniProgramDevtools.CodeError>;
|
|
47
52
|
toJSON(): MiniProgramSummer.ModuleJSON;
|
|
48
53
|
addWatchFile(file: string): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { MiniProgramDevtools } from '../../../types';
|
|
2
|
-
export type AvailableSummerPlugin = '
|
|
2
|
+
export type AvailableSummerPlugin = 'script' | 'wxss' | 'less' | 'sass' | 'minifywxml';
|
|
3
3
|
export declare function couldUseSWCMode(setting: MiniProgramDevtools.IProjectSetting): boolean;
|
|
4
4
|
export declare function getSummerPluginConfig(setting: MiniProgramDevtools.IProjectSetting): (AvailableSummerPlugin | [AvailableSummerPlugin, any])[];
|
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
import { MiniProgramCore, MiniProgramSummer } from '../../../../../types';
|
|
2
|
-
export declare function getBabelRoot(independentRoot: string): string;
|
|
3
|
-
export declare function transformES6ModuleAndGenCode(id: string, source: MiniProgramSummer.SourceDescription, options: {
|
|
4
|
-
babelRoot: string;
|
|
5
|
-
disableUseStrict: boolean;
|
|
6
|
-
}): {
|
|
7
|
-
code: string;
|
|
8
|
-
map: {
|
|
9
|
-
version: number;
|
|
10
|
-
sources: string[];
|
|
11
|
-
names: string[];
|
|
12
|
-
sourceRoot?: string | undefined;
|
|
13
|
-
sourcesContent?: string[] | undefined;
|
|
14
|
-
mappings: string;
|
|
15
|
-
file: string;
|
|
16
|
-
};
|
|
17
|
-
helpers: string[];
|
|
18
|
-
};
|
|
19
2
|
export default function (project: MiniProgramCore.IPreCompileProject, options: {
|
|
20
3
|
disableUseStrict: boolean;
|
|
21
4
|
}): MiniProgramSummer.SummerPlugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MiniProgramCore, MiniProgramSummer } from '../../../../../types';
|
|
2
|
+
export { MAX_CODE_LENGTH, } from '../../../../../config/config';
|
|
3
|
+
export declare function getSWCRoot(project: MiniProgramCore.IPreCompileProject, independentRoot: string): string;
|
|
4
|
+
export interface IScriptCompileOptions {
|
|
5
|
+
disableUseStrict?: boolean;
|
|
6
|
+
minify?: boolean;
|
|
7
|
+
resultType: MiniProgramCore.IResultType;
|
|
8
|
+
swcRoot: string;
|
|
9
|
+
target: 'es5' | 'es2022';
|
|
10
|
+
rc?: {
|
|
11
|
+
parser?: Record<string, string>;
|
|
12
|
+
module?: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface IScriptCompileResult {
|
|
16
|
+
code: string;
|
|
17
|
+
map?: MiniProgramSummer.SourceMap;
|
|
18
|
+
helpers: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface IScriptCompileOptions {
|
|
21
|
+
swc?: boolean;
|
|
22
|
+
independentRoot: string;
|
|
23
|
+
isBabelIgnore: boolean;
|
|
24
|
+
resultType: MiniProgramCore.IResultType;
|
|
25
|
+
}
|
|
26
|
+
export default function (project: MiniProgramCore.IPreCompileProject, options: {
|
|
27
|
+
disableUseStrict: boolean;
|
|
28
|
+
}): MiniProgramSummer.SummerPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
load(pluginName: string): typeof import("./
|
|
2
|
+
load(pluginName: string): typeof import("./filetask/script").default | typeof import("./base/wxss").default | typeof import("./less").default | null;
|
|
3
3
|
};
|
|
4
4
|
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MiniProgramSummer } from '../../../../../types';
|
|
2
|
+
export declare function getBabelRoot(independentRoot: string): string;
|
|
3
|
+
export declare function babelTransformJS(source: MiniProgramSummer.SourceDescription, sourcePath: string): Promise<MiniProgramSummer.SourceDescription>;
|
|
4
|
+
export declare function transformES6ModuleAndGenCode(id: string, source: MiniProgramSummer.SourceDescription, options: {
|
|
5
|
+
babelRoot: string;
|
|
6
|
+
disableUseStrict: boolean;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
code: string;
|
|
9
|
+
map: any;
|
|
10
|
+
helpers: string[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare function babelTransformTS(source: MiniProgramSummer.SourceDescription, sourcePath: string): Promise<MiniProgramSummer.SourceDescription>;
|
|
13
|
+
export declare function bableCompile(sourcePath: string, source: MiniProgramSummer.SourceDescription, options: {
|
|
14
|
+
typescript?: boolean;
|
|
15
|
+
enhance?: boolean;
|
|
16
|
+
babelRoot: string;
|
|
17
|
+
disableUseStrict: boolean;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
code: string;
|
|
20
|
+
map: any;
|
|
21
|
+
helpers: string[];
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MiniProgramCore, MiniProgramSummer } from '../../../../../types';
|
|
2
|
+
export interface ILoadScriptResult {
|
|
3
|
+
targetPath: string;
|
|
4
|
+
source: MiniProgramSummer.SourceDescription;
|
|
5
|
+
process: MiniProgramSummer.IPluginProcessInfo[];
|
|
6
|
+
}
|
|
7
|
+
export declare function loadScriptFile(project: MiniProgramCore.IPreCompileProject, targetPath: string, sourcePath: string, pluginName: string): Promise<ILoadScriptResult>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MiniProgramSummer } from '../../../../../types';
|
|
2
|
+
export declare function doCompress(targetPath: string, target: Pick<MiniProgramSummer.GenerateDescription, 'code' | 'map'>): Promise<{
|
|
3
|
+
code: string;
|
|
4
|
+
map: string | import("source-map").RawSourceMap | undefined;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MiniProgramCore, MiniProgramSummer } from '../../../../../types';
|
|
2
|
+
export interface ISwcCompileOptions {
|
|
3
|
+
disableUseStrict?: boolean;
|
|
4
|
+
minify?: boolean;
|
|
5
|
+
resultType: MiniProgramCore.IResultType;
|
|
6
|
+
swcRoot: string;
|
|
7
|
+
target: 'es5' | 'es2022';
|
|
8
|
+
rc?: {
|
|
9
|
+
parser?: Record<string, any>;
|
|
10
|
+
module?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export interface ISwcSourceInput {
|
|
14
|
+
sourceCode: string;
|
|
15
|
+
inputMap?: MiniProgramSummer.SourceMap;
|
|
16
|
+
}
|
|
17
|
+
export interface ISwcCompileResult {
|
|
18
|
+
code: string;
|
|
19
|
+
map?: MiniProgramSummer.SourceMap;
|
|
20
|
+
helpers: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function swcCompileTask(id: string, source: ISwcSourceInput, options: ISwcCompileOptions): Promise<ISwcCompileResult>;
|
|
@@ -31,7 +31,10 @@ export declare class SummerCompiler extends BaseCoreCompiler {
|
|
|
31
31
|
private loadStatus;
|
|
32
32
|
destroy(): void;
|
|
33
33
|
clearCache(): Promise<void>;
|
|
34
|
+
getProjectInfo(): MiniProgramDevtools.IDevtoolsProjectInfo;
|
|
34
35
|
updateOptions(options: MiniProgramDevtools.IDevtoolsProjectInfo): void;
|
|
36
|
+
updateOptionsWithoutJudge(options: MiniProgramDevtools.IDevtoolsProjectInfo): void;
|
|
37
|
+
updateOptionsWhenAttrNotChanged(options: MiniProgramDevtools.IDevtoolsProjectInfo): void;
|
|
35
38
|
private addProjectListener;
|
|
36
39
|
private removeProjectListener;
|
|
37
40
|
onFileChange: (type: 'unlink' | 'unlinkDir' | 'add' | 'addDir' | 'change', targetPath: string) => void;
|
|
@@ -39,6 +42,7 @@ export declare class SummerCompiler extends BaseCoreCompiler {
|
|
|
39
42
|
private invalidCodeCache;
|
|
40
43
|
private onProgressUpdate;
|
|
41
44
|
private getConf;
|
|
45
|
+
waitSubProcessReady(): Promise<void>;
|
|
42
46
|
getPackageFiles(graphId: MiniProgramDevtools.GraphId, root: string, resultType?: MiniProgramCore.IResultType, useCache?: boolean): Promise<FileInfo[]>;
|
|
43
47
|
_getPackageFiles: (graphId: import("../../types").MiniProgramCI.ProjectType, root: string, resultType?: MiniProgramCore.IResultType) => Promise<FileInfo[]>;
|
|
44
48
|
private isMiniappPlatformInclude;
|
|
@@ -37,6 +37,13 @@ export declare namespace MiniProgramDevtools {
|
|
|
37
37
|
outputPath?: string;
|
|
38
38
|
rc?: Record<string, any>;
|
|
39
39
|
};
|
|
40
|
+
type ISassSetting = {
|
|
41
|
+
scssCommonUseFilePath?: string;
|
|
42
|
+
sassCommonUseFilePath?: string;
|
|
43
|
+
};
|
|
44
|
+
type ILessSetting = {
|
|
45
|
+
commonUseFilePath?: string;
|
|
46
|
+
};
|
|
40
47
|
interface IDevtoolsProjectInfo {
|
|
41
48
|
appid: string;
|
|
42
49
|
attr: any;
|
|
@@ -189,6 +196,8 @@ export declare namespace MiniProgramDevtools {
|
|
|
189
196
|
enhance?: boolean;
|
|
190
197
|
swc?: boolean;
|
|
191
198
|
swcSetting?: ISWCSetting;
|
|
199
|
+
sassSetting?: ISassSetting;
|
|
200
|
+
lessSetting?: ILessSetting;
|
|
192
201
|
disableSWC?: boolean | null | undefined;
|
|
193
202
|
coverView?: boolean;
|
|
194
203
|
showShadowRootInWxmlPanel?: boolean;
|
|
@@ -69,14 +69,18 @@ export declare namespace MiniProgramSummer {
|
|
|
69
69
|
process: IPluginProcessInfo[];
|
|
70
70
|
}
|
|
71
71
|
type ITransformResult = ILoadResult;
|
|
72
|
-
type AsyncPluginHooks = 'load' | 'transform' | 'optimize' | 'generate' | 'compress' | 'sealed';
|
|
73
|
-
type FirstPluginHooks = 'load' | 'generate';
|
|
72
|
+
type AsyncPluginHooks = 'load' | 'transform' | 'optimize' | 'generate' | 'compress' | 'sealed' | 'compile';
|
|
73
|
+
type FirstPluginHooks = 'load' | 'generate' | 'compile';
|
|
74
74
|
type SequentialPluginHooks = 'transform' | 'optimize' | 'compress';
|
|
75
75
|
type ParallelPluginHooks = 'sealed';
|
|
76
76
|
type LoadHook = (this: PluginContext, targetPath: string, sourcePath: string, options: {
|
|
77
77
|
independentRoot: string;
|
|
78
78
|
isBabelIgnore: boolean;
|
|
79
79
|
}) => Promise<ILoadResult | undefined>;
|
|
80
|
+
type CompileHook = (this: PluginContext, targetPath: string, sourcePath: string, loadResult: ILoadResult, options: {
|
|
81
|
+
independentRoot: string;
|
|
82
|
+
isBabelIgnore: boolean;
|
|
83
|
+
} & ICompileOptions) => Promise<IGenerateResult | undefined>;
|
|
80
84
|
type TransformHook = (this: PluginContext, loadResult: ILoadResult, targetPath: string, sourcePath: string, options: {
|
|
81
85
|
independentRoot: string;
|
|
82
86
|
isBabelIgnore: boolean;
|
|
@@ -98,6 +102,7 @@ export declare namespace MiniProgramSummer {
|
|
|
98
102
|
optimize: OptimizeHook;
|
|
99
103
|
compress: CompressHook;
|
|
100
104
|
sealed: SealedHook;
|
|
105
|
+
compile: CompileHook;
|
|
101
106
|
}
|
|
102
107
|
interface ResolveExt {
|
|
103
108
|
json?: string | string[];
|
|
@@ -6,6 +6,6 @@ export declare function getHelperOutputPath(setting: MiniProgramDevtools.IProjec
|
|
|
6
6
|
export declare function getHelperContent(setting: MiniProgramDevtools.IProjectSetting, mod: string): Promise<string>;
|
|
7
7
|
export declare function getHelperDeps(setting: MiniProgramDevtools.IProjectSetting, helpers: Set<string>): string[];
|
|
8
8
|
export declare function appendHelpers(project: IProjectLike, helperSet: Set<string>, root: string, resultMap: MiniProgramCore.IAnyObject): Promise<void[]>;
|
|
9
|
-
export declare function isValidHelperFunc(funcName: string): "
|
|
9
|
+
export declare function isValidHelperFunc(funcName: string): "babel" | "swc" | undefined;
|
|
10
10
|
export declare function getHelperName(setting: MiniProgramDevtools.IProjectSetting, mod: string): string;
|
|
11
11
|
export {};
|
|
@@ -27,6 +27,7 @@ declare class PackOptionsHelper {
|
|
|
27
27
|
isIgnoreByUnusedFiles(file: string, production?: boolean): boolean;
|
|
28
28
|
getUnusedFiles(): Set<string>;
|
|
29
29
|
isScssOnlyImportedByFile(module: IModule): boolean;
|
|
30
|
+
clearUnusedFiles(): void;
|
|
30
31
|
initUnusedFiles(project: MiniProgramCore.IPreCompileProject, analyzer: Analyzer | null, production?: boolean): Promise<void>;
|
|
31
32
|
}
|
|
32
33
|
declare const _default: PackOptionsHelper;
|
|
@@ -16,7 +16,7 @@ export declare class SubProcessProxy {
|
|
|
16
16
|
miniappDirPath?: string;
|
|
17
17
|
devtoolsVersion?: string;
|
|
18
18
|
}, initOptions: any, inspectPort?: number, progressUpdate?: MiniProgramDevtools.ProgressUpdate | undefined);
|
|
19
|
-
|
|
19
|
+
ready(): Promise<any>;
|
|
20
20
|
private sendProcessMessage;
|
|
21
21
|
private init;
|
|
22
22
|
destroy(): void;
|
package/dist/ci/build-apk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateCloudAndroidApk=exports.buildApk=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),miniAppI18N_1=tslib_1.__importDefault(require("../utils/miniAppI18N")),checkBuildArgument_1=require("./miniapp/checkBuildArgument"),miniappJson_1=require("../utils/miniappJson"),tools_1=require("../utils/tools"),androidCloudBuild_1=require("./miniapp/androidCloudBuild"),log=tslib_1.__importStar(require("../utils/log")),tools_2=require("./utils/tools"),report_1=require("../utils/report");async function buildApk(e){const r=Date.now();let i;try{if(!e.project)throw new Error("缺少参数 project");const{project:r}=e;r.targetPlatform="mini-android",await r.miniappAttr();const{buildArchiveOpts:o,cloudBuildInfo:t}=(0,checkBuildArgument_1.transformAndroidBuildArgument)(e);e.disableCache&&((0,tools_2.clearAndroidCacheDir)(),log.info("清除 Apk 构建缓存成功")),i=await generateCloudAndroidApk(e,o,t)}catch(e){log.error("构建 Apk 失败:",e.message),i={success:!1,errmsg:"构建 Apk 失败:"+e.message}}const o=Date.now()-r;return e.project&&(0,report_1.reportAction)("buildApk",i.success?0:-1,i.errmsg,o,e.project),i}async function generateCloudAndroidApk(e,r,i){var o;const{project:t,output:s}=e;let n=!1,d="failed";try{miniAppI18N_1.default.createI18NInfo(t.projectPath);const{useCloudUpload:u,useAab:a,packageVersion:c,packageDesc:l,certificateInfo:p,uploadAppInfo:A}=i,g=Object.assign({},r);u?(g.useCloudSync=!0,g.version=c,g.desc=l):(g.version=A?A.userVersion:"",g.desc=A?A.userDesc:"");const k=(0,miniappJson_1.tryGetAndroidMiniappJson)(t.projectPath);await checkAndroidSdkVersion(k);const m=Object.assign(Object.assign({},e),{resourceDir:(0,tools_2.getMiniappCacheDir)(),robot:e.robot||1});let _="";_=a?await(0,androidCloudBuild_1.getAndroidAabBuild)(m).build(g,s,p.androidCertificate):await(0,androidCloudBuild_1.getAndroidApkBuild)(m).build(g,s,p.androidCertificate),(null===(o=k.channel)||void 0===o?void 0:o.value)&&(_=`${_.slice(0,-4)}-${k.channel.value}${a?".aab":".Apk"}`),log.success("构建 Apk 成功"),n=!0,d="success! output file at "+_}catch(e){n=!1,d=e.message,log.error("构建 Apk 失败:",e.message)}return{success:n,errmsg:d}}async function checkAndroidSdkVersion(e){if(e.sdkVersion&&(null==e?void 0:e.usePluginSdk)){const r="http://dldir1.qq.com/WechatWebDev/donut/android-extended-sdk-version.json";let{body:i}=await(0,request_1.request)({url:r,method:"get"});try{i=JSON.parse(i)}catch(e){}const o=i;if(o){Object.keys(e.usePluginSdk).forEach(r=>{const i=e.usePluginSdk[r];if(!i)return;const t=o[r][i].minMainSdk;if((0,tools_1.compareSemVer)(e.sdkVersion,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateCloudAndroidApk=exports.buildApk=void 0;const tslib_1=require("tslib"),request_1=require("../utils/request"),miniAppI18N_1=tslib_1.__importDefault(require("../utils/miniAppI18N")),checkBuildArgument_1=require("./miniapp/checkBuildArgument"),miniappJson_1=require("../utils/miniappJson"),tools_1=require("../utils/tools"),androidCloudBuild_1=require("./miniapp/androidCloudBuild"),log=tslib_1.__importStar(require("../utils/log")),tools_2=require("./utils/tools"),report_1=require("../utils/report");async function buildApk(e){const r=Date.now();let i;try{if(!e.project)throw new Error("缺少参数 project");const{project:r}=e;r.targetPlatform="mini-android",await r.miniappAttr();const{buildArchiveOpts:o,cloudBuildInfo:t}=(0,checkBuildArgument_1.transformAndroidBuildArgument)(e);e.disableCache&&((0,tools_2.clearAndroidCacheDir)(),log.info("清除 Apk 构建缓存成功")),i=await generateCloudAndroidApk(e,o,t)}catch(e){log.error("构建 Apk 失败:",e.message),i={success:!1,errmsg:"构建 Apk 失败:"+e.message}}const o=Date.now()-r;return e.project&&(0,report_1.reportAction)("buildApk",i.success?0:-1,i.errmsg,o,e.project),i}async function generateCloudAndroidApk(e,r,i){var o;const{project:t,output:s}=e;let n=!1,d="failed";try{miniAppI18N_1.default.createI18NInfo(t.projectPath);const{useCloudUpload:u,useAab:a,packageVersion:c,packageDesc:l,certificateInfo:p,uploadAppInfo:A}=i,g=Object.assign({},r);u?(g.useCloudSync=!0,g.version=c,g.desc=l):(g.version=A?A.userVersion:"",g.desc=A?A.userDesc:"");const k=(0,miniappJson_1.tryGetAndroidMiniappJson)(t.projectPath);await checkAndroidSdkVersion(k);const m=Object.assign(Object.assign({},e),{resourceDir:(0,tools_2.getMiniappCacheDir)(),robot:e.robot||1});let _="";_=a?await(0,androidCloudBuild_1.getAndroidAabBuild)(m).build(g,s,p.androidCertificate):await(0,androidCloudBuild_1.getAndroidApkBuild)(m).build(g,s,p.androidCertificate),(null===(o=k.channel)||void 0===o?void 0:o.value)&&(_=`${_.slice(0,-4)}-${k.channel.value}${a?".aab":".Apk"}`),log.success("构建 Apk 成功"),n=!0,d="success! output file at "+_}catch(e){n=!1,d=e.message,log.error("构建 Apk 失败:",e.message)}return{success:n,errmsg:d}}async function checkAndroidSdkVersion(e){if(e.sdkVersion&&(null==e?void 0:e.usePluginSdk)){const r="http://dldir1.qq.com/WechatWebDev/donut/android-extended-sdk-version.json";let{body:i}=await(0,request_1.request)({url:r,method:"get"});try{i=JSON.parse(i)}catch(e){}const o=i;if(o){Object.keys(e.usePluginSdk).forEach(r=>{const i=e.usePluginSdk[r];if(!i)return;const t=o[r],s=t?t[i]:void 0;if(!s){const e=`当前使用的 ${r} 扩展SDK版本(${i})未包含在官方支持的版本列表内,请检查`;return void log.warn(e)}const n=s.minMainSdk;if((0,tools_1.compareSemVer)(e.sdkVersion,n)<0)throw new Error("存在主模块 SDK 版本不满足拓展 SDK 使用最小版本情况,请检查")})}}}exports.buildApk=buildApk,exports.generateCloudAndroidApk=generateCloudAndroidApk;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getIOSTheme=void 0;const Jimp=require("jimp"),fse=require("fs-extra"),path=require("path"),getIOSWaterMarkRGBVal=async(e,t=375,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getIOSTheme=void 0;const Jimp=require("jimp"),fse=require("fs-extra"),path=require("path"),getIOSWaterMarkRGBVal=async(e,t=375,r=812,a=64)=>{if(!fse.existsSync(e))throw new Error(`iOS 启动页 ${e} 不存在`);const i=await Jimp.read(e);i.resize(t,r);const o=Math.floor(t/2),s=r-a,n=i.getPixelColor(o,s);let{r:l,g:p,b:c}=Jimp.intToRGBA(n);const h=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;l=h(l/255),p=h(p/255),c=h(c/255);const u=.2126*l+.7152*p+.0722*c;return u<=.1?"Light":u>.1&&u<=.16?"LightSpecial":u>.16&&u<.25?"DarkSpecial":"Dark"},getIOSTheme=async(e,t)=>{var r;const a=await e.miniappAttr()||{};let i="Dark";return(null===(r=null==a?void 0:a.cpa_package_info)||void 0===r?void 0:r.enable_remove_watermark)?i="Default":t&&(path.isAbsolute(t)||(t=path.join(null==e?void 0:e.projectPath,t)),i=await getIOSWaterMarkRGBVal(t)),i};exports.getIOSTheme=getIOSTheme;
|
package/dist/config/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.1.
|
|
1
|
+
"use strict";var COMPILE_TYPE,AstType,EFilterCode;function getDefaultIgnores(e){const _=["node_modules/**/*","**/node_modules/**","**/.git/**",".git/**/*","**/.svn/**",".svn/**/*",".DS_Store","**/.DS_Store"];return"multiPlatform"===e.projectArchitecture&&_.push(exports.multiPlatformRoot+"/**/*"),_}Object.defineProperty(exports,"__esModule",{value:!0}),exports.MAX_CODE_LENGTH=exports.EFilterCode=exports.AstType=exports.compileTypeConfig=exports.getDefaultIgnores=exports.FullPkg=exports.MainPkg=exports.multiPlatformRoot=exports.extendedLibMap=exports.jsonVariablePropertyWhiteList=exports.DefaultProjectAttr=exports.TABBAR_ICON_WHITE_LIST=exports.COMPILE_TYPE=exports.APP_TYPE=exports.MINI_GAME_WORKERS_PACKAGE_ROOT=exports.MINI_GAME_MAIN_PACKAGE_ROOT=exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT=exports.PROJECT_TYPE_ERROR=exports.GET_LATEST_VERSION_CGI_ERR=exports.UPLOAD_JS_SERVER_CGI_ERR=exports.CODE_PROTECT_TRANSLATE_FILENAME=exports.UPLOAD_CGI_ERR=exports.GENERATE_LOCAL_SIGNATURE_ERR=exports.GET_SIGNATURE_RAND_STRING_ERR=exports.APP_JSON_NOT_FOUND=exports.JSON_CONTENT_ERR=exports.FILE_NOT_UTF8=exports.JSON_PARSE_ERR=exports.FILE_NOT_FOUND=exports.PLUGIN_JSON_PARSE_ERR=exports.PLUGIN_JSON_CONTENT_ERR=exports.PLUGIN_JSON_FILE_NOT_FOUND=exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=exports.SUMMER_PLUGIN_CODE_ERR=exports.SUMMER_PLUGIN_ERR=exports.MINIFY_WXML_ERR=exports.POST_WXSS_ERR=exports.FILE_FLAT_ERR=exports.JS_ES6_ERR=exports.BABILI_JS_ERR=exports.UGLIFY_JS_ERR=exports.BABEL_TRANS_JS_ERR=exports.JS_NOT_FOUND=exports.WXML_NOT_FOUND=exports.PARAM_ERROR=exports.CI_VERSION=void 0,exports.CI_VERSION="2.1.30",exports.PARAM_ERROR=1e4,exports.WXML_NOT_FOUND=10007,exports.JS_NOT_FOUND=10008,exports.BABEL_TRANS_JS_ERR=10032,exports.UGLIFY_JS_ERR=10033,exports.BABILI_JS_ERR=10034,exports.JS_ES6_ERR=10035,exports.FILE_FLAT_ERR=10036,exports.POST_WXSS_ERR=10037,exports.MINIFY_WXML_ERR=10038,exports.SUMMER_PLUGIN_ERR=10045,exports.SUMMER_PLUGIN_CODE_ERR=10046,exports.GAME_PLUGIN_LIB_MD5_NOT_MATCH=10081,exports.PLUGIN_JSON_FILE_NOT_FOUND=10091,exports.PLUGIN_JSON_CONTENT_ERR=10092,exports.PLUGIN_JSON_PARSE_ERR=10093,exports.FILE_NOT_FOUND=10005,exports.JSON_PARSE_ERR=10006,exports.FILE_NOT_UTF8=10031,exports.JSON_CONTENT_ERR=10009,exports.APP_JSON_NOT_FOUND=2e4,exports.GET_SIGNATURE_RAND_STRING_ERR=20001,exports.GENERATE_LOCAL_SIGNATURE_ERR=20002,exports.UPLOAD_CGI_ERR=20003,exports.CODE_PROTECT_TRANSLATE_FILENAME=20004,exports.UPLOAD_JS_SERVER_CGI_ERR=20005,exports.GET_LATEST_VERSION_CGI_ERR=20006,exports.PROJECT_TYPE_ERROR=3e4,exports.MINI_PROGRAM_MAIN_PACKAGE_ROOT="__APP__",exports.MINI_GAME_MAIN_PACKAGE_ROOT="__GAME__",exports.MINI_GAME_WORKERS_PACKAGE_ROOT="workers.js",exports.APP_TYPE={NORMAL:0,PLUGIN:1,SHOP:2,MINISHOP:3,GAME:4,CARD:5,NATIVE:7},function(e){e.miniProgram="miniProgram",e.miniProgramPlugin="miniProgramPlugin",e.miniGame="miniGame",e.miniGamePlugin="miniGamePlugin"}(COMPILE_TYPE=exports.COMPILE_TYPE||(exports.COMPILE_TYPE={})),exports.TABBAR_ICON_WHITE_LIST=[".png",".jpg",".jpeg"],exports.DefaultProjectAttr={platform:!1,appType:0,isSandbox:!1,released:!1,setting:{MaxCodeSize:2,MaxSubpackageSubCodeSize:2,MaxSubpackageFullCodeSize:12,NavigateMiniprogramLimit:10,MaxSubPackageLimit:100,MinTabbarCount:2,MaxTabbarCount:5,MaxCustomTabbarCount:10,MaxTabbarIconSize:40}},exports.jsonVariablePropertyWhiteList={windowPropertWhiteList:["navigationBarBackgroundColor","navigationBarTextStyle","backgroundColor","backgroundTextStyle","backgroundColorTop","backgroundColorBottom","backgroundColorContent"],tabBarPropertyWhiteList:["color","selectedColor","backgroundColor","borderStyle"],tabbarListItemPropertyWhiteList:["iconPath","selectedIconPath"]},exports.extendedLibMap={kbone:{packages:["miniprogram-element","miniprogram-render"]},weui:{packages:["weui-miniprogram"]}},exports.multiPlatformRoot="miniapp",exports.MainPkg="__APP__",exports.FullPkg="__FULL__",exports.getDefaultIgnores=getDefaultIgnores,exports.compileTypeConfig={weapp:"weapp",game:"game",plugin:"plugin",gamePlugin:"gamePlugin"},function(e){e.Babel="babel",e.Acorn="acorn"}(AstType=exports.AstType||(exports.AstType={})),function(e){e[e.Include=0]="Include",e[e.PackOptionsIgnore=1]="PackOptionsIgnore",e[e.AnalyseNoUse=2]="AnalyseNoUse",e[e.PartialCompileNoUse=3]="PartialCompileNoUse"}(EFilterCode=exports.EFilterCode||(exports.EFilterCode={})),exports.MAX_CODE_LENGTH=2048e3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../../utils/cache"),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),schemaValidate_1=require("../validate/schemaValidate"),signaturejson_1=tslib_1.__importDefault(require("../validate/signaturejson")),gamepluginjson_1=tslib_1.__importDefault(require("../validate/gamepluginjson")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),reactiveCache_1=require("./reactiveCache");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:i}=o,r=t.path;let n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:i});const s=path_1.default.posix.join(r,"signature.json");n=e.stat(a,s);let c=(0,tools_1.normalizePath)(path_1.default.posix.join(a,s));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',c),filePath:i,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,s),l=(0,common_1.checkUTF8)(_,c);const f=(0,common_2.checkJSONFormat)(l,c);try{signaturejson_1.default.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:c})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:c});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:c});const i=path_1.default.posix.join(r,t.path);n=e.stat(a,i),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,i),filePath:c,code:config_1.FILE_NOT_FOUND});const s=e.getFile(a,i),_=(0,tools_1.generateMD5)(s);_!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(r,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:c})}const u=path_1.default.posix.join(r,"plugin.json");n=e.stat(a,u),c=(0,tools_1.normalizePath)(path_1.default.posix.join(a,u)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',c),code:config_1.FILE_NOT_FOUND,filePath:i}),_=e.getFile(a,u),l=(0,common_1.checkUTF8)(_,c);const h=(0,common_2.checkJSONFormat)(l,c);try{gamepluginjson_1.default.check(h)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:c})}h.main&&((0,common_1.checkPath)({value:h.main,tips:'["main"]',filePath:c}),n=e.stat(a,path_1.default.posix.join(r,h.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+h.main),filePath:c,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],i=(o,t,e)=>{const{plugins:i}=o;if(i)for(const o in i){if(!i.hasOwnProperty(o))continue;const r=i[o];r&&r.path&&a.push({alias:o,version:r.version||"",provider:r.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,r.path))})}};if(i(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];i(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,i=[],r=t.plugins||{};function n(o,t){const{appid:r}=e,n=isPluginMode(e);if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==r)i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',r));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else i.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else i.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const s={},c={};for(const o in r){if(!r.hasOwnProperty(o))continue;const t=r[o];n(t,`["plugins"]["${o}"]`)&&(s[t.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,s[t.provider].tips,"provider")):s[t.provider]=c[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],r=`${e}["${o}"]`;n(a,r)&&(s[a.provider]?i.push(locales_1.default.config.SAME_ITEM.format(r,s[a.provider].tips,"provider")):c[o]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(r,c[o].tips)):s[a.provider]=c[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:r})}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:i}=o,r=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:s}=o;t.subPackages.length>s.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,s.MaxSubPackageLimit]),filePath:i});const c={},_={};for(let o=0,i=t.subPackages.length;o<i;o++){const i=t.subPackages[o];if(i.name){if(i.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}c[i.name]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,c[i.name],"name")),c[i.name]=`${n}[${o}]`}if(i.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root==="/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,"/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root.startsWith(".")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(i.root.startsWith("__wx__")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}i.root.startsWith("/")||(i.root=(0,tools_1.normalizePath)("/"+i.root)),i.root.endsWith(".js")?i.root=(0,tools_1.normalizePath)(i.root):i.root=(0,tools_1.normalizePath)(i.root+"/"),_[i.root]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[i.root],"root")),_[i.root]=`${n}[${o}]`;const s=a.stat(e,i.root);if(s){if(s.isDirectory){i.root.endsWith("/")||(i.root+="/");const t=path_1.default.posix.join(i.root,"./game.js"),s=a.stat(e,t);s&&s.isFile||r.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else r.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:i})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:i}=o,{loadingImageInfo:r}=t;if(!r)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:r.path,filePath:i});const n=e.stat(a,r.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${r.path}"`),filePath:i}),r.progressBarColor&&!(0,tools_1.isHexColor)(r.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${r.progressBarColor}"`,"HexColor"),filePath:i})}function checkWorkers(o,t){const{project:e,root:a,filePath:i}=o,{workers:r}=t;if(void 0===r)return;const n=(0,tools_1.getWorkersPath)(r);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:i});const s=e.stat(a,n);s&&!s.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:i})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:i}=o,{openDataContext:r}=t;if(void 0===r)return;(0,common_1.checkPath)({value:r,tips:'["openDataContext"]',filePath:i});const n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:i});const s=path_1.default.posix.join(r,"./index.js"),c=e.stat(a,s);c&&c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',s),filePath:i}),t.openDataContext=(0,tools_1.normalizePath)(r+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const i=t.getFile(e,"game.json"),r=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(i,a),a),n=(0,schemaValidate_1.schemaValidate)("game",r);return n.warning&&(r.__warning__=locales_1.default.config.INVALID.format(n.warning)),(0,schemaValidate_1.transValidateResult)(a,n),checkOpenDataContext(o,r),checkPlugins(o,r),checkSubpackages(o,r),checkPluginPath(o,r),checkLoadingImageUrl(o,r),checkWorkers(o,r),r}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),cache_1=require("../../../../utils/cache"),common_1=require("../../../../utils/common"),config_1=require("../../../../config/config"),tools_1=require("../../../../utils/tools"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),schemaValidate_1=require("../validate/schemaValidate"),signaturejson_1=tslib_1.__importDefault(require("../validate/signaturejson")),gamepluginjson_1=tslib_1.__importDefault(require("../validate/gamepluginjson")),projectconfig_1=require("./projectconfig"),common_2=require("./common"),reactiveCache_1=require("./reactiveCache");function isPluginMode(o){return o.type===config_1.COMPILE_TYPE.miniGamePlugin}function checkLocalPlugin(o,t){const{project:e,root:a,filePath:i}=o,r=t.path;let n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t.tips+'["path"]',locales_1.default.config.DIRECTORY),filePath:i});const c=path_1.default.posix.join(r,"signature.json");n=e.stat(a,c);let s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,c));n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),filePath:i,code:config_1.FILE_NOT_FOUND});let _=e.getFile(a,c),l=(0,common_1.checkUTF8)(_,s);const f=(0,common_2.checkJSONFormat)(l,s);try{signaturejson_1.default.check(f)}catch(o){(0,common_1.throwError)({msg:"signature.json"+o.message,filePath:s})}f.provider!==t.provider&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format('["provider"]',`"${t.provider}"`),filePath:s});for(let o=0;o<f.signature.length;o++){const t=f.signature[o];(0,common_1.checkPath)({value:t.path,tips:`["signature"][${o}]["path"]`,filePath:s});const i=path_1.default.posix.join(r,t.path);n=e.stat(a,i),n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`["signature"][${o}]["path"]`,i),filePath:s,code:config_1.FILE_NOT_FOUND});const c=e.getFile(a,i),_=(0,tools_1.generateMD5)(c);_!==t.md5&&(0,common_1.throwError)({msg:locales_1.default.config.GAME_PLUGIN_SIGNATURE_MD5_NOT_MATCH_CONTENT.format(path_1.default.posix.join(r,t.path),_,t.md5),code:config_1.GAME_PLUGIN_LIB_MD5_NOT_MATCH,filePath:s})}const g=path_1.default.posix.join(r,"plugin.json");n=e.stat(a,g),s=(0,tools_1.normalizePath)(path_1.default.posix.join(a,g)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(t.tips+'["path"]',s),code:config_1.FILE_NOT_FOUND,filePath:i}),_=e.getFile(a,g),l=(0,common_1.checkUTF8)(_,s);const u=(0,common_2.checkJSONFormat)(l,s);try{gamepluginjson_1.default.check(u)}catch(o){(0,common_1.throwError)({msg:"plugin.json"+o.message,filePath:s})}u.main&&((0,common_1.checkPath)({value:u.main,tips:'["main"]',filePath:s}),n=e.stat(a,path_1.default.posix.join(r,u.main)),n||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["main"]',""+u.main),filePath:s,code:config_1.FILE_NOT_FOUND}))}function checkPluginPath(o,t){const{subPackages:e}=t,a=[],i=(o,t,e)=>{const{plugins:i}=o;if(i)for(const o in i){if(!i.hasOwnProperty(o))continue;const r=i[o];r&&r.path&&a.push({alias:o,version:r.version||"",provider:r.provider||"",tips:`${e}["plugins"]["${o}"]`,path:(0,tools_1.normalizePath)(path_1.default.posix.join(t,r.path))})}};if(i(t,"",""),e)for(let o=0;o<e.length;o++){const t=e[o];i(t,t.root||"",`["subPackages"][${o}]`)}if(!(a.length<=0))for(const t of a)checkLocalPlugin(o,t)}function checkPlugins(o,t){const{project:e,filePath:a}=o,i=[],r=t.plugins||{};function n(o,t){const{appid:r}=e,n=isPluginMode(e),c=(0,projectconfig_1.getProjectConfigJSON)(e),s=(null==c?void 0:c.pluginAppid)||r;if(n||"dev"!==o.version)if(n&&"dev"===o.version&&o.provider!==s)i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["provider"]',s));else if("dev"!==o.version||"string"!=typeof o.path){if("dev"===o.version||"latest"===o.version||/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/.test(o.version)||/^dev-[A-Za-z0-9]+$/.test(o.version))return o.path&&(0,common_1.checkPath)({value:o.path,tips:t+'["path"]',filePath:a}),!0;i.push(locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(t+'["version"]',locales_1.default.config.TRIPLE_NUMBER_DOT))}else i.push(locales_1.default.config.GAME_DEV_PLUGIN_SHOULD_NOT_USE_LOCAL_PATH.format(t,t+'["path"]'));else i.push(`${locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(t+'["version"]',"dev")}\n${locales_1.default.config.PLEASE_CHOOSE_PLUGIN_MODE}`)}const c={},s={};for(const o in r){if(!r.hasOwnProperty(o))continue;const t=r[o];n(t,`["plugins"]["${o}"]`)&&(c[t.provider]?i.push(locales_1.default.config.SAME_ITEM.format(`["plugins"]["${o}"]`,c[t.provider].tips,"provider")):c[t.provider]=s[o]={provider:t.provider,version:t.version,alias:o,path:t.path||"",tips:`["plugins"]["${o}"]`})}const _=t.subPackages||t.subpackages;if(Array.isArray(_))for(let o=0,t=_.length;o<t;o++){const t=_[o];if(!t.plugins)continue;const e=`["subPackages"][${o}]["plugins"]`;for(const o in t.plugins){const a=t.plugins[o],r=`${e}["${o}"]`;n(a,r)&&(c[a.provider]?i.push(locales_1.default.config.SAME_ITEM.format(r,c[a.provider].tips,"provider")):s[o]?i.push(locales_1.default.config.PLUGINS_SAME_ALIAS.format(r,s[o].tips)):c[a.provider]=s[o]={provider:a.provider,version:a.version,alias:o,path:a.path||"",tips:r})}}i.length>0&&(0,common_1.throwError)({msg:i.join("\n"),filePath:a})}function checkSubpackages(o,t){const{root:e,project:a,filePath:i}=o,r=[];let n='["subPackages"]';if(t.subpackages&&(n='["subpackages"]',t.subPackages=t.subpackages,delete t.subpackages),t.subPackages){const o=a.attrSync(),{setting:c}=o;t.subPackages.length>c.MaxSubPackageLimit&&(0,common_1.throwError)({msg:locales_1.default.config.EXCEED_LIMIT.format([n,c.MaxSubPackageLimit]),filePath:i});const s={},_={};for(let o=0,i=t.subPackages.length;o<i;o++){const i=t.subPackages[o];if(i.name){if(i.name===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.name===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["name"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}s[i.name]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,s[i.name],"name")),s[i.name]=`${n}[${o}]`}if(i.root===config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_PROGRAM_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_MAIN_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_MAIN_PACKAGE_ROOT));continue}if(i.root===config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root==="/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT){r.push(locales_1.default.config.JSON_CONTENT_SHOULD_NOT_BE.format(`${n}[${o}]["root"]`,"/"+config_1.MINI_GAME_WORKERS_PACKAGE_ROOT));continue}if(i.root.startsWith(".")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"."));continue}if(i.root.startsWith("__wx__")){r.push(locales_1.default.config.JSON_SHOULD_NOT_START_WITH.format(`${n}[${o}]["root"]`,"__wx__"));continue}i.root.startsWith("/")||(i.root=(0,tools_1.normalizePath)("/"+i.root)),i.root.endsWith(".js")?i.root=(0,tools_1.normalizePath)(i.root):i.root=(0,tools_1.normalizePath)(i.root+"/"),_[i.root]&&r.push(locales_1.default.config.SAME_ITEM.format(`${n}[${o}]`,_[i.root],"root")),_[i.root]=`${n}[${o}]`;const c=a.stat(e,i.root);if(c){if(c.isDirectory){i.root.endsWith("/")||(i.root+="/");const t=path_1.default.posix.join(i.root,"./game.js"),c=a.stat(e,t);c&&c.isFile||r.push(locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format(`${n}[${o}]["root"]`,t))}}else r.push(locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`${n}[${o}]["root"]`))}}r.length>0&&(0,common_1.throwError)({msg:r.join("\n"),filePath:i})}function checkLoadingImageUrl(o,t){const{project:e,root:a,filePath:i}=o,{loadingImageInfo:r}=t;if(!r)return;(0,common_1.checkPath)({tips:'["loadingImageInfo"]["path"]',value:r.path,filePath:i});const n=e.stat(a,r.path);n&&n.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_NOT_FOUND.format(`["loadingImageInfo"]["path"]: "${r.path}"`),filePath:i}),r.progressBarColor&&!(0,tools_1.isHexColor)(r.progressBarColor)&&(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(`["loadingImageInfo"]["progressBarColor"]: "${r.progressBarColor}"`,"HexColor"),filePath:i})}function checkWorkers(o,t){const{project:e,root:a,filePath:i}=o,{workers:r}=t;if(void 0===r)return;const n=(0,tools_1.getWorkersPath)(r);(0,common_1.checkPath)({tips:'["workers"]',value:n,filePath:i});const c=e.stat(a,n);c&&!c.isFile||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["workers"]',locales_1.default.config.DIRECTORY]),filePath:i})}function checkOpenDataContext(o,t){const{project:e,root:a,filePath:i}=o,{openDataContext:r}=t;if(void 0===r)return;(0,common_1.checkPath)({value:r,tips:'["openDataContext"]',filePath:i});const n=e.stat(a,r);n&&n.isDirectory||(0,common_1.throwError)({msg:locales_1.default.config.JSON_CONTENT_SHOULD_BE.format(['["openDataContext"]',locales_1.default.config.DIRECTORY]),filePath:i});const c=path_1.default.posix.join(r,"./index.js"),s=e.stat(a,c);s&&s.isFile||(0,common_1.throwError)({msg:locales_1.default.config.CORRESPONDING_FILE_NOT_FOUND.format('["openDataContext"]',c),filePath:i}),t.openDataContext=(0,tools_1.normalizePath)(r+"/")}function checkGameJSON(o){const{project:t,root:e,filePath:a}=o;t.stat(e,"game.json")||(0,common_1.throwError)({msg:locales_1.default.config.FILE_NOT_FOUND.format(path_1.default.posix.join(a)),filePath:a,code:config_1.FILE_NOT_FOUND});const i=t.getFile(e,"game.json"),r=(0,common_2.checkJSONFormat)((0,common_1.checkUTF8)(i,a),a),n=(0,schemaValidate_1.schemaValidate)("game",r);return n.warning&&(r.__warning__=locales_1.default.config.INVALID.format(n.warning)),(0,schemaValidate_1.transValidateResult)(a,n),checkOpenDataContext(o,r),checkPlugins(o,r),checkSubpackages(o,r),checkPluginPath(o,r),checkLoadingImageUrl(o,r),checkWorkers(o,r),r}const getGameJSON=(0,reactiveCache_1.wrapCompileJSONFunc)(cache_1.CACHE_KEY.GAME_JSON,o=>{const t=(0,projectconfig_1.getProjectConfigJSON)(o).miniprogramRoot||"";return checkGameJSON({project:o,root:t,filePath:(0,tools_1.normalizePath)(path_1.default.posix.join(t,"game.json"))})});exports.default=getGameJSON;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OriginalCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),baseCompiler_1=require("./baseCompiler"),original_1=require("./original"),tools_1=require("../../utils/tools");class OriginalCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e){super(e),this.isSummer=!1,this.ready()}destroy(){this._checkReadyTask=void 0,this.compileManager=void 0}async init(){this.compileManager=new original_1.OriginalCompileManager(this.project)}async isGameApp(){if(!this.project)return!1;const e=await this.project.attr();return null==e?void 0:e.gameApp}checkProject(){}async getExtJSON(){return await this.compileManager.getExtJSON()}async getAppJSON(){return this.checkProject(),await this.compileManager.getAppJSON()}async getSiteMapJSON(){const e=await this.compileManager.getSiteMapJSON();return lodash_1.default.cloneDeep(e)}async getPageJSON(e){this.checkProject();return await this.compileManager.getPageJSON({miniprogramRoot:this.project.miniprogramRoot,pagePath:e})}async getGameJSON(){return this.checkProject(),this.compileManager.getGameJSON()}async getPluginJSON(e=""){return this.checkProject(),await this.compileManager.getPluginJSON(e)}async getPluginPageJSON(e){this.checkProject();return await this.compileManager.getPluginPageJSON({root:this.project.pluginRoot,project:this.project,filePath:path_1.default.posix.join(this.project.pluginRoot||"",e+".json")})}async getPluginComponents(){var e;const t=this.getPluginJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(r)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,r)&&o.push(r))}return o}getWxssMap(e,t){throw new Error("Method not implemented.")}async getPluginJSFiles(){const e=this.getPluginJSFileList();return{jsFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxssFiles(){const e=this.getPluginWXSSFileList();return{wxssFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxmlAndWxsFiles(){const e=this.getPluginWXSFileList(),t=this.getPluginWXMLFileList(),o=e.concat(t);return{wxsFiles:e,wxmlFiles:t,content:o.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getMPFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.miniprogramRoot),o)}async getPluginFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.pluginRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.pluginRoot),o)}async checkThemeJSON(e){return this.checkProject(),await this.compileManager.checkThemeJSON(e)}async compile(e){return this.checkProject(),await this.compileManager.compile({nameMapping:e.nameMapping||{},setting:e.setting,onProgressUpdate:e.onProgressUpdate,__compileDebugInfo__:e.__compileDebugInfo__,compilePages:e.compilePages,analyzer:e.analyzer,devToolsCompileCache:e.devToolsCompileCache,disableSpreadingUsingComponents:e.disableSpreadingUsingComponents,resultType:e.resultType})}async compileJS(e){this.checkProject();const{root:t,filePath:o,babelRoot:i="@babel/runtime"}=e;try{return await this.compileManager.compileJS(o,{root:t,sourceCode:e.sourceCode,setting:Object.assign({},e.setting),babelRoot:i,onProgressUpdate:e.onProgressUpdate})}catch(e){throw e}}setLocale(e){this.compileManager.setLocale(e)}clearCache(){this.compileManager.clearCache()}async getPackageWxssFileList(e){return[]}async getPackageWxssFiles(e){return{}}async getPackageWxmlAndWxsFiles(e){return{}}async getAllWxmlAndWxsFiles(){return{}}getAllSortedJSFiles(){throw new Error("Method not implemented.")}getMainPkgSortedJSFiles(){throw new Error("Method not implemented.")}async getPackageFiles(e,t){if(this.isGameType(e)){const e=await this.getGameJSON(),o=this.getMPFileList();let i=e.workers||"";i="string"==typeof i?i:i.path;const r=e.openDataContext,n={__APP__:[],[r]:[]};i&&(n[i]=[]);for(const t of o)if(r&&(0,tools_1.isLeftSubPathOfRight)(t,r))n[r].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:r,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))n[i].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"object"==typeof e.workers&&e.workers.isSubpackage?i:"",isBabelIgnore:!1});else{if(e.subPackages){let o=!1;for(const i of e.subPackages){const e=i.root.replace(/^\//,"");if((0,tools_1.isLeftSubPathOfRight)(t,e)){n[i.root]||(n[e]=[]),n[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}n.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return n[t]||[]}throw new Error("Method not implemented.")}getSubPkgSortedJSFiles(e){throw new Error("Method not implemented.")}getCompAndPagesOfConf(){throw new Error("Method not implemented.")}async getAllPageAndComponent(){var e;const t=this.getMPJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,r)&&o.push(r)}return o}}exports.OriginalCompiler=OriginalCompiler;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OriginalCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),baseCompiler_1=require("./baseCompiler"),original_1=require("./original"),tools_1=require("../../utils/tools");class OriginalCompiler extends baseCompiler_1.BaseCoreCompiler{async waitSubProcessReady(){}constructor(e){super(e),this.isSummer=!1,this.ready()}destroy(){this._checkReadyTask=void 0,this.compileManager=void 0}async init(){this.compileManager=new original_1.OriginalCompileManager(this.project)}async isGameApp(){if(!this.project)return!1;const e=await this.project.attr();return null==e?void 0:e.gameApp}checkProject(){}async getExtJSON(){return await this.compileManager.getExtJSON()}async getAppJSON(){return this.checkProject(),await this.compileManager.getAppJSON()}async getSiteMapJSON(){const e=await this.compileManager.getSiteMapJSON();return lodash_1.default.cloneDeep(e)}async getPageJSON(e){this.checkProject();return await this.compileManager.getPageJSON({miniprogramRoot:this.project.miniprogramRoot,pagePath:e})}async getGameJSON(){return this.checkProject(),this.compileManager.getGameJSON()}async getPluginJSON(e=""){return this.checkProject(),await this.compileManager.getPluginJSON(e)}async getPluginPageJSON(e){this.checkProject();return await this.compileManager.getPluginPageJSON({root:this.project.pluginRoot,project:this.project,filePath:path_1.default.posix.join(this.project.pluginRoot||"",e+".json")})}async getPluginComponents(){var e;const t=this.getPluginJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");"plugin"!==path_1.default.normalize(r)&&(this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.pluginRoot,r)&&o.push(r))}return o}getWxssMap(e,t){throw new Error("Method not implemented.")}async getPluginJSFiles(){const e=this.getPluginJSFileList();return{jsFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxssFiles(){const e=this.getPluginWXSSFileList();return{wxssFiles:e,content:e.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getPluginWxmlAndWxsFiles(){const e=this.getPluginWXSFileList(),t=this.getPluginWXMLFileList(),o=e.concat(t);return{wxsFiles:e,wxmlFiles:t,content:o.reduce((e,t)=>{var o;return e[t]=this.project.getFile((null===(o=this.project)||void 0===o?void 0:o.pluginRoot)||"",t).toString(),e},{})}}async getMPFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.miniprogramRoot),o)}async getPluginFileInfo(){var e,t;const o=null===(e=this.project)||void 0===e?void 0:e.pluginRoot;return this.excludeKeyRoot(this.getAllFileInfo(null===(t=this.project)||void 0===t?void 0:t.pluginRoot),o)}async checkThemeJSON(e){return this.checkProject(),await this.compileManager.checkThemeJSON(e)}async compile(e){return this.checkProject(),await this.compileManager.compile({nameMapping:e.nameMapping||{},setting:e.setting,onProgressUpdate:e.onProgressUpdate,__compileDebugInfo__:e.__compileDebugInfo__,compilePages:e.compilePages,analyzer:e.analyzer,devToolsCompileCache:e.devToolsCompileCache,disableSpreadingUsingComponents:e.disableSpreadingUsingComponents,resultType:e.resultType})}async compileJS(e){this.checkProject();const{root:t,filePath:o,babelRoot:i="@babel/runtime"}=e;try{return await this.compileManager.compileJS(o,{root:t,sourceCode:e.sourceCode,setting:Object.assign({},e.setting),babelRoot:i,onProgressUpdate:e.onProgressUpdate})}catch(e){throw e}}setLocale(e){this.compileManager.setLocale(e)}clearCache(){this.compileManager.clearCache()}async getPackageWxssFileList(e){return[]}async getPackageWxssFiles(e){return{}}async getPackageWxmlAndWxsFiles(e){return{}}async getAllWxmlAndWxsFiles(){return{}}getAllSortedJSFiles(){throw new Error("Method not implemented.")}getMainPkgSortedJSFiles(){throw new Error("Method not implemented.")}async getPackageFiles(e,t){if(this.isGameType(e)){const e=await this.getGameJSON(),o=this.getMPFileList();let i=e.workers||"";i="string"==typeof i?i:i.path;const r=e.openDataContext,n={__APP__:[],[r]:[]};i&&(n[i]=[]);for(const t of o)if(r&&(0,tools_1.isLeftSubPathOfRight)(t,r))n[r].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:r,isBabelIgnore:!1});else if(i&&(0,tools_1.isLeftSubPathOfRight)(t,i))n[i].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"object"==typeof e.workers&&e.workers.isSubpackage?i:"",isBabelIgnore:!1});else{if(e.subPackages){let o=!1;for(const i of e.subPackages){const e=i.root.replace(/^\//,"");if((0,tools_1.isLeftSubPathOfRight)(t,e)){n[i.root]||(n[e]=[]),n[e].push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:i.independent?e:"",isBabelIgnore:!1}),o=!0;break}}if(o)continue}n.__APP__.push({path:t,source:t,sourceExt:path_1.default.extname(t),independentRoot:"",isBabelIgnore:!1})}return n[t]||[]}throw new Error("Method not implemented.")}getSubPkgSortedJSFiles(e){throw new Error("Method not implemented.")}getCompAndPagesOfConf(){throw new Error("Method not implemented.")}async getAllPageAndComponent(){var e;const t=this.getMPJSONFileList(),o=[];for(let i=0,r=t.length;i<r;i++){const r=t[i].replace(/\.json$/,"");this.isValidComponent(null===(e=this.project)||void 0===e?void 0:e.miniprogramRoot,r)&&o.push(r)}return o}}exports.OriginalCompiler=OriginalCompiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=exports.onMessage=exports.destroy=exports.initHandler=void 0;const summerCPProject_1=require("../../project/summerCPProject"),index_1=require("../precompiler/index"),progressRecorder_1=require("../../utils/progressRecorder"),index_2=require("./original/index"),summer_1=require("./summer/summer"),debug_1=require("../../utils/debug"),getProcess_1=require("../../utils/subprocess/getProcess");let summercompileManager,summerProject,preCompiler,precompileProject,inited=!1;async function processSend(e){await(0,debug_1.shouldRunInMainProcess)()?emiter.emit("message",e):(0,getProcess_1.getProcess)().send(e)}async function initHandler(e){const{passData:r,projectInfo:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=exports.onMessage=exports.destroy=exports.initHandler=void 0;const summerCPProject_1=require("../../project/summerCPProject"),index_1=require("../precompiler/index"),progressRecorder_1=require("../../utils/progressRecorder"),index_2=require("./original/index"),summer_1=require("./summer/summer"),debug_1=require("../../utils/debug"),getProcess_1=require("../../utils/subprocess/getProcess"),env_1=require("../../utils/env");let summercompileManager,summerProject,preCompiler,precompileProject,inited=!1;const MEMORY_THRESHOLD=500;async function processSend(e){await(0,debug_1.shouldRunInMainProcess)()?emiter.emit("message",e):(0,getProcess_1.getProcess)().send(e)}async function initHandler(e){const{passData:r,projectInfo:o,options:t}=e.data;if(inited)return;summerProject=new summerCPProject_1.SummerCPProject(o),await summerProject.ready();const{targetPlatform:s,targetPlatformDefines:a}=o;preCompiler=new index_1.PreCompiler(summerProject,{showBuildLog:(e,r,o)=>{processSend({type:"log",id:e,status:r,text:o})}},void 0),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:s,targetPlatformDefines:a,runEnv:"summer cp"});const{cachePath:i}=r;summercompileManager=new summer_1.SummerCompiler(precompileProject,i,t),checkMemoryAndGC(),inited=!0}async function checkMemoryAndGC(){(0,env_1.isElectron)()&&process.memoryUsage&&global.gc&&setInterval(()=>{process.memoryUsage().heapTotal>524288e3&&(console.time("[summer-compiler checkMemoryAndGC] gc"),global.gc(),console.timeEnd("[summer-compiler checkMemoryAndGC] gc"))},3e3)}async function getCodeFiles(e,r,o){let t={};"getDevCodeByFileList"===e?t=await r.run("getDevCodeByFileList-"+o.graphId,()=>summercompileManager.getDevCodeByFileList(o,r)):"getCode"===e&&(t=await r.run(`getCode-${o.graphId}-${o.package}`,()=>summercompileManager.getCode(o,r)));const{cacheMd5:s}=o;for(const e of Object.keys(s)){const r=t[e];r?"error"in r||r.md5!==s[e]||delete t[e]:t[e]={path:e,md5:"",code:""}}for(const e of Object.values(t))"error"in e&&e.error instanceof Error&&(e.error={code:e.error.code||-1,message:e.error.message,stack:e.error.stack,path:e.path});return t}async function destroy(){null==summercompileManager||summercompileManager.destroy(),summercompileManager=void 0,inited=!1,preCompiler=void 0,summerProject=void 0,precompileProject=void 0}exports.initHandler=initHandler,exports.destroy=destroy;const emiter=function(){const e={};return{on:(r,o)=>{e.hasOwnProperty(r)||(e[r]=[]),e[r].push(o)},off:(r,o)=>{var t;e[r]=(null===(t=e[r])||void 0===t?void 0:t.filter(e=>e!==o))||[]},emit:(r,...o)=>{const t=e[r];if((null==t?void 0:t.length)>0)for(const e of t)try{e(...o)}catch(e){}}}}(),onMessage=e=>{emiter.on("message",e)};async function messageHandler(e){if("event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:o}=e.data;summerProject.onFileChange(r,o)}else if("updateOptions"===e.name){const r=e.data;summerProject.updateOptions(r),summercompileManager.updateOptions(r)}else if("precompileOptionsChange"===e.name){const r=e.data;precompileProject.updateConditionCompileOptions(r)}if("request"===e.type){const{id:r,name:o,data:t}=e,s=r,a=new progressRecorder_1.Recorder((e,r,o)=>{processSend({type:"progress",id:e,taskId:s,status:r,message:o})});try{let e;if("getCode"===o||"getDevCodeByFileList"===o)e=await getCodeFiles(o,a,t);else if("getPackageFiles"===o)e=await summercompileManager.getPackageFiles(t,a);else if("getConf"===o)e=await summercompileManager.getConf(t,a);else if("getLocalFileList"===o)e=await summercompileManager.getLocalFileList(t);else if("compile"===o)e=await summercompileManager.compile(t,a);else if("compileNewLogic"===o)e=await summercompileManager.compileNewLogic(t,a);else if("compileSingleCode"===o)e=await summercompileManager.compileSingleCode(t,a);else if("setLocale"===o)(0,index_2.setLocale)(t);else if("clearCache"===o)summercompileManager.clearCache();else{if("loadStatus"!==o)throw new Error("unknown command "+o);e=summercompileManager.getStatus()}processSend({type:"response",id:r,data:e})}catch(e){processSend({type:"response",id:r,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.onMessage=onMessage,exports.messageHandler=messageHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=exports.JSONType=exports.FileType=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),pluginDriver_1=require("../pluginDriver"),module_1=tslib_1.__importDefault(require("../module")),config_1=require("../../../../config/config"),resolver_1=require("../resolver"),common_1=require("../../original/compile/common"),packOptionsHelper_1=tslib_1.__importDefault(require("../../../../utils/packOptionsHelper")),tools_1=require("../../../../utils/tools"),babel_helper_1=require("../../../../utils/babel_helper"),helper_util_1=require("../../../../utils/helper_util"),progressRecorder_1=require("../../../../utils/progressRecorder"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),customError_1=require("../../../../utils/customError"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager")),pluginconfig_1=require("../pluginconfig");var FileType,JSONType;function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===FileType.JS)return FileType.JS;if(t===FileType.WXML)return FileType.WXML;if(t===FileType.WXSS)return FileType.WXSS;if(t===FileType.WXS)return FileType.WXS;if(t===FileType.JSON)return FileType.JSON}throw Error("unknown the filetype of "+e)}!function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType=exports.FileType||(exports.FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType=exports.JSONType||(exports.JSONType={}));class BaseGraph{constructor(e){var t;this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp("^"+this.root),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.getCodeFileTask=async(e,t,i={useCache:!0,resultType:"dev"})=>{const o=this.loadModuleFromFile(e,t,i),s=await o.toCodeFile(i.resultType||"dev");if(!("error"in s)&&"dev"!==i.resultType){const e=await o.toGenerateResult(i.resultType||"dev");if(!("error"in e)){const t=await this.optimize(e,i),o=await this.compress(t,i);s.code=o.target.code,s.map=o.target.map}}return{file:e,codeFile:s,process:await o.getProcessInfo(i.resultType||"dev")||[]}},this.type=e.type,this.root=e.root,this.rootPath=(0,tools_1.joinPath)(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new pluginDriver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.compiler.proxyProject.addResolver(this.resolver),null===(t=this.project.event)||void 0===t||t.on("fileChange",this.onFileChange)}destroy(){var e;this.compiler.proxyProject.removeResolver(this.resolver),null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange)}clearCache(){this.modulesByPath.clear()}async ensureConf(e){this.conf||await this.getConf(e)}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[i,o]of this.resolver.resolveInfoMap.entries())e!==config_1.FullPkg&&this.checkFilePackage(i)!==e||t.push(o);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}loadModuleFromFile(e,t,i){let o=this.modulesByPath.get(e.path),s=!o||o.sourcePath!==e.source||o.independentRoot!==e.independentRoot;if(!s&&(null==o?void 0:o.getError(i.resultType))){if(o.getGeneratedTS(i.resultType)+1e3>Date.now())return o;s=!0}if(s){const t=getFileType(e.path);o=new module_1.default(this,e.path,e.source,t),o.independentRoot=e.independentRoot,e.isBabelIgnore&&(o.isBabelIgnore=!0),this.modulesByPath.set(e.path,o)}let r=o.getLoadingPromise();void 0===r&&(r=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(o,i)),o.setLoadingPromise(r));let a=o.getGeneratingPromise(i.resultType);return void 0===a&&(a=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await o.getLoadingPromise();return this.generate(e,o,i)}),o.setGeneratingPromise(i.resultType,a)),o}async loadSourceForModule(e,t){try{const i=(0,tools_1.joinPath)(this.rootPath,e.sourcePath),o=t=>Object.assign(Object.assign({},t),{rootPath:this.rootPath,addWatchFile:t=>{const i=(0,tools_1.normalizePath)(t);if(!i.startsWith(this.rootPath))throw(0,customError_1.makeCustomError)(`The file (${t}) required by ${e.sourcePath} is outside the project`,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,i))}});let s=await this.pluginDriver.hookFirst("load",[e.path,i,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:e.isBabelIgnore||!1})],o);if(!s){const t=Date.now(),o=await this.readFile(i);s={targetPath:e.path,source:{sourceCode:o},process:[{cost:Date.now()-t,pluginName:"readFile",action:"load"}]}}return await this.tranform(s,e,o,t)}catch(i){throw i.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,i),i}}async doCompileSingleCode(e,t){const i=this.loadModuleFromFile(e,progressRecorder_1.silentRecorder,{resultType:"dev"}),o=i.getError("dev");if(o)throw o;return await i.toCodeFile("dev")}async getCodeFiles(e,t,i={useCache:!0,resultType:"dev"}){var o;const s=Date.now(),r={},a=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const o of e)a.addTask(this.getCodeFileTask,o,t,i);const n=await a.runAllAsync();for(const e of n)r[e.file.path]=e.codeFile,(null===(o=e.codeFile.jsTag)||void 0===o?void 0:o.isLargeFile)&&t.message("warn",locales_1.default.config.LARGEFILE_WARNING.format(e.file.path,config_1.MAX_CODE_LENGTH/1024));return console.info(`getCodeFiles: count: ${e.length}, cost: ${Date.now()-s}ms.`),r}async readFile(e){const t=path_1.default.relative(this.project.projectPath,e);return this.project.getFile("",t).toString()}async tranform(e,t,i,o){return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})],(function(e,t){return void 0===t?e:t}),i)}async generate(e,t,i){const o=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},i),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);return void 0===o||(0,lodash_1.isNull)(o)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):o}async optimize(e,t){return await this.pluginDriver.hookReduceArg0("optimize",[e,t],(e,t)=>t,e=>e)}async compress(e,t){return await this.pluginDriver.hookReduceArg0("compress",[e,t],(e,t)=>t,e=>e)}async compile(e,t){const{jsons:i}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSON(e,t)),o=await this.compileCodeWithoutJSON(e,t),s=await t.run(locales_1.default.config.SUMMER_PACK_FILES.format(),()=>this.compileOther(Object.keys(i),t)),r=Object.assign(Object.assign(Object.assign({},s),o),i);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[r])),r}async compileWithFileList(e,t){const i=e.fileList,{jsons:o}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSONWithFileList(Object.assign(Object.assign({},e),{fileList:i.filter(e=>e.endsWith(".json"))}),t)),s=i.filter(e=>!e.endsWith(".json")),r=await this.compileCodeWithoutJSONWithFileList(Object.assign(Object.assign({},e),{fileList:s}),t),a=Object.assign(Object.assign({},r),o);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[a])),a}async getLocalFileList(){const e=this.getLocalCodeFileList(),t=new Set(this.resolver.allExts.map(e=>"."+e)),i=await this.getWhiteListConfig(),o=this.project.getFileList(this.root,"").filter(e=>{const o=path_1.default.posix.extname(e);return i.has(o)&&!t.has(o)}).map(e=>e.replace(new RegExp("^"+this.root),"")),s={};for(const t of e.concat(o)){const e=this.project.stat(this.root,t);s[t]=e}return s}async compileOther(e,t=progressRecorder_1.silentRecorder){const i=new Set(this.resolver.allExts.map(e=>"."+e));i.delete(".json");const o=await this.getWhiteListConfig(),s=this.project.getFileList(this.root,"").filter(s=>{const r=path_1.default.posix.extname(s),a=path_1.default.posix.relative(this.root,s);if(!o.has(r)||i.has(r)||e.includes(a))return!1;return!packOptionsHelper_1.default.isIgnoredByRules(s)||(t.message("warn",s+" is ignored by project.config.json packOptions.ignore setting"),!1)}),r=await(0,common_1.compileOther)(this.project,s,{onProgressUpdate:()=>{}}),a={};for(const e in r){a[path_1.default.posix.relative(this.root,e)]=r[e]}return a}async compileCodeWithoutJSON(e,t){var i;const o={},s=await this.getProdCode(t,Object.assign(Object.assign({},e),{package:config_1.FullPkg})),r=new Set;for(const e in s){const t=s[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(i=t.jsTag)||void 0===i?void 0:i.helpers)||[]).forEach(e=>{r.add(e)}),o[e]=t.code;const s=t.map&&(0,tools_1.formatSourceMap)(t.map);s&&(o[e+".map"]=s)}else o[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,r,"",o)),o}async compileCodeWithoutJSONWithFileList(e,t){var i;const o={},s=await this.getProdCodeByFileList(t,e),r=new Set;for(const e in s){const t=s[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(i=t.jsTag)||void 0===i?void 0:i.helpers)||[]).forEach(e=>{r.add(e)}),o[e]=t.code;const s=t.map&&(0,tools_1.formatSourceMap)(t.map);s&&(o[e+".map"]=s)}else o[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,r,"",o)),o}isBabelSettingIgnore(e){var t,i;let o=!1;if(e.path.endsWith(".js")){const s=(0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?null===(t=this.compiler.getSWCSetting())||void 0===t?void 0:t.ignore:null===(i=this.compiler.getBabelSetting())||void 0===i?void 0:i.ignore;s&&(o=(0,babel_helper_1.isIgnore)(s,e.source))}return o}async getDevCodeByFileList(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e)}async getProdCodeByFileList(e,t){let i=await this.getPackageFile(config_1.FullPkg);return i=i.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType||"prod"})}}exports.BaseGraph=BaseGraph;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseGraph=exports.JSONType=exports.FileType=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),pluginDriver_1=require("../pluginDriver"),module_1=tslib_1.__importDefault(require("../module")),config_1=require("../../../../config/config"),resolver_1=require("../resolver"),common_1=require("../../original/compile/common"),packOptionsHelper_1=tslib_1.__importDefault(require("../../../../utils/packOptionsHelper")),tools_1=require("../../../../utils/tools"),babel_helper_1=require("../../../../utils/babel_helper"),helper_util_1=require("../../../../utils/helper_util"),progressRecorder_1=require("../../../../utils/progressRecorder"),locales_1=tslib_1.__importDefault(require("../../../../utils/locales/locales")),customError_1=require("../../../../utils/customError"),taskmanager_1=tslib_1.__importDefault(require("../../../../utils/taskmanager")),pluginconfig_1=require("../pluginconfig");var FileType,JSONType;function getFileType(e){let t=path_1.default.extname(e);if(t.startsWith(".")){if(t=t.slice(1),t===FileType.JS)return FileType.JS;if(t===FileType.WXML)return FileType.WXML;if(t===FileType.WXSS)return FileType.WXSS;if(t===FileType.WXS)return FileType.WXS;if(t===FileType.JSON)return FileType.JSON}throw Error("unknown the filetype of "+e)}!function(e){e.JSON="json",e.WXML="wxml",e.WXSS="wxss",e.WXS="wxs",e.JS="js"}(FileType=exports.FileType||(exports.FileType={})),function(e){e.APP="app",e.Page="page",e.EXT="ext",e.SITEMAP="sitemap",e.THEME="theme"}(JSONType=exports.JSONType||(exports.JSONType={}));class BaseGraph{constructor(e){var t;this.invalidated=!0,this.running=!1,this.onFileChange=(e,t)=>{t.startsWith(this.root)&&(t=t.replace(new RegExp("^"+this.root),""),this.resolver.onFileChange(e,t),"change"!==e&&"unlink"!==e||this.invalidateModules(t),this.onFileChangeForGraph(e,t))},this.getCodeFileTask=async(e,t,o={useCache:!0,resultType:"dev"})=>{const i=this.loadModuleFromFile(e,t,o);if(i.sourcePath.endsWith(".js")||i.sourcePath.endsWith(".ts")){return{file:e,codeFile:await i.toCodeFile2(o.resultType||"dev"),process:[]}}const r=await i.toCodeFile(o.resultType||"dev");if(!("error"in r)&&"dev"!==o.resultType){const e=await i.toGenerateResult(o.resultType||"dev");if(!("error"in e)){const t=await this.optimize(e,o),i=await this.compress(t,o);r.code=i.target.code,r.map=i.target.map}}return{file:e,codeFile:r,process:await i.getProcessInfo(o.resultType||"dev")||[]}},this.type=e.type,this.root=e.root,this.rootPath=(0,tools_1.joinPath)(e.compiler.project.projectPath,this.root),this.persistCache=e.persistCache,this.compiler=e.compiler,this.project=this.compiler.project,this.cachedModules=new Map,this.pluginDriver=new pluginDriver_1.PluginDriver(this,e),this.modulesByPath=new Map,this.resolver=new resolver_1.Resolver(this,this.root,this.pluginDriver.resolveExtConf),this.compiler.proxyProject.addResolver(this.resolver),null===(t=this.project.event)||void 0===t||t.on("fileChange",this.onFileChange)}destroy(){var e;this.compiler.proxyProject.removeResolver(this.resolver),null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange)}clearCache(){this.modulesByPath.clear()}async ensureConf(e){this.conf||await this.getConf(e)}async getPackageFile(e){await this.ensureConf(progressRecorder_1.silentRecorder);const t=[];for(const[o,i]of this.resolver.resolveInfoMap.entries())e!==config_1.FullPkg&&this.checkFilePackage(o)!==e||t.push(i);return t.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}invalidateModules(e){for(const t of this.modulesByPath.values())(t.sourcePath===e||t.depFiles.includes(e))&&this.modulesByPath.delete(t.path)}loadModuleFromFile(e,t,o){let i=this.modulesByPath.get(e.path),r=!i||i.sourcePath!==e.source||i.independentRoot!==e.independentRoot;if(!r&&(null==i?void 0:i.getError(o.resultType))){if(i.getGeneratedTS(o.resultType)+1e3>Date.now())return i;r=!0}if(r){const t=getFileType(e.path);i=new module_1.default(e.path,e.source,t),i.independentRoot=e.independentRoot,e.isBabelIgnore&&(i.isBabelIgnore=!0),this.modulesByPath.set(e.path,i)}if(e.path.endsWith(".ts")||e.path.endsWith(".js")){let r=i.getLoadingPromise();void 0===r&&(r=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModuleWithoutTransform(i,o)),i.setLoadingPromise(r));let s=i.getCompilePromise(o.resultType);return void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await i.getLoadingPromise();return this.compileCode(e,i,o)}),i.setCompilePromise(o.resultType,s)),i}let s=i.getLoadingPromise();void 0===s&&(s=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(i,o)),i.setLoadingPromise(s));let a=i.getGeneratingPromise(o.resultType);return void 0===a&&(a=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),async()=>{const e=await i.getLoadingPromise();return this.generate(e,i,o)}),i.setGeneratingPromise(o.resultType,a)),i}async loadSourceForModuleWithoutTransform(e,t){try{const o=(0,tools_1.joinPath)(this.rootPath,e.sourcePath),i=t=>Object.assign(Object.assign({},t),{rootPath:this.rootPath,addWatchFile:t=>{const o=(0,tools_1.normalizePath)(t);if(!o.startsWith(this.rootPath))throw(0,customError_1.makeCustomError)(`The file (${t}) required by ${e.sourcePath} is outside the project`,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR,e.path);e.addWatchFile(path_1.default.posix.relative(this.rootPath,o))}});let r=await this.pluginDriver.hookFirst("load",[e.path,o,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:e.isBabelIgnore||!1})],i);if(!r){const t=Date.now(),i=await this.readFile(o);r={targetPath:e.path,source:{sourceCode:i},process:[{cost:Date.now()-t,pluginName:"readFile",action:"load"}]}}return r}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async loadSourceForModule(e,t){try{const o=await this.loadSourceForModuleWithoutTransform(e,t);return await this.tranform(o,e,t)}catch(o){throw o.path=(0,tools_1.joinPath)(this.root,e.sourcePath),e.setError(t.resultType,o),o}}async doCompileSingleCode(e,t){const o=this.loadModuleFromFile(e,progressRecorder_1.silentRecorder,{resultType:"dev"}),i=o.getError("dev");if(i)throw i;return await o.toCodeFile("dev")}async getCodeFiles(e,t,o={useCache:!0,resultType:"dev"}){var i;const r=Date.now(),s={},a=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const i of e)a.addTask(this.getCodeFileTask,i,t,o);const n=await a.runAllAsync();for(const e of n)s[e.file.path]=e.codeFile,(null===(i=e.codeFile.jsTag)||void 0===i?void 0:i.isLargeFile)&&t.message("warn",locales_1.default.config.LARGEFILE_WARNING.format(e.file.path,config_1.MAX_CODE_LENGTH/1024));return console.info(`getCodeFiles: count: ${e.length}, cost: ${Date.now()-r}ms.`),s}async readFile(e){const t=path_1.default.relative(this.project.projectPath,e);return this.project.getFile("",t).toString()}async tranform(e,t,o){return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})],(function(e,t){return void 0===t?e:t}))}async generate(e,t,o){const i=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);return void 0===i||(0,lodash_1.isNull)(i)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):i}async compileCode(e,t,o){const i=await this.pluginDriver.hookFirst("compile",[t.path,t.sourcePath,e,Object.assign(Object.assign({},o),{independentRoot:t.independentRoot,isBabelIgnore:t.isBabelIgnore||!1})]);if(!i)throw new Error("not handle for "+t.sourcePath);return i}async optimize(e,t){return await this.pluginDriver.hookReduceArg0("optimize",[e,t],(e,t)=>t,e=>e)}async compress(e,t){return await this.pluginDriver.hookReduceArg0("compress",[e,t],(e,t)=>t,e=>e)}async compile(e,t){const{jsons:o}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSON(e,t)),i=await this.compileCodeWithoutJSON(e,t),r=await t.run(locales_1.default.config.SUMMER_PACK_FILES.format(),()=>this.compileOther(Object.keys(o),t)),s=Object.assign(Object.assign(Object.assign({},r),i),o);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[s])),s}async compileWithFileList(e,t){const o=e.fileList,{jsons:i}=await t.run(locales_1.default.config.SUMMER_COMPILE_JSON.format(),()=>this.compileJSONWithFileList(Object.assign(Object.assign({},e),{fileList:o.filter(e=>e.endsWith(".json"))}),t)),r=o.filter(e=>!e.endsWith(".json")),s=await this.compileCodeWithoutJSONWithFileList(Object.assign(Object.assign({},e),{fileList:r}),t),a=Object.assign(Object.assign({},s),i);return await t.run(locales_1.default.config.SUMMER_SEAL_PACK.format(),()=>this.pluginDriver.hookParallel("sealed",[a])),a}async getLocalFileList(){const e=this.getLocalCodeFileList(),t=new Set(this.resolver.allExts.map(e=>"."+e)),o=await this.getWhiteListConfig(),i=this.project.getFileList(this.root,"").filter(e=>{const i=path_1.default.posix.extname(e);return o.has(i)&&!t.has(i)}).map(e=>e.replace(new RegExp("^"+this.root),"")),r={};for(const t of e.concat(i)){const e=this.project.stat(this.root,t);r[t]=e}return r}async compileOther(e,t=progressRecorder_1.silentRecorder){const o=new Set(this.resolver.allExts.map(e=>"."+e));o.delete(".json");const i=await this.getWhiteListConfig(),r=this.project.getFileList(this.root,"").filter(r=>{const s=path_1.default.posix.extname(r),a=path_1.default.posix.relative(this.root,r);if(!i.has(s)||o.has(s)||e.includes(a))return!1;return!packOptionsHelper_1.default.isIgnoredByRules(r)||(t.message("warn",r+" is ignored by project.config.json packOptions.ignore setting"),!1)}),s=await(0,common_1.compileOther)(this.project,r,{onProgressUpdate:()=>{}}),a={};for(const e in s){a[path_1.default.posix.relative(this.root,e)]=s[e]}return a}async compileCodeWithoutJSON(e,t){var o;const i={},r=await this.getProdCode(t,Object.assign(Object.assign({},e),{package:config_1.FullPkg})),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach(e=>{s.add(e)}),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[e+".map"]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i)),i}async compileCodeWithoutJSONWithFileList(e,t){var o;const i={},r=await this.getProdCodeByFileList(t,e),s=new Set;for(const e in r){const t=r[e];if("error"in t)throw t.error;if(t.path.endsWith(".js")){((null===(o=t.jsTag)||void 0===o?void 0:o.helpers)||[]).forEach(e=>{s.add(e)}),i[e]=t.code;const r=t.map&&(0,tools_1.formatSourceMap)(t.map);r&&(i[e+".map"]=r)}else i[e]=t.code}return await t.run(locales_1.default.config.SUMMER_APPEND_BABEL_HELPERS.format((0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?"swc":"babel"),()=>(0,helper_util_1.appendHelpers)(this.project,s,"",i)),i}isBabelSettingIgnore(e){var t,o;let i=!1;if(e.path.endsWith(".js")){const r=(0,pluginconfig_1.couldUseSWCMode)(this.project.setting)?null===(t=this.compiler.getSWCSetting())||void 0===t?void 0:t.ignore:null===(o=this.compiler.getBabelSetting())||void 0===o?void 0:o.ignore;r&&(i=(0,babel_helper_1.isIgnore)(r,e.source))}return i}async getDevCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(o,e)}async getProdCodeByFileList(e,t){let o=await this.getPackageFile(config_1.FullPkg);return o=o.filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(o,e,{useCache:!1,resultType:t.resultType||"prod"})}}exports.BaseGraph=BaseGraph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tools_1=require("../../../utils/tools"),customError_1=require("../../../utils/customError"),basegraph_1=require("./graph/basegraph");class JsTag{constructor(){this.isLargeFile=!1,this.isBabelIgnore=!1,this.helpers=[],this.resultType="dev"}setBabelIgnore(){this.isBabelIgnore=!0}setLargeFile(){this.isLargeFile=!0}addHelpers(e){for(const t of e)this.helpers.includes(t)||this.helpers.push(t)}setResultType(e="dev"){this.resultType=e}toJSON(){return{isLargeFile:this.isLargeFile,isBabelIgnore:this.isBabelIgnore,helpers:this.helpers}}}class Module{constructor(e,t,s
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const tools_1=require("../../../utils/tools"),customError_1=require("../../../utils/customError"),basegraph_1=require("./graph/basegraph"),env_1=require("../../../utils/env");class JsTag{constructor(){this.isLargeFile=!1,this.isBabelIgnore=!1,this.helpers=[],this.resultType="dev"}setBabelIgnore(){this.isBabelIgnore=!0}setLargeFile(){this.isLargeFile=!0}addHelpers(e){for(const t of e)this.helpers.includes(t)||this.helpers.push(t)}setResultType(e="dev"){this.resultType=e}toJSON(){return{isLargeFile:this.isLargeFile,isBabelIgnore:this.isBabelIgnore,helpers:this.helpers}}}class Module{constructor(e,t,s){this.path=e,this.sourcePath=t,this.fileType=s,this._error={},this.generateResultPromise={},this.compileResultPromise={},this.depFiles=[],this.independentRoot="",this.isBabelIgnore=!1,this.generatedTS={}}transResultType(e){return this.fileType===basegraph_1.FileType.JS||this.fileType===basegraph_1.FileType.WXML?e:"common"}getGeneratedTS(e){return this.generatedTS[this.transResultType(e)]||0}setError(e,t){const s=this.transResultType(e);this._error[s]=t,this.generatedTS[s]=Date.now()}getError(e){const t=this.transResultType(e);return this._error[t]}async getJsTag(){if(this.fileType!==basegraph_1.FileType.JS)return;if(this._jsTag)return this._jsTag;const e=new JsTag;(await this.getSource()).largeFile&&e.setLargeFile();const t=await this.generateResultPromise.common;return t.target&&(e.addHelpers(t.target.helpers||[]),e.setResultType(t.target.resultType)),this.isBabelIgnore&&e.setBabelIgnore(),this._jsTag=e,e}async getJsTag2(){if(this.fileType!==basegraph_1.FileType.JS)return;if(this._jsTag)return this._jsTag;const e=new JsTag;(await this.getSource()).largeFile&&e.setLargeFile();const t=await this.compileResultPromise.common;return t.target&&(e.addHelpers(t.target.helpers||[]),e.setResultType(t.target.resultType)),this.isBabelIgnore&&e.setBabelIgnore(),this._jsTag=e,e}async getSource(){return(await this.getLoadingPromise()).source}async getMd5(){const e=await this.getSource();return(0,tools_1.generateMD5)(e.sourceCode)}setLoadingPromise(e){this.loadResult=e}async clearUselessCache(){if((0,env_1.isElectron)()&&this.path.endsWith(".js")){const e=await this.loadResult;if(e){const t=e.source;delete t.astInfo,delete t.inputMap}for(const e in this.generateResultPromise){const t=e;if(void 0!==this.generateResultPromise[t]){delete(await this.generateResultPromise[t]).source}}}}getLoadingPromise(){return this.loadResult}setGeneratingPromise(e,t){const s=this.transResultType(e);this.generateResultPromise[s]=t,this.generateResultPromise.common=t,t.then(()=>{this.generatedTS[s]=Date.now()})}getGeneratingPromise(e){const t=this.transResultType(e);return this.generateResultPromise[t]}getCompilePromise(e){const t=this.transResultType(e);return this.compileResultPromise[t]}setCompilePromise(e,t){const s=this.transResultType(e);this.compileResultPromise[s]=t,this.compileResultPromise.common=t}async getProcessInfo(e){var t;const s=this.getGeneratingPromise(e);return null===(t=await s)||void 0===t?void 0:t.process}async toCodeFile(e){const t=this.getError(e);if(t)return t instanceof customError_1.CustomError?{path:this.path,error:t.toJSON()}:{path:this.path,error:this._error};const s=this.getGeneratingPromise(e);if(void 0===s)return{path:this.path,error:"empty result"};const r=await this.getJsTag(),i=await this.getSource();try{return Object.assign({path:this.path,md5:await this.getMd5(),jsTag:null==r?void 0:r.toJSON(),mtime:i.mtime},(await s).target)}catch(e){return{path:this.path,error:e}}}async toCodeFile2(e){const t=this.getError(e);if(t)return t instanceof customError_1.CustomError?{path:this.path,error:t.toJSON()}:{path:this.path,error:this._error};const s=await this.getJsTag2(),r=await this.getSource(),i=this.getCompilePromise(e);if(void 0===i)return{path:this.path,error:"empty result"};const a=await i;try{return Object.assign({path:this.path,md5:await this.getMd5(),jsTag:null==s?void 0:s.toJSON(),mtime:r.mtime},a.target)}catch(e){return{path:this.path,error:e}}}async toGenerateResult(e){const t=this.getGeneratingPromise(e);if(void 0===t)return{path:this.path,error:"empty result"};const s=await t;return{targetPath:this.path,source:await this.getSource(),target:s.target,process:s.process||[]}}toJSON(){return{code:"",map:void 0,path:this.path,sourcePath:this.sourcePath,depFileIds:this.depFiles}}addWatchFile(e){-1===this.depFiles.indexOf(e)&&this.depFiles.push(e)}}exports.default=Module;
|