@aiot-toolkit/aiotpack 2.0.2-dev.8 → 2.0.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/{utils/ux/UxFollowWorks.d.ts → afterCompile/ux/UxAfterCompile.d.ts} +11 -4
  2. package/lib/{utils/ux/UxFollowWorks.js → afterCompile/ux/UxAfterCompile.js} +95 -44
  3. package/lib/{followWorks → afterCompile}/xts/entryTemplate.d.ts +1 -1
  4. package/lib/{followWorks → afterCompile}/xts/entryTemplate.js +14 -13
  5. package/lib/{followWorks → afterCompile}/xts/generateRpk.d.ts +1 -1
  6. package/lib/{followWorks → afterCompile}/xts/generateRpk.js +5 -4
  7. package/lib/{followWorks → afterCompile}/xts/ts2wasm.d.ts +1 -1
  8. package/lib/{followWorks → afterCompile}/xts/ts2wasm.js +7 -6
  9. package/lib/afterWorks/ux/UxAfterWorks.d.ts +5 -0
  10. package/lib/afterWorks/ux/UxAfterWorks.js +22 -0
  11. package/lib/{utils/ux/UxPreWorks.d.ts → beforeCompile/ux/UxBeforeCompile.d.ts} +4 -4
  12. package/lib/{utils/ux/UxPreWorks.js → beforeCompile/ux/UxBeforeCompile.js} +11 -8
  13. package/lib/{preWorks → beforeCompile}/xts/preInstall.d.ts +1 -1
  14. package/lib/{preWorks → beforeCompile}/xts/preInstall.js +6 -5
  15. package/lib/beforeWorks/ux/UxBeforeWorks.d.ts +5 -0
  16. package/lib/beforeWorks/ux/UxBeforeWorks.js +22 -0
  17. package/lib/compiler/interface/ICompileParam.d.ts +1 -1
  18. package/lib/compiler/interface/ISignConfig.d.ts +6 -1
  19. package/lib/compiler/javascript/JavascriptCompiler.js +45 -12
  20. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +1 -2
  21. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.d.ts +9 -0
  22. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +16 -0
  23. package/lib/compiler/javascript/android/plugin/WrapPlugin.d.ts +20 -0
  24. package/lib/compiler/javascript/android/plugin/WrapPlugin.js +91 -0
  25. package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +16 -1
  26. package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +4 -4
  27. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +4 -2
  28. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +18 -5
  29. package/lib/compiler/javascript/vela/interface/IChunk.d.ts +6 -1
  30. package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -1
  31. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +1 -1
  32. package/lib/compiler/javascript/vela/model/Package.d.ts +2 -2
  33. package/lib/compiler/javascript/vela/model/Package.js +5 -5
  34. package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +1 -1
  35. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +16 -2
  36. package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
  37. package/lib/compiler/javascript/vela/utils/Jsc.js +19 -11
  38. package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +1 -1
  39. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +4 -4
  40. package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +29 -5
  41. package/lib/compiler/javascript/vela/utils/ZipUtil.js +45 -31
  42. package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +0 -1
  43. package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +23 -7
  44. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +94 -45
  45. package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +0 -1
  46. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +3 -0
  47. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +56 -0
  48. package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +3 -0
  49. package/lib/compiler/javascript/vela/utils/webpackLoader/{splitMap.js → extractMapData.js} +2 -2
  50. package/lib/config/UxConfig.d.ts +45 -7
  51. package/lib/config/UxConfig.js +156 -40
  52. package/lib/config/XtsConfig.d.ts +8 -4
  53. package/lib/config/XtsConfig.js +24 -8
  54. package/lib/index.d.ts +9 -1
  55. package/lib/index.js +35 -1
  56. package/lib/loader/ux/JsLoader.d.ts +2 -0
  57. package/lib/loader/ux/JsLoader.js +6 -9
  58. package/lib/loader/ux/PngLoader.js +4 -5
  59. package/lib/loader/ux/android/UxLoader.d.ts +13 -0
  60. package/lib/loader/ux/android/UxLoader.js +38 -0
  61. package/lib/loader/ux/{AppUxLoader.d.ts → vela/AppUxLoader.d.ts} +3 -1
  62. package/lib/loader/ux/{AppUxLoader.js → vela/AppUxLoader.js} +5 -3
  63. package/lib/loader/ux/vela/HmlLoader.d.ts +24 -0
  64. package/lib/loader/ux/vela/HmlLoader.js +63 -0
  65. package/lib/loader/ux/{UxLoader.d.ts → vela/UxLoader.d.ts} +3 -1
  66. package/lib/loader/ux/{UxLoader.js → vela/UxLoader.js} +11 -14
  67. package/lib/loader/xts/XtsLoader.js +6 -7
  68. package/lib/utils/BeforeCompileUtils.d.ts +21 -0
  69. package/lib/utils/BeforeCompileUtils.js +118 -0
  70. package/lib/utils/ux/ManifestSchema.d.ts +1 -1
  71. package/lib/utils/ux/UxFileUtils.d.ts +16 -3
  72. package/lib/utils/ux/UxFileUtils.js +53 -17
  73. package/lib/utils/ux/UxLoaderUtils.d.ts +7 -4
  74. package/lib/utils/ux/UxLoaderUtils.js +43 -25
  75. package/lib/utils/ux/android/AndroidUx.d.ts +27 -0
  76. package/lib/utils/ux/android/AndroidUx.js +98 -0
  77. package/lib/utils/xts/XtsFileLaneUtils.d.ts +10 -0
  78. package/lib/utils/xts/XtsFileLaneUtils.js +68 -0
  79. package/lib/utils/xts/XtsFollowWorks.js +8 -8
  80. package/package.json +15 -8
  81. package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +0 -3
  82. package/lib/utils/PreWorkUtils.d.ts +0 -22
  83. package/lib/utils/PreWorkUtils.js +0 -106
