@aiot-toolkit/aiotpack 2.0.1-alpha.9 → 2.0.2-batchmanifest-beta.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 (115) 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 +51 -18
  7. package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +1 -0
  8. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +5 -3
  9. package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +17 -5
  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.d.ts +1 -2
  13. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +11 -7
  14. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +0 -2
  15. package/lib/compiler/javascript/vela/enum/EntryType.js +0 -2
  16. package/lib/compiler/javascript/vela/interface/IChunk.js +0 -2
  17. package/lib/compiler/javascript/vela/interface/IManifest.d.ts +3 -0
  18. package/lib/compiler/javascript/vela/interface/IManifest.js +0 -2
  19. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +0 -2
  20. package/lib/compiler/javascript/vela/model/Package.js +2 -4
  21. package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +0 -1
  22. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +19 -24
  23. package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
  24. package/lib/compiler/javascript/vela/utils/Jsc.js +4 -7
  25. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +3 -5
  26. package/lib/compiler/javascript/vela/utils/ZipUtil.js +6 -8
  27. package/lib/compiler/javascript/vela/utils/signature/Base64.js +0 -2
  28. package/lib/compiler/javascript/vela/utils/signature/CRC32.js +0 -2
  29. package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +1 -1
  30. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +14 -12
  31. package/lib/compiler/javascript/vela/utils/signature/Signer.js +0 -2
  32. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +3 -0
  33. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +59 -0
  34. package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +3 -0
  35. package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +20 -0
  36. package/lib/config/UxConfig.d.ts +8 -19
  37. package/lib/config/UxConfig.js +69 -13
  38. package/lib/config/XtsConfig.d.ts +5 -2
  39. package/lib/config/XtsConfig.js +12 -5
  40. package/lib/{utils → followWorks}/ux/UxFollowWorks.d.ts +1 -0
  41. package/lib/{utils → followWorks}/ux/UxFollowWorks.js +72 -14
  42. package/lib/followWorks/xts/entryTemplate.d.ts +2 -2
  43. package/lib/followWorks/xts/entryTemplate.js +61 -44
  44. package/lib/followWorks/xts/generateRpk.js +1 -3
  45. package/lib/followWorks/xts/ts2wasm.js +3 -14
  46. package/lib/index.js +0 -2
  47. package/lib/interface/ICompileOptions.d.ts +1 -1
  48. package/lib/interface/ICompileOptions.js +1 -3
  49. package/lib/interface/IDeviceList.js +0 -2
  50. package/lib/loader/ux/AppUxLoader.d.ts +2 -0
  51. package/lib/loader/ux/AppUxLoader.js +14 -4
  52. package/lib/loader/ux/HmlLoader.d.ts +24 -0
  53. package/lib/loader/ux/HmlLoader.js +63 -0
  54. package/lib/loader/ux/JsLoader.d.ts +11 -0
  55. package/lib/loader/ux/JsLoader.js +40 -0
  56. package/lib/loader/ux/PngLoader.js +4 -9
  57. package/lib/loader/ux/UxLoader.d.ts +2 -0
  58. package/lib/loader/ux/UxLoader.js +15 -4
  59. package/lib/loader/xts/XtsLoader.js +3 -9
  60. package/lib/preWorks/ux/UxPreWorks.d.ts +10 -0
  61. package/lib/preWorks/ux/UxPreWorks.js +31 -0
  62. package/lib/preWorks/xts/preInstall.js +4 -12
  63. package/lib/utils/PngUtils.js +0 -2
  64. package/lib/utils/PreWorkUtils.d.ts +5 -0
  65. package/lib/utils/PreWorkUtils.js +45 -12
  66. package/lib/utils/ux/ManifestSchema.d.ts +3 -0
  67. package/lib/utils/ux/ManifestSchema.js +207 -0
  68. package/lib/utils/ux/UxFileUtils.d.ts +21 -4
  69. package/lib/utils/ux/UxFileUtils.js +74 -5
  70. package/lib/utils/ux/UxLoaderUtils.d.ts +14 -7
  71. package/lib/utils/ux/UxLoaderUtils.js +144 -38
  72. package/lib/utils/xts/XtsFollowWorks.js +3 -12
  73. package/package.json +8 -10
  74. package/lib/compiler/enum/CompileMode.js.map +0 -1
  75. package/lib/compiler/interface/ICompileParam.js.map +0 -1
  76. package/lib/compiler/interface/ICompiler.js.map +0 -1
  77. package/lib/compiler/interface/ISignConfig.js.map +0 -1
  78. package/lib/compiler/javascript/JavascriptCompiler.js.map +0 -1
  79. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +0 -1
  80. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +0 -1
  81. package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +0 -1
  82. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +0 -1
  83. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +0 -1
  84. package/lib/compiler/javascript/vela/enum/EntryType.js.map +0 -1
  85. package/lib/compiler/javascript/vela/interface/IChunk.js.map +0 -1
  86. package/lib/compiler/javascript/vela/interface/IManifest.js.map +0 -1
  87. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +0 -1
  88. package/lib/compiler/javascript/vela/model/Package.js.map +0 -1
  89. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +0 -1
  90. package/lib/compiler/javascript/vela/utils/Jsc.js.map +0 -1
  91. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +0 -1
  92. package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +0 -1
  93. package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +0 -1
  94. package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +0 -1
  95. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +0 -1
  96. package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +0 -1
  97. package/lib/config/UxConfig.js.map +0 -1
  98. package/lib/config/XtsConfig.js.map +0 -1
  99. package/lib/followWorks/xts/entryTemplate.js.map +0 -1
  100. package/lib/followWorks/xts/generateRpk.js.map +0 -1
  101. package/lib/followWorks/xts/ts2wasm.js.map +0 -1
  102. package/lib/index.js.map +0 -1
  103. package/lib/interface/ICompileOptions.js.map +0 -1
  104. package/lib/interface/IDeviceList.js.map +0 -1
  105. package/lib/loader/ux/AppUxLoader.js.map +0 -1
  106. package/lib/loader/ux/PngLoader.js.map +0 -1
  107. package/lib/loader/ux/UxLoader.js.map +0 -1
  108. package/lib/loader/xts/XtsLoader.js.map +0 -1
  109. package/lib/preWorks/xts/preInstall.js.map +0 -1
  110. package/lib/utils/PngUtils.js.map +0 -1
  111. package/lib/utils/PreWorkUtils.js.map +0 -1
  112. package/lib/utils/ux/UxFileUtils.js.map +0 -1
  113. package/lib/utils/ux/UxFollowWorks.js.map +0 -1
  114. package/lib/utils/ux/UxLoaderUtils.js.map +0 -1
  115. package/lib/utils/xts/XtsFollowWorks.js.map +0 -1
