@aiot-toolkit/aiotpack 2.0.2-beta.10 → 2.0.2-beta.12

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 (59) hide show
  1. package/lib/compiler/interface/ICompileParam.d.ts +1 -1
  2. package/lib/compiler/javascript/JavascriptCompiler.js +19 -6
  3. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.d.ts +9 -0
  4. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +16 -0
  5. package/lib/compiler/javascript/android/plugin/WrapPlugin.d.ts +20 -0
  6. package/lib/compiler/javascript/android/plugin/WrapPlugin.js +78 -0
  7. package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +7 -0
  8. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +2 -0
  9. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +14 -10
  10. package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -1
  11. package/lib/compiler/javascript/vela/model/Package.d.ts +1 -1
  12. package/lib/compiler/javascript/vela/model/Package.js +2 -5
  13. package/lib/compiler/javascript/vela/utils/Jsc.js +3 -4
  14. package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +1 -1
  15. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +3 -3
  16. package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +1 -1
  17. package/lib/compiler/javascript/vela/utils/ZipUtil.js +7 -9
  18. package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +3 -5
  19. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +53 -28
  20. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +2 -5
  21. package/lib/config/UxConfig.d.ts +40 -7
  22. package/lib/config/UxConfig.js +67 -35
  23. package/lib/config/XtsConfig.d.ts +2 -3
  24. package/lib/followWorks/ux/UxFollowWorks.d.ts +1 -1
  25. package/lib/followWorks/ux/UxFollowWorks.js +19 -24
  26. package/lib/followWorks/xts/entryTemplate.d.ts +1 -1
  27. package/lib/followWorks/xts/entryTemplate.js +10 -10
  28. package/lib/followWorks/xts/generateRpk.d.ts +1 -1
  29. package/lib/followWorks/xts/generateRpk.js +2 -2
  30. package/lib/followWorks/xts/ts2wasm.d.ts +1 -1
  31. package/lib/followWorks/xts/ts2wasm.js +4 -4
  32. package/lib/index.d.ts +9 -1
  33. package/lib/index.js +35 -1
  34. package/lib/loader/ux/JsLoader.js +5 -9
  35. package/lib/loader/ux/PngLoader.js +4 -5
  36. package/lib/loader/ux/android/UxLoader.d.ts +11 -0
  37. package/lib/loader/ux/android/UxLoader.js +39 -0
  38. package/lib/loader/ux/{AppUxLoader.d.ts → vela/AppUxLoader.d.ts} +1 -1
  39. package/lib/loader/ux/{AppUxLoader.js → vela/AppUxLoader.js} +3 -12
  40. package/lib/loader/ux/{UxLoader.d.ts → vela/UxLoader.d.ts} +1 -1
  41. package/lib/loader/ux/{UxLoader.js → vela/UxLoader.js} +2 -11
  42. package/lib/loader/xts/XtsLoader.js +6 -7
  43. package/lib/preWorks/ux/UxPreWorks.d.ts +1 -1
  44. package/lib/preWorks/xts/preInstall.d.ts +1 -1
  45. package/lib/preWorks/xts/preInstall.js +4 -4
  46. package/lib/utils/PreWorkUtils.d.ts +1 -2
  47. package/lib/utils/PreWorkUtils.js +27 -32
  48. package/lib/utils/ux/ManifestSchema.d.ts +1 -1
  49. package/lib/utils/ux/UxFileUtils.js +11 -13
  50. package/lib/utils/ux/UxLoaderUtils.d.ts +3 -3
  51. package/lib/utils/ux/UxLoaderUtils.js +14 -14
  52. package/lib/utils/ux/android/AndroidUx.d.ts +27 -0
  53. package/lib/utils/ux/android/AndroidUx.js +98 -0
  54. package/lib/utils/xts/XtsFileLaneUtils.d.ts +10 -0
  55. package/lib/utils/xts/XtsFileLaneUtils.js +68 -0
  56. package/lib/utils/xts/XtsFollowWorks.js +7 -7
  57. package/package.json +6 -5
  58. /package/lib/loader/ux/{HmlLoader.d.ts → vela/HmlLoader.d.ts} +0 -0
  59. /package/lib/loader/ux/{HmlLoader.js → vela/HmlLoader.js} +0 -0
