@aiot-toolkit/aiotpack 2.0.5-widget-provider-beta.2 → 2.0.6-alpha.0

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 (49) hide show
  1. package/README.md +46 -46
  2. package/lib/afterCompile/ux/UxAfterCompile.d.ts +0 -3
  3. package/lib/afterCompile/ux/UxAfterCompile.js +75 -81
  4. package/lib/beforeCompile/ux/UxBeforeCompile.js +2 -2
  5. package/lib/compiler/enum/CompileMode.js +2 -2
  6. package/lib/compiler/javascript/JavascriptCompiler.js +7 -7
  7. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +2 -2
  8. package/lib/compiler/javascript/android/plugin/WrapPlugin.js +7 -7
  9. package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +4 -0
  10. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +3 -3
  11. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +2 -2
  12. package/lib/compiler/javascript/vela/enum/EntryType.js +2 -2
  13. package/lib/compiler/javascript/vela/interface/IManifest.d.ts +0 -5
  14. package/lib/compiler/javascript/vela/interface/IManifest.js +2 -2
  15. package/lib/compiler/javascript/vela/model/Package.js +28 -28
  16. package/lib/compiler/javascript/vela/utils/Jsc.js +2 -2
  17. package/lib/compiler/javascript/vela/utils/LiteCard.d.ts +13 -0
  18. package/lib/compiler/javascript/vela/utils/LiteCard.js +41 -0
  19. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +17 -26
  20. package/lib/compiler/javascript/vela/utils/ZipUtil.js +62 -62
  21. package/lib/compiler/javascript/vela/utils/signature/Base64.js +2 -2
  22. package/lib/compiler/javascript/vela/utils/signature/CRC32.js +2 -2
  23. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +68 -68
  24. package/lib/compiler/javascript/vela/utils/signature/Signer.js +6 -6
  25. package/lib/compiler/javascript/vela/utils/signature/pem/certificate.pem +26 -26
  26. package/lib/compiler/javascript/vela/utils/signature/pem/private.pem +50 -50
  27. package/lib/compiler/tools/icu/ImageIcu.js +25 -25
  28. package/lib/compiler/tools/icu/icu_darwin_arm64 +0 -0
  29. package/lib/compiler/tools/icu/icu_darwin_x64 +0 -0
  30. package/lib/compiler/tools/icu/icu_linux_arm64 +0 -0
  31. package/lib/compiler/tools/icu/icu_linux_x64 +0 -0
  32. package/lib/compiler/tools/icu/icu_win32_x64.exe +0 -0
  33. package/lib/config/UxConfig.d.ts +3 -5
  34. package/lib/config/UxConfig.js +16 -17
  35. package/lib/loader/ux/JsLoader.d.ts +0 -5
  36. package/lib/loader/ux/JsLoader.js +7 -33
  37. package/lib/loader/ux/PngLoader.js +2 -2
  38. package/lib/loader/ux/android/UxLoader.js +2 -2
  39. package/lib/loader/ux/vela/AppUxLoader.js +3 -3
  40. package/lib/loader/ux/vela/HmlLoader.js +14 -14
  41. package/lib/utils/BeforeCompileUtils.js +14 -40
  42. package/lib/utils/PngUtils.js +11 -11
  43. package/lib/utils/ux/FileCompare.d.ts +12 -0
  44. package/lib/utils/ux/FileCompare.js +47 -0
  45. package/lib/utils/ux/UxFileUtils.d.ts +10 -8
  46. package/lib/utils/ux/UxFileUtils.js +63 -53
  47. package/lib/utils/ux/UxLoaderUtils.js +35 -35
  48. package/lib/utils/ux/android/AndroidUx.js +10 -10
  49. package/package.json +6 -7
