@aiot-toolkit/aiotpack 2.0.6-beta.7 → 2.0.6-beta.8
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.
|
@@ -31,6 +31,7 @@ export default interface IManifest {
|
|
|
31
31
|
component?: string;
|
|
32
32
|
}>;
|
|
33
33
|
};
|
|
34
|
+
services: IService[] | Record<string, IService>;
|
|
34
35
|
minAPILevel?: number;
|
|
35
36
|
packageInfo?: Dictionary<string | number>;
|
|
36
37
|
icon: string;
|
|
@@ -38,4 +39,9 @@ export default interface IManifest {
|
|
|
38
39
|
export interface IFeatures {
|
|
39
40
|
name: string;
|
|
40
41
|
}
|
|
42
|
+
export interface IService {
|
|
43
|
+
name: string;
|
|
44
|
+
autoStart?: boolean;
|
|
45
|
+
path: string;
|
|
46
|
+
}
|
|
41
47
|
export {};
|
|
@@ -40,8 +40,12 @@ class BeforeCompileUtils {
|
|
|
40
40
|
let entryList = [];
|
|
41
41
|
// 存储轻卡路由
|
|
42
42
|
let liteCardList = [];
|
|
43
|
+
|
|
44
|
+
// services 路由
|
|
45
|
+
let serviceList = [];
|
|
43
46
|
const {
|
|
44
|
-
router
|
|
47
|
+
router,
|
|
48
|
+
services
|
|
45
49
|
} = manifestContent;
|
|
46
50
|
if (router) {
|
|
47
51
|
const {
|
|
@@ -84,9 +88,13 @@ class BeforeCompileUtils {
|
|
|
84
88
|
// 没有router配置
|
|
85
89
|
_sharedUtils.ColorConsole.throw(`### manifest ### No router configuration`);
|
|
86
90
|
}
|
|
91
|
+
if (services) {
|
|
92
|
+
serviceList = Array.isArray(services) ? services : Object.values(services);
|
|
93
|
+
}
|
|
87
94
|
if (compilation) {
|
|
88
95
|
compilation['entries'] = entryList;
|
|
89
96
|
compilation['liteCards'] = liteCardList;
|
|
97
|
+
compilation['services'] = serviceList;
|
|
90
98
|
}
|
|
91
99
|
return Promise.resolve();
|
|
92
100
|
};
|
|
@@ -144,10 +144,29 @@ class UxLoaderUtils {
|
|
|
144
144
|
`;
|
|
145
145
|
}
|
|
146
146
|
const integrateFunction = (appImport, appStyleTree, appTemplateTree, appScriptTree) => {
|
|
147
|
+
const services = compilation['services'];
|
|
147
148
|
const scriptCode = appScriptTree.getText();
|
|
148
149
|
const hasScript = Boolean(scriptCode) && scriptCode !== '""';
|
|
150
|
+
const relativeFilePath = _path.default.relative(_path.default.join(context.projectPath, compilerOption.sourceRoot), filePath).replace(/\\/g, _path.default.posix.sep);
|
|
151
|
+
const isService = services?.some(service => relativeFilePath.startsWith(service.path));
|
|
152
|
+
|
|
149
153
|
// script代码放在第三个位置不能变化,影响更新source map
|
|
150
|
-
|
|
154
|
+
const createAppWrapper = () => {
|
|
155
|
+
return [`${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}`, translateStyleFunc()];
|
|
156
|
+
};
|
|
157
|
+
const createComponentWrapper = () => {
|
|
158
|
+
return [`${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$;`, `}`];
|
|
159
|
+
};
|
|
160
|
+
const createServiceWrapper = () => {
|
|
161
|
+
return ['', '', `var $app_script$ = ${UxLoaderUtils.wrapScript(isPageUx, appScriptTree)}`, `$app_script$({}, $app_exports$, $app_require$);`, `module.exports = $app_exports$.default;`];
|
|
162
|
+
};
|
|
163
|
+
if (isAppUx) {
|
|
164
|
+
return createAppWrapper();
|
|
165
|
+
} else if (isService) {
|
|
166
|
+
return createServiceWrapper();
|
|
167
|
+
} else {
|
|
168
|
+
return createComponentWrapper();
|
|
169
|
+
}
|
|
151
170
|
};
|
|
152
171
|
const {
|
|
153
172
|
targetTree,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.8",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.0.6-beta.
|
|
23
|
-
"@aiot-toolkit/parser": "2.0.6-beta.
|
|
24
|
-
"@aiot-toolkit/shared-utils": "2.0.6-beta.
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.6-beta.8",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.6-beta.8",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.6-beta.8",
|
|
25
25
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
26
26
|
"@rspack/core": "^1.3.9",
|
|
27
27
|
"aiot-parse5": "^1.0.2",
|
|
28
28
|
"babel-loader": "^9.1.3",
|
|
29
|
-
"file-lane": "2.0.6-beta.
|
|
29
|
+
"file-lane": "2.0.6-beta.8",
|
|
30
30
|
"file-loader": "^6.2.0",
|
|
31
31
|
"fs-extra": "^11.2.0",
|
|
32
32
|
"jsrsasign": "^11.1.0",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@types/jsrsasign": "^10.5.12",
|
|
43
43
|
"@types/webpack-sources": "^3.2.3"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "b9380b1c748324938f84da01d035345116f8d0ba"
|
|
46
46
|
}
|