@@ -1,19 +1,52 @@
1
1
  import { IFileLaneConfig } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
3
- import { IRule } from 'file-lane/lib/interface/IFileLaneConfig';
3
+ import JsLoader from '../loader/ux/JsLoader';
4
+ import PngLoader from '../loader/ux/PngLoader';
5
+ import AppUxLoader from '../loader/ux/vela/AppUxLoader';
6
+ import HmlLoader from '../loader/ux/vela/HmlLoader';
7
+ import UxLoader from '../loader/ux/vela/UxLoader';
4
8
  declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
5
9
  readonly projectPath: string;
6
10
  constructor(projectPath: string);
7
11
  exclude: (RegExp | ((filePath: string) => boolean))[];
8
12
  get output(): string;
9
- module: {
10
- rules: IRule[];
11
- };
12
- preWorks: import("file-lane/lib/interface/IFileLaneConfig").PreWork<IJavascriptCompileOption>[];
13
+ preWorks: import("file-lane").PreWork<IJavascriptCompileOption>[];
13
14
  followWorks: {
14
- worker: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<IJavascriptCompileOption>;
15
+ worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
15
16
  workerDescribe: string;
16
17
  }[];
17
- watchIgnores: RegExp[];
18
+ watchIgnores: (string | RegExp)[];
19
+ /**
20
+ * 通过项目类型,返回模块配置
21
+ */
22
+ get module(): {
23
+ rules: ({
24
+ test: string[];
25
+ loader: (typeof AppUxLoader)[];
26
+ exclude?: undefined;
27
+ } | {
28
+ test: RegExp[];
29
+ exclude: RegExp[];
30
+ loader: (typeof UxLoader)[];
31
+ } | {
32
+ test: RegExp[];
33
+ loader: (typeof HmlLoader | typeof UxLoader)[];
34
+ exclude?: undefined;
35
+ } | {
36
+ test: RegExp[];
37
+ loader: (typeof JsLoader)[];
38
+ exclude?: undefined;
39
+ } | {
40
+ test: RegExp[];
41
+ loader: (typeof PngLoader)[];
42
+ exclude?: undefined;
43
+ })[];
44
+ };
45
+ /**
46
+ * 判断项目类型
47
+ *
48
+ * 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
49
+ */
50
+ private getProjectType;
18
51
  }
19
52
  export default UxConfig;
@@ -3,18 +3,19 @@ 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
+ const parser_1 = require("@aiot-toolkit/parser");
7
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
8
+ const fs_1 = __importDefault(require("fs"));
6
9
  const path_1 = __importDefault(require("path"));
7
- const AppUxLoader_1 = __importDefault(require("../loader/ux/AppUxLoader"));
10
+ const UxFollowWorks_1 = __importDefault(require("../followWorks/ux/UxFollowWorks"));
8
11
  const JsLoader_1 = __importDefault(require("../loader/ux/JsLoader"));
9
12
  const PngLoader_1 = __importDefault(require("../loader/ux/PngLoader"));
10
- const UxLoader_1 = __importDefault(require("../loader/ux/UxLoader"));
11
- const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
12
- const UxFollowWorks_1 = __importDefault(require("../followWorks/ux/UxFollowWorks"));
13
+ const AppUxLoader_1 = __importDefault(require("../loader/ux/vela/AppUxLoader"));
14
+ const HmlLoader_1 = __importDefault(require("../loader/ux/vela/HmlLoader"));
15
+ const UxLoader_1 = __importDefault(require("../loader/ux/vela/UxLoader"));
13
16
  const UxPreWorks_1 = __importDefault(require("../preWorks/ux/UxPreWorks"));