@@ -8,45 +8,46 @@ var _CommonUtil = _interopRequireDefault(require("@aiot-toolkit/shared-utils/lib
8
8
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
9
  var _path = _interopRequireDefault(require("path"));
10
10
  var _ManifestSchema = _interopRequireDefault(require("./ManifestSchema"));
11
+ var _FileCompare = require("./FileCompare");
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
- /**
13
- * FileUtils
13
+ /**
14
+ * FileUtils
14
15
  */
15
16
  class UxFileUtils {
16
17
  static CONFIG_FILE_NAME = 'manifest.json';
17
- /**
18
- * 获取manifest.json路径
19
- * @param projectPath
20
- * @param sourceRoot
21
- * @returns
18
+ /**
19
+ * 获取manifest.json路径
20
+ * @param projectPath
21
+ * @param sourceRoot
22
+ * @returns
22
23
  */
23
24
  static getManifestFilePath(projectPath) {
24
25
  let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
25
26
  return _path.default.resolve(projectPath, sourceRoot, UxFileUtils.CONFIG_FILE_NAME);
26
27
  }
27
- /**
28
- * 获取manifest.json内容
29
- * @param projectPath
30
- * @param sourceRoot
31
- * @returns
28
+ /**
29
+ * 获取manifest.json内容
30
+ * @param projectPath
31
+ * @param sourceRoot
32
+ * @returns
32
33
  */
33
34
  static getManifestInfo(projectPath) {
34
35
  let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
35
36
  return _fsExtra.default.readJSONSync(UxFileUtils.getManifestFilePath(projectPath, sourceRoot));
36
37
  }
37
38
 
38
- /**
39
- * 检查 manifest文件,并显示错误信息
40
- *
41
- * 1. 使用ManifestSchema 校验
42
- * 1. TypeError: Error
43
- * 2. 其它: Warn
44
- * 2. 检查 router.entry 是否存在于 router.pages
45
- * 3. 检查icon是否存在
46
- *
47
- * @param projectPath 项目路径
48
- * @param sourceRoot 源码路径--相对项目根目录
49
- * @returns
39
+ /**
40
+ * 检查 manifest文件,并显示错误信息
41
+ *
42
+ * 1. 使用ManifestSchema 校验
43
+ * 1. TypeError: Error
44
+ * 2. 其它: Warn
45
+ * 2. 检查 router.entry 是否存在于 router.pages
46
+ * 3. 检查icon是否存在
47
+ *
48
+ * @param projectPath 项目路径
49
+ * @param sourceRoot 源码路径--相对项目根目录
50
+ * @returns
50
51
  */
51
52
  static validateManifest(projectPath) {
52
53
  let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
@@ -86,12 +87,12 @@ class UxFileUtils {
86
87
  }
87
88
  }
88
89
 
89
- /**
90
- * 检查 sitemap.json 文件,并显示错误信息
91
- *
92
- * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错
93
- * @param projectPath
94
- * @param sourceRoot
90
+ /**
91
+ * 检查 sitemap.json 文件,并显示错误信息
92
+ *
93
+ * 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错
94
+ * @param projectPath
95
+ * @param sourceRoot
95
96
  */
96
97
  static validateSitemap(projectPath) {
97
98
  let sourceRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'src';
@@ -112,39 +113,48 @@ class UxFileUtils {
112
113
  }
113
114
  }
114
115
  }
115
- /**
116
- * 1. 遍历旧文件列表
117
- * 1.1 若文件路径在新文件列表newFileList中,且内容一致时,从newFileList中移除该项
118
- * 1.2 若文件路径在新文件列表newFileList中,且内容不一致时,添加到diffList中表示待更新,从newFileList中移除该项
119
- * 1.3 若文件路径不在新文件列表中,表示该文件待删除(热更新时,可以不做删除,删除耗费性能)
120
- * 2. 若遍历完旧文件列表后,newFileList长度不为0,表示有文件待新增
121
- * @param oldFileList 旧文件列表
122
- * @param newFileList 新文件列表
123
- * @returns
116
+
117
+ /**
118
+ * 比较新旧文件列表差异
119
+ * 1. 遍历旧文件列表
120
+ * 1.1 若文件路径在新文件列表remainingNewFilest中,且内容一致时,从remainingNewFiles中移除该项
121
+ * 1.2 若文件路径在新文件列表remainingNewFiles中,且内容不一致时,添加到diffList中表示待更新,从remainingNewFiles中移除该项
122
+ * 1.3 若文件路径不在新文件列表中,表示该文件待删除(热更新时,可以不做删除,删除耗费性能)
123
+ * 2. 若遍历完旧文件列表后,remainingNewFiles长度不为0,表示有文件待新增
124
+ * @param oldFileList 旧文件路径列表(相对路径)
125
+ * @param newFileList 新文件路径列表(绝对路径)
126
+ * @param oldDir 旧文件所在目录(绝对路径)
127
+ * @param newDir 新文件所在目录(绝对路径)
128
+ * @returns 返回差异文件路径列表(相对路径)
124
129
  */
125
- static getDiffJSON(compilation, newFileList, buildPath) {
126
- const oldFileList = compilation.buildFileList;
127
- if (!oldFileList.length) {
130
+ static getDiffJSON(oldFileList, newFileList, oldDir, newDir) {
131
+ if (!oldFileList.length && !newFileList.length) {
128
132
  return [];
129
133
  }
130
134
  let diffList = [];
135
+ // 剩余待处理的新文件列表
136
+ const remainingNewFiles = [...newFileList];
131
137
  // 1.
132
- for (let i = 0; i < oldFileList.length; i++) {
133
- const index = newFileList.findIndex(file => file === oldFileList[i].path);
134
- // 1.3
138
+ for (const oldFile of oldFileList) {
139
+ const index = remainingNewFiles.findIndex(newFile => {
140
+ const relativePath = _path.default.relative(newDir, newFile);
141
+ return relativePath === oldFile;
142
+ });
135
143
  if (index !== -1) {
136
- // 1.2
137
- const oldContent = oldFileList[i].content?.toString('utf-8');
138
- const newContent = _fsExtra.default.readFileSync(_path.default.join(buildPath, newFileList[index]), 'utf-8');
139
- if (oldContent !== newContent) {
140
- diffList.push(newFileList[index]);
144
+ const oldFilePath = _path.default.join(oldDir, oldFile);
145
+ // 比较文件内容
146
+ const {
147
+ isEqual
148
+ } = (0, _FileCompare.compareFiles)(oldFilePath, remainingNewFiles[index]);
149
+ if (!isEqual) {
150
+ diffList.push(_path.default.relative(newDir, remainingNewFiles[index]));
141
151
  }
142
- // 从newFileList中移除该项
143
- newFileList.splice(index, 1);
152
+ // 从新文件列表中移除已比较过的文件
153
+ remainingNewFiles.splice(index, 1);
144
154
  }
145
155
  }
146
156
  // 2.
147
- newFileList.length > 0 && newFileList.forEach(file => diffList.push(file));
157
+ diffList.push(...remainingNewFiles.map(file => _path.default.relative(newDir, file)));
148
158
  return diffList;
149
159
  }
150
160
  }
@@ -19,8 +19,8 @@ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobu
19
19
  const {
20
20
  extractFunctions
21
21
  } = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/protobufControl');
22
- /**
23
- * UxLoaderUtils
22
+ /**
23
+ * UxLoaderUtils
24
24
  */
25
25
  class UxLoaderUtils {
26
26
  // 页面组件需要添加ViewModel数据校验和处理代码
@@ -47,12 +47,12 @@ class UxLoaderUtils {
47
47
  }
48
48
  })
49
49
  }`;
50
- /**
51
- * 转换单个ux文件为js文件
52
- * @param file ux文件内容
53
- * @param context 文件所在项目上下文
54
- * @param project
55
- * @returns
50
+ /**
51
+ * 转换单个ux文件为js文件
52
+ * @param file ux文件内容
53
+ * @param context 文件所在项目上下文
54
+ * @param project
55
+ * @returns
56
56
  */
57
57
  static async compileUxToJavascript(file, context, isAppUx, compilerOption) {
58
58
  const logs = [];
@@ -173,11 +173,11 @@ class UxLoaderUtils {
173
173
  logs
174
174
  };
175
175
  }
176
- /**
177
- * 转换app.ux文件为js文件
178
- * @param file
179
- * @param resultFiles
180
- * @param context
176
+ /**
177
+ * 转换app.ux文件为js文件
178
+ * @param file
179
+ * @param resultFiles
180
+ * @param context
181
181
  */
182
182
  static async compileAppUxToJavascript(file, context, compileOption) {
183
183
  const {
@@ -197,29 +197,29 @@ class UxLoaderUtils {
197
197
  }, context, isAppUx, compileOption);
198
198
  return compileResult;
199
199
  }
200
- /**
201
- * 判断是否为src/app.ux
202
- * @param filePath
203
- * @returns
200
+ /**
201
+ * 判断是否为src/app.ux
202
+ * @param filePath
203
+ * @returns
204
204
  */
205
205
  static isAppUx(filePath) {
206
206
  const parentDirName = _path.default.basename(_path.default.dirname(filePath));
207
207
  const fileName = _path.default.basename(filePath);
208
208
  return parentDirName === 'src' && fileName === 'app.ux';
209
209
  }
210
- /**
211
- * 判断是否为页面组件
212
- * @param context
213
- * @param filePath
214
- * @returns
210
+ /**
211
+ * 判断是否为页面组件
212
+ * @param context
213
+ * @param filePath
214
+ * @returns
215
215
  */
216
216
  static isPageUx(context, filePath) {
217
217
  return Boolean(context.entries?.includes(filePath));
218
218
  }
219
- /**
220
- * 获取app.ux的内容,且只返回script和style内容
221
- * @param fileContent
222
- * @returns
219
+ /**
220
+ * 获取app.ux的内容,且只返回script和style内容
221
+ * @param fileContent
222
+ * @returns
223
223
  */
224
224
  static getAppUxContent(fileContent) {
225
225
  const appUxAst = parse5.parseFragment(fileContent, {
@@ -318,10 +318,10 @@ class UxLoaderUtils {
318
318
  return result;
319
319
  }
320
320
 
321
- /**
322
- * 给template增加外层包裹内容
323
- * @param templateTree
324
- * @returns
321
+ /**
322
+ * 给template增加外层包裹内容
323
+ * @param templateTree
324
+ * @returns
325
325
  */
326
326
  static wrapTempalte(templateTree, file, compilerOption) {
327
327
  const result = `function (vm) {
@@ -344,11 +344,11 @@ class UxLoaderUtils {
344
344
  return code;
345
345
  }
346
346
 
347
- /**
348
- * 给script增加外层包裹内容
349
- * @param isPageUx
350
- * @param appScriptTree
351
- * @returns
347
+ /**
348
+ * 给script增加外层包裹内容
349
+ * @param isPageUx
350
+ * @param appScriptTree
351
+ * @returns
352
352
  */
353
353
  static wrapScript(isPageUx, appScriptTree) {
354
354
  if (isPageUx) {
@@ -11,18 +11,18 @@ var _generator = require("@aiot-toolkit/generator");
11
11
  var _path = _interopRequireDefault(require("path"));
12
12
  var _QuickAppDocHelp = require("@aiot-toolkit/shared-utils/lib/utils/QuickAppDocHelp");
13
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
- /**
15
- * AndroidUx
14
+ /**
15
+ * AndroidUx
16
16
  */
17
17
  class AndroidUx {
18
- /**
19
- *
20
- * 编译 ux 文件
21
- * 1. 获取文件类型:app page 普通ux
22
- * 2. 使用`UxParse`解析
23
- * 3. 使用`UxToTypeScript`转换
24
- * 4. 使用`TypeScriptGenerator`生成
25
- * @param params
18
+ /**
19
+ *
20
+ * 编译 ux 文件
21
+ * 1. 获取文件类型:app page 普通ux
22
+ * 2. 使用`UxParse`解析
23
+ * 3. 使用`UxToTypeScript`转换
24
+ * 4. 使用`TypeScriptGenerator`生成
25
+ * @param params
26
26
  */
27
27
  async compileUx(params) {
28
28
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/aiotpack",
3
- "version": "2.0.5-widget-provider-beta.2",
3
+ "version": "2.0.6-alpha.0",
4
4
  "description": "The process tool for packaging aiot projects.",
5
5
  "keywords": [
6
6
  "aiotpack"
@@ -19,17 +19,16 @@
19
19
  "test": "node ./__tests__/aiotpack.test.js"
20
20
  },
21
21
  "dependencies": {
22
- "@aiot-toolkit/generator": "2.0.5-widget-provider-beta.2",
23
- "@aiot-toolkit/parser": "2.0.5-widget-provider-beta.2",
24
- "@aiot-toolkit/shared-utils": "2.0.5-widget-provider-beta.2",
22
+ "@aiot-toolkit/generator": "2.0.6-alpha.0",
23
+ "@aiot-toolkit/parser": "2.0.6-alpha.0",
24
+ "@aiot-toolkit/shared-utils": "2.0.6-alpha.0",
25
25
  "@hap-toolkit/aaptjs": "^2.0.0",
26
26
  "@rspack/core": "^1.3.9",
27
27
  "aiot-parse5": "^1.0.2",
28
28
  "babel-loader": "^9.1.3",
29
- "file-lane": "2.0.5-widget-provider-beta.2",
29
+ "file-lane": "2.0.6-alpha.0",
30
30
  "file-loader": "^6.2.0",
31
31
  "fs-extra": "^11.2.0",
32
- "hap-toolkit": "^2.0.0",
33
32
  "jsrsasign": "^11.1.0",
34
33
  "jszip": "^3.10.1",
35
34
  "lodash": "^4.17.21",
@@ -43,5 +42,5 @@
43
42
  "@types/jsrsasign": "^10.5.12",
44
43
  "@types/webpack-sources": "^3.2.3"
45
44
  },
46
- "gitHead": "4a8894bc66a9c78cd835ed6c1af74d054300e064"
45
+ "gitHead": "d62548a25ca507fac9532e34983e87a8cdee36f5"
47
46
  }