@aiot-toolkit/aiotpack 2.0.1-alpha.8 → 2.0.2-dev.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.
Files changed (111) hide show
  1. package/lib/compiler/enum/CompileMode.js +0 -2
  2. package/lib/compiler/interface/ICompileParam.js +0 -2
  3. package/lib/compiler/interface/ICompiler.js +0 -2
  4. package/lib/compiler/interface/ISignConfig.js +0 -2
  5. package/lib/compiler/javascript/JavascriptCompiler.d.ts +1 -1
  6. package/lib/compiler/javascript/JavascriptCompiler.js +23 -26
  7. package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +1 -0
  8. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +5 -2
  9. package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +8 -4
  10. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +0 -2
  11. package/lib/compiler/javascript/interface/IWebpackConfigurator.js +0 -2
  12. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +0 -2
  13. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +0 -2
  14. package/lib/compiler/javascript/vela/enum/EntryType.js +0 -2
  15. package/lib/compiler/javascript/vela/interface/IChunk.js +0 -2
  16. package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -0
  17. package/lib/compiler/javascript/vela/interface/IManifest.js +0 -2
  18. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +0 -2
  19. package/lib/compiler/javascript/vela/model/Package.js +2 -4
  20. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +0 -2
  21. package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
  22. package/lib/compiler/javascript/vela/utils/Jsc.js +4 -7
  23. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +2 -4
  24. package/lib/compiler/javascript/vela/utils/ZipUtil.js +5 -7
  25. package/lib/compiler/javascript/vela/utils/signature/Base64.js +0 -2
  26. package/lib/compiler/javascript/vela/utils/signature/CRC32.js +0 -2
  27. package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +1 -1
  28. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +14 -12
  29. package/lib/compiler/javascript/vela/utils/signature/Signer.js +0 -2
  30. package/lib/config/UxConfig.d.ts +8 -3
  31. package/lib/config/UxConfig.js +23 -6
  32. package/lib/config/XtsConfig.d.ts +2 -2
  33. package/lib/config/XtsConfig.js +0 -2
  34. package/lib/followWorks/xts/entryTemplate.d.ts +2 -2
  35. package/lib/followWorks/xts/entryTemplate.js +61 -44
  36. package/lib/followWorks/xts/generateRpk.d.ts +2 -1
  37. package/lib/followWorks/xts/generateRpk.js +7 -3
  38. package/lib/followWorks/xts/ts2wasm.d.ts +2 -1
  39. package/lib/followWorks/xts/ts2wasm.js +17 -17
  40. package/lib/index.js +0 -2
  41. package/lib/interface/ICompileOptions.d.ts +6 -0
  42. package/lib/interface/ICompileOptions.js +4 -0
  43. package/lib/interface/IDeviceList.js +0 -2
  44. package/lib/loader/ux/AppUxLoader.d.ts +2 -0
  45. package/lib/loader/ux/AppUxLoader.js +1 -3
  46. package/lib/loader/ux/ImageCompressLoader.d.ts +9 -0
  47. package/lib/loader/ux/ImageCompressLoader.js +74 -0
  48. package/lib/loader/ux/JsLoader.d.ts +9 -0
  49. package/lib/loader/ux/JsLoader.js +39 -0
  50. package/lib/loader/ux/PngLoader.js +4 -9
  51. package/lib/loader/ux/UxLoader.d.ts +2 -0
  52. package/lib/loader/ux/UxLoader.js +15 -4
  53. package/lib/loader/xts/XtsLoader.js +3 -9
  54. package/lib/preWorks/xts/preInstall.d.ts +2 -1
  55. package/lib/preWorks/xts/preInstall.js +11 -5
  56. package/lib/utils/PngUtils.js +0 -2
  57. package/lib/utils/PreWorkUtils.d.ts +5 -0
  58. package/lib/utils/PreWorkUtils.js +39 -9
  59. package/lib/utils/ux/ManifestSchema.d.ts +3 -0
  60. package/lib/utils/ux/ManifestSchema.js +207 -0
  61. package/lib/utils/ux/UxFileUtils.d.ts +21 -4
  62. package/lib/utils/ux/UxFileUtils.js +74 -5
  63. package/lib/utils/ux/UxFollowWorks.d.ts +1 -0
  64. package/lib/utils/ux/UxFollowWorks.js +30 -5
  65. package/lib/utils/ux/UxLoaderUtils.d.ts +11 -7
  66. package/lib/utils/ux/UxLoaderUtils.js +115 -31
  67. package/lib/utils/ux/UxPreWorks.d.ts +10 -0
  68. package/lib/utils/ux/UxPreWorks.js +31 -0
  69. package/lib/utils/xts/XtsFollowWorks.js +3 -12
  70. package/package.json +6 -5
  71. package/lib/compiler/enum/CompileMode.js.map +0 -1
  72. package/lib/compiler/interface/ICompileParam.js.map +0 -1
  73. package/lib/compiler/interface/ICompiler.js.map +0 -1
  74. package/lib/compiler/interface/ISignConfig.js.map +0 -1
  75. package/lib/compiler/javascript/JavascriptCompiler.js.map +0 -1
  76. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +0 -1
  77. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +0 -1
  78. package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +0 -1
  79. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +0 -1
  80. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +0 -1
  81. package/lib/compiler/javascript/vela/enum/EntryType.js.map +0 -1
  82. package/lib/compiler/javascript/vela/interface/IChunk.js.map +0 -1
  83. package/lib/compiler/javascript/vela/interface/IManifest.js.map +0 -1
  84. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +0 -1
  85. package/lib/compiler/javascript/vela/model/Package.js.map +0 -1
  86. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +0 -1
  87. package/lib/compiler/javascript/vela/utils/Jsc.js.map +0 -1
  88. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +0 -1
  89. package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +0 -1
  90. package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +0 -1
  91. package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +0 -1
  92. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +0 -1
  93. package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +0 -1
  94. package/lib/config/UxConfig.js.map +0 -1
  95. package/lib/config/XtsConfig.js.map +0 -1
  96. package/lib/followWorks/xts/entryTemplate.js.map +0 -1
  97. package/lib/followWorks/xts/generateRpk.js.map +0 -1
  98. package/lib/followWorks/xts/ts2wasm.js.map +0 -1
  99. package/lib/index.js.map +0 -1
  100. package/lib/interface/IDeviceList.js.map +0 -1
  101. package/lib/loader/ux/AppUxLoader.js.map +0 -1
  102. package/lib/loader/ux/PngLoader.js.map +0 -1
  103. package/lib/loader/ux/UxLoader.js.map +0 -1
  104. package/lib/loader/xts/XtsLoader.js.map +0 -1
  105. package/lib/preWorks/xts/preInstall.js.map +0 -1
  106. package/lib/utils/PngUtils.js.map +0 -1
  107. package/lib/utils/PreWorkUtils.js.map +0 -1
  108. package/lib/utils/ux/UxFileUtils.js.map +0 -1
  109. package/lib/utils/ux/UxFollowWorks.js.map +0 -1
  110. package/lib/utils/ux/UxLoaderUtils.js.map +0 -1
  111. package/lib/utils/xts/XtsFollowWorks.js.map +0 -1
