@aiot-toolkit/aiotpack 2.0.6-beta.7 → 2.0.6-beta.9
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/javascript/vela/interface/IManifest.d.ts +6 -0
- package/lib/loader/ux/JsLoader.d.ts +2 -0
- package/lib/loader/ux/JsLoader.js +12 -3
- package/lib/utils/BeforeCompileUtils.js +9 -1
- package/lib/utils/ux/UxLoaderUtils.d.ts +6 -0
- package/lib/utils/ux/UxLoaderUtils.js +27 -1
- package/package.json +6 -6
|
@@ -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 {};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
+
import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
|
|
3
4
|
/**
|
|
4
5
|
* JsLoader
|
|
5
6
|
*/
|
|
6
7
|
declare class JsLoader implements ILoader {
|
|
7
8
|
context: IFileLaneContext;
|
|
8
9
|
compilerOption: IJavascriptCompileOption;
|
|
10
|
+
compilation: FileLaneCompilation;
|
|
9
11
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
10
12
|
}
|
|
11
13
|
export default JsLoader;
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _parser = require("@aiot-toolkit/parser");
|
|
8
8
|
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
9
|
+
var _UxLoaderUtils = _interopRequireDefault(require("../../utils/ux/UxLoaderUtils"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
/**
|
|
10
12
|
* JsLoader
|
|
11
13
|
*/
|
|
@@ -27,11 +29,18 @@ class JsLoader {
|
|
|
27
29
|
projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
|
|
28
30
|
onLog
|
|
29
31
|
};
|
|
32
|
+
const scriptTree = await new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
|
|
33
|
+
content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
|
|
34
|
+
}, []);
|
|
35
|
+
const isService = _UxLoaderUtils.default.isServiceFile(item.path, {
|
|
36
|
+
compilation: this.compilation,
|
|
37
|
+
compilerOption: this.compilerOption,
|
|
38
|
+
context: this.context
|
|
39
|
+
});
|
|
40
|
+
const content = isService ? _UxLoaderUtils.default.createServiceWrapper(scriptTree.targetTree).filter(Boolean).join('\n') : scriptTree.targetTree.getFullText();
|
|
30
41
|
result.push({
|
|
31
42
|
path: item.path,
|
|
32
|
-
content
|
|
33
|
-
content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
|
|
34
|
-
}, [])).targetTree.getFullText()
|
|
43
|
+
content
|
|
35
44
|
});
|
|
36
45
|
}
|
|
37
46
|
}
|
|
@@ -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
|
};
|
|
@@ -65,5 +65,11 @@ declare class UxLoaderUtils {
|
|
|
65
65
|
*/
|
|
66
66
|
static wrapScript(isPageUx: boolean, appScriptTree: SourceFile): string;
|
|
67
67
|
static getReturnType(isPageUx: boolean): "$app_exports$['entry'] =" | "module.exports = ";
|
|
68
|
+
static createServiceWrapper(appScriptTree: SourceFile): string[];
|
|
69
|
+
static isServiceFile(filePath: string, option: {
|
|
70
|
+
compilation: FileLaneCompilation;
|
|
71
|
+
context: IFileLaneContext;
|
|
72
|
+
compilerOption: IJavascriptCompileOption;
|
|
73
|
+
}): boolean;
|
|
68
74
|
}
|
|
69
75
|
export default UxLoaderUtils;
|
|
@@ -146,8 +146,26 @@ class UxLoaderUtils {
|
|
|
146
146
|
const integrateFunction = (appImport, appStyleTree, appTemplateTree, appScriptTree) => {
|
|
147
147
|
const scriptCode = appScriptTree.getText();
|
|
148
148
|
const hasScript = Boolean(scriptCode) && scriptCode !== '""';
|
|
149
|
+
const isService = UxLoaderUtils.isServiceFile(filePath, {
|
|
150
|
+
compilation,
|
|
151
|
+
context,
|
|
152
|
+
compilerOption
|
|
153
|
+
});
|
|
154
|
+
|
|
149
155
|
// script代码放在第三个位置不能变化,影响更新source map
|
|
150
|
-
|
|
156
|
+
const createAppWrapper = () => {
|
|
157
|
+
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()];
|
|
158
|
+
};
|
|
159
|
+
const createComponentWrapper = () => {
|
|
160
|
+
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$;`, `}`];
|
|
161
|
+
};
|
|
162
|
+
if (isAppUx) {
|
|
163
|
+
return createAppWrapper();
|
|
164
|
+
} else if (isService) {
|
|
165
|
+
return UxLoaderUtils.createServiceWrapper(appScriptTree);
|
|
166
|
+
} else {
|
|
167
|
+
return createComponentWrapper();
|
|
168
|
+
}
|
|
151
169
|
};
|
|
152
170
|
const {
|
|
153
171
|
targetTree,
|
|
@@ -373,5 +391,13 @@ class UxLoaderUtils {
|
|
|
373
391
|
static getReturnType(isPageUx) {
|
|
374
392
|
return isPageUx ? `$app_exports$['entry'] =` : 'module.exports = ';
|
|
375
393
|
}
|
|
394
|
+
static createServiceWrapper(appScriptTree) {
|
|
395
|
+
return ['', '', `var $app_script$ = ${UxLoaderUtils.wrapScript(false, appScriptTree)}`, `$app_script$({}, $app_exports$, $app_require$);`, `module.exports = $app_exports$.default;`];
|
|
396
|
+
}
|
|
397
|
+
static isServiceFile(filePath, option) {
|
|
398
|
+
const services = option.compilation['services'];
|
|
399
|
+
const relativeFilePath = _path.default.relative(_path.default.join(option.context.projectPath, option.compilerOption.sourceRoot), filePath).replace(/\\/g, _path.default.posix.sep);
|
|
400
|
+
return services?.some(service => relativeFilePath.startsWith(service.path));
|
|
401
|
+
}
|
|
376
402
|
}
|
|
377
403
|
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.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.9",
|
|
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.9",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.6-beta.9",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.6-beta.9",
|
|
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.9",
|
|
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": "18718f09f1ee7f1d7361022c5fb7858c87cee2bd"
|
|
46
46
|
}
|