@@ -1,14 +1,41 @@
1
1
  import { IFileLaneConfig } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
3
- import AppUxLoader from '../loader/ux/AppUxLoader';
4
3
  import JsLoader from '../loader/ux/JsLoader';
5
- import UxLoader from '../loader/ux/UxLoader';
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';
8
+ import UxBeforeWorks from '../beforeWorks/ux/UxBeforeWorks';
9
+ import UxAfterWorks from '../afterWorks/ux/UxAfterWorks';
10
+ import { IChangedFile } from 'file-lane/lib/interface/IChangedFile';
6
11
  declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
7
12
  readonly projectPath: string;
8
13
  constructor(projectPath: string);
9
- exclude: RegExp[];
14
+ /**
15
+ * 1. 取项目中所有的真实文件
16
+ * 1.1 无entryFileList时
17
+ * 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
18
+ * 1.3 有entryFileList且文件列表中有文件为 删除 操作时
19
+ * 2. 返回符合条件的文件列表
20
+ * 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
21
+ * @param entryFileList
22
+ * @returns
23
+ */
24
+ collectFile: (entryFileList?: IChangedFile[]) => string[];
25
+ exclude: (string | ((filePath: string) => boolean))[];
10
26
  get output(): string;
11
- module: {
27
+ beforeWorks: (typeof UxBeforeWorks.cleanOutput)[];
28
+ beforeCompile: import("file-lane").PreWork<IJavascriptCompileOption>[];
29
+ afterCompile: {
30
+ worker: import("file-lane").FollowWork<IJavascriptCompileOption>;
31
+ workerDescribe: string;
32
+ }[];
33
+ afterWorks: (typeof UxAfterWorks.cleanOutput)[];
34
+ watchIgnores: RegExp[];
35
+ /**
36
+ * 通过项目类型,返回模块配置
37
+ */
38
+ get module(): {
12
39
  rules: ({
13
40
  test: string[];
14
41
  loader: (typeof AppUxLoader)[];
@@ -17,14 +44,25 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
17
44
  test: RegExp[];
18
45
  exclude: RegExp[];
19
46
  loader: (typeof UxLoader)[];
47
+ } | {
48
+ test: RegExp[];
49
+ loader: (typeof HmlLoader | typeof UxLoader)[];
50
+ exclude?: undefined;
20
51
  } | {
21
52
  test: RegExp[];
22
53
  loader: (typeof JsLoader)[];
23
54
  exclude?: undefined;
55
+ } | {
56
+ test: RegExp[];
57
+ loader: (typeof PngLoader)[];
58
+ exclude?: undefined;
24
59
  })[];
25
60
  };
26
- preWorks: import("file-lane/lib/interface/IFileLaneConfig").PreWork<IJavascriptCompileOption>[];
27
- followWorks: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<IJavascriptCompileOption>[];
28
- watchIgnores: RegExp[];
61
+ /**
62
+ * 判断项目类型
63
+ *
64
+ * 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
65
+ */
66
+ private getProjectType;
29
67
  }
