@aiot-toolkit/aiotpack 2.0.1-alpha.8 → 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.d.ts +2 -2
- 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.d.ts +2 -1
- package/lib/followWorks/xts/generateRpk.js +7 -3
- package/lib/followWorks/xts/ts2wasm.d.ts +2 -1
- package/lib/followWorks/xts/ts2wasm.js +17 -17
- package/lib/index.js +0 -2
- package/lib/interface/ICompileOptions.d.ts +6 -0
- package/lib/interface/ICompileOptions.js +4 -0
- 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.d.ts +2 -1
- package/lib/preWorks/xts/preInstall.js +11 -5
- 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/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
|
@@ -38,12 +38,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
const generator_1 = require("@aiot-toolkit/generator");
|
|
39
39
|
const UxParser_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/parser/UxParser"));
|
|
40
40
|
const UxToTypescript_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/UxToTypescript"));
|
|
41
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
42
41
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
43
42
|
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
43
|
+
const StringUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/StringUtil"));
|
|
44
44
|
const parse5 = __importStar(require("parse5"));
|
|
45
45
|
const path_1 = __importDefault(require("path"));
|
|
46
46
|
const ts_morph_1 = require("ts-morph");
|
|
47
|
+
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
48
|
+
const { extractFunctions } = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/protobufControl');
|
|
47
49
|
/**
|
|
48
50
|
* UxLoaderUtils
|
|
49
51
|
*/
|
|
@@ -55,9 +57,10 @@ class UxLoaderUtils {
|
|
|
55
57
|
* @param project
|
|
56
58
|
* @returns
|
|
57
59
|
*/
|
|
58
|
-
static compileUxToJavascript(file, context, isAppUx) {
|
|
60
|
+
static compileUxToJavascript(file, context, isAppUx, compilerOption) {
|
|
59
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
62
|
const project = new ts_morph_1.Project();
|
|
63
|
+
const logs = [];
|
|
61
64
|
const { path: filePath, content } = file;
|
|
62
65
|
const { name, ext } = path_1.default.parse(filePath);
|
|
63
66
|
const fullName = `${name}${ext}`;
|
|
@@ -65,29 +68,34 @@ class UxLoaderUtils {
|
|
|
65
68
|
const newFileName = `${name}.js`;
|
|
66
69
|
//判断文本,空文本则结束该文件处理
|
|
67
70
|
if (!content) {
|
|
68
|
-
ColorConsole_1.default.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
ColorConsole_1.default.warn(`The file '${fullName}' under the path '${filePath}' has no content `);
|
|
72
|
+
return {
|
|
73
|
+
files: [],
|
|
74
|
+
logs
|
|
75
|
+
};
|
|
73
76
|
}
|
|
74
77
|
// 配置转换参数
|
|
75
78
|
const options = {
|
|
76
79
|
projectPath: context.projectPath,
|
|
77
|
-
filePath
|
|
80
|
+
filePath,
|
|
81
|
+
onLog: (log) => {
|
|
82
|
+
logs.push(log);
|
|
83
|
+
}
|
|
78
84
|
};
|
|
79
85
|
// 开始转换
|
|
80
|
-
const
|
|
86
|
+
const globalVar = ('globalVar' in context && context.globalVar) || {};
|
|
87
|
+
const parserResult = yield new UxParser_1.default(options, globalVar).parser(content.toString(), fullName);
|
|
81
88
|
// 区分app.ux和一般ux
|
|
82
89
|
// app.ux解析结果中加上manifest.json的内容
|
|
83
90
|
const manifestJson = `require('./manifest.json')`;
|
|
84
91
|
// 区分页面组件和子组件
|
|
85
92
|
const isPageUx = UxLoaderUtils.isPageUx(context, filePath);
|
|
86
93
|
const integrateFunction = (appImport, appStyleTree, appTemplateTree, appScriptTree) => {
|
|
94
|
+
// script代码放在第三个位置不能变化,影响更新source map
|
|
87
95
|
return isAppUx
|
|
88
96
|
? [
|
|
89
97
|
`${appImport.join('\n')}`,
|
|
90
|
-
`var $app_style$ = ${
|
|
98
|
+
`var $app_style$ = ${UxLoaderUtils.wrapStyle(StringUtil_1.default.arrayTostring(appStyleTree, true), file, compilerOption)}`,
|
|
91
99
|
`var $app_script$ = ${UxLoaderUtils.handleScriptContent(false, appScriptTree)}\n`,
|
|
92
100
|
`$app_script$({}, $app_exports$, $app_require$);\n\n`,
|
|
93
101
|
`$app_exports$.default.style = $app_style$;`,
|
|
@@ -95,9 +103,9 @@ class UxLoaderUtils {
|
|
|
95
103
|
]
|
|
96
104
|
: [
|
|
97
105
|
`${appImport.join('\n')}`,
|
|
98
|
-
`var $app_style$ = ${
|
|
106
|
+
`var $app_style$ = ${UxLoaderUtils.wrapStyle(StringUtil_1.default.arrayTostring(appStyleTree, true), file, compilerOption)}\n`,
|
|
99
107
|
`var $app_script$ = ${UxLoaderUtils.handleScriptContent(isPageUx, appScriptTree)}`,
|
|
100
|
-
`var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree)}\n`,
|
|
108
|
+
`var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree, file, compilerOption)}\n`,
|
|
101
109
|
`${UxLoaderUtils.getReturnType(isPageUx)} function ($app_exports$) {`,
|
|
102
110
|
`$app_script$({}, $app_exports$, $app_require$);`,
|
|
103
111
|
`$app_exports$.default.template = $app_template$;`,
|
|
@@ -105,24 +113,27 @@ class UxLoaderUtils {
|
|
|
105
113
|
`}`
|
|
106
114
|
];
|
|
107
115
|
};
|
|
108
|
-
const { targetTree, mapList } = new UxToTypescript_1.default(options, project, integrateFunction).translate(parserResult.ast, []);
|
|
109
|
-
const { code
|
|
116
|
+
const { targetTree, mapList, sourceMap } = yield new UxToTypescript_1.default(options, project, integrateFunction, compilerOption).translate(parserResult.ast, []);
|
|
117
|
+
const { code } = new generator_1.TypescriptGenerator().generate({
|
|
110
118
|
sourceFilePath: fullName,
|
|
111
119
|
targetFilePath: newFileName,
|
|
112
120
|
ast: targetTree,
|
|
113
121
|
mapList
|
|
114
122
|
});
|
|
115
123
|
// 返回转换后的文件内容以及map内容
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
return {
|
|
125
|
+
files: [
|
|
126
|
+
{
|
|
127
|
+
path: FileUtil_1.default.updatePath(filePath, newFileName),
|
|
128
|
+
content: code
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
path: FileUtil_1.default.updatePath(filePath, `${name}.js.map`),
|
|
132
|
+
content: sourceMap.toString()
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
logs
|
|
136
|
+
};
|
|
126
137
|
});
|
|
127
138
|
}
|
|
128
139
|
/**
|
|
@@ -131,7 +142,7 @@ class UxLoaderUtils {
|
|
|
131
142
|
* @param resultFiles
|
|
132
143
|
* @param context
|
|
133
144
|
*/
|
|
134
|
-
static compileAppUxToJavascript(file, resultFiles, context) {
|
|
145
|
+
static compileAppUxToJavascript(file, resultFiles, context, compileOption) {
|
|
135
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
147
|
const { path: filePath, content } = file;
|
|
137
148
|
let appContent = content;
|
|
@@ -141,8 +152,8 @@ class UxLoaderUtils {
|
|
|
141
152
|
appContent = UxLoaderUtils.getAppUxContent(content);
|
|
142
153
|
}
|
|
143
154
|
// 解析script和style两部分
|
|
144
|
-
const
|
|
145
|
-
resultFiles.push(...
|
|
155
|
+
const compileResult = yield UxLoaderUtils.compileUxToJavascript({ path: filePath, content: appContent }, context, isAppUx, compileOption);
|
|
156
|
+
resultFiles.push(...compileResult.files);
|
|
146
157
|
});
|
|
147
158
|
}
|
|
148
159
|
/**
|
|
@@ -184,16 +195,93 @@ class UxLoaderUtils {
|
|
|
184
195
|
}
|
|
185
196
|
return parse5.serialize(parentNode);
|
|
186
197
|
}
|
|
198
|
+
static addTemplateProtobuf(file, code) {
|
|
199
|
+
const funToString = (fun) => {
|
|
200
|
+
const { aiotfor, aiotcb } = fun;
|
|
201
|
+
// 如果aiotfor存在,需要把函数体替换为aiotfor.funcArr
|
|
202
|
+
if (aiotfor) {
|
|
203
|
+
const { funcArr = [], key, value } = aiotfor;
|
|
204
|
+
const forFun = `function(${key || '$idx'}, ${value || '$item'}) {
|
|
205
|
+
return [
|
|
206
|
+
${funcArr.map((item) => funToString(item)).join(',\r\n')}
|
|
207
|
+
]
|
|
208
|
+
}`;
|
|
209
|
+
return forFun;
|
|
210
|
+
}
|
|
211
|
+
if (aiotcb) {
|
|
212
|
+
const { funcArr = [] } = aiotcb;
|
|
213
|
+
const cbFun = `function($data){
|
|
214
|
+
return [
|
|
215
|
+
${funcArr.map((item) => funToString(item)).join(',\r\n')}
|
|
216
|
+
]
|
|
217
|
+
}`;
|
|
218
|
+
return cbFun;
|
|
219
|
+
}
|
|
220
|
+
return fun.toString();
|
|
221
|
+
};
|
|
222
|
+
const stringifyObjectWithFunctions = (obj) => {
|
|
223
|
+
const processValue = (value) => {
|
|
224
|
+
if (typeof value === 'function') {
|
|
225
|
+
return value.toString();
|
|
226
|
+
}
|
|
227
|
+
else if (typeof value === 'object' && value !== null) {
|
|
228
|
+
return stringifyObjectWithFunctions(value);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
return JSON.stringify(value, undefined, 2);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const entries = Object.entries(obj).map(([key, value]) => {
|
|
235
|
+
return `"${key}": ${processValue(value)}`;
|
|
236
|
+
});
|
|
237
|
+
return `{
|
|
238
|
+
${entries.join(',\r\n ')}
|
|
239
|
+
}`;
|
|
240
|
+
};
|
|
241
|
+
const { path } = file;
|
|
242
|
+
const aiot = extractFunctions(code);
|
|
243
|
+
const { funcArr = [], optArr } = aiot;
|
|
244
|
+
const templateResult = BinaryPlugin.addTemplate(path, path, code);
|
|
245
|
+
BinaryPlugin.addTagName(path, path);
|
|
246
|
+
const result = `function (vm) {
|
|
247
|
+
const _vm_ = vm || this
|
|
248
|
+
return aiot.__cv__(
|
|
249
|
+
"${templateResult.name}",
|
|
250
|
+
${templateResult.index},
|
|
251
|
+
{
|
|
252
|
+
__vm__:_vm_,
|
|
253
|
+
__func__:[
|
|
254
|
+
${funcArr.map((item) => funToString(item)).join(',\r\n')}
|
|
255
|
+
],
|
|
256
|
+
__optsArr__:[
|
|
257
|
+
${optArr.map((item) => stringifyObjectWithFunctions(item))},
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
}`;
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
187
264
|
/**
|
|
188
265
|
* 给template增加外层包裹内容
|
|
189
266
|
* @param templateTree
|
|
190
267
|
* @returns
|
|
191
268
|
*/
|
|
192
|
-
static wrapTempalte(templateTree) {
|
|
193
|
-
|
|
269
|
+
static wrapTempalte(templateTree, file, compilerOption) {
|
|
270
|
+
const result = `function (vm) {
|
|
194
271
|
const _vm_ = vm || this
|
|
195
272
|
return ${templateTree.getFullText()}
|
|
196
273
|
}`;
|
|
274
|
+
if (compilerOption.enableProtobuf) {
|
|
275
|
+
return this.addTemplateProtobuf(file, result);
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
static wrapStyle(code, file, compilerOption) {
|
|
280
|
+
if (compilerOption.enableProtobuf) {
|
|
281
|
+
const result = BinaryPlugin.addStyle(file.path, file.path, code);
|
|
282
|
+
return `['${result.name}', ${result.index}]`;
|
|
283
|
+
}
|
|
284
|
+
return code;
|
|
197
285
|
}
|
|
198
286
|
/**
|
|
199
287
|
* 给script增加外层包裹内容
|
|
@@ -206,10 +294,10 @@ class UxLoaderUtils {
|
|
|
206
294
|
// 页面组件添加ViewModel处理代码
|
|
207
295
|
appScriptTree.addStatements(UxLoaderUtils.contenAccess);
|
|
208
296
|
}
|
|
209
|
-
return `function __scriptModule__(module, exports, $app_require$) {\t${appScriptTree.getFullText()}}`;
|
|
297
|
+
return `function __scriptModule__(module, exports, $app_require$) {\t${appScriptTree.getFullText()}\n}`;
|
|
210
298
|
}
|
|
211
299
|
static getReturnType(isPageUx) {
|
|
212
|
-
return isPageUx ? `$app_exports$['entry'] =` : '
|
|
300
|
+
return isPageUx ? `$app_exports$['entry'] =` : 'module.exports = ';
|
|
213
301
|
}
|
|
214
302
|
}
|
|
215
303
|
// 页面组件需要添加ViewModel数据校验和处理代码
|
|
@@ -237,5 +325,3 @@ UxLoaderUtils.contenAccess = `\n
|
|
|
237
325
|
})
|
|
238
326
|
}`;
|
|
239
327
|
exports.default = UxLoaderUtils;
|
|
240
|
-
|
|
241
|
-
//# sourceMappingURL=UxLoaderUtils.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PreWork } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
2
|
+
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
+
/**
|
|
4
|
+
* UxPreWorks
|
|
5
|
+
*/
|
|
6
|
+
declare class UxPreWorks {
|
|
7
|
+
static validateManifest: PreWork<IJavascriptCompileOption>;
|
|
8
|
+
static validateSitemap: PreWork<IJavascriptCompileOption>;
|
|
9
|
+
}
|
|
10
|
+
export default UxPreWorks;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var _a;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const UxFileUtils_1 = __importDefault(require("./UxFileUtils"));
|
|
17
|
+
/**
|
|
18
|
+
* UxPreWorks
|
|
19
|
+
*/
|
|
20
|
+
class UxPreWorks {
|
|
21
|
+
}
|
|
22
|
+
_a = UxPreWorks;
|
|
23
|
+
UxPreWorks.validateManifest = (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const { projectPath } = context;
|
|
25
|
+
return UxFileUtils_1.default.validateManifest(projectPath);
|
|
26
|
+
});
|
|
27
|
+
UxPreWorks.validateSitemap = (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const { projectPath } = context;
|
|
29
|
+
UxFileUtils_1.default.validateSitemap(projectPath);
|
|
30
|
+
});
|
|
31
|
+
exports.default = UxPreWorks;
|
|
@@ -12,7 +12,6 @@ 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 shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
15
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
17
16
|
const FileLaneUtil_1 = __importDefault(require("file-lane/lib/utils/FileLaneUtil"));
|
|
18
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -34,10 +33,7 @@ class XtsFollowWorks {
|
|
|
34
33
|
const zipPath = path_1.default.join(projectPath, 'dist');
|
|
35
34
|
// buildPath必须是真实文件夹路径
|
|
36
35
|
if (!fs_extra_1.default.existsSync(buildPath)) {
|
|
37
|
-
ColorConsole_1.default.
|
|
38
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
39
|
-
message: `XtsConfig follwWorkers zip build error, buildPath not exist`
|
|
40
|
-
});
|
|
36
|
+
ColorConsole_1.default.throw(`buildPath: '${buildPath}' not exist`);
|
|
41
37
|
}
|
|
42
38
|
try {
|
|
43
39
|
// 确认文件夹是否存在,不存在则创建
|
|
@@ -48,7 +44,7 @@ class XtsFollowWorks {
|
|
|
48
44
|
yield FileLaneUtil_1.default.zipProject([buildPath], filePath, [options.packageName]);
|
|
49
45
|
}
|
|
50
46
|
catch (err) {
|
|
51
|
-
ColorConsole_1.default.
|
|
47
|
+
ColorConsole_1.default.throw(`${err.message}`);
|
|
52
48
|
}
|
|
53
49
|
});
|
|
54
50
|
}
|
|
@@ -125,10 +121,7 @@ class XtsFollowWorks {
|
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
123
|
else {
|
|
128
|
-
ColorConsole_1.default.
|
|
129
|
-
level: shared_utils_1.LOG_LEVEL.Error,
|
|
130
|
-
message: 'zip DistributedQuickApp not find manifest.json'
|
|
131
|
-
});
|
|
124
|
+
ColorConsole_1.default.throw('not find manifest.json');
|
|
132
125
|
}
|
|
133
126
|
});
|
|
134
127
|
}
|
|
@@ -146,5 +139,3 @@ class XtsFollowWorks {
|
|
|
146
139
|
}
|
|
147
140
|
}
|
|
148
141
|
exports.default = XtsFollowWorks;
|
|
149
|
-
|
|
150
|
-
//# sourceMappingURL=XtsFollowWorks.js.map
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2-beta.1",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
7
7
|
],
|
|
8
|
-
"author": "徐俊杰 <xujunjie1@xiaomi.com>",
|
|
9
8
|
"homepage": "",
|
|
10
9
|
"license": "ISC",
|
|
11
10
|
"main": "lib/index.js",
|
|
@@ -16,21 +15,17 @@
|
|
|
16
15
|
"files": [
|
|
17
16
|
"lib"
|
|
18
17
|
],
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "ssh://xujunjie1@git.mioffice.cn:29418/vela/aiot-toolkit"
|
|
22
|
-
},
|
|
23
18
|
"scripts": {
|
|
24
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
25
20
|
},
|
|
26
21
|
"dependencies": {
|
|
27
|
-
"@aiot-toolkit/generator": "2.0.
|
|
28
|
-
"@aiot-toolkit/parser": "2.0.
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.2-beta.1",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.2-beta.1",
|
|
29
24
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
30
25
|
"babel-loader": "^9.1.3",
|
|
31
26
|
"del": "^4.1.0",
|
|
32
27
|
"fast-glob": "^3.3.2",
|
|
33
|
-
"file-lane": "2.0.
|
|
28
|
+
"file-lane": "2.0.2-beta.1",
|
|
34
29
|
"file-loader": "^6.2.0",
|
|
35
30
|
"fs-extra": "^11.2.0",
|
|
36
31
|
"jsrsasign": "^7.2.2",
|
|
@@ -43,5 +38,5 @@
|
|
|
43
38
|
"@types/jsrsasign": "^10.5.12",
|
|
44
39
|
"@types/webpack-sources": "^3.2.3"
|
|
45
40
|
},
|
|
46
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "9244af36e617295ea4ff11a2f4f07f0e4f9f5f59"
|
|
47
42
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/enum/CompileMode.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAK,WAUJ;AAVD,WAAK,WAAW;IACd;;OAEG;IACH,0CAA2B,CAAA;IAE3B;;OAEG;IACH,wCAAyB,CAAA;AAC3B,CAAC,EAVI,WAAW,KAAX,WAAW,QAUf;AACD,WAAU,WAAW;IACnB;;;;OAIG;IACH,SAAgB,gBAAgB,CAAC,KAAkB;QACjD,OAAO,KAAK,KAAK,WAAW,CAAC,UAAU,CAAA;IACzC,CAAC;IAFe,4BAAgB,mBAE/B,CAAA;AACH,CAAC,EATS,WAAW,KAAX,WAAW,QASpB;AACD,kBAAe,WAAW,CAAA","file":"CompileMode.js","sourcesContent":["/**\n * 编译模式枚举\n */\nenum CompileMode {\n /**\n * 开发模式\n */\n DEVELOPMENT = 'development',\n\n /**\n * 生产模式\n */\n PRODUCTION = 'production'\n}\nnamespace CompileMode {\n /**\n * 判断是否为生产模式\n * @param value\n * @returns\n */\n export function isProductionMode(value: CompileMode): boolean {\n return value === CompileMode.PRODUCTION\n }\n} \nexport default CompileMode\n"],"sourceRoot":"../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/interface/ICompileParam.ts"],"names":[],"mappings":"","file":"ICompileParam.js","sourcesContent":["import { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\nimport CompileMode from '../enum/CompileMode'\n\n/**\n * 编译参数\n */\nexport default interface ICompileParam extends Dictionary<any> {\n /**\n * 项目路径\n */\n projectPath: string\n\n /**\n * 打包模式,开发环境/生产环境\n */\n mode: CompileMode\n\n platform: string\n\n /**\n * 打包来源\n *\n * cmd:命令行\n * quickapp-ide:快应用 IDE\n * 其它自定义值\n */\n originType?: string\n}\n"],"sourceRoot":"../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/interface/ICompiler.ts"],"names":[],"mappings":"","file":"ICompiler.js","sourcesContent":["import ICompileParam from \"./ICompileParam\";\n\nexport default interface ICompiler {\n compile(param: ICompileParam): Promise<void>;\n clean(param: ICompileParam): Promise<void>;\n}\n"],"sourceRoot":"../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/interface/ISignConfig.ts"],"names":[],"mappings":"","file":"ISignConfig.js","sourcesContent":["/**\n * ISignConfig\n */\nexport default interface ISignConfig {\n privatekey: Buffer\n certificate: Buffer\n}\n"],"sourceRoot":"../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/JavascriptCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iGAAwE;AACxE,gDAAuB;AACvB,qCAAgD;AAKhD,6FAAoE;AACpE,+EAAsD;AAEtD,MAAM,kBAAkB;IAChB,OAAO,CAAC,KAA+B;;YAC3C,OAAO,IAAI,OAAO,CAAC,CAAO,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC3C,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;gBACtB,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBACvB,MAAM,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;gBAC9C,IAAA,iBAAO,EAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;oBACxB,IAAI,KAAK,EAAE;wBACT,MAAM,CAAC,KAAK,CAAC,CAAA;qBACd;yBAAM;wBACL,uBAAa,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;wBACtC,OAAO,EAAE,CAAA;qBACV;gBACH,CAAC,CAAC,CAAA;YACJ,CAAC,CAAA,CAAC,CAAA;QACJ,CAAC;KAAA;IAEO,mBAAmB,CAAC,KAA+B;QACzD,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;QAC3C,IAAI,CAAC,YAAY,EAA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AE;YACrB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;SAC1B;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,eAAe;QACrB,OAAO,IAAI,iCAAuB,EAAE,CAAA;IACtC,CAAC;IAEO,UAAU,CAAC,KAAoB;QACrC,MAAM,GAAG,GAAG;YACV,aAAa,EAAE,KAAK,CAAC,QAAQ;YAC7B,UAAU,EAAE,KAAK,CAAC,IAAI;SACvB,CAAA;QAED,OAAO,CAAC,GAAG,CAAC,6BAA6B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;IAEK,KAAK,CAAC,KAA+C;;YACzD,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,KAAK,CAAA;YACtD,uBAAa,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;QAC/F,CAAC;KAAA;CACF;AAED,kBAAe,kBAAkB,CAAA","file":"JavascriptCompiler.js","sourcesContent":["import ColorConsole2 from '@aiot-toolkit/shared-utils/lib/ColorConsole2'\nimport path from 'path'\nimport { Configuration, webpack } from 'webpack'\nimport ICompileParam from '../interface/ICompileParam'\nimport ICompiler from '../interface/ICompiler'\nimport IJavascriptCompileOption from './interface/IJavascriptCompileOption'\nimport IWebpackConfigurator from './interface/IWebpackConfigurator'\nimport VelaWebpackConfigurator from './vela/VelaWebpackConfigurator'\nimport UxCompileUtil from './vela/utils/UxCompileUtil'\n\nclass JavascriptCompiler implements ICompiler {\n async compile(param: IJavascriptCompileOption): Promise<void> {\n return new Promise(async (resolve, reject) => {\n this.showEnvLog(param)\n await this.clean(param)\n const config = this.createWebpackConfig(param)\n webpack(config, (error) => {\n if (error) {\n reject(error)\n } else {\n ColorConsole2.info(`webpack complete`)\n resolve()\n }\n })\n })\n }\n\n private createWebpackConfig(param: IJavascriptCompileOption): Configuration {\n const configurator = this.getConfigurator()\n if (!configurator) {\n throw new Error(`This project is not supported`)\n }\n\n configurator.param = param\n // 如果configurator有 create 函数,直接返回\n // 否则,结合configurator生成默认配置,并使用\n if (configurator.create) {\n return configurator.create()\n }\n\n const { projectPath, mode, devtool, outputPath } = param\n const buildPath = path.resolve(projectPath, outputPath)\n\n const result: Configuration = {\n context: projectPath,\n mode,\n devtool,\n output: {\n globalObject: 'window',\n filename: '[name].js',\n publicPath: './',\n path: buildPath\n },\n module: {},\n stats: {\n builtAt: false,\n entrypoints: false,\n children: false,\n chunks: false,\n chunkModules: false,\n chunkOrigins: false,\n modules: false,\n version: false,\n assets: false\n }\n }\n\n if (configurator.createEntry) {\n result.entry = configurator.createEntry()\n }\n\n if (configurator.createRules && result.module) {\n result.module.rules = configurator.createRules()\n }\n\n if (configurator.createPlugins) {\n result.plugins = configurator.createPlugins()\n }\n\n if (configurator.hook) {\n configurator.hook(result)\n }\n\n return result\n }\n\n private getConfigurator(): IWebpackConfigurator {\n return new VelaWebpackConfigurator()\n }\n\n private showEnvLog(param: ICompileParam) {\n const env = {\n NODE_PLATFORM: param.platform,\n NODE_PHASE: param.mode\n }\n\n console.log(`Configuration environment:${JSON.stringify(env)}`)\n }\n\n async clean(param: ICompileParam & IJavascriptCompileOption): Promise<void> {\n const { outputPath, releasePath, projectPath } = param\n UxCompileUtil.clean([outputPath, releasePath].map((item) => path.resolve(projectPath, item)))\n }\n}\n\nexport default JavascriptCompiler\n"],"sourceRoot":"../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/JavascriptDefaultCompileOption.ts"],"names":[],"mappings":";;;;;AAAA,4CAAmB;AACnB,gDAAuB;AAGvB,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,iCAAiC,CAAC,CAAA;AACnF,MAAM,8BAA8B,GAAsC;IACxE,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,OAAO;IACnB,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,QAAQ;IACrB,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,eAAe;IAC7B,gBAAgB;IAChB,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE;CACvB,CAAA;AAED,kBAAe,8BAA8B,CAAA","file":"JavascriptDefaultCompileOption.js","sourcesContent":["import os from 'os'\nimport path from 'path'\nimport IJavascriptCompileOption from './interface/IJavascriptCompileOption'\n\nconst clientRecordPath = path.join(os.homedir(), 'hap-toolkit-client-records.json')\nconst JavascriptDefaultCompileOption: Partial<IJavascriptCompileOption> = {\n devtool: false,\n sourceRoot: './src',\n signRoot: './sign',\n releasePath: './dist',\n outputPath: './build',\n dataCoverage: './.nyc_output',\n clientRecordPath,\n server: { port: 8000 }\n}\n\nexport default JavascriptDefaultCompileOption\n"],"sourceRoot":"../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/interface/IJavascriptCompileOption.ts"],"names":[],"mappings":"","file":"IJavascriptCompileOption.js","sourcesContent":["import ICompileParam from '../../interface/ICompileParam'\nimport BuildNameFormatType from '../vela/enum/BuildNameFormatType'\n\nexport default interface IJavascriptCompileOption extends ICompileParam {\n devtool?: string | false\n\n /**\n * 源码根目录\n */\n sourceRoot: string\n\n /**\n * 证书签名路径\n */\n signRoot: string\n\n /**\n * 应用程序目录\n */\n releasePath: string\n\n /**\n * 输出目录\n */\n outputPath: string\n\n /**\n * 项目运行的代码覆盖率数据\n */\n dataCoverage: string\n\n clientRecordPath: string\n\n /**\n * 运行端口\n */\n server: { port: number }\n\n /**\n * 包名格式\n */\n buildNameFormat?: BuildNameFormatType\n\n /**\n * 禁用 jsc\n */\n disabledJSC?: boolean\n}\n"],"sourceRoot":"../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/interface/IWebpackConfigurator.ts"],"names":[],"mappings":"","file":"IWebpackConfigurator.js","sourcesContent":["import {\n Configuration,\n EntryObject,\n RuleSetRule,\n WebpackPluginInstance,\n} from \"webpack\";\nimport ICompileParam from \"../../interface/ICompileParam\";\n\n/**\n * webpack配置器\n *\n * 可用2种方式生成 webpack 配置\n *\n * 1. 完全自定义:仅实现 create 函数返回完整的 webpack配置\n * 2. 系统默认配置 +自定义常用属性:实现createPlugin、createEntry、createRules、hook\n */\ninterface IWebpackConfigurator {\n /**\n * 编译参数\n */\n param: ICompileParam;\n\n /**\n * 创建 webpack 完整配置\n *\n * 如实现此函数,则其它函数无效\n */\n create?(): Configuration;\n\n /**\n * 创建 webpack 的 plugins\n */\n createPlugins?(): WebpackPluginInstance[];\n\n /**\n * 创建 webpack 的 entry\n */\n createEntry?(): string | string[] | EntryObject;\n\n /**\n * 创建 webpack 的 rules\n */\n createRules?(): RuleSetRule[];\n\n /**\n * 对已有的 webpack 配置做修改\n * @param config\n */\n hook?(config: Configuration): void;\n}\n\nexport default IWebpackConfigurator;\n"],"sourceRoot":"../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/VelaWebpackConfigurator.ts"],"names":[],"mappings":";;;;;AAAA,wDAAyB;AACzB,gDAAuB;AAEvB,gFAAuD;AAIvD,qEAA4C;AAC5C,0EAAiD;AAEjD,MAAM,uBAAuB;IAG3B,aAAa;QACX,OAAO;YACL,cAAc;YACd,IAAI,oBAAU,EAAE;SACjB,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAC9C,MAAM,cAAc,GAAG,qBAAW,CAAC,mBAAmB,CACpD,IAAI,CAAC,KAAK,CAAC,WAAW,EACtB,IAAI,CAAC,KAAK,CAAC,UAAU,CACtB,CAAA;QAED,IAAI,kBAAE,CAAC,UAAU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'path'\nimport { Configuration, EntryObject, RuleSetRule, WebpackPluginInstance } from 'webpack'\nimport UxFileUtils from '../../../utils/ux/UxFileUtils'\nimport ICompileParam from '../../interface/ICompileParam'\nimport IJavascriptCompileOption from '../interface/IJavascriptCompileOption'\nimport IWebpackConfigurator from '../interface/IWebpackConfigurator'\nimport WrapPlugin from './plugin/WrapPlugin'\nimport UxCompileUtil from './utils/UxCompileUtil'\n\nclass VelaWebpackConfigurator implements IWebpackConfigurator {\n param!: ICompileParam & IJavascriptCompileOption\n\n createPlugins(): WebpackPluginInstance[] {\n return [\n // 给 入口js 添加包裹\n new WrapPlugin()\n ]\n }\n\n /**\n * 通过读取 manifest.json 生成 entry\n * @returns\n */\n createEntry(): string | EntryObject | string[] {\n const { projectPath, sourceRoot } = this.param\n const configFilePath = UxFileUtils.getManifestFilePath(\n this.param.projectPath,\n this.param.sourceRoot\n )\n\n if (fs.existsSync(configFilePath)) {\n const config = fs.readJSONSync(configFilePath)\n return UxCompileUtil.resolveEntries(\n config,\n path.resolve(projectPath, sourceRoot),\n projectPath\n )\n } else {\n throw new Error(`Configuration file does not exist: ${configFilePath}`)\n }\n }\n createRules(): RuleSetRule[] {\n const { projectPath, sourceRoot } = this.param\n const srcPath = path.resolve(projectPath, sourceRoot)\n return [\n {\n test: /\\.js$/,\n use: [\n {\n loader: require.resolve('babel-loader'),\n options: {\n // configFile: getBabelConfigJsPath(cwd),\n cwd: this.param.projectPath,\n cacheDirectory: true\n }\n }\n ]\n },\n {\n test: /\\.json$/,\n include: [path.join(srcPath, 'manifest.json')]\n },\n {\n test: /\\.(png|jpe?g|gif|svg|bmp|webp|mp4|wmv|avi|mpg|rmvb|mov|flv|otf|ttf|ttc|woff|eot)$/i,\n use: {\n loader: require.resolve('url-loader'),\n options: {\n limit: 0,\n name: `dynamicAssets/[name].[hash:8].[ext]`,\n publicPath: '/',\n esModule: false\n }\n }\n }\n ]\n }\n\n hook(config: Configuration): void {\n // todo 合并用户配置\n }\n}\n\nexport default VelaWebpackConfigurator\n"],"sourceRoot":"../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/enum/BuildNameFormatType.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAK,mBAUJ;AAVD,WAAK,mBAAmB;IACtB;;OAEG;IACH,mEAAW,CAAA;IAEX;;OAEG;IACH,qEAAY,CAAA;AACd,CAAC,EAVI,mBAAmB,KAAnB,mBAAmB,QAUvB;AAED,kBAAe,mBAAmB,CAAA;AAElC,WAAU,mBAAmB;IAC3B;;OAEG;IACU,4BAAQ,GAA0B;QAC7C,mBAAmB,CAAC,OAAO;QAC3B,mBAAmB,CAAC,QAAQ;KAC7B,CAAA;IAED;;OAEG;IACH,SAAgB,QAAQ,CAAC,KAA0B;QACjD,MAAM,GAAG,GAA6C;YACpD,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,SAAS;YACxC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,UAAU;SAC3C,CAAA;QACD,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;IANe,4BAAQ,WAMvB,CAAA;IAED,SAAgB,MAAM,CAAC,KAA0B;QAC/C,MAAM,GAAG,GAA6C;YACpD,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,yDAAyD;YACxF,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,iDAAiD;SAClF,CAAA;QACD,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAA;IACzB,CAAC;IANe,0BAAM,SAMrB,CAAA;AACH,CAAC,EA3BS,mBAAmB,KAAnB,mBAAmB,QA2B5B","file":"BuildNameFormatType.js","sourcesContent":["/**\n * 构建名格式类型枚举\n */\nenum BuildNameFormatType {\n /**\n * 默认格式\n */\n DEFAULT = 1,\n\n /**\n * 原始格式,文件名不带版本号\n */\n ORIGINAL = 2\n}\n\nexport default BuildNameFormatType\n\nnamespace BuildNameFormatType {\n /**\n * 枚举值列表,一般用于列表显示,例如下拉框\n */\n export const ALL_LIST: BuildNameFormatType[] = [\n BuildNameFormatType.DEFAULT,\n BuildNameFormatType.ORIGINAL\n ]\n\n /**\n * 枚举值转换为字符串\n */\n export function toString(value: BuildNameFormatType) {\n const dic: { [key in BuildNameFormatType]: string } = {\n [BuildNameFormatType.DEFAULT]: 'default',\n [BuildNameFormatType.ORIGINAL]: 'original'\n }\n return dic[value] || ''\n }\n\n export function toDesc(value: BuildNameFormatType) {\n const dic: { [key in BuildNameFormatType]: string } = {\n [BuildNameFormatType.DEFAULT]: 'The format is: packageName.signaturType.version.extname',\n [BuildNameFormatType.ORIGINAL]: 'The format is: packageName.signaturType.extname'\n }\n return dic[value] || ''\n }\n}\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/enum/EntryType.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAK,SA8BJ;AA9BD,WAAK,SAAS;IACZ;;OAEG;IACH,wBAAW,CAAA;IAEX;;OAEG;IACH,0BAAa,CAAA;IAEb;;OAEG;IACH,+BAAkB,CAAA;IAElB;;OAEG;IACH,0BAAa,CAAA;IAEb;;OAEG;IACH,4BAAe,CAAA;IAEf;;OAEG;IACH,sBAAS,CAAA;AACX,CAAC,EA9BI,SAAS,KAAT,SAAS,QA8Bb;AAED,kBAAe,SAAS,CAAA","file":"EntryType.js","sourcesContent":["/**\n * 入口类型枚举\n */\nenum EntryType {\n /**\n * 应用程序\n */\n APP = 'app',\n\n /**\n * 页面\n */\n PAGE = 'page',\n\n /**\n * 组件\n */\n COMPONENT = 'comp',\n\n /**\n * 卡片\n */\n CARD = 'card',\n\n /**\n * 悬浮窗口\n */\n FLOAT = 'float',\n\n /**\n * JavaScript\n */\n JS = 'js',\n}\n\nexport default EntryType"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/interface/IChunk.ts"],"names":[],"mappings":"","file":"IChunk.js","sourcesContent":["/**\n * IChunk\n */\nexport type IFileHash = {\n name: string\n hash: Buffer\n}\nexport type IChunkOptions = {\n files: IFileHash[]\n}\nexport type IPartChunk = {\n tag: boolean\n startIndex: number\n len: number\n previous: number\n sign?: Buffer\n}\nexport interface IChunk {\n signchunk: Buffer\n tag: boolean\n length: number\n options: IChunkOptions\n sections: {\n header: IPartChunk\n central: IPartChunk\n footer: IPartChunk\n }\n}\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/interface/IManifest.ts"],"names":[],"mappings":"","file":"IManifest.js","sourcesContent":["import { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\n\n/**\n * vela manifest文件对应的数据结构\n */\nexport default interface IManifest {\n package: string\n name?: string\n versionName?: string\n minPlatformVersion?: number\n deviceId?: string\n deviceTypeList?: string[]\n features?: IFeatures[]\n config?: {\n logLevel: string\n designWidth?: string | number\n }\n router: {\n entry: string\n pages: Dictionary<{ component?: string }>\n }\n minAPILevel?: number\n}\n\nexport interface IFeatures {\n name: string\n}\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/interface/IQuickAppConfig.ts"],"names":[],"mappings":"","file":"IQuickAppConfig.js","sourcesContent":["import { Configuration } from 'webpack'\nimport IJavascriptCompileOption from '../../interface/IJavascriptCompileOption'\n\n/**\n * IQuickAppConfig\n *\n * 项目中 quickapp.config.js 的对象结构\n */\nexport default interface IQuickAppConfig {\n cli: Partial<IJavascriptCompileOption>\n webpack: Partial<Configuration>\n}\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/model/Package.ts"],"names":[],"mappings":";;;;;AAAA,iGAAwE;AAwBxE;;;;GAIG;AACH,MAAM,OAAO;IAoCX;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAID;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,QAAgB;QAC7B,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;IACnC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,IAAmB;QACpC,MAAM,EAAE,aAAa,EAAE,GAAG,IAAI,CAAA;QAC9B,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YAC/B,uBAAa,CAAC,KAAK,CAAC,QAAQ,aAAa,sBAAsB,CAAC,CAAA;YAChE,OAAM;SACP;QACD,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,IAAI,CAAA;QACvC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAED,YAAY,IAAsB;QAjElC;;WAEG;QACH,eAAU,GAAY,KAAK,CAAA;QAoBnB,kBAAa,GAAoB,EAAE,CAAA;QASnC,iBAAY,GAAwB,EAAE,CAAA;QAkC5C,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAEzB,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC;aACjE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAC/B,IAAI,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;CACF;AACD,kBAAe,OAAO,CAAA","file":"Package.js","sourcesContent":["import ColorConsole2 from '@aiot-toolkit/shared-utils/lib/ColorConsole2'\nimport { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\n\n/**\n * 文件资源\n */\nexport interface IFileResource {\n /**\n * 文件路径\n */\n fileBuildPath: string\n\n /**\n * 文件内容\n */\n fileContentBuffer: Buffer\n\n /**\n * 文件摘要\n * 文件内容生成的 hash 值\n */\n fileContentDigest?: Uint8Array\n}\n\n/**\n * 定义文件包\n *\n * 相当于虚拟的 rpk 包\n */\nclass Package {\n /**\n * 包前缀\n */\n filePrefix?: string\n\n /**\n * 子包名称;整包没有\n */\n fileSubname?: string\n\n /**\n * 是否为独立包\n */\n standalone: boolean = false\n\n /**\n * 后缀名\n */\n fileSuffix?: string\n\n icon?: string\n\n banner?: string\n\n comment?: string\n\n /**\n * 资源路径匹配\n */\n subMatch?: RegExp\n\n readonly fileName: string\n\n private _resourceList: IFileResource[] = []\n\n /**\n * 资源文件列表\n */\n public get resourceList(): IFileResource[] {\n return this._resourceList\n }\n\n private _resourceDic: Dictionary<boolean> = {}\n\n /**\n * 资源文件字典,以高效检查资源是否存在\n */\n public get resourceDic(): Dictionary<boolean> {\n return this._resourceDic\n }\n\n /**\n * 是否已包含指定文件\n * @param filePath 文件路径\n * @returns\n */\n public include(filePath: string) {\n return this.resourceDic[filePath]\n }\n\n /**\n * 添加资源\n * @param data\n * @returns\n */\n public addResource(data: IFileResource) {\n const { fileBuildPath } = data\n if (this.include(fileBuildPath)) {\n ColorConsole2.throw(`File ${fileBuildPath} is added repeatedly`)\n return\n }\n this._resourceDic[fileBuildPath] = true\n this._resourceList.push(data)\n }\n\n constructor(data: Partial<Package>) {\n Object.assign(this, data)\n\n this.fileName = [this.filePrefix, this.fileSubname, this.fileSuffix]\n .filter((item) => Boolean(item))\n .join('.')\n }\n}\nexport default Package\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/plugin/WrapPlugin.ts"],"names":[],"mappings":";;AAAA,qCAA+C;AAC/C,qDAA8C;AAE9C,MAAM,UAAU;IACd,KAAK,CAAC,QAAkB;QACtB,cAAc;QACd,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,EAAE;YAC3D,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CACjC;gBACE,IAAI,EAAE,YAAY;gBAClB,KAAK,EAAE,qBAAW,CAAC,6BAA6B;aACjD,EACD,GAAG,EAAE;gBACH,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;YACxB,CAAC,CACF,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,IAAI,CAAC,WAAwB;QACnC,SAAS;QACT,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,CAAC,CAAA;QAEjF,wBAAwB;QACxB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YACvB,IAAI,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;gBAC7B,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAA;gBAC7D,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,8BAAY,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAQ,CAAA;aAChF;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAEO,YAAY,CAAC,IAAY;QAC/B,OAAO;;;;;;;;;;;;eAYI,IAAI;;;;;EAKjB,CAAA;IACA,CAAC;CACF;AAED,kBAAe,UAAU,CAAA","file":"WrapPlugin.js","sourcesContent":["import { Compilation, Compiler } from 'webpack'\nimport { ConcatSource } from 'webpack-sources'\n\nclass WrapPlugin {\n apply(compiler: Compiler) {\n // 给入口文件加上包裹函数\n compiler.hooks.compilation.tap('WrapPlugin', (compilation) => {\n compilation.hooks.processAssets.tap(\n {\n name: 'WrapPlugin',\n stage: Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE\n },\n () => {\n this.wrap(compilation)\n }\n )\n })\n }\n\n private wrap(compilation: Compilation) {\n // 获取入口文件\n const entrys = Object.keys(compilation.options.entry).map((item) => `${item}.js`)\n\n // 从chunk找到所有入口文件,添加包裹函数\n entrys.forEach((entry) => {\n if (compilation.assets[entry]) {\n const content = compilation.assets[entry].source().toString()\n compilation.assets[entry] = new ConcatSource(this.wrapFunction(content)) as any\n }\n })\n }\n\n private wrapFunction(code: string) {\n return `\nexport default function(global, globalThis, window, $app_exports$, $app_evaluate$){\n var org_app_require = $app_require$;\n\n (function(global, globalThis, window, $app_exports$, $app_evaluate$){\n var setTimeout = global.setTimeout;\n var setInterval = global.setInterval;\n var clearTimeout = global.clearTimeout;\n var clearInterval = global.clearInterval;\n var $app_require$ = global.$app_require$ || org_app_require\n\n var createPageHandler = function() {\n return ${code}\n }\n\n return createPageHandler();\n })(global, globalThis, window, $app_exports$, $app_evaluate$)\n}`\n }\n}\n\nexport default WrapPlugin\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/utils/Jsc.ts"],"names":[],"mappings":";;;;;AAAA,iGAAwE;AACxE,iGAAwE;AACxE,8CAAqB;AACrB;;GAEG;AACH,MAAM,GAAG;IACP,YACkB,WAAmB,EACnB,SAAiB;QADjB,gBAAW,GAAX,WAAW,CAAQ;QACnB,cAAS,GAAT,SAAS,CAAQ;IAChC,CAAC;IAEJ,GAAG;QACD,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,IAAI,CAAA;QACvC,OAAO,oBAAU,CAAC,aAAa,CAAC,WAAW,EAAE,mBAAmB,CAAC;aAC9D,IAAI,CAAC,CAAC,MAAW,EAAE,EAAE;YACpB,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAClC,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,IAAA,aAAG,EAAC,GAAG,SAAS,UAAU,CAAC,CAAA;QACpC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;YACtB,uBAAa,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAClC,OAAO,CAAC,IAAI,EAAE,CAAA;QAChB,CAAC,CAAC,CAAA;IACN,CAAC;CACF;AACD,kBAAe,GAAG,CAAA","file":"Jsc.js","sourcesContent":["import ColorConsole2 from '@aiot-toolkit/shared-utils/lib/ColorConsole2'\nimport CommonUtil from '@aiot-toolkit/shared-utils/lib/utils/CommonUtil'\nimport del from 'del'\n/**\n * Jsc\n */\nclass Jsc {\n constructor(\n public readonly projectPath: string,\n public readonly buildPath: string\n ) {}\n\n jsc() {\n const { projectPath, buildPath } = this\n return CommonUtil.requireModule(projectPath, `@aiot-toolkit/jsc`)\n .then((module: any) => {\n return module.default(buildPath)\n })\n .then(() => {\n return del(`${buildPath}/**/*.js`)\n })\n .catch((error: Error) => {\n ColorConsole2.error(error.message)\n process.exit()\n })\n }\n}\nexport default Jsc\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/utils/UxCompileUtil.ts"],"names":[],"mappings":";;;;;AACA,wDAAyB;AACzB,gDAAuB;AACvB,kEAAyC;AAEzC,MAAM,aAAa;IAIjB,MAAM,CAAC,KAAK,CAAC,OAAiB;QAC5B,IAAI,CAAC,OAAO,EAAE;YACZ,OAAM;SACP;QAED,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACvB,IAAI,kBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACvB,IAAI,kBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;oBAC9B,kBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;iBACpB;qBAAM;oBACL,kBAAE,CAAC,SAA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BAAgB,CAAC,OAAO,GAAG,IAAI;QACpC,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,CAAA;QAErB,IAAI,OAAO,EAAE;YACX,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;SACxC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;;AAnJD,QAAQ;AACQ,4BAAc,GAAG,UAAU,CAAA;AAqJ7C,kBAAe,aAAa,CAAA","file":"UxCompileUtil.js","sourcesContent":["import { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\nimport fs from 'fs-extra'\nimport path from 'path'\nimport EntryType from '../enum/EntryType'\n\nclass UxCompileUtil {\n // 摘要文件夹\n static readonly DIGEST_ZIP_DIR = 'META-INF'\n\n static clean(dirList: string[]) {\n if (!dirList) {\n return\n }\n\n dirList.forEach((item) => {\n if (fs.existsSync(item)) {\n if (fs.statSync(item).isFile()) {\n fs.unlinkSync(item)\n } else {\n fs.rmdirSync(item, { recursive: true })\n }\n }\n })\n }\n\n /**\n * 从项目配置文件中解析出入口文件\n * @param config 项目配置文件的内容,应为json对象\n * @param codeDir 源码目录\n * @param projectPath 项目目录\n * @returns {[入口名]:源文件路径}\n */\n static resolveEntries(config: any, codeDir: string, projectPath: string): Dictionary<string> {\n const { router } = config\n if (!router) {\n throw Error('No routing configured in manifest.json!')\n }\n\n const appFile = this.resolveFile(path.join(codeDir, 'app'))\n if (!fs.existsSync(appFile)) {\n console.log(`app file does not exist`)\n process.exit(1)\n }\n\n const { pages = {}, widgets = {}, floatingWindows = {} } = router\n const confsList = [\n {\n confs: pages,\n type: EntryType.PAGE\n },\n {\n confs: floatingWindows,\n type: EntryType.FLOAT\n },\n {\n confs: widgets,\n type: EntryType.CARD\n }\n ]\n\n // 1. 添加app\n const result: { [key: string]: any } = {\n app: `./${path.relative(projectPath, appFile)}?uxType=${EntryType.APP}`\n }\n\n // 2. 添加 route 配置的文件\n confsList.forEach((item) => {\n const { confs, type } = item\n Object.keys(confs).forEach((routePath) => {\n if (/^\\//.test(routePath)) {\n throw new Error(\n `Compilation failed: please confirm that '${routePath}' configured by router.pages in manifest.json is the directory name`\n )\n }\n const conf = confs[routePath]\n const entryKey = path.join(routePath, conf.component)\n const filePath = this.resolveFile(path.join(codeDir, entryKey))\n if (!filePath) {\n throw new Error(\n `Compilation failed: please confirm that the file path ${entryKey} configured in manifest.json exists`\n )\n }\n\n let sourceFile = `./${path.relative(projectPath, filePath)}?uxType=${type}`\n sourceFile = sourceFile.replace(/\\\\/g, '/')\n result[entryKey] = sourceFile\n })\n })\n\n // 3. 添加 workers\n const { workers } = config\n if (workers && workers.entries && Array.isArray(workers.entries)) {\n workers.entries\n .filter((worker: any) => worker.file)\n .forEach((worker: any) => {\n result[worker.file.replace(/\\.js$/, '')] = './src/' + worker.file\n })\n }\n\n // 4. 添加 services\n const { services } = config\n // 数组格式\n if (Array.isArray(services)) {\n services.forEach((item) => {\n const { name, path } = item\n if (name && path) {\n result['services/' + name] = './src/' + path + `?uxType=${EntryType.APP}`\n }\n })\n }\n // 字典格式\n else {\n for (const key in services) {\n if (Object.hasOwnProperty.call(services, key)) {\n result['services/' + key] = './src/' + services[key].path + `?uxType=${EntryType.APP}`\n }\n }\n }\n return result\n }\n\n /**\n * 通过无后缀的文件名路径获取存在的文件路径\n *\n * @example\n * const path = resolveFile('/project/a')\n * // path = '/project/a.ux'\n * @param filePath\n */\n static resolveFile(filePath: string) {\n const extensionList = this.getExtensionList()\n for (const item of extensionList) {\n const currentPath = `${filePath}${item}`\n if (fs.existsSync(currentPath)) {\n return currentPath\n }\n }\n return ''\n }\n\n /**\n * 获取ux文件支持的后缀列表\n * @param withDot\n * @returns\n */\n static getExtensionList(withDot = true) {\n const result = ['js']\n\n if (withDot) {\n return result.map((item) => `.${item}`)\n }\n\n return result\n }\n}\n\nexport default UxCompileUtil\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|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OAAO,CAAC,OAAO;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,SAAS,EAAE,IAAI;SAChB,CAAA;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IACO,MAAM,CAAO,qBAAqB,CACxC,WAAmB,EACnB,UAAmC;;YAEnC,gCAAgC;YAChC,gBAAgB;YAChB,IAAI,UAAU,EAAE;gBACd,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,UAAU,CAAA;gBAC9C,oBAAoB;gBACpB,MAAM,iBAAiB,GAAG,MAAM,kBAAQ,CAAC,uBAAuB,CAC9D,WAAW,EACX,UAAU,EACV,WAAW,CACZ,CAAA;gBACD,IAAI,iBAAiB,KAAK,KAAK,EAAE;oBAC/B,KAAK;oBACL,OAAO,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAA;iBAC9D;qBAAM;oBACL,WAAW,GAAG,iBAAiB,CAAA;iBAChC;aACF;YACD,WAAW;YACX,uBAAuB;YACvB,QAAQ;YACR,OAAO;gBACL,SAAS,EAAE,WAAW;aACvB,CAAA;QACH,CAAC;KAAA;;;AAxRe,wBAAgB,GAAG,WAAH,AAAc,CAAA;AAE9C,QAAQ;AACQ,iBAAS,GAAG,UAAH,AAAa,CAAA;AAEtC,gBAAgB;AACA,iBAAS,GAAG,GAAG,EAAI,CAAC,SAAS,OAApB,AAA2B,CAAA;AAEpD,SAAS;AACO,uBAAe,GAAG,GAAG,EAAI,CAAC,SAAS,YAApB,AAAgC,CAAA;AAE/D;;GAEG;AACa,kBAAU,GAAgC;IACxD,IAAI,EAAE,YAAY;IAClB,WAAW,EAAE,SAAS;IACtB,kBAAkB,EAAE;QAClB,KAAK,EAAE,CAAC;KACT;CALuB,AAMzB,CAAA;AAsQH,kBAAe,OAAO,CAAA","file":"ZipUtil.js","sourcesContent":["import ColorConsole2 from '@aiot-toolkit/shared-utils/lib/ColorConsole2'\nimport { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type'\nimport CommonUtil from '@aiot-toolkit/shared-utils/lib/utils/CommonUtil'\nimport FileUtil from '@aiot-toolkit/shared-utils/lib/utils/FileUtil'\nimport fs from 'fs-extra'\nimport JSZip from 'jszip'\nimport path from 'path'\nimport UxFileUtils from '../../../../utils/ux/UxFileUtils'\nimport CompileMode from '../../../enum/CompileMode'\nimport ISignConfig from '../../../interface/ISignConfig'\nimport IJavascriptCompileOption from '../../interface/IJavascriptCompileOption'\nimport BuildNameFormatType from '../enum/BuildNameFormatType'\nimport IManifest from '../interface/IManifest'\nimport Package, { IFileResource } from '../model/Package'\nimport UxCompileUtil from './UxCompileUtil'\nimport SignUtil from './signature/SignUtil'\n/**\n * Zip 用于将打包成功的 build 目录按特定规则压缩成 rpk\n *\n * @see ZipUtil.createRpk 打包的完整规则\n */\nclass ZipUtil {\n static readonly DIGEST_HASH_JSON = 'hash.json'\n\n // 摘要文件夹\n static readonly META_PATH = 'META-INF'\n\n // 文件摘要包(zip 文件)\n static readonly CERT_PATH = `${this.META_PATH}/CERT`\n\n // 打包信息文件\n static readonly BUILD_FILE_PATH = `${this.META_PATH}/build.txt`\n\n /**\n * zip压缩参数\n */\n static readonly ZIP_OPTION: JSZip.JSZipGeneratorOptions = {\n type: 'nodebuffer',\n compression: 'DEFLATE',\n compressionOptions: {\n level: 9\n }\n }\n\n /**\n * dist 目录生成 rpk\n * 1. 获取文件列表\n * 1. 过滤出需要的文件\n * 2. 按配置排序\n * 2. 生成文件流\n * 1. 每个文件生成加密串\n * 2. 生成元数据流\n * 3. 把元数据流和普通文件合并到一个流\n * 3. 写入到硬盘\n * @param dist\n * @param param\n * @returns\n */\n static async createRpk(dist: string, param: IJavascriptCompileOption) {\n const config = UxFileUtils.getMainfestInfo(param.projectPath, param.sourceRoot)\n\n // 1\n const files = this.getSortedFiles(dist, param, config)\n if (!files.length) {\n ColorConsole2.error(\n `The build file is missing, stop generating the application package, please check carefully`\n )\n return\n }\n\n // 2\n const { fullPackage } = await this.createPackagesDefinition(param, config, files)\n const zipBuffer = await this.packageToZipBuffer(fullPackage)\n\n // 生产出带签名的rpk文件buffer\n const signConfig = SignUtil.getProjectSignConfig(param)\n const { rpkBuffer } = await ZipUtil.buildProjectAndOutput(zipBuffer, signConfig)\n // IDE 扫码预览打包 todo\n // IDE 重置包名\n // 3\n this.generateDistFile(rpkBuffer, param, this.getFileName(param, config, 'rpk'))\n }\n\n private static getFileName(param: IJavascriptCompileOption, config: IManifest, ext: string) {\n const { mode, buildNameFormat } = param\n const { package: packageName } = config\n return [\n packageName,\n mode === CompileMode.DEVELOPMENT ? 'debug' : 'release',\n buildNameFormat === BuildNameFormatType.DEFAULT ? config.versionName : '',\n ext\n ]\n .filter(Boolean)\n .join('.')\n }\n\n private static async packageToZipBuffer(target: Package) {\n const { resourceList, comment } = target\n const packageFileList: { path: string; content: any }[] = resourceList.map((item) => {\n return {\n path: item.fileBuildPath,\n content: item.fileContentBuffer\n }\n })\n return await this.createZipBufferFromFileList(packageFileList, comment)\n }\n\n private static async generateDistFile(\n buffer: Buffer,\n param: IJavascriptCompileOption,\n fileName: string\n ) {\n const { releasePath, projectPath } = param\n const filePath = path.join(projectPath, releasePath, fileName)\n fs.outputFileSync(filePath, buffer)\n }\n\n static async createZipBufferFromFileList(\n fileList: { path: string; content: string | Buffer }[],\n comment?: string\n ): Promise<Buffer> {\n const zip = new JSZip()\n fileList.forEach((item) => {\n zip.file(item.path, item.content)\n })\n\n return (await zip.generateAsync({\n ...this.ZIP_OPTION,\n comment\n })) as Buffer\n }\n\n /**\n * 创建包,一个包对应一个 rpk 文件\n * @param param\n * @param config\n * @param files\n * @returns\n */\n private static async createPackagesDefinition(\n param: IJavascriptCompileOption,\n config: IManifest,\n files: string[]\n ) {\n const { projectPath, outputPath } = param\n const { package: appPackage } = config\n\n const comment = this.createComment(param)\n const fullPackage = new Package({\n filePrefix: appPackage,\n fileSuffix: 'rpk',\n standalone: true,\n comment: JSON.stringify(comment)\n })\n\n // 写入文件\n for (let fileBuildPath of files) {\n const absPath = path.join(projectPath, outputPath, fileBuildPath)\n let fileContentBuffer = fs.readFileSync(absPath)\n if (fileBuildPath === ZipUtil.CERT_PATH) {\n let metaZip = await JSZip.loadAsync(fileContentBuffer)\n fileContentBuffer = (await metaZip.generateAsync({\n ...ZipUtil.ZIP_OPTION,\n comment: null as any\n })) as Buffer\n }\n const fileContentDigest = CommonUtil.calcDataDigest(fileContentBuffer)\n\n const resourceInfo: IFileResource = {\n fileBuildPath,\n fileContentBuffer,\n fileContentDigest\n }\n fullPackage.addResource(resourceInfo)\n\n // 分包相关逻辑 todo\n }\n\n return { fullPackage }\n }\n\n /**\n * 获取有序的文件列表\n *\n * 打包后的文件夹生成vela 应用程序,需要先把文件排序,再进行压缩\n *\n * @see getPriorities 获取排序规则\n *\n * @param dist 打包后的文件目录的绝对路径\n * @param param 打包参数\n * @returns\n */\n static getSortedFiles(dist: string, param: IJavascriptCompileOption, config: IManifest) {\n const priorities = this.getPriorities(config)\n const getFileIndex = (file: string) => {\n const result = priorities.findIndex((item) => {\n if (typeof item === 'string') {\n return item === file\n }\n return file.match(item)\n })\n\n if (result < 0) {\n return Number.MAX_SAFE_INTEGER\n }\n return result\n }\n // 筛选中需要的文件并排序\n // 1. 排除META-INF 目录下的文件\n // 2. 生产环境排除 .map 文件\n const mapReg = /\\.map$/\n let result = FileUtil.readAlldirSync(dist)\n result = result\n .filter((item) => {\n return !(\n item.startsWith(UxCompileUtil.DIGEST_ZIP_DIR) ||\n (param.mode === 'production' && !mapReg.test(item))\n )\n })\n .map((item) => path.relative(dist, item))\n\n result.sort((a, b) => {\n const indexA = getFileIndex(a)\n const indexB = getFileIndex(b)\n return indexA - indexB\n })\n\n return result\n }\n\n /**\n * 根据 **固定规则**、**manifest.json入口配置**,获取压缩文件时使用的排序规则\n *\n * @param param\n * @returns\n */\n private static getPriorities(config: IManifest) {\n const entrySkFiles: string[] = [] // todo\n const { entry } = config.router\n const result = [\n 'META-INF/CERT',\n // 多语言配置文件要在 manifest 之前\n /^i18n\\/.+\\.json$/i,\n // 多终端配置文件如manifest-tv.json,也要在manifest之前,不然流式加载初始化的时候,会读不到对应的终端配置文件\n /^manifest-\\w+\\.json$/,\n 'manifest.json',\n 'app.js',\n /page-chunks.json$/,\n /skeleton\\/config\\.json$/,\n ...entrySkFiles,\n new RegExp(`^${entry}/$`),\n new RegExp(`^${entry}/.+`),\n /^common\\//i, // 静态资源\n /.+\\.js/,\n 'META-INF/build.txt'\n ]\n\n return result\n }\n\n /**\n * 创建打包的注释属性\n */\n public static createComment(param: IJavascriptCompileOption): Dictionary<any> {\n const obj = {\n originType: param.originType,\n toolkit: require(path.join(__dirname, '../../../../../package.json')).version,\n timeStamp: new Date().toJSON(),\n node: process.version,\n platform: process.platform,\n arch: process.arch,\n component: true\n }\n return obj\n }\n private static async buildProjectAndOutput(\n fullPackage: Buffer,\n signConfig: ISignConfig | undefined\n ) {\n // 1. 默认携带META,如果禁用流失打包,需要删除META\n // 2. 是否需要增加签名内容\n if (signConfig) {\n const { privatekey, certificate } = signConfig\n // fullPackageBuffer\n const fullPackageBuffer = await SignUtil.signZipBufferForPackage(\n fullPackage,\n privatekey,\n certificate\n )\n if (fullPackageBuffer === false) {\n // 报错\n console.error('【ZipUtil】error: fullpackage signature failed')\n } else {\n fullPackage = fullPackageBuffer\n }\n }\n // 3. 校验体积等\n // 4. 生成rpks:不需要META和签名\n // 5. 返回\n return {\n rpkBuffer: fullPackage\n }\n }\n}\nexport default ZipUtil\n"],"sourceRoot":"../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/utils/signature/Base64.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAM,MAAM;IAMV,MAAM,CAAC,MAAM,CAAC,CAAS;QACrB,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,IAAI,GAAG,GAAG,k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Exp(\n /-----BEGIN [^-]+-----([A-Za-z0-9+\\/=\\s]+)-----END [^-]+-----|begin-base64[^\\n]+\\n([A-Za-z0-9+\\/=\\s]+)====/\n )\n\n static decode(a: string) {\n let i = 0\n if (Base64.decoder === undefined) {\n let b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n let ignore = '= \\f\\n\\r\\t\\u00A0\\u2028\\u2029'\n Base64.decoder = []\n for (i = 0; i < 64; ++i) {\n Base64.decoder[b64.charAt(i)] = i\n }\n for (i = 0; i < ignore.length; ++i) {\n Base64.decoder[ignore.charAt(i)] = -1\n }\n }\n let out = []\n let bits = 0\n let char_count = 0\n for (i = 0; i < a.length; ++i) {\n let c = a.charAt(i)\n if (c === '=') break\n let d = Base64.decoder[c]\n if (d === -1) continue\n if (d === undefined) throw 'Illegal character at offset ' + i\n bits |= d\n\n if (++char_count >= 4) {\n out[out.length] = bits >> 16\n out[out.length] = (bits >> 8) & 0xff\n out[out.length] = bits & 0xff\n bits = 0\n char_count = 0\n } else {\n bits <<= 6\n }\n }\n switch (char_count) {\n case 1:\n throw 'Base64 encoding incomplete: at least 2 bits missing'\n case 2:\n out[out.length] = bits >> 10\n break\n case 3:\n out[out.length] = bits >> 16\n out[out.length] = (bits >> 8) & 0xff\n break\n }\n return out\n }\n static unarmor(a: Buffer | string) {\n let b = ''\n let m = Base64.re.exec(a.toString())\n if (m) {\n if (m[1]) {\n b = m[1]\n } else if (m[2]) {\n b = m[2]\n } else {\n throw 'RegExp out of sync'\n }\n }\n return Base64.decode(b)\n }\n}\nexport default Base64\n"],"sourceRoot":"../../../../../../src"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler/javascript/vela/utils/signature/CRC32.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,MAAM,KAAK;IAGT,MAAM,CAAC,MAAM,CAAC,GAAQ,EAAE,MAAW,SAAS;QAC1C,GAAG,GAAG,KAAK,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C,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;gBAC9C,OAAO,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAA;aAC/C;iBAAM;gBACL,OAAO,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,CAAA;gBAC/C,OAAO,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAA;gBACrD,OAAO,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAA;aAC/C;SACF;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;;AAhCuB,WAAK,GAC3B,iwEAAiwE,CAAA;AAiCrwE,kBAAe,KAAK,CAAA","file":"CRC32.js","sourcesContent":["/**\n * CRC32\n */\nclass CRC32 {\n private static readonly table =\n '00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D'\n static digest(str: any, crc: any = undefined) {\n str = CRC32.Utf8Encode(str)\n if (crc == undefined) crc = 0\n let n = 0 //a number between 0 and 255\n let x = 0 //an hex number\n crc = crc ^ -1\n for (var i = 0, iTop = str.length; i < iTop; i++) {\n n = (crc ^ str.charCodeAt(i)) & 0xff\n x = Number('0x' + CRC32.table.substr(n * 9, 8))\n crc = (crc >>> 8) ^ x\n }\n return crc ^ -1\n }\n private static Utf8Encode(string: any) {\n string = string.replace(/\\r\\n/g, '\\n')\n let utftext = ''\n for (let n = 0; n < string.length; n++) {\n let c = string.charCodeAt(n)\n if (c < 128) {\n utftext += String.fromCharCode(c)\n } else if (c > 127 && c < 2048) {\n utftext += String.fromCharCode((c >> 6) | 192)\n utftext += String.fromCharCode((c & 63) | 128)\n } else {\n utftext += String.fromCharCode((c >> 12) | 224)\n utftext += String.fromCharCode(((c >> 6) & 63) | 128)\n utftext += String.fromCharCode((c & 63) | 128)\n }\n }\n return utftext\n }\n}\nexport default CRC32\n"],"sourceRoot":"../../../../../../src"}
|