@@ -13,10 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  var _a;
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
16
17
  const del_1 = __importDefault(require("del"));
17
18
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
19
  const path_1 = __importDefault(require("path"));
20
+ const TranslateCache_1 = __importDefault(require("../../../parser/lib/ux/translate/vela/TranslateCache"));
19
21
  const UxFileUtils_1 = __importDefault(require("./ux/UxFileUtils"));
22
+ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
20
23
  /**
21
24
  * PreWorkUtils
22
25
  */
@@ -37,11 +40,13 @@ class PreWorkUtils {
37
40
  if (manifestContent) {
38
41
  const { router } = manifestContent;
39
42
  if (!router) {
40
- // 报错,没有router配置
43
+ // 没有router配置
44
+ ColorConsole_1.default.throw(`### manifest ### No router configuration`);
41
45
  }
42
46
  const { pages } = router;
43
47
  if (!pages) {
44
- // 报错,没有pages配置
48
+ // 没有pages配置
49
+ ColorConsole_1.default.throw(`### manifest ### No pages configuration`);
45
50
  }
46
51
  Object.keys(pages).map((page) => {
47
52
  const pageContent = pages[page];
@@ -51,26 +56,51 @@ class PreWorkUtils {
51
56
  entryList.push(entryPage);
52
57
  }
53
58
  else {
54
- // 报错,路径不存在
59
+ // 路径不存在
60
+ ColorConsole_1.default.throw(`### manifest ### path '${entryPage}' does not exist`);
55
61
  }
56
62
  });
57
63
  context['entries'] = entryList;
58
64
  return Promise.resolve();
59
65
  }
60
66
  else {
61
- // 报错 manifest.json文件无有效内容
67
+ // manifest.json文件无有效内容
68
+ ColorConsole_1.default.error(`### manifest ### File has no valid content`);
62
69
  return Promise.reject();
63
70
  }
64
71
  }
