miniprogram-ci 2.0.6 → 2.0.8
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 -2
- 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/processHandler.d.ts +23 -0
- package/dist/@types/modules/corecompiler/summer/graph/appgraph.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/graph/basegraph.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/graph/gamegraph.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/graph/gameplugingraph.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/graph/plugingraph.d.ts +3 -0
- package/dist/@types/modules/corecompiler/summer/summer.d.ts +1 -0
- package/dist/@types/modules/corecompiler/summerCompiler.d.ts +17 -1
- package/dist/@types/modules/index.d.ts +4 -2
- package/dist/@types/modules/nativecompiler/ios/buildCloud.d.ts +2 -2
- package/dist/@types/types/devtools.d.ts +7 -0
- package/dist/@types/utils/debug.d.ts +3 -0
- package/dist/@types/utils/miniappJson.d.ts +1 -0
- package/dist/@types/utils/tools.d.ts +1 -0
- package/dist/config/config.js +1 -1
- package/dist/modules/corecompiler/processHandler.js +1 -0
- package/dist/modules/corecompiler/summer/graph/appgraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/basegraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/gamegraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/gameplugingraph.js +1 -1
- package/dist/modules/corecompiler/summer/graph/plugingraph.js +1 -1
- package/dist/modules/corecompiler/summer/pluginDriver.js +1 -1
- package/dist/modules/corecompiler/summer/plugins/sass.js +1 -1
- package/dist/modules/corecompiler/summer/summer.js +1 -1
- package/dist/modules/corecompiler/summerCompiler.js +1 -1
- package/dist/modules/corecompiler/summerEntryProcess.js +1 -1
- package/dist/modules/index.js +1 -1
- package/dist/modules/nativecompiler/ios/buildCloud.js +1 -1
- package/dist/modules/nativecompiler/ios/index.js +1 -1
- package/dist/project/baseProject.js +1 -1
- package/dist/schema/dist/app.js +4 -1
- package/dist/schema/dist/ext.js +4 -1
- package/dist/schema/dist/game.js +1 -1
- package/dist/schema/dist/page.js +1 -1
- package/dist/schema/dist/plugin.js +1 -1
- package/dist/schema/dist/pluginpage.js +1 -1
- package/dist/schema/dist/projectconfig.js +4 -1
- package/dist/schema/dist/projectprivateconfig.js +4 -1
- package/dist/schema/dist/sitemap.js +1 -1
- package/dist/schema/dist/theme.js +1 -1
- package/dist/utils/codesign.js +1 -1
- package/dist/utils/debug.js +1 -0
- package/dist/utils/miniapp-builder.js +1 -1
- package/dist/utils/miniappJson.js +1 -1
- package/dist/utils/subprocess/processManager.js +1 -1
- package/dist/utils/tools.js +1 -1
- package/package.json +101 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
#### 2.0.
|
|
2
|
-
- `fix` 修复
|
|
1
|
+
#### 2.0.8
|
|
2
|
+
- `fix` 修复 babel 导致的 path.requeueComputedKeyAndDecorators 问题
|
|
3
|
+
#### 2.0.7
|
|
4
|
+
- `fix` 修复 Skyline disableScroll 不强制为 true
|
|
3
5
|
#### 2.0.5
|
|
4
6
|
- `fix` 修复 命令行执行完不退出的问题
|
|
5
7
|
- `fix` 修复 输出日志为[object Object]的问题
|
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@ miniprogram-ci 从 1.0.28 开始支持第三方平台开发的上传和预览,
|
|
|
8
8
|
|
|
9
9
|
## 最近变更
|
|
10
10
|
|
|
11
|
+
#### 2.0.8
|
|
12
|
+
- `fix` 修复 babel 导致的 path.requeueComputedKeyAndDecorators 问题
|
|
13
|
+
#### 2.0.7
|
|
14
|
+
- `fix` 修复 Skyline disableScroll 不强制为 true
|
|
11
15
|
#### 2.0.6
|
|
12
16
|
- `fix` 修复 未设置 onProgressUpdate 输出日志为[object Object]的问题
|
|
13
17
|
#### 2.0.5
|
|
@@ -106,6 +106,7 @@ export declare abstract class BaseCoreCompiler {
|
|
|
106
106
|
}>;
|
|
107
107
|
abstract getPackageFiles(graphId: MiniProgramDevtools.GraphId, root: string): Promise<FileInfo[]>;
|
|
108
108
|
abstract getSubPkgSortedJSFiles(rootPath: string): Promise<{
|
|
109
|
+
entryJS: string;
|
|
109
110
|
allFiles: string[];
|
|
110
111
|
pageFiles: string[];
|
|
111
112
|
componentFiles: string[];
|
|
@@ -93,6 +93,7 @@ export declare class OriginalCompiler extends BaseCoreCompiler {
|
|
|
93
93
|
}>;
|
|
94
94
|
getPackageFiles(graphId: MiniProgramDevtools.GraphId, root: string): Promise<FileInfo[]>;
|
|
95
95
|
getSubPkgSortedJSFiles(_rootPath: string): Promise<{
|
|
96
|
+
entryJS: string;
|
|
96
97
|
allFiles: string[];
|
|
97
98
|
pageFiles: string[];
|
|
98
99
|
componentFiles: string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MiniProgramDevtools } from '../../types';
|
|
2
|
+
interface IProcessMsg {
|
|
3
|
+
type: 'progress';
|
|
4
|
+
id: number;
|
|
5
|
+
taskId: number;
|
|
6
|
+
status: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
interface IResponseMsg {
|
|
10
|
+
type: 'response';
|
|
11
|
+
id: number;
|
|
12
|
+
data: any;
|
|
13
|
+
error?: {
|
|
14
|
+
code: number;
|
|
15
|
+
message: string;
|
|
16
|
+
stack: string;
|
|
17
|
+
path: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
type ICallbackMsg = IProcessMsg | IResponseMsg;
|
|
21
|
+
export declare function initHandler(message: MiniProgramDevtools.InitMsg): Promise<void>;
|
|
22
|
+
export declare function messageHandler(message: MiniProgramDevtools.SummerProcessMessage): Promise<ICallbackMsg | undefined>;
|
|
23
|
+
export {};
|
|
@@ -10,6 +10,9 @@ export declare class AppGraph extends BaseGraph {
|
|
|
10
10
|
getConf(recorder: Recorder): Promise<MiniProgramDevtools.IAppConf>;
|
|
11
11
|
compileSingleCode(filePath: string, sourceCode?: string): Promise<MiniProgramDevtools.CodeFile>;
|
|
12
12
|
getDevCode(recorder: Recorder, options: MiniProgramDevtools.IPackageCodeOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
|
+
getDevCodeByFileList(recorder: Recorder, options: {
|
|
14
|
+
fileList: string[];
|
|
15
|
+
}): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
16
|
getProdCode(recorder: Recorder, options: MiniProgramDevtools.IPackageCodeOptions & MiniProgramCore.ICompileOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
14
17
|
protected getLocalCodeFileList(): string[];
|
|
15
18
|
protected onFileChangeForGraph(type: 'unlink' | 'unlinkDir' | 'add' | 'addDir' | 'change', path: string): void;
|
|
@@ -76,6 +76,9 @@ export declare abstract class BaseGraph {
|
|
|
76
76
|
protected isBabelSettingIgnore(fileInfo: ResolveFileInfo): boolean;
|
|
77
77
|
protected abstract onFileChangeForGraph(type: 'unlink' | 'unlinkDir' | 'add' | 'addDir' | 'change', path: string): void;
|
|
78
78
|
abstract getConf(recorder: Recorder): Promise<MiniProgramDevtools.IAppConf | MiniProgramDevtools.IPluginConf | MiniProgramDevtools.IGameConf | MiniProgramDevtools.IGamePluginConf>;
|
|
79
|
+
abstract getDevCodeByFileList(recorder: Recorder, options: {
|
|
80
|
+
fileList: string[];
|
|
81
|
+
}): Promise<MiniProgramDevtools.CodeFiles>;
|
|
79
82
|
abstract getDevCode(recorder: Recorder, options?: MiniProgramDevtools.IPackageCodeOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
80
83
|
abstract getProdCode(recorder: Recorder, options?: MiniProgramDevtools.IPackageCodeOptions & MiniProgramCore.ICompileOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
81
84
|
abstract compileSingleCode(filePath: string, sourceCode?: string): Promise<MiniProgramDevtools.CodeFile>;
|
|
@@ -10,6 +10,9 @@ export declare class GameGraph extends BaseGraph {
|
|
|
10
10
|
getConf(recorder: Recorder): Promise<MiniProgramDevtools.IGameConf>;
|
|
11
11
|
compileSingleCode(filePath: string, sourceCode?: string): Promise<MiniProgramDevtools.CodeFile>;
|
|
12
12
|
getDevCode(recorder: Recorder, options: MiniProgramDevtools.IPackageCodeOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
|
+
getDevCodeByFileList(recorder: Recorder, options: {
|
|
14
|
+
fileList: string[];
|
|
15
|
+
}): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
16
|
getProdCode(recorder: Recorder, options: MiniProgramDevtools.IPackageCodeOptions & MiniProgramCore.ICompileOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
14
17
|
protected getLocalCodeFileList(): string[];
|
|
15
18
|
protected onFileChangeForGraph(type: 'unlink' | 'unlinkDir' | 'add' | 'addDir' | 'change', path: string): void;
|
|
@@ -10,6 +10,9 @@ export declare class GamePluginGraph extends BaseGraph {
|
|
|
10
10
|
getConf(recorder: Recorder): Promise<MiniProgramDevtools.IGamePluginConf>;
|
|
11
11
|
compileSingleCode(filePath: string, sourceCode?: string): Promise<MiniProgramDevtools.CodeFile>;
|
|
12
12
|
getDevCode(recorder: Recorder): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
|
+
getDevCodeByFileList(recorder: Recorder, options: {
|
|
14
|
+
fileList: string[];
|
|
15
|
+
}): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
16
|
getProdCode(recorder: Recorder, options: MiniProgramDevtools.IPackageCodeOptions & MiniProgramCore.ICompileOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
14
17
|
protected getLocalCodeFileList(): string[];
|
|
15
18
|
protected onFileChangeForGraph(type: 'unlink' | 'unlinkDir' | 'add' | 'addDir' | 'change', path: string): void;
|
|
@@ -10,6 +10,9 @@ export declare class PluginGraph extends BaseGraph {
|
|
|
10
10
|
getConf(recorder: Recorder): Promise<MiniProgramDevtools.IPluginConf>;
|
|
11
11
|
compileSingleCode(filePath: string, sourceCode?: string): Promise<MiniProgramDevtools.CodeFile>;
|
|
12
12
|
getDevCode(recorder: Recorder): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
|
+
getDevCodeByFileList(recorder: Recorder, options: {
|
|
14
|
+
fileList: string[];
|
|
15
|
+
}): Promise<MiniProgramDevtools.CodeFiles>;
|
|
13
16
|
getProdCode(recorder: Recorder, options: MiniProgramDevtools.IPackageCodeOptions & MiniProgramCore.ICompileOptions): Promise<MiniProgramDevtools.CodeFiles>;
|
|
14
17
|
protected getLocalCodeFileList(): string[];
|
|
15
18
|
protected onFileChangeForGraph(type: 'unlink' | 'unlinkDir' | 'add' | 'addDir' | 'change', path: string): void;
|
|
@@ -34,6 +34,7 @@ export declare class SummerCompiler {
|
|
|
34
34
|
getPackageFiles({ graphId, root, }: MiniProgramDevtools.IGetPackageFilesOptions): Promise<import("./graph/basegraph").FileInfo[] | undefined>;
|
|
35
35
|
getConf({ graphId }: MiniProgramDevtools.IGetConfOptions, recorder: Recorder): Promise<MiniProgramDevtools.IAppConf | MiniProgramDevtools.IPluginConf | MiniProgramDevtools.IGameConf | MiniProgramDevtools.IGamePluginConf>;
|
|
36
36
|
getCode(options: MiniProgramDevtools.IGetCodeOptions, recorder: Recorder): Promise<MiniProgramDevtools.CodeFiles>;
|
|
37
|
+
getDevCodeByFileList(options: MiniProgramDevtools.IGetCodeByFileListOptions, recorder: Recorder): Promise<MiniProgramDevtools.CodeFiles>;
|
|
37
38
|
getLocalFileList(graphId: MiniProgramDevtools.GraphId): Promise<MiniProgramCore.IFileInfos>;
|
|
38
39
|
compileSingleCode(options: MiniProgramDevtools.ICompileSingleCodeOptions, recorder: Recorder): Promise<MiniProgramDevtools.CodeFile>;
|
|
39
40
|
compile(options: MiniProgramCore.ICompileOptions, recorder: Recorder): Promise<MiniProgramDevtools.ICompileResult>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { MiniProgramDevtools, MiniProgramCore, ExtJSON } from '../../types';
|
|
3
|
+
import { FileInfo } from './summer/graph/basegraph';
|
|
3
4
|
import { SubProcessProxy } from '../../utils/subprocess/processManager';
|
|
4
5
|
import { IMessageHub } from '../../utils/messageHub';
|
|
5
6
|
import { BaseCoreCompiler } from './baseCompiler';
|
|
@@ -17,6 +18,7 @@ export declare class SummerCompiler extends BaseCoreCompiler {
|
|
|
17
18
|
_status: MiniProgramDevtools.ICompilerStatus | undefined;
|
|
18
19
|
private _eventAdded;
|
|
19
20
|
private _locale;
|
|
21
|
+
private codeCacheByPath;
|
|
20
22
|
constructor(project: MiniProgramCore.IPreCompileProject, cachePath: string, projectInfo: MiniProgramDevtools.IDevtoolsProjectInfo, devtoolMessagehub: IMessageHub);
|
|
21
23
|
get status(): MiniProgramDevtools.ICompilerStatus | undefined;
|
|
22
24
|
protected init(): Promise<void>;
|
|
@@ -31,7 +33,8 @@ export declare class SummerCompiler extends BaseCoreCompiler {
|
|
|
31
33
|
private invalidCodeCache;
|
|
32
34
|
private onProgressUpdate;
|
|
33
35
|
private getConf;
|
|
34
|
-
getPackageFiles(graphId: MiniProgramDevtools.GraphId, root: string): Promise<
|
|
36
|
+
getPackageFiles(graphId: MiniProgramDevtools.GraphId, root: string): Promise<FileInfo[]>;
|
|
37
|
+
private getCodeByFileList;
|
|
35
38
|
private getCode;
|
|
36
39
|
getExtJSON(): Promise<ExtJSON.IExtJSON>;
|
|
37
40
|
getAppJSON(): Promise<any>;
|
|
@@ -69,11 +72,24 @@ export declare class SummerCompiler extends BaseCoreCompiler {
|
|
|
69
72
|
otherFiles: string[];
|
|
70
73
|
}>;
|
|
71
74
|
getSubPkgSortedJSFiles(rootPath: string): Promise<{
|
|
75
|
+
entryJS: string;
|
|
72
76
|
allFiles: string[];
|
|
73
77
|
pageFiles: string[];
|
|
74
78
|
componentFiles: string[];
|
|
75
79
|
otherFiles: string[];
|
|
76
80
|
}>;
|
|
81
|
+
compileJSList(options: {
|
|
82
|
+
root: string;
|
|
83
|
+
fileList: string[];
|
|
84
|
+
babelRoot: string;
|
|
85
|
+
}): Promise<{
|
|
86
|
+
isLargeFile?: boolean | undefined;
|
|
87
|
+
isBabelIgnore?: boolean | undefined;
|
|
88
|
+
helpers?: string[] | undefined;
|
|
89
|
+
filePath: string;
|
|
90
|
+
code: string;
|
|
91
|
+
map: string | import("../../types").MiniProgramSummer.SourceMap | undefined;
|
|
92
|
+
}[]>;
|
|
77
93
|
compileJS(options: {
|
|
78
94
|
root: string;
|
|
79
95
|
filePath: string;
|
|
@@ -24,12 +24,14 @@ export declare class Builder {
|
|
|
24
24
|
private _nativeCompiler;
|
|
25
25
|
private _options;
|
|
26
26
|
private _checkReadyTask?;
|
|
27
|
+
private _getSummerCompilerTask?;
|
|
27
28
|
private _originalCompiler;
|
|
28
29
|
constructor(project: MiniProgramCI.IProject, opts: IBuilderOptions);
|
|
29
|
-
getCompiler(): Promise<
|
|
30
|
+
getCompiler(): Promise<any>;
|
|
30
31
|
getPreCompileProject(): Promise<PreCompileProject>;
|
|
31
32
|
getPreCompiler(): Promise<PreCompiler>;
|
|
32
|
-
getSummerCompiler(): Promise<
|
|
33
|
+
getSummerCompiler(): Promise<any>;
|
|
34
|
+
private _getSummerCompiler;
|
|
33
35
|
ready(): Promise<any>;
|
|
34
36
|
init(): Promise<void>;
|
|
35
37
|
getNativeCompiler(): Promise<NativeCompiler>;
|
|
@@ -4,7 +4,6 @@ import { IEntitlements } from '../../../utils/codesign';
|
|
|
4
4
|
import II18NInfo = IMiniApp.II18NInfo;
|
|
5
5
|
type ITheme = 'Light' | 'LightSpecial' | 'Dark' | 'DarkSpecial' | 'Default';
|
|
6
6
|
export declare const remoteBuildProjectMaterialAbsoluteCacheDir = "__absoluteFile";
|
|
7
|
-
export declare const privateDescriptions: string[];
|
|
8
7
|
export interface IBuildCloudResult {
|
|
9
8
|
projectPath: string;
|
|
10
9
|
demoIpaPath: string;
|
|
@@ -27,7 +26,8 @@ declare class buildCloudManager {
|
|
|
27
26
|
updateIOSAppexInfoPlistInfo(bindAppInfo: MiniProgramCore.IStringKeyMap, demoIpaPath: string, iosMiniappJson: MiniProgramCore.IStringKeyMap, CFBundleVersion: number, recorder: Recorder): Promise<void>;
|
|
28
27
|
private updateBundleIcons;
|
|
29
28
|
updateIOSIcons(projectPath: string, demoIpaPath: string, miniappCacheDirPath: string, iosMiniappJson: MiniProgramCore.IStringKeyMap, isPublish: boolean, recorder: Recorder): Promise<void>;
|
|
30
|
-
|
|
29
|
+
replaceLaunchScreenImage(storyboardPath: string, newScreenImagePath: string, oldScreenImageName: string, recorder: Recorder, projectPath: string, demoIpaPath: string): string | undefined;
|
|
30
|
+
updateSplashScreen(projectPath: string, demoIpaPath: string, iosMiniappJson: MiniProgramCore.IStringKeyMap, recorder: Recorder, theme: ITheme | undefined, i18nInfo: II18NInfo): Promise<void>;
|
|
31
31
|
genUseExtendedSdk(iosMiniappJson: MiniProgramCore.IStringKeyMap): MiniProgramCore.IStringKeyMap<any>;
|
|
32
32
|
updateExtendedSdk(bindAppInfo: MiniProgramCore.IStringKeyMap, demoIpaPath: string, sdkPath: string, arch: string, iosMiniappJson: MiniProgramCore.IStringKeyMap, recorder: Recorder): Promise<void>;
|
|
33
33
|
updatePrivacyInfo(demoIpaPath: string, iosMiniappJson: MiniProgramCore.IStringKeyMap, recorder: Recorder): Promise<void>;
|
|
@@ -63,6 +63,12 @@ export declare namespace MiniProgramDevtools {
|
|
|
63
63
|
cacheMd5: Record<string, string>;
|
|
64
64
|
package?: string;
|
|
65
65
|
};
|
|
66
|
+
type IGetCodeByFileListOptions = {
|
|
67
|
+
graphId: GraphId;
|
|
68
|
+
cacheMd5: Record<string, string>;
|
|
69
|
+
fileList: string[];
|
|
70
|
+
package?: string;
|
|
71
|
+
};
|
|
66
72
|
interface IDevtoolsProject {
|
|
67
73
|
id: string;
|
|
68
74
|
appid: string;
|
|
@@ -210,6 +216,7 @@ export declare namespace MiniProgramDevtools {
|
|
|
210
216
|
[key in string]: any;
|
|
211
217
|
}]>;
|
|
212
218
|
ignoreUploadUnusedFiles?: boolean;
|
|
219
|
+
ignoreCodeQuality?: boolean;
|
|
213
220
|
ignoreDevUnusedFiles?: boolean;
|
|
214
221
|
bigPackageSizeSupport?: boolean;
|
|
215
222
|
}
|
|
@@ -148,4 +148,5 @@ export declare function iOSAppJsonIsUsingIPadResizable(projectPath: string): boo
|
|
|
148
148
|
export declare function getRawAppJSON(projectPath: string): any;
|
|
149
149
|
export declare function getMiniprogramRoot(projectPath: string): any;
|
|
150
150
|
export declare function getTargetMiniprogramArg(projectPath: string, targetArg: string): any;
|
|
151
|
+
export declare const iosPrivacyDescObj: Record<string, string>;
|
|
151
152
|
export {};
|
|
@@ -38,3 +38,4 @@ export declare const pathRelative: (left: string, right: string) => string;
|
|
|
38
38
|
export declare function isLeftSubPathOfRight(child: string, parent: string): boolean;
|
|
39
39
|
export declare function isGameApp(project: MiniProgramCI.IProject): boolean;
|
|
40
40
|
export declare const checkIsUseCompilerPlugins: () => boolean;
|
|
41
|
+
export declare const sourcePathToTargetPath: (sourcePath: string) => string;
|
package/dist/config/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var COMPILE_TYPE,AstType;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.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.0.
|
|
1
|
+
"use strict";var COMPILE_TYPE,AstType;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.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.0.8",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={}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.messageHandler=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");let summercompileManager,preCompiler,summerProject,precompileProject,inited=!1;function processSend(e){if((0,debug_1.shouldRunInMainProcess)())return e;process.send(e)}async function initHandler(e){const{passData:r,projectInfo:t,options:a}=e.data;if(inited)return;summerProject=new summerCPProject_1.SummerCPProject(t),await summerProject.ready();const{targetPlatform:o,targetPlatformDefines:s}=t;preCompiler=new index_1.PreCompiler(summerProject),precompileProject=await preCompiler.getPreCompileProject({targetPlatform:o,targetPlatformDefines:s,runEnv:"summer cp"});const{cachePath:i}=r;summercompileManager=new summer_1.SummerCompiler(precompileProject,i,a),inited=!0}async function getCodeFiles(e,r,t){let a={};"getDevCodeByFileList"===e?a=await r.run(`getDevCodeByFileList-${t.graphId}-${t.package}`,()=>summercompileManager.getDevCodeByFileList(t,r)):"getCode"===e&&(a=await r.run(`getCode-${t.graphId}-${t.package}`,()=>summercompileManager.getCode(t,r)));const{cacheMd5:o}=t;for(const e of Object.keys(o)){const r=a[e];r?"error"in r||r.md5!==o[e]||delete a[e]:a[e]={path:e,md5:"",code:""}}for(const e of Object.values(a))"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 a}async function messageHandler(e){if("event"===e.type)if("fileChange"===e.name){const{type:r,targetPath:t}=e.data;summerProject.onFileChange(r,t)}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:t,data:a}=e,o=r,s=new progressRecorder_1.Recorder((e,r,t)=>{processSend({type:"progress",id:e,taskId:o,status:r,message:t})});try{let e;if("getCode"===t||"getDevCodeByFileList"===t)e=await getCodeFiles(t,s,a);else if("getPackageFiles"===t)e=await summercompileManager.getPackageFiles(a);else if("getConf"===t)e=await summercompileManager.getConf(a,s);else if("getLocalFileList"===t)e=await summercompileManager.getLocalFileList(a);else if("compile"===t)e=await summercompileManager.compile(a,s);else if("compileSingleCode"===t)e=await summercompileManager.compileSingleCode(a,s);else if("setLocale"===t)(0,index_2.setLocale)(a);else if("clearCache"===t)summercompileManager.clearCache();else{if("loadStatus"!==t)throw new Error("unknown command "+t);e=summercompileManager.getStatus()}return processSend({type:"response",id:r,data:e})}catch(e){return processSend({type:"response",id:r,data:null,error:{code:e.code||-1,message:e.message,stack:e.stack,path:e.path||""}})}}}exports.initHandler=initHandler,exports.messageHandler=messageHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const tools_1=require("../../../../utils/tools"),mpjson_1=require("../../original/compile/handler/mpjson"),config_1=require("../../../../config/config"),progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/"))return"functional-pages";if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app);const{pageResults:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppGraph=void 0;const tools_1=require("../../../../utils/tools"),mpjson_1=require("../../original/compile/handler/mpjson"),config_1=require("../../../../config/config"),progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),appconf_1=require("./appconf"),basegraph_1=require("./basegraph");class AppGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new appconf_1.AppConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getDevCodeByFileList(e,t){let s=await this.getPackageFile(config_1.FullPkg);return s=s.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("object"==typeof this.conf.app.functionalPages&&!0===this.conf.app.functionalPages.independent&&e.startsWith("functional-pages/"))return"functional-pages";if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),o={};o["app.json"]=JSON.stringify(s.app);const{pageResults:i,componentResults:n}=await this.appConf.buildPagesAndCompsForUpload(progressRecorder_1.silentRecorder,e.disableSpreadingUsingComponents);return(0,mpjson_1.addSkylineRendererToComponents)(i,n),{conf:s,jsons:Object.assign(Object.assign(Object.assign({},o),i),n)}}}exports.AppGraph=AppGraph;
|
|
@@ -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"),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.onFileAndDirChange=()=>{this.resolver.updateFileAndDirs()},this.getCodeFileTask=async(e,t,o={useCache:!0})=>{const i=await this.loadModuleFromFile(e,t,o),r=i.toCodeFile();if(!("error"in r)&&"prod"===o.resultType){const e=i.toGenerateResult(),t=await this.optimize(e,o),s=await this.compress(t,o);r.code=s.target.code,r.map=s.target.map}return{file:e,codeFile:r,process:i.processInfo||[]}},this.type=e.type,this.root=e.root,this.rootPath=path_1.default.posix.join(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(){this.compiler.proxyProject.removeResolver(this.resolver)}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)}async loadModuleFromFile(e,t,o={}){var i;let r=this.modulesByPath.get(e.path);if(null==r?void 0:r.loadingPromise)return await r.loadingPromise,this.loadModuleFromFile(e,t,o);let s=!r||r.sourcePath!==e.source||r.independentRoot!==e.independentRoot;if(!s&&(null==r?void 0:r.error)){if(r.loadEnd+1e3>Date.now())return r;s=!0}if(s){const s=getFileType(e.path);r=new module_1.default(this,e.path,e.source,s),r.independentRoot=e.independentRoot,e.isBabelIgnore&&(null===(i=r.jsTag)||void 0===i||i.setBabelIgnore()),this.modulesByPath.set(e.path,r),r.loadingPromise=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(r,o)),await r.loadingPromise,r.loadingPromise=void 0}return r}async loadSourceForModule(e,t={}){var o,i;try{const r=path_1.default.posix.join(this.rootPath,e.sourcePath),s=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))}}),a=null!==(i=await this.pluginDriver.hookFirst("load",[e.path,r,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:(null===(o=e.jsTag)||void 0===o?void 0:o.isBabelIgnore)||!1})],s))&&void 0!==i?i:{targetPath:e.path,source:{sourceCode:await this.readFile(r)},process:[{pluginName:"readFile",action:"load"}]},n=await this.tranform(a,e,s,t),l=await this.generate(n,e,s,t);return e.setResult(l),!0}catch(t){return t.path=path_1.default.posix.join(this.root,e.sourcePath),e.setError(t),!1}}async doCompileSingleCode(e,t){const o=getFileType(e.path),i=new module_1.default(this,e.path,e.source,o);if(await this.loadSourceForModule(i),i.error)throw i.error;return i.toCodeFile()}async getCodeFiles(e,t,o={useCache:!0,resultType:"dev"}){const i=Date.now(),r={},s=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const i of e)s.addTask(this.getCodeFileTask,i,t,o);const a=await s.runAllAsync();for(const e of a)r[e.file.path]=e.codeFile;return console.info(
|
|
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"),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.onFileAndDirChange=()=>{this.resolver.updateFileAndDirs()},this.getCodeFileTask=async(e,t,o={useCache:!0})=>{const i=await this.loadModuleFromFile(e,t,o),r=i.toCodeFile();if(!("error"in r)&&"prod"===o.resultType){const e=i.toGenerateResult(),t=await this.optimize(e,o),s=await this.compress(t,o);r.code=s.target.code,r.map=s.target.map}return{file:e,codeFile:r,process:i.processInfo||[]}},this.type=e.type,this.root=e.root,this.rootPath=path_1.default.posix.join(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)}async loadModuleFromFile(e,t,o={}){var i;let r=this.modulesByPath.get(e.path);if(null==r?void 0:r.loadingPromise)return await r.loadingPromise,this.loadModuleFromFile(e,t,o);let s=!r||r.sourcePath!==e.source||r.independentRoot!==e.independentRoot;if(!s&&(null==r?void 0:r.error)){if(r.loadEnd+1e3>Date.now())return r;s=!0}if(s){const s=getFileType(e.path);r=new module_1.default(this,e.path,e.source,s),r.independentRoot=e.independentRoot,e.isBabelIgnore&&(null===(i=r.jsTag)||void 0===i||i.setBabelIgnore()),this.modulesByPath.set(e.path,r),r.loadingPromise=t.run(locales_1.default.config.SUMMER_COMPILING_MODULE.format(e.source),()=>this.loadSourceForModule(r,o)),await r.loadingPromise,r.loadingPromise=void 0}return r}async loadSourceForModule(e,t={}){var o,i;try{const r=path_1.default.posix.join(this.rootPath,e.sourcePath),s=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))}}),a=null!==(i=await this.pluginDriver.hookFirst("load",[e.path,r,Object.assign(Object.assign({},t),{independentRoot:e.independentRoot,isBabelIgnore:(null===(o=e.jsTag)||void 0===o?void 0:o.isBabelIgnore)||!1})],s))&&void 0!==i?i:{targetPath:e.path,source:{sourceCode:await this.readFile(r)},process:[{pluginName:"readFile",action:"load"}]},n=await this.tranform(a,e,s,t),l=await this.generate(n,e,s,t);return e.setResult(l),!0}catch(t){return t.path=path_1.default.posix.join(this.root,e.sourcePath),e.setError(t),!1}}async doCompileSingleCode(e,t){const o=getFileType(e.path),i=new module_1.default(this,e.path,e.source,o);if(await this.loadSourceForModule(i),i.error)throw i.error;return i.toCodeFile()}async getCodeFiles(e,t,o={useCache:!0,resultType:"dev"}){const i=Date.now(),r={},s=new taskmanager_1.default({poolLimit:10,breakWhenError:!0});for(const i of e)s.addTask(this.getCodeFileTask,i,t,o);const a=await s.runAllAsync();for(const e of a)r[e.file.path]=e.codeFile;return console.info("!!!",`getCodeFiles: count: ${e.length}, cost: ${Date.now()-i}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,o,i={}){var r;return await this.pluginDriver.hookReduceArg0("transform",[e,t.path,t.sourcePath,Object.assign(Object.assign({},i),{independentRoot:t.independentRoot,isBabelIgnore:(null===(r=t.jsTag)||void 0===r?void 0:r.isBabelIgnore)||!1})],(function(e,t){return void 0===t?e:t}),o)}async generate(e,t,o,i={}){var r;const s=await this.pluginDriver.hookFirst("generate",[e,t.path,t.sourcePath,Object.assign(Object.assign({},i),{independentRoot:t.independentRoot,isBabelIgnore:(null===(r=t.jsTag)||void 0===r?void 0:r.isBabelIgnore)||!1})]);return void 0===s||(0,lodash_1.isNull)(s)?Object.assign(Object.assign({},e),{target:{code:e.source.sourceCode,map:e.source.inputMap}}):s}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))),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 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){const t=new Set(this.resolver.allExts.map(e=>"."+e));t.delete(".json");const 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)}),r=await(0,common_1.compileOther)(this.project,i,{onProgressUpdate:()=>{}}),s={};for(const t in r){const o=path_1.default.posix.relative(this.root,t);e.includes(o)||(s[o]=r[t])}return s}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}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}}exports.BaseGraph=BaseGraph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameGraph=void 0;const tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),white_ext_list_1=require("../../../../utils/white_ext_list"),progressRecorder_1=require("../../../../utils/progressRecorder"),gameconf_1=require("./gameconf"),basegraph_1=require("./basegraph");class GameGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new gameconf_1.GameConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GameGraph=void 0;const tools_1=require("../../../../utils/tools"),config_1=require("../../../../config/config"),white_ext_list_1=require("../../../../utils/white_ext_list"),progressRecorder_1=require("../../../../utils/progressRecorder"),gameconf_1=require("./gameconf"),basegraph_1=require("./basegraph");class GameGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.appConf=new gameconf_1.GameConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.appConf.destroy(),super.destroy()}async getConf(e){return this.conf=await this.appConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const s=this.resolver.resolveInfoMap.get(e);if(s)return super.doCompileSingleCode(Object.assign(Object.assign({},s),{independentRoot:this.getIndependentRoot(s.path),isBabelIgnore:this.isBabelSettingIgnore(s)}),t);throw new Error("file not found")}async getDevCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e)}async getDevCodeByFileList(e,t){let s=await this.getPackageFile(config_1.FullPkg);return s=s.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(s,e)}async getProdCode(e,t){let s=await this.getPackageFile(t.package);return s=s.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(s,e,Object.assign(Object.assign({},t),{useCache:!1}))}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){this.appConf.onFileChange(e,t)}getIndependentRoot(e){for(const t of Object.values(this.conf.packages))if(!0===t.independent){const s=t.root.replace(/^\//,"");if(e.startsWith(s))return s}if("string"==typeof this.conf.app.openDataContext&&e.startsWith(this.conf.app.openDataContext))return this.conf.app.openDataContext;const t=this.conf.app.workers&&(0,tools_1.getWorkersPath)(this.conf.app.workers);return t&&e.startsWith(t)?t:""}checkFilePackage(e){for(const t of Object.keys(this.conf.packages))if(e.startsWith(t))return t;return config_1.MainPkg}async compileJSON(e,t){const s=await this.getConf(progressRecorder_1.silentRecorder),i={};return i["game.json"]=JSON.stringify(s.app),{conf:s,jsons:Object.assign({},i)}}}exports.GameGraph=GameGraph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),gamepluginconf_1=require("./gamepluginconf"),config_1=require("../../../../config/config");class GamePluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new gamepluginconf_1.GamePluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getProdCode(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(){await this.ensureConf(progressRecorder_1.silentRecorder);const e=[];for(const[t,i]of this.resolver.resolveInfoMap.entries())e.push(i);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}checkFilePackage(e){return config_1.MainPkg}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};return t["plugin.json"]=JSON.stringify(e.plugin),{conf:e,jsons:t}}}exports.GamePluginGraph=GamePluginGraph;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.GamePluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),gamepluginconf_1=require("./gamepluginconf"),config_1=require("../../../../config/config");class GamePluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new gamepluginconf_1.GamePluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.GameWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getDevCodeByFileList(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e)}async getProdCode(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(){await this.ensureConf(progressRecorder_1.silentRecorder);const e=[];for(const[t,i]of this.resolver.resolveInfoMap.entries())e.push(i);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}checkFilePackage(e){return config_1.MainPkg}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};return t["plugin.json"]=JSON.stringify(e.plugin),{conf:e,jsons:t}}}exports.GamePluginGraph=GamePluginGraph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),pluginconf_1=require("./pluginconf"),config_1=require("../../../../config/config");class PluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new pluginconf_1.PluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getProdCode(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(){await this.ensureConf(progressRecorder_1.silentRecorder);const e=[];for(const[t,i]of this.resolver.resolveInfoMap.entries())e.push(i);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}checkFilePackage(e){return config_1.MainPkg}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};t["plugin.json"]=JSON.stringify(e.plugin);for(const i in e.pages)t[i+".json"]=JSON.stringify(e.pages[i]);for(const i in e.comps)t[i+".json"]=JSON.stringify(e.comps[i]);return{conf:e,jsons:t}}}exports.PluginGraph=PluginGraph;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginGraph=void 0;const progressRecorder_1=require("../../../../utils/progressRecorder"),white_ext_list_1=require("../../../../utils/white_ext_list"),basegraph_1=require("./basegraph"),pluginconf_1=require("./pluginconf"),config_1=require("../../../../config/config");class PluginGraph extends basegraph_1.BaseGraph{constructor(e){super(e),this.pluginConf=new pluginconf_1.PluginConf(this.compiler.proxyProject,this.root)}async getWhiteListConfig(){if(!this._whiteListConfig){const e=await(0,white_ext_list_1.getWhiteExtList)();this._whiteListConfig=e.MiniProgramWhiteList}return this._whiteListConfig}destroy(){this.pluginConf.destroy(),super.destroy()}async getConf(e){if("plugin"!==this.type)throw new Error("Couldn't call getAppConf without plugin type");return this.conf=await this.pluginConf.getConf(e),this.conf}async compileSingleCode(e,t){await this.ensureConf(progressRecorder_1.silentRecorder);const i=this.resolver.resolveInfoMap.get(e);if(i)return super.doCompileSingleCode(Object.assign(Object.assign({},i),{independentRoot:this.getIndependentRoot(i.path),isBabelIgnore:this.isBabelSettingIgnore(i)}),t);throw new Error("file not found")}async getDevCode(e){let t=await this.getPackageFile();return t=t.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(t,e)}async getDevCodeByFileList(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")).filter(e=>t.fileList.includes(e.path)),this.getCodeFiles(i,e)}async getProdCode(e,t){let i=await this.getPackageFile();return i=i.filter(e=>!e.path.endsWith("json")),this.getCodeFiles(i,e,{useCache:!1,resultType:t.resultType})}getLocalCodeFileList(){return Array.from(this.resolver.resolveInfoMap.entries()).map(([e,t])=>t.source)}onFileChangeForGraph(e,t){}async getPackageFile(){await this.ensureConf(progressRecorder_1.silentRecorder);const e=[];for(const[t,i]of this.resolver.resolveInfoMap.entries())e.push(i);return e.map(e=>Object.assign(Object.assign({},e),{independentRoot:this.getIndependentRoot(e.path),isBabelIgnore:this.isBabelSettingIgnore(e)}))}getIndependentRoot(e){const t=this.conf.plugin;return"string"==typeof t.workers&&e.startsWith(t.workers)?t.workers:""}checkFilePackage(e){return config_1.MainPkg}async compileJSON(){const e=await this.getConf(progressRecorder_1.silentRecorder),t={};t["plugin.json"]=JSON.stringify(e.plugin);for(const i in e.pages)t[i+".json"]=JSON.stringify(e.pages[i]);for(const i in e.comps)t[i+".json"]=JSON.stringify(e.comps[i]);return{conf:e,jsons:t}}}exports.PluginGraph=PluginGraph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginDriver=exports.getPluginContext=exports.genResovleExtConf=void 0;const customError_1=require("../../../utils/customError"),workerThread_1=require("../original/workerThread");function genResovleExtConf(r){const o={json:["json"],wxml:["wxml"],wxss:["wxss"],js:["js"],wxs:["wxs"]};for(const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PluginDriver=exports.getPluginContext=exports.genResovleExtConf=void 0;const customError_1=require("../../../utils/customError"),workerThread_1=require("../original/workerThread"),worker_1=require("./worker"),debug_1=require("../../../utils/debug");function genResovleExtConf(r){const o={json:["json"],wxml:["wxml"],wxss:["wxss"],js:["js"],wxs:["wxs"]};for(const e of r)if(e.resolveExt)for(const r of["json","wxml","wxss","js","wxs"]){const t=e.resolveExt[r];if("string"==typeof t)o[r].includes(t)||o[r].push(t);else if(Array.isArray(t))for(const e of t)o[r].includes(e)||o[r].push(e)}return o}function throwPluginError(r,o,{hook:e,id:t}={}){const s=(0,customError_1.makeCustomError)(r);throw s.code||(s.code=customError_1.CustomErrors.SUMMER_PLUGIN_ERR),s.plugin=o,e&&(s.hook=e),t&&!s.path&&(s.path=t),r.stack&&(s.stack=r.stack),s}function getPluginContext(r,o){return{addWatchFile(){throw new Error("addWatchFile should be implemented by replaceContext")},async runWorkerMethod(e,...t){const s=await o.project.serialize(),n={command:"runMethod",plugin:r.name,projectInfo:s,pluginOption:{},method:e,args:t};let i;if(i=(0,debug_1.shouldNotRunInWorker)()?await(0,worker_1.runSummerPluginHook)(n):await(0,workerThread_1.runTask)(workerThread_1.TASK_NAME.SUMMER_HOOK,n),i.error){if("CustomError"===i.error.type)throw new customError_1.CustomError(i.error);throw i.error}return i.result},error:o=>throwPluginError(o,r.name)}}exports.genResovleExtConf=genResovleExtConf,exports.getPluginContext=getPluginContext;class PluginDriver{constructor(r,o){this.graph=r,this.options=o,this.pluginContexts=new Map,this.plugins=o.plugins,this.resolveExtConf=genResovleExtConf(o.plugins);for(const o of this.plugins)this.pluginContexts.set(o,getPluginContext(o,r))}runHook(r,o,e,t){const s=e[r];if(!s)return;let n=this.pluginContexts.get(e);return t&&(n=t(n,e)),Promise.resolve().then(()=>s.apply(n,o)).catch(o=>throwPluginError(o,e.name,{hook:r}))}hookFirst(r,o,e){let t=Promise.resolve(void 0);for(const s of this.plugins)t=t.then(t=>t||this.runHook(r,o,s,e));return t}hookParallel(r,o,e){const t=[];for(const s of this.plugins){const n=this.runHook(r,o,s,e);n&&t.push(n)}return Promise.all(t).then(()=>{})}hookReduceArg0(r,[o,...e],t,s){let n=Promise.resolve(o);for(const o of this.plugins)n=n.then(n=>{const i=[n,...e],u=this.runHook(r,i,o,s);return u?u.then(r=>t.call(this.pluginContexts.get(o),n,r,o)):n});return n}}exports.PluginDriver=PluginDriver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),sass=()=>require("sass");function random(){return(0,tools_1.generateMD5)(`${Math.random()}${Date.now()}`)}exports.random=random;const importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,importCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.css)\1(?:\s*);/g;function default_1(s){return{name:"summer-sass",resolveExt:{wxss:["sass","scss"]},async load(t,e){if(e.endsWith(".scss")||e.endsWith(".sass")){const o=(0,tools_1.pathRelative)(s.projectPath,e);let r=s.getFile("",o).toString();const a=s.getTargetPath(s.miniprogramRoot,"global");if(o!==a+".scss"&&o!==a+".sass"){let t=path_1.default.extname(o);const e=(0,tools_1.pathRelative)(s.miniprogramRoot,path_1.default.dirname(o))||".";s.exists(s.miniprogramRoot,"global"+t)||(t=".sass"===t?".scss":".sass"),s.exists(s.miniprogramRoot,"global"+t)&&(r=".sass"===t?`@use '${"."===e?".":(0,tools_1.pathRelative)(e,"./")}/global${t}'\n${r}`:`@use '${"."===e?".":(0,tools_1.pathRelative)(e,"./")}/global${t}';\n${r}`)}const i=[];r=r.replace(importWxssReg,(s,t,e)=>(i.push(e),s.replace(e,e.slice(0,-4)+"css")));const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.random=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),tools_1=require("../../../../utils/tools"),customError_1=require("../../../../utils/customError"),debug_1=require("../../../../utils/debug"),sass=(0,debug_1.shouldRunInMainProcess)()?()=>{process.versions.electron="0.54.0";const s=require("sass");return delete process.versions.electron,s}:()=>require("sass");function random(){return(0,tools_1.generateMD5)(`${Math.random()}${Date.now()}`)}exports.random=random;const importWxssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.wxss)\1(?:\s*);/g,importCssReg=/(?:^|\s)?(?:@import)(?:\s*)?(["'])([^"']+.css)\1(?:\s*);/g;function default_1(s){return{name:"summer-sass",resolveExt:{wxss:["sass","scss"]},async load(t,e){if(e.endsWith(".scss")||e.endsWith(".sass")){const o=(0,tools_1.pathRelative)(s.projectPath,e);let r=s.getFile("",o).toString();const a=s.getTargetPath(s.miniprogramRoot,"global");if(o!==a+".scss"&&o!==a+".sass"){let t=path_1.default.extname(o);const e=(0,tools_1.pathRelative)(s.miniprogramRoot,path_1.default.dirname(o))||".";s.exists(s.miniprogramRoot,"global"+t)||(t=".sass"===t?".scss":".sass"),s.exists(s.miniprogramRoot,"global"+t)&&(r=".sass"===t?`@use '${"."===e?".":(0,tools_1.pathRelative)(e,"./")}/global${t}'\n${r}`:`@use '${"."===e?".":(0,tools_1.pathRelative)(e,"./")}/global${t}';\n${r}`)}const i=[];r=r.replace(importWxssReg,(s,t,e)=>(i.push(e),s.replace(e,e.slice(0,-4)+"css")));const n=path_1.default.posix.dirname((0,tools_1.pathRelative)(s.projectPath,e));return new Promise((s,o)=>{sass().render({file:e,data:r,sourceMap:!0,sourceMapContents:!0,omitSourceMapUrl:!0,outFile:e.slice(0,-5)+".wxss",includePaths:this.rootPath?[this.rootPath]:[]},(r,a)=>{if(r){const s=(0,customError_1.makeCustomError)(r,customError_1.CustomErrors.SUMMER_PLUGIN_CODE_ERR);return void o(s)}if(!a)return void o(new Error("no result"));const l=a.css.toString("utf-8").replace(importCssReg,(s,t,e)=>{const o=e.slice(0,-3)+"wxss";return i.includes(o)?s.replace(e,o):s});if(a.stats.includedFiles.length>0)for(const s of a.stats.includedFiles)s!==e&&this.addWatchFile(s);const u=a.map?JSON.parse(a.map.toString("utf-8")):void 0;u&&(u.sourceRoot=n),s({targetPath:t,source:{sourceCode:l,inputMap:u},process:[{pluginName:"summer-sass",action:"load"}]})})})}}}}exports.default=default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),reactiveCache_1=require("../original/json/reactiveCache"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),plugingraph_1=require("./graph/plugingraph"),gameplugingraph_1=require("./graph/gameplugingraph"),appgraph_1=require("./graph/appgraph"),initPlugin_1=require("./initPlugin"),pluginDriver_1=require("./pluginDriver"),persistCache_1=tslib_1.__importDefault(require("./persistCache")),babel_helper_1=require("../../../utils/babel_helper"),config_1=require("../../../config/config"),gamegraph_1=require("./graph/gamegraph");let proxyProject;function initProxyProjectForJSON(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=require("lodash"),reactiveCache_1=require("../original/json/reactiveCache"),locales_1=tslib_1.__importDefault(require("../../../utils/locales/locales")),tools_1=require("../../../utils/tools"),plugingraph_1=require("./graph/plugingraph"),gameplugingraph_1=require("./graph/gameplugingraph"),appgraph_1=require("./graph/appgraph"),initPlugin_1=require("./initPlugin"),pluginDriver_1=require("./pluginDriver"),persistCache_1=tslib_1.__importDefault(require("./persistCache")),babel_helper_1=require("../../../utils/babel_helper"),config_1=require("../../../config/config"),gamegraph_1=require("./graph/gamegraph");let proxyProject;function initProxyProjectForJSON(i){if(proxyProject&&proxyProject.projectPath!==i.projectPath&&(proxyProject.clearResolver(),proxyProject=void 0),!proxyProject){let t={};function e(e,r){const o=i.stat(e,r);if(o)return o;const p=i.getTargetPath(e,r);for(const i in t)if(p.startsWith(i))return t[i].stat(path_1.default.posix.relative(i,p))}proxyProject=new Proxy(i,{get:(i,t,r)=>"stat"===t?e:Reflect.get(i,t,r)}),proxyProject.addResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),t[i.root]=i},proxyProject.removeResolver=i=>{(0,reactiveCache_1.cleanReactiveCache)(),delete t[i.root]},proxyProject.clearResolver=()=>{t={},(0,reactiveCache_1.cleanReactiveCache)()}}return proxyProject}function getCacheBaseKey(i){const e=["es6","minified","postcss","uglifyFileName","compileWorklet","enhance","swc","minifyWXSS","minifyWXML","disableUseStrict"],t=[i.miniprogramRoot,i.pluginRoot,i.compileType,i.projectArchitecture,...i.summerPlugins,(0,babel_helper_1.getBabelHelperVersion)(),JSON.stringify(i.setting.swcSetting),JSON.stringify(i.setting.babelSetting)];for(const r of e)t.push(i.setting[r]?"1":"0");return(0,tools_1.generateMD5)(t.join("|"))}class SummerCompiler{constructor(i,e,t){this.project=i,this.cachePath=e,this.devtoolsProject=t,this.proxyProject=initProxyProjectForJSON(i),this.projectPath=i.projectPath,this.persistCache=new persistCache_1.default(this.proxyProject,e,getCacheBaseKey(t)),this.initPlugins(),this.initAppGraph(),this.isPluginType(i.type)&&this.initPluginGraph()}getBabelSetting(){return this.devtoolsProject.setting.babelSetting}getSWCSetting(){return this.devtoolsProject.setting.swcSetting}initPlugins(){this.plugins=this.devtoolsProject.summerPlugins.map(i=>{let e,t={};return"string"==typeof i?e=i:(e=i[0],t=i[1]),(0,initPlugin_1.initPlugin)(e,this.project,t)})}isGameType(i){return i===config_1.COMPILE_TYPE.miniGame||i===config_1.COMPILE_TYPE.miniGamePlugin}isPluginType(i){return i===config_1.COMPILE_TYPE.miniProgramPlugin||i===config_1.COMPILE_TYPE.miniGamePlugin}initAppGraph(){var i;null===(i=this.appGraph)||void 0===i||i.destroy(),this.isGameType(this.project.type)?this.appGraph=new gamegraph_1.GameGraph({type:"minigame",root:this.project.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this}):this.appGraph=new appgraph_1.AppGraph({type:"miniprogram",root:this.project.miniprogramRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}initPluginGraph(){var i;null===(i=this.pluginGraph)||void 0===i||i.destroy(),this.devtoolsProject.compileType===config_1.COMPILE_TYPE.miniGamePlugin?this.pluginGraph=new gameplugingraph_1.GamePluginGraph({type:"plugin",root:this.project.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this}):this.pluginGraph=new plugingraph_1.PluginGraph({type:"plugin",root:this.project.pluginRoot,persistCache:this.persistCache,plugins:this.plugins,compiler:this})}updateOptions(i){var e;const t=this.devtoolsProject;if(this.devtoolsProject=i,this.persistCache.updateBaseCacheKey(getCacheBaseKey(i)),!(0,lodash_1.isEqual)(i.setting,t.setting)||!(0,lodash_1.isEqual)(this.devtoolsProject.summerPlugins,t.summerPlugins))return this.project.setting=i.setting,this.initPlugins(),this.initAppGraph(),void("miniProgramPlugin"===this.devtoolsProject.compileType&&this.initPluginGraph());this.devtoolsProject.compileType!==t.compileType&&("miniProgramPlugin"===this.devtoolsProject.compileType?this.initPluginGraph():(null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.pluginGraph=void 0)),this.appGraph.root!==this.project.miniprogramRoot&&this.initAppGraph(),this.pluginGraph&&this.pluginGraph.root!==this.project.pluginRoot&&this.initPluginGraph()}destroy(){var i,e;null===(i=this.appGraph)||void 0===i||i.destroy(),null===(e=this.pluginGraph)||void 0===e||e.destroy(),this.proxyProject.clearResolver()}getStatus(){const i=(0,pluginDriver_1.genResovleExtConf)(this.plugins),e={},t=new Set;for(const r of["json","js","wxml","wxss","wxs"])e[r]={exts:i[r].reverse()},i[r].forEach(i=>{t.add(i)});return{codeExts:Array.from(t.keys()),codeConf:e}}clearCache(){var i,e,t;null===(e=(i=this.project).clearCache)||void 0===e||e.call(i),this.appGraph.clearCache(),null===(t=this.pluginGraph)||void 0===t||t.clearCache(),this.persistCache.clean(),(0,reactiveCache_1.cleanReactiveCache)()}async getPackageFiles({graphId:i,root:e}){var t;return this.isPluginType(i)?null===(t=this.pluginGraph)||void 0===t?void 0:t.getPackageFile():this.appGraph.getPackageFile(e)}async getConf({graphId:i},e){if(i===config_1.COMPILE_TYPE.miniProgram||i===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getConf(e)}if(this.isPluginType(i)){return await this.pluginGraph.getConf(e)}throw new Error("no support getConf for "+i)}async getCode(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getDevCode(e,{package:i.package})}if(this.isPluginType(i.graphId)){return await this.pluginGraph.getDevCode(e)}throw new Error("no support getCode for "+i.graphId)}async getDevCodeByFileList(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.getDevCodeByFileList(e,{fileList:i.fileList})}if(this.isPluginType(i.graphId)){return await this.pluginGraph.getDevCodeByFileList(e,{fileList:i.fileList})}throw new Error("no support getDevCodeByFileList for "+i.graphId)}async getLocalFileList(i){if(i===config_1.COMPILE_TYPE.miniProgram||i===config_1.COMPILE_TYPE.miniGame)return await this.appGraph.getLocalFileList();if(this.isPluginType(i))return await this.pluginGraph.getLocalFileList();throw new Error("no support getCode for "+i)}async compileSingleCode(i,e){if(i.graphId===config_1.COMPILE_TYPE.miniProgram||i.graphId===config_1.COMPILE_TYPE.miniGame){return await this.appGraph.compileSingleCode(i.filePath,i.sourceCode)}if(this.isPluginType(i.graphId)){return await this.pluginGraph.compileSingleCode(i.filePath,i.sourceCode)}throw new Error("no support getCode for "+i.graphId)}async compile(i,e){const t=await e.run(this.isGameType(this.project.type)?locales_1.default.config.SUMMER_COMPILE_MINIGAME.format():locales_1.default.config.SUMMER_COMPILE_MINIPROGRAM.format(),()=>this.appGraph.compile(i,e));if(this.project.type===config_1.COMPILE_TYPE.miniProgram||this.project.type===config_1.COMPILE_TYPE.miniGame)return t["project.config.json"]=JSON.stringify({miniprogramRoot:"",__compileDebugInfo__:{useSummer:!0}}),t;if(this.isPluginType(this.project.type)){const r={},o=await e.run(locales_1.default.config.SUMMER_COMPILE_PLUGIN.format(),()=>this.pluginGraph.compile(i,e));return Object.keys(t).forEach(i=>{r[path_1.default.posix.join(this.project.miniprogramRoot,i)]=t[i]}),Object.keys(o).forEach(i=>{r[path_1.default.posix.join(this.project.pluginRoot,i)]=o[i]}),r["project.config.json"]=JSON.stringify({miniprogramRoot:this.project.miniprogramRoot,pluginRoot:this.project.pluginRoot,__compileDebugInfo__:{useSummer:!0}}),r}throw new Error("no support compile for "+this.project.type)}}exports.SummerCompiler=SummerCompiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),request_1=require("../../utils/request"),progressRecorder_1=require("../../utils/progressRecorder"),tools_1=require("../../utils/tools"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),index_1=require("./original/index"),baseCompiler_1=require("./baseCompiler"),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,s){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,s,t,i){super(e),this.project=e,this.cachePath=s,this.projectInfo=t,this.devtoolMessagehub=i,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.onFileChange=(e,s)=>{if("change"!==e||s.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e)for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);this.invalidCodeCache(),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:s})},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,s,t)=>{const i="doing"===s?"doing":"done"===s?"success":"error";this.messageHub.showBuildLog(""+e,i,t)},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(i),this.ready()}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,e,{cachePath:this.cachePath},this.projectInfo,8891),this.addProjectListener(),this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){this._status=await this.subProcessManager.runTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){var e;await(null===(e=this.subProcessManager)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear()}updateOptions(e){var s;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.codeCache.clear(),null===(s=this.subProcessManager)||void 0===s||s.sendEvent("updateOptions",e),this.loadStatus())}addProjectListener(){var e,s;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(s=this.project.event)||void 0===s||s.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,s;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(s=this.project.event)||void 0===s||s.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(){for(const e of this.codeCache.values())e.isValid=!1}async getConf(e){var s,t;const i="getConf-"+e;if(this.promiseCache.has(i))return(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(i,"hit cache"),this.promiseCache.get(i);(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(i,"do request"),performanceMark("request get conf");const r={graphId:e},o=this.subProcessManager.runTask("getConf",r,this.onProgressUpdate);return this.promiseCache.set(i,o),performanceMark("request get conf",!0),o}async getPackageFiles(e,s){var t,i;const r=`getPackageFiles-${e}-${s}`;if(this.promiseCache.has(r))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(r,"hit cache"),this.promiseCache.get(r);(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(r,"do request"),performanceMark("request get getPackageFiles");const o=this.subProcessManager.runTask("getPackageFiles",{graphId:e,root:s},this.onProgressUpdate);return this.promiseCache.set(r,o),performanceMark("request get getPackageFiles",!0),o}async getCode(e,s){var t,i,r;const o=`getCode-${e}${s?"-"+s.package:""}`;if(this.promiseCache.has(o))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(o,"hit promise cache"),this.promiseCache.get(o);const n=this.codeCache.get(o);if(null==n?void 0:n.isValid)return n.codeFiles;(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(o,"do request");const a={};if(n){const{codeFiles:e}=n;for(const s of Object.keys(e)){const t=e[s];"error"in t||(a[s]=t.md5)}}const c={graphId:e,cacheMd5:a,package:null==s?void 0:s.package};performanceMark("request get code");const l=Date.now();(null===(r=process.env)||void 0===r?void 0:r.isDevtools)&&(console.time("[summer-compiler] runTask "+o),console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] runTask ${o}`));const g=this.subProcessManager.runTask("getCode",c,this.onProgressUpdate).then(e=>{var s,t;(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.timeEnd("[summer-compiler] runTask "+o);const i=(null===(t=this.codeCache.get(o))||void 0===t?void 0:t.codeFiles)||{};for(const s of Object.keys(e)){const t=e[s];"error"in t||""!==t.md5?i[s]=t:delete i[s]}return this.codeCache.set(o,{isValid:!0,codeFiles:i}),i},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),e});return g.finally(()=>{var e;performanceMark("request get code",!0),(null===(e=process.env)||void 0===e?void 0:e.isDevtools)&&console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] [cost ${Date.now()-l}ms] runTask ${o}`),this.promiseCache.delete(o)}),this.promiseCache.set(o,g),g}async getExtJSON(){return await(0,index_1.getExtJSON)(this.project)}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const s=await this.getConf(miniProgram),t=s.pages[e]||s.comps[e];if(!t)throw new Error("summer-compiler 收集json配置有遗漏, "+e);return t}async getAllPageAndComponent(){const e=await this.getConf(miniProgram);return Object.keys(e.pages).concat(Object.keys(e.comps))}async getAllSortedJSFiles(){const e=await this.getConf(miniProgram),s=Object.keys(e.pages),t=Object.keys(e.comps),i=s.filter(e=>!t.includes(e)).map(e=>e+".js"),r=t.map(e=>e+".js"),o=await this.getCode(miniProgram,{package:config_1.FullPkg}),n=Object.keys(o).filter(e=>e.endsWith(".js")&&"app.js"!==e&&!i.includes(e)&&!r.includes(e));return{jsPagesFiles:i,components:r,otherJsFiles:n}}async getAllWxmlAndWxsFiles(){const e=await this.getCode(miniProgram,{package:config_1.FullPkg}),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPackageWxmlAndWxsFiles(e){let s=await this.getCode(miniProgram,{package:e});if(e!==config_1.MainPkg){const e=await this.getCode(miniProgram,{package:config_1.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxml")),i=Object.keys(s).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async getPackageWxssFiles(e){let s=await this.getCode(miniProgram,{package:e});if(e!==config_1.MainPkg){const e=await this.getCode(miniProgram,{package:config_1.MainPkg});s=Object.assign(Object.assign({},s),e)}const t=Object.keys(s).filter(e=>e.endsWith(".wxss"));return{wxssFiles:t,content:t.reduce((e,t)=>{const i=s[t];if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}getWxssMap(e,s){s=(0,tools_1.normalizePath)(s);for(const[t,i]of this.codeCache.entries())if(t.startsWith("getCode-"+e)){const e=i.codeFiles[s];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),s=await this.getCode(miniProgram,{package:"__APP__"}),t=Object.keys(s).filter(e=>e.endsWith(".js")),i=[],r=[],o=[],n=[],a=[];let c=!1;const l={},g=s=>Object.keys(e.packages).find(e=>s.startsWith(e))||config_1.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const s=e.replace(/\.js$/,"");if(l[s])return;l[s]=!0,a.push(encodeURI(s))}}),e.app.workers&&t.forEach(s=>{if(s.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=s.replace(/\.js$/,"");if(l[e])return;l[e]=!0,n.push(e)}});Object.keys(e.comps).filter(e=>g(e)===config_1.MainPkg).forEach(s=>{if((s.startsWith("miniprogram_npm/weui-miniprogram")||s.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(l[s])return;l[s]=!0;const t=encodeURI(s);o.push(""+t)});Object.keys(e.pages).filter(e=>g(e)===config_1.MainPkg).forEach(e=>{if(l[e])return;l[e]=!0;const s=encodeURI(e);i.push(""+s)}),t.forEach(e=>{const s=e.replace(/\.js$/,"");l[s]||(l[s]=!0,"app.js"!==e?r.push(""+encodeURI(s)):c=!0)});const h=[...r,...o,...i];return c&&h.push("app"),{hasAppJS:c,allFiles:h,pageFiles:i,componentFiles:o,workerFiles:n,functionalPageFiles:a,otherFiles:r}}async getSubPkgSortedJSFiles(e){const s=await this.getConf(miniProgram),t=await this.getCode(miniProgram,{package:e}),i=Object.keys(t).filter(e=>e.endsWith(".js")),r=[],o=[],n={},a=e=>Object.keys(s.packages).find(s=>e.startsWith(s))||config_1.MainPkg;Object.keys(s.comps).filter(s=>a(s)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&s.app.useExtendedLib&&s.app.useExtendedLib.weui)return;if(n[e])return;n[e]=!0;const t=encodeURI(e);o.push(""+t)});Object.keys(s.pages).filter(s=>a(s)===e).forEach(e=>{if(n[e])return;n[e]=!0;const s=encodeURI(e);r.push(""+s)});const c=i.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{allFiles:c,pageFiles:r,componentFiles:o,otherFiles:c.filter(e=>!r.includes(e)&&!o.includes(e))}}async compileJS(e){const s=this.project.type;let t;if(e.root===this.project.miniprogramRoot){const i=await this.getConf(this.isGameType(s)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram),r=Object.keys(i.packages).find(s=>e.filePath.startsWith(s))||config_1.MainPkg;t=(await this.getCode(this.isGameType(s)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,{package:r,partialCompilePath:[]}))[e.filePath]}else{t=(await this.getCode(this.isGameType(s)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin))[e.filePath]}if(!t){const s=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw s.code="ENOENT",s}if("error"in t)throw t.error;return Object.assign({filePath:e.filePath,code:t.code,map:t.map},t.jsTag)}async compile(e){const s=await this.subProcessManager.runTask("compile",e,(s,t,i)=>{var r;null===(r=e.onProgressUpdate)||void 0===r||r.call(e,{id:s.toString(),status:t,message:i})});for(const e of Object.keys(s))"object"==typeof s[e]&&"Buffer"===s[e].type&&(s[e]=Buffer.from(s[e].data));return s}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const s=await this.getConf(miniProgramPlugin),t=s.pages[e]||s.comps[e];if(!t)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+e);return t}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),s=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(s)}async getPluginJSFiles(){const e=await this.getCode(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".js"));return{jsFiles:s,content:s.reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPluginWxssFiles(){const e=await this.getCode(miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".wxss"));return{wxssFiles:s,content:s.reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async getPluginWxmlAndWxsFiles(){const e=await this.getCode(miniProgramPlugin),s=Object.keys(e).filter(e=>e.endsWith(".wxml")),t=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:s,wxsFiles:t,content:s.concat(t).reduce((s,t)=>{const i=e[t];if("error"in i)throw i.error;return s[t]=i.code,s["./"+t]=i.code,s},{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.subProcessManager.runTask("setLocale",e))}async uglifyFileNames(e,s,t){return await(0,uglifyfilenames_1.uglifyFileNames)(e,s,t)}async getMPFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}}exports.SummerCompiler=SummerCompiler;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SummerCompiler=void 0;const tslib_1=require("tslib"),path_1=tslib_1.__importDefault(require("path")),lodash_1=tslib_1.__importDefault(require("lodash")),request_1=require("../../utils/request"),progressRecorder_1=require("../../utils/progressRecorder"),tools_1=require("../../utils/tools"),config_1=require("../../config/config"),processManager_1=require("../../utils/subprocess/processManager"),messageHub_1=require("../../utils/messageHub"),uglifyfilenames_1=require("./original/protect/uglifyfilenames"),index_1=require("./original/index"),baseCompiler_1=require("./baseCompiler"),miniProgram=config_1.COMPILE_TYPE.miniProgram,miniGame=config_1.COMPILE_TYPE.miniGame,miniProgramPlugin=config_1.COMPILE_TYPE.miniProgramPlugin,miniGamePlugin=config_1.COMPILE_TYPE.miniGamePlugin;function performanceMark(e,t){}class SummerCompiler extends baseCompiler_1.BaseCoreCompiler{constructor(e,t,i,s){super(e),this.project=e,this.cachePath=t,this.projectInfo=i,this.devtoolMessagehub=s,this.isSummer=!0,this.codeCache=new Map,this.promiseCache=new Map,this._status=void 0,this._eventAdded=!1,this._locale="",this.codeCacheByPath=new Map,this.onFileChange=(e,t)=>{if("change"!==e||t.endsWith(".json"))for(const e of this.promiseCache.keys())e.startsWith("getConf-")&&this.promiseCache.delete(e);if("change"!==e)for(const e of this.promiseCache.keys())e.startsWith("getPackageFiles-")&&this.promiseCache.delete(e);this.invalidCodeCache(t),this.subProcessManager.sendEvent("fileChange",{type:e,targetPath:t})},this.onPreCompileOptionsChange=async e=>{await this.clearCache(),this.subProcessManager.sendEvent("precompileOptionsChange",e)},this.onProgressUpdate=(e,t,i)=>{const s="doing"===t?"doing":"done"===t?"success":"error";this.messageHub.showBuildLog(""+e,s,i)},performanceMark("create summer compiler"),this.messageHub=new messageHub_1.MessageHub(s),this.ready()}get status(){return this._status}async init(){performanceMark("init summer compiler");const e=path_1.default.posix.join(__dirname,"./summerEntryProcess.js");this.subProcessManager=new processManager_1.SubProcessProxy(this.project,e,{cachePath:this.cachePath},this.projectInfo,8891),this.addProjectListener(),this.loadStatus(),performanceMark("init summer compiler",!0)}async loadStatus(){this._status=await this.subProcessManager.runTask("loadStatus")}destroy(){var e;null===(e=this.subProcessManager)||void 0===e||e.destroy(),this.removeProjectListener(),this._checkReadyTask=void 0}async clearCache(){var e;await(null===(e=this.subProcessManager)||void 0===e?void 0:e.runTask("clearCache")),this.codeCache.clear(),this.promiseCache.clear(),this.codeCacheByPath.clear()}updateOptions(e){var t;lodash_1.default.isEqual(e,this.projectInfo)||(this.projectInfo=e,this.promiseCache.clear(),this.codeCache.clear(),this.codeCacheByPath.clear(),null===(t=this.subProcessManager)||void 0===t||t.sendEvent("updateOptions",e),this.loadStatus())}addProjectListener(){var e,t;this._eventAdded&&this.removeProjectListener(),null===(e=this.project.event)||void 0===e||e.on("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.on("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!0}removeProjectListener(){var e,t;null===(e=this.project.event)||void 0===e||e.off("fileChange",this.onFileChange),null===(t=this.project.event)||void 0===t||t.off("precompileOptionsChange",this.onPreCompileOptionsChange),this._eventAdded=!1}invalidCodeCache(e){for(const e of this.codeCache.values())e.isValid=!1;this.codeCacheByPath.delete((0,tools_1.sourcePathToTargetPath)(e))}async getConf(e){var t,i;const s="getConf-"+e;if(this.promiseCache.has(s))return(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.log(s,"hit cache"),this.promiseCache.get(s);(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(s,"do request"),performanceMark("request get conf");const o={graphId:e},r=this.subProcessManager.runTask("getConf",o,this.onProgressUpdate);return this.promiseCache.set(s,r),performanceMark("request get conf",!0),r}async getPackageFiles(e,t){var i,s;const o=`getPackageFiles-${e}-${t}`;if(this.promiseCache.has(o))return(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(o,"hit cache"),this.promiseCache.get(o);(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(o,"do request"),performanceMark("request get getPackageFiles");const r=this.subProcessManager.runTask("getPackageFiles",{graphId:e,root:t},this.onProgressUpdate);return this.promiseCache.set(o,r),performanceMark("request get getPackageFiles",!0),r}async getCodeByFileList(e,t){const i={},s={},o=this.isPluginType(e)?this.project.pluginRoot:this.project.miniprogramRoot;for(const e of t){const t=this.codeCacheByPath.get(path_1.default.posix.join(o,e));t&&("error"in t||(i[e]=t.md5,s[e]=t))}const r=await this.subProcessManager.runTask("getDevCodeByFileList",{graphId:e,fileList:t,cacheMd5:i},this.onProgressUpdate);console.error(r);for(const e in r){const t=r[e],i=path_1.default.posix.join(o,e);"error"in t||""!==t.md5?this.codeCacheByPath.set(i,t):this.codeCacheByPath.delete(i),s[e]=t}return s}async getCode(e,t){var i,s,o;const r=`getCode-${e}${t?"-"+t.package:""}`;if(this.promiseCache.has(r))return(null===(i=process.env)||void 0===i?void 0:i.isDevtools)&&console.log(r,"hit promise cache"),this.promiseCache.get(r);const a=this.codeCache.get(r);if(null==a?void 0:a.isValid)return a.codeFiles;(null===(s=process.env)||void 0===s?void 0:s.isDevtools)&&console.log(r,"do request");const n={};if(a){const{codeFiles:e}=a;for(const t of Object.keys(e)){const i=e[t];"error"in i||(n[t]=i.md5)}}const c={graphId:e,cacheMd5:n,package:null==t?void 0:t.package};performanceMark("request get code");const l=Date.now();(null===(o=process.env)||void 0===o?void 0:o.isDevtools)&&(console.time("[summer-compiler] runTask "+r),console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] runTask ${r}`));const g=this.subProcessManager.runTask("getCode",c,this.onProgressUpdate).then(e=>{var t,i;(null===(t=process.env)||void 0===t?void 0:t.isDevtools)&&console.timeEnd("[summer-compiler] runTask "+r);const s=(null===(i=this.codeCache.get(r))||void 0===i?void 0:i.codeFiles)||{};for(const t of Object.keys(e)){const i=e[t];"error"in i||""!==i.md5?s[t]=i:delete s[t]}return this.codeCache.set(r,{isValid:!0,codeFiles:s}),s},e=>{throw e.code?console.error(e):console.error("Unexpected error when getCode",e),e});return g.finally(()=>{var e;performanceMark("request get code",!0),(null===(e=process.env)||void 0===e?void 0:e.isDevtools)&&console.log(`[summer-compiler] [${(0,progressRecorder_1.getPrintTime)()}] [cost ${Date.now()-l}ms] runTask ${r}`),this.promiseCache.delete(r)}),this.promiseCache.set(r,g),g}async getExtJSON(){return await(0,index_1.getExtJSON)(this.project)}async getAppJSON(){return(await this.getConf(miniProgram)).app}async getGameJSON(){return(await this.getConf(miniGame)).app}async getSiteMapJSON(){return(await this.getConf(miniProgram)).sitemap}async getPageJSON(e){const t=await this.getConf(miniProgram),i=t.pages[e]||t.comps[e];if(!i)throw new Error("summer-compiler 收集json配置有遗漏, "+e);return i}async getAllPageAndComponent(){const e=await this.getConf(miniProgram);return Object.keys(e.pages).concat(Object.keys(e.comps))}async getAllSortedJSFiles(){const e=await this.getConf(miniProgram),t=Object.keys(e.pages),i=Object.keys(e.comps),s=t.filter(e=>!i.includes(e)).map(e=>e+".js"),o=i.map(e=>e+".js"),r=await this.getCode(miniProgram,{package:config_1.FullPkg}),a=Object.keys(r).filter(e=>e.endsWith(".js")&&"app.js"!==e&&!s.includes(e)&&!o.includes(e));return{jsPagesFiles:s,components:o,otherJsFiles:a}}async getAllWxmlAndWxsFiles(){const e=await this.getCode(miniProgram,{package:config_1.FullPkg}),t=Object.keys(e).filter(e=>e.endsWith(".wxml")),i=Object.keys(e).filter(e=>e.endsWith(".wxs"));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((t,i)=>{const s=e[i];if("error"in s)throw s.error;return t[i]=s.code,t["./"+i]=s.code,t},{})}}async getPackageWxmlAndWxsFiles(e){let t=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path);if(e!==config_1.MainPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path);t=t.concat(e)}const i=t.filter(e=>e.endsWith(".wxml")),s=t.filter(e=>e.endsWith(".wxs")),o=await this.getCodeByFileList(miniProgram,i.concat(s));return{wxmlFiles:i,wxsFiles:s,content:i.concat(s).reduce((e,t)=>{const i=o[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async getPackageWxssFiles(e){let t=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path);if(e!==config_1.MainPkg){const e=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path);t=t.concat(e)}const i=t.filter(e=>e.endsWith(".wxss")),s=await this.getCodeByFileList(miniProgram,i);return{wxssFiles:i,content:i.reduce((e,t)=>{const i=s[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}getWxssMap(e,t){t=(0,tools_1.normalizePath)(t);for(const[i,s]of this.codeCache.entries())if(i.startsWith("getCode-"+e)){const e=s.codeFiles[t];if(e&&!("error"in e))return e.map}}async getMainPkgSortedJSFiles(){const e=await this.getConf(miniProgram),t=(await this.getPackageFiles(miniProgram,config_1.MainPkg)).map(e=>e.path).filter(e=>e.endsWith(".js")),i=[],s=[],o=[],r=[],a=[];let n=!1;const c={},l=t=>Object.keys(e.packages).find(e=>t.startsWith(e))||config_1.MainPkg;e.app.functionalPages&&t.forEach(e=>{if(e.startsWith("functional-pages/")){const t=e.replace(/\.js$/,"");if(c[t])return;c[t]=!0,a.push(encodeURI(t))}}),e.app.workers&&t.forEach(t=>{if(t.startsWith((0,tools_1.getWorkersPath)(e.app.workers))){const e=t.replace(/\.js$/,"");if(c[e])return;c[e]=!0,r.push(e)}});Object.keys(e.comps).filter(e=>l(e)===config_1.MainPkg).forEach(t=>{if((t.startsWith("miniprogram_npm/weui-miniprogram")||t.startsWith("weui-miniprogram"))&&e.app.useExtendedLib&&e.app.useExtendedLib.weui)return;if(c[t])return;c[t]=!0;const i=encodeURI(t);o.push(""+i)});Object.keys(e.pages).filter(e=>l(e)===config_1.MainPkg).forEach(e=>{if(c[e])return;c[e]=!0;const t=encodeURI(e);i.push(""+t)}),t.forEach(e=>{const t=e.replace(/\.js$/,"");c[t]||(c[t]=!0,"app.js"!==e?s.push(""+encodeURI(t)):n=!0)});const g=[...s,...o,...i];return n&&g.push("app"),{hasAppJS:n,allFiles:g,pageFiles:i,componentFiles:o,workerFiles:r,functionalPageFiles:a,otherFiles:s}}async getSubPkgSortedJSFiles(e){const t=await this.getConf(miniProgram),i=(await this.getPackageFiles(miniProgram,e)).map(e=>e.path).filter(e=>e.endsWith(".js")),s=[],o=[],r=[],a={},n=e=>Object.keys(t.packages).find(t=>e.startsWith(t))||config_1.MainPkg;Object.keys(t.comps).filter(t=>n(t)===e).forEach(e=>{if((e.startsWith("miniprogram_npm/weui-miniprogram")||e.startsWith("weui-miniprogram"))&&t.app.useExtendedLib&&t.app.useExtendedLib.weui)return;if(a[e])return;a[e]=!0;const i=encodeURI(e);r.push(""+i)});Object.keys(t.pages).filter(t=>n(t)===e).forEach(e=>{if(a[e])return;a[e]=!0;const t=encodeURI(e);s.push(""+t)});let c=t.packages[e].entry||"";c&&(c=path_1.default.join(e,c),c=c.replace(/\.js$/,"")),i.forEach(e=>{const t=e.replace(/\.js$/,"");a[t]||(a[t]=!0,t!==c&&o.push(""+encodeURI(t)))});const l=i.map(e=>""+encodeURI(e.replace(/\.js$/,"")));return{entryJS:c,allFiles:l,pageFiles:s,componentFiles:r,otherFiles:o}}async compileJSList(e){const t=this.project.type;let i=config_1.COMPILE_TYPE.miniProgram;i=e.root===this.project.miniprogramRoot?this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram:this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin;const s=await this.getCodeByFileList(i,e.fileList),o=[];for(const e in s){const t=s[e];if("error"in t)throw t.error;o.push(Object.assign({filePath:e,code:t.code,map:t.map},t.jsTag))}return o}async compileJS(e){const t=this.project.type;let i;if(e.root===this.project.miniprogramRoot){i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGame:config_1.COMPILE_TYPE.miniProgram,[e.filePath]))[e.filePath]}else{i=(await this.getCodeByFileList(this.isGameType(t)?config_1.COMPILE_TYPE.miniGamePlugin:miniProgramPlugin,[e.filePath]))[e.filePath]}if(!i){const t=new Error(`summer-compiler miss ${e.root} js file, ${e.filePath}`);throw t.code="ENOENT",t}if("error"in i)throw i.error;return Object.assign({filePath:e.filePath,code:i.code,map:i.map},i.jsTag)}async compile(e){const t=await this.subProcessManager.runTask("compile",e,(t,i,s)=>{var o;null===(o=e.onProgressUpdate)||void 0===o||o.call(e,{id:t.toString(),status:i,message:s})});for(const e of Object.keys(t))"object"==typeof t[e]&&"Buffer"===t[e].type&&(t[e]=Buffer.from(t[e].data));return t}async getPluginJSON(e=""){return(await this.getConf(this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin)).plugin}async getPluginPageJSON(e){const t=await this.getConf(miniProgramPlugin),i=t.pages[e]||t.comps[e];if(!i)throw new Error("summer-compiler 收集plugin json配置有遗漏, "+e);return i}async getPluginComponents(){const e=await this.getConf(miniProgramPlugin),t=new Set(Object.keys(e.pages).concat(Object.keys(e.comps)));return Array.from(t)}async getPluginJSFiles(){const e=this.isGameType(this.project.type)?miniGamePlugin:miniProgramPlugin,t=(await this.getPackageFiles(e,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".js")),i=await this.getCodeByFileList(e,t);return{jsFiles:t,content:t.reduce((e,t)=>{const s=i[t];if(!s)throw`lack of ${t} code`;if("error"in s)throw s.error;return e[t]=s.code,e["./"+t]=s.code,e},{})}}async getPluginWxssFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map(e=>e.path).filter(e=>e.endsWith(".wxss")),t=await this.getCodeByFileList(miniProgramPlugin,e);return{wxssFiles:e,content:e.reduce((e,i)=>{const s=t[i];if(!s)throw`lack of ${i} code`;if("error"in s)throw s.error;return e[i]=s.code,e["./"+i]=s.code,e},{})}}async getPluginWxmlAndWxsFiles(){const e=(await this.getPackageFiles(miniProgramPlugin,config_1.FullPkg)).map(e=>e.path),t=e.filter(e=>e.endsWith(".wxml")),i=e.filter(e=>e.endsWith(".wxs")),s=await this.getCodeByFileList(miniProgramPlugin,t.concat(i));return{wxmlFiles:t,wxsFiles:i,content:t.concat(i).reduce((e,t)=>{const i=s[t];if(!i)throw`lack of ${t} code`;if("error"in i)throw i.error;return e[t]=i.code,e["./"+t]=i.code,e},{})}}async checkThemeJSON(e){return(await this.getConf(miniProgram)).theme}setProxy(e){(0,request_1.setCiProxy)(e)}setLocale(e){this._locale!==e&&(this._locale=e,this.subProcessManager.runTask("setLocale",e))}async uglifyFileNames(e,t,i){return await(0,uglifyfilenames_1.uglifyFileNames)(e,t,i)}async getMPFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgram)}async getPluginFileInfo(){return this.subProcessManager.runTask("getLocalFileList",miniProgramPlugin)}async getCompAndPagesOfConf(){const e=await this.getConf(miniProgram);return{pages:e.pages,comps:e.comps}}}exports.SummerCompiler=SummerCompiler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _a,_b;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../utils/hackrequire/index");const
|
|
1
|
+
var _a,_b;process.env&&process.env.isDevtools&&require("../../utils/hackrequire/index"),Object.defineProperty(exports,"__esModule",{value:!0}),(null===(_a=process.env)||void 0===_a?void 0:_a.isDevtools)&&require("../../utils/hackrequire/index");const entryProcess_1=require("../../utils/subprocess/entryProcess"),processHandler_1=require("./processHandler");(0,entryProcess_1.runSubProcess)({initHandler:processHandler_1.initHandler,messageHandler:processHandler_1.messageHandler,timeout:(null===(_b=process.env)||void 0===_b?void 0:_b.timeout)||6e5});
|