@aiot-toolkit/aiotpack 2.0.2-beta.16 → 2.0.2-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/afterCompile/ux/UxAfterCompile.d.ts +7 -0
- package/lib/afterCompile/ux/UxAfterCompile.js +32 -7
- package/lib/afterCompile/xts/entryTemplate.js +4 -3
- package/lib/afterCompile/xts/generateRpk.js +4 -3
- package/lib/afterCompile/xts/ts2wasm.js +4 -3
- package/lib/afterWorks/ux/UxAfterWorks.js +2 -6
- package/lib/beforeCompile/ux/UxBeforeCompile.js +2 -2
- package/lib/beforeCompile/xts/preInstall.js +2 -1
- package/lib/beforeWorks/ux/UxBeforeWorks.js +2 -5
- package/lib/compiler/interface/ISignConfig.d.ts +0 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +15 -6
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +1 -2
- package/lib/compiler/javascript/android/plugin/WrapPlugin.d.ts +1 -1
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +16 -3
- package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +4 -4
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +3 -3
- package/lib/compiler/javascript/vela/interface/IChunk.d.ts +0 -1
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +1 -1
- package/lib/compiler/javascript/vela/model/Package.d.ts +1 -1
- package/lib/compiler/javascript/vela/model/Package.js +3 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +1 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +2 -2
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js +1 -5
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +4 -2
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +10 -8
- package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +0 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +5 -6
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +24 -15
- package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +0 -1
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +1 -1
- package/lib/config/UxConfig.d.ts +5 -3
- package/lib/config/UxConfig.js +15 -4
- package/lib/loader/ux/vela/UxLoader.js +9 -1
- package/lib/utils/BeforeCompileUtils.d.ts +2 -2
- package/lib/utils/BeforeCompileUtils.js +25 -10
- package/lib/utils/ux/UxFileUtils.d.ts +12 -0
- package/lib/utils/ux/UxFileUtils.js +33 -0
- package/lib/utils/ux/UxLoaderUtils.d.ts +1 -1
- package/lib/utils/xts/XtsFollowWorks.js +1 -1
- package/package.json +9 -10
|
@@ -15,6 +15,13 @@ declare class UxAfterCompile {
|
|
|
15
15
|
* @param compilerOption
|
|
16
16
|
*/
|
|
17
17
|
static copyResource: FollowWork<IJavascriptCompileOption>;
|
|
18
|
+
/**
|
|
19
|
+
* 对比 临时项目build文件夹 和 项目build文件夹,生成diff.json
|
|
20
|
+
* @param context
|
|
21
|
+
* @param config
|
|
22
|
+
* @param compilerOption
|
|
23
|
+
*/
|
|
24
|
+
static generateDiff: FollowWork<IJavascriptCompileOption>;
|
|
18
25
|
/**
|
|
19
26
|
* 打包结果移回源码项目,并删除中间项目
|
|
20
27
|
*
|
|
@@ -30,7 +30,8 @@ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobu
|
|
|
30
30
|
class UxAfterCompile {
|
|
31
31
|
}
|
|
32
32
|
_a = UxAfterCompile;
|
|
33
|
-
UxAfterCompile.webpack = (
|
|
33
|
+
UxAfterCompile.webpack = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const { context, compilerOption } = params;
|
|
34
35
|
return new JavascriptCompiler_1.default()
|
|
35
36
|
.compile(Object.assign(Object.assign({ projectPath: path_1.default.join(context.projectPath, context.output), mode: CompileMode_1.default.DEVELOPMENT, devtool: false, platform: 'vela' }, JavascriptDefaultCompileOption_1.default), compilerOption))
|
|
36
37
|
.then(() => {
|
|
@@ -68,17 +69,20 @@ UxAfterCompile.webpack = (context, config, compilerOption) => __awaiter(void 0,
|
|
|
68
69
|
}
|
|
69
70
|
});
|
|
70
71
|
});
|
|
71
|
-
UxAfterCompile.protobuf = (
|
|
72
|
+
UxAfterCompile.protobuf = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const { compilerOption } = params;
|
|
72
74
|
if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
|
|
73
75
|
BinaryPlugin.createBinFiles();
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
|
-
UxAfterCompile.jsc = (
|
|
78
|
+
UxAfterCompile.jsc = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
const { context, compilerOption } = params;
|
|
77
80
|
if (compilerOption && compilerOption.enableJsc === true) {
|
|
78
81
|
return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
|
|
79
82
|
}
|
|
80
83
|
});
|
|
81
|
-
UxAfterCompile.toRpk = (
|
|
84
|
+
UxAfterCompile.toRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const { compilerOption } = params;
|
|
82
86
|
if (compilerOption) {
|
|
83
87
|
return ZipUtil_1.default.createRpk(path_1.default.join(compilerOption.projectPath, compilerOption.outputPath), compilerOption);
|
|
84
88
|
}
|
|
@@ -89,7 +93,8 @@ UxAfterCompile.toRpk = (context, config, compilerOption) => __awaiter(void 0, vo
|
|
|
89
93
|
* @param config
|
|
90
94
|
* @param compilerOption
|
|
91
95
|
*/
|
|
92
|
-
UxAfterCompile.copyResource = (
|
|
96
|
+
UxAfterCompile.copyResource = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
+
const { context, compilerOption } = params;
|
|
93
98
|
const genDeviceManifests = (compilerOption) => {
|
|
94
99
|
const { projectPath, sourceRoot, outputPath } = compilerOption;
|
|
95
100
|
const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
|
|
@@ -197,6 +202,24 @@ UxAfterCompile.copyResource = (context, config, compilerOption) => __awaiter(voi
|
|
|
197
202
|
yield genMetaFiles(compilerOption);
|
|
198
203
|
}
|
|
199
204
|
});
|
|
205
|
+
/**
|
|
206
|
+
* 对比 临时项目build文件夹 和 项目build文件夹,生成diff.json
|
|
207
|
+
* @param context
|
|
208
|
+
* @param config
|
|
209
|
+
* @param compilerOption
|
|
210
|
+
*/
|
|
211
|
+
UxAfterCompile.generateDiff = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
|
+
const { compilerOption, compalition } = params;
|
|
213
|
+
if (!compilerOption || !compalition) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const { outputPath, projectPath } = compilerOption;
|
|
217
|
+
// 读取临时项目build文件夹中所有文件路径
|
|
218
|
+
const tempBuildPath = path_1.default.join(projectPath, outputPath);
|
|
219
|
+
// 待优化,map文件跟随源文件变化,与时间戳有关文件无需对比
|
|
220
|
+
const tempFileList = shared_utils_1.FileUtil.readAlldirSync(tempBuildPath).map((filePath) => path_1.default.relative(tempBuildPath, filePath));
|
|
221
|
+
UxFileUtils_1.default.getDiffJSON(compalition, tempFileList, tempBuildPath);
|
|
222
|
+
});
|
|
200
223
|
/**
|
|
201
224
|
* 打包结果移回源码项目,并删除中间项目
|
|
202
225
|
*
|
|
@@ -206,7 +229,8 @@ UxAfterCompile.copyResource = (context, config, compilerOption) => __awaiter(voi
|
|
|
206
229
|
* @param config
|
|
207
230
|
* @param compilerOption
|
|
208
231
|
*/
|
|
209
|
-
UxAfterCompile.moveBackResult = (
|
|
232
|
+
UxAfterCompile.moveBackResult = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
233
|
+
const { context, compilerOption } = params;
|
|
210
234
|
if (!compilerOption) {
|
|
211
235
|
return;
|
|
212
236
|
}
|
|
@@ -232,7 +256,8 @@ UxAfterCompile.moveBackResult = (context, config, compilerOption) => __awaiter(v
|
|
|
232
256
|
* @param config
|
|
233
257
|
* @param compilerOption
|
|
234
258
|
*/
|
|
235
|
-
UxAfterCompile.symlinkNodeModule = (
|
|
259
|
+
UxAfterCompile.symlinkNodeModule = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
260
|
+
const { context, compilerOption } = params;
|
|
236
261
|
if (!compilerOption) {
|
|
237
262
|
return;
|
|
238
263
|
}
|
|
@@ -122,11 +122,12 @@ exports.XtsEntryFileName = '__entry__.ts';
|
|
|
122
122
|
* 生成 __entry__.ts 文件
|
|
123
123
|
* @param context
|
|
124
124
|
*/
|
|
125
|
-
const generateEntryFile = function generateEntryFile(
|
|
126
|
-
var _a, _b;
|
|
125
|
+
const generateEntryFile = function generateEntryFile(params) {
|
|
127
126
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
var _a, _b;
|
|
128
|
+
const { context, compilerOption } = params;
|
|
128
129
|
const { projectPath, output } = context;
|
|
129
|
-
if ((_a =
|
|
130
|
+
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
|
|
130
131
|
shared_utils_1.ColorConsole.info(`### skip generate entry file due to --skip xts2ts}`);
|
|
131
132
|
return;
|
|
132
133
|
}
|
|
@@ -40,10 +40,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
40
40
|
const XtsFollowWorks_1 = __importDefault(require("../../utils/xts/XtsFollowWorks"));
|
|
41
41
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
42
42
|
const ts2wasm_1 = require("./ts2wasm");
|
|
43
|
-
const generateRpk = (
|
|
43
|
+
const generateRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
44
|
var _a;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const { context, compilerOption } = params;
|
|
46
|
+
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('package')) {
|
|
47
|
+
shared_utils_1.ColorConsole.info(`### skip package due to --skip ${compilerOption.skip.join(',')}`);
|
|
47
48
|
return;
|
|
48
49
|
}
|
|
49
50
|
const manifestPath = path_1.default.resolve(context.projectPath, 'app', 'manifest.json');
|
|
@@ -24,8 +24,9 @@ exports.wasmPackageName = 'wasmUnpacked';
|
|
|
24
24
|
* 将 __entry__.ts 文件打包成 warm 文件
|
|
25
25
|
* @param context
|
|
26
26
|
*/
|
|
27
|
-
const ts2wasm = (
|
|
27
|
+
const ts2wasm = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
var _a;
|
|
29
|
+
const { context, compilerOption } = params;
|
|
29
30
|
/** 1. 生成 app.wasm 文件 */
|
|
30
31
|
const { projectPath, output } = context;
|
|
31
32
|
const buildDir = path_1.default.resolve(projectPath, output);
|
|
@@ -43,8 +44,8 @@ const ts2wasm = (context, _, compilerOptions) => __awaiter(void 0, void 0, void
|
|
|
43
44
|
});
|
|
44
45
|
shared_utils_1.ColorConsole.info(`### ts2wasm ### ${res.toString()}`);
|
|
45
46
|
}
|
|
46
|
-
if ((_a =
|
|
47
|
-
shared_utils_1.ColorConsole.info(`### skip compile ts to wasm due to --skip ${
|
|
47
|
+
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('ts2wasm')) {
|
|
48
|
+
shared_utils_1.ColorConsole.info(`### skip compile ts to wasm due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
51
|
compile();
|
|
@@ -8,18 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
15
13
|
const file_lane_1 = require("file-lane");
|
|
16
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
14
|
class UxAfterWorks {
|
|
18
15
|
static cleanOutput(context) {
|
|
19
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
17
|
const outputPath = file_lane_1.FileLaneUtil.getOutputPath(context);
|
|
21
|
-
|
|
22
|
-
fs_extra_1.default.removeSync(outputPath);
|
|
18
|
+
shared_utils_1.FileUtil.del(outputPath);
|
|
23
19
|
});
|
|
24
20
|
}
|
|
25
21
|
}
|
|
@@ -20,11 +20,11 @@ const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
|
|
|
20
20
|
class UxBeforeCompile {
|
|
21
21
|
}
|
|
22
22
|
_a = UxBeforeCompile;
|
|
23
|
-
UxBeforeCompile.validateManifest = (
|
|
23
|
+
UxBeforeCompile.validateManifest = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
|
|
24
24
|
const { projectPath } = context;
|
|
25
25
|
return UxFileUtils_1.default.validateManifest(projectPath);
|
|
26
26
|
});
|
|
27
|
-
UxBeforeCompile.validateSitemap = (
|
|
27
|
+
UxBeforeCompile.validateSitemap = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
|
|
28
28
|
const { projectPath } = context;
|
|
29
29
|
UxFileUtils_1.default.validateSitemap(projectPath);
|
|
30
30
|
});
|
|
@@ -17,8 +17,9 @@ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
|
17
17
|
const child_process_1 = require("child_process");
|
|
18
18
|
const fs_1 = __importDefault(require("fs"));
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const preInstall = (
|
|
20
|
+
const preInstall = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
var _a;
|
|
22
|
+
const { context, compilerOption } = params;
|
|
22
23
|
if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('install')) {
|
|
23
24
|
shared_utils_1.ColorConsole.info(`### skip install pre-dependencies due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
|
|
24
25
|
return;
|
|
@@ -8,17 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
12
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
13
|
const file_lane_1 = require("file-lane");
|
|
17
14
|
class UxBeforeWorks {
|
|
18
15
|
static cleanOutput(context) {
|
|
19
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
17
|
const outputPath = file_lane_1.FileLaneUtil.getOutputPath(context);
|
|
21
|
-
|
|
18
|
+
shared_utils_1.FileUtil.del(outputPath);
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
21
|
}
|
|
@@ -13,9 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
+
const core_1 = require("@rspack/core");
|
|
16
17
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
18
|
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const webpack_1 = require("webpack");
|
|
19
19
|
const AndroidWebpackConfigurator_1 = __importDefault(require("./android/AndroidWebpackConfigurator"));
|
|
20
20
|
const VelaWebpackConfigurator_1 = __importDefault(require("./vela/VelaWebpackConfigurator"));
|
|
21
21
|
const UxCompileUtil_1 = __importDefault(require("./vela/utils/UxCompileUtil"));
|
|
@@ -28,12 +28,12 @@ class JavascriptCompiler {
|
|
|
28
28
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
yield this.clean(param);
|
|
30
30
|
const config = this.createWebpackConfig(param);
|
|
31
|
-
(0,
|
|
31
|
+
(0, core_1.rspack)(config, (error, stats) => {
|
|
32
32
|
if (error) {
|
|
33
33
|
reject({ errors: [error] });
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
-
const statsObj = stats === null || stats === void 0 ? void 0 : stats.toJson();
|
|
36
|
+
const statsObj = stats === null || stats === void 0 ? void 0 : stats.toJson({});
|
|
37
37
|
if (statsObj) {
|
|
38
38
|
const { errors, warnings } = statsObj;
|
|
39
39
|
if ((errors === null || errors === void 0 ? void 0 : errors.length) || (warnings === null || warnings === void 0 ? void 0 : warnings.length)) {
|
|
@@ -68,7 +68,7 @@ class JavascriptCompiler {
|
|
|
68
68
|
const result = {
|
|
69
69
|
context: projectPath,
|
|
70
70
|
mode,
|
|
71
|
-
devtool,
|
|
71
|
+
devtool: devtool,
|
|
72
72
|
output: {
|
|
73
73
|
globalObject: 'window',
|
|
74
74
|
filename: '[name].js',
|
|
@@ -78,7 +78,7 @@ class JavascriptCompiler {
|
|
|
78
78
|
module: {
|
|
79
79
|
rules: [
|
|
80
80
|
{
|
|
81
|
-
test: /\.ux$/,
|
|
81
|
+
test: /\.ux$/, // 匹配以 .ux 结尾的文件
|
|
82
82
|
use: [
|
|
83
83
|
{
|
|
84
84
|
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/extractMapData.js')
|
|
@@ -87,6 +87,15 @@ class JavascriptCompiler {
|
|
|
87
87
|
}
|
|
88
88
|
]
|
|
89
89
|
},
|
|
90
|
+
optimization: {
|
|
91
|
+
minimizer: [
|
|
92
|
+
new core_1.rspack.SwcJsMinimizerRspackPlugin({
|
|
93
|
+
minimizerOptions: {
|
|
94
|
+
module: true
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
},
|
|
90
99
|
resolve: {
|
|
91
100
|
extensions: ['.js', '.ts', '.ux']
|
|
92
101
|
},
|
|
@@ -115,7 +124,7 @@ class JavascriptCompiler {
|
|
|
115
124
|
// 判断devtool类型 inline-source-map时,添加第0列关系映射
|
|
116
125
|
if (devtool === 'inline-source-map') {
|
|
117
126
|
result.module.rules.unshift({
|
|
118
|
-
test: /\.ux$/,
|
|
127
|
+
test: /\.ux$/, // 匹配以 .ux 结尾的文件
|
|
119
128
|
use: [
|
|
120
129
|
{
|
|
121
130
|
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/addColSourceMap.js')
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setServerPort =
|
|
6
|
+
exports.setServerPort = setServerPort;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const clientRecordPath = path_1.default.join(os_1.default.homedir(), 'hap-toolkit-client-records.json');
|
|
@@ -19,5 +19,4 @@ const JavascriptDefaultCompileOption = {
|
|
|
19
19
|
function setServerPort(port) {
|
|
20
20
|
JavascriptDefaultCompileOption.server.port = port;
|
|
21
21
|
}
|
|
22
|
-
exports.setServerPort = setServerPort;
|
|
23
22
|
exports.default = JavascriptDefaultCompileOption;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const core_1 = require("@rspack/core");
|
|
7
7
|
const webpack_sources_1 = require("webpack-sources");
|
|
8
8
|
const UxFileUtils_1 = __importDefault(require("../../../../utils/ux/UxFileUtils"));
|
|
9
9
|
/**
|
|
@@ -17,7 +17,7 @@ class WrapPlugin {
|
|
|
17
17
|
compiler.hooks.compilation.tap('WrapPlugin', (compilation) => {
|
|
18
18
|
compilation.hooks.processAssets.tap({
|
|
19
19
|
name: 'WrapPlugin',
|
|
20
|
-
stage:
|
|
20
|
+
stage: core_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
21
21
|
}, () => {
|
|
22
22
|
this.wrap(compilation);
|
|
23
23
|
});
|
|
@@ -46,7 +46,20 @@ class WrapPlugin {
|
|
|
46
46
|
return new webpack_sources_1.ConcatSource(`
|
|
47
47
|
(function () {
|
|
48
48
|
var createPageHandler = function () {
|
|
49
|
-
|
|
49
|
+
// 转换动态 style 的函数
|
|
50
|
+
var $translateStyle$ = function (value) {
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
return Object.fromEntries(value.split(';').filter(item => Boolean(item && item.trim())).map(
|
|
53
|
+
item => {
|
|
54
|
+
const matchs = item.match(/([^:]+):(.*)/)
|
|
55
|
+
if (matchs && matchs.lenth> 2) {
|
|
56
|
+
return [matchs[1].trim().replace(/-([a-z])/g, (_, match) => match.toUpperCase()), matchs[2].trim()]
|
|
57
|
+
}
|
|
58
|
+
return []
|
|
59
|
+
}))}
|
|
60
|
+
return value
|
|
61
|
+
}
|
|
62
|
+
return`, source, `;
|
|
50
63
|
};
|
|
51
64
|
if (typeof window === "undefined") {
|
|
52
65
|
return createPageHandler();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Configuration, EntryObject,
|
|
2
|
-
import ICompileParam from
|
|
1
|
+
import { Configuration, EntryObject, RspackOptions, RspackPluginInstance, RuleSetRule } from '@rspack/core';
|
|
2
|
+
import ICompileParam from '../../interface/ICompileParam';
|
|
3
3
|
/**
|
|
4
4
|
* webpack配置器
|
|
5
5
|
*
|
|
@@ -18,11 +18,11 @@ interface IWebpackConfigurator {
|
|
|
18
18
|
*
|
|
19
19
|
* 如实现此函数,则其它函数无效
|
|
20
20
|
*/
|
|
21
|
-
create?():
|
|
21
|
+
create?(): RspackOptions;
|
|
22
22
|
/**
|
|
23
23
|
* 创建 webpack 的 plugins
|
|
24
24
|
*/
|
|
25
|
-
createPlugins?():
|
|
25
|
+
createPlugins?(): RspackPluginInstance[];
|
|
26
26
|
/**
|
|
27
27
|
* 创建 webpack 的 entry
|
|
28
28
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { EntryObject, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
2
1
|
import ICompileParam from '../../interface/ICompileParam';
|
|
3
2
|
import IJavascriptCompileOption from '../interface/IJavascriptCompileOption';
|
|
4
3
|
import IWebpackConfigurator from '../interface/IWebpackConfigurator';
|
|
4
|
+
import { EntryObject, RuleSetRule, RspackPluginInstance } from '@rspack/core';
|
|
5
5
|
declare class VelaWebpackConfigurator implements IWebpackConfigurator {
|
|
6
6
|
param: ICompileParam & IJavascriptCompileOption;
|
|
7
|
-
createPlugins():
|
|
8
|
-
protected createWrapPlugin():
|
|
7
|
+
createPlugins(): RspackPluginInstance[];
|
|
8
|
+
protected createWrapPlugin(): RspackPluginInstance;
|
|
9
9
|
protected createBundleAnalyzerPlugin(): any;
|
|
10
10
|
/**
|
|
11
11
|
* 通过读取 manifest.json 生成 entry
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
3
2
|
/**
|
|
4
3
|
* 文件资源
|
|
@@ -64,6 +63,7 @@ declare class Package {
|
|
|
64
63
|
* @returns
|
|
65
64
|
*/
|
|
66
65
|
include(filePath: string): boolean;
|
|
66
|
+
getResource(filePath: string): IFileResource | undefined;
|
|
67
67
|
/**
|
|
68
68
|
* 添加资源
|
|
69
69
|
* @param data
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const core_1 = require("@rspack/core");
|
|
4
4
|
const webpack_sources_1 = require("webpack-sources");
|
|
5
5
|
class WrapPlugin {
|
|
6
6
|
apply(compiler) {
|
|
@@ -8,7 +8,7 @@ class WrapPlugin {
|
|
|
8
8
|
compiler.hooks.compilation.tap('WrapPlugin', (compilation) => {
|
|
9
9
|
compilation.hooks.processAssets.tap({
|
|
10
10
|
name: 'WrapPlugin',
|
|
11
|
-
stage:
|
|
11
|
+
stage: core_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12
12
|
}, () => {
|
|
13
13
|
this.wrap(compilation);
|
|
14
14
|
});
|
|
@@ -8,12 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
-
const del_1 = __importDefault(require("del"));
|
|
17
13
|
/**
|
|
18
14
|
* Jsc
|
|
19
15
|
*/
|
|
@@ -32,7 +28,7 @@ class Jsc {
|
|
|
32
28
|
}
|
|
33
29
|
}))
|
|
34
30
|
.then(() => {
|
|
35
|
-
return
|
|
31
|
+
return shared_utils_1.FileUtil.del(`${buildPath}/**/*.js`);
|
|
36
32
|
})
|
|
37
33
|
.catch((error) => {
|
|
38
34
|
shared_utils_1.ColorConsole.throw(error.message);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
3
2
|
import JSZip from 'jszip';
|
|
4
3
|
import IJavascriptCompileOption from '../../interface/IJavascriptCompileOption';
|
|
5
4
|
import IManifest from '../interface/IManifest';
|
|
5
|
+
import Package from '../model/Package';
|
|
6
6
|
/**
|
|
7
7
|
* Zip 用于将打包成功的 build 目录按特定规则压缩成 rpk
|
|
8
8
|
*
|
|
@@ -52,7 +52,9 @@ declare class ZipUtil {
|
|
|
52
52
|
* @param files
|
|
53
53
|
* @returns
|
|
54
54
|
*/
|
|
55
|
-
|
|
55
|
+
static createPackagesDefinition(param: IJavascriptCompileOption, config: IManifest, files: string[]): Promise<{
|
|
56
|
+
fullPackage: Package;
|
|
57
|
+
}>;
|
|
56
58
|
/**
|
|
57
59
|
* 获取有序的文件列表
|
|
58
60
|
*
|
|
@@ -54,10 +54,9 @@ class ZipUtil {
|
|
|
54
54
|
}
|
|
55
55
|
// 2
|
|
56
56
|
const { fullPackage } = yield this.createPackagesDefinition(param, config, files);
|
|
57
|
-
const zipBuffer = yield this.packageToZipBuffer(fullPackage);
|
|
58
57
|
// 生产出带签名的rpk文件buffer
|
|
59
58
|
const signConfig = SignUtil_1.default.getProjectSignConfig(param);
|
|
60
|
-
const rpkBuffer = yield
|
|
59
|
+
const rpkBuffer = yield _a.buildProjectAndOutput(fullPackage, signConfig);
|
|
61
60
|
// 3
|
|
62
61
|
this.generateDistFile(rpkBuffer, param, this.getFileName(param, config, 'rpk'));
|
|
63
62
|
});
|
|
@@ -131,9 +130,9 @@ class ZipUtil {
|
|
|
131
130
|
for (let fileBuildPath of files) {
|
|
132
131
|
const absPath = path_1.default.join(projectPath, outputPath, fileBuildPath);
|
|
133
132
|
let fileContentBuffer = fs_extra_1.default.readFileSync(absPath);
|
|
134
|
-
if (fileBuildPath ===
|
|
133
|
+
if (fileBuildPath === _a.CERT_PATH) {
|
|
135
134
|
let metaZip = yield jszip_1.default.loadAsync(fileContentBuffer);
|
|
136
|
-
fileContentBuffer = (yield metaZip.generateAsync(Object.assign(Object.assign({},
|
|
135
|
+
fileContentBuffer = (yield metaZip.generateAsync(Object.assign(Object.assign({}, _a.ZIP_OPTION), { comment: null })));
|
|
137
136
|
}
|
|
138
137
|
const fileContentDigest = shared_utils_1.CommonUtil.calcDataDigest(fileContentBuffer);
|
|
139
138
|
const resourceInfo = {
|
|
@@ -212,7 +211,7 @@ class ZipUtil {
|
|
|
212
211
|
...entrySkFiles,
|
|
213
212
|
new RegExp(`^${entry}/$`),
|
|
214
213
|
new RegExp(`^${entry}/.+`),
|
|
215
|
-
/^common\//i,
|
|
214
|
+
/^common\//i, // 静态资源
|
|
216
215
|
/.+\.js/,
|
|
217
216
|
'META-INF/build.txt'
|
|
218
217
|
];
|
|
@@ -241,12 +240,12 @@ class ZipUtil {
|
|
|
241
240
|
* @param signConfig 证书信息
|
|
242
241
|
* @returns
|
|
243
242
|
*/
|
|
244
|
-
static buildProjectAndOutput(
|
|
243
|
+
static buildProjectAndOutput(target, signConfig) {
|
|
245
244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
246
|
-
let result
|
|
245
|
+
let result;
|
|
247
246
|
if (signConfig) {
|
|
248
247
|
const { privatekey, certificate } = signConfig;
|
|
249
|
-
const fullPackageBuffer = yield SignUtil_1.default.
|
|
248
|
+
const fullPackageBuffer = yield SignUtil_1.default.signPackage(target, privatekey, certificate);
|
|
250
249
|
if (fullPackageBuffer === false) {
|
|
251
250
|
shared_utils_1.ColorConsole.throw('Fullpackage signature failed');
|
|
252
251
|
}
|
|
@@ -254,6 +253,9 @@ class ZipUtil {
|
|
|
254
253
|
result = fullPackageBuffer;
|
|
255
254
|
}
|
|
256
255
|
}
|
|
256
|
+
if (!result) {
|
|
257
|
+
result = yield this.packageToZipBuffer(target);
|
|
258
|
+
}
|
|
257
259
|
return result;
|
|
258
260
|
});
|
|
259
261
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import IJavascriptCompileOption from '../../../interface/IJavascriptCompileOption';
|
|
2
|
+
import Package from '../../model/Package';
|
|
3
3
|
/**
|
|
4
4
|
* SignUtil
|
|
5
5
|
*/
|
|
@@ -16,16 +16,15 @@ declare class SignUtil {
|
|
|
16
16
|
/**
|
|
17
17
|
* 对二进制zipBuffer签名
|
|
18
18
|
*
|
|
19
|
-
* 1.
|
|
20
|
-
* 2.
|
|
21
|
-
* 3.
|
|
22
|
-
* 4. 对“新zipBuffer”,做整体签名
|
|
19
|
+
* 1. 对`META-INF/CERT`做签名,并生成新的`META-INF/CERT` buffer
|
|
20
|
+
* 2. "新`META-INF/CERT` + 其它文件"生成新的 zipBuffer
|
|
21
|
+
* 3. 对“新zipBuffer”,做整体签名
|
|
23
22
|
* @param zipBuffer
|
|
24
23
|
* @param privatekey
|
|
25
24
|
* @param certificate
|
|
26
25
|
* @returns
|
|
27
26
|
*/
|
|
28
|
-
static
|
|
27
|
+
static signPackage(target: Package, privatekey: Buffer, certificate: Buffer): Promise<false | Buffer>;
|
|
29
28
|
/**
|
|
30
29
|
* 根据ZIP流获取文件实例
|
|
31
30
|
*
|
|
@@ -99,24 +99,25 @@ class SignUtil {
|
|
|
99
99
|
/**
|
|
100
100
|
* 对二进制zipBuffer签名
|
|
101
101
|
*
|
|
102
|
-
* 1.
|
|
103
|
-
* 2.
|
|
104
|
-
* 3.
|
|
105
|
-
* 4. 对“新zipBuffer”,做整体签名
|
|
102
|
+
* 1. 对`META-INF/CERT`做签名,并生成新的`META-INF/CERT` buffer
|
|
103
|
+
* 2. "新`META-INF/CERT` + 其它文件"生成新的 zipBuffer
|
|
104
|
+
* 3. 对“新zipBuffer”,做整体签名
|
|
106
105
|
* @param zipBuffer
|
|
107
106
|
* @param privatekey
|
|
108
107
|
* @param certificate
|
|
109
108
|
* @returns
|
|
110
109
|
*/
|
|
111
|
-
static
|
|
110
|
+
static signPackage(target, privatekey, certificate) {
|
|
112
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
|
|
114
|
-
const
|
|
112
|
+
var _a;
|
|
113
|
+
const getFileBuffer = (path) => {
|
|
114
|
+
return target.getResource(path);
|
|
115
|
+
};
|
|
115
116
|
// 摘要 和 文件列表
|
|
116
117
|
const fileDigestHash = [];
|
|
117
118
|
const fileList = [];
|
|
118
|
-
//
|
|
119
|
-
const metaBuffer =
|
|
119
|
+
// 1
|
|
120
|
+
const metaBuffer = (_a = getFileBuffer(ZipUtil_1.default.CERT_PATH)) === null || _a === void 0 ? void 0 : _a.fileContentBuffer;
|
|
120
121
|
if (metaBuffer) {
|
|
121
122
|
const metaHash = {
|
|
122
123
|
name: ZipUtil_1.default.DIGEST_HASH_JSON,
|
|
@@ -138,9 +139,17 @@ class SignUtil {
|
|
|
138
139
|
});
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
|
-
// 2
|
|
142
|
-
const files =
|
|
143
|
-
files
|
|
142
|
+
// 2
|
|
143
|
+
const files = target.resourceList;
|
|
144
|
+
files
|
|
145
|
+
.map((item) => {
|
|
146
|
+
return {
|
|
147
|
+
path: item.fileBuildPath,
|
|
148
|
+
content: item.fileContentBuffer
|
|
149
|
+
};
|
|
150
|
+
})
|
|
151
|
+
.filter(SignUtil.fileFilter)
|
|
152
|
+
.map((item) => {
|
|
144
153
|
fileList.push(item);
|
|
145
154
|
fileDigestHash.push({
|
|
146
155
|
name: item.path,
|
|
@@ -148,8 +157,8 @@ class SignUtil {
|
|
|
148
157
|
});
|
|
149
158
|
});
|
|
150
159
|
// 因为META变化,重新创建ZIP流
|
|
151
|
-
const newZipBuffer = yield ZipUtil_1.default.createZipBufferFromFileList(fileList,
|
|
152
|
-
//
|
|
160
|
+
const newZipBuffer = yield ZipUtil_1.default.createZipBufferFromFileList(fileList, target.comment);
|
|
161
|
+
// 3
|
|
153
162
|
const signedZipBuffer = SignUtil.doSign(newZipBuffer, fileDigestHash, privatekey, certificate);
|
|
154
163
|
if (signedZipBuffer === false) {
|
|
155
164
|
// 签名失败
|
|
@@ -426,7 +435,7 @@ class SignUtil {
|
|
|
426
435
|
const cert = Buffer.from(Base64_1.default.unarmor(certificate));
|
|
427
436
|
const c = new jsrsasign_1.default.X509();
|
|
428
437
|
c.readCertPEM(certificate.toString());
|
|
429
|
-
const pubKey = jsrsasign_1.default.KEYUTIL.getPEM(c.
|
|
438
|
+
const pubKey = jsrsasign_1.default.KEYUTIL.getPEM(c.getPublicKey());
|
|
430
439
|
// 摘要块
|
|
431
440
|
const digestBuf = Buffer.alloc(sign.length + 12);
|
|
432
441
|
digestBuf.writeInt32LE(sign.length + 8, 0);
|
package/lib/config/UxConfig.d.ts
CHANGED
|
@@ -7,19 +7,21 @@ import HmlLoader from '../loader/ux/vela/HmlLoader';
|
|
|
7
7
|
import UxLoader from '../loader/ux/vela/UxLoader';
|
|
8
8
|
import UxBeforeWorks from '../beforeWorks/ux/UxBeforeWorks';
|
|
9
9
|
import UxAfterWorks from '../afterWorks/ux/UxAfterWorks';
|
|
10
|
+
import { IChangedFile } from 'file-lane/lib/interface/IChangedFile';
|
|
10
11
|
declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
11
12
|
readonly projectPath: string;
|
|
12
13
|
constructor(projectPath: string);
|
|
13
14
|
/**
|
|
14
15
|
* 1. 取项目中所有的真实文件
|
|
15
|
-
* 1.1 无entryFileList
|
|
16
|
+
* 1.1 无entryFileList时
|
|
16
17
|
* 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
|
|
18
|
+
* 1.3 有entryFileList且文件列表中有文件为 删除 操作时
|
|
17
19
|
* 2. 返回符合条件的文件列表
|
|
18
20
|
* 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
|
|
19
21
|
* @param entryFileList
|
|
20
22
|
* @returns
|
|
21
23
|
*/
|
|
22
|
-
collectFile: (entryFileList?:
|
|
24
|
+
collectFile: (entryFileList?: IChangedFile[]) => string[];
|
|
23
25
|
exclude: (RegExp | ((filePath: string) => boolean))[];
|
|
24
26
|
get output(): string;
|
|
25
27
|
beforeWorks: (typeof UxBeforeWorks.cleanOutput)[];
|
|
@@ -29,7 +31,7 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
|
29
31
|
workerDescribe: string;
|
|
30
32
|
}[];
|
|
31
33
|
afterWorks: (typeof UxAfterWorks.cleanOutput)[];
|
|
32
|
-
watchIgnores:
|
|
34
|
+
watchIgnores: RegExp[];
|
|
33
35
|
/**
|
|
34
36
|
* 通过项目类型,返回模块配置
|
|
35
37
|
*/
|
package/lib/config/UxConfig.js
CHANGED
|
@@ -18,13 +18,15 @@ const UxAfterWorks_1 = __importDefault(require("../afterWorks/ux/UxAfterWorks"))
|
|
|
18
18
|
const UxAfterCompile_1 = __importDefault(require("../afterCompile/ux/UxAfterCompile"));
|
|
19
19
|
const UxBeforeCompile_1 = __importDefault(require("../beforeCompile/ux/UxBeforeCompile"));
|
|
20
20
|
const BeforeCompileUtils_1 = __importDefault(require("../utils/BeforeCompileUtils"));
|
|
21
|
+
const IChangedFile_1 = require("file-lane/lib/interface/IChangedFile");
|
|
21
22
|
class UxConfig {
|
|
22
23
|
constructor(projectPath) {
|
|
23
24
|
this.projectPath = projectPath;
|
|
24
25
|
/**
|
|
25
26
|
* 1. 取项目中所有的真实文件
|
|
26
|
-
* 1.1 无entryFileList
|
|
27
|
+
* 1.1 无entryFileList时
|
|
27
28
|
* 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
|
|
29
|
+
* 1.3 有entryFileList且文件列表中有文件为 删除 操作时
|
|
28
30
|
* 2. 返回符合条件的文件列表
|
|
29
31
|
* 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
|
|
30
32
|
* @param entryFileList
|
|
@@ -38,8 +40,13 @@ class UxConfig {
|
|
|
38
40
|
return files;
|
|
39
41
|
};
|
|
40
42
|
// 2.
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
+
if (entryFileList) {
|
|
44
|
+
let isGetAll = entryFileList.every((item) => item.type === IChangedFile_1.HandlerType.UNLINK || !/\.(ux|json|js)$/.test(item.path));
|
|
45
|
+
if (!isGetAll) {
|
|
46
|
+
return entryFileList
|
|
47
|
+
.filter((filePath) => shared_utils_1.FileUtil.include(filePath.path, undefined, this.exclude))
|
|
48
|
+
.map((item) => item.path);
|
|
49
|
+
}
|
|
43
50
|
}
|
|
44
51
|
// 1.
|
|
45
52
|
return getProjectFiles();
|
|
@@ -94,13 +101,17 @@ class UxConfig {
|
|
|
94
101
|
worker: UxAfterCompile_1.default.toRpk,
|
|
95
102
|
workerDescribe: 'Package the project into an RPK file'
|
|
96
103
|
},
|
|
104
|
+
{
|
|
105
|
+
worker: UxAfterCompile_1.default.generateDiff,
|
|
106
|
+
workerDescribe: 'Generate diff json'
|
|
107
|
+
},
|
|
97
108
|
{
|
|
98
109
|
worker: UxAfterCompile_1.default.moveBackResult,
|
|
99
110
|
workerDescribe: 'Migrate temporary project'
|
|
100
111
|
}
|
|
101
112
|
];
|
|
102
113
|
this.afterWorks = [UxAfterWorks_1.default.cleanOutput];
|
|
103
|
-
this.watchIgnores = [/node_modules/,
|
|
114
|
+
this.watchIgnores = [/node_modules/, /build/, /dist/];
|
|
104
115
|
}
|
|
105
116
|
get output() {
|
|
106
117
|
const name = path_1.default.basename(this.projectPath);
|
|
@@ -23,7 +23,15 @@ class UxLoader {
|
|
|
23
23
|
for (const file of files) {
|
|
24
24
|
// 转换每个文件
|
|
25
25
|
const { files: compiledFiles, logs } = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false, this.compilerOption);
|
|
26
|
-
|
|
26
|
+
// style报错中,@import导入的文件报错路径存储在item.position.source中
|
|
27
|
+
shared_utils_1.CommonUtil.processingLogsInTerminal(logs.map((item) => {
|
|
28
|
+
var _a;
|
|
29
|
+
return (Object.assign(Object.assign({}, item), { filePath: ((_a = item.position) === null || _a === void 0 ? void 0 : _a.source)
|
|
30
|
+
? item.position.source
|
|
31
|
+
: item.filePath
|
|
32
|
+
? path_1.default.relative(projectPath, item.filePath)
|
|
33
|
+
: '' }));
|
|
34
|
+
}));
|
|
27
35
|
resultFiles.push(...compiledFiles);
|
|
28
36
|
}
|
|
29
37
|
return resultFiles;
|
|
@@ -10,8 +10,8 @@ declare class BeforeCompileUtils {
|
|
|
10
10
|
* @param fileList
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
static getEntries: PreWork
|
|
14
|
-
static clean: PreWork
|
|
13
|
+
static getEntries: PreWork;
|
|
14
|
+
static clean: PreWork;
|
|
15
15
|
/**
|
|
16
16
|
* 获取项目的全局样式变量配置
|
|
17
17
|
* @param context
|
|
@@ -15,7 +15,6 @@ var _a;
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
const parser_1 = require("@aiot-toolkit/parser");
|
|
17
17
|
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
|
-
const del_1 = __importDefault(require("del"));
|
|
19
18
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
20
19
|
const path_1 = __importDefault(require("path"));
|
|
21
20
|
const TranslateCache_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/TranslateCache"));
|
|
@@ -33,7 +32,8 @@ _a = BeforeCompileUtils;
|
|
|
33
32
|
* @param fileList
|
|
34
33
|
* @returns
|
|
35
34
|
*/
|
|
36
|
-
BeforeCompileUtils.getEntries = (
|
|
35
|
+
BeforeCompileUtils.getEntries = (params) => {
|
|
36
|
+
const { context, compilerOption } = params;
|
|
37
37
|
const { projectPath } = context;
|
|
38
38
|
const srcPath = path_1.default.join(projectPath, compilerOption.sourceRoot);
|
|
39
39
|
// 判断路径是否真实存在
|
|
@@ -70,27 +70,42 @@ BeforeCompileUtils.getEntries = (context, fileList, config, compilerOption) => {
|
|
|
70
70
|
context['entries'] = entryList;
|
|
71
71
|
return Promise.resolve();
|
|
72
72
|
};
|
|
73
|
-
BeforeCompileUtils.clean = (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
BeforeCompileUtils.clean = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
const { context, compilerOption, compalition } = params;
|
|
75
|
+
if (compilerOption) {
|
|
76
|
+
// 存储build中的文件列表
|
|
77
|
+
const buildPath = path_1.default.join(context.projectPath, compilerOption.outputPath);
|
|
78
|
+
const buildFileList = fs_extra_1.default.existsSync(buildPath)
|
|
79
|
+
? shared_utils_1.FileUtil.readAlldirSync(buildPath).map((filePath) => {
|
|
80
|
+
const relativePath = path_1.default.relative(buildPath, filePath);
|
|
81
|
+
const fileContent = fs_extra_1.default.readFileSync(filePath);
|
|
82
|
+
return { path: relativePath, content: fileContent };
|
|
83
|
+
})
|
|
84
|
+
: [];
|
|
85
|
+
if (compalition) {
|
|
86
|
+
compalition.buildFileList = buildFileList;
|
|
87
|
+
}
|
|
88
|
+
// 清空build文件夹、dist文件夹
|
|
89
|
+
yield shared_utils_1.FileUtil.del(path_1.default.join(context.projectPath, compilerOption.outputPath));
|
|
90
|
+
yield shared_utils_1.FileUtil.del(path_1.default.join(context.projectPath, compilerOption.releasePath));
|
|
77
91
|
}
|
|
78
92
|
context.translateCache = new TranslateCache_1.default();
|
|
79
93
|
BinaryPlugin.reset();
|
|
80
94
|
BinaryPlugin.config = {
|
|
81
95
|
projectPath: context.projectPath,
|
|
82
96
|
outputProjectPath: path_1.default.join(context.projectPath, context.output),
|
|
83
|
-
source:
|
|
84
|
-
output:
|
|
97
|
+
source: compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.sourceRoot,
|
|
98
|
+
output: compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.outputPath
|
|
85
99
|
};
|
|
86
100
|
});
|
|
87
101
|
/**
|
|
88
102
|
* 获取项目的全局样式变量配置
|
|
89
103
|
* @param context
|
|
90
104
|
*/
|
|
91
|
-
BeforeCompileUtils.getGlobalVar = (
|
|
105
|
+
BeforeCompileUtils.getGlobalVar = (params) => {
|
|
106
|
+
const { context, compilerOption } = params;
|
|
92
107
|
const { projectPath } = context;
|
|
93
|
-
const filePath = path_1.default.join(projectPath, compilerOption.sourceRoot, 'globalVar.json');
|
|
108
|
+
const filePath = path_1.default.join(projectPath, (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.sourceRoot) || '', 'globalVar.json');
|
|
94
109
|
let globalVar = {};
|
|
95
110
|
// 判断文件是否存在
|
|
96
111
|
if (fs_extra_1.default.existsSync(filePath)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import IManifest from '../../compiler/javascript/vela/interface/IManifest';
|
|
2
|
+
import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
|
|
2
3
|
export declare class UxFileUtils {
|
|
3
4
|
static readonly CONFIG_FILE_NAME = "manifest.json";
|
|
4
5
|
/**
|
|
@@ -35,5 +36,16 @@ export declare class UxFileUtils {
|
|
|
35
36
|
* @param sourceRoot
|
|
36
37
|
*/
|
|
37
38
|
static validateSitemap(projectPath: string, sourceRoot?: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* 1. 遍历旧文件列表
|
|
41
|
+
* 1.1 若文件路径在新文件列表newFileList中,且内容一致时,从newFileList中移除该项
|
|
42
|
+
* 1.2 若文件路径在新文件列表newFileList中,且内容不一致时,添加到diffList中表示待更新,从newFileList中移除该项
|
|
43
|
+
* 1.3 若文件路径不在新文件列表中,表示该文件待删除(热更新时,可以不做删除,删除耗费性能)
|
|
44
|
+
* 2. 若遍历完旧文件列表后,newFileList长度不为0,表示有文件待新增
|
|
45
|
+
* @param oldFileList 旧文件列表
|
|
46
|
+
* @param newFileList 新文件列表
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
static getDiffJSON(compilation: FileLaneCompilation, newFileList: string[], buildPath: string): void;
|
|
38
50
|
}
|
|
39
51
|
export default UxFileUtils;
|
|
@@ -97,6 +97,39 @@ class UxFileUtils {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* 1. 遍历旧文件列表
|
|
102
|
+
* 1.1 若文件路径在新文件列表newFileList中,且内容一致时,从newFileList中移除该项
|
|
103
|
+
* 1.2 若文件路径在新文件列表newFileList中,且内容不一致时,添加到diffList中表示待更新,从newFileList中移除该项
|
|
104
|
+
* 1.3 若文件路径不在新文件列表中,表示该文件待删除(热更新时,可以不做删除,删除耗费性能)
|
|
105
|
+
* 2. 若遍历完旧文件列表后,newFileList长度不为0,表示有文件待新增
|
|
106
|
+
* @param oldFileList 旧文件列表
|
|
107
|
+
* @param newFileList 新文件列表
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
static getDiffJSON(compilation, newFileList, buildPath) {
|
|
111
|
+
var _a;
|
|
112
|
+
const oldFileList = compilation.buildFileList;
|
|
113
|
+
let diffList = [];
|
|
114
|
+
// 1.
|
|
115
|
+
for (let i = 0; i < oldFileList.length; i++) {
|
|
116
|
+
const index = newFileList.findIndex((file) => file === oldFileList[i].path);
|
|
117
|
+
// 1.3
|
|
118
|
+
if (index !== -1) {
|
|
119
|
+
// 1.2
|
|
120
|
+
const oldContent = (_a = oldFileList[i].content) === null || _a === void 0 ? void 0 : _a.toString('utf-8');
|
|
121
|
+
const newContent = fs_extra_1.default.readFileSync(path_1.default.join(buildPath, newFileList[index]), 'utf-8');
|
|
122
|
+
if (oldContent !== newContent) {
|
|
123
|
+
diffList.push(newFileList[index]);
|
|
124
|
+
}
|
|
125
|
+
// 从newFileList中移除该项
|
|
126
|
+
newFileList.splice(index, 1);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// 2.
|
|
130
|
+
newFileList.length > 0 && newFileList.forEach((file) => diffList.push(file));
|
|
131
|
+
compilation.diffJson = diffList;
|
|
132
|
+
}
|
|
100
133
|
}
|
|
101
134
|
exports.UxFileUtils = UxFileUtils;
|
|
102
135
|
UxFileUtils.CONFIG_FILE_NAME = 'manifest.json';
|
|
@@ -25,7 +25,7 @@ declare class UxLoaderUtils {
|
|
|
25
25
|
* @param context
|
|
26
26
|
*/
|
|
27
27
|
static compileAppUxToJavascript(file: IFileParam, context: IFileLaneContext, compileOption: IJavascriptCompileOption): Promise<{
|
|
28
|
-
files: IFileParam
|
|
28
|
+
files: IFileParam[];
|
|
29
29
|
logs: ILog[];
|
|
30
30
|
}>;
|
|
31
31
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.2-beta.
|
|
3
|
+
"version": "2.0.2-beta.18",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,24 +19,23 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.0.2-beta.
|
|
23
|
-
"@aiot-toolkit/parser": "2.0.2-beta.
|
|
24
|
-
"@aiot-toolkit/shared-utils": "2.0.2-beta.
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.2-beta.18",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.2-beta.18",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.2-beta.18",
|
|
25
25
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
26
|
+
"@rspack/core": "^1.0.0",
|
|
26
27
|
"aiot-parse5": "^1.0.0",
|
|
27
|
-
"archiver": "^
|
|
28
|
+
"archiver": "^7.0.1",
|
|
28
29
|
"babel-loader": "^9.1.3",
|
|
29
|
-
"del": "^4.1.1",
|
|
30
30
|
"fast-glob": "^3.3.2",
|
|
31
|
-
"file-lane": "2.0.2-beta.
|
|
31
|
+
"file-lane": "2.0.2-beta.18",
|
|
32
32
|
"file-loader": "^6.2.0",
|
|
33
33
|
"fs-extra": "^11.2.0",
|
|
34
|
-
"jsrsasign": "^
|
|
34
|
+
"jsrsasign": "^11.1.0",
|
|
35
35
|
"jszip": "^3.10.1",
|
|
36
36
|
"lodash": "^4.17.21",
|
|
37
37
|
"ts-morph": "^19.0.0",
|
|
38
38
|
"url-loader": "^4.1.1",
|
|
39
|
-
"webpack": "^5.89.0",
|
|
40
39
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
41
40
|
"webpack-sources": "^3.2.3"
|
|
42
41
|
},
|
|
@@ -46,5 +45,5 @@
|
|
|
46
45
|
"@types/jsrsasign": "^10.5.12",
|
|
47
46
|
"@types/webpack-sources": "^3.2.3"
|
|
48
47
|
},
|
|
49
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "b73a79ef04edac808f316bf8b8fb1718422daa1c"
|
|
50
49
|
}
|