14
- const HmlLoader_1 = __importDefault(require("../loader/ux/HmlLoader"));
15
- const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
16
- const fs_1 = __importDefault(require("fs"));
17
- const parser_1 = require("@aiot-toolkit/parser");
17
+ const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
18
+ const UxLoader_2 = __importDefault(require("../loader/ux/android/UxLoader"));
18
19
  class UxConfig {
19
20
  constructor(projectPath) {
20
21
  this.projectPath = projectPath;
@@ -28,38 +29,13 @@ class UxConfig {
28
29
  if (![...parser_1.ExtensionConfig.SCRIPTS, ...parser_1.ExtensionConfig.STYLES].includes(ext)) {
29
30
  return false;
30
31
  }
31
- const hmlPath = FileUtil_1.default.updatePath(filePath, `${name}${parser_1.ExtensionConfig.HML}`);
32
+ const hmlPath = shared_utils_1.FileUtil.updateFileName(filePath, `${name}${parser_1.ExtensionConfig.HML}`);
32
33
  if (fs_1.default.existsSync(hmlPath)) {
33
34
  return true;
34
35
  }
35
36
  return false;
36
37
  }
37
38
  ];
38
- this.module = {
39
- rules: [
40
- {
41
- test: ['app.ux'],
42
- loader: [AppUxLoader_1.default]
43
- },
44
- {
45
- test: [/.+\.ux$/],
46
- exclude: [/app\.ux/],
47
- loader: [UxLoader_1.default]
48
- },
49
- {
50
- test: [/.+\.hml$/],
51
- loader: [HmlLoader_1.default, UxLoader_1.default]
52
- },
53
- {
54
- test: [/.+\.js$/],
55
- loader: [JsLoader_1.default]
56
- },
57
- {
58
- test: [/.+\.9.png/],
59
- loader: [PngLoader_1.default]
60
- }
61
- ]
62
- };
63
39
  this.preWorks = [
64
40
  UxPreWorks_1.default.validateManifest,
65
41
  UxPreWorks_1.default.validateSitemap,
@@ -97,12 +73,68 @@ class UxConfig {
97
73
  workerDescribe: 'Migrate temporary project'
98
74
  }
99
75
  ];
100
- this.watchIgnores = [/node_modules/];
76
+ this.watchIgnores = [/node_modules/, '/build/', '/dist/'];
101
77
  }
102
78
  get output() {
103
79
  const name = path_1.default.basename(this.projectPath);
104
80
  const result = `../.temp_${name}`;
105
81
  return result;
106
82
  }
83
+ /**
84
+ * 通过项目类型,返回模块配置
85
+ */
86
+ get module() {
87
+ const isVela = this.getProjectType() === shared_utils_1.ProjectType.VELA_UX;
88
+ return isVela
89
+ ? {
90
+ rules: [
91
+ {
92
+ test: ['app.ux'],
93
+ loader: [AppUxLoader_1.default]
94
+ },
95
+ {
96
+ test: [/.+\.ux$/],
97
+ exclude: [/app\.ux/],
98
+ loader: [UxLoader_1.default]
99
+ },
100
+ {
101
+ test: [/.+\.hml$/],
102
+ loader: [HmlLoader_1.default, UxLoader_1.default]
103
+ },
104
+ {
105
+ test: [/.+\.js$/],
106
+ loader: [JsLoader_1.default]
107
+ },
108
+ {
109
+ test: [/.+\.9.png/],
110
+ loader: [PngLoader_1.default]
111
+ }
112
+ ]
113
+ }
114
+ : {
115
+ rules: [
116
+ {
117
+ test: [/.+\.ux$/],
118
+ loader: [UxLoader_2.default]
119
+ },
120
+ {
121
+ test: [/.+\.js$/],
122
+ loader: [JsLoader_1.default]
123
+ },
124
+ {
125
+ test: [/.+\.9.png/],
126
+ loader: [PngLoader_1.default]
127
+ }
128
+ ]
129
+ };
130
+ }
131
+ /**
132
+ * 判断项目类型
133
+ *
134
+ * 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
135
+ */
136
+ getProjectType() {
137
+ return shared_utils_1.ProjectType.getProjectType(this.projectPath);
138
+ }
107
139
  }
108
140
  exports.default = UxConfig;
@@ -1,6 +1,5 @@
1
- import { IFileLaneConfig } from 'file-lane';
1
+ import { IFileLaneConfig, PreWork } from 'file-lane';
2
2
  import XtsLoader from '../loader/xts/XtsLoader';
3
- import { PreWork } from 'file-lane/lib/interface/IFileLaneConfig';
4
3
  /**
5
4
  * XtsConfig
6
5
  */
