@aiot-toolkit/aiotpack 2.0.2 → 2.0.3-beta.10
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 +1 -1
- package/lib/afterCompile/ux/UxAfterCompile.js +295 -243
- 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 -28
- 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 +53 -49
- 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 +31 -27
- 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.d.ts +10 -2
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -267
- 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.d.ts +2 -0
- package/lib/config/XtsConfig.js +30 -39
- 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.d.ts +2 -0
- package/lib/loader/ux/android/UxLoader.js +30 -32
- package/lib/loader/ux/vela/AppUxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/AppUxLoader.js +23 -25
- package/lib/loader/ux/vela/HmlLoader.js +59 -55
- package/lib/loader/ux/vela/UxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/UxLoader.js +29 -37
- package/lib/loader/xts/XtsLoader.js +55 -41
- package/lib/utils/BeforeCompileUtils.js +100 -95
- package/lib/utils/PngUtils.js +42 -36
- package/lib/utils/ux/ManifestSchema.js +198 -194
- package/lib/utils/ux/UxFileUtils.d.ts +3 -3
- package/lib/utils/ux/UxFileUtils.js +130 -125
- 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,49 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _core = require("@rspack/core");
|
|
8
|
+
var _webpackSources = require("webpack-sources");
|
|
9
|
+
var _UxFileUtils = _interopRequireDefault(require("../../../../utils/ux/UxFileUtils"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
/**
|
|
10
12
|
* WrapPlugin
|
|
11
13
|
*/
|
|
12
14
|
class WrapPlugin {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return new webpack_sources_1.ConcatSource(`
|
|
15
|
+
constructor(param) {
|
|
16
|
+
this.param = param;
|
|
17
|
+
}
|
|
18
|
+
apply(compiler) {
|
|
19
|
+
compiler.hooks.compilation.tap('WrapPlugin', compilation => {
|
|
20
|
+
compilation.hooks.processAssets.tap({
|
|
21
|
+
name: 'WrapPlugin',
|
|
22
|
+
stage: _core.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
23
|
+
}, () => {
|
|
24
|
+
this.wrap(compilation);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 添加包含代码
|
|
31
|
+
*
|
|
32
|
+
* 1. 仅 page 文件添加
|
|
33
|
+
* @param compilation
|
|
34
|
+
*/
|
|
35
|
+
wrap(compilation) {
|
|
36
|
+
// 获取入口文件
|
|
37
|
+
const entrys = Object.keys(compilation.options.entry).map(item => `${item}.js`);
|
|
38
|
+
entrys.forEach(entry => {
|
|
39
|
+
if (compilation.assets[entry]) {
|
|
40
|
+
const source = compilation.assets[entry];
|
|
41
|
+
const isApp = entry === 'app.js';
|
|
42
|
+
compilation.assets[entry] = isApp ? this.wrapApp(source) : this.wrapPage(source);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
wrapPage(source) {
|
|
47
|
+
return new _webpackSources.ConcatSource(`
|
|
47
48
|
(function () {
|
|
48
49
|
var createPageHandler = function () {
|
|
49
50
|
// 转换动态 style 的函数
|
|
@@ -52,7 +53,7 @@ class WrapPlugin {
|
|
|
52
53
|
return Object.fromEntries(value.split(';').filter(item => Boolean(item && item.trim())).map(
|
|
53
54
|
item => {
|
|
54
55
|
const matchs = item.match(/([^:]+):(.*)/)
|
|
55
|
-
if (matchs && matchs.
|
|
56
|
+
if (matchs && matchs.length> 2) {
|
|
56
57
|
return [matchs[1].trim().replace(/-([a-z])/g, (_, match) => match.toUpperCase()), matchs[2].trim()]
|
|
57
58
|
}
|
|
58
59
|
return []
|
|
@@ -67,13 +68,16 @@ class WrapPlugin {
|
|
|
67
68
|
window.createPageHandler = createPageHandler;
|
|
68
69
|
}
|
|
69
70
|
})();`);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
}
|
|
72
|
+
wrapApp(source) {
|
|
73
|
+
const {
|
|
74
|
+
projectPath,
|
|
75
|
+
sourceRoot
|
|
76
|
+
} = this.param;
|
|
77
|
+
return new _webpackSources.ConcatSource(`
|
|
74
78
|
(function () {
|
|
75
79
|
var $app_define_wrap$ = $app_define_wrap$ || function () {};
|
|
76
|
-
var manifestJson =${JSON.stringify(
|
|
80
|
+
var manifestJson =${JSON.stringify(_UxFileUtils.default.getMainfestInfo(projectPath, sourceRoot))}
|
|
77
81
|
var createAppHandler = function () {
|
|
78
82
|
`, source, `
|
|
79
83
|
}
|
|
@@ -86,6 +90,6 @@ class WrapPlugin {
|
|
|
86
90
|
}
|
|
87
91
|
})();
|
|
88
92
|
`);
|
|
89
|
-
|
|
93
|
+
}
|
|
90
94
|
}
|
|
91
|
-
exports.default = WrapPlugin;
|
|
95
|
+
var _default = exports.default = WrapPlugin;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
@@ -1,82 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _UxFileUtils = _interopRequireDefault(require("../../../utils/ux/UxFileUtils"));
|
|
10
|
+
var _WrapPlugin = _interopRequireDefault(require("./plugin/WrapPlugin"));
|
|
11
|
+
var _UxCompileUtil = _interopRequireDefault(require("./utils/UxCompileUtil"));
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
13
|
class VelaWebpackConfigurator {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
createWrapPlugin() {
|
|
22
|
-
return new WrapPlugin_1.default();
|
|
14
|
+
createPlugins() {
|
|
15
|
+
// 包裹代码的插件
|
|
16
|
+
const result = [this.createWrapPlugin()];
|
|
17
|
+
|
|
18
|
+
// 如果开启 stats 参数,则添加 webpack-bundle-analyzer 插件
|
|
19
|
+
if (this.param.enableStats) {
|
|
20
|
+
result.push(this.createBundleAnalyzerPlugin());
|
|
23
21
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
createWrapPlugin() {
|
|
25
|
+
return new _WrapPlugin.default();
|
|
26
|
+
}
|
|
27
|
+
createBundleAnalyzerPlugin() {
|
|
28
|
+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
29
|
+
return new BundleAnalyzerPlugin({
|
|
30
|
+
analyzerMode: 'static',
|
|
31
|
+
openAnalyzer: false,
|
|
32
|
+
excludeAssets: /^@(system|service)\./
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 通过读取 manifest.json 生成 entry
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
createEntry() {
|
|
41
|
+
const {
|
|
42
|
+
projectPath,
|
|
43
|
+
sourceRoot
|
|
44
|
+
} = this.param;
|
|
45
|
+
const configFilePath = _UxFileUtils.default.getManifestFilePath(this.param.projectPath, this.param.sourceRoot);
|
|
46
|
+
if (_fsExtra.default.existsSync(configFilePath)) {
|
|
47
|
+
const config = _fsExtra.default.readJSONSync(configFilePath);
|
|
48
|
+
return _UxCompileUtil.default.resolveEntries(config, _path.default.resolve(projectPath, sourceRoot), projectPath);
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(`Configuration file does not exist: ${configFilePath}`);
|
|
31
51
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
52
|
+
}
|
|
53
|
+
createRules() {
|
|
54
|
+
const {
|
|
55
|
+
projectPath,
|
|
56
|
+
sourceRoot
|
|
57
|
+
} = this.param;
|
|
58
|
+
const srcPath = _path.default.resolve(projectPath, sourceRoot);
|
|
59
|
+
return [{
|
|
60
|
+
test: /\.js$/,
|
|
61
|
+
use: [{
|
|
62
|
+
loader: require.resolve('babel-loader'),
|
|
63
|
+
options: {
|
|
64
|
+
cwd: this.param.projectPath,
|
|
65
|
+
cacheDirectory: true
|
|
42
66
|
}
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
}]
|
|
68
|
+
}, {
|
|
69
|
+
test: /\.json$/,
|
|
70
|
+
include: [_path.default.join(srcPath, 'manifest.json')]
|
|
71
|
+
}, {
|
|
72
|
+
test: /\.(png|jpe?g|gif|svg|bmp|webp|mp4|wmv|avi|mpg|rmvb|mov|flv|otf|ttf|ttc|woff|eot)$/i,
|
|
73
|
+
use: {
|
|
74
|
+
loader: require.resolve('url-loader'),
|
|
75
|
+
options: {
|
|
76
|
+
limit: 0,
|
|
77
|
+
name: `dynamicAssets/[name].[hash:8].[ext]`,
|
|
78
|
+
publicPath: '/',
|
|
79
|
+
esModule: false
|
|
45
80
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const srcPath = path_1.default.resolve(projectPath, sourceRoot);
|
|
50
|
-
return [
|
|
51
|
-
{
|
|
52
|
-
test: /\.js$/,
|
|
53
|
-
use: [
|
|
54
|
-
{
|
|
55
|
-
loader: require.resolve('babel-loader'),
|
|
56
|
-
options: {
|
|
57
|
-
cwd: this.param.projectPath,
|
|
58
|
-
cacheDirectory: true
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
test: /\.json$/,
|
|
65
|
-
include: [path_1.default.join(srcPath, 'manifest.json')]
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
test: /\.(png|jpe?g|gif|svg|bmp|webp|mp4|wmv|avi|mpg|rmvb|mov|flv|otf|ttf|ttc|woff|eot)$/i,
|
|
69
|
-
use: {
|
|
70
|
-
loader: require.resolve('url-loader'),
|
|
71
|
-
options: {
|
|
72
|
-
limit: 0,
|
|
73
|
-
name: `dynamicAssets/[name].[hash:8].[ext]`,
|
|
74
|
-
publicPath: '/',
|
|
75
|
-
esModule: false
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
+
}
|
|
82
|
+
}];
|
|
83
|
+
}
|
|
81
84
|
}
|
|
82
|
-
exports.default = VelaWebpackConfigurator;
|
|
85
|
+
var _default = exports.default = VelaWebpackConfigurator;
|
|
@@ -1,45 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
/**
|
|
4
8
|
* 构建名格式类型枚举
|
|
5
9
|
*/
|
|
6
|
-
var BuildNameFormatType
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
[BuildNameFormatType.DEFAULT]: 'default',
|
|
32
|
-
[BuildNameFormatType.ORIGINAL]: 'original'
|
|
33
|
-
};
|
|
34
|
-
return dic[value] || '';
|
|
35
|
-
}
|
|
36
|
-
BuildNameFormatType.toString = toString;
|
|
37
|
-
function toDesc(value) {
|
|
38
|
-
const dic = {
|
|
39
|
-
[BuildNameFormatType.DEFAULT]: 'The format is: packageName.signaturType.version.extname',
|
|
40
|
-
[BuildNameFormatType.ORIGINAL]: 'The format is: packageName.signaturType.extname'
|
|
41
|
-
};
|
|
42
|
-
return dic[value] || '';
|
|
43
|
-
}
|
|
44
|
-
BuildNameFormatType.toDesc = toDesc;
|
|
45
|
-
})(BuildNameFormatType || (BuildNameFormatType = {}));
|
|
10
|
+
var BuildNameFormatType = /*#__PURE__*/function (BuildNameFormatType) {
|
|
11
|
+
BuildNameFormatType[BuildNameFormatType["DEFAULT"] = 1] = "DEFAULT";
|
|
12
|
+
BuildNameFormatType[BuildNameFormatType["ORIGINAL"] = 2] = "ORIGINAL";
|
|
13
|
+
return BuildNameFormatType;
|
|
14
|
+
}(BuildNameFormatType || {});
|
|
15
|
+
var _default = exports.default = BuildNameFormatType;
|
|
16
|
+
(function (_BuildNameFormatType) {
|
|
17
|
+
const ALL_LIST = _BuildNameFormatType.ALL_LIST = [BuildNameFormatType.DEFAULT, BuildNameFormatType.ORIGINAL];
|
|
18
|
+
function toString(value) {
|
|
19
|
+
const dic = {
|
|
20
|
+
[BuildNameFormatType.DEFAULT]: 'default',
|
|
21
|
+
[BuildNameFormatType.ORIGINAL]: 'original'
|
|
22
|
+
};
|
|
23
|
+
return dic[value] || '';
|
|
24
|
+
}
|
|
25
|
+
_BuildNameFormatType.toString = toString;
|
|
26
|
+
function toDesc(value) {
|
|
27
|
+
const dic = {
|
|
28
|
+
[BuildNameFormatType.DEFAULT]: 'The format is: packageName.signaturType.version.extname',
|
|
29
|
+
[BuildNameFormatType.ORIGINAL]: 'The format is: packageName.signaturType.extname'
|
|
30
|
+
};
|
|
31
|
+
return dic[value] || '';
|
|
32
|
+
}
|
|
33
|
+
_BuildNameFormatType.toDesc = toDesc;
|
|
34
|
+
})(BuildNameFormatType || (BuildNameFormatType = {}));
|
|
@@ -1,33 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
3
7
|
/**
|
|
4
8
|
* 入口类型枚举
|
|
5
9
|
*/
|
|
6
|
-
var EntryType
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 组件
|
|
18
|
-
*/
|
|
19
|
-
EntryType["COMPONENT"] = "comp";
|
|
20
|
-
/**
|
|
21
|
-
* 卡片
|
|
22
|
-
*/
|
|
23
|
-
EntryType["CARD"] = "card";
|
|
24
|
-
/**
|
|
25
|
-
* 悬浮窗口
|
|
26
|
-
*/
|
|
27
|
-
EntryType["FLOAT"] = "float";
|
|
28
|
-
/**
|
|
29
|
-
* JavaScript
|
|
30
|
-
*/
|
|
31
|
-
EntryType["JS"] = "js";
|
|
32
|
-
})(EntryType || (EntryType = {}));
|
|
33
|
-
exports.default = EntryType;
|
|
10
|
+
var EntryType = /*#__PURE__*/function (EntryType) {
|
|
11
|
+
EntryType["APP"] = "app";
|
|
12
|
+
EntryType["PAGE"] = "page";
|
|
13
|
+
EntryType["COMPONENT"] = "comp";
|
|
14
|
+
EntryType["CARD"] = "card";
|
|
15
|
+
EntryType["FLOAT"] = "float";
|
|
16
|
+
EntryType["JS"] = "js";
|
|
17
|
+
return EntryType;
|
|
18
|
+
}(EntryType || {});
|
|
19
|
+
var _default = exports.default = EntryType;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
@@ -1,60 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
/**
|
|
9
|
+
* 文件资源
|
|
10
|
+
*/
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* 定义文件包
|
|
6
14
|
*
|
|
7
15
|
* 相当于虚拟的 rpk 包
|
|
8
16
|
*/
|
|
9
17
|
class Package {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
18
|
+
/**
|
|
19
|
+
* 包前缀
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 子包名称;整包没有
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 是否为独立包
|
|
28
|
+
*/
|
|
29
|
+
standalone = false;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 后缀名
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 资源路径匹配
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
_resourceList = [];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 资源文件列表
|
|
43
|
+
*/
|
|
44
|
+
get resourceList() {
|
|
45
|
+
return this._resourceList;
|
|
46
|
+
}
|
|
47
|
+
_resourceDic = {};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 资源文件字典,以高效检查资源是否存在
|
|
51
|
+
*/
|
|
52
|
+
get resourceDic() {
|
|
53
|
+
return this._resourceDic;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 是否已包含指定文件
|
|
58
|
+
* @param filePath 文件路径
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
include(filePath) {
|
|
62
|
+
return this.resourceDic[filePath];
|
|
63
|
+
}
|
|
64
|
+
getResource(filePath) {
|
|
65
|
+
return this.resourceList.find(item => item.fileBuildPath === filePath);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 添加资源
|
|
70
|
+
* @param data
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
addResource(data) {
|
|
74
|
+
const {
|
|
75
|
+
fileBuildPath
|
|
76
|
+
} = data;
|
|
77
|
+
if (this.include(fileBuildPath)) {
|
|
78
|
+
_sharedUtils.ColorConsole.throw(`File ${fileBuildPath} is added repeatedly`);
|
|
79
|
+
return;
|
|
58
80
|
}
|
|
81
|
+
this._resourceDic[fileBuildPath] = true;
|
|
82
|
+
this._resourceList.push(data);
|
|
83
|
+
}
|
|
84
|
+
constructor(data) {
|
|
85
|
+
Object.assign(this, data);
|
|
86
|
+
this.fileName = [this.filePrefix, this.fileSubname, this.fileSuffix].filter(item => Boolean(item)).join('.');
|
|
87
|
+
}
|
|
59
88
|
}
|
|
60
|
-
exports.default = Package;
|
|
89
|
+
var _default = exports.default = Package;
|