@@ -13,10 +13,14 @@ 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 parser_1 = require("@aiot-toolkit/parser");
23
+ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
20
24
  /**
21
25
  * PreWorkUtils
22
26
  */
@@ -37,40 +41,69 @@ class PreWorkUtils {
37
41
  if (manifestContent) {
38
42
  const { router } = manifestContent;
39
43
  if (!router) {
40
- // 报错,没有router配置
44
+ // 没有router配置
45
+ ColorConsole_1.default.throw(`### manifest ### No router configuration`);
41
46
  }
42
47
  const { pages } = router;
43
48
  if (!pages) {
44
- // 报错,没有pages配置
49
+ // 没有pages配置
50
+ ColorConsole_1.default.throw(`### manifest ### No pages configuration`);
45
51
  }
46
52
  Object.keys(pages).map((page) => {
47
53
  const pageContent = pages[page];
48
54
  const entryDir = path_1.default.join(srcPath, page);
49
- const entryPage = path_1.default.join(entryDir, `${pageContent.component}.ux`);
50
- if (fs_extra_1.default.existsSync(entryPage)) {
51
- entryList.push(entryPage);
55
+ const entryPages = parser_1.ExtensionConfig.TEMPLATES.map((item) => `${pageContent.component}${item}`);
56
+ const entry = entryPages.find((item) => fs_extra_1.default.existsSync(path_1.default.join(entryDir, item)));
57
+ if (entry) {
58
+ entryList.push(path_1.default.join(entryDir, entry));
52
59
  }
53
60
  else {
54
- // 报错,路径不存在
61
+ // 路径不存在
62
+ ColorConsole_1.default.throw(`### manifest ### path '${entryPages.join(' | ')}' does not exist`);
55
63
  }
56
64
  });
57
65
  context['entries'] = entryList;
58
66
  return Promise.resolve();
59
67
  }
60
68
  else {
61
- // 报错 manifest.json文件无有效内容
69
+ // manifest.json文件无有效内容
70
+ ColorConsole_1.default.error(`### manifest ### File has no valid content`);
62
71
  return Promise.reject();
63
72
  }
64
73
  }
74
+ /**
75
+ * 获取项目的全局样式变量配置
76
+ * @param context
77
+ */
78
+ static getGlobalVar(context) {
79
+ const { projectPath } = context;
80
+ const filePath = path_1.default.join(projectPath, 'src', 'globalVar.json');
81
+ let globalVar = {};
82
+ // 判断文件是否存在
83
+ if (fs_extra_1.default.existsSync(filePath)) {
84
+ // 存在则取内容,否则内容为空
85
+ globalVar = fs_extra_1.default.readJSONSync(filePath);
86
+ }
87
+ context.globalVar = globalVar;
88
+ return Promise.resolve();
89
+ }
65
90
  }
