@aiot-toolkit/aiotpack 2.0.6-beta.23 → 2.0.6-beta.25
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.
|
@@ -8,6 +8,10 @@ interface IWidget {
|
|
|
8
8
|
sizes: string[];
|
|
9
9
|
type?: string;
|
|
10
10
|
}
|
|
11
|
+
interface IWidgetProvider {
|
|
12
|
+
name: string;
|
|
13
|
+
path: string;
|
|
14
|
+
}
|
|
11
15
|
/**
|
|
12
16
|
* vela manifest文件对应的数据结构
|
|
13
17
|
*/
|
|
@@ -36,16 +40,13 @@ export default interface IManifest {
|
|
|
36
40
|
services: IService[] | Record<string, IService>;
|
|
37
41
|
minAPILevel?: number;
|
|
38
42
|
packageInfo?: Dictionary<string | number>;
|
|
43
|
+
widgetProvider?: IWidgetProvider[];
|
|
39
44
|
icon: string;
|
|
40
45
|
workers?: {
|
|
41
46
|
entries: {
|
|
42
47
|
file: string;
|
|
43
48
|
}[];
|
|
44
49
|
};
|
|
45
|
-
widgetProvider?: {
|
|
46
|
-
name: string;
|
|
47
|
-
path: string;
|
|
48
|
-
}[];
|
|
49
50
|
}
|
|
50
51
|
export interface IFeatures {
|
|
51
52
|
name: string;
|
|
@@ -10,6 +10,11 @@ declare class JsLoader implements ILoader {
|
|
|
10
10
|
compilerOption: IJavascriptCompileOption;
|
|
11
11
|
compilation: FileLaneCompilation;
|
|
12
12
|
logs: ILog[];
|
|
13
|
+
/**
|
|
14
|
+
* 解析文件内容
|
|
15
|
+
* @param files files 待处理的文件数组
|
|
16
|
+
* @returns 处理后的文件数组
|
|
17
|
+
*/
|
|
13
18
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
14
19
|
}
|
|
15
20
|
export default JsLoader;
|
|
@@ -7,14 +7,27 @@ exports.default = void 0;
|
|
|
7
7
|
var _parser = require("@aiot-toolkit/parser");
|
|
8
8
|
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
9
9
|
var _UxLoaderUtils = _interopRequireDefault(require("../../utils/ux/UxLoaderUtils"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
/**
|
|
12
13
|
* JsLoader
|
|
13
14
|
*/
|
|
14
15
|
class JsLoader {
|
|
15
16
|
logs = [];
|
|
17
|
+
/**
|
|
18
|
+
* 解析文件内容
|
|
19
|
+
* @param files files 待处理的文件数组
|
|
20
|
+
* @returns 处理后的文件数组
|
|
21
|
+
*/
|
|
16
22
|
async parser(files) {
|
|
17
23
|
const result = [];
|
|
24
|
+
const {
|
|
25
|
+
projectPath,
|
|
26
|
+
widgetProvider
|
|
27
|
+
} = this.context;
|
|
28
|
+
const {
|
|
29
|
+
sourceRoot
|
|
30
|
+
} = this.compilerOption;
|
|
18
31
|
for (const item of files) {
|
|
19
32
|
if (!item.content) {
|
|
20
33
|
result.push({
|
|
@@ -24,7 +37,7 @@ class JsLoader {
|
|
|
24
37
|
} else {
|
|
25
38
|
const options = {
|
|
26
39
|
filePath: item.path,
|
|
27
|
-
projectPath
|
|
40
|
+
projectPath,
|
|
28
41
|
content: item.content.toString(),
|
|
29
42
|
projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
|
|
30
43
|
onLog: log => {
|
|
@@ -39,11 +52,26 @@ class JsLoader {
|
|
|
39
52
|
compilerOption: this.compilerOption,
|
|
40
53
|
context: this.context
|
|
41
54
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
if (isService) {
|
|
56
|
+
result.push({
|
|
57
|
+
path: item.path,
|
|
58
|
+
content: _UxLoaderUtils.default.createServiceWrapper(scriptTree.targetTree).filter(Boolean).join('\n')
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
const isWidgetProvider = widgetProvider?.includes(_path.default.relative(_path.default.join(projectPath, sourceRoot), item.path).replace(/\\/g, '/'));
|
|
62
|
+
let content = scriptTree.targetTree.getFullText();
|
|
63
|
+
if (isWidgetProvider) {
|
|
64
|
+
const {
|
|
65
|
+
newScriptTree,
|
|
66
|
+
scriptSourceMap
|
|
67
|
+
} = _parser.SourceMapUtil.splitSourceMap(scriptTree.targetTree);
|
|
68
|
+
content = _parser.SourceMapUtil.concatSourceMap(`${newScriptTree.getFullText()}\n$app_exports$.default = exports["default"]\n`, scriptSourceMap);
|
|
69
|
+
}
|
|
70
|
+
result.push({
|
|
71
|
+
path: item.path,
|
|
72
|
+
content: content
|
|
73
|
+
});
|
|
74
|
+
}
|
|
47
75
|
}
|
|
48
76
|
}
|
|
49
77
|
return result;
|
|
@@ -29,7 +29,8 @@ class BeforeCompileUtils {
|
|
|
29
29
|
const {
|
|
30
30
|
context,
|
|
31
31
|
compilerOption,
|
|
32
|
-
compilation
|
|
32
|
+
compilation,
|
|
33
|
+
onLog
|
|
33
34
|
} = params;
|
|
34
35
|
const {
|
|
35
36
|
projectPath
|
|
@@ -46,8 +47,11 @@ class BeforeCompileUtils {
|
|
|
46
47
|
let serviceList = [];
|
|
47
48
|
const {
|
|
48
49
|
router,
|
|
49
|
-
services
|
|
50
|
+
services,
|
|
51
|
+
widgetProvider
|
|
50
52
|
} = manifestContent;
|
|
53
|
+
// 存储widgetProvider
|
|
54
|
+
let widgetProviderList = [];
|
|
51
55
|
if (router) {
|
|
52
56
|
const {
|
|
53
57
|
pages,
|
|
@@ -63,7 +67,12 @@ class BeforeCompileUtils {
|
|
|
63
67
|
entryList.push(_path.default.join(entryDir, entry));
|
|
64
68
|
} else {
|
|
65
69
|
// 路径不存在
|
|
66
|
-
|
|
70
|
+
onLog?.([{
|
|
71
|
+
level: _sharedUtils.Loglevel.THROW,
|
|
72
|
+
message: ['### manifest ### path', {
|
|
73
|
+
word: _path.default.join(entryDir, entryPages.join(' | '))
|
|
74
|
+
}, 'does not exist']
|
|
75
|
+
}]);
|
|
67
76
|
}
|
|
68
77
|
});
|
|
69
78
|
}
|
|
@@ -76,15 +85,22 @@ class BeforeCompileUtils {
|
|
|
76
85
|
if (_fsExtra.default.existsSync(cardPath)) {
|
|
77
86
|
liteCardList.push(card + _path.default.posix.sep + cardContent.component);
|
|
78
87
|
} else {
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
onLog?.([{
|
|
89
|
+
level: _sharedUtils.Loglevel.THROW,
|
|
90
|
+
message: [`### manifest ### lite card path`, {
|
|
91
|
+
word: cardPath
|
|
92
|
+
}, `does not exist`]
|
|
93
|
+
}]);
|
|
81
94
|
}
|
|
82
95
|
}
|
|
83
96
|
});
|
|
84
97
|
}
|
|
85
98
|
} else {
|
|
86
99
|
// 没有router配置
|
|
87
|
-
|
|
100
|
+
onLog?.([{
|
|
101
|
+
level: _sharedUtils.Loglevel.THROW,
|
|
102
|
+
message: ['### manifest ### No router configuration']
|
|
103
|
+
}]);
|
|
88
104
|
}
|
|
89
105
|
|
|
90
106
|
// e2e测试入口
|
|
@@ -98,10 +114,30 @@ class BeforeCompileUtils {
|
|
|
98
114
|
if (services) {
|
|
99
115
|
serviceList = Array.isArray(services) ? services : Object.values(services);
|
|
100
116
|
}
|
|
117
|
+
if (widgetProvider) {
|
|
118
|
+
const EXTENSION_JS = '.js';
|
|
119
|
+
for (const providerItem of widgetProvider) {
|
|
120
|
+
const {
|
|
121
|
+
path
|
|
122
|
+
} = providerItem;
|
|
123
|
+
const itemPath = _path.default.join(srcPath, path + EXTENSION_JS);
|
|
124
|
+
if (_fsExtra.default.existsSync(itemPath)) {
|
|
125
|
+
widgetProviderList.push(path + EXTENSION_JS);
|
|
126
|
+
} else {
|
|
127
|
+
onLog?.([{
|
|
128
|
+
level: _sharedUtils.Loglevel.THROW,
|
|
129
|
+
message: ['### manifest ### widgetProvider path', {
|
|
130
|
+
word: itemPath
|
|
131
|
+
}, 'does not exist']
|
|
132
|
+
}]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
101
136
|
if (compilation) {
|
|
102
137
|
compilation['entries'] = entryList;
|
|
103
138
|
compilation['liteCards'] = liteCardList;
|
|
104
139
|
compilation['services'] = serviceList;
|
|
140
|
+
context['widgetProvider'] = widgetProviderList;
|
|
105
141
|
}
|
|
106
142
|
return Promise.resolve();
|
|
107
143
|
};
|
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.25",
|
|
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.25",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.6-beta.25",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.6-beta.25",
|
|
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.25",
|
|
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": "25b954200dd056d25c2c9fa2c2ccd04f261d57af"
|
|
46
46
|
}
|