72
+ /**
73
+ * 获取项目的全局样式变量配置
74
+ * @param context
75
+ */
76
+ static getGlobalVar(context) {
77
+ const { projectPath } = context;
78
+ const filePath = path_1.default.join(projectPath, 'src', 'globalVar.json');
79
+ let globalVar = {};
80
+ // 判断文件是否存在
81
+ if (fs_extra_1.default.existsSync(filePath)) {
82
+ // 存在则取内容,否则内容为空
83
+ globalVar = fs_extra_1.default.readJSONSync(filePath);
84
+ }
85
+ context.globalVar = globalVar;
86
+ return Promise.resolve();
87
+ }
65
88
  }
66
89
  _a = PreWorkUtils;
67
90
  PreWorkUtils.clean = (context, _, config, compileOption) => __awaiter(void 0, void 0, void 0, function* () {
68
- (0, del_1.default)(path_1.default.join(context.projectPath, context.output));
91
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, context.output));
69
92
  if (compileOption) {
70
- (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
71
- (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
93
+ yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
94
+ yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
95
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.outputPath));
96
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.releasePath));
72
97
  }
98
+ TranslateCache_1.default.featureCache.clear();
99
+ BinaryPlugin.reset();
100
+ BinaryPlugin.config = {
101
+ projectPath: context.projectPath,
102
+ source: compileOption === null || compileOption === void 0 ? void 0 : compileOption.sourceRoot,
103
+ output: compileOption === null || compileOption === void 0 ? void 0 : compileOption.outputPath
104
+ };
73
105
  });
74
106
  exports.default = PreWorkUtils;
