@aiot-toolkit/aiotpack 2.0.5-beta.9 → 2.0.5-widget-provider-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.
- package/README.md +46 -46
- package/lib/afterCompile/ux/UxAfterCompile.d.ts +28 -1
- package/lib/afterCompile/ux/UxAfterCompile.js +186 -38
- package/lib/afterWorks/ux/UxAfterWorks.js +1 -1
- package/lib/beforeCompile/ux/UxBeforeCompile.js +2 -2
- package/lib/compiler/enum/CompileMode.js +2 -2
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +14 -0
- package/lib/compiler/javascript/JavascriptCompiler.js +91 -5
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +2 -2
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +7 -7
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +17 -1
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +5 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +3 -3
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +2 -2
- package/lib/compiler/javascript/vela/enum/EntryType.js +2 -2
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +11 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js +11 -1
- package/lib/compiler/javascript/vela/model/Package.js +28 -28
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +1 -2
- package/lib/compiler/javascript/vela/utils/Jsc.js +2 -2
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +31 -17
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +62 -62
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +2 -2
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +2 -2
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +68 -68
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +6 -6
- package/lib/compiler/javascript/vela/utils/signature/pem/certificate.pem +26 -26
- package/lib/compiler/javascript/vela/utils/signature/pem/private.pem +50 -50
- package/lib/compiler/javascript/vela/utils/webpackLoader/IWebpackLoaderOption.d.ts +11 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/IWebpackLoaderOption.js +1 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackJsLoader.d.ts +2 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackJsLoader.js +27 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackUxLoader.d.ts +2 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackUxLoader.js +26 -0
- package/lib/compiler/tools/icu/ImageIcu.d.ts +37 -0
- package/lib/compiler/tools/icu/ImageIcu.js +110 -0
- package/lib/compiler/tools/icu/icu_darwin_arm64 +0 -0
- package/lib/compiler/tools/icu/icu_darwin_x64 +0 -0
- package/lib/compiler/tools/icu/icu_linux_arm64 +0 -0
- package/lib/compiler/tools/icu/icu_linux_x64 +0 -0
- package/lib/compiler/tools/icu/icu_win32_x64.exe +0 -0
- package/lib/config/UxConfig.d.ts +9 -4
- package/lib/config/UxConfig.js +29 -17
- package/lib/index.d.ts +1 -3
- package/lib/index.js +2 -28
- package/lib/loader/ux/JsLoader.js +2 -2
- package/lib/loader/ux/PngLoader.js +2 -2
- package/lib/loader/ux/android/UxLoader.js +2 -2
- package/lib/loader/ux/vela/AppUxLoader.js +3 -3
- package/lib/loader/ux/vela/HmlLoader.js +14 -14
- package/lib/loader/ux/vela/UxLoader.js +7 -0
- package/lib/utils/BeforeCompileUtils.d.ts +2 -0
- package/lib/utils/BeforeCompileUtils.js +34 -12
- package/lib/utils/PngUtils.js +11 -11
- package/lib/utils/ux/ManifestSchema.js +6 -3
- package/lib/utils/ux/UxFileUtils.d.ts +1 -0
- package/lib/utils/ux/UxFileUtils.js +56 -45
- package/lib/utils/ux/UxLoaderUtils.js +35 -35
- package/lib/utils/ux/android/AndroidUx.js +10 -10
- package/package.json +8 -11
- package/lib/afterCompile/xts/entryTemplate.d.ts +0 -21
- package/lib/afterCompile/xts/entryTemplate.js +0 -182
- package/lib/afterCompile/xts/generateRpk.d.ts +0 -3
- package/lib/afterCompile/xts/generateRpk.js +0 -28
- package/lib/afterCompile/xts/ts2wasm.d.ts +0 -8
- package/lib/afterCompile/xts/ts2wasm.js +0 -69
- package/lib/beforeCompile/xts/preInstall.d.ts +0 -3
- package/lib/beforeCompile/xts/preInstall.js +0 -54
- package/lib/config/XtsConfig.d.ts +0 -22
- package/lib/config/XtsConfig.js +0 -36
- package/lib/interface/ICompileOptions.d.ts +0 -6
- package/lib/interface/ICompileOptions.js +0 -7
- package/lib/loader/xts/XtsLoader.d.ts +0 -9
- package/lib/loader/xts/XtsLoader.js +0 -62
- package/lib/utils/xts/XtsFileLaneUtils.d.ts +0 -10
- package/lib/utils/xts/XtsFileLaneUtils.js +0 -61
- package/lib/utils/xts/XtsFollowWorks.d.ts +0 -34
- package/lib/utils/xts/XtsFollowWorks.js +0 -134
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _generator = require("@aiot-toolkit/generator");
|
|
8
|
-
var _parser = require("@aiot-toolkit/parser");
|
|
9
|
-
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
var _tsMorph = require("ts-morph");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
/**
|
|
14
|
-
* XtsLoader
|
|
15
|
-
*/
|
|
16
|
-
class XtsLoader {
|
|
17
|
-
parser(files) {
|
|
18
|
-
const project = new _tsMorph.Project();
|
|
19
|
-
const resultFiles = [];
|
|
20
|
-
for (const file in files) {
|
|
21
|
-
const {
|
|
22
|
-
path,
|
|
23
|
-
content
|
|
24
|
-
} = files[file];
|
|
25
|
-
const {
|
|
26
|
-
name,
|
|
27
|
-
ext
|
|
28
|
-
} = _path.default.parse(path);
|
|
29
|
-
const fullName = `${name}${ext}`;
|
|
30
|
-
const newFileName = `${name}.ts`;
|
|
31
|
-
//判断文本,空文本则结束该文件处理
|
|
32
|
-
if (!content) {
|
|
33
|
-
_sharedUtils.ColorConsole.warn(`The file '${fullName}' under the path '${path}' has no content `);
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
const parserResult = new _parser.XtsParser(project, _sharedUtils.ColorConsole.logger).parser(content.toString(), fullName);
|
|
37
|
-
const {
|
|
38
|
-
ast,
|
|
39
|
-
mapList
|
|
40
|
-
} = new _parser.XtsToTypescript(project, _sharedUtils.ColorConsole.logger, this.context, path).translate(parserResult.ast, parserResult.offsetList);
|
|
41
|
-
const {
|
|
42
|
-
code,
|
|
43
|
-
sourcemap
|
|
44
|
-
} = new _generator.TypescriptGenerator().generate({
|
|
45
|
-
sourceFilePath: fullName,
|
|
46
|
-
targetFilePath: newFileName,
|
|
47
|
-
ast,
|
|
48
|
-
mapList
|
|
49
|
-
});
|
|
50
|
-
resultFiles.push({
|
|
51
|
-
path: _sharedUtils.FileUtil.updateFileName(path, newFileName),
|
|
52
|
-
content: code
|
|
53
|
-
}, {
|
|
54
|
-
path: _sharedUtils.FileUtil.updateFileName(path, `${name}.map.ts`),
|
|
55
|
-
content: sourcemap
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
// 返回内容
|
|
59
|
-
return resultFiles;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
var _default = exports.default = XtsLoader;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare class XtsFileLaneUtils {
|
|
2
|
-
/**
|
|
3
|
-
* 将buildPath文件夹的内容压缩成zip包,放置于targetPath路径下
|
|
4
|
-
* @param buildPath
|
|
5
|
-
* @param targetPath
|
|
6
|
-
* @param zipRootDirNames 可自定义压缩包内最外层目录的名称
|
|
7
|
-
*/
|
|
8
|
-
static zipProject(buildPath: string[], targetFile: string, zipRootDirNames?: string[]): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export default XtsFileLaneUtils;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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 _archiver = _interopRequireDefault(require("archiver"));
|
|
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
|
-
class XtsFileLaneUtils {
|
|
13
|
-
/**
|
|
14
|
-
* 将buildPath文件夹的内容压缩成zip包,放置于targetPath路径下
|
|
15
|
-
* @param buildPath
|
|
16
|
-
* @param targetPath
|
|
17
|
-
* @param zipRootDirNames 可自定义压缩包内最外层目录的名称
|
|
18
|
-
*/
|
|
19
|
-
static async zipProject(buildPath, targetFile, zipRootDirNames) {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
const output = _fsExtra.default.createWriteStream(targetFile);
|
|
22
|
-
const archive = _archiver.default.create('zip', {
|
|
23
|
-
zlib: {
|
|
24
|
-
level: 9
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
// 监听错误
|
|
28
|
-
archive.on('error', err => {
|
|
29
|
-
_sharedUtils.ColorConsole.throw(`${err.message}`);
|
|
30
|
-
output.close();
|
|
31
|
-
reject();
|
|
32
|
-
});
|
|
33
|
-
// 监听写入流打开的事件
|
|
34
|
-
output.on('open', () => {
|
|
35
|
-
_sharedUtils.ColorConsole.info(`Write stream is open`);
|
|
36
|
-
});
|
|
37
|
-
output.on('close', () => {
|
|
38
|
-
_sharedUtils.ColorConsole.info(`Write stream is closed`);
|
|
39
|
-
resolve();
|
|
40
|
-
});
|
|
41
|
-
// 将压缩文件导入到输出流中
|
|
42
|
-
archive.pipe(output);
|
|
43
|
-
|
|
44
|
-
// 指定压缩目录
|
|
45
|
-
buildPath.forEach((folder, index) => {
|
|
46
|
-
const folderName = _path.default.basename(folder); // 获取文件夹名
|
|
47
|
-
if (zipRootDirNames && zipRootDirNames[index]) {
|
|
48
|
-
archive.directory(folder, zipRootDirNames[index]);
|
|
49
|
-
} else {
|
|
50
|
-
archive.directory(folder, folderName);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
archive.on('finish', () => {
|
|
54
|
-
_sharedUtils.ColorConsole.info('finish');
|
|
55
|
-
});
|
|
56
|
-
// 完成压缩,关闭输出流
|
|
57
|
-
archive.finalize();
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
var _default = exports.default = XtsFileLaneUtils;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IFileLaneContext } from 'file-lane';
|
|
2
|
-
export interface DefaultZipProjectOptions {
|
|
3
|
-
tarDir?: string;
|
|
4
|
-
ext?: string;
|
|
5
|
-
packageName: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* XtsFollowWorks
|
|
9
|
-
*/
|
|
10
|
-
declare class XtsFollowWorks {
|
|
11
|
-
/**
|
|
12
|
-
* 将项目中build文件夹的内容压缩成zip包,并将压缩产物放到dist文件夹下
|
|
13
|
-
* @param context
|
|
14
|
-
*/
|
|
15
|
-
static defaultZipProject(context: IFileLaneContext, options: DefaultZipProjectOptions): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* 将分布式项目按照manifest.json中的配置打包,思路如下:
|
|
18
|
-
* 1. 获取manifest中aspect的路由配置
|
|
19
|
-
* 2. 对aspects中的所有路由信息进行遍历
|
|
20
|
-
* 3. 按照设备(设备+rule)对aspect分类
|
|
21
|
-
* 4. 按照设备列表分别进行打包
|
|
22
|
-
* @param context
|
|
23
|
-
*/
|
|
24
|
-
static zipDistributedQuickApp(context: IFileLaneContext): Promise<void>;
|
|
25
|
-
/**
|
|
26
|
-
* 根据项目路径,打包文件夹名和传入的压缩包名,生成压缩文件zip路径
|
|
27
|
-
* @param projectPath
|
|
28
|
-
* @param outputDir
|
|
29
|
-
* @param zipName
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
static getFilePath(projectPath: string, outputDir?: string, zipName?: string, ext?: string): string;
|
|
33
|
-
}
|
|
34
|
-
export default XtsFollowWorks;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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 _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _UxFileUtils = _interopRequireDefault(require("./../ux/UxFileUtils"));
|
|
11
|
-
var _XtsFileLaneUtils = _interopRequireDefault(require("../../utils/xts/XtsFileLaneUtils"));
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
/**
|
|
14
|
-
* XtsFollowWorks
|
|
15
|
-
*/
|
|
16
|
-
class XtsFollowWorks {
|
|
17
|
-
/**
|
|
18
|
-
* 将项目中build文件夹的内容压缩成zip包,并将压缩产物放到dist文件夹下
|
|
19
|
-
* @param context
|
|
20
|
-
*/
|
|
21
|
-
static async defaultZipProject(context, options) {
|
|
22
|
-
const {
|
|
23
|
-
projectPath
|
|
24
|
-
} = context;
|
|
25
|
-
const output = options.tarDir || context.output;
|
|
26
|
-
const buildPath = _path.default.join(projectPath, output);
|
|
27
|
-
const zipPath = _path.default.join(projectPath, 'dist');
|
|
28
|
-
// buildPath必须是真实文件夹路径
|
|
29
|
-
if (!_fsExtra.default.existsSync(buildPath)) {
|
|
30
|
-
_sharedUtils.ColorConsole.throw(`buildPath: '${buildPath}' not exist`);
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
// 确认文件夹是否存在,不存在则创建
|
|
34
|
-
_fsExtra.default.ensureDirSync(zipPath);
|
|
35
|
-
// 清空dist文件夹
|
|
36
|
-
_fsExtra.default.emptyDirSync(zipPath);
|
|
37
|
-
const filePath = XtsFollowWorks.getFilePath(projectPath, 'dist', options.packageName, 'rpk');
|
|
38
|
-
await _XtsFileLaneUtils.default.zipProject([buildPath], filePath, [options.packageName]);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
_sharedUtils.ColorConsole.throw(`${err.message}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 将分布式项目按照manifest.json中的配置打包,思路如下:
|
|
45
|
-
* 1. 获取manifest中aspect的路由配置
|
|
46
|
-
* 2. 对aspects中的所有路由信息进行遍历
|
|
47
|
-
* 3. 按照设备(设备+rule)对aspect分类
|
|
48
|
-
* 4. 按照设备列表分别进行打包
|
|
49
|
-
* @param context
|
|
50
|
-
*/
|
|
51
|
-
static async zipDistributedQuickApp(context) {
|
|
52
|
-
const deviceList = [{
|
|
53
|
-
device: 'phone',
|
|
54
|
-
aspectList: []
|
|
55
|
-
}];
|
|
56
|
-
const {
|
|
57
|
-
projectPath,
|
|
58
|
-
output
|
|
59
|
-
} = context;
|
|
60
|
-
const manifestPath = _UxFileUtils.default.getManifestFilePath(projectPath, 'app');
|
|
61
|
-
if (_fsExtra.default.existsSync(manifestPath)) {
|
|
62
|
-
//获取manifest.json内容
|
|
63
|
-
const aspectsRule = _fsExtra.default.readJSONSync(manifestPath)?.router?.aspects;
|
|
64
|
-
if (aspectsRule) {
|
|
65
|
-
Object.keys(aspectsRule).forEach(aspectRule => {
|
|
66
|
-
// 分别处理每个aspectRule数组
|
|
67
|
-
for (let item of aspectsRule[aspectRule]) {
|
|
68
|
-
const {
|
|
69
|
-
devices,
|
|
70
|
-
rule,
|
|
71
|
-
path
|
|
72
|
-
} = item;
|
|
73
|
-
// 如果存在设备列表
|
|
74
|
-
if (devices && Array.isArray(devices) && devices.length > 0) {
|
|
75
|
-
for (let device of devices) {
|
|
76
|
-
// 设备名与rule组合为一个设备
|
|
77
|
-
if (rule) {
|
|
78
|
-
device = `${device}.${rule}`;
|
|
79
|
-
}
|
|
80
|
-
// 查找设备是否已存在于设备列表中
|
|
81
|
-
const index = device === 'phone' ? 0 : deviceList.findIndex(item => item.device === device);
|
|
82
|
-
if (index === -1) {
|
|
83
|
-
// 新设备
|
|
84
|
-
deviceList.push({
|
|
85
|
-
device,
|
|
86
|
-
aspectList: [path]
|
|
87
|
-
});
|
|
88
|
-
} else {
|
|
89
|
-
// 已存在的设备信息时,仅需添加aspect路由
|
|
90
|
-
deviceList[index].aspectList.push(path);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
// 设备值默认值为phone
|
|
95
|
-
deviceList[0].aspectList.push(path);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const zipPath = _path.default.join(projectPath, 'dist');
|
|
101
|
-
_fsExtra.default.ensureDirSync(zipPath);
|
|
102
|
-
_fsExtra.default.emptyDirSync(zipPath);
|
|
103
|
-
// 根据deviceList进行打包
|
|
104
|
-
for (const item of deviceList) {
|
|
105
|
-
// 所有zip包都需要app信息
|
|
106
|
-
item.aspectList.push('app');
|
|
107
|
-
// 将路由转为真实路径
|
|
108
|
-
const buildPaths = item.aspectList.map(name => _path.default.join(projectPath, output, name));
|
|
109
|
-
const filePath = XtsFollowWorks.getFilePath(projectPath, 'dist', item.device);
|
|
110
|
-
try {
|
|
111
|
-
await _XtsFileLaneUtils.default.zipProject(buildPaths, filePath);
|
|
112
|
-
} catch (error) {}
|
|
113
|
-
}
|
|
114
|
-
} else {
|
|
115
|
-
_sharedUtils.ColorConsole.throw('not find manifest.json');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* 根据项目路径,打包文件夹名和传入的压缩包名,生成压缩文件zip路径
|
|
120
|
-
* @param projectPath
|
|
121
|
-
* @param outputDir
|
|
122
|
-
* @param zipName
|
|
123
|
-
* @returns
|
|
124
|
-
*/
|
|
125
|
-
static getFilePath(projectPath) {
|
|
126
|
-
let outputDir = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'dist';
|
|
127
|
-
let zipName = arguments.length > 2 ? arguments[2] : undefined;
|
|
128
|
-
let ext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'zip';
|
|
129
|
-
zipName = zipName ? `${zipName}.${ext}` : `${_path.default.basename(projectPath)}.${ext}`;
|
|
130
|
-
const zipPath = _path.default.join(projectPath, outputDir);
|
|
131
|
-
return _path.default.join(zipPath, zipName);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
var _default = exports.default = XtsFollowWorks;
|