@aiot-toolkit/aiotpack 2.0.2 → 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.
- package/lib/afterCompile/ux/UxAfterCompile.d.ts +1 -1
- package/lib/afterCompile/ux/UxAfterCompile.js +295 -243
- package/lib/afterCompile/xts/entryTemplate.js +111 -113
- package/lib/afterCompile/xts/generateRpk.js +25 -54
- package/lib/afterCompile/xts/ts2wasm.js +62 -63
- package/lib/afterWorks/ux/UxAfterWorks.js +12 -19
- package/lib/beforeCompile/ux/UxBeforeCompile.js +26 -28
- package/lib/beforeCompile/xts/preInstall.js +50 -55
- package/lib/beforeWorks/ux/UxBeforeWorks.js +12 -19
- package/lib/compiler/enum/CompileMode.js +16 -23
- package/lib/compiler/interface/ICompileParam.js +1 -2
- package/lib/compiler/interface/ICompiler.js +1 -2
- package/lib/compiler/interface/ISignConfig.js +1 -2
- package/lib/compiler/javascript/JavascriptCompiler.js +147 -154
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +20 -16
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +13 -11
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +53 -49
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +1 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +78 -75
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +30 -41
- package/lib/compiler/javascript/vela/enum/EntryType.js +15 -29
- package/lib/compiler/javascript/vela/interface/IChunk.js +4 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js +1 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +1 -2
- package/lib/compiler/javascript/vela/model/Package.js +80 -51
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +31 -27
- package/lib/compiler/javascript/vela/utils/Jsc.js +30 -33
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +152 -130
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +10 -2
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -267
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +65 -67
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +37 -35
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +755 -731
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +24 -22
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +47 -52
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +21 -17
- package/lib/config/UxConfig.js +145 -173
- package/lib/config/XtsConfig.d.ts +2 -0
- package/lib/config/XtsConfig.js +30 -39
- package/lib/index.js +88 -41
- package/lib/interface/ICompileOptions.js +5 -2
- package/lib/interface/IDeviceList.js +1 -2
- package/lib/loader/ux/JsLoader.js +32 -30
- package/lib/loader/ux/PngLoader.js +47 -53
- package/lib/loader/ux/android/UxLoader.d.ts +2 -0
- package/lib/loader/ux/android/UxLoader.js +30 -32
- package/lib/loader/ux/vela/AppUxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/AppUxLoader.js +23 -25
- package/lib/loader/ux/vela/HmlLoader.js +59 -55
- package/lib/loader/ux/vela/UxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/UxLoader.js +29 -37
- package/lib/loader/xts/XtsLoader.js +55 -41
- package/lib/utils/BeforeCompileUtils.js +100 -95
- package/lib/utils/PngUtils.js +42 -36
- package/lib/utils/ux/ManifestSchema.js +198 -194
- package/lib/utils/ux/UxFileUtils.d.ts +3 -3
- package/lib/utils/ux/UxFileUtils.js +130 -125
- package/lib/utils/ux/UxLoaderUtils.js +292 -307
- package/lib/utils/ux/android/AndroidUx.js +88 -90
- package/lib/utils/xts/XtsFileLaneUtils.js +58 -65
- package/lib/utils/xts/XtsFollowWorks.js +122 -129
- package/package.json +6 -6
|
@@ -1,66 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
pathPages_${i + 1}.set('${route.route}', function (params?: ${
|
|
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
|
-
|
|
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
|
|
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/${
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
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 =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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;
|