@aiot-toolkit/aiotpack 2.0.3-beta.10 → 2.0.3-beta.12
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IStyleNode } from '@aiot-toolkit/parser';
|
|
1
2
|
import { ILog } from '@aiot-toolkit/shared-utils';
|
|
2
3
|
import { IFileLaneContext, IFileParam } from 'file-lane';
|
|
3
4
|
import { SourceFile } from 'ts-morph';
|
|
@@ -54,7 +55,7 @@ declare class UxLoaderUtils {
|
|
|
54
55
|
* @returns
|
|
55
56
|
*/
|
|
56
57
|
static wrapTempalte(templateTree: SourceFile, file: IFileParam, compilerOption: IJavascriptCompileOption): string;
|
|
57
|
-
static wrapStyle(
|
|
58
|
+
static wrapStyle(styleNodes: IStyleNode[], file: IFileParam, compilerOption: IJavascriptCompileOption): string;
|
|
58
59
|
/**
|
|
59
60
|
* 给script增加外层包裹内容
|
|
60
61
|
* @param isPageUx
|
|
@@ -114,8 +114,10 @@ class UxLoaderUtils {
|
|
|
114
114
|
// app.ux解析结果中加上manifest.json的内容
|
|
115
115
|
const manifestJson = `require('./manifest.json')`;
|
|
116
116
|
const integrateFunction = (appImport, appStyleTree, appTemplateTree, appScriptTree) => {
|
|
117
|
+
const scriptCode = appScriptTree.getText();
|
|
118
|
+
const hasScript = Boolean(scriptCode) && scriptCode !== '""';
|
|
117
119
|
// script代码放在第三个位置不能变化,影响更新source map
|
|
118
|
-
return isAppUx ? [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(
|
|
120
|
+
return isAppUx ? [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(false, appScriptTree)}` : '', hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.style = $app_style$;`, `$app_exports$.default.manifest = ${manifestJson}`] : [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(isPageUx, appScriptTree)}` : '', `var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree, file, compilerOption)}`, `${UxLoaderUtils.getReturnType(isPageUx)} function ($app_exports$) {`, hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.template = $app_template$;`, `$app_exports$.default.style = $app_style$;`, `}`];
|
|
119
121
|
};
|
|
120
122
|
const {
|
|
121
123
|
targetTree,
|
|
@@ -302,10 +304,13 @@ class UxLoaderUtils {
|
|
|
302
304
|
}
|
|
303
305
|
return result;
|
|
304
306
|
}
|
|
305
|
-
static wrapStyle(
|
|
307
|
+
static wrapStyle(styleNodes, file, compilerOption) {
|
|
308
|
+
const code = JSON.stringify(styleNodes);
|
|
306
309
|
if (compilerOption.enableProtobuf) {
|
|
307
|
-
|
|
308
|
-
|
|
310
|
+
if (styleNodes?.length) {
|
|
311
|
+
const result = BinaryPlugin.addStyle(file.path, file.path, code);
|
|
312
|
+
return `['${result.name}', ${result.index}]`;
|
|
313
|
+
}
|
|
309
314
|
}
|
|
310
315
|
return code;
|
|
311
316
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.3-beta.
|
|
3
|
+
"version": "2.0.3-beta.12",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.0.3-beta.
|
|
23
|
-
"@aiot-toolkit/parser": "2.0.3-beta.
|
|
24
|
-
"@aiot-toolkit/shared-utils": "2.0.3-beta.
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.3-beta.12",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.3-beta.12",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.3-beta.12",
|
|
25
25
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
26
26
|
"@rspack/core": "^1.0.0",
|
|
27
27
|
"aiot-parse5": "^1.0.0",
|
|
28
28
|
"archiver": "^7.0.1",
|
|
29
29
|
"babel-loader": "^9.1.3",
|
|
30
30
|
"fast-glob": "^3.3.2",
|
|
31
|
-
"file-lane": "2.0.3-beta.
|
|
31
|
+
"file-lane": "2.0.3-beta.12",
|
|
32
32
|
"file-loader": "^6.2.0",
|
|
33
33
|
"fs-extra": "^11.2.0",
|
|
34
34
|
"jsrsasign": "^11.1.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@types/jsrsasign": "^10.5.12",
|
|
46
46
|
"@types/webpack-sources": "^3.2.3"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a20d364161209141515de30555c800e7a4eff733"
|
|
49
49
|
}
|