@aiot-toolkit/aiotpack 2.0.3-beta.1 → 2.0.3-beta.10

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 (57) hide show
  1. package/lib/afterCompile/ux/UxAfterCompile.js +292 -266
  2. package/lib/afterCompile/xts/entryTemplate.js +111 -113
  3. package/lib/afterCompile/xts/generateRpk.js +25 -54
  4. package/lib/afterCompile/xts/ts2wasm.js +62 -63
  5. package/lib/afterWorks/ux/UxAfterWorks.js +12 -19
  6. package/lib/beforeCompile/ux/UxBeforeCompile.js +26 -28
  7. package/lib/beforeCompile/xts/preInstall.js +50 -55
  8. package/lib/beforeWorks/ux/UxBeforeWorks.js +12 -19
  9. package/lib/compiler/enum/CompileMode.js +16 -23
  10. package/lib/compiler/interface/ICompileParam.js +1 -2
  11. package/lib/compiler/interface/ICompiler.js +1 -2
  12. package/lib/compiler/interface/ISignConfig.js +1 -2
  13. package/lib/compiler/javascript/JavascriptCompiler.js +147 -154
  14. package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +20 -16
  15. package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +13 -11
  16. package/lib/compiler/javascript/android/plugin/WrapPlugin.js +53 -49
  17. package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +1 -2
  18. package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -1
  19. package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +78 -75
  20. package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +30 -41
  21. package/lib/compiler/javascript/vela/enum/EntryType.js +15 -29
  22. package/lib/compiler/javascript/vela/interface/IChunk.js +4 -1
  23. package/lib/compiler/javascript/vela/interface/IManifest.js +1 -2
  24. package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +1 -2
  25. package/lib/compiler/javascript/vela/model/Package.js +80 -51
  26. package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +31 -27
  27. package/lib/compiler/javascript/vela/utils/Jsc.js +30 -33
  28. package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +152 -130
  29. package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -276
  30. package/lib/compiler/javascript/vela/utils/signature/Base64.js +65 -67
  31. package/lib/compiler/javascript/vela/utils/signature/CRC32.js +37 -35
  32. package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +755 -731
  33. package/lib/compiler/javascript/vela/utils/signature/Signer.js +24 -22
  34. package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +47 -52
  35. package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +21 -17
  36. package/lib/config/UxConfig.js +145 -173
  37. package/lib/config/XtsConfig.js +30 -40
  38. package/lib/index.js +88 -41
  39. package/lib/interface/ICompileOptions.js +5 -2
  40. package/lib/interface/IDeviceList.js +1 -2
  41. package/lib/loader/ux/JsLoader.js +32 -30
  42. package/lib/loader/ux/PngLoader.js +47 -53
  43. package/lib/loader/ux/android/UxLoader.js +30 -31
  44. package/lib/loader/ux/vela/AppUxLoader.js +23 -24
  45. package/lib/loader/ux/vela/HmlLoader.js +59 -55
  46. package/lib/loader/ux/vela/UxLoader.js +29 -35
  47. package/lib/loader/xts/XtsLoader.js +55 -41
  48. package/lib/utils/BeforeCompileUtils.js +100 -95
  49. package/lib/utils/PngUtils.js +42 -36
  50. package/lib/utils/ux/ManifestSchema.js +198 -194
  51. package/lib/utils/ux/UxFileUtils.d.ts +2 -2
  52. package/lib/utils/ux/UxFileUtils.js +130 -128
  53. package/lib/utils/ux/UxLoaderUtils.js +292 -307
  54. package/lib/utils/ux/android/AndroidUx.js +88 -90
  55. package/lib/utils/xts/XtsFileLaneUtils.js +58 -65
  56. package/lib/utils/xts/XtsFollowWorks.js +122 -129
  57. package/package.json +6 -6
