@aiot-toolkit/aiotpack 2.0.3-beta.1 → 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.
Files changed (57) hide show
  1. package/lib/afterCompile/ux/UxAfterCompile.js +292 -266
  2. package/lib/afterCompile/xts/entryTemplate.js +111 -113
  3. package/lib/afterCompile/xts/generateRpk.js +25 -54
  4. package/lib/afterCompile/xts/ts2wasm.js +62 -63
  5. package/lib/afterWorks/ux/UxAfterWorks.js +12 -19
  6. package/lib/beforeCompile/ux/UxBeforeCompile.js +26 -28
  7. package/lib/beforeCompile/xts/preInstall.js +50 -55
  8. package/lib/beforeWorks/ux/UxBeforeWorks.js +12 -19
  9. package/lib/compiler/enum/CompileMode.js +16 -23
  10. package/lib/compiler/interface/ICompileParam.js +1 -2
  11. package/lib/compiler/interface/ICompiler.js +1 -2
  12. package/lib/compiler/interface/ISignConfig.js +1 -2
  13. package/lib/compiler/javascript/JavascriptCompiler.js +147 -154
  14. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +20 -16
  15. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +13 -11
  16. package/lib/compiler/javascript/android/plugin/WrapPlugin.js +53 -49
  17. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +1 -2
  18. package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -1
  19. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +78 -75
  20. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +30 -41
  21. package/lib/compiler/javascript/vela/enum/EntryType.js +15 -29
  22. package/lib/compiler/javascript/vela/interface/IChunk.js +4 -1
  23. package/lib/compiler/javascript/vela/interface/IManifest.js +1 -2
  24. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +1 -2
  25. package/lib/compiler/javascript/vela/model/Package.js +80 -51
  26. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +31 -27
  27. package/lib/compiler/javascript/vela/utils/Jsc.js +30 -33
  28. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +152 -130
  29. package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -276
  30. package/lib/compiler/javascript/vela/utils/signature/Base64.js +65 -67
  31. package/lib/compiler/javascript/vela/utils/signature/CRC32.js +37 -35
  32. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +755 -731
  33. package/lib/compiler/javascript/vela/utils/signature/Signer.js +24 -22
  34. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +47 -52
  35. package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +21 -17
  36. package/lib/config/UxConfig.js +145 -173
  37. package/lib/config/XtsConfig.js +30 -40
  38. package/lib/index.js +88 -41
  39. package/lib/interface/ICompileOptions.js +5 -2
  40. package/lib/interface/IDeviceList.js +1 -2
  41. package/lib/loader/ux/JsLoader.js +32 -30
  42. package/lib/loader/ux/PngLoader.js +47 -53
  43. package/lib/loader/ux/android/UxLoader.js +30 -31
  44. package/lib/loader/ux/vela/AppUxLoader.js +23 -24
  45. package/lib/loader/ux/vela/HmlLoader.js +59 -55
  46. package/lib/loader/ux/vela/UxLoader.js +29 -35
  47. package/lib/loader/xts/XtsLoader.js +55 -41
  48. package/lib/utils/BeforeCompileUtils.js +100 -95
  49. package/lib/utils/PngUtils.js +42 -36
  50. package/lib/utils/ux/ManifestSchema.js +198 -194
  51. package/lib/utils/ux/UxFileUtils.d.ts +2 -2
  52. package/lib/utils/ux/UxFileUtils.js +130 -128
  53. package/lib/utils/ux/UxLoaderUtils.js +292 -307
  54. package/lib/utils/ux/android/AndroidUx.js +88 -90
  55. package/lib/utils/xts/XtsFileLaneUtils.js +58 -65
  56. package/lib/utils/xts/XtsFollowWorks.js +122 -129
  57. package/package.json +6 -6
