@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
@@ -1,10 +1,12 @@
1
1
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
+ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
2
3
  /**
3
4
  * 处理app.ux的Loader
4
5
  * AppUxLoader
5
6
  */
6
7
  declare class AppUxLoader implements ILoader {
7
8
  context: IFileLaneContext;
9
+ compilerOption: IJavascriptCompileOption;
8
10
  parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
9
11
  }
10
12
  export default AppUxLoader;
@@ -21,11 +21,9 @@ class AppUxLoader {
21
21
  parser(files) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
23
  const resultFiles = [];
24
- yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], resultFiles, this.context);
24
+ yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], resultFiles, this.context, this.compilerOption);
25
25
  return resultFiles;
26
26
  });
27
27
  }
28
28
  }
29
29
  exports.default = AppUxLoader;
30
-
31
- //# sourceMappingURL=AppUxLoader.js.map
@@ -0,0 +1,9 @@
1
+ import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
+ /**
3
+ * JsLoader
4
+ */
5
+ declare class JsLoader implements ILoader {
6
+ context: IFileLaneContext;
7
+ parser(files: IFileParam<any>[]): IFileParam<any>[] | Promise<IFileParam<any>[]>;
8
+ }
9
+ export default JsLoader;
@@ -0,0 +1,39 @@
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 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"));
9
+ /**
10
+ * JsLoader
11
+ */
12
+ class JsLoader {
13
+ parser(files) {
14
+ const project = ParserUtil_1.default.createProject();
15
+ const onLog = () => { };
16
+ return files.map((item) => {
17
+ if (!item.content) {
18
+ return {
19
+ path: item.path,
20
+ content: item.content
21
+ };
22
+ }
23
+ const options = {
24
+ filePath: item.path,
25
+ projectPath: this.context.projectPath,
26
+ onLog
27
+ };
28
+ return {
29
+ path: item.path,
30
+ content: new ScriptToTypescript_1.default(project, options)
31
+ .translate({
32
+ content: new ScriptParser_1.default(options).parser(item.content.toString()).ast.content
33
+ }, [])
34
+ .targetTree.getFullText()
35
+ };
36
+ });
37
+ }
38
+ }
39
+ exports.default = JsLoader;
@@ -12,7 +12,6 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
15
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
17
16
  const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
18
17
  const path_1 = __importDefault(require("path"));
@@ -31,10 +30,7 @@ class PngLoader {
31
30
  const fullName = `${name}${ext}`;
32
31
  //判断文本,空文本则结束该文件处理
33
32
  if (!content) {
34
- ColorConsole_1.default.log({
35
- level: shared_utils_1.LOG_LEVEL.Warn,
36
- message: `【XtsLoader】the file '${fullName}' under the path '${filePath}' has no content `
37
- });
33
+ ColorConsole_1.default.warn(`The file '${fullName}' under the path '${filePath}' has no content `);
38
34
  return [];
39
35
  }
40
36
  // 判断传入的.png资源是不是.9.png资源
@@ -58,13 +54,12 @@ class PngLoader {
58
54
  yield aaptjs.singleCrunch(filePath, outputFile);
59
55
  }
60
56
  catch (error) {
61
- // 报错
62
- console.error('.9.png资源文件优化失败', error);
57
+ ColorConsole_1.default.throw(`.9.png resource file processing failed`);
63
58
  }
64
59
  }
65
60
  });
66
61
  }
67
62
  }
63
+ ;
64
+ PngLoader.raw = true;
68
65
  exports.default = PngLoader;
69
-
70
- //# sourceMappingURL=PngLoader.js.map
@@ -1,6 +1,8 @@
1
1
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
+ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
2
3
  declare class UxLoader implements ILoader {
3
4
  context: IFileLaneContext;
5
+ compilerOption: IJavascriptCompileOption;
4
6
  parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
5
7
  }
6
8
  export default UxLoader;
@@ -12,20 +12,31 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
16
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
17
+ const path_1 = __importDefault(require("path"));
15
18
  const UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"));
16
19
  class UxLoader {
17
20
  parser(files) {
18
21
  return __awaiter(this, void 0, void 0, function* () {
19
22
  const resultFiles = [];
23
+ const { projectPath } = this.context;
20
24
  for (const file of files) {
21
25
  // 转换每个文件
22
- const compileFiles = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false);
23
- resultFiles.push(...compileFiles);
26
+ const { files, logs } = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false, this.compilerOption);
27
+ if (logs) {
28
+ logs.forEach((item) => {
29
+ ColorConsole_1.default.logger(Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' }));
30
+ });
31
+ // 如果有 error throw,则停止
32
+ if (logs.some((item) => item.level && [shared_utils_1.LOG_LEVEL.Throw].includes(item.level))) {
33
+ throw new Error('stop!');
34
+ }
35
+ }
36
+ resultFiles.push(...files);
24
37
  }
25
38
  return resultFiles;
26
39
  });
27
40
  }
