@aiot-toolkit/aiotpack 2.0.1-alpha.9 → 2.0.2-beta.2

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 (113) 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 +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.d.ts +1 -2
  13. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +0 -5
  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 +2 -4
  26. package/lib/compiler/javascript/vela/utils/ZipUtil.js +5 -7
  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 +58 -0
  34. package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +3 -0
  35. package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.js +20 -0
  36. package/lib/config/UxConfig.d.ts +7 -4
  37. package/lib/config/UxConfig.js +44 -12
  38. package/lib/config/XtsConfig.d.ts +3 -1
  39. package/lib/config/XtsConfig.js +11 -3
  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 +1 -3
  52. package/lib/loader/ux/JsLoader.d.ts +9 -0
  53. package/lib/loader/ux/JsLoader.js +39 -0
  54. package/lib/loader/ux/PngLoader.js +4 -9
  55. package/lib/loader/ux/UxLoader.d.ts +2 -0
  56. package/lib/loader/ux/UxLoader.js +15 -4
  57. package/lib/loader/xts/XtsLoader.js +3 -9
  58. package/lib/preWorks/ux/UxPreWorks.d.ts +10 -0
  59. package/lib/preWorks/ux/UxPreWorks.js +31 -0
  60. package/lib/preWorks/xts/preInstall.js +4 -12
  61. package/lib/utils/PngUtils.js +0 -2
  62. package/lib/utils/PreWorkUtils.d.ts +5 -0
  63. package/lib/utils/PreWorkUtils.js +40 -9
  64. package/lib/utils/ux/ManifestSchema.d.ts +3 -0
  65. package/lib/utils/ux/ManifestSchema.js +207 -0
  66. package/lib/utils/ux/UxFileUtils.d.ts +21 -4
  67. package/lib/utils/ux/UxFileUtils.js +74 -5
  68. package/lib/utils/ux/UxLoaderUtils.d.ts +11 -7
  69. package/lib/utils/ux/UxLoaderUtils.js +119 -33
  70. package/lib/utils/xts/XtsFollowWorks.js +3 -12
  71. package/package.json +6 -10
  72. package/lib/compiler/enum/CompileMode.js.map +0 -1
  73. package/lib/compiler/interface/ICompileParam.js.map +0 -1
  74. package/lib/compiler/interface/ICompiler.js.map +0 -1
  75. package/lib/compiler/interface/ISignConfig.js.map +0 -1
  76. package/lib/compiler/javascript/JavascriptCompiler.js.map +0 -1
  77. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +0 -1
  78. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +0 -1
  79. package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +0 -1
  80. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +0 -1
  81. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +0 -1
  82. package/lib/compiler/javascript/vela/enum/EntryType.js.map +0 -1
  83. package/lib/compiler/javascript/vela/interface/IChunk.js.map +0 -1
  84. package/lib/compiler/javascript/vela/interface/IManifest.js.map +0 -1
  85. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +0 -1
  86. package/lib/compiler/javascript/vela/model/Package.js.map +0 -1
  87. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +0 -1
  88. package/lib/compiler/javascript/vela/utils/Jsc.js.map +0 -1
  89. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +0 -1
  90. package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +0 -1
  91. package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +0 -1
  92. package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +0 -1
  93. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +0 -1
  94. package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +0 -1
  95. package/lib/config/UxConfig.js.map +0 -1
  96. package/lib/config/XtsConfig.js.map +0 -1
  97. package/lib/followWorks/xts/entryTemplate.js.map +0 -1
  98. package/lib/followWorks/xts/generateRpk.js.map +0 -1
  99. package/lib/followWorks/xts/ts2wasm.js.map +0 -1
  100. package/lib/index.js.map +0 -1
  101. package/lib/interface/ICompileOptions.js.map +0 -1
  102. package/lib/interface/IDeviceList.js.map +0 -1
  103. package/lib/loader/ux/AppUxLoader.js.map +0 -1
  104. package/lib/loader/ux/PngLoader.js.map +0 -1
  105. package/lib/loader/ux/UxLoader.js.map +0 -1
  106. package/lib/loader/xts/XtsLoader.js.map +0 -1
  107. package/lib/preWorks/xts/preInstall.js.map +0 -1
  108. package/lib/utils/PngUtils.js.map +0 -1
  109. package/lib/utils/PreWorkUtils.js.map +0 -1
  110. package/lib/utils/ux/UxFileUtils.js.map +0 -1
  111. package/lib/utils/ux/UxFollowWorks.js.map +0 -1
  112. package/lib/utils/ux/UxLoaderUtils.js.map +0 -1
  113. package/lib/utils/xts/XtsFollowWorks.js.map +0 -1
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const SourceMapUtil_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/utils/SourceMapUtil"));
16
+ function addColSourceMap(source, map) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const callback = this.async();
19
+ if (!map) {
20
+ callback(null, source, map);
21
+ }
22
+ let { consumer, tempGenerator } = yield SourceMapUtil_1.default.createConsumerAndGenerator(JSON.stringify(map));
23
+ let recordLine = -1;
24
+ consumer.eachMapping(mapping => {
25
+ if (mapping.source === consumer.sources[consumer.sources.length - 1]) {
26
+ if (recordLine < mapping.generatedLine && (mapping.generatedColumn !== 0 || mapping.originalColumn !== 0)) {
27
+ tempGenerator.addMapping({
28
+ generated: {
29
+ line: mapping.generatedLine,
30
+ column: 0
31
+ },
32
+ original: {
33
+ line: mapping.originalLine,
34
+ column: 0
35
+ },
36
+ source: mapping.source,
37
+ name: ''
38
+ });
39
+ }
40
+ recordLine = mapping.generatedLine;
41
+ }
42
+ tempGenerator.addMapping({
43
+ generated: {
44
+ line: mapping.generatedLine,
45
+ column: mapping.generatedColumn
46
+ },
47
+ original: {
48
+ line: mapping.originalLine,
49
+ column: mapping.originalColumn
50
+ },
51
+ source: mapping.source,
52
+ name: mapping.name
53
+ });
54
+ });
55
+ callback(null, source, JSON.parse(tempGenerator.toString()));
56
+ });
57
+ }
58
+ exports.default = addColSourceMap;
@@ -0,0 +1,3 @@
1
+ import { LoaderContext } from 'webpack';
2
+ declare function splitMap(this: LoaderContext<any>, source: string, map: any): void;
3
+ export default splitMap;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
8
+ function splitMap(source, map) {
9
+ const enterFilePath = this.resourcePath;
10
+ // 获取当前文件夹和文件名
11
+ const dirName = path_1.default.dirname(enterFilePath);
12
+ const fileName = path_1.default.basename(enterFilePath);
13
+ // 取到对应的map文件内容
14
+ const mapFilePath = path_1.default.join(dirName, fileName + '.map');
15
+ if (fs_1.default.existsSync(mapFilePath)) {
16
+ map = fs_1.default.readFileSync(mapFilePath, { encoding: 'utf-8' });
17
+ }
18
+ this.callback(null, source, map && JSON.parse(map));
19
+ }
20
+ exports.default = splitMap;
@@ -1,13 +1,12 @@
1
1
  import { IFileLaneConfig } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