@@ -15,7 +14,7 @@ declare class XtsConfig implements IFileLaneConfig {
15
14
  };
16
15
  preWorks: PreWork[];
17
16
  followWorks: {
18
- worker: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<import("../interface/ICompileOptions").IXtsCompileOptions>;
17
+ worker: import("file-lane").FollowWork<import("..").IXtsCompileOptions>;
19
18
  }[];
20
19
  }
21
20
  export default XtsConfig;
@@ -1,4 +1,4 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
3
3
  /**
4
4
  * UxFollowWorks
@@ -13,11 +13,7 @@ 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
16
  const shared_utils_1 = require("@aiot-toolkit/shared-utils");
18
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
19
- const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
20
- const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
21
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
22
18
  const lodash_1 = __importDefault(require("lodash"));
23
19
  const path_1 = __importDefault(require("path"));
@@ -38,7 +34,7 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
38
34
  return new JavascriptCompiler_1.default()
39
35
  .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))
40
36
  .then(() => {
41
- ColorConsole_1.default.info(`webpack complete`);
37
+ shared_utils_1.ColorConsole.info(`webpack complete`);
42
38
  })
43
39
  .catch(({ errors, warnings }) => {
44
40
  const errorLength = (errors === null || errors === void 0 ? void 0 : errors.length) || 0;
@@ -50,7 +46,7 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
50
46
  return `${index + 1}. ${item.message}`;
51
47
  })
52
48
  .join('\r\n'),
53
- style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
49
+ style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.THROW)
54
50
  });
55
51
  }
56
52
  if (warnings === null || warnings === void 0 ? void 0 : warnings.length) {
@@ -60,15 +56,15 @@ UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, v
60
56
  return `${errorLength + index + 1}. ${item.message}`;
61
57
  })
62
58
  .join('\r\n'),
63
- style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Warn)
59
+ style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.WARN)
64
60
  });
65
61
  }
66
62
  if (errors === null || errors === void 0 ? void 0 : errors.length) {
67
- ColorConsole_1.default.throw(...messages);
63
+ shared_utils_1.ColorConsole.throw(...messages);
68
64
  throw new Error();
69
65
  }
70
66
  else {
71
- ColorConsole_1.default.warn(...messages);
67
+ shared_utils_1.ColorConsole.warn(...messages);
72
68
  }
73
69
  });
74
70
  });
@@ -115,7 +111,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
115
111
  const copyResourceFiles = (compilerOption) => {
116
112
  // 复制除 js/jsx/ts/tsx/json 外,但是包含manifest.json、sitemap.json的文件
117
113
  const { projectPath, sourceRoot, outputPath } = compilerOption;
118
- const includeList = ['sitemap.json', /i18n(.+)\.json/];
114
+ const includeList = [/sitemap\.json$/, /i18n(.+)\.json/];
119
115
  const excludeExtList = [
120
116
  'js',
121
117
  'jsx',
@@ -128,7 +124,6 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
128
124
  'sass',
129
125
  'styl',
130
126
  'html',
131
- 'json',
132
127
  'md',
133
128
  'ux',
134
129
  'mix',
@@ -136,8 +131,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
136
131
  'map'
137
132
  ];
138
133
  const excludeReg = `\.(${excludeExtList.join('|')})$`;
139
- FileUtil_1.default.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
140
- FileUtil_1.default.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), undefined, includeList);
134
+ shared_utils_1.FileUtil.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
135
+ shared_utils_1.FileUtil.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), undefined, includeList);
141
136
  };
142
137
  /**
143
138
  * 写入 manifest.json 文件
@@ -146,17 +141,18 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
146
141
  * @param compilerOption
147
142
  */
148
143
  const updateManifest = (compilerOption) => {
149
- const { projectPath, sourceRoot, outputPath } = compilerOption;
144
+ const { projectPath, sourceRoot, outputPath, completeFeature } = compilerOption;
150
145
  const content = UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot);
146
+ const translateCache = context.translateCache;
151
147
  if (!content.minAPILevel) {
152
148
  content.minAPILevel = 1;
153
149
  }