28
41
  }
29
42
  exports.default = UxLoader;
30
-
31
- //# sourceMappingURL=UxLoader.js.map
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const generator_1 = require("@aiot-toolkit/generator");
7
7
  const parser_1 = require("@aiot-toolkit/parser");
8
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
9
8
  const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
10
9
  const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
11
10
  const path_1 = __importDefault(require("path"));
@@ -24,14 +23,11 @@ class XtsLoader {
24
23
  const newFileName = `${name}.ts`;
25
24
  //判断文本,空文本则结束该文件处理
26
25
  if (!content) {
27
- ColorConsole_1.default.log({
28
- level: shared_utils_1.LOG_LEVEL.Warn,
29
- message: `【XtsLoader】the file '${fullName}' under the path '${path}' has no content `
30
- });
26
+ ColorConsole_1.default.warn(`The file '${fullName}' under the path '${path}' has no content `);
31
27
  return [];
32
28
  }
33
- const parserResult = new parser_1.XtsParser(project, ColorConsole_1.default.log).parser(content, fullName);
34
- const { ast, mapList } = new parser_1.XtsToTypescript(project, ColorConsole_1.default.log, this.context, path).translate(parserResult.ast, parserResult.offsetList);
29
+ const parserResult = new parser_1.XtsParser(project, ColorConsole_1.default.logger).parser(content.toString(), fullName);
30
+ const { ast, mapList } = new parser_1.XtsToTypescript(project, ColorConsole_1.default.logger, this.context, path).translate(parserResult.ast, parserResult.offsetList);
35
31
  const { code, sourcemap } = new generator_1.TypescriptGenerator().generate({
36
32
  sourceFilePath: fullName,
37
33
  targetFilePath: newFileName,
@@ -51,5 +47,3 @@ class XtsLoader {
51
47
  }
52
48
  }
53
49
  exports.default = XtsLoader;
54
-
55
- //# sourceMappingURL=XtsLoader.js.map
@@ -0,0 +1,10 @@
1
+ import { PreWork } from 'file-lane/lib/interface/IFileLaneConfig';
2
+ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
3
+ /**
4
+ * UxPreWorks
5
+ */
6
+ declare class UxPreWorks {
7
+ static validateManifest: PreWork<IJavascriptCompileOption>;
8
+ static validateSitemap: PreWork<IJavascriptCompileOption>;
9
+ }
10
+ export default UxPreWorks;
@@ -0,0 +1,31 @@
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
+ var _a;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const UxFileUtils_1 = __importDefault(require("../../utils/ux/UxFileUtils"));
17
+ /**
18
+ * UxPreWorks
19
+ */
20
+ class UxPreWorks {
21
+ }
22
+ _a = UxPreWorks;
23
+ UxPreWorks.validateManifest = (context) => __awaiter(void 0, void 0, void 0, function* () {
24
+ const { projectPath } = context;
25
+ return UxFileUtils_1.default.validateManifest(projectPath);
26
+ });
27
+ UxPreWorks.validateSitemap = (context) => __awaiter(void 0, void 0, void 0, function* () {
28
+ const { projectPath } = context;
29
+ UxFileUtils_1.default.validateSitemap(projectPath);
30
+ });
31
+ exports.default = UxPreWorks;
@@ -20,16 +20,14 @@ const path_1 = __importDefault(require("path"));
20
20
  const preInstall = (context, _, __, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
21
21
  var _a;
22
22
  if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('install')) {
23
- ColorConsole_1.default.log({
24
- message: `skip install pre-dependencies due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`
25
- });
23
+ ColorConsole_1.default.info(`### skip install pre-dependencies due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
26
24
  return;
27
25
  }
28
26
  const { projectPath } = context;
29
27
  const packagePath = path_1.default.resolve(projectPath, 'package.json');
30
28
  const preContent = {
31
29
  dependencies: {
32
- '@mi/ts-framework': 'https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@mi/ts-framework/-/@mi/ts-framework-1.0.7.tgz',
30
+ '@mi/ts-framework': 'https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@mi/ts-framework/-/@mi/ts-framework-1.0.9.tgz',
33
31
  '@mi/wasmnizer-ts': 'https://pkgs.d.xiaomi.net:443/artifactory/api/npm/mi-npm/@mi/wasmnizer-ts/-/@mi/wasmnizer-ts-0.0.12.tgz'
34
32
  }
35
33
  };
@@ -49,18 +47,12 @@ const preInstall = (context, _, __, compilerOption) => __awaiter(void 0, void 0,
49
47
  });
50
48
  }
51
49
  }
52
- ColorConsole_1.default.log({
53
- message: 'Installing pre-dependencies. The initial build may take some time, please be patient...'
54
- });
50
+ ColorConsole_1.default.info('### Installing pre-dependencies. The initial build may take some time, please be patient...');
55
51
  (0, child_process_1.execSync)('npm install', {
56
52
  cwd: projectPath
57
53
  });
58
54
  // 目前ts2wasm不支持@符号
59
55
  fs_1.default.renameSync(path_1.default.resolve(projectPath, 'node_modules/@mi'), path_1.default.resolve(projectPath, 'node_modules/mi'));
60
- ColorConsole_1.default.log({
61
- message: 'Dependencies installation complete.'
62
- });
56
+ ColorConsole_1.default.info('### Dependencies installation complete.');
63
57
  });
64
58
  exports.preInstall = preInstall;
65
-
66
- //# sourceMappingURL=preInstall.js.map
@@ -41,5 +41,3 @@ class PngUtils {
41
41
  }
42
42
  }
43
43
  exports.default = PngUtils;
44
-
45
- //# sourceMappingURL=PngUtils.js.map
@@ -13,5 +13,10 @@ declare class PreWorkUtils {
13
13
  */
14
14
  static getEntries(context: IFileLaneContext): Promise<void>;
15
15
  static clean: PreWork<IJavascriptCompileOption>;
16
+ /**
17
+ * 获取项目的全局样式变量配置
18
+ * @param context
19
+ */
20
+ static getGlobalVar(context: IFileLaneContext): Promise<void>;
16
21
  }
17
22
  export default PreWorkUtils;
@@ -13,10 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  var _a;
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
16
17
  const del_1 = __importDefault(require("del"));
17
18
  const fs_extra_1 = __importDefault(require("fs-extra"));
18
19
  const path_1 = __importDefault(require("path"));
20
+ const TranslateCache_1 = __importDefault(require("../../../parser/lib/ux/translate/vela/TranslateCache"));
19
21
  const UxFileUtils_1 = __importDefault(require("./ux/UxFileUtils"));
22
+ const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
20
23
  /**
21
24
  * PreWorkUtils
22
25
  */
@@ -37,11 +40,13 @@ class PreWorkUtils {
37
40
  if (manifestContent) {
38
41
  const { router } = manifestContent;
39
42
  if (!router) {
40
- // 报错,没有router配置
43
+ // 没有router配置
44
+ ColorConsole_1.default.throw(`### manifest ### No router configuration`);
41
45
  }
42
46
  const { pages } = router;
43
47
  if (!pages) {
44
- // 报错,没有pages配置
48
+ // 没有pages配置
49
+ ColorConsole_1.default.throw(`### manifest ### No pages configuration`);
45
50
  }
46
51
  Object.keys(pages).map((page) => {
47
52
  const pageContent = pages[page];
@@ -51,26 +56,52 @@ class PreWorkUtils {
51
56
  entryList.push(entryPage);
52
57
  }
53
58
  else {
54
- // 报错,路径不存在
59
+ // 路径不存在
60
+ ColorConsole_1.default.throw(`### manifest ### path '${entryPage}' does not exist`);
55
61
  }
56
62
  });
57
63
  context['entries'] = entryList;
58
64
  return Promise.resolve();
59
65
  }
60
66
  else {
61
- // 报错 manifest.json文件无有效内容
67
+ // manifest.json文件无有效内容
68
+ ColorConsole_1.default.error(`### manifest ### File has no valid content`);
62
69
  return Promise.reject();
63
70
  }
64
71
  }
72
+ /**
73
+ * 获取项目的全局样式变量配置
74
+ * @param context
75
+ */
76
+ static getGlobalVar(context) {
77
+ const { projectPath } = context;
78
+ const filePath = path_1.default.join(projectPath, 'src', 'globalVar.json');
79
+ let globalVar = {};
80
+ // 判断文件是否存在
81
+ if (fs_extra_1.default.existsSync(filePath)) {
82
+ // 存在则取内容,否则内容为空
83
+ globalVar = fs_extra_1.default.readJSONSync(filePath);
84
+ }
85
+ context.globalVar = globalVar;
86
+ return Promise.resolve();
87
+ }
65
88
  }
66
89
  _a = PreWorkUtils;
67
90
  PreWorkUtils.clean = (context, _, config, compileOption) => __awaiter(void 0, void 0, void 0, function* () {
68
- (0, del_1.default)(path_1.default.join(context.projectPath, context.output));
91
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, context.output));
69
92
  if (compileOption) {
70
- (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
71
- (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
93
+ yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
94
+ yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
95
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.outputPath));
96
+ yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.releasePath));
72
97
  }
98
+ TranslateCache_1.default.featureCache.clear();
99
+ BinaryPlugin.reset();
100
+ BinaryPlugin.config = {
101
+ projectPath: context.projectPath,
102
+ outputProjectPath: path_1.default.join(context.projectPath, context.output),
103
+ source: compileOption === null || compileOption === void 0 ? void 0 : compileOption.sourceRoot,
104
+ output: compileOption === null || compileOption === void 0 ? void 0 : compileOption.outputPath
105
+ };
73
106
  });
74
107
  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;