30
68
  export default UxConfig;
@@ -3,61 +3,177 @@ 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"));
8
10
  const JsLoader_1 = __importDefault(require("../loader/ux/JsLoader"));
9
11
  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("../utils/ux/UxFollowWorks"));
13
- const UxPreWorks_1 = __importDefault(require("../utils/ux/UxPreWorks"));
12
+ const AppUxLoader_1 = __importDefault(require("../loader/ux/vela/AppUxLoader"));
13
+ const HmlLoader_1 = __importDefault(require("../loader/ux/vela/HmlLoader"));
14
+ const UxLoader_1 = __importDefault(require("../loader/ux/vela/UxLoader"));
15
+ const UxLoader_2 = __importDefault(require("../loader/ux/android/UxLoader"));
16
+ const UxBeforeWorks_1 = __importDefault(require("../beforeWorks/ux/UxBeforeWorks"));
17
+ const UxAfterWorks_1 = __importDefault(require("../afterWorks/ux/UxAfterWorks"));
18
+ const UxAfterCompile_1 = __importDefault(require("../afterCompile/ux/UxAfterCompile"));
19
+ const UxBeforeCompile_1 = __importDefault(require("../beforeCompile/ux/UxBeforeCompile"));
20
+ const BeforeCompileUtils_1 = __importDefault(require("../utils/BeforeCompileUtils"));
21
+ const IChangedFile_1 = require("file-lane/lib/interface/IChangedFile");
14
22
  class UxConfig {
15
23
  constructor(projectPath) {
16
24
  this.projectPath = projectPath;
17
- this.exclude = [/node_modules/, /dist/, /build/];
18
- this.module = {
19
- rules: [
20
- {
21
- test: ['app.ux'],
22
- loader: [AppUxLoader_1.default]
23
- },
24
- {
25
- test: [/.+\.ux$/],
26
- exclude: [/app\.ux/],
27
- loader: [UxLoader_1.default]
28
- },
29
- {
30
- test: [/.+\.js$/],
31
- loader: [JsLoader_1.default]
32
- },
33
- {
34
- test: [/.+\.9.png/],
35
- loader: [PngLoader_1.default]
25
+ /**
26
+ * 1. 取项目中所有的真实文件
27
+ * 1.1 无entryFileList时
28
+ * 1.2 有entryFileList且文件列表中有 与其他文件相关 的文件时
29
+ * 1.3 有entryFileList且文件列表中有文件为 删除 操作时
30
+ * 2. 返回符合条件的文件列表
31
+ * 2.1 有entryFileList且文件列表中 只有 不影响其他文件 的文件时
32
+ * @param entryFileList
33
+ * @returns
34
+ */
35
+ this.collectFile = (entryFileList) => {
36
+ // 取项目中所有的真实文件
37
+ const getProjectFiles = () => {
38
+ const projectPath = this.projectPath;
39
+ let files = shared_utils_1.FileUtil.readAlldirSync(projectPath, undefined, this.exclude);
40
+ return files;
41
+ };
42
+ // 2.
43
+ if (entryFileList) {
44
+ let isGetAll = entryFileList.every((item) => item.type === IChangedFile_1.HandlerType.UNLINK || !/\.(ux|json|js)$/.test(item.path));
45
+ if (!isGetAll) {
46
+ return entryFileList
47
+ .filter((filePath) => shared_utils_1.FileUtil.include(filePath.path, undefined, this.exclude))
48
+ .map((item) => item.path);
36
49
  }
37
- ]
50
+ }
51
+ // 1.
52
+ return getProjectFiles();
38
53
  };
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
54
+ this.exclude = [
55
+ '**/node_modules{,/**}',
56
+ '**/dist{,/**}',
57
+ '**/build{,/**}',
58
+ '**/.git{,/**}',
59
+ (filePath) => {
60
+ // 如果 是 script, style文件,且同路径下存在同名 hml,则忽略
61
+ const { ext, name } = path_1.default.parse(filePath);
62
+ if (![...parser_1.ExtensionConfig.SCRIPTS, ...parser_1.ExtensionConfig.STYLES].includes(ext)) {
63
+ return false;
64
+ }
65
+ const hmlPath = shared_utils_1.FileUtil.updateFileName(filePath, `${name}${parser_1.ExtensionConfig.HML}`);
66
+ if (fs_1.default.existsSync(hmlPath)) {
67
+ return true;
68
+ }
69
+ return false;
70
+ }
71
+ ];
72
+ this.beforeWorks = [UxBeforeWorks_1.default.cleanOutput];
73
+ this.beforeCompile = [
74
+ UxBeforeCompile_1.default.validateManifest,
75
+ UxBeforeCompile_1.default.validateSitemap,
76
+ BeforeCompileUtils_1.default.clean,
77
+ BeforeCompileUtils_1.default.getEntries,
78
+ BeforeCompileUtils_1.default.getGlobalVar
45
79
  ];
46
- this.followWorks = [
47
- UxFollowWorks_1.default.symlinkNodeModule,
48
- UxFollowWorks_1.default.webpack,
49
- UxFollowWorks_1.default.copyResource,
50
- UxFollowWorks_1.default.jsc,
51
- UxFollowWorks_1.default.toRpk,
52
- UxFollowWorks_1.default.moveBackResult,
53
- UxFollowWorks_1.default.protobuf
80
+ this.afterCompile = [
81
+ {
82
+ worker: UxAfterCompile_1.default.symlinkNodeModule,
83
+ workerDescribe: 'Create a soft link to the node_modules folder'
84
+ },
85
+ {
86
+ worker: UxAfterCompile_1.default.webpack,
87
+ workerDescribe: 'Compile the project using webpack'
88
+ },
89
+ {
90
+ worker: UxAfterCompile_1.default.copyResource,
91
+ workerDescribe: 'Copy resource files'
92
+ },
93
+ {
94
+ worker: UxAfterCompile_1.default.jsc,
95
+ workerDescribe: 'Generate jsc bytecode'
96
+ },
97
+ {
98
+ worker: UxAfterCompile_1.default.protobuf,
99
+ workerDescribe: 'Generate protobuf json'
100
+ },
101
+ {
102
+ worker: UxAfterCompile_1.default.toRpk,
103
+ workerDescribe: 'Package the project into an RPK file'
104
+ },
105
+ {
106
+ worker: UxAfterCompile_1.default.generateDiff,
107
+ workerDescribe: 'Generate diff json'
108
+ },
109
+ {
110
+ worker: UxAfterCompile_1.default.moveBackResult,
111
+ workerDescribe: 'Migrate temporary project'
112
+ }
54
113
  ];
55
- this.watchIgnores = [/node_modules/];
114
+ this.afterWorks = [UxAfterWorks_1.default.cleanOutput];
115
+ this.watchIgnores = [/node_modules/, /build/, /dist/];
56
116
  }
57
117
  get output() {
58
118
  const name = path_1.default.basename(this.projectPath);
59
119
  const result = `../.temp_${name}`;
60
120
  return result;
61
121
  }
122
+ /**
123
+ * 通过项目类型,返回模块配置
124
+ */
125
+ get module() {
126
+ const isVela = this.getProjectType() === shared_utils_1.ProjectType.VELA_UX;
127
+ return isVela
128
+ ? {
129
+ rules: [
130
+ {
131
+ test: ['app.ux'],
132
+ loader: [AppUxLoader_1.default]
133
+ },
134
+ {
135
+ test: [/.+\.ux$/],
136
+ exclude: [/app\.ux/],
137
+ loader: [UxLoader_1.default]
138
+ },
139
+ {
140
+ test: [/.+\.hml$/],
141
+ loader: [HmlLoader_1.default, UxLoader_1.default]
142
+ },
143
+ {
144
+ test: [/.+\.js$/],
145
+ loader: [JsLoader_1.default]
146
+ },
147
+ {
148
+ test: [/.+\.9.png/],
149
+ loader: [PngLoader_1.default]
150
+ }
151
+ ]
152
+ }
153
+ : {
154
+ rules: [
155
+ {
156
+ test: [/.+\.ux$/],
157
+ loader: [UxLoader_2.default]
158
+ },
159
+ {
160
+ test: [/.+\.js$/],
161
+ loader: [JsLoader_1.default]
162
+ },
163
+ {
164
+ test: [/.+\.9.png/],
165
+ loader: [PngLoader_1.default]
166
+ }
167
+ ]
168
+ };
169
+ }
170
+ /**
171
+ * 判断项目类型
172
+ *
173
+ * 目前的办法是通过 manifest.json 的 deviceTypeList 是否有 watch 判断
174
+ */
175
+ getProjectType() {
176
+ return shared_utils_1.ProjectType.getProjectType(this.projectPath);
177
+ }
62
178
  }
63
179
  exports.default = UxConfig;
@@ -1,10 +1,12 @@
1
- import { IFileLaneConfig } from 'file-lane';
1
+ import { IFileLaneConfig, PreWork } from 'file-lane';
2
2
  import XtsLoader from '../loader/xts/XtsLoader';
3
3
  /**
4
4
  * XtsConfig
5
5
  */
6
6
  declare class XtsConfig implements IFileLaneConfig {
7
- exclude: RegExp[];
7
+ projectPath: string;
8
+ constructor(projectPath: string);
9
+ exclude: string[];
8
10
  output: string;
9
11
  module: {
10
12
  rules: {
@@ -12,7 +14,9 @@ declare class XtsConfig implements IFileLaneConfig {
12
14
  loader: (typeof XtsLoader)[];
13
15
  }[];
14
16
  };
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>[];
17
+ beforeCompile: PreWork[];
18
+ afterCompile: {
19
+ worker: import("file-lane").FollowWork<import("..").IXtsCompileOptions>;
20
+ }[];
17
21
  }
18
22
  export default XtsConfig;
@@ -3,17 +3,23 @@ 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 entryTemplate_1 = require("../followWorks/xts/entryTemplate");
7
- const generateRpk_1 = require("../followWorks/xts/generateRpk");
8
- const ts2wasm_1 = require("../followWorks/xts/ts2wasm");
6
+ const entryTemplate_1 = require("../afterCompile/xts/entryTemplate");
7
+ const generateRpk_1 = require("../afterCompile/xts/generateRpk");
8
+ const ts2wasm_1 = require("../afterCompile/xts/ts2wasm");
9
9
  const XtsLoader_1 = __importDefault(require("../loader/xts/XtsLoader"));
10
- const preInstall_1 = require("../preWorks/xts/preInstall");
11
10
  /**
12
11
  * XtsConfig
13
12
  */
14
13
  class XtsConfig {
15
- constructor() {
16
- this.exclude = [/node_modules/, /dist/, /build/, /wasmUnpacked/];
14
+ constructor(projectPath) {
15
+ this.projectPath = projectPath;
16
+ this.exclude = [
17
+ '**/node_modules{,/**}',
18
+ '**/dist{,/**}',
19
+ '**/build{,/**}',
20
+ '**/.git{,/**}',
21
+ '**/.wasmUnpacked{,/**}'
22
+ ];
17
23
  this.output = 'build';
18
24
  this.module = {
19
25
  rules: [
@@ -23,8 +29,18 @@ class XtsConfig {
23
29
  }
24
30
  ]
25
31
  };
26
- this.preWorks = [preInstall_1.preInstall];
27
- this.followWorks = [entryTemplate_1.generateEntryFile, ts2wasm_1.ts2wasm, generateRpk_1.generateRpk];
32
+ this.beforeCompile = [];
33
+ this.afterCompile = [
34
+ {
35
+ worker: entryTemplate_1.generateEntryFile
36
+ },
37
+ {
38
+ worker: ts2wasm_1.ts2wasm
39
+ },
40
+ {
41
+ worker: generateRpk_1.generateRpk
42
+ }
43
+ ];
28
44
  }
29
45
  }
30
46
  exports.default = XtsConfig;
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,9 +1,11 @@
1
1
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
+ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
2
3
  /**
3
4
  * JsLoader
4
5
  */
5
6
  declare class JsLoader implements ILoader {
6
7
  context: IFileLaneContext;
8
+ compilerOption: IJavascriptCompileOption;
7
9
  parser(files: IFileParam<any>[]): IFileParam<any>[] | Promise<IFileParam<any>[]>;
8
10
  }
9
11
  export default JsLoader;
@@ -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) {
@@ -23,13 +18,15 @@ class JsLoader {
23
18
  const options = {
24
19
  filePath: item.path,
25
20
  projectPath: this.context.projectPath,
21
+ content: item.content.toString(),
22
+ projectType: shared_utils_1.ProjectType.getProjectType(this.context.projectPath),
26
23
  onLog
27
24
  };
28
25
  return {
29
26
  path: item.path,
30
- content: new ScriptToTypescript_1.default(project, options)
27
+ content: new parser_1.ScriptToTypescript(options, this.compilerOption, this.context)
31
28
  .translate({
32
- 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
33
30
  }, [])
34
31
  .targetTree.getFullText()
35
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,13 @@
1
+ import { ILog } from '@aiot-toolkit/shared-utils';
2
+ import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
3
+ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
4
+ /**
5
+ * UxLoader
6
+ */
7
+ declare class UxLoader implements ILoader {
8
+ context: IFileLaneContext;
9
+ compilerOption: IJavascriptCompileOption;
10
+ logs?: ILog[] | undefined;
11
+ parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
12
+ }
13
+ export default UxLoader;
@@ -0,0 +1,38 @@
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 path_1 = __importDefault(require("path"));
16
+ const AndroidUx_1 = __importDefault(require("../../../utils/ux/android/AndroidUx"));
17
+ /**
18
+ * UxLoader
19
+ */
20
+ class UxLoader {
21
+ parser(files) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const result = [];
24
+ const { projectPath } = this.context;
25
+ for (let item of files) {
26
+ const { files, logs } = yield new AndroidUx_1.default().compileUx({
27
+ context: this.context,
28
+ file: item,
29
+ compilerOption: this.compilerOption
30
+ });
31
+ this.logs = logs.map((item) => (Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' })));
32
+ result.push(...files);
33
+ }
34
+ return result;
35
+ });
36
+ }
37
+ }
38
+ exports.default = UxLoader;
@@ -1,5 +1,6 @@
1
+ import { ILog } from '@aiot-toolkit/shared-utils';
1
2
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
- import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
3
+ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
3
4
  /**
4
5
  * 处理app.ux的Loader
5
6
  * AppUxLoader
@@ -7,6 +8,7 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
7
8
  declare class AppUxLoader implements ILoader {
8
9
  context: IFileLaneContext;
9
10
  compilerOption: IJavascriptCompileOption;
11
+ logs?: ILog[] | undefined;
10
12
  parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
11
13
  }
12
14
  export default AppUxLoader;
@@ -12,7 +12,8 @@ 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 UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"));
15
+ const path_1 = __importDefault(require("path"));
16
+ const UxLoaderUtils_1 = __importDefault(require("../../../utils/ux/UxLoaderUtils"));
16
17
  /**
17
18
  * 处理app.ux的Loader
18
19
  * AppUxLoader
@@ -20,8 +21,9 @@ const UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"))
20
21
  class AppUxLoader {
21
22
  parser(files) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
- const resultFiles = [];
24
- yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], resultFiles, this.context, this.compilerOption);
24
+ const { projectPath } = this.context;
25
+ const { files: resultFiles, logs } = yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], this.context, this.compilerOption);
26
+ this.logs = logs.map((item) => (Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' })));
25
27
  return resultFiles;
26
28
  });
27
29
  }
@@ -0,0 +1,24 @@
1
+ import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
+ /**
3
+ * HmlLoader
4
+ */
5
+ declare class HmlLoader implements ILoader {
6
+ context?: IFileLaneContext | undefined;
7
+ compilerOption?: any;
8
+ parser(files: IFileParam<any>[]): IFileParam<any>[] | Promise<IFileParam<any>[]>;
9
+ /**
10
+ * 包裹 hml 文件
11
+ *
12
+ * # 路径
13
+ * 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
14
+ *
15
+ * # 内容
16
+ * 1. 给hml的内容加上<template></template>
17
+ * 2. 如果存在同路径同名的 script文件,则加到<script></script>中
18
+ * 3. 如果存在同路径同名的 style文件,则加到<style></style>中
19
+ *
20
+ * @param file
21
+ */
22
+ private wrapHml;
23
+ }
24
+ export default HmlLoader;