75
-
76
- //# sourceMappingURL=PreWorkUtils.js.map
@@ -0,0 +1,3 @@
1
+ import { JSONSchemaType } from '@aiot-toolkit/shared-utils/lib/utils/CommonUtil';
2
+ declare const ManifestSchema: JSONSchemaType;
3
+ export default ManifestSchema;
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ManifestSchema = {
4
+ type: 'object',
5
+ required: ['package', 'name', 'icon', 'versionCode', 'config', 'router'],
6
+ properties: {
7
+ package: {
8
+ type: 'string'
9
+ },
10
+ name: {
11
+ type: 'string'
12
+ },
13
+ icon: {
14
+ type: 'string'
15
+ },
16
+ banner: {
17
+ type: 'string'
18
+ },
19
+ versionName: {
20
+ type: 'string'
21
+ },
22
+ versionCode: {
23
+ type: ['number']
24
+ },
25
+ minPlatformVersion: {
26
+ type: ['number']
27
+ },
28
+ features: {
29
+ type: 'array',
30
+ items: {
31
+ type: 'object',
32
+ properties: {
33
+ name: {
34
+ type: 'string'
35
+ }
36
+ }
37
+ }
38
+ },
39
+ config: {
40
+ type: 'object',
41
+ properties: {
42
+ logLevel: {
43
+ enum: ['off', 'error', 'warn', 'info', 'log', 'debug']
44
+ },
45
+ designWidth: {
46
+ type: ['number', 'string']
47
+ },
48
+ data: {
49
+ // TODO 全局数据对象,属性名不能以$或_开头,
50
+ type: 'object'
51
+ },
52
+ background: {
53
+ // TODO 更详细的后台运行配置信息,
54
+ type: 'object'
55
+ },
56
+ network: {
57
+ // TODO 更详细的网络配置信息,
58
+ type: 'object'
59
+ }
60
+ }
61
+ },
62
+ router: {
63
+ // TODO 更详细的后台运行配置信息,
64
+ type: 'object',
65
+ required: ['entry', 'pages'],
66
+ properties: {
67
+ entry: {
68
+ type: 'string'
69
+ },
70
+ // TODO 看下 key 不确定能否校验值,
71
+ pages: {
72
+ type: 'object'
73
+ },
74
+ errorPage: {
75
+ type: 'string'
76
+ },
77
+ // TODO 看下 key 不确定能否校验值,
78
+ widgets: {
79
+ type: 'object'
80
+ }
81
+ }
82
+ },
83
+ display: {
84
+ type: 'object',
85
+ properties: {
86
+ backgroundColor: {
87
+ // TODO HEXColor
88
+ type: 'string'
89
+ },
90
+ fullScreen: {
91
+ type: 'boolean'
92
+ },
93
+ titleBar: {
94
+ type: 'boolean'
95
+ },
96
+ titleBarBackgroundColor: {
97
+ // TODO HEXColor
98
+ type: 'string'
99
+ },
100
+ titleBarTextColor: {
101
+ // TODO HEXColor
102
+ type: 'string'
103
+ },
104
+ menu: {
105
+ type: 'boolean'
106
+ },
107
+ windowSoftInputMode: {
108
+ enum: ['adjustPan', 'adjustResize']
109
+ },
110
+ pages: {
111
+ type: 'object'
112
+ },
113
+ orientation: {
114
+ enum: ['portrait', 'landscape']
115
+ },
116
+ statusBarImmersive: {
117
+ type: 'boolean'
118
+ },
119
+ statusBarTextStyle: {
120
+ enum: ['light', 'dark', 'auto']
121
+ },
122
+ statusBarBackgroundColor: {
123
+ type: 'string'
124
+ },
125
+ statusBarBackgroundOpacity: {
126
+ type: 'number'
127
+ },
128
+ fitCutout: {
129
+ enum: ['none', 'portrait', 'landscape']
130
+ },
131
+ textSizeAdjust: {
132
+ enum: ['none', 'auto']
133
+ },
134
+ themeMode: {
135
+ enum: [-1, 0, 1]
136
+ },
137
+ menuBarData: {
138
+ // TODO 详细校验
139
+ type: 'object'
140
+ },
141
+ forceDark: {
142
+ type: 'boolean'
143
+ },
144
+ pageCache: {
145
+ type: 'boolean'
146
+ },
147
+ cacheDuration: {
148
+ type: 'number'
149
+ }
150
+ }
151
+ },
152
+ subpackages: {
153
+ // TODO 与后面的分包校验融合
154
+ type: 'array',
155
+ items: {
156
+ type: 'object',
157
+ properties: {
158
+ name: {
159
+ type: 'string'
160
+ },
161
+ // TODO 详细的规则校验
162
+ resource: {
163
+ type: 'string'
164
+ }
165
+ },
166
+ // 是否必须?
167
+ required: ['name', 'resource']
168
+ }
169
+ },
170
+ menuBarData: {
171
+ type: 'object',
172
+ properties: {
173
+ menuBar: {
174
+ type: 'boolean'
175
+ },
176
+ menuBarStyle: {
177
+ enum: ['dark', 'light']
178
+ },
179
+ shareTitle: {
180
+ type: 'string'
181
+ },
182
+ shareDescription: {
183
+ type: 'string'
184
+ },
185
+ shareIcon: {
186
+ type: 'string'
187
+ },
188
+ shareCurrentPage: {
189
+ type: 'string'
190
+ },
191
+ shareParams: {
192
+ type: 'string'
193
+ },
194
+ shareUrl: {
195
+ type: 'string'
196
+ }
197
+ }
198
+ },
199
+ deviceTypeList: {
200
+ type: 'array',
201
+ items: {
202
+ type: 'string'
203
+ }
204
+ }
205
+ }
206
+ };
207
+ exports.default = ManifestSchema;
@@ -1,8 +1,5 @@
1
1
  import IManifest from '../../compiler/javascript/vela/interface/IManifest';
