@aiot-toolkit/aiotpack 2.0.2-dev.8 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{utils/ux/UxFollowWorks.d.ts → afterCompile/ux/UxAfterCompile.d.ts} +11 -4
- package/lib/{utils/ux/UxFollowWorks.js → afterCompile/ux/UxAfterCompile.js} +68 -43
- package/lib/{followWorks → afterCompile}/xts/entryTemplate.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/entryTemplate.js +14 -13
- package/lib/{followWorks → afterCompile}/xts/generateRpk.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/generateRpk.js +5 -4
- package/lib/{followWorks → afterCompile}/xts/ts2wasm.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/ts2wasm.js +7 -6
- package/lib/afterWorks/ux/UxAfterWorks.d.ts +5 -0
- package/lib/afterWorks/ux/UxAfterWorks.js +22 -0
- package/lib/{utils/ux/UxPreWorks.d.ts → beforeCompile/ux/UxBeforeCompile.d.ts} +4 -4
- package/lib/{utils/ux/UxPreWorks.js → beforeCompile/ux/UxBeforeCompile.js} +11 -8
- package/lib/{preWorks → beforeCompile}/xts/preInstall.d.ts +1 -1
- package/lib/{preWorks → beforeCompile}/xts/preInstall.js +6 -5
- package/lib/beforeWorks/ux/UxBeforeWorks.d.ts +5 -0
- package/lib/beforeWorks/ux/UxBeforeWorks.js +22 -0
- package/lib/compiler/interface/ICompileParam.d.ts +1 -1
- package/lib/compiler/interface/ISignConfig.d.ts +6 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +45 -12
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +1 -2
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.d.ts +9 -0
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +16 -0
- package/lib/compiler/javascript/android/plugin/WrapPlugin.d.ts +20 -0
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +91 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +16 -1
- package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +4 -4
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +4 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +18 -5
- package/lib/compiler/javascript/vela/interface/IChunk.d.ts +6 -1
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -1
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +1 -1
- package/lib/compiler/javascript/vela/model/Package.d.ts +2 -2
- package/lib/compiler/javascript/vela/model/Package.js +5 -5
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +1 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +16 -2
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js +19 -11
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +4 -4
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +19 -3
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +34 -29
- package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +0 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +23 -7
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +94 -45
- package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +0 -1
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +56 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/{splitMap.js → extractMapData.js} +2 -2
- package/lib/config/UxConfig.d.ts +45 -7
- package/lib/config/UxConfig.js +156 -40
- package/lib/config/XtsConfig.d.ts +6 -4
- package/lib/config/XtsConfig.js +22 -7
- package/lib/index.d.ts +9 -1
- package/lib/index.js +35 -1
- package/lib/loader/ux/JsLoader.d.ts +2 -0
- package/lib/loader/ux/JsLoader.js +6 -9
- package/lib/loader/ux/PngLoader.js +4 -5
- package/lib/loader/ux/android/UxLoader.d.ts +11 -0
- package/lib/loader/ux/android/UxLoader.js +39 -0
- package/lib/loader/ux/{AppUxLoader.d.ts → vela/AppUxLoader.d.ts} +1 -1
- package/lib/loader/ux/{AppUxLoader.js → vela/AppUxLoader.js} +6 -3
- package/lib/loader/ux/vela/HmlLoader.d.ts +24 -0
- package/lib/loader/ux/vela/HmlLoader.js +63 -0
- package/lib/loader/ux/{UxLoader.d.ts → vela/UxLoader.d.ts} +1 -1
- package/lib/loader/ux/{UxLoader.js → vela/UxLoader.js} +12 -13
- package/lib/loader/xts/XtsLoader.js +6 -7
- package/lib/utils/BeforeCompileUtils.d.ts +21 -0
- package/lib/utils/BeforeCompileUtils.js +118 -0
- package/lib/utils/ux/ManifestSchema.d.ts +1 -1
- package/lib/utils/ux/UxFileUtils.d.ts +16 -3
- package/lib/utils/ux/UxFileUtils.js +50 -17
- package/lib/utils/ux/UxLoaderUtils.d.ts +7 -4
- package/lib/utils/ux/UxLoaderUtils.js +43 -25
- package/lib/utils/ux/android/AndroidUx.d.ts +27 -0
- package/lib/utils/ux/android/AndroidUx.js +98 -0
- package/lib/utils/xts/XtsFileLaneUtils.d.ts +10 -0
- package/lib/utils/xts/XtsFileLaneUtils.js +68 -0
- package/lib/utils/xts/XtsFollowWorks.js +8 -8
- package/package.json +15 -8
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +0 -3
- package/lib/utils/PreWorkUtils.d.ts +0 -22
- package/lib/utils/PreWorkUtils.js +0 -106
package/lib/config/UxConfig.js
CHANGED
|
@@ -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
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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.
|
|
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,10 @@
|
|
|
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:
|
|
7
|
+
exclude: string[];
|
|
8
8
|
output: string;
|
|
9
9
|
module: {
|
|
10
10
|
rules: {
|
|
@@ -12,7 +12,9 @@ declare class XtsConfig implements IFileLaneConfig {
|
|
|
12
12
|
loader: (typeof XtsLoader)[];
|
|
13
13
|
}[];
|
|
14
14
|
};
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
beforeCompile: PreWork[];
|
|
16
|
+
afterCompile: {
|
|
17
|
+
worker: import("file-lane").FollowWork<import("..").IXtsCompileOptions>;
|
|
18
|
+
}[];
|
|
17
19
|
}
|
|
18
20
|
export default XtsConfig;
|
package/lib/config/XtsConfig.js
CHANGED
|
@@ -3,17 +3,22 @@ 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("../
|
|
7
|
-
const generateRpk_1 = require("../
|
|
8
|
-
const ts2wasm_1 = require("../
|
|
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
14
|
constructor() {
|
|
16
|
-
this.exclude = [
|
|
15
|
+
this.exclude = [
|
|
16
|
+
'**/node_modules{,/**}',
|
|
17
|
+
'**/dist{,/**}',
|
|
18
|
+
'**/build{,/**}',
|
|
19
|
+
'**/.git{,/**}',
|
|
20
|
+
'**/.wasmUnpacked{,/**}'
|
|
21
|
+
];
|
|
17
22
|
this.output = 'build';
|
|
18
23
|
this.module = {
|
|
19
24
|
rules: [
|
|
@@ -23,8 +28,18 @@ class XtsConfig {
|
|
|
23
28
|
}
|
|
24
29
|
]
|
|
25
30
|
};
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
31
|
+
this.beforeCompile = [];
|
|
32
|
+
this.afterCompile = [
|
|
33
|
+
{
|
|
34
|
+
worker: entryTemplate_1.generateEntryFile
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
worker: ts2wasm_1.ts2wasm
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
worker: generateRpk_1.generateRpk
|
|
41
|
+
}
|
|
42
|
+
];
|
|
28
43
|
}
|
|
29
44
|
}
|
|
30
45
|
exports.default = XtsConfig;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import XtsConfig from './config/XtsConfig';
|
|
2
|
-
|
|
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
|
|
7
|
-
const
|
|
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
|
|
27
|
+
content: new parser_1.ScriptToTypescript(options, this.compilerOption, this.context)
|
|
31
28
|
.translate({
|
|
32
|
-
content: new
|
|
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
|
|
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
|
-
|
|
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 (
|
|
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
|
-
|
|
56
|
+
shared_utils_1.ColorConsole.throw(`.9.png resource file processing failed`);
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
+
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
+
/**
|
|
4
|
+
* UxLoader
|
|
5
|
+
*/
|
|
6
|
+
declare class UxLoader implements ILoader {
|
|
7
|
+
context: IFileLaneContext;
|
|
8
|
+
compilerOption: IJavascriptCompileOption;
|
|
9
|
+
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
10
|
+
}
|
|
11
|
+
export default UxLoader;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const AndroidUx_1 = __importDefault(require("../../../utils/ux/android/AndroidUx"));
|
|
18
|
+
/**
|
|
19
|
+
* UxLoader
|
|
20
|
+
*/
|
|
21
|
+
class UxLoader {
|
|
22
|
+
parser(files) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const result = [];
|
|
25
|
+
const { projectPath } = this.context;
|
|
26
|
+
for (let item of files) {
|
|
27
|
+
const { files, logs } = yield new AndroidUx_1.default().compileUx({
|
|
28
|
+
context: this.context,
|
|
29
|
+
file: item,
|
|
30
|
+
compilerOption: this.compilerOption
|
|
31
|
+
});
|
|
32
|
+
shared_utils_1.CommonUtil.processingLogsInTerminal(logs.map((item) => (Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' }))));
|
|
33
|
+
result.push(...files);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = UxLoader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
-
import IJavascriptCompileOption from '
|
|
2
|
+
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
3
|
/**
|
|
4
4
|
* 处理app.ux的Loader
|
|
5
5
|
* AppUxLoader
|
|
@@ -12,7 +12,9 @@ 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
|
|
15
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const UxLoaderUtils_1 = __importDefault(require("../../../utils/ux/UxLoaderUtils"));
|
|
16
18
|
/**
|
|
17
19
|
* 处理app.ux的Loader
|
|
18
20
|
* AppUxLoader
|
|
@@ -20,8 +22,9 @@ const UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"))
|
|
|
20
22
|
class AppUxLoader {
|
|
21
23
|
parser(files) {
|
|
22
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const
|
|
24
|
-
yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0],
|
|
25
|
+
const { projectPath } = this.context;
|
|
26
|
+
const { files: resultFiles, logs } = yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], this.context, this.compilerOption);
|
|
27
|
+
shared_utils_1.CommonUtil.processingLogsInTerminal(logs.map((item) => (Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' }))));
|
|
25
28
|
return resultFiles;
|
|
26
29
|
});
|
|
27
30
|
}
|
|
@@ -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;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
9
|
+
/**
|
|
10
|
+
* HmlLoader
|
|
11
|
+
*/
|
|
12
|
+
class HmlLoader {
|
|
13
|
+
parser(files) {
|
|
14
|
+
return files.map((file) => {
|
|
15
|
+
return this.wrapHml(file);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 包裹 hml 文件
|
|
20
|
+
*
|
|
21
|
+
* # 路径
|
|
22
|
+
* 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
|
|
23
|
+
*
|
|
24
|
+
* # 内容
|
|
25
|
+
* 1. 给hml的内容加上<template></template>
|
|
26
|
+
* 2. 如果存在同路径同名的 script文件,则加到<script></script>中
|
|
27
|
+
* 3. 如果存在同路径同名的 style文件,则加到<style></style>中
|
|
28
|
+
*
|
|
29
|
+
* @param file
|
|
30
|
+
*/
|
|
31
|
+
wrapHml(file) {
|
|
32
|
+
const { path, content } = file;
|
|
33
|
+
const uxExt = parser_1.ExtensionConfig.UX;
|
|
34
|
+
const getFilePath = (ext) => {
|
|
35
|
+
const pathParsed = path_1.default.parse(path);
|
|
36
|
+
pathParsed.ext = ext;
|
|
37
|
+
pathParsed.base = pathParsed.name + ext;
|
|
38
|
+
return path_1.default.format(pathParsed);
|
|
39
|
+
};
|
|
40
|
+
const uxPath = getFilePath(uxExt);
|
|
41
|
+
if (fs_1.default.existsSync(uxPath)) {
|
|
42
|
+
throw new Error(`${uxPath} already exists`);
|
|
43
|
+
}
|
|
44
|
+
const scriptExts = parser_1.ExtensionConfig.SCRIPTS;
|
|
45
|
+
const styleExts = parser_1.ExtensionConfig.STYLES;
|
|
46
|
+
const scriptPath = scriptExts
|
|
47
|
+
.map((item) => getFilePath(item))
|
|
48
|
+
.find((item) => fs_1.default.existsSync(item));
|
|
49
|
+
const stylePath = styleExts.map((item) => getFilePath(item)).find((item) => fs_1.default.existsSync(item));
|
|
50
|
+
let uxContent = ['<template>', content, '</template>'].join('\n');
|
|
51
|
+
if (scriptPath) {
|
|
52
|
+
uxContent += ['<script>', fs_1.default.readFileSync(scriptPath, 'utf-8'), '</script>'].join('\n');
|
|
53
|
+
}
|
|
54
|
+
if (stylePath) {
|
|
55
|
+
uxContent += ['<style>', fs_1.default.readFileSync(stylePath, 'utf-8'), '</style>'].join('\n');
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
path,
|
|
59
|
+
content: uxContent
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.default = HmlLoader;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
-
import IJavascriptCompileOption from '
|
|
2
|
+
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
3
|
declare class UxLoader implements ILoader {
|
|
4
4
|
context: IFileLaneContext;
|
|
5
5
|
compilerOption: IJavascriptCompileOption;
|