@aiot-toolkit/aiotpack 2.0.1-alpha.0
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/README.md +46 -0
- package/lib/compiler/c/README.md +1 -0
- package/lib/compiler/c++/README.md +1 -0
- package/lib/compiler/enum/CompileMode.d.ts +22 -0
- package/lib/compiler/enum/CompileMode.js +30 -0
- package/lib/compiler/enum/CompileMode.js.map +1 -0
- package/lib/compiler/interface/ICompileParam.d.ts +24 -0
- package/lib/compiler/interface/ICompileParam.js +4 -0
- package/lib/compiler/interface/ICompileParam.js.map +1 -0
- package/lib/compiler/interface/ICompiler.d.ts +5 -0
- package/lib/compiler/interface/ICompiler.js +4 -0
- package/lib/compiler/interface/ICompiler.js.map +1 -0
- package/lib/compiler/interface/ISignConfig.d.ts +8 -0
- package/lib/compiler/interface/ISignConfig.js +4 -0
- package/lib/compiler/interface/ISignConfig.js.map +1 -0
- package/lib/compiler/javascript/JavascriptCompiler.d.ts +11 -0
- package/lib/compiler/javascript/JavascriptCompiler.js +108 -0
- package/lib/compiler/javascript/JavascriptCompiler.js.map +1 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.d.ts +3 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +21 -0
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js.map +1 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +40 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js +4 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.js.map +1 -0
- package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +40 -0
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js +4 -0
- package/lib/compiler/javascript/interface/IWebpackConfigurator.js.map +1 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +16 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +74 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js.map +1 -0
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.d.ts +25 -0
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js +47 -0
- package/lib/compiler/javascript/vela/enum/BuildNameFormatType.js.map +1 -0
- package/lib/compiler/javascript/vela/enum/EntryType.d.ts +30 -0
- package/lib/compiler/javascript/vela/enum/EntryType.js +35 -0
- package/lib/compiler/javascript/vela/enum/EntryType.js.map +1 -0
- package/lib/compiler/javascript/vela/interface/IChunk.d.ts +29 -0
- package/lib/compiler/javascript/vela/interface/IChunk.js +4 -0
- package/lib/compiler/javascript/vela/interface/IChunk.js.map +1 -0
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +27 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js +4 -0
- package/lib/compiler/javascript/vela/interface/IManifest.js.map +1 -0
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +11 -0
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js +4 -0
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.js.map +1 -0
- package/lib/compiler/javascript/vela/model/Package.d.ts +75 -0
- package/lib/compiler/javascript/vela/model/Package.js +62 -0
- package/lib/compiler/javascript/vela/model/Package.js.map +1 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +7 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +51 -0
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +10 -0
- package/lib/compiler/javascript/vela/utils/Jsc.js +34 -0
- package/lib/compiler/javascript/vela/utils/Jsc.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +29 -0
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +144 -0
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +75 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +278 -0
- package/lib/compiler/javascript/vela/utils/ZipUtil.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +11 -0
- package/lib/compiler/javascript/vela/utils/signature/Base64.js +77 -0
- package/lib/compiler/javascript/vela/utils/signature/Base64.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/CRC32.d.ts +9 -0
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js +45 -0
- package/lib/compiler/javascript/vela/utils/signature/CRC32.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +94 -0
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +713 -0
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +16 -0
- package/lib/compiler/javascript/vela/utils/signature/Signer.js +30 -0
- package/lib/compiler/javascript/vela/utils/signature/Signer.js.map +1 -0
- package/lib/compiler/javascript/vela/utils/signature/pem/certificate.pem +27 -0
- package/lib/compiler/javascript/vela/utils/signature/pem/private.pem +51 -0
- package/lib/config/UxConfig.d.ts +30 -0
- package/lib/config/UxConfig.js +52 -0
- package/lib/config/UxConfig.js.map +1 -0
- package/lib/config/XtsConfig.d.ts +18 -0
- package/lib/config/XtsConfig.js +28 -0
- package/lib/config/XtsConfig.js.map +1 -0
- package/lib/followWorks/xts/entryTemplate.d.ts +21 -0
- package/lib/followWorks/xts/entryTemplate.js +166 -0
- package/lib/followWorks/xts/entryTemplate.js.map +1 -0
- package/lib/followWorks/xts/ts2wasm.d.ts +6 -0
- package/lib/followWorks/xts/ts2wasm.js +31 -0
- package/lib/followWorks/xts/ts2wasm.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/interface/IDeviceList.d.ts +7 -0
- package/lib/interface/IDeviceList.js +4 -0
- package/lib/interface/IDeviceList.js.map +1 -0
- package/lib/loader/ux/AppUxLoader.d.ts +10 -0
- package/lib/loader/ux/AppUxLoader.js +31 -0
- package/lib/loader/ux/AppUxLoader.js.map +1 -0
- package/lib/loader/ux/PngLoader.d.ts +10 -0
- package/lib/loader/ux/PngLoader.js +70 -0
- package/lib/loader/ux/PngLoader.js.map +1 -0
- package/lib/loader/ux/UxLoader.d.ts +6 -0
- package/lib/loader/ux/UxLoader.js +31 -0
- package/lib/loader/ux/UxLoader.js.map +1 -0
- package/lib/loader/xts/XtsLoader.d.ts +9 -0
- package/lib/loader/xts/XtsLoader.js +55 -0
- package/lib/loader/xts/XtsLoader.js.map +1 -0
- package/lib/utils/PngUtils.d.ts +20 -0
- package/lib/utils/PngUtils.js +45 -0
- package/lib/utils/PngUtils.js.map +1 -0
- package/lib/utils/PreWorkUtils.d.ts +17 -0
- package/lib/utils/PreWorkUtils.js +76 -0
- package/lib/utils/PreWorkUtils.js.map +1 -0
- package/lib/utils/ux/UxFileUtils.d.ts +22 -0
- package/lib/utils/ux/UxFileUtils.js +34 -0
- package/lib/utils/ux/UxFileUtils.js.map +1 -0
- package/lib/utils/ux/UxFollowWorks.d.ts +35 -0
- package/lib/utils/ux/UxFollowWorks.js +200 -0
- package/lib/utils/ux/UxFollowWorks.js.map +1 -0
- package/lib/utils/ux/UxLoaderUtils.d.ts +60 -0
- package/lib/utils/ux/UxLoaderUtils.js +241 -0
- package/lib/utils/ux/UxLoaderUtils.js.map +1 -0
- package/lib/utils/xts/XtsFollowWorks.d.ts +29 -0
- package/lib/utils/xts/XtsFollowWorks.js +149 -0
- package/lib/utils/xts/XtsFollowWorks.js.map +1 -0
- package/package.json +44 -0
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.XtsConfig = void 0;
|
|
7
|
+
const XtsConfig_1 = __importDefault(require("./config/XtsConfig"));
|
|
8
|
+
exports.XtsConfig = XtsConfig_1.default;
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,mEAA0C;AACjC,oBADF,mBAAS,CACE","file":"index.js","sourcesContent":["import XtsConfig from './config/XtsConfig'\nexport { XtsConfig }\n"],"sourceRoot":"../src"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["interface/IDeviceList.ts"],"names":[],"mappings":"","file":"IDeviceList.js","sourcesContent":["/**\n * IDeviceList\n */\nexport default interface IDeviceList {\n device: string\n aspectList: string[]\n}\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
+
/**
|
|
3
|
+
* 处理app.ux的Loader
|
|
4
|
+
* AppUxLoader
|
|
5
|
+
*/
|
|
6
|
+
declare class AppUxLoader implements ILoader {
|
|
7
|
+
context: IFileLaneContext;
|
|
8
|
+
parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
|
|
9
|
+
}
|
|
10
|
+
export default AppUxLoader;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
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 UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"));
|
|
16
|
+
/**
|
|
17
|
+
* 处理app.ux的Loader
|
|
18
|
+
* AppUxLoader
|
|
19
|
+
*/
|
|
20
|
+
class AppUxLoader {
|
|
21
|
+
parser(files) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const resultFiles = [];
|
|
24
|
+
yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], resultFiles, this.context);
|
|
25
|
+
return resultFiles;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = AppUxLoader;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=AppUxLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["loader/ux/AppUxLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,iFAAwD;AACxD;;;GAGG;AACH,MAAM,WAAW;IAET,MAAM,CAAC,KAAwB;;YACnC,MAAM,WAAW,GAAiB,EAAE,CAAA;YACpC,MAAM,uBAAa,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;YACjF,OAAO,WAAW,CAAA;QACpB,CAAC;KAAA;CACF;AACD,kBAAe,WAAW,CAAA","file":"AppUxLoader.js","sourcesContent":["import { IFileLaneContext, IFileParam, ILoader } from 'file-lane'\nimport UxLoaderUtils from '../../utils/ux/UxLoaderUtils'\n/**\n * 处理app.ux的Loader\n * AppUxLoader\n */\nclass AppUxLoader implements ILoader {\n context!: IFileLaneContext\n async parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]> {\n const resultFiles: IFileParam[] = []\n await UxLoaderUtils.compileAppUxToJavascript(files[0], resultFiles, this.context)\n return resultFiles\n }\n}\nexport default AppUxLoader\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
+
/**
|
|
3
|
+
* PngLoader
|
|
4
|
+
*/
|
|
5
|
+
declare class PngLoader implements ILoader {
|
|
6
|
+
context: IFileLaneContext;
|
|
7
|
+
parser(files: IFileParam[]): Promise<IFileParam[]>;
|
|
8
|
+
private compile9Png;
|
|
9
|
+
}
|
|
10
|
+
export default PngLoader;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
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 ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
17
|
+
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const PngUtils_1 = __importDefault(require("../../utils/PngUtils"));
|
|
20
|
+
const aaptjs = require('@hap-toolkit/aaptjs');
|
|
21
|
+
/**
|
|
22
|
+
* PngLoader
|
|
23
|
+
*/
|
|
24
|
+
class PngLoader {
|
|
25
|
+
parser(files) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const resultFiles = [];
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
const { path: filePath, content } = file;
|
|
30
|
+
const { name, ext } = path_1.default.parse(filePath);
|
|
31
|
+
const fullName = `${name}${ext}`;
|
|
32
|
+
//判断文本,空文本则结束该文件处理
|
|
33
|
+
if (!content) {
|
|
34
|
+
ColorConsole_1.default.log({
|
|
35
|
+
level: shared_utils_1.LOG_LEVEL.Warn,
|
|
36
|
+
message: `【XtsLoader】the file '${fullName}' under the path '${filePath}' has no content `
|
|
37
|
+
});
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
// 判断传入的.png资源是不是.9.png资源
|
|
41
|
+
if (FileUtil_1.default.match(filePath, /.+\.9\.png$/)) {
|
|
42
|
+
yield this.compile9Png(filePath);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
resultFiles.push(file);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return resultFiles;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
compile9Png(filePath) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
// 判断.9.png是否经过编码处理
|
|
54
|
+
if (!PngUtils_1.default.isEncode9Png(filePath)) {
|
|
55
|
+
// 将.9.png资源使用@hap-toolkit/aaptjs处理
|
|
56
|
+
const outputFile = PngUtils_1.default.convertOutputPath(filePath, this.context);
|
|
57
|
+
try {
|
|
58
|
+
yield aaptjs.singleCrunch(filePath, outputFile);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// 报错
|
|
62
|
+
console.error('.9.png资源文件优化失败', error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.default = PngLoader;
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=PngLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["loader/ux/PngLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6DAAsD;AACtD,+FAAsE;AACtE,6FAAoE;AAEpE,gDAAuB;AACvB,oEAA2C;AAC3C,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;AAE7C;;GAEG;AACH,MAAM,SAAS;IAEP,MAAM,CAAC,KAAmB;;YAC9B,MAAM,WAAW,GAAiB,EAAE,CAAA;YACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;gBACxC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,cAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;gBAC1C,MAAM,QAAQ,GAAG,GAAG,IAAI,GAAG,GAAG,EAAE,CAAA;gBAChC,kBAAkB;gBAClB,IAAI,CAAC,OAAO,EAAE;oBACZ,sBAAY,CAAC,GAAG,CAAC;wBACf,KAAK,EAAE,wBAAS,CAAC,IAAI;wBACrB,OAAO,EAAE,wBAAwB,QAAQ,qBAAqB,QAAQ,mBAAmB;qBAC1F,CAAC,CAAA;oBACF,OAAO,EAAE,CAAA;iBACV;gBACD,yBAAyB;gBACzB,IAAI,kBAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE;oBAC3C,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;iBACjC;qBAAM;oBACL,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;iBACvB;aACF;YACD,OAAO,WAAW,CAAA;QACpB,CAAC;KAAA;IACa,WAAW,CAAC,QAAgB;;YACxC,mBAAmB;YACnB,IAAI,CAAC,kBAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE;gBACpC,mCAAmC;gBACnC,MAAM,UAAU,GAAG,kBAAQ,CAAC,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;gBACrE,IAAI;oBACF,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;iBAChD;gBAAC,OAAO,KAAK,EAAE;oBACd,KAAK;oBACL,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;iBACvC;aACF;QACH,CAAC;KAAA;CACF;AACD,kBAAe,SAAS,CAAA","file":"PngLoader.js","sourcesContent":["import { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport FileUtil from '@aiot-toolkit/shared-utils/lib/utils/FileUtil'\nimport { IFileLaneContext, IFileParam, ILoader } from 'file-lane'\nimport Path from 'path'\nimport PngUtils from '../../utils/PngUtils'\nconst aaptjs = require('@hap-toolkit/aaptjs')\n\n/**\n * PngLoader\n */\nclass PngLoader implements ILoader {\n context!: IFileLaneContext\n async parser(files: IFileParam[]): Promise<IFileParam[]> {\n const resultFiles: IFileParam[] = []\n for (const file of files) {\n const { path: filePath, content } = file\n const { name, ext } = Path.parse(filePath)\n const fullName = `${name}${ext}`\n //判断文本,空文本则结束该文件处理\n if (!content) {\n ColorConsole.log({\n level: LOG_LEVEL.Warn,\n message: `【XtsLoader】the file '${fullName}' under the path '${filePath}' has no content `\n })\n return []\n }\n // 判断传入的.png资源是不是.9.png资源\n if (FileUtil.match(filePath, /.+\\.9\\.png$/)) {\n await this.compile9Png(filePath)\n } else {\n resultFiles.push(file)\n }\n }\n return resultFiles\n }\n private async compile9Png(filePath: string) {\n // 判断.9.png是否经过编码处理\n if (!PngUtils.isEncode9Png(filePath)) {\n // 将.9.png资源使用@hap-toolkit/aaptjs处理\n const outputFile = PngUtils.convertOutputPath(filePath, this.context)\n try {\n await aaptjs.singleCrunch(filePath, outputFile)\n } catch (error) {\n // 报错\n console.error('.9.png资源文件优化失败', error)\n }\n }\n }\n}\nexport default PngLoader\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
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 UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"));
|
|
16
|
+
class UxLoader {
|
|
17
|
+
parser(files) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const resultFiles = [];
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
// 转换每个文件
|
|
22
|
+
const compileFiles = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false);
|
|
23
|
+
resultFiles.push(...compileFiles);
|
|
24
|
+
}
|
|
25
|
+
return resultFiles;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = UxLoader;
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=UxLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["loader/ux/UxLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,iFAAwD;AAExD,MAAM,QAAQ;IAEN,MAAM,CAAC,KAAwB;;YACnC,MAAM,WAAW,GAAiB,EAAE,CAAA;YACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,SAAS;gBACT,MAAM,YAAY,GAAG,MAAM,uBAAa,CAAC,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;gBAEzF,WAAW,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAA;aAClC;YACD,OAAO,WAAW,CAAA;QACpB,CAAC;KAAA;CACF;AACD,kBAAe,QAAQ,CAAA","file":"UxLoader.js","sourcesContent":["import { IFileLaneContext, IFileParam, ILoader } from 'file-lane'\nimport UxLoaderUtils from '../../utils/ux/UxLoaderUtils'\n\nclass UxLoader implements ILoader {\n context!: IFileLaneContext\n async parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]> {\n const resultFiles: IFileParam[] = []\n for (const file of files) {\n // 转换每个文件\n const compileFiles = await UxLoaderUtils.compileUxToJavascript(file, this.context, false)\n\n resultFiles.push(...compileFiles)\n }\n return resultFiles\n }\n}\nexport default UxLoader\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const generator_1 = require("@aiot-toolkit/generator");
|
|
7
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
8
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
9
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
10
|
+
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const ts_morph_1 = require("ts-morph");
|
|
13
|
+
/**
|
|
14
|
+
* XtsLoader
|
|
15
|
+
*/
|
|
16
|
+
class XtsLoader {
|
|
17
|
+
parser(files) {
|
|
18
|
+
const project = new ts_morph_1.Project();
|
|
19
|
+
const resultFiles = [];
|
|
20
|
+
for (const file in files) {
|
|
21
|
+
const { path, content } = files[file];
|
|
22
|
+
const { name, ext } = path_1.default.parse(path);
|
|
23
|
+
const fullName = `${name}${ext}`;
|
|
24
|
+
const newFileName = `${name}.ts`;
|
|
25
|
+
//判断文本,空文本则结束该文件处理
|
|
26
|
+
if (!content) {
|
|
27
|
+
ColorConsole_1.default.log({
|
|
28
|
+
level: shared_utils_1.LOG_LEVEL.Warn,
|
|
29
|
+
message: `【XtsLoader】the file '${fullName}' under the path '${path}' has no content `
|
|
30
|
+
});
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const parserResult = new parser_1.XtsParser(project, ColorConsole_1.default.log).parser(content, fullName);
|
|
34
|
+
const { ast, mapList } = new parser_1.XtsToTypescript(project, ColorConsole_1.default.log, this.context, path).translate(parserResult.ast, parserResult.offsetList);
|
|
35
|
+
const { code, sourcemap } = new generator_1.TypescriptGenerator().generate({
|
|
36
|
+
sourceFilePath: fullName,
|
|
37
|
+
targetFilePath: newFileName,
|
|
38
|
+
ast,
|
|
39
|
+
mapList
|
|
40
|
+
});
|
|
41
|
+
resultFiles.push({
|
|
42
|
+
path: FileUtil_1.default.updatePath(path, newFileName),
|
|
43
|
+
content: code
|
|
44
|
+
}, {
|
|
45
|
+
path: FileUtil_1.default.updatePath(path, `${name}.map.ts`),
|
|
46
|
+
content: sourcemap
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
// 返回内容
|
|
50
|
+
return resultFiles;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.default = XtsLoader;
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=XtsLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["loader/xts/XtsLoader.ts"],"names":[],"mappings":";;;;;AAAA,uDAA6D;AAC7D,iDAAiE;AACjE,6DAAsD;AACtD,+FAAsE;AACtE,6FAAoE;AAEpE,gDAAuB;AACvB,uCAAkC;AAClC;;GAEG;AACH,MAAM,SAAS;IAEb,MAAM,CAAC,KAAmB;QACxB,MAAM,OAAO,GAAG,IAAI,kBAAO,EAAE,CAAA;QAC7B,MAAM,WAAW,GAAiB,EAAE,CAAA;QACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;YACrC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YACtC,MAAM,QAAQ,GAAG,GAAG,IAAI,GAAG,GAAG,EAAE,CAAA;YAChC,MAAM,WAAW,GAAG,GAAG,IAAI,KAAK,CAAA;YAChC,kBAAkB;YAClB,IAAI,CAAC,OAAO,EAAE;gBACZ,sBAAY,CAAC,GAAG,CAAC;oBACf,KAAK,EAAE,wBAAS,CAAC,IAAI;oBACrB,OAAO,EAAE,wBAAwB,QAAQ,qBAAqB,IAAI,mBAAmB;iBACtF,CAAC,CAAA;gBACF,OAAO,EAAE,CAAA;aACV;YACD,MAAM,YAAY,GAAG,IAAI,kBAAS,CAAC,OAAO,EAAE,sBAAY,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;YACvF,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,wBAAe,CAC1C,OAAO,EACP,sBAAY,CAAC,GAAG,EAChB,IAAI,CAAC,OAAO,EACZ,IAAI,CACL,CAAC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,UAAU,CAAC,CAAA;YACtD,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,+BAAmB,EAAE,CAAC,QAAQ,CAAC;gBAC7D,cAAc,EAAE,QAAQ;gBACxB,cAAc,EAAE,WAAW;gBAC3B,GAAG;gBACH,OAAO;aACR,CAAC,CAAA;YACF,WAAW,CAAC,IAAI,CACd;gBACE,IAAI,EAAE,kBAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC;gBAC5C,OAAO,EAAE,IAAI;aACd,EACD;gBACE,IAAI,EAAE,kBAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,IAAI,SAAS,CAAC;gBACjD,OAAO,EAAE,SAAS;aACnB,CACF,CAAA;SACF;QACD,OAAO;QACP,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AACD,kBAAe,SAAS,CAAA","file":"XtsLoader.js","sourcesContent":["import { TypescriptGenerator } from '@aiot-toolkit/generator'\nimport { XtsParser, XtsToTypescript } from '@aiot-toolkit/parser'\nimport { LOG_LEVEL } from '@aiot-toolkit/shared-utils'\nimport ColorConsole from '@aiot-toolkit/shared-utils/lib/ColorConsole'\nimport FileUtil from '@aiot-toolkit/shared-utils/lib/utils/FileUtil'\nimport { IFileLaneContext, IFileParam, ILoader } from 'file-lane'\nimport Path from 'path'\nimport { Project } from 'ts-morph'\n/**\n * XtsLoader\n */\nclass XtsLoader implements ILoader {\n context!: IFileLaneContext\n parser(files: IFileParam[]): IFileParam[] {\n const project = new Project()\n const resultFiles: IFileParam[] = []\n for (const file in files) {\n const { path, content } = files[file]\n const { name, ext } = Path.parse(path)\n const fullName = `${name}${ext}`\n const newFileName = `${name}.ts`\n //判断文本,空文本则结束该文件处理\n if (!content) {\n ColorConsole.log({\n level: LOG_LEVEL.Warn,\n message: `【XtsLoader】the file '${fullName}' under the path '${path}' has no content `\n })\n return []\n }\n const parserResult = new XtsParser(project, ColorConsole.log).parser(content, fullName)\n const { ast, mapList } = new XtsToTypescript(\n project,\n ColorConsole.log,\n this.context,\n path\n ).translate(parserResult.ast, parserResult.offsetList)\n const { code, sourcemap } = new TypescriptGenerator().generate({\n sourceFilePath: fullName,\n targetFilePath: newFileName,\n ast,\n mapList\n })\n resultFiles.push(\n {\n path: FileUtil.updatePath(path, newFileName),\n content: code\n },\n {\n path: FileUtil.updatePath(path, `${name}.map.ts`),\n content: sourcemap\n }\n )\n }\n // 返回内容\n return resultFiles\n }\n}\nexport default XtsLoader\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IFileLaneContext } from 'file-lane';
|
|
2
|
+
/**
|
|
3
|
+
* PngUtils
|
|
4
|
+
*/
|
|
5
|
+
declare class PngUtils {
|
|
6
|
+
/**
|
|
7
|
+
* 检测.9.png是否编码
|
|
8
|
+
* @param filePath
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
static isEncode9Png(filePath: string): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 计算文件转换后的目标路径
|
|
14
|
+
* @param filePath
|
|
15
|
+
* @param context
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
static convertOutputPath(filePath: string, context: IFileLaneContext): string;
|
|
19
|
+
}
|
|
20
|
+
export default PngUtils;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
/**
|
|
9
|
+
* PngUtils
|
|
10
|
+
*/
|
|
11
|
+
class PngUtils {
|
|
12
|
+
/**
|
|
13
|
+
* 检测.9.png是否编码
|
|
14
|
+
* @param filePath
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
static isEncode9Png(filePath) {
|
|
18
|
+
const buff = fs_extra_1.default.readFileSync(filePath);
|
|
19
|
+
const start = 37;
|
|
20
|
+
const end = 41;
|
|
21
|
+
const encode = buff.subarray(start, end).toString() === 'npTc' ||
|
|
22
|
+
buff.subarray(start, end).toString() === 'npOl';
|
|
23
|
+
return encode;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 计算文件转换后的目标路径
|
|
27
|
+
* @param filePath
|
|
28
|
+
* @param context
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
static convertOutputPath(filePath, context) {
|
|
32
|
+
const { projectPath, output } = context;
|
|
33
|
+
const fileRelativePath = path_1.default.relative(projectPath, filePath);
|
|
34
|
+
const outputPath = path_1.default.join(projectPath, output, fileRelativePath);
|
|
35
|
+
const outputDir = path_1.default.dirname(outputPath);
|
|
36
|
+
// 判断输出文件夹是否存在,不存在则循环创建
|
|
37
|
+
if (!fs_extra_1.default.existsSync(outputDir)) {
|
|
38
|
+
fs_extra_1.default.mkdirSync(outputDir, { recursive: true });
|
|
39
|
+
}
|
|
40
|
+
return outputPath;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = PngUtils;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=PngUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["utils/PngUtils.ts"],"names":[],"mappings":";;;;;AACA,wDAAyB;AACzB,gDAAuB;AACvB;;GAEG;AACH,MAAM,QAAQ;IACZ;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,QAAgB;QAClC,MAAM,IAAI,GAAG,kBAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;QACtC,MAAM,KAAK,GAAG,EAAE,CAAA;QAChB,MAAM,GAAG,GAAG,EAAE,CAAA;QACd,MAAM,MAAM,GACV,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,MAAM;YAC/C,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,MAAM,CAAA;QACjD,OAAO,MAAM,CAAA;IACf,CAAC;IACD;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,QAAgB,EAAE,OAAyB;QAClE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;QACvC,MAAM,gBAAgB,GAAG,cAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;QAC7D,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,CAAC,CAAA;QAEnE,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;QAC1C,uBAAuB;QACvB,IAAI,CAAC,kBAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAC7B,kBAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;SAC7C;QACD,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AACD,kBAAe,QAAQ,CAAA","file":"PngUtils.js","sourcesContent":["import { IFileLaneContext } from 'file-lane'\nimport Fs from 'fs-extra'\nimport Path from 'path'\n/**\n * PngUtils\n */\nclass PngUtils {\n /**\n * 检测.9.png是否编码\n * @param filePath\n * @returns\n */\n static isEncode9Png(filePath: string): boolean {\n const buff = Fs.readFileSync(filePath)\n const start = 37\n const end = 41\n const encode =\n buff.subarray(start, end).toString() === 'npTc' ||\n buff.subarray(start, end).toString() === 'npOl'\n return encode\n }\n /**\n * 计算文件转换后的目标路径\n * @param filePath\n * @param context\n * @returns\n */\n static convertOutputPath(filePath: string, context: IFileLaneContext) {\n const { projectPath, output } = context\n const fileRelativePath = Path.relative(projectPath, filePath)\n const outputPath = Path.join(projectPath, output, fileRelativePath)\n\n const outputDir = Path.dirname(outputPath)\n // 判断输出文件夹是否存在,不存在则循环创建\n if (!Fs.existsSync(outputDir)) {\n Fs.mkdirSync(outputDir, { recursive: true })\n }\n return outputPath\n }\n}\nexport default PngUtils\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IFileLaneContext } from 'file-lane';
|
|
2
|
+
import { PreWork } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
3
|
+
import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
|
|
4
|
+
/**
|
|
5
|
+
* PreWorkUtils
|
|
6
|
+
*/
|
|
7
|
+
declare class PreWorkUtils {
|
|
8
|
+
/**
|
|
9
|
+
* 获取ux项目的路由入口
|
|
10
|
+
* @param context
|
|
11
|
+
* @param fileList
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
static getEntries(context: IFileLaneContext): Promise<void>;
|
|
15
|
+
static clean: PreWork<IJavascriptCompileOption>;
|
|
16
|
+
}
|
|
17
|
+
export default PreWorkUtils;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
var _a;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
const del_1 = __importDefault(require("del"));
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const UxFileUtils_1 = __importDefault(require("./ux/UxFileUtils"));
|
|
20
|
+
/**
|
|
21
|
+
* PreWorkUtils
|
|
22
|
+
*/
|
|
23
|
+
class PreWorkUtils {
|
|
24
|
+
/**
|
|
25
|
+
* 获取ux项目的路由入口
|
|
26
|
+
* @param context
|
|
27
|
+
* @param fileList
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
static getEntries(context) {
|
|
31
|
+
const { projectPath } = context;
|
|
32
|
+
const srcPath = path_1.default.join(projectPath, 'src');
|
|
33
|
+
// 判断路径是否真实存在
|
|
34
|
+
const manifestContent = UxFileUtils_1.default.getMainfestInfo(projectPath);
|
|
35
|
+
// 存储entries
|
|
36
|
+
let entryList = [];
|
|
37
|
+
if (manifestContent) {
|
|
38
|
+
const { router } = manifestContent;
|
|
39
|
+
if (!router) {
|
|
40
|
+
// 报错,没有router配置
|
|
41
|
+
}
|
|
42
|
+
const { pages } = router;
|
|
43
|
+
if (!pages) {
|
|
44
|
+
// 报错,没有pages配置
|
|
45
|
+
}
|
|
46
|
+
Object.keys(pages).map((page) => {
|
|
47
|
+
const pageContent = pages[page];
|
|
48
|
+
const entryDir = path_1.default.join(srcPath, page);
|
|
49
|
+
const entryPage = path_1.default.join(entryDir, `${pageContent.component}.ux`);
|
|
50
|
+
if (fs_extra_1.default.existsSync(entryPage)) {
|
|
51
|
+
entryList.push(entryPage);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// 报错,路径不存在
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
context['entries'] = entryList;
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// 报错 manifest.json文件无有效内容
|
|
62
|
+
return Promise.reject();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_a = PreWorkUtils;
|
|
67
|
+
PreWorkUtils.clean = (context, _, config, compileOption) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
(0, del_1.default)(path_1.default.join(context.projectPath, context.output));
|
|
69
|
+
if (compileOption) {
|
|
70
|
+
(0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.outputPath));
|
|
71
|
+
(0, del_1.default)(path_1.default.join(compileOption.projectPath, compileOption.releasePath));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
exports.default = PreWorkUtils;
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=PreWorkUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["utils/PreWorkUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,8CAAqB;AAGrB,wDAAyB;AACzB,gDAAuB;AAEvB,mEAA0C;AAE1C;;GAEG;AACH,MAAM,YAAY;IAChB;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,OAAyB;QACzC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAA;QAC/B,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QAC7C,aAAa;QACb,MAAM,eAAe,GAAG,qBAAW,CAAC,eAAe,CAAC,WAAW,CAAC,CAAA;QAChE,YAAY;QACZ,IAAI,SAAS,GAAa,EAAE,CAAA;QAC5B,IAAI,eAAe,EAAE;YACnB,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAA;YAClC,IAAI,CAAC,MAAM,EAAE;gBACX,gBAAgB;aACjB;YACD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;YACxB,IAAI,CAAC,KAAK,EAAE;gBACV,eAAe;aAChB;YACD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC9B,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;gBAC/B,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;gBACzC,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,WAAW,CAAC,SAAS,KAAK,CAAC,CAAA;gBACpE,IAAI,kBAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;oBAC5B,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;iBAC1B;qBAAM;oBACL,WAAW;iBACZ;YACH,CAAC,CAAC,CAAA;YACF,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAA;YAC9B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;SACzB;aAAM;YACL,0BAA0B;YAC1B,OAAO,OAAO,CAAC,MAAM,EAAE,CAAA;SACxB;IACH,CAAC;;;AAEM,kBAAK,GAAsC,CAAO,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE;IAC5F,IAAA,aAAG,EAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACnD,IAAI,aAAa,EAAE;QACjB,IAAA,aAAG,EAAC,cAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,CAAA;QACnE,IAAA,aAAG,EAAC,cAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAA;KACrE;AACH,CAAC,CANW,AAMX,CAAA;AAEH,kBAAe,YAAY,CAAA","file":"PreWorkUtils.js","sourcesContent":["import del from 'del'\nimport { IFileLaneContext } from 'file-lane'\nimport { PreWork } from 'file-lane/lib/interface/IFileLaneConfig'\nimport Fs from 'fs-extra'\nimport Path from 'path'\nimport IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption'\nimport UxFileUtils from './ux/UxFileUtils'\n\n/**\n * PreWorkUtils\n */\nclass PreWorkUtils {\n /**\n * 获取ux项目的路由入口\n * @param context\n * @param fileList\n * @returns\n */\n static getEntries(context: IFileLaneContext) {\n const { projectPath } = context\n const srcPath = Path.join(projectPath, 'src')\n // 判断路径是否真实存在\n const manifestContent = UxFileUtils.getMainfestInfo(projectPath)\n // 存储entries\n let entryList: string[] = []\n if (manifestContent) {\n const { router } = manifestContent\n if (!router) {\n // 报错,没有router配置\n }\n const { pages } = router\n if (!pages) {\n // 报错,没有pages配置\n }\n Object.keys(pages).map((page) => {\n const pageContent = pages[page]\n const entryDir = Path.join(srcPath, page)\n const entryPage = Path.join(entryDir, `${pageContent.component}.ux`)\n if (Fs.existsSync(entryPage)) {\n entryList.push(entryPage)\n } else {\n // 报错,路径不存在\n }\n })\n context['entries'] = entryList\n return Promise.resolve()\n } else {\n // 报错 manifest.json文件无有效内容\n return Promise.reject()\n }\n }\n\n static clean: PreWork<IJavascriptCompileOption> = async (context, _, config, compileOption) => {\n del(Path.join(context.projectPath, context.output))\n if (compileOption) {\n del(Path.join(compileOption.projectPath, compileOption.outputPath))\n del(Path.join(compileOption.projectPath, compileOption.releasePath))\n }\n }\n}\nexport default PreWorkUtils\n"],"sourceRoot":"../../src"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import IManifest from '../../compiler/javascript/vela/interface/IManifest';
|
|
2
|
+
/**
|
|
3
|
+
* FileUtils
|
|
4
|
+
*/
|
|
5
|
+
declare class UxFileUtils {
|
|
6
|
+
static readonly CONFIG_FILE_NAME = "manifest.json";
|
|
7
|
+
/**
|
|
8
|
+
* 获取manifest.json路径
|
|
9
|
+
* @param projectPath
|
|
10
|
+
* @param sourceRoot
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
static getManifestFilePath(projectPath: string, sourceRoot?: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 获取manifest.json内容
|
|
16
|
+
* @param projectPath
|
|
17
|
+
* @param sourceRoot
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
20
|
+
static getMainfestInfo(projectPath: string, sourceRoot?: string): IManifest;
|
|
21
|
+
}
|
|
22
|
+
export default UxFileUtils;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
/**
|
|
9
|
+
* FileUtils
|
|
10
|
+
*/
|
|
11
|
+
class UxFileUtils {
|
|
12
|
+
/**
|
|
13
|
+
* 获取manifest.json路径
|
|
14
|
+
* @param projectPath
|
|
15
|
+
* @param sourceRoot
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
static getManifestFilePath(projectPath, sourceRoot = 'src') {
|
|
19
|
+
return path_1.default.resolve(projectPath, sourceRoot, UxFileUtils.CONFIG_FILE_NAME);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 获取manifest.json内容
|
|
23
|
+
* @param projectPath
|
|
24
|
+
* @param sourceRoot
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
static getMainfestInfo(projectPath, sourceRoot = 'src') {
|
|
28
|
+
return fs_extra_1.default.readJSONSync(UxFileUtils.getManifestFilePath(projectPath, sourceRoot));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
UxFileUtils.CONFIG_FILE_NAME = 'manifest.json';
|
|
32
|
+
exports.default = UxFileUtils;
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=UxFileUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["utils/ux/UxFileUtils.ts"],"names":[],"mappings":";;;;;AAAA,wDAAyB;AACzB,gDAAuB;AAEvB;;GAEG;AACH,MAAM,WAAW;IAEf;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAmB,EAAE,aAAqB,KAAK;QACxE,OAAO,cAAI,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAA;IAC5E,CAAC;IACD;;;;;OAKG;IACH,MAAM,CAAC,eAAe,CAAC,WAAmB,EAAE,aAAqB,KAAK;QACpE,OAAO,kBAAE,CAAC,YAAY,CAAC,WAAW,CAAC,mBAAmB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAA;IAClF,CAAC;;AAlBe,4BAAgB,GAAG,eAAe,CAAA;AAoBpD,kBAAe,WAAW,CAAA","file":"UxFileUtils.js","sourcesContent":["import Fs from 'fs-extra'\nimport Path from 'path'\nimport IManifest from '../../compiler/javascript/vela/interface/IManifest'\n/**\n * FileUtils\n */\nclass UxFileUtils {\n static readonly CONFIG_FILE_NAME = 'manifest.json'\n /**\n * 获取manifest.json路径\n * @param projectPath\n * @param sourceRoot\n * @returns\n */\n static getManifestFilePath(projectPath: string, sourceRoot: string = 'src') {\n return Path.resolve(projectPath, sourceRoot, UxFileUtils.CONFIG_FILE_NAME)\n }\n /**\n * 获取manifest.json内容\n * @param projectPath\n * @param sourceRoot\n * @returns\n */\n static getMainfestInfo(projectPath: string, sourceRoot: string = 'src'): IManifest {\n return Fs.readJSONSync(UxFileUtils.getManifestFilePath(projectPath, sourceRoot))\n }\n}\nexport default UxFileUtils\n"],"sourceRoot":"../../../src"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FollowWork } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
2
|
+
import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
+
/**
|
|
4
|
+
* UxFollowWorks
|
|
5
|
+
*/
|
|
6
|
+
declare class UxFollowWorks {
|
|
7
|
+
static webpack: FollowWork<IJavascriptCompileOption>;
|
|
8
|
+
static jsc: FollowWork<IJavascriptCompileOption>;
|
|
9
|
+
static toRpk: FollowWork<IJavascriptCompileOption>;
|
|
10
|
+
/**
|
|
11
|
+
* 复制各类资源文件,例如图片、视频等
|
|
12
|
+
* @param context
|
|
13
|
+
* @param config
|
|
14
|
+
* @param compilerOption
|
|
15
|
+
*/
|
|
16
|
+
static copyResource: FollowWork<IJavascriptCompileOption>;
|
|
17
|
+
/**
|
|
18
|
+
* 打包结果移回源码项目,并删除中间项目
|
|
19
|
+
*
|
|
20
|
+
* 1. 把 build和rpk 目录从**中间项目**移回**源码项目**
|
|
21
|
+
* 2. 删除中间项目
|
|
22
|
+
* @param context
|
|
23
|
+
* @param config
|
|
24
|
+
* @param compilerOption
|
|
25
|
+
*/
|
|
26
|
+
static moveBackResult: FollowWork<IJavascriptCompileOption>;
|
|
27
|
+
/**
|
|
28
|
+
* 创建 node_module 软链
|
|
29
|
+
* @param context
|
|
30
|
+
* @param config
|
|
31
|
+
* @param compilerOption
|
|
32
|
+
*/
|
|
33
|
+
static symlinkNodeModule: FollowWork<IJavascriptCompileOption>;
|
|
34
|
+
}
|
|
35
|
+
export default UxFollowWorks;
|