@@ -1,66 +1,63 @@
1
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
- exports.generateEntryFile = exports.XtsEntryFileName = exports.entryTemplate = void 0;
16
- const parser_1 = require("@aiot-toolkit/parser");
17
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
18
- const fs_extra_1 = __importDefault(require("fs-extra"));
19
- const path_1 = __importDefault(require("path"));
20
- const entryTemplate = (options) => {
21
- const { aspects = [] } = options;
22
- function generatImportAspects() {
23
- if (!aspects)
24
- return '';
25
- let imports = '// import aspects\n';
26
- for (let i = 0; i < aspects.length; i++) {
27
- const aspect = aspects[i];
28
- imports += `import AspectClass${i + 1} from './${aspect.path}'\n`;
29
- const { routes = [] } = aspect;
30
- for (let r = 0; r < (routes === null || routes === void 0 ? void 0 : routes.length); r++) {
31
- const route = routes[r];
32
- imports += `import Page${i + 1}_${r + 1}, { ${parser_1.HomeState.interface} as ${parser_1.HomeState.interface}${i + 1}_${r + 1}_ } from './${route.importPath}'\n`;
33
- }
34
- }
35
- return imports;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.generateEntryFile = exports.entryTemplate = exports.XtsEntryFileName = void 0;
7
+ var _parser = require("@aiot-toolkit/parser");
8
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
9
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
10
+ var _path = _interopRequireDefault(require("path"));
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const entryTemplate = options => {
13
+ const {
14
+ aspects = []
15
+ } = options;
16
+ function generatImportAspects() {
17
+ if (!aspects) return '';
18
+ let imports = '// import aspects\n';
19
+ for (let i = 0; i < aspects.length; i++) {
20
+ const aspect = aspects[i];
21
+ imports += `import AspectClass${i + 1} from './${aspect.path}'\n`;
22
+ const {
23
+ routes = []
24
+ } = aspect;
25
+ for (let r = 0; r < routes?.length; r++) {
26
+ const route = routes[r];
27
+ imports += `import Page${i + 1}_${r + 1}, { ${_parser.HomeState.interface} as ${_parser.HomeState.interface}${i + 1}_${r + 1}_ } from './${route.importPath}'\n`;
28
+ }
36
29
  }
37
- function generateDefs() {
38
- let res = '// aspects\n';
39
- for (let i = 0; i < aspects.length; i++) {
40
- const aspect = aspects[i];
41
- const { routes = [] } = aspect;
42
- res += `
30
+ return imports;
31
+ }
32
+ function generateDefs() {
33
+ let res = '// aspects\n';
34
+ for (let i = 0; i < aspects.length; i++) {
35
+ const aspect = aspects[i];
36
+ const {
37
+ routes = []
38
+ } = aspect;
39
+ res += `
43
40
  const aspectName_${i + 1} = '${aspect.name}'
44
41
  const pathPages_${i + 1} = new Map()`;
45
- for (let r = 0; r < routes.length; r++) {
46
- const route = routes[r];
47
- res += `
48
- pathPages_${i + 1}.set('${route.route}', function (params?: ${parser_1.HomeState.interface}${i + 1}_${r + 1}_): Page {
42
+ for (let r = 0; r < routes.length; r++) {
43
+ const route = routes[r];
44
+ res += `
45
+ pathPages_${i + 1}.set('${route.route}', function (params?: ${_parser.HomeState.interface}${i + 1}_${r + 1}_): Page {
49
46
  return new Page${i + 1}_${r + 1}(params)
50
47
  })
51
48
  `;
52
- }
53
- res += `
49
+ }
50
+ res += `
54
51
  const aspectDef_${i + 1}: AspectDefinition = {
55
52
  newFn: (): ViewAspect => new AspectClass${i + 1}(),
56
53
  pathPages: pathPages_${i + 1}
57
54
  }
58
55
  aspectDefs.set(aspectName_${i + 1}, aspectDef_${i + 1})
59
56
  `;
60
- }
61
- return res;
62
57
  }
63
- return `import {
58
+ return res;
59
+ }
60
+ return `import {
64
61
  // class
65
62
  App,
66
63
  AppDefinition,
@@ -76,7 +73,7 @@ const entryTemplate = (options) => {
76
73
 
77
74
  // export function
78
75
  on
79
- } from '../node_modules/${parser_1.tsFrameWork.name}/index'
76
+ } from '../node_modules/${_parser.tsFrameWork.name}/index'
80
77
 
81
78
  // import app
82
79
  import AppClass from './${options.appPath}'
@@ -113,72 +110,73 @@ export { entry, on }
113
110
  };
114
111
  exports.entryTemplate = entryTemplate;
115
112
  function getManifest(manifestPath) {
116
- const content = fs_extra_1.default.readFileSync(manifestPath, 'utf-8');
117
- const data = JSON.parse(content);
118
- return data;
113
+ const content = _fsExtra.default.readFileSync(manifestPath, 'utf-8');
114
+ const data = JSON.parse(content);
115
+ return data;
119
116
  }
120
- exports.XtsEntryFileName = '__entry__.ts';
117
+ const XtsEntryFileName = exports.XtsEntryFileName = '__entry__.ts';
121
118
  /**
122
119
  * 生成 __entry__.ts 文件
123
120
  * @param context
124
121
  */
125
- const generateEntryFile = function generateEntryFile(params) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- var _a, _b;
128
- const { context, compilerOption } = params;
129
- const { projectPath, output } = context;
130
- if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('xts2ts')) {
131
- shared_utils_1.ColorConsole.info(`### skip generate entry file due to --skip xts2ts}`);
132
- return;
133
- }
134
- shared_utils_1.ColorConsole.info(`Generating entry file`);
135
- const buildDir = path_1.default.resolve(projectPath, output);
136
- const appManifestPath = path_1.default.join(buildDir, 'app', 'manifest.json');
137
- const appManifest = getManifest(appManifestPath);
138
- if (!appManifest) {
139
- shared_utils_1.ColorConsole.throw('not find app/manifest.json file !');
140
- }
141
- const appTs = path_1.default.join(buildDir, 'app', 'app.ts');
142
- if (!fs_extra_1.default.existsSync(appTs)) {
143
- shared_utils_1.ColorConsole.throw('not find app/app.ts file !');
144
- }
145
- function relativeDist(tar) {
146
- return path_1.default.join('.', path_1.default.relative(buildDir, tar)).replace(path_1.default.sep, '/');
147
- }
148
- let opt = {
149
- appPath: relativeDist(appTs.replace('.ts', '')),
150
- aspects: []
151
- };
152
- function getAspectRoutes(aspectPath) {
153
- var _a;
154
- const aspectManifestPath = path_1.default.join(aspectPath, 'src', 'manifest.json');
155
- const aspectManifest = getManifest(aspectManifestPath);
156
- if (!((_a = aspectManifest === null || aspectManifest === void 0 ? void 0 : aspectManifest.router) === null || _a === void 0 ? void 0 : _a.pages))
157
- return [];
158
- return Object.entries(aspectManifest.router.pages).map(([k, v]) => {
159
- return {
160
- importPath: relativeDist(path_1.default.resolve(path_1.default.dirname(aspectManifestPath), v.path)),
161
- name: k,
162
- route: v.path
163
- };
164
- });
165
- }
166
- if ((_b = appManifest === null || appManifest === void 0 ? void 0 : appManifest.router) === null || _b === void 0 ? void 0 : _b.aspects) {
167
- Object.entries(appManifest.router.aspects).forEach(([name, aspects]) => {
168
- aspects.forEach((aspect) => {
169
- var _a;
170
- const aspectPath = path_1.default.join(buildDir, aspect.path);
171
- (_a = opt.aspects) === null || _a === void 0 ? void 0 : _a.push({
172
- name: name,
173
- path: relativeDist(path_1.default.resolve(buildDir, aspect.path, 'src', 'aspect')),
174
- routes: getAspectRoutes(aspectPath)
175
- });
176
- });
177
- });
178
- }
179
- const template = (0, exports.entryTemplate)(opt);
180
- fs_extra_1.default.writeFileSync(path_1.default.join(projectPath, output, exports.XtsEntryFileName), template);
181
- shared_utils_1.ColorConsole.info(`entry file built`);
122
+ const generateEntryFile = exports.generateEntryFile = async function generateEntryFile(params) {
123
+ const {
124
+ context,
125
+ compilerOption
126
+ } = params;
127
+ const {
128
+ projectPath,
129
+ output
130
+ } = context;
131
+ if (compilerOption?.skip?.includes('xts2ts')) {
132
+ _sharedUtils.ColorConsole.info(`### skip generate entry file due to --skip xts2ts}`);
133
+ return;
134
+ }
135
+ _sharedUtils.ColorConsole.info(`Generating entry file`);
136
+ const buildDir = _path.default.resolve(projectPath, output);
137
+ const appManifestPath = _path.default.join(buildDir, 'app', 'manifest.json');
138
+ const appManifest = getManifest(appManifestPath);
139
+ if (!appManifest) {
140
+ _sharedUtils.ColorConsole.throw('not find app/manifest.json file !');
141
+ }
142
+ const appTs = _path.default.join(buildDir, 'app', 'app.ts');
143
+ if (!_fsExtra.default.existsSync(appTs)) {
144
+ _sharedUtils.ColorConsole.throw('not find app/app.ts file !');
145
+ }
146
+ function relativeDist(tar) {
147
+ return _path.default.join('.', _path.default.relative(buildDir, tar)).replace(_path.default.sep, '/');
148
+ }
149
+ let opt = {
150
+ appPath: relativeDist(appTs.replace('.ts', '')),
151
+ aspects: []
152
+ };
153
+ function getAspectRoutes(aspectPath) {
154
+ const aspectManifestPath = _path.default.join(aspectPath, 'src', 'manifest.json');
155
+ const aspectManifest = getManifest(aspectManifestPath);
156
+ if (!aspectManifest?.router?.pages) return [];
157
+ return Object.entries(aspectManifest.router.pages).map(_ref => {
158
+ let [k, v] = _ref;
159
+ return {
160
+ importPath: relativeDist(_path.default.resolve(_path.default.dirname(aspectManifestPath), v.path)),
161
+ name: k,
162
+ route: v.path
163
+ };
182
164
  });
183
- };
184
- exports.generateEntryFile = generateEntryFile;
165
+ }
166
+ if (appManifest?.router?.aspects) {
167
+ Object.entries(appManifest.router.aspects).forEach(_ref2 => {
168
+ let [name, aspects] = _ref2;
169
+ aspects.forEach(aspect => {
170
+ const aspectPath = _path.default.join(buildDir, aspect.path);
171
+ opt.aspects?.push({
172
+ name: name,
173
+ path: relativeDist(_path.default.resolve(buildDir, aspect.path, 'src', 'aspect')),
174
+ routes: getAspectRoutes(aspectPath)
175
+ });
176
+ });
177
+ });
178
+ }
179
+ const template = entryTemplate(opt);
180
+ _fsExtra.default.writeFileSync(_path.default.join(projectPath, output, XtsEntryFileName), template);
181
+ _sharedUtils.ColorConsole.info(`entry file built`);
182
+ };
@@ -1,57 +1,28 @@
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;
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
17
5
  });
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
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
6
  exports.generateRpk = void 0;
39
- const path_1 = __importDefault(require("path"));
40
- const XtsFollowWorks_1 = __importDefault(require("../../utils/xts/XtsFollowWorks"));
41
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
42
- const ts2wasm_1 = require("./ts2wasm");
43
- const generateRpk = (params) => __awaiter(void 0, void 0, void 0, function* () {
44
- var _a;
45
- const { context, compilerOption } = params;
46
- if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('package')) {
47
- shared_utils_1.ColorConsole.info(`### skip package due to --skip ${compilerOption.skip.join(',')}`);
48
- return;
49
- }
50
- const manifestPath = path_1.default.resolve(context.projectPath, 'app', 'manifest.json');
51
- const manifest = yield Promise.resolve(`${manifestPath}`).then(s => __importStar(require(s)));
52
- return XtsFollowWorks_1.default.defaultZipProject(context, {
53
- tarDir: ts2wasm_1.wasmPackageName,
54
- packageName: manifest.package
55
- });
56
- });
57
- exports.generateRpk = generateRpk;
7
+ var _path = _interopRequireDefault(require("path"));
8
+ var _XtsFollowWorks = _interopRequireDefault(require("../../utils/xts/XtsFollowWorks"));
9
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
10
+ var _ts2wasm = require("./ts2wasm");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const generateRpk = async params => {
13
+ const {
14
+ context,
15
+ compilerOption
16
+ } = params;
17
+ if (compilerOption?.skip?.includes('package')) {
18
+ _sharedUtils.ColorConsole.info(`### skip package due to --skip ${compilerOption.skip.join(',')}`);
19
+ return;
20
+ }
21
+ const manifestPath = _path.default.resolve(context.projectPath, 'app', 'manifest.json');
22
+ const manifest = await import(manifestPath);
23
+ return _XtsFollowWorks.default.defaultZipProject(context, {
24
+ tarDir: _ts2wasm.wasmPackageName,
25
+ packageName: manifest.package
26
+ });
27
+ };
28
+ exports.generateRpk = generateRpk;
@@ -1,70 +1,69 @@
1
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
- exports.ts2wasm = exports.wasmPackageName = void 0;
16
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
17
- const child_process_1 = require("child_process");
18
- const fast_glob_1 = __importDefault(require("fast-glob"));
19
- const fs_1 = __importDefault(require("fs"));
20
- const path_1 = __importDefault(require("path"));
21
- const entryTemplate_1 = require("./entryTemplate");
22
- exports.wasmPackageName = 'wasmUnpacked';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wasmPackageName = exports.ts2wasm = void 0;
7
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
+ var _child_process = require("child_process");
9
+ var _fastGlob = _interopRequireDefault(require("fast-glob"));
10
+ var _fs = _interopRequireDefault(require("fs"));
11
+ var _path = _interopRequireDefault(require("path"));
12
+ var _entryTemplate = require("./entryTemplate");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ const wasmPackageName = exports.wasmPackageName = 'wasmUnpacked';
15
+
23
16
  /**
24
17
  * 将 __entry__.ts 文件打包成 warm 文件
25
18
  * @param context
26
19
  */
27
- const ts2wasm = (params) => __awaiter(void 0, void 0, void 0, function* () {
28
- var _a;
29
- const { context, compilerOption } = params;
30
- /** 1. 生成 app.wasm 文件 */
31
- const { projectPath, output } = context;
32
- const buildDir = path_1.default.resolve(projectPath, output);
33
- const entryFile = path_1.default.resolve(buildDir, entryTemplate_1.XtsEntryFileName);
34
- const wasmDir = path_1.default.resolve(projectPath, exports.wasmPackageName);
35
- fs_1.default.mkdirSync(wasmDir, {
36
- recursive: true
20
+ const ts2wasm = async params => {
21
+ const {
22
+ context,
23
+ compilerOption
24
+ } = params;
25
+ /** 1. 生成 app.wasm 文件 */
26
+ const {
27
+ projectPath,
28
+ output
29
+ } = context;
30
+ const buildDir = _path.default.resolve(projectPath, output);
31
+ const entryFile = _path.default.resolve(buildDir, _entryTemplate.XtsEntryFileName);
32
+ const wasmDir = _path.default.resolve(projectPath, wasmPackageName);
33
+ _fs.default.mkdirSync(wasmDir, {
34
+ recursive: true
35
+ });
36
+ function compile() {
37
+ // TODO: 后续修改为 @mi
38
+ const ts2wasmpath = _path.default.resolve(projectPath, 'node_modules', 'mi/wasmnizer-ts');
39
+ _sharedUtils.ColorConsole.info('### Waiting for generating app.wasm file.');
40
+ const res = (0, _child_process.execSync)(`node ${ts2wasmpath}/build/cli/ts2wasm.js ${entryFile} -o ${wasmDir}/app.wasm`, {
41
+ encoding: 'utf-8'
37
42
  });
38
- function compile() {
39
- // TODO: 后续修改为 @mi
40
- const ts2wasmpath = path_1.default.resolve(projectPath, 'node_modules', 'mi/wasmnizer-ts');
41
- shared_utils_1.ColorConsole.info('### Waiting for generating app.wasm file.');
42
- const res = (0, child_process_1.execSync)(`node ${ts2wasmpath}/build/cli/ts2wasm.js ${entryFile} -o ${wasmDir}/app.wasm`, {
43
- encoding: 'utf-8'
44
- });
45
- shared_utils_1.ColorConsole.info(`### ts2wasm ### ${res.toString()}`);
46
- }
47
- if ((_a = compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip) === null || _a === void 0 ? void 0 : _a.includes('ts2wasm')) {
48
- shared_utils_1.ColorConsole.info(`### skip compile ts to wasm due to --skip ${compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.skip.join(',')}`);
49
- }
50
- else {
51
- compile();
52
- }
53
- /** 2. 拷贝静态资源 */
54
- // TODO: ignore 数组待优化
55
- const files = fast_glob_1.default.sync(`${fast_glob_1.default.convertPathToPattern(projectPath)}/${output}/**/*`, {
56
- absolute: true,
57
- ignore: ['**/*.ts', '**/*.xts', '**/package.json', '**/package-lock.json', '**/*.wasm'],
58
- onlyFiles: true
43
+ _sharedUtils.ColorConsole.info(`### ts2wasm ### ${res.toString()}`);
44
+ }
45
+ if (compilerOption?.skip?.includes('ts2wasm')) {
46
+ _sharedUtils.ColorConsole.info(`### skip compile ts to wasm due to --skip ${compilerOption?.skip.join(',')}`);
47
+ } else {
48
+ compile();
49
+ }
50
+
51
+ /** 2. 拷贝静态资源 */
52
+ // TODO: ignore 数组待优化
53
+ const files = _fastGlob.default.sync(`${_fastGlob.default.convertPathToPattern(projectPath)}/${output}/**/*`, {
54
+ absolute: true,
55
+ ignore: ['**/*.ts', '**/*.xts', '**/package.json', '**/package-lock.json', '**/*.wasm'],
56
+ onlyFiles: true
57
+ });
58
+ for (const from of files) {
59
+ const to = from.replace('/src', '').replace(`/${output}`, `/${wasmPackageName}`);
60
+ _fs.default.mkdirSync(_path.default.dirname(to), {
61
+ recursive: true
59
62
  });
60
- for (const from of files) {
61
- const to = from.replace('/src', '').replace(`/${output}`, `/${exports.wasmPackageName}`);
62
- fs_1.default.mkdirSync(path_1.default.dirname(to), {
63
- recursive: true
64
- });
65
- fs_1.default.copyFileSync(from, to);
66
- }
67
- /** 3. 特殊处理 app/manifest.json */
68
- 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'));
69
- });
70
- exports.ts2wasm = ts2wasm;
63
+ _fs.default.copyFileSync(from, to);
64
+ }
65
+
66
+ /** 3. 特殊处理 app/manifest.json */
67
+ _fs.default.copyFileSync(_path.default.resolve(_fastGlob.default.convertPathToPattern(projectPath), output, 'app', 'manifest.json'), _path.default.resolve(_fastGlob.default.convertPathToPattern(projectPath), wasmPackageName, 'manifest.json'));
68
+ };
69
+ exports.ts2wasm = ts2wasm;
@@ -1,22 +1,15 @@
1
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const shared_utils_1 = require("@aiot-toolkit/shared-utils");
13
- const file_lane_1 = require("file-lane");
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
+ var _fileLane = require("file-lane");
14
9
  class UxAfterWorks {
15
- static cleanOutput(context) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const outputPath = file_lane_1.FileLaneUtil.getOutputPath(context);
18
- shared_utils_1.FileUtil.del(outputPath);
19
- });
20
- }
10
+ static async cleanOutput(context) {
11
+ const outputPath = _fileLane.FileLaneUtil.getOutputPath(context);
12
+ _sharedUtils.FileUtil.del(outputPath);
13
+ }
21
14
  }
22
- exports.default = UxAfterWorks;
15
+ var _default = exports.default = UxAfterWorks;
@@ -1,34 +1,32 @@
1
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"));
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _UxFileUtils = _interopRequireDefault(require("../../utils/ux/UxFileUtils"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
9
  /**
18
10
  * UxBeforeCompile
19
11
  */
20
12
  class UxBeforeCompile {
13
+ static validateManifest = async _ref => {
14
+ let {
15
+ context
16
+ } = _ref;
17
+ const {
18
+ projectPath
19
+ } = context;
20
+ await _UxFileUtils.default.validateManifest(projectPath);
21
+ };
22
+ static validateSitemap = async _ref2 => {
23
+ let {
24
+ context
25
+ } = _ref2;
26
+ const {
27
+ projectPath
28
+ } = context;
29
+ _UxFileUtils.default.validateSitemap(projectPath);
30
+ };
21
31
  }
22
- _a = UxBeforeCompile;
23
- UxBeforeCompile.validateManifest = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
24
- const { projectPath } = context;
25
- const errors = yield UxFileUtils_1.default.validateManifest(projectPath);
26
- if (errors === null || errors === void 0 ? void 0 : errors.length) {
27
- return Promise.reject(errors);
28
- }
29
- });
30
- UxBeforeCompile.validateSitemap = (_b) => __awaiter(void 0, [_b], void 0, function* ({ context }) {
31
- const { projectPath } = context;
32
- UxFileUtils_1.default.validateSitemap(projectPath);
33
- });
34
- exports.default = UxBeforeCompile;
32
+ var _default = exports.default = UxBeforeCompile;