3
3
  import AppUxLoader from '../loader/ux/AppUxLoader';
4
- import PngLoader from '../loader/ux/PngLoader';
4
+ import JsLoader from '../loader/ux/JsLoader';
5
5
  import UxLoader from '../loader/ux/UxLoader';
6
6
  declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
7
7
  readonly projectPath: string;
8
8
  constructor(projectPath: string);
9
9
  exclude: RegExp[];
10
- include: RegExp[];
11
10
  get output(): string;
12
11
  module: {
13
12
  rules: ({
@@ -20,11 +19,15 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
20
19
  loader: (typeof UxLoader)[];
21
20
  } | {
22
21
  test: RegExp[];
23
- loader: (typeof PngLoader)[];
22
+ loader: (typeof JsLoader)[];
24
23
  exclude?: undefined;
25
24
  })[];
26
25
  };
27
26
  preWorks: import("file-lane/lib/interface/IFileLaneConfig").PreWork<IJavascriptCompileOption>[];
28
- followWorks: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<IJavascriptCompileOption>[];
27
+ followWorks: {
28
+ worker: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<IJavascriptCompileOption>;
29
+ workerDescribe: string;
30
+ }[];
31
+ watchIgnores: RegExp[];
29
32
  }
30
33
  export default UxConfig;