154
150
  if (!content.packageInfo) {
155
151
  content.packageInfo = ZipUtil_1.default.createComment(compilerOption);
156
152
  }
157
- if (TranslateCache_1.default.featureCache.size) {
153
+ if (completeFeature && (translateCache === null || translateCache === void 0 ? void 0 : translateCache.featureCache.size)) {
158
154
  const featureSet = new Set([
159
- ...Array.from(TranslateCache_1.default.featureCache),
155
+ ...Array.from(translateCache.featureCache),
160
156
  ...(content.features || []).map((item) => item.name)
161
157
  ]);
162
158
  content.features = Array.from(featureSet).map((item) => {
@@ -180,7 +176,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
180
176
  const files = ZipUtil_1.default.getSortedFiles(outputAbsPath, compilerOption, UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot));
181
177
  const digestDic = Object.fromEntries(files.map((item) => [
182
178
  item,
183
- CommonUtil_1.default.calcDataDigest(fs_extra_1.default.readFileSync(path_1.default.join(outputAbsPath, item))).toString('hex')
179
+ shared_utils_1.CommonUtil.calcDataDigest(fs_extra_1.default.readFileSync(path_1.default.join(outputAbsPath, item))).toString('hex')
184
180
  ]));
185
181
  const hashJson = [
186
182
  {
@@ -195,9 +191,9 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
195
191
  fs_extra_1.default.outputFileSync(path_1.default.join(outputAbsPath, ZipUtil_1.default.CERT_PATH), buffer);
196
192
  });
197
193
  if (compilerOption) {
198
- copyResourceFiles(compilerOption);
199
- updateManifest(compilerOption);
200
- genDeviceManifests(compilerOption);
194
+ yield copyResourceFiles(compilerOption);
195
+ yield updateManifest(compilerOption);
196
+ yield genDeviceManifests(compilerOption);
201
197
  yield genMetaFiles(compilerOption);
202
198
  }
203
199
  });
@@ -228,9 +224,7 @@ UxFollowWorks.moveBackResult = (context, config, compilerOption) => __awaiter(vo
228
224
  ];
229
225
  targetList.forEach((item) => {
230
226
  fs_extra_1.default.moveSync(item.from, item.to, { overwrite: true });
231
- fs_extra_1.default.removeSync(item.from);
232
227
  });
233
- fs_extra_1.default.removeSync(projectPath);
234
228
  });