66
91
  _a = PreWorkUtils;
67
92
  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));
93
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, context.output));
69
94
  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));
95
+ yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
96
+ yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
97
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.outputPath));
98
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.releasePath));
72
99
  }
100
+ TranslateCache_1.default.featureCache.clear();
101
+ BinaryPlugin.reset();
102
+ BinaryPlugin.config = {
103
+ projectPath: context.projectPath,
104
+ outputProjectPath: path_1.default.join(context.projectPath, context.output),
105
+ source: compileOption === null || compileOption === void 0 ? void 0 : compileOption.sourceRoot,
106
+ output: compileOption === null || compileOption === void 0 ? void 0 : compileOption.outputPath
107
+ };
73
108
  });
74
109
  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
@@ -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,20 @@ 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, context: IFileLaneContext, compileOption: IJavascriptCompileOption): Promise<{
28
+ files: IFileParam<any>[];
29
+ logs: ILog[];
30
+ }>;
26
31
  /**
27
32
  * 判断是否为src/app.ux
28
33
  * @param filePath
@@ -42,12 +47,14 @@ declare class UxLoaderUtils {
42
47
  * @returns
43
48
  */
44
49
  static getAppUxContent(fileContent: string): string;
50
+ private static addTemplateProtobuf;
45
51
  /**
46
52
  * 给template增加外层包裹内容
47
53
  * @param templateTree
48
54
  * @returns
49
55
  */
50
- static wrapTempalte(templateTree: SourceFile): string;
56
+ static wrapTempalte(templateTree: SourceFile, file: IFileParam, compilerOption: IJavascriptCompileOption): string;
57
+ private static wrapStyle;
51
58
  /**
52
59
  * 给script增加外层包裹内容
53
60
  * @param isPageUx
@@ -55,6 +62,6 @@ declare class UxLoaderUtils {
55
62
  * @returns
56
63
  */
57
64
  static handleScriptContent(isPageUx: boolean, appScriptTree: SourceFile): string;
58
- static getReturnType(isPageUx: boolean): "$app_exports$['entry'] =" | "return";
65
+ static getReturnType(isPageUx: boolean): "$app_exports$['entry'] =" | "module.exports = ";
59
66
  }
60
67
  export default UxLoaderUtils;