@@ -5,15 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const AppUxLoader_1 = __importDefault(require("../loader/ux/AppUxLoader"));
8
+ const JsLoader_1 = __importDefault(require("../loader/ux/JsLoader"));
8
9
  const PngLoader_1 = __importDefault(require("../loader/ux/PngLoader"));
9
10
  const UxLoader_1 = __importDefault(require("../loader/ux/UxLoader"));
10
11
  const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
11
- const UxFollowWorks_1 = __importDefault(require("../utils/ux/UxFollowWorks"));
12
+ const UxFollowWorks_1 = __importDefault(require("../followWorks/ux/UxFollowWorks"));
13
+ const UxPreWorks_1 = __importDefault(require("../preWorks/ux/UxPreWorks"));
12
14
  class UxConfig {
13
15
  constructor(projectPath) {
14
16
  this.projectPath = projectPath;
15
17
  this.exclude = [/node_modules/, /dist/, /build/];
16
- this.include = [/src/];
17
18
  this.module = {
18
19
  rules: [
19
20
  {
@@ -26,20 +27,53 @@ class UxConfig {
26
27
  loader: [UxLoader_1.default]
27
28
  },
28
29
  {
29
- test: [/.+\.png/],
30
+ test: [/.+\.js$/],
31
+ loader: [JsLoader_1.default]
32
+ },
33
+ {
34
+ test: [/.+\.9.png/],
30
35
  loader: [PngLoader_1.default]
31
36
  }
32
37
  ]
33
38
  };
34
- this.preWorks = [PreWorkUtils_1.default.clean, PreWorkUtils_1.default.getEntries];
39
+ this.preWorks = [
40
+ UxPreWorks_1.default.validateManifest,
41
+ UxPreWorks_1.default.validateSitemap,
42
+ PreWorkUtils_1.default.clean,
43
+ PreWorkUtils_1.default.getEntries,
44
+ PreWorkUtils_1.default.getGlobalVar
45
+ ];
35
46
  this.followWorks = [
36
- UxFollowWorks_1.default.symlinkNodeModule,
37
- UxFollowWorks_1.default.webpack,
38
- UxFollowWorks_1.default.copyResource,
39
- UxFollowWorks_1.default.jsc,
40
- UxFollowWorks_1.default.toRpk,
41
- UxFollowWorks_1.default.moveBackResult
47
+ {
48
+ worker: UxFollowWorks_1.default.symlinkNodeModule,
49
+ workerDescribe: 'Create a soft link to the node_modules folder'
50
+ },
51
+ {
52
+ worker: UxFollowWorks_1.default.webpack,
53
+ workerDescribe: 'Compile the project using webpack'
54
+ },
55
+ {
56
+ worker: UxFollowWorks_1.default.copyResource,
57
+ workerDescribe: 'Copy resource files'
58
+ },
59
+ {
60
+ worker: UxFollowWorks_1.default.jsc,
61
+ workerDescribe: 'Generate jsc bytecode'
62
+ },
63
+ {
64
+ worker: UxFollowWorks_1.default.protobuf,
65
+ workerDescribe: 'Generate protobuf json'
66
+ },
67
+ {
68
+ worker: UxFollowWorks_1.default.toRpk,
69
+ workerDescribe: 'Package the project into an RPK file'
70
+ },
71
+ {
72
+ worker: UxFollowWorks_1.default.moveBackResult,
73
+ workerDescribe: 'Migrate temporary project'
74
+ }
42
75
  ];
76
+ this.watchIgnores = [/node_modules/];
43
77
  }
44
78
  get output() {
45
79
  const name = path_1.default.basename(this.projectPath);
@@ -48,5 +82,3 @@ class UxConfig {
48
82
  }
49
83
  }
50
84
  exports.default = UxConfig;
51
-
52
- //# sourceMappingURL=UxConfig.js.map
@@ -13,6 +13,8 @@ declare class XtsConfig implements IFileLaneConfig {
13
13
  }[];
14
14
  };
15
15
  preWorks: import("file-lane/lib/interface/IFileLaneConfig").PreWork<import("../interface/ICompileOptions").IXtsCompileOptions>[];
16
- followWorks: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<import("../interface/ICompileOptions").IXtsCompileOptions>[];
16
+ followWorks: {
17
+ worker: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<import("../interface/ICompileOptions").IXtsCompileOptions>;
18
+ }[];
17
19
  }