235
229
  /**
236
230
  * 创建 node_module 软链
@@ -246,8 +240,9 @@ UxFollowWorks.symlinkNodeModule = (context, config, compilerOption) => __awaiter
246
240
  const foldList = ['node_modules'];
247
241
  foldList.forEach((item) => {
248
242
  const sourcePath = path_1.default.join(context.projectPath, item);
249
- if (fs_extra_1.default.existsSync(sourcePath)) {
250
- fs_extra_1.default.symlinkSync(sourcePath, path_1.default.join(compilerOption.projectPath, item), 'junction');
243
+ const targetPath = path_1.default.join(compilerOption.projectPath, item);
244
+ if (fs_extra_1.default.existsSync(sourcePath) && !fs_extra_1.default.existsSync(targetPath)) {
245
+ fs_extra_1.default.symlinkSync(sourcePath, targetPath, 'junction');
251
246
  }
252
247
  });
253
248
  }
@@ -1,4 +1,4 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  export interface Aspects {
3
3
  path: string;
4
4
  name: string;
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.generateEntryFile = exports.XtsEntryFileName = exports.entryTemplate = void 0;
16
- const Framework_1 = require("@aiot-toolkit/parser/lib/xts/enum/Framework");
17
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
16
+ const parser_1 = require("@aiot-toolkit/parser");
17
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
18
18
  const fs_extra_1 = __importDefault(require("fs-extra"));
19
19
  const path_1 = __importDefault(require("path"));
20
20
  const entryTemplate = (options) => {
@@ -29,7 +29,7 @@ const entryTemplate = (options) => {
29
29
  const { routes = [] } = aspect;
30
30
  for (let r = 0; r < (routes === null || routes === void 0 ? void 0 : routes.length); r++) {
31
31
  const route = routes[r];
32
- imports += `import Page${i + 1}_${r + 1}, { ${Framework_1.HomeState.interface} as ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_ } from './${route.importPath}'\n`;
32
+ imports += `import Page${i + 1}_${r + 1}, { ${parser_1.HomeState.interface} as ${parser_1.HomeState.interface}${i + 1}_${r + 1}_ } from './${route.importPath}'\n`;
33
33
  }
34
34
  }
35
35
  return imports;
@@ -45,7 +45,7 @@ const entryTemplate = (options) => {
45
45
  for (let r = 0; r < routes.length; r++) {
46
46
  const route = routes[r];
47
47
  res += `
48
- pathPages_${i + 1}.set('${route.route}', function (params?: ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
48
+ pathPages_${i + 1}.set('${route.route}', function (params?: ${parser_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
49
49
  return new Page${i + 1}_${r + 1}(params)
50
50
  })
51
51
  `;
@@ -76,7 +76,7 @@ const entryTemplate = (options) => {
76
76
 
77
77
  // export function
78
78
  on
79
- } from '../node_modules/${Framework_1.tsFrameWork.name}/index'
79
+ } from '../node_modules/${parser_1.tsFrameWork.name}/index'
80
80
 
81
81
  // import app
82
82
  import AppClass from './${options.appPath}'
@@ -127,19 +127,19 @@ const generateEntryFile = function generateEntryFile(context, _, compilerOptions
127
127
  return __awaiter(this, void 0, void 0, function* () {
128
128
  const { projectPath, output } = context;
129
129
  if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
130
- ColorConsole_1.default.info(`### skip generate entry file due to --skip xts2ts}`);
130
+ shared_utils_1.ColorConsole.info(`### skip generate entry file due to --skip xts2ts}`);
131
131
  return;
132
132
  }
133
- ColorConsole_1.default.info(`Generating entry file`);
133
+ shared_utils_1.ColorConsole.info(`Generating entry file`);
134
134
  const buildDir = path_1.default.resolve(projectPath, output);
135
135
  const appManifestPath = path_1.default.join(buildDir, 'app', 'manifest.json');
136
136
  const appManifest = getManifest(appManifestPath);
137
137
  if (!appManifest) {
138
- ColorConsole_1.default.throw('not find app/manifest.json file !');
138
+ shared_utils_1.ColorConsole.throw('not find app/manifest.json file !');
139
139
  }
140
140
  const appTs = path_1.default.join(buildDir, 'app', 'app.ts');
141
141
  if (!fs_extra_1.default.existsSync(appTs)) {
142
- ColorConsole_1.default.throw('not find app/app.ts file !');
142
+ shared_utils_1.ColorConsole.throw('not find app/app.ts file !');
143
143
  }
144
144
  function relativeDist(tar) {
145
145
  return path_1.default.join('.', path_1.default.relative(buildDir, tar)).replace(path_1.default.sep, '/');
@@ -177,7 +177,7 @@ const generateEntryFile = function generateEntryFile(context, _, compilerOptions
177
177
  }
178
178
  const template = (0, exports.entryTemplate)(opt);
179
179
  fs_extra_1.default.writeFileSync(path_1.default.join(projectPath, output, exports.XtsEntryFileName), template);
180
- ColorConsole_1.default.info(`entry file built`);
180
+ shared_utils_1.ColorConsole.info(`entry file built`);
181
181
  });
182
182
  };
183
183
  exports.generateEntryFile = generateEntryFile;
@@ -1,3 +1,3 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  import { IXtsCompileOptions } from '../../interface/ICompileOptions';
3
3
  export declare const generateRpk: FollowWork<IXtsCompileOptions>;
@@ -38,12 +38,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.generateRpk = void 0;
39
39
  const path_1 = __importDefault(require("path"));
40
40
  const XtsFollowWorks_1 = __importDefault(require("../../utils/xts/XtsFollowWorks"));
41
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
41
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
42
42
  const ts2wasm_1 = require("./ts2wasm");
43
43
  const generateRpk = (context, _, compilerOptions) => __awaiter(void 0, void 0, void 0, function* () {
44
44
  var _a;
45
45
  if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('package')) {
46
- ColorConsole_1.default.info(`### skip package due to --skip ${compilerOptions.skip.join(',')}`);
46
+ shared_utils_1.ColorConsole.info(`### skip package due to --skip ${compilerOptions.skip.join(',')}`);
47
47
  return;
48
48
  }
49
49
  const manifestPath = path_1.default.resolve(context.projectPath, 'app', 'manifest.json');
@@ -1,4 +1,4 @@
1
- import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
1
+ import { FollowWork } from 'file-lane';
2
2
  import { IXtsCompileOptions } from '../../interface/ICompileOptions';
3
3
  export declare const wasmPackageName = "wasmUnpacked";
4
4
  /**
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ts2wasm = exports.wasmPackageName = void 0;
16
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
16
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
17
17
  const child_process_1 = require("child_process");
18
18
  const fast_glob_1 = __importDefault(require("fast-glob"));
19
19
  const fs_1 = __importDefault(require("fs"));
@@ -37,14 +37,14 @@ const ts2wasm = (context, _, compilerOptions) => __awaiter(void 0, void 0, void
37
37
  function compile() {
38
38
  // TODO: 后续修改为 @mi
39
39
  const ts2wasmpath = path_1.default.resolve(projectPath, 'node_modules', 'mi/wasmnizer-ts');
40
- ColorConsole_1.default.info('### Waiting for generating app.wasm file.');
40
+ shared_utils_1.ColorConsole.info('### Waiting for generating app.wasm file.');
41
41
  const res = (0, child_process_1.execSync)(`node ${ts2wasmpath}/build/cli/ts2wasm.js ${entryFile} -o ${wasmDir}/app.wasm`, {
42
42
  encoding: 'utf-8'
43
43
  });
44
- ColorConsole_1.default.info(`### ts2wasm ### ${res.toString()}`);
44
+ shared_utils_1.ColorConsole.info(`### ts2wasm ### ${res.toString()}`);
45
45
  }
46
46
  if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('ts2wasm')) {
47
- ColorConsole_1.default.info(`### skip compile ts to wasm due to --skip ${compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip.join(',')}`);
47
+ shared_utils_1.ColorConsole.info(`### skip compile ts to wasm due to --skip ${compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip.join(',')}`);
48
48
  }
49
49
  else {
50
50
  compile();
package/lib/index.d.ts CHANGED
@@ -1,2 +1,10 @@
1
1
  import XtsConfig from './config/XtsConfig';
2
- export { XtsConfig };
2
+ import JavascriptDefaultCompileOption, { setServerPort } from './compiler/javascript/JavascriptDefaultCompileOption';
3
+ import UxConfig from './config/UxConfig';
4
+ import CompileMode from './compiler/enum/CompileMode';
5
+ import IJavascriptCompileOption from './compiler/javascript/interface/IJavascriptCompileOption';
6
+ import IQuickAppConfig from './compiler/javascript/vela/interface/IQuickAppConfig';
7
+ import UxFileUtils from './utils/ux/UxFileUtils';
8
+ import IManifest from './compiler/javascript/vela/interface/IManifest';
9
+ import { ISkipList, IXtsCompileOptions, skipList } from './interface/ICompileOptions';
10
+ export { XtsConfig, UxConfig, JavascriptDefaultCompileOption, CompileMode, IJavascriptCompileOption, IQuickAppConfig, setServerPort, UxFileUtils, IManifest, skipList, IXtsCompileOptions, ISkipList };
package/lib/index.js CHANGED
@@ -1,8 +1,42 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.XtsConfig = void 0;
29
+ exports.skipList = exports.UxFileUtils = exports.setServerPort = exports.CompileMode = exports.JavascriptDefaultCompileOption = exports.UxConfig = exports.XtsConfig = void 0;
7
30
  const XtsConfig_1 = __importDefault(require("./config/XtsConfig"));
8
31
  exports.XtsConfig = XtsConfig_1.default;
32
+ const JavascriptDefaultCompileOption_1 = __importStar(require("./compiler/javascript/JavascriptDefaultCompileOption"));
33
+ exports.JavascriptDefaultCompileOption = JavascriptDefaultCompileOption_1.default;
34
+ Object.defineProperty(exports, "setServerPort", { enumerable: true, get: function () { return JavascriptDefaultCompileOption_1.setServerPort; } });
35
+ const UxConfig_1 = __importDefault(require("./config/UxConfig"));
36
+ exports.UxConfig = UxConfig_1.default;
37
+ const CompileMode_1 = __importDefault(require("./compiler/enum/CompileMode"));
38
+ exports.CompileMode = CompileMode_1.default;
39
+ const UxFileUtils_1 = __importDefault(require("./utils/ux/UxFileUtils"));
40
+ exports.UxFileUtils = UxFileUtils_1.default;
41
+ const ICompileOptions_1 = require("./interface/ICompileOptions");
42
+ Object.defineProperty(exports, "skipList", { enumerable: true, get: function () { return ICompileOptions_1.skipList; } });
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const ParserUtil_1 = __importDefault(require("@aiot-toolkit/parser/lib/utils/ParserUtil"));
7
- const ScriptParser_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/parser/ScriptParser"));
8
- const ScriptToTypescript_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/ScriptToTypescript"));
3
+ const parser_1 = require("@aiot-toolkit/parser");
4
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
9
5
  /**
10
6
  * JsLoader
11
7
  */
