@aiot-toolkit/aiotpack 2.0.5-beta.2 → 2.0.5-beta.20
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 +28 -1
- package/lib/afterCompile/ux/UxAfterCompile.js +161 -16
- package/lib/afterWorks/ux/UxAfterWorks.js +1 -1
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +14 -0
- package/lib/compiler/javascript/JavascriptCompiler.js +91 -5
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +17 -1
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +5 -1
- 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/plugin/WrapPlugin.js +1 -4
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +5 -0
- 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 +5 -2
- package/lib/config/UxConfig.js +13 -2
- package/lib/index.d.ts +1 -3
- package/lib/index.js +2 -28
- package/lib/loader/ux/JsLoader.d.ts +1 -1
- package/lib/loader/ux/JsLoader.js +20 -17
- package/lib/loader/ux/vela/UxLoader.js +7 -0
- package/lib/utils/BeforeCompileUtils.d.ts +2 -0
- package/lib/utils/BeforeCompileUtils.js +25 -10
- package/lib/utils/ux/FileCompare.d.ts +12 -0
- package/lib/utils/ux/FileCompare.js +47 -0
- package/lib/utils/ux/ManifestSchema.js +6 -3
- package/lib/utils/ux/UxFileUtils.d.ts +11 -8
- package/lib/utils/ux/UxFileUtils.js +48 -27
- package/lib/utils/ux/UxLoaderUtils.js +28 -1
- package/package.json +9 -12
- 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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
declare class ImageIcu {
|
|
2
|
+
static EXT: string;
|
|
3
|
+
static INCLUDE_LIST: string[];
|
|
4
|
+
/**
|
|
5
|
+
* @private
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
getBinPath(): string;
|
|
9
|
+
/**
|
|
10
|
+
* 文件转换为 bin 格式
|
|
11
|
+
* @param {*} resourcePath 源文件
|
|
12
|
+
* @param {*} folder 产物目录
|
|
13
|
+
* @param {'lvgl'|'png'} format
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
translate(resourcePath: string, folder: string, format?: string): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* 资源转换为 bin 文件路径
|
|
19
|
+
*
|
|
20
|
+
* 如果是 png, jpg,jpeg, webp, bmp,则转换为 .bin 后缀;其它类型不处理
|
|
21
|
+
*
|
|
22
|
+
* **此方法仅返回转换后的路径, 不会实际转换文件**
|
|
23
|
+
* @param {string} path
|
|
24
|
+
* @example assetsToBinPath('images/test.png') // images/test.bin
|
|
25
|
+
*
|
|
26
|
+
* @return {string} 可转则返回对应的 bin 路径;否则返回''
|
|
27
|
+
*/
|
|
28
|
+
static assetsToBinPath(assetsPath: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* 是否可转换
|
|
31
|
+
* @param {string} assetsPath
|
|
32
|
+
* @param {'lvgl'|'png'} format
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
static canTranslate(assetsPath: string, format?: string): boolean;
|
|
36
|
+
}
|
|
37
|
+
export default ImageIcu;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _os = _interopRequireDefault(require("os"));
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
+
var _child_process = require("child_process");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
class ImageIcu {
|
|
13
|
+
static EXT = '.bin';
|
|
14
|
+
static INCLUDE_LIST = ['.png', '.jpg', '.jpeg', '.webp', '.bmp'];
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
getBinPath() {
|
|
20
|
+
const platform = _os.default.platform();
|
|
21
|
+
const arch = _os.default.arch();
|
|
22
|
+
let result = _path.default.join(__dirname, `icu_${platform}_${arch}`);
|
|
23
|
+
if (platform === 'win32') {
|
|
24
|
+
result += '.exe';
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 文件转换为 bin 格式
|
|
31
|
+
* @param {*} resourcePath 源文件
|
|
32
|
+
* @param {*} folder 产物目录
|
|
33
|
+
* @param {'lvgl'|'png'} format
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
translate(resourcePath, folder) {
|
|
37
|
+
let format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'lvgl';
|
|
38
|
+
if (!_fs.default.existsSync(resourcePath) || !ImageIcu.canTranslate(resourcePath)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const binPath = this.getBinPath();
|
|
42
|
+
if (_fs.default.existsSync(binPath)) {
|
|
43
|
+
const pathParse = _path.default.parse(resourcePath);
|
|
44
|
+
|
|
45
|
+
// 后缀,lvgl格式的后缀为"bin", 其它保持原后缀
|
|
46
|
+
const extDic = {
|
|
47
|
+
lvgl: ImageIcu.EXT,
|
|
48
|
+
png: pathParse.ext
|
|
49
|
+
};
|
|
50
|
+
const ext = extDic[format];
|
|
51
|
+
if (!_fs.default.existsSync(folder)) {
|
|
52
|
+
_fs.default.mkdirSync(folder, {
|
|
53
|
+
recursive: true
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const command = `"${binPath}" convert "${resourcePath}" -O "${folder}" -F ${format} -C i8 -r`;
|
|
57
|
+
const message = (0, _child_process.execSync)(command).toString('utf-8');
|
|
58
|
+
if (message) {
|
|
59
|
+
console.log(`convert error: path=${resourcePath} message=${message}`);
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
const result = _path.default.join(pathParse.dir, `${pathParse.name}${ext}`);
|
|
63
|
+
return result;
|
|
64
|
+
} else {
|
|
65
|
+
return resourcePath;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 资源转换为 bin 文件路径
|
|
71
|
+
*
|
|
72
|
+
* 如果是 png, jpg,jpeg, webp, bmp,则转换为 .bin 后缀;其它类型不处理
|
|
73
|
+
*
|
|
74
|
+
* **此方法仅返回转换后的路径, 不会实际转换文件**
|
|
75
|
+
* @param {string} path
|
|
76
|
+
* @example assetsToBinPath('images/test.png') // images/test.bin
|
|
77
|
+
*
|
|
78
|
+
* @return {string} 可转则返回对应的 bin 路径;否则返回''
|
|
79
|
+
*/
|
|
80
|
+
static assetsToBinPath(assetsPath) {
|
|
81
|
+
if (!assetsPath) {
|
|
82
|
+
return '';
|
|
83
|
+
}
|
|
84
|
+
const pathParse = _path.default.parse(assetsPath);
|
|
85
|
+
if (ImageIcu.canTranslate(assetsPath)) {
|
|
86
|
+
return _path.default.join(pathParse.dir, `${pathParse.name}${ImageIcu.EXT}`);
|
|
87
|
+
}
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 是否可转换
|
|
93
|
+
* @param {string} assetsPath
|
|
94
|
+
* @param {'lvgl'|'png'} format
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
static canTranslate(assetsPath) {
|
|
98
|
+
let format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'lvgl';
|
|
99
|
+
if (!assetsPath) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const pathParse = _path.default.parse(assetsPath);
|
|
103
|
+
const ext = pathParse.ext.toLowerCase();
|
|
104
|
+
if (format === 'png') {
|
|
105
|
+
return ext === '.png';
|
|
106
|
+
}
|
|
107
|
+
return ImageIcu.INCLUDE_LIST.includes(ext);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
var _default = exports.default = ImageIcu;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/config/UxConfig.d.ts
CHANGED
|
@@ -26,10 +26,13 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
|
26
26
|
get output(): string;
|
|
27
27
|
beforeWorks: (typeof UxBeforeWorks.cleanOutput)[];
|
|
28
28
|
beforeCompile: import("file-lane").PreWork<IJavascriptCompileOption>[];
|
|
29
|
-
afterCompile: {
|
|
29
|
+
afterCompile: ({
|
|
30
|
+
worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
|
|
31
|
+
workerDescribe?: undefined;
|
|
32
|
+
} | {
|
|
30
33
|
worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
|
|
31
34
|
workerDescribe: string;
|
|
32
|
-
}[];
|
|
35
|
+
})[];
|
|
33
36
|
afterWorks: (typeof UxAfterWorks.cleanOutput)[];
|
|
34
37
|
watchIgnores: RegExp[];
|
|
35
38
|
/**
|
package/lib/config/UxConfig.js
CHANGED
|
@@ -75,20 +75,28 @@ 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
|
+
}, {
|
|
78
80
|
worker: _UxAfterCompile.default.symlinkNodeModule,
|
|
79
81
|
workerDescribe: 'Create a soft link to the node_modules folder'
|
|
80
82
|
}, {
|
|
81
|
-
worker: _UxAfterCompile.default.
|
|
82
|
-
workerDescribe: 'Compile
|
|
83
|
+
worker: _UxAfterCompile.default.compileJavascript,
|
|
84
|
+
workerDescribe: 'Compile javascript project'
|
|
83
85
|
}, {
|
|
84
86
|
worker: _UxAfterCompile.default.copyResource,
|
|
85
87
|
workerDescribe: 'Copy resource files'
|
|
88
|
+
}, {
|
|
89
|
+
worker: _UxAfterCompile.default.compressResource,
|
|
90
|
+
workerDescribe: 'Compress resource files'
|
|
86
91
|
}, {
|
|
87
92
|
worker: _UxAfterCompile.default.jsc,
|
|
88
93
|
workerDescribe: 'Generate jsc bytecode'
|
|
89
94
|
}, {
|
|
90
95
|
worker: _UxAfterCompile.default.protobuf,
|
|
91
96
|
workerDescribe: 'Generate protobuf json'
|
|
97
|
+
}, {
|
|
98
|
+
worker: _UxAfterCompile.default.compileLiteCard,
|
|
99
|
+
workerDescribe: 'compile lite card'
|
|
92
100
|
}, {
|
|
93
101
|
worker: _UxAfterCompile.default.toRpk,
|
|
94
102
|
workerDescribe: 'Package the project into an RPK file'
|
|
@@ -98,6 +106,9 @@ class UxConfig {
|
|
|
98
106
|
}, {
|
|
99
107
|
worker: _UxAfterCompile.default.moveBackResult,
|
|
100
108
|
workerDescribe: 'Migrate temporary project'
|
|
109
|
+
}, {
|
|
110
|
+
worker: _UxAfterCompile.default.resourceCheck,
|
|
111
|
+
workerDescribe: 'Check resource'
|
|
101
112
|
}])();
|
|
102
113
|
afterWorks = (() => [_UxAfterWorks.default.cleanOutput])();
|
|
103
114
|
watchIgnores = [/node_modules/, /build/, /dist/];
|
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,6 +6,6 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
|
|
|
6
6
|
declare class JsLoader implements ILoader {
|
|
7
7
|
context: IFileLaneContext;
|
|
8
8
|
compilerOption: IJavascriptCompileOption;
|
|
9
|
-
parser(files: IFileParam<any>[]):
|
|
9
|
+
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
10
10
|
}
|
|
11
11
|
export default JsLoader;
|
|
@@ -10,29 +10,32 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
|
10
10
|
* JsLoader
|
|
11
11
|
*/
|
|
12
12
|
class JsLoader {
|
|
13
|
-
parser(files) {
|
|
13
|
+
async parser(files) {
|
|
14
14
|
const onLog = () => {};
|
|
15
|
-
|
|
15
|
+
const result = [];
|
|
16
|
+
for (const item of files) {
|
|
16
17
|
if (!item.content) {
|
|
17
|
-
|
|
18
|
+
result.push({
|
|
18
19
|
path: item.path,
|
|
19
20
|
content: item.content
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
const options = {
|
|
24
|
+
filePath: item.path,
|
|
25
|
+
projectPath: this.context.projectPath,
|
|
26
|
+
content: item.content.toString(),
|
|
27
|
+
projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
|
|
28
|
+
onLog
|
|
20
29
|
};
|
|
30
|
+
result.push({
|
|
31
|
+
path: item.path,
|
|
32
|
+
content: (await new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
|
|
33
|
+
content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
|
|
34
|
+
}, [])).targetTree.getFullText()
|
|
35
|
+
});
|
|
21
36
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
projectPath: this.context.projectPath,
|
|
25
|
-
content: item.content.toString(),
|
|
26
|
-
projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
|
|
27
|
-
onLog
|
|
28
|
-
};
|
|
29
|
-
return {
|
|
30
|
-
path: item.path,
|
|
31
|
-
content: new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
|
|
32
|
-
content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
|
|
33
|
-
}, []).targetTree.getFullText()
|
|
34
|
-
};
|
|
35
|
-
});
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
var _default = exports.default = JsLoader;
|
|
@@ -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,6 +10,7 @@ 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
|
|
|
@@ -19,6 +20,8 @@ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobu
|
|
|
19
20
|
class BeforeCompileUtils {
|
|
20
21
|
/**
|
|
21
22
|
* 获取ux项目的路由入口
|
|
23
|
+
* context.entries中存放ux页面路由
|
|
24
|
+
* context.liteCards中存放轻卡路由
|
|
22
25
|
* @param context
|
|
23
26
|
* @param fileList
|
|
24
27
|
* @returns
|
|
@@ -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 => {
|
|
@@ -76,14 +98,7 @@ class BeforeCompileUtils {
|
|
|
76
98
|
if (compilerOption) {
|
|
77
99
|
// 存储build中的文件列表
|
|
78
100
|
const buildPath = _path.default.join(context.projectPath, compilerOption.outputPath);
|
|
79
|
-
const buildFileList = _fsExtra.default.existsSync(buildPath) ? _sharedUtils.FileUtil.readAlldirSync(buildPath).map(filePath =>
|
|
80
|
-
const relativePath = _path.default.relative(buildPath, filePath);
|
|
81
|
-
const fileContent = _fsExtra.default.readFileSync(filePath);
|
|
82
|
-
return {
|
|
83
|
-
path: relativePath,
|
|
84
|
-
content: fileContent
|
|
85
|
-
};
|
|
86
|
-
}) : [];
|
|
101
|
+
const buildFileList = _fsExtra.default.existsSync(buildPath) ? _sharedUtils.FileUtil.readAlldirSync(buildPath).map(filePath => _path.default.relative(buildPath, filePath)) : [];
|
|
87
102
|
if (compalition) {
|
|
88
103
|
compalition.buildFileList = buildFileList;
|
|
89
104
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface FileComparisonResult {
|
|
2
|
+
isEqual: boolean;
|
|
3
|
+
details: {
|
|
4
|
+
hash1: string;
|
|
5
|
+
hash2: string;
|
|
6
|
+
fileSize1: number;
|
|
7
|
+
fileSize2: number;
|
|
8
|
+
comparisonTime: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function compareFiles(filePath1: string, filePath2: string): FileComparisonResult;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compareFiles = compareFiles;
|
|
7
|
+
var _crypto = require("crypto");
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
function compareFiles(filePath1, filePath2) {
|
|
11
|
+
const startTime = Date.now();
|
|
12
|
+
|
|
13
|
+
// 快速检查:文件大小不同则内容必然不同
|
|
14
|
+
const size1 = _fs.default.statSync(filePath1).size;
|
|
15
|
+
const size2 = _fs.default.statSync(filePath2).size;
|
|
16
|
+
if (size1 !== size2) {
|
|
17
|
+
return {
|
|
18
|
+
isEqual: false,
|
|
19
|
+
details: {
|
|
20
|
+
hash1: '',
|
|
21
|
+
hash2: '',
|
|
22
|
+
fileSize1: size1,
|
|
23
|
+
fileSize2: size2,
|
|
24
|
+
comparisonTime: Date.now() - startTime
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 计算两个文件的哈希
|
|
30
|
+
const hash1 = computeFileHash(filePath1);
|
|
31
|
+
const hash2 = computeFileHash(filePath2);
|
|
32
|
+
return {
|
|
33
|
+
isEqual: hash1 === hash2,
|
|
34
|
+
details: {
|
|
35
|
+
hash1,
|
|
36
|
+
hash2,
|
|
37
|
+
fileSize1: size1,
|
|
38
|
+
fileSize2: size2,
|
|
39
|
+
comparisonTime: Date.now() - startTime
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function computeFileHash(filePath) {
|
|
44
|
+
const fileData = _fs.default.readFileSync(filePath);
|
|
45
|
+
const hash = (0, _crypto.createHash)('sha-256').update(fileData);
|
|
46
|
+
return hash.digest('hex');
|
|
47
|
+
}
|
|
@@ -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'
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
|
|
2
1
|
import IManifest from '../../compiler/javascript/vela/interface/IManifest';
|
|
3
2
|
export declare class UxFileUtils {
|
|
4
3
|
static readonly CONFIG_FILE_NAME = "manifest.json";
|
|
@@ -23,6 +22,7 @@ export declare class UxFileUtils {
|
|
|
23
22
|
* 1. TypeError: Error
|
|
24
23
|
* 2. 其它: Warn
|
|
25
24
|
* 2. 检查 router.entry 是否存在于 router.pages
|
|
25
|
+
* 3. 检查icon是否存在
|
|
26
26
|
*
|
|
27
27
|
* @param projectPath 项目路径
|
|
28
28
|
* @param sourceRoot 源码路径--相对项目根目录
|
|
@@ -38,15 +38,18 @@ export declare class UxFileUtils {
|
|
|
38
38
|
*/
|
|
39
39
|
static validateSitemap(projectPath: string, sourceRoot?: string): void;
|
|
40
40
|
/**
|
|
41
|
+
* 比较新旧文件列表差异
|
|
41
42
|
* 1. 遍历旧文件列表
|
|
42
|
-
* 1.1 若文件路径在新文件列表
|
|
43
|
-
* 1.2 若文件路径在新文件列表
|
|
43
|
+
* 1.1 若文件路径在新文件列表remainingNewFilest中,且内容一致时,从remainingNewFiles中移除该项
|
|
44
|
+
* 1.2 若文件路径在新文件列表remainingNewFiles中,且内容不一致时,添加到diffList中表示待更新,从remainingNewFiles中移除该项
|
|
44
45
|
* 1.3 若文件路径不在新文件列表中,表示该文件待删除(热更新时,可以不做删除,删除耗费性能)
|
|
45
|
-
* 2. 若遍历完旧文件列表后,
|
|
46
|
-
* @param oldFileList
|
|
47
|
-
* @param newFileList
|
|
48
|
-
* @
|
|
46
|
+
* 2. 若遍历完旧文件列表后,remainingNewFiles长度不为0,表示有文件待新增
|
|
47
|
+
* @param oldFileList 旧文件路径列表(相对路径)
|
|
48
|
+
* @param newFileList 新文件路径列表(绝对路径)
|
|
49
|
+
* @param oldDir 旧文件所在目录(绝对路径)
|
|
50
|
+
* @param newDir 新文件所在目录(绝对路径)
|
|
51
|
+
* @returns 返回差异文件路径列表(相对路径)
|
|
49
52
|
*/
|
|
50
|
-
static getDiffJSON(
|
|
53
|
+
static getDiffJSON(oldFileList: string[], newFileList: string[], oldDir: string, newDir: string): string[];
|
|
51
54
|
}
|
|
52
55
|
export default UxFileUtils;
|