18
20
  export default XtsConfig;
@@ -24,9 +24,17 @@ class XtsConfig {
24
24
  ]
25
25
  };
26
26
  this.preWorks = [preInstall_1.preInstall];
27
- this.followWorks = [entryTemplate_1.generateEntryFile, ts2wasm_1.ts2wasm, generateRpk_1.generateRpk];
27
+ this.followWorks = [
28
+ {
29
+ worker: entryTemplate_1.generateEntryFile
30
+ },
31
+ {
32
+ worker: ts2wasm_1.ts2wasm
33
+ },
34
+ {
35
+ worker: generateRpk_1.generateRpk
36
+ }
37
+ ];
28
38
  }
29
39
  }
30
40
  exports.default = XtsConfig;
31
-
32
- //# sourceMappingURL=XtsConfig.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,9 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
18
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
16
19
  const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
17
20
  const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
18
21
  const fs_extra_1 = __importDefault(require("fs-extra"));
@@ -23,7 +26,8 @@ const JavascriptCompiler_1 = __importDefault(require("../../compiler/javascript/
23
26
  const JavascriptDefaultCompileOption_1 = __importDefault(require("../../compiler/javascript/JavascriptDefaultCompileOption"));
24
27
  const Jsc_1 = __importDefault(require("../../compiler/javascript/vela/utils/Jsc"));
25
28
  const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
26
- const UxFileUtils_1 = __importDefault(require("./UxFileUtils"));
29
+ const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
30
+ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
27
31
  /**
28
32
  * UxFollowWorks
29
33
  */
@@ -31,10 +35,50 @@ class UxFollowWorks {
31
35
  }
32
36
  _a = UxFollowWorks;
33
37
  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));
38
+ return new JavascriptCompiler_1.default()
39
+ .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
+ .then(() => {
41
+ ColorConsole_1.default.info(`webpack complete`);
42
+ })
43
+ .catch(({ errors, warnings }) => {
44
+ const errorLength = (errors === null || errors === void 0 ? void 0 : errors.length) || 0;
45
+ const messages = [`webpack error:\r\n`];
46
+ if (errors === null || errors === void 0 ? void 0 : errors.length) {
47
+ messages.push({
48
+ word: errors
49
+ .map((item, index) => {
50
+ return `${index + 1}. ${item.message}`;
51
+ })
52
+ .join('\r\n'),
53
+ style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
54
+ });
55
+ }
56
+ if (warnings === null || warnings === void 0 ? void 0 : warnings.length) {
57
+ messages.push({
58
+ word: warnings
59
+ .map((item, index) => {
60
+ return `${errorLength + index + 1}. ${item.message}`;
61
+ })
62
+ .join('\r\n'),
63
+ style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Warn)
64
+ });
65
+ }
66
+ if (errors === null || errors === void 0 ? void 0 : errors.length) {
67
+ ColorConsole_1.default.throw(...messages);
68
+ throw new Error();
69
+ }
70
+ else {
71
+ ColorConsole_1.default.warn(...messages);
72
+ }
73
+ });
74
+ });
75
+ UxFollowWorks.protobuf = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
76
+ if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
77
+ BinaryPlugin.createBinFiles();
78
+ }
35
79
  });
