@aiot-toolkit/aiotpack 2.0.5-beta.9 → 2.0.5-widget-provider-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -46
- package/lib/afterCompile/ux/UxAfterCompile.d.ts +28 -1
- package/lib/afterCompile/ux/UxAfterCompile.js +186 -38
- package/lib/afterWorks/ux/UxAfterWorks.js +1 -1
- package/lib/beforeCompile/ux/UxBeforeCompile.js +2 -2
- package/lib/compiler/enum/CompileMode.js +2 -2
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +14 -0
- package/lib/compiler/javascript/JavascriptCompiler.js +91 -5
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +2 -2
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +7 -7
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +17 -1
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +5 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +3 -3
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +2 -2
- package/lib/compiler/javascript/vela/enum/EntryType.js +2 -2
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +11 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js +11 -1
- package/lib/compiler/javascript/vela/model/Package.js +28 -28
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +1 -2
- package/lib/compiler/javascript/vela/utils/Jsc.js +2 -2
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +31 -17
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +62 -62
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +2 -2
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +2 -2
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +68 -68
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +6 -6
- package/lib/compiler/javascript/vela/utils/signature/pem/certificate.pem +26 -26
- package/lib/compiler/javascript/vela/utils/signature/pem/private.pem +50 -50
- package/lib/compiler/javascript/vela/utils/webpackLoader/IWebpackLoaderOption.d.ts +11 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/IWebpackLoaderOption.js +1 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackJsLoader.d.ts +2 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackJsLoader.js +27 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackUxLoader.d.ts +2 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackUxLoader.js +26 -0
- package/lib/compiler/tools/icu/ImageIcu.d.ts +37 -0
- package/lib/compiler/tools/icu/ImageIcu.js +110 -0
- package/lib/compiler/tools/icu/icu_darwin_arm64 +0 -0
- package/lib/compiler/tools/icu/icu_darwin_x64 +0 -0
- package/lib/compiler/tools/icu/icu_linux_arm64 +0 -0
- package/lib/compiler/tools/icu/icu_linux_x64 +0 -0
- package/lib/compiler/tools/icu/icu_win32_x64.exe +0 -0
- package/lib/config/UxConfig.d.ts +9 -4
- package/lib/config/UxConfig.js +29 -17
- package/lib/index.d.ts +1 -3
- package/lib/index.js +2 -28
- package/lib/loader/ux/JsLoader.js +2 -2
- package/lib/loader/ux/PngLoader.js +2 -2
- package/lib/loader/ux/android/UxLoader.js +2 -2
- package/lib/loader/ux/vela/AppUxLoader.js +3 -3
- package/lib/loader/ux/vela/HmlLoader.js +14 -14
- package/lib/loader/ux/vela/UxLoader.js +7 -0
- package/lib/utils/BeforeCompileUtils.d.ts +2 -0
- package/lib/utils/BeforeCompileUtils.js +34 -12
- package/lib/utils/PngUtils.js +11 -11
- package/lib/utils/ux/ManifestSchema.js +6 -3
- package/lib/utils/ux/UxFileUtils.d.ts +1 -0
- package/lib/utils/ux/UxFileUtils.js +56 -45
- package/lib/utils/ux/UxLoaderUtils.js +35 -35
- package/lib/utils/ux/android/AndroidUx.js +10 -10
- package/package.json +8 -11
- package/lib/afterCompile/xts/entryTemplate.d.ts +0 -21
- package/lib/afterCompile/xts/entryTemplate.js +0 -182
- package/lib/afterCompile/xts/generateRpk.d.ts +0 -3
- package/lib/afterCompile/xts/generateRpk.js +0 -28
- package/lib/afterCompile/xts/ts2wasm.d.ts +0 -8
- package/lib/afterCompile/xts/ts2wasm.js +0 -69
- package/lib/beforeCompile/xts/preInstall.d.ts +0 -3
- package/lib/beforeCompile/xts/preInstall.js +0 -54
- package/lib/config/XtsConfig.d.ts +0 -22
- package/lib/config/XtsConfig.js +0 -36
- package/lib/interface/ICompileOptions.d.ts +0 -6
- package/lib/interface/ICompileOptions.js +0 -7
- package/lib/loader/xts/XtsLoader.d.ts +0 -9
- package/lib/loader/xts/XtsLoader.js +0 -62
- package/lib/utils/xts/XtsFileLaneUtils.d.ts +0 -10
- package/lib/utils/xts/XtsFileLaneUtils.js +0 -61
- package/lib/utils/xts/XtsFollowWorks.d.ts +0 -34
- package/lib/utils/xts/XtsFollowWorks.js +0 -134
package/lib/config/UxConfig.js
CHANGED
|
@@ -25,15 +25,15 @@ class UxConfig {
|
|
|
25
25
|
constructor(projectPath) {
|
|
26
26
|
this.projectPath = projectPath;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
* 1. 取项目中所有的真实文件
|
|
30
|
-
* 1.1 无entryFileList时
|
|
31
|
-
* 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
|
|
32
|
-
* 1.3 有entryFileList且文件列表中有文件为 删除 操作时
|
|
33
|
-
* 2. 返回符合条件的文件列表
|
|
34
|
-
* 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
|
|
35
|
-
* @param entryFileList
|
|
36
|
-
* @returns
|
|
28
|
+
/**
|
|
29
|
+
* 1. 取项目中所有的真实文件
|
|
30
|
+
* 1.1 无entryFileList时
|
|
31
|
+
* 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
|
|
32
|
+
* 1.3 有entryFileList且文件列表中有文件为 删除 操作时
|
|
33
|
+
* 2. 返回符合条件的文件列表
|
|
34
|
+
* 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
|
|
35
|
+
* @param entryFileList
|
|
36
|
+
* @returns
|
|
37
37
|
*/
|
|
38
38
|
collectFile = entryFileList => {
|
|
39
39
|
// 取项目中所有的真实文件
|
|
@@ -75,20 +75,29 @@ class UxConfig {
|
|
|
75
75
|
beforeWorks = (() => [_UxBeforeWorks.default.cleanOutput])();
|
|
76
76
|
beforeCompile = (() => [_UxBeforeCompile.default.validateManifest, _UxBeforeCompile.default.validateSitemap, _BeforeCompileUtils.default.clean, _BeforeCompileUtils.default.getEntries, _BeforeCompileUtils.default.getGlobalVar])();
|
|
77
77
|
afterCompile = (() => [{
|
|
78
|
+
worker: _UxAfterCompile.default.writeGitIgnore,
|
|
79
|
+
workDescribe: 'Write .gitignore'
|
|
80
|
+
}, {
|
|
78
81
|
worker: _UxAfterCompile.default.symlinkNodeModule,
|
|
79
82
|
workerDescribe: 'Create a soft link to the node_modules folder'
|
|
80
83
|
}, {
|
|
81
|
-
worker: _UxAfterCompile.default.
|
|
82
|
-
workerDescribe: 'Compile
|
|
84
|
+
worker: _UxAfterCompile.default.compileJavascript,
|
|
85
|
+
workerDescribe: 'Compile javascript project'
|
|
83
86
|
}, {
|
|
84
87
|
worker: _UxAfterCompile.default.copyResource,
|
|
85
88
|
workerDescribe: 'Copy resource files'
|
|
89
|
+
}, {
|
|
90
|
+
worker: _UxAfterCompile.default.compressResource,
|
|
91
|
+
workerDescribe: 'Compress resource files'
|
|
86
92
|
}, {
|
|
87
93
|
worker: _UxAfterCompile.default.jsc,
|
|
88
94
|
workerDescribe: 'Generate jsc bytecode'
|
|
89
95
|
}, {
|
|
90
96
|
worker: _UxAfterCompile.default.protobuf,
|
|
91
97
|
workerDescribe: 'Generate protobuf json'
|
|
98
|
+
}, {
|
|
99
|
+
worker: _UxAfterCompile.default.compileLiteCard,
|
|
100
|
+
workerDescribe: 'compile lite card'
|
|
92
101
|
}, {
|
|
93
102
|
worker: _UxAfterCompile.default.toRpk,
|
|
94
103
|
workerDescribe: 'Package the project into an RPK file'
|
|
@@ -98,12 +107,15 @@ class UxConfig {
|
|
|
98
107
|
}, {
|
|
99
108
|
worker: _UxAfterCompile.default.moveBackResult,
|
|
100
109
|
workerDescribe: 'Migrate temporary project'
|
|
110
|
+
}, {
|
|
111
|
+
worker: _UxAfterCompile.default.resourceCheck,
|
|
112
|
+
workerDescribe: 'Check resource'
|
|
101
113
|
}])();
|
|
102
114
|
afterWorks = (() => [_UxAfterWorks.default.cleanOutput])();
|
|
103
115
|
watchIgnores = [/node_modules/, /build/, /dist/];
|
|
104
116
|
|
|
105
|
-
/**
|
|
106
|
-
* 通过项目类型,返回模块配置
|
|
117
|
+
/**
|
|
118
|
+
* 通过项目类型,返回模块配置
|
|
107
119
|
*/
|
|
108
120
|
get module() {
|
|
109
121
|
const isVela = this.getProjectType() === _sharedUtils.ProjectType.VELA_UX;
|
|
@@ -139,10 +151,10 @@ class UxConfig {
|
|
|
139
151
|
};
|
|
140
152
|
}
|
|
141
153
|
|
|
142
|
-
/**
|
|
143
|
-
* 判断项目类型
|
|
144
|
-
*
|
|
145
|
-
* 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
|
|
154
|
+
/**
|
|
155
|
+
* 判断项目类型
|
|
156
|
+
*
|
|
157
|
+
* 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
|
|
146
158
|
*/
|
|
147
159
|
getProjectType() {
|
|
148
160
|
return _sharedUtils.ProjectType.getProjectType(this.projectPath);
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import XtsConfig from './config/XtsConfig';
|
|
2
1
|
import JavascriptDefaultCompileOption, { setServerPort } from './compiler/javascript/JavascriptDefaultCompileOption';
|
|
3
2
|
import UxConfig from './config/UxConfig';
|
|
4
3
|
import CompileMode from './compiler/enum/CompileMode';
|
|
@@ -6,5 +5,4 @@ import IJavascriptCompileOption from './compiler/javascript/interface/IJavascrip
|
|
|
6
5
|
import IQuickAppConfig from './compiler/javascript/vela/interface/IQuickAppConfig';
|
|
7
6
|
import UxFileUtils from './utils/ux/UxFileUtils';
|
|
8
7
|
import IManifest from './compiler/javascript/vela/interface/IManifest';
|
|
9
|
-
|
|
10
|
-
export { XtsConfig, UxConfig, JavascriptDefaultCompileOption, CompileMode, IJavascriptCompileOption, IQuickAppConfig, setServerPort, UxFileUtils, IManifest, skipList, IXtsCompileOptions, ISkipList };
|
|
8
|
+
export { UxConfig, JavascriptDefaultCompileOption, CompileMode, IJavascriptCompileOption, IQuickAppConfig, setServerPort, UxFileUtils, IManifest };
|
package/lib/index.js
CHANGED
|
@@ -27,18 +27,6 @@ Object.defineProperty(exports, "IQuickAppConfig", {
|
|
|
27
27
|
return _IQuickAppConfig.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "ISkipList", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _ICompileOptions.ISkipList;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "IXtsCompileOptions", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _ICompileOptions.IXtsCompileOptions;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
30
|
Object.defineProperty(exports, "JavascriptDefaultCompileOption", {
|
|
43
31
|
enumerable: true,
|
|
44
32
|
get: function () {
|
|
@@ -57,25 +45,12 @@ Object.defineProperty(exports, "UxFileUtils", {
|
|
|
57
45
|
return _UxFileUtils.default;
|
|
58
46
|
}
|
|
59
47
|
});
|
|
60
|
-
Object.defineProperty(exports, "XtsConfig", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function () {
|
|
63
|
-
return _XtsConfig.default;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
48
|
Object.defineProperty(exports, "setServerPort", {
|
|
67
49
|
enumerable: true,
|
|
68
50
|
get: function () {
|
|
69
51
|
return _JavascriptDefaultCompileOption.setServerPort;
|
|
70
52
|
}
|
|
71
53
|
});
|
|
72
|
-
Object.defineProperty(exports, "skipList", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function () {
|
|
75
|
-
return _ICompileOptions.skipList;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
var _XtsConfig = _interopRequireDefault(require("./config/XtsConfig"));
|
|
79
54
|
var _JavascriptDefaultCompileOption = _interopRequireWildcard(require("./compiler/javascript/JavascriptDefaultCompileOption"));
|
|
80
55
|
var _UxConfig = _interopRequireDefault(require("./config/UxConfig"));
|
|
81
56
|
var _CompileMode = _interopRequireDefault(require("./compiler/enum/CompileMode"));
|
|
@@ -83,7 +58,6 @@ var _IJavascriptCompileOption = _interopRequireDefault(require("./compiler/javas
|
|
|
83
58
|
var _IQuickAppConfig = _interopRequireDefault(require("./compiler/javascript/vela/interface/IQuickAppConfig"));
|
|
84
59
|
var _UxFileUtils = _interopRequireDefault(require("./utils/ux/UxFileUtils"));
|
|
85
60
|
var _IManifest = _interopRequireDefault(require("./compiler/javascript/vela/interface/IManifest"));
|
|
86
|
-
|
|
61
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
87
62
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
88
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
89
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
63
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _parser = require("@aiot-toolkit/parser");
|
|
8
8
|
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
9
|
-
/**
|
|
10
|
-
* JsLoader
|
|
9
|
+
/**
|
|
10
|
+
* JsLoader
|
|
11
11
|
*/
|
|
12
12
|
class JsLoader {
|
|
13
13
|
async parser(files) {
|
|
@@ -10,8 +10,8 @@ var _PngUtils = _interopRequireDefault(require("../../utils/PngUtils"));
|
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
const aaptjs = require('@hap-toolkit/aaptjs');
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* PngLoader
|
|
13
|
+
/**
|
|
14
|
+
* PngLoader
|
|
15
15
|
*/
|
|
16
16
|
class PngLoader {
|
|
17
17
|
async parser(files) {
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _AndroidUx = _interopRequireDefault(require("../../../utils/ux/android/AndroidUx"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
-
* UxLoader
|
|
9
|
+
/**
|
|
10
|
+
* UxLoader
|
|
11
11
|
*/
|
|
12
12
|
class UxLoader {
|
|
13
13
|
async parser(files) {
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _UxLoaderUtils = _interopRequireDefault(require("../../../utils/ux/UxLoaderUtils"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
-
* 处理app.ux的Loader
|
|
11
|
-
* AppUxLoader
|
|
9
|
+
/**
|
|
10
|
+
* 处理app.ux的Loader
|
|
11
|
+
* AppUxLoader
|
|
12
12
|
*/
|
|
13
13
|
class AppUxLoader {
|
|
14
14
|
async parser(files) {
|
|
@@ -8,8 +8,8 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
8
8
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
9
|
var _parser = require("@aiot-toolkit/parser");
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
/**
|
|
12
|
-
* HmlLoader
|
|
11
|
+
/**
|
|
12
|
+
* HmlLoader
|
|
13
13
|
*/
|
|
14
14
|
class HmlLoader {
|
|
15
15
|
parser(files) {
|
|
@@ -18,18 +18,18 @@ class HmlLoader {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* 包裹 hml 文件
|
|
23
|
-
*
|
|
24
|
-
* # 路径
|
|
25
|
-
* 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
|
|
26
|
-
*
|
|
27
|
-
* # 内容
|
|
28
|
-
* 1. 给hml的内容加上<template></template>
|
|
29
|
-
* 2. 如果存在同路径同名的 script文件,则加到<script></script>中
|
|
30
|
-
* 3. 如果存在同路径同名的 style文件,则加到<style></style>中
|
|
31
|
-
*
|
|
32
|
-
* @param file
|
|
21
|
+
/**
|
|
22
|
+
* 包裹 hml 文件
|
|
23
|
+
*
|
|
24
|
+
* # 路径
|
|
25
|
+
* 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
|
|
26
|
+
*
|
|
27
|
+
* # 内容
|
|
28
|
+
* 1. 给hml的内容加上<template></template>
|
|
29
|
+
* 2. 如果存在同路径同名的 script文件,则加到<script></script>中
|
|
30
|
+
* 3. 如果存在同路径同名的 style文件,则加到<style></style>中
|
|
31
|
+
*
|
|
32
|
+
* @param file
|
|
33
33
|
*/
|
|
34
34
|
wrapHml(file) {
|
|
35
35
|
const {
|
|
@@ -5,11 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _UxLoaderUtils = _interopRequireDefault(require("../../../utils/ux/UxLoaderUtils"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _parser = require("@aiot-toolkit/parser");
|
|
8
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
class UxLoader {
|
|
10
12
|
async parser(files) {
|
|
11
13
|
const resultFiles = [];
|
|
14
|
+
const liteCardList = this.context.liteCards?.map(item => _path.default.join(this.context.projectPath, this.compilerOption.sourceRoot, `${item}${_parser.ExtensionConfig.UX}`)) || [];
|
|
12
15
|
for (const file of files) {
|
|
16
|
+
// 轻卡ux不转换
|
|
17
|
+
if (liteCardList.includes(file.path)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
13
20
|
// 转换每个文件
|
|
14
21
|
const {
|
|
15
22
|
files: compiledFiles,
|
|
@@ -10,18 +10,21 @@ var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
|
10
10
|
var _path = _interopRequireDefault(require("path"));
|
|
11
11
|
var _TranslateCache = _interopRequireDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/TranslateCache"));
|
|
12
12
|
var _UxFileUtils = _interopRequireDefault(require("./ux/UxFileUtils"));
|
|
13
|
+
var _IManifest = require("../compiler/javascript/vela/interface/IManifest");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
* BeforeCompileUtils
|
|
17
|
+
/**
|
|
18
|
+
* BeforeCompileUtils
|
|
18
19
|
*/
|
|
19
20
|
class BeforeCompileUtils {
|
|
20
|
-
/**
|
|
21
|
-
* 获取ux项目的路由入口
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
21
|
+
/**
|
|
22
|
+
* 获取ux项目的路由入口
|
|
23
|
+
* context.entries中存放ux页面路由
|
|
24
|
+
* context.liteCards中存放轻卡路由
|
|
25
|
+
* @param context
|
|
26
|
+
* @param fileList
|
|
27
|
+
* @returns
|
|
25
28
|
*/
|
|
26
29
|
static getEntries = params => {
|
|
27
30
|
const {
|
|
@@ -34,14 +37,17 @@ class BeforeCompileUtils {
|
|
|
34
37
|
const srcPath = _path.default.join(projectPath, compilerOption.sourceRoot);
|
|
35
38
|
// 判断路径是否真实存在
|
|
36
39
|
const manifestContent = _UxFileUtils.default.getManifestInfo(projectPath);
|
|
37
|
-
//
|
|
40
|
+
// 存储页面entries
|
|
38
41
|
let entryList = [];
|
|
42
|
+
// 存储轻卡路由
|
|
43
|
+
let liteCardList = [];
|
|
39
44
|
const {
|
|
40
45
|
router
|
|
41
46
|
} = manifestContent;
|
|
42
47
|
if (router) {
|
|
43
48
|
const {
|
|
44
|
-
pages
|
|
49
|
+
pages,
|
|
50
|
+
widgets
|
|
45
51
|
} = router;
|
|
46
52
|
if (pages) {
|
|
47
53
|
Object.keys(pages).map(page => {
|
|
@@ -60,11 +66,27 @@ class BeforeCompileUtils {
|
|
|
60
66
|
// 没有pages配置
|
|
61
67
|
_sharedUtils.ColorConsole.throw(`### manifest ### No pages configuration`);
|
|
62
68
|
}
|
|
69
|
+
//获取轻卡路由
|
|
70
|
+
if (widgets) {
|
|
71
|
+
Object.keys(widgets).map(card => {
|
|
72
|
+
const cardContent = widgets[card];
|
|
73
|
+
if (cardContent.type === _IManifest.LITE_CARD_TYPE) {
|
|
74
|
+
const cardPath = _path.default.join(srcPath, card, cardContent.component + _parser.ExtensionConfig.UX);
|
|
75
|
+
if (_fsExtra.default.existsSync(cardPath)) {
|
|
76
|
+
liteCardList.push(card + _path.default.posix.sep + cardContent.component);
|
|
77
|
+
} else {
|
|
78
|
+
// 报错
|
|
79
|
+
_sharedUtils.ColorConsole.throw(`### manifest ### lite card path '${cardPath}' does not exist`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
63
84
|
} else {
|
|
64
85
|
// 没有router配置
|
|
65
86
|
_sharedUtils.ColorConsole.throw(`### manifest ### No router configuration`);
|
|
66
87
|
}
|
|
67
88
|
context['entries'] = entryList;
|
|
89
|
+
context['liteCards'] = liteCardList;
|
|
68
90
|
return Promise.resolve();
|
|
69
91
|
};
|
|
70
92
|
static clean = async params => {
|
|
@@ -97,9 +119,9 @@ class BeforeCompileUtils {
|
|
|
97
119
|
output: compilerOption?.outputPath
|
|
98
120
|
};
|
|
99
121
|
};
|
|
100
|
-
/**
|
|
101
|
-
* 获取项目的全局样式变量配置
|
|
102
|
-
* @param context
|
|
122
|
+
/**
|
|
123
|
+
* 获取项目的全局样式变量配置
|
|
124
|
+
* @param context
|
|
103
125
|
*/
|
|
104
126
|
static getGlobalVar = params => {
|
|
105
127
|
const {
|
package/lib/utils/PngUtils.js
CHANGED
|
@@ -7,14 +7,14 @@ exports.default = void 0;
|
|
|
7
7
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
/**
|
|
11
|
-
* PngUtils
|
|
10
|
+
/**
|
|
11
|
+
* PngUtils
|
|
12
12
|
*/
|
|
13
13
|
class PngUtils {
|
|
14
|
-
/**
|
|
15
|
-
* 检测.9.png是否编码
|
|
16
|
-
* @param filePath
|
|
17
|
-
* @returns
|
|
14
|
+
/**
|
|
15
|
+
* 检测.9.png是否编码
|
|
16
|
+
* @param filePath
|
|
17
|
+
* @returns
|
|
18
18
|
*/
|
|
19
19
|
static isEncode9Png(filePath) {
|
|
20
20
|
const buff = _fsExtra.default.readFileSync(filePath);
|
|
@@ -23,11 +23,11 @@ class PngUtils {
|
|
|
23
23
|
const encode = buff.subarray(start, end).toString() === 'npTc' || buff.subarray(start, end).toString() === 'npOl';
|
|
24
24
|
return encode;
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
* 计算文件转换后的目标路径
|
|
28
|
-
* @param filePath
|
|
29
|
-
* @param context
|
|
30
|
-
* @returns
|
|
26
|
+
/**
|
|
27
|
+
* 计算文件转换后的目标路径
|
|
28
|
+
* @param filePath
|
|
29
|
+
* @param context
|
|
30
|
+
* @returns
|
|
31
31
|
*/
|
|
32
32
|
static convertOutputPath(filePath, context) {
|
|
33
33
|
const {
|
|
@@ -9,13 +9,16 @@ const ManifestSchema = {
|
|
|
9
9
|
required: ['package', 'name', 'icon', 'versionCode', 'config', 'router'],
|
|
10
10
|
properties: {
|
|
11
11
|
package: {
|
|
12
|
-
type: 'string'
|
|
12
|
+
type: 'string',
|
|
13
|
+
minLength: 1
|
|
13
14
|
},
|
|
14
15
|
name: {
|
|
15
|
-
type: 'string'
|
|
16
|
+
type: 'string',
|
|
17
|
+
minLength: 1
|
|
16
18
|
},
|
|
17
19
|
icon: {
|
|
18
|
-
type: 'string'
|
|
20
|
+
type: 'string',
|
|
21
|
+
minLength: 1
|
|
19
22
|
},
|
|
20
23
|
banner: {
|
|
21
24
|
type: 'string'
|
|
@@ -9,43 +9,44 @@ var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
|
10
10
|
var _ManifestSchema = _interopRequireDefault(require("./ManifestSchema"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* FileUtils
|
|
12
|
+
/**
|
|
13
|
+
* FileUtils
|
|
14
14
|
*/
|
|
15
15
|
class UxFileUtils {
|
|
16
16
|
static CONFIG_FILE_NAME = 'manifest.json';
|
|
17
|
-
/**
|
|
18
|
-
* 获取manifest.json路径
|
|
19
|
-
* @param projectPath
|
|
20
|
-
* @param sourceRoot
|
|
21
|
-
* @returns
|
|
17
|
+
/**
|
|
18
|
+
* 获取manifest.json路径
|
|
19
|
+
* @param projectPath
|
|
20
|
+
* @param sourceRoot
|
|
21
|
+
* @returns
|
|
22
22
|
*/
|
|
23
23
|
static getManifestFilePath(projectPath) {
|
|
24
24
|
let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
|
|
25
25
|
return _path.default.resolve(projectPath, sourceRoot, UxFileUtils.CONFIG_FILE_NAME);
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* 获取manifest.json内容
|
|
29
|
-
* @param projectPath
|
|
30
|
-
* @param sourceRoot
|
|
31
|
-
* @returns
|
|
27
|
+
/**
|
|
28
|
+
* 获取manifest.json内容
|
|
29
|
+
* @param projectPath
|
|
30
|
+
* @param sourceRoot
|
|
31
|
+
* @returns
|
|
32
32
|
*/
|
|
33
33
|
static getManifestInfo(projectPath) {
|
|
34
34
|
let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
|
|
35
35
|
return _fsExtra.default.readJSONSync(UxFileUtils.getManifestFilePath(projectPath, sourceRoot));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
* 检查 manifest文件,并显示错误信息
|
|
40
|
-
*
|
|
41
|
-
* 1. 使用ManifestSchema 校验
|
|
42
|
-
* 1. TypeError: Error
|
|
43
|
-
* 2. 其它: Warn
|
|
44
|
-
* 2. 检查 router.entry 是否存在于 router.pages
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @param
|
|
48
|
-
* @
|
|
38
|
+
/**
|
|
39
|
+
* 检查 manifest文件,并显示错误信息
|
|
40
|
+
*
|
|
41
|
+
* 1. 使用ManifestSchema 校验
|
|
42
|
+
* 1. TypeError: Error
|
|
43
|
+
* 2. 其它: Warn
|
|
44
|
+
* 2. 检查 router.entry 是否存在于 router.pages
|
|
45
|
+
* 3. 检查icon是否存在
|
|
46
|
+
*
|
|
47
|
+
* @param projectPath 项目路径
|
|
48
|
+
* @param sourceRoot 源码路径--相对项目根目录
|
|
49
|
+
* @returns
|
|
49
50
|
*/
|
|
50
51
|
static validateManifest(projectPath) {
|
|
51
52
|
let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
|
|
@@ -60,27 +61,37 @@ class UxFileUtils {
|
|
|
60
61
|
const errors = _CommonUtil.default.validateJson(jsonData, schema) || [];
|
|
61
62
|
|
|
62
63
|
// 2
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
if (jsonData.router) {
|
|
65
|
+
const {
|
|
66
|
+
entry,
|
|
67
|
+
pages
|
|
68
|
+
} = jsonData.router;
|
|
69
|
+
if (!pages[entry]) {
|
|
70
|
+
errors.push(new TypeError(`router.entry content: ${entry}, is missing in router.pages`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 3
|
|
75
|
+
if (jsonData.icon) {
|
|
76
|
+
const iconPath = _path.default.join(projectPath, sourceRoot, jsonData.icon);
|
|
77
|
+
if (!_fsExtra.default.existsSync(iconPath)) {
|
|
78
|
+
errors.push(new Error(`icon: "${jsonData.icon}" is missing in project`));
|
|
79
|
+
}
|
|
69
80
|
}
|
|
70
81
|
if (errors?.length) {
|
|
71
|
-
const message = `
|
|
82
|
+
const message = `error in ${path}: ${errors.map((item, index) => {
|
|
72
83
|
return `\r\n${index + 1}. ${item.message}`;
|
|
73
84
|
})}`;
|
|
74
85
|
throw new Error(message);
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
|
|
78
|
-
/**
|
|
79
|
-
* 检查 sitemap.json 文件,并显示错误信息
|
|
80
|
-
*
|
|
81
|
-
* 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错
|
|
82
|
-
* @param projectPath
|
|
83
|
-
* @param sourceRoot
|
|
89
|
+
/**
|
|
90
|
+
* 检查 sitemap.json 文件,并显示错误信息
|
|
91
|
+
*
|
|
92
|
+
* 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错
|
|
93
|
+
* @param projectPath
|
|
94
|
+
* @param sourceRoot
|
|
84
95
|
*/
|
|
85
96
|
static validateSitemap(projectPath) {
|
|
86
97
|
let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
|
|
@@ -101,15 +112,15 @@ class UxFileUtils {
|
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
}
|
|
104
|
-
/**
|
|
105
|
-
* 1. 遍历旧文件列表
|
|
106
|
-
* 1.1 若文件路径在新文件列表newFileList中,且内容一致时,从newFileList中移除该项
|
|
107
|
-
* 1.2 若文件路径在新文件列表newFileList中,且内容不一致时,添加到diffList中表示待更新,从newFileList中移除该项
|
|
108
|
-
* 1.3 若文件路径不在新文件列表中,表示该文件待删除(热更新时,可以不做删除,删除耗费性能)
|
|
109
|
-
* 2. 若遍历完旧文件列表后,newFileList长度不为0,表示有文件待新增
|
|
110
|
-
* @param oldFileList 旧文件列表
|
|
111
|
-
* @param newFileList 新文件列表
|
|
112
|
-
* @returns
|
|
115
|
+
/**
|
|
116
|
+
* 1. 遍历旧文件列表
|
|
117
|
+
* 1.1 若文件路径在新文件列表newFileList中,且内容一致时,从newFileList中移除该项
|
|
118
|
+
* 1.2 若文件路径在新文件列表newFileList中,且内容不一致时,添加到diffList中表示待更新,从newFileList中移除该项
|
|
119
|
+
* 1.3 若文件路径不在新文件列表中,表示该文件待删除(热更新时,可以不做删除,删除耗费性能)
|
|
120
|
+
* 2. 若遍历完旧文件列表后,newFileList长度不为0,表示有文件待新增
|
|
121
|
+
* @param oldFileList 旧文件列表
|
|
122
|
+
* @param newFileList 新文件列表
|
|
123
|
+
* @returns
|
|
113
124
|
*/
|
|
114
125
|
static getDiffJSON(compilation, newFileList, buildPath) {
|
|
115
126
|
const oldFileList = compilation.buildFileList;
|