2
- /**
3
- * FileUtils
4
- */
5
- declare class UxFileUtils {
2
+ export declare class UxFileUtils {
6
3
  static readonly CONFIG_FILE_NAME = "manifest.json";
7
4
  /**
8
5
  * 获取manifest.json路径
@@ -18,5 +15,25 @@ declare class UxFileUtils {
18
15
  * @returns
19
16
  */
20
17
  static getMainfestInfo(projectPath: string, sourceRoot?: string): IManifest;
18
+ /**
19
+ * 检查 manifest文件,并显示错误信息
20
+ *
21
+ * 1. TypeError,使用Error 样式
22
+ * 2. 其它错误,使用 Warn 样式
23
+ * 3. 如果存在TypeError,则终止程序
24
+ *
25
+ * @param projectPath 项目路径
26
+ * @param sourceRoot 源码路径--相对项目根目录
27
+ * @returns
28
+ */
29
+ static validateManifest(projectPath: string, sourceRoot?: string): Error[] | undefined;
30
+ /**
31
+ * 检查 sitemap.json 文件,并显示错误信息
32
+ *
33
+ * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错并终止程序
34
+ * @param projectPath
35
+ * @param sourceRoot
36
+ */
37
+ static validateSitemap(projectPath: string, sourceRoot?: string): void;
21
38
  }
22
39
  export default UxFileUtils;
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UxFileUtils = void 0;
7
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
8
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
9
+ const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
6
10
  const fs_extra_1 = __importDefault(require("fs-extra"));
7
11
  const path_1 = __importDefault(require("path"));
8
- /**
9
- * FileUtils
10
- */
12
+ const ManifestSchema_1 = __importDefault(require("./ManifestSchema"));
11
13
  class UxFileUtils {
12
14
  /**
13
15
  * 获取manifest.json路径
@@ -27,8 +29,75 @@ class UxFileUtils {
27
29
  static getMainfestInfo(projectPath, sourceRoot = 'src') {
28
30
  return fs_extra_1.default.readJSONSync(UxFileUtils.getManifestFilePath(projectPath, sourceRoot));
29
31
  }
32
+ /**
33
+ * 检查 manifest文件,并显示错误信息
34
+ *
35
+ * 1. TypeError,使用Error 样式
36
+ * 2. 其它错误,使用 Warn 样式
37
+ * 3. 如果存在TypeError,则终止程序
38
+ *
39
+ * @param projectPath 项目路径
40
+ * @param sourceRoot 源码路径--相对项目根目录
41
+ * @returns
42
+ */
43
+ static validateManifest(projectPath, sourceRoot = 'src') {
44
+ const path = UxFileUtils.getManifestFilePath(projectPath, sourceRoot);
45
+ if (!fs_extra_1.default.existsSync(path)) {
46
+ ColorConsole_1.default.throw(`file is missing`, {
47
+ word: path,
48
+ style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
49
+ });
50
+ }
51
+ const jsonData = this.getMainfestInfo(projectPath, sourceRoot);
52
+ const schema = ManifestSchema_1.default;
53
+ const errors = CommonUtil_1.default.validateJson(jsonData, schema);
54
+ if (errors) {
55
+ ColorConsole_1.default.warn(`Manefest.json error: `, ...errors.map((item, index) => {
56
+ return {
57
+ word: `\r\n${index + 1}. ${item.message}`,
58
+ style: item instanceof TypeError
59
+ ? ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Error)
60
+ : ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Warn)
61
+ };
62
+ }));
63
+ const stop = Boolean(errors.find((item) => item instanceof TypeError));
64
+ if (stop) {
65
+ ColorConsole_1.default.throw({
66
+ word: `missing required content, program stoped`,
67
+ style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
68
+ });
69
+ }
70
+ }
71
+ return errors;
72
+ }
73
+ /**
74
+ * 检查 sitemap.json 文件,并显示错误信息
75
+ *
76
+ * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错并终止程序
77
+ * @param projectPath
78
+ * @param sourceRoot
79
+ */
80
+ static validateSitemap(projectPath, sourceRoot = 'src') {
81
+ const sitemapPath = path_1.default.join(projectPath, sourceRoot, 'sitemap.json');
82
+ if (fs_extra_1.default.existsSync(sitemapPath)) {
83
+ try {
84
+ const rules = fs_extra_1.default.readJSONSync(sitemapPath).rules;
85
+ const manifest = this.getMainfestInfo(projectPath, sourceRoot);
86
+ const pages = Object.keys(manifest.router.pages || {});
87
+ rules.forEach((item, index) => {
88
+ const page = item.page;
89
+ if (page !== '*' && !pages.includes(page)) {
90
+ ColorConsole_1.default.throw(`The ${index + 1}th item of sitemap rules is configured incorrectly, the page ${page} does not exist`);
91
+ }
92
+ return page;
93
+ });
94
+ }
95
+ catch (error) {
96
+ ColorConsole_1.default.warn(error === null || error === void 0 ? void 0 : error.toString());
97
+ }
98
+ }
99
+ }
30
100
  }