36
80
  UxFollowWorks.jsc = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
37
- if (compilerOption && !compilerOption.disabledJSC) {
81
+ if (compilerOption && compilerOption.disabledJSC === false) {
38
82
  return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
39
83
  }
40
84
  });
@@ -54,6 +98,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
54
98
  const { projectPath, sourceRoot, outputPath } = compilerOption;
55
99
  const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
56
100
  const { deviceTypeList } = manifest;
101
+ // 生成设备的 manifest 文件,规则为:manifest.json + config-设备类型.json
57
102
  if (deviceTypeList) {
58
103
  deviceTypeList.forEach((deviceType) => {
59
104
  let data = Object.assign({}, manifest);
@@ -87,7 +132,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
87
132
  'md',
88
133
  'ux',
89
134
  'mix',
90
- 'DS_Store'
135
+ 'DS_Store',
136
+ 'map'
91
137
  ];
92
138
  const excludeReg = `\.(${excludeExtList.join('|')})$`;
93
139
  FileUtil_1.default.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
@@ -108,6 +154,15 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
108
154
  if (!content.packageInfo) {
109
155
  content.packageInfo = ZipUtil_1.default.createComment(compilerOption);
110
156
  }
157
+ if (TranslateCache_1.default.featureCache.size) {
158
+ const featureSet = new Set([
159
+ ...Array.from(TranslateCache_1.default.featureCache),
160
+ ...(content.features || []).map((item) => item.name)
161
+ ]);
162
+ content.features = Array.from(featureSet).map((item) => {
163
+ return { name: item };
164
+ });
165
+ }
111
166
  fs_extra_1.default.writeJSONSync(path_1.default.join(projectPath, outputPath, UxFileUtils_1.default.CONFIG_FILE_NAME), content, {
112
167
  spaces: 2
113
168
  });
@@ -141,8 +196,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
141
196
  });
142
197
  if (compilerOption) {
143
198
  copyResourceFiles(compilerOption);
144
- genDeviceManifests(compilerOption);
145
199
  updateManifest(compilerOption);
200
+ genDeviceManifests(compilerOption);
146
201
  yield genMetaFiles(compilerOption);
147
202
  }
148
203
  });
@@ -187,14 +242,17 @@ UxFollowWorks.symlinkNodeModule = (context, config, compilerOption) => __awaiter
187
242
  if (!compilerOption) {
188
243
  return;
189
244
  }
190
- const foldList = ['node_modules'];
191
- foldList.forEach((item) => {
192
- const sourcePath = path_1.default.join(context.projectPath, item);
193
- if (fs_extra_1.default.existsSync(sourcePath)) {
194
- fs_extra_1.default.symlinkSync(sourcePath, path_1.default.join(compilerOption.projectPath, item));
195
- }
196
- });
245
+ try {
246
+ const foldList = ['node_modules'];
247
+ foldList.forEach((item) => {
248
+ 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');
251
+ }
252
+ });
253
+ }
254
+ catch (error) {
255
+ throw new Error(`${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}. Please check whether the file system of the current disk supports the creation of soft links.`);
256
+ }
197
257
  });
198
258
  exports.default = UxFollowWorks;
