@aiot-toolkit/aiotpack 2.0.3-beta.7 → 2.0.3-beta.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/lib/afterCompile/ux/UxAfterCompile.js +301 -266
- package/lib/afterCompile/xts/entryTemplate.js +111 -113
- package/lib/afterCompile/xts/generateRpk.js +25 -54
- package/lib/afterCompile/xts/ts2wasm.js +62 -63
- package/lib/afterWorks/ux/UxAfterWorks.js +12 -19
- package/lib/beforeCompile/ux/UxBeforeCompile.js +26 -25
- package/lib/beforeCompile/xts/preInstall.js +50 -55
- package/lib/beforeWorks/ux/UxBeforeWorks.js +12 -19
- package/lib/compiler/enum/CompileMode.js +16 -23
- package/lib/compiler/interface/ICompileParam.js +1 -2
- package/lib/compiler/interface/ICompiler.js +1 -2
- package/lib/compiler/interface/ISignConfig.js +1 -2
- package/lib/compiler/javascript/JavascriptCompiler.js +147 -154
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +20 -16
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +13 -11
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +52 -48
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +1 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +78 -75
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +30 -41
- package/lib/compiler/javascript/vela/enum/EntryType.js +15 -29
- package/lib/compiler/javascript/vela/interface/IChunk.js +4 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js +1 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +1 -2
- package/lib/compiler/javascript/vela/model/Package.js +80 -51
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +30 -26
- package/lib/compiler/javascript/vela/utils/Jsc.js +30 -33
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +152 -130
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -276
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +65 -67
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +37 -35
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +755 -731
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +24 -22
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +47 -52
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +21 -17
- package/lib/config/UxConfig.js +145 -173
- package/lib/config/XtsConfig.js +30 -40
- package/lib/index.js +88 -41
- package/lib/interface/ICompileOptions.js +5 -2
- package/lib/interface/IDeviceList.js +1 -2
- package/lib/loader/ux/JsLoader.js +32 -30
- package/lib/loader/ux/PngLoader.js +47 -53
- package/lib/loader/ux/android/UxLoader.js +30 -31
- package/lib/loader/ux/vela/AppUxLoader.js +23 -24
- package/lib/loader/ux/vela/HmlLoader.js +59 -55
- package/lib/loader/ux/vela/UxLoader.js +29 -35
- package/lib/loader/xts/XtsLoader.js +55 -41
- package/lib/utils/BeforeCompileUtils.js +100 -92
- package/lib/utils/PngUtils.js +42 -36
- package/lib/utils/ux/ManifestSchema.js +198 -194
- package/lib/utils/ux/UxFileUtils.js +130 -116
- package/lib/utils/ux/UxLoaderUtils.js +292 -307
- package/lib/utils/ux/android/AndroidUx.js +88 -90
- package/lib/utils/xts/XtsFileLaneUtils.js +58 -65
- package/lib/utils/xts/XtsFollowWorks.js +122 -129
- package/package.json +6 -6
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
13
8
|
/**
|
|
14
9
|
* Jsc
|
|
15
10
|
*/
|
|
16
11
|
class Jsc {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
constructor(projectPath, buildPath) {
|
|
13
|
+
this.projectPath = projectPath;
|
|
14
|
+
this.buildPath = buildPath;
|
|
15
|
+
}
|
|
16
|
+
jsc() {
|
|
17
|
+
const {
|
|
18
|
+
projectPath,
|
|
19
|
+
buildPath
|
|
20
|
+
} = this;
|
|
21
|
+
return _sharedUtils.CommonUtil.requireNodeModule(projectPath, `@aiot-toolkit/jsc`).then(async module => {
|
|
22
|
+
const msg = await module.default(buildPath);
|
|
23
|
+
if (msg) {
|
|
24
|
+
_sharedUtils.ColorConsole.success({
|
|
25
|
+
word: 'jsc command'
|
|
26
|
+
}, msg);
|
|
27
|
+
}
|
|
28
|
+
}).then(() => {
|
|
29
|
+
return _sharedUtils.FileUtil.del(`${buildPath}/**/*.js`);
|
|
30
|
+
}).catch(error => {
|
|
31
|
+
_sharedUtils.ColorConsole.throw(error.message);
|
|
32
|
+
return Promise.reject(error);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
38
35
|
}
|
|
39
|
-
exports.default = Jsc;
|
|
36
|
+
var _default = exports.default = Jsc;
|
|
@@ -1,142 +1,164 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _EntryType = _interopRequireDefault(require("../enum/EntryType"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
12
|
class UxCompileUtil {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (fs_extra_1.default.existsSync(item)) {
|
|
17
|
-
if (fs_extra_1.default.statSync(item).isFile()) {
|
|
18
|
-
fs_extra_1.default.unlinkSync(item);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
fs_extra_1.default.rmSync(item, { recursive: true, force: true });
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
13
|
+
// 摘要文件夹
|
|
14
|
+
static DIGEST_ZIP_DIR = 'META-INF';
|
|
15
|
+
static clean(dirList) {
|
|
16
|
+
if (!dirList) {
|
|
17
|
+
return;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!router) {
|
|
36
|
-
throw Error('No routing configured in manifest.json!');
|
|
37
|
-
}
|
|
38
|
-
const appFile = this.resolveFile(path_1.default.join(codeDir, 'app'));
|
|
39
|
-
if (!fs_extra_1.default.existsSync(appFile)) {
|
|
40
|
-
shared_utils_1.ColorConsole.throw(`App file does not exist`);
|
|
19
|
+
dirList.forEach(item => {
|
|
20
|
+
if (_fsExtra.default.existsSync(item)) {
|
|
21
|
+
if (_fsExtra.default.statSync(item).isFile()) {
|
|
22
|
+
_fsExtra.default.unlinkSync(item);
|
|
23
|
+
} else {
|
|
24
|
+
_fsExtra.default.rmSync(item, {
|
|
25
|
+
recursive: true,
|
|
26
|
+
force: true
|
|
27
|
+
});
|
|
41
28
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (name && path) {
|
|
95
|
-
result['services/' + name] = './src/' + path + `?uxType=${EntryType_1.default.APP}`;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 从项目配置文件中解析出入口文件
|
|
35
|
+
* @param config 项目配置文件的内容,应为json对象
|
|
36
|
+
* @param codeDir 源码目录
|
|
37
|
+
* @param projectPath 项目目录
|
|
38
|
+
* @returns {[入口名]:源文件路径}
|
|
39
|
+
*/
|
|
40
|
+
static resolveEntries(config, codeDir, projectPath) {
|
|
41
|
+
const {
|
|
42
|
+
router
|
|
43
|
+
} = config;
|
|
44
|
+
if (!router) {
|
|
45
|
+
throw Error('No routing configured in manifest.json!');
|
|
46
|
+
}
|
|
47
|
+
const appFile = this.resolveFile(_path.default.join(codeDir, 'app'));
|
|
48
|
+
if (!_fsExtra.default.existsSync(appFile)) {
|
|
49
|
+
_sharedUtils.ColorConsole.throw(`App file does not exist`);
|
|
50
|
+
}
|
|
51
|
+
const {
|
|
52
|
+
pages = {},
|
|
53
|
+
widgets = {},
|
|
54
|
+
floatingWindows = {}
|
|
55
|
+
} = router;
|
|
56
|
+
const confsList = [{
|
|
57
|
+
confs: pages,
|
|
58
|
+
type: _EntryType.default.PAGE
|
|
59
|
+
}, {
|
|
60
|
+
confs: floatingWindows,
|
|
61
|
+
type: _EntryType.default.FLOAT
|
|
62
|
+
}, {
|
|
63
|
+
confs: widgets,
|
|
64
|
+
type: _EntryType.default.CARD
|
|
65
|
+
}];
|
|
66
|
+
|
|
67
|
+
// 1. 添加app
|
|
68
|
+
const result = {
|
|
69
|
+
app: `./${_path.default.relative(projectPath, appFile)}?uxType=${_EntryType.default.APP}`
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// 2. 添加 route 配置的文件
|
|
73
|
+
confsList.forEach(item => {
|
|
74
|
+
const {
|
|
75
|
+
confs,
|
|
76
|
+
type
|
|
77
|
+
} = item;
|
|
78
|
+
Object.keys(confs).forEach(routePath => {
|
|
79
|
+
if (/^\//.test(routePath)) {
|
|
80
|
+
throw new Error(`Compilation failed: please confirm that '${routePath}' configured by router.pages in manifest.json is the directory name`);
|
|
98
81
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
}
|
|
82
|
+
const conf = confs[routePath];
|
|
83
|
+
const entryKey = _path.default.join(routePath, conf.component);
|
|
84
|
+
const filePath = this.resolveFile(_path.default.join(codeDir, entryKey));
|
|
85
|
+
if (!filePath) {
|
|
86
|
+
throw new Error(`Compilation failed: please confirm that the file path ${entryKey} configured in manifest.json exists`);
|
|
106
87
|
}
|
|
107
|
-
|
|
88
|
+
let sourceFile = `./${_path.default.relative(projectPath, filePath)}?uxType=${type}`;
|
|
89
|
+
sourceFile = sourceFile.replace(/\\/g, '/');
|
|
90
|
+
result[entryKey] = sourceFile;
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// 3. 添加 workers
|
|
95
|
+
const {
|
|
96
|
+
workers
|
|
97
|
+
} = config;
|
|
98
|
+
if (workers && workers.entries && Array.isArray(workers.entries)) {
|
|
99
|
+
workers.entries.filter(worker => worker.file).forEach(worker => {
|
|
100
|
+
result[worker.file.replace(/\.js$/, '')] = './src/' + worker.file;
|
|
101
|
+
});
|
|
108
102
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
103
|
+
|
|
104
|
+
// 4. 添加 services
|
|
105
|
+
const {
|
|
106
|
+
services
|
|
107
|
+
} = config;
|
|
108
|
+
// 数组格式
|
|
109
|
+
if (Array.isArray(services)) {
|
|
110
|
+
services.forEach(item => {
|
|
111
|
+
const {
|
|
112
|
+
name,
|
|
113
|
+
path
|
|
114
|
+
} = item;
|
|
115
|
+
if (name && path) {
|
|
116
|
+
result['services/' + name] = './src/' + path + `?uxType=${_EntryType.default.APP}`;
|
|
124
117
|
}
|
|
125
|
-
|
|
118
|
+
});
|
|
126
119
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
static getExtensionList(withDot = true) {
|
|
133
|
-
const result = ['ux', 'hml'];
|
|
134
|
-
if (withDot) {
|
|
135
|
-
return result.map((item) => `.${item}`);
|
|
120
|
+
// 字典格式
|
|
121
|
+
else {
|
|
122
|
+
for (const key in services) {
|
|
123
|
+
if (Object.hasOwnProperty.call(services, key)) {
|
|
124
|
+
result['services/' + key] = './src/' + services[key].path + `?uxType=${_EntryType.default.APP}`;
|
|
136
125
|
}
|
|
137
|
-
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* 通过无后缀的文件名路径获取存在的文件路径
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const path = resolveFile('/project/a')
|
|
136
|
+
* // path = '/project/a.ux'
|
|
137
|
+
* @param filePath
|
|
138
|
+
*/
|
|
139
|
+
static resolveFile(filePath) {
|
|
140
|
+
const extensionList = this.getExtensionList();
|
|
141
|
+
for (const item of extensionList) {
|
|
142
|
+
const currentPath = `${filePath}${item}`;
|
|
143
|
+
if (_fsExtra.default.existsSync(currentPath)) {
|
|
144
|
+
return currentPath;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return '';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 获取ux文件支持的后缀列表
|
|
152
|
+
* @param withDot
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
static getExtensionList() {
|
|
156
|
+
let withDot = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
157
|
+
const result = ['ux', 'hml'];
|
|
158
|
+
if (withDot) {
|
|
159
|
+
return result.map(item => `.${item}`);
|
|
138
160
|
}
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
139
163
|
}
|
|
140
|
-
|
|
141
|
-
UxCompileUtil.DIGEST_ZIP_DIR = 'META-INF';
|
|
142
|
-
exports.default = UxCompileUtil;
|
|
164
|
+
var _default = exports.default = UxCompileUtil;
|