@@ -1,49 +1,50 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const core_1 = require("@rspack/core");
7
- const webpack_sources_1 = require("webpack-sources");
8
- const UxFileUtils_1 = __importDefault(require("../../../../utils/ux/UxFileUtils"));
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
- constructor(param) {
14
- this.param = param;
15
- }
16
- apply(compiler) {
17
- compiler.hooks.compilation.tap('WrapPlugin', (compilation) => {
18
- compilation.hooks.processAssets.tap({
19
- name: 'WrapPlugin',
20
- stage: core_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
21
- }, () => {
22
- this.wrap(compilation);
23
- });
24
- });
25
- }
26
- /**
27
- * 添加包含代码
28
- *
29
- * 1. 仅 page 文件添加
30
- * @param compilation
31
- */
32
- wrap(compilation) {
33
- // 获取入口文件
34
- const entrys = Object.keys(compilation.options.entry).map((item) => `${item}.js`);
35
- entrys.forEach((entry) => {
36
- if (compilation.assets[entry]) {
37
- const source = compilation.assets[entry];
38
- const isApp = entry === 'app.js';
39
- compilation.assets[entry] = isApp
40
- ? this.wrapApp(source)
41
- : this.wrapPage(source);
42
- }
43
- });
44
- }
45
- wrapPage(source) {
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.lenth> 2) {
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
- wrapApp(source) {
72
- const { projectPath, sourceRoot } = this.param;
73
- return new webpack_sources_1.ConcatSource(`
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(UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot))}
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,2 +1,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,82 +1,85 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_extra_1 = __importDefault(require("fs-extra"));
7
- const path_1 = __importDefault(require("path"));
8
- const UxFileUtils_1 = __importDefault(require("../../../utils/ux/UxFileUtils"));
9
- const WrapPlugin_1 = __importDefault(require("./plugin/WrapPlugin"));
10
- const UxCompileUtil_1 = __importDefault(require("./utils/UxCompileUtil"));
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
- createPlugins() {
13
- // 包裹代码的插件
14
- const result = [this.createWrapPlugin()];
15
- // 如果开启 stats 参数,则添加 webpack-bundle-analyzer 插件
16
- if (this.param.enableStats) {
17
- result.push(this.createBundleAnalyzerPlugin());
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
- createBundleAnalyzerPlugin() {
25
- const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
26
- return new BundleAnalyzerPlugin({
27
- analyzerMode: 'static',
28
- openAnalyzer: false,
29
- excludeAssets: /^@(system|service)\./
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
- * 通过读取 manifest.json 生成 entry
34
- * @returns
35
- */
36
- createEntry() {
37
- const { projectPath, sourceRoot } = this.param;
38
- const configFilePath = UxFileUtils_1.default.getManifestFilePath(this.param.projectPath, this.param.sourceRoot);
39
- if (fs_extra_1.default.existsSync(configFilePath)) {
40
- const config = fs_extra_1.default.readJSONSync(configFilePath);
41
- return UxCompileUtil_1.default.resolveEntries(config, path_1.default.resolve(projectPath, sourceRoot), projectPath);
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
- else {
44
- throw new Error(`Configuration file does not exist: ${configFilePath}`);
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
- createRules() {
48
- const { projectPath, sourceRoot } = this.param;
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
- Object.defineProperty(exports, "__esModule", { value: true });
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
- (function (BuildNameFormatType) {
8
- /**
9
- * 默认格式
10
- */
11
- BuildNameFormatType[BuildNameFormatType["DEFAULT"] = 1] = "DEFAULT";
12
- /**
13
- * 原始格式,文件名不带版本号
14
- */
15
- BuildNameFormatType[BuildNameFormatType["ORIGINAL"] = 2] = "ORIGINAL";
16
- })(BuildNameFormatType || (BuildNameFormatType = {}));
17
- exports.default = BuildNameFormatType;
18
- (function (BuildNameFormatType) {
19
- /**
20
- * 枚举值列表,一般用于列表显示,例如下拉框
21
- */
22
- BuildNameFormatType.ALL_LIST = [
23
- BuildNameFormatType.DEFAULT,
24
- BuildNameFormatType.ORIGINAL
25
- ];
26
- /**
27
- * 枚举值转换为字符串
28
- */
29
- function toString(value) {
30
- const dic = {
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
- Object.defineProperty(exports, "__esModule", { value: true });
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
- (function (EntryType) {
8
- /**
9
- * 应用程序
10
- */
11
- EntryType["APP"] = "app";
12
- /**
13
- * 页面
14
- */
15
- EntryType["PAGE"] = "page";
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,5 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -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
- Object.defineProperty(exports, "__esModule", { value: true });
3
- 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");
8
+ /**
9
+ * 文件资源
10
+ */
11
+
4
12
  /**
5
13
  * 定义文件包
6
14
  *
7
15
  * 相当于虚拟的 rpk 包
8
16
  */
9
17
  class Package {
10
- /**
11
- * 资源文件列表
12
- */
13
- get resourceList() {
14
- return this._resourceList;
15
- }
16
- /**
17
- * 资源文件字典,以高效检查资源是否存在
18
- */
19
- get resourceDic() {
20
- return this._resourceDic;
21
- }
22
- /**
23
- * 是否已包含指定文件
24
- * @param filePath 文件路径
25
- * @returns
26
- */
27
- include(filePath) {
28
- return this.resourceDic[filePath];
29
- }
30
- getResource(filePath) {
31
- return this.resourceList.find((item) => item.fileBuildPath === filePath);
32
- }
33
- /**
34
- * 添加资源
35
- * @param data
36
- * @returns
37
- */
38
- addResource(data) {
39
- const { fileBuildPath } = data;
40
- if (this.include(fileBuildPath)) {
41
- shared_utils_1.ColorConsole.throw(`File ${fileBuildPath} is added repeatedly`);
42
- return;
43
- }
44
- this._resourceDic[fileBuildPath] = true;
45
- this._resourceList.push(data);
46
- }
47
- constructor(data) {
48
- /**
49
- * 是否为独立包
50
- */
51
- this.standalone = false;
52
- this._resourceList = [];
53
- this._resourceDic = {};
54
- Object.assign(this, data);
55
- this.fileName = [this.filePrefix, this.fileSubname, this.fileSuffix]
56
- .filter((item) => Boolean(item))
57
- .join('.');
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;