12
8
  class JsLoader {
13
9
  parser(files) {
14
- const project = ParserUtil_1.default.createProject();
15
10
  const onLog = () => { };
16
11
  return files.map((item) => {
17
12
  if (!item.content) {
@@ -24,13 +19,14 @@ class JsLoader {
24
19
  filePath: item.path,
25
20
  projectPath: this.context.projectPath,
26
21
  content: item.content.toString(),
22
+ projectType: shared_utils_1.ProjectType.getProjectType(this.context.projectPath),
27
23
  onLog
28
24
  };
29
25
  return {
30
26
  path: item.path,
31
- content: new ScriptToTypescript_1.default(project, options, this.compilerOption)
27
+ content: new parser_1.ScriptToTypescript(options, this.compilerOption, this.context)
32
28
  .translate({
33
- content: new ScriptParser_1.default(options).parser(item.content.toString()).ast.content
29
+ content: new parser_1.ScriptParser(options).parser(item.content.toString()).ast.content
34
30
  }, [])
35
31
  .targetTree.getFullText()
36
32
  };
@@ -12,8 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
16
- const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
15
+ const shared_utils_1 = require("@aiot-toolkit/shared-utils");
17
16
  const path_1 = __importDefault(require("path"));
18
17
  const PngUtils_1 = __importDefault(require("../../utils/PngUtils"));
19
18
  const aaptjs = require('@hap-toolkit/aaptjs');
@@ -30,11 +29,11 @@ class PngLoader {
30
29
  const fullName = `${name}${ext}`;
31
30
  //判断文本,空文本则结束该文件处理
32
31
  if (!content) {
33
- ColorConsole_1.default.warn(`The file '${fullName}' under the path '${filePath}' has no content `);
32
+ shared_utils_1.ColorConsole.warn(`The file '${fullName}' under the path '${filePath}' has no content `);
34
33
  return [];
35
34
  }
36
35
  // 判断传入的.png资源是不是.9.png资源
37
- if (FileUtil_1.default.match(filePath, /.+\.9\.png$/)) {
36
+ if (shared_utils_1.FileUtil.match(filePath, /.+\.9\.png$/)) {
38
37
  yield this.compile9Png(filePath);
39
38
  }
40
39
  else {
@@ -54,7 +53,7 @@ class PngLoader {
54
53
  yield aaptjs.singleCrunch(filePath, outputFile);
55
54
  }
56
55
  catch (error) {
57
- ColorConsole_1.default.throw(`.9.png resource file processing failed`);
56
+ shared_utils_1.ColorConsole.throw(`.9.png resource file processing failed`);
58
57
  }
59
58
  }
60
59
  });
@@ -0,0 +1,11 @@
1
+ import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
+ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
3
+ /**
4
+ * UxLoader
5
+ */
6
+ declare class UxLoader implements ILoader {
7
+ context: IFileLaneContext;
8
+ compilerOption: IJavascriptCompileOption;
9
+ parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
10
+ }
11
+ export default UxLoader;