@aiot-toolkit/aiotpack 2.0.2 → 2.0.3-beta.10
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/afterCompile/ux/UxAfterCompile.d.ts +1 -1
- package/lib/afterCompile/ux/UxAfterCompile.js +295 -243
- package/lib/afterCompile/xts/entryTemplate.js +111 -113
- package/lib/afterCompile/xts/generateRpk.js +25 -54
- package/lib/afterCompile/xts/ts2wasm.js +62 -63
- package/lib/afterWorks/ux/UxAfterWorks.js +12 -19
- package/lib/beforeCompile/ux/UxBeforeCompile.js +26 -28
- package/lib/beforeCompile/xts/preInstall.js +50 -55
- package/lib/beforeWorks/ux/UxBeforeWorks.js +12 -19
- package/lib/compiler/enum/CompileMode.js +16 -23
- package/lib/compiler/interface/ICompileParam.js +1 -2
- package/lib/compiler/interface/ICompiler.js +1 -2
- package/lib/compiler/interface/ISignConfig.js +1 -2
- package/lib/compiler/javascript/JavascriptCompiler.js +147 -154
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +20 -16
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +13 -11
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +53 -49
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +1 -2
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -1
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +78 -75
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +30 -41
- package/lib/compiler/javascript/vela/enum/EntryType.js +15 -29
- package/lib/compiler/javascript/vela/interface/IChunk.js +4 -1
- package/lib/compiler/javascript/vela/interface/IManifest.js +1 -2
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +1 -2
- package/lib/compiler/javascript/vela/model/Package.js +80 -51
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +31 -27
- package/lib/compiler/javascript/vela/utils/Jsc.js +30 -33
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +152 -130
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +10 -2
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +282 -267
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +65 -67
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +37 -35
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +755 -731
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +24 -22
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +47 -52
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.js +21 -17
- package/lib/config/UxConfig.js +145 -173
- package/lib/config/XtsConfig.d.ts +2 -0
- package/lib/config/XtsConfig.js +30 -39
- package/lib/index.js +88 -41
- package/lib/interface/ICompileOptions.js +5 -2
- package/lib/interface/IDeviceList.js +1 -2
- package/lib/loader/ux/JsLoader.js +32 -30
- package/lib/loader/ux/PngLoader.js +47 -53
- package/lib/loader/ux/android/UxLoader.d.ts +2 -0
- package/lib/loader/ux/android/UxLoader.js +30 -32
- package/lib/loader/ux/vela/AppUxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/AppUxLoader.js +23 -25
- package/lib/loader/ux/vela/HmlLoader.js +59 -55
- package/lib/loader/ux/vela/UxLoader.d.ts +2 -0
- package/lib/loader/ux/vela/UxLoader.js +29 -37
- package/lib/loader/xts/XtsLoader.js +55 -41
- package/lib/utils/BeforeCompileUtils.js +100 -95
- package/lib/utils/PngUtils.js +42 -36
- package/lib/utils/ux/ManifestSchema.js +198 -194
- package/lib/utils/ux/UxFileUtils.d.ts +3 -3
- package/lib/utils/ux/UxFileUtils.js +130 -125
- package/lib/utils/ux/UxLoaderUtils.js +292 -307
- package/lib/utils/ux/android/AndroidUx.js +88 -90
- package/lib/utils/xts/XtsFileLaneUtils.js +58 -65
- package/lib/utils/xts/XtsFollowWorks.js +122 -129
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -1,42 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
exports
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Object.defineProperty(exports, "
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CompileMode", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _CompileMode.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "IJavascriptCompileOption", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _IJavascriptCompileOption.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "IManifest", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _IManifest.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "IQuickAppConfig", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _IQuickAppConfig.default;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "ISkipList", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _ICompileOptions.ISkipList;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "IXtsCompileOptions", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _ICompileOptions.IXtsCompileOptions;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "JavascriptDefaultCompileOption", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _JavascriptDefaultCompileOption.default;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "UxConfig", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () {
|
|
51
|
+
return _UxConfig.default;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "UxFileUtils", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _UxFileUtils.default;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "XtsConfig", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () {
|
|
63
|
+
return _XtsConfig.default;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "setServerPort", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () {
|
|
69
|
+
return _JavascriptDefaultCompileOption.setServerPort;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "skipList", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _ICompileOptions.skipList;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
var _XtsConfig = _interopRequireDefault(require("./config/XtsConfig"));
|
|
79
|
+
var _JavascriptDefaultCompileOption = _interopRequireWildcard(require("./compiler/javascript/JavascriptDefaultCompileOption"));
|
|
80
|
+
var _UxConfig = _interopRequireDefault(require("./config/UxConfig"));
|
|
81
|
+
var _CompileMode = _interopRequireDefault(require("./compiler/enum/CompileMode"));
|
|
82
|
+
var _IJavascriptCompileOption = _interopRequireDefault(require("./compiler/javascript/interface/IJavascriptCompileOption"));
|
|
83
|
+
var _IQuickAppConfig = _interopRequireDefault(require("./compiler/javascript/vela/interface/IQuickAppConfig"));
|
|
84
|
+
var _UxFileUtils = _interopRequireDefault(require("./utils/ux/UxFileUtils"));
|
|
85
|
+
var _IManifest = _interopRequireDefault(require("./compiler/javascript/vela/interface/IManifest"));
|
|
86
|
+
var _ICompileOptions = require("./interface/ICompileOptions");
|
|
87
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
88
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
89
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.skipList = void 0;
|
|
4
|
-
exports.skipList = ['xts2ts', 'install', 'ts2wasm', 'package'];
|
|
7
|
+
const skipList = exports.skipList = ['xts2ts', 'install', 'ts2wasm', 'package'];
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _parser = require("@aiot-toolkit/parser");
|
|
8
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
5
9
|
/**
|
|
6
10
|
* JsLoader
|
|
7
11
|
*/
|
|
8
12
|
class JsLoader {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
}
|
|
13
|
+
parser(files) {
|
|
14
|
+
const onLog = () => {};
|
|
15
|
+
return files.map(item => {
|
|
16
|
+
if (!item.content) {
|
|
17
|
+
return {
|
|
18
|
+
path: item.path,
|
|
19
|
+
content: item.content
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const options = {
|
|
23
|
+
filePath: item.path,
|
|
24
|
+
projectPath: this.context.projectPath,
|
|
25
|
+
content: item.content.toString(),
|
|
26
|
+
projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
|
|
27
|
+
onLog
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
path: item.path,
|
|
31
|
+
content: new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
|
|
32
|
+
content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
|
|
33
|
+
}, []).targetTree.getFullText()
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
|
-
exports.default = JsLoader;
|
|
38
|
+
var _default = exports.default = JsLoader;
|
|
@@ -1,64 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const PngUtils_1 = __importDefault(require("../../utils/PngUtils"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _sharedUtils = require("@aiot-toolkit/shared-utils");
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _PngUtils = _interopRequireDefault(require("../../utils/PngUtils"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
11
|
const aaptjs = require('@hap-toolkit/aaptjs');
|
|
12
|
+
|
|
19
13
|
/**
|
|
20
14
|
* PngLoader
|
|
21
15
|
*/
|
|
22
16
|
class PngLoader {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
17
|
+
async parser(files) {
|
|
18
|
+
const resultFiles = [];
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const {
|
|
21
|
+
path: filePath,
|
|
22
|
+
content
|
|
23
|
+
} = file;
|
|
24
|
+
const {
|
|
25
|
+
name,
|
|
26
|
+
ext
|
|
27
|
+
} = _path.default.parse(filePath);
|
|
28
|
+
const fullName = `${name}${ext}`;
|
|
29
|
+
//判断文本,空文本则结束该文件处理
|
|
30
|
+
if (!content) {
|
|
31
|
+
_sharedUtils.ColorConsole.warn(`The file '${fullName}' under the path '${filePath}' has no content `);
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
// 判断传入的.png资源是不是.9.png资源
|
|
35
|
+
if (_sharedUtils.FileUtil.match(filePath, /.+\.9\.png$/)) {
|
|
36
|
+
await this.compile9Png(filePath);
|
|
37
|
+
} else {
|
|
38
|
+
resultFiles.push(file);
|
|
39
|
+
}
|
|
45
40
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
});
|
|
41
|
+
return resultFiles;
|
|
42
|
+
}
|
|
43
|
+
async compile9Png(filePath) {
|
|
44
|
+
// 判断.9.png是否经过编码处理
|
|
45
|
+
if (!_PngUtils.default.isEncode9Png(filePath)) {
|
|
46
|
+
// 将.9.png资源使用@hap-toolkit/aaptjs处理
|
|
47
|
+
const outputFile = _PngUtils.default.convertOutputPath(filePath, this.context);
|
|
48
|
+
try {
|
|
49
|
+
await aaptjs.singleCrunch(filePath, outputFile);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
_sharedUtils.ColorConsole.throw(`.9.png resource file processing failed`);
|
|
52
|
+
}
|
|
60
53
|
}
|
|
54
|
+
}
|
|
61
55
|
}
|
|
62
56
|
;
|
|
63
57
|
PngLoader.raw = true;
|
|
64
|
-
exports.default = PngLoader;
|
|
58
|
+
var _default = exports.default = PngLoader;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILog } from '@aiot-toolkit/shared-utils';
|
|
1
2
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
3
|
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
4
|
/**
|
|
@@ -6,6 +7,7 @@ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJa
|
|
|
6
7
|
declare class UxLoader implements ILoader {
|
|
7
8
|
context: IFileLaneContext;
|
|
8
9
|
compilerOption: IJavascriptCompileOption;
|
|
10
|
+
logs?: ILog[] | undefined;
|
|
9
11
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
10
12
|
}
|
|
11
13
|
export default UxLoader;
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const AndroidUx_1 = __importDefault(require("../../../utils/ux/android/AndroidUx"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _AndroidUx = _interopRequireDefault(require("../../../utils/ux/android/AndroidUx"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
10
|
/**
|
|
19
11
|
* UxLoader
|
|
20
12
|
*/
|
|
21
13
|
class UxLoader {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
14
|
+
async parser(files) {
|
|
15
|
+
const result = [];
|
|
16
|
+
const {
|
|
17
|
+
projectPath
|
|
18
|
+
} = this.context;
|
|
19
|
+
for (let item of files) {
|
|
20
|
+
const {
|
|
21
|
+
files,
|
|
22
|
+
logs
|
|
23
|
+
} = await new _AndroidUx.default().compileUx({
|
|
24
|
+
context: this.context,
|
|
25
|
+
file: item,
|
|
26
|
+
compilerOption: this.compilerOption
|
|
27
|
+
});
|
|
28
|
+
this.logs = logs.map(item => ({
|
|
29
|
+
...item,
|
|
30
|
+
filePath: item.filePath ? _path.default.relative(projectPath, item.filePath) : ''
|
|
31
|
+
}));
|
|
32
|
+
result.push(...files);
|
|
37
33
|
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
38
36
|
}
|
|
39
|
-
exports.default = UxLoader;
|
|
37
|
+
var _default = exports.default = UxLoader;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ILog } from '@aiot-toolkit/shared-utils';
|
|
1
2
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
3
|
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
4
|
/**
|
|
@@ -7,6 +8,7 @@ import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJa
|
|
|
7
8
|
declare class AppUxLoader implements ILoader {
|
|
8
9
|
context: IFileLaneContext;
|
|
9
10
|
compilerOption: IJavascriptCompileOption;
|
|
11
|
+
logs?: ILog[] | undefined;
|
|
10
12
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
11
13
|
}
|
|
12
14
|
export default AppUxLoader;
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const UxLoaderUtils_1 = __importDefault(require("../../../utils/ux/UxLoaderUtils"));
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _UxLoaderUtils = _interopRequireDefault(require("../../../utils/ux/UxLoaderUtils"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
10
|
/**
|
|
19
11
|
* 处理app.ux的Loader
|
|
20
12
|
* AppUxLoader
|
|
21
13
|
*/
|
|
22
14
|
class AppUxLoader {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
15
|
+
async parser(files) {
|
|
16
|
+
const {
|
|
17
|
+
projectPath
|
|
18
|
+
} = this.context;
|
|
19
|
+
const {
|
|
20
|
+
files: resultFiles,
|
|
21
|
+
logs
|
|
22
|
+
} = await _UxLoaderUtils.default.compileAppUxToJavascript(files[0], this.context, this.compilerOption);
|
|
23
|
+
this.logs = logs.map(item => ({
|
|
24
|
+
...item,
|
|
25
|
+
filePath: item.filePath ? _path.default.relative(projectPath, item.filePath) : ''
|
|
26
|
+
}));
|
|
27
|
+
return resultFiles;
|
|
28
|
+
}
|
|
31
29
|
}
|
|
32
|
-
exports.default = AppUxLoader;
|
|
30
|
+
var _default = exports.default = AppUxLoader;
|
|
@@ -1,63 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
var _parser = require("@aiot-toolkit/parser");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
/**
|
|
10
12
|
* HmlLoader
|
|
11
13
|
*/
|
|
12
14
|
class HmlLoader {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
parser(files) {
|
|
16
|
+
return files.map(file => {
|
|
17
|
+
return this.wrapHml(file);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 包裹 hml 文件
|
|
23
|
+
*
|
|
24
|
+
* # 路径
|
|
25
|
+
* 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
|
|
26
|
+
*
|
|
27
|
+
* # 内容
|
|
28
|
+
* 1. 给hml的内容加上<template></template>
|
|
29
|
+
* 2. 如果存在同路径同名的 script文件,则加到<script></script>中
|
|
30
|
+
* 3. 如果存在同路径同名的 style文件,则加到<style></style>中
|
|
31
|
+
*
|
|
32
|
+
* @param file
|
|
33
|
+
*/
|
|
34
|
+
wrapHml(file) {
|
|
35
|
+
const {
|
|
36
|
+
path,
|
|
37
|
+
content
|
|
38
|
+
} = file;
|
|
39
|
+
const uxExt = _parser.ExtensionConfig.UX;
|
|
40
|
+
const getFilePath = ext => {
|
|
41
|
+
const pathParsed = _path.default.parse(path);
|
|
42
|
+
pathParsed.ext = ext;
|
|
43
|
+
pathParsed.base = pathParsed.name + ext;
|
|
44
|
+
return _path.default.format(pathParsed);
|
|
45
|
+
};
|
|
46
|
+
const uxPath = getFilePath(uxExt);
|
|
47
|
+
if (_fs.default.existsSync(uxPath)) {
|
|
48
|
+
throw new Error(`${uxPath} already exists`);
|
|
17
49
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* 1. 给hml的内容加上<template></template>
|
|
26
|
-
* 2. 如果存在同路径同名的 script文件,则加到<script></script>中
|
|
27
|
-
* 3. 如果存在同路径同名的 style文件,则加到<style></style>中
|
|
28
|
-
*
|
|
29
|
-
* @param file
|
|
30
|
-
*/
|
|
31
|
-
wrapHml(file) {
|
|
32
|
-
const { path, content } = file;
|
|
33
|
-
const uxExt = parser_1.ExtensionConfig.UX;
|
|
34
|
-
const getFilePath = (ext) => {
|
|
35
|
-
const pathParsed = path_1.default.parse(path);
|
|
36
|
-
pathParsed.ext = ext;
|
|
37
|
-
pathParsed.base = pathParsed.name + ext;
|
|
38
|
-
return path_1.default.format(pathParsed);
|
|
39
|
-
};
|
|
40
|
-
const uxPath = getFilePath(uxExt);
|
|
41
|
-
if (fs_1.default.existsSync(uxPath)) {
|
|
42
|
-
throw new Error(`${uxPath} already exists`);
|
|
43
|
-
}
|
|
44
|
-
const scriptExts = parser_1.ExtensionConfig.SCRIPTS;
|
|
45
|
-
const styleExts = parser_1.ExtensionConfig.STYLES;
|
|
46
|
-
const scriptPath = scriptExts
|
|
47
|
-
.map((item) => getFilePath(item))
|
|
48
|
-
.find((item) => fs_1.default.existsSync(item));
|
|
49
|
-
const stylePath = styleExts.map((item) => getFilePath(item)).find((item) => fs_1.default.existsSync(item));
|
|
50
|
-
let uxContent = ['<template>', content, '</template>'].join('\n');
|
|
51
|
-
if (scriptPath) {
|
|
52
|
-
uxContent += ['<script>', fs_1.default.readFileSync(scriptPath, 'utf-8'), '</script>'].join('\n');
|
|
53
|
-
}
|
|
54
|
-
if (stylePath) {
|
|
55
|
-
uxContent += ['<style>', fs_1.default.readFileSync(stylePath, 'utf-8'), '</style>'].join('\n');
|
|
56
|
-
}
|
|
57
|
-
return {
|
|
58
|
-
path,
|
|
59
|
-
content: uxContent
|
|
60
|
-
};
|
|
50
|
+
const scriptExts = _parser.ExtensionConfig.SCRIPTS;
|
|
51
|
+
const styleExts = _parser.ExtensionConfig.STYLES;
|
|
52
|
+
const scriptPath = scriptExts.map(item => getFilePath(item)).find(item => _fs.default.existsSync(item));
|
|
53
|
+
const stylePath = styleExts.map(item => getFilePath(item)).find(item => _fs.default.existsSync(item));
|
|
54
|
+
let uxContent = ['<template>', content, '</template>'].join('\n');
|
|
55
|
+
if (scriptPath) {
|
|
56
|
+
uxContent += ['<script>', _fs.default.readFileSync(scriptPath, 'utf-8'), '</script>'].join('\n');
|
|
61
57
|
}
|
|
58
|
+
if (stylePath) {
|
|
59
|
+
uxContent += ['<style>', _fs.default.readFileSync(stylePath, 'utf-8'), '</style>'].join('\n');
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
path,
|
|
63
|
+
content: uxContent
|
|
64
|
+
};
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
|
-
exports.default = HmlLoader;
|
|
67
|
+
var _default = exports.default = HmlLoader;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
+
import { ILog } from '@aiot-toolkit/shared-utils/lib/interface/ILog';
|
|
3
4
|
declare class UxLoader implements ILoader {
|
|
4
5
|
context: IFileLaneContext;
|
|
5
6
|
compilerOption: IJavascriptCompileOption;
|
|
7
|
+
logs?: ILog[] | undefined;
|
|
6
8
|
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
7
9
|
}
|
|
8
10
|
export default UxLoader;
|