@aiot-toolkit/aiotpack 2.0.1-alpha.9 → 2.0.2-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/lib/compiler/enum/CompileMode.js +0 -2
- package/lib/compiler/interface/ICompileParam.js +0 -2
- package/lib/compiler/interface/ICompiler.js +0 -2
- package/lib/compiler/interface/ISignConfig.js +0 -2
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +1 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +40 -18
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +1 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +5 -3
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +8 -4
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +0 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +0 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +1 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +0 -5
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +0 -2
- package/lib/compiler/javascript/vela/enum/EntryType.js +0 -2
- package/lib/compiler/javascript/vela/interface/IChunk.js +0 -2
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +3 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js +0 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +0 -2
- package/lib/compiler/javascript/vela/model/Package.js +2 -4
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +0 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +19 -24
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js +4 -7
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +2 -4
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +5 -7
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +0 -2
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +0 -2
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +14 -12
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +0 -2
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.js +20 -0
- package/lib/config/UxConfig.d.ts +3 -3
- package/lib/config/UxConfig.js +17 -6
- package/lib/config/XtsConfig.js +0 -2
- package/lib/followWorks/xts/entryTemplate.d.ts +2 -2
- package/lib/followWorks/xts/entryTemplate.js +61 -44
- package/lib/followWorks/xts/generateRpk.js +1 -3
- package/lib/followWorks/xts/ts2wasm.js +3 -14
- package/lib/index.js +0 -2
- package/lib/interface/ICompileOptions.d.ts +1 -1
- package/lib/interface/ICompileOptions.js +1 -3
- package/lib/interface/IDeviceList.js +0 -2
- package/lib/loader/ux/AppUxLoader.d.ts +2 -0
- package/lib/loader/ux/AppUxLoader.js +1 -3
- package/lib/loader/ux/JsLoader.d.ts +9 -0
- package/lib/loader/ux/JsLoader.js +39 -0
- package/lib/loader/ux/PngLoader.js +4 -9
- package/lib/loader/ux/UxLoader.d.ts +2 -0
- package/lib/loader/ux/UxLoader.js +15 -4
- package/lib/loader/xts/XtsLoader.js +3 -9
- package/lib/preWorks/xts/preInstall.js +4 -12
- package/lib/utils/PngUtils.js +0 -2
- package/lib/utils/PreWorkUtils.d.ts +5 -0
- package/lib/utils/PreWorkUtils.js +39 -9
- package/lib/utils/ux/ManifestSchema.d.ts +3 -0
- package/lib/utils/ux/ManifestSchema.js +207 -0
- package/lib/utils/ux/UxFileUtils.d.ts +21 -4
- package/lib/utils/ux/UxFileUtils.js +74 -5
- package/lib/utils/ux/UxFollowWorks.d.ts +1 -0
- package/lib/utils/ux/UxFollowWorks.js +60 -7
- package/lib/utils/ux/UxLoaderUtils.d.ts +11 -7
- package/lib/utils/ux/UxLoaderUtils.js +119 -33
- package/lib/utils/ux/UxPreWorks.d.ts +10 -0
- package/lib/utils/ux/UxPreWorks.js +31 -0
- package/lib/utils/xts/XtsFollowWorks.js +3 -12
- package/package.json +5 -10
- package/lib/compiler/enum/CompileMode.js.map +0 -1
- package/lib/compiler/interface/ICompileParam.js.map +0 -1
- package/lib/compiler/interface/ICompiler.js.map +0 -1
- package/lib/compiler/interface/ISignConfig.js.map +0 -1
- package/lib/compiler/javascript/JavascriptCompiler.js.map +0 -1
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +0 -1
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +0 -1
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +0 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +0 -1
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +0 -1
- package/lib/compiler/javascript/vela/enum/EntryType.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IChunk.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js.map +0 -1
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +0 -1
- package/lib/compiler/javascript/vela/model/Package.js.map +0 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +0 -1
- package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +0 -1
- package/lib/config/UxConfig.js.map +0 -1
- package/lib/config/XtsConfig.js.map +0 -1
- package/lib/followWorks/xts/entryTemplate.js.map +0 -1
- package/lib/followWorks/xts/generateRpk.js.map +0 -1
- package/lib/followWorks/xts/ts2wasm.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface/ICompileOptions.js.map +0 -1
- package/lib/interface/IDeviceList.js.map +0 -1
- package/lib/loader/ux/AppUxLoader.js.map +0 -1
- package/lib/loader/ux/PngLoader.js.map +0 -1
- package/lib/loader/ux/UxLoader.js.map +0 -1
- package/lib/loader/xts/XtsLoader.js.map +0 -1
- package/lib/preWorks/xts/preInstall.js.map +0 -1
- package/lib/utils/PngUtils.js.map +0 -1
- package/lib/utils/PreWorkUtils.js.map +0 -1
- package/lib/utils/ux/UxFileUtils.js.map +0 -1
- package/lib/utils/ux/UxFollowWorks.js.map +0 -1
- package/lib/utils/ux/UxLoaderUtils.js.map +0 -1
- package/lib/utils/xts/XtsFollowWorks.js.map +0 -1
|
@@ -13,10 +13,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
var _a;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
16
17
|
const del_1 = __importDefault(require("del"));
|
|
17
18
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
19
|
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const TranslateCache_1 = __importDefault(require("../../../parser/lib/ux/translate/vela/TranslateCache"));
|
|
19
21
|
const UxFileUtils_1 = __importDefault(require("./ux/UxFileUtils"));
|
|
22
|
+
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
20
23
|
/**
|
|
21
24
|
* PreWorkUtils
|
|
22
25
|
*/
|
|
@@ -37,11 +40,13 @@ class PreWorkUtils {
|
|
|
37
40
|
if (manifestContent) {
|
|
38
41
|
const { router } = manifestContent;
|
|
39
42
|
if (!router) {
|
|
40
|
-
//
|
|
43
|
+
// 没有router配置
|
|
44
|
+
ColorConsole_1.default.throw(`### manifest ### No router configuration`);
|
|
41
45
|
}
|
|
42
46
|
const { pages } = router;
|
|
43
47
|
if (!pages) {
|
|
44
|
-
//
|
|
48
|
+
// 没有pages配置
|
|
49
|
+
ColorConsole_1.default.throw(`### manifest ### No pages configuration`);
|
|
45
50
|
}
|
|
46
51
|
Object.keys(pages).map((page) => {
|
|
47
52
|
const pageContent = pages[page];
|
|
@@ -51,26 +56,51 @@ class PreWorkUtils {
|
|
|
51
56
|
entryList.push(entryPage);
|
|
52
57
|
}
|
|
53
58
|
else {
|
|
54
|
-
//
|
|
59
|
+
// 路径不存在
|
|
60
|
+
ColorConsole_1.default.throw(`### manifest ### path '${entryPage}' does not exist`);
|
|
55
61
|
}
|
|
56
62
|
});
|
|
57
63
|
context['entries'] = entryList;
|
|
58
64
|
return Promise.resolve();
|
|
59
65
|
}
|
|
60
66
|
else {
|
|
61
|
-
//
|
|
67
|
+
// manifest.json文件无有效内容
|
|
68
|
+
ColorConsole_1.default.error(`### manifest ### File has no valid content`);
|
|
62
69
|
return Promise.reject();
|
|
63
70
|
}
|
|
64
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* 获取项目的全局样式变量配置
|
|
74
|
+
* @param context
|
|
75
|
+
*/
|
|
76
|
+
static getGlobalVar(context) {
|
|
77
|
+
const { projectPath } = context;
|
|
78
|
+
const filePath = path_1.default.join(projectPath, 'src', 'globalVar.json');
|
|
79
|
+
let globalVar = {};
|
|
80
|
+
// 判断文件是否存在
|
|
81
|
+
if (fs_extra_1.default.existsSync(filePath)) {
|
|
82
|
+
// 存在则取内容,否则内容为空
|
|
83
|
+
globalVar = fs_extra_1.default.readJSONSync(filePath);
|
|
84
|
+
}
|
|
85
|
+
context.globalVar = globalVar;
|
|
86
|
+
return Promise.resolve();
|
|
87
|
+
}
|
|
65
88
|
}
|
|
66
89
|
_a = PreWorkUtils;
|
|
67
90
|
PreWorkUtils.clean = (context, _, config, compileOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
-
(0, del_1.default)(path_1.default.join(context.projectPath, context.output));
|
|
91
|
+
yield (0, del_1.default)(path_1.default.join(context.projectPath, context.output));
|
|
69
92
|
if (compileOption) {
|
|
70
|
-
(0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
|
|
71
|
-
(0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
|
|
93
|
+
yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
|
|
94
|
+
yield (0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
|
|
95
|
+
yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.outputPath));
|
|
96
|
+
yield (0, del_1.default)(path_1.default.join(context.projectPath, compileOption.releasePath));
|
|
72
97
|
}
|
|
98
|
+
TranslateCache_1.default.featureCache.clear();
|
|
99
|
+
BinaryPlugin.reset();
|
|
100
|
+
BinaryPlugin.config = {
|
|
101
|
+
projectPath: context.projectPath,
|
|
102
|
+
source: compileOption === null || compileOption === void 0 ? void 0 : compileOption.sourceRoot,
|
|
103
|
+
output: compileOption === null || compileOption === void 0 ? void 0 : compileOption.outputPath
|
|
104
|
+
};
|
|
73
105
|
});
|
|
74
106
|
exports.default = PreWorkUtils;
|
|
75
|
-
|
|
76
|
-
//# sourceMappingURL=PreWorkUtils.js.map
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ManifestSchema = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
required: ['package', 'name', 'icon', 'versionCode', 'config', 'router'],
|
|
6
|
+
properties: {
|
|
7
|
+
package: {
|
|
8
|
+
type: 'string'
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: 'string'
|
|
12
|
+
},
|
|
13
|
+
icon: {
|
|
14
|
+
type: 'string'
|
|
15
|
+
},
|
|
16
|
+
banner: {
|
|
17
|
+
type: 'string'
|
|
18
|
+
},
|
|
19
|
+
versionName: {
|
|
20
|
+
type: 'string'
|
|
21
|
+
},
|
|
22
|
+
versionCode: {
|
|
23
|
+
type: ['number']
|
|
24
|
+
},
|
|
25
|
+
minPlatformVersion: {
|
|
26
|
+
type: ['number']
|
|
27
|
+
},
|
|
28
|
+
features: {
|
|
29
|
+
type: 'array',
|
|
30
|
+
items: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
name: {
|
|
34
|
+
type: 'string'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
config: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
properties: {
|
|
42
|
+
logLevel: {
|
|
43
|
+
enum: ['off', 'error', 'warn', 'info', 'log', 'debug']
|
|
44
|
+
},
|
|
45
|
+
designWidth: {
|
|
46
|
+
type: ['number', 'string']
|
|
47
|
+
},
|
|
48
|
+
data: {
|
|
49
|
+
// TODO 全局数据对象,属性名不能以$或_开头,
|
|
50
|
+
type: 'object'
|
|
51
|
+
},
|
|
52
|
+
background: {
|
|
53
|
+
// TODO 更详细的后台运行配置信息,
|
|
54
|
+
type: 'object'
|
|
55
|
+
},
|
|
56
|
+
network: {
|
|
57
|
+
// TODO 更详细的网络配置信息,
|
|
58
|
+
type: 'object'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
router: {
|
|
63
|
+
// TODO 更详细的后台运行配置信息,
|
|
64
|
+
type: 'object',
|
|
65
|
+
required: ['entry', 'pages'],
|
|
66
|
+
properties: {
|
|
67
|
+
entry: {
|
|
68
|
+
type: 'string'
|
|
69
|
+
},
|
|
70
|
+
// TODO 看下 key 不确定能否校验值,
|
|
71
|
+
pages: {
|
|
72
|
+
type: 'object'
|
|
73
|
+
},
|
|
74
|
+
errorPage: {
|
|
75
|
+
type: 'string'
|
|
76
|
+
},
|
|
77
|
+
// TODO 看下 key 不确定能否校验值,
|
|
78
|
+
widgets: {
|
|
79
|
+
type: 'object'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
display: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
backgroundColor: {
|
|
87
|
+
// TODO HEXColor
|
|
88
|
+
type: 'string'
|
|
89
|
+
},
|
|
90
|
+
fullScreen: {
|
|
91
|
+
type: 'boolean'
|
|
92
|
+
},
|
|
93
|
+
titleBar: {
|
|
94
|
+
type: 'boolean'
|
|
95
|
+
},
|
|
96
|
+
titleBarBackgroundColor: {
|
|
97
|
+
// TODO HEXColor
|
|
98
|
+
type: 'string'
|
|
99
|
+
},
|
|
100
|
+
titleBarTextColor: {
|
|
101
|
+
// TODO HEXColor
|
|
102
|
+
type: 'string'
|
|
103
|
+
},
|
|
104
|
+
menu: {
|
|
105
|
+
type: 'boolean'
|
|
106
|
+
},
|
|
107
|
+
windowSoftInputMode: {
|
|
108
|
+
enum: ['adjustPan', 'adjustResize']
|
|
109
|
+
},
|
|
110
|
+
pages: {
|
|
111
|
+
type: 'object'
|
|
112
|
+
},
|
|
113
|
+
orientation: {
|
|
114
|
+
enum: ['portrait', 'landscape']
|
|
115
|
+
},
|
|
116
|
+
statusBarImmersive: {
|
|
117
|
+
type: 'boolean'
|
|
118
|
+
},
|
|
119
|
+
statusBarTextStyle: {
|
|
120
|
+
enum: ['light', 'dark', 'auto']
|
|
121
|
+
},
|
|
122
|
+
statusBarBackgroundColor: {
|
|
123
|
+
type: 'string'
|
|
124
|
+
},
|
|
125
|
+
statusBarBackgroundOpacity: {
|
|
126
|
+
type: 'number'
|
|
127
|
+
},
|
|
128
|
+
fitCutout: {
|
|
129
|
+
enum: ['none', 'portrait', 'landscape']
|
|
130
|
+
},
|
|
131
|
+
textSizeAdjust: {
|
|
132
|
+
enum: ['none', 'auto']
|
|
133
|
+
},
|
|
134
|
+
themeMode: {
|
|
135
|
+
enum: [-1, 0, 1]
|
|
136
|
+
},
|
|
137
|
+
menuBarData: {
|
|
138
|
+
// TODO 详细校验
|
|
139
|
+
type: 'object'
|
|
140
|
+
},
|
|
141
|
+
forceDark: {
|
|
142
|
+
type: 'boolean'
|
|
143
|
+
},
|
|
144
|
+
pageCache: {
|
|
145
|
+
type: 'boolean'
|
|
146
|
+
},
|
|
147
|
+
cacheDuration: {
|
|
148
|
+
type: 'number'
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
subpackages: {
|
|
153
|
+
// TODO 与后面的分包校验融合
|
|
154
|
+
type: 'array',
|
|
155
|
+
items: {
|
|
156
|
+
type: 'object',
|
|
157
|
+
properties: {
|
|
158
|
+
name: {
|
|
159
|
+
type: 'string'
|
|
160
|
+
},
|
|
161
|
+
// TODO 详细的规则校验
|
|
162
|
+
resource: {
|
|
163
|
+
type: 'string'
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
// 是否必须?
|
|
167
|
+
required: ['name', 'resource']
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
menuBarData: {
|
|
171
|
+
type: 'object',
|
|
172
|
+
properties: {
|
|
173
|
+
menuBar: {
|
|
174
|
+
type: 'boolean'
|
|
175
|
+
},
|
|
176
|
+
menuBarStyle: {
|
|
177
|
+
enum: ['dark', 'light']
|
|
178
|
+
},
|
|
179
|
+
shareTitle: {
|
|
180
|
+
type: 'string'
|
|
181
|
+
},
|
|
182
|
+
shareDescription: {
|
|
183
|
+
type: 'string'
|
|
184
|
+
},
|
|
185
|
+
shareIcon: {
|
|
186
|
+
type: 'string'
|
|
187
|
+
},
|
|
188
|
+
shareCurrentPage: {
|
|
189
|
+
type: 'string'
|
|
190
|
+
},
|
|
191
|
+
shareParams: {
|
|
192
|
+
type: 'string'
|
|
193
|
+
},
|
|
194
|
+
shareUrl: {
|
|
195
|
+
type: 'string'
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
deviceTypeList: {
|
|
200
|
+
type: 'array',
|
|
201
|
+
items: {
|
|
202
|
+
type: 'string'
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
exports.default = ManifestSchema;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import IManifest from '../../compiler/javascript/vela/interface/IManifest';
|
|
2
|
-
|
|
3
|
-
* FileUtils
|
|
4
|
-
*/
|
|
5
|
-
declare class UxFileUtils {
|
|
2
|
+
export declare class UxFileUtils {
|
|
6
3
|
static readonly CONFIG_FILE_NAME = "manifest.json";
|
|
7
4
|
/**
|
|
8
5
|
* 获取manifest.json路径
|
|
@@ -18,5 +15,25 @@ declare class UxFileUtils {
|
|
|
18
15
|
* @returns
|
|
19
16
|
*/
|
|
20
17
|
static getMainfestInfo(projectPath: string, sourceRoot?: string): IManifest;
|
|
18
|
+
/**
|
|
19
|
+
* 检查 manifest文件,并显示错误信息
|
|
20
|
+
*
|
|
21
|
+
* 1. TypeError,使用Error 样式
|
|
22
|
+
* 2. 其它错误,使用 Warn 样式
|
|
23
|
+
* 3. 如果存在TypeError,则终止程序
|
|
24
|
+
*
|
|
25
|
+
* @param projectPath 项目路径
|
|
26
|
+
* @param sourceRoot 源码路径--相对项目根目录
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
static validateManifest(projectPath: string, sourceRoot?: string): Error[] | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* 检查 sitemap.json 文件,并显示错误信息
|
|
32
|
+
*
|
|
33
|
+
* 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错并终止程序
|
|
34
|
+
* @param projectPath
|
|
35
|
+
* @param sourceRoot
|
|
36
|
+
*/
|
|
37
|
+
static validateSitemap(projectPath: string, sourceRoot?: string): void;
|
|
21
38
|
}
|
|
22
39
|
export default UxFileUtils;
|
|
@@ -3,11 +3,13 @@ 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
|
+
exports.UxFileUtils = void 0;
|
|
7
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
9
|
+
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
6
10
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
11
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
|
|
9
|
-
* FileUtils
|
|
10
|
-
*/
|
|
12
|
+
const ManifestSchema_1 = __importDefault(require("./ManifestSchema"));
|
|
11
13
|
class UxFileUtils {
|
|
12
14
|
/**
|
|
13
15
|
* 获取manifest.json路径
|
|
@@ -27,8 +29,75 @@ class UxFileUtils {
|
|
|
27
29
|
static getMainfestInfo(projectPath, sourceRoot = 'src') {
|
|
28
30
|
return fs_extra_1.default.readJSONSync(UxFileUtils.getManifestFilePath(projectPath, sourceRoot));
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* 检查 manifest文件,并显示错误信息
|
|
34
|
+
*
|
|
35
|
+
* 1. TypeError,使用Error 样式
|
|
36
|
+
* 2. 其它错误,使用 Warn 样式
|
|
37
|
+
* 3. 如果存在TypeError,则终止程序
|
|
38
|
+
*
|
|
39
|
+
* @param projectPath 项目路径
|
|
40
|
+
* @param sourceRoot 源码路径--相对项目根目录
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static validateManifest(projectPath, sourceRoot = 'src') {
|
|
44
|
+
const path = UxFileUtils.getManifestFilePath(projectPath, sourceRoot);
|
|
45
|
+
if (!fs_extra_1.default.existsSync(path)) {
|
|
46
|
+
ColorConsole_1.default.throw(`file is missing`, {
|
|
47
|
+
word: path,
|
|
48
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const jsonData = this.getMainfestInfo(projectPath, sourceRoot);
|
|
52
|
+
const schema = ManifestSchema_1.default;
|
|
53
|
+
const errors = CommonUtil_1.default.validateJson(jsonData, schema);
|
|
54
|
+
if (errors) {
|
|
55
|
+
ColorConsole_1.default.warn(`Manefest.json error: `, ...errors.map((item, index) => {
|
|
56
|
+
return {
|
|
57
|
+
word: `\r\n${index + 1}. ${item.message}`,
|
|
58
|
+
style: item instanceof TypeError
|
|
59
|
+
? ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Error)
|
|
60
|
+
: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Warn)
|
|
61
|
+
};
|
|
62
|
+
}));
|
|
63
|
+
const stop = Boolean(errors.find((item) => item instanceof TypeError));
|
|
64
|
+
if (stop) {
|
|
65
|
+
ColorConsole_1.default.throw({
|
|
66
|
+
word: `missing required content, program stoped`,
|
|
67
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return errors;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* 检查 sitemap.json 文件,并显示错误信息
|
|
75
|
+
*
|
|
76
|
+
* 1. 当sitemap.json的 rules 中配置的page 不存在于 manifest.json 中时,报错并终止程序
|
|
77
|
+
* @param projectPath
|
|
78
|
+
* @param sourceRoot
|
|
79
|
+
*/
|
|
80
|
+
static validateSitemap(projectPath, sourceRoot = 'src') {
|
|
81
|
+
const sitemapPath = path_1.default.join(projectPath, sourceRoot, 'sitemap.json');
|
|
82
|
+
if (fs_extra_1.default.existsSync(sitemapPath)) {
|
|
83
|
+
try {
|
|
84
|
+
const rules = fs_extra_1.default.readJSONSync(sitemapPath).rules;
|
|
85
|
+
const manifest = this.getMainfestInfo(projectPath, sourceRoot);
|
|
86
|
+
const pages = Object.keys(manifest.router.pages || {});
|
|
87
|
+
rules.forEach((item, index) => {
|
|
88
|
+
const page = item.page;
|
|
89
|
+
if (page !== '*' && !pages.includes(page)) {
|
|
90
|
+
ColorConsole_1.default.throw(`The ${index + 1}th item of sitemap rules is configured incorrectly, the page ${page} does not exist`);
|
|
91
|
+
}
|
|
92
|
+
return page;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
ColorConsole_1.default.warn(error === null || error === void 0 ? void 0 : error.toString());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
30
100
|
}
|
|
101
|
+
exports.UxFileUtils = UxFileUtils;
|
|
31
102
|
UxFileUtils.CONFIG_FILE_NAME = 'manifest.json';
|
|
32
103
|
exports.default = UxFileUtils;
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=UxFileUtils.js.map
|
|
@@ -5,6 +5,7 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
|
|
|
5
5
|
*/
|
|
6
6
|
declare class UxFollowWorks {
|
|
7
7
|
static webpack: FollowWork<IJavascriptCompileOption>;
|
|
8
|
+
static protobuf: FollowWork<IJavascriptCompileOption>;
|
|
8
9
|
static jsc: FollowWork<IJavascriptCompileOption>;
|
|
9
10
|
static toRpk: FollowWork<IJavascriptCompileOption>;
|
|
10
11
|
/**
|
|
@@ -13,6 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
var _a;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const TranslateCache_1 = __importDefault(require("@aiot-toolkit/parser/lib//ux/translate/vela/TranslateCache"));
|
|
17
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
18
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
16
19
|
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
17
20
|
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
18
21
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -24,6 +27,7 @@ const JavascriptDefaultCompileOption_1 = __importDefault(require("../../compiler
|
|
|
24
27
|
const Jsc_1 = __importDefault(require("../../compiler/javascript/vela/utils/Jsc"));
|
|
25
28
|
const ZipUtil_1 = __importDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
|
|
26
29
|
const UxFileUtils_1 = __importDefault(require("./UxFileUtils"));
|
|
30
|
+
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
27
31
|
/**
|
|
28
32
|
* UxFollowWorks
|
|
29
33
|
*/
|
|
@@ -31,10 +35,50 @@ class UxFollowWorks {
|
|
|
31
35
|
}
|
|
32
36
|
_a = UxFollowWorks;
|
|
33
37
|
UxFollowWorks.webpack = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
-
|
|
38
|
+
return new JavascriptCompiler_1.default()
|
|
39
|
+
.compile(Object.assign(Object.assign({ projectPath: path_1.default.join(context.projectPath, context.output), mode: CompileMode_1.default.DEVELOPMENT, devtool: false, platform: 'vela' }, JavascriptDefaultCompileOption_1.default), compilerOption))
|
|
40
|
+
.then(() => {
|
|
41
|
+
ColorConsole_1.default.info(`webpack complete`);
|
|
42
|
+
})
|
|
43
|
+
.catch(({ errors, warnings }) => {
|
|
44
|
+
const errorLength = (errors === null || errors === void 0 ? void 0 : errors.length) || 0;
|
|
45
|
+
const messages = [`webpack error:\r\n`];
|
|
46
|
+
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
47
|
+
messages.push({
|
|
48
|
+
word: errors
|
|
49
|
+
.map((item, index) => {
|
|
50
|
+
return `${index + 1}. ${item.message}`;
|
|
51
|
+
})
|
|
52
|
+
.join('\r\n'),
|
|
53
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Throw)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (warnings === null || warnings === void 0 ? void 0 : warnings.length) {
|
|
57
|
+
messages.push({
|
|
58
|
+
word: warnings
|
|
59
|
+
.map((item, index) => {
|
|
60
|
+
return `${errorLength + index + 1}. ${item.message}`;
|
|
61
|
+
})
|
|
62
|
+
.join('\r\n'),
|
|
63
|
+
style: ColorConsole_1.default.getStyle(shared_utils_1.LOG_LEVEL.Warn)
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (errors === null || errors === void 0 ? void 0 : errors.length) {
|
|
67
|
+
ColorConsole_1.default.throw(...messages);
|
|
68
|
+
throw new Error();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
ColorConsole_1.default.warn(...messages);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
UxFollowWorks.protobuf = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
if (compilerOption === null || compilerOption === void 0 ? void 0 : compilerOption.enableProtobuf) {
|
|
77
|
+
BinaryPlugin.createBinFiles();
|
|
78
|
+
}
|
|
35
79
|
});
|
|
36
80
|
UxFollowWorks.jsc = (context, config, compilerOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
if (compilerOption &&
|
|
81
|
+
if (compilerOption && compilerOption.disabledJSC === false) {
|
|
38
82
|
return new Jsc_1.default(context.projectPath, path_1.default.join(context.projectPath, context.output, compilerOption.outputPath)).jsc();
|
|
39
83
|
}
|
|
40
84
|
});
|
|
@@ -54,6 +98,7 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
54
98
|
const { projectPath, sourceRoot, outputPath } = compilerOption;
|
|
55
99
|
const manifest = fs_extra_1.default.readJSONSync(path_1.default.join(projectPath, sourceRoot, 'manifest.json'));
|
|
56
100
|
const { deviceTypeList } = manifest;
|
|
101
|
+
// 生成设备的 manifest 文件,规则为:manifest.json + config-设备类型.json
|
|
57
102
|
if (deviceTypeList) {
|
|
58
103
|
deviceTypeList.forEach((deviceType) => {
|
|
59
104
|
let data = Object.assign({}, manifest);
|
|
@@ -87,7 +132,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
87
132
|
'md',
|
|
88
133
|
'ux',
|
|
89
134
|
'mix',
|
|
90
|
-
'DS_Store'
|
|
135
|
+
'DS_Store',
|
|
136
|
+
'map'
|
|
91
137
|
];
|
|
92
138
|
const excludeReg = `\.(${excludeExtList.join('|')})$`;
|
|
93
139
|
FileUtil_1.default.copyFiles(path_1.default.join(projectPath, sourceRoot), path_1.default.join(projectPath, outputPath), new RegExp(excludeReg));
|
|
@@ -108,6 +154,15 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
108
154
|
if (!content.packageInfo) {
|
|
109
155
|
content.packageInfo = ZipUtil_1.default.createComment(compilerOption);
|
|
110
156
|
}
|
|
157
|
+
if (TranslateCache_1.default.featureCache.size) {
|
|
158
|
+
const featureSet = new Set([
|
|
159
|
+
...Array.from(TranslateCache_1.default.featureCache),
|
|
160
|
+
...(content.features || []).map((item) => item.name)
|
|
161
|
+
]);
|
|
162
|
+
content.features = Array.from(featureSet).map((item) => {
|
|
163
|
+
return { name: item };
|
|
164
|
+
});
|
|
165
|
+
}
|
|
111
166
|
fs_extra_1.default.writeJSONSync(path_1.default.join(projectPath, outputPath, UxFileUtils_1.default.CONFIG_FILE_NAME), content, {
|
|
112
167
|
spaces: 2
|
|
113
168
|
});
|
|
@@ -141,8 +196,8 @@ UxFollowWorks.copyResource = (context, config, compilerOption) => __awaiter(void
|
|
|
141
196
|
});
|
|
142
197
|
if (compilerOption) {
|
|
143
198
|
copyResourceFiles(compilerOption);
|
|
144
|
-
genDeviceManifests(compilerOption);
|
|
145
199
|
updateManifest(compilerOption);
|
|
200
|
+
genDeviceManifests(compilerOption);
|
|
146
201
|
yield genMetaFiles(compilerOption);
|
|
147
202
|
}
|
|
148
203
|
});
|
|
@@ -191,10 +246,8 @@ UxFollowWorks.symlinkNodeModule = (context, config, compilerOption) => __awaiter
|
|
|
191
246
|
foldList.forEach((item) => {
|
|
192
247
|
const sourcePath = path_1.default.join(context.projectPath, item);
|
|
193
248
|
if (fs_extra_1.default.existsSync(sourcePath)) {
|
|
194
|
-
fs_extra_1.default.symlinkSync(sourcePath, path_1.default.join(compilerOption.projectPath, item));
|
|
249
|
+
fs_extra_1.default.symlinkSync(sourcePath, path_1.default.join(compilerOption.projectPath, item), 'junction');
|
|
195
250
|
}
|
|
196
251
|
});
|
|
197
252
|
});
|
|
198
253
|
exports.default = UxFollowWorks;
|
|
199
|
-
|
|
200
|
-
//# sourceMappingURL=UxFollowWorks.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ILog } from '@aiot-toolkit/shared-utils';
|
|
1
2
|
import { IFileLaneContext, IFileParam } from 'file-lane';
|
|
2
3
|
import { SourceFile } from 'ts-morph';
|
|
4
|
+
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
5
|
/**
|
|
4
6
|
* UxLoaderUtils
|
|
5
7
|
*/
|
|
@@ -12,17 +14,17 @@ declare class UxLoaderUtils {
|
|
|
12
14
|
* @param project
|
|
13
15
|
* @returns
|
|
14
16
|
*/
|
|
15
|
-
static compileUxToJavascript(file: IFileParam, context: IFileLaneContext, isAppUx: boolean): Promise<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
17
|
+
static compileUxToJavascript(file: IFileParam, context: IFileLaneContext, isAppUx: boolean, compilerOption: IJavascriptCompileOption): Promise<{
|
|
18
|
+
files: IFileParam[];
|
|
19
|
+
logs: ILog[];
|
|
20
|
+
}>;
|
|
19
21
|
/**
|
|
20
22
|
* 转换app.ux文件为js文件
|
|
21
23
|
* @param file
|
|
22
24
|
* @param resultFiles
|
|
23
25
|
* @param context
|
|
24
26
|
*/
|
|
25
|
-
static compileAppUxToJavascript(file: IFileParam, resultFiles: IFileParam[], context: IFileLaneContext): Promise<void>;
|
|
27
|
+
static compileAppUxToJavascript(file: IFileParam, resultFiles: IFileParam[], context: IFileLaneContext, compileOption: IJavascriptCompileOption): Promise<void>;
|
|
26
28
|
/**
|
|
27
29
|
* 判断是否为src/app.ux
|
|
28
30
|
* @param filePath
|
|
@@ -42,12 +44,14 @@ declare class UxLoaderUtils {
|
|
|
42
44
|
* @returns
|
|
43
45
|
*/
|
|
44
46
|
static getAppUxContent(fileContent: string): string;
|
|
47
|
+
private static addTemplateProtobuf;
|
|
45
48
|
/**
|
|
46
49
|
* 给template增加外层包裹内容
|
|
47
50
|
* @param templateTree
|
|
48
51
|
* @returns
|
|
49
52
|
*/
|
|
50
|
-
static wrapTempalte(templateTree: SourceFile): string;
|
|
53
|
+
static wrapTempalte(templateTree: SourceFile, file: IFileParam, compilerOption: IJavascriptCompileOption): string;
|
|
54
|
+
private static wrapStyle;
|
|
51
55
|
/**
|
|
52
56
|
* 给script增加外层包裹内容
|
|
53
57
|
* @param isPageUx
|
|
@@ -55,6 +59,6 @@ declare class UxLoaderUtils {
|
|
|
55
59
|
* @returns
|
|
56
60
|
*/
|
|
57
61
|
static handleScriptContent(isPageUx: boolean, appScriptTree: SourceFile): string;
|
|
58
|
-
static getReturnType(isPageUx: boolean): "$app_exports$['entry'] =" | "
|
|
62
|
+
static getReturnType(isPageUx: boolean): "$app_exports$['entry'] =" | "module.exports = ";
|
|
59
63
|
}
|
|
60
64
|
export default UxLoaderUtils;
|