101
+ exports.UxFileUtils = UxFileUtils;
31
102
  UxFileUtils.CONFIG_FILE_NAME = 'manifest.json';
32
103
  exports.default = UxFileUtils;
33
-
34
- //# sourceMappingURL=UxFileUtils.js.map
@@ -5,6 +5,7 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
5
5
  */
6
6
  declare class UxFollowWorks {
7
7
  static webpack: FollowWork<IJavascriptCompileOption>;
8
+ static protobuf: FollowWork<IJavascriptCompileOption>;
8
9
  static jsc: FollowWork<IJavascriptCompileOption>;
9
10
  static toRpk: FollowWork<IJavascriptCompileOption>;
10
11
  /**
@@ -13,6 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  var _a;
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ const TranslateCache_1 = __importDefault(require("@aiot-toolkit/parser/lib//ux/translate/vela/TranslateCache"));
17
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
16
18
  const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
17
19
  const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
18
20
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -24,6 +26,7 @@ const JavascriptDefaultCompileOption_1 = __importDefault(require("../../compiler
24
26
  const Jsc_1 = __importDefault(require("../../compiler/javascript/vela/utils/Jsc"));
25
27
  const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
26
28
  const UxFileUtils_1 = __importDefault(require("./UxFileUtils"));
29
+ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
27
30
  /**
28
31
  * UxFollowWorks
29
32
  */
@@ -31,10 +34,24 @@ class UxFollowWorks {
31
34
  }
32
35
  _a = UxFollowWorks;
33
36
  UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
34
- yield new JavascriptCompiler_1.default().compile(Object.assign(Object.assign({ projectPath: path_1.default.join(context.projectPath, context.output), mode: CompileMode_1.default.DEVELOPMENT, devtool: false, platform: 'vela' }, JavascriptDefaultCompileOption_1.default), compilerOption));
37
+ return new JavascriptCompiler_1.default()
38
+ .compile(Object.assign(Object.assign({ projectPath: path_1.default.join(context.projectPath, context.output), mode: CompileMode_1.default.DEVELOPMENT, devtool: false, platform: 'vela' }, JavascriptDefaultCompileOption_1.default), compilerOption))
39
+ .then(() => {
40
+ ColorConsole_1.default.info(`webpack complete`);
41
+ })
42
+ .catch((errors) => {
43
+ ColorConsole_1.default.warn(`webpack error: \r\n`, {
44
+ word: errors.map((item, index) => `${index + 1}. ${item.message}`).join('\r\n\r\n')
45
+ });
46
+ });
47
+ });
48
+ UxFollowWorks.protobuf = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
49
+ if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
50
+ BinaryPlugin.createBinFiles();
51
+ }
35
52
  });
36
53
  UxFollowWorks.jsc = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
37
- if (compilerOption && !compilerOption.disabledJSC) {
54
+ if (compilerOption && compilerOption.disabledJSC === false) {
38
55
  return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
39
56
  }
40
57
  });
@@ -54,6 +71,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
54
71
  const { projectPath, sourceRoot, outputPath } = compilerOption;
55
72
  const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
56
73
  const { deviceTypeList } = manifest;