199
-
200
- //# sourceMappingURL=UxFollowWorks.js.map
@@ -1,4 +1,4 @@
1
- import { IFileLaneContext } from 'file-lane';
1
+ import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
2
2
  export interface Aspects {
3
3
  path: string;
4
4
  name: string;
@@ -18,4 +18,4 @@ export declare const XtsEntryFileName = "__entry__.ts";
18
18
  * 生成 __entry__.ts 文件
19
19
  * @param context
20
20
  */
21
- export declare function generateEntryFile(context: IFileLaneContext): Promise<void>;
21
+ export declare const generateEntryFile: FollowWork;
@@ -14,9 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.generateEntryFile = exports.XtsEntryFileName = exports.entryTemplate = void 0;
16
16
  const Framework_1 = require("@aiot-toolkit/parser/lib/xts/enum/Framework");
17
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
18
17
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
19
- const fast_glob_1 = __importDefault(require("fast-glob"));
20
18
  const fs_extra_1 = __importDefault(require("fs-extra"));
21
19
  const path_1 = __importDefault(require("path"));
22
20
  const entryTemplate = (options) => {
@@ -41,20 +39,24 @@ const entryTemplate = (options) => {
41
39
  for (let i = 0; i < aspects.length; i++) {
42
40
  const aspect = aspects[i];
43
41
  const { routes = [] } = aspect;
42
+ res += `
43
+ const aspectName_${i + 1} = '${aspect.name}'
44
+ const pathPages_${i + 1} = new Map()`;
44
45
  for (let r = 0; r < routes.length; r++) {
45
46
  const route = routes[r];
46
47
  res += `
47
- const pathPages${i + 1}_${r + 1} = new Map()
48
- pathPages${i + 1}_${r + 1}.set('${route.route}', function (params?: ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
48
+ pathPages_${i + 1}.set('${route.route}', function (params?: ${Framework_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
49
49
  return new Page${i + 1}_${r + 1}(params)
50
50
  })
51
- const aspectName_${i + 1} = '${aspect.name}'
51
+ `;
52
+ }
53
+ res += `
52
54
  const aspectDef_${i + 1}: AspectDefinition = {
53
55
  newFn: (): ViewAspect => new AspectClass${i + 1}(),
54
- pathPages: pathPages${i + 1}_${r + 1}
56
+ pathPages: pathPages_${i + 1}
55
57
  }
56
- aspectDefs.set(aspectName_${i + 1}, aspectDef_${i + 1})`;
57
- }
58
+ aspectDefs.set(aspectName_${i + 1}, aspectDef_${i + 1})
59
+ `;
58
60
  }
59
61
  return res;
60
62
  }
@@ -110,57 +112,72 @@ export { entry, on }
110
112
  `;
111
113
  };
112
114
  exports.entryTemplate = entryTemplate;
115
+ function getManifest(manifestPath) {
116
+ const content = fs_extra_1.default.readFileSync(manifestPath, 'utf-8');
117
+ const data = JSON.parse(content);
118
+ return data;
119
+ }
113
120
  exports.XtsEntryFileName = '__entry__.ts';
114
121
  /**
115
122
  * 生成 __entry__.ts 文件
116
123
  * @param context
117
124
  */
118
- function generateEntryFile(context) {
119
- var _a, _b, _c;
125
+ const generateEntryFile = function generateEntryFile(context, _, compilerOptions) {
126
+ var _a, _b;
120
127
  return __awaiter(this, void 0, void 0, function* () {
121
128
  const { projectPath, output } = context;
122
- ColorConsole_1.default.log({
123
- level: shared_utils_1.LOG_LEVEL.Info,
124
- message: `Generating entry file`
125
- });
126
- const dist = path_1.default.resolve(projectPath, output);
127
- const manifests = yield (0, fast_glob_1.default)(`${fast_glob_1.default.convertPathToPattern(dist)}/**/manifest.json`);
128
- function relativeDist(tar) {
129
- return path_1.default.join('.', path_1.default.relative(dist, tar)).replace(path_1.default.sep, '/');
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}`);
131
+ return;
132
+ }
133
+ ColorConsole_1.default.info(`Generating entry file`);
134
+ const buildDir = path_1.default.resolve(projectPath, output);
135
+ const appManifestPath = path_1.default.join(buildDir, 'app', 'manifest.json');
136
+ const appManifest = getManifest(appManifestPath);
137
+ if (!appManifest) {
138
+ ColorConsole_1.default.throw('not find app/manifest.json file !');
130
139
  }
131
- const appTs = yield (0, fast_glob_1.default)(`${fast_glob_1.default.convertPathToPattern(dist)}/**/app.ts`);
132
- if (appTs.length !== 1) {
133
- ColorConsole_1.default.log({ level: shared_utils_1.LOG_LEVEL.Error, message: 'app.ts can only have one!' });
140
+ const appTs = path_1.default.join(buildDir, 'app', 'app.ts');
141
+ if (!fs_extra_1.default.existsSync(appTs)) {
142
+ ColorConsole_1.default.throw('not find app/app.ts file !');
143
+ }
144
+ function relativeDist(tar) {
145
+ return path_1.default.join('.', path_1.default.relative(buildDir, tar)).replace(path_1.default.sep, '/');
134
146
  }
135
147
  let opt = {
136
- appPath: relativeDist(appTs[0].replace('.ts', '')),
148
+ appPath: relativeDist(appTs.replace('.ts', '')),
137
149
  aspects: []
138
150
  };
139
- for (const manifest of manifests) {
140
- const content = fs_extra_1.default.readFileSync(manifest, 'utf-8');
141
- const data = JSON.parse(content);
142
- if ((_a = data === null || data === void 0 ? void 0 : data.router) === null || _a === void 0 ? void 0 : _a.pages) {
143
- (_b = opt.aspects) === null || _b === void 0 ? void 0 : _b.push({
144
- name: data.name,
145
- path: relativeDist(path_1.default.resolve(path_1.default.dirname(manifest), 'aspect')),
146
- routes: Object.entries((_c = data === null || data === void 0 ? void 0 : data.router) === null || _c === void 0 ? void 0 : _c.pages).map(([k, v]) => {
147
- return {
148
- importPath: relativeDist(path_1.default.resolve(path_1.default.dirname(manifest), v.path)),
149
- name: k,
150
- route: v.path
151
- };
152
- })
151
+ function getAspectRoutes(aspectPath) {
152
+ var _a;
153
+ const aspectManifestPath = path_1.default.join(aspectPath, 'src', 'manifest.json');
154
+ const aspectManifest = getManifest(aspectManifestPath);
155
+ if (!((_a = aspectManifest === null || aspectManifest === void 0 ? void 0 : aspectManifest.router) === null || _a === void 0 ? void 0 : _a.pages))
156
+ return [];
157
+ return Object.entries(aspectManifest.router.pages).map(([k, v]) => {
158
+ return {
159
+ importPath: relativeDist(path_1.default.resolve(path_1.default.dirname(aspectManifestPath), v.path)),
160
+ name: k,
161
+ route: v.path
162
+ };
163
+ });
164
+ }
165
+ if ((_b = appManifest === null || appManifest === void 0 ? void 0 : appManifest.router) === null || _b === void 0 ? void 0 : _b.aspects) {
166
+ Object.entries(appManifest.router.aspects).forEach(([name, aspects]) => {
167
+ aspects.forEach((aspect) => {
168
+ var _a;
169
+ const aspectPath = path_1.default.join(buildDir, aspect.path);
170
+ (_a = opt.aspects) === null || _a === void 0 ? void 0 : _a.push({
171
+ name: name,
172
+ path: relativeDist(path_1.default.resolve(buildDir, aspect.path, 'src', 'aspect')),
173
+ routes: getAspectRoutes(aspectPath)
174
+ });
153
175
  });
154
- }
176
+ });
155
177
  }
156
178
  const template = (0, exports.entryTemplate)(opt);
157
179
  fs_extra_1.default.writeFileSync(path_1.default.join(projectPath, output, exports.XtsEntryFileName), template);
158
- ColorConsole_1.default.log({
159
- level: shared_utils_1.LOG_LEVEL.Info,
160
- message: `Entry file built`
161
- });
180
+ ColorConsole_1.default.info(`entry file built`);
162
181
  });
163
- }
182
+ };
164
183
  exports.generateEntryFile = generateEntryFile;
165
-
166
- //# sourceMappingURL=entryTemplate.js.map
@@ -43,7 +43,7 @@ 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.log({ message: `skip package due to --skip ${compilerOptions.skip.join(',')}` });
46
+ ColorConsole_1.default.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');
@@ -54,5 +54,3 @@ const generateRpk = (context, _, compilerOptions) => __awaiter(void 0, void 0, v
54
54
  });
55
55
  });
56
56
  exports.generateRpk = generateRpk;
57
-
58
- //# sourceMappingURL=generateRpk.js.map
@@ -13,7 +13,6 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
17
16
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
18
17
  const child_process_1 = require("child_process");
19
18
  const fast_glob_1 = __importDefault(require("fast-glob"));
@@ -38,22 +37,14 @@ const ts2wasm = (context, _, compilerOptions) => __awaiter(void 0, void 0, void
38
37
  function compile() {
39
38
  // TODO: 后续修改为 @mi
40
39
  const ts2wasmpath = path_1.default.resolve(projectPath, 'node_modules', 'mi/wasmnizer-ts');
41
- ColorConsole_1.default.log({
42
- level: shared_utils_1.LOG_LEVEL.Info,
43
- message: 'Waiting for generating app.wasm file.'
44
- });
40
+ ColorConsole_1.default.info('### Waiting for generating app.wasm file.');
45
41
  const res = (0, child_process_1.execSync)(`node ${ts2wasmpath}/build/cli/ts2wasm.js ${entryFile} -o ${wasmDir}/app.wasm`, {
46
42
  encoding: 'utf-8'
47
43
  });
48
- ColorConsole_1.default.log({
49
- level: shared_utils_1.LOG_LEVEL.Info,
50
- message: res
51
- });
44
+ ColorConsole_1.default.info(`### ts2wasm ### ${res.toString()}`);
52
45
  }
53
46
  if ((_a = compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip) === null || _a === void 0 ? void 0 : _a.includes('ts2wasm')) {
54
- ColorConsole_1.default.log({
55
- message: `skip compile ts to wasm due to --skip ${compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip.join(',')}`
56
- });
47
+ ColorConsole_1.default.info(`### skip compile ts to wasm due to --skip ${compilerOptions === null || compilerOptions === void 0 ? void 0 : compilerOptions.skip.join(',')}`);
57
48
  }
58
49
  else {
59
50
  compile();
@@ -76,5 +67,3 @@ const ts2wasm = (context, _, compilerOptions) => __awaiter(void 0, void 0, void
76
67
  fs_1.default.copyFileSync(path_1.default.resolve(fast_glob_1.default.convertPathToPattern(projectPath), output, 'app', 'manifest.json'), path_1.default.resolve(fast_glob_1.default.convertPathToPattern(projectPath), exports.wasmPackageName, 'manifest.json'));
77
68
  });
78
69
  exports.ts2wasm = ts2wasm;
79
-
80
- //# sourceMappingURL=ts2wasm.js.map
package/lib/index.js CHANGED
@@ -6,5 +6,3 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.XtsConfig = void 0;
7
7
  const XtsConfig_1 = __importDefault(require("./config/XtsConfig"));
8
8
  exports.XtsConfig = XtsConfig_1.default;
9
-
10
- //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- export declare const skipList: readonly ["install", "ts2wasm", "package"];
1
+ export declare const skipList: readonly ["xts2ts", "install", "ts2wasm", "package"];
2
2
  export type ISkipList = typeof skipList;
3
3
  export interface IXtsCompileOptions {
4
4
  watch?: boolean;
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.skipList = void 0;
4
- exports.skipList = ['install', 'ts2wasm', 'package'];
5
-
6
- //# sourceMappingURL=ICompileOptions.js.map
4
+ exports.skipList = ['xts2ts', 'install', 'ts2wasm', 'package'];
@@ -1,4 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
-
4
- //# sourceMappingURL=IDeviceList.js.map