@aiot-toolkit/aiotpack 2.0.5-widget-provider-beta.1 → 2.0.5-widget-provider-beta.2
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
|
*/
|
|
@@ -33,6 +37,7 @@ export default interface IManifest {
|
|
|
33
37
|
};
|
|
34
38
|
minAPILevel?: number;
|
|
35
39
|
packageInfo?: Dictionary<string | number>;
|
|
40
|
+
widgetProvider?: IWidgetProvider[];
|
|
36
41
|
icon: string;
|
|
37
42
|
}
|
|
38
43
|
export interface IFeatures {
|
|
@@ -6,6 +6,11 @@ import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavas
|
|
|
6
6
|
declare class JsLoader implements ILoader {
|
|
7
7
|
context: IFileLaneContext;
|
|
8
8
|
compilerOption: IJavascriptCompileOption;
|
|
9
|
+
/**
|
|
10
|
+
* 解析文件内容
|
|
11
|
+
* @param files files 待处理的文件数组
|
|
12
|
+
* @returns 处理后的文件数组
|
|
13
|
+
*/
|
|
9
14
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
10
15
|
}
|
|
11
16
|
export default JsLoader;
|
|
@@ -6,13 +6,27 @@ 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 _path = _interopRequireDefault(require("path"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
/**
|
|
10
12
|
* JsLoader
|
|
11
13
|
*/
|
|
12
14
|
class JsLoader {
|
|
15
|
+
/**
|
|
16
|
+
* 解析文件内容
|
|
17
|
+
* @param files files 待处理的文件数组
|
|
18
|
+
* @returns 处理后的文件数组
|
|
19
|
+
*/
|
|
13
20
|
async parser(files) {
|
|
14
21
|
const onLog = () => {};
|
|
15
22
|
const result = [];
|
|
23
|
+
const {
|
|
24
|
+
projectPath,
|
|
25
|
+
widgetProvider
|
|
26
|
+
} = this.context;
|
|
27
|
+
const {
|
|
28
|
+
sourceRoot
|
|
29
|
+
} = this.compilerOption;
|
|
16
30
|
for (const item of files) {
|
|
17
31
|
if (!item.content) {
|
|
18
32
|
result.push({
|
|
@@ -22,16 +36,28 @@ class JsLoader {
|
|
|
22
36
|
} else {
|
|
23
37
|
const options = {
|
|
24
38
|
filePath: item.path,
|
|
25
|
-
projectPath
|
|
39
|
+
projectPath,
|
|
26
40
|
content: item.content.toString(),
|
|
27
|
-
projectType: _sharedUtils.ProjectType.getProjectType(
|
|
41
|
+
projectType: _sharedUtils.ProjectType.getProjectType(projectPath),
|
|
28
42
|
onLog
|
|
29
43
|
};
|
|
44
|
+
const JSTree = (await new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
|
|
45
|
+
content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
|
|
46
|
+
}, [])).targetTree;
|
|
47
|
+
// 切割script中的转换结果和source map
|
|
48
|
+
const spliteResult = _parser.SourceMapUtil.splitSourceMap(JSTree);
|
|
49
|
+
let JSContent = spliteResult.newScriptTree.getFullText();
|
|
50
|
+
// 若为widgetProvider.js文件,则给内容添加包裹
|
|
51
|
+
if (widgetProvider) {
|
|
52
|
+
const a = _path.default.relative(_path.default.join(projectPath, sourceRoot), item.path).replace(/\\/g, '/');
|
|
53
|
+
const isWidgetProvider = widgetProvider.includes(a);
|
|
54
|
+
if (isWidgetProvider) {
|
|
55
|
+
JSContent += `$app_exports$.default = exports["default"]`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
30
58
|
result.push({
|
|
31
59
|
path: item.path,
|
|
32
|
-
content:
|
|
33
|
-
content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
|
|
34
|
-
}, [])).targetTree.getFullText()
|
|
60
|
+
content: _parser.SourceMapUtil.concatSourceMap(JSContent, spliteResult.scriptSourceMap)
|
|
35
61
|
});
|
|
36
62
|
}
|
|
37
63
|
}
|
|
@@ -41,8 +41,11 @@ class BeforeCompileUtils {
|
|
|
41
41
|
let entryList = [];
|
|
42
42
|
// 存储轻卡路由
|
|
43
43
|
let liteCardList = [];
|
|
44
|
+
// 存储widgetProvider
|
|
45
|
+
let widgetProviderList = [];
|
|
44
46
|
const {
|
|
45
|
-
router
|
|
47
|
+
router,
|
|
48
|
+
widgetProvider
|
|
46
49
|
} = manifestContent;
|
|
47
50
|
if (router) {
|
|
48
51
|
const {
|
|
@@ -85,8 +88,24 @@ class BeforeCompileUtils {
|
|
|
85
88
|
// 没有router配置
|
|
86
89
|
_sharedUtils.ColorConsole.throw(`### manifest ### No router configuration`);
|
|
87
90
|
}
|
|
91
|
+
if (widgetProvider) {
|
|
92
|
+
const EXTENSION_JS = '.js';
|
|
93
|
+
for (const providerItem of widgetProvider) {
|
|
94
|
+
const {
|
|
95
|
+
path
|
|
96
|
+
} = providerItem;
|
|
97
|
+
const itemPath = _path.default.join(srcPath, path + EXTENSION_JS);
|
|
98
|
+
if (_fsExtra.default.existsSync(itemPath)) {
|
|
99
|
+
widgetProviderList.push(path + EXTENSION_JS);
|
|
100
|
+
} else {
|
|
101
|
+
// 报错
|
|
102
|
+
_sharedUtils.ColorConsole.throw(`### manifest ### widgetProvider path '${itemPath}' does not exist`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
88
106
|
context['entries'] = entryList;
|
|
89
107
|
context['liteCards'] = liteCardList;
|
|
108
|
+
context['widgetProvider'] = widgetProviderList;
|
|
90
109
|
return Promise.resolve();
|
|
91
110
|
};
|
|
92
111
|
static clean = async params => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.5-widget-provider-beta.
|
|
3
|
+
"version": "2.0.5-widget-provider-beta.2",
|
|
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.5-widget-provider-beta.
|
|
23
|
-
"@aiot-toolkit/parser": "2.0.5-widget-provider-beta.
|
|
24
|
-
"@aiot-toolkit/shared-utils": "2.0.5-widget-provider-beta.
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.5-widget-provider-beta.2",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.5-widget-provider-beta.2",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.0.5-widget-provider-beta.2",
|
|
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.5-widget-provider-beta.
|
|
29
|
+
"file-lane": "2.0.5-widget-provider-beta.2",
|
|
30
30
|
"file-loader": "^6.2.0",
|
|
31
31
|
"fs-extra": "^11.2.0",
|
|
32
32
|
"hap-toolkit": "^2.0.0",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"@types/jsrsasign": "^10.5.12",
|
|
44
44
|
"@types/webpack-sources": "^3.2.3"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "4a8894bc66a9c78cd835ed6c1af74d054300e064"
|
|
47
47
|
}
|