74
+ // 生成设备的 manifest 文件,规则为:manifest.json + config-设备类型.json
57
75
  if (deviceTypeList) {
58
76
  deviceTypeList.forEach((deviceType) => {
59
77
  let data = Object.assign({}, manifest);
@@ -108,6 +126,15 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
108
126
  if (!content.packageInfo) {
109
127
  content.packageInfo = ZipUtil_1.default.createComment(compilerOption);
110
128
  }
129
+ if (TranslateCache_1.default.featureCache.size) {
130
+ const featureSet = new Set([
131
+ ...Array.from(TranslateCache_1.default.featureCache),
132
+ ...(content.features || []).map((item) => item.name)
133
+ ]);
134
+ content.features = Array.from(featureSet).map((item) => {
135
+ return { name: item };
136
+ });
137
+ }
111
138
  fs_extra_1.default.writeJSONSync(path_1.default.join(projectPath, outputPath, UxFileUtils_1.default.CONFIG_FILE_NAME), content, {
112
139
  spaces: 2
113
140
  });
@@ -141,8 +168,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
141
168
  });
142
169
  if (compilerOption) {
143
170
  copyResourceFiles(compilerOption);
144
- genDeviceManifests(compilerOption);
145
171
  updateManifest(compilerOption);
172
+ genDeviceManifests(compilerOption);
146
173
  yield genMetaFiles(compilerOption);
147
174
  }
148
175
  });
@@ -196,5 +223,3 @@ UxFollowWorks.symlinkNodeModule = (context, config, compilerOption) => __awaiter
196
223
  });
197
224
  });
198
225
  exports.default = UxFollowWorks;
199
-
200
- //# sourceMappingURL=UxFollowWorks.js.map
@@ -1,5 +1,7 @@
1
+ import { ILog } from '@aiot-toolkit/shared-utils';
1
2
  import { IFileLaneContext, IFileParam } from 'file-lane';
2
3
  import { SourceFile } from 'ts-morph';
4
+ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
3
5
  /**
4
6
  * UxLoaderUtils
5
7
  */
@@ -12,17 +14,17 @@ declare class UxLoaderUtils {
12
14
  * @param project
13
15
  * @returns
14
16
  */
15
- static compileUxToJavascript(file: IFileParam, context: IFileLaneContext, isAppUx: boolean): Promise<{
16
- path: string;
17
- content: string;
18
- }[]>;
17
+ static compileUxToJavascript(file: IFileParam, context: IFileLaneContext, isAppUx: boolean, compilerOption: IJavascriptCompileOption): Promise<{
18
+ files: IFileParam[];
19
+ logs: ILog[];
20
+ }>;
19
21
  /**
20
22
  * 转换app.ux文件为js文件
21
23
  * @param file
22
24
  * @param resultFiles
23
25
  * @param context
24
26
  */
25
- static compileAppUxToJavascript(file: IFileParam, resultFiles: IFileParam[], context: IFileLaneContext): Promise<void>;
27
+ static compileAppUxToJavascript(file: IFileParam, resultFiles: IFileParam[], context: IFileLaneContext, compileOption: IJavascriptCompileOption): Promise<void>;
26
28
  /**
27
29
  * 判断是否为src/app.ux
28
30
  * @param filePath
@@ -42,12 +44,14 @@ declare class UxLoaderUtils {
42
44
  * @returns
43
45
  */
44
46
  static getAppUxContent(fileContent: string): string;
47
+ private static addTemplateProtobuf;
45
48
  /**
46
49
  * 给template增加外层包裹内容
47
50
  * @param templateTree
48
51
  * @returns
49
52
  */
50
- static wrapTempalte(templateTree: SourceFile): string;
53
+ static wrapTempalte(templateTree: SourceFile, file: IFileParam, compilerOption: IJavascriptCompileOption): string;
54
+ private static wrapStyle;
51
55
  /**
52
56
  * 给script增加外层包裹内容
53
57
  * @param isPageUx
@@ -55,6 +59,6 @@ declare class UxLoaderUtils {
55
59
  * @returns
56
60
  */
57
61
  static handleScriptContent(isPageUx: boolean, appScriptTree: SourceFile): string;
58
- static getReturnType(isPageUx: boolean): "$app_exports$['entry'] =" | "return";
62
+ static getReturnType(isPageUx: boolean): "$app_exports$['entry'] =" | "module.exports = ";
59
63
  }
60
64
  export default UxLoaderUtils;