@aiot-toolkit/aiotpack 2.0.6-beta.8 → 2.1.0-prender.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/afterCompile/ux/UxAfterCompile.d.ts +4 -0
- package/lib/afterCompile/ux/UxAfterCompile.js +90 -2
- package/lib/compiler/javascript/JavascriptCompiler.js +11 -4
- package/lib/compiler/javascript/TemplateCompiler.d.ts +29 -0
- package/lib/compiler/javascript/TemplateCompiler.js +564 -0
- package/lib/compiler/javascript/ViteCompiler.d.ts +13 -0
- package/lib/compiler/javascript/ViteCompiler.js +414 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +26 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +3 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +16 -1
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +12 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +10 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +241 -57
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +3 -2
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +12 -4
- package/lib/compiler/javascript/vela/utils/VruUtil.d.ts +50 -0
- package/lib/compiler/javascript/vela/utils/VruUtil.js +128 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +9 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +112 -6
- package/lib/compiler/javascript/vela/utils/webpackLoader/WebpackJsLoader.js +1 -1
- package/lib/config/UxConfig.d.ts +12 -5
- package/lib/config/UxConfig.js +7 -6
- package/lib/loader/ux/JsLoader.d.ts +9 -0
- package/lib/loader/ux/JsLoader.js +47 -8
- package/lib/loader/ux/vela/HmlLoader.d.ts +6 -6
- package/lib/loader/ux/vela/HmlLoader.js +30 -13
- package/lib/prerender/PrerenderVM.d.ts +86 -0
- package/lib/prerender/PrerenderVM.js +677 -0
- package/lib/prerender/StyleSerializer.d.ts +18 -0
- package/lib/prerender/StyleSerializer.js +92 -0
- package/lib/prerender/TemplateSerializer.d.ts +26 -0
- package/lib/prerender/TemplateSerializer.js +122 -0
- package/lib/prerender/index.d.ts +20 -0
- package/lib/prerender/index.js +519 -0
- package/lib/prerender/interface/IPrerenderOption.d.ts +15 -0
- package/lib/prerender/interface/IPrerenderOption.js +1 -0
- package/lib/utils/BeforeCompileUtils.d.ts +1 -1
- package/lib/utils/BeforeCompileUtils.js +52 -9
- package/lib/utils/ux/ManifestSchema.js +0 -1
- package/lib/utils/ux/UxFileUtils.js +1 -1
- package/lib/utils/ux/UxLoaderUtils.d.ts +6 -0
- package/lib/utils/ux/UxLoaderUtils.js +22 -10
- package/package.json +9 -6
|
@@ -115,7 +115,12 @@ class UxLoaderUtils {
|
|
|
115
115
|
const parserResult = await new _parser.UxParser(options, compilerOption, globalVar, collectImageResource).parser();
|
|
116
116
|
// 区分app.ux和一般ux
|
|
117
117
|
// app.ux解析结果中加上manifest.json的内容
|
|
118
|
-
const
|
|
118
|
+
const manifestPath = _path.default.join(_path.default.dirname(filePath), 'manifest.json');
|
|
119
|
+
let manifestContent = '{}';
|
|
120
|
+
if (_fsExtra.default.existsSync(manifestPath)) {
|
|
121
|
+
manifestContent = _fsExtra.default.readFileSync(manifestPath, 'utf-8').trim();
|
|
122
|
+
}
|
|
123
|
+
const manifestJson = `JSON.parse('${manifestContent.replace(/'/g, "\\'").replace(/\n/g, '')}')`;
|
|
119
124
|
function translateStyleFunc() {
|
|
120
125
|
return `
|
|
121
126
|
var $translateStyle$ = function (value) {
|
|
@@ -144,26 +149,25 @@ class UxLoaderUtils {
|
|
|
144
149
|
`;
|
|
145
150
|
}
|
|
146
151
|
const integrateFunction = (appImport, appStyleTree, appTemplateTree, appScriptTree) => {
|
|
147
|
-
const services = compilation['services'];
|
|
148
152
|
const scriptCode = appScriptTree.getText();
|
|
149
153
|
const hasScript = Boolean(scriptCode) && scriptCode !== '""';
|
|
150
|
-
const
|
|
151
|
-
|
|
154
|
+
const isService = UxLoaderUtils.isServiceFile(filePath, {
|
|
155
|
+
compilation,
|
|
156
|
+
context,
|
|
157
|
+
compilerOption
|
|
158
|
+
});
|
|
152
159
|
|
|
153
160
|
// script代码放在第三个位置不能变化,影响更新source map
|
|
154
161
|
const createAppWrapper = () => {
|
|
155
|
-
return [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ?
|
|
162
|
+
return [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? appScriptTree.getFullText() : 'export default {};'];
|
|
156
163
|
};
|
|
157
164
|
const createComponentWrapper = () => {
|
|
158
|
-
return [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ?
|
|
159
|
-
};
|
|
160
|
-
const createServiceWrapper = () => {
|
|
161
|
-
return ['', '', `var $app_script$ = ${UxLoaderUtils.wrapScript(isPageUx, appScriptTree)}`, `$app_script$({}, $app_exports$, $app_require$);`, `module.exports = $app_exports$.default;`];
|
|
165
|
+
return [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? appScriptTree.getFullText() : 'export default {};'];
|
|
162
166
|
};
|
|
163
167
|
if (isAppUx) {
|
|
164
168
|
return createAppWrapper();
|
|
165
169
|
} else if (isService) {
|
|
166
|
-
return createServiceWrapper();
|
|
170
|
+
return UxLoaderUtils.createServiceWrapper(appScriptTree);
|
|
167
171
|
} else {
|
|
168
172
|
return createComponentWrapper();
|
|
169
173
|
}
|
|
@@ -392,5 +396,13 @@ class UxLoaderUtils {
|
|
|
392
396
|
static getReturnType(isPageUx) {
|
|
393
397
|
return isPageUx ? `$app_exports$['entry'] =` : 'module.exports = ';
|
|
394
398
|
}
|
|
399
|
+
static createServiceWrapper(appScriptTree) {
|
|
400
|
+
return ['', '', `var $app_script$ = ${UxLoaderUtils.wrapScript(false, appScriptTree)}`, `$app_script$({}, $app_exports$, $app_require$);`, `module.exports = $app_exports$.default;`];
|
|
401
|
+
}
|
|
402
|
+
static isServiceFile(filePath, option) {
|
|
403
|
+
const services = option.compilation['services'];
|
|
404
|
+
const relativeFilePath = _path.default.relative(_path.default.join(option.context.projectPath, option.compilerOption.sourceRoot), filePath).replace(/\\/g, _path.default.posix.sep);
|
|
405
|
+
return services?.some(service => relativeFilePath.startsWith(service.path));
|
|
406
|
+
}
|
|
395
407
|
}
|
|
396
408
|
var _default = exports.default = UxLoaderUtils;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-prender.1",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,14 +19,16 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.0
|
|
23
|
-
"@aiot-toolkit/parser": "2.0
|
|
24
|
-
"@aiot-toolkit/shared-utils": "2.0
|
|
22
|
+
"@aiot-toolkit/generator": "2.1.0-prender.1",
|
|
23
|
+
"@aiot-toolkit/parser": "2.1.0-prender.1",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.1.0-prender.1",
|
|
25
25
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
26
26
|
"@rspack/core": "^1.3.9",
|
|
27
|
+
"acorn": "^8.16.0",
|
|
27
28
|
"aiot-parse5": "^1.0.2",
|
|
29
|
+
"astring": "^1.9.0",
|
|
28
30
|
"babel-loader": "^9.1.3",
|
|
29
|
-
"file-lane": "2.0
|
|
31
|
+
"file-lane": "2.1.0-prender.1",
|
|
30
32
|
"file-loader": "^6.2.0",
|
|
31
33
|
"fs-extra": "^11.2.0",
|
|
32
34
|
"jsrsasign": "^11.1.0",
|
|
@@ -34,6 +36,7 @@
|
|
|
34
36
|
"lodash": "^4.17.21",
|
|
35
37
|
"ts-morph": "^19.0.0",
|
|
36
38
|
"url-loader": "^4.1.1",
|
|
39
|
+
"vite": "^8.0.14",
|
|
37
40
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
38
41
|
"webpack-sources": "^3.2.3"
|
|
39
42
|
},
|
|
@@ -42,5 +45,5 @@
|
|
|
42
45
|
"@types/jsrsasign": "^10.5.12",
|
|
43
46
|
"@types/webpack-sources": "^3.2.3"
|
|
44
47
|
},
|
|
45
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "8bb39a59fbe7a7c22c1167e69d44c78024330cec"
|
|
46
49
|
}
|